--emulated-tls explanation?
IGotD-
nise at nise.com
Tue Oct 13 11:54:31 UTC 2020
On Tuesday, 13 October 2020 at 11:38:33 UTC, IGotD- wrote:
>
> The function prototype of __tls_get_address is wrong. It should
> be
>
> struct tls_index
> {
> size_t ti_module;
> size_t ti_offset;
> };
>
> void* __tls_get_addr(tls_index* ti)
>
>
> You perhaps don't use modules but you certainly need an offset.
>
> It should rather be something like
>
> void* __tls_get_addr(tls_index* ti)
> {
> return getThreadTlsArea(ti->ti_module) + ti->ti_offset;
> }
Just to add to the confusion. If you compile everything
statically into one binary, __tls_get_addr should never really be
called at least with C/C++. Then the compiler should optimize and
call __aeabi_read_tp directly. The compiler inserts TP + offset
itself instead as it assumes all statically and dynamically
linked that are loaded during program start have already
allocated the TLS area and TP is valid.
However, I've seen that D seems to insert calls __tls_get_addr
anyway like the initial exec model optimization doesn't exist.
That's a question if that model is implemented in D.
More information about the digitalmars-d-ldc
mailing list