odr-violation.cc revision 2d1fdb26e458c4ddc04155c1d421bced3ba90cd0
1// Different size: detect a bug if detect_odr_violation>=1 2// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so 3// RUN: %clangxx_asan %s %t.so -Wl,-R. -o %t 4// RUN: ASAN_OPTIONS=detect_odr_violation=1 not %run %t 2>&1 | FileCheck %s 5// RUN: ASAN_OPTIONS=detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s 6// RUN: ASAN_OPTIONS=detect_odr_violation=0 %run %t 2>&1 | FileCheck %s --check-prefix=DISABLED 7// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=DISABLED 8// 9// Same size: report a bug only if detect_odr_violation>=2. 10// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so -DSZ=100 11// RUN: ASAN_OPTIONS=detect_odr_violation=1 %run %t 2>&1 | FileCheck %s --check-prefix=DISABLED 12// RUN: ASAN_OPTIONS=detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s 13 14// GNU driver doesn't handle .so files properly. 15// REQUIRES: Clang 16 17#ifndef SZ 18# define SZ 4 19#endif 20 21#if BUILD_SO 22char G[SZ]; 23#else 24#include <stdio.h> 25char G[100]; 26int main(int argc, char **argv) { 27 printf("PASS: %p\n", &G); 28} 29#endif 30 31// CHECK: ERROR: AddressSanitizer: odr-violation 32// CHECK: size=100 G 33// DISABLED: PASS 34