diff options
| author | Paul Eggert | 2019-04-21 21:16:03 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-04-21 21:16:26 -0700 |
| commit | e85bff0bbb60e1d819f8f5e00f8496026f27f7ea (patch) | |
| tree | dbfe6998ce8235bb5dde9e6576fe88db6f65a3a0 /src | |
| parent | 4a5ed6b05a71593cda33af4da44f30eb84b51f30 (diff) | |
| download | emacs-e85bff0bbb60e1d819f8f5e00f8496026f27f7ea.tar.gz emacs-e85bff0bbb60e1d819f8f5e00f8496026f27f7ea.zip | |
Fix drain_reloc_list alignment bug
* src/pdumper.c (dump_charset): Use alignof (struct charset),
not alignof (int), since struct charset might be more strictly
aligned than int. I think this is just a minor performance
issue, but we might as well use the correct alignment.
(drain_reloc_list): Use an alignment instead of a size for the
output alignment. This prevents undefined behavior when
alignof (struct emacs_reloc) == 8 and sizeof (dump_off) == 4
when building on x86-64 with gcc -fsanitize=undefined.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pdumper.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pdumper.c b/src/pdumper.c index 6ab82769ec9..39931c6807f 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -3167,7 +3167,7 @@ dump_charset (struct dump_context *ctx, int cs_i) | |||
| 3167 | #if CHECK_STRUCTS && !defined (HASH_charset_317C49E291) | 3167 | #if CHECK_STRUCTS && !defined (HASH_charset_317C49E291) |
| 3168 | # error "charset changed. See CHECK_STRUCTS comment." | 3168 | # error "charset changed. See CHECK_STRUCTS comment." |
| 3169 | #endif | 3169 | #endif |
| 3170 | dump_align_output (ctx, alignof (int)); | 3170 | dump_align_output (ctx, alignof (struct charset)); |
| 3171 | const struct charset *cs = charset_table + cs_i; | 3171 | const struct charset *cs = charset_table + cs_i; |
| 3172 | struct charset out; | 3172 | struct charset out; |
| 3173 | dump_object_start (ctx, &out, sizeof (out)); | 3173 | dump_object_start (ctx, &out, sizeof (out)); |
| @@ -3816,7 +3816,8 @@ drain_reloc_list (struct dump_context *ctx, | |||
| 3816 | Lisp_Object relocs = Fsort (Fnreverse (*reloc_list), | 3816 | Lisp_Object relocs = Fsort (Fnreverse (*reloc_list), |
| 3817 | Qdump_emacs_portable__sort_predicate); | 3817 | Qdump_emacs_portable__sort_predicate); |
| 3818 | *reloc_list = Qnil; | 3818 | *reloc_list = Qnil; |
| 3819 | dump_align_output (ctx, sizeof (dump_off)); | 3819 | dump_align_output (ctx, max (alignof (struct dump_reloc), |
| 3820 | alignof (struct emacs_reloc))); | ||
| 3820 | struct dump_table_locator locator; | 3821 | struct dump_table_locator locator; |
| 3821 | memset (&locator, 0, sizeof (locator)); | 3822 | memset (&locator, 0, sizeof (locator)); |
| 3822 | locator.offset = ctx->offset; | 3823 | locator.offset = ctx->offset; |