retdec
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
retdec::bin2llvmir::CtorDtor Class Reference

#include <ctor_dtor.h>

Collaboration diagram for retdec::bin2llvmir::CtorDtor:
Collaboration graph
[legend]

Classes

class  FunctionInfo
 

Public Types

using FunctionSet = std::set< llvm::Function * >
 
using FunctionToInfo = std::map< llvm::Function *, FunctionInfo >
 
using StoreToVtable = std::map< llvm::StoreInst *, const common::Vtable * >
 

Public Member Functions

void runOnModule (llvm::Module *m, Config *c, FileImage *i)
 
FunctionToInfogetResults ()
 

Private Member Functions

void findPossibleCtorsDtors ()
 
void analyseFunction (llvm::Function *fnc)
 
FunctionInfo analyseFunctionForward (llvm::Function *fnc)
 
FunctionInfo analyseFunctionBackward (llvm::Function *fnc)
 
int getOffset (llvm::Value *ecxStoreOp)
 
llvm::StoreInst * findPreviousStoreToECX (llvm::Instruction *inst)
 
void propagateCtorDtor ()
 
template<class T >
FunctionInfo analyseFunctionCommon (T begin, T end)
 

Private Attributes

llvm::Module * module = nullptr
 
Configconfig = nullptr
 
FileImageimage = nullptr
 
FunctionSet possibleCtorsDtors
 
StoreToVtable stores2vtables
 
FunctionToInfo function2info
 

Member Typedef Documentation

◆ FunctionSet

using retdec::bin2llvmir::CtorDtor::FunctionSet = std::set<llvm::Function*>

◆ FunctionToInfo

using retdec::bin2llvmir::CtorDtor::FunctionToInfo = std::map<llvm::Function*, FunctionInfo>

◆ StoreToVtable

using retdec::bin2llvmir::CtorDtor::StoreToVtable = std::map<llvm::StoreInst*, const common::Vtable*>

Member Function Documentation

◆ analyseFunction()

void retdec::bin2llvmir::CtorDtor::analyseFunction ( llvm::Function *  fnc)
private

◆ analyseFunctionBackward()

CtorDtor::FunctionInfo retdec::bin2llvmir::CtorDtor::analyseFunctionBackward ( llvm::Function *  fnc)
private

◆ analyseFunctionCommon()

template<class T >
CtorDtor::FunctionInfo retdec::bin2llvmir::CtorDtor::analyseFunctionCommon ( begin,
end 
)
private

◆ analyseFunctionForward()

CtorDtor::FunctionInfo retdec::bin2llvmir::CtorDtor::analyseFunctionForward ( llvm::Function *  fnc)
private

◆ findPossibleCtorsDtors()

void retdec::bin2llvmir::CtorDtor::findPossibleCtorsDtors ( )
private

Collects all stores to global variables at vtable addresses. Collects functions where these stores are.

◆ findPreviousStoreToECX()

StoreInst * retdec::bin2llvmir::CtorDtor::findPreviousStoreToECX ( llvm::Instruction *  inst)
private

Find store to gpr1 (ecx) before inst.

Parameters
instInstruction to find store before.
Returns
Found store, or nullptr.

◆ getOffset()

int retdec::bin2llvmir::CtorDtor::getOffset ( llvm::Value *  ecxStoreOp)
private

◆ getResults()

CtorDtor::FunctionToInfo & retdec::bin2llvmir::CtorDtor::getResults ( )

◆ propagateCtorDtor()

void retdec::bin2llvmir::CtorDtor::propagateCtorDtor ( )
private

Sometimes function analysis can not decide, if function is ctor or dtor. This is typical for base classes' ctors/dtors, which are not calling super methods. However, we can do a bottom-up propagation: if we know some method is ctor/dtor and it is calling some super method, we can say if the super method is ctor/dtor.

◆ runOnModule()

void retdec::bin2llvmir::CtorDtor::runOnModule ( llvm::Module *  m,
Config c,
FileImage i 
)

Member Data Documentation

◆ config

Config* retdec::bin2llvmir::CtorDtor::config = nullptr
private

◆ function2info

FunctionToInfo retdec::bin2llvmir::CtorDtor::function2info
private

◆ image

FileImage* retdec::bin2llvmir::CtorDtor::image = nullptr
private

◆ module

llvm::Module* retdec::bin2llvmir::CtorDtor::module = nullptr
private

◆ possibleCtorsDtors

FunctionSet retdec::bin2llvmir::CtorDtor::possibleCtorsDtors
private

◆ stores2vtables

StoreToVtable retdec::bin2llvmir::CtorDtor::stores2vtables
private

The documentation for this class was generated from the following files: