Class ElfGotRelocationContext<H extends ElfRelocationHandler>
java.lang.Object
ghidra.app.util.bin.format.elf.relocation.ElfRelocationContext<H>
ghidra.app.util.bin.format.elf.relocation.ElfGotRelocationContext<H>
- Type Parameters:
H- ELF relocation handler class
public abstract class ElfGotRelocationContext<H extends ElfRelocationHandler>
extends ElfRelocationContext<H>
ElfGotRelocationContext provides ability to generate a
Global Offset Table (GOT) to facilitate GOT related relocations encountered within
object modules.
NOTE: This should be considered experimental and has its limitations with GOT size and placement which could behave improperly for large binaries.
-
Field Summary
Fields inherited from class ghidra.app.util.bin.format.elf.relocation.ElfRelocationContext
handler, loadHelper, program, relocationTable, symbolMap, symbolTable -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Dispose relocation context when processing of corresponding relocation table is complete.getGotEntryAddress(ElfSymbol elfSymbol) Get or allocate a GOT entry for the specified symbolValue.longReturns the appropriate .got section using the DT_PLTGOT value defined in the .dynamic section.longgetSymbolValue(ElfSymbol symbol) Get the adjusted symbol value based upon its placement within the program.protected abstract booleanReturns true if the specified relocation type requires a GOT entry..Methods inherited from class ghidra.app.util.bin.format.elf.relocation.ElfRelocationContext
endRelocationTableProcessing, extractAddend, getElfHeader, getImageBaseWordAdjustmentOffset, getLoadAdapter, getLoadHelper, getLog, getProgram, getRelocationAddress, getRelocationContext, getRelrRelocationType, getSymbol, getSymbolAddress, getSymbolName, hasRelocationHandler, isBigEndian, markRelocationError, processRelocation, processRelocation, startRelocationTableProcessing
-
Method Details
-
getSymbolValue
Description copied from class:ElfRelocationContextGet 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.- Overrides:
getSymbolValuein classElfRelocationContext<H extends ElfRelocationHandler>- Parameters:
symbol- Elf symbol- Returns:
- adjusted Elf symbol value or 0 if symbol mapping not found
-
getGOTValue
Description copied from class:ElfRelocationContextReturns 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.- Overrides:
getGOTValuein classElfRelocationContext<H extends ElfRelocationHandler>- Returns:
- the .got section address offset
- Throws:
NotFoundException- if the dynamic DT_PLTGOT not defined and _GLOBAL_OFFSET_TABLE_ symbol not defined
-
requiresGotEntry
Returns true if the specified relocation type requires a GOT entry..NOTE: It is very important that all relocations types which invoke
getGotEntryAddress(ElfSymbol)result in this method returning true. Failure to do so could result in an under allocation of the GOT memory block.- Parameters:
r- relocation type- Returns:
- true if the specified relocation type requires a GOT entry.
-
getGotEntryAddress
Get or allocate a GOT entry for the specified symbolValue. NOTE: This is restricted to object modules only which do not of a GOT.- Parameters:
elfSymbol- ELF symbol- Returns:
- GOT entry address or null if unable to allocate
-
dispose
public void dispose()Description copied from class:ElfRelocationContextDispose 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.- Overrides:
disposein classElfRelocationContext<H extends ElfRelocationHandler>
-