Class ElfGotRelocationContext<H extends ElfRelocationHandler>

java.lang.Object
ghidra.app.util.bin.format.elf.relocation.ElfRelocationContext<H>
ghidra.app.util.bin.format.elf.relocation.ElfGotRelocationContext<H>
Type Parameters:
H - ELF relocation handler class

public abstract class ElfGotRelocationContext<H extends ElfRelocationHandler> extends ElfRelocationContext<H>
ElfGotRelocationContext provides ability to generate a Global Offset Table (GOT) to facilitate GOT related relocations encountered within object modules.

NOTE: This should be considered experimental and has its limitations with GOT size and placement which could behave improperly for large binaries.

  • Method Details

    • getSymbolValue

      public long getSymbolValue(ElfSymbol symbol)
      Description copied from class: ElfRelocationContext
      Get the adjusted symbol value based upon its placement within the program. This value may differ from symbol.getValue() and will reflect the addressable unit/word offset of it program address.
      Overrides:
      getSymbolValue in class ElfRelocationContext<H extends ElfRelocationHandler>
      Parameters:
      symbol - Elf symbol
      Returns:
      adjusted Elf symbol value or 0 if symbol mapping not found
    • getGOTValue

      public long getGOTValue() throws NotFoundException
      Description copied from class: ElfRelocationContext
      Returns the appropriate .got section using the DT_PLTGOT value defined in the .dynamic section. If no such dynamic value defined, the symbol offset for _GLOBAL_OFFSET_TABLE_ will be used, otherwise a NotFoundException will be thrown.
      Overrides:
      getGOTValue in class ElfRelocationContext<H extends ElfRelocationHandler>
      Returns:
      the .got section address offset
      Throws:
      NotFoundException - if the dynamic DT_PLTGOT not defined and _GLOBAL_OFFSET_TABLE_ symbol not defined
    • requiresGotEntry

      protected abstract boolean requiresGotEntry(ElfRelocation r)
      Returns true if the specified relocation type requires a GOT entry..

      NOTE: It is very important that all relocations types which invoke getGotEntryAddress(ElfSymbol) result in this method returning true. Failure to do so could result in an under allocation of the GOT memory block.

      Parameters:
      r - relocation type
      Returns:
      true if the specified relocation type requires a GOT entry.
    • getGotEntryAddress

      public Address getGotEntryAddress(ElfSymbol elfSymbol)
      Get or allocate a GOT entry for the specified symbolValue. NOTE: This is restricted to object modules only which do not of a GOT.
      Parameters:
      elfSymbol - ELF symbol
      Returns:
      GOT entry address or null if unable to allocate
    • dispose

      public void dispose()
      Description copied from class: ElfRelocationContext
      Dispose relocation context when processing of corresponding relocation table is complete. Instance should be disposed to allow all program changes to be flushed prior to processing a subsequent relocation table.
      Overrides:
      dispose in class ElfRelocationContext<H extends ElfRelocationHandler>