decompiler  1.0.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
ghidra::AddrSpace Class Reference

A region where processor data is stored. More...

#include <space.hh>

Inheritance diagram for ghidra::AddrSpace:
ghidra::ConstantSpace ghidra::FspecSpace ghidra::IopSpace ghidra::JoinSpace ghidra::OtherSpace ghidra::OverlaySpace ghidra::SpacebaseSpace ghidra::UniqueSpace

Public Types

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
}
 

Public Member Functions

 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 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 this space's containing space (if any) 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...
 
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.
 

Static Public Member Functions

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

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

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.
 

Private Attributes

spacetype type
 Type of space (PROCESSOR, CONSTANT, INTERNAL, ...)
 
AddrSpaceManagermanage
 Manager for processor using this space.
 
const Translatetrans
 Processor translator (for register names etc) for this space.
 
int4 refcount
 Number of managers using this space.
 
uint4 flags
 Attributes of the space.
 
uintb highest
 Highest (byte) offset into this space.
 
uintb pointerLowerBound
 Offset below which we don't search for pointers.
 
uintb pointerUpperBound
 Offset above which we don't search for pointers.
 
char shortcut
 Shortcut character for printing.
 

Friends

class AddrSpaceManager
 

Detailed Description

A region where processor data is stored.

An AddrSpace (Address Space) is an arbitrary sequence of bytes where a processor can store data. As is usual with most processors' concept of RAM, an integer offset paired with an AddrSpace forms the address (See Address) of a byte. The size of an AddrSpace indicates the number of bytes that can be separately addressed and is usually described by the number of bytes needed to encode the biggest offset. I.e. a 4-byte address space means that there are offsets ranging from 0x00000000 to 0xffffffff within the space for a total of 2^32 addressable bytes within the space. There can be multiple address spaces, and it is typical to have spaces

The processor specification can set up any address spaces it needs in an arbitrary manner, but all data manipulated by the processor, which the specification hopes to model, must be contained in some address space, including RAM, ROM, general registers, special registers, i/o ports, etc.

The analysis engine also uses additional address spaces to model special concepts. These include

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
big_endian 

Space is big endian if set, little endian otherwise.

heritaged 

This space is heritaged.

does_deadcode 

Dead-code analysis is done on this space.

programspecific 

Space is specific to a particular loadimage.

reverse_justification 

Justification within aligned word is opposite of endianness.

formal_stackspace 

Space attached to the formal stack pointer.

overlay 

This space is an overlay of another space.

overlaybase 

This is the base space for overlay space(s)

truncated 

Space is truncated from its original size, expect pointers larger than this size.

hasphysical 

Has physical memory associated with it.

is_otherspace 

Quick check for the OtherSpace derived class.

has_nearpointers 

Does there exist near pointers into this space.

Constructor & Destructor Documentation

◆ AddrSpace() [1/2]

ghidra::AddrSpace::AddrSpace ( AddrSpaceManager m,
const Translate t,
spacetype  tp,
const string &  nm,
uint4  size,
uint4  ws,
int4  ind,
uint4  fl,
int4  dl 
)

Initialize an address space with its basic attributes

Parameters
mis the space manager associated with the new space
tis the processor translator associated with the new space
tpis the type of the new space (PROCESSOR, CONSTANT, INTERNAL,...)
nmis the name of the new space
sizeis the (offset encoding) size of the new space
wsis the number of bytes in an addressable unit
indis the integer identifier for the new space
flcan be 0 or AddrSpace::hasphysical
dlis the number of rounds to delay heritage for the new space

References addressSize, big_endian, calcScaleMask(), deadcodedelay, delay, does_deadcode, flags, hasphysical, heritaged, index, ghidra::Translate::isBigEndian(), manage, minimumPointerSize, name, refcount, shortcut, trans, type, and wordsize.

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

◆ AddrSpace() [2/2]

ghidra::AddrSpace::AddrSpace ( AddrSpaceManager m,
const Translate t,
spacetype  tp 
)

For use with decode.

This is a partial constructor, for initializing a space via XML

Parameters
mthe associated address space manager
tis the processor translator
tpthe basic type of the space

References does_deadcode, flags, heritaged, manage, minimumPointerSize, refcount, shortcut, trans, type, and wordsize.

Member Function Documentation

◆ addressToByte()

uintb ghidra::AddrSpace::addressToByte ( uintb  val,
uint4  ws 
)
inlinestatic

◆ addressToByteInt()

int8 ghidra::AddrSpace::addressToByteInt ( int8  val,
uint4  ws 
)
inlinestatic

Scale int4 from addressable units to byte units.

Given an int8 offset into an address space based on the addressable unit size (wordsize), convert it into a byte relative offset

Parameters
valis the offset to convert
wsis the number of bytes in the addressable word
Returns
the scaled offset

Referenced by ghidra::AddTreeState::AddTreeState(), ghidra::ActionSetCasts::apply(), ghidra::RuleStructOffset0::applyOp(), ghidra::RulePtraddUndo::applyOp(), ghidra::SplitDatatype::RootPointer::backUpPointer(), ghidra::AddTreeState::calcSubtype(), ghidra::SplitDatatype::getValueDatatype(), ghidra::AddTreeState::initAlternateForm(), ghidra::TypePointer::isPtrsubMatching(), ghidra::TypePointerRel::isPtrsubMatching(), ghidra::PrintC::opPtrsub(), ghidra::TypeOpIntAdd::propagateAddIn2Out(), and ~AddrSpace().

◆ byteToAddress()

uintb ghidra::AddrSpace::byteToAddress ( uintb  val,
uint4  ws 
)
inlinestatic

Scale from byte units to addressable units.

Given an offset in an address space based on bytes, convert it into an offset relative to the addressable unit of the space (wordsize)

Parameters
valis the offset to convert
wsis the number of bytes in the addressable word
Returns
the scaled offset

Referenced by ghidra::MapState::addRange(), ghidra::ScopeLocal::buildVariableName(), ghidra::ScopeInternal::buildVariableName(), ghidra::AddTreeState::calcSubtype(), ghidra::Funcdata::createStackRef(), ghidra::TypeSpacebase::getSubType(), ghidra::MapState::initialize(), ghidra::TypeSpacebase::nearestArrayedComponentForward(), printRaw(), ghidra::PrintC::pushAnnotation(), ghidra::Funcdata::spacebaseConstant(), and ~AddrSpace().

◆ byteToAddressInt()

int8 ghidra::AddrSpace::byteToAddressInt ( int8  val,
uint4  ws 
)
inlinestatic

Scale int4 from byte units to addressable units.

Given an int8 offset in an address space based on bytes, convert it into an offset relative to the addressable unit of the space (wordsize)

Parameters
valis the offset to convert
wsis the number of bytes in the addressable word
Returns
the scaled offset

Referenced by ghidra::AddTreeState::AddTreeState(), ghidra::SplitDatatype::buildPointers(), ghidra::AddTreeState::calcSubtype(), ghidra::TypePointerRel::getPointerOffset(), ghidra::AddTreeState::hasMatchingSubType(), ghidra::AddTreeState::initAlternateForm(), ghidra::TypeSpacebase::nearestArrayedComponentForward(), and ~AddrSpace().

◆ calcScaleMask()

void ghidra::AddrSpace::calcScaleMask ( void  )
protected

Calculate scale and mask.

Calculate highest based on addressSize, and wordsize. This also calculates the default pointerLowerBound

References addressSize, ghidra::calc_mask(), highest, pointerLowerBound, pointerUpperBound, and wordsize.

Referenced by AddrSpace(), ghidra::OverlaySpace::decode(), decodeBasicAttributes(), and truncateSpace().

◆ clearFlags()

void ghidra::AddrSpace::clearFlags ( uint4  fl)
inlineprotected

Clear a cached attribute.

An internal method for derived classes to clear space attibutes

Parameters
flis the set of attributes to clear

References flags.

Referenced by ghidra::ConstantSpace::ConstantSpace(), ghidra::FspecSpace::FspecSpace(), ghidra::IopSpace::IopSpace(), ghidra::JoinSpace::JoinSpace(), and ghidra::OtherSpace::OtherSpace().

◆ compareByIndex()

bool ghidra::AddrSpace::compareByIndex ( const AddrSpace a,
const AddrSpace b 
)
inlinestatic

Compare two spaces by their index.

For sorting a sequence of address spaces.

Parameters
ais the first space
bis the second space
Returns
true if the first space should come before the second

References index.

Referenced by ghidra::Architecture::cacheAddrSpaceProperties(), and ~AddrSpace().

◆ decodeAttributes()

uintb ghidra::AddrSpace::decodeAttributes ( Decoder decoder,
uint4 &  size 
) const
virtual

Recover an offset and size.

For an open element describing an address in this space, this routine recovers the offset and possibly the size described by the element

Parameters
decoderis the stream decoder
sizeis a reference where the recovered size should be stored
Returns
the recovered offset

Reimplemented in ghidra::JoinSpace.

References ghidra::Decoder::getNextAttributeId(), ghidra::Decoder::readSignedInteger(), and ghidra::Decoder::readUnsignedInteger().

Referenced by ghidra::VarnodeData::decodeFromAttributes(), ghidra::LoadImageXml::open(), and ~AddrSpace().

◆ decodeBasicAttributes()

void ghidra::AddrSpace::decodeBasicAttributes ( Decoder decoder)
protected

Read attributes for this space from an open XML element.

Walk attributes of the current element and recover all the properties defining this space. The processor translator, trans, and the type must already be filled in.

Parameters
decoderis the stream decoder

References addressSize, big_endian, calcScaleMask(), deadcodedelay, delay, flags, ghidra::Decoder::getNextAttributeId(), hasphysical, index, name, ghidra::Decoder::readBool(), ghidra::Decoder::readSignedInteger(), ghidra::Decoder::readString(), ghidra::Decoder::readUnsignedInteger(), and wordsize.

Referenced by decode(), and ghidra::SpacebaseSpace::decode().

◆ doesDeadcode()

bool ghidra::AddrSpace::doesDeadcode ( void  ) const
inline

Return true if dead code analysis should be done on this space.

Most memory locations should have dead-code analysis performed, and this routine will return true. For certain special spaces like the constant space, dead-code analysis doesn't make sense, and this routine returns false.

References does_deadcode, and flags.

Referenced by ghidra::ActionDeadCode::apply(), ghidra::RuleEarlyRemoval::applyOp(), and ~AddrSpace().

◆ encodeAttributes() [1/2]

void ghidra::AddrSpace::encodeAttributes ( Encoder encoder,
uintb  offset 
) const
virtual

Encode address attributes to a stream.

Write the main attributes for an address within this space. The caller provides only the offset, and this routine fills in other details pertaining to this particular space.

Parameters
encoderis the stream encoder
offsetis the offset of the address

Reimplemented in ghidra::FspecSpace, ghidra::JoinSpace, and ghidra::IopSpace.

References ghidra::Encoder::writeSpace(), and ghidra::Encoder::writeUnsignedInteger().

Referenced by ghidra::InjectContextGhidra::encode(), ghidra::Comment::encode(), ghidra::Address::encode(), ghidra::SeqNum::encode(), ghidra::Varnode::encode(), ghidra::JumpBasicOverride::encode(), ghidra::JumpTable::encode(), ghidra::Database::encode(), ghidra::ContextInternal::encodeContext(), ghidra::FuncProto::encodeLikelyTrash(), ghidra::ContextDatabase::encodeTracked(), and ~AddrSpace().

◆ encodeAttributes() [2/2]

void ghidra::AddrSpace::encodeAttributes ( Encoder encoder,
uintb  offset,
int4  size 
) const
virtual

Encode an address and size attributes to a stream.

Write the main attributes of an address with this space and a size. The caller provides the offset and size, and other details about this particular space are filled in.

Parameters
encoderis the stream encoder
offsetis the offset of the address
sizeis the size of the memory location

Reimplemented in ghidra::FspecSpace, ghidra::JoinSpace, and ghidra::IopSpace.

References ghidra::Encoder::writeSignedInteger(), ghidra::Encoder::writeSpace(), and ghidra::Encoder::writeUnsignedInteger().

◆ getAddrSize()

uint4 ghidra::AddrSpace::getAddrSize ( void  ) const
inline

◆ getContain()

AddrSpace * ghidra::AddrSpace::getContain ( void  ) const
inlinevirtual

Return this space's containing space (if any)

If this space is virtual, then this routine returns the containing address space, otherwise it returns NULL.

Returns
a pointer to the containing space or NULL

Reimplemented in ghidra::OverlaySpace, and ghidra::SpacebaseSpace.

Referenced by ghidra::Architecture::addOtherSpace(), ghidra::Architecture::addToGlobalScope(), ghidra::ActionSetCasts::checkPointerIssues(), ghidra::RuleLoadVarnode::correctSpacebase(), ghidra::Funcdata::createStackRef(), ghidra::Heritage::guardStores(), ghidra::AddrSpaceManager::insertSpace(), ghidra::Funcdata::opStackLoad(), ghidra::Funcdata::opStackStore(), and ~AddrSpace().

◆ getDeadcodeDelay()

int4 ghidra::AddrSpace::getDeadcodeDelay ( void  ) const
inline

Get number of passes before deadcode removal is allowed.

The point at which deadcode removal is performed on varnodes within a space can be set to skip some number of heritage passes, in case not all the varnodes are created within a single pass. This method gives the number of rounds that should be skipped before deadcode elimination begins

Returns
the number of rounds to skip deadcode removal

References deadcodedelay.

Referenced by ghidra::Heritage::bumpDeadcodeDelay(), ghidra::OverlaySpace::decode(), ghidra::Override::hasDeadcodeDelay(), ghidra::HeritageInfo::HeritageInfo(), and ~AddrSpace().

◆ getDelay()

int4 ghidra::AddrSpace::getDelay ( void  ) const
inline

Get number of heritage passes being delayed.

If the heritage algorithms need to trace dataflow within this space, the algorithms can delay tracing this space in order to let indirect references into the space resolve themselves. This method indicates the number of rounds of dataflow analysis that should be skipped for this space to let this resolution happen

Returns
the number of rounds to skip heritage

References delay.

Referenced by ghidra::Architecture::addSpacebase(), ghidra::Heritage::bumpDeadcodeDelay(), ghidra::Architecture::cacheAddrSpaceProperties(), ghidra::OverlaySpace::decode(), ghidra::IfcPrintSpaces::execute(), ghidra::HeritageInfo::HeritageInfo(), and ~AddrSpace().

◆ getHighest()

uintb ghidra::AddrSpace::getHighest ( void  ) const
inline

◆ getIndex()

int4 ghidra::AddrSpace::getIndex ( void  ) const
inline

Get the integer identifier.

Each address space has an associated index that can be used as an integer encoding of the space.

Returns
the unique index

References index.

Referenced by ghidra::ScopeInternal::addMapInternal(), ghidra::ScopeGhidra::addRange(), ghidra::ParamListStandard::addResolverRange(), ghidra::RuleSegment::applyOp(), ghidra::ConditionalExecution::buildHeritageArray(), ghidra::ParamListStandard::characterizeAsParam(), ghidra::TypePointer::compare(), ghidra::EffectRecord::compareByAddress(), ghidra::TypePointer::compareDependency(), ghidra::AddrSpaceManager::copySpaces(), ghidra::Funcdata::createStackRef(), ghidra::AddrSpaceManager::decodeSpaces(), ghidra::SymbolEntry::EntrySubsort::EntrySubsort(), ghidra::IfcPrintSpaces::execute(), ghidra::EmulatePcodeOp::executeSegmentOp(), ghidra::ScopeInternal::findAddr(), ghidra::ScopeInternal::findClosestFit(), ghidra::ScopeInternal::findCodeLabel(), ghidra::ScopeInternal::findContainer(), ghidra::ParamListStandard::findEntry(), ghidra::ScopeInternal::findExternalRef(), ghidra::ScopeInternal::findFunction(), ghidra::ScopeInternal::findOverlap(), ghidra::ParamListStandard::getBiggestContainedParam(), ghidra::Heritage::getInfo(), ghidra::MemoryState::getMemoryBank(), ghidra::AddrSpaceManager::getNextSpaceInOrder(), ghidra::Architecture::getSegmentOp(), ghidra::SymbolEntry::getSubsort(), ghidra::Override::hasDeadcodeDelay(), ghidra::Override::insertDeadcodeDelay(), ghidra::AddrSpaceManager::insertResolver(), ghidra::SleighCompile::newSpace(), ghidra::VarnodeData::operator<(), ghidra::Address::operator<(), ghidra::Range::operator<(), ghidra::Address::operator<=(), ghidra::Architecture::parseProcessorConfig(), ghidra::UserOpManage::registerOp(), ghidra::ScopeGhidra::removeQuery(), ghidra::ScopeInternal::removeSymbolMappings(), ghidra::AddrSpaceManager::resolveConstant(), ghidra::MemoryState::setMemoryBank(), ghidra::ConditionalExecution::testRemovability(), and ~AddrSpace().

◆ getManager()

AddrSpaceManager * ghidra::AddrSpace::getManager ( void  ) const
inline

Get the space manager.

Every address space is associated with a manager of (all possible) spaces. This method recovers the address space manager object.

Returns
a pointer to the address space manager

References manage.

Referenced by ghidra::JoinSpace::decodeAttributes(), ghidra::JoinSpace::encodeAttributes(), ghidra::ParamEntry::getAddrBySlot(), ghidra::JoinSpace::overlapJoin(), ghidra::JoinSpace::printRaw(), ghidra::JoinSpace::read(), ghidra::ParamEntry::resolveJoin(), and ~AddrSpace().

◆ getMinimumPtrSize()

int4 ghidra::AddrSpace::getMinimumPtrSize ( void  ) const
inline

Get the minimum pointer size for this space.

A value of 0 means the size must match exactly. If the space is truncated, or if there exists near pointers, this value may be non-zero.

References minimumPointerSize.

Referenced by ghidra::ActionConstantPtr::selectInferSpace(), and ~AddrSpace().

◆ getName()

const string & ghidra::AddrSpace::getName ( void  ) const
inline

◆ getPointerLowerBound()

uintb ghidra::AddrSpace::getPointerLowerBound ( void  ) const
inline

Get lower bound for assuming an offset is a pointer.

Constant offsets are tested against this lower bound as a quick filter before attempting to lookup symbols.

Returns
the minimum offset that will be inferred as a pointer

References pointerLowerBound.

Referenced by ghidra::ActionConstantPtr::isPointer(), ghidra::ScoreUnionFields::scoreConstantFit(), and ~AddrSpace().

◆ getPointerUpperBound()

uintb ghidra::AddrSpace::getPointerUpperBound ( void  ) const
inline

Get upper bound for assuming an offset is a pointer.

Constant offsets are tested against this upper bound as a quick filter before attempting to lookup symbols.

Returns
the maximum offset that will be inferred as a pointer

References pointerUpperBound.

Referenced by ghidra::ActionConstantPtr::isPointer(), ghidra::ScoreUnionFields::scoreConstantFit(), and ~AddrSpace().

◆ getShortcut()

char ghidra::AddrSpace::getShortcut ( void  ) const
inline

Get the shortcut character.

Return a unique short cut character that is associated with this space. The shortcut character can be used by the read method to quickly specify the space of an address.

Returns
the shortcut character

References shortcut.

Referenced by ghidra::IfcPrintSpaces::execute(), ghidra::Address::getShortcut(), and ~AddrSpace().

◆ getSpacebase()

const VarnodeData & ghidra::AddrSpace::getSpacebase ( int4  i) const
inlinevirtual

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 in ghidra::SpacebaseSpace.

References name.

Referenced by ghidra::ActionPrototypeTypes::apply(), ghidra::StackSolver::build(), ghidra::ActionStackPtrFlow::checkClog(), ghidra::Heritage::discoverIndexedStackPointers(), ghidra::Funcdata::findSpacebaseInput(), ghidra::Architecture::getSpaceBySpacebase(), ghidra::Funcdata::newSpacebasePtr(), ghidra::TypeFactory::setupSizes(), ghidra::Funcdata::spacebase(), and ~AddrSpace().

◆ getSpacebaseFull()

const VarnodeData & ghidra::AddrSpace::getSpacebaseFull ( int4  i) const
inlinevirtual

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 in ghidra::SpacebaseSpace.

References name.

Referenced by ghidra::ActionPrototypeTypes::apply(), and ~AddrSpace().

◆ getTrans()

const Translate * ghidra::AddrSpace::getTrans ( void  ) const
inline

Get the processor translator.

Every address space is associated with a processor which may have additional objects like registers etc. associated with it. This method returns a pointer to that processor translator

Returns
a pointer to the Translate object

References trans.

Referenced by ghidra::JoinSpace::decodeAttributes(), ghidra::VarnodeData::decodeFromAttributes(), ghidra::Range::decodeFromAttributes(), ghidra::Varnode::printRawNoMarkup(), ghidra::Range::Range(), ghidra::JoinSpace::read(), ghidra::VarnodeBank::VarnodeBank(), and ~AddrSpace().

◆ getType()

spacetype ghidra::AddrSpace::getType ( void  ) const
inline

Get the type of space.

Return the defining type for this address space.

  • IPTR_CONSTANT for the constant space
  • IPTR_PROCESSOR for a normal space
  • IPTR_INTERNAL for the temporary register space
  • IPTR_FSPEC for special FuncCallSpecs references
  • IPTR_IOP for special PcodeOp references
    Returns
    the basic type of this space

References type.

Referenced by ghidra::FuncCallSpecs::abortSpacebaseRelative(), ghidra::ActionStackPtrFlow::analyzeExtraPop(), ghidra::Funcdata::ancestorOpUse(), ghidra::ActionParamDouble::apply(), ghidra::ActionRestrictLocal::apply(), ghidra::RulePullsubIndirect::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::AddrSpaceManager::assignShortcut(), ghidra::StackSolver::build(), ghidra::RulePushPtr::buildVarnodeOut(), ghidra::Heritage::bumpDeadcodeDelay(), ghidra::Architecture::cacheAddrSpaceProperties(), ghidra::IfcDuplicateHash::check(), ghidra::SleighCompile::checkCaseSensitivity(), ghidra::EmulateSnippet::checkForLegalCode(), ghidra::FuncCallSpecs::checkInputTrialUse(), ghidra::FuncCallSpecs::commitNewInputs(), ghidra::HighVariable::compareName(), ghidra::AddrSpaceManager::constructJoinAddress(), ghidra::Heritage::discoverIndexedStackPointers(), ghidra::PcodeOp::encode(), ghidra::Funcdata::encodeTree(), ghidra::AncestorRealistic::enterNode(), ghidra::IfcPrintSpaces::execute(), ghidra::EmulateSnippet::executeBranch(), ghidra::Merge::findAllIntoCopies(), ghidra::FuncCallSpecs::FuncCallSpecs(), ghidra::ActionFuncLink::funcLinkInput(), ghidra::ActionFuncLink::funcLinkOutput(), ghidra::Funcdata::getCallSpecs(), ghidra::TypeOpCall::getInputLocal(), ghidra::TypeOpCall::getOutputLocal(), ghidra::GhidraTranslate::getRegisterName(), ghidra::MemoryState::getValue(), ghidra::EmulateSnippet::getVarnodeValue(), ghidra::Architecture::globalify(), ghidra::Heritage::guardCalls(), ghidra::FuncCallSpecs::hasEffectTranslate(), ghidra::HeritageInfo::HeritageInfo(), ghidra::Architecture::highPtrPossible(), ghidra::AddrSpaceManager::insertSpace(), ghidra::Address::isConstant(), ghidra::Address::isJoin(), ghidra::RulePiecePathology::isPathology(), ghidra::ProtoModel::lookupEffect(), ghidra::Merge::mergeAddrTied(), ghidra::Funcdata::onlyOpUse(), ghidra::PrintC::opCall(), ghidra::Funcdata::opInsertAfter(), ghidra::JoinSpace::overlapJoin(), ghidra::ParamListStandard::parsePentry(), ghidra::Heritage::placeMultiequals(), ghidra::ParamListStandard::populateResolver(), ghidra::ActionMultiCse::preferredOutput(), ghidra::TransformManager::preserveAddress(), ghidra::ActionDeadCode::propagateConsumed(), ghidra::IfaceDecompData::readVarnode(), ghidra::ParamActive::registerTrial(), ghidra::Heritage::reprocessFreeStores(), ghidra::ParamEntry::resolveJoin(), ghidra::FuncCallSpecs::resolveSpacebaseRelative(), ghidra::SleighBase::saveXml(), ghidra::FuncCallSpecs::transferLockedInputParam(), ghidra::Funcdata::truncatedFlow(), ghidra::RulePtrFlow::truncatePointer(), ghidra::FuncProto::updateOutputTypes(), ghidra::Varnode::Varnode(), and ~AddrSpace().

◆ getWordSize()

uint4 ghidra::AddrSpace::getWordSize ( void  ) const
inline

Get the addressable unit size.

This method indicates the number of bytes contained in an addressable unit of this space. This is almost always 1, but can be any other small integer.

Returns
the number of bytes in a unit

References wordsize.

Referenced by ghidra::MapState::addRange(), ghidra::LoadImageXml::adjustVma(), ghidra::RawLoadImage::adjustVma(), ghidra::ActionDeindirect::apply(), ghidra::RuleLoadVarnode::applyOp(), ghidra::RuleStoreVarnode::applyOp(), ghidra::ParamListStandard::assignMap(), ghidra::ParamListStandardOut::assignMap(), ghidra::JumpBasic::buildAddresses(), ghidra::ArchitectureGhidra::buildSymbols(), ghidra::SleighArchitecture::buildSymbols(), ghidra::ScopeLocal::buildVariableName(), ghidra::ScopeInternal::buildVariableName(), ghidra::Funcdata::createStackRef(), ghidra::OverlaySpace::decode(), ghidra::IfcPrintSpaces::execute(), ghidra::IfcPointerSetting::execute(), ghidra::EmulateMemory::executeLoad(), ghidra::EmulateMemory::executeStore(), ghidra::AliasChecker::gatherInternal(), ghidra::TypeOpLoad::getInputCast(), ghidra::TypeOpStore::getInputCast(), ghidra::TypeOpCbranch::getInputLocal(), ghidra::TypeOpCallind::getInputLocal(), ghidra::MapState::initialize(), ghidra::AddrSpaceManager::parseAddressSimple(), ghidra::Funcdata::prepareThisPointer(), ghidra::TypeOpEqual::propagateAcrossCompare(), ghidra::TypeOpCopy::propagateType(), ghidra::TypeOpLoad::propagateType(), ghidra::TypeOpStore::propagateType(), ghidra::TypeOpIntXor::propagateType(), ghidra::TypeOpIntAnd::propagateType(), ghidra::TypeOpIntOr::propagateType(), ghidra::TypeOpMulti::propagateType(), ghidra::TypeOpIndirect::propagateType(), ghidra::PrintC::pushAnnotation(), ghidra::PrintC::pushPtrCodeConstant(), ghidra::AddrSpaceManager::resolveConstant(), ghidra::Funcdata::spacebase(), ghidra::Funcdata::spacebaseConstant(), ghidra::JumpBasicOverride::trialNorm(), ghidra::TypePointer::TypePointer(), and ~AddrSpace().

◆ hasPhysical()

bool ghidra::AddrSpace::hasPhysical ( void  ) const
inline

Return true if data is physically stored in this.

This routine returns true, if, like most spaces, the space has actual read/writeable bytes associated with it. Some spaces, like the constant space, do not.

Returns
true if the space has physical data in it.

References flags, and hasphysical.

Referenced by ghidra::OverlaySpace::decode(), saveBasicAttributes(), ghidra::EmulateFunction::setExecuteAddress(), and ~AddrSpace().

◆ isBigEndian()

bool ghidra::AddrSpace::isBigEndian ( void  ) const
inline

Return true if values in this space are big endian.

If integer values stored in this space are encoded in this space using the big endian format, then return true.

Returns
true if the space is big endian

References big_endian, and flags.

Referenced by ghidra::ActionParamDouble::apply(), ghidra::RulePullsubMulti::applyOp(), ghidra::RulePullsubIndirect::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::RulePiecePathology::applyOp(), ghidra::ActionMarkExplicit::baseExplicit(), ghidra::SplitDatatype::buildInConstants(), ghidra::LaneDivide::buildLoad(), ghidra::LaneDivide::buildStore(), ghidra::RulePullsubMulti::buildSubpiece(), ghidra::TypePointer::calcTruncate(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::TypeOpPiece::computeByteOffsetForComposite(), ghidra::TypeOpSubpiece::computeByteOffsetForComposite(), ghidra::RulePieceStructure::convertZextToPiece(), ghidra::ParamEntry::decode(), ghidra::OverlaySpace::decode(), ghidra::IfcPrintSpaces::execute(), ghidra::Funcdata::fillinReadOnly(), ghidra::MemoryImage::find(), ghidra::PieceNode::findRoot(), ghidra::PieceNode::gatherPieces(), ghidra::SplitDatatype::generateConstants(), ghidra::EmulatePcodeOp::getLoadImageValue(), ghidra::EmulateSnippet::getLoadImageValue(), ghidra::MemoryBank::getPage(), ghidra::ContextDatabase::getTrackedValue(), ghidra::MemoryBank::getValue(), ghidra::Heritage::guardCallOverlappingOutput(), ghidra::Heritage::guardReturnsOverlapping(), ghidra::Address::isBigEndian(), ghidra::ParamEntry::isLeftJustified(), ghidra::Merge::markInternalCopies(), ghidra::PrintC::opSubpiece(), ghidra::JoinSpace::overlapJoin(), ghidra::Varnode::partialCopyShadow(), ghidra::PrintC::pushPartialSymbol(), ghidra::ParamEntry::resolveOverlap(), saveBasicAttributes(), ghidra::SpacebaseSpace::setBaseRegister(), ghidra::MemoryBank::setPage(), ghidra::MemoryBank::setValue(), and ~AddrSpace().

◆ isFormalStackSpace()

bool ghidra::AddrSpace::isFormalStackSpace ( void  ) const
inline

Return true if this is attached to the formal stack pointer.

Currently an architecture can declare only one formal stack pointer.

References flags, and formal_stackspace.

Referenced by ~AddrSpace().

◆ isHeritaged()

bool ghidra::AddrSpace::isHeritaged ( void  ) const
inline

Return true if dataflow has been traced.

During analysis, memory locations in most spaces need to have their data-flow traced. This method returns true for these spaces. For some of the special spaces, like the constant space, tracing data flow makes no sense, and this routine will return false.

Returns
true if this space's data-flow is analyzed

References flags, and heritaged.

Referenced by ghidra::ConditionalExecution::buildHeritageArray(), ghidra::HeritageInfo::HeritageInfo(), and ~AddrSpace().

◆ isReverseJustified()

bool ghidra::AddrSpace::isReverseJustified ( void  ) const
inline

Return true if alignment justification does not match endianness.

Certain architectures or compilers specify an alignment for accessing words within the space The space required for a variable must be rounded up to the alignment. For variables smaller than the alignment, there is the issue of how the variable is "justified" within the aligned word. Usually the justification depends on the endianness of the space, for certain weird cases the justification may be the opposite of the endianness.

References flags, and reverse_justification.

Referenced by ghidra::ParamEntry::decode(), and ~AddrSpace().

◆ isTruncated()

bool ghidra::AddrSpace::isTruncated ( void  ) const
inline

Return true if this space is truncated from its original size.

If this method returns true, the logical form of this space is truncated from its actual size Pointers may refer to this original size put the most significant bytes are ignored

References flags, and truncated.

Referenced by ghidra::ActionPrototypeTypes::apply(), ghidra::Architecture::decodeStackPointer(), ghidra::RulePtrFlow::RulePtrFlow(), ghidra::Funcdata::spacebaseConstant(), and ~AddrSpace().

◆ numSpacebase()

int4 ghidra::AddrSpace::numSpacebase ( void  ) const
inlinevirtual

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 in ghidra::SpacebaseSpace.

Referenced by ghidra::Heritage::analyzeNewLoadGuards(), ghidra::ActionPrototypeTypes::apply(), ghidra::Heritage::discoverIndexedStackPointers(), ghidra::Funcdata::spacebase(), and ~AddrSpace().

◆ overlapJoin()

int4 ghidra::AddrSpace::overlapJoin ( uintb  offset,
int4  size,
AddrSpace pointSpace,
uintb  pointOff,
int4  pointSkip 
) const
virtual

Determine if a given point is contained in an address range in this address space.

The point is specified as an address space and offset pair plus an additional number of bytes to "skip". A non-negative value is returned if the point falls in the address range. If the point falls on the first byte of the range, 0 is returned. For the second byte, 1 is returned, etc. Otherwise -1 is returned.

Parameters
offsetis the starting offset of the address range within this space
sizeis the size of the address range in bytes
pointSpaceis the address space of the given point
pointOffis the offset of the given point
pointSkipis the additional bytes to skip
Returns
a non-negative value indicating where the point falls in the range, or -1

Reimplemented in ghidra::JoinSpace, and ghidra::ConstantSpace.

References wrapOffset().

Referenced by ghidra::Address::overlapJoin(), and ~AddrSpace().

◆ printOffset()

void ghidra::AddrSpace::printOffset ( ostream &  s,
uintb  offset 
) const

Write an address offset to a stream.

Print the offset as hexidecimal digits.

Parameters
sis the stream to write to
offsetis the offset to be printed

Referenced by ~AddrSpace().

◆ printRaw()

void ghidra::AddrSpace::printRaw ( ostream &  s,
uintb  offset 
) const
virtual

Write an address in this space to a stream.

This is a printing method for the debugging routines. It prints taking into account the wordsize, adding a "+n" if the offset is not on-cut with wordsize. It also returns the expected/typical size of values from this space.

Parameters
sis the stream being written
offsetis the offset to be printed

Reimplemented in ghidra::FspecSpace, ghidra::JoinSpace, ghidra::OtherSpace, ghidra::ConstantSpace, and ghidra::IopSpace.

References byteToAddress(), getAddrSize(), and wordsize.

Referenced by ghidra::Address::printRaw(), and ~AddrSpace().

◆ read()

uintb ghidra::AddrSpace::read ( const string &  s,
int4 &  size 
) const
virtual

Read in an address (and possible size) from a string.

For the console mode, an address space can tailor how it converts user strings into offsets within the space. The base routine can read and convert register names as well as absolute hex addresses. A size can be indicated by appending a ':' and integer, .i.e. 0x1000:2. Offsets within a register can be indicated by appending a '+' and integer, i.e. eax+2

Parameters
sis the string to be parsed
sizeis a reference to the size being returned
Returns
the parsed offset

Reimplemented in ghidra::JoinSpace.

References addressToByte(), ghidra::AddrSpaceManager::getDefaultSize(), ghidra::Translate::getRegister(), manage, ghidra::VarnodeData::offset, trans, and wordsize.

Referenced by ghidra::Address::read(), ghidra::JoinSpace::read(), and ~AddrSpace().

◆ saveBasicAttributes()

void ghidra::AddrSpace::saveBasicAttributes ( ostream &  s) const
protected

Write the XML attributes of this space.

Save the name, index, bigendian, delay, size, wordsize, and physical attributes which are common with all address spaces derived from AddrSpace

Parameters
sthe stream where the attributes are written

References ghidra::a_v(), ghidra::a_v_b(), ghidra::a_v_i(), addressSize, deadcodedelay, delay, hasPhysical(), index, isBigEndian(), name, and wordsize.

Referenced by saveXml(), ghidra::SpacebaseSpace::saveXml(), ghidra::OtherSpace::saveXml(), and ghidra::UniqueSpace::saveXml().

◆ saveXml()

void ghidra::AddrSpace::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 in ghidra::FspecSpace, ghidra::OverlaySpace, ghidra::JoinSpace, ghidra::UniqueSpace, ghidra::OtherSpace, ghidra::ConstantSpace, ghidra::SpacebaseSpace, and ghidra::IopSpace.

References saveBasicAttributes().

Referenced by ghidra::OverlaySpace::getContain(), ghidra::SleighBase::saveXml(), and ~AddrSpace().

◆ setFlags()

void ghidra::AddrSpace::setFlags ( uint4  fl)
inlineprotected

◆ stackGrowsNegative()

bool ghidra::AddrSpace::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 in ghidra::SpacebaseSpace.

Referenced by ghidra::ProtoModel::decode(), ghidra::AliasChecker::gather(), and ~AddrSpace().

◆ truncateSpace()

void ghidra::AddrSpace::truncateSpace ( uint4  newsize)
protected

The logical form of the space is truncated from its actual size Pointers may refer to this original size put the most significant bytes are ignored

Parameters
newsizeis the size (in bytes) of the truncated (logical) space

References addressSize, calcScaleMask(), minimumPointerSize, setFlags(), and truncated.

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

◆ wrapOffset()

uintb ghidra::AddrSpace::wrapOffset ( uintb  off) const
inline

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