mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-28 09:40:26 +08:00
GP-6479 improve DWARF's handling of stuff with a zeroed out address
Typically will be funcs or global vars that just have 0 for their lowpc or the result of a expression that just hard codes DW_OP_addr 0.
This commit is contained in:
@@ -366,6 +366,14 @@ public class DWARFFunction {
|
|||||||
public boolean syncWithExistingGhidraFunction(boolean createIfMissing) {
|
public boolean syncWithExistingGhidraFunction(boolean createIfMissing) {
|
||||||
try {
|
try {
|
||||||
Program currentProgram = getProgram().getGhidraProgram();
|
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);
|
function = currentProgram.getListing().getFunctionAt(address);
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
if (function.hasNoReturn() && !noReturn) {
|
if (function.hasNoReturn() && !noReturn) {
|
||||||
|
|||||||
+5
@@ -388,6 +388,11 @@ public class DWARFFunctionImporter {
|
|||||||
Namespace namespace = globalVar.name.getParentNamespace(currentProgram);
|
Namespace namespace = globalVar.name.getParentNamespace(currentProgram);
|
||||||
String name = globalVar.name.getName();
|
String name = globalVar.name.getName();
|
||||||
Address address = globalVar.getRamAddress();
|
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;
|
DataType dataType = globalVar.type;
|
||||||
|
|
||||||
SymbolTable symbolTable = currentProgram.getSymbolTable();
|
SymbolTable symbolTable = currentProgram.getSymbolTable();
|
||||||
|
|||||||
@@ -617,6 +617,11 @@ public class DWARFProgram implements Closeable {
|
|||||||
.getAddress(offset + programBaseAddressFixup, true);
|
.getAddress(offset + programBaseAddressFixup, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isZeroDataAddress(Address addr) {
|
||||||
|
Address realZero = getDataAddress(0);
|
||||||
|
return realZero.equals(addr);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean stackGrowsNegative() {
|
public boolean stackGrowsNegative() {
|
||||||
return stackGrowsNegative;
|
return stackGrowsNegative;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user