forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[asan] Optimize initialization order checking (llvm#101837)
The pair `__asan_before_dynamic_init` and `__asan_after_dynamic_init` is executed for each TU. `__asan_after_dynamic_init` unpoisons all globals, which makes the time complexity O(N^2), where N is the maximum of the global count and the TU count. This is expensive for large binaries. This patch decreases the time complexity to O(N), when lld and static runtime is used on SANITIZER_CAN_USE_PREINIT_ARRAY platforms. This requires: Enabling incremental poisoning (`__asan_before_dynamic_init` since llvm#101597). Making most `__asan_after_dynamic_init` calls do nothing.
- Loading branch information
1 parent
98ae8ae
commit 93e9a3a
Showing
3 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
compiler-rt/test/asan/TestCases/Linux/initialization-nobug-lld.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// RUN: %clangxx_asan -O3 %S/../initialization-nobug.cpp %S/../Helpers/initialization-nobug-extra.cpp -fuse-ld=lld -o %t && %env_asan_opts=check_initialization_order=true:report_globals=3 %run %t 2>&1 | FileCheck %s --implicit-check-not "DynInit" | ||
|
||
// Same as initialization-nobug.cpp, but with lld we expect just one | ||
// `DynInitUnpoison` executed after `AfterDynamicInit` at the end. | ||
// REQUIRES: lld-available | ||
|
||
// With dynamic runtimes `AfterDynamicInit` will called before `executable` | ||
// contructors, with constructors of dynamic runtime. | ||
// XFAIL: asan-dynamic-runtime | ||
|
||
// CHECK: DynInitPoison | ||
// CHECK: DynInitPoison | ||
// CHECK: UnpoisonBeforeMain | ||
// CHECK: DynInitUnpoison |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters