summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/dlclose-test.cc
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2014-05-14 14:41:38 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2014-05-14 14:41:38 +0000
commit95b74edef69316968ec58ccba6b76a5c7a6795fc (patch)
tree6b3bb106c88a0fe26ed9eeb2e6da6ba922056309 /test/asan/TestCases/dlclose-test.cc
parent56812ee8727bd45f1995a44a4cabd802c0a18159 (diff)
[ASan tests] Get rid of SharedLibs/
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208780 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases/dlclose-test.cc')
-rw-r--r--test/asan/TestCases/dlclose-test.cc30
1 files changed, 26 insertions, 4 deletions
diff --git a/test/asan/TestCases/dlclose-test.cc b/test/asan/TestCases/dlclose-test.cc
index 82819c0a9..07d57b1cf 100644
--- a/test/asan/TestCases/dlclose-test.cc
+++ b/test/asan/TestCases/dlclose-test.cc
@@ -14,15 +14,16 @@
// It works on i368/x86_64 Linux, but not necessary anywhere else.
// REQUIRES: x86_64-supported-target,i386-supported-target
-// RUN: %clangxx_asan -O0 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O0 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O1 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O1 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O1 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O2 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O2 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O2 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O3 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O3 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
+#if !defined(SHARED_LIB)
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
@@ -75,3 +76,24 @@ int main(int argc, char *argv[]) {
// CHECK: PASS
return 0;
}
+#else // SHARED_LIB
+#include <stdio.h>
+
+static int pad1;
+static int static_var;
+static int pad2;
+
+extern "C"
+int *get_address_of_static_var() {
+ return &static_var;
+}
+
+__attribute__((constructor))
+void at_dlopen() {
+ printf("%s: I am being dlopened\n", __FILE__);
+}
+__attribute__((destructor))
+void at_dlclose() {
+ printf("%s: I am being dlclosed\n", __FILE__);
+}
+#endif // SHARED_LIB