diff options
author | Alan Modra <amodra@gmail.com> | 2017-01-24 08:43:01 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-01-24 12:15:54 +1030 |
commit | f0158f44168c29338e0b4424c69589f79bf58b19 (patch) | |
tree | 6dc86299e189f17a526e41b275c1be42d303a391 /bfd/ChangeLog | |
parent | 741bcbe94d7811caa1efa500dacd047c428cce61 (diff) | |
download | gdb-f0158f44168c29338e0b4424c69589f79bf58b19.zip gdb-f0158f44168c29338e0b4424c69589f79bf58b19.tar.gz gdb-f0158f44168c29338e0b4424c69589f79bf58b19.tar.bz2 |
PowerPC dynamic relocations
This patch fixes a number of issues with powerpc dynamic relocations.
1) Both ppc and ppc64 were emitting more dynamic symbols and
relocations than necessary, due to not supporting static linker
resolution of tls_index entries for __tls_get_addr_opt. This meant
that any @got@tlsgd or @got@tlsld reloc needed to make their symbols
dynamic and generate dptmod and dtprel relocs for the dynamic linker.
That would have been passable, but what happened was that practically
all @got relocations resulted in their symbols being made dynamic and
dynamic relocations emitted against the GOT entries. (Mostly visible
on ppc32 executables since ppc64 gcc really only uses @got style
relocs for TLS.)
2) The PowerOpen syntax was not supported with __tls_get_addr_opt.
DTPMOD/DTPREL relocs on tls_index TOC entries did not use the trick of
forcing dynamic symbols and relocations so those entries always
resulted in the full __tls_get_addr processing. gcc doesn't use the
PowerOpen syntax for TLS, and normally such code would be optimized to
TLS IE or LE so the impact of missing this support was minimal.
3) In an executable, relocations against GNU indirect functions always
used the value of their PLT stub. While this is correct, it is
better in some cases to use a dynamic relocation. An extra dynamic
relocation can mean that calls via function pointers need not bounce
through the PLT stub at runtime.
The patch also tidies the PLT handling code in ppc32
allocate_dynrelocs. Allocating PLT entries after other dynamic relocs
allows the PLT loop to omit special handling for undefined weak
symbols, and that in turn allows the loop to be simplified.
bfd/
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Merge two cases
where dynamic relocs are preferable. Allow ifunc too.
(ensure_undefweak_dynamic): New function.
(allocate_dynrelocs): Use it here. Move plt handling last and
don't make symbols dynamic, simplifying loop. Only make undef
weak symbols with GOT entries dynamic. Correct condition
for GOT relocs. Handle dynamic relocs on ifuncs. Correct
comments. Remove goto.
(ppc_elf_relocate_section): Correct test for using dynamic
symbol on GOT relocs. Rearrange test for emitting GOT relocs
to suit. Set up explicit tls_index entries and implicit GOT
tls_index entries resolvable at link time for
__tls_get_addr_opt. Simplify test to clear mem for prelink.
* elf64-ppc.c (allocate_got): Correct condition for GOT relocs.
(ensure_undefweak_dynamic): New function.
(allocate_dynrelocs): Use it here. Only make undef weak symbols
with GOT entries dynamic. Remove unnecessary test of
WILL_CALL_FINISH_DYNAMIC_SYMBOL in PLT handling.
(ppc64_elf_relocate_section): Correct test for using dynamic
symbol on GOT relocs. Rearrange test for emitting GOT relocs
to suit. Set up explicit tls_index entries and implicit GOT
tls_index entries resolvable at link time for __tls_get_addr_opt.
Simplify expression to clear mem for prelink.
ld/
* testsuite/ld-powerpc/tlsexe.r: Update for fewer dynamic relocs
and symbols.
* testsuite/ld-powerpc/tlsexe.d: Likewise.
* testsuite/ld-powerpc/tlsexe.g: Likewise.
Diffstat (limited to 'bfd/ChangeLog')
-rw-r--r-- | bfd/ChangeLog | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 857f57a..5102221 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,29 @@ +2017-01-24 Alan Modra <amodra@gmail.com> + + * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Merge two cases + where dynamic relocs are preferable. Allow ifunc too. + (ensure_undefweak_dynamic): New function. + (allocate_dynrelocs): Use it here. Move plt handling last and + don't make symbols dynamic, simplifying loop. Only make undef + weak symbols with GOT entries dynamic. Correct condition + for GOT relocs. Handle dynamic relocs on ifuncs. Correct + comments. Remove goto. + (ppc_elf_relocate_section): Correct test for using dynamic + symbol on GOT relocs. Rearrange test for emitting GOT relocs + to suit. Set up explicit tls_index entries and implicit GOT + tls_index entries resolvable at link time for + __tls_get_addr_opt. Simplify test to clear mem for prelink. + * elf64-ppc.c (allocate_got): Correct condition for GOT relocs. + (ensure_undefweak_dynamic): New function. + (allocate_dynrelocs): Use it here. Only make undef weak symbols + with GOT entries dynamic. Remove unnecessary test of + WILL_CALL_FINISH_DYNAMIC_SYMBOL in PLT handling. + (ppc64_elf_relocate_section): Correct test for using dynamic + symbol on GOT relocs. Rearrange test for emitting GOT relocs + to suit. Set up explicit tls_index entries and implicit GOT + tls_index entries resolvable at link time for __tls_get_addr_opt. + Simplify expression to clear mem for prelink. + 2017-01-23 Yury Norov <ynorov@caviumnetworks.com> * elfnn-aarch64.c: Fix relaxations for ILP32 mode. |