Skip to content

Commit 982cfae

Browse files
authored
[test][asan] Check for order of DynInitPoison (#101584)
Also make sure we have dynamic init variables with any `-O`.
1 parent d6cbcf9 commit 982cfae

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Linker initialized:
22
int getAB();
3-
static int ab = getAB();
3+
int ab = getAB();
44
// Function local statics:
55
int countCalls();
6-
static int one = countCalls();
6+
int one = countCalls();
77
// Trivial constructor, non-trivial destructor:
88
int getStructWithDtorValue();
9-
static int val = getStructWithDtorValue();
9+
int val = getStructWithDtorValue();

compiler-rt/test/asan/TestCases/initialization-nobug.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
// A collection of various initializers which shouldn't trip up initialization
22
// order checking. If successful, this will just return 0.
33

4-
// RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-nobug-extra.cpp -o %t
5-
// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
6-
// RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-nobug-extra.cpp -o %t
7-
// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
8-
// RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-nobug-extra.cpp -o %t
9-
// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
10-
// RUN: %clangxx_asan -O3 %s %p/Helpers/initialization-nobug-extra.cpp -o %t
11-
// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&1
4+
// RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInit"
5+
// RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInit"
6+
// RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInit"
7+
// RUN: %clangxx_asan -O3 %s %p/Helpers/initialization-nobug-extra.cpp -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInit"
128

139
// Simple access:
1410
// Make sure that accessing a global in the same TU is safe
1511

1612
bool condition = true;
17-
int initializeSameTU() {
13+
__attribute__((noinline, weak)) int initializeSameTU() {
1814
return condition ? 0x2a : 052;
1915
}
2016
int sameTU = initializeSameTU();
@@ -46,3 +42,6 @@ StructWithDtor struct_with_dtor;
4642
int getStructWithDtorValue() { return struct_with_dtor.value; }
4743

4844
int main() { return 0; }
45+
46+
// CHECK: DynInitPoison module: {{.*}}initialization-nobug.cpp
47+
// CHECK: DynInitPoison module: {{.*}}initialization-nobug-extra.cpp

0 commit comments

Comments
 (0)