Repository navigation
feat(ghidra): admit recordless legacy MIPS32 ELFs with a pinned 32-bit language - #1898
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3afbf4d31e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 526d68cb0e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…t language Firmware built with pre-ABI-flags GNU toolchains declares EF_MIPS_ARCH_32 with an unspecified ABI field and no PT_MIPS_ABIFLAGS record. The lane refused them before provider selection, and Ghidra's own header auto-selection picks a 64-bit R6 language for exactly these files. Admit ELF32 ET_EXEC headers with EF_MIPS_ARCH_32 or EF_MIPS_ARCH_32R2, an unspecified ABI field, EF_MIPS_ABI2 clear and no observed ABI flags record. o32 is recorded as an inferred analysis assumption (mips_abi_basis), floating-point ABI semantics stay unverified, and the existing refusals (FP64, NAN2008, ASEs, machine variants, ELF64) are unchanged. The profile pins -processor MIPS:<LE|BE>:32:default through a provider-pinned-v1 selection the bridge-reported language_id is checked against after import; a caller-selected REA_GHIDRA_LANGUAGE_ID still wins. The lane identity is versioned elf32-exec-arch32-legacy-pinned-v1. verify:ghidra:mips gains a recordless legacy round for both byte orders that strips the ABI record declarations from a real mips32 fixture, checks REA's interpretation against GNU readelf, asserts the pinned language after import and the retained assumption limitations through a snapshot round-trip. Fixes morluto#1620
Address review: undefined ABI flags means the record was not inspected, not that none exists. Only an inspected absence (null) establishes the recordless legacy admission; a merely unobserved record keeps its specific refusal. Also document the legacy admission and its pinned language in the MIPS provider guide.
Address review: a recordless-looking header whose ABI-record inspection left declaration sources unexamined (carved ELF with a partial section table and no program-header record) no longer establishes the recordless admission; it is refused with the inspection limitation retained. An EF_MIPS_ARCH_32 header that declares an ABI is refused rather than relabeled through the 32R2 declared-ABI lane.
3b29d23 to
6ae210e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ae210e0d6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Address review: bit 0x40 declares the old n32 ABI. A recordless header carrying it was admitted with the inferred-o32 assumption even though the header itself declares n32; the recordless shape now requires the bit clear and refuses it with a specific constraint.
|
TL;DR: The change works on files with the recordless header, and the tests pass at 6f98144. I made two such files by editing real OpenWrt kernels, and both open as 32-bit MIPS. Every real file I found declares o32, so I had no unedited one to test. ResultsBase is dfe3117, the merge base of this PR. Main (72489a9) has no changes in the MIPS files since then. "Head 1" is 6ae210e. "Head 2" is 6f98144, pushed while I tested.
Thanks, BaaRai, for the PR. Thanks, bqw371, for the issue. Not run
Test setup
FixturesLittle-endian file, from the OpenWrt kamikaze 7.09 rb532 build. Big-endian file, from the OpenWrt backfire 10.03.1 build. BusyBox 1.30.1 (GPL-2.0-only), file /bin/busybox from the Debian mipsel package. The edit clears bits 12 to 15 of Commands
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
CassieFox23, thank you for this. The edited-kernel fixtures, the Capstone cross-check on the decompiled entry and the 228-instruction function, and catching that Head 1 admitted 0x50000041 are exactly the verification this lane needed, and the report is generous with detail. Your read on the deliberate refusals matches the design: real EF_MIPS_ARCH_32 files carry 0x50001001, and those keep the inspected ABI record path, so the recordless lane refusing them is intended. Your 38-file Debian and OpenWrt survey finding no real recordless files without an ABI field lines up with the issue being driven by private firmware. Your not-run list is fair, and the two I would watch first are the same ones you flagged: floating-point code paths under the pinned language, and the typed refusal for a pinned profile plus an env override on snapshot reopen. If you end up testing either, the findings would be welcome here. |
|
TL;DR: Float code decodes and decompiles well under the pinned 32-bit language. The typed refusal never showed. Snapshot reopen fails first, with a generic error. Thanks, BaaRai, for asking for both checks. This follows my first comment. Head is still 6f98144. I tested it as is. The PR now conflicts with main. Floating-point codeTest files: BusyBox 1.30.1 (GPL-2.0-only) from Debian. One is little-endian and one is big-endian. Its record says FPXX hard float. I removed the ABI record and cleared the ABI field, the same way the PR's own fixture does. Both files are then recordless with
Odd output, all identical in the unedited file:
Pinned profile plus env override on snapshot reopenThe code in Over MCP I opened the edited little-endian kernel from my first comment. I saved a snapshot and reopened it.
Thanks again, BaaRai, for the PR. Not run
Test setup
FixturesThe edit clears bits 12 to 15 of The snapshot test used the little-endian OpenWrt file from my first comment, with the same edit. Commands
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
Composes the soft-float and relocatable MIPS lanes and the analyzer overrides from main with the recordless legacy admission: the fixture builder keeps both the float-ABI parameter and the legacy option, the profile keeps the soft-float storage, relocatable lane ids, and the legacy pin and ABI-basis limitations, and the client keeps the pinned import language beside the disabled-analyzer commitment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e03ae33745
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
dandgabr
left a comment
There was a problem hiding this comment.
Review findings
P2 — Restrict legacy recordless admission to ET_EXEC
src/ghidra/GhidraMipsProfile.ts admits a recordless ELF based on its flags and ABI-record inspection, but this predicate does not require target.mips.type === MIPS_ET_EXEC. The outer support check also permits both ET_EXEC and ET_REL. As a result, a recordless MIPS ET_REL object can be assigned the inferred-o32 assumption and labeled elf32-exec-arch32-legacy-pinned-v1, even though the lane and its evidence are scoped to executable firmware images. Require ET_EXEC for this admission and keep ET_REL on the declared-ABI path.
P2 — Scope the ABI-record documentation to the declared-ABI lane
docs/ghidra-mips.md says provider admission requires a v0 ABI-flags record and that a missing record is refused. That contradicts the newly documented recordless legacy exception earlier in the file. Clarify that the record requirement applies to the declared-ABI lane; otherwise users get conflicting admission rules.
…lane The recordless admission now requires ET_EXEC: the lane and its verification cover executable firmware images, and a recordless ET_REL object must stay on the declared-ABI path instead of inheriting the inferred-o32 assumption under an executable lane id. The ABI-record requirement paragraph is scoped to the declared-ABI lane so it no longer contradicts the recordless admission documented above it.
|
dandgabr, thank you for the review. Both findings are correct and fixed in 29e8d1e. The recordless admission now requires ET_EXEC: the lane and its verification cover executable firmware images, so a recordless relocatable object stays on the declared-ABI path instead of inheriting the inferred-o32 assumption under an elf32-exec lane id. Your review caught a real interaction with the new relocatable support, since the outer check admitting ET_REL is what made this predicate reachable for objects. Covered by a new test where a recordless 0x50000001 ET_REL target is refused and fails profile resolution. The ABI-record paragraph is now scoped to the declared-ABI lane and states that the recordless admission above is the only path that admits a recordless image, so the two sections no longer give conflicting admission rules. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29e8d1e4d4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…the legacy lane A recordless relocatable object is not an incomplete inspection, so its refusal now names the ET_EXEC scope of the legacy admission instead of claiming unavailable ABI headers remain unknown. The recordless legacy verifier round reads the probe pair and applies the full assertMipsProbe oracle like the standard round, and its report keeps the independent GNU readelf receipt beside the fixture facts.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5061817f7c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Codex, all three findings are fixed in 5061817.
Verified on Linux: the real Ghidra MIPS lane passes all six fixtures (recordless legacy both endians, hard and soft float both endians) with the reader receipts present, and process lineage is verified. |
|
@greptileai review |
|
…ssion # Conflicts: # docs/ghidra-mips.md # src/ghidra/GhidraAnalysisProfile.ts # src/ghidra/GhidraMipsProfile.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17d34f89b1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4dcc6cbb48
ℹ️ 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".
|
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 legacy verifier now fetches the instructions at probe and probe + 4 and calls the shared assertMipsProbe, checking exact bytes, the 0x1234 immediate, and conditional branch destination. A real Ghidra run is still required to establish that the revised verifier passes. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. Leaving this thread open for the required execution evidence. The legacy predicate now requires abiFlags === null; uninspected undefined declarations cannot enter the inferred-o32 lane. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. Record absence is admitted only when the owning ABI inspection has no limitations. Partially captured declaration tables remain unsupported and preserve their inspection reasons. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. The refusal distinguishes a recordless ET_REL exclusion from incomplete ABI inspection. It now explains the ET_EXEC boundary instead of prescribing impossible re-inspection. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. The standard declared-ABI path retains its EF_MIPS_ARCH_32R2 requirement after the legacy early return. ARCH_32 with an explicit ABI cannot receive the standard 32R2 lane label. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. The legacy verifier now requires the separate floating-point ABI uncertainty sentence in retained Evidence, in addition to the o32 assumption. A real Ghidra run remains outstanding. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. Leaving this thread open for the required execution evidence. The record-required paragraph is now explicitly scoped to the declared-ABI lane and identifies the separate recordless exception. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. The legacy predicate excludes EF_MIPS_ABI_ON32, and the refusal identifies that explicit declaration rather than inferring o32. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. The recordless predicate requires ET_EXEC. ET_REL stays outside the inferred-o32 lane instead of inheriting the executable firmware assumption. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. The guide now documents the recordless ET_EXEC lane separately, including its inferred o32 basis, pinned language, floating-point uncertainty, and verification scope. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. Legacy and shared MIPS pins now come from one target-derived ghidraMipsLanguageOverride used by the central resolver. Provider startup compares the committed language against the current target byte order, so an LE profile cannot authorize a BE target. The obsolete shared-only helper was removed. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. Both legacy admission and its refusal owner now exclude EF_MIPS_32BITMODE. The header cannot receive a generic MIPS32 pin while declaring a 64-bit processor interpretation. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. The legacy receipt now retains its independent_reader object, including the selected GNU readelf command, version, symbols, and bounded raw header/ABI/symbol output. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. |
|
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 legacy verifier now fetches the instructions at probe and probe + 4 and calls the shared assertMipsProbe, checking exact bytes, the 0x1234 immediate, and conditional branch destination. The verifier was inspected; no real Ghidra run is claimed. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. The legacy verifier now requires the separate floating-point ABI uncertainty sentence in retained Evidence, in addition to the o32 assumption. The verifier was inspected; no real Ghidra run is claimed. Current source: 4dcc6cb. Validation: source inspection only; tests and checks were skipped at the user's explicit request. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac73b4e803
ℹ️ 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".
| committedProfile.parameters, | ||
| ); | ||
| const pinnedLanguage = ghidraPinnedMipsLanguage(committedProfile.parameters); | ||
| const targetLanguage = ghidraPinnedLanguage(target); |
There was a problem hiding this comment.
Bind provider-pinned MIPS profiles to their support lane
When a provider-pinned little-endian MIPS16 shared profile is paired with a little-endian recordless legacy target, both ghidraPinnedMipsLanguage and this target-derived lookup produce MIPS:LE:32:default, so the subsequent guard and equality check accept the mismatched profile. The session then retains the shared-image mips_support_lane/mips_elf facts and omits the legacy inferred-o32 and floating-point limitations while analyzing the legacy artifact. Fresh evidence beyond the prior no-pin and unsupported-target fixes is that an admitted different MIPS lane establishes the identical pin; validate the committed support lane/basis against the current target's lane rather than treating language equality as applicability.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| declaring `EF_MIPS_ARCH_32` or `EF_MIPS_ARCH_32R2` with an unspecified ABI | ||
| field, `EF_MIPS_ABI2` clear, and an _inspected_ absence of any ABI flags | ||
| record (a target whose record was merely not observed stays refused). For |
There was a problem hiding this comment.
Include every required-clear legacy flag in the guide
A fully inspected recordless ET_EXEC with e_flags 0x50000041 or 0x50000101 satisfies the conditions listed here (ARCH_32, zero ABI field, ABI2 clear), but runtime now rejects those values for EF_MIPS_ABI_ON32 and EF_MIPS_32BITMODE in GhidraMipsProfile.ts:98-101. After adding those runtime guards, leaving their required-clear bits out of the provider admission guide makes supported inputs look broader than they are; add both exclusions here.
AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.
| the declared-ABI lane refuses them; the recordless legacy admission above is | ||
| the only path that admits a recordless image. Unknown record |
There was a problem hiding this comment.
Preserve the recordless MIPS16 shared exception
Fresh evidence after qualifying the declared-ABI paragraph is that the new “only path” claim is still contradicted by the MIPS16 shared profile: ghidraMipsUnsupportedReason accepts a completely inspected shared target with abiFlags === null, and this guide documents that supported case at lines 99-104. Users of recordless ET_DYN images are therefore told their supported lane does not exist; scope “only path” to the standard-instruction ET_EXEC/ET_REL profiles or name the MIPS16 exception.
AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.
|
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 legacy helper recognized only a header shape, so it could derive a language before unsupported floating-point, ASE or machine declarations were rejected. Header-shape recognition is now internal; public legacy admission and target language derivation require the complete ghidraMipsUnsupportedReason decision. Profile construction and client binding therefore share the same admission owner. Added same-endian FP64, NAN2008, ASE and machine-variant binding regressions that require rejection before provider startup, alongside the endian case. Current source: ac73b4e. Validation: source inspection only; authored regressions were not executed. Tests, checks, builds and provider execution were skipped at the user's explicit request. No passing runtime or real-provider result is claimed. Directly related representation and consumer cleanup is included. The fallback to the committed profile pin turned an absent target-derived pin into a self-comparison. Client construction now rejects a committed MIPS pin when the current target has no pin, compares the committed language only with the caller override or independently derived target language, and uses that validated committed slot for import. Removed the redundant committed-pin import fallback. Added x86 ELF and declared-ABI MIPS mismatch regressions requiring no provider startup. Current source: ac73b4e. Validation: source inspection only; authored regressions were not executed. Tests, checks, builds and provider execution were skipped at the user's explicit request. No passing runtime or real-provider result is claimed. Directly related representation and consumer cleanup is included. |
Summary
Fixes #1620.
Admits recordless legacy MIPS32 ELF executables (EF_MIPS_ARCH_32 or EF_MIPS_ARCH_32R2, unspecified ABI field, EF_MIPS_ABI2 clear, no ABI flags record) with the 32-bit Ghidra language pinned, so 2000s pre-ABI-flags firmware stops being refused and stops being analyzed as a 64-bit R6 image by header auto-selection.
Problem and expected behavior
The lane refused these files before provider selection, while Ghidra's own auto-selection picks
MIPS:LE:64:64-32R6addrfor exactly this shape, so simple relaxation would mislabel MIPS32 firmware. The issue asks for admission with o32 as a recorded assumption, a pinned-processor MIPS:<LE|BE>:32:defaultchecked against the bridge-reported language after import, evidence that records the ABI as inferred, and unchanged refusals elsewhere.Change and scope
ET_EXECwithEF_MIPS_ARCH_32/_32R2, ABI field 0,EF_MIPS_ABI2clear and no observed ABI flags record is admitted. FP64/NAN2008/ASE/machine-variant/ELF64/n32 refusals are unchanged; a declared o32 field without a record is still refused.elf32-exec-arch32-legacy-pinned-v1withmips_abi_basis: inferred-o32-assumption-v1. The import language is pinned through aprovider-pinned-v1selection that drives-processor MIPS:<LE|BE>:32:default -cspec defaultand is checked against the bridge-reportedlanguage_idafter import (the sameexpectedLanguageIdmechanism DOS uses). A caller-selectedREA_GHIDRA_LANGUAGE_IDstill wins; combining the pin with an env override is a typed refusal.Verification
Locally verified on Linux with Ghidra 12.1.4 PUBLIC, clang 21.1.8 (Debian), lld 21.1.8 and GNU readelf 2.47; fork PRs currently receive no CI check runs in this repository, so results below are from this machine:
verify:ghidra:mipspasses with a new recordless legacy round for both byte orders: the fixture is built with-march=mips32, then the ABI record declarations are stripped (PT_MIPS_ABIFLAGS to PT_NULL, SHT_MIPS_ABIFLAGS to SHT_PROGBITS, section renamed in the string table) and the header ABI field zeroed; GNU readelf independently confirms the recordless header; REA's interpretation is checked against it; the pinned language is asserted after import; decoded probe instructions, entry symbols, pseudocode and the retained assumption limitations are asserted through a snapshot round-trip.vitestsrc/ghidra/GhidraMipsProfile.test.ts(new admission/pinning/refusal cases),tsc --noEmitclean,oxlint0 errors on touched files.