Supporting emulated tls
Johannes Pfau
nospam at example.com
Mon Mar 19 01:17:30 PDT 2012
Am Sun, 18 Mar 2012 22:06:41 +0100
schrieb Jacob Carlborg <doob at me.com>:
> On 2012-03-18 19:39, Johannes Pfau wrote:
>
> > You mean getting rid of __tls_beg and __tls_end? I'd also like to
> > remove those, but:
>
> __tls_beg and __tls_end is not used by Mac OS X any more:
>
> https://github.com/D-Programming-Language/druntime/commit/73cf2c150665cb17d9365a6e3d6cf144d76312d6
>
> https://github.com/D-Programming-Language/dmd/commit/054c525edba048ad7829dd5ec2d8d9261a6517c3
Yes, but OSX still uses emulated tls. With the way dmd emulates TLS
it's possible to remove __tls_beg and __tls_end, but for native TLS
those symbols are still needed. However, as the runtime linker (ld.so)
has got the necessary information, it's possible that OSX even offers a
API to access it. It's just that most C libraries don't provide a way to
get the TLS segment sizes and the (per thread) addresses of the TLS
blocks.
> > TLS is mostly object-format specific (not as much OS specific). The
> > ELF implementation lays out the TLS data for a module (module =
> > shared library or the application) in a contiguous way. The details
> > are described in "ELF Handling For Thread-Local
> > Storage" (www.akkadia.org/drepper/tls.pdf).
> >
>
> Mac OS X 10.7 + supports TLS natively. But I don't know where to find
> documentation about it. It always possible to look at the source code.
>
Then it's probably already supported by GCC/GDC. But having working
emulated TLS would be nice for many other architectures. Native TLS is
not that widespread.
More information about the D.gnu
mailing list