Package ghidra.program.database.symbol
Class MemorySymbol
java.lang.Object
ghidra.program.database.DatabaseObject
ghidra.program.database.symbol.SymbolDB
ghidra.program.database.symbol.MemorySymbol
- All Implemented Interfaces:
Symbol
- Direct Known Subclasses:
CodeSymbol,FunctionSymbol
MemorySymbol corresponds to any symbol that resides at a memory location.
The corresponding address may be either a memory address
or a fake external address. While an external address is
not a memory address it corresponds to an ExternalLocation which may identify a
specific memory address if known.-
Field Summary
Fields inherited from class ghidra.program.database.symbol.SymbolDB
address, lock, record, symbolMgrFields inherited from class ghidra.program.database.DatabaseObject
key -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMemorySymbol(SymbolManager mgr, DBObjectCache<SymbolDB> cache, Address addr, long key) Constructs a new MemorySymbol which corresponds to the specified symbol key and has no record.protectedMemorySymbol(SymbolManager mgr, DBObjectCache<SymbolDB> cache, Address addr, DBRecord record) Constructs a new MemorySymbol which corresponds to the specified symbol record, -
Method Summary
Modifier and TypeMethodDescriptionfinal StringGets the optional field which is intended to store the original mangled name for an externalSymbolType.LABELorSymbolType.FUNCTIONwhich has anexternal address.final AddressGets the optional field which is intended to store the original mangled name for an externalSymbolType.LABELorSymbolType.FUNCTIONwhich has anexternal address.intGet the number of References to this symbol or its address.getReferences(TaskMonitor monitor) Returns all memory references to the address of this symbol.booleanfinal booleanReturns true if this an external symbol.final booleanfinal booleanisPinned()Returns true if the symbol is pinned to its current address.protected voidmoveLowLevel(Address newAddress, String newName, Namespace newNamespace, SourceType newSource, boolean pinned) low level record adjustment to move a symbol.final voidsetExternalOriginalImportedName(String originalImportedName, boolean notify) Sets the symbol's original imported external name field for an externalSymbolType.LABELorSymbolType.FUNCTIONwhich has anexternal address.final voidsetExternalProgramAddress(Address externalProgramAddress, boolean notify) Sets the symbol's external Program Address field for an externalSymbolType.LABELorSymbolType.FUNCTIONwhich has anexternal address.final voidsetPinned(boolean pinned) Sets whether or not this symbol is pinned to its associated address.Methods inherited from class ghidra.program.database.symbol.SymbolDB
checkDeleted, delete, doCheckIsPrimary, doGetName, doGetParentNamespace, doSetNameAndNamespace, doSetPrimary, equals, getAddress, getDataTypeId, getID, getName, getName, getParentNamespace, getParentSymbol, getPath, getProgram, getSource, getSymbolsDynamicallyRenamedByMyRename, hashCode, isDeleted, isDeleting, isDescendant, isDynamic, isGlobal, isPrimary, isValidParent, refresh, refresh, setAddress, setDataTypeId, setName, setNameAndNamespace, setNamespace, setPrimary, setSource, setSourceFlagBits, toString, updateRecord, validateNameSourceMethods inherited from class ghidra.program.database.DatabaseObject
checkIsValid, checkIsValid, getKey, isDeleted, isInvalid, keyChanged, setDeleted, setInvalid, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.symbol.Symbol
getObject, getProgramLocation, getReferences, getSymbolType
-
Constructor Details
-
MemorySymbol
protected MemorySymbol(SymbolManager mgr, DBObjectCache<SymbolDB> cache, Address addr, DBRecord record) Constructs a new MemorySymbol which corresponds to the specified symbol record,- Parameters:
mgr- the symbol managercache- symbol object cacheaddr- the address associated with the symbolrecord- the record for this symbol
-
MemorySymbol
Constructs a new MemorySymbol which corresponds to the specified symbol key and has no record. This is intended to support dynamic label cases which do not have a record and do not support an external address.- Parameters:
mgr- the symbol managercache- symbol object cacheaddr- the address associated with the symbolkey- this must be the absolute encoding of addr
-
-
Method Details
-
isExternalEntryPoint
public final boolean isExternalEntryPoint()- Returns:
- true if the symbol is at an address set as a external entry point.
-
isExternal
public final boolean isExternal()Description copied from interface:SymbolReturns true if this an external symbol.- Returns:
- true if this an external symbol.
- See Also:
-
isPinned
public final boolean isPinned()Description copied from interface:SymbolReturns true if the symbol is pinned to its current address. If it is pinned, then moving or removing the memory associated with that address will not affect this symbol.- Returns:
- true if the symbol is pinned to its current address.
-
setPinned
public final void setPinned(boolean pinned) Description copied from interface:SymbolSets whether or not this symbol is pinned to its associated address.
If the symbol is pinned then moving or removing the memory associated with its address will not cause this symbol to be removed and will not cause its address to change. If the symbol is not pinned, then removing the memory at its address will also remove this symbol.
Likewise, moving a memory block containing a symbol that is not anchored will change the address for that symbol to keep it associated with the same byte in the memory block.
- Parameters:
pinned- true indicates this symbol is anchored to its address. false indicates this symbol is not anchored to its address.
-
moveLowLevel
protected void moveLowLevel(Address newAddress, String newName, Namespace newNamespace, SourceType newSource, boolean pinned) low level record adjustment to move a symbol. Used only when moving a memory block or changing the image base.- Parameters:
newAddress- the new address for the symbolnewName- the new name for the symbol (or null if the name should stay the same)newNamespace- the new namespace for the symbol (or null if it should stay the same)newSource- the new SourceType for the symbol (or null if it should stay the same)pinned- the new pinned state
-
getReferenceCount
public int getReferenceCount()Description copied from interface:SymbolGet the number of References to this symbol or its address.NOTE: this method differ from
Symbol.hasReferences()behavior for memory symbols since this method will returnReferenceManager.getReferenceCountTo(Address)if this is the only symbol at its address.- Returns:
- the number of References to this symbol or its address.
-
hasReferences
public boolean hasReferences()- Returns:
- true if this symbol has at least one reference to it.
Explicit references to other symbols at the same address are not considered
(see
Reference.getSymbolID()which indicates a specific symbol reference).
-
getReferences
Description copied from interface:SymbolReturns all memory references to the address of this symbol. If you do not have aTaskMonitorinstance, then you can passTaskMonitor.DUMMYornull.- Parameters:
monitor- the monitor that is used to report progress and to cancel this potentially long-running call- Returns:
- all memory references to the address of this symbol.
-
getExternalOriginalImportedName
Gets the optional field which is intended to store the original mangled name for an externalSymbolType.LABELorSymbolType.FUNCTIONwhich has anexternal address. These symbol types correspond toCodeSymbolandFunctionSymbolDB symbol implementations respectively. This is generally set when anExternalLocationDBis renamed which generally corresponds the external symbol being demangled.- Returns:
- original imported external name or null if not external or symbol has not been demangled or renamed.
-
setExternalOriginalImportedName
Sets the symbol's original imported external name field for an externalSymbolType.LABELorSymbolType.FUNCTIONwhich has anexternal address. These symbol types correspond toCodeSymbolandFunctionSymbolDB symbol implementations respectively. This is generally set when anExternalLocationDBis renamed which generally corresponds the external symbol being demangled.- Parameters:
originalImportedName- the original import name or nullnotify- if true, a program change notification will be generated- Throws:
UnsupportedOperationException- if symbol is neither an externalSymbolType.LABELorSymbolType.FUNCTION.
-
getExternalProgramAddress
Gets the optional field which is intended to store the original mangled name for an externalSymbolType.LABELorSymbolType.FUNCTIONwhich has anexternal address. These symbol types correspond toCodeSymbolandFunctionSymbolDB symbol implementations respectively. This is generally set when anExternalLocationDBis renamed which generally corresponds the external symbol being demangled.- Returns:
- external Program address or null if not external or unknown
-
setExternalProgramAddress
Sets the symbol's external Program Address field for an externalSymbolType.LABELorSymbolType.FUNCTIONwhich has anexternal address. These symbol types correspond toCodeSymbolandFunctionSymbolDB symbol implementations respectively.- Parameters:
externalProgramAddress- the external Program Address which corresponds to the externally linked location (may be null).notify- if true, a program change notification will be generated- Throws:
UnsupportedOperationException- if symbol is neither an externalSymbolType.LABELorSymbolType.FUNCTION.
-