Index: compiler-rt/trunk/lib/hwasan/hwasan.h =================================================================== --- compiler-rt/trunk/lib/hwasan/hwasan.h +++ compiler-rt/trunk/lib/hwasan/hwasan.h @@ -154,6 +154,8 @@ void AppendToErrorMessageBuffer(const char *buffer); +void AndroidTestTlsSlot(); + } // namespace __hwasan #define HWASAN_MALLOC_HOOK(ptr, size) \ Index: compiler-rt/trunk/lib/hwasan/hwasan.cc =================================================================== --- compiler-rt/trunk/lib/hwasan/hwasan.cc +++ compiler-rt/trunk/lib/hwasan/hwasan.cc @@ -283,6 +283,8 @@ __sanitizer_set_report_path(common_flags()->log_path); + AndroidTestTlsSlot(); + DisableCoreDumperIfNecessary(); __hwasan_shadow_init(); Index: compiler-rt/trunk/lib/hwasan/hwasan_linux.cc =================================================================== --- compiler-rt/trunk/lib/hwasan/hwasan_linux.cc +++ compiler-rt/trunk/lib/hwasan/hwasan_linux.cc @@ -24,6 +24,7 @@ #include "hwasan_thread.h" #include "hwasan_thread_list.h" +#include #include #include #include @@ -283,6 +284,22 @@ } #endif +#if SANITIZER_ANDROID +void AndroidTestTlsSlot() { + uptr kMagicValue = 0x010203040A0B0C0D; + *(uptr *)get_android_tls_ptr() = kMagicValue; + dlerror(); + if (*(uptr *)get_android_tls_ptr() != kMagicValue) { + Printf( + "ERROR: Incompatible version of Android: TLS_SLOT_SANITIZER(6) is used " + "for dlerror().\n"); + Die(); + } +} +#else +void AndroidTestTlsSlot() {} +#endif + Thread *GetCurrentThread() { auto *R = (StackAllocationsRingBuffer*)GetCurrentThreadLongPtr(); return hwasanThreadList().GetThreadByBufferAddress((uptr)(R->Next()));