Merge remote-tracking branch 'origin/GT-3654_ghidra1_ELF_R_ARM_PC24' into Ghidra_9.2

This commit is contained in:
ghidra1 2020-11-03 16:46:10 -05:00
commit b9d16db00e

View file

@ -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);