From c77cb2a09c5532ad6d3b94fccca93eb02f7cc0d8 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Wed, 29 Jul 2020 20:56:41 +0100 Subject: 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"), . 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. --- ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d | 6 ++++++ ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d | 6 ++++++ ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d | 6 ++++++ ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d | 6 ++++++ ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d | 6 ++++++ ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d | 13 +++++++++++++ ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d | 13 +++++++++++++ ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d | 13 +++++++++++++ ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d | 13 +++++++++++++ ld/testsuite/ld-mips-elf/mips-elf.exp | 6 ++++++ 10 files changed, 88 insertions(+) create mode 100644 ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d create mode 100644 ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d create mode 100644 ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d create mode 100644 ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d create mode 100644 ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d create mode 100644 ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d create mode 100644 ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d create mode 100644 ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d create mode 100644 ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d (limited to 'ld/testsuite/ld-mips-elf') 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" -- cgit v1.1