[compiler-rt] r273250 - [sanitizers] [PowerPC] Intercept __tls_get_addr_opt.

Marcin Koscielnicki via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 00:09:36 PDT 2016


Author: koriakin
Date: Tue Jun 21 02:09:36 2016
New Revision: 273250

URL: http://llvm.org/viewvc/llvm-project?rev=273250&view=rev
Log:
[sanitizers] [PowerPC] Intercept __tls_get_addr_opt.

On PowerPC, if binutils and glibc are new enough, the linker uses
an optimized code sequence to implement __tls_get_addr call stub,
which will end up calling __tls_get_addr_opt instead of __tls_get_addr.
Thus, we need to intercept it in addition to __tls_get_addr.

This symbol is actually an alias of __tls_get_addr - its only purpose
is that its presence in glibc triggers the optimization in linker.
This means we can make our own intercepting symbol an alias as well.

This patch will make the linker attempt optimization even on older
glibc's (since it sees a defined __tls_get_addr_opt symbol in msan)
- however, this is only a very minor performance problem (the linker
generated code will never recognize a filled static TLS descriptor,
always burning a few cycles), not a correctness problem.

This fixes MSan's dtls_test.c, allowing us to finally enable MSan
on PowerPC64.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=273250&r1=273249&r2=273250&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Tue Jun 21 02:09:36 2016
@@ -4435,6 +4435,14 @@ INTERCEPTOR(void *, __tls_get_addr, void
   }
   return res;
 }
+#if SANITIZER_PPC
+// On PowerPC, we also need to intercept __tls_get_addr_opt, which has
+// mostly the same semantics as __tls_get_addr, but its presence enables
+// some optimizations in linker (which are safe to ignore here).
+extern "C" __attribute__((alias("__interceptor___tls_get_addr"),
+                          visibility("default")))
+void *__tls_get_addr_opt(void *arg);
+#endif
 #else // SANITIZER_S390
 // On s390, we have to intercept two functions here:
 // - __tls_get_addr_internal, which is a glibc-internal function that is like




More information about the llvm-commits mailing list