Skip to content

feat(ghidra): admit recordless legacy MIPS32 ELFs with a pinned 32-bit language - #1898

Merged
morluto merged 11 commits into
morluto:mainfrom
BaaRai:feat/mips-legacy-admission
Oct 13, 2026
Merged

morluto merged 11 commits into
morluto:mainfrom
BaaRai:feat/mips-legacy-admission

Conversation

@BaaRai

@BaaRai BaaRai commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

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-32R6addr for 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:default checked against the bridge-reported language after import, evidence that records the ABI as inferred, and unchanged refusals elsewhere.

Change and scope

  • Admission: ELF32 ET_EXEC with EF_MIPS_ARCH_32/_32R2, ABI field 0, EF_MIPS_ABI2 clear 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.
  • Profile: the lane identity is versioned elf32-exec-arch32-legacy-pinned-v1 with mips_abi_basis: inferred-o32-assumption-v1. The import language is pinned through a provider-pinned-v1 selection that drives -processor MIPS:<LE|BE>:32:default -cspec default and is checked against the bridge-reported language_id after import (the same expectedLanguageId mechanism DOS uses). A caller-selected REA_GHIDRA_LANGUAGE_ID still wins; combining the pin with an env override is a typed refusal.
  • Evidence: sessions on this admission carry the limitations that the header declares no ABI, that o32 conventions are an analysis assumption, not a declared fact, and that floating-point ABI semantics are unverified.

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:mips passes 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.
  • The pre-existing standard lane round still passes unchanged (o32/32R2 with record).
  • vitest src/ghidra/GhidraMipsProfile.test.ts (new admission/pinning/refusal cases), tsc --noEmit clean, oxlint 0 errors on touched files.
  • The pre-change tree refuses the same fixture with "requires an inspected ABI flags record".

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T13:49:59.742296Z ac73b4e 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: 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".

Comment thread src/ghidra/GhidraMipsProfile.ts Resolved
Comment thread src/ghidra/GhidraMipsProfile.ts Resolved

@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: 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".

Comment thread src/ghidra/GhidraMipsProfile.ts Resolved
Comment thread src/ghidra/GhidraMipsProfile.ts Resolved
…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.
@BaaRai
BaaRai force-pushed the feat/mips-legacy-admission branch from 3b29d23 to 6ae210e Compare October 11, 2026 17:52

@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: 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".

Comment thread src/ghidra/GhidraMipsProfile.ts Resolved
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.
@CassieFox23

CassieFox23 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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.

Results

Base 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.

Check Base dfe3117 Head 2 6f98144
Little-endian kernel, edited refused opens as MIPS:LE:32:default
Big-endian kernel, same edit refused opens as MIPS:BE:32:default, 6,833 functions
The same kernels, not edited refused refused, new message
BusyBox 1.30.1 with the record (0x70001007) opens, 3,698 functions same result
Seven other header edits (list below) refused still refused
0x70000001 (32R2, no ABI) refused admitted
0x50000041 (ABI_ON32 bit) refused refused (Head 1 admitted it)
New tests in GhidraMipsProfile.test.ts 10 of 30 fail on base 31 pass
npm run verify:ghidra:mips n/a passes, both byte orders
npm run test:fast not run 398 files, 4,874 tests pass, 3 skipped
  • The pin matters on little-endian. Ghidra alone picks MIPS:LE:64:64-32R6addr for the edited little-endian kernel. With the pin it picks MIPS:LE:32:default. On the big-endian kernel Ghidra alone already picks the 32-bit language. The pin changes nothing there.
  • Lane. The edited files get lane elf32-exec-arch32-legacy-pinned-v1 and pinned language selection.
  • Evidence. Both new limitation lines appear in the load-image Evidence. They say o32 is an assumption and floating-point ABI is unverified.
  • Decompile. I checked the big-endian entry function against Capstone 5.0.9 on the same bytes. They agree. A second function of 228 instructions agrees too. Three mnemonics differ in name only (Ghidra says clear, Capstone says move).
  • Other header edits. FP64, NAN2008, MIPS16, n32, O64, a cut-off section table, and the record kept with the ABI cleared. All still refused.
  • Head 1 gap. At 6ae210e a header with the ABI_ON32 bit (0x50000041) and no record was admitted as inferred o32. Head 2 refuses it. The new unit test covers it.
  • Caller language wins. With REA_GHIDRA_LANGUAGE_ID set, the file opens in the language asked for. The lane id still reads legacy-pinned, while the selection reads configured-v1.
  • Real files. I checked 38 real MIPS ELFs from Debian and OpenWrt, 2007 to 2015. None has an unspecified ABI field. Real EF_MIPS_ARCH_32 files carry 0x50001001, so this PR refuses them by design.

Thanks, BaaRai, for the PR. Thanks, bqw371, for the issue.

Not run

  • An unmodified public file with 0x50000001, and the issue's private firmware (the 400 of 5,250 count).
  • Floating-point code, Hopper, IDA, tsc and oxlint.
  • The typed refusal for a pinned profile plus an env override on snapshot reopen. Only the unit tests cover it.
    • Edit: that was wrong. No test uses that message. I ran this case in my follow-up.
  • A build merged onto current main.
  • On Head 2, the real-file and BusyBox base comparisons were not re-run. The header gate and the tests were.
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9

  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads

  • RAM: 32 GB DDR4-3600

  • Node: 24.18.0

  • Head 2, head 1, base: 6f98144, 6ae210e, dfe3117

  • Timing: the box was shared with other test agents. A first Ghidra load took 5 seconds for the small file, 70 seconds for the 2.8 MB kernel and about 100 seconds for BusyBox.

  • Ghidra: 12.1.4 (Apache-2.0) with JDK 21.0.12.1

  • Other tools and licences:

    clang 22.1.8        Apache-2.0 WITH LLVM-exception
    GNU readelf 2.46.1  GPL-3.0-or-later
    Capstone 5.0.9      BSD-3-Clause
    OpenWrt kernels     GPL-2.0
    Debian kernels      GPL-2.0-only
    
Fixtures

Little-endian file, from the OpenWrt kamikaze 7.09 rb532 build.

url:    https://archive.openwrt.org/kamikaze/7.09/rb532-2.6/openwrt-rb532-2.6-vmlinux
sha256: 09acf547c3221b23662ab9e68619b6657d024cdbcbcc25c316eba23215ca1edf
edited: 1dfba17fb610b408071806a9267380692ec537dc68e38e5530368252545c7a73

Big-endian file, from the OpenWrt backfire 10.03.1 build.

url:    https://archive.openwrt.org/backfire/10.03.1/atheros/openwrt-atheros-vmlinux.elf
sha256: ccb47755d2e8babf33bec322e6d0a7f628eb94ae139b4b943b217ae26105b304
edited: 4ad8e6093e4e271ec5df594700aa7d15451cb935f4f2f45ec6f05c2da0a48a4b

BusyBox 1.30.1 (GPL-2.0-only), file /bin/busybox from the Debian mipsel package.

url:    https://archive.debian.org/debian/pool/main/b/busybox/busybox-static_1.30.1-4_mipsel.deb
sha256: 67d1f1abb3693dcf35b21d656b19e1f58be7b1ecbf5d6146de719ded18f6a57b

The edit clears bits 12 to 15 of e_flags at file offset 36. Nothing else changes.

Commands
  • npm ci && npm run build && npm run test:prepare in each tree, Node 24.
  • Gate check: parseBinaryTarget then ghidraMipsUnsupportedReason from dist/, on every file.
  • MCP over stdio: open_binary with provider ghidra, inspect_native_load_image, inspect_native_instruction, list_procedures, analyze_function, close_binary.
  • Ghidra alone: analyzeHeadless ... -import FILE [-processor MIPS:LE:32:default -cspec default] -postScript CountFns.java.
  • npx vitest run src/ghidra/GhidraMipsProfile.test.ts, npm run verify:ghidra:mips, npm run test:fast.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@BaaRai

BaaRai commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

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.

@CassieFox23

CassieFox23 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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 code

Test 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 e_flags 0x70000007.

Check Little Big
Opens through REA yes, MIPS:LE:32:default, pinned yes, MIPS:BE:32:default, pinned
FPU instructions Capstone finds in .text 690 689
Of those, decoded by Ghidra with the same mnemonic 690 689
Functions decompiled 6 6
Unedited file, same functions same output same output
  • What the 690 cover. 28 distinct instructions, such as ldc1, sdc1, mul.d, div.d, cvt.d.w, trunc.w.d, c.le.d, bc1t, mtc1 and mfhc1. The big-endian file also has madd.d.
  • Decompile. The six functions per file have doubles in the right places. One example takes a double, scales it by 2.3283064365386963e-10 (2 to the minus 32), and returns the low 32 bits. That reads right against the instructions.
  • Unedited file. The unedited BusyBox takes the standard lane. Ghidra picks the same 32-bit language there, so identical output is expected. It shows the pin changes nothing for this code. It is not an independent check.
  • Capstone gap. Capstone 5.0.9 cannot decode c.le.d and similar compares when the condition code is not 0. Ghidra decodes them. So those compares are not in the 690.

Odd output, all identical in the unedited file:

  • Half-written register. One function starts with mthc1 zero, f0 and never sets the low half. Ghidra shows (double)(ulonglong)in_f0 <= param_1. That is a number cast of the low half, not the bit pattern. The code has a non-standard calling convention (it also reads v1 as an input), so I think the odd shape comes from the code. I did not prove it.
  • Listing text. sub.d prints as sub.D D, f12, f12, f0, with a stray D. This happens 11 times in the six little-endian functions. Compares print the condition code, as in bc1f 0x1, addr. Cosmetic only.
  • A one-byte function. In the big-endian file Ghidra makes a function at a data address. Its body is halt_baddata(). It is in the unedited file too.

Pinned profile plus env override on snapshot reopen

The code in GhidraProviderClient.ts refuses when the committed profile is pinned and REA_GHIDRA_LANGUAGE_ID is set. The message says "cannot be combined". I searched src and tests for that message. No test uses it.

Over MCP I opened the edited little-endian kernel from my first comment. I saved a snapshot and reopened it.

Reopen with Result
nothing set opens, MIPS:LE:32:default, pinned
language MIPS:LE:64:64-32R6addr refused, evidence_integrity_mismatch
language MIPS:LE:32:default (same as the pin) refused, same error
same language plus compiler spec default refused, same error
compiler spec only server will not start
  • The error. All three refusals use the code evidence_integrity_mismatch. The text is below. It does not name the env override.

    Analysis snapshot profile_mismatch: target, provider, or analysis profile does not match the requested binary
    
  • Why. With the env set, REA builds a new profile with configured-v1 instead of the pin. It no longer equals the snapshot profile. The snapshot check fails before the Ghidra client is made. So the typed refusal was never reached.

  • Not new. A non-MIPS control did the same. I saved a snapshot of GNU true, then reopened it with REA_GHIDRA_LANGUAGE_ID=x86:LE:64:default and compiler spec gcc. The result was the same error.

  • Compiler spec alone. The server exits at start with a config error, shown below. That check is in the config code, not in this PR.

    REA configuration is invalid: REA_GHIDRA_COMPILER_SPEC_ID: requires REA_GHIDRA_LANGUAGE_ID.
    
  • What I can say. Same language or different, the user gets a refusal. I found no route that reaches the typed message. I do not know if one exists.

Thanks again, BaaRai, for the PR.

Not run

  • Soft-float code, FP64 code, and code that uses odd float registers.
  • A recordless file with floating point that I did not edit.
  • A check of the decompiled doubles against the source code.
  • Any route that reaches the typed refusal other than snapshot reopen.
  • Hopper, IDA, and a build merged onto main.
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9

  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads

  • RAM: 32 GB DDR4-3600

  • Node: 24.18.0

  • Head / base: 6f98144 / dfe3117

  • Timing: the box was shared with other test agents. Each BusyBox load took about 100 seconds.

  • Ghidra: 12.1.4 (Apache-2.0) with JDK 21.0.12.1

  • Other tools and licences:

    Capstone 5.0.9      BSD-3-Clause
    GNU true (coreutils) GPL-3.0-or-later
    OpenWrt kernel       GPL-2.0
    
Fixtures
BusyBox 1.30.1-4 mipsel, /bin/busybox from
https://archive.debian.org/debian/pool/main/b/busybox/busybox-static_1.30.1-4_mipsel.deb
real:       67d1f1abb3693dcf35b21d656b19e1f58be7b1ecbf5d6146de719ded18f6a57b
recordless: a0e5a153e652ea6541cb1eca1e84778b119645babc5ca12effa93b6fff6ef8f5

BusyBox 1.30.1-4 mips, /bin/busybox from
https://archive.debian.org/debian/pool/main/b/busybox/busybox-static_1.30.1-4_mips.deb
real:       432ce6086ec578eba08ed84bb8330069bcb9953e37d9734eb579a5b20ebdfe0c
recordless: 6601bc669a9238dddafd78fdae8960396220b5e2389d2ce7dcc5ab52244629cd

The edit clears bits 12 to 15 of e_flags. It retypes PT_MIPS_ABIFLAGS to PT_NULL and SHT_MIPS_ABIFLAGS to SHT_PROGBITS. It renames .MIPS.abiflags in the string table. Code bytes do not change.

The snapshot test used the little-endian OpenWrt file from my first comment, with the same edit.

Commands
  • npm ci && npm run build && npm run test:prepare, Node 24.
  • A Capstone sweep of the code lists the float instructions.
  • MCP over stdio: open_binary, inspect_native_load_image, list_procedures, read_function_instructions, analyze_function, inspect_native_instruction, close_binary with snapshot_path.
  • Snapshot cases: REA_GHIDRA_LANGUAGE_ID and REA_GHIDRA_COMPILER_SPEC_ID set in the server environment on the reopen call.

🤖 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.

@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: 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".

Comment thread src/ghidra/GhidraMipsProfile.ts Resolved
Comment thread docs/ghidra-mips.md Resolved

@dandgabr dandgabr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@BaaRai

BaaRai commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

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.

@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: 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".

Comment thread src/ghidra/GhidraMipsProfile.ts Resolved
Comment thread scripts/verify-real-ghidra-mips.mjs Resolved
Comment thread scripts/verify-real-ghidra-mips.mjs Resolved
…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.

@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: 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".

Comment thread src/ghidra/GhidraMipsProfile.ts Resolved
@BaaRai

BaaRai commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Codex, all three findings are fixed in 5061817.

  • The recordless ET_REL refusal now names the ET_EXEC scope of the legacy admission instead of claiming unavailable ABI headers, since a fully inspected recordless object is not an incomplete inspection.
  • The recordless legacy verifier round reads the probe pair at probe and probe+4 and applies the full assertMipsProbe oracle like the standard round, so a lost immediate or wrong bytes can no longer pass on instruction shape alone.
  • The legacy report keeps the independent GNU readelf receipt from inspectLegacyMipsReadelf under independent_reader, matching the standard fixtures.

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.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

Admits narrowly defined recordless legacy MIPS32 executables with a pinned 32-bit Ghidra language. Profiles and retained evidence record o32 as an assumption.

  • Recordless legacy MIPS32 executables use a pinned 32-bit Ghidra language.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Inspected MIPS ELF] --> B{Header admitted?}
  B -->|No| C[Typed refusal]
  B -->|Yes| D[Resolve analysis profile]
  D --> E[Compare committed language with current target]
  E -->|Mismatch| C
  E -->|Match| F[Import with pinned language]
  F --> G[Check bridge-reported language]
  G --> H[Retain analysis assumptions in evidence]
Loading

Reviews (5) · Last reviewed commit: "fix(ghidra): bind legacy profiles to ful..." · Reviewed by Greptile

…ssion

# Conflicts:
#	docs/ghidra-mips.md
#	src/ghidra/GhidraAnalysisProfile.ts
#	src/ghidra/GhidraMipsProfile.ts

@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: 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".

Comment thread src/ghidra/GhidraProviderClient.ts Resolved
Comment thread scripts/verify-real-ghidra-mips.mjs Resolved

@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: 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".

Comment thread src/ghidra/GhidraMipsProfile.ts Resolved
Comment thread src/ghidra/GhidraProviderClient.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

  1. thread 1

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.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

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.

  1. thread 1

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.

  1. thread 1

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.

@morluto
morluto merged commit a4b8e9c into morluto:main Oct 13, 2026
2 checks passed

@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: 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread docs/ghidra-mips.md
Comment on lines +27 to +29
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread docs/ghidra-mips.md
Comment on lines +71 to +72
the declared-ABI lane refuses them; the recordless legacy admission above is
the only path that admits a recordless image. Unknown record

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

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.

  1. thread 1

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.

  1. thread 1

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.

@morluto morluto added enhancement New feature or request area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto mentioned this pull request Oct 14, 2026
3 tasks done
@morluto morluto added the provider: ghidra Analysis provider / engine: ghidra label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Admit legacy MIPS32 ELFs with an unspecified ABI, pinning the 32-bit Ghidra language (auto-selection picks MIPS:LE:64:64-32R6addr)

4 participants