Class CoffRelocationContext

java.lang.Object
ghidra.app.util.bin.format.coff.relocation.CoffRelocationContext

public class CoffRelocationContext extends Object
CoffRelocationContext provide COFF relocation context data to be used by CoffRelocationHandler during processing of relocations.
  • Constructor Details

    • CoffRelocationContext

      public CoffRelocationContext(Program program, CoffFileHeader header, Map<CoffSymbol,Symbol> symbolsMap)
      Construct COFF relocation context
      Parameters:
      program - program to which relocations are applied
      header - COFF file header
      symbolsMap - symbol lookup map
  • Method Details

    • resetContext

      public void resetContext(CoffSectionHeader coffSection)
      Reset context at start of COFF section relocation processing
      Parameters:
      coffSection - COFF section
    • getProgram

      public Program getProgram()
      Get program to which relocations are being applied
      Returns:
      program
    • getSection

      public CoffSectionHeader getSection()
      Get COFF section to which relocations are being applied
      Returns:
      COFF section
    • getSymbol

      public Symbol getSymbol(CoffRelocation relocation) throws RelocationException
      Get symbol required to process a relocation. Method should only be invoked when a symbol is required since some relocations may not require a symbol.
      Parameters:
      relocation - relocation whose related symbol should be returned
      Returns:
      relocation symbol
      Throws:
      RelocationException - if symbol not found
    • getSymbolAddress

      public Address getSymbolAddress(CoffRelocation relocation) throws RelocationException
      Get address of symbol required to process a relocation. Method should only be invoked when a symbol is required since some relocations may not require a symbol.
      Parameters:
      relocation - relocation whose related symbol should be returned
      Returns:
      relocation symbol
      Throws:
      RelocationException - if symbol not found
    • computeContextValueIfAbsent

      public Object computeContextValueIfAbsent(String key, Function<String,Object> mappingFunction)
      Get and optionally compute context value for specified key
      Parameters:
      key - extension-specific context key
      mappingFunction - function used to compute value if absent
      Returns:
      context value
    • putContextValue

      public void putContextValue(String key, Object value)
      Store context value for specified key
      Parameters:
      key - extension-specific context key
      value - context value
    • getContextValue

      public Object getContextValue(String key)
      Get context value for specified key
      Parameters:
      key - extension-specific key
      Returns:
      context value or null if absent