Use p_vaddr_offset to set p_vaddr on segments without sections
authorAlan Modra <amodra@gmail.com>
Sat, 6 Oct 2018 02:54:28 +0000 (12:24 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 8 Oct 2018 09:56:08 +0000 (20:26 +1030)
commit5d695627883b32cf33adb529c8fc7271b46dcf55
tree4baf2317406f3ca458656472fcd8812edde379be
parent1b9e270b09c140464a7892c95c28eafa812c6b08
Use p_vaddr_offset to set p_vaddr on segments without sections

p_vaddr is currently set from the first section vma if a segment has
sections, and to zero if a segment has no sections.  This means we
lose p_vaddr when objcopy'ing executables if a segment without
sections has a non-zero p_vaddr.

This patch saves p_vaddr to p_vaddr_offset, and to make the use of
p_vaddr_offset consistent, inverts the sign.  (It's now added to
section vma to get segment vaddr, and added to zero when there are no
sections.)

* elf.c (assign_file_positions_for_load_sections): Set p_vaddr
from m->p_vaddr_offset for segments without sections.  Invert
sign of p_vaddr_offset.
(rewrite_elf_program_header, copy_elf_program_header): Save
old segment p_vaddr to p_vaddr_offset.  Invert sign of
p_vaddr_offset.
bfd/ChangeLog
bfd/elf.c