Package ghidra.app.util.bin.format.elf
Class ElfRelocationTable
java.lang.Object
ghidra.app.util.bin.format.elf.ElfRelocationTable
- All Implemented Interfaces:
ElfFileSection
,StructConverter
A container class to hold ELF relocations.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionElfRelocationTable
(BinaryReader reader, ElfHeader header, ElfSectionHeader relocTableSection, long fileOffset, long addrOffset, long length, long entrySize, boolean addendTypeReloc, ElfSymbolTable symbolTable, ElfSectionHeader sectionToBeRelocated, ElfRelocationTable.TableFormat format) Construct an Elf Relocation Table -
Method Summary
Modifier and TypeMethodDescriptionlong
Preferred memory address offset where data should be loaded.Returns the associated symbol table.int
Size of each structured entry in byteslong
Offset within file where section bytes are specifiedlong
Length of file section in bytesint
Get number of relocation entries contained within this tableReturns the relocations defined in this table.Returns the section where the relocations will be applied.Get section header which corresponds to this table, or null if only associated with a dynamic table entryboolean
boolean
Determine if required symbol table is missing.boolean
Returns a structure datatype representing the contents of the implementor of this interface.
-
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 headerrelocTableSection
- relocation table section header or null if associated with a dynamic table entryfileOffset
- relocation table file offsetaddrOffset
- memory address of relocation table (should already be adjusted for prelink)length
- length of relocation table in bytesentrySize
- size of each relocation entry in bytesaddendTypeReloc
- true if addend type relocation tablesymbolTable
- associated symbol table (may be null if not applicable)sectionToBeRelocated
- or null for dynamic relocation tableformat
- 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
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
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
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 interfaceElfFileSection
- 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 interfaceElfFileSection
- Returns:
- default memory address offset where data should be loaded
-
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 interfaceElfFileSection
- 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 interfaceElfFileSection
- Returns:
- entry size or -1 if variable
-
toDataType
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 interfaceStructConverter
- Returns:
- returns a structure datatype representing the implementor of this interface
- Throws:
IOException
- if an IO-related error occurs- See Also:
-