• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Test that we can properly report an ODR violation
2 // between an instrumented global and a non-instrumented global.
3 
4 // RUN: %clang_asan %s -fPIC -shared -o %t-1.so  -DFILE1
5 // RUN: %clang_asan %s -fPIC -shared -o %t-2.so  -DFILE2
6 // RUN: %clang_asan %s -fPIE %t-1.so %t-2.so -Wl,-R`pwd` -o %t
7 // RUN: not %run %t 2>&1 | FileCheck %s
8 //
9 // REQUIRES: x86_64-target-arch
10 //
11 // CHECK: The following global variable is not properly aligned.
12 // CHECK: ERROR: AddressSanitizer: odr-violation
13 #if defined(FILE1)
14 __attribute__((aligned(8))) int x;
15 __attribute__((aligned(1))) char y;
16 // The gold linker puts ZZZ at the start of bss (where it is aligned)
17 // unless we have a large alternative like Displace:
18 __attribute__((aligned(1))) char Displace[105];
19 __attribute__((aligned(1))) char ZZZ[100];
20 #elif defined(FILE2)
21 int ZZZ = 1;
22 #else
23 extern int ZZZ;
main()24 int main() {
25   return ZZZ;
26 }
27 #endif
28 
29