llvm-project/clang/lib/AST
Peter Collingbourne d954601f63 CFI: Implement bitset emission for the Microsoft ABI.
Clang's control flow integrity implementation works by conceptually attaching
"tags" (in the form of bitset entries) to each virtual table, identifying
the names of the classes that the virtual table is compatible with. Under
the Itanium ABI, it is simple to assign tags to virtual tables; they are
simply the address points, which are available via VTableLayout. Because any
overridden methods receive an entry in the derived class's virtual table,
a check for an overridden method call can always be done by checking the
tag of whichever derived class overrode the method call.

The Microsoft ABI is a little different, as it does not directly use address
points, and overrides in a derived class do not cause new virtual table entries
to be added to the derived class; instead, the slot in the base class is
reused, and the compiler needs to adjust the this pointer at the call site
to (generally) the base class that initially defined the method. After the
this pointer has been adjusted, we cannot check for the derived class's tag,
as the virtual table may not be compatible with the derived class. So we
need to determine which base class we have been adjusted to.

Specifically, at each call site, we use ASTRecordLayout to identify the most
derived class whose virtual table is laid out at the "this" pointer offset
we are using to make the call, and check the virtual table for that tag.

Because address point information is unavailable, we "reconstruct" it as
follows: any virtual tables we create for a non-derived class receive a tag
for that class, and virtual tables for a base class inside a derived class
receive a tag for the base class, together with tags for any derived classes
which are laid out at the same position as the derived class (and therefore
have compatible virtual tables).

Differential Revision: http://reviews.llvm.org/D10520

llvm-svn: 240117
2015-06-19 02:30:43 +00:00
..
APValue.cpp Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or just letting them be implicitly created. 2014-08-27 06:28:36 +00:00
ASTConsumer.cpp Sort all of Clang's files under 'lib', and fix up the broken headers 2012-12-04 09:13:33 +00:00
ASTContext.cpp Honor the objc_runtime_name attribute when encoding class/protocol names. 2015-06-16 21:04:55 +00:00
ASTDiagnostic.cpp Update assumption in template diffing about integer template arguments. 2015-02-26 02:40:48 +00:00
ASTDumper.cpp [modules] Add local submodule visibility support for declarations. 2015-05-15 20:05:43 +00:00
ASTImporter.cpp Use a more reliable method to determine whether 2015-04-30 00:44:21 +00:00
ASTTypeTraits.cpp Fix bug in DynTypedMatcher::constructVariadic() that would cause false negatives. 2014-10-06 13:14:30 +00:00
AttrImpl.cpp Devirtualize Attr and all subclasses. 2015-03-19 16:06:49 +00:00
CMakeLists.txt MS ABI: Don't use the Itanium scheme for numbering lambdas 2014-08-22 04:22:50 +00:00
CXXABI.h MS ABI: Implement copy-ctor closures, finish implementing throw 2015-03-11 18:36:39 +00:00
CXXInheritance.cpp CXXInheritance: Modernize removal of hidden virtual base class decls. 2015-02-11 19:09:16 +00:00
Comment.cpp Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>. 2014-08-30 16:55:39 +00:00
CommentBriefParser.cpp Some refactoring in my patch on document 2013-03-02 02:39:57 +00:00
CommentCommandTraits.cpp Fix for PR21254 - Assertion in comment parser 2014-10-15 16:18:20 +00:00
CommentLexer.cpp Comment parsing: fix an assertion failure on a verbatim block terminated with "**/" 2015-04-15 23:45:43 +00:00
CommentParser.cpp [C++11] Use 'nullptr'. AST edition. 2014-05-12 05:36:57 +00:00
CommentSema.cpp [C++11] Use 'nullptr'. AST edition. 2014-05-12 05:36:57 +00:00
Decl.cpp [AST] Put VarDeclBitfields on a diet 2015-05-19 00:57:16 +00:00
DeclBase.cpp [modules] Fix some visibility issues with default template arguments. 2015-06-09 00:35:49 +00:00
DeclCXX.cpp Update -Winvalid-noreturn to handle destructors better. 2015-05-28 00:14:02 +00:00
DeclFriend.cpp [C++11] Use 'nullptr'. AST edition. 2014-05-12 05:36:57 +00:00
DeclGroup.cpp Replace custom alignment enforcement with LLVM_ALIGNAS. 2015-04-02 12:25:07 +00:00
DeclObjC.cpp [modules] Deserialize CXXCtorInitializer list for a constructor lazily. 2015-03-24 06:36:48 +00:00
DeclOpenMP.cpp [C++11] Use 'nullptr'. AST edition. 2014-05-12 05:36:57 +00:00
DeclPrinter.cpp [AST] There is no message for C++1z-style static_assert 2015-06-05 18:03:58 +00:00
DeclTemplate.cpp [modules] Improve diagnostic for a template-id that's invalid because a default 2015-06-17 20:16:32 +00:00
DeclarationName.cpp [C++11] Use 'nullptr'. AST edition. 2014-05-12 05:36:57 +00:00
Expr.cpp some StmtExprs do not have side-effects 2015-06-10 15:18:23 +00:00
ExprCXX.cpp Replace the broken LambdaCapture::isInitCapture API. 2015-05-07 18:48:18 +00:00
ExprClassification.cpp Implementing C99 partial re-initialization behavior (DR-253) 2015-06-10 00:27:52 +00:00
ExprConstant.cpp Implementing C99 partial re-initialization behavior (DR-253) 2015-06-10 00:27:52 +00:00
ExternalASTSource.cpp [modules] Deserialize CXXCtorInitializer list for a constructor lazily. 2015-03-24 06:36:48 +00:00
InheritViz.cpp InheritViz: Hide implementation details 2015-03-09 15:03:20 +00:00
ItaniumCXXABI.cpp Replace getPointeeType()->isFunctionType with isMemberDataPointerType 2015-04-24 01:25:08 +00:00
ItaniumMangle.cpp CFI: Implement bitset emission for the Microsoft ABI. 2015-06-19 02:30:43 +00:00
Makefile
Mangle.cpp This patch fixes a crash involving use of predefined 2014-12-02 18:42:51 +00:00
MicrosoftCXXABI.cpp Wrap to 80 columns. No behavior change. 2015-06-12 04:44:52 +00:00
MicrosoftMangle.cpp CFI: Implement bitset emission for the Microsoft ABI. 2015-06-19 02:30:43 +00:00
NSAPI.cpp [modules] Stop trying to fake up a linear MacroDirective history. 2015-04-29 23:20:19 +00:00
NestedNameSpecifier.cpp -ms-extensions: Implement __super scope specifier (PR13236). 2014-09-26 00:28:20 +00:00
ParentMap.cpp [C++11] Use 'nullptr'. AST edition. 2014-05-12 05:36:57 +00:00
RawCommentList.cpp Comment parsing: when comment ranges are deserialized from multiple modules, 2014-03-27 15:40:39 +00:00
RecordLayout.cpp CXXInfo memory should be released after calling the destructor 2014-05-24 07:19:25 +00:00
RecordLayoutBuilder.cpp Fix "the the" in comments/documentation/etc. 2015-06-19 01:52:53 +00:00
SelectorLocationsKind.cpp
Stmt.cpp [OPENMP] Support for '#pragma omp taskgroup' directive. 2015-06-18 12:14:09 +00:00
StmtIterator.cpp [C++11] Use 'nullptr'. AST edition. 2014-05-12 05:36:57 +00:00
StmtPrinter.cpp [OPENMP] Support for '#pragma omp taskgroup' directive. 2015-06-18 12:14:09 +00:00
StmtProfile.cpp [OPENMP] Support for '#pragma omp taskgroup' directive. 2015-06-18 12:14:09 +00:00
StmtViz.cpp
TemplateBase.cpp Use APSInt::isSameValue instead of operator== in a place where two APSInt's 2015-01-09 00:58:16 +00:00
TemplateName.cpp [C++11] Use 'nullptr'. AST edition. 2014-05-12 05:36:57 +00:00
Type.cpp Fix confusing indent. No behavior change. 2015-05-18 00:00:29 +00:00
TypeLoc.cpp Fix initializing TypeOfTypeLoc 2014-10-24 13:52:55 +00:00
TypePrinter.cpp TypePrinter print __restrict if not in C99 mode 2015-03-03 23:58:09 +00:00
VTTBuilder.cpp Update for LLVM API change to make Small(Ptr)Set::insert return pair<iterator, bool> as per the C++ standard's associative container concept. 2014-11-19 07:49:47 +00:00
VTableBuilder.cpp Wrap a few comments to 80 columns. 2015-05-16 23:49:53 +00:00