aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2020-07-29 20:56:41 +0100
committerMaciej W. Rozycki <macro@linux-mips.org>2020-07-29 20:56:41 +0100
commitc77cb2a09c5532ad6d3b94fccca93eb02f7cc0d8 (patch)
tree5e87c11662315d54ec03da8e49e5d828a5608a1f /ld
parent3f1b17bbf022a34f92f3dc32d742e4901816708e (diff)
downloadfsf-binutils-gdb-c77cb2a09c5532ad6d3b94fccca93eb02f7cc0d8.zip
fsf-binutils-gdb-c77cb2a09c5532ad6d3b94fccca93eb02f7cc0d8.tar.gz
fsf-binutils-gdb-c77cb2a09c5532ad6d3b94fccca93eb02f7cc0d8.tar.bz2
MIPS: Make the IRIX naming of local section symbols consistent
Make the MIPS/IRIX naming of local section symbols consistent between files produced by generic ELF code and ELF linker code, complementing commit 174fd7f95561 ("New bfd elf hook: force naming of local section symbols"), <https://sourceware.org/ml/binutils/2004-02/msg00072.html>. Local section symbols have no names in the standard ELF gABI, however the lack of a name causes problems with IRIX's MIPSpro linker. To work around the issue we give them names, however we do that in generic ELF code only, based on what the `elf_backend_name_local_section_symbols' hook returns if present. That makes objects created by GAS or `objdump' work correctly, however not ones created by `ld -r'. That would not normally cause issues with IRIX systems using GAS and `objdump' only with the MIPSpro linker, however if GNU LD was used for whatever reason in producing objects later fed to IRIX's MIPSpro linker, then things would break. Modify ELF linker code accordingly then, using the same hook. Adjust the `ld-elf/64ksec-r' test accordingly so that it also accepts a section symbol with a name. Also modify the hook itself so that only actual ET_REL objects have names assigned to local section symbols. Other kinds of ELF files are not ever supposed to be relocated with the MIPSpro linker, so we can afford producing more standard output. Add suitable GAS, LD and `objcopy' test cases to the relevant testsuites to keep these tools consistently verified. This change also fixes: FAIL: objcopy executable (pr25662) across MIPS targets using the IRIX compatibility mode. bfd/ * elflink.c (bfd_elf_final_link): Give local symbols a name if so requested. * elfxx-mips.c (_bfd_mips_elf_name_local_section_symbols): Only return TRUE if making ET_REL output. binutils/ * testsuite/binutils-all/mips/global-local-symtab-sort-o32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n64.d: New test. * testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d: New test. * testsuite/binutils-all/mips/global-local-symtab-final-o32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-final-n32.d: New test. * testsuite/binutils-all/mips/global-local-symtab-final-n64.d: New test. * testsuite/binutils-all/mips/mips.exp: Run the new tests. gas/ * testsuite/gas/mips/global-local-symtab-sort-o32.d: New test. * testsuite/gas/mips/global-local-symtab-sort-o32t.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n32.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n32t.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n64.d: New test. * testsuite/gas/mips/global-local-symtab-sort-n64t.d: New test. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-elf/sec64k.exp: Also accept a section symbol with a name. * testsuite/ld-mips-elf/global-local-symtab-sort-o32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n64.d: New test. * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: New test. * testsuite/ld-mips-elf/global-local-symtab-final-o32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-final-n32.d: New test. * testsuite/ld-mips-elf/global-local-symtab-final-n64.d: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog24
-rw-r--r--ld/testsuite/ld-elf/sec64k.exp2
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d6
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d6
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d13
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d13
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d13
-rw-r--r--ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d13
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp6
12 files changed, 113 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 96edfb3..6b619f2 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,29 @@
2020-07-29 Maciej W. Rozycki <macro@linux-mips.org>
+ * testsuite/ld-elf/sec64k.exp: Also accept a section symbol with
+ a name.
+ * testsuite/ld-mips-elf/global-local-symtab-sort-o32.d: New
+ test.
+ * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: New
+ test.
+ * testsuite/ld-mips-elf/global-local-symtab-sort-n32.d: New
+ test.
+ * testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d: New
+ test.
+ * testsuite/ld-mips-elf/global-local-symtab-sort-n64.d: New
+ test.
+ * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: New
+ test.
+ * testsuite/ld-mips-elf/global-local-symtab-final-o32.d: New
+ test.
+ * testsuite/ld-mips-elf/global-local-symtab-final-n32.d: New
+ test.
+ * testsuite/ld-mips-elf/global-local-symtab-final-n64.d: New
+ test.
+ * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
+
+2020-07-29 Maciej W. Rozycki <macro@linux-mips.org>
+
* testsuite/ld-mips-elf/global-local-symtab-o32.d: New test.
* testsuite/ld-mips-elf/global-local-symtab-o32t.d: New test.
* testsuite/ld-mips-elf/global-local-symtab-n32.d: New test.
diff --git a/ld/testsuite/ld-elf/sec64k.exp b/ld/testsuite/ld-elf/sec64k.exp
index 7c85979..f17a118 100644
--- a/ld/testsuite/ld-elf/sec64k.exp
+++ b/ld/testsuite/ld-elf/sec64k.exp
@@ -145,7 +145,7 @@ if { ![istarget "m32r-*-*"] } then {
puts $ofd " \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
puts $ofd " \\\[65280\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
puts $ofd "#..."
- puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... "
+ 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 "#..."
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d
new file mode 100644
index 0000000..4110577
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d
@@ -0,0 +1,6 @@
+#name: MIPS symbol table sort and section symbol names (fully linked) (n32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -e 0 -T global-local-symtab.ld
+#readelf: -sW
+#dump: global-local-symtab-sort-o32t.d
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d b/ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d
new file mode 100644
index 0000000..6e14ee9
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d
@@ -0,0 +1,6 @@
+#name: MIPS symbol table sort and section symbol names (fully linked) (n64)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -e 0 -T global-local-symtab.ld
+#readelf: -sW
+#dump: global-local-symtab-sort-n64t.d
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d
new file mode 100644
index 0000000..4110577
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d
@@ -0,0 +1,6 @@
+#name: MIPS symbol table sort and section symbol names (fully linked) (n32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -e 0 -T global-local-symtab.ld
+#readelf: -sW
+#dump: global-local-symtab-sort-o32t.d
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d
new file mode 100644
index 0000000..3ea40b5
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d
@@ -0,0 +1,6 @@
+#name: MIPS symbol table sort and section symbol names (relocatable) (n32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -sW
+#dump: global-local-symtab-sort-o32.d
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d
new file mode 100644
index 0000000..0d14ddc
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d
@@ -0,0 +1,6 @@
+#name: MIPS symbol table sort and section symbol names (relocatable) (n32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -sW
+#dump: global-local-symtab-sort-o32t.d
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d
new file mode 100644
index 0000000..6491bca
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d
@@ -0,0 +1,13 @@
+#name: MIPS symbol table sort and section symbol names (relocatable) (n64)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -sW
+
+Symbol table '\.symtab' contains 5 entries:
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+ 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 \.data
+ 2: 0000000000000000 0 FILE LOCAL DEFAULT ABS tmpdir/global-local-symtab\.o
+ 3: 0000000000000004 4 OBJECT LOCAL DEFAULT 1 bar
+ 4: 0000000000000000 4 OBJECT GLOBAL DEFAULT 1 foo
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d
new file mode 100644
index 0000000..90d37ec2
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d
@@ -0,0 +1,13 @@
+#name: MIPS symbol table sort and section symbol names (relocatable) (n64)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -sW
+
+Symbol table '\.symtab' contains 5 entries:
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+ 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1
+ 2: 0000000000000000 0 FILE LOCAL DEFAULT ABS tmpdir/global-local-symtab\.o
+ 3: 0000000000000004 4 OBJECT LOCAL DEFAULT 1 bar
+ 4: 0000000000000000 4 OBJECT GLOBAL DEFAULT 1 foo
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d
new file mode 100644
index 0000000..1e6ff20
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d
@@ -0,0 +1,13 @@
+#name: MIPS symbol table sort and section symbol names (relocatable) (n32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -sW
+
+Symbol table '\.symtab' contains 5 entries:
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
+ 1: 00000000 0 SECTION LOCAL DEFAULT 1 \.data
+ 2: 00000000 0 FILE LOCAL DEFAULT ABS tmpdir/global-local-symtab\.o
+ 3: 00000004 4 OBJECT LOCAL DEFAULT 1 bar
+ 4: 00000000 4 OBJECT GLOBAL DEFAULT 1 foo
diff --git a/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d
new file mode 100644
index 0000000..9e7ceaa
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d
@@ -0,0 +1,13 @@
+#name: MIPS symbol table sort and section symbol names (relocatable) (n32)
+#source: ../../../gas/testsuite/gas/mips/global-local-symtab.s
+#as: -mno-pdr
+#ld: -r -T global-local-symtab.ld
+#readelf: -sW
+
+Symbol table '\.symtab' contains 5 entries:
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
+ 1: 00000000 0 SECTION LOCAL DEFAULT 1
+ 2: 00000000 0 FILE LOCAL DEFAULT ABS tmpdir/global-local-symtab\.o
+ 3: 00000004 4 OBJECT LOCAL DEFAULT 1 bar
+ 4: 00000000 4 OBJECT GLOBAL DEFAULT 1 foo
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 4b257c3..388fbd3 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -1663,3 +1663,9 @@ run_dump_test_o32 "reloc-pcrel-r6"
run_dump_test_o32 "global-local-symtab-o32${tmips}"
run_dump_test_n32 "global-local-symtab-n32${tmips}"
run_dump_test_n64 "global-local-symtab-n64"
+run_dump_test_o32 "global-local-symtab-sort-o32${tmips}"
+run_dump_test_n32 "global-local-symtab-sort-n32${tmips}"
+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"