TLS on x86-64 question..
Andreas Jaeger
aj@suse.de
Fri Sep 5 11:21:00 GMT 2003
Jakub Jelinek <jakub@redhat.com> writes:
> On Fri, Sep 05, 2003 at 11:57:56AM +0200, Andreas Jaeger wrote:
>>
>> If I compile the following small program on x86-64 (with either GCC
>> 3.3 CVS, GCC 3.3 hammer-branch CVS or 3.4 CVS) I get the following
>> error:
>>
>> $ /opt/gcc/3.3-devel/bin/gcc -g -c tls.c -o tls.o -fPIC -ftls-model=local-exec
>> $ /opt/gcc/3.3-devel/bin/gcc -g -o tls.so -shared tls.o
>> /usr/bin/ld: tls.o: relocation R_X86_64_TPOFF32 can not be used when making a shared object; recompile with -fPIC
>> tls.o: could not read symbols: Bad value
>> collect2: ld returned 1 exit status
>>
>> The program is:
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> static __thread int foo;
>>
>> int getTLSVar(void)
>> {
>> return foo;
>> }
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> This works fine on other platforms, e.g. i386.
>>
>> Jakub, any ideas on this one?
>
> local-exec is not supported in shared libraries on x86_64 (well, it is not
> supported on most arches).
In that case shouldn't gcc already reject the combination -fPIC
-ftls-model=local-exec?
> It is the same thing as supporting -fno-pic code in shared libraries
> - local-exec would mean TLS relocations against .text segment.
Ok, understood.
Thanks for the explanation,
Andreas
--
Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
SuSE Linux AG, Deutschherrnstr. 15-19, 90429 Nürnberg, Germany
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20030905/0b73cd3e/attachment.sig>
More information about the Binutils
mailing list