|
LLVM
8.0.1
|
#include "llvm/CodeGen/StackProtector.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/BranchProbabilityInfo.h"#include "llvm/Analysis/EHPersonalities.h"#include "llvm/Analysis/OptimizationRemarkEmitter.h"#include "llvm/CodeGen/Passes.h"#include "llvm/CodeGen/TargetLowering.h"#include "llvm/CodeGen/TargetPassConfig.h"#include "llvm/CodeGen/TargetSubtargetInfo.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DebugInfo.h"#include "llvm/IR/DebugLoc.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/IRBuilder.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/MDBuilder.h"#include "llvm/IR/Module.h"#include "llvm/IR/Type.h"#include "llvm/IR/User.h"#include "llvm/Pass.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Target/TargetMachine.h"#include "llvm/Target/TargetOptions.h"#include <utility>
Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "stack-protector" |
Functions | |
| STATISTIC (NumFunProtected, "Number of functions protected") | |
| STATISTIC (NumAddrTaken, "Number of local variables that have their address" " taken.") | |
| INITIALIZE_PASS_BEGIN (StackProtector, DEBUG_TYPE, "Insert stack protectors", false, true) INITIALIZE_PASS_END(StackProtector | |
| static const CallInst * | findStackProtectorIntrinsic (Function &F) |
| Search for the first call to the llvm.stackprotector intrinsic and return it if present. More... | |
| static Value * | getStackGuard (const TargetLoweringBase *TLI, Module *M, IRBuilder<> &B, bool *SupportsSelectionDAGSP=nullptr) |
| Create a stack guard loading and populate whether SelectionDAG SSP is supported. More... | |
| static bool | CreatePrologue (Function *F, Module *M, ReturnInst *RI, const TargetLoweringBase *TLI, AllocaInst *&AI) |
| Insert code into the entry block that stores the stack guard variable onto the stack: More... | |
Variables | |
| static cl::opt< bool > | EnableSelectionDAGSP ("enable-selectiondag-sp", cl::init(true), cl::Hidden) |
| DEBUG_TYPE | |
| Insert stack | protectors |
| Insert stack | false |
| #define DEBUG_TYPE "stack-protector" |
Definition at line 54 of file StackProtector.cpp.
Referenced by findStackProtectorIntrinsic().
|
static |
Insert code into the entry block that stores the stack guard variable onto the stack:
entry: StackGuardSlot = alloca i8* StackGuard = <stack guard>=""> call void .stackprotector(StackGuard, StackGuardSlot)
Returns true if the platform/triple supports the stackprotectorcreate pseudo node.
Definition at line 355 of file StackProtector.cpp.
References llvm::DominatorTreeBase< NodeT, IsPostDom >::addNewBlock(), assert(), B, llvm::Function::begin(), Context, llvm::BasicBlock::Create(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateCondBr(), llvm::IRBuilder< T, Inserter >::CreateGlobalStringPtr(), llvm::IRBuilder< T, Inserter >::CreateICmpEQ(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::IRBuilder< T, Inserter >::CreateUnreachable(), llvm::dyn_cast(), E, llvm::TargetOptions::EnableFastISel, llvm::TargetOptions::EnableGlobalISel, EnableSelectionDAGSP, llvm::Function::end(), llvm::Instruction::eraseFromParent(), findStackProtectorIntrinsic(), llvm::BasicBlock::front(), llvm::DebugLoc::get(), llvm::CallBase::getArgOperand(), llvm::Function::getAttributes(), llvm::BranchProbabilityInfo::getBranchProbStackProtector(), llvm::Function::getCallingConv(), llvm::Function::getContext(), llvm::Value::getContext(), llvm::Intrinsic::getDeclaration(), llvm::Function::getEntryBlock(), llvm::Type::getInt8PtrTy(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::Module::getOrInsertFunction(), llvm::TargetLoweringBase::getSSPStackGuardCheck(), getStackGuard(), llvm::Function::getSubprogram(), llvm::BasicBlock::getTerminator(), llvm::Type::getVoidTy(), I, llvm::Triple::isOSOpenBSD(), llvm::DominatorTree::isReachableFromEntry(), llvm::BasicBlock::moveAfter(), llvm::TargetMachine::Options, llvm::CallBase::setAttributes(), llvm::CallBase::setCallingConv(), llvm::IRBuilderBase::SetCurrentDebugLocation(), llvm::BasicBlock::splitBasicBlock(), llvm::Intrinsic::stackprotector, and llvm::TargetLoweringBase::useStackGuardXorFP().
Search for the first call to the llvm.stackprotector intrinsic and return it if present.
Definition at line 196 of file StackProtector.cpp.
References DEBUG_TYPE, llvm::OptimizationRemarkEmitter::emit(), llvm::Intrinsic::getDeclaration(), llvm::Function::hasFnAttribute(), I, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::Attribute::SafeStack, llvm::MachineFrameInfo::SSPLK_AddrOf, llvm::MachineFrameInfo::SSPLK_LargeArray, llvm::MachineFrameInfo::SSPLK_SmallArray, llvm::Attribute::StackProtect, llvm::Intrinsic::stackprotector, llvm::Attribute::StackProtectReq, and llvm::Attribute::StackProtectStrong.
Referenced by CreatePrologue().
|
static |
Create a stack guard loading and populate whether SelectionDAG SSP is supported.
Definition at line 322 of file StackProtector.cpp.
References llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::Intrinsic::getDeclaration(), llvm::TargetLoweringBase::getIRStackGuard(), llvm::TargetLoweringBase::insertSSPDeclarations(), and llvm::Intrinsic::stackguard.
Referenced by CreatePrologue().
| INITIALIZE_PASS_BEGIN | ( | StackProtector | , |
| DEBUG_TYPE | , | ||
| "Insert stack protectors" | , | ||
| false | , | ||
| true | |||
| ) |
| STATISTIC | ( | NumFunProtected | , |
| "Number of functions protected" | |||
| ) |
| STATISTIC | ( | NumAddrTaken | , |
| "Number of local variables that have their address" " taken." | |||
| ) |
| DEBUG_TYPE |
Definition at line 68 of file StackProtector.cpp.
Referenced by CreatePrologue().
| Insert stack false |
Definition at line 68 of file StackProtector.cpp.
| Insert stack protectors |
Definition at line 68 of file StackProtector.cpp.
1.8.13