Skip to content

feat(ghidra): admit ELFv2 PPC64 executables through a Power ISA 3.0 lane - #12517

Merged
morluto merged 4 commits into
morluto:mainfrom
Davmunrey:feat/ghidra-ppc64-lane
Nov 19, 2026
Merged

morluto merged 4 commits into
morluto:mainfrom
Davmunrey:feat/ghidra-ppc64-lane

Conversation

@Davmunrey

@Davmunrey Davmunrey commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #12085. Since #12089, an EM_PPC64 ELF is classified in the powerpc family, but the Ghidra lane still refused every ELF64 file ("This Ghidra PowerPC lane supports ELF32 only; PPC64 remains unsupported"). This PR admits ELF64 ET_EXEC files that declare the ELFv2 ABI, in both byte orders, so rea analyze, rea function and the MCP session tools work on ppc64le and big-endian ELFv2 executables through the existing Ghidra provider.

Problem and expected behavior

On main (d865c776), the public sample from #12085 is refused before Ghidra starts:

rea analyze esbuild --provider ghidra --json   (npm @esbuild/[email protected], sha256 487759a8…)
code: capability_unavailable / category: unsupported_provider
ghidra: architecture_unsupported — "This Ghidra PowerPC lane supports ELF32 only; PPC64 remains unsupported."

With this PR it opens with a pinned Power ISA 3.0 language, and Evidence carries subject.identity.architecture: "powerpc". Shapes outside the verified lane are refused with their own reasons.

Change and scope

One correction to my own proposal in #12085. The issue suggested pinning PowerPC:LE:64:default / PowerPC:BE:64:default. Measuring against real Ghidra 12.2 shows that would be wrong:

Ghidra 12.2 language ldefs description POWER8 -O3 build POWER9 -O3 build
PowerPC:LE:64:A2ALT (what the loader picks) Power ISA 3.0 Little Endian w/Altivec 155 instructions, 0 errors 144 instructions, 0 errors
PowerPC:LE:64:default PowerPC 64-bit little endian w/Altivec, G2 48 instructions, 6 "Unable to resolve constructor" errors 40 instructions, 6 errors

The default 64-bit languages are the G2-era instruction set and stop at the first VSX instruction. Despite the name, A2ALT is the one that decodes current server code. Through REA itself, the lane's VSX probe (xxlor 0,1,2) is decoded under the lane language and not-in-listing when REA_GHIDRA_LANGUAGE_ID=PowerPC:LE:64:default is configured.

So the lane:

  • Admits ELF64 ET_EXEC with e_flags ABI 2 (ELFv2), little or big endian.
  • Pins PowerPC:LE:64:A2ALT or PowerPC:BE:64:A2ALT by byte order, with compiler spec default, as language_selection: "provider-pinned". The ELF loader selects A2ALT today; passing it explicitly means a later loader preference cannot change how these files decode. The session readback checks the observed language as for the other pinned lanes. REA_GHIDRA_LANGUAGE_ID still replaces it (for example with the G2-era default).
  • Commits powerpc_support_lane: "elf64-elfv2-exec-isa3" with the header facts in the analysis profile, so the interpretation is part of snapshot identity.
  • Refuses, each with its own reason:
    • ELFv1 (ABI 1, .opd function descriptors) and an undeclared ABI (0).
    • Other e_flags bits.
    • ET_DYN (shared objects and PIE) and ET_REL.

The 32-bit lane, Hopper and IDA are unchanged. Hopper and IDA still decline the family by name.

ELFv2 detail that the docs now explain: a function that uses the TOC has a global entry (symbol value, sets r2 from r12) and a local entry st_other bytes later. Ghidra keeps the symbol on the global entry as a thunk and puts the body at the local entry as .name. REA reports that faithfully: analyze_function on the symbol returns the thunk with classification.thunk_target = local entry, and its pseudocode follows into the body. Direct calls resolve to the callee's local entry.

Not included (follow-ups): ELFv1 big-endian (needs .opd verification, and Clang+LLD cannot produce a genuine ELFv1 fixture: LLD always stamps e_flags 2), ET_DYN/PIE load verification, 32-bit little-endian, VLE, XCOFF.

Follow the contribution scope. Scope decision: not applicable. This is a read-only import lane inside the existing Ghidra provider, the same shape as the merged 32-bit PowerPC lane, with no target execution, injection or mutation.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/ghidra/GhidraPowerPcProfile.ts (ghidraPowerPcUnsupportedReason, ghidraPowerPcLanguage, ghidraPowerPcProfileParameters). Consumers are unchanged: ghidraPinnedLanguage, the analysis profile and the PSP/processor gate already route powerpc through these functions.
  • Contribution scope fit and linked maintainer decision: [Feature] Admit 64-bit PowerPC ELF (EM_PPC64, 21) through a pinned Ghidra lane #12085 and [Feature] Add PowerPC (32-bit big-endian) native analysis through Ghidra, with a GameCube/Wii DOL follow-up #1741. No new provider or capability.
  • CLI and MCP/tool-catalog contract: no tool or schema change. ELFv2 PPC64 ET_EXEC targets move from refused to supported.
  • Provider, bridge, target-format, or platform compatibility: Ghidra on Linux/macOS only. Windows P0 is unchanged. No bridge/Java change.
  • Evidence, artifact, provenance, or reconstruction contract: the analysis profile gains powerpc_support_lane: "elf64-elfv2-exec-isa3" and language_id A2ALT for these targets. 32-bit profiles are byte-for-byte unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged. The verifier confirms that no descendant process survives.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none. A new optional script, verify:ghidra:ppc64, is added.

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/GhidraPowerPcProfile.test.ts:
      • LE/BE ELFv2 admission with the pinned language, lane id and profile round-trip.
      • A configured G2-era language replacing the default.
      • Refusal rows for ELFv1, ABI 0, ABI 3, extra flag bits, ET_DYN and ET_REL.
      • Hopper/IDA still decline.
    • tests/conformance/ghidra/ppc-checks.test.ts:
      • The GNU readelf ELF64 parser (localentry column, ELFv1/ET_DYN/missing-localentry rejection).
      • Probe words in file byte order.
      • A VSX word reported not-in-listing is rejected.
      • The doubleword in both byte orders.
      • The global-entry thunk to the local-entry pair.
    • New real-provider lane npm run verify:ghidra:ppc64:
      • tests/conformance/c/ppc64.c and tests/conformance/ghidra/ppc64-probe.S.
      • The shared fixture builder in ppc-fixture.mjs.
      • Toolchain lane ppc64.
  • Base reproduction: on d865c776 the esbuild sample is refused with "supports ELF32 only; PPC64 remains unsupported" (output above).
  • User-visible CLI/MCP output: see below.
  • Remaining proof gaps:
    • Verified on Linux x86-64 only, not on macOS.
    • BE coverage is ELFv2 only.
    • Pseudocode presence is a liveness check, not semantic equivalence.

rea function powerpc64le.elf rea_ppc64_entry --provider ghidra --json, from the fixture:

procedure: 0x100102d0 rea_ppc64_entry  classification.thunk=true  thunk_target=0x100102d8
unsigned_long rea_ppc64_entry(unsigned_long selector) {
  if (selector < 0xb) { uStack_20 = selector + 1; } else { uStack_20 = selector; }
  uVar1 = _rea_ppc64_leaf(uStack_20);
  return uVar1 + 0x72;
}

Public sample from #12085, @esbuild/[email protected] bin/esbuild (ELF64 LE, ET_EXEC, ELFv2, sha256 487759a8…), with this branch:

rea analyze esbuild --provider ghidra --json        (2 min 04 s wall, 2.1 GB peak RSS)
subject.identity.architecture: powerpc
language_id: PowerPC:LE:64:A2ALT   language_selection: provider-pinned   powerpc_support_lane: elf64-elfv2-exec-isa3
procedure_count: 6420   string_count: 14987   image_base: 0x10000

rea function esbuild 0x7e570 --provider ghidra --json   (the ELF entry point)
void entry(void) { FUN_0007e540(); return; }

The markupsafe 3.0.4 cp312 ppc64le wheel's _speedups…so (ET_DYN, sha256 b49223b5…) is refused before Ghidra starts with architecture_unsupported: "This Ghidra PPC64 lane supports ET_EXEC only; relocatable objects, shared objects and position-independent executables need separate load verification."

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

On head 471ccbe700, 46 focused PowerPC source tests, 11 compiled process-boundary tests, check:fast, and docs:check passed. Clang/LLD and LLVM checks confirmed the expected headers for three source-built fixtures. The real Linux Ghidra results below are from before both verifier-supervision changes. The PowerPC and PPC64 Ghidra verifiers still need to be rerun against the revised ownership path.

Run on Linux x86-64, Node 22.23, Ghidra 12.2 (ghidra_12.2_PUBLIC_20261016.zip), OpenJDK 25.0.5, Ubuntu Clang 18.1.3 + LLD, GNU readelf 2.42.

  • Public samples from [Feature] Admit 64-bit PowerPC ELF (EM_PPC64, 21) through a pinned Ghidra lane #12085: esbuild analyzed (6,420 procedures) and markupsafe .so refused, as shown above.
  • npm run verify:ghidra:ppc64: passed.
    • powerpc64le fixture: PowerPC:LE:64:A2ALT.
    • powerpc64 (BE ELFv2) fixture: PowerPC:BE:64:A2ALT.
    • ET_DYN refused before provider startup.
    • process_lineage.status: verified, no descendants.
  • npm run verify:ghidra:ppc (32-bit lane, after the shared fixture/checks refactor): passed, PowerPC:BE:32:default.
  • npm run check: passed. 0 lint/typed-lint errors and no warnings in touched files.
  • npx vitest run over the 110 Ghidra/Hopper/IDA/PowerPC test files: 2821 passed, 11 skipped.
  • node scripts/check-doc-facts.mjs --built: passed.
  • npm run jscpd, npm run knip, npm run metadata:check, node scripts/verify/architecture-guards.mjs: passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Previously refused targets become supported; existing profiles are unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: real Ghidra 12.2 on Linux x86-64 (above). No Hopper/IDA change.
  • Package or release metadata impact: a new optional npm script, verify:ghidra:ppc64.
  • Security, privacy, process, or containment review: read-only import. Fixtures are never executed. No new process authority.

Author readiness

Human owner: @Davmunrey

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

Before merge

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

An EM_PPC64 ELF has been classified in the powerpc family since morluto#12089, but
the Ghidra lane still refused every ELF64 file. It now admits ELF64 ET_EXEC
files that declare the ELFv2 ABI, little or big endian, and imports them with
PowerPC:LE:64:A2ALT or PowerPC:BE:64:A2ALT by byte order.

Ghidra's 64-bit "default" languages decode the G2-era instruction set and
stop at the first VSX instruction in POWER8 or POWER9 code; the A2ALT
languages are Power ISA 3.0 and decode it. The ELF loader selects A2ALT
today, and the lane passes it explicitly and records it as provider-pinned.

ELFv1 (.opd function descriptors), an undeclared ABI, other e_flags bits,
ET_DYN and ET_REL are refused with their own reasons. The 32-bit lane is
unchanged.

npm run verify:ghidra:ppc64 builds a source-owned ELFv2 fixture in both byte
orders and checks it against GNU readelf and real Ghidra through MCP and the
CLI: the bound language, fixed instruction bytes including a VSX xxlor, the
global-entry thunk to each function's local entry, direct calls, snapshot
identity, and a shared object refused before Ghidra starts.

Refs morluto#12085
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 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-19T22:51:44.978817Z 471ccbe 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.

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Adds read-only Ghidra analysis for ELFv2 PPC64 executables in either byte order. The follow-up gives both PowerPC verifiers shared ownership of compiler, reader and CLI processes.

  • Ghidra analyzes ELFv2 PPC64 executables in either byte order.
  • A real-provider lane checks PPC64 ELFv2 in both byte orders.
  • The 32-bit verifier runs its tools through one command owner.

No new actionable issues were found. Syntax checks passed for the four changed verifier/helper scripts. Real Ghidra reruns after the cleanup changes remain marked pending.

Reviews (2) · Last reviewed commit: "fix(ghidra): finish shared PowerPC verif..." · Reviewed by Greptile

Comment thread scripts/verify-real-ghidra-ppc64.mjs Resolved

@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: ef1db045af

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/ghidra-ppc.md Resolved
cursoragent and others added 3 commits November 19, 2026 22:41
Timeouts on bare execFile stop only the direct child, so a linker can
outlive Clang and disappear from the parent-tree cleanup check. Launch
those commands through the shared command owner, pass that runner into
the PPC64 fixture builder, and close the owner before the lineage check.
A failed close stays registered for retry and the diagnostic workspace
is retained.
Add the feature specification, plan, and tasks for the lane, and index
them with the other feature records.
@morluto
morluto merged commit 0e0c5a8 into morluto:main Nov 19, 2026
50 of 51 checks passed
@morluto morluto added enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Admit 64-bit PowerPC ELF (EM_PPC64, 21) through a pinned Ghidra lane

3 participants