Repository navigation
[AUTOMATED] fix(p4): a caller passes its inputs on to a forwarder that calls its target (passthrough) - #764
Merged
Merged
Conversation
…t calls its target (passthrough) passthrough takes a register at a call only when the callee's body is seen reading it, and the callee-body walk ends at every call. A callee that forwards by a call (sub rsp,8; call narrow; add rsp,8; ret, or a tail call the spec models as a call) therefore read nothing, so its callers lost the arguments it passes on, while a jmp forwarder kept them. The walk now also counts what each direct call's target takes, for the register bytes nothing on the forwarder's path wrote before that call, up to three calls deep. A target takes a read only where its own protoorder statement would pass passthrough's callee-side tests (an arity-sound list naming the register, not as a variadic tail); without that, a variadic's register-save prologue on an error path leaks 8-byte reads of every argument register. Only passthrough's stated_width reads the widened summary; calleedeadarg, calleearitybody and the arity claim see the plain walk. Probes stay cached for the run; the fold reads statements, so it is memoized per caller. Fixes #749 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
…ster at (passthrough) A target's read through a call no longer counts for a register the forwarder reads itself. That register is already proven an input by the forwarder's own read, and the deeper read could only change its width: openssh channel_by_id pushes all of rsi for a variadic %d, which made channel_send_open(ssh, int id) and the other channel_lookup callers take a 64-bit id. The through-call step now only adds registers the forwarder never touches. Also routes resolve_node and seed_callee_entry_dead through probe_cached, and adds the gcc-built passthrough_widthfwd_x86_64 fixture with a probe. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
mahaloz
force-pushed
the
fix/issue-749
branch
from
September 29, 2026 21:07
858041f to
c24e79e
Compare
mahaloz
added a commit
to phix33/kuna
that referenced
this pull request
Sep 30, 2026
…call result
An ARM wrapper that calls and returns (`push {r4,lr}; bl provider;
pop {r4,pc}`) stayed `void` in decompile-all, while the same wrapper on
x86-64 (`call provider; ret`) already gets `return provider(a0);` from
passthrough's tail-return rule. The ARM compiler specs inject the mode
switch of every `bx lr` / `pop {...,pc}` as an incidental `r0 = r0`
(MIPS: `v0 = v0` at `jr ra`), and the rule's "the function never touches
the return register" test counted it.
- The tail-return rule no longer counts an injected COPY of a register
onto itself, and returns_tail_result follows the RETURN's value back
through it to the call's result.
- A returned register the body touches (if only through that no-op)
keeps its call-site argument trials scored as with the option off, so
`bl g; bl f; pop {r4,pc}` stays `return f(g(a0))`.
- The argument side is unchanged.
This replaces the opt-in `wrapperreturn` option and its whole-program
caller ledger: main already handled the argument side (Noelo-Lab#764), the return
side needed no caller evidence on x86-64, and with the option on
`mov r0,Noelo-Lab#5; bl inc; pop {r4,pc}` printed `return inc();`. The
docs/features/wrapperreturn fixtures and the stage test that only pinned
the no-evidence case are removed; the stage harness states no callee
prototype, so the positive witness is the kuna-cli test, as for the
other passthrough fixes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
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.
A function that forwards its registers to a callee gets them as parameters when the callee forwards by a jump (
jmp narrow), but not when the callee forwards by a call (sub rsp,8; call narrow; add rsp,8; ret). The caller of the second kind loses its arguments.mk.pyfrom #749 (writesfwdcall.elf, no toolchain needed)python3 mk.py && kuna decompile-all fwdcall.elfWith this change the second one is
long pass_fwd_call(long a0,long a1) { return fwd_call(a0,a1) * 2; }.The fix
passthroughonly takes a register from a callee whose body is seen reading it. The body walk stops at every call, so a callee that forwards by a call reads nothing. The walk now also counts what each direct call's target takes, for the register bytes nothing wrote before that call, up to three calls deep (reads_through_callsinkuna_calleedeadarg.rs).passthroughalready asks of a callee. Without this check, a variadic function's register-save prologue on some error path would count as reads of every argument register. In dash,or's fourth parameter came outunsigned longwith casts at every use.channel_by_id(which doespush %rsito passidto a variadic logger) madechannel_send_open(ssh, int id)and the other callers ofchannel_lookuptake a 64-bitid.passthrough's own check reads the wider set.calleedeadarg,calleearitybodyand the arity check see the same walk as before. Body probes stay cached for the whole run, and the rest is memoized per caller because callee prototypes are still being added as the run goes.passthrough's own rule, so--option passthrough offstill gives the old output.Tests
passthrough_callfwd_x86_64(generated by the.pynext to it) with twotests/cliprobes, one with the default and one withpassthrough off. Callers of a one-deep and a two-deep call forwarder get(a0,a1). A forwarder that writesesifirst passes onlya0. An indirect-call forwarder and a call cycle get nothing. The default probe fails on main.passthrough_widthfwd_x86_64, built by gcc from the.cnext to it, has the openssh shape above. Its probe expectssend_openanduse_sendto gain the struct pointer and keepunsigned int a1. It fails on main (no arguments) and without the width check (unsigned long a1).decompile-allover the 264 ELF fixtures (5,423 functions).decompile-allover 266 stripped x86-64 -O2 binaries from 25 projects (92,275 functions): 111 functions gain 179 parameters and 163 calls gain arguments. Every one with a DWARF twin agrees with it, and nothing loses an argument. Parameter widths move toward DWARF in 28 places and away in 2. The 2 are gnulibmkstemp_len/mkdtemp_len, which hand asize_ttogen_tempname_len'sintand get theintthe callee reads.decompile-all, interleaved min of 11: dash -O2 5.755s -> 5.767s, openssh ssh -O2-noinline 39.0s -> 38.4s.Fixes #749
🤖 Generated with Claude Code
https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG