summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2019-07-22 14:07:55 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2019-07-22 14:07:55 +0000
commitd15f1142f795ba0d739c1f636fd20be4ab2e8ebe (patch)
treec252790936908da0fee53c06228e4632b723a051
parent81d3c1ad4204a54e19b525a151afbd3a957e7d00 (diff)
downloadcompiler-rt-d15f1142f795ba0d739c1f636fd20be4ab2e8ebe.tar.gz
Revert r366413 on LLVM 9 branch
This commit caused test suite failures on multiple platforms and has been reverted on mainline as r366472/r366482. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/branches/release_90@366690 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/interception/interception_linux.cc9
-rw-r--r--test/asan/TestCases/Linux/dlopen-mixed-c-cxx.c42
2 files changed, 2 insertions, 49 deletions
diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
index 4b27102a1..d07f060b5 100644
--- a/lib/interception/interception_linux.cc
+++ b/lib/interception/interception_linux.cc
@@ -33,7 +33,7 @@ static int StrCmp(const char *s1, const char *s2) {
}
#endif
-static void *GetFuncAddr(const char *name, uptr wrapper_addr) {
+static void *GetFuncAddr(const char *name) {
#if SANITIZER_NETBSD
// FIXME: Find a better way to handle renames
if (StrCmp(name, "sigaction"))
@@ -47,18 +47,13 @@ static void *GetFuncAddr(const char *name, uptr wrapper_addr) {
// want the address of the real definition, though, so look it up using
// RTLD_DEFAULT.
addr = dlsym(RTLD_DEFAULT, name);
-
- // In case `name' is not loaded, dlsym ends up finding the actual wrapper.
- // We don't want to intercept the wrapper and have it point to itself.
- if ((uptr)addr == wrapper_addr)
- addr = nullptr;
}
return addr;
}
bool InterceptFunction(const char *name, uptr *ptr_to_real, uptr func,
uptr wrapper) {
- void *addr = GetFuncAddr(name, wrapper);
+ void *addr = GetFuncAddr(name);
*ptr_to_real = (uptr)addr;
return addr && (func == wrapper);
}
diff --git a/test/asan/TestCases/Linux/dlopen-mixed-c-cxx.c b/test/asan/TestCases/Linux/dlopen-mixed-c-cxx.c
deleted file mode 100644
index 8bce907ef..000000000
--- a/test/asan/TestCases/Linux/dlopen-mixed-c-cxx.c
+++ /dev/null
@@ -1,42 +0,0 @@
-// RUN: %clangxx_asan -xc++ -shared -fPIC -o %t.so - < %s
-// RUN: %clang_asan %s -o %t.out -ldl
-// RUN: ASAN_OPTIONS=verbosity=1 not %t.out %t.so 2>&1 | FileCheck %s
-//
-// CHECK: AddressSanitizer: failed to intercept '__cxa_throw'
-//
-// dlopen() can not be intercepted on Android
-// UNSUPPORTED: android
-#ifdef __cplusplus
-
-static void foo(void) {
- int i = 0;
- throw(i);
-}
-
-extern "C" {
-int bar(void);
-};
-int bar(void) {
- try {
- foo();
- } catch (int i) {
- return i;
- }
- return -1;
-}
-
-#else
-
-#include <assert.h>
-#include <dlfcn.h>
-
-int main(int argc, char **argv) {
- int (*bar)(void);
- void *handle = dlopen(argv[1], RTLD_LAZY);
- assert(handle);
- bar = dlsym(handle, "bar");
- assert(bar);
- return bar();
-}
-
-#endif