[PATCH] Fix i386 GD->IE TLS transition

H. J. Lu hjl@lucon.org
Fri Jun 23 17:34:00 GMT 2006


On Fri, Jun 23, 2006 at 09:26:52AM -0700, H. J. Lu wrote:
> On Fri, Jun 23, 2006 at 04:00:51PM +0200, Jakub Jelinek wrote:
> > Hi!
> > 
> > #!/bin/sh
> > CFLAGS="-g -m32 -O2"
> > gcc $CFLAGS -fpic -c -o a.o -xc - <<EOF
> > extern __thread int data; extern int *foo (void); extern void abort (void);
> > int main (void) { if (foo () != &data) abort (); return 0; }
> > EOF
> > gcc $CFLAGS -c -o b.o -xc - <<EOF
> > extern __thread int data;
> > int *foo (void) { return &data; }
> > EOF
> > echo '__thread int data;' | gcc $CFLAGS -c -o c.o -xc -
> > gcc $CFLAGS -Wl,--export-dynamic -o test a.o b.o c.o
> > ./test; echo $?
> > 
> > is mis-linked, as the GOT slot contains R_386_TPOFF value (0xfffffffc),
> > but the code in main subtracts this value from %gs:0 rather than adds to it.
> > 
> > Apparently H.J. was trying to fix this two months ago, but the fix was both
> > insufficient and flawed.
> 
> I can't duplicate the failure with the testcase above.

The correct testcase is ld-i386/tlsbin.dd. The patch looks good to me.


H.J.



More information about the Binutils mailing list