https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88150
--- Comment #11 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> --- > --- Comment #10 from Iain Buclaw <ibuclaw at gdcproject dot org> --- > I've got a (horrible?) hack for getting tls_modid from Solaris. Cool, and not really horrible ;-) It's already this way in Solaris 9 (I happen to have access to those sources and just checked), so we can assume this is stable. > Looking at dlinfo(RTLD_DI_LINKMAP): > > https://github.com/illumos/illumos-gate/blob/4e0c5eff9af325c80994e9527b7cb8b3a1ffd1d4/usr/src/cmd/sgs/rtld/common/dlfcns.c#L1927-L1934 I missed that because I initially looked only at public headers for tlsmodid, and Rt_map is private to ld.so.1. This is intentionally missing from dlinfo(3C), too. I only found it in <rtld_db.h>'s rd_loadobj_t, but it seemed hard to apply librtld_db to the current process instead of one being debugged... > Interestingly, Solaris sets the first tlsmodid to zero. > > https://github.com/illumos/illumos-gate/blob/8a06b3d6467c15646e663c05086378f16288af85/usr/src/cmd/sgs/rtld/common/tls.c#L52-L60 > > This is in stark contrast to what elf_shared expects, given that there's an > assert that it is always non-zero if _tlsSize is set. Right: 0 had been used for the tlsmodid of the main executable until dlpi_tls_modid was added to dl_phdr_info for Solaris 11.5 (still in beta) when this would-be incompatibility with the Linux and BSD versions was noticed. It was only changed to 1 once it could be determined that it was safe to do so.