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 a9ae6a9561..69eb86b4a6 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 @@ -66,12 +66,11 @@ public class ARM_ElfRelocationHandler extends ElfRelocationHandler { switch (type) { case ARM_ElfRelocationConstants.R_ARM_PC24: { // Target class: ARM Instruction int oldValue = memory.getInt(relocationAddress, instructionBigEndian); - newValue = (int) (symbolValue + addend); - newValue -= (offset + 8); // PC relative, PC will be 8 bytes after inst start - if (isThumb) { - newValue |= 1; + if (elfRelocationContext.extractAddend()) { + addend = (oldValue << 8 >> 6); // extract addend and sign-extend with *4 factor } - // is this a BLX instruction, must put the lower half word in bit24 + newValue = (int) (symbolValue - offset + addend); + // if this a BLX instruction, must set bit24 to identify half-word if ((oldValue & 0xf0000000) == 0xf0000000) { newValue = (oldValue & 0xfe000000) | (((newValue >> 1) & 1) << 24) | ((newValue >> 2) & 0x00ffffff);