Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-4133 Adjustment for forced indirect return

caheckman99d8762b9cf3
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
index 839223ea14..b4d9509840 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
@@ -1512,13 +1512,12 @@ void ParamListStandardOut::assignMap(const PrototypePieces &proto,TypeFactory &t
Datatype *pointertp = typefactory.getTypePointer(pointersize, proto.outtype, wordsize);
if (responseCode == AssignAction::hiddenret_specialreg_void) {
res.back().type = typefactory.getTypeVoid();
- res.back().flags = 0;
}
else {
if (assignAddressFallback(TYPECLASS_PTR,pointertp,false,status,res.back()) == AssignAction::fail)
throw ParamUnassignedError("Cannot assign return value as a pointer");
- res.back().flags = ParameterPieces::indirectstorage;
}
+ res.back().flags = ParameterPieces::indirectstorage;
res.emplace_back(); // Add extra storage location in the input params
res.back().type = pointertp; // that holds a pointer to where the return value should be stored
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/lang/ParameterPieces.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/lang/ParameterPieces.java
index 40b314a2fe..c69dc68c59 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/lang/ParameterPieces.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/lang/ParameterPieces.java
@@ -92,18 +92,15 @@ public class ParameterPieces {
VariableStorage store;
try {
if (joinPieces != null) {
- store = new DynamicVariableStorage(program, false, joinPieces);
+ store = new DynamicVariableStorage(program, isIndirect, joinPieces);
}
else {
if (hiddenReturnPtr) {
store = new DynamicVariableStorage(program,
AutoParameterType.RETURN_STORAGE_PTR, address, sz);
}
- else if (isIndirect) {
- store = new DynamicVariableStorage(program, true, address, sz);
- }
else {
- store = new DynamicVariableStorage(program, false, address, sz);
+ store = new DynamicVariableStorage(program, isIndirect, address, sz);
}
}
}