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