feat(ghidra): admit bounded PSP ELF through installed Allegrex (#1599)

* feat(ghidra): admit bounded PSP ELF through installed Allegrex

Build on merged generic MIPS without weakening its policy. Bind caller-installed processor files into the analysis profile, check them again before launch, force and verify PSP language selection, retain limitations, and extend the public CLI/MCP verifier with source-owned PSP and target-switching checks. Local actual focused Vitest: 102 passed, one existing permission skip. Hosted static and real-provider results are pending.

* fix(ghidra): validate PSPSDK ABI records in PSP admission

* test(ghidra): bind PSP ABI verification to snapshot profiles

* test(ghidra): declare independent PSP ABI reader contract

* test(ghidra): retain the PSP fixture discriminated type

* test(ghidra): contextually type PSP metadata as the MIPS target variant

* test(ghidra): keep carved firmware checks scoped to generic MIPS fixtures

* style(ghidra): format PSP language-override guard

* style(test): format PSP language override regressions

* fix(ghidra): bound PSP extension enumeration before allocation

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
Jay-Alexander Elliot
2026-10-11 19:47:33 +08:00
committed by GitHub
co-authored by github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> morluto
parent 0153b4d95b
commit e4407dbed5
17 changed files with 1637 additions and 146 deletions
+30 -5
View File
@@ -13,10 +13,13 @@ import { ProviderAdapterError } from "../domain/providerAdapterError.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
import { err, ok, type Result } from "../domain/result.js";
import type { GhidraInstallationInspection } from "./GhidraInstallation.js";
import { ghidraMipsProfileParameters } from "./GhidraMipsProfile.js";
import {
ghidraMipsProfileParameters,
ghidraMipsUnsupportedReason,
} from "./GhidraMipsProfile.js";
ghidraProcessorUnsupportedReason,
isGhidraPspTarget,
} from "./GhidraPspProfile.js";
import { resolveGhidraPspExtension } from "./GhidraPspExtension.js";
import {
NATIVE_AOT_MAX_REPORT_BYTES,
NATIVE_AOT_MAX_SOURCE_BYTES,
@@ -26,7 +29,7 @@ import {
} from "../domain/native/nativeAotPe.js";
/** Resolve version-bound, deterministic semantics before Ghidra imports a target. */
export const resolveGhidraAnalysisProfile = (
export const resolveGhidraAnalysisProfile = async (
target: BinaryTarget,
identity: ProviderIdentity,
installation: GhidraInstallationInspection,
@@ -41,7 +44,7 @@ export const resolveGhidraAnalysisProfile = (
return Promise.resolve(
err(new ProviderAdapterError(identity.id, "resolve_analysis_profile")),
);
const mipsReason = ghidraMipsUnsupportedReason(target);
const mipsReason = ghidraProcessorUnsupportedReason(target);
if (mipsReason !== null)
return Promise.resolve(
err(
@@ -52,6 +55,19 @@ export const resolveGhidraAnalysisProfile = (
),
),
);
// A caller-selected generic processor cannot override this verified PSP loader.
if (isGhidraPspTarget(target) && languageOverride !== undefined)
return err(
new AnalysisUnsupportedTargetError(
"resolve_analysis_profile",
target.path,
"The bounded PSP Allegrex profile does not accept REA_GHIDRA_LANGUAGE_ID overrides.",
),
);
const pspExtension = isGhidraPspTarget(target)
? await resolveGhidraPspExtension(installation, signal)
: null;
if (pspExtension !== null && !pspExtension.ok) return pspExtension;
const provider = { ...identity, version: installation.providerVersion };
const dosMz = target.format === "dos-mz";
const dosCom = target.format === "dos-com";
@@ -151,6 +167,15 @@ export const resolveGhidraAnalysisProfile = (
: {}),
analyzer_preset: "ghidra-default",
...ghidraMipsProfileParameters(target),
...(pspExtension?.ok === true
? {
mips_support_lane: "psp-elf32-exec-eabi32-allegrex-v2",
loader: "PspElfLoader",
language_id: "Allegrex:LE:32:default",
compiler_spec_id: "default",
psp_extension: { ...pspExtension.value },
}
: {}),
}),
}),
);