Files
reverse-engineering-anything/docs/specs/native/ppc64-elfv2/plan.md
T
0e0c5a8fea feat(ghidra): admit ELFv2 PPC64 executables through a Power ISA 3.0 lane (#12517)
* feat(ghidra): admit ELFv2 PPC64 executables through a Power ISA 3.0 lane

An EM_PPC64 ELF has been classified in the powerpc family since #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 #12085

* fix(ghidra): supervise PPC64 verifier compiler and CLI processes

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.

* docs(ghidra): record the PPC64 ELFv2 Power ISA 3.0 lane

Add the feature specification, plan, and tasks for the lane, and index
them with the other feature records.

* fix(ghidra): finish shared PowerPC verifier command ownership

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-19 18:27:31 -05:00

1.9 KiB

Implementation plan

Boundary and contract

src/ghidra/GhidraPowerPcProfile.ts owns PPC64 admission (ghidraPowerPcUnsupportedReason), the pinned language (ghidraPowerPcLanguage), and the profile facts (ghidraPowerPcProfileParameters). ghidraPinnedLanguage, the analysis profile, and the processor gate already route powerpc through these functions. Callers keep the selected inputs. No CLI or MCP schema changes.

The optional verifier scripts/verify-real-ghidra-ppc64.mjs obtains its runner from createVerifierCommands. Clang launches, including those inside buildPowerPc64Fixture, GNU readelf and the one-shot CLI use that runner. The verifier closes the owner before completeVerifierRun. A failed close stays registered on the fixture for retry, and the diagnostic workspace is retained.

Incremental work and validation

  1. Admit ELF64 ET_EXEC ELFv2 in both byte orders and refuse the other PPC64 shapes from the PowerPC profile, without changing the 32-bit lane.
  2. Pin PowerPC:LE:64:A2ALT or PowerPC:BE:64:A2ALT with compiler spec default, and commit powerpc_support_lane: "elf64-elfv2-exec-isa3" with the header facts.
  3. Extend the profile tests for admission, a configured replacement language, the refused shapes, and Hopper/IDA decline.
  4. Extend the independent readelf and probe checks for the 64-bit fixture, including a VSX word that is not in the listing and the global-entry thunk fields.
  5. Add verify:ghidra:ppc64. Own its compiler, reader and CLI processes with the shared command runner, and describe the lane in the PowerPC guide.

Effects and compatibility

ELF64 ET_EXEC ELFv2 targets move from refused to supported. Existing 32-bit profiles are unchanged. The import stays read-only: the lane does not execute the image, and Hopper, IDA, and Windows Ghidra P0 are unchanged. The verifier adds no process authority beyond the shared command owner.