Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
19 #ifndef __CPUI_VARMAP__
20 #define __CPUI_VARMAP__
37 addr(ad), useaddr(use), size(sz), name(nm), symbolId(
id) {}
38 const Address &getAddr(
void)
const {
return addr; }
39 const Address &getUseAddr(
void)
const {
return useaddr; }
40 int4 getSize(
void)
const {
return size; }
41 string getName(
void)
const {
return name; }
42 uint8 getSymbolId(
void)
const {
return symbolId; }
56 usePoint(addr), hash(h), name(nm), symbolId(
id) {}
57 const Address &getAddress(
void)
const {
return usePoint; }
58 uint8 getHash(
void)
const {
return hash; }
59 string getName(
void)
const {
return name; }
60 uint8 getSymbolId(
void)
const {
return symbolId; }
72 addr(ad), dataType(dt) {}
73 const Address &getAddress(
void)
const {
return addr; }
74 Datatype *getType(
void)
const {
return dataType; }
104 start=st; size=sz; sstart=sst; type=ct; flags=fl; rangeType = rt; highind=hi; }
133 mutable vector<AddBase> addBase;
134 mutable vector<uintb> alias;
135 mutable bool calculated;
138 mutable uintb aliasBoundary;
140 void deriveBoundaries(
const FuncProto &proto);
141 void gatherInternal(
void)
const;
147 const vector<AddBase> &getAddBase(
void)
const {
return addBase; }
148 const vector<uintb> &getAlias(
void)
const {
return alias; }
162 vector<RangeHint *> maplist;
163 vector<RangeHint *>::iterator iter;
168 void reconcileDatatypes(
void);
170 #ifdef OPACTION_DEBUG
171 mutable bool debugon;
173 void turnOnDebug(
Architecture *g)
const { debugon =
true; glb=g; }
174 void turnOffDebug(
void)
const { debugon =
false; }
179 void sortAlias(
void) { checker.
sortAlias(); }
180 const vector<uintb> &getAlias(
void) {
return checker.getAlias(); }
186 bool getNext(
void) { ++iter;
if (iter==maplist.end())
return false;
return true; }
199 list<NameRecommend> nameRecommend;
200 list<DynamicRecommend> dynRecommend;
201 list<TypeRecommend> typeRecommend;
202 bool stackGrowsNegative;
207 void markUnaliased(
const vector<uintb> &alias);
208 void fakeInputSymbols(
void);
209 void addRecommendName(
Symbol *sym);
210 void collectNameRecs(
void);
215 AddrSpace *getSpaceId(
void)
const {
return space; }
226 virtual void saveXml(ostream &s)
const;
231 int4 &index,uint4 flags)
const;
bool hasLocalAlias(Varnode *vn) const
Return true if it looks like the given Varnode is aliased by a pointer.
Definition: varmap.cc:565
@ fixed
A data-type with a fixed size.
Definition: varmap.hh:89
Data-type for a storage location when there is no Symbol (yet)
Definition: varmap.hh:67
static void gatherAdditiveBase(Varnode *startvn, vector< AddBase > &addbase)
Gather result Varnodes for all sums that the given starting Varnode is involved in.
Definition: varmap.cc:595
A region where processor data is stored.
Definition: space.hh:73
void sortAlias(void) const
Sort the alias starting offsets.
Definition: varmap.cc:580
int4 compare(const RangeHint &op2) const
Order this with another RangeHint.
Definition: varmap.cc:247
A Symbol scope for local variables of a particular function.
Definition: varmap.hh:196
An in-memory implementation of the Scope interface.
Definition: database.hh:726
void restructureVarnode(bool aliasyes)
Layout mapped symbols based on Varnode information.
Definition: varmap.cc:997
An interval map container.
Definition: rangemap.hh:64
bool reconcile(const RangeHint *b) const
Can the given intersecting RangeHint coexist with this at their given offsets.
Definition: varmap.cc:26
void gatherVarnodes(const Funcdata &fd)
Add stack Varnodes as hints to the collection.
Definition: varmap.cc:901
Funcdata * fd
(If non-null) the function which this is the local Scope for
Definition: database.hh:415
@ endpoint
An (artificial) boundary to the range of bytes getting analyzed.
Definition: varmap.hh:91
ScopeLocal(uint8 id, AddrSpace *spc, Funcdata *fd, Architecture *g)
Constructor.
Definition: varmap.cc:269
void markNotMapped(AddrSpace *spc, uintb first, int4 sz, bool param)
Mark a specific address range is not mapped.
Definition: varmap.cc:366
void gatherOpen(const Funcdata &fd)
Add pointer references as hints to the collection.
Definition: varmap.cc:952
An XML element. A node in the DOM tree.
Definition: xml.hh:150
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
A storage location for a particular Symbol.
Definition: database.hh:51
Description of a LOAD operation that needs to be guarded.
Definition: heritage.hh:105
A prototype model: a model for passing parameters between functions.
Definition: fspec.hh:622
A container for hints about the data-type layout of an address space.
Definition: varmap.hh:159
virtual string buildVariableName(const Address &addr, const Address &pc, Datatype *ct, int4 &index, uint4 flags) const
Given an address and data-type, build a suitable generic symbol name.
Definition: varmap.cc:408
bool absorb(RangeHint *b)
Try to absorb the other RangeHint into this.
Definition: varmap.cc:107
MapState(AddrSpace *spc, const RangeList &rn, const RangeList &pm, Datatype *dt)
Constructor.
Definition: varmap.cc:715
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
A disjoint set of Ranges, possibly across multiple address spaces.
Definition: address.hh:203
A helper class holding a Varnode pointer reference and a possible index added to it.
Definition: varmap.hh:125
static uintb gatherOffset(Varnode *vn)
If the given Varnode is a sum result, return the constant portion of this sum.
Definition: varmap.cc:671
RangeType
The basic categorization of the range.
Definition: varmap.hh:88
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
SymbolEntry * remapSymbolDynamic(Symbol *sym, uint8 hash, const Address &usepoint)
Make the primary mapping for the given Symbol, dynamic.
Definition: varmap.cc:1234
Container for data structures associated with a single function.
Definition: funcdata.hh:45
The base datatype class for the decompiler.
Definition: type.hh:62
void gatherHighs(const Funcdata &fd)
Add HighVariables as hints to the collection.
Definition: varmap.cc:923
Container class for all Datatype objects in an Architecture.
Definition: type.hh:396
bool isUnaffectedStorage(Varnode *vn) const
Is this a storage location for unaffected registers.
Definition: varmap.hh:221
A symbol name recommendation with its associated storage location.
Definition: varmap.hh:29
Symbol and Scope objects for the decompiler.
A name recommendation for a particular dynamic storage location.
Definition: varmap.hh:49
void applyTypeRecommendations(void)
Try to apply recommended data-type information.
Definition: varmap.cc:1323
OpCode
The op-code defining a specific p-code operation (PcodeOp)
Definition: opcodes.hh:35
SymbolEntry * remapSymbol(Symbol *sym, const Address &addr, const Address &usepoint)
Change the primary mapping for the given Symbol to be a specific storage address and use point.
Definition: varmap.cc:1206
void restructureHigh(void)
Layout mapped symbols based on HighVariable information.
Definition: varmap.cc:1028
virtual void restoreXml(const Element *el)
Restore this Scope from a <scope> XML tag.
Definition: varmap.cc:348
virtual void saveXml(ostream &s) const
Write out this as a <scope> XML tag.
Definition: varmap.cc:337
~MapState(void)
Destructor.
Definition: varmap.cc:732
Partial data-type information mapped to a specific range of bytes.
Definition: varmap.hh:83
bool merge(RangeHint *b, AddrSpace *space, TypeFactory *typeFactory)
Try to form the union of this with another RangeHint.
Definition: varmap.cc:160
@ open
An array with a (possibly unknown) number of elements.
Definition: varmap.hh:90
void recoverNameRecommendationsForSymbols(void)
Run through name recommendations, checking if any match unnamed symbols.
Definition: varmap.cc:1256
bool contain(const RangeHint *b) const
Return true if this or the given range contains the other.
Definition: varmap.cc:56
bool initialize(void)
Initialize the hint collection for iteration.
Definition: varmap.cc:876
void gatherSymbols(const EntryMap *rangemap)
Add Symbol information as hints to the collection.
Definition: varmap.cc:858
void resetLocalWindow(void)
Reset the set of addresses that are considered mapped by the scope to the default.
Definition: varmap.cc:310
void gather(const Funcdata *f, AddrSpace *spc, bool defer)
Gather Varnodes that point on the stack.
Definition: varmap.cc:546
Varnode * base
The Varnode holding the base pointer.
Definition: varmap.hh:126
bool preferred(const RangeHint *b, bool reconcile) const
Return true if the this range's data-type is preferred over the other given range.
Definition: varmap.cc:73
A function prototype.
Definition: fspec.hh:1164
A light-weight class for analyzing pointers and aliasing on the stack.
Definition: varmap.hh:122
Varnode * index
The index value or NULL.
Definition: varmap.hh:127
The base class for a symbol in a symbol table or scope.
Definition: database.hh:152