mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Merge remote-tracking branch 'origin/Ghidra_9.2'
This commit is contained in:
commit
027ba3884a
11 changed files with 114 additions and 33 deletions
|
@ -129,13 +129,14 @@ public final class DataUtilities {
|
|||
return data;
|
||||
}
|
||||
|
||||
if (clearMode == ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA &&
|
||||
if (!stackPointers && clearMode == ClearDataMode.CLEAR_ALL_UNDEFINED_CONFLICT_DATA &&
|
||||
!Undefined.isUndefined(existingDT)) {
|
||||
throw new CodeUnitInsertionException("Could not create Data at address " + addr);
|
||||
}
|
||||
|
||||
// Check for external reference on pointer
|
||||
if (existingDT instanceof Pointer) {
|
||||
if ((stackPointers || newDataType instanceof Pointer) &&
|
||||
existingDT instanceof Pointer) {
|
||||
// TODO: This can probably be eliminated
|
||||
Reference[] refs = refMgr.getReferencesFrom(addr);
|
||||
for (Reference ref : refs) {
|
||||
|
@ -174,19 +175,26 @@ public final class DataUtilities {
|
|||
throw new CodeUnitInsertionException(
|
||||
"Could not create DataType " + newDataType.getDisplayName());
|
||||
}
|
||||
|
||||
if (stackPointers && existingDT instanceof Pointer && newDataType instanceof Pointer) {
|
||||
listing.clearCodeUnits(addr, addr, false);
|
||||
}
|
||||
|
||||
Data newData;
|
||||
try {
|
||||
return listing.createData(addr, dti.getDataType(), dti.getLength());
|
||||
newData = listing.createData(addr, dti.getDataType(), dti.getLength());
|
||||
}
|
||||
catch (CodeUnitInsertionException e) {
|
||||
// ok lets see if we need to clear some code units
|
||||
if (clearMode == ClearDataMode.CLEAR_SINGLE_DATA) {
|
||||
listing.clearCodeUnits(addr, addr, false);
|
||||
}
|
||||
else {
|
||||
checkEnoughSpace(program, addr, existingDataLen, dti, clearMode);
|
||||
}
|
||||
newData = listing.createData(addr, dti.getDataType(), dti.getLength());
|
||||
}
|
||||
if (clearMode == ClearDataMode.CLEAR_SINGLE_DATA) {
|
||||
listing.clearCodeUnits(addr, addr, false);
|
||||
}
|
||||
else {
|
||||
checkEnoughSpace(program, addr, existingDataLen, dti, clearMode);
|
||||
}
|
||||
Data newData = listing.createData(addr, dti.getDataType(), dti.getLength());
|
||||
|
||||
// if this was a pointer and had an external reference, put it back!
|
||||
if ((newDataType instanceof Pointer) && extRef != null) {
|
||||
ExternalLocation extLoc = ((ExternalReference) extRef).getExternalLocation();
|
||||
|
@ -203,6 +211,7 @@ public final class DataUtilities {
|
|||
|
||||
private static void checkEnoughSpace(Program program, Address addr, int existingDataLen,
|
||||
DataTypeInstance dti, ClearDataMode mode) throws CodeUnitInsertionException {
|
||||
// NOTE: method not invoked when clearMode == ClearDataMode.CLEAR_SINGLE_DATA
|
||||
Listing listing = program.getListing();
|
||||
try {
|
||||
Address end = addr.addNoWrap(existingDataLen - 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue