Skip to content

Ghidra is a software reverse engineering (SRE) framework

Merge remote-tracking branch 'origin/patch'

ghidra13118f6aa3658
diff --cc Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/StructureDB.java
index 3caebcf105,168fb8d594..9c99fa273a
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/StructureDB.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/StructureDB.java
@@@ -67,25 -67,14 +67,26 @@@ class StructureDB extends CompositeDB i
Field[] ids = componentAdapter.getComponentIdsInComposite(key);
for (Field id : ids) {
DBRecord rec = componentAdapter.getRecord(id.getLongValue());
+ if (rec.getIntValue(ComponentDBAdapter.COMPONENT_ORDINAL_COL) < 0) {
+ // old flex-array component record - defer migration (see below)
+ oldFlexArrayRecord = rec;
+ continue;
+ }
DataTypeComponentDB component =
new DataTypeComponentDB(dataMgr, componentAdapter, this, rec);
- if (component.isFlexibleArrayComponent()) {
- flexibleArrayComponent = component;
- }
- else {
- components.add(component);
- }
+ components.add(component);
+ }
+
+ Collections.sort(components, ComponentComparator.INSTANCE);
+
+ structLength = record.getIntValue(CompositeDBAdapter.COMPOSITE_LENGTH_COL);
+ structAlignment = record.getIntValue(CompositeDBAdapter.COMPOSITE_ALIGNMENT_COL);
+ computedAlignment = -1;
- numComponents = record.getIntValue(CompositeDBAdapter.COMPOSITE_NUM_COMPONENTS_COL);
++ numComponents = isPackingEnabled() ? components.size()
++ : record.getIntValue(CompositeDBAdapter.COMPOSITE_NUM_COMPONENTS_COL);
+
+ if (oldFlexArrayRecord != null) {
+ migrateOldFlexArray(oldFlexArrayRecord);
}
}
catch (IOException e) {
@@@ -205,8 -128,9 +206,8 @@@
DataTypeComponentDB dtc = null;
try {
if (dataType == DataType.DEFAULT) {
- // Structre will grow by 1-byte below (ignored by packed structure)
- // assume non-packed structure (non-stored undefined component)
- dtc = new DataTypeComponentDB(dataMgr, componentAdapter, this, key,
- numComponents, structLength);
++ // assume non-packed structure - structre will grow by 1-byte below
+ dtc = new DataTypeComponentDB(dataMgr, this, numComponents, structLength);
}
else {
int componentLength = getPreferredComponentLength(dataType, length);
diff --cc Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/StructureDataType.java
index faf215041e,c708242bcc..45209e1335
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/StructureDataType.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/StructureDataType.java
@@@ -577,9 -495,9 +577,8 @@@ public class StructureDataType extends
DataTypeComponentImpl dtc;
if (dataType == DataType.DEFAULT) {
- // Structre will grow by 1-byte below (ignored by packed structure)
- // FIXME: verify - does not appear to modify structure
-- dtc =
-- new DataTypeComponentImpl(DataType.DEFAULT, this, 1, numComponents, structLength);
++ // assume non-packed structure - structre will grow by 1-byte below
++ dtc = new DataTypeComponentImpl(DataType.DEFAULT, this, 1, numComponents, structLength);
}
else {
diff --cc Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/PcodeDataTypeManager.java
index 4c4a6c1595,44c76b31bb..63b9b912db
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/PcodeDataTypeManager.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/PcodeDataTypeManager.java
@@@ -591,23 -597,20 +591,21 @@@ public class PcodeDataTypeManager
sz = size;
isVarLength = true;
}
- appendNameIdAttributes(resBuf, origType);
+ appendNameIdAttributes(resBuf, type);
if (sz < 16) {
SpecXmlUtils.encodeStringAttribute(resBuf, "metatype", "unknown");
- SpecXmlUtils.encodeSignedIntegerAttribute(resBuf, "size", sz);
- resBuf.append('>');
}
else {
// Build an "opaque" structure with no fields
SpecXmlUtils.encodeStringAttribute(resBuf, "metatype", "struct");
- SpecXmlUtils.encodeSignedIntegerAttribute(resBuf, "size", sz);
- if (isVarLength) {
- SpecXmlUtils.encodeBooleanAttribute(resBuf, "varlength", isVarLength);
- }
- resBuf.append('>');
}
+ SpecXmlUtils.encodeSignedIntegerAttribute(resBuf, "size", sz);
+ if (isVarLength) {
+ SpecXmlUtils.encodeBooleanAttribute(resBuf, "varlength", true);
+ }
+ resBuf.append('>');
}
+ resBuf.append("</type>");
return resBuf.toString();
}