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