From 9d6dc7b16426068447d6d7b90c273b1274717a5a Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Tue, 15 Nov 2016 21:12:50 +0000 Subject: [PATCH] [sanitizer-coverage] make sure asan does not instrument coverage guards (reported in https://github.com/google/oss-fuzz/issues/84) llvm-svn: 287030 --- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 2 +- .../test/Instrumentation/SanitizerCoverage/tracing-comdat.ll | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index 73881fa..031effb 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -514,7 +514,7 @@ void SanitizerCoverageModule::CreateFunctionGuardArray(size_t NumGuards, ArrayType *ArrayOfInt32Ty = ArrayType::get(Int32Ty, NumGuards); FunctionGuardArray = new GlobalVariable( *CurModule, ArrayOfInt32Ty, false, GlobalVariable::PrivateLinkage, - Constant::getNullValue(ArrayOfInt32Ty), "__sancov_guard"); + Constant::getNullValue(ArrayOfInt32Ty), "__sancov_gen_"); if (auto Comdat = F.getComdat()) FunctionGuardArray->setComdat(Comdat); FunctionGuardArray->setSection(SanCovTracePCGuardSection); diff --git a/llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll b/llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll index f5fa326..baf4dc1 100644 --- a/llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll +++ b/llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll @@ -1,5 +1,7 @@ ; Test that the coverage guards have proper comdat -; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s +; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s +; Make sure asan does not instrument __sancov_gen_ +; RUN: opt < %s -sancov -asan -asan-module -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" $Foo = comdat any @@ -9,4 +11,10 @@ entry: ret void } -; CHECK: @__sancov_guard = private global [1 x i32] zeroinitializer, section "__sancov_guards", comdat($Foo) +define linkonce_odr void @Bar() { +entry: + ret void +} + +; CHECK: @__sancov_gen_ = private global [1 x i32] zeroinitializer, section "__sancov_guards", comdat($Foo) +; CHECK: @__sancov_gen_.1 = private global [1 x i32] zeroinitializer, section "__sancov_guards" -- 2.7.4