[binutils-gdb] ld/ELF: suppress note section rearrangement for relocatable linking

Jan Beulich jbeulich@sourceware.org
Fri Jan 9 07:48:31 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f463751648d92d817c3d1420d908f2c59e5ef088

commit f463751648d92d817c3d1420d908f2c59e5ef088
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Jan 9 08:39:14 2026 +0100

    ld/ELF: suppress note section rearrangement for relocatable linking
    
    Input sections would generally best retain their order from in the
    input(s) or relocatable links. In particular the (odd) sorting of note
    sections by alignment is entirely unnecessary there, and could potentially
    even be harmful. Simply accumulate orphan sections in the order observed.
    
    Of course this has an effect on section order, so a few testsuite
    adjustments are necessary. The test for PR ld/27590 is being relaxed, as
    it's no clear why sh_link fields would need to have exact expectations
    when at the same time section numbers aren't matched. (Obviously the .rela
    sections should match their corresponding data sections', but afaict this
    cannot be [easily] expressed.) Xstormy16 XFAILs for a few tests can be
    dropped as the sections of interest there are orphan ones, and hence now
    are placed independent of the linker scripts unusual placing of .data
    ahead of .text.

Diff:
---
 ld/ldlang.c                                 |  2 +-
 ld/testsuite/ld-elf/group2.d                |  2 --
 ld/testsuite/ld-elf/group4.d                |  2 --
 ld/testsuite/ld-elf/group5.d                |  2 --
 ld/testsuite/ld-elf/group6.d                |  2 --
 ld/testsuite/ld-elf/orphan2.d               |  2 --
 ld/testsuite/ld-elf/sec64k.exp              |  2 +-
 ld/testsuite/ld-mips-elf/sections-1-n32.rd  |  2 +-
 ld/testsuite/ld-mips-elf/sections-1-n32p.rd |  6 +++---
 ld/testsuite/ld-mips-elf/sections-1-n32t.rd |  6 +++---
 ld/testsuite/ld-mips-elf/sections-1-n64.rd  |  2 +-
 ld/testsuite/ld-mips-elf/sections-1-n64t.rd |  6 +++---
 ld/testsuite/ld-mips-elf/sections-1-o32.rd  |  2 +-
 ld/testsuite/ld-mips-elf/sections-1-o32t.rd |  2 +-
 ld/testsuite/ld-pe/longsecn-3.d             | 31 +++++++++++++----------------
 ld/testsuite/ld-pe/longsecn-4.d             | 31 +++++++++++++----------------
 ld/testsuite/ld-pe/longsecn-5.d             | 31 +++++++++++++----------------
 ld/testsuite/ld-x86-64/pr27590.rd           |  6 +++---
 ld/testsuite/ld-x86-64/split-by-file.rd     |  6 +++---
 19 files changed, 63 insertions(+), 82 deletions(-)

diff --git a/ld/ldlang.c b/ld/ldlang.c
index 76a6c621dcb..c1c60b3f474 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -2078,7 +2078,7 @@ lang_insert_orphan (asection *s,
 
       as = *place->section;
 
-      if (!as)
+      if (!as || bfd_link_relocatable (&link_info))
 	{
 	  /* Put the section at the end of the list.  */
 
diff --git a/ld/testsuite/ld-elf/group2.d b/ld/testsuite/ld-elf/group2.d
index 604c685b606..08d23d2a48f 100644
--- a/ld/testsuite/ld-elf/group2.d
+++ b/ld/testsuite/ld-elf/group2.d
@@ -1,8 +1,6 @@
 #source: ../../../binutils/testsuite/binutils-all/group.s
 #ld: -r
 #readelf: -Sg --wide
-# xstormy uses a non-standard script, putting .data before .text.
-#xfail: xstormy*-*-*
 
 #...
   \[[ 0-9]+\] \.group[ \t]+GROUP[ \t]+.*
diff --git a/ld/testsuite/ld-elf/group4.d b/ld/testsuite/ld-elf/group4.d
index 9530300766e..2364e6b3dbf 100644
--- a/ld/testsuite/ld-elf/group4.d
+++ b/ld/testsuite/ld-elf/group4.d
@@ -1,8 +1,6 @@
 #source: ../../../binutils/testsuite/binutils-all/group-2.s
 #ld: -r
 #readelf: -Sg --wide
-# xstormy uses a non-standard script, putting .data before .text.
-#xfail: xstormy*-*-*
 
 #...
   \[[ 0-9]+\] .group[ \t]+GROUP[ \t]+.*
diff --git a/ld/testsuite/ld-elf/group5.d b/ld/testsuite/ld-elf/group5.d
index b39c5690cc5..4b952275496 100644
--- a/ld/testsuite/ld-elf/group5.d
+++ b/ld/testsuite/ld-elf/group5.d
@@ -1,8 +1,6 @@
 #source: ../../../binutils/testsuite/binutils-all/group-3.s
 #ld: -r
 #readelf: -Sg --wide
-# xstormy uses a non-standard script, putting .data before .text.
-#xfail: xstormy*-*-*
 
 #...
   \[[ 0-9]+\] .group[ \t]+GROUP[ \t]+.*
diff --git a/ld/testsuite/ld-elf/group6.d b/ld/testsuite/ld-elf/group6.d
index a495eac733e..5010f09bb03 100644
--- a/ld/testsuite/ld-elf/group6.d
+++ b/ld/testsuite/ld-elf/group6.d
@@ -1,8 +1,6 @@
 #source: ../../../binutils/testsuite/binutils-all/group-4.s
 #ld: -r
 #readelf: -Sg --wide
-# xstormy uses a non-standard script, putting .data before .text.
-#xfail: xstormy*-*-*
 
 #...
   \[[ 0-9]+\] .group[ \t]+GROUP[ \t]+.*
diff --git a/ld/testsuite/ld-elf/orphan2.d b/ld/testsuite/ld-elf/orphan2.d
index ddf69c7472e..a82e7217753 100644
--- a/ld/testsuite/ld-elf/orphan2.d
+++ b/ld/testsuite/ld-elf/orphan2.d
@@ -1,8 +1,6 @@
 #source: orphan2.s
 #ld: -r
 #readelf: -S --wide
-#xfail: xstormy*-*-*
-# xstormy uses a non-standard script, resulting is unexpected section order
 
 #...
   \[[ 0-9]+\] \.text[ \t]+PROGBITS[ \t0-9a-f]+AX?.*
diff --git a/ld/testsuite/ld-elf/sec64k.exp b/ld/testsuite/ld-elf/sec64k.exp
index 84496e24ee0..724346382a1 100644
--- a/ld/testsuite/ld-elf/sec64k.exp
+++ b/ld/testsuite/ld-elf/sec64k.exp
@@ -147,7 +147,7 @@ if { ![istarget "m32r-*-*"] } then {
     puts $ofd "#..."
     puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... .*"
     puts $ofd "#..."
-    puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[2-7\] bar_1$"
+    puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[2-8\] bar_1$"
     puts $ofd "#..."
     puts $ofd ".* bar_34000$"
     puts $ofd "#..."
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n32.rd b/ld/testsuite/ld-mips-elf/sections-1-n32.rd
index ee7043bad6f..106e079bda4 100644
--- a/ld/testsuite/ld-mips-elf/sections-1-n32.rd
+++ b/ld/testsuite/ld-mips-elf/sections-1-n32.rd
@@ -17,6 +17,7 @@ Section Headers:
   \[..\] \.lit4 +PROGBITS .*
   \[..\] \.sbss +NOBITS .*
   \[..\] \.bss +NOBITS .*
+  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
   \[..\] \.pdr +PROGBITS .*
   \[..\] \.gcc_compiled_long32 +PROGBITS .*
   \[..\] \.gcc_compiled_long64 +PROGBITS .*
@@ -28,7 +29,6 @@ Section Headers:
   \[..\] \.mdebug\.abiO64 +PROGBITS .*
   \[..\] \.mdebug\.eabi32 +PROGBITS .*
   \[..\] \.mdebug\.eabi64 +PROGBITS .*
-  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
   \[..\] \.symtab +SYMTAB .*
   \[..\] \.strtab +STRTAB .*
   \[..\] \.shstrtab +STRTAB .*
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n32p.rd b/ld/testsuite/ld-mips-elf/sections-1-n32p.rd
index 3e210acd437..784012563b7 100644
--- a/ld/testsuite/ld-mips-elf/sections-1-n32p.rd
+++ b/ld/testsuite/ld-mips-elf/sections-1-n32p.rd
@@ -17,6 +17,9 @@ Section Headers:
   \[..\] \.lit4 +PROGBITS .*
   \[..\] \.sbss +NOBITS .*
   \[..\] \.bss +NOBITS .*
+  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+  \[..\] \.gptab\.sdata +MIPS_GPTAB .*
+  \[..\] \.gptab\.sbss +MIPS_GPTAB .*
   \[..\] \.pdr +PROGBITS .*
   \[..\] \.gcc_compiled_long32 +PROGBITS .*
   \[..\] \.gcc_compiled_long64 +PROGBITS .*
@@ -26,9 +29,6 @@ Section Headers:
   \[..\] \.mdebug\.abiO64 +PROGBITS .*
   \[..\] \.mdebug\.eabi32 +PROGBITS .*
   \[..\] \.mdebug\.eabi64 +PROGBITS .*
-  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
-  \[..\] \.gptab\.sdata +MIPS_GPTAB .*
-  \[..\] \.gptab\.sbss +MIPS_GPTAB .*
   \[..\] \.symtab +SYMTAB .*
   \[..\] \.strtab +STRTAB .*
   \[..\] \.shstrtab +STRTAB .*
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n32t.rd b/ld/testsuite/ld-mips-elf/sections-1-n32t.rd
index 3e210acd437..784012563b7 100644
--- a/ld/testsuite/ld-mips-elf/sections-1-n32t.rd
+++ b/ld/testsuite/ld-mips-elf/sections-1-n32t.rd
@@ -17,6 +17,9 @@ Section Headers:
   \[..\] \.lit4 +PROGBITS .*
   \[..\] \.sbss +NOBITS .*
   \[..\] \.bss +NOBITS .*
+  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+  \[..\] \.gptab\.sdata +MIPS_GPTAB .*
+  \[..\] \.gptab\.sbss +MIPS_GPTAB .*
   \[..\] \.pdr +PROGBITS .*
   \[..\] \.gcc_compiled_long32 +PROGBITS .*
   \[..\] \.gcc_compiled_long64 +PROGBITS .*
@@ -26,9 +29,6 @@ Section Headers:
   \[..\] \.mdebug\.abiO64 +PROGBITS .*
   \[..\] \.mdebug\.eabi32 +PROGBITS .*
   \[..\] \.mdebug\.eabi64 +PROGBITS .*
-  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
-  \[..\] \.gptab\.sdata +MIPS_GPTAB .*
-  \[..\] \.gptab\.sbss +MIPS_GPTAB .*
   \[..\] \.symtab +SYMTAB .*
   \[..\] \.strtab +STRTAB .*
   \[..\] \.shstrtab +STRTAB .*
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n64.rd b/ld/testsuite/ld-mips-elf/sections-1-n64.rd
index 57323de23e3..86b543136d7 100644
--- a/ld/testsuite/ld-mips-elf/sections-1-n64.rd
+++ b/ld/testsuite/ld-mips-elf/sections-1-n64.rd
@@ -17,6 +17,7 @@ Section Headers:
   \[..\] \.lit4 +PROGBITS .*
   \[..\] \.sbss +NOBITS .*
   \[..\] \.bss +NOBITS .*
+  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
   \[..\] \.pdr +PROGBITS .*
   \[..\] \.gcc_compiled_long32 +PROGBITS .*
   \[..\] \.gcc_compiled_long64 +PROGBITS .*
@@ -28,7 +29,6 @@ Section Headers:
   \[..\] \.mdebug\.abiO64 +PROGBITS .*
   \[..\] \.mdebug\.eabi32 +PROGBITS .*
   \[..\] \.mdebug\.eabi64 +PROGBITS .*
-  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
   \[..\] \.symtab +SYMTAB .*
   \[..\] \.strtab +STRTAB .*
   \[..\] \.shstrtab +STRTAB .*
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n64t.rd b/ld/testsuite/ld-mips-elf/sections-1-n64t.rd
index 3852b62e808..4ae146b8302 100644
--- a/ld/testsuite/ld-mips-elf/sections-1-n64t.rd
+++ b/ld/testsuite/ld-mips-elf/sections-1-n64t.rd
@@ -17,6 +17,9 @@ Section Headers:
   \[..\] \.lit4 +PROGBITS .*
   \[..\] \.sbss +NOBITS .*
   \[..\] \.bss +NOBITS .*
+  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+  \[..\] \.gptab\.sdata +MIPS_GPTAB .*
+  \[..\] \.gptab\.sbss +MIPS_GPTAB .*
   \[..\] \.pdr +PROGBITS .*
   \[..\] \.gcc_compiled_long32 +PROGBITS .*
   \[..\] \.gcc_compiled_long64 +PROGBITS .*
@@ -26,9 +29,6 @@ Section Headers:
   \[..\] \.mdebug\.abiO64 +PROGBITS .*
   \[..\] \.mdebug\.eabi32 +PROGBITS .*
   \[..\] \.mdebug\.eabi64 +PROGBITS .*
-  \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
-  \[..\] \.gptab\.sdata +MIPS_GPTAB .*
-  \[..\] \.gptab\.sbss +MIPS_GPTAB .*
   \[..\] \.symtab +SYMTAB .*
   \[..\] \.strtab +STRTAB .*
   \[..\] \.shstrtab +STRTAB .*
diff --git a/ld/testsuite/ld-mips-elf/sections-1-o32.rd b/ld/testsuite/ld-mips-elf/sections-1-o32.rd
index 5a601e64dfa..a9a4cd08f01 100644
--- a/ld/testsuite/ld-mips-elf/sections-1-o32.rd
+++ b/ld/testsuite/ld-mips-elf/sections-1-o32.rd
@@ -17,7 +17,6 @@ Section Headers:
   \[..\] \.lit4 +PROGBITS .*
   \[..\] \.sbss +NOBITS .*
   \[..\] \.bss +NOBITS .*
-  \[..\] \.pdr +PROGBITS .*
   \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
   \[..\] \.gptab\.sdata +MIPS_GPTAB .*
   \[..\] \.gptab\.sbss +MIPS_GPTAB .*
@@ -29,6 +28,7 @@ Section Headers:
   \[..\] \.mdebug\.eabi64 +PROGBITS .*
   \[..\] \.gcc_compiled_long32 +PROGBITS .*
   \[..\] \.gcc_compiled_long64 +PROGBITS .*
+  \[..\] \.pdr +PROGBITS .*
   \[..\] \.symtab +SYMTAB .*
   \[..\] \.strtab +STRTAB .*
   \[..\] \.shstrtab +STRTAB .*
diff --git a/ld/testsuite/ld-mips-elf/sections-1-o32t.rd b/ld/testsuite/ld-mips-elf/sections-1-o32t.rd
index 29daf27eff4..da3fa08d306 100644
--- a/ld/testsuite/ld-mips-elf/sections-1-o32t.rd
+++ b/ld/testsuite/ld-mips-elf/sections-1-o32t.rd
@@ -17,7 +17,6 @@ Section Headers:
   \[..\] \.lit4 +PROGBITS .*
   \[..\] \.sbss +NOBITS .*
   \[..\] \.bss +NOBITS .*
-  \[..\] \.pdr +PROGBITS .*
   \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
   \[..\] \.gptab\.sdata +MIPS_GPTAB .*
   \[..\] \.gptab\.sbss +MIPS_GPTAB .*
@@ -29,6 +28,7 @@ Section Headers:
   \[..\] \.mdebug\.eabi64 +PROGBITS .*
   \[..\] \.gcc_compiled_long32 +PROGBITS .*
   \[..\] \.gcc_compiled_long64 +PROGBITS .*
+  \[..\] \.pdr +PROGBITS .*
   \[..\] \.symtab +SYMTAB .*
   \[..\] \.strtab +STRTAB .*
   \[..\] \.shstrtab +STRTAB .*
diff --git a/ld/testsuite/ld-pe/longsecn-3.d b/ld/testsuite/ld-pe/longsecn-3.d
index c86a828db95..13391f984af 100644
--- a/ld/testsuite/ld-pe/longsecn-3.d
+++ b/ld/testsuite/ld-pe/longsecn-3.d
@@ -7,34 +7,31 @@
 
 Sections:
 Idx Name          Size      VMA +LMA +File off  Algn
-  0 \.(text|bss )         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
-                  (CONTENTS, ALLOC, LOAD, (READONLY, )?CODE|ALLOC)
-  1 \.text\.very\.long\.section\.name [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+#...
+ *[0-9]+ \.text\.very\.long\.section\.name [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
-  2 \.data         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
-                  CONTENTS, ALLOC, LOAD, DATA
-  3 \.data\$1       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\$1       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  4 \.rodata\$1     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\$1     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  5 \.data\$123     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\$123     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  6 \.rodata\$123   [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\$123   [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  7 \.data\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  8 \.rodata\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  9 \.data\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 10 \.rodata\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 11 \.data\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 12 \.rodata\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 13 \.data\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 14 \.rodata\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
 #...
diff --git a/ld/testsuite/ld-pe/longsecn-4.d b/ld/testsuite/ld-pe/longsecn-4.d
index e326d98e807..ce1e9185c67 100644
--- a/ld/testsuite/ld-pe/longsecn-4.d
+++ b/ld/testsuite/ld-pe/longsecn-4.d
@@ -7,34 +7,31 @@
 
 Sections:
 Idx Name          Size      VMA +LMA +File off  Algn
-  0 \.(text|bss )         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
-                  (CONTENTS, ALLOC, LOAD, (READONLY, )?CODE|ALLOC)
-  1 \.text\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+#...
+ *[0-9]+ \.text\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
-  2 \.data         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
-                  CONTENTS, ALLOC, LOAD, DATA
-  3 \.data\$1       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\$1       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  4 \.rodata\$      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\$      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  5 \.data\$12      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\$12      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  6 \.rodata\$      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\$      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  7 \.data\$12      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\$12      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  8 \.rodata\$      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\$      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  9 \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 10 \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 11 \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 12 \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 13 \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\.ve      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 14 \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\.      [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
 #...
diff --git a/ld/testsuite/ld-pe/longsecn-5.d b/ld/testsuite/ld-pe/longsecn-5.d
index f3ef22bd9a4..7f753cd1f5a 100644
--- a/ld/testsuite/ld-pe/longsecn-5.d
+++ b/ld/testsuite/ld-pe/longsecn-5.d
@@ -7,34 +7,31 @@
 
 Sections:
 Idx Name          Size      VMA +LMA +File off  Algn
-  0 \.(text|bss )         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
-                  (CONTENTS, ALLOC, LOAD, (READONLY, )?CODE|ALLOC)
-  1 \.text\.very\.long\.section\.name [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+#...
+ *[0-9]+ \.text\.very\.long\.section\.name [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
-  2 \.data         [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
-                  CONTENTS, ALLOC, LOAD, DATA
-  3 \.data\$1       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\$1       [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  4 \.rodata\$1     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\$1     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  5 \.data\$123     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\$123     [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  6 \.rodata\$123   [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\$123   [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  7 \.data\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  8 \.rodata\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\$123456789 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
-  9 \.data\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 10 \.rodata\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\.very\.long\.section [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 11 \.data\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 12 \.rodata\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\.very\.long\.section\$1 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 13 \.data\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.data\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
- 14 \.rodata\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
+ *[0-9]+ \.rodata\.very\.long\.section\$1234 [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  [0-9a-fA-F]+  2\*\*[0-9]
                   CONTENTS, ALLOC, LOAD, DATA
 #...
diff --git a/ld/testsuite/ld-x86-64/pr27590.rd b/ld/testsuite/ld-x86-64/pr27590.rd
index 55ed17d6f7e..92517768937 100644
--- a/ld/testsuite/ld-x86-64/pr27590.rd
+++ b/ld/testsuite/ld-x86-64/pr27590.rd
@@ -1,11 +1,11 @@
 #...
   \[[ 0-9]+\] .gnu.debuglto_.debug_info PROGBITS +0+ [0-9a-f]+ 0+42 00 +E  0 +0  1
-  \[[ 0-9]+\] .rela.gnu.debuglto_.debug_info RELA +0+ [0-9a-f]+ 0+f0 18 +I 26  17  8
+  \[[ 0-9]+\] .rela.gnu.debuglto_.debug_info RELA +0+ [0-9a-f]+ 0+f0 18 +I 26 +[1-9][0-9]*  8
   \[[ 0-9]+\] .gnu.debuglto_.debug_abbrev PROGBITS +0+ [0-9a-f]+ 0+26 00 +E  0 +0  1
   \[[ 0-9]+\] .gnu.debuglto_.debug_macro PROGBITS +0+ [0-9a-f]+ 0+2a 00 +E  0 +0  1
-  \[[ 0-9]+\] .rela.gnu.debuglto_.debug_macro RELA +0+ [0-9a-f]+ 0+60 18 +I 26  20  8
+  \[[ 0-9]+\] .rela.gnu.debuglto_.debug_macro RELA +0+ [0-9a-f]+ 0+60 18 +I 26 +[1-9][0-9]*  8
   \[[ 0-9]+\] .gnu.debuglto_.debug_macro PROGBITS +0+ [0-9a-f]+ 0+10 00  GE  0 +0  1
-  \[[ 0-9]+\] .rela.gnu.debuglto_.debug_macro RELA +0+ [0-9a-f]+ 0+30 18  IG 26  22  8
+  \[[ 0-9]+\] .rela.gnu.debuglto_.debug_macro RELA +0+ [0-9a-f]+ 0+30 18  IG 26 +[1-9][0-9]*  8
   \[[ 0-9]+\] .gnu.debuglto_.debug_line PROGBITS +0+ [0-9a-f]+ 0+8a 00 +E  0 +0  1
   \[[ 0-9]+\] .gnu.debuglto_.debug_str PROGBITS +0+ [0-9a-f]+ 0+15c 01 MSE  0 +0  1
 #pass
diff --git a/ld/testsuite/ld-x86-64/split-by-file.rd b/ld/testsuite/ld-x86-64/split-by-file.rd
index 4e3e74a2e75..b6d109e0811 100644
--- a/ld/testsuite/ld-x86-64/split-by-file.rd
+++ b/ld/testsuite/ld-x86-64/split-by-file.rd
@@ -4,9 +4,9 @@ Section Headers:
   \[Nr\] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
   \[ 0\]                   NULL            0000000000000000 000000 000000 00      0   0  0
   \[ 1\] .text             PROGBITS        0000000000000000 000040 000000 00  AX  0   0  1
-  \[ 2\] .foo              PROGBITS        0000000000000000 000040 000003 00 AXl  0   0  1
-  \[ 3\] .data             PROGBITS        0000000000000000 000043 000000 00  WA  0   0  1
-  \[ 4\] .bss              NOBITS          0000000000000000 000043 000000 00  WA  0   0  1
+  \[ 2\] .data             PROGBITS        0000000000000000 000040 000000 00  WA  0   0  1
+  \[ 3\] .bss              NOBITS          0000000000000000 000040 000000 00  WA  0   0  1
+  \[ 4\] .foo              PROGBITS        0000000000000000 000040 000003 00 AXl  0   0  1
   \[ 5\] .foo.0            PROGBITS        0000000000000003 000043 000003 00 AXl  0   0  1
   \[ 6\] .symtab           SYMTAB          0000000000000000 [0-9a-f]+ [0-9a-f]+ 18      7   [0-9]  8
   \[ 7\] .strtab           STRTAB          0000000000000000 [0-9a-f]+ [0-9a-f]+ 00      0   0  1


More information about the Binutils-cvs mailing list