retdec
|
This class is the main chunk of code that converts an LLVM module to the specified high-level language (HLL). More...
#include <llvmir2hll.h>
Public Member Functions | |
LlvmIr2Hll (retdec::config::Config *c=nullptr) | |
Constructs a new decompiler. More... | |
virtual void | getAnalysisUsage (llvm::AnalysisUsage &au) const override |
virtual bool | runOnModule (llvm::Module &m) override |
void | setConfig (retdec::config::Config *c) |
void | setOutputString (std::string *outString) |
Static Public Attributes | |
static char | ID = 0 |
Private Member Functions | |
bool | initialize (llvm::Module &m) |
Initializes all the needed private variables. More... | |
void | createSemantics () |
Creates the used semantics. More... | |
void | createSemanticsFromParameter () |
Creates the used semantics as requested by the user. More... | |
void | createSemanticsFromLLVMIR () |
Creates the used semantics based on the data in the input LLVM IR. More... | |
bool | loadConfig () |
Loads a config for the module. More... | |
void | saveConfig () |
Saves the config file. More... | |
bool | convertLLVMIRToBIR () |
Convert the LLVM IR module into a BIR module using the instantiated converter. More... | |
void | removeLibraryFuncs () |
Removes defined functions which are from some standard library whose header file has to be included because of some function declarations. More... | |
void | removeCodeUnreachableInCFG () |
Removes code from all the functions in the module that is unreachable in the CFG. More... | |
void | fixSignedUnsignedTypes () |
Fixes signed and unsigned types in the resulting module. More... | |
void | convertLLVMIntrinsicFunctions () |
Converts LLVM intrinsic functions to functions from the standard library. More... | |
void | obtainDebugInfo () |
When available, obtains debugging information. More... | |
void | initAliasAnalysis () |
Initializes the alias analysis. More... | |
void | runOptimizations () |
Runs the optimizations over the resulting module. More... | |
void | renameVariables () |
Renames variables in the resulting module by using the selected variable renamer. More... | |
void | convertConstantsToSymbolicNames () |
Converts constants in function calls to symbolic names. More... | |
void | validateResultingModule () |
Validates the resulting module. More... | |
void | findPatterns () |
Finds patterns in the resulting module. More... | |
void | emitCFGs () |
Emits a control-flow graph (CFG) for each function in the resulting module. More... | |
void | emitCG () |
Emits a call graph (CG) for the resulting module. More... | |
void | emitTargetHLLCode () |
Emits the target HLL code. More... | |
void | finalize () |
Finalizes the run of the back-end part. More... | |
void | cleanup () |
Cleanup. More... | |
llvmir2hll::StringSet | parseListOfOpts (const std::string &opts) const |
Parses the given list of optimizations. More... | |
std::string | getTypeOfRunOptimizations () const |
Returns the type of optimizations that should be run (as a string). More... | |
llvmir2hll::StringVector | getIdsOfPatternFindersToBeRun () const |
Returns the IDs of pattern finders to be run. More... | |
llvmir2hll::PatternFinderRunner::PatternFinders | instantiatePatternFinders (const llvmir2hll::StringVector &pfsIds) |
Instantiates and returns the pattern finders described by their ID. More... | |
ShPtr< llvmir2hll::PatternFinderRunner > | instantiatePatternFinderRunner () const |
Instantiates and returns a proper PatternFinderRunner. More... | |
Private Attributes | |
llvm::Module * | llvmModule = nullptr |
The input LLVM module. More... | |
ShPtr< llvmir2hll::Module > | resModule |
The resulting module in BIR. More... | |
ShPtr< llvmir2hll::Semantics > | semantics |
The used semantics. More... | |
config::Config * | globalConfig = nullptr |
The used config. More... | |
ShPtr< llvmir2hll::Config > | config |
ShPtr< llvmir2hll::HLLWriter > | hllWriter |
The used HLL writer. More... | |
ShPtr< llvmir2hll::AliasAnalysis > | aliasAnalysis |
The used alias analysis. More... | |
ShPtr< llvmir2hll::CallInfoObtainer > | cio |
The used obtainer of information about function and function calls. More... | |
ShPtr< llvmir2hll::ArithmExprEvaluator > | arithmExprEvaluator |
The used evaluator of arithmetical expressions. More... | |
ShPtr< llvmir2hll::VarNameGen > | varNameGen |
The used generator of variable names. More... | |
ShPtr< llvmir2hll::VarRenamer > | varRenamer |
The used renamer of variables. More... | |
std::unique_ptr< llvm::ToolOutputFile > | outFile |
Output file stream. More... | |
std::unique_ptr< llvm::raw_string_ostream > | outStringStream |
Output string stream. More... | |
This class is the main chunk of code that converts an LLVM module to the specified high-level language (HLL).
The decompilation is composed of the following steps: 1) LLVM instantiates Decompiler with the output stream, where the target code will be emitted. 2) The function runOnModule() is called, which decompiles the given LLVM IR into BIR (backend IR). 3) The resulting IR is then converted into the requested HLL at the end of runOnModule().
The HLL is specified in -target-hll
when running llvmir2hll. Debug comments can be enabled by using the -emit-debug-comments
parameter. For more information, run llvmir2hll with -help
.
retdec::llvmir2hll::LlvmIr2Hll::LlvmIr2Hll | ( | retdec::config::Config * | c = nullptr | ) |
Constructs a new decompiler.
|
private |
Cleanup.
|
private |
Converts constants in function calls to symbolic names.
|
private |
Converts LLVM intrinsic functions to functions from the standard library.
|
private |
Convert the LLVM IR module into a BIR module using the instantiated converter.
True
if decompilation should continue, False
if something went wrong and decompilation should abort.
|
private |
Creates the used semantics.
|
private |
Creates the used semantics based on the data in the input LLVM IR.
|
private |
Creates the used semantics as requested by the user.
|
private |
Emits a control-flow graph (CFG) for each function in the resulting module.
|
private |
Emits a call graph (CG) for the resulting module.
|
private |
Emits the target HLL code.
|
private |
Finalizes the run of the back-end part.
|
private |
Finds patterns in the resulting module.
|
private |
Fixes signed and unsigned types in the resulting module.
|
overridevirtual |
|
private |
Returns the IDs of pattern finders to be run.
|
private |
Returns the type of optimizations that should be run (as a string).
|
private |
Initializes the alias analysis.
|
private |
Initializes all the needed private variables.
true
if the decompilation should continue (the initialization went OK), false
otherwise.
|
private |
Instantiates and returns a proper PatternFinderRunner.
|
private |
Instantiates and returns the pattern finders described by their ID.
If a pattern finder cannot be instantiated, a warning message is emitted.
|
private |
Loads a config for the module.
false
otherwise.
|
private |
When available, obtains debugging information.
|
private |
Parses the given list of optimizations.
opts should be a list of strings separated by a comma.
|
private |
Removes code from all the functions in the module that is unreachable in the CFG.
|
private |
Removes defined functions which are from some standard library whose header file has to be included because of some function declarations.
|
private |
Renames variables in the resulting module by using the selected variable renamer.
|
overridevirtual |
|
private |
Runs the optimizations over the resulting module.
|
private |
Saves the config file.
void retdec::llvmir2hll::LlvmIr2Hll::setConfig | ( | retdec::config::Config * | c | ) |
void retdec::llvmir2hll::LlvmIr2Hll::setOutputString | ( | std::string * | outString | ) |
|
private |
Validates the resulting module.
|
private |
The used alias analysis.
|
private |
The used evaluator of arithmetical expressions.
|
private |
The used obtainer of information about function and function calls.
|
private |
|
private |
The used config.
|
private |
The used HLL writer.
|
static |
|
private |
The input LLVM module.
|
private |
Output file stream.
|
private |
Output string stream.
|
private |
The resulting module in BIR.
|
private |
The used semantics.
|
private |
The used generator of variable names.
|
private |
The used renamer of variables.