powerpc __tls_get_addr call optimization
Carlos O'Donell
carlos@redhat.com
Wed Mar 18 17:07:00 GMT 2015
On 03/18/2015 02:11 AM, Alan Modra wrote:
> Now that Alex's fixes for static TLS have gone in, I figure it's worth
> revisiting an old patch of mine.
> https://sourceware.org/ml/libc-alpha/2009-03/msg00053.html
I'm not against this patch, but it certainly seems like you would be
better served by just implementing tls descriptors?
Do you have a reference to the binutils patch?
> This patch is glibc support for a PowerPC TLS optimization, inspired
> by Alexandre Oliva's TLS optimization for other processors,
> http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt
>
> In essence, this optimization uses a zero module id in the TLS
> descriptor to indicate that a TLS variable is allocated space in the
> static TLS area. A special plt call linker stub for __tls_get_addr
> checks for such a TLS descriptor and if found, returns the offset
> immediately. The linker communicates the fact that the special
> __tls_get_addr stub is present by setting a bit in the dynamic tag
> DT_PPC64_OPT/DT_PPC_OPT.
I'm confused, you write "TLS descriptor" but power doesn't have TLS DESC
support yet in glibc?
The code in question writes a module id of zero into the GOT entry
associated with the TLS variable, not really the TLS descriptor?
Speaking of which, you wouldn't happen to have a Latex contribution
that describes the Power TLS support so I can add it to and update
tls.pdf? :-)
> tst-tlsmod2.so is built with -Wl,--no-tls-get-addr-optimize for
> tst-tls-dlinfo, which otherwise would fail since it tests that no
> static tls is allocated. The ld option --no-tls-get-addr-optimize has
> been available since binutils-2.20 so doesn't need a configure test.
OK.
> Regression tested powerpc-linux and powerpc64-linux.
>
> * NEWS: Advertise TLS optimization.
> * elf/elf.h (R_PPC_TLSGD, R_PPC_TLSLD, DT_PPC_OPT, PPC_OPT_TLS): Define.
> (DT_PPC_NUM): Increment.
> * elf/dynamic-link.h (HAVE_STATIC_TLS): Define, extracted from..
> (CHECK_STATIC_TLS): ..here.
> * sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela): Optimize
> TLS descriptors.
> * sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Likewise.
> * sysdeps/powerpc/dl-tls.c: New file.
> * sysdeps/powerpc/Versions: Add __tls_get_addr_opt.
> * sysdeps/unix/sysv/linux/powerpc/Makefile: Build tst-tlsmod2.so
> with --no-tls-get-addr-optimize.
> * sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist: Update.
> * sysdeps/unix/sysv/linux/powerpc/powerpc64/ld.abilist: Likewise.
> * sysdeps/unix/sysv/linux/powerpc/powerpc64/ld-le.abilist: Likewise.
This absolutely needs a new ppc64-specific test case to make sure this is
actually working as intended? If it requires a new binutils, then you'll need
to have the test return 77 (UNSUPPORTED) if the present binutils is not new
enough.
The rest looks fine.
Cheers,
Carlos.
More information about the Libc-alpha
mailing list