From 81a678ce6837b657dd58013f363c698cdf1bbc36 Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Mon, 26 Apr 2021 16:30:14 -0400 Subject: [PATCH 1/2] Fix TypeEnum comparisons --- Ghidra/Features/Decompiler/src/decompile/cpp/type.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc index b05109d696..66b5f3d64c 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc @@ -764,6 +764,9 @@ int4 TypeEnum::compareDependency(const Datatype &op) const const TypeEnum *te = (const TypeEnum *) &op; map::const_iterator iter1,iter2; + if (namemap.size() != te->namemap.size()) { + return (namemap.size() < te->namemap.size()) ? -1 : 1; + } iter1 = namemap.begin(); iter2 = te->namemap.begin(); while(iter1 != namemap.end()) { From 0ba753427a5f29f02572b569d5ab7b27e49e078e Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Fri, 14 May 2021 12:06:28 -0400 Subject: [PATCH 2/2] Set variable_length flag early --- Ghidra/Features/Decompiler/src/decompile/cpp/type.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc index 66b5f3d64c..02fdcf36d9 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc @@ -1290,18 +1290,21 @@ void TypeCode::saveXml(ostream &s) const void TypeCode::restoreXml(const Element *el,TypeFactory &typegrp) { + const List &list(el->getChildren()); + List::const_iterator iter; + iter = list.begin(); + if (iter != list.end()) { + // Traditionally a tag implies variable length, without a "varlength" attribute + flags |= variable_length; + } restoreXmlBasic(el); if (proto != (FuncProto *)0) { delete proto; proto = (FuncProto *)0; } - const List &list(el->getChildren()); - List::const_iterator iter; - iter = list.begin(); if (iter == list.end()) return; // No underlying prototype Architecture *glb = typegrp.getArch(); factory = &typegrp; - flags |= variable_length; proto = new FuncProto(); proto->setInternal( glb->defaultfp, typegrp.getTypeVoid() ); proto->restoreXml(*iter,glb);