Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
18 #ifndef __CPUI_ARCHITECTURE__
19 #define __CPUI_ARCHITECTURE__
35 #include "prefersplit.hh"
37 #ifdef CPUI_STATISTICS
51 void process_cast(
const Funcdata &data);
55 void countCast(
void) { castcount += 1; }
57 void printResults(ostream &s);
72 static const uint4 majorversion;
73 static const uint4 minorversion;
74 static vector<ArchitectureCapability *> thelist;
78 const string &getName(
void)
const {
return name; }
95 virtual bool isFileMatch(
const string &filename)
const=0;
109 static uint4 getMajorVersion(
void) {
return majorversion; }
110 static uint4 getMinorVersion(
void) {
return minorversion; }
164 #ifdef CPUI_STATISTICS
167 #ifdef OPACTION_DEBUG
168 ostream *debugstream;
175 bool hasModel(
const string &nm)
const;
191 virtual string getDescription(
void)
const {
return archid; }
197 virtual void printMessage(
const string &message)
const=0;
198 virtual void saveXml(ostream &s)
const;
201 #ifdef OPACTION_DEBUG
202 void setDebugStream(ostream *s) { debugstream = s; }
203 void printDebug(
const string &message)
const { *debugstream << message << endl; }
207 int4 truncSize,
bool isreversejustified,
bool stackGrowth);
bool infer_pointers
True if we should infer pointers from constants that are likely addresses.
Definition: architecture.hh:131
int4 trim_recurse_max
How many levels to let parameter trims recurse.
Definition: architecture.hh:124
void resetDefaults(void)
Reset defaults values for options owned by this.
Definition: architecture.cc:1325
virtual Scope * buildDatabase(DocumentStorage &store)
Build the database and global scope for this executable.
Definition: architecture.cc:550
ProtoModel * getModel(const string &nm) const
Get a specific PrototypeModel.
Definition: architecture.cc:184
The base class API for emitting a high-level language.
Definition: printlanguage.hh:134
virtual PcodeInjectLibrary * buildPcodeInjectLibrary(void)=0
Build the injection library.
void parseDefaultProto(const Element *el)
Apply default prototype model configuration.
Definition: architecture.cc:801
const LanedRegister * getLanedRegister(const Address &loc, int4 size) const
Get LanedRegister associated with storage.
Definition: architecture.cc:241
A region where processor data is stored.
Definition: space.hh:73
virtual void postSpecFile(void)
Let components initialize after Translate is built.
Definition: architecture.cc:632
ProtoModel * evalfp_current
Function proto to use when evaluating current function.
Definition: architecture.hh:145
static ArchitectureCapability * getCapability(const string &name)
Get a capability by name.
Definition: architecture.cc:70
void parseDeadcodeDelay(const Element *el)
Apply dead-code delay configuration.
Definition: architecture.cc:986
virtual void resolveArchitecture(void)=0
Figure out the processor and compiler of the target executable.
static void sortCapabilities(void)
Sort extensions.
Definition: architecture.cc:84
OptionDatabase * options
Options that can be configured.
Definition: architecture.hh:157
ContextDatabase * context
Map from addresses to context settings.
Definition: architecture.hh:141
Classes for disassembly and pcode generation.
bool highPtrPossible(const Address &loc, int4 size) const
Are pointers possible to the given location?
Definition: architecture.hh:313
RangeList nohighptr
Ranges for which high-level pointers are not possible.
Definition: architecture.hh:151
void parseCompilerConfig(DocumentStorage &store)
Apply compiler specific configuration.
Definition: architecture.cc:1161
virtual Architecture * buildArchitecture(const string &filename, const string &target, ostream *estream)=0
Build an Architecture given a raw file or data.
int4 max_term_duplication
Max terms duplicated without a new variable.
Definition: architecture.hh:126
void init(DocumentStorage &store)
Load the image and configure architecture.
Definition: architecture.cc:1285
Classes for keeping track of local variables and reconstructing stack layout.
bool inRange(const Address &addr, int4 size) const
Check containment an address range.
Definition: address.cc:402
void collectBehaviors(vector< OpBehavior * > &behave) const
Provide a list of OpBehavior objects.
Definition: architecture.cc:313
AddrSpace * getSpaceBySpacebase(const Address &loc, int4 size) const
Get space associated with a spacebase register.
Definition: architecture.cc:214
int4 funcptr_align
How many bits of alignment a function ptr has.
Definition: architecture.hh:134
Classes for managing p-code injection.
Classes and API for accessing a binary load image.
virtual void buildContext(DocumentStorage &store)
Build the Context database.
Definition: architecture.cc:540
virtual void buildConstantPool(DocumentStorage &store)
Build the constant pool.
Definition: architecture.cc:617
void parseInferPtrBounds(const Element *el)
Apply pointer inference bounds.
Definition: architecture.cc:1003
vector< Rule * > extra_pool_rules
Extra rules that go in the main pool (cpu specific, experimental)
Definition: architecture.hh:138
virtual void initialize(void)
Do specialized initialization.
Definition: architecture.cc:33
@ IPTR_INTERNAL
Internally managed temporary space.
Definition: space.hh:32
void restoreFlowOverride(const Element *el)
Set flow overrides from XML.
Definition: architecture.cc:402
virtual void buildAction(DocumentStorage &store)
Build the Action framework.
Definition: architecture.cc:529
virtual void printMessage(const string &message) const =0
Print an error message to console.
An interface to the pool of constant objects for byte-code languages.
Definition: cpool.hh:92
virtual void restoreXml(DocumentStorage &store)
Restore the Architecture state from an XML stream.
Definition: architecture.cc:442
A complete in-memory XML document.
Definition: xml.hh:206
void parseStackPointer(const Element *el)
Apply stack pointer configuration.
Definition: architecture.cc:955
spacetype getType(void) const
Get the type of space.
Definition: space.hh:291
vector< TypeOp * > inst
Registered p-code instructions.
Definition: architecture.hh:158
A collection of p-code injection payloads.
Definition: pcodeinject.hh:162
A collection of Symbol objects within a single (namespace or functional) scope.
Definition: database.hh:402
ActionDatabase allacts
Actions that can be applied in this architecture.
Definition: architecture.hh:162
Classes for more detailed definitions of user defined p-code operations.
void readLoaderSymbols(const string &delim)
Read any symbols from loader into database.
Definition: architecture.cc:295
void parseProcessorConfig(DocumentStorage &store)
Apply processor specific configuration.
Definition: architecture.cc:1108
void parseExtraRules(DocumentStorage &store)
Apply any Rule tags.
Definition: architecture.cc:1249
void parseNoHighPtr(const Element *el)
Apply memory alias configuration.
Definition: architecture.cc:1057
Classes for processing architecture configuration options.
Database of root Action objects that can be used to transform a function.
Definition: action.hh:298
VarnodeData defaultReturnAddr
Default storage location of return address (for current function)
Definition: architecture.hh:144
An XML element. A node in the DOM tree.
Definition: xml.hh:150
virtual void buildCommentDB(DocumentStorage &store)
Build the comment database.
Definition: architecture.cc:600
void addSpacebase(AddrSpace *basespace, const string &nm, const VarnodeData &ptrdata, int4 truncSize, bool isreversejustified, bool stackGrowth)
Create a new space and associated pointer.
Definition: architecture.cc:503
virtual Address resolve(uintb val, int4 sz, const Address &point, uintb &fullEncoding)
Virtual destructor
Definition: architecture.cc:1334
Abstract class for converting native constants to addresses.
Definition: translate.hh:140
void setPrototype(const PrototypePieces &pieces)
Set the prototype for a particular function.
Definition: architecture.cc:341
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
uint4 flowoptions
options passed to flow following engine
Definition: architecture.hh:135
PrintLanguage * print
Current high-level language printer.
Definition: architecture.hh:155
An interface into a particular binary executable image.
Definition: loadimage.hh:71
Manager/container for description objects (UserPcodeOp) of user defined p-code ops.
Definition: userop.hh:250
virtual Translate * buildTranslator(DocumentStorage &store)=0
Build the Translator object.
int4 getMinimumLanedRegisterSize(void) const
Get the minimum size of a laned register in bytes.
Definition: architecture.cc:263
A prototype model: a model for passing parameters between functions.
Definition: fspec.hh:622
void parseProtoEval(const Element *el)
Apply prototype evaluation configuration.
Definition: architecture.cc:778
void clearAnalysis(Funcdata *fd)
Clear analysis specific to a function.
Definition: architecture.cc:283
SegmentedResolver(Architecture *g, AddrSpace *sp, SegmentOp *sop)
Definition: architecture.hh:301
void parseIncidentalCopy(const Element *el)
Apply incidental copy configuration.
Definition: architecture.cc:913
Infrastructure for discovering code extensions to the decompiler.
ProtoModel * parseProto(const Element *el)
Build a proto-type model from an XML tag.
Definition: architecture.cc:752
ProtoModel * defaultfp
Parsed form of default prototype.
Definition: architecture.hh:143
A disjoint set of Ranges, possibly across multiple address spaces.
Definition: address.hh:203
static ArchitectureCapability * findCapability(const string &filename)
Find an extension to process a file.
Definition: architecture.cc:42
Describes a (register) storage location and the ways it might be split into lanes.
Definition: transform.hh:88
void globalify(void)
Mark all spaces as global.
Definition: architecture.cc:386
StringManager * stringManager
Manager of decoded strings.
Definition: architecture.hh:153
CommentDatabase * commentdb
Comments for this architecture.
Definition: architecture.hh:152
void cacheAddrSpaceProperties(void)
Calculate some frequently used space properties and cache them.
Definition: architecture.cc:682
const Translate * translate
Translation method for this binary.
Definition: architecture.hh:148
TypeFactory * types
List of types for this binary.
Definition: architecture.hh:147
bool readonlypropagate
true if readonly values should be treated as constants
Definition: architecture.hh:130
void setDefaultModel(const string &nm)
Set the default PrototypeModel.
Definition: architecture.cc:274
AddrSpace * getSpace(void) const
Get the address space.
Definition: address.hh:294
virtual bool isFileMatch(const string &filename) const =0
Determine if this extension can handle this file.
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
Raw components of a function prototype (obtained from parsing source code)
Definition: fspec.hh:1144
virtual void buildLoader(DocumentStorage &store)=0
Build the LoadImage object and load the executable image.
Container for data structures associated with a single function.
Definition: funcdata.hh:45
virtual void buildStringManager(DocumentStorage &store)
Build the string manager.
Definition: architecture.cc:608
Container class for all Datatype objects in an Architecture.
Definition: type.hh:396
vector< LanedRegister > lanerecords
Vector registers that have preferred lane sizes.
Definition: architecture.hh:161
int4 min_funcsymbol_size
Minimum size of a function symbol.
Definition: architecture.hh:128
Classes for decoding and storing string data.
An interface to a database of disassembly/decompiler context information.
Definition: globalcontext.hh:108
A manager for symbol scopes for a whole executable.
Definition: database.hh:844
Architecture(void)
Construct an uninitialized Architecture.
Definition: architecture.cc:100
map< string, ProtoModel * > protoModels
Parsed forms of possible prototypes.
Definition: architecture.hh:142
bool hasModel(const string &nm) const
Does this Architecture have a specific PrototypeModel.
Definition: architecture.cc:197
Class for automatically registering extension points to the decompiler.
Definition: capability.hh:36
UserOpManage userops
Specifically registered user-defined p-code ops.
Definition: architecture.hh:159
bool aggressive_ext_trim
Aggressively trim inputs that look like they are sign extended.
Definition: architecture.hh:129
Symbol and Scope objects for the decompiler.
string archid
ID string uniquely describing this architecture.
Definition: architecture.hh:121
The interface to a translation engine for a processor.
Definition: translate.hh:294
void parseDynamicRule(const Element *el)
Apply details of a dynamic Rule object.
Definition: architecture.cc:722
virtual void buildSpecFile(DocumentStorage &store)=0
Load any relevant specification files.
int4 max_implied_ref
Maximum number of references to an implied var.
Definition: architecture.hh:125
void parseReadOnly(const Element *el)
Apply read-only region configuration.
Definition: architecture.cc:864
Definitions for specifying functions prototypes.
A contiguous range of bytes in some address space.
Definition: address.hh:161
Utilities for getting address-based context to the disassembler and decompiler.
void parseVolatile(const Element *el)
Apply volatile region configuration.
Definition: architecture.cc:880
SegmentOp * getSegmentOp(AddrSpace *spc) const
Retrieve the segment op for the given space if any.
Definition: architecture.cc:328
void resetDefaultsInternal(void)
Reset default values for options specific to Architecture.
Definition: architecture.cc:1308
A resolver for segmented architectures.
Definition: architecture.hh:292
vector< AddrSpace * > inferPtrSpaces
Set of address spaces in which a pointer constant is inferable.
Definition: architecture.hh:133
int4 alias_block_level
Aliases blocked by 0=none, 1=struct, 2=array, 3=all.
Definition: architecture.hh:137
void parseLaneSizes(const Element *el)
Apply lane size configuration.
Definition: architecture.cc:930
void initializeSegments()
Set up segment resolvers.
Definition: architecture.cc:665
virtual ~Architecture(void)
Destructor.
Definition: architecture.cc:134
Action, Rule, and other associates classes supporting transformations on function data-flow.
void parseGlobal(const Element *el)
Apply global space configuration.
Definition: architecture.cc:817
PcodeInjectLibrary * pcodeinjectlib
Pcode injection manager.
Definition: architecture.hh:150
virtual void buildInstructions(DocumentStorage &store)
Register the p-code operations.
Definition: architecture.cc:626
void parseSpacebase(const Element *el)
Create an additional indexed space.
Definition: architecture.cc:1043
Data defining a specific memory location.
Definition: pcoderaw.hh:33
void fillinReadOnlyFromLoader(void)
Load info about read-only sections.
Definition: architecture.cc:1265
virtual void modifySpaces(Translate *trans)=0
Modify address spaces as required by this Architecture.
virtual void saveXml(ostream &s) const
Serialize this architecture to XML.
Definition: architecture.cc:423
string name
Identifier for this capability.
Definition: architecture.hh:76
virtual bool isXmlMatch(Document *doc) const =0
Determine is this extension can handle this XML document.
void parseFuncPtrAlign(const Element *el)
Apply function pointer alignment configuration.
Definition: architecture.cc:1020
A container for parsed XML documents.
Definition: xml.hh:249
void parseReturnAddress(const Element *el)
Apply return address configuration.
Definition: architecture.cc:897
A manager for different address spaces.
Definition: translate.hh:218
ProtoModel * evalfp_called
Function proto to use when evaluating called functions.
Definition: architecture.hh:146
virtual void buildTypegrp(DocumentStorage &store)
Build the data-type factory/container.
Definition: architecture.cc:563
void addOtherSpace(void)
Add OTHER space and all of its overlays to the symboltab.
Definition: architecture.cc:844
LoadImage * loader
Method for loading portions of binary.
Definition: architecture.hh:149
int4 max_basetype_size
Maximum size of an "integer" type before creating an array type.
Definition: architecture.hh:127
ConstantPool * cpool
Deferred constant values.
Definition: architecture.hh:154
bool analyze_for_loops
True if we should attempt conversion of whiledo loops to for loops.
Definition: architecture.hh:132
bool loadersymbols_parsed
True if loader symbols have been read.
Definition: architecture.hh:163
void restoreFromSpec(DocumentStorage &store)
Fully initialize the Translate object.
Definition: architecture.cc:641
Database * symboltab
Memory map of global variables and functions.
Definition: architecture.hh:140
vector< PrintLanguage * > printlist
List of high-level language printers supported.
Definition: architecture.hh:156
virtual void nameFunction(const Address &addr, string &name) const
Pick a default name for a function.
Definition: architecture.cc:485
void addNoHighPtr(const Range &rng)
Add a new region where pointers do not exist.
Definition: architecture.cc:520
uint4 max_instructions
Maximum instructions that can be processed in one function.
Definition: architecture.hh:136
void parsePreferSplit(const Element *el)
Designate registers to be split.
Definition: architecture.cc:1073
void parseAggressiveTrim(const Element *el)
Designate how to trim extension p-code ops.
Definition: architecture.cc:1093
The segmented address operator.
Definition: userop.hh:199
Storage for decoding and storing strings associated with an address.
Definition: stringmanage.hh:31
A Dispatcher for possible ArchOption commands.
Definition: options.hh:63
vector< PreferSplitRecord > splitrecords
registers that we would prefer to see split for this processor
Definition: architecture.hh:160
void setPrintLanguage(const string &nm)
Establish a particular output language.
Definition: architecture.cc:360
Abstract extension point for building Architecture objects.
Definition: architecture.hh:71