• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Test that mixing instrumented and non-instrumented code doesn't lead to crash.
2 // Build two modules (one is instrumented, another is not) that have globals
3 // with same names. Check, that ASan doesn't crash with CHECK failure or
4 // false positive global-buffer-overflow due to sanitized library poisons
5 // globals from non-sanitized one.
6 //
7 // FIXME: https://github.com/google/sanitizers/issues/316
8 // XFAIL: android
9 // XFAIL: mips64
10 //
11 // RUN: %clangxx_asan -DBUILD_INSTRUMENTED_DSO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %t-INSTRUMENTED-SO.so
12 // RUN: %clangxx -DBUILD_UNINSTRUMENTED_DSO=1 -fPIC -shared %s -o %t-UNINSTRUMENTED-SO.so
13 // RUN: %clangxx %s -c -mllvm -asan-use-private-alias -o %t.o
14 // RUN: %clangxx_asan %t.o %t-UNINSTRUMENTED-SO.so %t-INSTRUMENTED-SO.so -o %t-EXE
15 // RUN: %env_asan_opts=use_odr_indicator=true %run %t-EXE
16 
17 #if defined (BUILD_INSTRUMENTED_DSO)
18 long h = 15;
19 long f = 4;
foo(long * p)20 long foo(long *p) {
21   return *p;
22 }
23 #elif defined (BUILD_UNINSTRUMENTED_DSO)
24 long foo(long *);
25 long h = 12;
26 long i = 13;
27 long f = 5;
28 
bar()29 int bar() {
30   if (foo(&f) != 5 || foo(&h) != 12 || foo(&i) != 13)
31     return 1;
32   return 0;
33 }
34 #else
35 extern int bar();
36 
main()37 int main() {
38   return bar();
39 }
40 #endif
41