mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-24 13:21:22 +08:00
GT-3349 Corrected ELF relocation fixups for R_MIPS_REL32,
R_X86_64_RELATIVE and R_X86_64_RELATIVE64
This commit is contained in:
+2
-3
@@ -402,10 +402,9 @@ public class MIPS_ElfRelocationHandler extends ElfRelocationHandler {
|
||||
break;
|
||||
|
||||
case MIPS_ElfRelocationConstants.R_MIPS_REL32:
|
||||
// TODO: some guess-work was used here
|
||||
// TODO: unsure if reloc valid for symbolIndex != 0
|
||||
if (symbolIndex == 0) {
|
||||
// TODO: may need to use relocation section load address if applicable
|
||||
symbolValue = program.getImageBase().getOffset();
|
||||
symbolValue = mipsRelocationContext.getImageBaseWordAdjustmentOffset();
|
||||
}
|
||||
value = (int) symbolValue;
|
||||
value += mipsRelocationContext.extractAddend() ? oldValue : addend;
|
||||
|
||||
+4
-5
@@ -182,7 +182,7 @@ public class X86_64_ElfRelocationHandler extends ElfRelocationHandler {
|
||||
value = symbolValue + dotgot + addend - offset;
|
||||
memory.setInt(relocationAddress, (int) value);
|
||||
break;
|
||||
|
||||
|
||||
case X86_64_ElfRelocationConstants.R_X86_64_RELATIVE:
|
||||
// word64 for LP64 and specifies word32 for ILP32,
|
||||
// we assume LP64 only. We probably need a hybrid
|
||||
@@ -191,14 +191,13 @@ public class X86_64_ElfRelocationHandler extends ElfRelocationHandler {
|
||||
// dl_machine.h
|
||||
// value = (Elf64_64Addr) map->l_addr + reloc->r_addend
|
||||
appliedSymbol = false; // symbol not used, symbolIndex of 0 expected
|
||||
long base = program.getImageBase().getAddressableWordOffset();
|
||||
long imageBaseAdjustment = elfRelocationContext.getImageBaseWordAdjustmentOffset();
|
||||
if (elf.isPreLinked()) {
|
||||
// adjust prelinked value that is already in memory
|
||||
value = memory.getLong(relocationAddress) +
|
||||
elfRelocationContext.getImageBaseWordAdjustmentOffset();
|
||||
value = memory.getLong(relocationAddress) + imageBaseAdjustment;
|
||||
}
|
||||
else {
|
||||
value = base + addend;
|
||||
value = addend + imageBaseAdjustment;
|
||||
}
|
||||
memory.setLong(relocationAddress, value);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user