summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/StackProtector.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-11-30 22:41:21 +0000
committerReid Kleckner <rnk@google.com>2017-11-30 22:41:21 +0000
commitba4014e9dce96618ab4d8f820447df2a86023b74 (patch)
tree378fd33b9c4ff2742645fa7f05fb1f2f8da439a3 /llvm/lib/CodeGen/StackProtector.cpp
parent669cae1f28fee3b02ca536181279cf4bbf2314d2 (diff)
downloadbcm5719-llvm-ba4014e9dce96618ab4d8f820447df2a86023b74.tar.gz
bcm5719-llvm-ba4014e9dce96618ab4d8f820447df2a86023b74.zip
XOR the frame pointer with the stack cookie when protecting the stack
Summary: This strengthens the guard and matches MSVC. Reviewers: hans, etienneb Subscribers: hiraditya, JDevlieghere, vlad.tsyrklevich, llvm-commits Differential Revision: https://reviews.llvm.org/D40622 llvm-svn: 319490
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r--llvm/lib/CodeGen/StackProtector.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp
index e3340028863..62cef95a4af 100644
--- a/llvm/lib/CodeGen/StackProtector.cpp
+++ b/llvm/lib/CodeGen/StackProtector.cpp
@@ -385,8 +385,12 @@ static bool CreatePrologue(Function *F, Module *M, ReturnInst *RI,
/// - The epilogue checks the value stored in the prologue against the original
/// value. It calls __stack_chk_fail if they differ.
bool StackProtector::InsertStackProtectors() {
+ // If the target wants to XOR the frame pointer into the guard value, it's
+ // impossible to emit the check in IR, so the target *must* support stack
+ // protection in SDAG.
bool SupportsSelectionDAGSP =
- EnableSelectionDAGSP && !TM->Options.EnableFastISel;
+ TLI->useStackGuardXorFP() ||
+ (EnableSelectionDAGSP && !TM->Options.EnableFastISel);
AllocaInst *AI = nullptr; // Place on stack that stores the stack guard.
for (Function::iterator I = F->begin(), E = F->end(); I != E;) {
OpenPOWER on IntegriCloud