Corrected bitfield related regression issues

This commit is contained in:
ghidra1 2020-02-06 12:45:11 -05:00
parent 36b1246829
commit 05fba7639c
4 changed files with 75 additions and 55 deletions

View file

@ -772,7 +772,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
private DataType resolveBitFieldDataType(BitFieldDataType bitFieldDataType,
DataTypeConflictHandler handler) {
// NOTE: When a bit-field is getting adding added it will get resolved more than once.
// NOTE: When a bit-field is getting added it will get resolved more than once.
// The first time we will ensure that the base data type, which may be a TypeDef, gets
// resolved. If the bit-offset is too large it will be set to 0
// with the expectation that it will get corrected during subsequent packing.
@ -786,7 +786,8 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
int storageSizeBits = 8 * storageSize;
if ((bitOffset + bitSize) > storageSizeBits) {
// should get recomputed during packing when used within aligned structure
bitOffset = getDataOrganization().isBigEndian() ? baseLengthBits - bitSize : 0;
int effectiveBitSize = Math.min(bitSize, baseLengthBits);
bitOffset = getDataOrganization().isBigEndian() ? baseLengthBits - effectiveBitSize : 0;
storageSize = baseLength;
}
try {

View file

@ -997,10 +997,7 @@ class StructureDB extends CompositeDB implements Structure {
if (ordinal < 0 || ordinal >= numComponents) {
throw new ArrayIndexOutOfBoundsException(ordinal);
}
if (dataType instanceof BitFieldDataType) {
throw new IllegalArgumentException(
"Components may not be replaced with a bit-field");
}
validateDataType(dataType);
DataTypeComponent origDtc = getComponent(ordinal);
@ -1044,9 +1041,7 @@ class StructureDB extends CompositeDB implements Structure {
throw new IllegalArgumentException(
"Offset " + offset + " is beyond end of structure (" + structLength + ").");
}
if (dataType instanceof BitFieldDataType) {
throw new IllegalArgumentException("Components may not be replaced with a bit-field");
}
lock.acquire();
try {
checkDeleted();

View file

@ -1149,9 +1149,6 @@ public class StructureDataType extends CompositeDataTypeImpl implements Structur
if (index < 0 || index >= numComponents) {
throw new ArrayIndexOutOfBoundsException(index);
}
if (dataType instanceof BitFieldDataType) {
throw new IllegalArgumentException("Components may not be replaced with a bit-field");
}
validateDataType(dataType);
@ -1191,9 +1188,6 @@ public class StructureDataType extends CompositeDataTypeImpl implements Structur
throw new IllegalArgumentException(
"Offset " + offset + " is beyond end of structure (" + structLength + ").");
}
if (dataType instanceof BitFieldDataType) {
throw new IllegalArgumentException("Components may not be replaced with a bit-field");
}
validateDataType(dataType);