Implement Control Flow Integrity for virtual calls.
This patch introduces the -fsanitize=cfi-vptr flag, which enables a control
flow integrity scheme that checks that virtual calls take place using a vptr of
the correct dynamic type. More details in the new docs/ControlFlowIntegrity.rst
file.
It also introduces the -fsanitize=cfi flag, which is currently a synonym for
-fsanitize=cfi-vptr, but will eventually cover all CFI checks implemented
in Clang.
Differential Revision: http://reviews.llvm.org/D7424
llvm-svn: 230055
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 7bec383..d09378c 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -47,7 +47,8 @@
SupportsCoverage = Address | Memory | Leak | Undefined | Integer,
RecoverableByDefault = Undefined | Integer,
Unrecoverable = Address | Unreachable | Return,
- LegacyFsanitizeRecoverMask = Undefined | Integer
+ LegacyFsanitizeRecoverMask = Undefined | Integer,
+ NeedsLTO = CFIVptr,
};
}
@@ -148,6 +149,10 @@
return hasOneOf(Sanitizers, NeedsUnwindTables);
}
+bool SanitizerArgs::needsLTO() const {
+ return hasOneOf(Sanitizers, CFIVptr);
+}
+
void SanitizerArgs::clear() {
Sanitizers.clear();
RecoverableSanitizers.clear();