summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/interception/interception_linux.cc
diff options
context:
space:
mode:
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