Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1742 corrected ELF ARM-32 relocation adjustment for R_ARM_THM_JUMP11 and R_ARM_THM_JUMP8

ghidra1026fad27abc6
diff --git a/Ghidra/Processors/ARM/src/main/java/ghidra/app/util/bin/format/elf/relocation/ARM_ElfRelocationHandler.java b/Ghidra/Processors/ARM/src/main/java/ghidra/app/util/bin/format/elf/relocation/ARM_ElfRelocationHandler.java
index 9245668d5e..3970457508 100644
--- a/Ghidra/Processors/ARM/src/main/java/ghidra/app/util/bin/format/elf/relocation/ARM_ElfRelocationHandler.java
+++ b/Ghidra/Processors/ARM/src/main/java/ghidra/app/util/bin/format/elf/relocation/ARM_ElfRelocationHandler.java
@@ -573,9 +573,7 @@ public class ARM_ElfRelocationHandler extends ElfRelocationHandler {
addend = (oldValue << 21 >> 20); // extract addend and sign-extend with *2 factor
}
newValue = (int) (symbolValue + addend);
-
- newValue -= (offset + 4); // PC relative, PC will be 4 bytes past inst start
-
+ newValue -= offset; // PC relative
newValue = (oldValue & 0x0000f800) | ((newValue >> 1) & 0x000007ff);
memory.setShort(relocationAddress, (short) newValue, instructionBigEndian);
break;
@@ -586,9 +584,7 @@ public class ARM_ElfRelocationHandler extends ElfRelocationHandler {
addend = (oldValue << 24 >> 23); // extract addend and sign-extend with *2 factor
}
newValue = (int) (symbolValue + addend);
-
- newValue -= (offset + 4); // PC relative, PC will be 4 bytes past inst start
-
+ newValue -= offset; // PC relative
newValue = (oldValue & 0x0000ff00) | ((newValue >> 1) & 0x000000ff);
memory.setShort(relocationAddress, (short) newValue, instructionBigEndian);
break;