diff options
author | Charles Davis <cdavis5x@gmail.com> | 2016-08-08 21:03:39 +0000 |
---|---|---|
committer | Charles Davis <cdavis5x@gmail.com> | 2016-08-08 21:03:39 +0000 |
commit | 3e43970d71fdcea0120f198ee60cadab667dba09 (patch) | |
tree | 7cf82716bce0a06e605177ea195bc0059b41f5ec /clang/lib/Sema/SemaDeclAttr.cpp | |
parent | 6b4422e6fe22df3523ac0c9d854eb4d2436d99a3 (diff) | |
download | bcm5719-llvm-3e43970d71fdcea0120f198ee60cadab667dba09.tar.gz bcm5719-llvm-3e43970d71fdcea0120f198ee60cadab667dba09.zip |
[Attr] Add support for the `ms_hook_prologue` attribute.
Summary:
Based on a patch by Michael Mueller.
This attribute specifies that a function can be hooked or patched. This
mechanism was originally devised by Microsoft for hotpatching their
binaries (which they're constantly updating to stay ahead of crackers,
script kiddies, and other ne'er-do-wells on the Internet), but it's now
commonly abused by Windows programs that want to hook API functions. It
is for this reason that this attribute was added to GCC--hence the name,
`ms_hook_prologue`.
Depends on D19908.
Reviewers: rnk, aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D19909
llvm-svn: 278050
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index d74cebc718c..5dbe7aa52ea 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1664,15 +1664,6 @@ static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &Attr) { D->addAttr(CA); } -static void handleNakedAttr(Sema &S, Decl *D, const AttributeList &Attr) { - if (checkAttrMutualExclusion<DisableTailCallsAttr>(S, D, Attr.getRange(), - Attr.getName())) - return; - - D->addAttr(::new (S.Context) NakedAttr(Attr.getRange(), S.Context, - Attr.getAttributeSpellingListIndex())); -} - static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &attr) { if (hasDeclarator(D)) return; @@ -3673,7 +3664,9 @@ OptimizeNoneAttr *Sema::mergeOptimizeNoneAttr(Decl *D, SourceRange Range, static void handleAlwaysInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (checkAttrMutualExclusion<NotTailCalledAttr>(S, D, Attr.getRange(), - Attr.getName())) + Attr.getName()) || + checkAttrMutualExclusion<MSHookPrologueAttr>(S, D, Attr.getRange(), + Attr.getName())) return; if (AlwaysInlineAttr *Inline = S.mergeAlwaysInlineAttr( @@ -5552,7 +5545,8 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, handleHotAttr(S, D, Attr); break; case AttributeList::AT_Naked: - handleNakedAttr(S, D, Attr); + handleSimpleAttributeWithExclusions<NakedAttr, DisableTailCallsAttr, + MSHookPrologueAttr>(S, D, Attr); break; case AttributeList::AT_NoReturn: handleNoReturnAttr(S, D, Attr); @@ -5780,6 +5774,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, break; case AttributeList::AT_LayoutVersion: handleLayoutVersion(S, D, Attr); + case AttributeList::AT_MSHookPrologue: + handleSimpleAttributeWithExclusions<MSHookPrologueAttr, NakedAttr, + AlwaysInlineAttr>(S, D, Attr); break; case AttributeList::AT_MSNoVTable: handleSimpleAttribute<MSNoVTableAttr>(S, D, Attr); |