Skip to content

fix(elf): admit Xtensa through canonical target contracts - #11178

Merged
gensokyo-dev merged 4 commits into
mainfrom
fix/xtensa-elf-10765
Nov 15, 2026
Merged

gensokyo-dev merged 4 commits into
mainfrom
fix/xtensa-elf-10765

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #10765. Xtensa ELF headers (EM_XTENSA = 94) now produce canonical xtensa targets, pass Ghidra admission and preserve the architecture in Evidence. Ghidra's ELF loader selects the import language. Hopper and IDA continue to decline this family.

Adapted from @bezabyte / Josh's #10774 with original authorship preserved. One canonical exclusion set supplies both HeaderArchitecture and live CLI/MCP summary schemas, preventing impossible Xtensa PE, Mach-O and DOS targets. No screenshots or binaries are committed.

Boundary and scope

ELF header parsing owns the family fact; target types, provider admission and Evidence consume it. Shared header-family constraints replace duplicated runtime exclusions. This is an ordinary correction within existing read-only ELF/Ghidra authority: no new provider, target execution, injection, mutation, installer or processor profile. Maintainer scope decision: not applicable. Raw-binary selection and language overrides retain their contracts. The Ghidra guide records the header-selected policy and ISA/ABI limits.

Executed evidence

  • Official Espressif fixture: esp32-bootloader.elf, SHA-256 ec58a07e847ccb405d5644d6daa66707c0641770eb8bfc2f36e1bffbd8c02a33. readelf independently confirms ELF32 little-endian Xtensa and call_start_cpu0 at 0x40098118.
  • Affected-main CLI inspect-artifact rejected machine 94; fixed CLI inspection succeeds on that same file.
  • Real public CLI and SDK stdio MCP with Ghidra 12.1.4 / Temurin JDK 21.0.12.1, Linux: CLI decompile and MCP open_binary → procedure_pseudo_code → binary_session → close_binary all succeed. Target SHA-256, analysis-profile digest and pseudocode agree between CLI and MCP; the input digest is unchanged. Both retain the provider's calling-convention warning.
  • Direct Ghidra control also imports with Xtensa:LE:32:default and decompiles the expected symbol at the readelf address. Its owned project was deleted. This establishes loader/decompiler acceptance, not full bootloader semantic equivalence or support for every Xtensa extension/ABI.
  • Runs used two CPU cores and a 2 GiB Java heap. Public deep-analysis runs used a temporary Linux user/PID/mount namespace: on the shared host, inaccessible environment data from unrelated processes prevents the existing process-owner cleanup proof. Initial ordinary-host Java probes failed before import, including an x86 control; isolated runs preserve the production ownership checks and succeed. No process-supervision code changed.

Checks and review corrections

  • npm run test:focused -- src/domain/binaryTarget.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/hopper/HopperProvider.test.ts src/ida/IdaProvider.test.ts tests/boundary/mcp/liveBinaryTargetSummary.test.ts — 387 passed initially and again after synchronizing main and correcting the review findings.
  • Impossible-summary regressions failed in both JSON Schema dialects against fix(elf): admit Xtensa binaries through Ghidra #10774 before sharing the canonical constraint. Both session-output schemas now check every valid/invalid fixture, replacing a positional slice and first-format lookup that silently dropped coverage. The updated 4-test matrix passed on the synchronized base.
  • npm run check:fast — typecheck, lint and architecture guards passed, including after synchronizing main.
  • npm run docs:check — generated-document checks and 8 consistency tests passed before main synchronization.
  • npm run verify:advertised-schemas -- --update-summary — succeeded in the temporary namespace; listed 4 packaged catalogs and checked 31 patterns through V8, Go RE2 and Python. C++ RE2/Rust validators were unavailable and are explicitly unverified. Updated the tracked summary: only open_binary's compact output digest changes after main's schema-profile migration.

Greptile follow-up completed successfully (5/5); both actionable review threads are resolved. Codex review could not run because the repository quota is exhausted. Actions remain queued, so they are not reported as passed. Maintainer-authorized administrative merge is used for that infrastructure blocker after local validation.

Author readiness

Human owner: @N0zoM1z0 (listed author exemption in CONTRIBUTING.md).

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

joshua4163 and others added 2 commits November 15, 2026 13:43
Adapted from #10774 without illustrative screenshots.

Co-authored-by: gensokyo-dev <[email protected]>
Keep ELF-only Xtensa out of PE, Mach-O and DOS summaries with one canonical exclusion set. Validate both advertised JSON Schema dialects and preserve the Ghidra header-selected language policy.

Co-authored-by: gensokyo-dev <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T13:52:34.297738Z
We couldn’t complete this review. Comment @codex review to try again.
37fa99b PR opened
ℹ️ 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

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] No blocking code issue remains in the reviewed changes.

Summary

The PR recognizes ELF machine 94 as xtensa and admits it through Ghidra’s existing header-based import path.

  • Xtensa ELF files reach Ghidra and keep their architecture in results.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  ELF["ELF machine 94"] --> Parser["Canonical xtensa target"]
  Parser --> Summary["CLI/MCP summary and Evidence"]
  Parser --> Admission{"Provider"}
  Admission --> Ghidra["Ghidra: header-selected import"]
  Admission --> Hopper["Hopper: declined"]
  Admission --> IDA["IDA: declined"]
  Exclusions["Shared header exclusions"] --> Summary
Loading

Reviews (2) · Last reviewed commit: "test(elf): preserve the full target matr..." · Reviewed by Greptile

Comment thread src/domain/binaryTargetTypes.ts Resolved
gensokyo-dev and others added 2 commits November 15, 2026 13:59
Validate every canonical and impossible classification through both live session outputs. Refresh the packaged catalog summary after synchronizing with main's compact schema contracts.

Co-authored-by: gensokyo-dev <[email protected]>
@gensokyo-dev
gensokyo-dev merged commit 1995ab7 into main Nov 15, 2026
7 of 11 checks passed
@gensokyo-dev
gensokyo-dev deleted the fix/xtensa-elf-10765 branch November 15, 2026 14:09
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working labels Nov 22, 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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ELF files with e_machine = EM_XTENSA (94) are rejected before analysis, although Ghidra supports Xtensa

4 participants