Class MachoRelocationHandler

java.lang.Object
ghidra.app.util.bin.format.macho.relocation.MachoRelocationHandler
All Implemented Interfaces:
ExtensionPoint

public abstract class MachoRelocationHandler extends Object implements 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 Details

    • MachoRelocationHandler

      public MachoRelocationHandler()
  • Method Details

    • canRelocate

      public abstract 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 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

      public abstract boolean isPairedRelocation(RelocationInfo relocation)
      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 relocation
      RelocationException - if supported relocation encountered an error during processing. This exception should be thrown in place of returning RelocationResult.FAILURE or a status of Relocation.Status.FAILURE which will facilitate a failure reason via Throwable.getMessage().
    • read

      public static long read(MachoRelocation relocation) throws MemoryAccessException
      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

      public static int write(MachoRelocation relocation, long value) throws MemoryAccessException
      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 write
      value - The value to write
      Returns:
      number of bytes written
      Throws:
      MemoryAccessException - If there is a problem accessing memory during the write