PR22978, TLS local-dynamic incorrectly linked on hppa-linux

Carlos O'Donell carlos@redhat.com
Fri Apr 20 15:55:00 GMT 2018


On 04/20/2018 08:49 AM, Alan Modra wrote:
> 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.

This looks reasonable, but if we could fix the ld.so bug that would also
be good!

How did you test this fix? Sometimes changes like this have surprises,
and I would test it but my box is currently inaccessible and needs some
cleanup.

I've included Dave on the TO, to see if he's interested in testing this
a little more widely.

-- 
Cheers,
Carlos.



More information about the Binutils mailing list