Class ElfRelocationHandler
java.lang.Object
ghidra.app.util.bin.format.elf.relocation.ElfRelocationHandler
- All Implemented Interfaces:
ExtensionPoint
ElfRelocationHandler
provides the base class for processor specific
ELF relocation handlers.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
applyComponentOffsetPointer
(Program program, Address addr, long componentOffset) Apply a pointer-typedef with a specified component-offset.abstract boolean
canRelocate
(ElfHeader elf) createRelocationContext
(ElfLoadHelper loadHelper, ElfRelocationTable relocationTable, Map<ElfSymbol, Address> symbolMap) Relocation context for a specific Elf image and relocation table.int
Get the architecture-specific relative relocation type which should be applied to RELR relocations.static void
markAsError
(Program program, Address relocationAddress, long type, String symbolName, String msg, MessageLog log) Generate error log entry and bookmark at relocationAddress where import failed to be applied.static void
markAsError
(Program program, Address relocationAddress, String type, String symbolName, String msg, MessageLog log) Generate error log entry and bookmark at relocationAddress where import failed to be applied.static void
markAsUnhandled
(Program program, Address relocationAddress, long type, long symbolIndex, String symbolName, MessageLog log) Generate error log entry and bookmark at relocationAddress indicating an unhandled relocation.static void
markAsUninitializedMemory
(Program program, Address relocationAddress, long type, long symbolIndex, String symbolName, MessageLog log) Generate error log entry and bookmark at relocationAddress where import failed to transition block to initialized while processing relocation.static void
markAsUnsupportedRelr
(Program program, Address relocationAddress) Generate error log entry and bookmark at relocationAddress indicating an unsupported RELR relocation.static void
markAsWarning
(Program program, Address relocationAddress, String type, String symbolName, long symbolIndex, String msg, MessageLog log) Generate warning log entry and bookmark at relocationAddress where import issue occurred.static void
markAsWarning
(Program program, Address relocationAddress, String type, String msg, MessageLog log) Generate warning log entry and bookmark at relocationAddress where import issue occurred.abstract void
relocate
(ElfRelocationContext elfRelocationContext, ElfRelocation relocation, Address relocationAddress) Perform relocation fixupstatic void
warnExternalOffsetRelocation
(Program program, Address relocationAddress, Address symbolAddr, String symbolName, long adjustment, MessageLog log) Determine if symbolAddr is contained within the EXTERNAL block with a non-zero adjustment.
-
Constructor Details
-
ElfRelocationHandler
public ElfRelocationHandler()
-
-
Method Details
-
canRelocate
-
getRelrRelocationType
public int getRelrRelocationType()Get the architecture-specific relative relocation type which should be applied to RELR relocations. The default implementation returns 0 which indicates RELR is unsupported.- Returns:
- RELR relocation type
-
createRelocationContext
public ElfRelocationContext createRelocationContext(ElfLoadHelper loadHelper, ElfRelocationTable relocationTable, Map<ElfSymbol, Address> symbolMap) Relocation context for a specific Elf image and relocation table. The relocation context is used to process relocations and manage any data required to process relocations.- Parameters:
loadHelper
- Elf load helperrelocationTable
- Elf relocation tablesymbolMap
- Elf symbol placement map- Returns:
- relocation context or null if unsupported
-
relocate
public abstract void relocate(ElfRelocationContext elfRelocationContext, ElfRelocation relocation, Address relocationAddress) throws MemoryAccessException, NotFoundException Perform relocation fixup- Parameters:
elfRelocationContext
- relocation contextrelocation
- ELF relocationrelocationAddress
- relocation target address (fixup location)- Throws:
MemoryAccessException
- memory access failureNotFoundException
- required relocation data not found
-
applyComponentOffsetPointer
Apply a pointer-typedef with a specified component-offset.- Parameters:
program
- programaddr
- address where data should be appliedcomponentOffset
- component offset
-
warnExternalOffsetRelocation
public static void warnExternalOffsetRelocation(Program program, Address relocationAddress, Address symbolAddr, String symbolName, long adjustment, MessageLog log) Determine if symbolAddr is contained within the EXTERNAL block with a non-zero adjustment. If so, relocationAddress will be marked with aEXTERNAL Data Elf Relocation with pointer-offset
warning bookmark. NOTE: This method should only be invoked when the symbol offset will be adjusted with a non-zero value (i.e., addend).- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarked if EXTERNAL block relocationsymbolAddr
- symbol address correspondng to relocation (may be null)symbolName
- symbol name (may not be null if symbolAddr is not null)adjustment
- relocation symbol offset adjustment/addendlog
- import log
-
markAsUnhandled
public static void markAsUnhandled(Program program, Address relocationAddress, long type, long symbolIndex, String symbolName, MessageLog log) Generate error log entry and bookmark at relocationAddress indicating an unhandled relocation.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedtype
- relocation typesymbolIndex
- associated symbol index within symbol tablesymbolName
- associated symbol namelog
- import log
-
markAsUnsupportedRelr
Generate error log entry and bookmark at relocationAddress indicating an unsupported RELR relocation.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarked
-
markAsUninitializedMemory
public static void markAsUninitializedMemory(Program program, Address relocationAddress, long type, long symbolIndex, String symbolName, MessageLog log) Generate error log entry and bookmark at relocationAddress where import failed to transition block to initialized while processing relocation.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedtype
- relocation typesymbolIndex
- associated symbol index within symbol tablesymbolName
- associated symbol namelog
- import log
-
markAsError
public static void markAsError(Program program, Address relocationAddress, long type, String symbolName, String msg, MessageLog log) Generate error log entry and bookmark at relocationAddress where import failed to be applied.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedtype
- relocation typesymbolName
- associated symbol namemsg
- error messgelog
- import log
-
markAsError
public static void markAsError(Program program, Address relocationAddress, String type, String symbolName, String msg, MessageLog log) Generate error log entry and bookmark at relocationAddress where import failed to be applied.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedtype
- relocation typesymbolName
- associated symbol namemsg
- additional error messagelog
- import log
-
markAsWarning
public static void markAsWarning(Program program, Address relocationAddress, String type, String msg, MessageLog log) Generate warning log entry and bookmark at relocationAddress where import issue occurred.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedtype
- relocation typemsg
- message associated with warninglog
- import log
-
markAsWarning
public static void markAsWarning(Program program, Address relocationAddress, String type, String symbolName, long symbolIndex, String msg, MessageLog log) Generate warning log entry and bookmark at relocationAddress where import issue occurred.- Parameters:
program
- programrelocationAddress
- relocation address to be bookmarkedtype
- relocation typesymbolName
- symbol namesymbolIndex
- symbol indexmsg
- message associated with warninglog
- import log
-