[PATCH] D91605: [sanitizers] Implement GetTls on Solaris

Rainer Orth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 17 05:49:08 PST 2022


ro added a comment.

In D91605#3322312 <https://reviews.llvm.org/D91605#3322312>, @ro wrote:

> In D91605#3321554 <https://reviews.llvm.org/D91605#3321554>, @MaskRay wrote:
>
>> `GetTls` is about the static TLS block size. It consists of the main executable's TLS, and initially loaded shared objects' TLS, `struct pthread`, and padding.
>> Solaris should be able to just use the code path like FreeBSD, Linux musl, and various unpopular architectures of Linux glibc:
>>
>>   #elif SANITIZER_FREEBSD || SANITIZER_LINUX
>>     uptr align;
>>     GetStaticTlsBoundary(addr, size, &align);
>
> Not unconditionally, unfortunally: as the comment above `GetSizeFromHdr` explains, `dlpi_tls_modid` was only introduced in an update to Solaris 11.4 FCS (which is sort of a problem), but isn't present in 11.3 (don't reallly care) and Illumos (this would break compilation for them).  OTOH my solution is successfully being used in GCC's `libphobos` on Solaris 11.3, 11.4, and most likely Illumos, too.  I'd rather not burn the Illumos bridge if it can be avoided.

As an experiment, I've tried to use `GetStaticTlsBoundary` instead.  It does indeed work on recent Solaris 11.4 and the resulting patch is at D120048 <https://reviews.llvm.org/D120048>.  I'm pretty certain that support for Solaris 11.3/Illumos which lack `dlpi_tls_modid` using `dlinfo(RTLD_SELF, RTLD_DI_LINKMAP)` can be added on top of that one, unbreaking the Illumos build.  This would avoid considerable duplication of the `dl_iterate_phdr` code, which is certainly a nice benefit.  I'll experiment with that route later.

I know now why I did the present patch the way it is: `GetStaticTlsBoundary` was only introduced months after I submitted this one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91605/new/

https://reviews.llvm.org/D91605



More information about the cfe-commits mailing list