diff options
author | Kostya Serebryany <kcc@google.com> | 2015-02-25 00:49:12 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2015-02-25 00:49:12 +0000 |
commit | efa60dfd347fe18c47cd94f176a856769938b605 (patch) | |
tree | 9d512707c5a647e2225e53c55e8a89d39e3f644a | |
parent | 7d1069d09ed6b9c1026132bb1d68952f079e8db7 (diff) | |
download | bcm5719-llvm-efa60dfd347fe18c47cd94f176a856769938b605.tar.gz bcm5719-llvm-efa60dfd347fe18c47cd94f176a856769938b605.zip |
[asan] add suppressions for odr violations
llvm-svn: 230409
-rw-r--r-- | compiler-rt/lib/asan/asan_globals.cc | 4 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_suppressions.cc | 11 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_suppressions.h | 1 | ||||
-rw-r--r-- | compiler-rt/test/asan/TestCases/Linux/odr-violation.cc | 5 |
4 files changed, 19 insertions, 2 deletions
diff --git a/compiler-rt/lib/asan/asan_globals.cc b/compiler-rt/lib/asan/asan_globals.cc index c8f6f447343..853a1810247 100644 --- a/compiler-rt/lib/asan/asan_globals.cc +++ b/compiler-rt/lib/asan/asan_globals.cc @@ -18,6 +18,7 @@ #include "asan_report.h" #include "asan_stack.h" #include "asan_stats.h" +#include "asan_suppressions.h" #include "asan_thread.h" #include "sanitizer_common/sanitizer_common.h" #include "sanitizer_common/sanitizer_mutex.h" @@ -158,7 +159,8 @@ static void RegisterGlobal(const Global *g) { // the entire redzone of the second global may be within the first global. for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) { if (g->beg == l->g->beg && - (flags()->detect_odr_violation >= 2 || g->size != l->g->size)) + (flags()->detect_odr_violation >= 2 || g->size != l->g->size) && + !IsODRViolationSuppressed(g->name)) ReportODRViolation(g, FindRegistrationSite(g), l->g, FindRegistrationSite(l->g)); } diff --git a/compiler-rt/lib/asan/asan_suppressions.cc b/compiler-rt/lib/asan/asan_suppressions.cc index 62198aec64e..ea40554e453 100644 --- a/compiler-rt/lib/asan/asan_suppressions.cc +++ b/compiler-rt/lib/asan/asan_suppressions.cc @@ -26,8 +26,10 @@ static SuppressionContext *suppression_ctx = nullptr; static const char kInterceptorName[] = "interceptor_name"; static const char kInterceptorViaFunction[] = "interceptor_via_fun"; static const char kInterceptorViaLibrary[] = "interceptor_via_lib"; +static const char kODRViolation[] = "odr_violation"; static const char *kSuppressionTypes[] = { - kInterceptorName, kInterceptorViaFunction, kInterceptorViaLibrary}; + kInterceptorName, kInterceptorViaFunction, kInterceptorViaLibrary, + kODRViolation}; void InitializeSuppressions() { CHECK_EQ(nullptr, suppression_ctx); @@ -49,6 +51,13 @@ bool HaveStackTraceBasedSuppressions() { suppression_ctx->HasSuppressionType(kInterceptorViaLibrary); } +bool IsODRViolationSuppressed(const char *global_var_name) { + CHECK(suppression_ctx); + Suppression *s; + // Match "odr_violation" suppressions. + return suppression_ctx->Match(global_var_name, kODRViolation, &s); +} + bool IsStackTraceSuppressed(const StackTrace *stack) { if (!HaveStackTraceBasedSuppressions()) return false; diff --git a/compiler-rt/lib/asan/asan_suppressions.h b/compiler-rt/lib/asan/asan_suppressions.h index cd7ba2ef0ae..5246b4b3033 100644 --- a/compiler-rt/lib/asan/asan_suppressions.h +++ b/compiler-rt/lib/asan/asan_suppressions.h @@ -23,6 +23,7 @@ void InitializeSuppressions(); bool IsInterceptorSuppressed(const char *interceptor_name); bool HaveStackTraceBasedSuppressions(); bool IsStackTraceSuppressed(const StackTrace *stack); +bool IsODRViolationSuppressed(const char *global_var_name); } // namespace __asan diff --git a/compiler-rt/test/asan/TestCases/Linux/odr-violation.cc b/compiler-rt/test/asan/TestCases/Linux/odr-violation.cc index 4e130837d86..38cecc5f955 100644 --- a/compiler-rt/test/asan/TestCases/Linux/odr-violation.cc +++ b/compiler-rt/test/asan/TestCases/Linux/odr-violation.cc @@ -17,6 +17,11 @@ // RUN: ASAN_OPTIONS=fast_unwind_on_malloc=0:detect_odr_violation=1 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED // RUN: ASAN_OPTIONS=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s // RUN: not %run %t-ODR-EXE 2>&1 | FileCheck %s +// RUN: echo "odr_violation:foo::ZZZ" > %t.supp +// RUN: ASAN_OPTIONS=fast_unwind_on_malloc=0:detect_odr_violation=2:suppressions=%t.supp not %run %t-ODR-EXE 2>&1 | FileCheck %s +// RUN: echo "odr_violation:foo::G" > %t.supp +// RUN: ASAN_OPTIONS=fast_unwind_on_malloc=0:detect_odr_violation=2:suppressions=%t.supp %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED +// RUN: rm -f %t.supp // GNU driver doesn't handle .so files properly. // REQUIRES: Clang |