Skip to content

[AUTOMATED] feat(p1): ifuncfpret Stage A - name x86-64 IFUNC PLT stubs so tail jumps to glibc dispatchers become named tail calls - #287

Merged
mahaloz merged 5 commits into
mainfrom
feat/ifuncstub
Aug 12, 2026
Merged

mahaloz merged 5 commits into
mainfrom
feat/ifuncstub

Conversation

@mahaloz

@mahaloz mahaloz commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What (Stage A of the ifuncfpret chain)

New option ifuncfpret (P1 loader, default-off, x86-64): name the IFUNC
(R_X86_64_IRELATIVE) .plt.sec/.iplt PLT stubs that the symbol-keyed PLT pass
leaves undiscovered (an IRELATIVE slot carries no symbol — only its resolver's
address). When on, each stub becomes a discovered ifunc_<resolver> function, so a
tail jmp to it is recovered as a tailcalljump instead of flowing into the stub.

Why

From the interp-bee/jit-bee IDA study (docs/features/ifuncfpret/proposal.md):
f64_log_base @ 0xf090 reads xmm0 uninitialized because glibc log
(sub_15620) tail-jumps to an undiscovered IFUNC stub, so kuna types the whole
math-wrapper family void. Stage A makes sub_15620 render
ifunc_15c80(); // tail-call instead of the opaque (*dat_def20)().

Scope: Stage A only

This ships the loader-fidelity prerequisite. It does not yet fix the xmm0
return type — that needs Stage B (recover an indirect tail-jmp as
return (*ptr)(...)), a Ghidra-divergent change to core call/return recovery
that will land as a focused follow-up PR. The proposal documents the fully-proven
mechanism: forcing sub_15620 to float8 makes f64_log_base render exactly
IDA's v1 = fake_log(a1); return v1 / fake_log(a0);.

Gates

  • make test 675/675 and stages PARITY OK (default-off = byte-identical).
  • make rust-test green: new elf_plt::tests::x86_64_ifunc_stub_naming +
    kuna_ifuncfpret gate test; EXCLUDED_ON_PURPOSE updated; catalog counts
    101→102 (analysis tier 35→36, fixture, PASS_GATES).
  • make check-spec OK (strict); kuna catalog --check OK.
  • CLI bridge verified: --option ifuncfpret on → ifunc_15c80(), off → (*dat_def20)().

🤖 Generated with Claude Code

https://claude.ai/code/session_017irbkwk5TigYwPSP7DrfPj

@mahaloz
mahaloz marked this pull request as ready for review August 12, 2026 14:06
@mahaloz mahaloz changed the title [AUTOMATED] [PROPOSAL] p1: ifuncfpret - IFUNC-stub tail calls & FP-return recovery for glibc math wrappers [AUTOMATED] feat(p1): ifuncfpret Stage A - name x86-64 IFUNC PLT stubs so tail jumps to glibc dispatchers become named tail calls Aug 12, 2026
mahaloz and others added 5 commits August 12, 2026 14:10
…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
mahaloz merged commit 80f8f29 into main Aug 12, 2026
9 checks passed
@mahaloz
mahaloz deleted the feat/ifuncstub branch August 12, 2026 14:21
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant