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... | |
void | resetDefaultsInternal (void) |
Reset default values for options specific to Architecture. | |
void | resetDefaults (void) |
Reset defaults values for options owned by this. 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... | |
ProtoModel * | createUnknownModel (const string &modelName) |
Create a model for an unrecognized name. 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... | |
const LanedRegister * | getLanedRegister (const Address &loc, int4 size) const |
Get LanedRegister associated with storage. More... | |
int4 | getMinimumLanedRegisterSize (void) const |
Get the minimum size of a laned register in bytes. More... | |
void | setDefaultModel (ProtoModel *model) |
Set the default PrototypeModel. More... | |
void | clearAnalysis (Funcdata *fd) |
Clear analysis specific to a function. More... | |
void | readLoaderSymbols (const string &delim) |
Read any symbols from loader into database. More... | |
void | collectBehaviors (vector< OpBehavior *> &behave) const |
Provide a list of OpBehavior objects. More... | |
SegmentOp * | getSegmentOp (AddrSpace *spc) const |
Retrieve the segment op for the given space if any. 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 | decodeFlowOverride (Decoder &decoder) |
Set flow overrides from XML. More... | |
virtual | ~Architecture (void) |
Destructor. More... | |
virtual string | getDescription (void) const |
Get a string describing this architecture. | |
virtual void | printMessage (const string &message) const =0 |
Print an error message to console. More... | |
virtual void | encode (Encoder &encoder) const |
Encode this architecture to a stream. More... | |
virtual void | restoreXml (DocumentStorage &store) |
Restore the Architecture state from XML documents. More... | |
virtual void | nameFunction (const Address &addr, string &name) const |
Pick a default name for a function. More... | |
Public Member Functions inherited from ghidra::AddrSpaceManager | |
AddrSpaceManager (void) | |
Construct an empty address space manager. More... | |
virtual | ~AddrSpaceManager (void) |
Destroy the manager. 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 * | getDefaultCodeSpace (void) const |
Get the default address space of this processor. More... | |
AddrSpace * | getDefaultDataSpace (void) const |
Get the default address space where data is stored. 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, uintb &fullEncoding) const |
Resolve a native constant into an Address. More... | |
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 (AddrSpace *spc, 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... | |
void | renormalizeJoinAddress (Address &addr, int4 size) |
Make sure a possibly offset join address has a proper JoinRecord. More... | |
Address | parseAddressSimple (const string &val) |
Parse a string with just an address space name and a hex offset. More... | |
Public Attributes | |
string | archid |
ID string uniquely describing this architecture. | |
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. | |
uint4 | max_jumptable_size |
Maximum number of entries in a single JumpTable. | |
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. | |
bool | analyze_for_loops |
True if we should attempt conversion of whiledo loops to for loops. | |
vector< AddrSpace * > | inferPtrSpaces |
Set of address spaces in which a pointer constant is inferable. | |
int4 | funcptr_align |
How many bits of alignment a function ptr has. | |
uint4 | flowoptions |
options passed to flow following engine | |
uint4 | max_instructions |
Maximum instructions that can be processed in one function. | |
int4 | alias_block_level |
Aliases blocked by 0=none, 1=struct, 2=array, 3=all. | |
uint4 | split_datatype_config |
Toggle for data-types splitting: Bit 0=structs, 1=arrays, 2=pointers. | |
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. | |
StringManager * | stringManager |
Manager of decoded strings. | |
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 | |
vector< LanedRegister > | lanerecords |
Vector registers that have preferred lane sizes. | |
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, bool isFormal) |
Create a new address space associated with a pointer register. More... | |
void | addNoHighPtr (const Range &rng) |
Add a new region where pointers do not exist. More... | |
virtual Scope * | buildDatabase (DocumentStorage &store) |
Build the database and 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)=0 |
Build the data-type factory/container. More... | |
virtual void | buildCommentDB (DocumentStorage &store)=0 |
Build the comment database. More... | |
virtual void | buildStringManager (DocumentStorage &store)=0 |
Build the string manager. More... | |
virtual void | buildConstantPool (DocumentStorage &store)=0 |
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)=0 |
Build the Context database. More... | |
virtual void | buildSymbols (DocumentStorage &store)=0 |
Build any symbols from spec files. 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 | cacheAddrSpaceProperties (void) |
Calculate some frequently used space properties and cache them. More... | |
void | createModelAlias (const string &aliasName, const string &parentName) |
Create name alias for a ProtoModel. 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 | decodeDynamicRule (Decoder &decoder) |
Apply details of a dynamic Rule object. More... | |
ProtoModel * | decodeProto (Decoder &decoder) |
Parse a proto-type model from a stream. More... | |
void | decodeProtoEval (Decoder &decoder) |
Apply prototype evaluation configuration. More... | |
void | decodeDefaultProto (Decoder &decoder) |
Apply default prototype model configuration. More... | |
void | decodeGlobal (Decoder &decoder, vector< RangeProperties > &rangeProps) |
Parse information about global ranges. More... | |
void | addToGlobalScope (const RangeProperties &props) |
Add a memory range to the set of addresses considered global. More... | |
void | addOtherSpace (void) |
Add OTHER space and all of its overlays to the symboltab. | |
void | decodeReadOnly (Decoder &decoder) |
Apply read-only region configuration. More... | |
void | decodeVolatile (Decoder &decoder) |
Apply volatile region configuration. More... | |
void | decodeReturnAddress (Decoder &decoder) |
Apply return address configuration. More... | |
void | decodeIncidentalCopy (Decoder &decoder) |
Apply incidental copy configuration. More... | |
void | decodeLaneSizes (Decoder &decoder) |
Apply lane size configuration. More... | |
void | decodeStackPointer (Decoder &decoder) |
Apply stack pointer configuration. More... | |
void | decodeDeadcodeDelay (Decoder &decoder) |
Apply dead-code delay configuration. More... | |
void | decodeInferPtrBounds (Decoder &decoder) |
Apply pointer inference bounds. More... | |
void | decodeFuncPtrAlign (Decoder &decoder) |
Apply function pointer alignment configuration. More... | |
void | decodeSpacebase (Decoder &decoder) |
Create an additional indexed space. More... | |
void | decodeNoHighPtr (Decoder &decoder) |
Apply memory alias configuration. More... | |
void | decodePreferSplit (Decoder &decoder) |
Designate registers to be split. More... | |
void | decodeAggressiveTrim (Decoder &decoder) |
Designate how to trim extension p-code ops. More... | |
Protected Member Functions inherited from ghidra::AddrSpaceManager | |
AddrSpace * | decodeSpace (Decoder &decoder, const Translate *trans) |
Add a space to the model based an on XML tag. More... | |
void | decodeSpaces (Decoder &decoder, const Translate *trans) |
Restore address spaces in the model from an XML tag. More... | |
void | setDefaultCodeSpace (int4 index) |
Set the default address space (for code) More... | |
void | setDefaultDataSpace (int4 index) |
Set the default address space for data. More... | |
void | setReverseJustified (AddrSpace *spc) |
Set reverse justified property on this space. More... | |
void | assignShortcut (AddrSpace *spc) |
Select a shortcut character for a new space. More... | |
void | markNearPointers (AddrSpace *spc, int4 size) |
Mark that given space can be accessed with near pointers. 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... | |
void | setInferPtrBounds (const Range &range) |
Set the range of addresses that can be inferred as pointers. More... | |
JoinRecord * | findJoinInternal (uintb offset) const |
Find JoinRecord for offset in the join 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
ghidra::Architecture::Architecture | ( | void | ) |
Construct an uninitialized Architecture.
Set most sub-components to null pointers. Provide reasonable defaults for the configurable options
References ghidra::PrintLanguageCapability::buildLanguage(), and ghidra::PrintLanguageCapability::getDefault().
|
virtual |
Destructor.
Release resources for all sub-components.
|
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 ghidra::Range::getFirst(), ghidra::Range::getLast(), and ghidra::Range::getSpace().
|
protected |
Create a new address space associated with a pointer register.
This process sets up a register relative"space for this architecture. If indicated, this space takes on the role of the formal 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 |
isFormal | is the indicator for the formal stack space |
References ghidra::AddrSpace::getDelay(), and ghidra::VarnodeData::space.
|
protected |
Add a memory range to the set of addresses considered global.
Add a memory range parse from a <global> tag to the global scope. Varnodes in this region will be assumed to be global variables.
props | is information about a specific range |
References ghidra::AddrSpace::getContain(), ghidra::Range::getFirst(), ghidra::Range::getLast(), ghidra::Range::getSpace(), ghidra::AddrSpace::isOverlay(), and ghidra::AddrSpace::isOverlayBase().
|
protectedvirtual |
|
protectedpure virtual |
Build the comment database.
Build the container that holds comments in this Architecture.
store | may hold configuration information |
Implemented in ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
protectedpure virtual |
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 |
Implemented in ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
protectedpure virtual |
Build the Context database.
Build the database which holds status register settings and other information that can affect disassembly depending on context.
store | may hold configuration information |
Implemented in ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
protectedvirtual |
Build the database and global scope for this executable.
Create the database object, which currently doesn't not depend on any configuration data. Then create the root (global) scope and attach it to the database.
store | is the storage for any configuration data |
Reimplemented in ghidra::ArchitectureGhidra.
|
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 ghidra::TypeOp::registerInstructions().
|
protectedpure virtual |
Build the LoadImage object and load the executable image.
store | may hold configuration information |
Implemented in ghidra::ArchitectureGhidra, ghidra::BfdArchitecture, ghidra::RawBinaryArchitecture, and ghidra::XmlArchitecture.
|
protectedpure virtual |
Build the injection library.
This creates the container for p-code injections. It is initially empty.
Implemented in ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
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 ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
protectedpure virtual |
Build the string manager.
Build container that holds decoded strings for this Architecture.
store | may hold configuration information |
Implemented in ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
protectedpure virtual |
Build any symbols from spec files.
Formal symbols described in a spec file are added to the global scope.
store | may hold symbol elements |
Implemented in ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
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 ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
protectedpure virtual |
Build the data-type factory/container.
Build the TypeFactory object specific to this Architecture and prepopulate 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 |
Implemented in ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
protected |
Calculate some frequently used space properties and cache them.
Determine the minimum pointer size for the space and whether or not there are near pointers. Set up an ordered list of inferable spaces (where constant pointers can be infered). Inferable spaces include the default space and anything explicitly listed in the cspec <global> tag that is not a register space. An initial list of potential spaces is passed in that needs to be ordered, filtered, and deduplicated.
References ghidra::AddrSpace::compareByIndex(), ghidra::AddrSpace::getDelay(), ghidra::SegmentOp::getInnerSize(), ghidra::AddrSpace::getType(), ghidra::IPTR_SPACEBASE, ghidra::AddrSpace::isOtherSpace(), and ghidra::AddrSpace::isOverlay().
void ghidra::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 ghidra::Funcdata::clear(), ghidra::Funcdata::getAddress(), ghidra::Comment::warning, and ghidra::Comment::warningheader.
Referenced by ghidra::ActionRestartGroup::apply(), and ghidra::Funcdata::inlineFlow().
void ghidra::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 ghidra::TypeOp::getBehavior().
Referenced by ghidra::PcodeInjectLibraryGhidra::getBehaviors().
|
protected |
Create name alias for a ProtoModel.
Clone the named ProtoModel, attaching it to another name.
aliasName | is the new name to assign |
parentName | is the name of the parent model |
References ghidra::ProtoModel::getAliasParent(), and ghidra::ProtoModel::isMerged().
ProtoModel * ghidra::Architecture::createUnknownModel | ( | const string & | modelName | ) |
Create a model for an unrecognized name.
A new UnknownProtoModel, which clones its behavior from the default model, is created and associated with the unrecognized name. Subsequent queries of the name return this new model.
modelName | is the unrecognized name |
References ghidra::ProtoModel::setPrintInDecl().
Referenced by ghidra::FuncProto::decode().
|
protected |
Designate how to trim extension p-code ops.
Configure, based on the <aggressivetrim> element, how aggressively the decompiler will remove extension operations.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Decoder::getNextAttributeId(), ghidra::Decoder::openElement(), and ghidra::Decoder::readBool().
|
protected |
Apply dead-code delay configuration.
Manually alter the dead-code delay for a specific address space, based on a <deadcodedelay> element.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Decoder::openElement(), ghidra::Decoder::readSignedInteger(), and ghidra::Decoder::readSpace().
|
protected |
Apply default prototype model configuration.
There should be exactly one <default_proto> element that specifies what the default prototype model is. This builds the ProtoModel object and sets it as the default.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Decoder::openElement(), and ghidra::Decoder::peekElement().
|
protected |
Apply details of a dynamic Rule object.
Recover information out of a <rule> element and build the new Rule object.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Decoder::getNextAttributeId(), ghidra::Decoder::openElement(), ghidra::Decoder::readBool(), and ghidra::Decoder::readString().
void ghidra::Architecture::decodeFlowOverride | ( | Decoder & | decoder | ) |
Set flow overrides from XML.
Insert a series of out-of-band flow overrides based on a <flowoverridelist> element.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Address::decode(), ghidra::Funcdata::getOverride(), ghidra::Override::insertFlowOverride(), ghidra::Decoder::openElement(), ghidra::Decoder::readString(), and ghidra::Override::stringToType().
|
protected |
Apply function pointer alignment configuration.
Pull information from a <funcptr> element. Turn on alignment analysis of function pointers, some architectures have aligned function pointers and encode extra information in the unused bits.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Decoder::openElement(), and ghidra::Decoder::readSignedInteger().
|
protected |
Parse information about global ranges.
Parse a <global> element for child <range> elements that will be added to the global scope. Ranges are stored in partial form so that elements can be parsed before all address spaces exist.
decoder | is the stream decoder |
rangeProps | is where the partially parsed ranges are stored |
References ghidra::Decoder::closeElement(), ghidra::Decoder::openElement(), and ghidra::Decoder::peekElement().
|
protected |
Apply incidental copy configuration.
Apply information from an <incidentalcopy> element, which marks a set of addresses as being copied to incidentally. This allows the decompiler to ignore certain side-effects.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::VarnodeData::decode(), ghidra::Varnode::incidental_copy, ghidra::VarnodeData::offset, ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), ghidra::VarnodeData::size, and ghidra::VarnodeData::space.
|
protected |
Apply pointer inference bounds.
Alter the range of addresses for which a pointer is allowed to be inferred.
References ghidra::Decoder::closeElement(), ghidra::Range::decode(), ghidra::Decoder::openElement(), and ghidra::Decoder::peekElement().
|
protected |
Apply lane size configuration.
Look for <register> elements that have a vector_lane_size attribute. Record these so that the decompiler can split large registers into appropriate lane size pieces.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::LanedRegister::decode(), ghidra::LanedRegister::getSizeBitMask(), ghidra::LanedRegister::getWholeSize(), ghidra::Decoder::openElement(), and ghidra::Decoder::peekElement().
|
protected |
Apply memory alias configuration.
Configure memory based on a <nohighptr> element. Mark specific address ranges to indicate the decompiler will not encounter pointers (aliases) into the range.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Range::decode(), ghidra::Decoder::openElement(), and ghidra::Decoder::peekElement().
|
protected |
Designate registers to be split.
Configure registers based on a <prefersplit> element. Mark specific varnodes that the decompiler should automatically split when it first sees them.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), and ghidra::Decoder::readString().
|
protected |
Parse a proto-type model from a stream.
This handles the <prototype> and <resolveprototype> elements. It builds the ProtoModel object based on the tag and makes it available generally to the decompiler.
decoder | is the stream decoder |
References ghidra::ProtoModel::decode(), ghidra::ProtoModel::getName(), and ghidra::Decoder::peekElement().
|
protected |
Apply prototype evaluation configuration.
This decodes the <eval_called_prototype> and <eval_current_prototype> elements. This determines which prototype model to assume when recovering the prototype for a called function and the current function respectively.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Decoder::openElement(), and ghidra::Decoder::readString().
|
protected |
Apply read-only region configuration.
This applies info from a <readonly> element marking a specific region of the executable as read-only.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Range::decode(), ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), and ghidra::Varnode::readonly.
|
protected |
Apply return address configuration.
This applies info from <returnaddress> element and sets the default storage location for the return address of a function.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Decoder::openElement(), and ghidra::Decoder::peekElement().
|
protected |
Create an additional indexed space.
Designate a new index register and create a new address space associated with it, based on a <spacebase> element.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Decoder::openElement(), ghidra::Decoder::readSpace(), and ghidra::Decoder::readString().
|
protected |
Apply stack pointer configuration.
Create a stack space and a stack-pointer register from a <stackpointer> element
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::AddrSpace::getAddrSize(), ghidra::Decoder::getNextAttributeId(), ghidra::AddrSpace::isTruncated(), ghidra::Decoder::openElement(), ghidra::Decoder::readBool(), ghidra::Decoder::readSpace(), and ghidra::Decoder::readString().
|
protected |
Apply volatile region configuration.
This applies info from a <volatile> element marking specific regions of the executable as holding volatile memory or registers.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::Range::decode(), ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), and ghidra::Varnode::volatil.
|
virtual |
Encode this architecture to a stream.
Write the current state of all types, symbols, functions, etc. to a stream.
encoder | is the stream encoder |
Reimplemented in ghidra::BfdArchitecture, ghidra::RawBinaryArchitecture, and ghidra::XmlArchitecture.
References ghidra::Encoder::closeElement(), ghidra::Encoder::openElement(), and ghidra::Encoder::writeBool().
Referenced by ghidra::RawBinaryArchitecture::encode(), ghidra::XmlArchitecture::encode(), and ghidra::BfdArchitecture::encode().
|
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 ghidra::RangeList::begin(), ghidra::RangeList::end(), and ghidra::Varnode::readonly.
const LanedRegister * ghidra::Architecture::getLanedRegister | ( | const Address & | loc, |
int4 | size | ||
) | const |
Get LanedRegister associated with storage.
Look-up the laned register record associated with a specific storage location. Currently, the record is only associated with the size of the storage, not its address. If there is no associated record, null is returned.
loc | is the starting address of the storage location |
size | is the size of the storage in bytes |
References ghidra::LanedRegister::getWholeSize().
Referenced by ghidra::Funcdata::checkForLanedRegister().
int4 ghidra::Architecture::getMinimumLanedRegisterSize | ( | void | ) | const |
Get the minimum size of a laned register in bytes.
Return a size intended for comparison with a Varnode size to immediately determine if the Varnode is a potential laned register. If there are no laned registers for the architecture, -1 is returned.
Referenced by ghidra::Funcdata::clear(), and ghidra::Funcdata::Funcdata().
ProtoModel * ghidra::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. If the model doesn't exist, null is returned.
nm | is the name |
Referenced by ghidra::OptionDefaultPrototype::apply(), ghidra::OptionProtoEval::apply(), and ghidra::FuncProto::decode().
Retrieve the segment op for the given space if any.
This method searches for a user-defined segment op registered for the given space.
spc | is the address space to check |
References ghidra::AddrSpace::getIndex(), ghidra::SegmentOp::getResolve(), and ghidra::VarnodeData::space.
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 ghidra::Address::getOffset(), ghidra::Address::getSpace(), and ghidra::AddrSpace::getSpacebase().
Referenced by ghidra::RuleLoadVarnode::correctSpacebase().
void ghidra::Architecture::globalify | ( | void | ) |
Mark all spaces as global.
Set all IPTR_PROCESSOR and IPTR_SPACEBASE spaces to be global.
References ghidra::AddrSpace::getHighest(), ghidra::AddrSpace::getType(), ghidra::IPTR_PROCESSOR, and ghidra::IPTR_SPACEBASE.
bool ghidra::Architecture::hasModel | ( | const string & | nm | ) | const |
Does this Architecture have a specific PrototypeModel.
nm | is the name of the model |
|
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 ghidra::Address::getSpace(), ghidra::AddrSpace::getType(), and ghidra::IPTR_INTERNAL.
void ghidra::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 |
Referenced by ghidra::FunctionTestCollection::buildProgram(), ghidra::XmlArchitecture::restoreXml(), ghidra::RawBinaryArchitecture::restoreXml(), and ghidra::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 ghidra::SegmentOp::getSpace().
|
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 ghidra::SleighArchitecture, and ghidra::ArchitectureGhidra.
|
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 ghidra::Address::printRaw().
|
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 ghidra::InjectPayload::CALLFIXUP_TYPE, ghidra::XmlDecode::closeElement(), ghidra::DocumentStorage::getTag(), ghidra::XmlDecode::openElement(), ghidra::XmlDecode::peekElement(), and ghidra::XmlDecode::readString().
|
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 ghidra::XmlDecode::closeElement(), ghidra::DocumentStorage::getTag(), ghidra::XmlDecode::openElement(), and ghidra::XmlDecode::peekElement().
|
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 ghidra::XmlDecode::closeElement(), ghidra::XmlDecode::closeElementSkipping(), ghidra::XmlDecode::getCurrentXmlElement(), ghidra::AddrSpace::getIndex(), ghidra::DocumentStorage::getTag(), ghidra::XmlDecode::openElement(), ghidra::XmlDecode::peekElement(), ghidra::XmlDecode::readSpace(), and ghidra::DocumentStorage::registerTag().
|
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 ghidra::ArchitectureGhidra, and ghidra::SleighArchitecture.
Referenced by ghidra::ActionReturnSplit::apply(), ghidra::Action::issueWarning(), ghidra::Rule::issueWarning(), and ghidra::ActionPool::processOp().
void ghidra::Architecture::readLoaderSymbols | ( | const string & | delim | ) |
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
delim | is the delimiter separating namespaces from symbol base names |
References ghidra::Scope::addFunction(), ghidra::LoadImageFunc::address, and ghidra::LoadImageFunc::name.
void ghidra::Architecture::resetDefaults | ( | void | ) |
Reset defaults values for options owned by this.
Reset options that can be modified by the OptionDatabase. This includes options specific to this class and options under PrintLanguage and ActionDatabase
|
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 ghidra::Translate::initialize(), and ghidra::Translate::setDefaultFloatFormats().
|
virtual |
Restore the Architecture state from XML documents.
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 ghidra::BfdArchitecture, ghidra::RawBinaryArchitecture, and ghidra::XmlArchitecture.
References ghidra::XmlDecode::closeElement(), ghidra::XmlDecode::getNextAttributeId(), ghidra::DocumentStorage::getTag(), ghidra::XmlDecode::openElement(), ghidra::XmlDecode::peekElement(), and ghidra::XmlDecode::readBool().
Referenced by ghidra::RawBinaryArchitecture::restoreXml(), ghidra::XmlArchitecture::restoreXml(), and ghidra::BfdArchitecture::restoreXml().
void ghidra::Architecture::setDefaultModel | ( | ProtoModel * | model | ) |
Set the default PrototypeModel.
The default model is used whenever an explicit model is not known or can't be determined.
model | is the ProtoModel object to make the default |
References ghidra::ProtoModel::setPrintInDecl().
Referenced by ghidra::OptionDefaultPrototype::apply().
void ghidra::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 ghidra::PrintLanguageCapability::buildLanguage(), ghidra::PrintLanguageCapability::findCapability(), ghidra::ArchitectureCapability::getName(), and ghidra::PrintLanguage::setOutputStream().
Referenced by ghidra::OptionSetLanguage::apply().
void ghidra::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 ghidra::Funcdata::getFuncProto(), ghidra::PrototypePieces::name, ghidra::Scope::queryFunction(), and ghidra::FuncProto::setPieces().