2016-05-11 20:24:05 +08:00
|
|
|
#source: tlsopt5.s
|
|
|
|
#as: -a64
|
2017-07-14 17:07:26 +08:00
|
|
|
#ld: -shared --gc-sections --no-plt-localentry tlsdll.so
|
2016-05-11 20:24:05 +08:00
|
|
|
#objdump: -dr
|
|
|
|
#target: powerpc64*-*-*
|
|
|
|
|
|
|
|
.*
|
|
|
|
|
|
|
|
Disassembly of section \.text:
|
|
|
|
|
2018-08-01 10:44:22 +08:00
|
|
|
.* <.*\.plt_call\.foo>:
|
|
|
|
.*: (18 00 41 f8|f8 41 00 18) std r2,24\(r1\)
|
|
|
|
.*: (28 80 82 e9|e9 82 80 28) ld r12,-32728\(r2\)
|
|
|
|
.*: (a6 03 89 7d|7d 89 03 a6) mtctr r12
|
|
|
|
.*: (20 04 80 4e|4e 80 04 20) bctr
|
|
|
|
\.\.\.
|
|
|
|
|
2017-08-06 20:34:25 +08:00
|
|
|
.* <.*\.plt_call\.__tls_get_addr_opt@@GLIBC_2\.22>:
|
2016-05-11 20:24:05 +08:00
|
|
|
.*: (00 00 63 e9|e9 63 00 00) ld r11,0\(r3\)
|
|
|
|
.*: (08 00 83 e9|e9 83 00 08) ld r12,8\(r3\)
|
|
|
|
.*: (78 1b 60 7c|7c 60 1b 78) mr r0,r3
|
|
|
|
.*: (00 00 2b 2c|2c 2b 00 00) cmpdi r11,0
|
|
|
|
.*: (14 6a 6c 7c|7c 6c 6a 14) add r3,r12,r13
|
2019-04-05 06:50:16 +08:00
|
|
|
.*: (20 00 82 4d|4d 82 00 20) beqlr
|
2016-05-11 20:24:05 +08:00
|
|
|
.*: (78 03 03 7c|7c 03 03 78) mr r3,r0
|
|
|
|
.*: (a6 02 68 7d|7d 68 02 a6) mflr r11
|
|
|
|
.*: (08 00 61 f9|f9 61 00 08) std r11,8\(r1\)
|
|
|
|
.*: (18 00 41 f8|f8 41 00 18) std r2,24\(r1\)
|
2018-08-01 10:44:22 +08:00
|
|
|
.*: (30 80 82 e9|e9 82 80 30) ld r12,-32720\(r2\)
|
2016-05-11 20:24:05 +08:00
|
|
|
.*: (a6 03 89 7d|7d 89 03 a6) mtctr r12
|
|
|
|
.*: (21 04 80 4e|4e 80 04 21) bctrl
|
|
|
|
.*: (18 00 41 e8|e8 41 00 18) ld r2,24\(r1\)
|
|
|
|
.*: (08 00 61 e9|e9 61 00 08) ld r11,8\(r1\)
|
|
|
|
.*: (a6 03 68 7d|7d 68 03 a6) mtlr r11
|
|
|
|
.*: (20 00 80 4e|4e 80 00 20) blr
|
2018-08-01 10:44:22 +08:00
|
|
|
\.\.\.
|
2016-05-11 20:24:05 +08:00
|
|
|
|
2017-08-06 20:34:25 +08:00
|
|
|
.* <_start>:
|
2016-05-11 20:24:05 +08:00
|
|
|
.*: (08 80 62 38|38 62 80 08) addi r3,r2,-32760
|
2018-08-01 10:44:22 +08:00
|
|
|
.*: (9d ff ff 4b|4b ff ff 9d) bl .* <.*\.plt_call\.__tls_get_addr_opt@@GLIBC_2\.22>
|
|
|
|
.*: (00 00 00 60|60 00 00 00) nop
|
|
|
|
.*: (75 ff ff 4b|4b ff ff 75) bl .* <.*\.plt_call\.foo>
|
|
|
|
.*: (18 00 41 e8|e8 41 00 18) ld r2,24\(r1\)
|
2016-05-11 20:24:05 +08:00
|
|
|
.*: (00 00 00 60|60 00 00 00) nop
|
2017-08-06 20:34:25 +08:00
|
|
|
.*
|
|
|
|
.*
|
2016-05-11 20:24:05 +08:00
|
|
|
|
2017-08-06 20:34:25 +08:00
|
|
|
.* <__glink_PLTresolve>:
|
2016-05-11 20:24:05 +08:00
|
|
|
.*: (a6 02 08 7c|7c 08 02 a6) mflr r0
|
|
|
|
.*: (05 00 9f 42|42 9f 00 05) bcl .*
|
|
|
|
.*: (a6 02 68 7d|7d 68 02 a6) mflr r11
|
PPC64_OPT_LOCALENTRY
ELFv2 functions with localentry:0 are those with a single entry point,
ie. global entry == local entry, and that have no requirement on r2 or
r12, and guarantee r2 is unchanged on return. Such an external
function can be called via the PLT without saving r2 or restoring it
on return, avoiding a common load-hit-store for small functions. The
optimization is attractive. The TOC pointer load-hit-store is a major
reason why calls to small functions that need no register saves, or
with shrink-wrap, no register saves on a fast path, are slow on
powerpc64le.
To be safe, this optimization needs ld.so support to check that the
run-time matches link-time function implementation. If a function
in a shared library with st_other localentry non-zero is called
without saving and restoring r2, r2 will be trashed on return, leading
to segfaults. For that reason the optimization does not happen for
weak functions since a weak definition is a fairly solid hint that the
function will likely be overridden. I'm also not enabling the
optimization by default unless glibc-2.26 is detected, which should
have the ld.so checks implemented.
bfd/
* elf64-ppc.c (struct ppc_link_hash_table): Add has_plt_localentry0.
(ppc64_elf_merge_symbol_attribute): Merge localentry bits from
dynamic objects.
(is_elfv2_localentry0): New function.
(ppc64_elf_tls_setup): Default params->plt_localentry0.
(plt_stub_size): Adjust size for tls_get_addr_opt stub.
(build_tls_get_addr_stub): Use a simpler stub when r2 is not saved.
(ppc64_elf_size_stubs): Leave stub_type as ppc_stub_plt_call for
optimized localentry:0 stubs.
(ppc64_elf_build_stubs): Save r2 in ELFv2 __glink_PLTresolve.
(ppc64_elf_relocate_section): Leave nop unchanged for optimized
localentry:0 stubs.
(ppc64_elf_finish_dynamic_sections): Set PPC64_OPT_LOCALENTRY in
DT_PPC64_OPT.
* elf64-ppc.h (struct ppc64_elf_params): Add plt_localentry0.
include/
* elf/ppc64.h (PPC64_OPT_LOCALENTRY): Define.
ld/
* emultempl/ppc64elf.em (params): Init plt_localentry0 field.
(enum ppc64_opt): New, replacing OPTION_* defines. Add
OPTION_PLT_LOCALENTRY, and OPTION_NO_PLT_LOCALENTRY.
(PARSE_AND_LIST_*): Support --plt-localentry and --no-plt-localentry.
* testsuite/ld-powerpc/elfv2so.d: Update.
* testsuite/ld-powerpc/powerpc.exp (TLS opt 5): Use --no-plt-localentry.
* testsuite/ld-powerpc/tlsopt5.d: Update.
2017-05-26 08:32:29 +08:00
|
|
|
.*: (18 00 41 f8|f8 41 00 18) std r2,24\(r1\)
|
2016-05-11 20:24:05 +08:00
|
|
|
.*: (f0 ff 4b e8|e8 4b ff f0) ld r2,-16\(r11\)
|
|
|
|
.*: (a6 03 08 7c|7c 08 03 a6) mtlr r0
|
|
|
|
.*: (50 60 8b 7d|7d 8b 60 50) subf r12,r11,r12
|
|
|
|
.*: (14 5a 62 7d|7d 62 5a 14) add r11,r2,r11
|
|
|
|
.*: (d0 ff 0c 38|38 0c ff d0) addi r0,r12,-48
|
|
|
|
.*: (00 00 8b e9|e9 8b 00 00) ld r12,0\(r11\)
|
|
|
|
.*: (82 f0 00 78|78 00 f0 82) rldicl r0,r0,62,2
|
|
|
|
.*: (a6 03 89 7d|7d 89 03 a6) mtctr r12
|
|
|
|
.*: (08 00 6b e9|e9 6b 00 08) ld r11,8\(r11\)
|
|
|
|
.*: (20 04 80 4e|4e 80 04 20) bctr
|
|
|
|
|
2018-08-01 10:44:22 +08:00
|
|
|
.* <foo@plt>:
|
|
|
|
.* (c8 ff ff 4b|4b ff ff c8) b .*
|
|
|
|
|
2017-08-06 20:34:25 +08:00
|
|
|
.* <__tls_get_addr_opt@plt>:
|
2018-08-01 10:44:22 +08:00
|
|
|
.*: (c4 ff ff 4b|4b ff ff c4) b .*
|