Merge remote-tracking branch 'origin/GP-493_ghidravore_graph_goto_fake_functions--SQUASHED' into patch

This commit is contained in:
ghidravore 2020-12-14 11:54:12 -05:00
commit 19aec078e0

View file

@ -20,6 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import docking.widgets.EventTrigger;
import ghidra.app.events.*;
import ghidra.app.nav.NavigationUtils;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginEvent;
import ghidra.framework.plugintool.PluginTool;
@ -158,9 +159,22 @@ public abstract class AddressBasedGraphDisplayListener
if (symbols.isEmpty()) {
return null;
}
// there should only be one external symbol with the same name, so just assume the first one is good
return symbols.get(0).getAddress();
// There should only be one external symbol with the same name.
// Since externals are not shown in the listing, we are going to do a hack and try
// and navigate to a "fake" function if one exists. A "fake" function in Ghidra is just
// an indirect pointer to the external function. If such a pointer exists, Ghidra marks
// up the location with the function signature.
Address symbolAddress = symbols.get(0).getAddress();
if (symbolAddress.isExternalAddress()) {
Address[] externalLinkageAddresses =
NavigationUtils.getExternalLinkageAddresses(program, symbolAddress);
// If this is a "fake" function situation, then there should only be one address
if (externalLinkageAddresses.length == 1) {
symbolAddress = externalLinkageAddresses[0];
}
}
return symbolAddress;
}
protected Address getAddress(AttributedVertex vertex) {