Merge remote-tracking branch 'origin/GP-3261_PartialUnionStripping'

This commit is contained in:
Ryan Kurtz 2023-03-27 09:56:40 -04:00
commit 2baf786689
2 changed files with 14 additions and 0 deletions

View file

@ -19,6 +19,8 @@ import java.util.Iterator;
import java.util.Map.Entry;
import java.util.TreeMap;
import ghidra.program.model.pcode.PartialUnion;
/**
* Build a structure from a "noisy" source of field information.
* Feed it field records, either via addDataType(), when we
@ -92,6 +94,11 @@ public class NoisyStructureBuilder {
dt = manager.getPointer(DataType.DEFAULT, dt.getLength());
}
}
else if (dt instanceof PartialUnion) {
// The decompiler can produce the internal data-type PartialUnion, which must
// be replaced with a suitable formal data-type within the structure being built
dt = ((PartialUnion) dt).getStrippedDataType();
}
computeMax(offset, dt.getLength());
Entry<Long, DataType> firstEntry = checkForOverlap(offset, dt.getLength());
if (firstEntry != null) {

View file

@ -119,4 +119,11 @@ public class PartialUnion extends AbstractDataType {
return 0;
}
/**
* Get a data-type that can be used as a formal replacement for this (internal) data-type
* @return a replacement data-type
*/
public DataType getStrippedDataType() {
return Undefined.getUndefinedDataType(size);
}
}