Skip to content

feat(ghidra): admit PlayStation 2 EE executables through ghidra-emotionengine-reloaded - #5240

Open
litterboks wants to merge 6 commits into
morluto:mainfrom
litterboks:feat/ghidra-ps2-ee-profile
Open

litterboks wants to merge 6 commits into
morluto:mainfrom
litterboks:feat/ghidra-ps2-ee-profile

Conversation

@litterboks

@litterboks litterboks commented Oct 19, 2026 •

Copy link
Copy Markdown

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 ghidra failed with architecture_unsupported. With the extension installed under $GHIDRA_INSTALL_DIR/Ghidra/Extensions/ghidra-emotionengine-reloaded and its r5900.sla precompiled, the same call resolves lane ps2-elf32-exec-eabi64-r5900-v1, imports with r5900: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:

    • little-endian ELF32 ET_EXEC;
    • EF_MIPS_ARCH_3;
    • ABI EABI64 or none, optionally NOREORDER;
    • no other header bits, no MIPS ABI flags record, no GNU MIPS attributes section (any section, or an uninspected one, is refused).

    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.ts and GhidraEeExtension.ts are 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.needsCompilation recompiles a .sla that 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 (not sla + format 4);
    • compiled_language_stale (older, in whole milliseconds as Java compares, than r5900.slaspec or any file reachable through @include);
    • compiled_language_source_unresolved (absolute, variable, escaping, missing or cyclic include).

    Every @include line 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 keeps declared-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 revalidateGhidraProcessorExtension for 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 in docs/README.md and docs/.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

  • Semantic owner and earliest changed stage:
    • Ghidra provider target admission (ghidraProcessorUnsupportedReason), then analysis-profile resolution.
    • Installed-extension facts are produced once by GhidraProcessorExtension.ts and consumed by profile resolution and the launcher re-inspection.
  • Contribution scope fit and linked maintainer decision: static decompilation of a new processor family through an existing provider. No maintainer decision is linked yet; one is requested here.
  • CLI and MCP/tool-catalog contract: unchanged. New admitted targets and a new failure code EE_EXTENSION_UNAVAILABLE with compiled_language_* diagnostics.
  • Provider, bridge, target-format, or platform compatibility: Ghidra 12.x (>= 12.2, as main requires) only, Linux x64 only; bridge unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: new profile parameters (mips_support_lane, ee_extension fingerprint, pinned language). Results carry three EE limitations.
  • Target selection, authority, upstream behavior, and cleanup details:
    • Static import into an ephemeral project, as before.
    • Observed with Ghidra 12.2: loading the language creates an empty r5900.sla.lock next to a writable .sla (Ghidra's SleighLanguageFile), even when the .sla is 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.
  • Generated metadata, package, or installation impact: none. The extension and its compiled language stay caller-installed.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • 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):
      • a resolved EE profile opens through the provider client seam with the pinned language and extension;
      • fresh and equal-mtime languages are admitted;
      • missing, old-format, non-SLA, stale-source, stale-include and unresolved-include languages are refused;
      • refusals leave the installation byte- and mtime-identical;
      • a language that turns stale, or an extension that vanishes, after resolution stops the launcher before spawn.
  • Base reproduction: on main, the CLI call returns architecture_unsupported. Before the open fix, the new open test failed with the committed-profile language conflict.
  • User-visible CLI output (executed; a retail PS2 EE executable; abridged; target-specific content omitted):
provider: ghidra 12.2
language_id: r5900:LE:32:default
language_selection: provider-pinned
mips_support_lane: ps2-elf32-exec-eabi64-r5900-v1
ee_extension: { id: ghidra-emotionengine-reloaded, ghidra_version: 12.2, sha256: <64 hex> }
limitations: "PlayStation 2 EE analysis uses the caller-installed ghidra-emotionengine-reloaded extension ..."

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 ...

  • Remaining proof gaps:
    • One producer and one executable verified.
    • No CI job with Ghidra and the extension installed.
    • The full npm test / check:pr suite was not run locally.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

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:focused on all src/ghidra/*.test.ts, src/ghidra/extensions/*.test.ts and tests/boundary/filesystem/ghidra*.test.ts: 51 files, 1583 passed, 1 skipped.
  • Real provider run.
    • Setup:
      • Ghidra 12.2 (ghidra_12.2_PUBLIC_20261016.zip, SHA-256 checked against the release);
      • Temurin JDK 25.0.5.1+2;
      • ghidra-emotionengine-reloaded v2.1.39 (ghidra_12.2_PUBLIC_20261029 archive, SHA-256 checked);
      • Linux x64, one retail PS2 EE executable.
    • rea analyze ... --provider ghidra --json with the extension installed but not compiled: refused with EE_EXTENSION_UNAVAILABLE / compiled_language_missing. The Ghidra tree was unchanged.
    • support/sleigh .../r5900.slaspec: produced r5900.sla with the sla format-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 was r5900.sla.lock.
    • rea decompile ... ram:<entry> --provider ghidra --json: succeeded with r5900:LE:32:default and the EE limitations.
    • After touching an included .sinc, rea analyze ...: refused with compiled_language_stale, naming that file. The extension directory was unchanged.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: real Ghidra 12.2 with JDK 25 on Linux x64, one target.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: same model as the PSP lane. Installed extension code runs inside Ghidra, and REA fingerprints it by content identity, not a signature. REA never compiles or installs the language; it refuses states that Ghidra would rebuild inside the installation.

Author readiness

Human owner: @litterboks

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Author checklist (completed by the PR author before requesting review)

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.

…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.
Comment thread src/ghidra/GhidraEeExtension.ts Resolved
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@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.
cc @gensokyo-dev @dandgabr

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@litterboks also, this branch has merge conflicts with main — please resolve those along with the open threads.

Martin Steinberger added 2 commits November 26, 2026 11:15
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.
@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The latest changes appear safe to merge; no new blocking issue was found.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The latest changes appear safe to merge; no new blocking issue was found.

Summary

Adds bounded PlayStation 2 EE analysis through a caller-installed Ghidra extension.

  • Ghidra analyzes supported PlayStation 2 EE executables with the R5900 language.
  • REA checks the installed EE language before it starts Ghidra.

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
Loading

Reviews (4) · Last reviewed commit: "fix(ghidra): state an inferred EE ABI an..." · Reviewed by Greptile

Comment thread src/ghidra/GhidraEeProfile.ts Resolved
Comment thread src/ghidra/GhidraEeProfile.ts Resolved
Comment thread docs/providers/ghidra-ps2.md Resolved
Martin Steinberger added 2 commits November 26, 2026 13:35
- 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.
@litterboks
litterboks marked this pull request as ready for review November 27, 2026 06:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T06:41:32.820610Z 4dbd370 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@litterboks

Copy link
Copy Markdown
Author

@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 action_required? I would also appreciate your scope decision on adding the PlayStation 2 EE lane to the Ghidra provider; the PR description summarises the boundary and the verification done with Ghidra 12.2. Thank you.

@litterboks

Copy link
Copy Markdown
Author

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

  • Merged main, which now targets Ghidra 12.2. Conflicts are resolved, PSP behaviour is unchanged, and main's committed-lane check at open binds the EE lane.

  • src/ghidra/GhidraProcessorExtension.ts is now the shared owner of caller-installed processor-extension inspection. GhidraPspExtension.ts and GhidraEeExtension.ts are thin specs over it.

  • The EE extension must ship a precompiled r5900.sla, mirroring Ghidra 12.2 SleighLanguageFile.needsCompilation. The refusal codes are:

    • compiled_language_missing
    • compiled_language_format: not sla + format 4
    • compiled_language_stale: older than r5900.slaspec or any file reachable through @include
    • compiled_language_source_unresolved

    The check runs at profile resolution and again before launch, before any JVM starts, and writes nothing.

  • Fixed the EE profile committing language_selection: provider-pinned-v1; it is now provider-pinned. With the old value, every resolved EE profile was refused at open.

  • EE admission now refuses any GNU MIPS attributes section, and an uninspected one.

  • The guide moved to docs/providers/ghidra-ps2.md and is registered in docs/README.md and docs/.vitepress/documentation.ts.

Verification

  • Node.js 24.22.1: npm run check, npm run docs:check, and all src/ghidra and Ghidra boundary tests pass (51 files, 1580 tests).
  • New boundary tests in tests/boundary/filesystem/ghidraEeExtension.test.ts:
    • a resolved profile opens through the client seam;
    • fresh, missing, wrong-format, stale and unresolved-include languages behave as specified;
    • refusals leave the installation byte- and mtime-identical;
    • a language that turns stale after resolution never reaches spawn.
  • Real run on Linux x64: Ghidra 12.2 (release SHA-256 checked), Temurin JDK 25.0.5.1+2, ghidra-emotionengine-reloaded v2.1.39, one retail PS2 EE executable.
    • Before precompiling, the extension was refused with compiled_language_missing.
    • After support/sleigh, analyze and decompile succeeded with r5900:LE:32:default.
    • Touching an included .sinc was refused with compiled_language_stale.

Open points

  • Your scope decision for the EE lane.
  • Approval of the fork workflow runs.
  • Only one producer and executable are verified, and no CI job has Ghidra with the extension installed.
  • Ghidra 12.2 itself creates an empty r5900.sla.lock next to a writable .sla on load. That changes the next fingerprint, which only causes a cache miss. The PSP lane behaves the same; this PR does not change it.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/ghidra/GhidraEeProfile.ts Resolved
Comment thread src/ghidra/GhidraLauncher.ts Resolved
- 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants