]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
PR22978, TLS local-dynamic incorrectly linked on hppa-linux
authorAlan Modra <amodra@gmail.com>
Thu, 19 Apr 2018 01:49:35 +0000 (11:19 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 20 Apr 2018 13:28:28 +0000 (22:58 +0930)
commit4352556b36ab4f1c6f81a0ac3daf4619a419558d
treea305d1cdea77d3a14b25c908c94656c057ec6648
parent1a1de166f4e18227760b42301e3b615d71a62dc8
PR22978, TLS local-dynamic incorrectly linked on hppa-linux

We were emitting dynamic relocs on the second word of a TLS GD GOT
entry pair (the dtprel offset), without the addend necessary when no
symbol is present on the dynamic reloc.  Unfortunately the simple
solution of providing the proper addend doesn't work due to an hppa
glibc ld.so bug that ignores such addends.  So instead optimize the
relocs.  The dtprel offset is known at link time for locally defined
symbols (the only case where we'll end up with no symbol on a dynamic
reloc) so we can omit the dynamic reloc in that case.

Furthermore, we can omit a dynamic reloc on the first word of a TLS GD
GOT entry pair (the module id) if the symbol is local and we are
producing an executable.  Similarly, a tprel reloc on a TLS IE GOT
entry is not needed for local symbols in an executable.  So the
condition for TLS GOT relocs can become bfd_link_dll(info) rather than
bfd_link_pic(info) as needed for normal GOT relocs.

This all presumes hppa ld.so doesn't need to differentiate TLS GD GOT
pairs from TLS LD GOT pairs, which is currently true.

PR 22978
* elf32-hppa.c (got_relocs_needed): Add extra param to special
case both dtprel and tprel relocs.
(allocate_dynrelocs): Adjust conditions for got relocs.
(elf32_hppa_relocate_section): Likewise for local sym got relocs.
Emit dynamic relocs on TLS GOT entries for shared libraries,
not when pic.  Omit dynamic reloc on dtprel entry when local,
and on tprel entry when local and executable.
bfd/ChangeLog
bfd/elf32-hppa.c