Skip to content

feat(native): resolve RISC-V ELF initializer pointers - #11828

Closed
ShuaixinHuang wants to merge 1 commit into
morluto:mainfrom
ShuaixinHuang:feat/elf-riscv-pointer-relocations
Closed

ShuaixinHuang wants to merge 1 commit into
morluto:mainfrom
ShuaixinHuang:feat/elf-riscv-pointer-relocations

Conversation

@ShuaixinHuang

@ShuaixinHuang ShuaixinHuang commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Simple Clang/LLD-produced RV32/RV64 ELF shared libraries return incomplete initializer reports with all four addresses unknown on main. Resolve their RELATIVE/RELR local constructors and finalizers, and word-sized absolute references to defined functions; keep external constructors unresolved imports.

The shared relocation owner now selects rules by machine and ELF class, with RV32/RV64 profiles, explicit GLOB_DAT ownership, and known COPY/TLS/resolver write extents. RISC-V type 6 is TLS_DTPMOD32 and must never inherit x86 GLOB_DAT value semantics. Migrate section consumers to the same class-aware rules. Preserve malformed/unknown, partial-write, duplicate-write, capacity and cancellation behavior.

This is a read-only compatibility extension to existing ELF inspection. No matching open initializer PR was found; existing RISC-V provider-admission work covers a different boundary.

Validation

  • 184 initializer/ELF tests across 8 files, including public CLI/stdio MCP for RV32/RV64 RELA, RELR, defined/imported symbols, unknown kinds, write-width mismatches and unchanged input SHA-256.
  • 290 shared-reader/JNI/IL2CPP tests across 4 files (50 overlap the first run): sparse provenance, value materialization, signed addends, TLS/IFUNC uncertainty, COPY sizes, mapping ownership and existing large-table capacity.
  • npm run check:fast: typecheck/lint and architecture guards passed.
  • npm run docs:check: 6 generated-document tasks and 8 consistency tests passed. Updated the existing guide/spec/plan/tasks.
  • npm run verify:test-discovery: all 3,773 test/spec files discovered exactly once.
  • Independent producer: Debian Clang/LLD 19.1.7 and GNU readelf 2.44, six RV32/RV64 ET_REL, RELA and RELR images from the committed inert C source and recipe. Public CLI addresses matched readelf's local/defined symbol coordinates in all six files; one external import stayed unknown and source hashes stayed unchanged. The four shared-object controls on the unchanged base reader returned four unknown addresses/incomplete coverage.

The old unsupported-machine controls in initializer and IL2CPP tests now use still-unsupported PPC64; their refusal assertions remain in place. Portable tests use synthetic ELF carriers, while compiler-produced binaries remain outside the repository.

Coverage limit: verification ran on Linux x86-64 with little-endian cross-produced files. No RISC-V host, dynamic-loader execution, production application dump, or target execution was tested. TLS/COPY/resolver controls are source tests, not claims about the six producer images.

Author readiness

Human owner: @ShuaixinHuang

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

@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-17T13:04:24.633351Z
We couldn’t complete this review. Comment @codex review to try again.
84a7d3d 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 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge based on the changed code.

Summary

Adds RV32/RV64 support to read-only ELF initializer inspection through shared, class-aware relocation rules.

  • RISC-V ELF pointer readers now resolve relocations by machine and class.
  • RISC-V initializer reports now resolve local constructor and finalizer addresses.

Review used code inspection; tests were not rerun.

Reviews (3) · Last reviewed commit: "feat(native): resolve RISC-V ELF initial..." · Reviewed by Greptile

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

2 participants