Ghidra is a software reverse engineering (SRE) framework
GP-1502 stopping FID analyzer from running twice on programs with callfixups or identified non-returning flow
emteere436ca68c0794
diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/analyzer/FidAnalyzer.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/analyzer/FidAnalyzer.javaindex 65b130f24f..2d349f4a9f 100644--- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/analyzer/FidAnalyzer.java+++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/analyzer/FidAnalyzer.java@@ -15,16 +15,23 @@*/package ghidra.feature.fid.analyzer;+import java.io.IOException;+import java.util.Iterator;+import ghidra.app.plugin.core.analysis.AutoAnalysisManager;import ghidra.app.services.*;import ghidra.app.util.importer.MessageLog;import ghidra.feature.fid.cmd.ApplyFidEntriesCommand;-import ghidra.feature.fid.service.FidService;+import ghidra.feature.fid.db.FidQueryService;+import ghidra.feature.fid.service.*;import ghidra.framework.options.Options;import ghidra.program.model.address.AddressSetView;+import ghidra.program.model.listing.Function;import ghidra.program.model.listing.Program;+import ghidra.program.model.mem.MemoryAccessException;import ghidra.util.Msg;import ghidra.util.exception.CancelledException;+import ghidra.util.exception.VersionException;import ghidra.util.task.TaskMonitor;/**@@ -105,6 +112,11 @@ public class FidAnalyzer extends AbstractAnalyzer {Msg.warn(this, "No FID Libraries apply for language " + program.getLanguageID());return false;}++ if (!isFullExecutable(program, set)) {+ return true;+ }+ApplyFidEntriesCommand cmd;cmd = new ApplyFidEntriesCommand(set, scoreThreshold, multiScoreThreshold,alwaysApplyFidLabels, createBookmarksEnabled);@@ -112,11 +124,30 @@ public class FidAnalyzer extends AbstractAnalyzer {// Name Change can change the nature of a function from a system// library. Probably a better way to do this.- AutoAnalysisManager.getAnalysisManager(program).functionModifierChanged(- cmd.getFIDLocations());+ AutoAnalysisManager.getAnalysisManager(program)+ .functionModifierChanged(cmd.getFIDLocations());return true;}+ /**+ * Check if set contains the full executable or loaded/initialized memory areas.+ *+ * @param program program to check+ * @param set set to check+ * @return true if all program executable or load/initialized memory is in set+ */+ private boolean isFullExecutable(Program program, AddressSetView set) {+ // if has an execute set, then set to FID, must contain the execute set+ AddressSetView executeSet = program.getMemory().getExecuteSet();+ if (!executeSet.isEmpty()) {+ return set.contains(executeSet);+ }++ // if there are no execute blocks, then use loaded/initialized for program blocks+ AddressSetView loadSet = program.getMemory().getLoadedAndInitializedAddressSet();+ return set.contains(loadSet);+ }+@Overridepublic void registerOptions(Options options, Program program) {options.registerOption(SCORE_THRESHOLD_OPTION_NAME, service.getDefaultScoreThreshold(),