GP-1090 corrected NPE related to recent change. Check for existing data

before attempted creation.
This commit is contained in:
ghidra1 2021-07-16 17:46:39 -04:00
parent a05125de6d
commit d89b1f5bdc
2 changed files with 12 additions and 5 deletions

View file

@ -1962,7 +1962,11 @@ class ElfProgramBuilder extends MemorySectionResolver implements ElfLoadHelper {
if (length == 0) {
length = 1;
}
program.getListing().createData(address, Undefined.getUndefinedDataType(length));
Data d = listing.getDefinedDataAt(address);
if (d != null && d.getLength() == length) {
return d;
}
listing.createData(address, Undefined.getUndefinedDataType(length));
}
catch (CodeUnitInsertionException e) {
Msg.warn(this, "ELF data markup conflict at " + address);

View file

@ -369,18 +369,21 @@ public abstract class MemorySectionResolver {
comment = comment + " - displaced by " + priorityBlock.getName();
}
}
// As an overlay no conflict should ever occur
block = createInitializedBlock(section.key, true, blockName, physicalStartAddr,
fileOffset, rangeSize, comment, section.isReadable(), section.isWritable(),
section.isExecute(), monitor);
}
else {
block = createInitializedBlock(section.key, false, blockName, physicalStartAddr,
fileOffset, rangeSize, section.getComment(), section.isReadable(),
section.isWritable(), section.isExecute(), monitor);
}
if (block != null) {
minAddr = block.getStart();
maxAddr = block.getEnd();
}
else {
// block may be null due to unexpected conflict or pruning - allow to continue
block = createInitializedBlock(section.key, false, blockName, physicalStartAddr,
fileOffset, rangeSize, section.getComment(), section.isReadable(),
section.isWritable(), section.isExecute(), monitor);
minAddr = physicalStartAddr;
maxAddr = physicalStartAddr.addNoWrap(rangeSize - 1);
}