Skip to content

fix(native): retain defined global and weak ELF symbols with GNU version index 0 - #9100

Merged
morluto merged 1 commit into
morluto:mainfrom
highmachs:fix/elf-exports-unversioned-global-version-index-0
Nov 6, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
highmachs:fix/elf-exports-unversioned-global-version-index-0

Conversation

@highmachs

Copy link
Copy Markdown
Contributor

Summary

Fixes #8984.

Retains defined, default/protected-visibility global, weak, and unique dynamic ELF symbols when their GNU symbol-version index is 0 (VER_NDX_LOCAL), reporting them as unversioned exports (version: null) rather than unconditionally omitting them from export inventory.

Problem and expected behavior

NativeExportParser parses defined dynamic symbols and applies binding, section, and visibility guards (rejecting undefined, local, and hidden/internal symbols). However, when a .gnu.version table was present, line 697 unconditionally executed if (versionIndex === 0) continue;, discarding any defined global or weak symbol assigned version index 0.

GNU Binutils and Oracle Solaris versioning specifications state that version index 0 denotes an unversioned base symbol (or one to which no explicit version definition applies), not that an otherwise global or weak symbol definition is localized or hidden. Consequently, defined exports with version index 0 were omitted from inspect-native-exports results despite coverage.status: "complete".

Expected behavior:

  • Defined global, weak, and unique symbols with version index 0 are emitted with version: null.
  • Non-export symbols (undefined, local binding, hidden/internal visibility) continue to be excluded by existing guards.

Change and scope

  • In src/native/exports/NativeExportParser.ts, removed if (versionIndex === 0) continue;. Version indexes 0 and 1 correctly resolve to version: null, while indexes >= 2 resolve through version definitions and requirements.
  • In src/native/exports/NativeExportParser.test.ts:
    • Updated the dynamic symbol fixture to distinguish between an unversioned global symbol at version 0 and a locally bound symbol at version 0 (binding: 0).
    • Added a dedicated test verifying defined global and weak symbols at version index 0 are retained with version: null, while undefined, hidden, and local symbols remain excluded.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/native/exports/NativeExportParser.ts.
  • Contribution scope fit and linked maintainer decision: not applicable (bugfix within native diagnostics export parser).
  • CLI and MCP/tool-catalog contract: preserves inspect-native-exports and native_exports schema.
  • Provider, bridge, target-format, or platform compatibility: ELF dynamic symbol parser across all architectures (x86, x86-64, arm, arm64, ppc, etc.).
  • Evidence, artifact, provenance, or reconstruction contract: unversioned global/weak symbols now visible in export evidence.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/native/exports/NativeExportParser.test.ts — 46/46 tests passed.
  • npm run compile — passed with 0 errors.
  • npm run check:fast — passed with 0 errors (Turbo typecheck and linting across all packages).
  • npm run verify:module-boundaries — 3750 source files checked, passed.
  • npm run verify:test-discovery — 3128 test files checked, passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: safe static ELF parser improvement.

Author readiness

Human owner: @highmachs

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

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 05:14
@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-06T05:14:14.197056Z
We couldn’t complete this review. Comment @codex review to try again.
98ec5c0 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.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@morluto
morluto merged commit 711b374 into morluto:main Nov 6, 2026
44 checks passed
Afloat16 added a commit to Afloat16/rea that referenced this pull request Nov 6, 2026
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.
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working labels Nov 26, 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.

[Bug] inspect-native-exports omits unversioned global and weak ELF symbols with version index 0

3 participants