summaryrefslogtreecommitdiff
path: root/lib/asan/asan_interceptors.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2011-12-05 17:56:32 +0000
committerKostya Serebryany <kcc@google.com>2011-12-05 17:56:32 +0000
commitb3010e75d1c88b6f2084c80530e06ffe8d6f19a2 (patch)
tree855da9e4a3a967a4cd86d8e27a246e02fee5cc4d /lib/asan/asan_interceptors.h
parent75f74616d227a158539a5cc23ea8282142623159 (diff)
downloadcompiler-rt-b3010e75d1c88b6f2084c80530e06ffe8d6f19a2.tar.gz
compiler-rt-b3010e75d1c88b6f2084c80530e06ffe8d6f19a2.tar.bz2
compiler-rt-b3010e75d1c88b6f2084c80530e06ffe8d6f19a2.tar.xz
[asan] don't require __cxa_throw to be present in the process. This is the last dependency on libstdc++
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@145821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_interceptors.h')
-rw-r--r--lib/asan/asan_interceptors.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/asan/asan_interceptors.h b/lib/asan/asan_interceptors.h
index 7bb7280c..39b66fec 100644
--- a/lib/asan/asan_interceptors.h
+++ b/lib/asan/asan_interceptors.h
@@ -37,18 +37,33 @@
#include "mach_override/mach_override.h"
#define WRAP(x) wrap_##x
#define WRAPPER_NAME(x) "wrap_"#x
+
#define OVERRIDE_FUNCTION(oldfunc, newfunc) \
CHECK(0 == mach_override_ptr((void*)(oldfunc), \
(void*)(newfunc), \
(void**)&real_##oldfunc)); \
CHECK(real_##oldfunc != NULL);
+
+#define OVERRIDE_FUNCTION_IF_EXISTS(oldfunc, newfunc) \
+ do { mach_override_ptr((void*)(oldfunc), \
+ (void*)(newfunc), \
+ (void**)&real_##oldfunc); } while (0)
+
#define INTERCEPT_FUNCTION(func) \
OVERRIDE_FUNCTION(func, WRAP(func))
-#else
+
+#define INTERCEPT_FUNCTION_IF_EXISTS(func) \
+ OVERRIDE_FUNCTION_IF_EXISTS(func, WRAP(func))
+
+#else // __linux__
#define WRAP(x) x
#define WRAPPER_NAME(x) #x
+
#define INTERCEPT_FUNCTION(func) \
CHECK((real_##func = (func##_f)dlsym(RTLD_NEXT, #func)));
+
+#define INTERCEPT_FUNCTION_IF_EXISTS(func) \
+ do { real_##func = (func##_f)dlsym(RTLD_NEXT, #func); } while (0)
#endif
#ifdef __APPLE__