Ghidra is a software reverse engineering (SRE) framework
abstract what variables require dynamic storage to function
caheckmanb88ea8c927b5
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionDBUtil.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionDBUtil.javaindex 8cd3ad2b31..f4257b8a67 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionDBUtil.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionDBUtil.java@@ -456,7 +456,7 @@ public class HighFunctionDBUtil {Variable var;VariableStorage storage;HighVariable tmpHigh = variable.getHighVariable();- if (tmpHigh != null && tmpHigh.getRepresentative().isUnique()) {+ if (tmpHigh != null && tmpHigh.requiresDynamicStorage()) {storage =DynamicEntry.buildDynamicStorage(tmpHigh.getRepresentative(), highFunction);var = null;diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighVariable.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighVariable.javaindex 22fbdeb36b..f92ecc61c3 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighVariable.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighVariable.java@@ -176,6 +176,22 @@ public abstract class HighVariable {setHighOnInstances();}+ /**+ * Return true in when the HighVariable should be recorded (in the database) using dynamic storage+ * rather than using the actual address space and offset of the representative varnode. Dynamic storage+ * is typically needed if the actual storage is ephemeral (in the unique space).+ * @return true if this needs dynamic storage+ */+ public boolean requiresDynamicStorage() {+ if (represent.isUnique()) {+ return true; // Temporary Varnodes always need dynamic storage+ }+ if (represent.getAddress().isStackAddress() && !represent.isAddrTied()) {+ return true;+ }+ return false;+ }+/*** Restore this HighVariable from a <high> XML tag* @param parser is the XML streamdiff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/MappedEntry.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/MappedEntry.javaindex fabb9d33f6..0827ed6e3e 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/MappedEntry.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/MappedEntry.java@@ -16,6 +16,7 @@package ghidra.program.model.pcode;import ghidra.program.model.address.*;+import ghidra.program.model.data.AbstractFloatDataType;import ghidra.program.model.listing.Program;import ghidra.program.model.listing.VariableStorage;import ghidra.program.model.mem.MemoryBlock;@@ -85,7 +86,7 @@ public class MappedEntry extends SymbolEntry {public void saveXml(StringBuilder buf) {int logicalsize = 0; // Assume datatype size and storage size are the sameint typeLength = symbol.type.getLength();- if (typeLength != storage.size() && typeLength > 0) {+ if (typeLength != storage.size() && symbol.type instanceof AbstractFloatDataType) {logicalsize = typeLength; // Force a logicalsize}String addrRes = Varnode.buildXMLAddress(storage.getVarnodes(), logicalsize);