abstract what variables require dynamic storage to function

This commit is contained in:
caheckman 2019-12-29 13:46:56 -05:00
parent 7b407f1965
commit b88ea8c927
3 changed files with 19 additions and 2 deletions

View file

@ -456,7 +456,7 @@ public class HighFunctionDBUtil {
Variable var; Variable var;
VariableStorage storage; VariableStorage storage;
HighVariable tmpHigh = variable.getHighVariable(); HighVariable tmpHigh = variable.getHighVariable();
if (tmpHigh != null && tmpHigh.getRepresentative().isUnique()) { if (tmpHigh != null && tmpHigh.requiresDynamicStorage()) {
storage = storage =
DynamicEntry.buildDynamicStorage(tmpHigh.getRepresentative(), highFunction); DynamicEntry.buildDynamicStorage(tmpHigh.getRepresentative(), highFunction);
var = null; var = null;

View file

@ -176,6 +176,22 @@ public abstract class HighVariable {
setHighOnInstances(); 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 * Restore this HighVariable from a <high> XML tag
* @param parser is the XML stream * @param parser is the XML stream

View file

@ -16,6 +16,7 @@
package ghidra.program.model.pcode; package ghidra.program.model.pcode;
import ghidra.program.model.address.*; import ghidra.program.model.address.*;
import ghidra.program.model.data.AbstractFloatDataType;
import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Program;
import ghidra.program.model.listing.VariableStorage; import ghidra.program.model.listing.VariableStorage;
import ghidra.program.model.mem.MemoryBlock; import ghidra.program.model.mem.MemoryBlock;
@ -85,7 +86,7 @@ public class MappedEntry extends SymbolEntry {
public void saveXml(StringBuilder buf) { public void saveXml(StringBuilder buf) {
int logicalsize = 0; // Assume datatype size and storage size are the same int logicalsize = 0; // Assume datatype size and storage size are the same
int typeLength = symbol.type.getLength(); int typeLength = symbol.type.getLength();
if (typeLength != storage.size() && typeLength > 0) { if (typeLength != storage.size() && symbol.type instanceof AbstractFloatDataType) {
logicalsize = typeLength; // Force a logicalsize logicalsize = typeLength; // Force a logicalsize
} }
String addrRes = Varnode.buildXMLAddress(storage.getVarnodes(), logicalsize); String addrRes = Varnode.buildXMLAddress(storage.getVarnodes(), logicalsize);