]> git.eshelyaron.com Git - emacs.git/commit
ELF unexec: Drive from PT_LOAD header rather than sections
authorAlan Modra <amodra@gmail.com>
Sun, 8 Nov 2015 17:29:00 +0000 (09:29 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 8 Nov 2015 18:01:00 +0000 (10:01 -0800)
commit0d6442265e5b709af5eebedf8f0d6b82974f4c31
tree876114cfc291a8f240e6ca27ddf9f4782901c134
parent8285c2ab8050de218c0c06182659ee0a7b23a0f6
ELF unexec: Drive from PT_LOAD header rather than sections

This rewrites bss handling in the ELF unexec code.  Finding bss
sections by name results in complicated code that
- does not account for all names of possible bss sections,
- assumes specific ordering of bss sections,
- can wrongly choose a SHT_NOBITS section not in the bss segment,
- incorrectly calculates bss size (no accounting for alignment gaps),
- assumes .data and .bss are in the same segment.

All of these problems and more are solved by finding the bss segment
in PT_LOAD headers, ie. the address range included in p_memsz but not
p_filesz of the last PT_LOAD header, then matching SHT_NOBITS sections
in that address range.

* unexelf.c: Delete old ppc comment.
(OLD_PROGRAM_H): Define.
(round_up): Delete.
(unexec): Don't search for bss style sections by name.  Instead,
use the last PT_LOAD header address range covered by p_memsz
but not p_filesz and match any SHT_NOBITS section in that
address range.  Simplify initialisation of section header vars.
Don't assume that section headers are above bss segment.  Move
copying of bss area out of section loop.  Align .data2 section
to 1, since it now covers the entire bss area.  For SHT_NOBITS
sections in the bss segment, leave sh_addr and sh_addralign
unchanged, but correct sh_offset.  Clear memory corresponding
to SHT_NOBITS .plt section.  Delete comment and hacks for
sections partly overlapping bss range now that the full range
is properly calculated.  Delete now dead .sbss code.
(Bug#20614)
src/unexelf.c