diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-06-19 01:51:54 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-06-19 01:51:54 +0000 |
commit | 6708c4a1767d44a4d25938b07f8f144a906fb411 (patch) | |
tree | a669e81facf705913b7aadb42b0e112be99a6557 /clang/lib/Driver/SanitizerArgs.cpp | |
parent | 2a567835d1a77150634800247c864f12ca836f2b (diff) | |
download | bcm5719-llvm-6708c4a1767d44a4d25938b07f8f144a906fb411.tar.gz bcm5719-llvm-6708c4a1767d44a4d25938b07f8f144a906fb411.zip |
Implement diagnostic mode for -fsanitize=cfi*, -fsanitize=cfi-diag.
This causes programs compiled with this flag to print a diagnostic when
a control flow integrity check fails instead of aborting. Diagnostics are
printed using UBSan's runtime library.
The main motivation of this feature over -fsanitize=vptr is fidelity with
the -fsanitize=cfi implementation: the diagnostics are printed under exactly
the same conditions as those which would cause -fsanitize=cfi to abort the
program. This means that the same restrictions apply regarding compiling
all translation units with -fsanitize=cfi, cross-DSO virtual calls are
forbidden, etc.
Differential Revision: http://reviews.llvm.org/D10268
llvm-svn: 240109
Diffstat (limited to 'clang/lib/Driver/SanitizerArgs.cpp')
-rw-r--r-- | clang/lib/Driver/SanitizerArgs.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index fee6e8f3ed3..9918fcbd5e1 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -25,7 +25,7 @@ using namespace clang::driver; using namespace llvm::opt; enum : SanitizerMask { - NeedsUbsanRt = Undefined | Integer, + NeedsUbsanRt = Undefined | Integer | CFI, NotAllowedWithTrap = Vptr, RequiresPIE = Memory | DataFlow, NeedsUnwindTables = Address | Thread | Memory | DataFlow, @@ -35,7 +35,8 @@ enum : SanitizerMask { LegacyFsanitizeRecoverMask = Undefined | Integer, NeedsLTO = CFI, TrappingSupported = - (Undefined & ~Vptr) | UnsignedIntegerOverflow | LocalBounds, + (Undefined & ~Vptr) | UnsignedIntegerOverflow | LocalBounds | CFI, + TrappingDefault = CFI, }; enum CoverageFeature { @@ -166,6 +167,9 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D, } } + // Apply default trapping behavior. + TrappingKinds |= TrappingDefault & ~TrapRemove; + return TrappingKinds; } |