r331674 - [CFI] Force LLVM to die if the implicit blacklist files cannot be found.
Peter Collingbourne via cfe-commits
cfe-commits at lists.llvm.org
Mon May 7 13:54:05 PDT 2018
Author: pcc
Date: Mon May 7 13:54:05 2018
New Revision: 331674
URL: http://llvm.org/viewvc/llvm-project?rev=331674&view=rev
Log:
[CFI] Force LLVM to die if the implicit blacklist files cannot be found.
Currently LLVM CFI tries to use an implicit blacklist file, currently
in /usr/lib64/clang/<version>/share. If the file is not there, LLVM
happily continues, which causes CFI to add checks to files/functions
that are known to fail, generating binaries that fail. This CL causes
LLVM to die (I hope) if it can't find these implicit blacklist files.
Patch by Caroline Tice!
Differential Revision: https://reviews.llvm.org/D46403
Added:
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-blacklist.c
cfe/trunk/test/Frontend/dependency-gen.c
Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=331674&r1=331673&r2=331674&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon May 7 13:54:05 2018
@@ -115,6 +115,10 @@ static void addDefaultBlacklists(const D
llvm::sys::path::append(Path, "share", BL.File);
if (llvm::sys::fs::exists(Path))
BlacklistFiles.push_back(Path.str());
+ else if (BL.Mask == CFI)
+ // If cfi_blacklist.txt cannot be found in the resource dir, driver
+ // should fail.
+ D.Diag(clang::diag::err_drv_no_such_file) << Path;
}
}
Added: cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt?rev=331674&view=auto
==============================================================================
(empty)
Modified: cfe/trunk/test/Driver/fsanitize-blacklist.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-blacklist.c?rev=331674&r1=331673&r2=331674&view=diff
==============================================================================
--- cfe/trunk/test/Driver/fsanitize-blacklist.c (original)
+++ cfe/trunk/test/Driver/fsanitize-blacklist.c Mon May 7 13:54:05 2018
@@ -62,4 +62,8 @@
// CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
// CHECK-ONLY_FIRST-DISABLED-NOT: good
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt'
+
// DELIMITERS: {{^ *"}}
Modified: cfe/trunk/test/Frontend/dependency-gen.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/dependency-gen.c?rev=331674&r1=331673&r2=331674&view=diff
==============================================================================
--- cfe/trunk/test/Frontend/dependency-gen.c (original)
+++ cfe/trunk/test/Frontend/dependency-gen.c Mon May 7 13:54:05 2018
@@ -21,7 +21,7 @@
// RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
// CHECK-SIX: {{ }}x.h
// RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
// CHECK-SEVEN: .blacklist
// CHECK-SEVEN: {{ }}x.h
#ifndef INCLUDE_FLAG_TEST
More information about the cfe-commits
mailing list