Repository navigation
feat(ghidra): admit PlayStation 2 EE executables through ghidra-emotionengine-reloaded - #5240
litterboks wants to merge 6 commits into
Conversation
…eloaded Admit little-endian ELF32 ET_EXEC MIPS targets whose machine field declares EF_MIPS_MACH_5900 (ISA EF_MIPS_ARCH_3, ABI EABI64 or none, optionally NOREORDER, no ABI flags record, no GNU attributes) -- the declaration ee-gcc writes for retail executables. The lane pins r5900:LE:32:default with the default compiler specification through the standard ELF loader, refuses a caller-selected language, and fingerprints the caller-installed ghidra-emotionengine-reloaded extension before profile resolution and again before launch, as the PSP lane does for ghidra-allegrex. The PSP extension inspection is generalised into a processor-extension inspection parameterised by id, label, failure code and required files; the PSP exports and messages are unchanged. Verified against a retail SCES_511.90 (e_flags 0x20924000) with Ghidra 12.1.4 and extension v2.1.38: profile lane ps2-elf32-exec-eabi64-r5900-v1, decompilation with the extension's MMIO labels and COP2 intrinsics.
|
@litterboks thanks for the PR — there is 1 open review thread here:
Could you address or reply to this? Once it's resolved and CI is green we can take another look. |
|
@litterboks also, this branch has merge conflicts with |
Resolve the conflicts with the reworked Ghidra provider: - The processor-extension inspection now lives in GhidraProcessorExtension.ts, generalised from main's GhidraPspExtension.ts (typed admission codes, shared failure classifier). PSP exports, codes and messages are unchanged. - The EE wiring follows main's helpers: languageOverrideConflict for caller language overrides, ghidraProfileConflict at open, the required launch resource scope, and HOST_PLATFORM for the host check. - Main now binds the committed MIPS lane at open. The EE lane replaces the generic lane and ABI basis there; without that, every resolved EE profile was refused at open as resolved for a different target.
The EE extension spec required r5900.slaspec but not r5900.sla, so an installation with SLEIGH sources only was fingerprinted and admitted. Ghidra 12.2's SleighLanguageFile.needsCompilation recompiles a missing, wrong-format or stale .sla and writes it into the installation, which a read-only EE open must not cause. The shared processor-extension owner now takes an optional compiled-language declaration and, during the same bounded inspection, refuses before any JVM starts when the compiled file is missing, lacks the "sla" format-4 header, or is older (whole milliseconds, as Java compares) than its .slaspec or any file reachable through @include. Every @include line counts, conditional or not; absolute, variable, escaping, missing and cyclic includes are refused, so the check can only refuse more than Ghidra would recompile. Refusals report EE_EXTENSION_UNAVAILABLE with compiled_language_* codes and precompile guidance. The launcher re-inspection applies the same rule. PSP declares no compiled-language check and is unchanged. Boundary tests cover fresh, equal-time, missing, old-format, non-SLA, stale-source, stale-include, unincluded-source and unresolved-include cases, assert that refusals leave the installation byte- and mtime-identical, and that a language turning stale after resolution stops the launcher before spawning.
[Medium impact] The latest changes appear safe to merge; no new blocking issue was found. SummaryAdds bounded PlayStation 2 EE analysis through a caller-installed Ghidra extension.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Inspect EE ELF declarations] --> B[Inspect installed extension]
B --> C[Check compiled language]
C --> D[Resolve pinned profile and ABI basis]
D --> E[Recheck extension before launch]
E --> F[Start Ghidra]
B -->|Unavailable| G[Return setup hint]
C -->|Missing or stale| G
E -->|Unavailable or changed| G
Reviews (4) · Last reviewed commit: "fix(ghidra): state an inferred EE ABI an..." · Reviewed by Greptile |
- The EE profile committed language_selection "provider-pinned-v1", which ghidraProfileLanguageOverride does not read, so open compared an undefined committed language with the pinned r5900 language and refused every resolved EE profile. Commit "provider-pinned" like the other pinned lanes. A boundary test now resolves the profile and opens it through the client seam, asserting the pinned language and the EE extension reach the launcher. - EE admission reused the generic MIPS GNU-attribute rule, which admits records verified for generic MIPS. The EE boundary is producers without GNU MIPS attributes, so any attributes section, and an uninspected one, is refused, with negative tests. - Move the guide to docs/providers/ghidra-ps2.md beside the MIPS and PSP guides, which its relative links expect, and register it in docs/README.md and docs/.vitepress/documentation.ts.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@morluto the review threads are addressed and the branch is merged with main without conflicts. Could a maintainer please approve the workflow runs for this fork PR (CI, PR title, CodeQL production), which are waiting on |
|
Some context for review. The latest changes were prepared with an AI coding agent on behalf of @litterboks, who owns the PR and marked it ready. Everything below was run as described. What changed since the last review
Verification
Open points
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e8492270a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- An EE header without an ABI field is admitted, but the profile recorded declared-eabi64-r5900-extension-v1 for it. It now commits inferred-eabi64-r5900-assumption-v1, and results add a limitation that EABI64 is assumed, not established by the header. - Pre-launch revalidation resolved the installed extension root with a bare realpath, so an extension removed after profile resolution surfaced as a generic launch failure. The shared owner now provides revalidateGhidraProcessorExtension, which classifies that failure like any failed inspection (EE_EXTENSION_UNAVAILABLE / PSP_EXTENSION_UNAVAILABLE) and reports foreign-installation or changed-content states; the launcher uses it for both lanes instead of two copied blocks. The launcher messages are unchanged. Tests cover both ABI bases and their limitations, lane binding for the inferred basis, and a vanished EE and PSP extension stopping before spawn.
Summary
PlayStation 2 executables are MIPS ELF32 files whose header declares the Emotion Engine (
EF_MIPS_MACH_5900). Every provider refused them: the Ghidra lane stopped at "Machine-specific MIPS variants, including PSP Allegrex, need a separately supported processor profile". This adds that profile, built the same way as the PSP lane. REA pins the language of a caller-installed extension (ghidra-emotionengine-reloaded,r5900:LE:32:default) and fingerprints it, but never installs or compiles it.No issue exists for this. The PSP lane (#1330) is the precedent the design follows.
Problem and expected behavior
rea analyze <PS2 EE ELF> --provider ghidrafailed witharchitecture_unsupported. With the extension installed under$GHIDRA_INSTALL_DIR/Ghidra/Extensions/ghidra-emotionengine-reloadedand itsr5900.slaprecompiled, the same call resolves laneps2-elf32-exec-eabi64-r5900-v1, imports withr5900:LE:32:default, and serves the ordinary inventory and decompilation operations.Without the extension, or with a compiled language that Ghidra would rebuild inside the installation, the call fails with
EE_EXTENSION_UNAVAILABLE, a specific code and a remedy.Change and scope
GhidraEeProfile.ts: admits exactly the ee-gcc declaration:ET_EXEC;EF_MIPS_ARCH_3;EABI64or none, optionallyNOREORDER;It also provides the pinned language (
language_selection: provider-pinned), the profile parameters and the result limitations. Everything else is refused, not inferred.GhidraProcessorExtension.ts(new): the shared owner of caller-installed processor-extension inspection, generalised from the PSP inspection. It covers id, profile, failure code and required files, plus an optional compiled-language declaration.GhidraPspExtension.tsandGhidraEeExtension.tsare thin specs over it. PSP exports, codes and messages are unchanged, and PSP declares no compiled-language check.Precompiled SLEIGH requirement (EE). The extension's release archives ship SLEIGH sources only. Ghidra 12.2
SleighLanguageFile.needsCompilationrecompiles a.slathat is missing, has another format version, or is older than its sources, and writes it into the installation. During the bounded inspection, at profile resolution and again before launch, REA refuses with:compiled_language_missing,compiled_language_format(notsla+ format 4);compiled_language_stale(older, in whole milliseconds as Java compares, thanr5900.slaspecor any file reachable through@include);compiled_language_source_unresolved(absolute, variable, escaping, missing or cyclic include).Every
@includeline counts regardless of conditionals, so the check can only refuse more than Ghidra would recompile. A refusal happens before any JVM starts and writes nothing.A header without an ABI field commits
mips_abi_basis: inferred-eabi64-r5900-assumption-v1(declared EABI64 keepsdeclared-eabi64-r5900-extension-v1), and its results state that EABI64 is assumed.Wiring in the processor dispatcher, analysis profile, provider host check, provider client and launcher. The pre-launch revalidation goes through
revalidateGhidraProcessorExtensionfor both the PSP and EE lanes, so an extension removed after resolution is reported as*_EXTENSION_UNAVAILABLE. The committed-lane check at open binds the EE lane instead of the generic MIPS lane.docs/providers/ghidra-ps2.md, registered indocs/README.mdanddocs/.vitepress/documentation.ts.Not included: IRX modules, relocatable/shared images, ISO containers, overlays, non-Linux-x64 hosts, producers that write an ABI flags record or GNU attributes.
Contract and boundary impact
ghidraProcessorUnsupportedReason), then analysis-profile resolution.GhidraProcessorExtension.tsand consumed by profile resolution and the launcher re-inspection.EE_EXTENSION_UNAVAILABLEwithcompiled_language_*diagnostics.mips_support_lane,ee_extensionfingerprint, pinned language). Results carry three EE limitations.r5900.sla.locknext to a writable.sla(Ghidra'sSleighLanguageFile), even when the.slais fresh. That file joins the next fingerprint, which only means a cache miss. The PSP lane behaves the same; this PR does not change it.Expected effects:
Evidence and regression coverage
src/ghidra/GhidraEeProfile.test.ts: admission of the ee-gcc declaration, refusals (ASE, other ISA or ABI, undeclared bits, ABI flags record, uninspected declarations, GNU attributes sections), and lane binding at open.tests/boundary/filesystem/ghidraEeExtension.test.ts(16 cases):main, the CLI call returnsarchitecture_unsupported. Before the open fix, the new open test failed with the committed-profile language conflict.Without the precompiled language:
EE_EXTENSION_UNAVAILABLE: compiled_language_missing Precompile data/languages/r5900.sla from data/languages/r5900.slaspec with the selected installation's support/sleigh ...npm test/check:prsuite was not run locally.For evidence-bearing changes:
Validation performed
Node.js 24.22.1 (
.nvmrc).npm run check(typecheck, lint, format, knip, metadata, architecture guards, production reachability, typed lint): passed.npm run docs:check: passed.npm run test:focusedon allsrc/ghidra/*.test.ts,src/ghidra/extensions/*.test.tsandtests/boundary/filesystem/ghidra*.test.ts: 51 files, 1583 passed, 1 skipped.ghidra_12.2_PUBLIC_20261016.zip, SHA-256 checked against the release);ghidra_12.2_PUBLIC_20261029archive, SHA-256 checked);rea analyze ... --provider ghidra --jsonwith the extension installed but not compiled: refused withEE_EXTENSION_UNAVAILABLE/compiled_language_missing. The Ghidra tree was unchanged.support/sleigh .../r5900.slaspec: producedr5900.slawith theslaformat-4 header.rea analyze ... --provider ghidra --json: succeeded in 1:46 min wall time with the profile above. Afterwards the only change in the extension directory wasr5900.sla.lock.rea decompile ... ram:<entry> --provider ghidra --json: succeeded withr5900:LE:32:defaultand the EE limitations..sinc,rea analyze ...: refused withcompiled_language_stale, naming that file. The extension directory was unchanged.Compatibility, safety, and release
Author readiness
Human owner: @litterboks
Author checklist (completed by the PR author before requesting review)
type(scope): outcome.REA_runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.