mirror of
https://github.com/darlinghq/darling-compiler-rt.git
synced 2024-11-27 13:50:30 +00:00
[asan] add suppressions for odr violations
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230409 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
79be91c1d0
commit
562af0e7f9
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user