This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: powerpc __tls_get_addr call optimization

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)

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

 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

Alan Modra
Australia Development Lab, IBM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]