Repository navigation
feat(ghidra): admit ELFv2 PPC64 executables through a Power ISA 3.0 lane - #12517
Conversation
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
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. |
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryAdds 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.
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 |
There was a problem hiding this comment.
💡 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".
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.
Summary
Fixes #12085. Since #12089, an
EM_PPC64ELF is classified in thepowerpcfamily, but the Ghidra lane still refused every ELF64 file ("This Ghidra PowerPC lane supports ELF32 only; PPC64 remains unsupported"). This PR admits ELF64ET_EXECfiles that declare the ELFv2 ABI, in both byte orders, sorea analyze,rea functionand 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: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:-O3build-O3buildPowerPC:LE:64:A2ALT(what the loader picks)PowerPC:LE:64:defaultThe
default64-bit languages are the G2-era instruction set and stop at the first VSX instruction. Despite the name,A2ALTis the one that decodes current server code. Through REA itself, the lane's VSX probe (xxlor 0,1,2) isdecodedunder the lane language andnot-in-listingwhenREA_GHIDRA_LANGUAGE_ID=PowerPC:LE:64:defaultis configured.So the lane:
ET_EXECwithe_flagsABI 2 (ELFv2), little or big endian.PowerPC:LE:64:A2ALTorPowerPC:BE:64:A2ALTby byte order, with compiler specdefault, aslanguage_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_IDstill replaces it (for example with the G2-eradefault).powerpc_support_lane: "elf64-elfv2-exec-isa3"with the header facts in the analysis profile, so the interpretation is part of snapshot identity..opdfunction descriptors) and an undeclared ABI (0).e_flagsbits.ET_DYN(shared objects and PIE) andET_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
r2fromr12) and a local entryst_otherbytes 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_functionon the symbol returns the thunk withclassification.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
.opdverification, and Clang+LLD cannot produce a genuine ELFv1 fixture: LLD always stampse_flags2),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
src/ghidra/GhidraPowerPcProfile.ts(ghidraPowerPcUnsupportedReason,ghidraPowerPcLanguage,ghidraPowerPcProfileParameters). Consumers are unchanged:ghidraPinnedLanguage, the analysis profile and the PSP/processor gate already routepowerpcthrough these functions.ET_EXECtargets move from refused to supported.powerpc_support_lane: "elf64-elfv2-exec-isa3"andlanguage_idA2ALT for these targets. 32-bit profiles are byte-for-byte unchanged.docs/public/product-catalog.json), package, or installation impact: none. A new optional script,verify:ghidra:ppc64, is added.Expected effects:
Evidence and regression coverage
src/ghidra/GhidraPowerPcProfile.test.ts:ET_DYNandET_REL.tests/conformance/ghidra/ppc-checks.test.ts:not-in-listingis rejected.npm run verify:ghidra:ppc64:tests/conformance/c/ppc64.candtests/conformance/ghidra/ppc64-probe.S.ppc-fixture.mjs.ppc64.d865c776the esbuild sample is refused with "supports ELF32 only; PPC64 remains unsupported" (output above).rea function powerpc64le.elf rea_ppc64_entry --provider ghidra --json, from the fixture:Public sample from #12085,
@esbuild/[email protected]bin/esbuild(ELF64 LE,ET_EXEC, ELFv2, sha256487759a8…), with this branch:The
markupsafe 3.0.4cp312 ppc64le wheel's_speedups…so(ET_DYN, sha256b49223b5…) is refused before Ghidra starts witharchitecture_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:
Validation performed
On head
471ccbe700, 46 focused PowerPC source tests, 11 compiled process-boundary tests,check:fast, anddocs:checkpassed. 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..sorefused, as shown above.npm run verify:ghidra:ppc64: passed.powerpc64lefixture:PowerPC:LE:64:A2ALT.powerpc64(BE ELFv2) fixture:PowerPC:BE:64:A2ALT.ET_DYNrefused 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 runover 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
verify:ghidra:ppc64.Author readiness
Human owner: @Davmunrey
Before merge
type(scope): outcome.