aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-11-23 11:10:39 +0000
committerNick Clifton <nickc@redhat.com>2016-11-23 11:10:39 +0000
commit1a9ccd70f9a75dc6b48d340059f28ef3550c107b (patch)
treea270b05984cd44808359c6f6773ce0dfa5d3dff7 /ld
parent128e85e3ab36b8e30f6612fb50de3cbb4ede6824 (diff)
downloadgdb-1a9ccd70f9a75dc6b48d340059f28ef3550c107b.zip
gdb-1a9ccd70f9a75dc6b48d340059f28ef3550c107b.tar.gz
gdb-1a9ccd70f9a75dc6b48d340059f28ef3550c107b.tar.bz2
Fix the linker so that it will not silently generate ELF binaries with invalid program headers. Fix readelf to report such invalid binaries.
PR ld/20815 bfd * elf.c (elf_modify_segment_map): Allow empty LOAD segments if they contain the program headers. (_bfd_elf_map_sections_to_segments): If the linker created the PHDR segment then always attempt to include it in a LOAD segment. (assign_file_positions_for_non_load_sections): Allow LOAD segments to overlap PHDR segments. (phdr_sorter): New function. Sorts program headers. (assign_file_positions_except_relocs): Sort the program headers before writing them out. Issue an error if the PHDR segment is not covered by a LOAD segment, unless the backend allows it. * elf-bfd.h (struct elf_backend_data): Add elf_backend_allow_non_load_phdr. * elfxx-target.h (elf_backend_allow_non_load_phdr): Provide default definition that returns FALSE. (elfNN_bed): Initialise the elf_backend_allow_non_load_phdr field. * elf64-hppa.c (elf64_hppa_allow_non_load_phdr): New function. Returns TRUE. (elf_backend_allow_non_load_phdr): Define. * elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Do not place the interpreter string into the .interp section if the nointerp flag is set in the link info structure. * elf32-arc.c (elf_arc_size_dynamic_sections): Likewise. * elf32-score7.c (score_elf_final_link_relocate): Allow for the _gp symbol not being part of the output. binutils* readelf.c (process_program_headers): Check PT_LOAD and PT_PHDR segments for validity. ld * ld.texinfo: Note that PT_TLS can be used as a segment type. * testsuite/ld-discard/discard.ld: Add space for program headers. * testsuite/ld-elf/flags1.ld: Likewise. * testsuite/ld-elf/maxpage3.t: Likewise. * testsuite/ld-elf/noload-1.t: Likewise. * testsuite/ld-elf/orphan.ld: Likewise. * testsuite/ld-elf/overlay.t: Likewise. * testsuite/ld-elf/pr14052.t: Likewise. * testsuite/ld-elf/pr19539.t: Likewise. * testsuite/ld-elf/provide-hidden-1.ld: Likewise. * testsuite/ld-elf/provide-hidden-s.ld: Likewise. * testsuite/ld-elf/weak-dyn-1.ld: Likewise. * testsuite/ld-i386/pr19539.t: Likewise. * testsuite/ld-scripts/defined.t: Likewise. * testsuite/ld-scripts/defined6.t: Likewise. * testsuite/ld-scripts/dynamic-sections.t: Likewise. * testsuite/ld-scripts/empty-aligned.t: Likewise. * testsuite/ld-scripts/provide-2.t: Likewise. * testsuite/ld-scripts/provide-4.t: Likewise. * testsuite/ld-vax-elf/plt-local.ld: Likewise. * testsuite/ld-x86-64/pr19539.t: Likewise. * testsuite/ld-elf/ehdr_start-missing.d: Do not initialise the dynamic linker. * testsuite/ld-elf/ehdr_start-weak.d: Likewise. * testsuite/ld-elf/elf.exp (pr14170, pr17068): Likewise. * testsuite/ld-elf/loadaddr1.d: Update expected readelf output. * testsuite/ld-elf/noload-2.d: Likewise. * testsuite/ld-powerpc/vxworks2.sd: Likewise. * testsuite/ld-scripts/phdrs3a.d: Likewise. * testsuite/ld-scripts/size-2.d: Likewise. * testsuite/ld-elf/group.ld: Add program headers. * testsuite/ld-elf/overlay.d: Skip for SPU. * testsuite/ld-elf/flags1.d: Skip for RX. * testsuite/ld-elf/pr19162.d: Skip for HPPA64. * testsuite/ld-elf/pr19539.d: Skip for ALPHA. * testsuite/ld-scripts/empty-orphan.t: Update program headers. * testsuite/ld-scripts/size-2.t: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog41
-rw-r--r--ld/ld.texinfo3
-rw-r--r--ld/testsuite/ld-discard/discard.ld1
-rw-r--r--ld/testsuite/ld-elf/ehdr_start-missing.d2
-rw-r--r--ld/testsuite/ld-elf/ehdr_start-weak.d2
-rw-r--r--ld/testsuite/ld-elf/elf.exp4
-rw-r--r--ld/testsuite/ld-elf/flags1.d1
-rw-r--r--ld/testsuite/ld-elf/flags1.ld1
-rw-r--r--ld/testsuite/ld-elf/group.ld8
-rw-r--r--ld/testsuite/ld-elf/loadaddr1.d2
-rw-r--r--ld/testsuite/ld-elf/maxpage3.t1
-rw-r--r--ld/testsuite/ld-elf/noload-1.t1
-rw-r--r--ld/testsuite/ld-elf/noload-2.d2
-rw-r--r--ld/testsuite/ld-elf/orphan.ld1
-rw-r--r--ld/testsuite/ld-elf/overlay.d2
-rw-r--r--ld/testsuite/ld-elf/overlay.t3
-rw-r--r--ld/testsuite/ld-elf/pr14052.t1
-rw-r--r--ld/testsuite/ld-elf/pr19162.d2
-rw-r--r--ld/testsuite/ld-elf/pr19539.d2
-rw-r--r--ld/testsuite/ld-elf/pr19539.t5
-rw-r--r--ld/testsuite/ld-elf/provide-hidden-1.ld1
-rw-r--r--ld/testsuite/ld-elf/provide-hidden-s.ld1
-rw-r--r--ld/testsuite/ld-elf/weak-dyn-1.ld1
-rw-r--r--ld/testsuite/ld-i386/pr19539.t5
-rw-r--r--ld/testsuite/ld-powerpc/vxworks2.sd2
-rw-r--r--ld/testsuite/ld-scripts/defined.t1
-rw-r--r--ld/testsuite/ld-scripts/defined6.t1
-rw-r--r--ld/testsuite/ld-scripts/dynamic-sections.t1
-rw-r--r--ld/testsuite/ld-scripts/empty-aligned.t1
-rw-r--r--ld/testsuite/ld-scripts/empty-orphan.t6
-rw-r--r--ld/testsuite/ld-scripts/phdrs3a.d2
-rw-r--r--ld/testsuite/ld-scripts/provide-2.t1
-rw-r--r--ld/testsuite/ld-scripts/provide-4.t1
-rw-r--r--ld/testsuite/ld-scripts/size-2.d4
-rw-r--r--ld/testsuite/ld-scripts/size-2.t4
-rw-r--r--ld/testsuite/ld-vax-elf/plt-local.ld2
-rw-r--r--ld/testsuite/ld-x86-64/pr19539.t5
37 files changed, 104 insertions, 20 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 1f4814d..8d28692 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,44 @@
+2016-11-23 Nick Clifton <nickc@redhat.com>
+
+ PR ld/20815
+ * ld.texinfo: Note that PT_TLS can be used as a segment type.
+ * testsuite/ld-discard/discard.ld: Add space for program headers.
+ * testsuite/ld-elf/flags1.ld: Likewise.
+ * testsuite/ld-elf/maxpage3.t: Likewise.
+ * testsuite/ld-elf/noload-1.t: Likewise.
+ * testsuite/ld-elf/orphan.ld: Likewise.
+ * testsuite/ld-elf/overlay.t: Likewise.
+ * testsuite/ld-elf/pr14052.t: Likewise.
+ * testsuite/ld-elf/pr19539.t: Likewise.
+ * testsuite/ld-elf/provide-hidden-1.ld: Likewise.
+ * testsuite/ld-elf/provide-hidden-s.ld: Likewise.
+ * testsuite/ld-elf/weak-dyn-1.ld: Likewise.
+ * testsuite/ld-i386/pr19539.t: Likewise.
+ * testsuite/ld-scripts/defined.t: Likewise.
+ * testsuite/ld-scripts/defined6.t: Likewise.
+ * testsuite/ld-scripts/dynamic-sections.t: Likewise.
+ * testsuite/ld-scripts/empty-aligned.t: Likewise.
+ * testsuite/ld-scripts/provide-2.t: Likewise.
+ * testsuite/ld-scripts/provide-4.t: Likewise.
+ * testsuite/ld-vax-elf/plt-local.ld: Likewise.
+ * testsuite/ld-x86-64/pr19539.t: Likewise.
+ * testsuite/ld-elf/ehdr_start-missing.d: Do not initialise the
+ dynamic linker.
+ * testsuite/ld-elf/ehdr_start-weak.d: Likewise.
+ * testsuite/ld-elf/elf.exp (pr14170, pr17068): Likewise.
+ * testsuite/ld-elf/loadaddr1.d: Update expected readelf output.
+ * testsuite/ld-elf/noload-2.d: Likewise.
+ * testsuite/ld-powerpc/vxworks2.sd: Likewise.
+ * testsuite/ld-scripts/phdrs3a.d: Likewise.
+ * testsuite/ld-scripts/size-2.d: Likewise.
+ * testsuite/ld-elf/group.ld: Add program headers.
+ * testsuite/ld-elf/overlay.d: Skip for SPU.
+ * testsuite/ld-elf/flags1.d: Skip for RX.
+ * testsuite/ld-elf/pr19162.d: Skip for HPPA64.
+ * testsuite/ld-elf/pr19539.d: Skip for ALPHA.
+ * testsuite/ld-scripts/empty-orphan.t: Update program headers.
+ * testsuite/ld-scripts/size-2.t: Likewise.
+
2016-11-22 Ambrogino Modigliani <ambrogino.modigliani@gmail.com>
* configure: Regenerate.
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index d4f33b7..ec7ff1b 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -5359,6 +5359,9 @@ ABI.
@item @code{PT_PHDR} (6)
Indicates a segment where the program headers may be found.
+@item @code{PT_TLS} (7)
+Indicates a segment containing thread local storage.
+
@item @var{expression}
An expression giving the numeric type of the program header. This may
be used for types not defined above.
diff --git a/ld/testsuite/ld-discard/discard.ld b/ld/testsuite/ld-discard/discard.ld
index a7ff4a5..64f3350 100644
--- a/ld/testsuite/ld-discard/discard.ld
+++ b/ld/testsuite/ld-discard/discard.ld
@@ -1,6 +1,7 @@
ENTRY(_start)
SECTIONS
{
+ . = SIZEOF_HEADERS;
/* Sections to be discarded */
/DISCARD/ : {
*(.data.exit)
diff --git a/ld/testsuite/ld-elf/ehdr_start-missing.d b/ld/testsuite/ld-elf/ehdr_start-missing.d
index 5c2090f..046e39a 100644
--- a/ld/testsuite/ld-elf/ehdr_start-missing.d
+++ b/ld/testsuite/ld-elf/ehdr_start-missing.d
@@ -1,4 +1,4 @@
#source: ehdr_start-strongref.s
-#ld: -e _start -T ehdr_start-missing.t
+#ld: -e _start -T ehdr_start-missing.t --no-dynamic-linker
#error: .*: undefined reference to `__ehdr_start'
#target: *-*-linux* *-*-gnu* *-*-nacl*
diff --git a/ld/testsuite/ld-elf/ehdr_start-weak.d b/ld/testsuite/ld-elf/ehdr_start-weak.d
index 5644d05..d3d5af7 100644
--- a/ld/testsuite/ld-elf/ehdr_start-weak.d
+++ b/ld/testsuite/ld-elf/ehdr_start-weak.d
@@ -1,5 +1,5 @@
#source: ehdr_start.s
-#ld: -e _start -T ehdr_start-missing.t
+#ld: -e _start -T ehdr_start-missing.t --no-dynamic-linker
#nm: -n
#target: *-*-linux* *-*-gnu* *-*-nacl*
#xfail: frv-*-*
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index 59284bd..f93ad46 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -75,7 +75,7 @@ if { ![istarget hppa64*-hpux*] } {
setup_xfail "bfin-*-*"
run_ld_link_tests {
{"PR ld/14170"
- "tmpdir/pr14170a.o tmpdir/pr14170.so" "" "" "pr14170c.s"
+ "--no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" "" "pr14170c.s"
{ } "pr14170" }
}
}
@@ -112,7 +112,7 @@ if { [check_shared_lib_support] } then {
setup_xfail "bfin-*-*"
run_ld_link_tests {
{"pr17068 link --as-needed lib in group"
- "--as-needed" "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a --end-group" ""
+ "--as-needed --no-dynamic-linker" "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a --end-group" ""
{start.s pr17068.s} {} "pr17068"}
}
# xfail on tic6x due to non-PIC/non-PID warnings
diff --git a/ld/testsuite/ld-elf/flags1.d b/ld/testsuite/ld-elf/flags1.d
index 6cd8b3f..aadf936 100644
--- a/ld/testsuite/ld-elf/flags1.d
+++ b/ld/testsuite/ld-elf/flags1.d
@@ -2,6 +2,7 @@
#ld: -Tflags1.ld
#objcopy_linked_file: --set-section-flags .post_text_reserve=contents,alloc,load,readonly,code
#readelf: -S --wide
+#notarget: rx-*-*
#...
Section Headers:
diff --git a/ld/testsuite/ld-elf/flags1.ld b/ld/testsuite/ld-elf/flags1.ld
index a94cbe8..c003ce7 100644
--- a/ld/testsuite/ld-elf/flags1.ld
+++ b/ld/testsuite/ld-elf/flags1.ld
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
.text :
{
*(.text)
diff --git a/ld/testsuite/ld-elf/group.ld b/ld/testsuite/ld-elf/group.ld
index f8e50c3..53e2790 100644
--- a/ld/testsuite/ld-elf/group.ld
+++ b/ld/testsuite/ld-elf/group.ld
@@ -1,6 +1,12 @@
+PHDRS
+{
+ header PT_PHDR PHDRS ;
+ image PT_LOAD PHDRS;
+}
+
SECTIONS
{
. = 0x1000;
- .text : { *(.text) *(.rodata.brlt) }
+ .text : { *(.text) *(.rodata.brlt) } :image :header
/DISCARD/ : { *(.dropme) *(.reginfo) *(.MIPS.abiflags) }
}
diff --git a/ld/testsuite/ld-elf/loadaddr1.d b/ld/testsuite/ld-elf/loadaddr1.d
index 0fd96a7..0aa372c 100644
--- a/ld/testsuite/ld-elf/loadaddr1.d
+++ b/ld/testsuite/ld-elf/loadaddr1.d
@@ -5,6 +5,6 @@
#...
LOAD +0x000000 0xf*80000000 0xf*80000000 0x100050 0x100050 RWE 0x200000
- LOAD +0x200000 0xf*ff600000 0xf*80101000 0x0*10 0x0*10 R E 0x200000
LOAD +0x302000 0xf*80102000 0xf*80102000 0x0*10 0x0*10 RW 0x200000
+ LOAD +0x200000 0xf*ff600000 0xf*80101000 0x0*10 0x0*10 R E 0x200000
#pass
diff --git a/ld/testsuite/ld-elf/maxpage3.t b/ld/testsuite/ld-elf/maxpage3.t
index 556dcd5..f5ada18 100644
--- a/ld/testsuite/ld-elf/maxpage3.t
+++ b/ld/testsuite/ld-elf/maxpage3.t
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
.text : {*(.text)}
. = ALIGN(CONSTANT (MAXPAGESIZE));
.data : {*(.data)}
diff --git a/ld/testsuite/ld-elf/noload-1.t b/ld/testsuite/ld-elf/noload-1.t
index 1efd06c..768cd42 100644
--- a/ld/testsuite/ld-elf/noload-1.t
+++ b/ld/testsuite/ld-elf/noload-1.t
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
TEST (NOLOAD) :
{
*(TEST)
diff --git a/ld/testsuite/ld-elf/noload-2.d b/ld/testsuite/ld-elf/noload-2.d
index 0e25d9b..c9668a0 100644
--- a/ld/testsuite/ld-elf/noload-2.d
+++ b/ld/testsuite/ld-elf/noload-2.d
@@ -4,5 +4,5 @@
#target: *-*-linux* *-*-gnu*
#...
- +LOAD +0x200000 +0x0+ +0x0+ +0x0+ +0x0+1 +RW +0x200000
+ +LOAD +0x.00000 +0x0+ +0x0+ +0x0+.. +0x0+.. +RW +0x200000
#pass
diff --git a/ld/testsuite/ld-elf/orphan.ld b/ld/testsuite/ld-elf/orphan.ld
index 1ae908b..8b5015e 100644
--- a/ld/testsuite/ld-elf/orphan.ld
+++ b/ld/testsuite/ld-elf/orphan.ld
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
.text : { *(.text) }
.data : { *(.data) }
.bss : { *(.bss) *(COMMON) }
diff --git a/ld/testsuite/ld-elf/overlay.d b/ld/testsuite/ld-elf/overlay.d
index 00d25d5..c4409ae 100644
--- a/ld/testsuite/ld-elf/overlay.d
+++ b/ld/testsuite/ld-elf/overlay.d
@@ -1,5 +1,7 @@
# ld: -T overlay.t -u __load_start_text1 -u __load_start_text2 -u __load_stop_text1 -u __load_stop_text2
#readelf: -s
+#notarget: 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-elf/overlay.t b/ld/testsuite/ld-elf/overlay.t
index bdb33c8..dd374bb 100644
--- a/ld/testsuite/ld-elf/overlay.t
+++ b/ld/testsuite/ld-elf/overlay.t
@@ -1,10 +1,11 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
.text : { *(.text) }
OVERLAY 0x1000 : AT (0x4000)
{
.text1 {*(.text1)}
.text2 {*(.text2)}
- }
+ }
/DISCARD/ : { *(.*) }
}
diff --git a/ld/testsuite/ld-elf/pr14052.t b/ld/testsuite/ld-elf/pr14052.t
index 360c231..84fffbd 100644
--- a/ld/testsuite/ld-elf/pr14052.t
+++ b/ld/testsuite/ld-elf/pr14052.t
@@ -1,4 +1,5 @@
SECTIONS {
+ . = SIZEOF_HEADERS;
.text : {
*(.text)
}
diff --git a/ld/testsuite/ld-elf/pr19162.d b/ld/testsuite/ld-elf/pr19162.d
index 1a54546..4d706ff 100644
--- a/ld/testsuite/ld-elf/pr19162.d
+++ b/ld/testsuite/ld-elf/pr19162.d
@@ -3,7 +3,7 @@
#ld: -shared -z max-page-size=0x200000
#readelf: -l --wide
#target: *-*-linux* *-*-gnu* *-*-nacl*
-#notarget: arc*-*-* hppa-*-*
+#notarget: arc*-*-* hppa*-*-*
# arc target has an extra 64K stack section.
# hppa fails due to PR 12376.
diff --git a/ld/testsuite/ld-elf/pr19539.d b/ld/testsuite/ld-elf/pr19539.d
index 87c2b1b..e7d8298 100644
--- a/ld/testsuite/ld-elf/pr19539.d
+++ b/ld/testsuite/ld-elf/pr19539.d
@@ -3,7 +3,7 @@
#ld: -pie -T pr19539.t
#readelf : --dyn-syms --wide
#target: *-*-linux* *-*-gnu* *-*-solaris*
-#notarget: cris*-*-*
+#notarget: cris*-*-* alpha-*-*
Symbol table '\.dynsym' contains [0-9]+ entries:
#pass
diff --git a/ld/testsuite/ld-elf/pr19539.t b/ld/testsuite/ld-elf/pr19539.t
index b6b48e7..82ef917 100644
--- a/ld/testsuite/ld-elf/pr19539.t
+++ b/ld/testsuite/ld-elf/pr19539.t
@@ -1 +1,6 @@
HIDDEN (foo = .);
+
+SECTIONS
+{
+ . = SIZEOF_HEADERS;
+}
diff --git a/ld/testsuite/ld-elf/provide-hidden-1.ld b/ld/testsuite/ld-elf/provide-hidden-1.ld
index 47cdbb7..479862d 100644
--- a/ld/testsuite/ld-elf/provide-hidden-1.ld
+++ b/ld/testsuite/ld-elf/provide-hidden-1.ld
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
. = 0x12300000;
.data :
{
diff --git a/ld/testsuite/ld-elf/provide-hidden-s.ld b/ld/testsuite/ld-elf/provide-hidden-s.ld
index cca804f..fc5761a 100644
--- a/ld/testsuite/ld-elf/provide-hidden-s.ld
+++ b/ld/testsuite/ld-elf/provide-hidden-s.ld
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
. = 0x12300000;
.data : { *(.data) }
.got : { *(.got) }
diff --git a/ld/testsuite/ld-elf/weak-dyn-1.ld b/ld/testsuite/ld-elf/weak-dyn-1.ld
index 495b712..25a510c 100644
--- a/ld/testsuite/ld-elf/weak-dyn-1.ld
+++ b/ld/testsuite/ld-elf/weak-dyn-1.ld
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
. = 0x800000;
PROVIDE (bar = .);
.data : {
diff --git a/ld/testsuite/ld-i386/pr19539.t b/ld/testsuite/ld-i386/pr19539.t
index b6b48e7..82ef917 100644
--- a/ld/testsuite/ld-i386/pr19539.t
+++ b/ld/testsuite/ld-i386/pr19539.t
@@ -1 +1,6 @@
HIDDEN (foo = .);
+
+SECTIONS
+{
+ . = SIZEOF_HEADERS;
+}
diff --git a/ld/testsuite/ld-powerpc/vxworks2.sd b/ld/testsuite/ld-powerpc/vxworks2.sd
index 0876568..2294cb6 100644
--- a/ld/testsuite/ld-powerpc/vxworks2.sd
+++ b/ld/testsuite/ld-powerpc/vxworks2.sd
@@ -6,7 +6,7 @@ Program Headers:
Type .*
PHDR .*
#...
- LOAD .* 0x00080000 0x00080000 .* R E 0x10000
+ LOAD .* 0x00070000 0x00070000 .* R E 0x10000
LOAD .* 0x00090000 0x00090000 .* RW 0x10000
DYNAMIC .*
diff --git a/ld/testsuite/ld-scripts/defined.t b/ld/testsuite/ld-scripts/defined.t
index c1ef1b6..e4e105f 100644
--- a/ld/testsuite/ld-scripts/defined.t
+++ b/ld/testsuite/ld-scripts/defined.t
@@ -1,4 +1,5 @@
SECTIONS {
+ . = SIZEOF_HEADERS;
.text : { *(.text) }
.data : { *(.data) }
.bss : { *(.bss) *(COMMON) }
diff --git a/ld/testsuite/ld-scripts/defined6.t b/ld/testsuite/ld-scripts/defined6.t
index f4ca38a..9713aac 100644
--- a/ld/testsuite/ld-scripts/defined6.t
+++ b/ld/testsuite/ld-scripts/defined6.t
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
.text : { *(.text) }
.data : { *(.data) }
.bss : { *(.bss) *(COMMON) }
diff --git a/ld/testsuite/ld-scripts/dynamic-sections.t b/ld/testsuite/ld-scripts/dynamic-sections.t
index f1f24c8..64cf47d6 100644
--- a/ld/testsuite/ld-scripts/dynamic-sections.t
+++ b/ld/testsuite/ld-scripts/dynamic-sections.t
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
.data : { *(.data) }
.rodata : { *(.rodata) }
diff --git a/ld/testsuite/ld-scripts/empty-aligned.t b/ld/testsuite/ld-scripts/empty-aligned.t
index 5f6a38d..0073f13 100644
--- a/ld/testsuite/ld-scripts/empty-aligned.t
+++ b/ld/testsuite/ld-scripts/empty-aligned.t
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
.text : { *(.text) }
/* Alignment at beginning shouldn't result in empty section being kept. */
.text1 ALIGN (4096) :
diff --git a/ld/testsuite/ld-scripts/empty-orphan.t b/ld/testsuite/ld-scripts/empty-orphan.t
index b57e164..c0dc628 100644
--- a/ld/testsuite/ld-scripts/empty-orphan.t
+++ b/ld/testsuite/ld-scripts/empty-orphan.t
@@ -7,14 +7,14 @@ MEMORY
PHDRS
{
- default_phdr PT_LOAD;
- text_phdr PT_LOAD;
+ headers PT_PHDR PHDRS;
+ text_phdr PT_LOAD PHDRS;
data_phdr PT_LOAD;
}
SECTIONS
{
- .text : { *(.text) } > text_mem : text_phdr
+ .text : { *(.text) } > text_mem : text_phdr :headers
.data : { *(.data) } > data_mem : data_phdr
.bss : { *(.bss) } > data_mem : data_phdr
/DISCARD/ : { *(.reginfo) *(.glue*) }
diff --git a/ld/testsuite/ld-scripts/phdrs3a.d b/ld/testsuite/ld-scripts/phdrs3a.d
index 80bde71..d96bd13 100644
--- a/ld/testsuite/ld-scripts/phdrs3a.d
+++ b/ld/testsuite/ld-scripts/phdrs3a.d
@@ -4,6 +4,6 @@
#readelf: -l --wide
#...
-[ \t]+LOAD[ x0-9a-f]+ R [ x0-9a-f]+
[ \t]+LOAD[ x0-9a-f]+ E [ x0-9a-f]+
+[ \t]+LOAD[ x0-9a-f]+ R [ x0-9a-f]+
#pass
diff --git a/ld/testsuite/ld-scripts/provide-2.t b/ld/testsuite/ld-scripts/provide-2.t
index fe30dd8..abf6eb3 100644
--- a/ld/testsuite/ld-scripts/provide-2.t
+++ b/ld/testsuite/ld-scripts/provide-2.t
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
PROVIDE (foo = 1);
PROVIDE (bar = 2);
PROVIDE (baz = 3);
diff --git a/ld/testsuite/ld-scripts/provide-4.t b/ld/testsuite/ld-scripts/provide-4.t
index 424c238..da663db 100644
--- a/ld/testsuite/ld-scripts/provide-4.t
+++ b/ld/testsuite/ld-scripts/provide-4.t
@@ -1,5 +1,6 @@
SECTIONS
{
+ . = SIZEOF_HEADERS;
PROVIDE (foo = 1);
PROVIDE (bar = 2);
PROVIDE (baz = 3);
diff --git a/ld/testsuite/ld-scripts/size-2.d b/ld/testsuite/ld-scripts/size-2.d
index c925673..d76745e 100644
--- a/ld/testsuite/ld-scripts/size-2.d
+++ b/ld/testsuite/ld-scripts/size-2.d
@@ -6,9 +6,9 @@
#...
Program Headers:
+Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg +Align
- +PHDR +0x[0-9a-f]+ 0x0+0000 0x0+0000 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x[0-9a-f]+
+ +PHDR +0x[0-9a-f]+ 0x0+00.. 0x0+00.. 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x[0-9a-f]+
#...
- +LOAD +0x[0-9a-f]+ 0x0+0100 0x0+0100 0x0+0030 0x0+0030 R E +0x[0-9a-f]+
+ +LOAD +0x[0-9a-f]+ 0x0+0... 0x0+0... 0x0+0... 0x0+0... R E +0x[0-9a-f]+
+TLS +0x[0-9a-f]+ 0x0+0108 0x0+0108 0x0+0014 0x0+002c R +0x[0-9a-f]+
Section to Segment mapping:
diff --git a/ld/testsuite/ld-scripts/size-2.t b/ld/testsuite/ld-scripts/size-2.t
index e67b3fa..7238639 100644
--- a/ld/testsuite/ld-scripts/size-2.t
+++ b/ld/testsuite/ld-scripts/size-2.t
@@ -1,8 +1,8 @@
PHDRS
{
- header PT_PHDR FILEHDR PHDRS ;
+ header PT_PHDR PHDRS ;
- image PT_LOAD FLAGS (5);
+ image PT_LOAD FLAGS (5) PHDRS;
tls PT_TLS FLAGS (4);
}
diff --git a/ld/testsuite/ld-vax-elf/plt-local.ld b/ld/testsuite/ld-vax-elf/plt-local.ld
index ca87459..03c74a4 100644
--- a/ld/testsuite/ld-vax-elf/plt-local.ld
+++ b/ld/testsuite/ld-vax-elf/plt-local.ld
@@ -1,7 +1,7 @@
ENTRY (foo_global)
SECTIONS
{
- . = 0;
+ . = SIZEOF_HEADERS;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
diff --git a/ld/testsuite/ld-x86-64/pr19539.t b/ld/testsuite/ld-x86-64/pr19539.t
index b6b48e7..82ef917 100644
--- a/ld/testsuite/ld-x86-64/pr19539.t
+++ b/ld/testsuite/ld-x86-64/pr19539.t
@@ -1 +1,6 @@
HIDDEN (foo = .);
+
+SECTIONS
+{
+ . = SIZEOF_HEADERS;
+}