From 2b58ce5ab4e22e796303d68fb246d4031cb5d4ca Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 4 Nov 2008 02:10:20 +0000 Subject: Initial checkin for stack protectors. Here's what it does: * The prologue is modified to read the __stack_chk_guard global and insert it onto the stack. * The epilogue is modified to read the stored guard from the stack and compare it to the original __stack_chk_guard value. If they differ, then the __stack_chk_fail() function is called. * The stack protector needs to be first on the stack (after the parameters) to catch any stack-smashing activities. Front-end support will follow after a round of beta testing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58673 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/LLVMTargetMachine.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/CodeGen/LLVMTargetMachine.cpp') diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index ee3f604abd..e1dd46342d 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -60,6 +60,11 @@ static cl::opt EnableFastISelOption("fast-isel", cl::Hidden, cl::desc("Enable the experimental \"fast\" instruction selector")); +// Enable stack protectors. +static cl::opt +EnableStackProtector("enable-stack-protector", cl::init(0), + cl::desc("Use ProPolice as a stack protection method.")); + FileModel::Model LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, raw_ostream &Out, @@ -165,6 +170,8 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM, bool Fast) { if (!Fast) PM.add(createCodeGenPreparePass(getTargetLowering())); + PM.add(createStackProtectorPass(EnableStackProtector)); + if (PrintISelInput) PM.add(createPrintFunctionPass("\n\n" "*** Final LLVM Code input to ISel ***\n", -- cgit v1.2.3