mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
GP-1518 Decompiler support for unions
This commit is contained in:
parent
53e2c4dc4f
commit
3fdbbbb231
65 changed files with 5119 additions and 1068 deletions
|
@ -144,11 +144,7 @@ typedef rangemap<SymbolEntry> EntryMap; ///< A rangemap of SymbolEntry
|
|||
/// At its most basic, a Symbol is a \b name and a \b data-type.
|
||||
/// Practically a Symbol knows what Scope its in, how it should be
|
||||
/// displayed, and the symbols \e category. A category is a subset
|
||||
/// of symbols that are stored together for quick access. The
|
||||
/// \b category field can be:
|
||||
/// - -1 for no category
|
||||
/// - 0 indicates a function parameter
|
||||
/// - 1 indicates an equate symbol
|
||||
/// of symbols that are stored together for quick access.
|
||||
class Symbol {
|
||||
friend class Scope;
|
||||
friend class ScopeInternal;
|
||||
|
@ -162,7 +158,7 @@ protected:
|
|||
// only typelock,namelock,readonly,externref
|
||||
// addrtied, persist inherited from scope
|
||||
uint4 dispflags; ///< Flags affecting the display of this symbol
|
||||
int2 category; ///< Special category (-1==none 0=parameter 1=equate)
|
||||
int2 category; ///< Special category (\b function_parameter, \b equate, etc.)
|
||||
uint2 catindex; ///< Index within category
|
||||
uint8 symbolId; ///< Unique id, 0=unassigned
|
||||
vector<list<SymbolEntry>::iterator> mapentry; ///< List of storage locations labeled with \b this Symbol
|
||||
|
@ -187,6 +183,14 @@ public:
|
|||
is_this_ptr = 64 ///< We are the "this" symbol for a class method
|
||||
};
|
||||
|
||||
/// \brief The possible specialize Symbol \e categories
|
||||
enum {
|
||||
no_category = -1, ///< Symbol is not in a special category
|
||||
function_parameter = 0, ///< The Symbol is a parameter to a function
|
||||
equate = 1, ///< The Symbol holds \e equate information about a constant
|
||||
union_facet = 2 ///< Symbol holding read or write facing union field information
|
||||
};
|
||||
|
||||
Symbol(Scope *sc,const string &nm,Datatype *ct); ///< Construct given a name and data-type
|
||||
Symbol(Scope *sc); ///< Construct for use with restoreXml()
|
||||
const string &getName(void) const { return name; } ///< Get the local name of the symbol
|
||||
|
@ -271,13 +275,23 @@ class EquateSymbol : public Symbol {
|
|||
uintb value; ///< Value of the constant being equated
|
||||
public:
|
||||
EquateSymbol(Scope *sc,const string &nm,uint4 format,uintb val); ///< Constructor
|
||||
EquateSymbol(Scope *sc) : Symbol(sc) { value = 0; category = 1; } ///< Constructor for use with restoreXml
|
||||
EquateSymbol(Scope *sc) : Symbol(sc) { value = 0; category = equate; } ///< Constructor for use with restoreXml
|
||||
uintb getValue(void) const { return value; } ///< Get the constant value
|
||||
bool isValueClose(uintb op2Value,int4 size) const; ///< Is the given value similar to \b this equate
|
||||
virtual void saveXml(ostream &s) const;
|
||||
virtual void restoreXml(const Element *el);
|
||||
};
|
||||
|
||||
class UnionFacetSymbol : public Symbol {
|
||||
int4 fieldNum; ///< Particular field to associate with Symbol access
|
||||
public:
|
||||
UnionFacetSymbol(Scope *sc,const string &nm,Datatype *unionDt,int4 fldNum); ///< Constructor from components
|
||||
UnionFacetSymbol(Scope *sc) : Symbol(sc) { fieldNum = -1; category = union_facet; } ///< Constructor for restoreXml
|
||||
int4 getFieldNumber(void) const { return fieldNum; } ///< Get the particular field associate with \b this
|
||||
virtual void saveXml(ostream &s) const;
|
||||
virtual void restoreXml(const Element *el);
|
||||
};
|
||||
|
||||
/// \brief A Symbol that labels code internal to a function
|
||||
class LabSymbol : public Symbol {
|
||||
void buildType(void); ///< Build placeholder data-type
|
||||
|
@ -894,7 +908,7 @@ inline Symbol::Symbol(Scope *sc,const string &nm,Datatype *ct)
|
|||
type=ct;
|
||||
flags=0;
|
||||
dispflags=0;
|
||||
category=-1;
|
||||
category=no_category;
|
||||
catindex = 0;
|
||||
symbolId=0;
|
||||
wholeCount=0;
|
||||
|
@ -911,7 +925,7 @@ inline Symbol::Symbol(Scope *sc)
|
|||
type = (Datatype *)0;
|
||||
flags=0;
|
||||
dispflags=0;
|
||||
category=-1;
|
||||
category=no_category;
|
||||
catindex = 0;
|
||||
symbolId = 0;
|
||||
wholeCount=0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue