Class RelocationState
- java.lang.Object
-
- ghidra.app.util.bin.format.pef.RelocationState
-
public class RelocationState extends java.lang.ObjectThis class maintains the running state while applying relocations.relocAddressHolds an address within the section where the relocations are to be performed. The initial value is the base address of the section to be relocated.importIndexHolds a symbol index, which is used to access an imported symbol's address. This address can then be used for relocations. The initial value is 0.sectionCHolds the memory address of an instantiated section within the PEF container, this variable is used by relocation instructions that relocate section addresses. The initial value is the memory address of section 0 (if that section is present and instantiated), otherwise it is 0.sectionDHolds the memory address of an instantiated section within the PEF container, this variable is used by relocation instructions that relocate section addresses. The initial value is the memory address of section 1 (if that section is present and instantiated), otherwise it is 0.
-
-
Constructor Summary
Constructors Constructor Description RelocationState(ContainerHeader header, LoaderRelocationHeader relocationHeader, Program program, ImportStateCache importState)Constructs a new relocation state
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()voidfixupMemory(Address address, Address fixupAddress, MessageLog log)Adds the fixup address to the contents stored at address, then creates a pointer at address.intgetImportIndex()Returns the current import index.AddressgetRelocationAddress()Returns the current relocation address.AddressgetSectionC()Returns the current sectionC address.AddressgetSectionD()Returns the current sectionD address.AddressgetSectionToBeRelocated()Returns the base address of the section to be relocated.voidincrementImportIndex()Increments the import index by one.voidincrementRelocationAddress(int addend)Increments the relocation address by the given addendvoidrelocateMemoryAt(Address address, int addend, MessageLog log)Increments the integer in memory at the specified addressvoidsetImportIndex(int importIndex)Sets the import index.voidsetRelocationAddress(Address relocationAddress)Sets the relocation address.voidsetSectionC(Address sectionC)Set the sectionC variable to given address.voidsetSectionD(Address sectionD)Set the sectionD variable to given address.
-
-
-
Constructor Detail
-
RelocationState
public RelocationState(ContainerHeader header, LoaderRelocationHeader relocationHeader, Program program, ImportStateCache importState)
Constructs a new relocation state- Parameters:
header- the PEF container headerrelocationHeader- the specific relocation header for this stateprogram- the program being relocatedimportState- the current import state
-
-
Method Detail
-
dispose
public void dispose()
-
incrementImportIndex
public void incrementImportIndex()
Increments the import index by one.
-
incrementRelocationAddress
public void incrementRelocationAddress(int addend)
Increments the relocation address by the given addend- Parameters:
addend- the amount to increment the relocation address
-
setRelocationAddress
public void setRelocationAddress(Address relocationAddress)
Sets the relocation address.- Parameters:
relocationAddress- the new relocation address
-
setSectionC
public void setSectionC(Address sectionC)
Set the sectionC variable to given address.- Parameters:
sectionC- the new sectionC address
-
setSectionD
public void setSectionD(Address sectionD)
Set the sectionD variable to given address.- Parameters:
sectionD- the new sectionD address
-
getImportIndex
public int getImportIndex()
Returns the current import index.- Returns:
- the current import index
-
setImportIndex
public void setImportIndex(int importIndex)
Sets the import index.- Parameters:
importIndex- the new import index value
-
getRelocationAddress
public Address getRelocationAddress()
Returns the current relocation address.- Returns:
- the current relocation address
-
getSectionC
public Address getSectionC()
Returns the current sectionC address.- Returns:
- the current sectionC address
-
getSectionD
public Address getSectionD()
Returns the current sectionD address.- Returns:
- the current sectionD address
-
fixupMemory
public void fixupMemory(Address address, Address fixupAddress, MessageLog log)
Adds the fixup address to the contents stored at address, then creates a pointer at address.- Parameters:
address- the address to fixupfixupAddress- the value to use in fixuplog- message log for recording errors
-
relocateMemoryAt
public void relocateMemoryAt(Address address, int addend, MessageLog log)
Increments the integer in memory at the specified address- Parameters:
address- the address to incrementaddend- the value to addlog- a message log
-
getSectionToBeRelocated
public Address getSectionToBeRelocated()
Returns the base address of the section to be relocated.- Returns:
- the base address of the section to be relocated
-
-