mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02: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:
parent
da92b68bcd
commit
f3b4e6de16
1 changed files with 22 additions and 4 deletions
|
@ -83,8 +83,10 @@ public class ARM_ElfRelocationHandler extends ElfRelocationHandler {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ARM_ElfRelocationConstants.R_ARM_ABS32: { // Target class: Data
|
case ARM_ElfRelocationConstants.R_ARM_ABS32: { // Target class: Data
|
||||||
int oldValue = memory.getInt(relocationAddress);
|
if (elfRelocationContext.extractAddend()) {
|
||||||
newValue = (int) (symbolValue + addend + oldValue);
|
addend = memory.getInt(relocationAddress);
|
||||||
|
}
|
||||||
|
newValue = (int) (symbolValue + addend);
|
||||||
if (isThumb) {
|
if (isThumb) {
|
||||||
newValue |= 1;
|
newValue |= 1;
|
||||||
}
|
}
|
||||||
|
@ -92,8 +94,10 @@ public class ARM_ElfRelocationHandler extends ElfRelocationHandler {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ARM_ElfRelocationConstants.R_ARM_REL32: { // Target class: Data
|
case ARM_ElfRelocationConstants.R_ARM_REL32: { // Target class: Data
|
||||||
int oldValue = memory.getInt(relocationAddress);
|
if (elfRelocationContext.extractAddend()) {
|
||||||
newValue = (int) (symbolValue + addend + oldValue);
|
addend = memory.getInt(relocationAddress);
|
||||||
|
}
|
||||||
|
newValue = (int) (symbolValue + addend);
|
||||||
newValue -= offset; // PC relative
|
newValue -= offset; // PC relative
|
||||||
if (isThumb) {
|
if (isThumb) {
|
||||||
newValue |= 1;
|
newValue |= 1;
|
||||||
|
@ -101,6 +105,20 @@ public class ARM_ElfRelocationHandler extends ElfRelocationHandler {
|
||||||
memory.setInt(relocationAddress, newValue);
|
memory.setInt(relocationAddress, newValue);
|
||||||
break;
|
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
|
case ARM_ElfRelocationConstants.R_ARM_LDR_PC_G0: { // Target class: ARM Instruction
|
||||||
int oldValue = memory.getInt(relocationAddress, instructionBigEndian);
|
int oldValue = memory.getInt(relocationAddress, instructionBigEndian);
|
||||||
newValue = (int) (symbolValue + addend);
|
newValue = (int) (symbolValue + addend);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue