diff options
author | Kostya Serebryany <kcc@google.com> | 2014-02-24 08:37:41 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2014-02-24 08:37:41 +0000 |
commit | 3c74a2cb4cf2451f4bad7be9e5570d135d39969c (patch) | |
tree | f3692fd799049d579676590b2b293b8a332a1f53 /lib/interception | |
parent | a8a35a4f7c21ca44deaf546640c83dd111e7931c (diff) | |
download | compiler-rt-3c74a2cb4cf2451f4bad7be9e5570d135d39969c.tar.gz |
[sanitizer] Interception macros for sanitizers on FreeBSD; patch by Viktor Kutuzov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202009 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/interception')
-rw-r--r-- | lib/interception/interception.h | 9 | ||||
-rw-r--r-- | lib/interception/interception_linux.cc | 6 | ||||
-rw-r--r-- | lib/interception/interception_linux.h | 12 |
3 files changed, 14 insertions, 13 deletions
diff --git a/lib/interception/interception.h b/lib/interception/interception.h index baddd6c13..7b6b6475e 100644 --- a/lib/interception/interception.h +++ b/lib/interception/interception.h @@ -15,7 +15,8 @@ #ifndef INTERCEPTION_H #define INTERCEPTION_H -#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) +#if !defined(__linux__) && !defined(__FreeBSD__) && \ + !defined(__APPLE__) && !defined(_WIN32) # error "Interception doesn't work on this operating system." #endif @@ -235,11 +236,11 @@ typedef unsigned long uptr; // NOLINT #define INCLUDED_FROM_INTERCEPTION_LIB -#if defined(__linux__) +#if defined(__linux__) || defined(__FreeBSD__) # include "interception_linux.h" -# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX(func) +# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) # define INTERCEPT_FUNCTION_VER(func, symver) \ - INTERCEPT_FUNCTION_VER_LINUX(func, symver) + INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) #elif defined(__APPLE__) # include "interception_mac.h" # define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_MAC(func) diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc index 53f428810..6e908ac01 100644 --- a/lib/interception/interception_linux.cc +++ b/lib/interception/interception_linux.cc @@ -12,10 +12,10 @@ // Linux-specific interception methods. //===----------------------------------------------------------------------===// -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #include "interception.h" -#include <dlfcn.h> // for dlsym +#include <dlfcn.h> // for dlsym() and dlvsym() namespace __interception { bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, @@ -33,4 +33,4 @@ void *GetFuncAddrVer(const char *func_name, const char *ver) { } // namespace __interception -#endif // __linux__ +#endif // __linux__ || __FreeBSD__ diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h index 847e622bd..d3f774bed 100644 --- a/lib/interception/interception_linux.h +++ b/lib/interception/interception_linux.h @@ -12,7 +12,7 @@ // Linux-specific interception methods. //===----------------------------------------------------------------------===// -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #if !defined(INCLUDED_FROM_INTERCEPTION_LIB) # error "interception_linux.h should be included from interception library only" @@ -28,20 +28,20 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, void *GetFuncAddrVer(const char *func_name, const char *ver); } // namespace __interception -#define INTERCEPT_FUNCTION_LINUX(func) \ +#define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \ ::__interception::GetRealFunctionAddress( \ #func, (::__interception::uptr *)&__interception::PTR_TO_REAL(func), \ (::__interception::uptr) & (func), \ (::__interception::uptr) & WRAP(func)) #if !defined(__ANDROID__) // android does not have dlvsym -# define INTERCEPT_FUNCTION_VER_LINUX(func, symver) \ +# define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ ::__interception::real_##func = (func##_f)(unsigned long) \ ::__interception::GetFuncAddrVer(#func, symver) #else -# define INTERCEPT_FUNCTION_VER_LINUX(func, symver) \ - INTERCEPT_FUNCTION_LINUX(func) +# define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ + INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) #endif // !defined(__ANDROID__) #endif // INTERCEPTION_LINUX_H -#endif // __linux__ +#endif // __linux__ || __FreeBSD__ |