Web lists-archives.org

Re: [Mingw-users] __thread not using PE loader support?




Roland Schwarz writes:
>While working on the TLS support of the boost library I discovered
>that the 4.2.x version of gcc is said to honor the __thread keyword.

At some point GCC added support for the __thread keyword on all targets,
regardless whether linker and assembler supported it.

>However I was not able to grep the "tls_used" keyword anywhere in the
>sources. This is _very_ strange for me.

You can call that variable whatever you want it to.  The Windows PE
loader doesn't use it.

>Does this mean TLS support for mingw does not make use of the windows
>loader support to initialize TLS variables?

Yes.

>Somewhere on this list I read that there is believe that the gnu linker
>does not yet support this. This is _wrong_! The gnu linker is able to
>do everything that is necessary to correctly initialize a PE image
>(including the TLS directory). I was able to succesfully hook to the
>tls callback function that way. (This is what I really need.)

The GNU binutils package doesn't fully support thread local variables on
PE-COFF targets.  While the linker does support creating a TLS directory,
that's not sufficient.  You also need section relative relocations to
be supported in both the assembler and linker so the code can reference
the variables.

>I would be very glad if someone on this list can give me an update
>on the matter, because when putting my code into the boost library I
>want to do it in such a manner it will be compatible with gcc/g++.

Well, you should know that TLS callbacks aren't portable.  They don't
work on Win9x/ME targets and they don't work wirth dynamically loaded
DLLs on any version of Windows.  I'm not sure what the limitations
of using GCC's fallback thread local variable support with MinGW are.
I don't know if anyone's actually bothered to try it out yet.

					Ross Ridge


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users