[SPARC] Fix PR ld/22972
Eric Botcazou
ebotcazou@adacore.com
Thu Mar 22 16:34:00 GMT 2018
Hi,
this is a regression present on mainline and 2.30 branch for the corner case
of a hidden symbol in a PIC/PIE binary which is subject to both a new-style
GOTDATA relocation and an old-style GOT relocation. In this case, depending
on the link order, the R_SPARC_RELATIVE dynamic relocation for the GOT slot
needed because of the old-style relocation can be replaced with R_SPARC_NONE
coming from the GOTDATA relocation.
The attached patch simply records whether an old-style GOT relocation is seen
for a symbol and prevents the R_SPARC_NONE from being generated in this case.
Tested on SPARC64/Linux with a GCC bootstrap, OK for mainline and 2.30 branch?
2018-03-22 Eric Botcazou <ebotcazou@adacore.com>
PR ld/22972
bfd/
* elfxx-sparc.c (struct _bfd_sparc_elf_link_hash_entry): Add new flag
has_old_style_got_reloc.
(_bfd_sparc_elf_check_relocs) <GOT relocations>: Set it for old-style
relocations. Fix a couple of long lines.
(_bfd_sparc_elf_relocate_section) <R_SPARC_GOTDATA_OP>: Do not generate
a R_SPARC_NONE for the GOT slot if the symbol is also subject to old-style
GOT relocations.
ld/
* testsuite/ld-sparc/sparc.exp: Add test for mixed GOTDATA/GOT relocations.
* testsuite/ld-sparc/gotop-hidden.c: New file.
* testsuite/ld-sparc/got-hidden32.s: Likewise.
* testsuite/ld-sparc/got-hidden64.s: Likewise.
* testsuite/ld-sparc/pass.out: Likewise.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr22972.diff
Type: text/x-patch
Size: 5244 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180322/be93dc94/attachment.bin>
More information about the Binutils
mailing list