diff options
author | Alan Modra <amodra@gmail.com> | 2018-10-05 11:40:54 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-10-08 20:26:08 +1030 |
commit | 64029e93683a266c38d19789e780f3748bd6a188 (patch) | |
tree | 9984a3e982904e0132021869f097249ccdc99759 /ld | |
parent | 7358942661ccb0ea1e819fd2f5d47914cebf0aa2 (diff) | |
download | gdb-64029e93683a266c38d19789e780f3748bd6a188.zip gdb-64029e93683a266c38d19789e780f3748bd6a188.tar.gz gdb-64029e93683a266c38d19789e780f3748bd6a188.tar.bz2 |
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.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 14 | ||||
-rw-r--r-- | ld/ldexp.c | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/loadaddr1.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/loadaddr2.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/overlay.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/vxworks2.sd | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-powerpc/vxworks2.sd | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-spu/ovl.lnk | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-tic6x/dsbt-be.ld | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-tic6x/dsbt-inrange.ld | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-tic6x/dsbt-overflow.ld | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-tic6x/dsbt.ld | 1 |
12 files changed, 19 insertions, 20 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 55efbbf..e0a6f72 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,19 @@ 2018-10-08 Alan Modra <amodra@gmail.com> + * 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. + +2018-10-08 Alan Modra <amodra@gmail.com> + * ldlang.c (insert_os_after): Clear ignore_first on assignment to dot, not any assignment. Clear ignore_first on output section statement contents too. @@ -692,6 +692,7 @@ fold_name (etree_type *tree) switch (tree->type.node_code) { case SIZEOF_HEADERS: + link_info.load_phdrs = 1; if (expld.phase != lang_first_phase_enum) { bfd_vma hdr_size = 0; diff --git a/ld/testsuite/ld-elf/loadaddr1.d b/ld/testsuite/ld-elf/loadaddr1.d index c4c5ed8..0e38b64 100644 --- a/ld/testsuite/ld-elf/loadaddr1.d +++ b/ld/testsuite/ld-elf/loadaddr1.d @@ -1,5 +1,5 @@ #source: loadaddr.s -#ld: -T loadaddr1.t -T loadaddr.t -z max-page-size=0x200000 +#ld: -T loadaddr1.t -T loadaddr.t -z max-page-size=0x200000 -z noseparate-code #readelf: -l --wide #target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi diff --git a/ld/testsuite/ld-elf/loadaddr2.d b/ld/testsuite/ld-elf/loadaddr2.d index 577fb6a..5fbfa54 100644 --- a/ld/testsuite/ld-elf/loadaddr2.d +++ b/ld/testsuite/ld-elf/loadaddr2.d @@ -1,5 +1,5 @@ #source: loadaddr.s -#ld: -T loadaddr2.t -T loadaddr.t -z max-page-size=0x200000 +#ld: -T loadaddr2.t -T loadaddr.t -z max-page-size=0x200000 -z noseparate-code #readelf: -l --wide #target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi diff --git a/ld/testsuite/ld-elf/overlay.d b/ld/testsuite/ld-elf/overlay.d index a258eda..00d25d5 100644 --- a/ld/testsuite/ld-elf/overlay.d +++ b/ld/testsuite/ld-elf/overlay.d @@ -1,7 +1,5 @@ # ld: -T overlay.t -u __load_start_text1 -u __load_start_text2 -u __load_stop_text1 -u __load_stop_text2 #readelf: -s -#xfail: spu-*-* -# The SPU adds its own LOAD segments, out of order, at the start of the program header table. #... [ ]+[0-9]+:[ ]+0*4000[ ]+0[ ]+NOTYPE[ ]+GLOBAL[ ]+DEFAULT[ ]+ABS __load_start_text1 diff --git a/ld/testsuite/ld-i386/vxworks2.sd b/ld/testsuite/ld-i386/vxworks2.sd index 4f56f2a..dc1a6e6 100644 --- a/ld/testsuite/ld-i386/vxworks2.sd +++ b/ld/testsuite/ld-i386/vxworks2.sd @@ -2,12 +2,7 @@ Elf file type is EXEC \(Executable file\) Entry point 0x80400 #... -Program Headers: - Type .* - PHDR .* -#... - LOAD .* 0x0007f000 0x0007f000 .* R E 0x1000 + LOAD .* 0x00080000 0x00080000 .* R E 0x1000 LOAD .* 0x00081000 0x00081000 .* RW 0x1000 DYNAMIC .* - #... diff --git a/ld/testsuite/ld-powerpc/vxworks2.sd b/ld/testsuite/ld-powerpc/vxworks2.sd index 2294cb6..04c678e 100644 --- a/ld/testsuite/ld-powerpc/vxworks2.sd +++ b/ld/testsuite/ld-powerpc/vxworks2.sd @@ -2,12 +2,7 @@ Elf file type is EXEC \(Executable file\) Entry point 0x80400 #... -Program Headers: - Type .* - PHDR .* -#... LOAD .* 0x00070000 0x00070000 .* R E 0x10000 LOAD .* 0x00090000 0x00090000 .* RW 0x10000 DYNAMIC .* - #... diff --git a/ld/testsuite/ld-spu/ovl.lnk b/ld/testsuite/ld-spu/ovl.lnk index 0015652..045f986 100644 --- a/ld/testsuite/ld-spu/ovl.lnk +++ b/ld/testsuite/ld-spu/ovl.lnk @@ -1,6 +1,6 @@ SECTIONS { - . = SIZEOF_HEADERS; + . = 0x100; .text : { *(.text) *(.stub) } .data : { *(.data) *(.ovtab) } .bss : { *(.bss) } diff --git a/ld/testsuite/ld-tic6x/dsbt-be.ld b/ld/testsuite/ld-tic6x/dsbt-be.ld index 40ba14c..b78d910 100644 --- a/ld/testsuite/ld-tic6x/dsbt-be.ld +++ b/ld/testsuite/ld-tic6x/dsbt-be.ld @@ -3,7 +3,6 @@ OUTPUT_FORMAT("elf32-tic6x-be", "elf32-tic6x-be", EXTERN (__c6xabi_DSBT_BASE); SECTIONS { - PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x0)); . = SEGMENT_START("text-segment", 0x0) + SIZEOF_HEADERS; . = 0x8000; .hash : { *(.hash) } .gnu.hash : { *(.gnu.hash) } diff --git a/ld/testsuite/ld-tic6x/dsbt-inrange.ld b/ld/testsuite/ld-tic6x/dsbt-inrange.ld index 603f020..e5a2c87 100644 --- a/ld/testsuite/ld-tic6x/dsbt-inrange.ld +++ b/ld/testsuite/ld-tic6x/dsbt-inrange.ld @@ -1,7 +1,6 @@ EXTERN (__c6xabi_DSBT_BASE); SECTIONS { - PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x0)); . = SEGMENT_START("text-segment", 0x0) + SIZEOF_HEADERS; . = 0x8000; .hash : { *(.hash) } .gnu.hash : { *(.gnu.hash) } diff --git a/ld/testsuite/ld-tic6x/dsbt-overflow.ld b/ld/testsuite/ld-tic6x/dsbt-overflow.ld index 3128a35..fecd865 100644 --- a/ld/testsuite/ld-tic6x/dsbt-overflow.ld +++ b/ld/testsuite/ld-tic6x/dsbt-overflow.ld @@ -1,7 +1,6 @@ EXTERN (__c6xabi_DSBT_BASE); SECTIONS { - PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x0)); . = SEGMENT_START("text-segment", 0x0) + SIZEOF_HEADERS; . = 0x8000; .hash : { *(.hash) } .gnu.hash : { *(.gnu.hash) } diff --git a/ld/testsuite/ld-tic6x/dsbt.ld b/ld/testsuite/ld-tic6x/dsbt.ld index fdde8ba..83b93ff 100644 --- a/ld/testsuite/ld-tic6x/dsbt.ld +++ b/ld/testsuite/ld-tic6x/dsbt.ld @@ -3,7 +3,6 @@ OUTPUT_FORMAT("elf32-tic6x-le", "elf32-tic6x-le", EXTERN (__c6xabi_DSBT_BASE); SECTIONS { - PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x0)); . = SEGMENT_START("text-segment", 0x0) + SIZEOF_HEADERS; . = 0x8000; .hash : { *(.hash) } .gnu.hash : { *(.gnu.hash) } |