mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-3107 corrected issues related to resolving datatype from program to
an archive or composite editor.
This commit is contained in:
parent
6f35c7ec47
commit
efe7088757
1 changed files with 21 additions and 5 deletions
|
@ -1042,6 +1042,9 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
return resolvedDataType;
|
||||
}
|
||||
|
||||
// TODO: delayed pointer-resolve use of "undefined *" could cause unintended
|
||||
// equivalence match. May need to use an internal reserved type instead.
|
||||
|
||||
SourceArchive sourceArchive = dataType.getSourceArchive();
|
||||
if (sourceArchive != null && sourceArchive.getArchiveType() == ArchiveType.BUILT_IN) {
|
||||
resolvedDataType = resolveBuiltIn(dataType, currentHandler);
|
||||
|
@ -1411,6 +1414,15 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
return existingDataType;
|
||||
}
|
||||
|
||||
if (sourceArchive.getSourceArchiveID().equals(getUniversalID())) {
|
||||
// Avoid conflict handling for types with a source which matches
|
||||
// this archive, although a conflict name may still be used.
|
||||
// This can occur when a semi-mirrored archive instance is used
|
||||
// such as the CompositeViewerDataTypeManager which uses the same
|
||||
// Archive UniversalID as the edited datatype's source.
|
||||
return createDataType(dataType, sourceArchive, handler);
|
||||
}
|
||||
|
||||
// If we have the same path name and the existing data type is a local data type
|
||||
// and is equivalent to this one, then associate it with the source archive
|
||||
existingDataType = findEquivalentDataTypeSameLocation(dataType);
|
||||
|
@ -1421,7 +1433,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
}
|
||||
return existingDataType;
|
||||
}
|
||||
|
||||
|
||||
return resolveNoEquivalentFound(dataType, sourceArchive, handler);
|
||||
}
|
||||
|
||||
|
@ -1437,11 +1449,15 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
private DataType resolveNoEquivalentFound(DataType dataType, SourceArchive sourceArchive,
|
||||
DataTypeConflictHandler handler) {
|
||||
|
||||
if (sourceArchive != null && sourceArchive.getArchiveType() == ArchiveType.PROGRAM) {
|
||||
sourceArchive = null; // do not preserve program as a source archive
|
||||
}
|
||||
|
||||
// If not found, do we have the same named data type in the same category already?
|
||||
// (preference is given to similar kind of datatype when checking existing conflict types)
|
||||
DataType existingDataType = findDataTypeSameLocation(dataType);
|
||||
if (existingDataType == null) {
|
||||
return createDataType(dataType, handler);
|
||||
return createDataType(dataType, sourceArchive, handler);
|
||||
}
|
||||
|
||||
// So we have a dataType with the same path and name, but not equivalent, so use
|
||||
|
@ -1472,15 +1488,15 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
}
|
||||
|
||||
case RENAME_AND_ADD: // default handler behavior
|
||||
return createDataType(dataType, handler);
|
||||
return createDataType(dataType, sourceArchive, handler);
|
||||
|
||||
default: // USE_EXISTING - new type is discarded and old conflicted type is returned
|
||||
return existingDataType;
|
||||
}
|
||||
}
|
||||
|
||||
private DataType createDataType(DataType dataType, DataTypeConflictHandler handler) {
|
||||
SourceArchive sourceArchive = dataType.getSourceArchive();
|
||||
private DataType createDataType(DataType dataType, SourceArchive sourceArchive,
|
||||
DataTypeConflictHandler handler) {
|
||||
String dtName = getUnusedConflictName(dataType);
|
||||
DataType newDataType = createDataType(dataType, dtName, sourceArchive, handler);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue