This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [rs6000/rfc] -fPIC vs TLS


On Fri, Mar 10, 2006 at 07:05:55AM -0800, Richard Henderson wrote:
> On Fri, Mar 10, 2006 at 02:41:50PM +1030, Alan Modra wrote:
> > You don't necessarily have any sort of GOT pointer around at
> > the point we emit that sequence.
> 
> Um... we don't?  It sure looks like we do.  The patch I 
> sent does in fact seem to work.  When will it fail?

static __thread int x;

int foo (void)
{
  return x;
}

-m32 -O2 -S -fPIC yields

foo:
        mflr 0
        stwu 1,-16(1)
        bcl 20,31,$+8
        .long _GLOBAL_OFFSET_TABLE_-$
        mflr 3
        stw 0,20(1)
        nop
        nop
        lwz 0,0(3)
        stw 30,8(1)
        add 3,3,0
        addi 3,3,x@got@tlsld
        bl __tls_get_addr@plt
        lwz 0,20(1)
        lwz 30,8(1)
        addi 1,1,16
        addis 3,3,x@dtprel@ha
        addi 3,3,x@dtprel@l
        mtlr 0
        lwz 3,0(3)
        blr

Note lack of usual GOT pointer load in function prologue.  Oh.  Hmm,
this is -mbss-plt.  -msecure-plt does in fact get you a GOT pointer.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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