summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/interception/interception_linux.cc
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2017-12-06 17:02:00 +0000
committerKamil Rytarowski <n54@gmx.com>2017-12-06 17:02:00 +0000
commit90b46353e7a63a42f0a4d7ce0fcbe4ae8ad3226b (patch)
tree6da3d781a90f87f0033ffcd335f49ddd425471a5 /compiler-rt/lib/interception/interception_linux.cc
parenta74ff71a376882405873dd29e5a90f5da58e614c (diff)
downloadbcm5719-llvm-90b46353e7a63a42f0a4d7ce0fcbe4ae8ad3226b.tar.gz
bcm5719-llvm-90b46353e7a63a42f0a4d7ce0fcbe4ae8ad3226b.zip
[Sanitizers] Use SANITIZER_* macros in lib/interception
Summary: Unlike the rest of the sanitizer code, lib/interception uses native macros like __linux__ to check for specific targets instead of the common ones like SANITIZER_LINUX. When working on the Solaris port of the sanitizers, the current style was found to not only be inconsistent, but clumsy to use because the canonical way to check for Solaris is to check for __sun__ && __svr4__ which is a mouthful. Therefore, this patch switches to use SANITIZER_* macros instead. Tested on x86_64-pc-linux-gnu. Reviewers: kcc, vitalybuka Reviewed By: vitalybuka Subscribers: #sanitizers, srhines, krytarowski, llvm-commits, fedor.sergeev Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39798 llvm-svn: 319906
Diffstat (limited to 'compiler-rt/lib/interception/interception_linux.cc')
-rw-r--r--compiler-rt/lib/interception/interception_linux.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler-rt/lib/interception/interception_linux.cc b/compiler-rt/lib/interception/interception_linux.cc
index 5299c42d625..500243a3772 100644
--- a/compiler-rt/lib/interception/interception_linux.cc
+++ b/compiler-rt/lib/interception/interception_linux.cc
@@ -12,19 +12,20 @@
// Linux-specific interception methods.
//===----------------------------------------------------------------------===//
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
#include "interception.h"
+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+
#include <dlfcn.h> // for dlsym() and dlvsym()
-#ifdef __NetBSD__
+#if SANITIZER_NETBSD
#include "sanitizer_common/sanitizer_libc.h"
#endif
namespace __interception {
bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
uptr real, uptr wrapper) {
-#ifdef __NetBSD__
+#if SANITIZER_NETBSD
// XXX: Find a better way to handle renames
if (internal_strcmp(func_name, "sigaction") == 0) func_name = "__sigaction14";
#endif
@@ -40,12 +41,12 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
return real == wrapper;
}
-#if !defined(__ANDROID__) // android does not have dlvsym
+#if !SANITIZER_ANDROID // android does not have dlvsym
void *GetFuncAddrVer(const char *func_name, const char *ver) {
return dlvsym(RTLD_NEXT, func_name, ver);
}
-#endif // !defined(__ANDROID__)
+#endif // !SANITIZER_ANDROID
} // namespace __interception
-#endif // __linux__ || __FreeBSD__ || __NetBSD__
+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
OpenPOWER on IntegriCloud