1 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 2 // XFAIL: android 3 // 4 // We use fast_unwind_on_malloc=0 to have full unwinding even w/o frame 5 // pointers. This setting is not on by default because it's too expensive. 6 // 7 // Different size: detect a bug if detect_odr_violation>=1 8 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %dynamiclib 9 // RUN: %clangxx_asan %s %ld_flags_rpath_exe -o %t-ODR-EXE 10 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=1 not %run %t-ODR-EXE 2>&1 | FileCheck %s 11 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s 12 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=0 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED 13 // RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s 14 // 15 // Same size: report a bug only if detect_odr_violation>=2. 16 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %dynamiclib -DSZ=100 17 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=1 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED 18 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s 19 // RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s 20 // RUN: echo "odr_violation:foo::ZZZ" > %t.supp 21 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2:suppressions=%t.supp not %run %t-ODR-EXE 2>&1 | FileCheck %s 22 // RUN: echo "odr_violation:foo::G" > %t.supp 23 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2:suppressions=%t.supp %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED 24 // RUN: rm -f %t.supp 25 // 26 // Use private aliases for global variables without indicator symbol. 27 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %dynamiclib -DSZ=100 28 // RUN: %clangxx_asan -mllvm -asan-use-private-alias %s %ld_flags_rpath_exe -o %t-ODR-EXE 29 // RUN: %env_asan_opts=fast_unwind_on_malloc=0 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED 30 31 // Use private aliases for global variables: use indicator symbol to detect ODR violation. 32 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared -mllvm -asan-use-private-alias -mllvm -asan-use-odr-indicator %s -o %dynamiclib -DSZ=100 33 // RUN: %clangxx_asan -mllvm -asan-use-private-alias -mllvm -asan-use-odr-indicator %s %ld_flags_rpath_exe -o %t-ODR-EXE 34 // RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s 35 36 // Same as above but with clang switches. 37 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared -fsanitize-address-use-odr-indicator %s -o %dynamiclib -DSZ=100 38 // RUN: %clangxx_asan -fsanitize-address-use-odr-indicator %s %ld_flags_rpath_exe -o %t-ODR-EXE 39 // RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s 40 41 // GNU driver doesn't handle .so files properly. 42 // REQUIRES: Clang 43 44 #ifndef SZ 45 # define SZ 4 46 #endif 47 48 #if BUILD_SO 49 namespace foo { char G[SZ]; } 50 #else 51 #include <stdio.h> 52 namespace foo { char G[100]; } 53 // CHECK: ERROR: AddressSanitizer: odr-violation 54 // CHECK: size=100 'foo::G' {{.*}}odr-violation.cpp:[[@LINE-2]]:22 55 // CHECK: size={{4|100}} 'foo::G' 56 int main(int argc, char **argv) { 57 printf("PASS: %p\n", &foo::G); 58 } 59 #endif 60 61 // CHECK: These globals were registered at these points: 62 // CHECK: ODR-EXE 63 // CHECK: odr-violation.cpp.dynamic 64 // CHECK: SUMMARY: AddressSanitizer: odr-violation: global 'foo::G' at {{.*}}odr-violation.cpp 65 // DISABLED: PASS 66