Class RelocationState
- java.lang.Object
-
- ghidra.app.util.bin.format.pef.RelocationState
-
public class RelocationState extends java.lang.Object
This class maintains the running state while applying relocations.relocAddress
Holds 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.importIndex
Holds 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.sectionC
Holds 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.sectionD
Holds 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 void
dispose()
void
fixupMemory(Address address, Address fixupAddress, MessageLog log)
Adds the fixup address to the contents stored at address, then creates a pointer at address.int
getImportIndex()
Returns the current import index.Address
getRelocationAddress()
Returns the current relocation address.Address
getSectionC()
Returns the current sectionC address.Address
getSectionD()
Returns the current sectionD address.Address
getSectionToBeRelocated()
Returns the base address of the section to be relocated.void
incrementImportIndex()
Increments the import index by one.void
incrementRelocationAddress(int addend)
Increments the relocation address by the given addendvoid
relocateMemoryAt(Address address, int addend, MessageLog log)
Increments the integer in memory at the specified addressvoid
setImportIndex(int importIndex)
Sets the import index.void
setRelocationAddress(Address relocationAddress)
Sets the relocation address.void
setSectionC(Address sectionC)
Set the sectionC variable to given address.void
setSectionD(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 relocatedsectionMap
- the map of section headers to memory blocks
-
-
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:
program
- the programaddress
- 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
-
-