decompiler  1.0.0
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Architecture Class Referenceabstract

Manager for all the major decompiler subsystems. More...

#include <architecture.hh>

Inheritance diagram for Architecture:
AddrSpaceManager ArchitectureGhidra SleighArchitecture BfdArchitecture RawBinaryArchitecture XmlArchitecture

Public Member Functions

 Architecture (void)
 Construct an uninitialized Architecture. More...
 
void init (DocumentStorage &store)
 Load the image and configure architecture. More...
 
ProtoModelgetModel (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...
 
AddrSpacegetSpaceBySpacebase (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...
 
AddrSpacegetSpaceByName (const string &nm) const
 Get address space by name. More...
 
AddrSpacegetSpaceByShortcut (char sc) const
 Get address space from its shortcut. More...
 
AddrSpacegetIopSpace (void) const
 Get the internal pcode op space. More...
 
AddrSpacegetFspecSpace (void) const
 Get the internal callspec space. More...
 
AddrSpacegetJoinSpace (void) const
 Get the joining space. More...
 
AddrSpacegetStackSpace (void) const
 Get the stack space for this processor. More...
 
AddrSpacegetUniqueSpace (void) const
 Get the temporary register space for this processor. More...
 
AddrSpacegetDefaultSpace (void) const
 Get the default address space of this processor. More...
 
AddrSpacegetConstantSpace (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...
 
AddrSpacegetSpace (int4 i) const
 Get an address space via its index. More...
 
AddrSpacegetNextSpaceInOrder (AddrSpace *spc) const
 Get the next contiguous address space. More...
 
JoinRecordfindAddJoin (const vector< VarnodeData > &pieces, uint4 logicalsize)
 Get (or create) JoinRecord for pieces. More...
 
JoinRecordfindJoin (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)
 
Databasesymboltab
 Memory map of global variables and functions.
 
ContextDatabasecontext
 Map from addresses to context settings.
 
map< string, ProtoModel * > protoModels
 Parsed forms of possible prototypes.
 
ProtoModeldefaultfp
 Parsed form of default prototype.
 
VarnodeData defaultReturnAddr
 Default storage location of return address (for current function)
 
ProtoModelevalfp_current
 Function proto to use when evaluating current function.
 
ProtoModelevalfp_called
 Function proto to use when evaluating called functions.
 
TypeFactorytypes
 List of types for this binary.
 
const Translatetranslate
 Translation method for this binary.
 
LoadImageloader
 Method for loading portions of binary.
 
PcodeInjectLibrarypcodeinjectlib
 Pcode injection manager.
 
RangeList nohighptr
 Ranges for which high-level pointers are not possible.
 
CommentDatabasecommentdb
 Comments for this architecture.
 
ConstantPoolcpool
 Deferred constant values.
 
PrintLanguageprint
 Current high-level language printer.
 
vector< PrintLanguage * > printlist
 List of high-level language printers supported.
 
OptionDatabaseoptions
 Options that can be configured.
 
vector< TypeOp * > inst
 Registered p-code instructions.
 
UserOpManage userops
 Specifically registered user-defined p-code ops.
 
vector< PreferSplitRecordsplitrecords
 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 ScopebuildGlobalScope (void)
 Build the global scope for this executable. More...
 
virtual TranslatebuildTranslator (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 PcodeInjectLibrarybuildPcodeInjectLibrary (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...
 
ProtoModelparseProto (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
AddrSpacerestoreXmlSpace (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...
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Architecture()

Architecture::Architecture ( void  )

◆ ~Architecture()

Architecture::~Architecture ( void  )
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.

Member Function Documentation

◆ addNoHighPtr()

void Architecture::addNoHighPtr ( const Range rng)
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

Parameters
rngis the new range with no aliases to be added

References Range::getFirst(), Range::getLast(), Range::getSpace(), RangeList::insertRange(), and nohighptr.

Referenced by parseNoHighPtr().

◆ addSpacebase()

void Architecture::addSpacebase ( AddrSpace basespace,
const string &  nm,
const VarnodeData ptrdata,
int4  truncSize,
bool  isreversejustified,
bool  stackGrowth 
)
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

Parameters
basespaceis the address space underlying the stack
nmis the name of the new space
ptrdatais the register location acting as a pointer into the new space
truncSizeis the (possibly truncated) size of the register that fits the space
isreversejustifiedis true if small variables are justified opposite of endianness
stackGrowthis 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().

◆ buildAction()

void Architecture::buildAction ( DocumentStorage store)
protectedvirtual

Build the Action framework.

This builds the universal Action for function transformation and instantiates the "decompile" root Action

Parameters
storemay hold configuration information

References allacts, parseExtraRules(), ActionDatabase::setCurrent(), and universal_action().

Referenced by restoreFromSpec().

◆ buildCommentDB()

void Architecture::buildCommentDB ( DocumentStorage store)
protectedvirtual

Build the comment database.

Build the container that holds comments for executable in this Architecture.

Parameters
storemay hold configuration information

Reimplemented in ArchitectureGhidra.

References commentdb.

Referenced by init().

◆ buildConstantPool()

void Architecture::buildConstantPool ( DocumentStorage store)
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.

Parameters
storemay hold configuration information

Reimplemented in ArchitectureGhidra.

References cpool.

Referenced by init().

◆ buildContext()

void Architecture::buildContext ( DocumentStorage store)
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.

Parameters
storemay hold configuration information

Reimplemented in ArchitectureGhidra.

References context.

Referenced by init().

◆ buildGlobalScope()

Scope * Architecture::buildGlobalScope ( void  )
protectedvirtual

Build the global scope for this executable.

If it does not already exist create the glocal Scope object

Returns
the global Scope object

Reimplemented in ArchitectureGhidra.

References Database::attachScope(), Database::getGlobalScope(), and symboltab.

Referenced by globalify(), and parseGlobal().

◆ buildInstructions()

void Architecture::buildInstructions ( DocumentStorage store)
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.

Parameters
storemay hold configuration information

References inst, TypeOp::registerInstructions(), translate, and types.

Referenced by init().

◆ buildLoader()

virtual void Architecture::buildLoader ( DocumentStorage store)
protectedpure virtual

Build the LoadImage object and load the executable image.

Parameters
storemay hold configuration information

Implemented in ArchitectureGhidra, BfdArchitecture, RawBinaryArchitecture, and XmlArchitecture.

Referenced by init().

◆ buildPcodeInjectLibrary()

virtual PcodeInjectLibrary* Architecture::buildPcodeInjectLibrary ( void  )
protectedpure virtual

Build the injection library.

This creates the container for p-code injections. It is initially empty.

Returns
the PcodeInjectLibrary object

Implemented in SleighArchitecture, and ArchitectureGhidra.

Referenced by restoreFromSpec().

◆ buildSpecFile()

virtual void Architecture::buildSpecFile ( DocumentStorage store)
protectedpure virtual

Load any relevant specification files.

Processor/architecture specific configuration files are loaded into the XML store

Parameters
storeis the document store that will hold the configuration

Implemented in SleighArchitecture, and ArchitectureGhidra.

Referenced by init().

◆ buildTranslator()

virtual Translate* Architecture::buildTranslator ( DocumentStorage store)
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.

Parameters
storemay hold configuration information
Returns
the Translate object

Implemented in SleighArchitecture, and ArchitectureGhidra.

Referenced by restoreFromSpec().

◆ buildTypegrp()

void Architecture::buildTypegrp ( DocumentStorage store)
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.

Parameters
storecontains 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().

◆ clearAnalysis()

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.

Parameters
fdis the function to clear

References Funcdata::clear(), CommentDatabase::clearType(), commentdb, Funcdata::getAddress(), Comment::warning, and Comment::warningheader.

Referenced by ActionRestartGroup::apply(), and Funcdata::inlineFlow().

◆ collectBehaviors()

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.

Parameters
behaveis the list to be populated

References TypeOp::getBehavior(), and inst.

Referenced by PcodeInjectLibraryGhidra::getBehaviors().

◆ fillinReadOnlyFromLoader()

void Architecture::fillinReadOnlyFromLoader ( void  )
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().

◆ getModel()

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.

Parameters
nmis the name
Returns
the matching model

References protoModels.

Referenced by ProtoModelMerged::restoreXml(), FuncProto::restoreXml(), and setDefaultModel().

◆ getSpaceBySpacebase()

AddrSpace * Architecture::getSpaceBySpacebase ( const Address loc,
int4  size 
) const

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.

Parameters
locis the location of the spacebase register
sizeis the size of the register in bytes
Returns
a pointer to the address space

References Address::getOffset(), Address::getSpace(), AddrSpaceManager::getSpace(), AddrSpace::getSpacebase(), and AddrSpaceManager::numSpaces().

Referenced by RuleLoadVarnode::correctSpacebase().

◆ globalify()

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.

◆ hasModel()

bool Architecture::hasModel ( const string &  nm) const

Does this Architecture have a specific PrototypeModel.

Parameters
nmis the name of the model
Returns
true if this Architecture supports a model with that name

References protoModels.

◆ hasNearPointers()

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

Parameters
spcis the address space to check
Returns
true if the space supports a segment operation

References AddrSpace::getIndex(), SegmentOp::getResolve(), UserOpManage::getSegmentOp(), UserOpManage::numSegmentOps(), VarnodeData::space, and userops.

Referenced by ActionConstantPtr::apply().

◆ highPtrPossible()

bool Architecture::highPtrPossible ( const Address loc,
int4  size 
) const
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.

Parameters
locis the starting address of the range
sizeis the size of the range in bytes
Returns
true if pointers are possible

References Address::getSpace(), AddrSpace::getType(), RangeList::inRange(), IPTR_INTERNAL, and nohighptr.

Referenced by Heritage::guard().

◆ init()

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.

Parameters
storeis 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().

◆ initializeSegments()

void Architecture::initializeSegments ( void  )
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().

◆ modifySpaces()

virtual void Architecture::modifySpaces ( Translate trans)
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.

Parameters
transis the processor disassembly object

Implemented in SleighArchitecture, and ArchitectureGhidra.

Referenced by restoreFromSpec().

◆ nameFunction()

void Architecture::nameFunction ( const Address addr,
string &  name 
) const
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

Parameters
addris the address of the function
namewill hold the constructed name

References Address::printRaw().

◆ parseAggressiveTrim()

void Architecture::parseAggressiveTrim ( const Element el)
protected

Designate how to trim extension p-code ops.

Configure based on the <aggressivetrim> tag, how aggressively the decompiler will remove extension operations.

Parameters
elis the XML element

References aggressive_ext_trim.

Referenced by parseCompilerConfig().

◆ parseCompilerConfig()

void Architecture::parseCompilerConfig ( DocumentStorage store)
protected

◆ parseDeadcodeDelay()

void Architecture::parseDeadcodeDelay ( const Element el)
protected

Apply dead-code delay configuration.

Manually alter the dead-code delay for a specific address space, based on a <deadcodedelay> tag.

Parameters
elis the XML element

References AddrSpace::getIndex(), AddrSpaceManager::getSpaceByName(), and AddrSpaceManager::setDeadcodeDelay().

Referenced by parseCompilerConfig().

◆ parseDefaultProto()

void Architecture::parseDefaultProto ( const Element el)
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.

Parameters
elis the XML element

References defaultfp, and parseProto().

Referenced by parseCompilerConfig().

◆ parseDynamicRule()

void Architecture::parseDynamicRule ( const Element el)
protected

Apply details of a dynamic Rule object.

Recover information out of a <rule> tag and build the new Rule object.

Parameters
elis the XML element

References extra_pool_rules.

Referenced by parseExtraRules().

◆ parseExtraRules()

void Architecture::parseExtraRules ( DocumentStorage store)
protected

Apply any Rule tags.

Look for the <experimental_rules> tag and create any dynamic Rule objects it specifies.

Parameters
storeis the document store containing the tag

References parseDynamicRule().

Referenced by buildAction().

◆ parseFuncPtrAlign()

void Architecture::parseFuncPtrAlign ( const Element el)
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.

Parameters
elis the XML element

References funcptr_align.

Referenced by parseCompilerConfig().

◆ parseGlobal()

void Architecture::parseGlobal ( const Element el)
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.

Parameters
elis 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().

◆ parseIncidentalCopy()

void Architecture::parseIncidentalCopy ( const Element el)
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.

Parameters
elis the XML element

References Varnode::incidental_copy, VarnodeData::offset, VarnodeData::restoreXml(), Database::setPropertyRange(), VarnodeData::size, VarnodeData::space, and symboltab.

Referenced by parseProcessorConfig().

◆ parseNoHighPtr()

void Architecture::parseNoHighPtr ( const Element el)
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.

Parameters
elis the XML element

References addNoHighPtr(), and Range::restoreXml().

Referenced by parseCompilerConfig().

◆ parsePreferSplit()

void Architecture::parsePreferSplit ( const Element el)
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.

Parameters
elis the XML element

References VarnodeData::restoreXml(), and splitrecords.

Referenced by parseCompilerConfig().

◆ parseProcessorConfig()

void Architecture::parseProcessorConfig ( DocumentStorage store)
protected

Apply processor specific configuration.

This looks for the <processor_spec> tag and and sets configuration parameters based on it.

Parameters
storeis the document store holding the tag

References context, parseIncidentalCopy(), UserOpManage::parseJumpAssist(), parseVolatile(), ContextDatabase::restoreFromSpec(), and userops.

Referenced by restoreFromSpec().

◆ parseProto()

ProtoModel * Architecture::parseProto ( const Element el)
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.

Parameters
elis the XML tag element

References ProtoModel::getName(), protoModels, and ProtoModel::restoreXml().

Referenced by parseCompilerConfig(), and parseDefaultProto().

◆ parseProtoEval()

void Architecture::parseProtoEval ( const Element el)
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.

Parameters
elis the XML element

References evalfp_called, evalfp_current, and protoModels.

Referenced by parseCompilerConfig().

◆ parseReadOnly()

void Architecture::parseReadOnly ( const Element el)
protected

Apply read-only region configuration.

This applies info from a <readonly> tag marking a specific region of the executable as read-only.

Parameters
elis the XML element

References Varnode::readonly, Range::restoreXml(), Database::setPropertyRange(), and symboltab.

Referenced by parseCompilerConfig().

◆ parseReturnAddress()

void Architecture::parseReturnAddress ( const Element el)
protected

Apply return address configuration.

This applies info from <returnaddress> tag and sets the default storage location for the return address of a function.

Parameters
elis the XML element

References defaultReturnAddr, VarnodeData::restoreXml(), and VarnodeData::space.

Referenced by parseCompilerConfig().

◆ parseSpacebase()

void Architecture::parseSpacebase ( const Element el)
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.

Parameters
elis the XML element

References addSpacebase(), Translate::getRegister(), AddrSpaceManager::getSpaceByName(), and translate.

Referenced by parseCompilerConfig().

◆ parseStackPointer()

void Architecture::parseStackPointer ( const Element el)
protected

Apply stack pointer configuration.

Create a stack space and a stack-pointer register from this <stackpointer> element

Parameters
elis the XML element

References addSpacebase(), AddrSpace::getAddrSize(), Translate::getRegister(), AddrSpaceManager::getSpaceByName(), AddrSpace::isTruncated(), VarnodeData::size, and translate.

Referenced by parseCompilerConfig().

◆ parseVolatile()

void Architecture::parseVolatile ( const Element el)
protected

Apply volatile region configuration.

This applies info from a <volatile> tag marking specific regions of the executable as holding volatile memory or registers.

Parameters
elis the XML element

References UserOpManage::parseVolatile(), Range::restoreXml(), Database::setPropertyRange(), symboltab, userops, and Varnode::volatil.

Referenced by parseProcessorConfig().

◆ printMessage()

virtual void Architecture::printMessage ( const string &  message) const
pure virtual

Print an error message to console.

Write the given message to whatever the registered error stream is

Parameters
messageis 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().

◆ readLoaderSymbols()

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.

◆ restoreFlowOverride()

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.

Parameters
elis the XML element

References Database::getGlobalScope(), Funcdata::getOverride(), Override::insertFlowOverride(), Scope::queryFunction(), Address::restoreXml(), Override::stringToType(), and symboltab.

Referenced by restoreXml().

◆ restoreFromSpec()

void Architecture::restoreFromSpec ( DocumentStorage store)
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

Parameters
storewill 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().

◆ restoreXml()

void Architecture::restoreXml ( DocumentStorage store)
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

Parameters
storeis 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().

◆ saveXml()

void Architecture::saveXml ( ostream &  s) const
virtual

Serialize this architecture to XML.

Write the current state of all types, symbols, functions, etc. an XML stream

Parameters
sis 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().

◆ setDefaultModel()

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.

Parameters
nmis the name of the model to set

References defaultfp, and getModel().

Referenced by OptionDefaultPrototype::apply().

◆ setPrintLanguage()

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.

Parameters
nmis 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().

◆ setPrototype()

void Architecture::setPrototype ( const PrototypePieces pieces)

Set the prototype for a particular function.

Establish details of the prototype for a given function symbol

Parameters
piecesholds the raw prototype information and the symbol name

References Funcdata::getFuncProto(), Database::getGlobalScope(), PrototypePieces::name, Scope::queryFunction(), FuncProto::setPieces(), and symboltab.


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