summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/interception/interception_linux.cc
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-05-01 20:57:59 +0000
committerJulian Lettner <jlettner@apple.com>2019-05-01 20:57:59 +0000
commit91c166cbb035a22db1b0ebee7bb760c55c80b77d (patch)
treed9b4ec3871e1422ee31cf3e54905d9dcf6201fa8 /compiler-rt/lib/interception/interception_linux.cc
parent5833bb280f96cc0bc3cce2b19041921ada39d5ce (diff)
downloadbcm5719-llvm-91c166cbb035a22db1b0ebee7bb760c55c80b77d.tar.gz
bcm5719-llvm-91c166cbb035a22db1b0ebee7bb760c55c80b77d.zip
[Sanitizer] Reland "Cleanup INTERCEPT_FUNCTION macro"
On Linux both version of the INTERCEPT_FUNCTION macro now return true when interception was successful. Adapt and cleanup some usages. Also note that `&(func) == &WRAP(func)` is a link-time property, but we do a runtime check. Tested on Linux and macOS. Previous attempt reverted by: 5642c3feb03d020dc06a62e3dc54f3206a97a391 This attempt to bring order to the interceptor macro goes the other direction and aligns the Linux implementation with the way things are done on Windows. Reviewed By: vitalybuka, rnk Differential Revision: https://reviews.llvm.org/D61358 llvm-svn: 359725
Diffstat (limited to 'compiler-rt/lib/interception/interception_linux.cc')
-rw-r--r--compiler-rt/lib/interception/interception_linux.cc24
1 files changed, 16 insertions, 8 deletions
diff --git a/compiler-rt/lib/interception/interception_linux.cc b/compiler-rt/lib/interception/interception_linux.cc
index d019d482d6d..d07f060b5b6 100644
--- a/compiler-rt/lib/interception/interception_linux.cc
+++ b/compiler-rt/lib/interception/interception_linux.cc
@@ -33,13 +33,7 @@ static int StrCmp(const char *s1, const char *s2) {
}
#endif
-bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
- uptr real, uptr wrapper) {
- *func_addr = (uptr)GetFuncAddr(func_name);
- return real == wrapper;
-}
-
-void *GetFuncAddr(const char *name) {
+static void *GetFuncAddr(const char *name) {
#if SANITIZER_NETBSD
// FIXME: Find a better way to handle renames
if (StrCmp(name, "sigaction"))
@@ -57,11 +51,25 @@ void *GetFuncAddr(const char *name) {
return addr;
}
+bool InterceptFunction(const char *name, uptr *ptr_to_real, uptr func,
+ uptr wrapper) {
+ void *addr = GetFuncAddr(name);
+ *ptr_to_real = (uptr)addr;
+ return addr && (func == wrapper);
+}
+
// Android and Solaris do not have dlvsym
#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
-void *GetFuncAddrVer(const char *name, const char *ver) {
+static void *GetFuncAddr(const char *name, const char *ver) {
return dlvsym(RTLD_NEXT, name, ver);
}
+
+bool InterceptFunction(const char *name, const char *ver, uptr *ptr_to_real,
+ uptr func, uptr wrapper) {
+ void *addr = GetFuncAddr(name, ver);
+ *ptr_to_real = (uptr)addr;
+ return addr && (func == wrapper);
+}
#endif // !SANITIZER_ANDROID
} // namespace __interception
OpenPOWER on IntegriCloud