1 // RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc \
2 // RUN: -fPIC -shared -o %t-so.so
3 // RUN: %clangxx_asan -O0 %s -o %t && not %t 2>&1 | FileCheck %s
4 // RUN: %clangxx_asan -O1 %p/SharedLibs/shared-lib-test-so.cc \
5 // RUN: -fPIC -shared -o %t-so.so
6 // RUN: %clangxx_asan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
7 // RUN: %clangxx_asan -O2 %p/SharedLibs/shared-lib-test-so.cc \
8 // RUN: -fPIC -shared -o %t-so.so
9 // RUN: %clangxx_asan -O2 %s -o %t && not %t 2>&1 | FileCheck %s
10 // RUN: %clangxx_asan -O3 %p/SharedLibs/shared-lib-test-so.cc \
11 // RUN: -fPIC -shared -o %t-so.so
12 // RUN: %clangxx_asan -O3 %s -o %t && not %t 2>&1 | FileCheck %s
22 typedef void (fun_t
)(int x
);
24 int main(int argc
, char *argv
[]) {
25 string path
= string(argv
[0]) + "-so.so";
26 printf("opening %s ... \n", path
.c_str());
27 void *lib
= dlopen(path
.c_str(), RTLD_NOW
);
29 printf("error in dlopen(): %s\n", dlerror());
32 fun_t
*inc
= (fun_t
*)dlsym(lib
, "inc");
37 // CHECK: {{.*ERROR: AddressSanitizer: global-buffer-overflow}}
38 // CHECK: {{READ of size 4 at 0x.* thread T0}}
39 // CHECK: {{ #0 0x.*}}
40 // CHECK: {{ #1 0x.* in main .*shared-lib-test.cc:}}[[@LINE-4]]