]> granicus.if.org Git - clang/commitdiff
[cfi] Exclude ubsan runtime library from non-diag CFI builds (driver changes).
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 16 Dec 2015 00:38:42 +0000 (00:38 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 16 Dec 2015 00:38:42 +0000 (00:38 +0000)
Split the CFI runtime in two: cfi and cfi_diag. The latter includes
UBSan runtime to allow printing diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255736 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/SanitizerArgs.h
lib/Driver/SanitizerArgs.cpp
lib/Driver/Tools.cpp
test/Driver/sanitizer-ld.c

index 66b6f2ed46f098b4c96f9150c4e258cd4a7750bb..c2611b5cd8ee2b1026523c3d070bd62a0c6eecec 100644 (file)
@@ -55,6 +55,7 @@ class SanitizerArgs {
     return Sanitizers.has(SanitizerKind::SafeStack);
   }
   bool needsCfiRt() const;
+  bool needsCfiDiagRt() const;
 
   bool requiresPIE() const;
   bool needsUnwindTables() const;
index 82ac2b0258c754b836d11f8b0f23b940b32835ca..2fded1c80da99420952ff6a36965c44390e969af 100644 (file)
@@ -165,7 +165,11 @@ bool SanitizerArgs::needsUbsanRt() const {
 }
 
 bool SanitizerArgs::needsCfiRt() const {
-  return CfiCrossDso;
+  return !(Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso;
+}
+
+bool SanitizerArgs::needsCfiDiagRt() const {
+  return (Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso;
 }
 
 bool SanitizerArgs::requiresPIE() const {
index 01cef9070aa83cb7ff85ce3af155fd488a0dd016..20a1035bd582aede0113dd57a6f4af608ff106c1 100644 (file)
@@ -2794,6 +2794,8 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
     StaticRuntimes.push_back("safestack");
   if (SanArgs.needsCfiRt())
     StaticRuntimes.push_back("cfi");
+  if (SanArgs.needsCfiDiagRt())
+    StaticRuntimes.push_back("cfi_diag");
 }
 
 // Should be called before we add system libraries (C++ ABI, libstdc++/libc++,
index 0903ddc61cfa006f0309b1dc6f9e6741a9630d5b..ad30ca390d9bd665cb05ebeac3fe5d7a42a808bd 100644 (file)
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-LINUX %s
 // CHECK-CFI-CROSS-DSO-LINUX: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
-// CHECK-CFI-CROSS-DSO-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-LINUX: libclang_rt.cfi-
 // CHECK-CFI-CROSS-DSO-LINUX-NOT: libclang_rt.
 
 // Cross-DSO CFI with diagnostics links just the CFI runtime.
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-LINUX %s
 // CHECK-CFI-CROSS-DSO-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
-// CHECK-CFI-CROSS-DSO-DIAG-LINUX: libclang_rt.cfi
+// CHECK-CFI-CROSS-DSO-DIAG-LINUX: libclang_rt.cfi_diag-
 // CHECK-CFI-CROSS-DSO-DIAG-LINUX-NOT: libclang_rt.
 
 // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \