Repository navigation
[AUTOMATED] feat(p1): ifuncfpret Stage A - name x86-64 IFUNC PLT stubs so tail jumps to glibc dispatchers become named tail calls - #287
Merged
Conversation
mahaloz
marked this pull request as ready for review
August 12, 2026 14:06
…turn recovery A five-link analysis chain (IFUNC .plt.sec stub discovery -> tailcalljump -> indirect tail-return recovery -> non-void inconclusive return -> call-site xmm0 output recovery) needed to recover the double return of glibc math wrappers like sub_15620 (log), so callers like f64_log_base @ 0xf090 stop reading xmm0 uninitialized. Root-caused from the interp-bee/jit-bee IDA study; proposal only, no implementation (large/multi-part per CLAUDE.md). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_017irbkwk5TigYwPSP7DrfPj
…tubs (elf_plt.rs) Stage A of the ifuncfpret chain: name the x86-64 .plt.sec/.iplt IFUNC (R_X86_64_IRELATIVE) stubs the symbol-keyed PLT pass leaves undiscovered, gated by `option ifuncfpret` (default-off env bridge, like i386_pie_plt). When on, the stub becomes a discovered `ifunc_<resolver>` FunctionSymbol so tailcalljump recovers a tail `jmp` to it: sub_15620 renders `ifunc_15c80(); // tail-call` instead of `(*dat_def20)()`. Default-off is byte-identical. Stages B-D (the actual FP-return-type recovery) remain BLOCKED on a Ghidra-divergent change: truncate_indirect_jump plants a void artificial_halt for an indirect tail-jmp (upstream-faithful), so the stub is void and the double return can't propagate. Documented in docs/features/ifuncfpret/proposal.md. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_017irbkwk5TigYwPSP7DrfPj
…spec Complete the ifuncfpret option (default-off, opt-in): architecture flag + handler, env bridge on the decompile / decompile-all CLIs and the console catalog live value, phases.toml settable row, options.rs registration, catalog counts (settables 101->102, analysis tier 35->36, PASS_GATES + fixture), an elf_plt unit test (x86_64_ifunc_stub_naming) and the gate-module test, docs/options.md, and the docs/spec/01 loader-PLT prose. Default-off is byte-identical (675/675 and stages PARITY OK); when on, x86-64 IFUNC .plt.sec stubs are named ifunc_<resolver> so tailcalljump recovers tail jumps to them. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_017irbkwk5TigYwPSP7DrfPj
…ve-preset invariant) ifuncfpret is default-off and its Stage-A-only behavior (synthetic ifunc_<resolver> names, tail-call recovery, no xmm0-return fix yet) is a deliberate opt-in, so it joins v850indirectbranch/dwarf_lines/formatstring in EXCLUDED_ON_PURPOSE rather than AGGRESSIVE_OVERRIDES. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_017irbkwk5TigYwPSP7DrfPj
…cfpret proposal ActionReturnRecovery recovers the output register from what CPUI_RETURN reads; the stub's void artificial_halt reads none, so the callee is void. Stage B = make the indirect tail-jmp's terminal RETURN read the CALLIND's return-register output (XMM0, inter-procedurally inferred), a Ghidra-divergent core-flow change. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_017irbkwk5TigYwPSP7DrfPj
mahaloz
force-pushed
the
feat/ifuncstub
branch
from
August 12, 2026 14:15
617cb7e to
28b0fdf
Compare
This was referenced Aug 12, 2026
Merged
mahaloz
added a commit
that referenced
this pull request
Aug 12, 2026
…hile the catalog is 103 `main` is red on the cargo workspace suite at 80f8f29: thread 'fixture_has_all_102_settables' panicked at crates/kuna-decomp/tests/catalog_bytecompat.rs:82:5: assertion `left == right` failed left: 103 right: 102 Nothing is wrong with the catalog. `phases.toml` has 103 settable rows, the fixture `tests/fixtures/phase_catalog.json` carries 103, and `kuna_phases/tests.rs` correctly asserts 103. Only this one test's three hard-coded copies of the same number were left behind: #287 regenerated the fixture and bumped `kuna_phases/tests.rs`, but did not touch `catalog_bytecompat.rs`, which #290 had last set to 102. This is the fourth time this class of counter has broken in two days -- three of the four during the round-4 merge train, where `main` and a branch had made the identical `N -> N+1` edit and git auto-merged them silently at the wrong value with no conflict marker. It reaches `main` because the workspace suite is skipped for internal PRs (#274), so nothing runs it until after the merge. Exactly one test failed in the whole CI run and the spec-tree guards never fired, so this assert is the entire breakage. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH
mahaloz
added a commit
that referenced
this pull request
Aug 12, 2026
…hile the catalog is 103 (#292) `main` is red on the cargo workspace suite at 80f8f29: thread 'fixture_has_all_102_settables' panicked at crates/kuna-decomp/tests/catalog_bytecompat.rs:82:5: assertion `left == right` failed left: 103 right: 102 Nothing is wrong with the catalog. `phases.toml` has 103 settable rows, the fixture `tests/fixtures/phase_catalog.json` carries 103, and `kuna_phases/tests.rs` correctly asserts 103. Only this one test's three hard-coded copies of the same number were left behind: #287 regenerated the fixture and bumped `kuna_phases/tests.rs`, but did not touch `catalog_bytecompat.rs`, which #290 had last set to 102. This is the fourth time this class of counter has broken in two days -- three of the four during the round-4 merge train, where `main` and a branch had made the identical `N -> N+1` edit and git auto-merged them silently at the wrong value with no conflict marker. It reaches `main` because the workspace suite is skipped for internal PRs (#274), so nothing runs it until after the merge. Exactly one test failed in the whole CI run and the spec-tree guards never fired, so this assert is the entire breakage. Claude-Session: https://claude.ai/code/session_01C8UQbPqALzdUQ3cLLjUeKH Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Aug 13, 2026
…inst a 103-row table (#291) PR #287 (ifuncfpret) added the 103rd settableTable row and bumped both `phases.toml` and `kuna_phases/tests.rs`, but not the third counter in `tests/catalog_bytecompat.rs`, so `make rust-test` has been red on main since that merge: fixture_has_all_102_settables ... FAILED assertion `left == right` failed left: 103 right: 102 CI did not catch it because internal pull requests skip the workspace suite (#274), which leaves the author as that gate. Also renames `surface_count_is_101`, which has asserted 102 since the surface table last grew, so the test name stops contradicting its body. No production code changes; counts only. Claude-Session: https://claude.ai/code/session_01XTrU5w3qoWMyu38FprpfXZ Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What (Stage A of the
ifuncfpretchain)New
option ifuncfpret(P1 loader, default-off, x86-64): name the IFUNC(
R_X86_64_IRELATIVE).plt.sec/.ipltPLT stubs that the symbol-keyed PLT passleaves undiscovered (an IRELATIVE slot carries no symbol — only its resolver's
address). When on, each stub becomes a discovered
ifunc_<resolver>function, so atail
jmpto it is recovered as atailcalljumpinstead of flowing into the stub.Why
From the interp-bee/jit-bee IDA study (
docs/features/ifuncfpret/proposal.md):f64_log_base @ 0xf090readsxmm0uninitialized because glibclog(
sub_15620) tail-jumps to an undiscovered IFUNC stub, so kuna types the wholemath-wrapper family
void. Stage A makessub_15620renderifunc_15c80(); // tail-callinstead of the opaque(*dat_def20)().Scope: Stage A only
This ships the loader-fidelity prerequisite. It does not yet fix the
xmm0return type — that needs Stage B (recover an indirect tail-
jmpasreturn (*ptr)(...)), a Ghidra-divergent change to core call/return recoverythat will land as a focused follow-up PR. The proposal documents the fully-proven
mechanism: forcing
sub_15620tofloat8makesf64_log_baserender exactlyIDA's
v1 = fake_log(a1); return v1 / fake_log(a0);.Gates
make test675/675 and stages PARITY OK (default-off = byte-identical).make rust-testgreen: newelf_plt::tests::x86_64_ifunc_stub_naming+kuna_ifuncfpretgate test;EXCLUDED_ON_PURPOSEupdated; catalog counts101→102 (analysis tier 35→36, fixture, PASS_GATES).
make check-specOK (strict);kuna catalog --checkOK.--option ifuncfpret on→ifunc_15c80(), off →(*dat_def20)().🤖 Generated with Claude Code
https://claude.ai/code/session_017irbkwk5TigYwPSP7DrfPj