diff options
author | kcc <kcc@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-22 07:09:21 +0000 |
---|---|---|
committer | kcc <kcc@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-22 07:09:21 +0000 |
commit | 7d752f28b590bbad13c877c2aa7f5f8de2cdff10 (patch) | |
tree | f90afdf42b3ae78508a5c6422f458a5bb0216aa2 /libsanitizer/ubsan | |
parent | ca1a66e9c405dff80abce41c96371525e515bdb4 (diff) | |
download | gcc-7d752f28b590bbad13c877c2aa7f5f8de2cdff10.tar.gz |
libsanitizer merge from upstream r209283
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210743 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libsanitizer/ubsan')
-rw-r--r-- | libsanitizer/ubsan/ubsan_diag.cc | 21 | ||||
-rw-r--r-- | libsanitizer/ubsan/ubsan_value.h | 6 |
2 files changed, 23 insertions, 4 deletions
diff --git a/libsanitizer/ubsan/ubsan_diag.cc b/libsanitizer/ubsan/ubsan_diag.cc index 786ffa7254f..1dfe7255f68 100644 --- a/libsanitizer/ubsan/ubsan_diag.cc +++ b/libsanitizer/ubsan/ubsan_diag.cc @@ -11,6 +11,7 @@ #include "ubsan_diag.h" #include "sanitizer_common/sanitizer_common.h" +#include "sanitizer_common/sanitizer_flags.h" #include "sanitizer_common/sanitizer_libc.h" #include "sanitizer_common/sanitizer_report_decorator.h" #include "sanitizer_common/sanitizer_stacktrace.h" @@ -19,6 +20,22 @@ using namespace __ubsan; +static void InitializeSanitizerCommon() { + static StaticSpinMutex init_mu; + SpinMutexLock l(&init_mu); + static bool initialized; + if (initialized) + return; + if (0 == internal_strcmp(SanitizerToolName, "SanitizerTool")) { + // UBSan is run in a standalone mode. Initialize it now. + SanitizerToolName = "UndefinedBehaviorSanitizer"; + CommonFlags *cf = common_flags(); + SetCommonFlagsDefaults(cf); + cf->print_summary = false; + } + initialized = true; +} + Location __ubsan::getCallerLocation(uptr CallerLoc) { if (!CallerLoc) return Location(); @@ -30,9 +47,11 @@ Location __ubsan::getCallerLocation(uptr CallerLoc) { Location __ubsan::getFunctionLocation(uptr Loc, const char **FName) { if (!Loc) return Location(); + // FIXME: We may need to run initialization earlier. + InitializeSanitizerCommon(); AddressInfo Info; - if (!Symbolizer::GetOrInit()->SymbolizeCode(Loc, &Info, 1) || + if (!Symbolizer::GetOrInit()->SymbolizePC(Loc, &Info, 1) || !Info.module || !*Info.module) return Location(Loc); diff --git a/libsanitizer/ubsan/ubsan_value.h b/libsanitizer/ubsan/ubsan_value.h index 6ca0f56c99d..abfd31fbd99 100644 --- a/libsanitizer/ubsan/ubsan_value.h +++ b/libsanitizer/ubsan/ubsan_value.h @@ -12,9 +12,9 @@ #ifndef UBSAN_VALUE_H #define UBSAN_VALUE_H -// For now, only support linux and darwin. Other platforms should be easy to -// add, and probably work as-is. -#if !defined(__linux__) && !defined(__APPLE__) +// For now, only support Linux, FreeBSD and Darwin. Other platforms should +// be easy to add, and probably work as-is. +#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__APPLE__) #error "UBSan not supported for this platform!" #endif |