<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 1, 2018 at 5:46 PM Ryan Prichard via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">rprichard added a subscriber: enh.<br>
rprichard added a comment.<br>
<br>
@eugenis @enh<br>
<br>
I'm wondering whether moving the `TLS_SLOT_TSAN` slot is feasible. e.g. This sanitizer code would stop working, but it could presumably be fixed in a newer sanitizer library:<br>
<br>
  // The Android Bionic team has allocated a TLS slot for TSan starting with N,<br>
  // given that Android currently doesn't support ELF TLS. It is used to store<br>
  // Sanitizers thread specific data.<br>
  static const int TLS_SLOT_TSAN = 8;<br>
<br>
  ALWAYS_INLINE uptr *get_android_tls_ptr() {<br>
    return reinterpret_cast<uptr *>(&__get_tls()[TLS_SLOT_TSAN]);<br>
  }<br>
<br>
As to where to move it:<br>
<br>
- use initial-exec ELF TLS (but then the sanitizer solib requires a new version of Bionic and must not be loaded via dlopen, directly or indirectly).<br>
- use a negative TP offset on arm (and positive on x86).<br>
- use a mechanism for allocating a slot (something like my `pthread_alloc_tls_word_np` proposal for fixing golang on <a href="http://b/118381796#comment7" rel="noreferrer" target="_blank">http://b/118381796#comment7</a>).<br>
- change one of the existing slots to a normal pthread field. (e.g. `TLS_SLOT_ERRNO` or `TLS_SLOT_DLERROR`)<br></blockquote><div><br></div><div>i think the dlerror slot should be completely safe to change... there shouldn't be any binary compatibility issue there since there's no static dlerror(3).</div><div><br></div><div>(less certain about the errno slot but that _should_ be okay --- `__errno` is the API that gives you that address.)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The issue is that our current use of Bionic slots disagrees with the standard arm{32,64} ELF TLS ABI. The standard ABI requires negative slots on arm and positive on x86. e.g.:<br>
<br>
- <a href="https://github.com/fuchsia-mirror/zircon/blob/0dbac4d37ca09eaebcb5d1337775b9dc78a4ac06/system/public/zircon/tls.h" rel="noreferrer" target="_blank">https://github.com/fuchsia-mirror/zircon/blob/0dbac4d37ca09eaebcb5d1337775b9dc78a4ac06/system/public/zircon/tls.h</a><br>
<br>
<br>
Repository:<br>
  rLLD LLVM Linker<br>
<br>
<a href="https://reviews.llvm.org/D53906" rel="noreferrer" target="_blank">https://reviews.llvm.org/D53906</a><br>
<br>
<br>
<br>
</blockquote></div></div>