decompiler 1.0.0
Public Member Functions | Protected Types | Protected Attributes | Friends | List of all members
ghidra::SymbolEntry Class Referenceabstract

A storage location for a particular Symbol. More...

#include <database.hh>

Inheritance diagram for ghidra::SymbolEntry:
ghidra::DynamicEntry ghidra::MapEntry ghidra::MapEntryConflict

Public Member Functions

 SymbolEntry (Symbol *sym)
 Construct an uninitialized SymbolEntry. More...
 
 SymbolEntry (Symbol *sym, uint4 exflags, int4 sz, int4 off, const RangeList &use)
 Constructor. More...
 
bool isPiece (void) const
 Is this a proper piece of the whole Symbol.
 
bool isDynamic (void) const
 Is storage dynamic.
 
bool isConflict (void) const
 Does storage have potential Symbol conflicts.
 
virtual Datatype * getSizedType (const Address &addr, int4 sz) const =0
 Get the data-type associated with (a piece of) this. More...
 
virtual void printEntry (ostream &s) const =0
 Print a one-line description of this to a debug stream. More...
 
virtual void encode (Encoder &encoder) const =0
 Encode storage element internal to <mapsym> More...
 
virtual void decode (Decoder &decoder)=0
 Decode storage element internal to <mapsym> More...
 
uint4 getAllFlags (void) const
 Get all Varnode flags for this storage. More...
 
int4 getOffset (void) const
 Get offset of this within the Symbol.
 
Symbol * getSymbol (void) const
 Get the Symbol associated with this.
 
int4 getSize (void) const
 Get the number of bytes consumed by this storage.
 
bool inUse (const Address &usepoint) const
 Is this storage valid for the given code address. More...
 
const RangeList & getUseLimit (void) const
 Get the set of valid code addresses for this storage.
 
Address getFirstUseAddress (void) const
 Get the first code address where this storage is valid.
 
void setUseLimit (const RangeList &uselim)
 Set the range of code addresses where this is valid.
 
bool isAddrTied (void) const
 Is this storage address tied.
 
bool updateType (Varnode *vn) const
 Update a Varnode data-type from this. More...
 

Protected Types

enum  { map_entry = 0 , conflict_entry = 1 , dynamic_entry = 2 }
 The type (derived class) of SymbolEntry. More...
 

Protected Attributes

Symbol * symbol
 Symbol object being mapped.
 
RangeList uselimit
 Code address ranges where this storage is valid.
 
uint4 extraflags
 Varnode flags specific to this storage location.
 
int4 offset
 Offset into the Symbol that this covers.
 
int4 size
 Number of bytes consumed by this (piece of the) storage.
 
uint2 entrytype
 Type of SymbolEntry.
 
bool is_piece
 Is this a piece of the whole symbol.
 

Friends

class Scope
 
class ScopeInternal
 

Detailed Description

A storage location for a particular Symbol.

Storage can be a fixed Address or a dynamically located Varnode representing the Symbol. Storage may get recycled for different Symbols at different points in the code. The uselimit object defines the range of instruction addresses over which a particular SymbolEntry does represent a Symbol, with the convention that an empty uselimit indicates the storage holds the Symbol across all code.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected

The type (derived class) of SymbolEntry.

Enumerator
map_entry 

Is a MapEntry.

conflict_entry 

Is a MapEntryConflict.

dynamic_entry 

Is a DynamicEntry.

Constructor & Destructor Documentation

◆ SymbolEntry() [1/2]

ghidra::SymbolEntry::SymbolEntry ( Symbol *  sym)

Construct an uninitialized SymbolEntry.

For use with decode().

Parameters
symis the Symbol this will be a map for

References entrytype, extraflags, is_piece, map_entry, offset, and size.

◆ SymbolEntry() [2/2]

ghidra::SymbolEntry::SymbolEntry ( Symbol *  sym,
uint4  exflags,
int4  sz,
int4  off,
const RangeList &  use 
)

Constructor.

Parameters
symis the Symbol this will be a map for
exflagsare Varnode flags to be associated with the Symbol
szis the number of bytes needed to store the Symbol (or this part of the Symbol) in memory
offis the byte offset into the Symbol, if this represents a piece
useis the range of code addresses where this mapping applies

References entrytype, extraflags, is_piece, map_entry, offset, size, symbol, and uselimit.

Member Function Documentation

◆ decode()

virtual void ghidra::SymbolEntry::decode ( Decoder &  decoder)
pure virtual

Decode storage element internal to <mapsym>

Implemented in ghidra::MapEntry, ghidra::MapEntryConflict, and ghidra::DynamicEntry.

◆ encode()

virtual void ghidra::SymbolEntry::encode ( Encoder &  encoder) const
pure virtual

Encode storage element internal to <mapsym>

Implemented in ghidra::MapEntry, ghidra::MapEntryConflict, and ghidra::DynamicEntry.

◆ getAllFlags()

uint4 ghidra::SymbolEntry::getAllFlags ( void  ) const
inline

Get all Varnode flags for this storage.

Retrieve the (union of) Varnode flags specific to the Symbol and specific to this storage.

Returns
all Varnode flags that apply

References extraflags, ghidra::Symbol::getFlags(), and symbol.

Referenced by ghidra::Scope::queryProperties(), ghidra::Varnode::setSymbolProperties(), and ghidra::Funcdata::syncVarnodesWithSymbols().

◆ getSizedType()

virtual Datatype * ghidra::SymbolEntry::getSizedType ( const Address &  addr,
int4  sz 
) const
pure virtual

Get the data-type associated with (a piece of) this.

Return the data-type that matches the given size and address within this storage. NULL is returned if there is no valid sub-type matching the size.

Parameters
addris the given address
szis the given size (in bytes)
Returns
the matching data-type or NULL

Implemented in ghidra::MapEntry, and ghidra::DynamicEntry.

Referenced by ghidra::VolatileWriteOp::getInputLocal(), ghidra::VolatileReadOp::getOutputLocal(), ghidra::Funcdata::syncVarnodesWithSymbols(), and updateType().

◆ inUse()

bool ghidra::SymbolEntry::inUse ( const Address &  usepoint) const

Is this storage valid for the given code address.

This storage location may only hold the Symbol value for a limited portion of the code.

Parameters
usepointis the given code address to test
Returns
true if this storage is valid at the given address

References ghidra::RangeList::inRange(), isAddrTied(), ghidra::Address::isInvalid(), and uselimit.

Referenced by ghidra::ScopeInternal::findAddr(), ghidra::ScopeInternal::findClosestFit(), ghidra::ScopeInternal::findCodeLabel(), ghidra::ScopeInternal::findContainer(), ghidra::Funcdata::findLinkedVarnode(), and ghidra::Funcdata::findLinkedVarnodes().

◆ printEntry()

virtual void ghidra::SymbolEntry::printEntry ( ostream &  s) const
pure virtual

Print a one-line description of this to a debug stream.

Implemented in ghidra::MapEntry, ghidra::MapEntryConflict, and ghidra::DynamicEntry.

◆ updateType()

bool ghidra::SymbolEntry::updateType ( Varnode *  vn) const

Update a Varnode data-type from this.

If the Symbol associated with this is type-locked, change the given Varnode's attached data-type to match the Symbol

Parameters
vnis the Varnode to modify
Returns
true if the data-type was changed

References ghidra::Varnode::getAddr(), ghidra::Symbol::getFlags(), ghidra::Varnode::getSize(), getSizedType(), symbol, ghidra::Varnode::typelock, and ghidra::Varnode::updateType().

Referenced by ghidra::Varnode::setSymbolProperties().


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