aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ld/emulparams/elf64bmip-defs.sh6
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp21
-rw-r--r--ld/testsuite/ld-mips-elf/pie-n64.d12
-rw-r--r--ld/testsuite/ld-mips-elf/sections-1-n32.rd36
-rw-r--r--ld/testsuite/ld-mips-elf/sections-1-n32p.rd36
-rw-r--r--ld/testsuite/ld-mips-elf/sections-1-n32t.rd36
-rw-r--r--ld/testsuite/ld-mips-elf/sections-1-n64.rd36
-rw-r--r--ld/testsuite/ld-mips-elf/sections-1-n64t.rd36
-rw-r--r--ld/testsuite/ld-mips-elf/sections-1-o32.rd36
-rw-r--r--ld/testsuite/ld-mips-elf/sections-1-o32t.rd36
-rw-r--r--ld/testsuite/ld-mips-elf/sections-2-n32.rd33
-rw-r--r--ld/testsuite/ld-mips-elf/sections-2-n32p.rd33
-rw-r--r--ld/testsuite/ld-mips-elf/sections-2-n32t.rd33
-rw-r--r--ld/testsuite/ld-mips-elf/sections-2-n64.rd33
-rw-r--r--ld/testsuite/ld-mips-elf/sections-2-n64t.rd33
-rw-r--r--ld/testsuite/ld-mips-elf/sections-2-o32.rd33
-rw-r--r--ld/testsuite/ld-mips-elf/sections-2-o32t.rd33
-rw-r--r--ld/testsuite/ld-mips-elf/sections.s44
18 files changed, 559 insertions, 7 deletions
diff --git a/ld/emulparams/elf64bmip-defs.sh b/ld/emulparams/elf64bmip-defs.sh
index 4165f51..19d782d 100644
--- a/ld/emulparams/elf64bmip-defs.sh
+++ b/ld/emulparams/elf64bmip-defs.sh
@@ -1,6 +1,10 @@
source_sh ${srcdir}/emulparams/elf32bmipn32-defs.sh
COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
-INITIAL_READONLY_SECTIONS="
+INITIAL_READONLY_SECTIONS=
+if test -z "${CREATE_SHLIB}"; then
+ INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
+fi
+INITIAL_READONLY_SECTIONS="${INITIAL_READONLY_SECTIONS}
.MIPS.abiflags ${RELOCATING-0} : { *(.MIPS.abiflags) }
.MIPS.xhash ${RELOCATING-0} : { *(.MIPS.xhash) }
.MIPS.options : { *(.MIPS.options) }
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 920bb12..44f9dc9 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -1669,3 +1669,24 @@ run_dump_test_n64 "global-local-symtab-sort-n64${tmips}"
run_dump_test_o32 "global-local-symtab-final-o32"
run_dump_test_n32 "global-local-symtab-final-n32"
run_dump_test_n64 "global-local-symtab-final-n64"
+
+# Section ordering tests.
+foreach { abi } $abis {
+ set ps2 [expr \
+ ({$abi} == {"n32"} && [istarget "mips64*el-ps2-elf*"]) ? {"p"} : {""}]
+ run_ld_link_tests [list \
+ [list \
+ "MIPS section ordering test 1 ($abi)" \
+ "$abi_ldflags($abi) -r" "" \
+ "$abi_asflags($abi) -mpdr" \
+ [list sections.s] \
+ [list "readelf -WS sections-1-${abi}${tmips}${ps2}.rd"] \
+ "sections-1-${abi}.o"] \
+ [list \
+ "MIPS section ordering test 2 ($abi)" \
+ "$abi_ldflags($abi) -e 0" "" \
+ "$abi_asflags($abi) -mpdr" \
+ [list sections.s] \
+ [list "readelf -WS sections-2-${abi}${tmips}${ps2}.rd"] \
+ "sections-2-${abi}"]]
+}
diff --git a/ld/testsuite/ld-mips-elf/pie-n64.d b/ld/testsuite/ld-mips-elf/pie-n64.d
index bf7c6b2..1fda251 100644
--- a/ld/testsuite/ld-mips-elf/pie-n64.d
+++ b/ld/testsuite/ld-mips-elf/pie-n64.d
@@ -2,16 +2,16 @@
#ld: -pie
#readelf: -d
-Dynamic section at offset 0x208 contains 17 entries:
+Dynamic section at offset 0x220 contains 17 entries:
Tag * Type * Name/Value
- 0x0+00000004 \(HASH\) * 0x368
- 0x0+00000005 \(STRTAB\) * 0x3c8
- 0x0+00000006 \(SYMTAB\) * 0x380
+ 0x0+00000004 \(HASH\) * 0x380
+ 0x0+00000005 \(STRTAB\) * 0x3e0
+ 0x0+00000006 \(SYMTAB\) * 0x398
0x0+0000000a \(STRSZ\) * 28 \(bytes\)
0x0+0000000b \(SYMENT\) * 24 \(bytes\)
- 0x0+70000035 \(MIPS_RLD_MAP_REL\) * 0x101c8
+ 0x0+70000035 \(MIPS_RLD_MAP_REL\) * 0x101a0
0x0+00000015 \(DEBUG\) * 0x0
- 0x0+00000003 \(PLTGOT\) * 0x10430
+ 0x0+00000003 \(PLTGOT\) * 0x10420
0x0+70000001 \(MIPS_RLD_VERSION\) * 1
0x0+70000005 \(MIPS_FLAGS\) * NOTPOT
0x0+70000006 \(MIPS_BASE_ADDRESS\) * 0x0
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n32.rd b/ld/testsuite/ld-mips-elf/sections-1-n32.rd
new file mode 100644
index 0000000..ee7043b
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-1-n32.rd
@@ -0,0 +1,36 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.pdr +PROGBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.gptab\.sbss +MIPS_GPTAB .*
+ \[..\] \.gptab\.sdata +MIPS_GPTAB .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n32p.rd b/ld/testsuite/ld-mips-elf/sections-1-n32p.rd
new file mode 100644
index 0000000..3e210ac
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-1-n32p.rd
@@ -0,0 +1,36 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.pdr +PROGBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.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 .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n32t.rd b/ld/testsuite/ld-mips-elf/sections-1-n32t.rd
new file mode 100644
index 0000000..3e210ac
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-1-n32t.rd
@@ -0,0 +1,36 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.pdr +PROGBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.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 .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n64.rd b/ld/testsuite/ld-mips-elf/sections-1-n64.rd
new file mode 100644
index 0000000..57323de
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-1-n64.rd
@@ -0,0 +1,36 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.MIPS\.options +MIPS_OPTIONS .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.pdr +PROGBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.gptab\.sbss +MIPS_GPTAB .*
+ \[..\] \.gptab\.sdata +MIPS_GPTAB .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-1-n64t.rd b/ld/testsuite/ld-mips-elf/sections-1-n64t.rd
new file mode 100644
index 0000000..3852b62
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-1-n64t.rd
@@ -0,0 +1,36 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.MIPS\.options +MIPS_OPTIONS .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.pdr +PROGBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.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 .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-1-o32.rd b/ld/testsuite/ld-mips-elf/sections-1-o32.rd
new file mode 100644
index 0000000..5a601e6
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-1-o32.rd
@@ -0,0 +1,36 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.pdr +PROGBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.gptab\.sdata +MIPS_GPTAB .*
+ \[..\] \.gptab\.sbss +MIPS_GPTAB .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-1-o32t.rd b/ld/testsuite/ld-mips-elf/sections-1-o32t.rd
new file mode 100644
index 0000000..29daf27
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-1-o32t.rd
@@ -0,0 +1,36 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.pdr +PROGBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.gptab\.sdata +MIPS_GPTAB .*
+ \[..\] \.gptab\.sbss +MIPS_GPTAB .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-2-n32.rd b/ld/testsuite/ld-mips-elf/sections-2-n32.rd
new file mode 100644
index 0000000..e6accc2
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-2-n32.rd
@@ -0,0 +1,33 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-2-n32p.rd b/ld/testsuite/ld-mips-elf/sections-2-n32p.rd
new file mode 100644
index 0000000..5932768
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-2-n32p.rd
@@ -0,0 +1,33 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-2-n32t.rd b/ld/testsuite/ld-mips-elf/sections-2-n32t.rd
new file mode 100644
index 0000000..5932768
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-2-n32t.rd
@@ -0,0 +1,33 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-2-n64.rd b/ld/testsuite/ld-mips-elf/sections-2-n64.rd
new file mode 100644
index 0000000..2f7afdd
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-2-n64.rd
@@ -0,0 +1,33 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.MIPS\.options +MIPS_OPTIONS .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-2-n64t.rd b/ld/testsuite/ld-mips-elf/sections-2-n64t.rd
new file mode 100644
index 0000000..d24e04b
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-2-n64t.rd
@@ -0,0 +1,33 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.MIPS\.options +MIPS_OPTIONS .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-2-o32.rd b/ld/testsuite/ld-mips-elf/sections-2-o32.rd
new file mode 100644
index 0000000..7bb3263
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-2-o32.rd
@@ -0,0 +1,33 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections-2-o32t.rd b/ld/testsuite/ld-mips-elf/sections-2-o32t.rd
new file mode 100644
index 0000000..a0fc114
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections-2-o32t.rd
@@ -0,0 +1,33 @@
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ \[Nr\] Name +Type .*
+ \[..\] +NULL .*
+ \[..\] \.interp +PROGBITS .*
+ \[..\] \.MIPS\.abiflags +MIPS_ABIFLAGS .*
+ \[..\] \.reginfo +MIPS_REGINFO .*
+ \[..\] \.MIPS\.xhash +MIPS_XHASH .*
+ \[..\] \.text +PROGBITS .*
+ \[..\] \.rodata +PROGBITS .*
+ \[..\] \.got\.plt +PROGBITS .*
+ \[..\] \.data +PROGBITS .*
+ \[..\] \.got +PROGBITS .*
+ \[..\] \.sdata +PROGBITS .*
+ \[..\] \.lit8 +PROGBITS .*
+ \[..\] \.lit4 +PROGBITS .*
+ \[..\] \.sbss +NOBITS .*
+ \[..\] \.bss +NOBITS .*
+ \[..\] \.gnu\.attributes +GNU_ATTRIBUTES .*
+ \[..\] \.mdebug\.abi32 +PROGBITS .*
+ \[..\] \.mdebug\.abiN32 +PROGBITS .*
+ \[..\] \.mdebug\.abi64 +PROGBITS .*
+ \[..\] \.mdebug\.abiO64 +PROGBITS .*
+ \[..\] \.mdebug\.eabi32 +PROGBITS .*
+ \[..\] \.mdebug\.eabi64 +PROGBITS .*
+ \[..\] \.gcc_compiled_long32 +PROGBITS .*
+ \[..\] \.gcc_compiled_long64 +PROGBITS .*
+ \[..\] \.symtab +SYMTAB .*
+ \[..\] \.strtab +STRTAB .*
+ \[..\] \.shstrtab +STRTAB .*
+Key to Flags:
+#pass
diff --git a/ld/testsuite/ld-mips-elf/sections.s b/ld/testsuite/ld-mips-elf/sections.s
new file mode 100644
index 0000000..3039349
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/sections.s
@@ -0,0 +1,44 @@
+ .section .MIPS.xhash
+ .dc.l 0
+ .section .bss
+ .dc.l 0
+ .section .data
+ .dc.l 0
+ .section .gcc_compiled_long32
+ .dc.l 0
+ .section .gcc_compiled_long64
+ .dc.l 0
+ .section .got
+ .dc.l 0
+ .section .got.plt
+ .dc.l 0
+ .section .gptab.sbss
+ .dc.l 0
+ .section .gptab.sdata
+ .dc.l 0
+ .section .interp
+ .dc.l 0
+ .section .lit4
+ .dc.l 0
+ .section .lit8
+ .dc.l 0
+ .section .mdebug.abi32
+ .dc.l 0
+ .section .mdebug.abi64
+ .dc.l 0
+ .section .mdebug.abiN32
+ .dc.l 0
+ .section .mdebug.abiO64
+ .dc.l 0
+ .section .mdebug.eabi32
+ .dc.l 0
+ .section .mdebug.eabi64
+ .dc.l 0
+ .section .rodata
+ .dc.l 0
+ .section .sbss
+ .dc.l 0
+ .section .sdata
+ .dc.l 0
+ .section .text
+ .dc.l 0