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.