113e9c1d1SMitch Phillips /// Same as global-location.cpp, but without debuginfo. In a separate file to
213e9c1d1SMitch Phillips /// allow this test to also run on Windows (which can't be done for the
313e9c1d1SMitch Phillips /// debuginfo variant).
413e9c1d1SMitch Phillips 
513e9c1d1SMitch Phillips // RUN: %clangxx_asan -O2 %S/global-location.cpp -o %t -Wl,-S
613e9c1d1SMitch Phillips // RUN: not %run %t g 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=GLOB-NO-G
713e9c1d1SMitch Phillips // RUN: not %run %t c 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CLASS_STATIC-NO-G
813e9c1d1SMitch Phillips // RUN: not %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=FUNC_STATIC-NO-G
913e9c1d1SMitch Phillips // RUN: not %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=LITERAL-NO-G
1013e9c1d1SMitch Phillips 
11b4ae67ffSRainer Orth /// Solaris ld -S has different semantics.
12b4ae67ffSRainer Orth // XFAIL: solaris
13b4ae67ffSRainer Orth 
14*ca479dacSMitch Phillips /// MSVC linker doesn't support `-S`.
15*ca479dacSMitch Phillips // UNSUPPORTED: windows
16*ca479dacSMitch Phillips 
1713e9c1d1SMitch Phillips // CHECK: AddressSanitizer: global-buffer-overflow
187b235527SMitch Phillips // CLASS_STATIC-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable '{{.*}}C::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
197b235527SMitch Phillips // GLOB-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable '{{.*}}global{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
207b235527SMitch Phillips // FUNC_STATIC-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable '{{.*}}main::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
2113e9c1d1SMitch Phillips // LITERAL-NO-G: 0x{{.*}} is located 0 bytes to the right of global variable {{.*}} defined in '{{.*}}global-location.cpp' {{.*}} of size 11
2213e9c1d1SMitch Phillips // CHECK: SUMMARY: AddressSanitizer: global-buffer-overflow
23