decompiler
1.0.0
|
Manager for all the major decompiler subsystems. More...
#include <architecture.hh>
Public Member Functions | |
Architecture (void) | |
Construct an uninitialized Architecture. More... | |
void | init (DocumentStorage &store) |
Load the image and configure architecture. More... | |
ProtoModel * | getModel (const string &nm) const |
Get a specific PrototypeModel. More... | |
bool | hasModel (const string &nm) const |
Does this Architecture have a specific PrototypeModel. More... | |
bool | highPtrPossible (const Address &loc, int4 size) const |
Are pointers possible to the given location? More... | |
AddrSpace * | getSpaceBySpacebase (const Address &loc, int4 size) const |
Get space associated with a spacebase register. More... | |
void | setDefaultModel (const string &nm) |
Set the default PrototypeModel. More... | |
void | clearAnalysis (Funcdata *fd) |
Clear analysis specific to a function. More... | |
void | readLoaderSymbols (void) |
Read any symbols from loader into database. More... | |
void | collectBehaviors (vector< OpBehavior * > &behave) const |
Provide a list of OpBehavior objects. More... | |
bool | hasNearPointers (AddrSpace *spc) const |
Does the given address space support near pointers. More... | |
void | setPrototype (const PrototypePieces &pieces) |
Set the prototype for a particular function. More... | |
void | setPrintLanguage (const string &nm) |
Establish a particular output language. More... | |
void | globalify (void) |
Mark all spaces as global. More... | |
void | restoreFlowOverride (const Element *el) |
Set flow overrides from XML. More... | |
virtual | ~Architecture (void) |
Destructor. More... | |
virtual void | printMessage (const string &message) const =0 |
Print an error message to console. More... | |
virtual void | saveXml (ostream &s) const |
Serialize this architecture to XML. More... | |
virtual void | restoreXml (DocumentStorage &store) |
Restore the Architecture state from an XML stream. More... | |
virtual void | nameFunction (const Address &addr, string &name) const |
Pick a default name for a function. More... | |
Public Member Functions inherited from AddrSpaceManager | |
AddrSpaceManager (void) | |
Construct an empty address space manager. More... | |
virtual | ~AddrSpaceManager (void) |
Destroy the manager. More... | |
char | assignShortcut (spacetype tp) const |
Select a shortcut character for a new space. More... | |
int4 | getDefaultSize (void) const |
Get size of addresses for the default space. More... | |
AddrSpace * | getSpaceByName (const string &nm) const |
Get address space by name. More... | |
AddrSpace * | getSpaceByShortcut (char sc) const |
Get address space from its shortcut. More... | |
AddrSpace * | getIopSpace (void) const |
Get the internal pcode op space. More... | |
AddrSpace * | getFspecSpace (void) const |
Get the internal callspec space. More... | |
AddrSpace * | getJoinSpace (void) const |
Get the joining space. More... | |
AddrSpace * | getStackSpace (void) const |
Get the stack space for this processor. More... | |
AddrSpace * | getUniqueSpace (void) const |
Get the temporary register space for this processor. More... | |
AddrSpace * | getDefaultSpace (void) const |
Get the default address space of this processor. More... | |
AddrSpace * | getConstantSpace (void) const |
Get the constant space. More... | |
Address | getConstant (uintb val) const |
Get a constant encoded as an Address. More... | |
Address | createConstFromSpace (AddrSpace *spc) const |
Create a constant address encoding an address space. More... | |
Address | resolveConstant (AddrSpace *spc, uintb val, int4 sz, const Address &point) const |
Resolve native constant to address. | |
int4 | numSpaces (void) const |
Get the number of address spaces for this processor. More... | |
AddrSpace * | getSpace (int4 i) const |
Get an address space via its index. More... | |
AddrSpace * | getNextSpaceInOrder (AddrSpace *spc) const |
Get the next contiguous address space. More... | |
JoinRecord * | findAddJoin (const vector< VarnodeData > &pieces, uint4 logicalsize) |
Get (or create) JoinRecord for pieces. More... | |
JoinRecord * | findJoin (uintb offset) const |
Find JoinRecord for offset in the join space. More... | |
void | setDeadcodeDelay (int4 spcnum, int4 delaydelta) |
Set the deadcodedelay for a specific space. More... | |
void | truncateSpace (const TruncationTag &tag) |
Mark a space as truncated from its original size. More... | |
Address | constructFloatExtensionAddress (const Address &realaddr, int4 realsize, int4 logicalsize) |
Build a logically lower precision storage location for a bigger floating point register. More... | |
Address | constructJoinAddress (const Translate *translate, const Address &hiaddr, int4 hisz, const Address &loaddr, int4 losz) |
Build a logical whole from register pairs. More... | |
Public Attributes | |
string | archid |
ID string uniquely describing this architecture. | |
string | description |
Description of architecture. | |
string | version |
Configuration version. | |
int4 | trim_recurse_max |
How many levels to let parameter trims recurse. | |
int4 | max_implied_ref |
Maximum number of references to an implied var. | |
int4 | max_term_duplication |
Max terms duplicated without a new variable. | |
int4 | max_basetype_size |
Maximum size of an "integer" type before creating an array type. | |
int4 | min_funcsymbol_size |
Minimum size of a function symbol. | |
bool | aggressive_ext_trim |
Aggressively trim inputs that look like they are sign extended. | |
bool | readonlypropagate |
true if readonly values should be treated as constants | |
bool | infer_pointers |
True if we should infer pointers from constants that are likely addresses. | |
uintb | pointer_lowerbound |
Zero or lowest value that can be inferred as an address. | |
int4 | funcptr_align |
How many bits of alignment a function ptr has. | |
uint4 | flowoptions |
options passed to flow following engine | |
vector< Rule * > | extra_pool_rules |
Extra rules that go in the main pool (cpu specific, experimental) | |
Database * | symboltab |
Memory map of global variables and functions. | |
ContextDatabase * | context |
Map from addresses to context settings. | |
map< string, ProtoModel * > | protoModels |
Parsed forms of possible prototypes. | |
ProtoModel * | defaultfp |
Parsed form of default prototype. | |
VarnodeData | defaultReturnAddr |
Default storage location of return address (for current function) | |
ProtoModel * | evalfp_current |
Function proto to use when evaluating current function. | |
ProtoModel * | evalfp_called |
Function proto to use when evaluating called functions. | |
TypeFactory * | types |
List of types for this binary. | |
const Translate * | translate |
Translation method for this binary. | |
LoadImage * | loader |
Method for loading portions of binary. | |
PcodeInjectLibrary * | pcodeinjectlib |
Pcode injection manager. | |
RangeList | nohighptr |
Ranges for which high-level pointers are not possible. | |
CommentDatabase * | commentdb |
Comments for this architecture. | |
ConstantPool * | cpool |
Deferred constant values. | |
PrintLanguage * | |
Current high-level language printer. | |
vector< PrintLanguage * > | printlist |
List of high-level language printers supported. | |
OptionDatabase * | options |
Options that can be configured. | |
vector< TypeOp * > | inst |
Registered p-code instructions. | |
UserOpManage | userops |
Specifically registered user-defined p-code ops. | |
vector< PreferSplitRecord > | splitrecords |
registers that we would prefer to see split for this processor | |
ActionDatabase | allacts |
Actions that can be applied in this architecture. | |
bool | loadersymbols_parsed |
True if loader symbols have been read. | |
Protected Member Functions | |
void | addSpacebase (AddrSpace *basespace, const string &nm, const VarnodeData &ptrdata, int4 truncSize, bool isreversejustified, bool stackGrowth) |
Create a new space and associated pointer. More... | |
void | addNoHighPtr (const Range &rng) |
Add a new region where pointers do not exist. More... | |
virtual Scope * | buildGlobalScope (void) |
Build the global scope for this executable. More... | |
virtual Translate * | buildTranslator (DocumentStorage &store)=0 |
Build the Translator object. More... | |
virtual void | buildLoader (DocumentStorage &store)=0 |
Build the LoadImage object and load the executable image. More... | |
virtual PcodeInjectLibrary * | buildPcodeInjectLibrary (void)=0 |
Build the injection library. More... | |
virtual void | buildTypegrp (DocumentStorage &store) |
Build the data-type factory/container. More... | |
virtual void | buildCommentDB (DocumentStorage &store) |
Build the comment database. More... | |
virtual void | buildConstantPool (DocumentStorage &store) |
Build the constant pool. More... | |
virtual void | buildInstructions (DocumentStorage &store) |
Register the p-code operations. More... | |
virtual void | buildAction (DocumentStorage &store) |
Build the Action framework. More... | |
virtual void | buildContext (DocumentStorage &store) |
Build the Context database. More... | |
virtual void | buildSpecFile (DocumentStorage &store)=0 |
Load any relevant specification files. More... | |
virtual void | modifySpaces (Translate *trans)=0 |
Modify address spaces as required by this Architecture. More... | |
virtual void | postSpecFile (void) |
Let components initialize after Translate is built. | |
virtual void | resolveArchitecture (void)=0 |
Figure out the processor and compiler of the target executable. | |
void | restoreFromSpec (DocumentStorage &store) |
Fully initialize the Translate object. More... | |
void | fillinReadOnlyFromLoader (void) |
Load info about read-only sections. More... | |
void | initializeSegments () |
Set up segment resolvers. More... | |
void | parseProcessorConfig (DocumentStorage &store) |
Apply processor specific configuration. More... | |
void | parseCompilerConfig (DocumentStorage &store) |
Apply compiler specific configuration. More... | |
void | parseExtraRules (DocumentStorage &store) |
Apply any Rule tags. More... | |
void | parseDynamicRule (const Element *el) |
Apply details of a dynamic Rule object. More... | |
ProtoModel * | parseProto (const Element *el) |
Build a proto-type model from an XML tag. More... | |
void | parseProtoEval (const Element *el) |
Apply prototype evaluation configuration. More... | |
void | parseDefaultProto (const Element *el) |
Apply default prototype model configuration. More... | |
void | parseGlobal (const Element *el) |
Apply global space configuration. More... | |
void | parseReadOnly (const Element *el) |
Apply read-only region configuration. More... | |
void | parseVolatile (const Element *el) |
Apply volatile region configuration. More... | |
void | parseReturnAddress (const Element *el) |
Apply return address configuration. More... | |
void | parseIncidentalCopy (const Element *el) |
Apply incidental copy configuration. More... | |
void | parseStackPointer (const Element *el) |
Apply stack pointer configuration. More... | |
void | parseDeadcodeDelay (const Element *el) |
Apply dead-code delay configuration. More... | |
void | parseFuncPtrAlign (const Element *el) |
Apply function pointer alignment configuration. More... | |
void | parseSpacebase (const Element *el) |
Create an additional indexed space. More... | |
void | parseNoHighPtr (const Element *el) |
Apply memory alias configuration. More... | |
void | parsePreferSplit (const Element *el) |
Designate registers to be split. More... | |
void | parseAggressiveTrim (const Element *el) |
Designate how to trim extension p-code ops. More... | |
Protected Member Functions inherited from AddrSpaceManager | |
AddrSpace * | restoreXmlSpace (const Element *el, const Translate *trans) |
Add a space to the model based an on XML tag. More... | |
void | restoreXmlSpaces (const Element *el, const Translate *trans) |
Restore address spaces in the model from an XML tag. More... | |
void | setDefaultSpace (int4 index) |
Set the default address space. More... | |
void | setReverseJustified (AddrSpace *spc) |
Set reverse justified property on this space. More... | |
void | insertSpace (AddrSpace *spc) |
Add a new address space to the model. More... | |
void | copySpaces (const AddrSpaceManager *op2) |
Copy spaces from another manager. More... | |
void | addSpacebasePointer (SpacebaseSpace *basespace, const VarnodeData &ptrdata, int4 truncSize, bool stackGrowth) |
Set the base register of a spacebase space. More... | |
void | insertResolver (AddrSpace *spc, AddressResolver *rsolv) |
Override the base resolver for a space. More... | |
Manager for all the major decompiler subsystems.
An instantiation is tailored to a specific LoadImage, processor, and compiler spec. This class is the owner of the LoadImage, Translate, symbols (Database), PrintLanguage, etc. This class also holds numerous configuration parameters for the analysis process
Architecture::Architecture | ( | void | ) |
Construct an uninitialized Architecture.
Set most sub-components to null pointers. Provide reasonable defaults for the configurable options
References aggressive_ext_trim, PrintLanguageCapability::buildLanguage(), commentdb, context, cpool, defaultfp, defaultReturnAddr, evalfp_called, evalfp_current, flowoptions, funcptr_align, PrintLanguageCapability::getDefault(), infer_pointers, loader, loadersymbols_parsed, max_basetype_size, max_implied_ref, max_term_duplication, min_funcsymbol_size, options, pcodeinjectlib, pointer_lowerbound, print, printlist, readonlypropagate, VarnodeData::space, symboltab, translate, trim_recurse_max, and types.
|
virtual |
Destructor.
Release resources for all sub-components.
References commentdb, context, cpool, extra_pool_rules, inst, loader, options, pcodeinjectlib, printlist, protoModels, symboltab, translate, and types.
|
protected |
Add a new region where pointers do not exist.
This routine is used by the initialization process to add address ranges to which there is never an (indirect) pointer Should only be called during initialization
rng | is the new range with no aliases to be added |
References Range::getFirst(), Range::getLast(), Range::getSpace(), RangeList::insertRange(), and nohighptr.
Referenced by parseNoHighPtr().
|
protected |
Create a new space and associated pointer.
This process sets up a "register relative" space for this architecture If the name is "stack", this space takes on the role of an "official" stack space Should only be called once during initialization
basespace | is the address space underlying the stack |
nm | is the name of the new space |
ptrdata | is the register location acting as a pointer into the new space |
truncSize | is the (possibly truncated) size of the register that fits the space |
isreversejustified | is true if small variables are justified opposite of endianness |
stackGrowth | is true if a stack implemented in this space grows in the negative direction |
References AddrSpaceManager::addSpacebasePointer(), AddrSpace::getDelay(), AddrSpaceManager::insertSpace(), AddrSpaceManager::numSpaces(), AddrSpaceManager::setReverseJustified(), VarnodeData::space, and translate.
Referenced by parseSpacebase(), and parseStackPointer().
|
protectedvirtual |
Build the Action framework.
This builds the universal Action for function transformation and instantiates the "decompile" root Action
store | may hold configuration information |
References allacts, parseExtraRules(), ActionDatabase::setCurrent(), and universal_action().
Referenced by restoreFromSpec().
|
protectedvirtual |
Build the comment database.
Build the container that holds comments for executable in this Architecture.
store | may hold configuration information |
Reimplemented in ArchitectureGhidra.
References commentdb.
Referenced by init().
|
protectedvirtual |
Build the constant pool.
Some processor models (Java byte-code) need a database of constants. The database is always built, but may remain empty.
store | may hold configuration information |
Reimplemented in ArchitectureGhidra.
References cpool.
Referenced by init().
|
protectedvirtual |
Build the Context database.
This builds the database which holds the status registers setings and other information that can affect disassembly depending on context.
store | may hold configuration information |
Reimplemented in ArchitectureGhidra.
References context.
Referenced by init().
|
protectedvirtual |
Build the global scope for this executable.
If it does not already exist create the glocal Scope object
Reimplemented in ArchitectureGhidra.
References Database::attachScope(), Database::getGlobalScope(), and symboltab.
Referenced by globalify(), and parseGlobal().
|
protectedvirtual |
Register the p-code operations.
This registers the OpBehavior objects for all known p-code OpCodes. The Translate and TypeFactory object should already be built.
store | may hold configuration information |
References inst, TypeOp::registerInstructions(), translate, and types.
Referenced by init().
|
protectedpure virtual |
Build the LoadImage object and load the executable image.
store | may hold configuration information |
Implemented in ArchitectureGhidra, BfdArchitecture, RawBinaryArchitecture, and XmlArchitecture.
Referenced by init().
|
protectedpure virtual |
Build the injection library.
This creates the container for p-code injections. It is initially empty.
Implemented in SleighArchitecture, and ArchitectureGhidra.
Referenced by restoreFromSpec().
|
protectedpure virtual |
Load any relevant specification files.
Processor/architecture specific configuration files are loaded into the XML store
store | is the document store that will hold the configuration |
Implemented in SleighArchitecture, and ArchitectureGhidra.
Referenced by init().
|
protectedpure virtual |
Build the Translator object.
This builds the main disassembly component for the Architecture This does not initially the engine for a specific processor.
store | may hold configuration information |
Implemented in SleighArchitecture, and ArchitectureGhidra.
Referenced by restoreFromSpec().
|
protectedvirtual |
Build the data-type factory/container.
This builds the TypeFactory object specific to this architecture and prepopulates it with the core types. Core types may be pulled from the configuration information, or default core types are used.
store | contains possible configuration information |
Reimplemented in ArchitectureGhidra.
References TypeFactory::cacheCoreTypes(), TypeFactory::restoreXmlCoreTypes(), TypeFactory::setCoreType(), TYPE_BOOL, TYPE_CODE, TYPE_FLOAT, TYPE_INT, TYPE_UINT, TYPE_UNKNOWN, TYPE_VOID, and types.
Referenced by init().
void Architecture::clearAnalysis | ( | Funcdata * | fd | ) |
Clear analysis specific to a function.
Throw out the syntax tree, (unlocked) symbols, comments, and other derived information about a single function.
fd | is the function to clear |
References Funcdata::clear(), CommentDatabase::clearType(), commentdb, Funcdata::getAddress(), Comment::warning, and Comment::warningheader.
Referenced by ActionRestartGroup::apply(), and Funcdata::inlineFlow().
void Architecture::collectBehaviors | ( | vector< OpBehavior * > & | behave | ) | const |
Provide a list of OpBehavior objects.
For all registered p-code opcodes, return the corresponding OpBehavior object. The object pointers are provided in a list indexed by OpCode.
behave | is the list to be populated |
References TypeOp::getBehavior(), and inst.
Referenced by PcodeInjectLibraryGhidra::getBehaviors().
|
protected |
Load info about read-only sections.
The LoadImage may have access information about the executables sections. Query for any read-only ranges and store this information in the property database
References RangeList::begin(), RangeList::end(), LoadImage::getReadonly(), loader, Varnode::readonly, Database::setPropertyRange(), and symboltab.
Referenced by init().
ProtoModel * Architecture::getModel | ( | const string & | nm | ) | const |
Get a specific PrototypeModel.
The Architecture maintains the set of prototype models that can be applied for this particular executable. Retrieve one by name. The model must exist or an exception is thrown.
nm | is the name |
References protoModels.
Referenced by ProtoModelMerged::restoreXml(), FuncProto::restoreXml(), and setDefaultModel().
Get space associated with a spacebase register.
Get the address space associated with the indicated spacebase register. I.e. if the location of the stack pointer is passed in, this routine would return a pointer to the stack space. An exception is thrown if no corresponding space is found.
loc | is the location of the spacebase register |
size | is the size of the register in bytes |
References Address::getOffset(), Address::getSpace(), AddrSpaceManager::getSpace(), AddrSpace::getSpacebase(), and AddrSpaceManager::numSpaces().
Referenced by RuleLoadVarnode::correctSpacebase().
void Architecture::globalify | ( | void | ) |
Mark all spaces as global.
Set all IPTR_PROCESSOR and IPTR_SPACEBASE spaces to be global.
References Database::addRange(), buildGlobalScope(), AddrSpace::getHighest(), AddrSpaceManager::getSpace(), AddrSpace::getType(), IPTR_PROCESSOR, IPTR_SPACEBASE, AddrSpaceManager::numSpaces(), and symboltab.
bool Architecture::hasModel | ( | const string & | nm | ) | const |
Does this Architecture have a specific PrototypeModel.
nm | is the name of the model |
References protoModels.
bool Architecture::hasNearPointers | ( | AddrSpace * | spc | ) | const |
Does the given address space support near pointers.
A near pointer is some form of truncated pointer that needs segment or other information to fully form an address. This method searches for a user-defined segment op registered for the space
spc | is the address space to check |
References AddrSpace::getIndex(), SegmentOp::getResolve(), UserOpManage::getSegmentOp(), UserOpManage::numSegmentOps(), VarnodeData::space, and userops.
Referenced by ActionConstantPtr::apply().
|
inline |
Are pointers possible to the given location?
The Translate object keeps track of address ranges for which it is effectively impossible to have a pointer into. This is used for pointer aliasing calculations. This routine returns true if it is possible to have pointers into the indicated range.
loc | is the starting address of the range |
size | is the size of the range in bytes |
References Address::getSpace(), AddrSpace::getType(), RangeList::inRange(), IPTR_INTERNAL, and nohighptr.
Referenced by Heritage::guard().
void Architecture::init | ( | DocumentStorage & | store | ) |
Load the image and configure architecture.
Create the LoadImage and load the executable to be analyzed. Using this and possibly other initialization information, create all the sub-components necessary for a complete Architecture The DocumentStore may hold previously gleaned configuration information and is used to read in other configuration files while initializing.
store | is the XML document store |
References buildCommentDB(), buildConstantPool(), buildContext(), buildInstructions(), buildLoader(), buildSpecFile(), buildTypegrp(), fillinReadOnlyFromLoader(), PrintLanguage::getCastStrategy(), postSpecFile(), print, resolveArchitecture(), restoreFromSpec(), CastStrategy::setTypeFactory(), and types.
Referenced by RegisterProgram::rawAction(), XmlArchitecture::restoreXml(), RawBinaryArchitecture::restoreXml(), and BfdArchitecture::restoreXml().
|
protected |
Set up segment resolvers.
If any address space supports near pointers and segment operators, setup SegmentedResolver objects that can be used to recover full pointers in context.
References UserOpManage::getSegmentOp(), SegmentOp::getSpace(), AddrSpaceManager::insertResolver(), UserOpManage::numSegmentOps(), and userops.
Referenced by parseCompilerConfig().
|
protectedpure virtual |
Modify address spaces as required by this Architecture.
If spaces need to be truncated or otherwise changed from processor defaults, this routine performs the modification.
trans | is the processor disassembly object |
Implemented in SleighArchitecture, and ArchitectureGhidra.
Referenced by restoreFromSpec().
|
virtual |
Pick a default name for a function.
If no better name is available, this method can be used to generate a function name based on its address
addr | is the address of the function |
name | will hold the constructed name |
References Address::printRaw().
|
protected |
Designate how to trim extension p-code ops.
Configure based on the <aggressivetrim> tag, how aggressively the decompiler will remove extension operations.
el | is the XML element |
References aggressive_ext_trim.
Referenced by parseCompilerConfig().
|
protected |
Apply compiler specific configuration.
This looks for the <compiler_spec> tag and sets configuration parameters based on it.
store | is the document store holding the tag |
References archid, InjectPayload::CALLFIXUP_TYPE, context, defaultfp, initializeSegments(), parseAggressiveTrim(), UserOpManage::parseCallOtherFixup(), TypeFactory::parseDataOrganization(), parseDeadcodeDelay(), parseDefaultProto(), TypeFactory::parseEnumConfig(), parseFuncPtrAlign(), parseGlobal(), parseNoHighPtr(), parsePreferSplit(), parseProto(), parseProtoEval(), parseReadOnly(), parseReturnAddress(), UserOpManage::parseSegmentOp(), parseSpacebase(), parseStackPointer(), pcodeinjectlib, protoModels, ContextDatabase::restoreFromSpec(), PcodeInjectLibrary::restoreXmlInject(), UserOpManage::setDefaults(), TypeFactory::setupSizes(), splitrecords, types, and userops.
Referenced by restoreFromSpec().
|
protected |
Apply dead-code delay configuration.
Manually alter the dead-code delay for a specific address space, based on a <deadcodedelay> tag.
el | is the XML element |
References AddrSpace::getIndex(), AddrSpaceManager::getSpaceByName(), and AddrSpaceManager::setDeadcodeDelay().
Referenced by parseCompilerConfig().
|
protected |
Apply default prototype model configuration.
There should be exactly one <default_proto> tag that specifies what the default prototype model is. This builds the ProtoModel object and sets it as the default.
el | is the XML element |
References defaultfp, and parseProto().
Referenced by parseCompilerConfig().
|
protected |
Apply details of a dynamic Rule object.
Recover information out of a <rule> tag and build the new Rule object.
el | is the XML element |
References extra_pool_rules.
Referenced by parseExtraRules().
|
protected |
Apply any Rule tags.
Look for the <experimental_rules> tag and create any dynamic Rule objects it specifies.
store | is the document store containing the tag |
References parseDynamicRule().
Referenced by buildAction().
|
protected |
Apply function pointer alignment configuration.
Pull information from a <funcptr> tag. Turn on alignment analysis of function pointers, some architectures have aligned function pointers and encode extra information in the unused bits.
el | is the XML element |
References funcptr_align.
Referenced by parseCompilerConfig().
|
protected |
Apply global space configuration.
This handles the <global> tag adding an address space (or part of the space) to the global scope. Varnodes in this region will be assumed to be global variables.
el | is the XML element |
References Database::addRange(), buildGlobalScope(), OverlaySpace::getBaseSpace(), Range::getFirst(), Range::getLast(), Range::getSpace(), AddrSpaceManager::getSpace(), AddrSpace::isOverlay(), AddrSpace::isOverlayBase(), AddrSpaceManager::numSpaces(), Range::restoreXml(), and symboltab.
Referenced by parseCompilerConfig().
|
protected |
Apply incidental copy configuration.
Apply information from an <incidentalcopy> tag, which marks a set of addresses as being copied to incidentally. This allows the decompiler to ignore certain side-effects.
el | is the XML element |
References Varnode::incidental_copy, VarnodeData::offset, VarnodeData::restoreXml(), Database::setPropertyRange(), VarnodeData::size, VarnodeData::space, and symboltab.
Referenced by parseProcessorConfig().
|
protected |
Apply memory alias configuration.
Configure memory based on a <nohighptr> tag. Mark specific address ranges to indicate the decompiler will not encounter pointers (aliases) into the range.
el | is the XML element |
References addNoHighPtr(), and Range::restoreXml().
Referenced by parseCompilerConfig().
|
protected |
Designate registers to be split.
Configure registers based on a <prefersplit> tag. Mark specific varnodes that the decompiler should automatically split when it first sees them.
el | is the XML element |
References VarnodeData::restoreXml(), and splitrecords.
Referenced by parseCompilerConfig().
|
protected |
Apply processor specific configuration.
This looks for the <processor_spec> tag and and sets configuration parameters based on it.
store | is the document store holding the tag |
References context, parseIncidentalCopy(), UserOpManage::parseJumpAssist(), parseVolatile(), ContextDatabase::restoreFromSpec(), and userops.
Referenced by restoreFromSpec().
|
protected |
Build a proto-type model from an XML tag.
This handles the <prototype> and <resolveprototype> tags. It builds the ProtoModel object based on the tag and makes it available generally to the decompiler.
el | is the XML tag element |
References ProtoModel::getName(), protoModels, and ProtoModel::restoreXml().
Referenced by parseCompilerConfig(), and parseDefaultProto().
|
protected |
Apply prototype evaluation configuration.
This supports the <eval_called_prototype> and <eval_current_prototype> tag. This determines which prototype model to assume when recovering the prototype for a called function and the current function respectively.
el | is the XML element |
References evalfp_called, evalfp_current, and protoModels.
Referenced by parseCompilerConfig().
|
protected |
Apply read-only region configuration.
This applies info from a <readonly> tag marking a specific region of the executable as read-only.
el | is the XML element |
References Varnode::readonly, Range::restoreXml(), Database::setPropertyRange(), and symboltab.
Referenced by parseCompilerConfig().
|
protected |
Apply return address configuration.
This applies info from <returnaddress> tag and sets the default storage location for the return address of a function.
el | is the XML element |
References defaultReturnAddr, VarnodeData::restoreXml(), and VarnodeData::space.
Referenced by parseCompilerConfig().
|
protected |
Create an additional indexed space.
Designate a new index register and create a new address space associated with it, based on a <spacebase> tag.
el | is the XML element |
References addSpacebase(), Translate::getRegister(), AddrSpaceManager::getSpaceByName(), and translate.
Referenced by parseCompilerConfig().
|
protected |
Apply stack pointer configuration.
Create a stack space and a stack-pointer register from this <stackpointer> element
el | is the XML element |
References addSpacebase(), AddrSpace::getAddrSize(), Translate::getRegister(), AddrSpaceManager::getSpaceByName(), AddrSpace::isTruncated(), VarnodeData::size, and translate.
Referenced by parseCompilerConfig().
|
protected |
Apply volatile region configuration.
This applies info from a <volatile> tag marking specific regions of the executable as holding volatile memory or registers.
el | is the XML element |
References UserOpManage::parseVolatile(), Range::restoreXml(), Database::setPropertyRange(), symboltab, userops, and Varnode::volatil.
Referenced by parseProcessorConfig().
|
pure virtual |
Print an error message to console.
Write the given message to whatever the registered error stream is
message | is the error message |
Implemented in ArchitectureGhidra, and SleighArchitecture.
Referenced by Scope::addCodeLabel(), Scope::addFunction(), Scope::addMapSym(), ActionReturnSplit::apply(), Action::issueWarning(), Rule::issueWarning(), and ActionPool::processOp().
void Architecture::readLoaderSymbols | ( | void | ) |
Read any symbols from loader into database.
Symbols do not necessarily need to be available for the decompiler. This routine loads all the load image knows about into the symbol table
References Scope::addFunction(), LoadImageFunc::address, LoadImage::closeSymbols(), Database::getGlobalScope(), LoadImage::getNextSymbol(), loader, loadersymbols_parsed, LoadImageFunc::name, LoadImage::openSymbols(), and symboltab.
void Architecture::restoreFlowOverride | ( | const Element * | el | ) |
Set flow overrides from XML.
Insert a series of out-of-band flow overrides based on a <flowoverridelist> tag.
el | is the XML element |
References Database::getGlobalScope(), Funcdata::getOverride(), Override::insertFlowOverride(), Scope::queryFunction(), Address::restoreXml(), Override::stringToType(), and symboltab.
Referenced by restoreXml().
|
protected |
Fully initialize the Translate object.
Once the processor is known, the Translate object can be built and fully initialized. Processor and compiler specific configuration is performed
store | will hold parsed configuration information |
References buildAction(), buildPcodeInjectLibrary(), buildTranslator(), AddrSpaceManager::copySpaces(), Translate::getAlignment(), AddrSpaceManager::getDefaultSize(), UserOpManage::initialize(), Translate::initialize(), AddrSpaceManager::insertSpace(), min_funcsymbol_size, modifySpaces(), AddrSpaceManager::numSpaces(), parseCompilerConfig(), parseProcessorConfig(), pcodeinjectlib, pointer_lowerbound, Translate::setDefaultFloatFormats(), translate, and userops.
Referenced by init().
|
virtual |
Restore the Architecture state from an XML stream.
Read in all the sub-component state from a <save_state> XML tag When adding stuff to this BEWARE: The spec file has already initialized stuff
store | is document store containing the parsed root tag |
Reimplemented in BfdArchitecture, RawBinaryArchitecture, and XmlArchitecture.
References commentdb, context, cpool, loadersymbols_parsed, options, pcodeinjectlib, PcodeInjectLibrary::restoreDebug(), restoreFlowOverride(), OptionDatabase::restoreXml(), CommentDatabase::restoreXml(), ConstantPool::restoreXml(), ContextDatabase::restoreXml(), TypeFactory::restoreXml(), Database::restoreXml(), symboltab, and types.
Referenced by XmlArchitecture::restoreXml(), RawBinaryArchitecture::restoreXml(), and BfdArchitecture::restoreXml().
|
virtual |
Serialize this architecture to XML.
Write the current state of all types, symbols, functions, etc. an XML stream
s | is the output stream |
Reimplemented in BfdArchitecture, RawBinaryArchitecture, and XmlArchitecture.
References commentdb, context, cpool, ConstantPool::empty(), loadersymbols_parsed, CommentDatabase::saveXml(), ConstantPool::saveXml(), ContextDatabase::saveXml(), TypeFactory::saveXml(), Database::saveXml(), symboltab, and types.
Referenced by XmlArchitecture::saveXml(), RawBinaryArchitecture::saveXml(), and BfdArchitecture::saveXml().
void Architecture::setDefaultModel | ( | const string & | nm | ) |
Set the default PrototypeModel.
The default model is used whenever an explicit model is not known or can't be determined.
nm | is the name of the model to set |
References defaultfp, and getModel().
Referenced by OptionDefaultPrototype::apply().
void Architecture::setPrintLanguage | ( | const string & | nm | ) |
Establish a particular output language.
The decompiler supports one or more output languages (C, Java). This method does the main work of selecting one of the supported languages. In addition to selecting the main PrintLanguage object, this triggers configuration of the cast strategy and p-code op behaviors.
nm | is the name of the language |
References PrintLanguage::adjustTypeOperators(), PrintLanguageCapability::buildLanguage(), PrintLanguage::emitsXml(), PrintLanguageCapability::findCapability(), PrintLanguage::getCastStrategy(), PrintLanguage::getOutputStream(), print, printlist, PrintLanguage::setOutputStream(), CastStrategy::setTypeFactory(), PrintLanguage::setXML(), and types.
Referenced by OptionSetLanguage::apply().
void Architecture::setPrototype | ( | const PrototypePieces & | pieces | ) |
Set the prototype for a particular function.
Establish details of the prototype for a given function symbol
pieces | holds the raw prototype information and the symbol name |
References Funcdata::getFuncProto(), Database::getGlobalScope(), PrototypePieces::name, Scope::queryFunction(), FuncProto::setPieces(), and symboltab.