Skip to content

Commit 7357b75

Browse files
committed
Merge remote-tracking branch 'origin/Ghidra_9.2'
2 parents 532d60c + 165a767 commit 7357b75

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,13 +1584,20 @@ bool Funcdata::ancestorOpUse(int4 maxlevel,const Varnode *invn,
15841584
// as an "only use"
15851585
if (def->isIndirectCreation())
15861586
return false;
1587-
// fallthru
1587+
return ancestorOpUse(maxlevel-1,def->getIn(0),op,trial);
15881588
case CPUI_MULTIEQUAL:
15891589
// Check if there is any ancestor whose only
15901590
// use is in this op
1591-
for(i=0;i<def->numInput();++i)
1592-
if (ancestorOpUse(maxlevel-1,def->getIn(i),op,trial)) return true;
1593-
1591+
if (def->isMark()) return false; // Trim the loop
1592+
def->setMark(); // Mark that this MULTIEQUAL is on the path
1593+
// Note: onlyOpUse is using Varnode::setMark
1594+
for(i=0;i<def->numInput();++i) {
1595+
if (ancestorOpUse(maxlevel-1,def->getIn(i),op,trial)) {
1596+
def->clearMark();
1597+
return true;
1598+
}
1599+
}
1600+
def->clearMark();
15941601
return false;
15951602
case CPUI_COPY:
15961603
if ((invn->getSpace()->getType()==IPTR_INTERNAL)||def->isIncidentalCopy()||def->getIn(0)->isIncidentalCopy()) {

Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileCallback.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,17 @@ public String getExternalRefXML(String addrstring) { // Return any external refe
757757
if (extRef != null) {
758758
func = listing.getFunctionAt(extRef.getToAddress());
759759
if (func == null) {
760+
Symbol symbol = extRef.getExternalLocation().getSymbol();
761+
long extId;
762+
if (symbol != null) {
763+
extId = symbol.getID();
764+
}
765+
else {
766+
extId = program.getSymbolTable().getDynamicSymbolID(addr);
767+
768+
}
760769
HighSymbol shellSymbol =
761-
new HighFunctionShellSymbol(0, extRef.getLabel(), addr, dtmanage);
770+
new HighFunctionShellSymbol(extId, extRef.getLabel(), addr, dtmanage);
762771
return buildResult(shellSymbol, null);
763772
}
764773
}

Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunction.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@ public Function getFunction() {
7979
}
8080

8181
/**
82-
* Get the id with the associated function symbol, if it exists
83-
* @return the id or 0 otherwise
82+
* Get the id with the associated function symbol, if it exists.
83+
* Otherwise return a dynamic id based on the entry point.
84+
* @return the symbol id, or possibly a dynamic id
8485
*/
8586
public long getID() {
8687
if (func instanceof FunctionDB) {
8788
return func.getSymbol().getID();
8889
}
89-
return 0;
90+
return func.getProgram().getSymbolTable().getDynamicSymbolID(func.getEntryPoint());
9091
}
9192

9293
/**

Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionShellSymbol.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public boolean isGlobal() {
5555
@Override
5656
public void saveXML(StringBuilder buf) {
5757
buf.append("<function");
58+
SpecXmlUtils.encodeUnsignedIntegerAttribute(buf, "id", getId());
5859
SpecXmlUtils.xmlEscapeAttribute(buf, "name", name);
5960
SpecXmlUtils.encodeSignedIntegerAttribute(buf, "size", 1);
6061
buf.append(">\n");

0 commit comments

Comments
 (0)