decompiler  1.0.0
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
SymbolEntry Class Reference

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

#include <database.hh>


class  EntryInitData
 Initialization data for a SymbolEntry to facilitate a rangemap. More...
class  EntrySubsort
 Class for sub-sorting different SymbolEntry objects at the same address. More...

Public Types

typedef uintb linetype
 The linear element for a rangemap of SymbolEntry.
typedef EntrySubsort subsorttype
 The sub-sort object for a rangemap.
typedef EntryInitData inittype
 Initialization data for a SymbolEntry in a rangemap.

Public Member Functions

 SymbolEntry (uintb a, uintb b)
 Construct given just the offset range. More...
 SymbolEntry (Symbol *sym, uint4 exfl, uint8 h, int4 off, int4 sz, const RangeList &rnglist)
 Construct a dynamic SymbolEntry. More...
bool isPiece (void) const
 Is this a high or low piece of the whole Symbol.
bool isDynamic (void) const
 Is storage dynamic.
bool isInvalid (void) const
 Is this storage invalid.
uint4 getAllFlags (void) const
 Get all Varnode flags for this storage. More...
int4 getOffset (void) const
 Get offset of this within the Symbol.
uintb getFirst (void) const
 Get the first offset of this storage location.
uintb getLast (void) const
 Get the last offset of this storage location.
subsorttype getSubsort (void) const
 Get the sub-sort object. More...
void initialize (const EntryInitData &data)
 Fully initialize this. More...
SymbolgetSymbol (void) const
 Get the Symbol associated with this.
const AddressgetAddr (void) const
 Get the starting address of this storage.
uint8 getHash (void) const
 Get the hash used to identify this storage.
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 RangeListgetUseLimit (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...
DatatypegetSizedType (const Address &addr, int4 sz) const
 Get the data-type associated with (a piece of) this. More...
void printEntry (ostream &s) const
 Dump a description of this to a stream. More...
void saveXml (ostream &s) const
 Save this to an XML stream. More...
List::const_iterator restoreXml (List::const_iterator iter, const AddrSpaceManager *manage)
 Restore this from an XML stream. More...

Private Member Functions

 SymbolEntry (Symbol *sym)
 Construct a mapping for a Symbol without an address. More...

Private Attributes

 Symbol object being mapped.
uint4 extraflags
 Varnode flags specific to this storage location.
Address addr
 Starting address of the storage location.
uint8 hash
 A dynamic storage address (an alternative to addr for dynamic symbols)
int4 offset
 Offset into the Symbol that this covers.
int4 size
 Number of bytes consumed by this (piece of the) storage.
RangeList uselimit
 Code address ranges where this storage is valid.


class Scope

Detailed Description

A storage location for a particular Symbol.

Where a Symbol is stored, as a byte address and a size, is of particular importance to the decompiler. This class encapsulates this storage meta-data. A single Symbol split across multiple storage locations is supported by the offset and size fields. The hash field supports dynamic storage, where a Symbol is represented by a constant or a temporary register. In this case, storage must be tied to the particular p-code operators using the value.

A particular memory address does not have to represent the symbol across all code. 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 memory address does represent a Symbol, with the convention that an empty uselimit indicates the storage holds the Symbol across all code.

Constructor & Destructor Documentation

◆ SymbolEntry() [1/3]

SymbolEntry::SymbolEntry ( Symbol sym)

Construct a mapping for a Symbol without an address.

This SymbolEntry is unintegrated. An address or hash must be provided either directly or via restoreXml().

symis the Symbol this will be a map for

References extraflags, hash, offset, and size.

◆ SymbolEntry() [2/3]

SymbolEntry::SymbolEntry ( uintb  a,
uintb  b 

Construct given just the offset range.

This constructor is for use with rangemap container. It must be followed by an initialize() call.

ais the first offset covered by the new SymbolEntry
bis the last offset covered

References addr, Address::getSpace(), and size.

◆ SymbolEntry() [3/3]

SymbolEntry::SymbolEntry ( Symbol sym,
uint4  exfl,
uint8  h,
int4  off,
int4  sz,
const RangeList rnglist 

Construct a dynamic SymbolEntry.

This is used specifically for dynamic Symbol objects, where the storage location is attached to a temporary register or a constant. The main address field (addr) is set to invalid, and the hash becomes the primary location information.

symis the underlying Symbol
exflare the Varnode flags associated with the storage location
his the the hash
offif the offset into the Symbol for this (piece of) storage
szis the size in bytes of this (piece of) storage
rnglistis the set of code addresses where this SymbolEntry represents the Symbol

References addr, extraflags, hash, offset, size, symbol, and uselimit.

Member Function Documentation

◆ getAllFlags()

uint4 SymbolEntry::getAllFlags ( void  ) const

Get all Varnode flags for this storage.

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

all Varnode flags that apply

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

Referenced by Funcdata::attemptDynamicMapping(), Scope::queryProperties(), and Funcdata::updateFlags().

◆ getSizedType()

Datatype * SymbolEntry::getSizedType ( const Address inaddr,
int4  sz 
) const

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.

inaddris the given address
szis the given size (in bytes)
the matching data-type or NULL

References addr, Address::getOffset(), Datatype::getSize(), Datatype::getSubType(), Symbol::getType(), isDynamic(), offset, and symbol.

Referenced by TypeOpCallother::getInputLocal(), TypeOpCallother::getOutputLocal(), and updateType().

◆ getSubsort()

SymbolEntry::subsorttype SymbolEntry::getSubsort ( void  ) const

Get the sub-sort object.

Get data used to sub-sort entries (in a rangemap) at the same address

the sub-sort object

References Varnode::addrtied, Range::getFirst(), RangeList::getFirstRange(), Symbol::getFlags(), AddrSpace::getIndex(), Range::getSpace(), symbol, SymbolEntry::EntrySubsort::useindex, uselimit, and SymbolEntry::EntrySubsort::useoffset.

◆ initialize()

void SymbolEntry::initialize ( const EntryInitData data)

Fully initialize this.

Assuming the boundary offsets have been specified with the constructor, fill in the rest of the data.

datacontains the raw initialization data

References addr, extraflags, SymbolEntry::EntryInitData::extraflags, Address::getOffset(), offset, SymbolEntry::EntryInitData::offset, SymbolEntry::EntryInitData::space, symbol, SymbolEntry::EntryInitData::symbol, uselimit, and SymbolEntry::EntryInitData::uselimit.

◆ inUse()

bool 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.

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

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

Referenced by ScopeInternal::findAddr(), ScopeInternal::findClosestFit(), ScopeInternal::findCodeLabel(), and ScopeInternal::findContainer().

◆ printEntry()

void SymbolEntry::printEntry ( ostream &  s) const

Dump a description of this to a stream.

Give a contained one-line description of this storage, suitable for a debug console

sis the output stream

References addr, Symbol::getName(), Address::getShortcut(), Datatype::getSize(), Symbol::getType(), Address::isInvalid(), RangeList::printBounds(), Address::printRaw(), Datatype::printRaw(), symbol, and uselimit.

◆ restoreXml()

List::const_iterator SymbolEntry::restoreXml ( List::const_iterator  iter,
const AddrSpaceManager manage 

Restore this from an XML stream.

Given an iterator to children of a <mapsym> tag, restore the storage address (or the hash if the symbol is dynamic) and the uselimit describing the valid range of code addresses, then advance the iterator to the next tag.

iteris the iterator pointing to the address or hash tag
manageis an address space manager for constructing Address objects
the advanced iterator

References addr, hash, Address::restoreXml(), RangeList::restoreXml(), and uselimit.

Referenced by Scope::addMapSym().

◆ saveXml()

void SymbolEntry::saveXml ( ostream &  s) const

Save this to an XML stream.

This writes tags internal to the <mapsym> tag associated with the Symbol. It outputs the address tag (or the <hash> tag for dynamic symbols) and a <rangelist> tag associated with the uselimit.

sis the output stream

References addr, hash, Address::isInvalid(), isPiece(), Address::saveXml(), RangeList::saveXml(), and uselimit.

Referenced by ScopeInternal::saveXml().

◆ updateType()

bool 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

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

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

Referenced by Funcdata::attemptDynamicMapping(), Funcdata::newVarnode(), Funcdata::newVarnodeOut(), and Funcdata::setVarnodeProperties().

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