Package ghidra.program.database.reloc
Class RelocationManager
java.lang.Object
ghidra.program.database.reloc.RelocationManager
- All Implemented Interfaces:
ManagerDB
,RelocationTable
An implementation of the relocation table interface.
-
Field Summary
Fields inherited from interface ghidra.program.model.reloc.RelocationTable
RELOCATABLE_PROP_NAME
-
Constructor Summary
ConstructorDescriptionRelocationManager
(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock, TaskMonitor monitor) Constructs a new relocation manager. -
Method Summary
Modifier and TypeMethodDescriptionadd
(Address addr, Relocation.Status status, int type, long[] values, byte[] bytes, String symbolName) Adds a new relocation entry when the original bytes being replaced are to be specified.add
(Address addr, Relocation.Status status, int type, long[] values, int byteLength, String symbolName) Adds a new relocation entry when the original bytes being replaced should be determined from the underlyingFileBytes
.void
deleteAddressRange
(Address startAddr, Address endAddr, TaskMonitor monitor) Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly.Returns the next relocation address which follows the specified address.Returns an iterator over all defined relocations (in ascending address order) located within the program.getRelocations
(Address addr) Returns the ordered list of relocations which have been defined for the specified address.Returns an iterator over all defined relocations (in ascending address order) located within the program over the specified address set.int
getSize()
Returns the number of relocation in this table.boolean
hasRelocation
(Address addr) Determine if the specified address has a relocation defined.void
invalidateCache
(boolean all) Clears all data caches.boolean
Returns true if this relocation table contains relocations for a relocatable binary.void
moveAddressRange
(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) Move all objects within an address range to a new location.void
programReady
(OpenMode openMode, int currentRevision, TaskMonitor monitor) Callback from program made to each manager after the program has completed initialization.void
Callback from program used to indicate all manager have been created.
-
Constructor Details
-
RelocationManager
public RelocationManager(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock, TaskMonitor monitor) throws VersionException, IOException Constructs a new relocation manager.- Parameters:
handle
- the database handleaddrMap
- the address mapopenMode
- the open mode; CREATE, UPDATE, READONLY, UPGRADElock
- the program synchronization lockmonitor
- the task monitor- Throws:
VersionException
IOException
-
-
Method Details
-
invalidateCache
public void invalidateCache(boolean all) Description copied from interface:ManagerDB
Clears all data caches.- Specified by:
invalidateCache
in interfaceManagerDB
- Parameters:
all
- if false, some managers may not need to update their cache if they can tell that its not necessary. If this flag is true, then all managers should clear their cache no matter what.
-
setProgram
Description copied from interface:ManagerDB
Callback from program used to indicate all manager have been created. When this method is invoked, all managers have been instantiated but may not be fully initialized.- Specified by:
setProgram
in interfaceManagerDB
- Parameters:
p
- the program is set when all the initializations have been completed.
-
programReady
public void programReady(OpenMode openMode, int currentRevision, TaskMonitor monitor) throws IOException, CancelledException Description copied from interface:ManagerDB
Callback from program made to each manager after the program has completed initialization. This method may be used by managers to perform additional upgrading which may have been deferred.- Specified by:
programReady
in interfaceManagerDB
- Parameters:
openMode
- the mode that the program is being opened.currentRevision
- current program revision. If openMode is UPGRADE, this value reflects the pre-upgrade value.monitor
- the task monitor to use in any upgrade operations.- Throws:
IOException
- if a database io error occurs.CancelledException
- if the user cancelled the operation via the task monitor.
-
add
public Relocation add(Address addr, Relocation.Status status, int type, long[] values, byte[] bytes, String symbolName) Description copied from interface:RelocationTable
Adds a new relocation entry when the original bytes being replaced are to be specified.- Specified by:
add
in interfaceRelocationTable
- Parameters:
addr
- the memory address where the relocation is requiredstatus
- relocation status (useRelocation.Status.UNKNOWN
if not known).type
- the type of relocation to performvalues
- relocation-specific values which may be useful in diagnosing relocation; may be null.bytes
- original memory bytes affected by relocation. A null value may be passed but this case is deprecated (seeRelocationTable.add(Address, Status, int, long[], int, String)
. If null is specified andRelocation.Status.hasBytes()
is true a default number of original bytes will be assumed and obtained from the underlying memoryFileBytes
if possible.symbolName
- the name of the symbol being relocated; may be null- Returns:
- the newly added relocation object
-
add
public Relocation add(Address addr, Relocation.Status status, int type, long[] values, int byteLength, String symbolName) Description copied from interface:RelocationTable
Adds a new relocation entry when the original bytes being replaced should be determined from the underlyingFileBytes
.- Specified by:
add
in interfaceRelocationTable
- Parameters:
addr
- the memory address where the relocation is requiredstatus
- relocation status (useRelocation.Status.UNKNOWN
if not known).type
- the type of relocation to performvalues
- relocation-specific values which may be useful in diagnosing relocation; may be null.byteLength
- the number of bytes affected by this relocation. This value is only used with a status ofRelocation.Status.UNKNOWN
,Relocation.Status.APPLIED
orRelocation.Status.APPLIED_OTHER
. Valid range is 1..8 bytes.symbolName
- the name of the symbol being relocated; may be null- Returns:
- the newly added relocation object
-
hasRelocation
Description copied from interface:RelocationTable
Determine if the specified address has a relocation defined.- Specified by:
hasRelocation
in interfaceRelocationTable
- Parameters:
addr
- memory address within program- Returns:
- true if relocation defined, otherwise false
-
getRelocations
Description copied from interface:RelocationTable
Returns the ordered list of relocations which have been defined for the specified address. In most cases there will be one or none, but in some cases multiple relocations may be applied to a single address.- Specified by:
getRelocations
in interfaceRelocationTable
- Parameters:
addr
- the address where the relocation(s) are defined- Returns:
- the ordered list of relocations which have been defined for the specified address.
-
getRelocations
Description copied from interface:RelocationTable
Returns an iterator over all defined relocations (in ascending address order) located within the program.- Specified by:
getRelocations
in interfaceRelocationTable
- Returns:
- ordered relocation iterator
-
getRelocationAddressAfter
Description copied from interface:RelocationTable
Returns the next relocation address which follows the specified address.- Specified by:
getRelocationAddressAfter
in interfaceRelocationTable
- Parameters:
addr
- starting point- Returns:
- next relocation address after addr or null if none
-
getRelocations
Description copied from interface:RelocationTable
Returns an iterator over all defined relocations (in ascending address order) located within the program over the specified address set.- Specified by:
getRelocations
in interfaceRelocationTable
- Parameters:
set
- address set- Returns:
- ordered relocation iterator
-
getSize
public int getSize()Description copied from interface:RelocationTable
Returns the number of relocation in this table.- Specified by:
getSize
in interfaceRelocationTable
- Returns:
- the number of relocation in this table
-
isRelocatable
public boolean isRelocatable()Description copied from interface:RelocationTable
Returns true if this relocation table contains relocations for a relocatable binary. Some binaries may contain relocations, but not actually be relocatable. For example, ELF executables.- Specified by:
isRelocatable
in interfaceRelocationTable
- Returns:
- true if this relocation table contains relocations for a relocatable binary
-
deleteAddressRange
Description copied from interface:ManagerDB
Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly. The specified start and end addresses must form a valid range within a singleAddressSpace
.- Specified by:
deleteAddressRange
in interfaceManagerDB
- Parameters:
startAddr
- the first address in the range.endAddr
- the last address in the range.monitor
- the task monitor to use in any upgrade operations.
-
moveAddressRange
Description copied from interface:ManagerDB
Move all objects within an address range to a new location.- Specified by:
moveAddressRange
in interfaceManagerDB
- Parameters:
fromAddr
- the first address of the range to be moved.toAddr
- the address where to the range is to be moved.length
- the number of addresses to move.monitor
- the task monitor to use in any upgrade operations.
-