about TLS and GCC
Jakub Jelinek
jakub@redhat.com
Mon Oct 20 15:57:00 GMT 2003
On Mon, Oct 20, 2003 at 09:10:16PM +0800, Jonathan Wilson wrote:
> After looking into GCC, its becoming clear that TLS as implemented by GCC
> (and by the various unix-ish platforms and libraries that provide the
> runtime support for it) and TLS as implemented by Visual C++ and the
> Windows Kernel are totally different and its not going to be possible to
> implement win32 TLS as a special case in the existing TLS handler.
>
> For starters, win32 doesnt have any "TLS access models", it only ever
> supports one model. (but because there is no clear documentation on just
> what the different access models in GCC actually mean, I cant say if win32
> matches any of them or none of them at all)
And the problem is? TLS access models are just optimizations of the most
generic Global Dynamic model which is slowest but works everywhere.
>From your description it sounds like win32 TLS model is something close
to the Local-Exec model, in that there is no function call involved in
the TLS access and the address is stored in the instruction directly
rather than having to go through GOT.
I don't know how win32 handles dlopen (or whatever similar functionality it
has) with TLS in use and multiple threads already running. From the chunk
you posted, it looks like at dlopen time it needs to grow the __tls_array
per-thread array (whether by preallocating some space and hoping it will
be always enough or somehow else (reallocating the arrays seems to be hard,
since you don't know if some thread already read its fs:__tls_array and
keeps it in some register)).
Jakub
More information about the Gcc
mailing list