1 // Test that non-sanitized executables work with sanitized shared libs
2 // and preloaded runtime.
3 //
4 // RUN: %clangxx -DBUILD_SO=1 -fPIC -shared %s -o %t.so
5 // RUN: %clangxx %s %t.so -o %t
6 //
7 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so
8 // RUN: LD_PRELOAD=%shared_libasan not %run %t 2>&1 | FileCheck %s
9
10 // REQUIRES: asan-dynamic-runtime
11 // XFAIL: android
12
13 #if BUILD_SO
14 char dummy;
do_access(const void * p)15 void do_access(const void *p) {
16 // CHECK: AddressSanitizer: heap-buffer-overflow
17 dummy = ((const char *)p)[1];
18 }
19 #else
20 #include <stdlib.h>
21 extern void do_access(const void *p);
main(int argc,char ** argv)22 int main(int argc, char **argv) {
23 void *p = malloc(1);
24 do_access(p);
25 free(p);
26 return 0;
27 }
28 #endif
29