1 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 2 // XFAIL: android 3 // 4 // Different size: detect a bug if detect_odr_violation>=1 5 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t-ODR-SO.so 6 // RUN: %clangxx_asan %s %t-ODR-SO.so -Wl,-R. -o %t-ODR-EXE 7 // RUN: ASAN_OPTIONS=detect_odr_violation=1 not %run %t-ODR-EXE 2>&1 | FileCheck %s 8 // RUN: ASAN_OPTIONS=detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s 9 // RUN: ASAN_OPTIONS=detect_odr_violation=0 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED 10 // RUN: not %run %t-ODR-EXE 2>&1 | FileCheck %s 11 // 12 // Same size: report a bug only if detect_odr_violation>=2. 13 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t-ODR-SO.so -DSZ=100 14 // RUN: ASAN_OPTIONS=detect_odr_violation=1 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED 15 // RUN: ASAN_OPTIONS=detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s 16 // RUN: not %run %t-ODR-EXE 2>&1 | FileCheck %s 17 18 // GNU driver doesn't handle .so files properly. 19 // REQUIRES: Clang 20 21 #ifndef SZ 22 # define SZ 4 23 #endif 24 25 #if BUILD_SO 26 char G[SZ]; 27 #else 28 #include <stdio.h> 29 char G[100]; 30 int main(int argc, char **argv) { 31 printf("PASS: %p\n", &G); 32 } 33 #endif 34 35 // CHECK: ERROR: AddressSanitizer: odr-violation 36 // CHECK: size=100 G 37 // CHECK: size={{4|100}} G 38 // CHECK: These globals were registered at these points: 39 // CHECK: ODR-EXE 40 // CHECK: ODR-SO 41 // DISABLED: PASS 42