Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3044 Removed check for instructions that might fall into the top of a function being considered for a shared return function

emteere86040a79f95e
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/analysis/SharedReturnAnalysisCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/analysis/SharedReturnAnalysisCmd.java
index 90b09dede6..cc64aafe59 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/analysis/SharedReturnAnalysisCmd.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/analysis/SharedReturnAnalysisCmd.java
@@ -68,7 +68,7 @@ public class SharedReturnAnalysisCmd extends BackgroundCommand {
SymbolTable symbolTable = program.getSymbolTable();
SymbolIterator fnSymbols = symbolTable.getSymbols(set, SymbolType.FUNCTION, true);
while (fnSymbols.hasNext()) {
- monitor.checkCanceled();
+ monitor.checkCancelled();
Symbol s = fnSymbols.next();
Address entry = s.getAddress();
@@ -82,7 +82,7 @@ public class SharedReturnAnalysisCmd extends BackgroundCommand {
fnSymbols = symbolTable.getSymbols(set, SymbolType.FUNCTION, true);
while (fnSymbols.hasNext()) {
- monitor.checkCanceled();
+ monitor.checkCancelled();
Symbol s = fnSymbols.next();
checkAboveFunction(s, jumpScanSet);
checkBelowFunction(s, jumpScanSet);
@@ -96,7 +96,7 @@ public class SharedReturnAnalysisCmd extends BackgroundCommand {
ReferenceManager refMgr = program.getReferenceManager();
AddressIterator refSrcIter = refMgr.getReferenceSourceIterator(jumpScanSet, true);
while (refSrcIter.hasNext()) {
- monitor.checkCanceled();
+ monitor.checkCancelled();
Address srcAddr = refSrcIter.next();
RefType flow = null;
Address destAddr = null;
@@ -283,7 +283,10 @@ public class SharedReturnAnalysisCmd extends BackgroundCommand {
if (fallFrom != null) {
Instruction fallInstr = program.getListing().getInstructionContaining(fallFrom);
if (fallInstr != null && location.equals(fallInstr.getFallThrough())) {
- return true;
+ // if there is a function above, then it falls into this routine
+ if (program.getFunctionManager().getFunctionContaining(fallFrom) != null) {
+ return true;
+ }
}
}
return false;
@@ -341,7 +344,7 @@ public class SharedReturnAnalysisCmd extends BackgroundCommand {
InstructionIterator instructionIter = program.getListing().getInstructions(set, true);
while (instructionIter.hasNext()) {
- monitor.checkCanceled();
+ monitor.checkCancelled();
Instruction instr = instructionIter.next();
FlowType ft = instr.getFlowType();
if (!ft.isJump()) {
@@ -371,11 +374,6 @@ public class SharedReturnAnalysisCmd extends BackgroundCommand {
private void processFunctionJumpReferences(Program program, Address entry, TaskMonitor monitor)
throws CancelledException {
- // check if there is any fallthru flow to the entry point
- if (hasFallThruTo(program, entry)) {
- return;
- }
-
// since reference fixup will occur when flow override is done,
// avoid concurrent modification during reference iterator use
// by building list of jump references
@@ -387,7 +385,7 @@ public class SharedReturnAnalysisCmd extends BackgroundCommand {
FunctionManager funcMgr = program.getFunctionManager();
for (Reference ref : fnRefList) {
- monitor.checkCanceled();
+ monitor.checkCancelled();
Instruction instr = program.getListing().getInstructionAt(ref.getFromAddress());
if (instr == null) {
continue;
@@ -429,7 +427,7 @@ public class SharedReturnAnalysisCmd extends BackgroundCommand {
List<Reference> fnRefList = null;
ReferenceIterator referencesTo = program.getReferenceManager().getReferencesTo(entry);
while (referencesTo.hasNext()) {
- monitor.checkCanceled();
+ monitor.checkCancelled();
Reference ref = referencesTo.next();
if (!ref.getReferenceType().isJump()) {
continue;