Skip to content

feat(elf): report separate debug-file linkage and verify a candidate debug file - #9560

Merged
N0zoM1z0 merged 33 commits into
morluto:mainfrom
mvanhorn:fix/elf-debug-file-linkage
Nov 17, 2026
Merged

N0zoM1z0 merged 33 commits into
morluto:mainfrom
mvanhorn:fix/elf-debug-file-linkage

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add offline inspect-elf-debug-link / inspect_elf_debug_link for ELF32/ELF64 debuglink/altlink declarations, GNU build IDs, conventional lookup strings and MiniDebugInfo presence. Only the selected image and optional selected candidate are opened; neither is executed. Candidate CRC32 and SHA-256 stream over the complete file while retained decoding bytes stay bounded.

Integrate current shared ownership: canonical named parser limits, completed buffered/streamed identity, preserved cancellation and failed-close resources, and application-owned complete/partial Evidence with original caller selections across cleanup completion. Hardening retains confirmed PIE/NX/RELRO when a shared note budget stops decoding. The candidate's fixed whole-file ceiling has distinct recovery from the image's selected read budget.

Validation

  • Focused parser, provider and service tests passed, including compressed-name admission, omitted/explicit controls, candidate cancellation, failed-close ownership, partial Evidence after cleanup release, and lifecycle registration.
  • Public CLI/MCP, filesystem, shared resource/finalization and short-read checks passed; hardening parser and provider capability conformance checks passed.
  • Real GCC/objcopy ELF on Linux: CLI and stdio MCP in full and hot-cold profiles returned matches for split debug info and does_not_match for a one-byte altered candidate. Independent readelf build IDs and Python CRC32 agreed; target hashes stayed unchanged. The target was not executed.
  • Typecheck, Knip, architecture guards, advertised-schema verification, generated metadata and docs checks passed. Changed-file lint/format passed. Final-head CI passed all required gates, all 12 test shards and the Windows capability/package lane. Automated review passed with no unresolved threads.

Local expensive checks ran serially under one CPU and an 8 GiB hard / 6 GiB early-stop memory budget; no OOM occurred. Full typed lint was not rerun after exceeding that local budget during the preceding integration. Real dwz altlinks, distribution debuginfo packages and MiniDebugInfo decoding were not verified; MiniDebugInfo remains presence-only.

Author readiness

Human owner: @mvanhorn

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

…debug file

inspect_elf_debug_link and inspect-elf-debug-link read one local ELF32
or ELF64 image and report its .gnu_debuglink name and CRC32, its
.gnu_debugaltlink name and build-id, its GNU build-id from PT_NOTE and
SHT_NOTE, and .gnu_debugdata presence, plus the conventional GNU/Linux
lookup path strings, which are not opened. With a caller-selected
candidate, the candidate is streamed in bounded chunks and its CRC32 and
GNU build-id are compared, returning matches, does_not_match or
cannot_verify. Nothing is executed or searched for. Names, build-ids and
note scans are bounded, target-derived names are marked untrusted, and
the MCP input schema requires absolute paths.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

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-17T08:54:08.983808Z
We couldn’t complete this review. Comment @codex review to try again.
6f2e68d 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.

@greptile-apps

greptile-apps Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge, with no new actionable findings.

Summary

Adds offline ELF debug-file inspection and verification of one caller-selected candidate.

  • ELF inspections report debug-file links and check one selected candidate.
  • Stable file reads can hash whole streams while keeping only a bounded prefix.
  • ELF note scans report named limits and preserve confirmed hardening facts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[CLI or MCP request] --> B[Validate selected paths and limits]
  B --> C[Stable read of selected ELF image]
  C --> D[Decode linkage and build-ids]
  D --> E{Candidate selected?}
  E -->|No| H[Create Evidence]
  E -->|Yes| F[Stream selected candidate]
  F --> G[Compare CRC32 and available build-id]
  G --> H
  F -->|Cancellation or failed close| I[Retain completed observations]
  I --> J[Attach caller Evidence to matching errors]
  J --> K[Preserve Evidence after cleanup retry]
Loading

Reviews (20) · Last reviewed commit: "fix(elf): retain caller Evidence through..." · Reviewed by Greptile

Comment thread src/native/elf/ElfDebugLinkProvider.ts Resolved
Comment thread src/native/elf/ElfDebugLinkProvider.ts Resolved
Comment thread src/resources/readStableArtifact.ts Resolved
Comment thread src/native/elf/ElfDebugLink.ts Resolved
Comment thread src/domain/native/elfDebugLink.ts Resolved
Comment thread docs/guides/native/elf-debug-link.md 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: 779b36250d

ℹ️ 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/native/elf/ElfDebugLinkProvider.ts Resolved
Comment thread src/native/elf/ElfDebugLink.ts Resolved
The documentation guide assigns analyst workflows to docs/guides/<domain>/.
Move the guide there, place its navigation and directory entries in the
Native binaries group, and update links from the docs index, CLI guide,
spec and authored skill. The public /elf-debug-link route is unchanged.

@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: a801927de0

ℹ️ 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/native/elf/ElfDebugLinkProvider.ts Resolved
…e failed candidate close

parseElfNotes accepts maxGnuBuildIdBytes and leaves a larger GNU build-id
descriptor undecoded, so inspect_elf_debug_link judges the 256-byte limit
from descsz before any hex expansion, for both the image and the candidate.

build_id.sources lists each contributing GNU build-id note with its table
kind, table index, and note and descriptor file ranges, so distinct or
conflicting ids stay traceable to their notes.

A candidate read that failed with integrity or limit and whose close also
failed now fails the call instead of returning candidate_unreadable, so
the pending handle stays visible.
Comment thread src/native/elf/ElfDebugLink.ts Resolved
Comment thread src/cli/binaryDiagnosticsCommands.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: c7dd630703

ℹ️ 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/resources/readStableArtifact.ts Resolved
…ate failures

Retain the decoded image report as partial Evidence when the candidate
phase fails (cancellation, close failure, path refusal). A candidate
stream that completed before cancellation or a failed close keeps its
full comparison, including whole-file SHA-256 and size.

completedStableArtifact recognized only buffered {bytes, sha256}
completions. Stream completions {sha256, size, prefix} now recover their
whole-file identity from size, so file-snapshot observations no longer
drop a completed stream.

A candidate data-read EIO is classified as unreadable, so inspect returns
cannot_verify with the image linkage instead of discarding it.

Evidence construction moves to src/domain/native/elfDebugLinkEvidence.ts
so the provider and service share one interpretation.
…CLI spelling

candidateSections reported .debug_info and .symtab as present from the
section name alone. A declaration whose range is not inside the file
now leaves that section unknown instead of claiming the candidate adds
debug information or symbols.

The CLI resolved --candidate-path before Evidence and only bound the
image's original spelling. finishCliEvidenceCommand now accepts
additional caller paths, and inspect-elf-debug-link binds the candidate
as caller_input_paths.candidate_path, matching inspect-api-contract.

@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: f6a0463139

ℹ️ 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/native/elf/ElfDebugLink.ts Resolved
A compressed .shstrtab was inflated by readElfImage under the directory's
fixed 16 MiB structural allowance before observeBuildId checked the
caller-selected source-plus-decoded-names budget, so a small max_file_bytes
did not prevent the allocation it refuses. Check the declared decoded size
against the remaining allowance before either decoder runs, for the image
and for the candidate.
Comment thread src/native/elf/ElfNoteParser.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: 2735594326

ℹ️ 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/native/elf/ElfNoteParser.ts Resolved
…ports

The early name-expansion check read the compression header itself and
rejected an image whose .shstrtab used an unsupported compression type
with a large declared size, although no decoder would inflate it and the
build-id was still recoverable. Expose the section-name table's header
facts from its owning reader and charge the budget only for zlib or zstd.

@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: 4b8c91cc37

ℹ️ 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/native/elf/ElfNoteParser.ts Resolved
mvanhorn and others added 4 commits November 9, 2026 04:10
The early name-expansion check read the raw e_shnum, so an image whose
section count lives in section zero skipped the check while readElfImage
still inflated .shstrtab under its structural allowance. Use the section
directory's resolved table declarations, which include extended counts.
Resolve cliEvidenceCallerPath.ts by taking upstream's CallerInputPaths type for additionalPaths, which covers this branch's single candidate path.
# Conflicts:
#	src/artifacts/StableArtifactObservation.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: e57a0c8c2a

ℹ️ 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/native/elf/ElfDebugLinkProvider.ts Resolved
A fully read image that then fails ELF decoding or exceeds max_entries
now forwards its completed snapshot to projectStableArtifactFailure, so
callers receive the file-snapshot-hash partial observation, matching
ElfNotesProvider.
Picks up the upstream compilation fix for the duplicate packageName
declaration in src/cli/adbCommands.ts that the previous main merge
carried into this branch.
@mvanhorn

Copy link
Copy Markdown
Contributor Author

The apk_signature / real-apk-signature job on b3d0143 failed during setup with a read timeout while downloading the pinned Android SDK archives from dl.google.com, before any rea code ran; could a maintainer re-run that job when convenient?

Keep the streamed stable read and pass main's validated-state observer
through it; register inspect-elf-debug-link through main's contract
projection with candidate_path as a caller path; keep the provider below
the application layer; and record the full-profile dialect counts the new
tool adds.
@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.

Main replaced the per-tool register files with the service binding table
and declares standalone availability on contracts, so
inspect_elf_debug_link now binds through serviceToolBindings, declares
availability "standalone", and registerElfDebugLinkTool.ts is removed.

Main also replaced ElfNoteSectionNameBudgetFailure with a shared
ParseFailureError limit, so assertElfSectionNameBudget throws that limit
and the debug-link reader, provider and tests read it through
elfNoteSectionNameBudget.
@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.

@mvanhorn

Copy link
Copy Markdown
Contributor Author

Merged current main in f3bef99 to clear the conflicts in src/application/CapabilityInventory.ts, src/server/createServer.ts and src/native/elf/ElfNoteParser.ts. inspect_elf_debug_link now binds through serviceToolBindings.ts with availability "standalone" in place of its register file, and the debug-link reader and provider read main's shared section-name budget limit instead of the removed ElfNoteSectionNameBudgetFailure class.

Comment thread src/native/elf/ElfDebugLink.ts Resolved
Bind the tool through main's shared service binding table, declare its
availability on the contract, and report coverage with the shared coverage
vocabulary that main's new guards require.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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

Keep inspect_elf_debug_link as a contract CLI command after command names moved onto each tool, and keep the debug-link section-name budget on main's shared decoder.
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Merged current main in e7530b4 to clear the new conflicts. src/cliCommandNames.ts stays deleted as on main, and inspect_elf_debug_link now declares cli: true and toolContractMetadata("inspect_elf_debug_link", evidenceEffects) in binaryDiagnosticsToolContracts.ts in place of the old name and effect tables. ElfNoteParser.ts keeps main's change alongside the debug-link additions.

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

Resolve the import conflict in src/native/elf/ElfNoteParser.ts by keeping
both sides: the branch's section-directory and section-name-table header
readers, and main's sha256Hex helper.
Main now requires every integrity ArtifactReaderFailure to name its check,
so the provider tests pass container-identity for a changed candidate.
@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.

@mvanhorn

Copy link
Copy Markdown
Contributor Author

Merged current main again in a184f30 to clear the new conflict. ElfNoteParser.ts keeps both import sets: the branch's readElfTableDeclarationsFromBuffer and readElfSectionNameTableHeader, and main's sha256Hex. Main now requires an integrity ArtifactReaderFailure to name its check, so ElfDebugLinkProvider.test.ts passes container-identity for the changed-candidate cases. src/cliCommandNames.ts stays deleted, and the elfDebugLink conformance entry is still in providerCapabilityCases.ts.

On Node 24.22.1, npm run typecheck, npm run verify:module-boundaries, and vitest on the ELF debug-link, ElfNoteParser, and provider capability conformance test files pass locally.

gensokyo-dev and others added 2 commits November 17, 2026 08:23
Preserve both ELF diagnostics registrations and use the completed stable-read identity for buffered and streamed failure observations.

Co-authored-by: gensokyo-dev <[email protected]>
Keep complete and partial Evidence creation in the application service with caller-selected parameters. Migrate shared ELF note budgets and their debug-link, notes and hardening consumers to canonical parse limits. Preserve completed stream identity and failed-close ownership, with distinct candidate read-ceiling recovery.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)

Co-authored-by: gensokyo-dev <[email protected]>
@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.

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the selected-path offline scope and integration with current main. Canonical note budgets preserve hardening facts; complete and partial Evidence share the application owner and preserve caller selections. Focused public/lifecycle checks and real GCC/objcopy CLI plus stdio MCP match/mismatch controls passed. Exact-head CI and automated review remain the merge gates.

Normalize each cleanup owner sharing the same partial report to the same application Evidence, so cleanup release cannot expose stale parameters. Register the provider lifecycle coverage with its public operation and cancellation controls.

Co-authored-by: gensokyo-dev <[email protected]>
@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.

@N0zoM1z0
N0zoM1z0 enabled auto-merge (squash) November 17, 2026 08:57
@N0zoM1z0
N0zoM1z0 merged commit 54e3918 into morluto:main Nov 17, 2026
58 of 60 checks passed
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request 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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants