Repository navigation
[AUTOMATED] fix(p4): passthrough hands back an ARM or MIPS wrapper's call result - #752
Merged
Merged
Conversation
phix33
force-pushed
the
fix/arm-wrapper-returns
branch
from
September 30, 2026 00:14
82c3ec9 to
ee487d2
Compare
phix33
force-pushed
the
fix/arm-wrapper-returns
branch
from
September 30, 2026 01:01
ee487d2 to
985201e
Compare
Resolves the stage corpus count, the option count tests and the stage baseline against main's fieldtype option and stage. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
…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
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
…s its ARM/MIPS reach
- arm_wrapper_returns.rs gains a Thumb object (pop {r4,pc}, pop.w
{r4,lr}; bx lr, a returning and a void call chain, an argument write)
and a linked little- and big-endian MIPS image (jal; jr ra, a write
after the call, jalr); each fails on main where it should.
- The passthrough phases.toml row and the spec's Default paragraph state
that the return arm now takes ARM/MIPS call-then-return wrappers, with
the rates over 92 ARM firmware binaries (182 of 221 DWARF-described,
82.4%; 105 of 113 without the two -Og projects) next to the tail-jump
rate on the same set. docs/options.md and phase_catalog.json are
regenerated.
- The spec quotes the chain's actual output, v1 = g(a0); return f(v1);.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
The 92 ARM firmware binaries behind the passthrough return-arm rates include 28 O0 builds, so the phases.toml row, docs/options.md, the catalog fixture and the spec say "O0, O2 and O2-noinline". Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
mahaloz
added a commit
to phix33/kuna
that referenced
this pull request
Sep 30, 2026
No conflicts (Noelo-Lab#752 passthrough wrapper returns). options.md, phase_catalog.json and the stages baseline regenerate unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
mahaloz
added a commit
that referenced
this pull request
Sep 30, 2026
…ads returns it under voidret too arm_wrapper_returns.rs (#752) pinned void for the indirect and argument-write wrappers and for passthrough off, while the fixture's consumer reads r0 after the call and printed v1 = wrapper() of a void wrapper. decompile-all's voidret redo returns those results; a wrapper no caller reads stays void. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01JiRmwW65ibgRi4sd1CkDiE
mahaloz
added a commit
that referenced
this pull request
Sep 30, 2026
…ads returns it under voidret too arm_wrapper_returns.rs (#752) pinned void for the indirect and argument-write wrappers and for passthrough off, while the fixture's consumer reads r0 after the call and printed v1 = wrapper() of a void wrapper. decompile-all's voidret redo returns those results; a wrapper no caller reads stays void. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01JiRmwW65ibgRi4sd1CkDiE
mahaloz
added a commit
that referenced
this pull request
Sep 30, 2026
…ads returns it under voidret too arm_wrapper_returns.rs (#752) pinned void for the indirect and argument-write wrappers and for passthrough off, while the fixture's consumer reads r0 after the call and printed v1 = wrapper() of a void wrapper. decompile-all's voidret redo returns those results; a wrapper no caller reads stays void. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01JiRmwW65ibgRi4sd1CkDiE
mahaloz
added a commit
that referenced
this pull request
Sep 30, 2026
… on top Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01JiRmwW65ibgRi4sd1CkDiE
mahaloz
added a commit
that referenced
this pull request
Sep 30, 2026
… on top Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01JiRmwW65ibgRi4sd1CkDiE
mahaloz
added a commit
that referenced
this pull request
Sep 30, 2026
…ion computes itself (#772) Follow-up to #752. ## Problem A function that calls something and then computes a float return value is decompiled as returning the callee's integer result, and its float parameter disappears. #752 made this happen on hard-float ARM and MIPS; x86-64 and AArch64 have done the same since `passthrough` became the default. ```sh cat > f.c <<'EOF' extern int counter; __attribute__((noinline)) int ise(int x) { counter++; return x * 3; } float float_after_i(int x, float y) { ise(x); return y * 2.0f; } EOF clang --target=armv7a-linux-gnueabihf -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -c f.c -o f.o decompiler/target/release/kuna decompile-all f.o ``` ```text // Function: float_after_i @ 0x400020 int float_after_i(int a0) { return ise(a0); } ``` `gcc -O2 -fno-ipa-ra -c f.c` on x86-64 prints the same (`call ise; movss 4(%rsp),%xmm0; addss %xmm0,%xmm0; ret`), and so do AArch64 and MIPS builds of it. ## Fix - `passthrough` only hands back a tail call's result when the function returns nothing of its own. Once the return trials are scored, it runs the output model over the trials it does not own, which gives the return value the function would have with `passthrough off`. If that value is in another storage class (`s0`, `xmm0`, `$f0` against `r0`, `rax`, `$v0`), the claim is dropped. The example now prints `float float_after_i(float a0,int a1) { ise(a1); return a0 + a0; }`. That is the pre-#752 output, and it is the same with `armfloatreturn` on or off. - A register of the same class, like the `r1` in `bl g; mov r1,#0`, can be the rest of the claimed value, so it keeps the claim. - A value that is zero at every RETURN keeps the claim too. `-fzero-call-used-regs` writes zero into every call-used register a function does not return in, so openssh's `sshkey_certify` ends `call ...; pxor %xmm0,%xmm0; ret`, and it still returns its `int`. The cost is that `g(); return 0.0;` keeps the callee's result, as it does today. - There is no new option. This is a bug fix inside `passthrough`'s own rule. ## Tests - `kuna-cli/tests/passthrough_own_return.rs` builds ARM, x86-64, AArch64 and little- and big-endian MIPS objects inside the test. It fails on main at the first ARM function. - The failing cases are a float computed after the call on every architecture, a float constant loaded after it (ARM, with `armfloatreturn` off and on) and an x86-64 double. - The controls keep their callee's result: a plain wrapper on every arch, the ARM `r1` write, and an x86-64 forwarder that ends in the zeroing epilogue. - Base vs head `decompile-all` changes no function over the 274 ELF fixtures and 562 debug-stripped decbench binaries: 98 ARM firmware images at O0, O2 and O2-noinline, also run with `armfloatreturn on`, and 464 x86-64 binaries at O2 and O2-noinline. Without the zero rule, the nine copies of openssh's `sshkey_certify` in that set became `return 0;`. - Datatests and stages are unchanged, and `arm_wrapper_returns.rs` and the `passthrough-*` CLI probes pass unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
mahaloz
added a commit
that referenced
this pull request
Sep 30, 2026
… on top Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01JiRmwW65ibgRi4sd1CkDiE
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.
Problem
A caller tests a wrapper's result, but whole-program decompilation declares an ARM wrapper that calls and returns (
push {r4,lr}; bl provider; pop {r4,pc})void. The same wrapper on x86-64 (call provider; ret) already getsreturn provider(a0);.Fix
bx lrandpop {...,pc}as an incidentalr0 = r0(MIPS doesv0 = v0atjr ra).passthrough's tail-return rule requires that the function never touch the return register, and it counted that no-op. It no longer does, and the RETURN's value is followed back through the no-op to the call's result:unsigned int wrapper(unsigned int *a0) { return provider(a0); }.passthrough off. Sobl g; bl f; pop {r4,pc}printsv1 = g(a0); return f(v1);, notg(a0); return f();.passthrough's existing rule, which is on by default and already applies to x86-64. Itsphases.tomlrow and spec now state the ARM/MIPS reach and the rates below.voidwrapper that ends in a call to a value-returning function compiles to the same bytes, so it gets that function's return value.Tests
kuna-cli/tests/arm_wrapper_returns.rsbuilds its images inside the test. These cases fail on main:pop {r4,pc}orbx lr, one whose caller ignores the result, and a three-deep chain.pop {r4,pc}orpop.w {r4,lr}; bx lr.jal provider; ...; jr rawrappers, built as a linked image because kuna does not apply MIPS object relocations.These controls are unchanged: a void callee, a call cycle, an indirect call, a write to the return register before or after the call, declared
voidprototypes, andstore(provider(a0))in A32 and Thumb.Base vs head
decompile-allover the 272 fixture ELFs changes one function, a synthetic Cortex-M reset handler. Over 92 debug-stripped ARM firmware binaries (decbench O0, O2 and O2-noinline), 223 functions gain a return. DWARF confirms 182 and saysvoidfor 39, and 2 have no DWARF entry: 82.4%.-Ogbuilds.-Ogturns off sibling calls, so every one-linevoidwrapper ends inbl f; pop {..,pc}.call; retreturns on 64 binaries are 93.4% / 94.6%.Datatests and stages are unchanged.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG