This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug sanitizer/68824] [6 Regression] libtsan is missing the __interceptor___tls_get_addr symbol without bumping the soname


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68824

--- Comment #8 from Dmitry Vyukov <dvyukov at google dot com> ---
Jakub, does the following patch look good to you?
Just don't want to intermix tsan and sanitizer_common interceptor macros.
I think it's better to define and initialize an interceptor in a single file.


Index: rtl/tsan_interceptors.cc
===================================================================
--- rtl/tsan_interceptors.cc    (revision 257875)
+++ rtl/tsan_interceptors.cc    (working copy)
@@ -2313,6 +2313,11 @@
 // Since the interceptor only initializes memory for msan, the simplest
solution
 // is to disable the interceptor in tsan (other sanitizers do not call
 // signal handlers from COMMON_INTERCEPTOR_ENTER).
+// As __tls_get_addr has been intercepted in the past, to avoid breaking
+// libtsan ABI, keep it around, but just call the real function.
+#if SANITIZER_INTERCEPT_TLS_GET_ADDR
+#define NEED_TLS_GET_ADDR
+#endif
 #undef SANITIZER_INTERCEPT_TLS_GET_ADDR

 #define COMMON_INTERCEPT_FUNCTION(name) INTERCEPT_FUNCTION(name)
@@ -2538,6 +2543,12 @@

 #include "sanitizer_common/sanitizer_common_syscalls.inc"

+#ifdef NEED_TLS_GET_ADDR
+TSAN_INTERCEPTOR(void *, __tls_get_addr, void *arg) {
+  return REAL(__tls_get_addr)(arg);
+}
+#endif
+
 namespace __tsan {

 static void finalize(void *arg) {
@@ -2721,6 +2732,10 @@
   TSAN_INTERCEPT(__cxa_atexit);
   TSAN_INTERCEPT(_exit);

+#ifdef NEED_TLS_GET_ADDR
+  TSAN_INTERCEPT(__tls_get_addr);
+#endif
+
 #if !SANITIZER_MAC && !SANITIZER_ANDROID
   // Need to setup it, because interceptors check that the function is
resolved.
   // But atexit is emitted directly into the module, so can't be resolved.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]