Skip to content

Commit

Permalink
Ignore blacklist when generating __cfi_check_fail.
Browse files Browse the repository at this point in the history
Summary: Fixes PR37898.

Reviewers: pcc, vlad.tsyrklevich

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D48454

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335305 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
eugenis committed Jun 21, 2018
1 parent 8fa8ac3 commit ae3ac6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3075,6 +3075,11 @@ void CodeGenFunction::EmitCfiCheckFail() {
StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args,
SourceLocation());

// This function should not be affected by blacklist. This function does
// not have a source location, but "src:*" would still apply. Revert any
// changes to SanOpts made in StartFunction.
SanOpts = CGM.getLangOpts().Sanitize;

llvm::Value *Data =
EmitLoadOfScalar(GetAddrOfLocalVar(&ArgData), /*Volatile=*/false,
CGM.getContext().VoidPtrTy, ArgData.getLocation());
Expand Down
6 changes: 6 additions & 0 deletions test/CodeGen/cfi-check-fail2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
// RUN: -fsanitize=cfi-vcall \
// RUN: -emit-llvm -o - %s | FileCheck %s

// Check that blacklist does not affect generated code.
// RUN: echo "src:*" > %t-all.blacklist
// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \
// RUN: -emit-llvm -o - %s | FileCheck %s

void caller(void (*f)()) {
f();
}
Expand Down

0 comments on commit ae3ac6a

Please sign in to comment.