[PATCH] D48141: [ASan] Linker-initialize static ScopedInErrorReport::current_error_.

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 13 12:06:31 PDT 2018


alekseyshl created this revision.
alekseyshl added reviewers: eugenis, morehouse.
Herald added subscribers: Sanitizers, delcypher, kubamracek.

Static ScopedInErrorReport::current_error_ can be linker initialized to
shave one global ctor call on the startup and be __asan_init-safe.

Issue: https://github.com/google/sanitizers/issues/194


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D48141

Files:
  lib/asan/asan_errors.h
  lib/asan/asan_report.cc


Index: lib/asan/asan_report.cc
===================================================================
--- lib/asan/asan_report.cc
+++ lib/asan/asan_report.cc
@@ -206,7 +206,7 @@
   bool halt_on_error_;
 };
 
-ErrorDescription ScopedInErrorReport::current_error_;
+ErrorDescription ScopedInErrorReport::current_error_(LINKER_INITIALIZED);
 
 void ReportDeadlySignal(const SignalContext &sig) {
   ScopedInErrorReport in_report(/*fatal*/ true);
Index: lib/asan/asan_errors.h
===================================================================
--- lib/asan/asan_errors.h
+++ lib/asan/asan_errors.h
@@ -414,6 +414,7 @@
   };
 
   ErrorDescription() { internal_memset(this, 0, sizeof(*this)); }
+  explicit ErrorDescription(LinkerInitialized) {}
   ASAN_FOR_EACH_ERROR_KIND(ASAN_ERROR_DESCRIPTION_CONSTRUCTOR)
 
   bool IsValid() { return kind != kErrorKindInvalid; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48141.151223.patch
Type: text/x-patch
Size: 860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180613/97116360/attachment.bin>


More information about the llvm-commits mailing list