@@ -520,43 +520,6 @@ void __asan_before_dynamic_init(const char *module_name) {
520
520
current_dynamic_init_module_name = module_name;
521
521
}
522
522
523
- // Maybe SANITIZER_CAN_USE_PREINIT_ARRAY is to conservative for `.init_array`,
524
- // however we should not make mistake here. If `UnpoisonBeforeMain` was not
525
- // executed at all we will have false reports on globals.
526
- #if SANITIZER_CAN_USE_PREINIT_ARRAY
527
- // This optimization aims to reduce the overhead of `__asan_after_dynamic_init`
528
- // calls by leveraging incremental unpoisoning/poisoning in
529
- // `__asan_before_dynamic_init`. We expect most `__asan_after_dynamic_init
530
- // calls` to be no-ops. However, to ensure all globals are unpoisoned before the
531
- // `main`, we force `UnpoisonBeforeMain` to fully execute
532
- // `__asan_after_dynamic_init`.
533
-
534
- // With lld, `UnpoisonBeforeMain` runs after standard `.init_array`, making it
535
- // the final `__asan_after_dynamic_init` call for the static runtime. In
536
- // contrast, GNU ld executes it earlier, causing subsequent
537
- // `__asan_after_dynamic_init` calls to perform full unpoisoning, losing the
538
- // optimization.
539
- bool allow_after_dynamic_init SANITIZER_GUARDED_BY (mu_for_globals) = false;
540
-
541
- static void UnpoisonBeforeMain (void ) {
542
- {
543
- Lock lock (&mu_for_globals);
544
- if (allow_after_dynamic_init)
545
- return ;
546
- allow_after_dynamic_init = true ;
547
- }
548
- if (flags ()->report_globals >= 3 )
549
- Printf (" UnpoisonBeforeMain\n " );
550
- __asan_after_dynamic_init ();
551
- }
552
-
553
- __attribute__ ((section(" .init_array.65537" ), used)) static void (
554
- *asan_after_init_array)(void ) = UnpoisonBeforeMain;
555
- #else
556
- // Incremental poisoning is disabled, unpoison globals immediately.
557
- static constexpr bool allow_after_dynamic_init = true ;
558
- #endif // SANITIZER_CAN_USE_PREINIT_ARRAY
559
-
560
523
// This method runs immediately after dynamic initialization in each TU, when
561
524
// all dynamically initialized globals except for those defined in the current
562
525
// TU are poisoned. It simply unpoisons all dynamically initialized globals.
@@ -565,8 +528,6 @@ void __asan_after_dynamic_init() {
565
528
return ;
566
529
CHECK (AsanInited ());
567
530
Lock lock (&mu_for_globals);
568
- if (!allow_after_dynamic_init)
569
- return ;
570
531
if (!current_dynamic_init_module_name)
571
532
return ;
572
533
0 commit comments