MIPS: Make the IRIX naming of local section symbols consistent
authorMaciej W. Rozycki <macro@linux-mips.org>
Wed, 29 Jul 2020 19:56:41 +0000 (20:56 +0100)
committerMaciej W. Rozycki <macro@linux-mips.org>
Wed, 29 Jul 2020 19:56:41 +0000 (20:56 +0100)
commitc77cb2a09c5532ad6d3b94fccca93eb02f7cc0d8
tree5e87c11662315d54ec03da8e49e5d828a5608a1f
parent3f1b17bbf022a34f92f3dc32d742e4901816708e
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.
34 files changed:
bfd/ChangeLog
bfd/elflink.c
bfd/elfxx-mips.c
binutils/ChangeLog
binutils/testsuite/binutils-all/mips/global-local-symtab-final-n32.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/global-local-symtab-final-n64.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/global-local-symtab-final-o32.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/mips.exp
gas/ChangeLog
gas/testsuite/gas/mips/global-local-symtab-sort-n32.d [new file with mode: 0644]
gas/testsuite/gas/mips/global-local-symtab-sort-n32t.d [new file with mode: 0644]
gas/testsuite/gas/mips/global-local-symtab-sort-n64.d [new file with mode: 0644]
gas/testsuite/gas/mips/global-local-symtab-sort-n64t.d [new file with mode: 0644]
gas/testsuite/gas/mips/global-local-symtab-sort-o32.d [new file with mode: 0644]
gas/testsuite/gas/mips/global-local-symtab-sort-o32t.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips.exp
ld/ChangeLog
ld/testsuite/ld-elf/sec64k.exp
ld/testsuite/ld-mips-elf/global-local-symtab-final-n32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/global-local-symtab-final-n64.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/global-local-symtab-final-o32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d [new file with mode: 0644]
ld/testsuite/ld-mips-elf/mips-elf.exp