binutils-gdb/ld/testsuite/ld-mips-elf/pic-and-nonpic-3a.dd
Simon Atanasyan 3be08ea472 BFD: Prevent writing the MIPS _gp_disp symbol into symbol tables
The _gp_disp is a magic symbol, always implicitly defined by the linker.
It does not make a sense to write it into symbol tables for output files.
Moreover, now if the linker gets a version script, the _gp_disp symbol
gets zero version definition index.  The zero index means[1]:

"The symbol is local, not available outside the object."

But the _gp_disp symbol has GLOBAL binding.  That confuses some tools
like for example the LLD linker when they get such files as inputs.

This patch fixes the problem - it prevents writing the _gp_disp symbol
in regular and dynamic symbol tables.

This was tested by running LD test suite on a mipsel-linux board.

References:

[1] "Linux Standard Base Specification", Section "10.7.2 Symbol
    Version Table", p. 32

2018-05-03  Simon Atanasyan  <simon@atanasyan.com>

bfd/

	* elf32-mips.c: (elf32_mips_fixup_symbol): New function.
	(elf_backend_fixup_symbol): New macro.
	* elfxx-mips.c: (mips_elf_output_extsym): Discard _gp_disp
	handling.
	(_bfd_mips_elf_finish_dynamic_symbol): Likewise.

ld/

	* testsuite/ld-mips-elf/gp-disp-sym.d: New test.
	* testsuite/ld-mips-elf/gp-disp-sym.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
	* testsuite/ld-mips-elf/mips16-pic-2.ad: Update for _gp_disp
	symbol removal.
	* testsuite/ld-mips-elf/mips16-pic-2.nd: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-3a.dd: Likewise.
	* testsuite/ld-mips-elf/tlslib-o32-hidden.got: Likewise.
	* testsuite/ld-mips-elf/tlslib-o32-ver.got: Likewise.
	* testsuite/ld-mips-elf/tlslib-o32.got: Likewise.
2018-05-03 17:17:46 +01:00

40 lines
866 B
Plaintext

# GOT layout:
#
# -32752: lazy resolution function
# -32748: reserved for module pointer
# -32744: the GOT page entry
# -32740: foo's GOT entry
# -32736: ext's GOT entry
.*
Disassembly of section \.text:
00000800 <foo>:
800: 3c1c0001 lui gp,0x1
804: 279c7bf0 addiu gp,gp,31728
808: 0399e021 addu gp,gp,t9
80c: 8f99801c lw t9,-32740\(gp\)
810: 8f828018 lw v0,-32744\(gp\)
814: 03200008 jr t9
818: 24420000 addiu v0,v0,0
0000081c <bar>:
81c: f000 6a01 li v0,1
820: f3cf 0a10 la v0,83f0 .*
824: f400 3240 sll v0,16
828: e269 addu v0,v1
82a: f030 9a60 lw v1,-32736\(v0\)
82e: 659a move gp,v0
830: eb00 jr v1
832: 653b move t9,v1
#...
Disassembly of section \.MIPS\.stubs:
00000c00 <_MIPS_STUBS_>:
c00: 8f998010 lw t9,-32752\(gp\)
c04: 03e07825 move t7,ra
c08: 0320f809 jalr t9
c0c: 24180004 li t8,4
\.\.\.