Package ghidra.program.model.address
Class OverlayAddressSpace
java.lang.Object
ghidra.program.model.address.OverlayAddressSpace
- All Implemented Interfaces:
AddressSpace,Comparable<AddressSpace>
- Direct Known Subclasses:
ProgramOverlayAddressSpace
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Addressprotected longprotected final Addressprotected final longstatic final Stringprotected final intprotected longFields inherited from interface ghidra.program.model.address.AddressSpace
DEFAULT_REGISTER_SPACE, EXTERNAL_SPACE, HASH_SPACE, ID_SIZE_MASK, ID_SIZE_SHIFT, ID_TYPE_MASK, ID_UNIQUE_SHIFT, OTHER_SPACE, TYPE_CODE, TYPE_CONSTANT, TYPE_DELETED, TYPE_EXTERNAL, TYPE_IPTR_CONSTANT, TYPE_IPTR_INTERNAL, TYPE_IPTR_SPACEBASE, TYPE_JOIN, TYPE_NONE, TYPE_OTHER, TYPE_RAM, TYPE_REGISTER, TYPE_STACK, TYPE_SYMBOL, TYPE_UNIQUE, TYPE_UNKNOWN, TYPE_VARIABLE, VARIABLE_SPACE -
Constructor Summary
ConstructorsConstructorDescriptionOverlayAddressSpace(AddressSpace baseSpace, int unique, String orderedKey) Construction an overlay address space instance. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new address (possibly in a new space) by adding the given displacement from the given address.Creates a new address by adding displacement to the given address.addNoWrap(GenericAddress addr, BigInteger displacement) Creates a new address by adding displacement to the given address.Creates a new address by adding displacement to the given address.addWrapSpace(Address addr, long displacement) Creates a new address by adding the displacement to the given address.intcompareTo(AddressSpace space) abstract booleancontains(long offset) Determine if the specified offset is contained within a defined region of this overlay space.final booleangetAddress(long offset) Returns a new address in this space with the given byte offset.getAddress(long offset, boolean isAddressableWordOffset) Returns a new address in this space with the given offset.final AddressgetAddress(String addrString) Parses the String into an address within this address space.getAddress(String addrString, boolean caseSensitive) Parses the String into an address within this address space.intReturns the number of data bytes which correspond to each addressable location within this space (i.e., word-size in bytes).longgetAddressableWordOffset(long byteOffset) Get the addressable memory word offset which corresponds to the specified memory byte offset.getAddressInThisSpaceOnly(long offset) Get a byte address from this address space.intGet the maximum address allowed for this AddressSpace.Get the minimum address allowed for this AddressSpace.Get the ordered key assigned to this overlay address space instance This value is used when performingequals(Object)andComparable.compareTo(AddressSpace)operations.getOverlayAddress(Address addr) No overlay translation necessary, this is a base addressSpace.abstract AddressSetViewGet theAddressSetwhich corresponds to overlayed physical region which corresponds to the defined overlay regions within the overlay (i.e., overlay blocks).Get the overlayed (i.e., underlying) base space associated with this overlay space.Returns the physical space associated with an address space.intReturns the absolute size of a pointer into this space (in bytes).intgetSize()Returns the number of bits that are used to form the address.intGet the ID for this spacegetTruncatedAddress(long offset, boolean isAddressableWordOffset) Returns a new address in this space with the given offset.intgetType()Returns the type of this address spaceprotected AddressgetUncheckedAddress(long offset) Instantiates an address within this space.intReturns the unique id value for this space.final inthashCode()booleanReturns true if this space has registers that are mapped into it.booleanReturns true if space uses signed offsetbooleanReturns true if this space in the constant spacebooleanReturns true if this space in the EXTERNAL_SPACEbooleanReturns true if this space represents a location in the HASH space.booleanReturns true if this space represents a Loaded Memory region (e.g., processor RAM).booleanReturns true if this space represents a memory address.booleanReturns true if this space represents a Non-Loaded storage region for retaining non-loaded file data (e.g., OTHER)booleanReturns true if this addressSpace is an OverlayAddressSpacebooleanReturns true if this space represents a register locationbooleanReturns true if this space represents a stack locationbooleanisSuccessor(Address addr1, Address addr2) Tests whether addr2 immediately follows addr1.booleanReturns true if this space in the unique spacebooleanisValidRange(long byteOffset, long length) Check the specified address range for validity within this space.booleanReturns true if this space represents a variable locationlongmakeValidOffset(long offset) Tests if the offset if valid.voidsetHasMappedRegisters(boolean hasRegisters) Tag this memory space as having memory mapped registersvoidsetShowSpaceName(boolean b) booleanReturns true if the address should display its addressSpace name.Creates a new address (possibly in a new space) by subtracting the given displacement from the given address.longCalculates the displacement between addr1 and addr2 (addr1 - addr2)subtractNoWrap(Address addr, long displacement) Creates a new address by subtracting displacement from addr's offset.subtractWrap(Address addr, long displacement) Creates a new address by subtracting displacement from addr's offset.subtractWrapSpace(Address addr, long displacement) Creates a new address by subtracting the displacement from the given address.protected voidtestAddressSpace(Address addr) toString()translateAddress(Address addr) If the given address is outside the overlay block, then the address is tranlated to an address in the base space with the same offset, otherwise (if the address exists in the overlay block), it is returnedtranslateAddress(Address addr, boolean forceTranslation) Tranlated an overlay-space address (addr, which may exceed the bounds of the overlay space) to an address in the base space with the same offset.longtruncateAddressableWordOffset(long wordOffset) Truncate the specified addressable unit/word offset within this space to produce a valid offset.longtruncateOffset(long offset) Truncate the specified byte offset within this space to produce a valid offset.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.address.AddressSpace
getName
-
Field Details
-
OV_SEPARATER
- See Also:
-
minOffset
protected final long minOffset -
maxOffset
protected long maxOffset -
minAddress
-
maxAddress
-
spaceSize
protected long spaceSize -
spaceID
protected final int spaceID
-
-
Constructor Details
-
OverlayAddressSpace
Construction an overlay address space instance.- Parameters:
baseSpace- base overlayed address spaceunique- unique index/sequence numberorderedKey- unique ordered key which should generally match overlay name unless already used (e.g., on a renamed overlay space). This associated value should not be changed for a given address factory instance.
-
-
Method Details
-
getOrderedKey
Get the ordered key assigned to this overlay address space instance This value is used when performingequals(Object)andComparable.compareTo(AddressSpace)operations.If this value does not have its optimal value (i.e., same as address space name), the associated
AddressFactoryshould report astale overlay condition.- Returns:
- instance ordered key
-
getAddress
Description copied from interface:AddressSpaceParses the String into an address within this address space.- Specified by:
getAddressin interfaceAddressSpace- Parameters:
addrString- the string to parse as an address.caseSensitive- specifies if addressSpace names must match case.- Returns:
- an address if the string parsed successfully or null if the AddressSpace specified in the addrString is not this space.
- Throws:
AddressFormatException- if the string cannot be parsed or the parsed offset is larger than the size for this space.
-
subtract
Description copied from interface:AddressSpaceCalculates the displacement between addr1 and addr2 (addr1 - addr2)- Specified by:
subtractin interfaceAddressSpace- Parameters:
addr1- the address to subtract from.addr2- the address to subtract.- Returns:
- the difference. (
addr1.offset - addr2.offset).
-
isOverlaySpace
public boolean isOverlaySpace()Description copied from interface:AddressSpaceReturns true if this addressSpace is an OverlayAddressSpace- Specified by:
isOverlaySpacein interfaceAddressSpace
-
getOverlayedSpace
Get the overlayed (i.e., underlying) base space associated with this overlay space.- Returns:
- overlayed base space.
-
getPhysicalSpace
Description copied from interface:AddressSpaceReturns the physical space associated with an address space. There is always exactly one physical space associated with an address space (it may be its own physical space).- Specified by:
getPhysicalSpacein interfaceAddressSpace- Returns:
- the associated physical space.
-
hasMappedRegisters
public boolean hasMappedRegisters()Description copied from interface:AddressSpaceReturns true if this space has registers that are mapped into it. This means that registers could actually have pointers to them.- Specified by:
hasMappedRegistersin interfaceAddressSpace- Returns:
- true if this space has any registers mapped in it.
-
contains
public abstract boolean contains(long offset) Determine if the specified offset is contained within a defined region of this overlay space.- Parameters:
offset- unsigned address offset- Returns:
- true if contained within defined region otherwise false
-
getOverlayAddressSet
Get theAddressSetwhich corresponds to overlayed physical region which corresponds to the defined overlay regions within the overlay (i.e., overlay blocks).- Returns:
- defined regions within the overlay. All addresses are overlay addresses.
-
getAddressInThisSpaceOnly
Description copied from interface:AddressSpaceGet a byte address from this address space. Don't allow overlay spaces to remap the address into a base space when the address is not contained in the bounds of the overlay region.- Parameters:
offset- the byte offset for the new address.- Returns:
- an address if the offset is valid.
-
getAddress
Description copied from interface:AddressSpaceReturns a new address in this space with the given byte offset. NOTE: This method is the same as invoking getAddress(long byteOffset, false).- Parameters:
offset- the byte offset for the new address.- Returns:
- address with given byte offset
-
getUncheckedAddress
Instantiates an address within this space. No offset validation should be performed.- Parameters:
offset- address offset- Returns:
- requested unchecked address
-
getOverlayAddress
No overlay translation necessary, this is a base addressSpace. (non-Javadoc)- Specified by:
getOverlayAddressin interfaceAddressSpace- Parameters:
addr- address possibly falling within this overlay space.- Returns:
- an address relative to this overlay
- See Also:
-
translateAddress
If the given address is outside the overlay block, then the address is tranlated to an address in the base space with the same offset, otherwise (if the address exists in the overlay block), it is returned- Parameters:
addr- the address to translate to the base space if it is outside the overlay block- Returns:
- either the given address if it is contained in the overlay memory block or an address in the base space with the same offset as the given address.
-
translateAddress
Tranlated an overlay-space address (addr, which may exceed the bounds of the overlay space) to an address in the base space with the same offset. If forceTranslation is false and addr is contained within the overlay-space the original addr is returned.- Parameters:
addr- the address to translate to the base spaceforceTranslation- if true addr will be translated even if addr falls within the bounds of this overlay-space.- Returns:
- either the given address if it is contained in the overlay memory block or an address in the base space with the same offset as the given address.
-
getBaseSpaceID
public int getBaseSpaceID()- Returns:
- the ID of the address space underlying this space
-
toString
-
equals
-
hasSignedOffset
public boolean hasSignedOffset()Description copied from interface:AddressSpaceReturns true if space uses signed offset- Specified by:
hasSignedOffsetin interfaceAddressSpace
-
getSize
public int getSize()Description copied from interface:AddressSpaceReturns the number of bits that are used to form the address. Thus the maximum offset for this address space will be 2^size-1.- Specified by:
getSizein interfaceAddressSpace
-
getAddressableUnitSize
public int getAddressableUnitSize()Description copied from interface:AddressSpaceReturns the number of data bytes which correspond to each addressable location within this space (i.e., word-size in bytes). NOTE: When transforming a byte-offset to an addressable word offset the methodAddressSpace.getAddressableWordOffset(long)should be used instead of simple division. When transforming an addressable word-offset to a byte-offset simple multiplication may be used. Neither of these transformations perform address space bounds checking.byteOffset = wordOffset * addressUnitSize wordOffset = getAddressableWordOffset(byteOffset)
- Specified by:
getAddressableUnitSizein interfaceAddressSpace
-
getAddressableWordOffset
public long getAddressableWordOffset(long byteOffset) Description copied from interface:AddressSpaceGet the addressable memory word offset which corresponds to the specified memory byte offset. This method handles some of the issues of unsigned math when stuck using Java's signed long primitives. No space bounds checking is performed.- Specified by:
getAddressableWordOffsetin interfaceAddressSpace- Parameters:
byteOffset- memory byte offset- Returns:
- addressable memory word offset
-
getPointerSize
public int getPointerSize()Description copied from interface:AddressSpaceReturns the absolute size of a pointer into this space (in bytes).- Specified by:
getPointerSizein interfaceAddressSpace- See Also:
-
getType
public int getType()Description copied from interface:AddressSpaceReturns the type of this address space- Specified by:
getTypein interfaceAddressSpace
-
getUnique
public int getUnique()Returns the unique id value for this space.- Specified by:
getUniquein interfaceAddressSpace
-
getAddress
Description copied from interface:AddressSpaceParses the String into an address within this address space.- Specified by:
getAddressin interfaceAddressSpace- Parameters:
addrString- the string to parse as an address.- Returns:
- an address if the string parsed successfully or null if the AddressSpace specified in the addrString is not this space.
- Throws:
AddressFormatException- if the string cannot be parsed or the parsed offset is larger than the size for this space.
-
getAddress
public Address getAddress(long offset, boolean isAddressableWordOffset) throws AddressOutOfBoundsException Description copied from interface:AddressSpaceReturns a new address in this space with the given offset. NOTE: for those spaces with an addressable unit size other than 1, the address returned may not correspond to an addressable unit/word boundary if a byte-offset is specified.- Specified by:
getAddressin interfaceAddressSpace- Parameters:
offset- the offset for the new address.isAddressableWordOffset- if true the specified offset is an addressable unit/word offset, otherwise offset is a byte offset. SeeAddressSpace.getAddressableUnitSize()to understand the distinction (i.e., wordOffset = byteOffset * addressableUnitSize).- Returns:
- address with given offset
- Throws:
AddressOutOfBoundsException- if the offset is less than 0 or greater than the max offset allowed for this space.
-
getTruncatedAddress
Description copied from interface:AddressSpaceReturns a new address in this space with the given offset. The specified offset will be truncated within the space and will not throw an exception. NOTE: for those spaces with an addressable unit size other than 1, the address returned may not correspond to a word boundary (addressable unit) if a byte-offset is specified.- Specified by:
getTruncatedAddressin interfaceAddressSpace- Parameters:
offset- the offset for the new address.isAddressableWordOffset- if true the specified offset is an addressable unit/word offset, otherwise offset is a byte offset. SeeAddressSpace.getAddressableUnitSize()to understand the distinction (i.e., wordOffset = byteOffset * addressableUnitSize).- Returns:
- address with given byte offset truncated to the physical space size
-
subtractWrap
Description copied from interface:AddressSpaceCreates a new address by subtracting displacement from addr's offset.- Specified by:
subtractWrapin interfaceAddressSpace- Parameters:
addr- the original address. The new address will wrap in a manner that depends on the address space. For a generic address space this will wrap at the extents of the address space. For a segmented address space it will wrap at the extents of the segment.displacement- the displacement to subtract.- Returns:
- a new address created by subtracting the displacement from addr.offset.
-
subtractWrapSpace
Description copied from interface:AddressSpaceCreates a new address by subtracting the displacement from the given address. If the offset is greater than the max offset of the address space, the high order bits are masked off, making the address wrap. For non-segmented addresses this will be the same as subtractWrap(). For segmented addresses, the address will wrap when the 20 bit (oxfffff) offset is exceeded, as opposed to when the segment offset is exceeded.- Specified by:
subtractWrapSpacein interfaceAddressSpace- Parameters:
addr- the address to subtract the displacement from.displacement- the displacement to subtract.- Returns:
- The new Address formed by subtracting the displacement from the specified address.
-
subtractNoWrap
Description copied from interface:AddressSpaceCreates a new address by subtracting displacement from addr's offset. The new offset will NOT wrap!- Specified by:
subtractNoWrapin interfaceAddressSpace- Parameters:
addr- the original addressdisplacement- the displacement to subtract.- Returns:
- The new address created by subtracting displacement from addr.offset.
- Throws:
AddressOverflowException- if the subtraction would cause a wrap,
-
subtract
Description copied from interface:AddressSpaceCreates a new address (possibly in a new space) by subtracting the given displacement from the given address.- Specified by:
subtractin interfaceAddressSpace- Parameters:
addr- original address being subtracted fromdisplacement- amount to subtract- Returns:
- the new address
-
addWrap
Description copied from interface:AddressSpaceCreates a new address by adding displacement to the given address. The resulting address may wrap. The new address will wrap in a manner that depends on the address space. For a generic address space this will wrap at the extents of the address space. For a segmented address space it will wrap at the extents of the segment.- Specified by:
addWrapin interfaceAddressSpace- Parameters:
addr- the original address.displacement- the displacement to add.- Returns:
- the new address created by adding displacement to addr.offset.
-
addWrapSpace
Description copied from interface:AddressSpaceCreates a new address by adding the displacement to the given address. If the offset is greater than the max offset of the address space, the high order bits are masked off, making the address wrap. For non-segmented addresses this will be the same as addWrap(). For segmented addresses, the address will wrap when the 20 bit (oxfffff) offset is exceeded, as opposed to when the segment offset is exceeded.- Specified by:
addWrapSpacein interfaceAddressSpace- Parameters:
addr- the address to add the displacement to.displacement- the displacement to add.- Returns:
- The new Address formed by adding the displacement to the specified addresst.
-
addNoWrap
Description copied from interface:AddressSpaceCreates a new address by adding displacement to the given address. The new address will NOT wrap!- Specified by:
addNoWrapin interfaceAddressSpace- Parameters:
addr- the original address.displacement- the displacement to add.- Returns:
- The new address created by adding displacement to addr.offset.
- Throws:
AddressOverflowException- if the addition would cause a wrap,
-
addNoWrap
public Address addNoWrap(GenericAddress addr, BigInteger displacement) throws AddressOverflowException Description copied from interface:AddressSpaceCreates a new address by adding displacement to the given address. The new address will NOT wrap!- Specified by:
addNoWrapin interfaceAddressSpace- Parameters:
addr- the original address.displacement- the displacement to add.- Returns:
- The new address created by adding displacement to addr.offset.
- Throws:
AddressOverflowException- if the addition would cause a wrap,
-
add
Description copied from interface:AddressSpaceCreates a new address (possibly in a new space) by adding the given displacement from the given address.- Specified by:
addin interfaceAddressSpace- Parameters:
addr- original address being subtracted fromdisplacement- amount to subtract- Returns:
- the new address
- Throws:
AddressOutOfBoundsException- if the result does not correspond to any address.
-
isValidRange
public boolean isValidRange(long byteOffset, long length) Description copied from interface:AddressSpaceCheck the specified address range for validity within this space. Segmented spaces will restrict a range to a single segment.- Specified by:
isValidRangein interfaceAddressSpace- Parameters:
byteOffset-length-- Returns:
- true if range is valid for this space
-
isSuccessor
Description copied from interface:AddressSpaceTests whether addr2 immediately follows addr1.- Specified by:
isSuccessorin interfaceAddressSpace- Parameters:
addr1- the first address.addr2- the second address.
-
getMaxAddress
Description copied from interface:AddressSpaceGet the maximum address allowed for this AddressSpace. NOTE: Use of this method to identify the region associated with an overlay memory block within its overlay address space is no longer supported. Defined regions of an overlay space may now be determined usinggetOverlayAddressSet().- Specified by:
getMaxAddressin interfaceAddressSpace- Returns:
- maximum address of this address space.
-
getMinAddress
Description copied from interface:AddressSpaceGet the minimum address allowed for this AddressSpace. For a memory space the returned address will have an offset of 0 within this address space. NOTE: Use of this method to identify the region associated with an overlay memory block within its overlay address space is no longer supported. Defined regions of an overlay space may now be determined usinggetOverlayAddressSet().- Specified by:
getMinAddressin interfaceAddressSpace- Returns:
- minimum address of this address space.
-
compareTo
- Specified by:
compareToin interfaceComparable<AddressSpace>
-
hashCode
public final int hashCode() -
getSpaceID
public int getSpaceID()Description copied from interface:AddressSpaceGet the ID for this space- Specified by:
getSpaceIDin interfaceAddressSpace- Returns:
- space ID
-
testAddressSpace
-
showSpaceName
public boolean showSpaceName()Description copied from interface:AddressSpaceReturns true if the address should display its addressSpace name.- Specified by:
showSpaceNamein interfaceAddressSpace
-
makeValidOffset
Description copied from interface:AddressSpaceTests if the offset if valid. If the space is signed, then it sign extends the offset.- Specified by:
makeValidOffsetin interfaceAddressSpace- Parameters:
offset- the offset to test and/or sign extend- Returns:
- the valid positive offset or appropriate sign extended offset.
- Throws:
AddressOutOfBoundsException- if offset is invalid
-
truncateOffset
public long truncateOffset(long offset) Description copied from interface:AddressSpaceTruncate the specified byte offset within this space to produce a valid offset.- Specified by:
truncateOffsetin interfaceAddressSpace- Parameters:
offset- any byte offset- Returns:
- truncated byte offset
-
truncateAddressableWordOffset
public long truncateAddressableWordOffset(long wordOffset) Description copied from interface:AddressSpaceTruncate the specified addressable unit/word offset within this space to produce a valid offset.- Specified by:
truncateAddressableWordOffsetin interfaceAddressSpace- Parameters:
wordOffset- any addressable unit/word offset- Returns:
- truncated word offset
-
isMemorySpace
public boolean isMemorySpace()Description copied from interface:AddressSpaceReturns true if this space represents a memory address. NOTE: It is important to make the distinction between Loaded and Non-Loaded memory addresses. Program importers may create memory blocks associated with Non-Loaded file content which are not associated with processor defined memory regions. While Loaded file content is placed into memory blocks which are associated with specific memory address spaces defined by the processor language specification.- Specified by:
isMemorySpacein interfaceAddressSpace- See Also:
-
isLoadedMemorySpace
public boolean isLoadedMemorySpace()Description copied from interface:AddressSpaceReturns true if this space represents a Loaded Memory region (e.g., processor RAM).- Specified by:
isLoadedMemorySpacein interfaceAddressSpace
-
isNonLoadedMemorySpace
public boolean isNonLoadedMemorySpace()Description copied from interface:AddressSpaceReturns true if this space represents a Non-Loaded storage region for retaining non-loaded file data (e.g., OTHER)- Specified by:
isNonLoadedMemorySpacein interfaceAddressSpace
-
isHashSpace
public boolean isHashSpace()Description copied from interface:AddressSpaceReturns true if this space represents a location in the HASH space.- Specified by:
isHashSpacein interfaceAddressSpace
-
isRegisterSpace
public boolean isRegisterSpace()Description copied from interface:AddressSpaceReturns true if this space represents a register location- Specified by:
isRegisterSpacein interfaceAddressSpace
-
isStackSpace
public boolean isStackSpace()Description copied from interface:AddressSpaceReturns true if this space represents a stack location- Specified by:
isStackSpacein interfaceAddressSpace
-
isUniqueSpace
public boolean isUniqueSpace()Description copied from interface:AddressSpaceReturns true if this space in the unique space- Specified by:
isUniqueSpacein interfaceAddressSpace
-
isConstantSpace
public boolean isConstantSpace()Description copied from interface:AddressSpaceReturns true if this space in the constant space- Specified by:
isConstantSpacein interfaceAddressSpace
-
isVariableSpace
public boolean isVariableSpace()Description copied from interface:AddressSpaceReturns true if this space represents a variable location- Specified by:
isVariableSpacein interfaceAddressSpace
-
isExternalSpace
public boolean isExternalSpace()Description copied from interface:AddressSpaceReturns true if this space in the EXTERNAL_SPACE- Specified by:
isExternalSpacein interfaceAddressSpace
-
setShowSpaceName
public void setShowSpaceName(boolean b) -
setHasMappedRegisters
public void setHasMappedRegisters(boolean hasRegisters) Tag this memory space as having memory mapped registers- Parameters:
hasRegisters- true if it has registers, false otherwise
-