From 9c1fed6a133c3e2a39bf57e97d9f4c4c457d534b Mon Sep 17 00:00:00 2001 From: ghidra1 Date: Tue, 23 Feb 2021 12:27:48 -0500 Subject: [PATCH] GP-710 Added support for additional PIC30 ELF relocations (closes #2792) --- .../elf/relocation/PIC30_ElfRelocationHandler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Ghidra/Processors/PIC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PIC30_ElfRelocationHandler.java b/Ghidra/Processors/PIC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PIC30_ElfRelocationHandler.java index 6059bd0968..915ad21d31 100644 --- a/Ghidra/Processors/PIC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PIC30_ElfRelocationHandler.java +++ b/Ghidra/Processors/PIC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PIC30_ElfRelocationHandler.java @@ -155,15 +155,25 @@ public class PIC30_ElfRelocationHandler extends ElfRelocationHandler { if (elf.e_machine() == ElfConstants.EM_DSPIC30F) { switch (type) { case R_PIC30_16: // 2 - newValue = (symbolValue + addend + oldShortValue) & 0xffff; + case R_PIC30_FILE_REG_WORD: // 6 + newValue = (symbolValue + addend + oldShortValue); memory.setShort(relocationAddress, (short) newValue); break; case R_PIC30_32: // 3 newValue = symbolValue + addend + oldValue; memory.setInt(relocationAddress, newValue); break; + case R_PIC30_FILE_REG_BYTE: // 4 short + case R_PIC30_FILE_REG: // 5 short + int reloc = symbolValue; + reloc += addend; + reloc += oldShortValue; + reloc &= 0x1fff; + newValue = reloc | (oldShortValue & ~0x1fff); + memory.setShort(relocationAddress, (short) newValue); + break; case R_PIC30_FILE_REG_WORD_WITH_DST: // 7 - int reloc = symbolValue >> 1; + reloc = symbolValue >> 1; reloc += addend; reloc += oldValue >> 4; reloc &= 0x7fff;