Class ElfRelocationContext
- java.lang.Object
-
- ghidra.app.util.bin.format.elf.relocation.ElfRelocationContext
-
public class ElfRelocationContext extends java.lang.Object
ElfRelocationContext
provides a relocation handler context related to the processing of entries contained within a specific relocation table.
-
-
Field Summary
Fields Modifier and Type Field Description protected ElfRelocationHandler
handler
protected ElfLoadHelper
loadHelper
protected Program
program
protected ElfRelocationTable
relocationTable
protected java.util.Map<ElfSymbol,Address>
symbolMap
protected ElfSymbol[]
symbols
-
Constructor Summary
Constructors Modifier Constructor Description protected
ElfRelocationContext(ElfRelocationHandler handler, ElfLoadHelper loadHelper, ElfRelocationTable relocationTable, java.util.Map<ElfSymbol,Address> symbolMap)
Relocation context for a specific Elf image and relocation table
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Dispose relocation context when processing of corresponding relocation table is complete.boolean
extractAddend()
Determine if addend data must be extractedElfHeader
getElfHeader()
long
getGOTValue()
Returns the appropriate .got section using the DT_PLTGOT value defined in the .dynamic section.long
getImageBaseWordAdjustmentOffset()
Get image base addressable word adjustment value to be applied to any pre-linked address values such as those contained with the dynamic table.ElfLoadAdapter
getLoadAdapter()
ElfLoadHelper
getLoadHelper()
MessageLog
getLog()
Program
getProgram()
Address
getRelocationAddress(Address baseAddress, long relocOffset)
Get relocation addressstatic ElfRelocationContext
getRelocationContext(ElfLoadHelper loadHelper, ElfRelocationTable relocationTable, java.util.Map<ElfSymbol,Address> symbolMap)
Get a relocation context for a specfic Elf image and relocation tablelong
getRelrRelocationType()
Get the RELR relocation type associated with the underlying relocation handler.ElfSymbol
getSymbol(int symbolIndex)
Get the Elf symbol which corresponds to the specified index.Address
getSymbolAddress(ElfSymbol symbol)
Get the program address at which the specified Elf symbol was placed.long
getSymbolValue(ElfSymbol symbol)
Get the adjusted symbol value based upon its placement within the program.boolean
hasRelocationHandler()
boolean
isBigEndian()
void
processRelocation(ElfRelocation relocation, Address relocationAddress)
Process a relocation from the relocation table which corresponds to this context.
-
-
-
Field Detail
-
handler
protected final ElfRelocationHandler handler
-
loadHelper
protected final ElfLoadHelper loadHelper
-
relocationTable
protected final ElfRelocationTable relocationTable
-
symbols
protected final ElfSymbol[] symbols
-
program
protected final Program program
-
-
Constructor Detail
-
ElfRelocationContext
protected ElfRelocationContext(ElfRelocationHandler handler, ElfLoadHelper loadHelper, ElfRelocationTable relocationTable, java.util.Map<ElfSymbol,Address> symbolMap)
Relocation context for a specific Elf image and relocation table- Parameters:
handler
- relocation handler or null if not availableloadHelper
- the elf load helperrelocationTable
- Elf relocation tablesymbolMap
- Elf symbol placement map
-
-
Method Detail
-
processRelocation
public final void processRelocation(ElfRelocation relocation, Address relocationAddress)
Process a relocation from the relocation table which corresponds to this context. All relocation entries must be processed in the order they appear within the table.- Parameters:
relocation
-relocationAddress
-
-
getRelrRelocationType
public long getRelrRelocationType()
Get the RELR relocation type associated with the underlying relocation handler.- Returns:
- RELR relocation type or 0 if not supported
-
getRelocationContext
public static ElfRelocationContext getRelocationContext(ElfLoadHelper loadHelper, ElfRelocationTable relocationTable, java.util.Map<ElfSymbol,Address> symbolMap)
Get a relocation context for a specfic Elf image and relocation table- Parameters:
loadHelper
- Elf load helperrelocationTable
- Elf relocation tablesymbolMap
- Elf symbol placement map- Returns:
- relocation context or null
-
hasRelocationHandler
public final boolean hasRelocationHandler()
- Returns:
- true if a relocation handler was found
-
getImageBaseWordAdjustmentOffset
public long getImageBaseWordAdjustmentOffset()
Get image base addressable word adjustment value to be applied to any pre-linked address values such as those contained with the dynamic table. (Applies to default address space only)- Returns:
- image base adjustment value
-
extractAddend
public boolean extractAddend()
Determine if addend data must be extracted- Returns:
- true if relocation does not provide addend data and it must be extracted from relocation target if appropriate
-
getProgram
public final Program getProgram()
-
isBigEndian
public final boolean isBigEndian()
-
getElfHeader
public final ElfHeader getElfHeader()
-
getLoadHelper
public final ElfLoadHelper getLoadHelper()
-
getLoadAdapter
public final ElfLoadAdapter getLoadAdapter()
-
getLog
public final MessageLog getLog()
-
getSymbol
public final ElfSymbol getSymbol(int symbolIndex)
Get the Elf symbol which corresponds to the specified index. Each relocation table corresponds to a specific symbol table to which the specified symbolIndex will be applied.- Parameters:
symbolIndex
-- Returns:
- Elf symbol which corresponds to symbol index
-
getSymbolAddress
public Address getSymbolAddress(ElfSymbol symbol)
Get the program address at which the specified Elf symbol was placed.- Parameters:
symbol
- Elf symbol- Returns:
- program address
-
getSymbolValue
public long getSymbolValue(ElfSymbol symbol)
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.- Parameters:
symbol
- Elf symbol- Returns:
- adjusted Elf symbol value or 0 if symbol mapping not found
-
getGOTValue
public long getGOTValue() throws NotFoundException
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.- Returns:
- the .got section address offset
- Throws:
NotFoundException
- if the dynamic DT_PLTGOT not defined and _GLOBAL_OFFSET_TABLE_ symbol not defined
-
dispose
public void dispose()
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.
-
-