Separate header PT_LOAD for -z separate-code
authorAlan Modra <amodra@gmail.com>
Fri, 5 Oct 2018 02:10:54 +0000 (11:40 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 8 Oct 2018 09:56:08 +0000 (20:26 +1030)
commit64029e93683a266c38d19789e780f3748bd6a188
tree9984a3e982904e0132021869f097249ccdc99759
parent7358942661ccb0ea1e819fd2f5d47914cebf0aa2
Separate header PT_LOAD for -z separate-code

This patch, along with previous patches in the series, supports
putting the ELF file header and program headers in a PT_LOAD without
sections.

Logic governing whether headers a loaded has changed a little:  The
primary reason to include headers is now the presence of
SIZEOF_HEADERS in a linker script.  However, to support scripts that
may have reserved space for headers by hand, we continue to add
headers whenever the first section address is past the end of headers
modulo page size.

include/
* bfdlink.h (struct bfd_link_info): Add load_phdrs field.
bfd/
* elf-nacl.c (nacl_modify_segment_map): Cope with header PT_LOAD
lacking sections.
* elf.c (_bfd_elf_map_sections_to_segments): Assume file and
program headers are required when info->load_phdrs.  Reorganize
code handling program headers.  Generate a mapping without
sections just for file and program headers when -z separate-code
would indicate they should be on a different page to the first
section.
ld/
* ldexp.c (fold_name <SIZEOF_HEADERS>): Set link_info.load_phdrs.
* testsuite/ld-elf/loadaddr1.d: Pass -z noseparate-code.
* testsuite/ld-elf/loadaddr2.d: Likewise.
* testsuite/ld-i386/vxworks2.sd: Adjust expected output.
* testsuite/ld-powerpc/vxworks2.sd: Likewise.
* testsuite/ld-elf/overlay.d: Remove spu xfail.
* testsuite/ld-spu/ovl.lnk: Don't use SIZEOF_HEADERS.
* testsuite/ld-tic6x/dsbt-be.ld: Likewise.
* testsuite/ld-tic6x/dsbt-inrange.ld: Likewise.
* testsuite/ld-tic6x/dsbt-overflow.ld: Likewise.
* testsuite/ld-tic6x/dsbt.ld: Likewise.
17 files changed:
bfd/ChangeLog
bfd/elf-nacl.c
bfd/elf.c
include/ChangeLog
include/bfdlink.h
ld/ChangeLog
ld/ldexp.c
ld/testsuite/ld-elf/loadaddr1.d
ld/testsuite/ld-elf/loadaddr2.d
ld/testsuite/ld-elf/overlay.d
ld/testsuite/ld-i386/vxworks2.sd
ld/testsuite/ld-powerpc/vxworks2.sd
ld/testsuite/ld-spu/ovl.lnk
ld/testsuite/ld-tic6x/dsbt-be.ld
ld/testsuite/ld-tic6x/dsbt-inrange.ld
ld/testsuite/ld-tic6x/dsbt-overflow.ld
ld/testsuite/ld-tic6x/dsbt.ld