This is the mail archive of the
mailing list for the GCC project.
Re: wanting to implement Thread Local Storage on windows and am lookingfor pointers into the GCC codebase
- From: Jonathan Wilson <jonwil at tpgi dot com dot au>
- To: Richard Henderson <rth at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Wed, 15 Oct 2003 20:16:58 +0800
- Subject: Re: wanting to implement Thread Local Storage on windows and am lookingfor pointers into the GCC codebase
- References: <3F86ADD8.firstname.lastname@example.org> <20031010203221.GC19470@redhat.com>
just posted patch for binutils support of TLS to binutils list.
Anyway, the gist of what GCC needs to do:
1.anytime it sees a variable marked with __declspec(thread) it should mark
it as "thread local" somehow
2.all variable marked "thread local" need to go into a segment called .tls$
instead of wherver else they would go
3.when the variable is accessed, the folowing must be output: (or something
mov eax, ds:__tls_index
mov ecx, dword ptr fs:__tls_array
mov edx, edx, [ecx+eax*4]
then you do something like:
mov ds:_x[edx], 0 (in this case it sets it to 0)
Thats what it looks like in the obj file.
__tis_index and __tls_array should be marked external (they come from the
tlssup.c and atlssup.s respectivly, see my post to the binutils list for
if the variable is local to this file, it should be defined as a SEGEF that
points to the .tls$ segment.
if the variable is in another file, the same ASM as above is used but it
points to an extern not a SEGDEF.
BTW, you cant access a variable thats Thread Local across DLL boundries.
Would like to get all of this stuff into GCC, Binutils and MingW-Runtime
for the next release of each (in particular, I want to get it into GCC 3.4
because if I miss the boat, GCC 3.5 is a very long way off)