retdec
|
Namespaces | |
capstone_utils | |
inst_opt | |
inst_opt_rda | |
llvm_utils | |
names | |
st_match | |
x86_addr_spaces | |
Typedefs | |
using | Changed = bool |
using | BBEntrySet = std::unordered_set< BasicBlockEntry * > |
using | DefSet = std::unordered_set< Definition * > |
using | UseSet = std::unordered_set< Use * > |
using | DefVector = std::vector< Definition > |
using | UseVector = std::vector< Use > |
typedef FilterableLayout::Order | OrderID |
using | ValueEntrySet = std::unordered_set< ValueEntry, ValueEntryHash > |
using | TypeEntrySet = std::unordered_set< TypeEntry, TypeEntryHash > |
using | EquationEntrySet = std::unordered_set< EquationEntry, EquationEntryHash > |
using | ValueMap = std::unordered_map< llvm::Value *, EqSet * > |
using | ValuePair = std::pair< llvm::Value *, llvm::Value * > |
using | ValuePairList = std::list< ValuePair > |
using | Llvm2CapstoneInsnMap = typename std::map< llvm::StoreInst *, cs_insn * > |
Enumerations | |
enum | CC_compiler { CC_ANY = 0 , CC_Borland , CC_GCC , CC_Intel , CC_LLVM , CC_OWatcom , CC_VStudio } |
Compiler type. More... | |
enum | CC_arch { ARCH_ANY = 0 , ARCH_MIPS , ARCH_POWERPC , ARCH_ARM , ARCH_THUMB , ARCH_x86 } |
Target architecture. More... | |
enum class | eSourcePriority { PRIORITY_NONE = 0 , PRIORITY_LTI , PRIORITY_DEBUG } |
Functions | |
template<typename T > | |
std::string | llvmObjToString (const T *t) |
std::string | llvmObjToString (const llvm::Module *t) |
void | dumpModuleToFile (const llvm::Module *m, fs::path dirName, const std::string &fileName="") |
void | dumpControFlowToJson (llvm::Module *m, fs::path dirName, const std::string &fileName="control-flow.json") |
std::ostream & | operator<< (std::ostream &out, const ReachingDefinitionsAnalysis &rda) |
std::ostream & | operator<< (std::ostream &out, const BasicBlockEntry &bbe) |
llvm::Instruction * | defInBasicBlock (llvm::Value *v, llvm::BasicBlock *bb, llvm::Instruction *start=nullptr) |
bool | usesInBasicBlock (llvm::Value *v, llvm::BasicBlock *bb, std::set< llvm::Instruction * > &uses, llvm::Instruction *start=nullptr) |
std::ostream & | operator<< (std::ostream &out, const SymbolicTree &s) |
static RegisterPass< AsmInstructionRemover > | X ("retdec-remove-asm-instrs", "Assembly mapping instruction removal", false, false) |
static RegisterPass< ClassHierarchyAnalysis > | RegisterPass ("retdec-class-hierarchy", "C++ class hierarchy optimization", false, false) |
static RegisterPass< CondBranchOpt > | X ("retdec-cond-branch-opt", "Conditional branch optimization", false, false) |
static RegisterPass< ConstantsAnalysis > | X ("retdec-constants", "Constants optimization", false, false) |
bool | insnWrittesPc (csh &ce, cs_insn *insn) |
bool | looksLikeArmFunctionStart (cs_insn *insn) |
bool | insnWrittesPcArm64 (csh &ce, cs_insn *insn) |
bool | looksLikeArm64FunctionStart (cs_insn *insn) |
static llvm::RegisterPass< Decoder > | X ("retdec-decoder", "Input binary to LLVM IR decoding", false, false) |
std::ostream & | operator<< (std::ostream &os, const RangesToDecode &rs) |
std::ostream & | operator<< (std::ostream &out, const JumpTarget &jt) |
std::ostream & | operator<< (std::ostream &out, const JumpTargets &jts) |
bool | isBadBranch (FileImage *img, cs_insn *br) |
static RegisterPass< DumpModule > | X ("retdec-dump-module", "Module to LLVM IR file dumper", false, false) |
RegisterPass< Idioms > | IdiomsRegistered ("retdec-idioms", "Instruction idioms optimization", false, false) |
template<> | |
llvm::Value * | IdiomsLibgccImpl::getOp0< std::int32_t > (llvm::CallInst *call) |
template<> | |
llvm::Value * | IdiomsLibgccImpl::getOp0< std::int64_t > (llvm::CallInst *call) |
template<> | |
llvm::Value * | IdiomsLibgccImpl::getOp1< std::int32_t > (llvm::CallInst *call) |
template<> | |
llvm::Value * | IdiomsLibgccImpl::getOp1< std::int64_t > (llvm::CallInst *call) |
template<> | |
llvm::Value * | IdiomsLibgccImpl::getRes0< std::int32_t > (llvm::CallInst *call, llvm::Value *res) |
template<> | |
llvm::Value * | IdiomsLibgccImpl::getRes0< std::int64_t > (llvm::CallInst *call, llvm::Value *res) |
template<> | |
llvm::Value * | IdiomsLibgccImpl::getRes1< std::int32_t > (llvm::CallInst *call, llvm::Value *res) |
template<> | |
llvm::Value * | IdiomsLibgccImpl::getRes1< std::int64_t > (llvm::CallInst *call, llvm::Value *res) |
static RegisterPass< IdiomsLibgcc > | X ("retdec-idioms-libgcc", "Libgcc idioms optimization", false, false) |
static RegisterPass< InstructionOptimizer > | X ("retdec-inst-opt", "LLVM instruction optimization", false, false) |
static RegisterPass< InstructionRdaOptimizer > | X ("retdec-inst-opt-rda", "LLVM instruction optimization using RDA", false, false) |
static RegisterPass< MainDetection > | X ("retdec-main-detection", "Main function identification optimization", false, false) |
static RegisterPass< ParamReturn > | X ("retdec-param-return", "Function parameters and returns optimization", false, false) |
static llvm::RegisterPass< PhiRemover > | X ("retdec-remove-phi", "Phi removal", false, false) |
common::Address | getInstAddress (const llvm::Instruction *i) |
llvm::MDNode * | getInstAddressMeta (common::Address a, llvm::Module *m) |
common::Pattern | saveCryptoRule (const yaracpp::YaraRule &rule, retdec::fileformat::FileFormat *file) |
static RegisterPass< ProviderInitialization > | X ("retdec-provider-init", "Providers initialization", false, false) |
static RegisterPass< RegisterLocalization > | X ("retdec-register-localization", "Make all registers local", false, false) |
static RegisterPass< SelectFunctions > | X ("retdec-select-fncs", "Selected functions optimization", false, false) |
std::string | priority2string (eSourcePriority p) |
static RegisterPass< SimpleTypesAnalysis > | X ("retdec-simple-types", "Simple types recovery optimization", false, false) |
std::ostream & | operator<< (std::ostream &out, const EqSetContainer &eqs) |
std::ostream & | operator<< (std::ostream &out, const EqSet &eq) |
std::ostream & | operator<< (std::ostream &out, const ValueEntry &ve) |
std::ostream & | operator<< (std::ostream &out, const TypeEntry &te) |
std::ostream & | operator<< (std::ostream &out, const EquationEntry &ee) |
static RegisterPass< StackAnalysis > | X ("retdec-stack", "Stack optimization", false, false) |
static RegisterPass< StackPointerOpsRemove > | X ("retdec-stack-ptr-op-remove", "Stack pointer operations optimization", false, false) |
static RegisterPass< SyscallFixer > | X ("retdec-syscalls", "Syscalls optimization", false, false) |
static llvm::RegisterPass< TypesPropagator > | X ("retdec-types-propagation", "Data types propagation", false, false) |
RegisterPass< UnreachableFuncs > | UnreachableFuncsRegistered ("retdec-unreachable-funcs", "Unreachable functions optimization", false, false) |
static RegisterPass< ValueProtect > | X ("retdec-value-protect", "Value protection optimization", false, false) |
void | _getConstantExprInstructionUsers (llvm::ConstantExpr *expr, std::set< llvm::Instruction * > &users, std::set< llvm::ConstantExpr * > &seen) |
void | getConstantExprInstructionUsers (llvm::ConstantExpr *expr, std::set< llvm::Instruction * > &users) |
static RegisterPass< BitcodeWriter > | X ("retdec-write-bc", "Generate the current bitcode", false, false) |
std::unique_ptr< ToolOutputFile > | createBitcodeOutputFile (const std::string &outputFile) |
static RegisterPass< ConfigWriter > | X ("retdec-write-config", "Generate the current config", false, false) |
static llvm::RegisterPass< DsmWriter > | X ("retdec-write-dsm", "Disassembly generation", false, false) |
static RegisterPass< LlvmIrWriter > | X ("retdec-write-ll", "Generate the current LLVM IR", false, false) |
std::unique_ptr< ToolOutputFile > | createAssemblyOutputFile (const std::string &outputFile) |
static RegisterPass< X86AddressSpacesPass > | X ("retdec-x86-addr-spaces", "x86 address spaces optimization", false, false) |
int | augmentedRank (Eigen::MatrixXd &A, Eigen::MatrixXd &B) |
static RegisterPass< X87FpuAnalysis > | X ("retdec-x87-fpu", "x87 fpu register analysis", false, false) |
std::list< FunctionAnalyzeMetadata > | getFunctions2Analyze (llvm::GlobalVariable *top) |
retdec::common::Address | getBasicBlockAddressFromName (llvm::BasicBlock *b) |
std::ostream & | operator<< (std::ostream &out, const AsmInstruction &a) |
void | _eraseUnusedInstructionRecursive (const std::unordered_set< llvm::Value * > &workset) |
Variables | |
retdec::config::Config | _emptyConfig |
using retdec::bin2llvmir::BBEntrySet = typedef std::unordered_set<BasicBlockEntry*> |
using retdec::bin2llvmir::Changed = typedef bool |
using retdec::bin2llvmir::DefSet = typedef std::unordered_set<Definition*> |
using retdec::bin2llvmir::DefVector = typedef std::vector<Definition> |
using retdec::bin2llvmir::EquationEntrySet = typedef std::unordered_set<EquationEntry, EquationEntryHash> |
using retdec::bin2llvmir::Llvm2CapstoneInsnMap = typedef typename std::map<llvm::StoreInst*, cs_insn*> |
using retdec::bin2llvmir::TypeEntrySet = typedef std::unordered_set<TypeEntry, TypeEntryHash> |
using retdec::bin2llvmir::UseSet = typedef std::unordered_set<Use*> |
using retdec::bin2llvmir::UseVector = typedef std::vector<Use> |
using retdec::bin2llvmir::ValueEntrySet = typedef std::unordered_set<ValueEntry, ValueEntryHash> |
using retdec::bin2llvmir::ValueMap = typedef std::unordered_map<llvm::Value*, EqSet*> |
using retdec::bin2llvmir::ValuePair = typedef std::pair<llvm::Value*, llvm::Value*> |
using retdec::bin2llvmir::ValuePairList = typedef std::list<ValuePair> |
|
strong |
void retdec::bin2llvmir::_eraseUnusedInstructionRecursive | ( | const std::unordered_set< llvm::Value * > & | workset | ) |
void retdec::bin2llvmir::_getConstantExprInstructionUsers | ( | llvm::ConstantExpr * | expr, |
std::set< llvm::Instruction * > & | users, | ||
std::set< llvm::ConstantExpr * > & | seen | ||
) |
int retdec::bin2llvmir::augmentedRank | ( | Eigen::MatrixXd & | A, |
Eigen::MatrixXd & | B | ||
) |
std::unique_ptr<ToolOutputFile> retdec::bin2llvmir::createAssemblyOutputFile | ( | const std::string & | outputFile | ) |
Create assembly output file object.
std::unique_ptr<ToolOutputFile> retdec::bin2llvmir::createBitcodeOutputFile | ( | const std::string & | outputFile | ) |
Create bitcode output file object.
llvm::Instruction* retdec::bin2llvmir::defInBasicBlock | ( | llvm::Value * | v, |
llvm::BasicBlock * | bb, | ||
llvm::Instruction * | start = nullptr |
||
) |
Find the last definition of value v
in basic block bb
. If start
is defined (not nullptr
), start the reverse iteration search from this instruction, otherwise start from the basic block's back.
v
(at most one definition is possible in BB), or nullptr
if definition not found. void retdec::bin2llvmir::dumpControFlowToJson | ( | llvm::Module * | m, |
fs::path | dirName, | ||
const std::string & | fileName = "control-flow.json" |
||
) |
void retdec::bin2llvmir::dumpModuleToFile | ( | const llvm::Module * | m, |
fs::path | dirName, | ||
const std::string & | fileName = "" |
||
) |
retdec::common::Address retdec::bin2llvmir::getBasicBlockAddressFromName | ( | llvm::BasicBlock * | b | ) |
void retdec::bin2llvmir::getConstantExprInstructionUsers | ( | llvm::ConstantExpr * | expr, |
std::set< llvm::Instruction * > & | users | ||
) |
Recursively collect all instrucions where expr is used.
std::list<FunctionAnalyzeMetadata> retdec::bin2llvmir::getFunctions2Analyze | ( | llvm::GlobalVariable * | top | ) |
common::Address retdec::bin2llvmir::getInstAddress | ( | const llvm::Instruction * | i | ) |
llvm::MDNode* retdec::bin2llvmir::getInstAddressMeta | ( | common::Address | a, |
llvm::Module * | m | ||
) |
llvm::Value* retdec::bin2llvmir::IdiomsLibgccImpl::getOp0< std::int32_t > | ( | llvm::CallInst * | call | ) |
llvm::Value* retdec::bin2llvmir::IdiomsLibgccImpl::getOp0< std::int64_t > | ( | llvm::CallInst * | call | ) |
llvm::Value* retdec::bin2llvmir::IdiomsLibgccImpl::getOp1< std::int32_t > | ( | llvm::CallInst * | call | ) |
llvm::Value* retdec::bin2llvmir::IdiomsLibgccImpl::getOp1< std::int64_t > | ( | llvm::CallInst * | call | ) |
llvm::Value* retdec::bin2llvmir::IdiomsLibgccImpl::getRes0< std::int32_t > | ( | llvm::CallInst * | call, |
llvm::Value * | res | ||
) |
llvm::Value* retdec::bin2llvmir::IdiomsLibgccImpl::getRes0< std::int64_t > | ( | llvm::CallInst * | call, |
llvm::Value * | res | ||
) |
llvm::Value* retdec::bin2llvmir::IdiomsLibgccImpl::getRes1< std::int32_t > | ( | llvm::CallInst * | call, |
llvm::Value * | res | ||
) |
llvm::Value* retdec::bin2llvmir::IdiomsLibgccImpl::getRes1< std::int64_t > | ( | llvm::CallInst * | call, |
llvm::Value * | res | ||
) |
RegisterPass<Idioms> retdec::bin2llvmir::IdiomsRegistered | ( | "retdec-idioms" | , |
"Instruction idioms optimization" | , | ||
false | , | ||
false | |||
) |
bool retdec::bin2llvmir::insnWrittesPc | ( | csh & | ce, |
cs_insn * | insn | ||
) |
bool retdec::bin2llvmir::insnWrittesPcArm64 | ( | csh & | ce, |
cs_insn * | insn | ||
) |
bool retdec::bin2llvmir::isBadBranch | ( | FileImage * | img, |
cs_insn * | br | ||
) |
Patterns of branch instructions that does not make sense and should not be accepted.
std::string retdec::bin2llvmir::llvmObjToString | ( | const llvm::Module * | t | ) |
We need special function for Module
printing because its print
method takes one more parameter.
t | Module to print. |
std::string retdec::bin2llvmir::llvmObjToString | ( | const T * | t | ) |
Print any LLVM object which implements print(llvm::raw_string_ostream&)
method into std::string.
t | LLVM object to print. |
bool retdec::bin2llvmir::looksLikeArm64FunctionStart | ( | cs_insn * | insn | ) |
bool retdec::bin2llvmir::looksLikeArmFunctionStart | ( | cs_insn * | insn | ) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | os, |
const RangesToDecode & | rs | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const AsmInstruction & | a | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const BasicBlockEntry & | bbe | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const EqSet & | eq | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const EqSetContainer & | eqs | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const EquationEntry & | ee | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const JumpTarget & | jt | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const JumpTargets & | jts | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const ReachingDefinitionsAnalysis & | rda | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const SymbolicTree & | s | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const TypeEntry & | te | ||
) |
std::ostream& retdec::bin2llvmir::operator<< | ( | std::ostream & | out, |
const ValueEntry & | ve | ||
) |
std::string retdec::bin2llvmir::priority2string | ( | eSourcePriority | p | ) |
|
static |
common::Pattern retdec::bin2llvmir::saveCryptoRule | ( | const yaracpp::YaraRule & | rule, |
retdec::fileformat::FileFormat * | file | ||
) |
RegisterPass<UnreachableFuncs> retdec::bin2llvmir::UnreachableFuncsRegistered | ( | "retdec-unreachable-funcs" | , |
"Unreachable functions optimization" | , | ||
false | , | ||
false | |||
) |
bool retdec::bin2llvmir::usesInBasicBlock | ( | llvm::Value * | v, |
llvm::BasicBlock * | bb, | ||
std::set< llvm::Instruction * > & | uses, | ||
llvm::Instruction * | start = nullptr |
||
) |
Find all uses of value v
in basic block bb
and add them to uses
. If start
is defined (not nullptr
), start the iteration search from this instruction, otherwise start from the basic block's front.
True
if the basic block kills the value, false
otherwise.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
retdec::config::Config retdec::bin2llvmir::_emptyConfig |