Repository navigation
feat(ghidra): admit 32-bit big-endian PowerPC ELF - #1747
Conversation
Recognize EM_PPC as a provider-neutral `powerpc` family that keeps its ELF class, byte order, type and flags, and admit ELF32 big-endian ET_EXEC through a bounded Ghidra lane. ELF64, little-endian, relocatable/shared objects and EF_PPC_EMB are refused with a specific reason; Hopper and IDA do not gain PowerPC support, and Windows Ghidra P0 is unchanged. Ghidra's ELF loader selects PowerPC:BE:32:e500:default for a plain EM_PPC header, which misreads 750-family code. The lane binds PowerPC:BE:32:default/default in the profile (language_selection "admitted-lane-v1"), imports with it and checks the reported language. A language set through REA_GHIDRA_LANGUAGE_ID still replaces the lane default. Add a source-owned fixture, fixed-encoding probe, GNU readelf cross-check and the optional `verify:ghidra:ppc` real-provider lane, plus docs/ghidra-ppc.md. Refs morluto#1741
Codex Review SummaryThis 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. |
|
@greptileai review |
|
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. The shared default language owner also enforced the restricted MIPS/RISC-V override rule on the newly added PowerPC fallback. Commit 43557da exempts PowerPC from that restriction, preserving explicit caller language/compiler selections for installed-catalog validation while retaining the generic fallback and client readback. MIPS and RISC-V restrictions remain enforced. Source inspection and git diff --check completed; touched files were formatted. Tests, builds, lint, checks, CI reruns, and performance measurements were not run at the explicit user request. Real Ghidra PowerPC behavior remains unverified. |
Summary
Milestone 1 of #1741: 32-bit big-endian PowerPC ELF executables can reach REA's normal Ghidra workflow. Before this change
EM_PPCwas "unsupported ELF architecture", so no PowerPC target could be opened.Opened as a draft while #1741 waits for maintainer input on direction; happy to reshape it.
Problem and expected behavior
A legally obtained PowerPC ELF (embedded/firmware code, or reconstruction work on PowerPC programs) should give functions, instructions, pseudocode, references and Evidence through the existing tools, with the same admission discipline as the MIPS lane.
One PowerPC-specific trap shapes the design: for a plain
EM_PPCheader withe_flags0, Ghidra 12.1.4's ELF loader picksPowerPC:BE:32:e500:default. e500 is the Book-E/SPE variant without the classic FPU, so it misreads 750-family code, and nothing in the header distinguishes the two. Observed headless import of the fixture:Change and scope
powerpcjoinsBINARY_ARCHITECTURES.EM_PPC(20) resolves to an ELF target that carriesPowerPcElfMetadata(class, byte order,e_type, rawe_flags), mirroring how MIPS keeps its header facts.EM_PPC64(21) is not mapped to this family.ElfHeaderArchitecture = "mips" | "powerpc"replaces theExclude<…, "mips">spellings.src/ghidra/GhidraPowerPcProfile.ts): ELF32, big endian,ET_EXEC. ELF64, little endian, relocatable/shared objects andEF_PPC_EMBare refused with a specific reason. Othere_flagsbits only declare relocation conventions.language_id: "PowerPC:BE:32:default",compiler_spec_id: "default",language_selection: "admitted-lane-v1", pluspowerpc_elfheader facts andpowerpc_support_lane: "elf32-be-exec-generic-v1". The client reads that back (ghidraProfileLaneLanguage) and uses the existing launcher/handshake path:-processor … -cspec …on import andexpectedLanguageIdchecked against the bridge's reported language. A caller'sREA_GHIDRA_LANGUAGE_IDstill wins (configured-v1, admitted against the installed catalog as before), e.g.PowerPC:BE:32:e500for real e500 code.Not included: GameCube/Wii DOL, Gekko/Broadway paired singles, PPC64, little-endian PowerPC, REL/RSO, VLE. Unlike the MIPS lane there is no carved-section case, because PowerPC admission reads no section-borne ABI record.
Contract and boundary impact
src/domain/binaryTarget.ts; lane admission insrc/ghidra/GhidraPowerPcProfile.ts.architectureenum in target/Evidence/snapshot schemas gains"powerpc".powerpc; profile-bound snapshots are invalidated when header facts change.docs:checkpasses.Evidence and regression coverage
src/domain/binaryTarget.powerpc.test.ts: header facts for both byte orders, ELF64 flag offset,EM_PPC64not recognized.src/ghidra/GhidraPowerPcProfile.test.ts: bound language andadmitted-lane-v1, configured language replaces it (real temporary catalog), header flags change the profile digest, refusals (ELF64, little endian,ET_REL,ET_DYN,EF_PPC_EMB), Windows P0, Hopper/IDA refusal.tests/composition/analysis-sessions/powerpc-identity.test.ts: identity through Evidence, snapshot andopen_binaryschema.tests/conformance/ghidra/ppc-checks.test.ts: GNU readelf parser against real 2.47 output; rejects wrong class/order/machine/type/flags, ambiguous fields, an e500 loaded language, and wrong probe bytes/immediate/destination.unsupported ELF architecture; a directanalyzeHeadless -importpicks e500 (log above).open_binaryon the fixture returnsarchitecture: "powerpc";inspect_native_load_imagereportslanguage_id: "PowerPC:BE:32:default".For evidence-bearing changes:
Validation performed
Host: macOS 26 arm64, Node 24.18.0, npm 11.16.0, Ghidra 12.1.4, OpenJDK 21, Homebrew clang/LLD 23.1.3, GNU readelf 2.47.
npm run check:fast: passednpm run verify:test-discovery: "Discovered all 817 test files exactly once."npm run test:changed: 379 files, 4296 passed, 7 skippednpm run docs:check: passedGHIDRA_INSTALL_DIR=… REA_PPC_CLANG=… REA_PPC_READELF=… npm run verify:ghidra:ppc: passed (effective_language: "PowerPC:BE:32:default", 3 procedures, process lineage verified)npm run verify:ghidra:mipson this branch: passed for both byte orders (shared ELF parsing and language plumbing unchanged for MIPS)Compatibility, safety, and release
verify:ghidra:ppcscript; no package contents change.Review checklist
type(scope): outcome.Refs #1741