From ce910a111223a05ca684f3fee362b6ea5da00d6d Mon Sep 17 00:00:00 2001 From: ghidra1 Date: Thu, 25 Feb 2021 19:04:33 -0500 Subject: [PATCH] Revert "GP-710 Added register symbol processing to ELF PIC30 import processing. Improved code unit operand format to render memory register name when no reference is present." This reverts commit c545a6fb5a3a1cc1f1c090546d8e24e80363fc7f. --- .../program/model/listing/CodeUnitFormat.java | 18 +----------- .../format/elf/extend/PIC30_ElfExtension.java | 28 ------------------- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/program/model/listing/CodeUnitFormat.java b/Ghidra/Features/Base/src/main/java/ghidra/program/model/listing/CodeUnitFormat.java index 4124eeec9a..2bf413cddd 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/program/model/listing/CodeUnitFormat.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/program/model/listing/CodeUnitFormat.java @@ -493,8 +493,7 @@ public class CodeUnitFormat { InstructionScalarInfo info = new InstructionScalarInfo(representations, primaryRef); if (info.hasSingleAddressWithNoScalars()) { int addressIndex = info.getAddressIndex(); - return markupAddressAsRegister(inst, primaryRef, representations, addressIndex) || - markupAddressAsScalar(inst, primaryRef, representations, addressIndex); + return markupAddressAsScalar(inst, primaryRef, representations, addressIndex); } if (info.hasNoScalars()) { @@ -565,21 +564,6 @@ public class CodeUnitFormat { return primaryRef == null; } - private boolean markupAddressAsRegister(Instruction instr, Reference primaryRef, - List representationList, int addressIndex) { - if (primaryRef != null) { - return false; - } - // NOTE: although preferrable, access type/size is not considered - Address addr = (Address) representationList.get(addressIndex); - Register reg = instr.getProgram().getRegister(addr); - if (reg != null) { - representationList.set(addressIndex, reg.getName()); - return true; - } - return false; - } - private boolean markupAddressAsScalar(Instruction instr, Reference primaryRef, List representationList, int addressIndex) { Address addr = (Address) representationList.get(addressIndex); diff --git a/Ghidra/Processors/PIC/src/main/java/ghidra/app/util/bin/format/elf/extend/PIC30_ElfExtension.java b/Ghidra/Processors/PIC/src/main/java/ghidra/app/util/bin/format/elf/extend/PIC30_ElfExtension.java index af2fae7d51..8442870220 100644 --- a/Ghidra/Processors/PIC/src/main/java/ghidra/app/util/bin/format/elf/extend/PIC30_ElfExtension.java +++ b/Ghidra/Processors/PIC/src/main/java/ghidra/app/util/bin/format/elf/extend/PIC30_ElfExtension.java @@ -22,9 +22,7 @@ import ghidra.app.util.bin.format.elf.*; import ghidra.program.model.address.Address; import ghidra.program.model.address.AddressSpace; import ghidra.program.model.lang.Language; -import ghidra.program.model.lang.Register; import ghidra.util.exception.CancelledException; -import ghidra.util.exception.NoValueException; import ghidra.util.task.TaskMonitor; public class PIC30_ElfExtension extends ElfExtension { @@ -221,32 +219,6 @@ public class PIC30_ElfExtension extends ElfExtension { return language.getDefaultDataSpace().equals(start.getAddressSpace().getPhysicalSpace()); } - @Override - public Address calculateSymbolAddress(ElfLoadHelper elfLoadHelper, ElfSymbol elfSymbol) - throws NoValueException { - - if (elfSymbol.getValue() != 0 || !elfSymbol.isGlobal() || - elfSymbol.getSectionHeaderIndex() != 0) { - return null; - } - - String name = elfSymbol.getNameAsString(); - if (name == null) { - return null; - } - - if (name.startsWith("_")) { - name = name.substring(1); - } - - Register reg = elfLoadHelper.getProgram().getRegister(name); - if (reg != null && !reg.getAddress().isRegisterAddress()) { - return reg.getAddress(); // only consider memory-based registers - } - - return null; - } - private static class PIC30FilteredDataInputStream extends FilterInputStream { // BYTES: