Skip to content

Ghidra is a software reverse engineering (SRE) framework

Merge remote-tracking branch 'origin/patch'

ghidra17c5313cf5dd1
diff --cc Ghidra/Processors/x86/src/main/java/ghidra/app/util/bin/format/elf/relocation/X86_64_ElfRelocationHandler.java
index e16d67a159,20be2c3716..993bfbf700
--- a/Ghidra/Processors/x86/src/main/java/ghidra/app/util/bin/format/elf/relocation/X86_64_ElfRelocationHandler.java
+++ b/Ghidra/Processors/x86/src/main/java/ghidra/app/util/bin/format/elf/relocation/X86_64_ElfRelocationHandler.java
@@@ -292,7 -257,55 +292,33 @@@ public class X86_64_ElfRelocationHandle
}
value = symbolGotAddress.getOffset() + addend - offset;
memory.setLong(relocationAddress, value);
+ break;
+
+ case R_X86_64_GOT64: // 64 bit GOT entry offset (UNVERIFIED)
+ symbolGotAddress = elfRelocationContext.getGotEntryAddress(sym);
+ if (symbolGotAddress == null) {
+ markAsError(program, relocationAddress, type, symbolName, symbolIndex,
+ "GOT allocation failure", elfRelocationContext.getLog());
+ return RelocationResult.FAILURE;
+ }
+ value = symbolGotAddress.getOffset() + addend;
+ memory.setLong(relocationAddress, value);
+ break;
+
+ case R_X86_64_PLTOFF64: // 64 bit GOT relative offset to PLT entry (UNVERIFIED)
+ long dotgot;
+ try {
+ dotgot = elfRelocationContext.getGOTValue();
+ }
+ catch (NotFoundException e) {
+ markAsError(program, relocationAddress, type, symbolName, symbolIndex,
+ "GOT allocation failure", elfRelocationContext.getLog());
+ return RelocationResult.FAILURE;
+ }
+ value = symbolValue - dotgot + addend;
+ memory.setLong(relocationAddress, value);
+ break;
- case R_X86_64_RELATIVE:
- // word64 for LP64 and specifies word32 for ILP32,
- // we assume LP64 only. We probably need a hybrid
- // variant to handle the ILP32 case.
- case R_X86_64_RELATIVE64:
- // dl_machine.h
- // value = (Elf64_64Addr) map->l_addr + reloc->r_addend
- long imageBaseAdjustment = elfRelocationContext.getImageBaseWordAdjustmentOffset();
- if (elfRelocationContext.getElfHeader().isPreLinked()) {
- // adjust prelinked value that is already in memory
- value = memory.getLong(relocationAddress) + imageBaseAdjustment;
- }
- else {
- value = addend + imageBaseAdjustment;
- }
- memory.setLong(relocationAddress, value);
- break;
- case R_X86_64_IRELATIVE:
- value = addend + elfRelocationContext.getImageBaseWordAdjustmentOffset();
- memory.setLong(relocationAddress, value);
- break;
-
// case ElfRelocationConstants.R_X86_64_TLSGD:
// case ElfRelocationConstants.R_X86_64_TLSLD:
// case ElfRelocationConstants.R_X86_64_DTPOFF32: