mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Merge remote-tracking branch
'origin/GP-2612_PrototypeModel_return_address' (Closes #4611)
This commit is contained in:
commit
daa2342aa4
4 changed files with 27 additions and 6 deletions
|
@ -136,6 +136,7 @@ public class ProgramCompilerSpec extends BasicCompilerSpec {
|
|||
continue;
|
||||
}
|
||||
markPrototypeAsExtension(model);
|
||||
setDefaultReturnAddressIfNeeded(model);
|
||||
finalList.add(model);
|
||||
usermodels.put(model.getName(), model);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class BasicCompilerSpec implements CompilerSpec {
|
|||
private List<Varnode> preferSplit; // List of registers the decompiler prefers to split
|
||||
private AddressSet noHighPtr; // Memory regions the decompiler treats as not addressable
|
||||
private AddressSet readOnlySet; // (Additional) memory ranges the decompiler treats as read-only
|
||||
private Varnode returnAddress; // Register/memory where decompiler expects return address to be stored
|
||||
protected Varnode returnAddress; // Register/memory where decompiler expects return address to be stored
|
||||
private int funcPtrAlign; // Alignment of function pointers, 0=no alignment (default)
|
||||
private List<Pair<AddressSpace, Integer>> deadCodeDelay;
|
||||
private List<AddressRange> inferPtrBounds; // Restrictions on where decompiler can infer pointers
|
||||
|
@ -1066,6 +1066,7 @@ public class BasicCompilerSpec implements CompilerSpec {
|
|||
model = new PrototypeModel();
|
||||
model.restoreXml(parser, this);
|
||||
}
|
||||
setDefaultReturnAddressIfNeeded(model);
|
||||
modelList.add(model);
|
||||
return model;
|
||||
}
|
||||
|
@ -1169,6 +1170,19 @@ public class BasicCompilerSpec implements CompilerSpec {
|
|||
model.isExtension = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code returnaddress} of {@code model} to the {@code returnAddress}
|
||||
* of {@code this} if the model does not have a return address set.
|
||||
* @param model prototype
|
||||
*/
|
||||
protected void setDefaultReturnAddressIfNeeded(PrototypeModel model) {
|
||||
if (model.getReturnAddress() == null) {
|
||||
Varnode[] retAddr =
|
||||
(returnAddress == null) ? new Varnode[0] : new Varnode[] { returnAddress };
|
||||
model.setReturnAddress(retAddr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEquivalent(CompilerSpec obj) {
|
||||
if (getClass() != obj.getClass()) {
|
||||
|
|
|
@ -156,9 +156,6 @@ public class PrototypeModel {
|
|||
* @return list of registers/memory used to store the return address
|
||||
*/
|
||||
public Varnode[] getReturnAddress() {
|
||||
if (returnaddress == null) {
|
||||
returnaddress = new Varnode[0];
|
||||
}
|
||||
return returnaddress;
|
||||
}
|
||||
|
||||
|
@ -444,8 +441,7 @@ public class PrototypeModel {
|
|||
encoder.writeSignedInteger(ATTRIB_STACKSHIFT, stackshift);
|
||||
GenericCallingConvention nameType = GenericCallingConvention.guessFromName(name);
|
||||
if (nameType != genericCallingConvention) {
|
||||
encoder.writeString(ATTRIB_TYPE,
|
||||
genericCallingConvention.getDeclarationName());
|
||||
encoder.writeString(ATTRIB_TYPE, genericCallingConvention.getDeclarationName());
|
||||
}
|
||||
if (hasThis) {
|
||||
encoder.writeBool(ATTRIB_HASTHIS, true);
|
||||
|
@ -794,4 +790,12 @@ public class PrototypeModel {
|
|||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the return address
|
||||
* @param returnaddress return address
|
||||
*/
|
||||
protected void setReturnAddress(Varnode[] returnaddress) {
|
||||
this.returnaddress = returnaddress;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue