ghidra: handle destructor ABI differences

develop
Ben Lubar 2020-03-21 08:53:11 -05:00
parent b2940b69f8
commit 5b8952baf8
No known key found for this signature in database
GPG Key ID: 92939677AB59EDA4
2 changed files with 29 additions and 3 deletions

@ -1 +1 @@
Subproject commit 8e18759023229cf261bc7c3e30c6547ace4adec3 Subproject commit ef09097be76a58b5911b5bf65bee7c3cd6d7bb16

@ -1214,12 +1214,38 @@ public class import_df_structures extends GhidraScript
for (var vm : t.vmethods) for (var vm : t.vmethods)
{ {
String mname = null; String mname = null;
if (vm.isDestructor)
{
mname = "~" + name;
if (baseClassPadding == 1)
{
// GCC
var mt = dtm.getPointer(createMethodDataType(name + "::" + mname, vm), currentProgram.getDefaultPointerSize());
st.add(mt, mname, null);
st.add(mt, mname + "(deleting)", null);
}
else
{
// MSVC
if (vm.arguments.isEmpty())
{
var arg = new TypeDef.Field();
arg.meta = "number";
arg.subtype = "bool";
arg.hasName = true;
arg.name = "deleting";
vm.arguments.add(arg);
}
var mt = dtm.getPointer(createMethodDataType(name + "::" + mname, vm), currentProgram.getDefaultPointerSize());
st.add(mt, mname, null);
}
continue;
}
if (vm.hasName) if (vm.hasName)
mname = vm.name; mname = vm.name;
else if (vm.hasAnonName) else if (vm.hasAnonName)
mname = name + "_" + vm.anonName; mname = name + "_" + vm.anonName;
else if (vm.isDestructor)
mname = "~" + name;
st.add(dtm.getPointer(createMethodDataType(name + "::" + mname, vm), currentProgram.getDefaultPointerSize()), mname, null); st.add(dtm.getPointer(createMethodDataType(name + "::" + mname, vm), currentProgram.getDefaultPointerSize()), mname, null);
} }