This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: TLS question


Alireza Moshtaghi <alireza.moshtaghi@ericsson.com> writes:

> STT_TLS is not set for my extern __thread symbol.
> and my linker ends up emitting:
>
> TLS definition in /tmp/cccF5k6P.o section .tbss mismatches non-TLS
> reference in /tmp/ccMzRAeS.o
>
> What is responsible for setting this flag? the compiler? or it is set
> while the elf is being read? I'm sure I have failed to implement
> something in my port.


(Please don't top-post.  Thanks.)

The STT_TLS symbol type is in the symbol table in the .o file--you can
see it using readelf -s.  Normally the assembler, which generates the .o
file, is responsible for setting this symbol type when it sees a
TLS-specific relocation applied to the symbol.

If you are using gas look for S_SET_THREAD_LOCAL.

Ian



> On Thu, 2012-03-22 at 14:53 -0400, Ian Lance Taylor wrote:
>> Alireza Moshtaghi <alireza.moshtaghi@ericsson.com> writes:
>> 
>> > An extern variable is defined as an UND symbol in the elf file, however,
>> > when it is classified with __thread, the linker needs to match it up
>> > with the correct definition from another object file.
>> > The way that I have implemented TLS support in my port of binutils, the
>> > linker complains that the extern symbol is not TLS and it can not link
>> > it to the definition from the other object file. 
>> >
>> > The only thing that I can think of is to teach ld to look at the
>> > relocation for that symbol and if it is a TLS relocation, it should be
>> > able to match the two, but I don't know how to teach ld to do so.
>> >
>> > Question is: where in the linker I must modify?
>> 
>> An extern __thread variable should be SHN_UNDEF, STB_GLOBAL, STT_TLS.
>> In other words, you don't have to look at relocations, you just have to
>> look at the symbol type.
>> 
>> Ian


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