Class ElfRelocationTable

java.lang.Object
ghidra.app.util.bin.format.elf.ElfRelocationTable
All Implemented Interfaces:
ElfFileSection, StructConverter

public class ElfRelocationTable extends Object implements ElfFileSection
A container class to hold ELF relocations.
  • Constructor Details

    • ElfRelocationTable

      public ElfRelocationTable(BinaryReader reader, ElfHeader header, ElfSectionHeader relocTableSection, long fileOffset, long addrOffset, long length, long entrySize, boolean addendTypeReloc, ElfSymbolTable symbolTable, ElfSectionHeader sectionToBeRelocated, ElfRelocationTable.TableFormat format) throws IOException
      Construct an Elf Relocation Table
      Parameters:
      reader - byte provider reader (reader is not retained and position is unaffected)
      header - elf header
      relocTableSection - relocation table section header or null if associated with a dynamic table entry
      fileOffset - relocation table file offset
      addrOffset - memory address of relocation table (should already be adjusted for prelink)
      length - length of relocation table in bytes
      entrySize - size of each relocation entry in bytes
      addendTypeReloc - true if addend type relocation table
      symbolTable - associated symbol table (may be null if not applicable)
      sectionToBeRelocated - or null for dynamic relocation table
      format - table format
      Throws:
      IOException - if an IO or parse error occurs
  • Method Details

    • isMissingRequiredSymbolTable

      public boolean isMissingRequiredSymbolTable()
      Determine if required symbol table is missing. If so, relocations may not be processed.
      Returns:
      true if required symbol table is missing, else false
    • hasAddendRelocations

      public boolean hasAddendRelocations()
      Returns:
      true if has addend relocations, otherwise addend extraction from relocation target may be required
    • getSectionToBeRelocated

      public ElfSectionHeader getSectionToBeRelocated()
      Returns the section where the relocations will be applied. For example, this method will return ".plt" for ".rel.plt"
      Returns:
      the section where the relocations will be applied or null for dynamic relocation table not associated with a section.
    • getRelocations

      public ElfRelocation[] getRelocations()
      Returns the relocations defined in this table.
      Returns:
      the relocations defined in this table
    • getRelocationCount

      public int getRelocationCount()
      Get number of relocation entries contained within this table
      Returns:
      relocation entry count
    • getAssociatedSymbolTable

      public ElfSymbolTable getAssociatedSymbolTable()
      Returns the associated symbol table. A relocation object contains a symbol index. This index is into this symbol table.
      Returns:
      the associated symbol table or null if not applicable to this reloc table
    • getLength

      public long getLength()
      Description copied from interface: ElfFileSection
      Length of file section in bytes
      Specified by:
      getLength in interface ElfFileSection
      Returns:
      length of file section in bytes
    • getAddressOffset

      public long getAddressOffset()
      Description copied from interface: ElfFileSection
      Preferred memory address offset where data should be loaded. The returned offset will already have the prelink adjustment applied, although will not reflect any change in the image base.
      Specified by:
      getAddressOffset in interface ElfFileSection
      Returns:
      default memory address offset where data should be loaded
    • getTableSectionHeader

      public ElfSectionHeader getTableSectionHeader()
      Get section header which corresponds to this table, or null if only associated with a dynamic table entry
      Returns:
      relocation table section header or null
    • isRelrTable

      public boolean isRelrTable()
    • getFileOffset

      public long getFileOffset()
      Description copied from interface: ElfFileSection
      Offset within file where section bytes are specified
      Specified by:
      getFileOffset in interface ElfFileSection
      Returns:
      offset within file where section bytes are specified
    • getEntrySize

      public int getEntrySize()
      Description copied from interface: ElfFileSection
      Size of each structured entry in bytes
      Specified by:
      getEntrySize in interface ElfFileSection
      Returns:
      entry size or -1 if variable
    • toDataType

      public DataType toDataType() throws IOException
      Description copied from interface: StructConverter
      Returns a structure datatype representing the contents of the implementor of this interface.

      For example, given:

       class A {
           int foo;
           double bar;
       }
       

      The return value should be a structure data type with two data type components; an INT and a DOUBLE. The structure should contain field names and, if possible, field comments.

      Specified by:
      toDataType in interface StructConverter
      Returns:
      returns a structure datatype representing the implementor of this interface
      Throws:
      IOException
      See Also: