From 6c37abb4fd78dda28362411cbd4556c264202865 Mon Sep 17 00:00:00 2001 From: ghidorahrex Date: Fri, 25 Aug 2023 14:07:28 +0000 Subject: [PATCH 1/2] GP-3788: Fixed PowerPC VLE load/store SD4 operand display --- Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc b/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc index 7ef0eee86e..11473741d7 100644 --- a/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc +++ b/Ghidra/Processors/PowerPC/data/languages/ppc_vle.sinc @@ -28,8 +28,8 @@ d8PlusRaAddress: S8IMM(A) is S8IMM & A {tmp:$(REGISTER_SIZE) = A+S8IMM; ex d8PlusRaOrZeroAddress: S8IMM(RA_OR_ZERO) is S8IMM & RA_OR_ZERO {tmp:$(REGISTER_SIZE) = RA_OR_ZERO+S8IMM; export tmp; } sd4PlusRxAddr: SD4_VLE(RX_VLE) is SD4_VLE & RX_VLE {tmp:$(REGISTER_SIZE) = RX_VLE+SD4_VLE; export tmp; } -sd4HPlusRxAddr: SD4_VLE(RX_VLE) is SD4_VLE & RX_VLE {tmp:$(REGISTER_SIZE) = RX_VLE+(SD4_VLE << 1); export tmp; } -sd4WPlusRxAddr: SD4_VLE(RX_VLE) is SD4_VLE & RX_VLE {tmp:$(REGISTER_SIZE) = RX_VLE+(SD4_VLE << 2); export tmp; } +sd4HPlusRxAddr: SD4_OFF(RX_VLE) is SD4_VLE & RX_VLE [SD4_OFF = SD4_VLE << 1;] {tmp:$(REGISTER_SIZE) = RX_VLE+SD4_OFF; export tmp; } +sd4WPlusRxAddr: SD4_OFF(RX_VLE) is SD4_VLE & RX_VLE [SD4_OFF = SD4_VLE << 2;] {tmp:$(REGISTER_SIZE) = RX_VLE+SD4_OFF; export tmp; } OIMM: val is UI5_VLE [ val = UI5_VLE+1; ] { export *[const]:$(REGISTER_SIZE) val; } From 7d9c1c748a0bd1bf35359983a29ce03371982979 Mon Sep 17 00:00:00 2001 From: ghidra1 Date: Thu, 18 Jan 2024 15:04:12 -0500 Subject: [PATCH 2/2] GP-4228 Corrected X86-64 ELF GOT allocation for object module import for R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX relocations --- .../elf/relocation/X86_64_ElfRelocationContext.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Ghidra/Processors/x86/src/main/java/ghidra/app/util/bin/format/elf/relocation/X86_64_ElfRelocationContext.java b/Ghidra/Processors/x86/src/main/java/ghidra/app/util/bin/format/elf/relocation/X86_64_ElfRelocationContext.java index 8ca1f6dadb..71e6bc9038 100644 --- a/Ghidra/Processors/x86/src/main/java/ghidra/app/util/bin/format/elf/relocation/X86_64_ElfRelocationContext.java +++ b/Ghidra/Processors/x86/src/main/java/ghidra/app/util/bin/format/elf/relocation/X86_64_ElfRelocationContext.java @@ -113,6 +113,7 @@ class X86_64_ElfRelocationContext extends ElfRelocationContext { } private boolean requiresGotEntry(ElfRelocation r) { + switch (r.getType()) { case X86_64_ElfRelocationConstants.R_X86_64_GOTPCREL: // case X86_64_ElfRelocationConstants.R_X86_64_GOTOFF64: @@ -120,8 +121,11 @@ class X86_64_ElfRelocationContext extends ElfRelocationContext { // case X86_64_ElfRelocationConstants.R_X86_64_GOT64: case X86_64_ElfRelocationConstants.R_X86_64_GOTPCREL64: // case X86_64_ElfRelocationConstants.R_X86_64_GOTPC64: -// case X86_64_ElfRelocationConstants.R_X86_64_GOTPCRELX: -// case X86_64_ElfRelocationConstants.R_X86_64_REX_GOTPCRELX: + return true; + case X86_64_ElfRelocationConstants.R_X86_64_GOTPCRELX: + case X86_64_ElfRelocationConstants.R_X86_64_REX_GOTPCRELX: + // NOTE: Relocation may not actually require GOT entry in which case %got + // may be over-allocated, but is required in some cases. return true; default: return false;