decompiler  1.0.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ghidra::SpacebaseSpace Class Reference

A virtual space stack space. More...

#include <translate.hh>

Inheritance diagram for ghidra::SpacebaseSpace:
ghidra::AddrSpace

Public Member Functions

 SpacebaseSpace (AddrSpaceManager *m, const Translate *t, const string &nm, int4 ind, int4 sz, AddrSpace *base, int4 dl, bool isFormal)
 
 SpacebaseSpace (AddrSpaceManager *m, const Translate *t)
 For use with decode. More...
 
virtual int4 numSpacebase (void) const
 Number of base registers associated with this space. More...
 
virtual const VarnodeDatagetSpacebase (int4 i) const
 Get a base register that creates this virtual space. More...
 
virtual const VarnodeDatagetSpacebaseFull (int4 i) const
 Return original spacebase register before truncation. More...
 
virtual bool stackGrowsNegative (void) const
 Return true if a stack in this space grows negative. More...
 
virtual AddrSpacegetContain (void) const
 Return containing space.
 
virtual void saveXml (ostream &s) const
 Write the details of this space as XML. More...
 
virtual void decode (Decoder &decoder)
 Recover the details of this space from XML.
 
- Public Member Functions inherited from ghidra::AddrSpace
 AddrSpace (AddrSpaceManager *m, const Translate *t, spacetype tp, const string &nm, uint4 size, uint4 ws, int4 ind, uint4 fl, int4 dl)
 
 AddrSpace (AddrSpaceManager *m, const Translate *t, spacetype tp)
 For use with decode. More...
 
virtual ~AddrSpace (void)
 The address space destructor.
 
const string & getName (void) const
 Get the name. More...
 
AddrSpaceManagergetManager (void) const
 Get the space manager. More...
 
const TranslategetTrans (void) const
 Get the processor translator. More...
 
spacetype getType (void) const
 Get the type of space. More...
 
int4 getDelay (void) const
 Get number of heritage passes being delayed. More...
 
int4 getDeadcodeDelay (void) const
 Get number of passes before deadcode removal is allowed. More...
 
int4 getIndex (void) const
 Get the integer identifier. More...
 
uint4 getWordSize (void) const
 Get the addressable unit size. More...
 
uint4 getAddrSize (void) const
 Get the size of the space. More...
 
uintb getHighest (void) const
 Get the highest byte-scaled address. More...
 
uintb getPointerLowerBound (void) const
 Get lower bound for assuming an offset is a pointer. More...
 
uintb getPointerUpperBound (void) const
 Get upper bound for assuming an offset is a pointer. More...
 
int4 getMinimumPtrSize (void) const
 Get the minimum pointer size for this space. More...
 
uintb wrapOffset (uintb off) const
 Wrap -off- to the offset that fits into this space. More...
 
char getShortcut (void) const
 Get the shortcut character. More...
 
bool isHeritaged (void) const
 Return true if dataflow has been traced. More...
 
bool doesDeadcode (void) const
 Return true if dead code analysis should be done on this space. More...
 
bool hasPhysical (void) const
 Return true if data is physically stored in this. More...
 
bool isBigEndian (void) const
 Return true if values in this space are big endian. More...
 
bool isReverseJustified (void) const
 Return true if alignment justification does not match endianness. More...
 
bool isFormalStackSpace (void) const
 Return true if this is attached to the formal stack pointer. More...
 
bool isOverlay (void) const
 Return true if this is an overlay space.
 
bool isOverlayBase (void) const
 Return true if other spaces overlay this space.
 
bool isOtherSpace (void) const
 Return true if this is the other address space.
 
bool isTruncated (void) const
 Return true if this space is truncated from its original size. More...
 
bool hasNearPointers (void) const
 Return true if near (truncated) pointers into this space are possible.
 
void printOffset (ostream &s, uintb offset) const
 Write an address offset to a stream. More...
 
virtual int4 overlapJoin (uintb offset, int4 size, AddrSpace *pointSpace, uintb pointOff, int4 pointSkip) const
 Determine if a given point is contained in an address range in this address space. More...
 
virtual void encodeAttributes (Encoder &encoder, uintb offset) const
 Encode address attributes to a stream. More...
 
virtual void encodeAttributes (Encoder &encoder, uintb offset, int4 size) const
 Encode an address and size attributes to a stream. More...
 
virtual uintb decodeAttributes (Decoder &decoder, uint4 &size) const
 Recover an offset and size. More...
 
virtual void printRaw (ostream &s, uintb offset) const
 Write an address in this space to a stream. More...
 
virtual uintb read (const string &s, int4 &size) const
 Read in an address (and possible size) from a string. More...
 

Private Member Functions

void setBaseRegister (const VarnodeData &data, int4 origSize, bool stackGrowth)
 Set the base register at time space is created. More...
 

Private Attributes

AddrSpacecontain
 Containing space.
 
bool hasbaseregister
 true if a base register has been attached
 
bool isNegativeStack
 true if stack grows in negative direction
 
VarnodeData baseloc
 location data of the base register
 
VarnodeData baseOrig
 Original base register before any truncation.
 

Friends

class AddrSpaceManager
 

Additional Inherited Members

- Public Types inherited from ghidra::AddrSpace
enum  {
  big_endian = 1, heritaged = 2, does_deadcode = 4, programspecific = 8,
  reverse_justification = 16, formal_stackspace = 0x20, overlay = 0x40, overlaybase = 0x80,
  truncated = 0x100, hasphysical = 0x200, is_otherspace = 0x400, has_nearpointers = 0x800
}
 
- Static Public Member Functions inherited from ghidra::AddrSpace
static uintb addressToByte (uintb val, uint4 ws)
 Scale from addressable units to byte units. More...
 
static uintb byteToAddress (uintb val, uint4 ws)
 Scale from byte units to addressable units. More...
 
static int8 addressToByteInt (int8 val, uint4 ws)
 Scale int4 from addressable units to byte units. More...
 
static int8 byteToAddressInt (int8 val, uint4 ws)
 Scale int4 from byte units to addressable units. More...
 
static bool compareByIndex (const AddrSpace *a, const AddrSpace *b)
 Compare two spaces by their index. More...
 
- Protected Member Functions inherited from ghidra::AddrSpace
void calcScaleMask (void)
 Calculate scale and mask. More...
 
void setFlags (uint4 fl)
 Set a cached attribute. More...
 
void clearFlags (uint4 fl)
 Clear a cached attribute. More...
 
void saveBasicAttributes (ostream &s) const
 Write the XML attributes of this space. More...
 
void decodeBasicAttributes (Decoder &decoder)
 Read attributes for this space from an open XML element. More...
 
void truncateSpace (uint4 newsize)
 
- Protected Attributes inherited from ghidra::AddrSpace
string name
 Name of this space.
 
uint4 addressSize
 Size of an address into this space in bytes.
 
uint4 wordsize
 Size of unit being addressed (1=byte)
 
int4 minimumPointerSize
 Smallest size of a pointer into this space (in bytes)
 
int4 index
 An integer identifier for the space.
 
int4 delay
 Delay in heritaging this space.
 
int4 deadcodedelay
 Delay before deadcode removal is allowed on this space.
 

Detailed Description

A virtual space stack space.

In a lot of analysis situations it is convenient to extend the notion of an address space to mean bytes that are indexed relative to some base register. The canonical example of this is the stack space, which models the concept of local variables stored on the stack. An address of (stack, 8) might model the address of a function parameter on the stack for instance, and (stack, 0xfffffff4) might be the address of a local variable. A space like this is inherently virtual and contained within whatever space is being indexed into.

Constructor & Destructor Documentation

◆ SpacebaseSpace() [1/2]

ghidra::SpacebaseSpace::SpacebaseSpace ( AddrSpaceManager m,
const Translate t,
const string &  nm,
int4  ind,
int4  sz,
AddrSpace base,
int4  dl,
bool  isFormal 
)

Construct a virtual space. This is usually used for the stack space, which is indicated by the isFormal parameters, but multiple such spaces are allowed.

Parameters
mis the manager for this program specific address space
tis associated processor translator
nmis the name of the space
indis the integer identifier
szis the size of the space
baseis the containing space
dlis the heritage delay
isFormalis the formal stack space indicator

References contain, ghidra::AddrSpace::formal_stackspace, hasbaseregister, ghidra::IPTR_SPACEBASE, isNegativeStack, and ghidra::AddrSpace::setFlags().

Referenced by ghidra::AddrSpaceManager::decodeSpace().

◆ SpacebaseSpace() [2/2]

ghidra::SpacebaseSpace::SpacebaseSpace ( AddrSpaceManager m,
const Translate t 
)

For use with decode.

This is a partial constructor, which must be followed up with decode in order to fillin the rest of the spaces attributes

Parameters
mis the associated address space manager
tis the associated processor translator

References hasbaseregister, ghidra::IPTR_SPACEBASE, isNegativeStack, ghidra::AddrSpace::programspecific, and ghidra::AddrSpace::setFlags().

Member Function Documentation

◆ getSpacebase()

const VarnodeData & ghidra::SpacebaseSpace::getSpacebase ( int4  i) const
virtual

Get a base register that creates this virtual space.

For virtual spaces, like the stack space, this routine returns the location information for a base register of the space. This routine will throw an exception if the register does not exist

Parameters
iis the index of the base register starting at
Returns
the VarnodeData that describes the register

Reimplemented from ghidra::AddrSpace.

References baseloc, ghidra::AddrSpace::getName(), and hasbaseregister.

◆ getSpacebaseFull()

const VarnodeData & ghidra::SpacebaseSpace::getSpacebaseFull ( int4  i) const
virtual

Return original spacebase register before truncation.

If a stack pointer is truncated to fit the stack space, we may need to know the extent of the original register

Parameters
iis the index of the base register
Returns
the original register before truncation

Reimplemented from ghidra::AddrSpace.

References baseOrig, ghidra::AddrSpace::getName(), and hasbaseregister.

◆ numSpacebase()

int4 ghidra::SpacebaseSpace::numSpacebase ( void  ) const
virtual

Number of base registers associated with this space.

Some spaces are "virtual", like the stack spaces, where addresses are really relative to a base pointer stored in a register, like the stackpointer. This routine will return non-zero if this space is virtual and there is 1 (or more) associated pointer registers

Returns
the number of base registers associated with this space

Reimplemented from ghidra::AddrSpace.

References hasbaseregister.

◆ saveXml()

void ghidra::SpacebaseSpace::saveXml ( ostream &  s) const
virtual

Write the details of this space as XML.

Write a tag fully describing the details of this space suitable for later recovery via decode.

Parameters
sis the stream being written

Reimplemented from ghidra::AddrSpace.

References ghidra::a_v(), contain, ghidra::AddrSpace::getName(), and ghidra::AddrSpace::saveBasicAttributes().

◆ setBaseRegister()

void ghidra::SpacebaseSpace::setBaseRegister ( const VarnodeData data,
int4  truncSize,
bool  stackGrowth 
)
private

Set the base register at time space is created.

This routine sets the base register associated with this virtual space It will throw an exception if something tries to set two (different) base registers

Parameters
datais the location data for the base register
truncSizeis the size of the space covered by the register
stackGrowthis true if the stack which this register manages grows in a negative direction

References baseloc, baseOrig, ghidra::AddrSpace::getName(), hasbaseregister, ghidra::AddrSpace::isBigEndian(), isNegativeStack, ghidra::VarnodeData::offset, ghidra::VarnodeData::size, and ghidra::VarnodeData::space.

Referenced by ghidra::AddrSpaceManager::addSpacebasePointer().

◆ stackGrowsNegative()

virtual bool ghidra::SpacebaseSpace::stackGrowsNegative ( void  ) const
inlinevirtual

Return true if a stack in this space grows negative.

For stack (or other spacebase) spaces, this routine returns true if the space can viewed as a stack and a push operation causes the spacebase pointer to be decreased (grow negative)

Returns
true if stacks grow in negative direction.

Reimplemented from ghidra::AddrSpace.


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