Skip to content

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

Closed
ShuaixinHuang wants to merge 1 commit into
morluto:mainfrom
ShuaixinHuang:replace/pr-12041
Closed

ShuaixinHuang wants to merge 1 commit into
morluto:mainfrom
ShuaixinHuang:replace/pr-12041

Conversation

@ShuaixinHuang

@ShuaixinHuang ShuaixinHuang commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces #12041 against main 8a10fa9.

Carry the class-aware RV32/RV64 relocation profiles and TLS offset fix onto the shared fixed/APS2 relocation path. Imported pointers remain unresolved, and TLS offsets supply neither an initializer address nor an address name.

Validation

  • 380 focused tests passed across the ELF reader, APS2, initializer parsers, IL2CPP and compiled CLI/stdio MCP.
  • Scoped lint passed for the changed TypeScript files.
  • Full hosted checks and other platforms were not run locally.

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

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T15:48:31.433075Z 66ff608 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.

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

[Medium impact] The change affects native ELF initializer inspection across its existing entry points.

The focused acceptance test must follow the required contract-import rule before merging; no new code defect was found.

Findings

  1. P2 Focused test loads every contract. ▶
Fix with agent prompt
### Issue 1
tests/acceptance/riscvNativeInitializersCli.test.ts:undefined-5
This single-tool test imports `toolContracts.ts`, which loads every contract family. The testing guide requires focused tests to import their named contract family and reserves the full catalog for catalog-wide checks. Import `BINARY_DIAGNOSTICS_TOOL_CONTRACTS` and select `inspect_native_initializers` by name instead. This avoids unrelated setup work and dependencies.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds RV32/RV64 initializer pointer decoding through the shared ELF reader.

  • RISC-V initializer pointers resolve using their ELF class.

This review used source inspection; tests were not rerun. Checking whether another PR supersedes this one was blocked by unavailable GitHub authentication.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Class["ELF machine and word size"] --> Profiles["Shared relocation profiles"]
  Fixed["Fixed REL/RELA, APS2 and RELR"] --> Dynamic["Dynamic relocation reader"]
  Profiles --> Dynamic
  Profiles --> Sections["Section relocation reader"]
  Records["Section REL/RELA"] --> Sections
  Dynamic --> Slots["Initializer targets and names"]
  Sections --> Slots
  Slots --> Report["CLI / MCP report"]
Loading

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

import { readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect } from "vitest";
import { toolContract } from "../../src/contracts/toolContracts.js";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Focused test loads every contract. This single-tool test imports toolContracts.ts, which loads every contract family. The testing guide requires focused tests to import their named contract family and reserves the full catalog for catalog-wide checks. Import BINARY_DIAGNOSTICS_TOOL_CONTRACTS and select inspect_native_initializers by name instead. This avoids unrelated setup work and dependencies.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/acceptance/riscvNativeInitializersCli.test.ts
Line: 5

Comment:
**Focused test loads every contract.** This single-tool test imports `toolContracts.ts`, which loads every contract family. The testing guide requires focused tests to import their named contract family and reserves the full catalog for catalog-wide checks. Import `BINARY_DIAGNOSTICS_TOOL_CONTRACTS` and select `inspect_native_initializers` by name instead. This avoids unrelated setup work and dependencies.

**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@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