38 lines · cpp
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 globals3// with same names. Check, that ASan doesn't crash with CHECK failure or4// false positive global-buffer-overflow due to sanitized library poisons5// globals from non-sanitized one.6//7// RUN: mkdir -p %t.dir && cd %t.dir8// RUN: %clangxx_asan -DBUILD_INSTRUMENTED_DSO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %dynamiclib19// RUN: %clangxx -DBUILD_UNINSTRUMENTED_DSO=1 -fPIC -shared %s -o %dynamiclib210// RUN: %clangxx %s -c -mllvm -asan-use-private-alias -o %t.o11// RUN: %clangxx_asan %t.o %ld_flags_rpath_exe2 %ld_flags_rpath_exe1 -o %t.dir/EXE12// RUN: %run %t.dir/EXE13 14#if defined (BUILD_INSTRUMENTED_DSO)15long h = 15;16long f = 4;17long foo(long *p) {18 return *p;19}20#elif defined (BUILD_UNINSTRUMENTED_DSO)21long foo(long *);22long h = 12;23long i = 13;24long f = 5;25 26int bar() {27 if (foo(&f) != 5 || foo(&h) != 12 || foo(&i) != 13)28 return 1;29 return 0;30}31#else32extern int bar();33 34int main() {35 return bar();36}37#endif38