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

#include <config.h>

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

Public Types

using IntrinsicFunctionCreatorPtr = llvm::Function *(*)(llvm::Module *)
 

Public Member Functions

void doFinalization ()
 
void tagFunctionsWithUsedCryptoGlobals ()
 
retdec::config::ConfiggetConfig ()
 
const retdec::config::ConfiggetConfig () const
 
retdec::common::FunctiongetConfigFunction (const llvm::Function *fnc)
 
retdec::common::FunctiongetConfigFunction (retdec::common::Address startAddr)
 
llvm::Function * getLlvmFunction (retdec::common::Address startAddr)
 
retdec::common::Address getFunctionAddress (const llvm::Function *fnc)
 
llvm::Function * getIntrinsicFunction (IntrinsicFunctionCreatorPtr f)
 
const retdec::common::ObjectgetConfigRegister (const llvm::Value *val)
 
std::optional< unsigned > getConfigRegisterNumber (const llvm::Value *val)
 
const retdec::common::ObjectgetConfigGlobalVariable (const llvm::GlobalVariable *gv)
 
const retdec::common::ObjectgetConfigGlobalVariable (retdec::common::Address address)
 
llvm::GlobalVariable * getLlvmGlobalVariable (retdec::common::Address address)
 
llvm::GlobalVariable * getLlvmGlobalVariable (const std::string &name, retdec::common::Address address)
 
retdec::common::Address getGlobalAddress (const llvm::GlobalVariable *gv)
 
bool isGlobalVariable (const llvm::Value *val)
 
const retdec::common::ObjectgetConfigLocalVariable (const llvm::Value *val)
 
retdec::common::ObjectgetConfigStackVariable (const llvm::Value *val)
 
llvm::AllocaInst * getLlvmStackVariable (llvm::Function *fnc, int offset)
 
llvm::AllocaInst * getLlvmStackVariable (llvm::Function *fnc, const std::string &realName)
 
bool isStackVariable (const llvm::Value *val)
 
std::optional< int > getStackVariableOffset (const llvm::Value *val)
 
const retdec::common::ObjectinsertGlobalVariable (const llvm::GlobalVariable *gv, retdec::common::Address address, bool fromDebug=false, const std::string &realName="", const std::string &cryptoDesc="")
 
const retdec::common::ObjectinsertStackVariable (const llvm::AllocaInst *sv, int offset, bool fromDebug=false, const std::string &realName=std::string())
 
const retdec::common::FunctioninsertFunction (const llvm::Function *fnc, retdec::common::Address start=retdec::common::Address::Undefined, retdec::common::Address end=retdec::common::Address::Undefined, bool fromDebug=false)
 
retdec::common::FunctionrenameFunction (retdec::common::Function *fnc, const std::string &name)
 
void setLlvmCallPseudoFunction (llvm::Function *f)
 
llvm::Function * getLlvmCallPseudoFunction () const
 
bool isLlvmCallPseudoFunction (llvm::Value *f)
 
llvm::CallInst * isLlvmCallPseudoFunctionCall (llvm::Value *c)
 
void setLlvmReturnPseudoFunction (llvm::Function *f)
 
llvm::Function * getLlvmReturnPseudoFunction () const
 
bool isLlvmReturnPseudoFunction (llvm::Value *f)
 
llvm::CallInst * isLlvmReturnPseudoFunctionCall (llvm::Value *c)
 
void setLlvmBranchPseudoFunction (llvm::Function *f)
 
llvm::Function * getLlvmBranchPseudoFunction () const
 
bool isLlvmBranchPseudoFunction (llvm::Value *f)
 
llvm::CallInst * isLlvmBranchPseudoFunctionCall (llvm::Value *c)
 
void setLlvmCondBranchPseudoFunction (llvm::Function *f)
 
llvm::Function * getLlvmCondBranchPseudoFunction () const
 
bool isLlvmCondBranchPseudoFunction (llvm::Value *f)
 
llvm::CallInst * isLlvmCondBranchPseudoFunctionCall (llvm::Value *c)
 
llvm::CallInst * isLlvmAnyBranchPseudoFunctionCall (llvm::Value *c)
 
llvm::CallInst * isLlvmAnyUncondBranchPseudoFunctionCall (llvm::Value *c)
 
void setLlvmX87DataStorePseudoFunction (llvm::Function *f)
 
llvm::Function * getLlvmX87DataStorePseudoFunction () const
 
bool isLlvmX87DataStorePseudoFunction (llvm::Value *f)
 
llvm::CallInst * isLlvmX87DataStorePseudoFunctionCall (llvm::Value *c)
 
void setLlvmX87DataLoadPseudoFunction (llvm::Function *f)
 
llvm::Function * getLlvmX87DataLoadPseudoFunction () const
 
bool isLlvmX87DataLoadPseudoFunction (llvm::Value *f)
 
llvm::CallInst * isLlvmX87DataLoadPseudoFunctionCall (llvm::Value *c)
 
llvm::CallInst * isLlvmX87StorePseudoFunctionCall (llvm::Value *c)
 
llvm::CallInst * isLlvmX87LoadPseudoFunctionCall (llvm::Value *c)
 
void addPseudoAsmFunction (llvm::Function *f)
 
bool isPseudoAsmFunction (llvm::Function *f)
 
llvm::CallInst * isPseudoAsmFunctionCall (llvm::Value *c)
 
llvm::GlobalVariable * getGlobalDummy ()
 
fs::path getOutputDirectory ()
 
bool getCryptoPattern (retdec::common::Address addr, std::string &name, std::string &description, llvm::Type *&type) const
 

Static Public Member Functions

static Config empty (llvm::Module *m)
 
static Config fromConfig (llvm::Module *m, retdec::config::Config &c)
 

Public Attributes

llvm::Module * _module = nullptr
 

Private Member Functions

 Config (retdec::config::Config &c)
 

Private Attributes

retdec::config::Config_configDB
 
llvm::GlobalVariable * _globalDummy = nullptr
 
llvm::Function * _callFunction = nullptr
 
llvm::Function * _returnFunction = nullptr
 
llvm::Function * _branchFunction = nullptr
 
llvm::Function * _condBranchFunction = nullptr
 
llvm::Function * _x87DataStoreFunction = nullptr
 
llvm::Function * _x87DataLoadFunction = nullptr
 
std::map< IntrinsicFunctionCreatorPtr, llvm::Function * > _intrinsicFunctions
 
std::set< llvm::Function * > _pseudoAsmFunctions
 

Member Typedef Documentation

◆ IntrinsicFunctionCreatorPtr

using retdec::bin2llvmir::Config::IntrinsicFunctionCreatorPtr = llvm::Function* (*)(llvm::Module*)

Constructor & Destructor Documentation

◆ Config()

retdec::bin2llvmir::Config::Config ( retdec::config::Config c)
private

Member Function Documentation

◆ addPseudoAsmFunction()

void retdec::bin2llvmir::Config::addPseudoAsmFunction ( llvm::Function *  f)

◆ doFinalization()

void retdec::bin2llvmir::Config::doFinalization ( )

Save the config to reflect changes that have been done to it in the bin2llvmirl.

◆ empty()

Config retdec::bin2llvmir::Config::empty ( llvm::Module *  m)
static

◆ fromConfig()

Config retdec::bin2llvmir::Config::fromConfig ( llvm::Module *  m,
retdec::config::Config c 
)
static

◆ getConfig() [1/2]

retdec::config::Config & retdec::bin2llvmir::Config::getConfig ( )

◆ getConfig() [2/2]

const retdec::config::Config & retdec::bin2llvmir::Config::getConfig ( ) const

◆ getConfigFunction() [1/2]

retdec::common::Function * retdec::bin2llvmir::Config::getConfigFunction ( const llvm::Function *  fnc)

◆ getConfigFunction() [2/2]

retdec::common::Function * retdec::bin2llvmir::Config::getConfigFunction ( retdec::common::Address  startAddr)

◆ getConfigGlobalVariable() [1/2]

const retdec::common::Object * retdec::bin2llvmir::Config::getConfigGlobalVariable ( const llvm::GlobalVariable *  gv)

◆ getConfigGlobalVariable() [2/2]

const retdec::common::Object * retdec::bin2llvmir::Config::getConfigGlobalVariable ( retdec::common::Address  address)

◆ getConfigLocalVariable()

const retdec::common::Object * retdec::bin2llvmir::Config::getConfigLocalVariable ( const llvm::Value *  val)

◆ getConfigRegister()

const retdec::common::Object * retdec::bin2llvmir::Config::getConfigRegister ( const llvm::Value *  val)

◆ getConfigRegisterNumber()

std::optional< unsigned > retdec::bin2llvmir::Config::getConfigRegisterNumber ( const llvm::Value *  val)

◆ getConfigStackVariable()

retdec::common::Object * retdec::bin2llvmir::Config::getConfigStackVariable ( const llvm::Value *  val)

◆ getCryptoPattern()

bool retdec::bin2llvmir::Config::getCryptoPattern ( retdec::common::Address  addr,
std::string &  name,
std::string &  description,
llvm::Type *&  type 
) const

Get crypto pattern information for address addr - fill name, description, and type, if there is a pattern on address.

Returns
True if pattern was found, false otherwise.

◆ getFunctionAddress()

retdec::common::Address retdec::bin2llvmir::Config::getFunctionAddress ( const llvm::Function *  fnc)

◆ getGlobalAddress()

retdec::common::Address retdec::bin2llvmir::Config::getGlobalAddress ( const llvm::GlobalVariable *  gv)

◆ getGlobalDummy()

llvm::GlobalVariable * retdec::bin2llvmir::Config::getGlobalDummy ( )
Returns
Always returns the same dummy global variable.

◆ getIntrinsicFunction()

llvm::Function * retdec::bin2llvmir::Config::getIntrinsicFunction ( IntrinsicFunctionCreatorPtr  f)

◆ getLlvmBranchPseudoFunction()

llvm::Function * retdec::bin2llvmir::Config::getLlvmBranchPseudoFunction ( ) const

◆ getLlvmCallPseudoFunction()

llvm::Function * retdec::bin2llvmir::Config::getLlvmCallPseudoFunction ( ) const

◆ getLlvmCondBranchPseudoFunction()

llvm::Function * retdec::bin2llvmir::Config::getLlvmCondBranchPseudoFunction ( ) const

◆ getLlvmFunction()

llvm::Function * retdec::bin2llvmir::Config::getLlvmFunction ( retdec::common::Address  startAddr)

◆ getLlvmGlobalVariable() [1/2]

llvm::GlobalVariable * retdec::bin2llvmir::Config::getLlvmGlobalVariable ( const std::string &  name,
retdec::common::Address  address 
)

Global variables have two unique IDs – name and address. This method returns LLVM global with either name (string search in module's globals) or address (config used to get global by address).

◆ getLlvmGlobalVariable() [2/2]

llvm::GlobalVariable * retdec::bin2llvmir::Config::getLlvmGlobalVariable ( retdec::common::Address  address)

◆ getLlvmReturnPseudoFunction()

llvm::Function * retdec::bin2llvmir::Config::getLlvmReturnPseudoFunction ( ) const

◆ getLlvmStackVariable() [1/2]

llvm::AllocaInst * retdec::bin2llvmir::Config::getLlvmStackVariable ( llvm::Function *  fnc,
const std::string &  realName 
)

◆ getLlvmStackVariable() [2/2]

llvm::AllocaInst * retdec::bin2llvmir::Config::getLlvmStackVariable ( llvm::Function *  fnc,
int  offset 
)
Returns
LLVM alloca instruction for stack variable with offset offset in function fnc. nullptr if such variable does not exist.

◆ getLlvmX87DataLoadPseudoFunction()

llvm::Function * retdec::bin2llvmir::Config::getLlvmX87DataLoadPseudoFunction ( ) const

◆ getLlvmX87DataStorePseudoFunction()

llvm::Function * retdec::bin2llvmir::Config::getLlvmX87DataStorePseudoFunction ( ) const

◆ getOutputDirectory()

fs::path retdec::bin2llvmir::Config::getOutputDirectory ( )

◆ getStackVariableOffset()

std::optional< int > retdec::bin2llvmir::Config::getStackVariableOffset ( const llvm::Value *  val)

◆ insertFunction()

const retdec::common::Function * retdec::bin2llvmir::Config::insertFunction ( const llvm::Function *  fnc,
retdec::common::Address  start = retdec::common::Address::Undefined,
retdec::common::Address  end = retdec::common::Address::Undefined,
bool  fromDebug = false 
)

◆ insertGlobalVariable()

const retdec::common::Object * retdec::bin2llvmir::Config::insertGlobalVariable ( const llvm::GlobalVariable *  gv,
retdec::common::Address  address,
bool  fromDebug = false,
const std::string &  realName = "",
const std::string &  cryptoDesc = "" 
)

◆ insertStackVariable()

const retdec::common::Object * retdec::bin2llvmir::Config::insertStackVariable ( const llvm::AllocaInst *  sv,
int  offset,
bool  fromDebug = false,
const std::string &  realName = std::string() 
)

◆ isGlobalVariable()

bool retdec::bin2llvmir::Config::isGlobalVariable ( const llvm::Value *  val)

◆ isLlvmAnyBranchPseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmAnyBranchPseudoFunctionCall ( llvm::Value *  c)

◆ isLlvmAnyUncondBranchPseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmAnyUncondBranchPseudoFunctionCall ( llvm::Value *  c)

◆ isLlvmBranchPseudoFunction()

bool retdec::bin2llvmir::Config::isLlvmBranchPseudoFunction ( llvm::Value *  f)

◆ isLlvmBranchPseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmBranchPseudoFunctionCall ( llvm::Value *  c)

◆ isLlvmCallPseudoFunction()

bool retdec::bin2llvmir::Config::isLlvmCallPseudoFunction ( llvm::Value *  f)

◆ isLlvmCallPseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmCallPseudoFunctionCall ( llvm::Value *  c)

◆ isLlvmCondBranchPseudoFunction()

bool retdec::bin2llvmir::Config::isLlvmCondBranchPseudoFunction ( llvm::Value *  f)

◆ isLlvmCondBranchPseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmCondBranchPseudoFunctionCall ( llvm::Value *  c)

◆ isLlvmReturnPseudoFunction()

bool retdec::bin2llvmir::Config::isLlvmReturnPseudoFunction ( llvm::Value *  f)

◆ isLlvmReturnPseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmReturnPseudoFunctionCall ( llvm::Value *  c)

◆ isLlvmX87DataLoadPseudoFunction()

bool retdec::bin2llvmir::Config::isLlvmX87DataLoadPseudoFunction ( llvm::Value *  f)

◆ isLlvmX87DataLoadPseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmX87DataLoadPseudoFunctionCall ( llvm::Value *  c)

◆ isLlvmX87DataStorePseudoFunction()

bool retdec::bin2llvmir::Config::isLlvmX87DataStorePseudoFunction ( llvm::Value *  f)

◆ isLlvmX87DataStorePseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmX87DataStorePseudoFunctionCall ( llvm::Value *  c)

◆ isLlvmX87LoadPseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmX87LoadPseudoFunctionCall ( llvm::Value *  c)

◆ isLlvmX87StorePseudoFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isLlvmX87StorePseudoFunctionCall ( llvm::Value *  c)

◆ isPseudoAsmFunction()

bool retdec::bin2llvmir::Config::isPseudoAsmFunction ( llvm::Function *  f)

◆ isPseudoAsmFunctionCall()

llvm::CallInst * retdec::bin2llvmir::Config::isPseudoAsmFunctionCall ( llvm::Value *  c)

◆ isStackVariable()

bool retdec::bin2llvmir::Config::isStackVariable ( const llvm::Value *  val)
Returns
True if the the provided LLVM value val is a stack variable. False otherwise.

◆ renameFunction()

retdec::common::Function * retdec::bin2llvmir::Config::renameFunction ( retdec::common::Function fnc,
const std::string &  name 
)

◆ setLlvmBranchPseudoFunction()

void retdec::bin2llvmir::Config::setLlvmBranchPseudoFunction ( llvm::Function *  f)

◆ setLlvmCallPseudoFunction()

void retdec::bin2llvmir::Config::setLlvmCallPseudoFunction ( llvm::Function *  f)

◆ setLlvmCondBranchPseudoFunction()

void retdec::bin2llvmir::Config::setLlvmCondBranchPseudoFunction ( llvm::Function *  f)

◆ setLlvmReturnPseudoFunction()

void retdec::bin2llvmir::Config::setLlvmReturnPseudoFunction ( llvm::Function *  f)

◆ setLlvmX87DataLoadPseudoFunction()

void retdec::bin2llvmir::Config::setLlvmX87DataLoadPseudoFunction ( llvm::Function *  f)

◆ setLlvmX87DataStorePseudoFunction()

void retdec::bin2llvmir::Config::setLlvmX87DataStorePseudoFunction ( llvm::Function *  f)

◆ tagFunctionsWithUsedCryptoGlobals()

void retdec::bin2llvmir::Config::tagFunctionsWithUsedCryptoGlobals ( )

Member Data Documentation

◆ _branchFunction

llvm::Function* retdec::bin2llvmir::Config::_branchFunction = nullptr
private

◆ _callFunction

llvm::Function* retdec::bin2llvmir::Config::_callFunction = nullptr
private

◆ _condBranchFunction

llvm::Function* retdec::bin2llvmir::Config::_condBranchFunction = nullptr
private

◆ _configDB

retdec::config::Config& retdec::bin2llvmir::Config::_configDB
private

◆ _globalDummy

llvm::GlobalVariable* retdec::bin2llvmir::Config::_globalDummy = nullptr
private

◆ _intrinsicFunctions

std::map<IntrinsicFunctionCreatorPtr, llvm::Function*> retdec::bin2llvmir::Config::_intrinsicFunctions
private

◆ _module

llvm::Module* retdec::bin2llvmir::Config::_module = nullptr

◆ _pseudoAsmFunctions

std::set<llvm::Function*> retdec::bin2llvmir::Config::_pseudoAsmFunctions
private

◆ _returnFunction

llvm::Function* retdec::bin2llvmir::Config::_returnFunction = nullptr
private

◆ _x87DataLoadFunction

llvm::Function* retdec::bin2llvmir::Config::_x87DataLoadFunction = nullptr
private

◆ _x87DataStoreFunction

llvm::Function* retdec::bin2llvmir::Config::_x87DataStoreFunction = nullptr
private

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