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
llvm-svn: 191056
diff --git a/compiler-rt/lib/interception/interception_linux.h b/compiler-rt/lib/interception/interception_linux.h
index 5e0ec2a..8f7a706 100644
--- a/compiler-rt/lib/interception/interception_linux.h
+++ b/compiler-rt/lib/interception/interception_linux.h
@@ -35,9 +35,8 @@
(::__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__)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
index f612770..cc9bfbe 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
@@ -1057,49 +1057,49 @@
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 @@
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);
diff --git a/compiler-rt/lib/tsan/rtl/tsan_stat.cc b/compiler-rt/lib/tsan/rtl/tsan_stat.cc
index 366d5c8..2ac670d 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_stat.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_stat.cc
@@ -169,15 +169,12 @@
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 ";
diff --git a/compiler-rt/lib/tsan/rtl/tsan_stat.h b/compiler-rt/lib/tsan/rtl/tsan_stat.h
index c7536f4..f17d83a 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_stat.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_stat.h
@@ -164,12 +164,12 @@
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,