Skip to content

feat(domain): classify 64-bit PowerPC ELF (EM_PPC64) in the powerpc family - #12089

Merged
morluto merged 4 commits into
morluto:mainfrom
Davmunrey:feat/elf-ppc64-family
Nov 18, 2026
Merged

morluto merged 4 commits into
morluto:mainfrom
Davmunrey:feat/elf-ppc64-family

Conversation

@Davmunrey

@Davmunrey Davmunrey commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

REA refused every ELF with e_machine = 21 (EM_PPC64) before any provider was consulted, with the generic file_format_rejected constraint. This classifies an ELF64 EM_PPC64 header in the existing powerpc family at target resolution. It is the classification step proposed in #12085 and adds no provider lane: a 64-bit PowerPC file now reaches provider selection and is declined there with reasons that name PPC64 or the family.

Refs #12085. The Ghidra lane is not part of this PR.

The scope question in #12085 (reuse powerpc or add a separate family) is still open, so the scope box under "Before merge" is unchecked. The change reverses one pinned test, named under "Change and scope".

Problem and expected behavior

Smallest trigger: an ELF64 header with e_machine = 21. elfArchitecture() had no case for it, so parseElf returned unsupported ELF architecture: e_machine 21 and rea analyze, rea inspect and rea inspect-artifact all answered target_unavailable. The specific refusal in ghidraPowerPcUnsupportedReason ("This Ghidra PowerPC lane supports ELF32 only; PPC64 remains unsupported.") could not be reached by a real EM_PPC64 file.

Expected: the family is recognized with its class, byte order, e_type and e_flags, and providers decline with their own reasons.

Change and scope

  • elfArchitecture() takes an optional ELF class and names powerpc for machine 21 only when the caller commits ELF64. Header admission passes the class. parseElf already keeps ElfFamilyMetadata for the family, so class 64, byte order, e_type and e_flags (ELFv1 or ELFv2 ABI in the low two bits) are retained with no further change.
  • An ELF32 header that claims EM_PPC64 stays unclassified and is refused as before. Classified by number alone, it would have become a powerpc target with class 32, which the 32-bit Ghidra lane admits.
  • Static readers pass only the machine, so nothing changes for them: they report ppc64, their Evidence subject has no family for it, and records saved earlier stay valid.
  • docs/ghidra-ppc.md states the boundary.

Reversed on purpose: the test "does not recognize EM_PPC64 as the 32-bit family" in binaryTarget.powerpc.test.ts.

Not included: any Ghidra lane (pinned language, verification fixture), changes to GhidraPowerPcProfile, the Hopper, IDA and Kuna messages, and a subject family for ppc64 reader reports. That last one changes what views expect from saved Evidence, so it belongs with a provider lane.

Changes after review

  • The first commit classified machine 21 by number alone. Codex and Greptile pointed out that an ELF32 header claiming EM_PPC64 then entered the 32-bit lane. eba42b74b requires ELF64.
  • The second commit mapped the reader name ppc64 to the powerpc subject. Greptile pointed out that views would refuse saved records. 6e03b1842 reverts it. The same effect reached further than that file: elfArchitecture() also feeds the Evidence subject of the ELF dependency, notes, unwind, hardening, initializer and DWARF readers. Requiring the class from the caller leaves all of them as on main.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/elfFixedHeader.ts elfArchitecture() and admitElfFixedHeaderFacts() (ELF machine and class to family). Consumer: parseElf and target resolution, then provider target support.
  • Contribution scope fit and linked maintainer decision: pending in [Feature] Admit 64-bit PowerPC ELF (EM_PPC64, 21) through a pinned Ghidra lane #12085.
  • CLI and MCP/tool-catalog contract: no schema or catalog change. For an ELF64 EM_PPC64 file, analyze, inspect and open_binary change from target_unavailable (file_format_rejected) to capability_unavailable (target_unsupported) with per-provider reasons, and inspect-artifact returns its inventory. Static reader commands are unchanged.
  • Provider, bridge, target-format, or platform compatibility: ELF only. No provider admits these files. Windows Ghidra P0 is unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged. No Evidence subject changes, so saved records are read as before.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable; static header classification.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none; npm run docs:check passed with no generated changes.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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/domain/binaryTarget.powerpc.test.ts: ELF64 EM_PPC64 headers (little-endian with flags 2, big-endian with flags 1) classify as powerpc with class 64; an ELF32 header that claims EM_PPC64 is refused in both byte orders; machine 22 is still refused by name.
    • src/domain/elfFixedHeader.test.ts: elfArchitecture(21, 64) is powerpc; elfArchitecture(21, 32) and elfArchitecture(21) are unclassified.
    • src/ghidra/GhidraPowerPcProfile.test.ts: the three header shapes of the public samples in [Feature] Admit 64-bit PowerPC ELF (EM_PPC64, 21) through a pinned Ghidra lane #12085 are refused with a reason containing "PPC64" by inspectTargetSupport and resolveAnalysisProfile; Hopper and IDA decline an ELF64 little-endian powerpc target.
    • src/domain/native/nativeExportParser.test.ts: machine 21 keeps the reader name ppc64.
  • Base reproduction or other evidence (executed):

    • With main's classifier and this branch's tests, 3 tests fail: the two classification cases and the elfArchitecture contract.
    • With the first commit's classifier, the two "refuses an ELF32 header that claims EM_PPC64" cases fail. That is the review finding.
  • User-visible CLI/MCP output, rea analyze <file> --provider ghidra on bin/esbuild from npm @esbuild/[email protected] (sha256 487759a8814cc6360234d085fc3bc65fec828c59de097bbcdbead2501f0628d9). The Debian big-endian file and the PyPI shared object from [Feature] Admit 64-bit PowerPC ELF (EM_PPC64, 21) through a pinned Ghidra lane #12085 give the same result.

    main (23adfc610):

    code: target_unavailable
    category: unsupported_target
    message: Cannot open artifact: unsupported ELF architecture: e_machine 21.
    details.constraint: file_format_rejected
    

    This branch, target-origin rejections:

    code: capability_unavailable
    category: unsupported_provider
    details.selection_reason: target_unsupported
    ghidra: This Ghidra PowerPC lane supports ELF32 only; PPC64 remains unsupported.
    hopper: REA's Hopper adapter does not admit powerpc targets. Select the Ghidra provider instead.
    ida:    REA's IDA adapter has no verified powerpc lane. Select a supported Ghidra profile instead.
    kuna:   REA verified the Kuna provider on x86-64, AArch64 and ARM; powerpc is not admitted yet.
    

    On the same three files, inspect-elf-dependencies and inspect-go-binary give architecture: ppc64 and no subject architecture, as on main. A 52-byte ELF32 big-endian ET_EXEC header with e_machine = 21 gives target_unavailable on this branch, as on main.

  • Remaining proof gaps: no Ghidra, Hopper, IDA or Kuna installation was available, so each provider's decline was observed in the CLI's rejection list (next to an availability rejection for the missing provider) and in unit tests, not from a configured provider. The full built test group was not run; the source group and the 31 test files that mention the family or the changed functions were. Not run on macOS or Windows.

Boundary regressions: tests/boundary/goRustSubjectArchitecture.test.ts is unchanged and still pins that a ppc64 report has no subject family. No lifecycle surface is touched.

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

Linux x64, Node 24, on ffae857c2 plus this branch at eba42b74b.

  • node scripts/ci/test-group.mjs source — 4371 files, 31,212 tests passed, 0 failed, 74 skipped
  • npx vitest run on the 31 test files that mention powerpc, ppc64, elfArchitecture, architectureForElfMachine, binaryMetadataArchitecture or the ELF architecture refusal — 732 tests passed
  • node scripts/run-typescript.mjs --noEmit — no errors
  • npm run check:fast — passed
  • node scripts/verify/architecture-guards.mjs — passed across 2873 source files
  • npm run docs:check — passed
  • npx oxfmt --check src/domain src/ghidra docs/ghidra-ppc.md — all formatted
  • npm run build, then node scripts/verify-go-binary.mjs with Go 1.24.7 — passed with main's script; its linux/ppc64 fixture still has no subject family
  • node scripts/rea.mjs analyze --provider ghidra, inspect-artifact, inspect-elf-dependencies and inspect-go-binary on the three public files from [Feature] Admit 64-bit PowerPC ELF (EM_PPC64, 21) through a pinned Ghidra lane #12085 and on the ELF32 header above — results as shown

The first CI run failed in Static checks on tests/boundary/providers/CutterBridgeService.test.ts(108,31) (TS2322). That came from main: 7005e2780, the commit before #12088, fails typecheck with the same error, and b236bcfe3 passes. This branch does not touch that file.

Compatibility, safety, and release

  • Breaking changes or migration steps: none intended. A caller that matched target_unavailable for ELF64 EM_PPC64 files now receives capability_unavailable with provider reasons.
  • Real Hopper/Ghidra, browser, or OS coverage: none; no provider was installed. No provider behavior changes for any file a provider admits today.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: header classification only. No new parsing, no new bytes read, no process started.

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 ELF with e_machine 21 was refused as "unsupported ELF architecture" before any provider was consulted, so every entry point answered a 64-bit PowerPC file with the generic file-format refusal.

The header reader now places EM_PPC64 in the powerpc family and keeps its class, byte order, e_type and e_flags as it does for EM_PPC. No provider lane admits these files: the Ghidra PowerPC gate already refuses ELF64 by naming PPC64, and Hopper, IDA and Kuna decline the family. Static ELF readers keep the name ppc64 for the machine.

Refs morluto#12085.
Static readers report a 64-bit PowerPC ELF as ppc64, and the Evidence subject of those reports had no architecture because the name mapped to no family. With EM_PPC64 classified as powerpc, the subject now carries that family, as it does for ppc.

The Go verifier and the Go and Rust guides state the new mapping, and the boundary test keeps an unknown machine (s390) to show that unrecognized names still map to no family.

Refs morluto#12085.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 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-18T18:59:16.140960Z eba42b7 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.

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

ℹ️ 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 src/domain/elfFixedHeader.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] No code blockers were found; the draft should remain pending the maintainer decision already noted by Davmunrey.

Summary

Recognizes ELF64 EM_PPC64 files as powerpc without enabling provider analysis or changing static-reader subjects.

  • ELF64 PPC64 files now enter the powerpc target family.

Davmunrey keeps this PR in draft pending the family-scope decision in #12085. No superseding change was found in the available Git history. This review checked source; tests were not rerun.

Reviews (2) · Last reviewed commit: "fix(domain): classify EM_PPC64 only for ..." · Reviewed by Greptile

Comment thread src/domain/elfFixedHeader.ts Resolved
This reverts commit bbd7f7f.

Evidence saved before the mapping carries no subject architecture for a ppc64 report. Views over those records compare the saved subject with the family the reader name maps to, so the mapping made them refuse records they accepted before. Nothing in this branch produces Evidence that needs the family, so the mapping can wait for a provider lane.

Refs morluto#12085.
Classifying machine 21 by number alone had two effects beyond target resolution. An ELF32 big-endian ET_EXEC header that claims EM_PPC64 became a powerpc target with class 32, which the 32-bit Ghidra lane admits because it sees only class, byte order, type and flags. And every static reader that maps a machine to a family started to put powerpc in its Evidence subject, which changes what views expect from records saved earlier.

elfArchitecture now takes the ELF class and names the family for machine 21 only when the caller commits ELF64. Header admission passes the class. Readers that pass only a machine keep the machine unclassified, so their reports, reader names and Evidence subjects are as they were.

Refs morluto#12085.
@morluto
morluto merged commit cc971d6 into morluto:main Nov 18, 2026
43 checks passed
Davmunrey added a commit to Davmunrey/Davmunrey that referenced this pull request Nov 18, 2026
morluto added a commit that referenced this pull request Nov 19, 2026
…ane (#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 <[email protected]>
Co-authored-by: morluto <[email protected]>
@morluto morluto added area: domain Domain logic, errors, and pure functions enhancement New feature or request labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants