November 27, 2014 Re: Solaris/x86 port - how to get the TLS section? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kai Nacke | On 2014-11-27 18:39, Kai Nacke wrote: > Here are the dirty details: > > On Linux and FreeBSD, the module id and size of the TLS section is found > in the ELF structure dl_phdr_info. The module id is converted to a > pointer to the first byte of the TLS section for every thread: > > auto ti = tls_index(moduleId, 0); > return (__tls_get_addr(&ti)-TLS_DTV_OFFSET)[0 .. sz]; > > (sz is the size) > > Solaris does not have the dl_phdr_info.dlpi_tls_modid field therefore > this methods breaks. > > But I think I found the solution. After reading the link you posted the > tenth time I realized the following sentence: > > "The static TLS arena associated with the calculated TLS size tlssizeS, > is placed immediately preceding the thread pointer tpt. Accesses to this > TLS data is based off of subtractions from tpt." > > The thread pointer is fs:0 or gs:0 on Intel and r7 on Sparc. The size of > the TLS data is found in the ELF header as before. I simply need to do > the rounding as documented in the chapter and then I can calculate the > required pointer. > > Great!!! I don't really understand this but it's great if you found a solution. -- /Jacob Carlborg |
Copyright © 1999-2021 by the D Language Foundation