Class AbstractElfRelocationHandler<T extends ElfRelocationType,C extends ElfRelocationContext<?>>
java.lang.Object
ghidra.app.util.bin.format.elf.relocation.ElfRelocationHandler
ghidra.app.util.bin.format.elf.relocation.AbstractElfRelocationHandler<T,C>
- Type Parameters:
T
- ELF relocation type enum classC
- ELF relocation context class
- All Implemented Interfaces:
ExtensionPoint
public abstract class AbstractElfRelocationHandler<T extends ElfRelocationType,C extends ElfRelocationContext<?>>
extends ElfRelocationHandler
ElfRelocationHandler
provides the base class for processor specific
ELF relocation handlers. Implementations may only specify a public default constructor
as they will be identified and instatiated by the ClassSearcher
. As such their
name must end with "ElfRelocationHandler" (e.g., MyProc_ElfRelocationHandler).-
Field Summary
Fields inherited from class ghidra.app.util.bin.format.elf.relocation.ElfRelocationHandler
GOT_BLOCK_NAME
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractElfRelocationHandler
(Class<T> relocationEnumClass) Abstract constructor for anAbstractElfRelocationHandler
. -
Method Summary
Modifier and TypeMethodDescriptiongetRelocationType
(int typeId) Get the relocation type enum object which corresponds to the specified type ID value.protected boolean
handleUnresolvedSymbol
(ElfRelocationContext<?> elfRelocationContext, ElfRelocation relocation, Address relocationAddress) Check for unresolved relocation symbol.protected void
markAsError
(Program program, Address relocationAddress, T relocationType, String symbolName, int symbolIndex, String msg, MessageLog log) Generate relocation error log entry and bookmark at relocationAddress.protected void
markAsUndefined
(Program program, Address relocationAddress, int typeId, String symbolName, int symbolIndex, MessageLog log) Generate error log entry and bookmark at relocationAddress indicating an unhandled relocation.protected void
markAsUnhandled
(Program program, Address relocationAddress, T relocationType, int symbolIndex, String symbolName, MessageLog log) Generate error log entry and bookmark at relocationAddress indicating an unhandled relocation.protected void
markAsUnsupportedCopy
(Program program, Address relocationAddress, T relocationType, String symbolName, int symbolIndex, long symbolSize, MessageLog log) Generate error log entry and bookmark at relocationAddress indicating an unspportable COPY relocation.protected void
markAsWarning
(Program program, Address relocationAddress, T relocationType, String symbolName, int symbolIndex, String msg, MessageLog log) Generate relocation warning log entry and bookmark at relocationAddress.protected abstract RelocationResult
relocate
(C elfRelocationContext, ElfRelocation relocation, T relocationType, Address relocationAddress, ElfSymbol elfSymbol, Address symbolAddr, long symbolValue, String symbolName) Perform relocation fixup.protected final RelocationResult
relocate
(ElfRelocationContext elfRelocationContext, ElfRelocation relocation, Address relocationAddress) Perform relocation fixup.Methods inherited from class ghidra.app.util.bin.format.elf.relocation.ElfRelocationHandler
applyComponentOffsetPointer, bookmarkNoHandlerError, bookmarkUnsupportedRelr, canRelocate, createRelocationContext, getRelrRelocationType, markAsError, markAsError, markAsError, markAsError, markAsUnhandled, markAsUnhandled, markAsWarning, markAsWarning, markAsWarning, warnExternalOffsetRelocation
-
Constructor Details
-
AbstractElfRelocationHandler
Abstract constructor for anAbstractElfRelocationHandler
.- Parameters:
relocationEnumClass
- specifies theElfRelocationType
enum which defines all supported relocation types for this relocation handler.
-
-
Method Details
-
getRelocationType
Get the relocation type enum object which corresponds to the specified type ID value.- Parameters:
typeId
- relocation type ID value- Returns:
- relocation type enum value or null if type not found or this handler was not
constructed with a
ElfRelocationType
enum class. The returned value may be safely cast to the relocation enum class specified during handler construction.
-
relocate
protected final RelocationResult relocate(ElfRelocationContext elfRelocationContext, ElfRelocation relocation, Address relocationAddress) throws MemoryAccessException Perform relocation fixup.- Specified by:
relocate
in classElfRelocationHandler
- Parameters:
elfRelocationContext
- relocation contextrelocation
- ELF relocationrelocationAddress
- relocation target address (fixup location)- Returns:
- applied relocation result (conveys status and applied byte-length)
- Throws:
MemoryAccessException
- memory access failure
-
relocate
protected abstract RelocationResult relocate(C elfRelocationContext, ElfRelocation relocation, T relocationType, Address relocationAddress, ElfSymbol elfSymbol, Address symbolAddr, long symbolValue, String symbolName) throws MemoryAccessException Perform relocation fixup.
NOTE: This method will not be invoked if elfSymbol is null andElfRelocationContext.processRelocation(ElfRelocation, Address)
will report relocation failure.
NOTE: This method will not be invoked fortype
== 0/NONE and will be marked as skipped.- Parameters:
elfRelocationContext
- relocation contextrelocation
- ELF relocationrelocationType
- ELF relocation type enum valuerelocationAddress
- relocation target address (fixup location)elfSymbol
- relocation symbolsymbolAddr
- elfSymbol memory address (may be null)symbolValue
- unadjusted elfSymbol value (0 if no symbol)symbolName
- elfSymbol name (may be null)- Returns:
- applied relocation result (conveys status and applied byte-length)
- Throws:
MemoryAccessException
- memory access failure
-
handleUnresolvedSymbol
protected boolean handleUnresolvedSymbol(ElfRelocationContext<?> elfRelocationContext, ElfRelocation relocation, Address relocationAddress) Check for unresolved relocation symbol. If symbol has not been resolved the associated symbol address will be null and the symbol value invalid.- Parameters:
elfRelocationContext
- relocation contextrelocation
- ELF relocationrelocationAddress
- relocation target address (fixup location)- Returns:
- true if symbol was not resolved else false if symbol was resolved
-
markAsUnsupportedCopy
protected void markAsUnsupportedCopy(Program program, Address relocationAddress, T relocationType, String symbolName, int symbolIndex, long symbolSize, MessageLog log) Generate error log entry and bookmark at relocationAddress indicating an unspportable COPY relocation. A warning is produced for this COPY relocation failure.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedrelocationType
- relocation typesymbolName
- associated symbol namesymbolIndex
- associated symbol index within symbol tablesymbolSize
- number of bytes associated with symbol that failed to be copiedlog
- import log
-
markAsUndefined
protected void markAsUndefined(Program program, Address relocationAddress, int typeId, String symbolName, int symbolIndex, MessageLog log) Generate error log entry and bookmark at relocationAddress indicating an unhandled relocation.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedtypeId
- relocation type ID valuesymbolName
- associated symbol namesymbolIndex
- associated symbol index within symbol tablelog
- import log
-
markAsUnhandled
protected void markAsUnhandled(Program program, Address relocationAddress, T relocationType, int symbolIndex, String symbolName, MessageLog log) Generate error log entry and bookmark at relocationAddress indicating an unhandled relocation.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedrelocationType
- relocation typesymbolIndex
- associated symbol index within symbol tablesymbolName
- associated symbol namelog
- import log
-
markAsWarning
protected void markAsWarning(Program program, Address relocationAddress, T relocationType, String symbolName, int symbolIndex, String msg, MessageLog log) Generate relocation warning log entry and bookmark at relocationAddress.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedrelocationType
- relocation typesymbolName
- symbol namesymbolIndex
- symbol index (-1 to ignore)msg
- message associated with warninglog
- import log
-
markAsError
protected void markAsError(Program program, Address relocationAddress, T relocationType, String symbolName, int symbolIndex, String msg, MessageLog log) Generate relocation error log entry and bookmark at relocationAddress.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedrelocationType
- relocation typesymbolName
- associated symbol namesymbolIndex
- symbol index (-1 to ignore)msg
- additional error messagelog
- import log
-