From fa94fa52ad6cd63018010af649d12a34dd06b5f2 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 7 Dec 2012 17:54:38 +0000 Subject: [PATCH] ASan: intercept prctl on Linux only llvm-svn: 169616 --- compiler-rt/lib/asan/asan_intercepted_functions.h | 2 ++ compiler-rt/lib/asan/asan_interceptors.cc | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/asan/asan_intercepted_functions.h b/compiler-rt/lib/asan/asan_intercepted_functions.h index 06d7577fcfbe..60b05e6dd5a3 100644 --- a/compiler-rt/lib/asan/asan_intercepted_functions.h +++ b/compiler-rt/lib/asan/asan_intercepted_functions.h @@ -41,8 +41,10 @@ using __sanitizer::uptr; #if defined(__linux__) # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 1 +# define ASAN_INTERCEPT_PRCTL 1 #else # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 0 +# define ASAN_INTERCEPT_PRCTL 0 #endif #if !defined(__APPLE__) diff --git a/compiler-rt/lib/asan/asan_interceptors.cc b/compiler-rt/lib/asan/asan_interceptors.cc index ef5f3454b0d1..501fddf1df81 100644 --- a/compiler-rt/lib/asan/asan_interceptors.cc +++ b/compiler-rt/lib/asan/asan_interceptors.cc @@ -177,10 +177,11 @@ INTERCEPTOR(void, siglongjmp, void *env, int val) { } #endif +#if ASAN_INTERCEPT_PRCTL #define PR_SET_NAME 15 - -INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3, - unsigned long arg4, unsigned long arg5) { +INTERCEPTOR(int, prctl, int option, + unsigned long arg2, unsigned long arg3, // NOLINT + unsigned long arg4, unsigned long arg5) { // NOLINT int res = REAL(prctl(option, arg2, arg3, arg4, arg5)); if (option == PR_SET_NAME) { AsanThread *t = asanThreadRegistry().GetCurrent(); @@ -193,6 +194,7 @@ INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3, } return res; } +#endif #if ASAN_INTERCEPT___CXA_THROW INTERCEPTOR(void, __cxa_throw, void *a, void *b, void *c) { @@ -737,7 +739,9 @@ void InitializeAsanInterceptors() { #if ASAN_INTERCEPT_SIGLONGJMP ASAN_INTERCEPT_FUNC(siglongjmp); #endif +#if ASAN_INTERCEPT_PRCTL ASAN_INTERCEPT_FUNC(prctl); +#endif // Intercept exception handling functions. #if ASAN_INTERCEPT___CXA_THROW