Skip to content

Ghidra is a software reverse engineering (SRE) framework

Scope id fix for external references

caheckman078159dd2912
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileCallback.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileCallback.java
index 92002b4d14..1140ca057f 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileCallback.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileCallback.java
@@ -757,8 +757,17 @@ public class DecompileCallback {
if (extRef != null) {
func = listing.getFunctionAt(extRef.getToAddress());
if (func == null) {
+ Symbol symbol = extRef.getExternalLocation().getSymbol();
+ long extId;
+ if (symbol != null) {
+ extId = symbol.getID();
+ }
+ else {
+ extId = program.getSymbolTable().getDynamicSymbolID(addr);
+
+ }
HighSymbol shellSymbol =
- new HighFunctionShellSymbol(0, extRef.getLabel(), addr, dtmanage);
+ new HighFunctionShellSymbol(extId, extRef.getLabel(), addr, dtmanage);
return buildResult(shellSymbol, null);
}
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionShellSymbol.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionShellSymbol.java
index 82857373c1..ec8782fb5b 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionShellSymbol.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionShellSymbol.java
@@ -55,6 +55,7 @@ public class HighFunctionShellSymbol extends HighSymbol {
@Override
public void saveXML(StringBuilder buf) {
buf.append("<function");
+ SpecXmlUtils.encodeUnsignedIntegerAttribute(buf, "id", getId());
SpecXmlUtils.xmlEscapeAttribute(buf, "name", name);
SpecXmlUtils.encodeSignedIntegerAttribute(buf, "size", 1);
buf.append(">\n");