PowerPC PIC vs. DLL TLS issues
authorAlan Modra <amodra@gmail.com>
Thu, 3 Oct 2019 23:18:41 +0000 (08:48 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 4 Oct 2019 13:23:56 +0000 (22:53 +0930)
commitf749f26eea052459c27e21d0d15f5fac060961dc
treea3f3e0e4355e7c712c31228440c20948c0e46e1b
parent9cb09e33e04feb12df2aaa6e81d61b82ad609ce5
PowerPC PIC vs. DLL TLS issues

1) GOT entries generated for any of the GOT TLS relocations don't need
dynamic relocations for locally defined symbols in PIEs.  In the case
of a tls_index doubleword, the dtpmod entry is known to be 1, and the
dtprel entry is also known at link time and relative.  Similarly,
dtprel and tprel words are known at link time and relative.  (GOT
entries for other than TLS symbols are not relative and thus need
dynamic relocations in PIEs.)
2) Local dynamic TLS code is really only meant for accesses local to
the current binary.  There was a cheapskate test for this before using
the common tlsld_got slot, but the test wasn't exactly correct and
might confuse anyone looking at the code.  The proper test,
SYMBOL_REFERENCES_LOCAL isn't so expensive that it should be avoided.
3) The same cheap test for local syms when optimising TLS sequences
should be SYMBOL_REFERENCES_LOCAL too.

bfd/
* elf64-ppc.c (ppc64_elf_check_relocs): Move initialisation of vars.
(ppc64_elf_tls_optimize): Correct is_local condition.
(allocate_got): Don't reserve dynamic relocations for any of the
tls got relocs in PIEs when the symbol is local.
(allocate_dynrelocs): Correct validity test for local sym using
tlsld_got slot.
(ppc64_elf_size_dynamic_sections): Don't reserve dynamic relocations
for any of the tls got relocs in PIEs.
(ppc64_elf_layout_multitoc): Likewise.
(ppc64_elf_relocate_section): Correct validity test for local sym
using tlsld_got slot.  Don't emit dynamic relocations for any of
the tls got relocs in PIEs when the symbol is local.
* elf32-ppc.c (ppc_elf_tls_optimize): Correct is_local condition.
(got_relocs_needed): Delete.
(allocate_dynrelocs): Correct validity test for local sym using
tlsld_got slot.  Don't reserve dynamic relocations for any of the
tls got relocs in PIEs when the symbol is local.
(ppc_elf_size_dynamic_sections): Don't reserve dynamic relocations
for any of the tls got relocs in PIEs.
(ppc_elf_relocate_section): Correct validity test for local sym
using tlsld_got slot.  Don't emit dynamic relocations for any of
the tls got relocs in PIEs when the symbol is local.
ld/
* testsuite/ld-powerpc/tlsso.d: Adjust to suit tlsld_got usage change.
* testsuite/ld-powerpc/tlsso.g: Likewise.
* testsuite/ld-powerpc/tlsso.r: Likewise.
* testsuite/ld-powerpc/tlsso32.d: Likewise.
* testsuite/ld-powerpc/tlsso32.g: Likewise.
* testsuite/ld-powerpc/tlsso32.r: Likewise.
bfd/ChangeLog
bfd/elf32-ppc.c
bfd/elf64-ppc.c
ld/ChangeLog
ld/testsuite/ld-powerpc/tlsso.d
ld/testsuite/ld-powerpc/tlsso.g
ld/testsuite/ld-powerpc/tlsso.r
ld/testsuite/ld-powerpc/tlsso32.d
ld/testsuite/ld-powerpc/tlsso32.g
ld/testsuite/ld-powerpc/tlsso32.r
This page took 0.028915 seconds and 4 git commands to generate.