Skip to content

feat(elf): inspect exports without section headers - #9083

Merged
N0zoM1z0 merged 10 commits into
morluto:mainfrom
Afloat16:feat/elf-sectionless-exports
Nov 22, 2026
Merged

N0zoM1z0 merged 10 commits into
morluto:mainfrom
Afloat16:feat/elf-sectionless-exports

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Inspect ELF exports when no usable SHT_DYNSYM section exists but program headers describe a readable dynamic table. Read PT_DYNAMIC, translate addresses through admitted file-backed PT_LOAD mappings, and derive the symbol count from DT_HASH or DT_GNU_HASH. Reuse existing symbol selection, decoding, inventory limits and output schemas; section-backed ELF and PE retain their existing paths.

An indeterminate count remains unsupported; conflicting counts or malformed declarations produce typed failures. Version indices and hidden flags are retained, but unresolved version definition/requirement names are marked partial. The tool description and binary diagnostics guide document these limits.

Current integration and validation

Head: 313c00ad693f0cbd70b0e0b7257befa808216925 (2026-11-20).

Integrated main c0ee832a30, including #12416's shared cooperative ELF directory. parseElfExportsFromDirectorySteps now consumes the already-admitted directory; the shared ELF image helper and NativeExportsProvider are identical to main. The fallback qualification and resource limits are retained.

With Node 24.22.1 / npm 11.16.0 and ordinary locked npm ci:

  • Standard runtime/skill build and 208 focused tests across 10 files passed, including upstream ELF section-name cancellation controls.
  • npm run check:fast (typecheck, lint, architecture guards), npm run docs:check (all 8 README consistency tests), formatting of all 7 changed files and git diff --check passed.
  • Published tree ee1d2e4d2637e1b55a27fd258a3e7e623d2965cf exactly matches the validated candidate.
  • Required CI passed: 18 successful, 25 conditionally skipped, no failed checks.

Regression and earlier evidence

  • Initial ELF32 big-endian SysV, ELF64 little-endian GNU and ELF64 big-endian dual-hash fixtures reproduced the former unsupported result. Twenty parser cases cover enumeration, bounds, malformed/incomplete declarations and string/version qualifications. A filesystem regression checks typed rejection, service reuse and unchanged input identity. The current 208-case run validates retained regressions; no new unchanged-main red run is claimed.
  • Four GCC-built shared libraries (SysV, GNU, dual-hash and versioned GNU), with only section-directory declarations cleared, were compared using the compiled CLI and readelf --use-dynamic --symbols --wide. Names, values, sizes, types, bindings and visibility agreed. The first three returned two complete exports; the versioned fixture returned three, preserved index 2 and marked the unresolved name partial. No target was executed.
  • The retained-section control proves the fallback also works with a regular section present and no SHT_DYNSYM; a sectionless-only implementation returned zero exports. Regression evidence.
  • Earlier exact-head integration validation passed 199 tests across 9 files, build, fast/docs gates and clean-source checks; its artifact retains complete logs.
  • The inherited Windows Kimi fixture was changed from removed full to supported compact, preserving lowercase-only environment assertions. Before/after validation reproduced the failure and passed 75 tests; four focused Windows controls also caught an injected duplicate uppercase key.

Validation limits

Local runs did not exercise provider runtime integrations or the optional full check:pr gate. The expanded, separate Windows Kimi suite had one unchanged POSIX-slash expectation fail (28/29 passed); that file is outside the curated Windows lane. Real-library comparisons establish static inventory behavior, not execution or general ELF coverage.

Author readiness

Human owner: @Afloat16

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

Use the dynamic segment and hash tables to enumerate exports when an ELF image has no dynamic symbol section. Preserve symbol coverage, version qualifications, and typed failures through the existing native export path.
@chatgpt-codex-connector

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 ⚠️ Failed 2026-11-06T03:12:28.976875Z
We couldn’t complete this review. Comment @codex review to try again.
4fcce55 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 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new actionable issues remain.

Summary

Adds ELF export inspection through PT_DYNAMIC when SHT_DYNSYM is absent.

  • ELF export inspection reads symbols from dynamic tables when section tables are missing.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Admitted ELF directory"] --> B{"SHT_DYNSYM present?"}
  B -->|Yes| C["Read section-backed tables"]
  B -->|No| D["Read PT_DYNAMIC declarations"]
  D --> E["Map tables through PT_LOAD and read hash count"]
  E --> F{"Count established?"}
  F -->|No| G["Unsupported coverage"]
  F -->|Yes| H["Shared symbol and name reader"]
  C --> H
  H --> I["Exports with complete or partial coverage"]
Loading

Reviews (11) · Last reviewed commit: "fix(native): integrate sectionless expor..." · Reviewed by Greptile

Integrate the upstream version-index correction in morluto#9100. The old dynamic-table test excluded a defined global symbol solely because its GNU version index was zero. Check both global and weak symbols as unversioned exports, and keep a local-binding control that must stay excluded.
@CassieFox23

CassieFox23 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I ran the PR's 2 changed test files on Node 22.23.4, 24.22.1 and 26.12.1. All 24 tests passed on each version. The head is 44 commits behind main, and I did not merge with main.

Edit (20 Nov): I ran the new head, 313c00a, in a VM, and the results are here.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
Test Files 2 passed (2) 2 passed (2) 2 passed (2)
Tests 24 passed (24) 24 passed (24) 24 passed (24)

The two files are src/native/exports/ElfDynamicExportTables.test.ts and tests/boundary/filesystem/nativeExportsSectionless.test.ts. I ran them on head 80f92c4.

The PR changes 8 files against the merge base f912a68. Two are test files and 6 are others.

CI on head 80f92c4, read live with gh:

  • Workflow runs CI, PR readiness and PR title are completed/success. CodeQL production is completed/skipped.
  • 23 check runs are success. They include Source tests, Static checks, CI required, Portable tests and Test shard (1/8) through Test shard (8/8).
  • 22 check runs are skipped. They include Deep static checks and website.
  • The commit status PR readiness is success.
  • GitHub shows mergeable true, state clean, and not a draft.

The head is 48 commits behind main c78c8ae.

Not run

  • A run of the full test suite on my VM on head 80f92c4
  • A merge with current main, c78c8ae.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 80f92c4 / f912a68 (merge base with main)
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/native/exports/ElfDynamicExportTables.test.ts tests/boundary/filesystem/nativeExportsSectionless.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

Integrate main a8527d4 while keeping the sectionless export fallback. Unify table selection as a tagged result so compressed section tables retain their unsupported inventory and table_unavailable issue before projection.

Validation: all 96 selected native export parser and filesystem tests pass on Node 24.22.1 with repository-locked dependencies and the repository Vitest configuration. The automatic merge reproduced four compressed-table regressions before this fix. Full repository CI remains pending.

Afloat16 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged main at a8527d43 into this branch in e21f6bb6 and resolved the tool-description conflict while retaining the current concise contract wording.

The merge also exposed a regression in the compressed ELF section-table path: the relocated table-selection helper tried to return a complete inventory and referenced an out-of-scope result. Table selection now returns a tagged result for both section and dynamic paths, preserving the existing unsupported status, table_unavailable issue and original file offset for compressed section tables. Dynamic fallback is still selected only when SHT_DYNSYM is absent.

Validation on the published tree: all 96 tests across ElfDynamicExportTables.test.ts, NativeExportParser.test.ts, nativeExports.test.ts and nativeExportsSectionless.test.ts passed on Node 24.22.1 using the locked dependencies and repository Vitest configuration. The automatic merge failed four compressed-table cases before this correction. git diff --check passed. Repository CI has now passed on e21f6bb6, including all eight test shards, source tests, static checks and the required CI gate. The author declaration now matches the repository template, and PR readiness has passed on this head. Ready for maintainer review.

Move dynamic table parsing with the native domain parsers, retain duplicate-section and reserved-symbol policies, and update the filesystem identity regression.

Afloat16 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated the branch in 5b4f674 by merging main at 093e41a5; GitHub now reports it conflict-free.

The dynamic helper and tests move with the native parsers into src/domain/native/. The shared export projection retains main's duplicate-section checks and reserved-symbol policy: a nonzero reserved st_name is recorded without discarding real exports, while other nonzero reserved fields remain malformed. The fallback keeps typed inventory limits, and the filesystem assertion follows the current Evidence subject.identity contract.

All 110 tests in the four parser/dynamic-table/filesystem suites passed, including three new reserved-name cases. Scoped TypeScript 7.0.2 checking, changed-file lint/format, test discovery and diff checks also passed (lint warnings remain). Local checks used a small dependency installation with Node 24.22.1, Vitest 5.0.3 and Zod 4.6.6; complete locked-install/build/check/docs coverage remains with CI on this head, currently queued. The PR description now distinguishes this validation from the earlier revisions.

Compatibility with #9063 at d46d283 is now checked as well: both merge orders produce tree 3f11027a900b68fb691e48a79c2984e61f415efe, and all 116 tests in the five combined parser/dynamic-table/filesystem suites passed. Neither branch depends on the other.

Use the supported compact profile in the Windows environment-spelling regression. Keep the exact environment assertion so a duplicate uppercase key still fails, and retain separate coverage rejecting the removed full profile.

Copy link
Copy Markdown
Contributor Author

The inherited Windows Kimi fixture blocker is fixed in e60a04f, and required upstream CI for this head has now passed, including the selected tests, Windows capability/package lane, three native package baselines and the final CI required gate.

The update only changes the fixture to the supported compact profile; the ELF export implementation and its regression coverage are unchanged. The Windows control also confirms that introducing a duplicate uppercase environment key still fails the exact assertion and that restoration passes. The PR description now records the completed CI result.

Ready for final maintainer review and merge if the change looks good.

Afloat16 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Integrated main acc3fbb12a in 65ca65cdea5, resolving the new ELF parser conflicts while preserving sectionless enumeration, current name-budget admission and checked table ranges. The original feature tests, fixture and tool contract remain unchanged.

Exact-head validation passed with Node 24.22.1 / npm 11.16.0 and locked npm ci: the standard runtime/skill build, 199 tests across 9 affected parser/metadata/filesystem suites, check:fast, docs:check (8 README consistency tests), changed-file formatting and clean tracked-source checks. The run verifies the exact candidate SHA, tree and merge parents and retains complete logs.

The published head is mergeable again; upstream required checks are pending. The PR body records current and historical validation separately.

Preserve sectionless export enumeration while forwarding the current ELF
name budget and retaining checked section-table ranges and shared symbol widths.

Signed-off-by: Afloat <[email protected]>
Preserve the dynamic export fallback while adopting the admitted ELF directory and shared image projection from current main. Keep synchronous, cooperative, and Android JNI consumers on the same directory facts.
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran the 2 changed test files from PR #9083 on head 313c00a. All 27 tests passed on Node 22.23.4, 24.22.1 and 26.12.1. The head is 32 commits behind main 3e3faf2, and I did not test a merge.

Findings

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
The 2 changed test files pass: Test Files 2 passed (2), Tests 27 passed (27) pass: Test Files 2 passed (2), Tests 27 passed (27) pass: Test Files 2 passed (2), Tests 27 passed (27)

The 2 files are src/domain/native/elfDynamicExportTables.test.ts and tests/boundary/filesystem/nativeExportsSectionless.test.ts. The PR changes 7 files against the merge base. I ran only those 2 test files, not the full suite.

On head 313c00a, GitHub reports mergeable true and state clean. I read CI live with gh.

  • Workflow runs: CI is completed/success, PR title is completed/success, and CodeQL production is completed/skipped.
  • 18 check runs ended in success. The 18 include CI required, Portable tests, Static checks, Test shard (1/1) and Documentation.
  • Other success runs include Windows capability and package lane (capabilities), Windows capability and package lane (package) and the three Native package baseline checks.
  • 25 check runs were skipped. The 25 include Source tests and Deep static checks.

Not run

  • A run of the full suite at head 313c00a.
  • A merge with current main, 3e3faf2.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB, Linux 7.2.11) on my Nobara 44 PC
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 313c00a / c0ee832 (merge base with main)
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/domain/native/elfDynamicExportTables.test.ts tests/boundary/filesystem/nativeExportsSectionless.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@gensokyo-dev
gensokyo-dev force-pushed the feat/elf-sectionless-exports branch from 3377efd to 313c00a Compare November 22, 2026 07:38
@N0zoM1z0 N0zoM1z0 closed this Nov 22, 2026
@N0zoM1z0 N0zoM1z0 reopened this Nov 22, 2026

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

Verified on current main: 101 focused tests pass, and the sectionless boundary regression fails without the change. PT_DYNAMIC symbols are counted only from DT_HASH/DT_GNU_HASH through admitted PT_LOAD mappings, conflicting counts are refused, and unresolved versions stay partial. Fresh CI is green. Thanks.

@N0zoM1z0
N0zoM1z0 merged commit 7e15884 into morluto:main Nov 22, 2026
121 of 134 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.

5 participants