This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: powerpc __tls_get_addr call optimization
- From: Alan Modra <amodra at gmail dot com>
- To: Rich Felker <dalias at libc dot org>
- Cc: Carlos O'Donell <carlos at redhat dot com>, libc-alpha at sourceware dot org
- Date: Sat, 21 Mar 2015 18:03:32 +1030
- Subject: Re: powerpc __tls_get_addr call optimization
- Authentication-results: sourceware.org; auth=none
- References: <20150318061145 dot GE24573 at bubble dot grove dot modra dot org> <5509B0D4 dot 2020903 at redhat dot com> <20150319025631 dot GC28603 at bubble dot grove dot modra dot org> <550B94FC dot 3070903 at redhat dot com> <20150320075502 dot GC26234 at bubble dot grove dot modra dot org> <20150320152712 dot GK23507 at brightrain dot aerifal dot cx> <20150321030702 dot GD26234 at bubble dot grove dot modra dot org> <20150321043630 dot GX23507 at brightrain dot aerifal dot cx>
On Sat, Mar 21, 2015 at 12:36:30AM -0400, Rich Felker wrote:
> On Sat, Mar 21, 2015 at 01:37:02PM +1030, Alan Modra wrote:
> > On Fri, Mar 20, 2015 at 11:27:12AM -0400, Rich Felker wrote:
> > > I also don't see how your approach is a "direct call". The function
> > > being called is in a different DSO so it has to go through a pointer
> > > in the GOT or similar, in which case it's just as "indirect" as the
> > > TLSDESC call would be.
> >
> > It is a direct call to the linker provided stub, which will return
> > after a few instructions in the optimized case when static TLS is
> > available.
>
> That linker-provided stub address is loaded from a "GOT slot" of some
> sort,
No, it really is a direct call. The linker provided stub is local.
This ppc64 elfv2 GD sequence in a relocatable object file
addi r3,r2,x@got@tlsgd
bl __tls_get_addr(x@tlsgd)
nop
results in shared library code of
addi r3,r2,x@got@tlsgd # r3 -> tls_index entry in GOT
bl __tls_get_addr_opt_stub # direct call
nop
.
.
__tls_get_addr_opt_stub:
ld r11,0(r3) # tls_index->ti_module
ld r12 8(r3) # tls_index->ti_offset
mr r0,r3
cmpdi r11,0
add r3,r12,r13 # r13 == thread pointer
beqlr # return if static TLS allocated
mr r3,r0
mflr r11
std r11, 8(r1)
std r2 24(r1)
addis r12,r2,__tls_get_addr_opt@plt@ha
ld r12, __tls_get_addr_opt@plt@l(r12)
mtctr r12
bctrl # call __tls_get_addr_opt
ld r2,24(r1)
ld r11,8(r1)
mtlr r11
blr
--
Alan Modra
Australia Development Lab, IBM