Class MachoRelocationHandler
java.lang.Object
ghidra.app.util.bin.format.macho.relocation.MachoRelocationHandler
- All Implemented Interfaces:
ExtensionPoint
An abstract class used to perform Mach-O relocations. Classes should extend this class to
provide relocations in a machine/processor specific way.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
canRelocate
(MachHeader header) Checks to see whether or not an instance of this Mach-O relocation handler can handle relocating the Mach-O defined by the provided file headerabstract boolean
isPairedRelocation
(RelocationInfo relocation) Checks to see if the given relocation is a "paired" relocation.static long
read
(MachoRelocation relocation) Reads bytes at the given address.abstract RelocationResult
relocate
(MachoRelocation relocation) Performs a relocationstatic int
write
(MachoRelocation relocation, long value) Writes bytes at the given address.
-
Constructor Details
-
MachoRelocationHandler
public MachoRelocationHandler()
-
-
Method Details
-
canRelocate
Checks to see whether or not an instance of this Mach-O relocation handler can handle relocating the Mach-O defined by the provided file header- Parameters:
header
- The header associated with the Mach-O to relocate- Returns:
- True if this relocation handler can do the relocation; otherwise, false
-
isPairedRelocation
Checks to see if the given relocation is a "paired" relocation. A paired relocation has a certain expectation from the relocation that follows it.- Parameters:
relocation
- The relocation to check- Returns:
- True if the given relocation is a "paired" relocation; otherwise, false
-
relocate
public abstract RelocationResult relocate(MachoRelocation relocation) throws MemoryAccessException, RelocationException Performs a relocation- Parameters:
relocation
- The relocation to perform- Returns:
- applied relocation result
- Throws:
MemoryAccessException
- If there is a problem accessing memory during the relocationRelocationException
- if supported relocation encountered an error during processing. This exception should be thrown in place of returningRelocationResult.FAILURE
or a status ofRelocation.Status.FAILURE
which will facilitate a failure reason viaThrowable.getMessage()
.
-
read
Reads bytes at the given address. The size of the read is determined by the length of the relocation info.- Parameters:
relocation
- The relocation to read- Returns:
- The read bytes
- Throws:
MemoryAccessException
- If there is a problem accessing memory during the read
-
write
Writes bytes at the given address. The size of the write is determined by the length of the relocation info.- Parameters:
relocation
- The relocation to writevalue
- The value to write- Returns:
- number of bytes written
- Throws:
MemoryAccessException
- If there is a problem accessing memory during the write
-