mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-25 17:00:36 -09:00
GP-164 Added ELF ARM relocation R_ARM_PREL31 and corrected issue with
R_ARM_ABS32 relocation. Fixes #2261, Fixes #2276
This commit is contained in:
@@ -83,8 +83,10 @@ public class ARM_ElfRelocationHandler extends ElfRelocationHandler {
|
||||
break;
|
||||
}
|
||||
case ARM_ElfRelocationConstants.R_ARM_ABS32: { // Target class: Data
|
||||
int oldValue = memory.getInt(relocationAddress);
|
||||
newValue = (int) (symbolValue + addend + oldValue);
|
||||
if (elfRelocationContext.extractAddend()) {
|
||||
addend = memory.getInt(relocationAddress);
|
||||
}
|
||||
newValue = (int) (symbolValue + addend);
|
||||
if (isThumb) {
|
||||
newValue |= 1;
|
||||
}
|
||||
@@ -92,8 +94,10 @@ public class ARM_ElfRelocationHandler extends ElfRelocationHandler {
|
||||
break;
|
||||
}
|
||||
case ARM_ElfRelocationConstants.R_ARM_REL32: { // Target class: Data
|
||||
int oldValue = memory.getInt(relocationAddress);
|
||||
newValue = (int) (symbolValue + addend + oldValue);
|
||||
if (elfRelocationContext.extractAddend()) {
|
||||
addend = memory.getInt(relocationAddress);
|
||||
}
|
||||
newValue = (int) (symbolValue + addend);
|
||||
newValue -= offset; // PC relative
|
||||
if (isThumb) {
|
||||
newValue |= 1;
|
||||
@@ -101,6 +105,20 @@ public class ARM_ElfRelocationHandler extends ElfRelocationHandler {
|
||||
memory.setInt(relocationAddress, newValue);
|
||||
break;
|
||||
}
|
||||
case ARM_ElfRelocationConstants.R_ARM_PREL31: { // Target class: Data
|
||||
int oldValue = memory.getInt(relocationAddress);
|
||||
if (elfRelocationContext.extractAddend()) {
|
||||
addend = (oldValue << 1) >> 1;
|
||||
}
|
||||
newValue = (int) (symbolValue + addend);
|
||||
newValue -= offset; // PC relative
|
||||
if (isThumb) {
|
||||
newValue |= 1;
|
||||
}
|
||||
newValue = (newValue & 0x7fffffff) + (oldValue & 0x80000000);
|
||||
memory.setInt(relocationAddress, newValue);
|
||||
break;
|
||||
}
|
||||
case ARM_ElfRelocationConstants.R_ARM_LDR_PC_G0: { // Target class: ARM Instruction
|
||||
int oldValue = memory.getInt(relocationAddress, instructionBigEndian);
|
||||
newValue = (int) (symbolValue + addend);
|
||||
|
||||
Reference in New Issue
Block a user