summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2018-06-14 18:22:23 +0000
committerAlex Shlyapnikov <alekseys@google.com>2018-06-14 18:22:23 +0000
commit241b75869011979b6b3aa36692e6871e24040cc7 (patch)
treefc141e3aef985cb2c4cdf7825f0c60b361122884
parentf56ef90e26bd1bb5cfa8e4b0e09ec56a9142dbfb (diff)
downloadbcm5719-llvm-241b75869011979b6b3aa36692e6871e24040cc7.tar.gz
bcm5719-llvm-241b75869011979b6b3aa36692e6871e24040cc7.zip
[ASan] Linker-initialize static ScopedInErrorReport::current_error_.
Summary: Static ScopedInErrorReport::current_error_ can be linker initialized to shave one global ctor call on application startup and be __asan_init-safe. Global constructors in ASan runtime are bad because __asan_init runs from preinit_array, before any such constructors. Issue: https://github.com/google/sanitizers/issues/194 Reviewers: eugenis, morehouse Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D48141 llvm-svn: 334748
-rw-r--r--compiler-rt/lib/asan/asan_errors.h1
-rw-r--r--compiler-rt/lib/asan/asan_report.cc2
2 files changed, 2 insertions, 1 deletions
diff --git a/compiler-rt/lib/asan/asan_errors.h b/compiler-rt/lib/asan/asan_errors.h
index 512d2537bd0..574197ebff8 100644
--- a/compiler-rt/lib/asan/asan_errors.h
+++ b/compiler-rt/lib/asan/asan_errors.h
@@ -414,6 +414,7 @@ struct ErrorDescription {
};
ErrorDescription() { internal_memset(this, 0, sizeof(*this)); }
+ explicit ErrorDescription(LinkerInitialized) {}
ASAN_FOR_EACH_ERROR_KIND(ASAN_ERROR_DESCRIPTION_CONSTRUCTOR)
bool IsValid() { return kind != kErrorKindInvalid; }
diff --git a/compiler-rt/lib/asan/asan_report.cc b/compiler-rt/lib/asan/asan_report.cc
index 18daace3990..b1762c6974e 100644
--- a/compiler-rt/lib/asan/asan_report.cc
+++ b/compiler-rt/lib/asan/asan_report.cc
@@ -206,7 +206,7 @@ class ScopedInErrorReport {
bool halt_on_error_;
};
-ErrorDescription ScopedInErrorReport::current_error_;
+ErrorDescription ScopedInErrorReport::current_error_(LINKER_INITIALIZED);
void ReportDeadlySignal(const SignalContext &sig) {
ScopedInErrorReport in_report(/*fatal*/ true);
OpenPOWER on IntegriCloud