mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-02 06:19:49 +08:00
Merge remote-tracking branch 'origin/GP-5846_ghidra1_PPC64_ELFRelocations' into patch
This commit is contained in:
+6
@@ -522,6 +522,7 @@ public class PowerPC64_ElfExtension extends ElfExtension {
|
|||||||
Function f = elfLoadHelper.createOneByteFunction(name, address, false);
|
Function f = elfLoadHelper.createOneByteFunction(name, address, false);
|
||||||
if (f != null && localFunction != null) {
|
if (f != null && localFunction != null) {
|
||||||
f.setThunkedFunction(localFunction);
|
f.setThunkedFunction(localFunction);
|
||||||
|
elfLoadHelper.setElfSymbolAddress(elfSymbol, address);
|
||||||
return null; // symbol creation handled
|
return null; // symbol creation handled
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,6 +544,11 @@ public class PowerPC64_ElfExtension extends ElfExtension {
|
|||||||
if (elf.e_machine() != ElfConstants.EM_PPC64) {
|
if (elf.e_machine() != ElfConstants.EM_PPC64) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elf.getSection(".opd") != null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: While the e_flags should indicate the use of function descriptors, this
|
// TODO: While the e_flags should indicate the use of function descriptors, this
|
||||||
// may not be set reliably. The presence of the .opd section is another
|
// may not be set reliably. The presence of the .opd section is another
|
||||||
// indicator but could be missing if sections have been stripped.
|
// indicator but could be missing if sections have been stripped.
|
||||||
|
|||||||
+15
-8
@@ -215,27 +215,34 @@ public class PowerPC64_ElfRelocationHandler
|
|||||||
memory.setInt(relocationAddress, newValue);
|
memory.setInt(relocationAddress, newValue);
|
||||||
break;
|
break;
|
||||||
case R_PPC64_JMP_SLOT:
|
case R_PPC64_JMP_SLOT:
|
||||||
// TODO: do we need option to allow function descriptor
|
MemoryBlock block = memory.getBlock(symbolAddr);
|
||||||
// use - or not? The EF_PPC64_ABI in e_flags is not reliable.
|
|
||||||
Address functionDescriptorAddr = relocationAddress.getNewAddress(symbolValue);
|
|
||||||
MemoryBlock block = memory.getBlock(functionDescriptorAddr);
|
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
throw new MemoryAccessException(
|
throw new MemoryAccessException(
|
||||||
"Function descriptor not found at: " + functionDescriptorAddr);
|
"Relocation symbol not found in memory: " + symbolAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MemoryBlock.EXTERNAL_BLOCK_NAME.equals(block.getName())) {
|
if (MemoryBlock.EXTERNAL_BLOCK_NAME.equals(block.getName())) {
|
||||||
// If symbol is in EXTERNAL block, we don't have descriptor entry;
|
// If symbol is in EXTERNAL block, we don't have descriptor entry;
|
||||||
// just fill-in first slot with EXTERNAL address
|
// just fill-in first slot with EXTERNAL address
|
||||||
memory.setLong(relocationAddress, symbolValue);
|
memory.setLong(relocationAddress, symbolValue);
|
||||||
byteLength = 8;
|
byteLength = 8;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
if (PowerPC64_ElfExtension
|
||||||
|
.getPpc64ABIVersion(elfRelocationContext.getElfHeader()) == 1) {
|
||||||
|
// ABI ELFv1 (used by big-endian PPC64) expected to copy full function descriptor
|
||||||
|
// into .got.plt section where symbolAddr refers to function descriptor
|
||||||
// Copy function descriptor data
|
// Copy function descriptor data
|
||||||
byte[] bytes = new byte[24]; // TODO: can descriptor size vary ?
|
byte[] bytes = new byte[24];
|
||||||
memory.getBytes(functionDescriptorAddr, bytes);
|
memory.getBytes(symbolAddr, bytes);
|
||||||
memory.setBytes(relocationAddress, bytes);
|
memory.setBytes(relocationAddress, bytes);
|
||||||
byteLength = bytes.length;
|
byteLength = bytes.length;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
memory.setLong(relocationAddress, symbolValue);
|
||||||
|
byteLength = 8;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case R_PPC64_UADDR32:
|
case R_PPC64_UADDR32:
|
||||||
newValue = (int) (symbolValue + addend);
|
newValue = (int) (symbolValue + addend);
|
||||||
|
|||||||
Reference in New Issue
Block a user