diff --git a/compiler-rt/lib/interception/interception.h b/compiler-rt/lib/interception/interception.h --- a/compiler-rt/lib/interception/interception.h +++ b/compiler-rt/lib/interception/interception.h @@ -121,6 +121,7 @@ # define WRAPPER_NAME(x) "wrap_"#x # define INTERCEPTOR_ATTRIBUTE # define DECLARE_WRAPPER(ret_type, func, ...) +# define DECLARED_FUNC(func) func #elif SANITIZER_WINDOWS # define WRAP(x) __asan_wrap_##x @@ -135,6 +136,14 @@ # define WRAPPER_NAME(x) #x # define INTERCEPTOR_ATTRIBUTE # define DECLARE_WRAPPER(ret_type, func, ...) +#elif defined(_FORTIFY_SOURCE) && (SANITIZER_FREEBSD || SANITIZER_NETBSD || !SANITIZER_FUCHSIA) +# define WRAP(x) __interceptor_ ## x +# define WRAPPER_NAME(x) "__interceptor_" #x +# define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default"))) +# define DECLARED_FUNC(func) WRAP(func) +# define DECLARE_WRAPPER(ret_type, func, ...) \ + extern "C" ret_type __interceptor_ ## func(__VA_ARGS__) \ + __attribute__((visibility("default"))); #elif SANITIZER_FREEBSD || SANITIZER_NETBSD # define WRAP(x) __interceptor_ ## x # define WRAPPER_NAME(x) "__interceptor_" #x diff --git a/compiler-rt/lib/interception/interception_linux.h b/compiler-rt/lib/interception/interception_linux.h --- a/compiler-rt/lib/interception/interception_linux.h +++ b/compiler-rt/lib/interception/interception_linux.h @@ -32,7 +32,7 @@ ::__interception::InterceptFunction( \ #func, \ (::__interception::uptr *) & REAL(func), \ - (::__interception::uptr) & (func), \ + (::__interception::uptr) & (DECLARED_FUNC(func)), \ (::__interception::uptr) & WRAP(func)) // Android and Solaris do not have dlvsym @@ -41,7 +41,7 @@ ::__interception::InterceptFunction( \ #func, symver, \ (::__interception::uptr *) & REAL(func), \ - (::__interception::uptr) & (func), \ + (::__interception::uptr) & (DECLARED_FUNC(func)), \ (::__interception::uptr) & WRAP(func)) #else #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \