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

Inherited from FunctionPass:

Inherited from Pass:

Methods

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()

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)

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()

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()

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()

Declared at: llvm/include/llvm/CodeGen/StackProtector.h:106

void copyToMachineFrameInfo(
    llvm::MachineFrameInfo& MFI) const

Declared at: llvm/include/llvm/CodeGen/StackProtector.h:115

Parameters

llvm::MachineFrameInfo& MFI

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

llvm::AnalysisUsage& AU

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

Declared at: llvm/include/llvm/CodeGen/StackProtector.h:111

Parameters

const llvm::BasicBlock& BB