[PATCH] D20346: [stack-protection] Add support for MSVC buffer security check

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 14:23:46 PDT 2016


majnemer added a subscriber: majnemer.
majnemer added a comment.

@rnk How does this play with WinEHPrepare, AsmPrinter and the state number insertion pass? Should those be updated later? Should we not enable /GS by default until they are implemented?


================
Comment at: lib/CodeGen/StackProtector.cpp:358-364
@@ +357,9 @@
+    // providing.
+    if (Value* GuardCheck = TLI->getSSPStackGuardCheck(*M)) {
+      // Generate the function-based epilogue instrumentation.
+      // The target provides a guard check function, generate a call to it.
+      IRBuilder<> B(RI);
+      LoadInst *Guard = B.CreateLoad(AI, true, "Guard");
+      CallInst* Call = B.CreateCall(GuardCheck, {Guard});
+      llvm::Function* Function = cast<llvm::Function>(GuardCheck);
+      Call->setAttributes(Function->getAttributes());
----------------
Pointers lean right.

================
Comment at: lib/Target/X86/X86ISelLowering.cpp:1980
@@ +1979,3 @@
+    // MSVC CRT has a function to validate security cookie.
+    auto* SecurityCheckCookie = cast<Function>(
+        M.getOrInsertFunction("__security_check_cookie",
----------------
Pointers lean right.


http://reviews.llvm.org/D20346





More information about the llvm-commits mailing list