Repository navigation
[AUTOMATED] Narrow a SPARC int's return 0 folded into the return pair - #1000
Merged
Merged
Conversation
On SPARC, restore copies %i1 back into %o1 on every return, so return
recovery joins %o0:%o1 (first register low) for a function that returns
one int. The uncomputed-half repair drops the %o1 half when it is the
untouched argument, but by then the rule pool has folded PIECE(a1, 0)
into ZEXT(a1) << 32, which the repair did not read: `int f(int *p, int b)
{ *p = b; return 0; }` printed as a long long returning
`(unsigned long long)a1 << 0x20`.
The repair now reads ZEXT(hi) << 8k as the pair hi:0 on a pair joined
first register low on an ABI that returns the first register high
(Funcdata::kuna_pairs_first_low). There the folded value has its words
swapped for any genuine 64-bit return, so narrowing it replaces only a
wrong value; no option. Over 25 userland projects built with clang for
SPARC (-O0, -O2, -Os) and PowerPC, MIPS and ARM big-endian (-O0, -O2),
1,272 of 90,049 functions change, all on SPARC, none with an eight-byte
DWARF return type.
Adds tests/stages/kuna-sparc-zeropair.xml (re-records
docs/baseline-stages.json, corpus count 483), unit tests for the folded
form, and extends the SPARC big-endian round-trip CLI tests with
keep_zero, zero_after and one_after.
Fixes #796
[AUTOMATED] change made by Claude Code.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JiSdQ5U9toD6x81TksF4u9
mahaloz
force-pushed
the
fix/issue-796-sparc-const-pair-return
branch
from
October 10, 2026 02:06
f0097e1 to
b517894
Compare
# Conflicts: # decompiler/crates/kuna-base/src/xml.rs # docs/baseline-stages.json
mahaloz
pushed a commit
that referenced
this pull request
Nov 13, 2026
…ktrap) (#1519) AArch64 SLEIGH lifts `brk #imm` to a jump through a SoftwareBreakpoint user-op. Flow truncated that jump to a call followed by a return, so a function whose overflow or bounds check ends in a compiler trap printed as void, passed its return value to the trap, or returned a value made up from a call through it. Flow classification now replaces that jump with a no-return halt when the immediate is one a compiler emits for a trap that does not return: #1 (llvm.trap, Swift, and Darwin/Windows unreachable), #1000 (GCC), #0x5500-#0x55ff (llvm.ubsantrap), #0xc470-#0xc473 (arm64e pointer-auth failure) and #0xf003 (MSVC __fastfail). The trap still prints as a SoftwareBreakpoint(..) statement. For __fastfail it also reads the failure code from w0, so `mov w0,#8; brk #0xf003` prints `SoftwareBreakpoint(0xf003,..,8);`. No other trap reads a register. Always on, with no option: a brk never returns to its caller. brk #0xf000, #0 and the Linux kernel's resumable immediates keep the old rendering. ptrauthtrap still removes the pointer-auth checks it matches, and a check it keeps now ends the flow. The fix lives in p2_lift/kuna_brktrap.rs and is covered by tests/stages/kuna-brktrap.xml. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
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.
On SPARC, a function that returns an
intprinted as along longthat shifts its second argument into the high word whenever it returns 0.With this change both are
unsigned int, and thereturn 0paths printreturn 0;.Fix
restorecopies%i1back into%o1, so return recovery joins%o0:%o1for these functions. The uncomputed-half repair already drops a leftover%o1beside any other value (return 5was fine), but the rules foldedPIECE(a1, 0)intoZEXT(a1) << 32before it ran. The repair now reads that form as the paira1 : 0.long long, so narrowing it never replaces a correct value, and no option is added.unsigned long long f(unsigned a, unsigned b) { return b; }is the same SPARC code asint f(int a, int b) { return 0; }and now prints as thatint, as((u64)5 << 32) | balready printedreturn 5;.Tests
tests/stages/kuna-sparc-zeropair.xml: SPARC -O2 and -O0keep_zero,sameandflag_zeroreturn anint0;keep_fiveand threelong longreturns keep their output. 5 of its 7 asserts fail without the fix.decompile_all_cli.rsnow includekeep_zero,zero_afterandone_after(both fail without the fix), plus unit tests for the folded form.Fixes #796
🤖 Generated with Claude Code
https://claude.ai/code/session_01JiSdQ5U9toD6x81TksF4u9