brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · f8a3eae Raw
35 lines · c
1// Test that we can properly report an ODR violation between an instrumented2// global and a non-instrumented global if not using private aliases.3 4// RUN: mkdir -p %t.dir && cd %t.dir5// RUN: %clang_asan -fcommon %s -fPIC -shared -mllvm -asan-use-private-alias=0 -o %dynamiclib1  -DFILE16// RUN: %clang_asan -fcommon %s -fPIC -shared -mllvm -asan-use-private-alias=0 -o %dynamiclib2  -DFILE27// RUN: %clang_asan -fcommon %s -fPIE %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t.dir/exe8// RUN: not %run %t.dir/exe 2>&1 | FileCheck %s9 10// RUN: %clang_asan -fcommon %s -fPIC -shared -mllvm -asan-use-private-alias=1 -o %dynamiclib1  -DFILE111// RUN: %clang_asan -fcommon %s -fPIC -shared -mllvm -asan-use-private-alias=1 -o %dynamiclib2  -DFILE212// RUN: %run %t.dir/exe 2>&1 | count 013 14// Unaligned accesses don't work on strict-alignment targets like SPARC.15// UNSUPPORTED: sparc-target-arch16 17// CHECK: The following global variable is not properly aligned.18// CHECK: ERROR: AddressSanitizer: odr-violation19#if defined(FILE1)20__attribute__((aligned(8))) int x;21__attribute__((aligned(1))) char y;22// The gold linker puts ZZZ at the start of bss (where it is aligned)23// unless we have a large alternative like Displace:24__attribute__((aligned(1))) char Displace[105];25__attribute__((aligned(1))) char ZZZ[100];26#elif defined(FILE2)27int ZZZ = 1;28#else29extern int ZZZ;30int main() {31  return ZZZ;32}33#endif34 35