|
15 | 15 |
|
16 | 16 | #include "interception/interception.h" |
17 | 17 | #include "sanitizer_common/sanitizer_allocator_dlsym.h" |
| 18 | +#include "sanitizer_common/sanitizer_glibc_version.h" |
18 | 19 | #include "sanitizer_common/sanitizer_platform_interceptors.h" |
19 | 20 |
|
20 | 21 | #include "interception/interception.h" |
|
46 | 47 |
|
47 | 48 | using namespace __sanitizer; |
48 | 49 |
|
49 | | -#if defined(__x86_64__) || defined(__mips__) || SANITIZER_PPC64V1 || \ |
50 | | - defined(__s390x__) |
51 | | -#define PTHREAD_ABI_BASE "GLIBC_2.3.2" |
52 | | -#elif defined(__aarch64__) || SANITIZER_PPC64V2 |
53 | | -#define PTHREAD_ABI_BASE "GLIBC_2.17" |
54 | | -#elif SANITIZER_LOONGARCH64 |
55 | | -#define PTHREAD_ABI_BASE "GLIBC_2.36" |
56 | | -#elif SANITIZER_RISCV64 |
57 | | -#define PTHREAD_ABI_BASE "GLIBC_2.27" |
58 | | -#endif |
59 | | - |
60 | 50 | DECLARE_REAL_AND_INTERCEPTOR(void *, malloc, usize size) |
61 | 51 | DECLARE_REAL_AND_INTERCEPTOR(void, free, void *ptr) |
62 | 52 |
|
@@ -1701,12 +1691,24 @@ void __rtsan::InitializeInterceptors() { |
1701 | 1691 | INTERCEPT_FUNCTION(pthread_mutex_unlock); |
1702 | 1692 | INTERCEPT_FUNCTION(pthread_join); |
1703 | 1693 |
|
1704 | | - INTERCEPT_FUNCTION_VER(pthread_cond_init, PTHREAD_ABI_BASE); |
1705 | | - INTERCEPT_FUNCTION_VER(pthread_cond_signal, PTHREAD_ABI_BASE); |
1706 | | - INTERCEPT_FUNCTION_VER(pthread_cond_broadcast, PTHREAD_ABI_BASE); |
1707 | | - INTERCEPT_FUNCTION_VER(pthread_cond_wait, PTHREAD_ABI_BASE); |
1708 | | - INTERCEPT_FUNCTION_VER(pthread_cond_timedwait, PTHREAD_ABI_BASE); |
1709 | | - INTERCEPT_FUNCTION_VER(pthread_cond_destroy, PTHREAD_ABI_BASE); |
| 1694 | + // See the comment in tsan_interceptors_posix.cpp. |
| 1695 | +#if SANITIZER_GLIBC && !__GLIBC_PREREQ(2, 36) && \ |
| 1696 | + (defined(__x86_64__) || defined(__mips__) || SANITIZER_PPC64V1 || \ |
| 1697 | + defined(__s390x__)) |
| 1698 | + INTERCEPT_FUNCTION_VER(pthread_cond_init, "GLIBC_2.3.2"); |
| 1699 | + INTERCEPT_FUNCTION_VER(pthread_cond_signal, "GLIBC_2.3.2"); |
| 1700 | + INTERCEPT_FUNCTION_VER(pthread_cond_broadcast, "GLIBC_2.3.2"); |
| 1701 | + INTERCEPT_FUNCTION_VER(pthread_cond_wait, "GLIBC_2.3.2"); |
| 1702 | + INTERCEPT_FUNCTION_VER(pthread_cond_timedwait, "GLIBC_2.3.2"); |
| 1703 | + INTERCEPT_FUNCTION_VER(pthread_cond_destroy, "GLIBC_2.3.2"); |
| 1704 | +#else |
| 1705 | + INTERCEPT_FUNCTION(pthread_cond_init); |
| 1706 | + INTERCEPT_FUNCTION(pthread_cond_signal); |
| 1707 | + INTERCEPT_FUNCTION(pthread_cond_broadcast); |
| 1708 | + INTERCEPT_FUNCTION(pthread_cond_wait); |
| 1709 | + INTERCEPT_FUNCTION(pthread_cond_timedwait); |
| 1710 | + INTERCEPT_FUNCTION(pthread_cond_destroy); |
| 1711 | +#endif |
1710 | 1712 |
|
1711 | 1713 | INTERCEPT_FUNCTION(pthread_rwlock_rdlock); |
1712 | 1714 | INTERCEPT_FUNCTION(pthread_rwlock_unlock); |
|
0 commit comments