[compiler-rt] r191056 - tsan: fix linking of tsan runtime into dynamic libraries

Dmitry Vyukov dvyukov at google.com
Thu Sep 19 16:44:51 PDT 2013


Author: dvyukov
Date: Thu Sep 19 18:44:51 2013
New Revision: 191056

URL: http://llvm.org/viewvc/llvm-project?rev=191056&view=rev
Log:
tsan: fix linking of tsan runtime into dynamic libraries
versioned symbols can not be linked into dynamic library w/o linker script
also simplifies code as side effect


Modified:
    compiler-rt/trunk/lib/interception/interception_linux.h
    compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h

Modified: compiler-rt/trunk/lib/interception/interception_linux.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_linux.h?rev=191056&r1=191055&r2=191056&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception_linux.h (original)
+++ compiler-rt/trunk/lib/interception/interception_linux.h Thu Sep 19 18:44:51 2013
@@ -35,9 +35,8 @@ void *GetFuncAddrVer(const char *func_na
           (::__interception::uptr)&WRAP(func))
 
 #if !defined(__ANDROID__)  // android does not have dlvsym
-#define INTERCEPT_FUNCTION_VER(func, funcver, symver) \
-    __asm__(".symver "#funcver","#func"@@"#symver); \
-    ::__interception::real_##funcver = (funcver##_f)(unsigned long) \
+#define INTERCEPT_FUNCTION_VER(func, symver) \
+    ::__interception::real_##func = (func##_f)(unsigned long) \
         ::__interception::GetFuncAddrVer(#func, #symver)
 #endif  // !defined(__ANDROID__)
 

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=191056&r1=191055&r2=191056&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Thu Sep 19 18:44:51 2013
@@ -1057,49 +1057,49 @@ TSAN_INTERCEPTOR(int, pthread_rwlock_unl
   return res;
 }
 
-TSAN_INTERCEPTOR(int, pthread_cond_init_2_3_2, void *c, void *a) {
-  SCOPED_TSAN_INTERCEPTOR(pthread_cond_init_2_3_2, c, a);
+TSAN_INTERCEPTOR(int, pthread_cond_init, void *c, void *a) {
+  SCOPED_TSAN_INTERCEPTOR(pthread_cond_init, c, a);
   MemoryWrite(thr, pc, (uptr)c, kSizeLog1);
-  int res = REAL(pthread_cond_init_2_3_2)(c, a);
+  int res = REAL(pthread_cond_init)(c, a);
   return res;
 }
 
-TSAN_INTERCEPTOR(int, pthread_cond_destroy_2_3_2, void *c) {
-  SCOPED_TSAN_INTERCEPTOR(pthread_cond_destroy_2_3_2, c);
+TSAN_INTERCEPTOR(int, pthread_cond_destroy, void *c) {
+  SCOPED_TSAN_INTERCEPTOR(pthread_cond_destroy, c);
   MemoryWrite(thr, pc, (uptr)c, kSizeLog1);
-  int res = REAL(pthread_cond_destroy_2_3_2)(c);
+  int res = REAL(pthread_cond_destroy)(c);
   return res;
 }
 
-TSAN_INTERCEPTOR(int, pthread_cond_signal_2_3_2, void *c) {
-  SCOPED_TSAN_INTERCEPTOR(pthread_cond_signal_2_3_2, c);
+TSAN_INTERCEPTOR(int, pthread_cond_signal, void *c) {
+  SCOPED_TSAN_INTERCEPTOR(pthread_cond_signal, c);
   MemoryRead(thr, pc, (uptr)c, kSizeLog1);
-  int res = REAL(pthread_cond_signal_2_3_2)(c);
+  int res = REAL(pthread_cond_signal)(c);
   return res;
 }
 
-TSAN_INTERCEPTOR(int, pthread_cond_broadcast_2_3_2, void *c) {
-  SCOPED_TSAN_INTERCEPTOR(pthread_cond_broadcast_2_3_2, c);
+TSAN_INTERCEPTOR(int, pthread_cond_broadcast, void *c) {
+  SCOPED_TSAN_INTERCEPTOR(pthread_cond_broadcast, c);
   MemoryRead(thr, pc, (uptr)c, kSizeLog1);
-  int res = REAL(pthread_cond_broadcast_2_3_2)(c);
+  int res = REAL(pthread_cond_broadcast)(c);
   return res;
 }
 
-TSAN_INTERCEPTOR(int, pthread_cond_wait_2_3_2, void *c, void *m) {
-  SCOPED_TSAN_INTERCEPTOR(pthread_cond_wait_2_3_2, c, m);
+TSAN_INTERCEPTOR(int, pthread_cond_wait, void *c, void *m) {
+  SCOPED_TSAN_INTERCEPTOR(pthread_cond_wait, c, m);
   MutexUnlock(thr, pc, (uptr)m);
   MemoryRead(thr, pc, (uptr)c, kSizeLog1);
-  int res = REAL(pthread_cond_wait_2_3_2)(c, m);
+  int res = REAL(pthread_cond_wait)(c, m);
   MutexLock(thr, pc, (uptr)m);
   return res;
 }
 
-TSAN_INTERCEPTOR(int, pthread_cond_timedwait_2_3_2, void *c, void *m,
+TSAN_INTERCEPTOR(int, pthread_cond_timedwait, void *c, void *m,
     void *abstime) {
-  SCOPED_TSAN_INTERCEPTOR(pthread_cond_timedwait_2_3_2, c, m, abstime);
+  SCOPED_TSAN_INTERCEPTOR(pthread_cond_timedwait, c, m, abstime);
   MutexUnlock(thr, pc, (uptr)m);
   MemoryRead(thr, pc, (uptr)c, kSizeLog1);
-  int res = REAL(pthread_cond_timedwait_2_3_2)(c, m, abstime);
+  int res = REAL(pthread_cond_timedwait)(c, m, abstime);
   MutexLock(thr, pc, (uptr)m);
   return res;
 }
@@ -1995,18 +1995,12 @@ void InitializeInterceptors() {
   TSAN_INTERCEPT(pthread_rwlock_timedwrlock);
   TSAN_INTERCEPT(pthread_rwlock_unlock);
 
-  INTERCEPT_FUNCTION_VER(pthread_cond_init, pthread_cond_init_2_3_2,
-      GLIBC_2.3.2);
-  INTERCEPT_FUNCTION_VER(pthread_cond_destroy, pthread_cond_destroy_2_3_2,
-      GLIBC_2.3.2);
-  INTERCEPT_FUNCTION_VER(pthread_cond_signal, pthread_cond_signal_2_3_2,
-      GLIBC_2.3.2);
-  INTERCEPT_FUNCTION_VER(pthread_cond_broadcast, pthread_cond_broadcast_2_3_2,
-      GLIBC_2.3.2);
-  INTERCEPT_FUNCTION_VER(pthread_cond_wait, pthread_cond_wait_2_3_2,
-      GLIBC_2.3.2);
-  INTERCEPT_FUNCTION_VER(pthread_cond_timedwait, pthread_cond_timedwait_2_3_2,
-      GLIBC_2.3.2);
+  INTERCEPT_FUNCTION_VER(pthread_cond_init, GLIBC_2.3.2);
+  INTERCEPT_FUNCTION_VER(pthread_cond_destroy, GLIBC_2.3.2);
+  INTERCEPT_FUNCTION_VER(pthread_cond_signal, GLIBC_2.3.2);
+  INTERCEPT_FUNCTION_VER(pthread_cond_broadcast, GLIBC_2.3.2);
+  INTERCEPT_FUNCTION_VER(pthread_cond_wait, GLIBC_2.3.2);
+  INTERCEPT_FUNCTION_VER(pthread_cond_timedwait, GLIBC_2.3.2);
 
   TSAN_INTERCEPT(pthread_barrier_init);
   TSAN_INTERCEPT(pthread_barrier_destroy);

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc?rev=191056&r1=191055&r2=191056&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc Thu Sep 19 18:44:51 2013
@@ -169,15 +169,12 @@ void StatOutput(u64 *stat) {
   name[StatInt_pthread_rwlock_timedwrlock]
                                          = "  pthread_rwlock_timedwrlock      ";
   name[StatInt_pthread_rwlock_unlock]    = "  pthread_rwlock_unlock           ";
-  name[StatInt_pthread_cond_init_2_3_2]  = "  pthread_cond_init               ";
-  name[StatInt_pthread_cond_destroy_2_3_2]
-                                         = "  pthread_cond_destroy            ";
-  name[StatInt_pthread_cond_signal_2_3_2]= "  pthread_cond_signal             ";
-  name[StatInt_pthread_cond_broadcast_2_3_2]
-                                         = "  pthread_cond_broadcast          ";
-  name[StatInt_pthread_cond_wait_2_3_2]  = "  pthread_cond_wait               ";
-  name[StatInt_pthread_cond_timedwait_2_3_2]
-                                         = "  pthread_cond_timedwait          ";
+  name[StatInt_pthread_cond_init]        = "  pthread_cond_init               ";
+  name[StatInt_pthread_cond_destroy]     = "  pthread_cond_destroy            ";
+  name[StatInt_pthread_cond_signal]      = "  pthread_cond_signal             ";
+  name[StatInt_pthread_cond_broadcast]   = "  pthread_cond_broadcast          ";
+  name[StatInt_pthread_cond_wait]        = "  pthread_cond_wait               ";
+  name[StatInt_pthread_cond_timedwait]   = "  pthread_cond_timedwait          ";
   name[StatInt_pthread_barrier_init]     = "  pthread_barrier_init            ";
   name[StatInt_pthread_barrier_destroy]  = "  pthread_barrier_destroy         ";
   name[StatInt_pthread_barrier_wait]     = "  pthread_barrier_wait            ";

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h?rev=191056&r1=191055&r2=191056&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.h Thu Sep 19 18:44:51 2013
@@ -164,12 +164,12 @@ enum StatType {
   StatInt_pthread_rwlock_trywrlock,
   StatInt_pthread_rwlock_timedwrlock,
   StatInt_pthread_rwlock_unlock,
-  StatInt_pthread_cond_init_2_3_2,
-  StatInt_pthread_cond_destroy_2_3_2,
-  StatInt_pthread_cond_signal_2_3_2,
-  StatInt_pthread_cond_broadcast_2_3_2,
-  StatInt_pthread_cond_wait_2_3_2,
-  StatInt_pthread_cond_timedwait_2_3_2,
+  StatInt_pthread_cond_init,
+  StatInt_pthread_cond_destroy,
+  StatInt_pthread_cond_signal,
+  StatInt_pthread_cond_broadcast,
+  StatInt_pthread_cond_wait,
+  StatInt_pthread_cond_timedwait,
   StatInt_pthread_barrier_init,
   StatInt_pthread_barrier_destroy,
   StatInt_pthread_barrier_wait,





More information about the llvm-commits mailing list