r255736 - [cfi] Exclude ubsan runtime library from non-diag CFI builds (driver changes).
Evgeniy Stepanov via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 15 16:38:42 PST 2015
Author: eugenis
Date: Tue Dec 15 18:38:42 2015
New Revision: 255736
URL: http://llvm.org/viewvc/llvm-project?rev=255736&view=rev
Log:
[cfi] Exclude ubsan runtime library from non-diag CFI builds (driver changes).
Split the CFI runtime in two: cfi and cfi_diag. The latter includes
UBSan runtime to allow printing diagnostics.
Modified:
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/sanitizer-ld.c
Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=255736&r1=255735&r2=255736&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Tue Dec 15 18:38:42 2015
@@ -55,6 +55,7 @@ class SanitizerArgs {
return Sanitizers.has(SanitizerKind::SafeStack);
}
bool needsCfiRt() const;
+ bool needsCfiDiagRt() const;
bool requiresPIE() const;
bool needsUnwindTables() const;
Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=255736&r1=255735&r2=255736&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Tue Dec 15 18:38:42 2015
@@ -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 {
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=255736&r1=255735&r2=255736&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Dec 15 18:38:42 2015
@@ -2794,6 +2794,8 @@ collectSanitizerRuntimes(const ToolChain
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++,
Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=255736&r1=255735&r2=255736&view=diff
==============================================================================
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Tue Dec 15 18:38:42 2015
@@ -317,7 +317,7 @@
// 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.
@@ -328,7 +328,7 @@
// 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 \
More information about the cfe-commits
mailing list