Skip to content

Ghidra is a software reverse engineering (SRE) framework

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

ghidra1d89b1f5bdcbe
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfProgramBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfProgramBuilder.java
index 77cea7bd16..f5542845da 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfProgramBuilder.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/ElfProgramBuilder.java
@@ -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);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MemorySectionResolver.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MemorySectionResolver.java
index fdd2f67513..e89a807870 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MemorySectionResolver.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MemorySectionResolver.java
@@ -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);
- 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);
+ }
+ if (block != null) {
+ minAddr = block.getStart();
+ maxAddr = block.getEnd();
+ }
+ else {
+ // block may be null due to unexpected conflict or pruning - allow to continue
minAddr = physicalStartAddr;
maxAddr = physicalStartAddr.addNoWrap(rangeSize - 1);
}