Ghidra is a software reverse engineering (SRE) framework
GP-6479 improve DWARF's handling of stuff with a zeroed out address
dev7473681b45dbd472f8
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFFunction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFFunction.javaindex a16abf808c..da55530e66 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFFunction.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFFunction.java@@ -366,6 +366,14 @@ public class DWARFFunction {public boolean syncWithExistingGhidraFunction(boolean createIfMissing) {try {Program currentProgram = getProgram().getGhidraProgram();+ if (!currentProgram.getMemory().getExecuteSet().contains(address)) {+ // NOTE: if func's DIE specifies a lowpc == 0, the calculated address will be+ // the program's imagebase. This typically can only be valid in .o files.+ // If this binary is not a .o, and doesn't have executable segment at '0'+ // (or where ever the binary was imported at), then the addr = 0 is probably+ // just bad data that the toolchain put into the dwarf info.+ return false; // dwarf function address info is probably bogus+ }function = currentProgram.getListing().getFunctionAt(address);if (function != null) {if (function.hasNoReturn() && !noReturn) {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFFunctionImporter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFFunctionImporter.javaindex 8e38092891..ce07df2d68 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFFunctionImporter.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFFunctionImporter.java@@ -388,6 +388,11 @@ public class DWARFFunctionImporter {Namespace namespace = globalVar.name.getParentNamespace(currentProgram);String name = globalVar.name.getName();Address address = globalVar.getRamAddress();+ if (prog.isZeroDataAddress(address)) {+ // skip, its probably an incomplete DIE with a zero-d out location / address+ // we can't create a bookmark with a warning since we don't have a good address.+ return;+ }DataType dataType = globalVar.type;SymbolTable symbolTable = currentProgram.getSymbolTable();diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFProgram.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFProgram.javaindex b1275206c4..9537127ed7 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFProgram.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFProgram.java@@ -617,6 +617,11 @@ public class DWARFProgram implements Closeable {.getAddress(offset + programBaseAddressFixup, true);}+ public boolean isZeroDataAddress(Address addr) {+ Address realZero = getDataAddress(0);+ return realZero.equals(addr);+ }+public boolean stackGrowsNegative() {return stackGrowsNegative;}