fix(ghidra): clear wrong no-return flags before serving a session (#1419)
* fix(ghidra): clear wrong no-return flags before serving a session Auto-analysis can flag ordinary functions as no-return (stream readers, __cxa_guard_acquire, ...). Their callers then end at the call and the decompiler truncates them. Run a postScript before the bridge that clears the flag on functions containing a real RET and re-disassembles the call sites that were terminators. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(ghidra): refit in place and scope no-return call-site repair Keep function types by refitting the owning functions with fixupFunctionBody instead of removing and recreating them. Only redo call sites whose callee was actually cleared (including thunks to it), skip sites followed by a function start or x86 padding so real end calls do not run on, and always log the result. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(ghidra): constrain no-return repair to admitted return evidence --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
morluto
parent
fef6f73064
commit
162f9bf7ff
@@ -134,6 +134,7 @@ export class GhidraHeadlessLauncher implements GhidraLauncher {
|
||||
if (isAborted(options.signal))
|
||||
return err(new AnalysisCancelledError("open_binary"));
|
||||
const headlessArguments = ghidraHeadlessArguments({
|
||||
platform,
|
||||
projectRoot: paths.projectRoot,
|
||||
targetPath: session.targetPath,
|
||||
bridgeScriptPath: this.options.bridgeScriptPath,
|
||||
@@ -358,6 +359,7 @@ const cleanupStartedProcess = (
|
||||
|
||||
/** Paths encoded into one bounded analyzeHeadless invocation. */
|
||||
export interface GhidraHeadlessArgumentOptions {
|
||||
readonly platform?: NodeJS.Platform;
|
||||
readonly projectRoot: string;
|
||||
readonly targetPath: string;
|
||||
readonly bridgeScriptPath: string;
|
||||
@@ -411,6 +413,12 @@ export const ghidraHeadlessArguments = (
|
||||
join(dirname(options.bridgeScriptPath), "ReaGhidraPrepareCom.java"),
|
||||
]
|
||||
: []),
|
||||
...((options.platform ?? process.platform) === "win32"
|
||||
? []
|
||||
: [
|
||||
"-postScript",
|
||||
join(dirname(options.bridgeScriptPath), "ReaGhidraNoReturnFix.java"),
|
||||
]),
|
||||
"-postScript",
|
||||
// Ghidra checks the caller's cwd before scriptPath for a basename. Select
|
||||
// the packaged source explicitly so unrelated entries cannot shadow it.
|
||||
|
||||
Reference in New Issue
Block a user