class StackProtector
Declaration
class StackProtector : public FunctionPass { /* full declaration omitted */ };
Description
FunctionPass class - This class is used to implement most global optimizations. Optimizations should subclass this class if they meet the following constraints: 1. Optimizations are organized globally, i.e., a function at a time 2. Optimizing a function does not cause the addition or removal of any functions in the module
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:36
Inherits from: FunctionPass
Member Variables
- private const llvm::TargetMachine* TM = nullptr
- private const llvm::TargetLoweringBase* TLI = nullptr
- TLI - Keep a pointer of a TargetLowering to consult for determining target type sizes.
- private llvm::Triple Trip
- private llvm::Function* F
- private llvm::Module* M
- private llvm::DominatorTree* DT
- private llvm::StackProtector::SSPLayoutMap Layout
- Layout - Mapping of allocations to the required SSPLayoutKind. StackProtector analysis will update this map when determining if an AllocaInst triggers a stack protector.
- private unsigned int SSPBufferSize = 0
- The minimum size of buffers that will receive stack smashing protection when -fstack-protection is used.
- private SmallPtrSet<const llvm::PHINode*, 16> VisitedPHIs
- VisitedPHIs - The set of PHI nodes visited when determining if a variable's reference has been taken. This set is maintained to ensure we don't visit the same PHI node multiple times.
- private bool HasPrologue = false
- private bool HasIRCheck = false
- public static char ID
Method Overview
- private bool ContainsProtectableArray(llvm::Type * Ty, bool & IsLarge, bool Strong = false, bool InStruct = false) const
- private llvm::BasicBlock * CreateFailBB()
- private bool HasAddressTaken(const llvm::Instruction * AI, llvm::TypeSize AllocSize)
- private bool InsertStackProtectors()
- private bool RequiresStackProtector()
- public StackProtector()
- public void copyToMachineFrameInfo(llvm::MachineFrameInfo & MFI) const
- public void getAnalysisUsage(llvm::AnalysisUsage & AU) const
- public bool runOnFunction(llvm::Function & Fn)
- public bool shouldEmitSDCheck(const llvm::BasicBlock & BB) const
Inherited from FunctionPass:
- public assignPassManager
- public createPrinterPass
- public getPotentialPassManagerType
- public runOnFunction
- protected skipFunction
Inherited from Pass:
- public assignPassManager
- public createPass
- public createPrinterPass
- public doFinalization
- public doInitialization
- public dump
- public dumpPassStructure
- public getAdjustedAnalysisPointer
- public getAnalysis
- public getAnalysis
- public getAnalysisID
- public getAnalysisID
- public getAnalysisIfAvailable
- public getAnalysisUsage
- public getAsImmutablePass
- public getAsPMDataManager
- public getPassID
- public getPassKind
- public getPassName
- public getPotentialPassManagerType
- public getResolver
- public lookupPassInfo
- public lookupPassInfo
- public mustPreserveAnalysisID
- public preparePassManager
- public print
- public releaseMemory
- public setResolver
- public verifyAnalysis
Methods
¶bool ContainsProtectableArray(
llvm::Type* Ty,
bool& IsLarge,
bool Strong = false,
bool InStruct = false) const
bool ContainsProtectableArray(
llvm::Type* Ty,
bool& IsLarge,
bool Strong = false,
bool InStruct = false) const
Description
ContainsProtectableArray - Check whether the type either is an array or contains an array of sufficient size so that we need stack protectors for it.
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:93
Parameters
- llvm::Type* Ty
- bool& IsLarge
- is set to true if a protectable array is found and it is "large" ( >= ssp-buffer-size). In the case of a structure with multiple arrays, this gets set if any of them is large.
- bool Strong = false
- bool InStruct = false
¶llvm::BasicBlock* CreateFailBB()
llvm::BasicBlock* CreateFailBB()
Description
CreateFailBB - Create a basic block to jump to when the stack protector check fails.
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:85
¶bool HasAddressTaken(const llvm::Instruction* AI,
llvm::TypeSize AllocSize)
bool HasAddressTaken(const llvm::Instruction* AI,
llvm::TypeSize AllocSize)
Description
Check whether a stack allocation has its address taken.
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:97
Parameters
- const llvm::Instruction* AI
- llvm::TypeSize AllocSize
¶bool InsertStackProtectors()
bool InsertStackProtectors()
Description
InsertStackProtectors - Insert code into the prologue and epilogue of the function. - The prologue code loads and stores the stack guard onto the stack. - The epilogue checks the value stored in the prologue against the original value. It calls __stack_chk_fail if they differ.
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:81
¶bool RequiresStackProtector()
bool RequiresStackProtector()
Description
RequiresStackProtector - Check whether or not this function needs a stack protector based upon the stack protector level.
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:101
¶StackProtector()
StackProtector()
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:106
¶void copyToMachineFrameInfo(
llvm::MachineFrameInfo& MFI) const
void copyToMachineFrameInfo(
llvm::MachineFrameInfo& MFI) const
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:115
Parameters
¶void getAnalysisUsage(
llvm::AnalysisUsage& AU) const
void getAnalysisUsage(
llvm::AnalysisUsage& AU) const
Description
getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job. If a pass specifies that it uses a particular analysis result to this function, it can then use the getAnalysis <AnalysisType >() function, below.
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:108
Parameters
¶bool runOnFunction(llvm::Function& Fn)
bool runOnFunction(llvm::Function& Fn)
Description
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:113
Parameters
- llvm::Function& Fn
¶bool shouldEmitSDCheck(
const llvm::BasicBlock& BB) const
bool shouldEmitSDCheck(
const llvm::BasicBlock& BB) const
Declared at: llvm/include/llvm/CodeGen/StackProtector.h:111
Parameters
- const llvm::BasicBlock& BB