diff options
author | Manoj Gupta <manojgupta@google.com> | 2018-05-09 21:41:18 +0000 |
---|---|---|
committer | Manoj Gupta <manojgupta@google.com> | 2018-05-09 21:41:18 +0000 |
commit | 4fbf84c1732fca596ad1d6e96015e19760eb8a9b (patch) | |
tree | da2839f5bb056cbf550d7d5b63590981ab29331f /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 4246a462a33fd045addf052c4b6b816e91f82fed (diff) | |
download | bcm5719-llvm-4fbf84c1732fca596ad1d6e96015e19760eb8a9b.tar.gz bcm5719-llvm-4fbf84c1732fca596ad1d6e96015e19760eb8a9b.zip |
[Clang] Implement function attribute no_stack_protector.
Summary:
This attribute tells clang to skip this function from stack protector
when -stack-protector option is passed.
GCC option for this is:
__attribute__((__optimize__("no-stack-protector"))) and the
equivalent clang syntax would be: __attribute__((no_stack_protector))
This is used in Linux kernel to selectively disable stack protector
in certain functions.
Reviewers: aaron.ballman, rsmith, rnk, probinson
Reviewed By: aaron.ballman
Subscribers: probinson, srhines, cfe-commits
Differential Revision: https://reviews.llvm.org/D46300
llvm-svn: 331925
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index bfdd1e65e2c..3a27d999352 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1142,12 +1142,14 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); - if (LangOpts.getStackProtector() == LangOptions::SSPOn) - B.addAttribute(llvm::Attribute::StackProtect); - else if (LangOpts.getStackProtector() == LangOptions::SSPStrong) - B.addAttribute(llvm::Attribute::StackProtectStrong); - else if (LangOpts.getStackProtector() == LangOptions::SSPReq) - B.addAttribute(llvm::Attribute::StackProtectReq); + if (!D || !D->hasAttr<NoStackProtectorAttr>()) { + if (LangOpts.getStackProtector() == LangOptions::SSPOn) + B.addAttribute(llvm::Attribute::StackProtect); + else if (LangOpts.getStackProtector() == LangOptions::SSPStrong) + B.addAttribute(llvm::Attribute::StackProtectStrong); + else if (LangOpts.getStackProtector() == LangOptions::SSPReq) + B.addAttribute(llvm::Attribute::StackProtectReq); + } if (!D) { // If we don't have a declaration to control inlining, the function isn't |