On Monday, 9 November 2015 at 15:29:25 UTC, Jacob Carlborg wrote:
On 2015-11-08 19:12, bitwise wrote:

So, since binaries will not be mapped to overlapping address spaces, I can loop over all the binary images and find the range to which the argument of ___tls_get_addr() belongs, and map the pointer to the
appropriate block of memory.

I am concerned that looping over all binary images for each TLS access will have performance implications, but for now, this solution is good enough. Later, ___tls_get_addr() can be amended to pass a pointer to the image from which the TLS originated, allowing constant time lookup. I believe Martin has already done this for linux/fbsd, but I had time to
look at this specific issue.

Not sure if this would be too much work for the first version. But would it be possible to, for each loaded image, register its memory range in an associative array. Where the key is the range the value is the image?

Hmm, when I think about, it might not help at all.

The AA is not needed. The offset of the TLS var is known at compile time. If you look at sections_elf_shared.d you can see the signature of __tls_get_addr, and that it takes a pointer to the struct tls_index or something. *if* I understand correctly, one of the two vars in that struct is the index of the image, and the other is the offset into the imag's tls section. Not sure where/hoe that struct is outputted though. So you would have to figure out how to get the backend to do the same thing for OSX. I think the image index may have to be assigned at load time, but I'm not sure. The amount of code to actually do it should be trivial, it's reading/interpreting the backend that will be the problem ;)

   Bit

Reply via email to