diff options
author | John Wiegley <johnw@newartisans.com> | 2015-12-29 21:39:08 -0800 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2015-12-29 21:39:08 -0800 |
commit | ec0a80cc283badc7f7fd5ef78512dde6d34b1355 (patch) | |
tree | 7190e0fb3d4aa06018d8cf997f06b806fb09a9c8 /src/unexelf.c | |
parent | d259328fb87db8cc67d52771efcfa653e52c5b71 (diff) | |
parent | e823c34072bf045800d91e12c7ddb61fa23c6e30 (diff) | |
download | emacs-25-merge.tar.gz |
Merge emacs-25 into master (using imerge)emacs-25-merge
Diffstat (limited to 'src/unexelf.c')
-rw-r--r-- | src/unexelf.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/unexelf.c b/src/unexelf.c index c10c7f21bf2..03e6dafe8ee 100644 --- a/src/unexelf.c +++ b/src/unexelf.c @@ -247,7 +247,7 @@ unexec (const char *new_name, const char *old_name) ElfW (Phdr) *old_bss_seg, *new_bss_seg; ElfW (Addr) old_bss_addr, new_bss_addr; - ElfW (Word) old_bss_size, new_data2_size; + ElfW (Word) old_bss_size, bss_size_growth, new_data2_size; ElfW (Off) old_bss_offset, new_data2_offset; ptrdiff_t n; @@ -331,7 +331,11 @@ unexec (const char *new_name, const char *old_name) new_break = sbrk (0); new_bss_addr = (ElfW (Addr)) new_break; - new_data2_size = new_bss_addr - old_bss_addr; + bss_size_growth = new_bss_addr - old_bss_addr; + new_data2_size = bss_size_growth; + new_data2_size += alignof (ElfW (Shdr)) - 1; + new_data2_size -= new_data2_size % alignof (ElfW (Shdr)); + new_data2_offset = old_bss_offset; #ifdef UNEXELF_DEBUG @@ -399,7 +403,8 @@ unexec (const char *new_name, const char *old_name) new_bss_seg->p_memsz = new_bss_seg->p_filesz; /* Copy over what we have in memory now for the bss area. */ - memcpy (new_base + new_data2_offset, (caddr_t) old_bss_addr, new_data2_size); + memcpy (new_base + new_data2_offset, (caddr_t) old_bss_addr, + bss_size_growth); /* Walk through all section headers, copying data and updating. */ for (n = 1; n < old_file_h->e_shnum; n++) |