GP-4370 Internal Storage

This commit is contained in:
caheckman 2024-04-19 16:54:30 +00:00
parent f1e2c8db04
commit 05818c5c3a
17 changed files with 219 additions and 63 deletions

View file

@ -50,6 +50,7 @@ public class PrototypeModel {
private Varnode[] killedbycall; // Memory ranges definitely affected by calls
private Varnode[] returnaddress; // Memory used to store the return address
private Varnode[] likelytrash; // Memory likely to be meaningless on input
private Varnode[] internalstorage; // Registers holding internal compiler constants
private PrototypeModel compatModel; // The model this is an alias of
private AddressSet localRange; // Range on the stack considered for local storage
private AddressSet paramRange; // Range on the stack considered for parameter storage
@ -81,6 +82,7 @@ public class PrototypeModel {
killedbycall = model.killedbycall;
returnaddress = model.returnaddress;
likelytrash = model.likelytrash;
internalstorage = model.internalstorage;
compatModel = model;
localRange = new AddressSet(model.localRange);
paramRange = new AddressSet(model.paramRange);
@ -101,6 +103,7 @@ public class PrototypeModel {
killedbycall = null;
returnaddress = null;
likelytrash = null;
internalstorage = null;
compatModel = null;
localRange = null;
paramRange = null;
@ -140,6 +143,16 @@ public class PrototypeModel {
return likelytrash;
}
/**
* @return list of registers used to store internal compiler constants
*/
public Varnode[] getInternalStorage() {
if (internalstorage == null) {
internalstorage = new Varnode[0];
}
return internalstorage;
}
/**
* @return list of registers/memory used to store the return address
*/
@ -456,6 +469,11 @@ public class PrototypeModel {
encodeVarnodes(encoder, likelytrash);
encoder.closeElement(ELEM_LIKELYTRASH);
}
if (internalstorage != null) {
encoder.openElement(ELEM_INTERNAL_STORAGE);
encodeVarnodes(encoder, internalstorage);
encoder.closeElement(ELEM_INTERNAL_STORAGE);
}
if (returnaddress != null) {
encoder.openElement(ELEM_RETURNADDRESS);
encodeVarnodes(encoder, returnaddress);
@ -633,6 +651,9 @@ public class PrototypeModel {
else if (elName.equals("likelytrash")) {
likelytrash = readVarnodes(parser, cspec);
}
else if (elName.equals("internal_storage")) {
internalstorage = readVarnodes(parser, cspec);
}
else if (elName.equals("localrange")) {
localRange = readAddressSet(parser, cspec);
}
@ -741,6 +762,9 @@ public class PrototypeModel {
if (!SystemUtilities.isArrayEqual(likelytrash, obj.likelytrash)) {
return false;
}
if (!SystemUtilities.isArrayEqual(internalstorage, obj.internalstorage)) {
return false;
}
String compatName = (compatModel != null) ? compatModel.getName() : "";
String compatNameOp2 = (obj.compatModel != null) ? obj.compatModel.getName() : "";
if (!compatName.equals(compatNameOp2)) {

View file

@ -268,6 +268,7 @@ public record ElementId(String name, int id) {
public static final ElementId ELEM_RETPARAM = new ElementId("retparam", 171);
public static final ElementId ELEM_RETURNSYM = new ElementId("returnsym", 172);
public static final ElementId ELEM_UNAFFECTED = new ElementId("unaffected", 173);
public static final ElementId ELEM_INTERNAL_STORAGE = new ElementId("internal_storage", 286);
// options
public static final ElementId ELEM_ALIASBLOCK = new ElementId("aliasblock", 174);
@ -456,5 +457,5 @@ public record ElementId(String name, int id) {
new ElementId("join_per_primitive", 283);
public static final ElementId ELEM_JOIN_DUAL_CLASS = new ElementId("join_dual_class", 285);
public static final ElementId ELEM_UNKNOWN = new ElementId("XMLunknown", 286);
public static final ElementId ELEM_UNKNOWN = new ElementId("XMLunknown", 287);
}