Skip to content

[AUTOMATED] Keep a tested call argument in a function with six parameters - #1889

Merged
mahaloz merged 61 commits into
Noelo-Lab:mainfrom
sjkim1127:fix/calleereadarg-sixth-param
Nov 23, 2026
Merged

mahaloz merged 61 commits into
Noelo-Lab:mainfrom
sjkim1127:fix/calleereadarg-sixth-param

Conversation

@sjkim1127

Copy link
Copy Markdown
Contributor

A function with six or more register parameters drops the argument of a call when it also tests that value. clang -O2 for if (buf[0]) return ext(buf[0]) + 1; inside a six-parameter function loads buf[0] into edi, tests it, and calls ext, which reads edi. kuna prints the call with no argument:

printf '%s' \
 8d047fc36666662e0f1f840000000000c36666666666662e0f1f840000000000 \
 55415741564154534883ec104489cb4489c54189ce4189d74189f440883c2444 \
 89cfe8c9ffffff83e301488d041c4501f74101ef4183e40745883c040fb63c24 \
 85ff7409e897ffffffffc0eb05b8050000004883c4105b415c415e415f5dc390 \
 | xxd -r -p > six.bin
kuna decompile six.bin --raw-image --target x86:LE:64:default:gcc --base 0x401000 0x401020
  if (v1[0])
    return sub_401000() + 1;

With this change: return sub_401000((unsigned char)v1[0]) + 1;

Fix

  • calleereadarg restores a tested argument when the callee's body reads the register. It skipped every call in a function whose own entry reads the last argument register (r9 on SysV x86-64), treating that as a possible variadic register-save prologue.
  • A save prologue only stores the registers. The function now counts as possibly variadic only when its entry reads the last argument register just to store it. A function that keeps a sixth parameter (mov %r9d,%ebx) is not variadic on that account.
  • The al test and the callee-side checks are unchanged. No option: the old output passed a call fewer arguments than the program does.

Tests

  • New tests/stages/kuna-calleereadarg-sixth.xml (the bytes above). Both assertions fail without the fix.
  • tests/stages/kuna-pointerwalk-memo.xml gains an assertion for its ext(buf[0]) call, which had the same bug.
  • No existing datatest or stage assertion pinned the dropped argument. Stage corpus CPU time is unchanged within noise.

🤖 Generated with Claude Code

morluto and others added 24 commits November 18, 2026 18:58
[AUTOMATED] Preserve the exact decoded call site and executable-section exclusion without adding a discovered procedure.
…traps

The datatest harness built every test file's architecture from scratch:
it re-decoded the same .sla and re-parsed every .ldefs for each file,
which was ~60% of `make test` / `make test-stages` CPU.

engine::reuse_specs() (opt-in, called by decomp_test_dbg) makes a process
scan each set of on-disk spec roots once, and keep a decoded template of
each .sla a thread decodes twice (kuna_slacache, keyed by file contents).
Later translators are SleighBase::clone_decoded copies: a fresh space set
rebuilt from the .sla space records, every space reference remapped by
index, xrefs and context variables rebuilt as a decode does. Single-binary
CLI runs never enable it and take the unchanged decode path.

Harness output is byte-identical on both corpora. decomp_test_dbg, A/B:
datatests 3.3 s -> 1.25 s CPU, stages ~50-58 s -> ~23-28 s CPU; peak RSS
96 -> 232 MB and ~400 -> ~620 MB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kuna-cli tests that compile printed C and run the result used bare
Command::output()/status(), so a child that never exits stalled the whole
suite. On macOS 26 Apple clang 17's ASan runtime hangs before main, which
made `make rust-test` never finish.

- common::process gains a Capped trait (capped_output/capped_status) that
  kills and reaps a child after 300 s; required_output/optional_output and
  every run of a natively built or emulated executable go through it.
- sanitizer_runs() builds and runs a trivial program with the sanitizer
  flags once per process under a 30 s cap; the ASan round trips skip a
  compiler that fails it, the same way they skip a missing compiler.
- a_float_handed_on_through_wrappers_to_an_integer_round_trips runs its
  MAP_FIXED_NOREPLACE harness only on Linux.
- a_value_read_by_a_sign_sensitive_op_is_not_re_read_from_a_global runs its
  x86-64 ELF fixtures only on Linux x86-64 and checks the spelling elsewhere.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
macOS answered no resident set, so `--max-fn-memory N` was refused on every
Mac. Read `proc_pid_rusage(RUSAGE_INFO_V2)`'s `ri_phys_footprint`: unlike
`task_info`'s resident size it drops when libmalloc marks freed pages
reusable, which matters because macOS has no `malloc_trim` to hand pages back
between functions. One call costs ~0.4 µs and is taken at most every 50 ms
per armed drive, and not at all without the flag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
calleereadarg restores a register argument the caller also tests when the
callee's body reads that register. It declined whenever the calling
function's own entry read its last argument register, taking that as a sign
of a variadic register-save prologue. A function with six parameters reads
r9 too (clang keeps it with mov %r9d,%ebx), so `if (buf[0]) return
ext(buf[0]) + 1;` printed `ext() + 1`. A register-save prologue only stores
the registers; the caller now counts as possibly variadic only when its
entry reads the last argument register just to store it.

Strict correctness fix, no option. New stage test kuna-calleereadarg-sixth;
kuna-pointerwalk-memo gains an assertion for the same call (found by the
differential checker). No existing assertion pinned the dropped argument.

Automated change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sjkim1127
sjkim1127 force-pushed the fix/calleereadarg-sixth-param branch from 6364887 to e7a9a57 Compare November 22, 2026 20:18
mahaloz and others added 28 commits November 22, 2026 22:15
…tride

Resolves the stage-corpus file count (main's 861 plus this branch's
kuna-aif-slot-edges = 862) and re-synthesizes docs/baseline-stages.json
from both sides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
…n export

The xrefs section on exports called through their own PLT stub now says
that ARM, AArch64, PowerPC32 absolute/BSS-PLT and PowerPC64 ELFv1 stubs
are recognized by shape, and which shapes are not joined (Thumb
interworking prefixes, --long-plt, PAC entries, PowerPC32 secure-PLT PIC
stubs), so a reader knows when to query the stub address instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
With e500 selected for every SPE-note image, ordinary integer functions lose
arguments: the e500 model drops a 32-bit argument read through mulhwu
(`ud3(u32 a) { return a / 3; }` decompiles as `ud3(void)` with an
uninitialized 64-bit local), and 64-bit integer pairs lose halves. On 414
GCC -O2 PPC32 objects given an SPE note, 23 integer-only functions went from
the DWARF parameter count to too few and 12 from too many to correct.

ppcapu becomes isel|on|off, default isel. isel selects the generic PowerPC32
model plus ISEL for an ISEL, SPE or embedded floating-point requirement or the
embedded ABI flag, so every such image decodes what main decodes plus isel.
on keeps the e500 selection for SPE requirements (the previous PR default and
main's opt-in); off keeps the generic decoder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
…ot a reference to it

A name query widened to an export's own PLT stub and slot also picked up
every `data` row whose value merely equals the stub's or slot's address:
an immediate (`li r9,0x2064`, `mov w0,#0x4b50`) or an AArch64 adrp page
base that happens to equal the slot. In a position-independent image such
a value is not the export's address. refs_to_class now drops `data` rows
to the export-PLT members only; calls, jumps, reads and writes are kept,
the x86-64 veneer path is unchanged, and a query by the stub's address
still lists the row. Over 348 changed name queries on real AArch64/ARM/PPC
shared objects this removes exactly the 14 such rows and nothing else.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
@mahaloz
mahaloz merged commit 98d63b5 into Noelo-Lab:main Nov 23, 2026
2 checks passed
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.

4 participants