aboutsummaryrefslogtreecommitdiff
path: root/binutils
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 /binutils
parent3f1b17bbf022a34f92f3dc32d742e4901816708e (diff)
downloadgdb-c77cb2a09c5532ad6d3b94fccca93eb02f7cc0d8.zip
gdb-c77cb2a09c5532ad6d3b94fccca93eb02f7cc0d8.tar.gz
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 'binutils')
-rw-r--r--binutils/ChangeLog22
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-final-n32.d9
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-final-n64.d9
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-final-o32.d9
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32.d8
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d8
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64.d14
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d14
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32.d14
-rw-r--r--binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d14
-rw-r--r--binutils/testsuite/binutils-all/mips/mips.exp6
11 files changed, 127 insertions, 0 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index a5efafc..4e66a13 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,27 @@
2020-07-29 Maciej W. Rozycki <macro@linux-mips.org>
+ * 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.
+
+2020-07-29 Maciej W. Rozycki <macro@linux-mips.org>
+
* testsuite/binutils-all/mips/global-local-symtab-o32.d: New
test.
* testsuite/binutils-all/mips/global-local-symtab-o32t.d: New
diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n32.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n32.d
new file mode 100644
index 0000000..0623ddc
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n32.d
@@ -0,0 +1,9 @@
+#PROG: objcopy
+#DUMPPROG: readelf
+#name: MIPS symbol table sort and section symbol names (fully linked) (n32)
+#as: -n32 -mno-pdr -mips3
+#ld: -e 0 -T ../../../../ld/testsuite/ld-mips-elf/global-local-symtab.ld
+#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab
+#readelf: -s
+#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s
+#dump: global-local-symtab-sort-o32t.d
diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n64.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n64.d
new file mode 100644
index 0000000..eaee008
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-n64.d
@@ -0,0 +1,9 @@
+#PROG: objcopy
+#DUMPPROG: readelf
+#name: MIPS symbol table sort and section symbol names (fully linked) (n64)
+#as: -64 -mno-pdr -mips3
+#ld: -e 0 -T ../../../../ld/testsuite/ld-mips-elf/global-local-symtab.ld
+#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab
+#readelf: -s
+#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s
+#dump: global-local-symtab-sort-n64t.d
diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-final-o32.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-o32.d
new file mode 100644
index 0000000..580acb0
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-final-o32.d
@@ -0,0 +1,9 @@
+#PROG: objcopy
+#DUMPPROG: readelf
+#name: MIPS symbol table sort and section symbol names (fully linked) (o32)
+#as: -32 -mno-pdr
+#ld: -e 0 -T ../../../../ld/testsuite/ld-mips-elf/global-local-symtab.ld
+#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab
+#readelf: -s
+#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s
+#dump: global-local-symtab-sort-o32t.d
diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32.d
new file mode 100644
index 0000000..818d791
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32.d
@@ -0,0 +1,8 @@
+#PROG: objcopy
+#DUMPPROG: readelf
+#name: MIPS symbol table sort and section symbol names (relocatable) (n32)
+#as: -n32 -mno-pdr -mips3
+#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab
+#readelf: -s
+#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s
+#dump: global-local-symtab-sort-o32.d
diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d
new file mode 100644
index 0000000..a6f6548
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d
@@ -0,0 +1,8 @@
+#PROG: objcopy
+#DUMPPROG: readelf
+#name: MIPS symbol table sort and section symbol names (relocatable) (n32)
+#as: -n32 -mno-pdr -mips3
+#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab
+#readelf: -s
+#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s
+#dump: global-local-symtab-sort-o32t.d
diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64.d
new file mode 100644
index 0000000..dcb5c23
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64.d
@@ -0,0 +1,14 @@
+#PROG: objcopy
+#DUMPPROG: readelf
+#name: MIPS symbol table sort and section symbol names (relocatable) (n64)
+#as: -64 -mno-pdr -mips3
+#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab
+#readelf: -s
+#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s
+
+Symbol table '\.symtab' contains 4 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: 0000000000000004 4 OBJECT LOCAL DEFAULT 1 bar
+ 3: 0000000000000000 4 OBJECT GLOBAL DEFAULT 1 foo
diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d
new file mode 100644
index 0000000..e38f789
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d
@@ -0,0 +1,14 @@
+#PROG: objcopy
+#DUMPPROG: readelf
+#name: MIPS symbol table sort and section symbol names (relocatable) (n64)
+#as: -64 -mno-pdr -mips3
+#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab
+#readelf: -s
+#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s
+
+Symbol table '\.symtab' contains 4 entries:
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+ 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1
+ 2: 0000000000000004 4 OBJECT LOCAL DEFAULT 1 bar
+ 3: 0000000000000000 4 OBJECT GLOBAL DEFAULT 1 foo
diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32.d
new file mode 100644
index 0000000..d46fccd
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32.d
@@ -0,0 +1,14 @@
+#PROG: objcopy
+#DUMPPROG: readelf
+#name: MIPS symbol table sort and section symbol names (relocatable) (o32)
+#as: -32 -mno-pdr
+#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab
+#readelf: -s
+#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s
+
+Symbol table '\.symtab' contains 4 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 4 OBJECT GLOBAL DEFAULT 1 foo
+ 3: 00000004 4 OBJECT LOCAL DEFAULT 1 bar
diff --git a/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d
new file mode 100644
index 0000000..d97322f
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d
@@ -0,0 +1,14 @@
+#PROG: objcopy
+#DUMPPROG: readelf
+#name: MIPS symbol table sort and section symbol names (relocatable) (o32)
+#as: -32 -mno-pdr
+#objcopy: -j .data -j .symtab -j .strtab -j .shstrtab
+#readelf: -s
+#source: ../../../../gas/testsuite/gas/mips/global-local-symtab.s
+
+Symbol table '\.symtab' contains 4 entries:
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
+ 1: 00000000 0 SECTION LOCAL DEFAULT 1
+ 2: 00000004 4 OBJECT LOCAL DEFAULT 1 bar
+ 3: 00000000 4 OBJECT GLOBAL DEFAULT 1 foo
diff --git a/binutils/testsuite/binutils-all/mips/mips.exp b/binutils/testsuite/binutils-all/mips/mips.exp
index eed1dd1..e304737 100644
--- a/binutils/testsuite/binutils-all/mips/mips.exp
+++ b/binutils/testsuite/binutils-all/mips/mips.exp
@@ -252,3 +252,9 @@ run_dump_test_n32 "mips-reginfo-n32"
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" useld
+run_dump_test_n32 "global-local-symtab-final-n32" useld
+run_dump_test_n64 "global-local-symtab-final-n64" useld