Skip to content

[AUTOMATED] feat(p1): peimportcall - bind a Windows call [IAT slot] to its import (DIV-57) - #254

Merged
mahaloz merged 1 commit into
mainfrom
fix/decbench-peimportcall
Aug 3, 2026
Merged

mahaloz merged 1 commit into
mainfrom
fix/decbench-peimportcall

Conversation

@mahaloz

@mahaloz mahaloz commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What

A Windows PE reaches its imports through an Import Address Table slot, which is
data. call dword ptr [slot] therefore lifts to a CALLIND whose target is the
contents of a global — unlike an ELF PLT stub or a Mach-O __stubs entry, which are
code and resolve as ordinary direct calls. The only pass that resolves such a target,
ActionDeindirect (coreaction.cc:1235), gates its queryExternalRefFunction arm on
isPersist() && isExternalRef(), and Varnode::externref was set nowhere in the
workspace
: Ghidra sets it from an ExternRefSymbol (Scope::addExternalRef) that
kuna's port never carried.

So every Windows API call in every PE stayed an unnamed (*dat_4112c4)(0) — no name,
no prototype and, the damaging part, no no-return flow effect, so a function
ending in ExitThread/ExitProcess kept its fall-through and swallowed the whole of
the next function.

Closes decbench case O0-mydoom-mydoom-mmsender_th (IDA, Ghidra and angr all GED 0;
kuna 37) and its un-triaged ida-pool sibling O0-mydoom-mydoom-sync_visual_th.

Before / after — mmsender_th (mydoom.exe @ 0x4041e2)

// BEFORE (option peimportcall off) — 50 lines, 4 ifs, and a `while` loop the
// function does not have: everything from `v7 = ...0x4102e0;` down belongs to the
// NEXT function, which kuna separately emits as sub_40424c, statement for statement.
void sub_4041e2(int4 a0)
{
  ...
  if (dat_4102e4) { LOCK(); UNLOCK(); }
  (*dat_4112c4)(0);                         // <- this is ExitThread(0)
  v7 = (unsigned int *)0x4102e0;
  v3 = dat_4102e0;
  while (v7 = v3, v8 = v7 != NULL, v8) {
    v1 = (char *)&v7[2];
    if (*v1 != '\x02') v3 = (unsigned int *)*v7;
    else {
      v4 = (*dat_411324)();                 // GetTickCount
      ...
      v6 = (*dat_411308)();                 // GetProcessHeap
      (*dat_41133c)(v6,0,v7);               // HeapFree
    }
  }
  return;
}
// AFTER (option peimportcall on, the shipped default) — exactly IDA's and Ghidra's
// shape: 2 ifs, no loop, ends at the no-return import.
void sub_4041e2(int4 a0)
{
  LOCK();
  UNLOCK();
  if (a0) {
    *(char *)(a0 + 8) = 1;
    sub_4040eb(a0);
    *(char *)(a0 + 8) = 2;
  }
  if (dat_4102e4) {
    LOCK();
    UNLOCK();
  }
  ExitThread(0); // no-return
}

The stored IDA pane for reference (GED 0): _InterlockedExchangeAdd(&dword_4102E4, 1u); … if (lpThreadParameter) { … sub_4040EB(…); … } … if (dword_4102E4) _InterlockedExchangeAdd(…); … ExitThread(0);. The full captured side-by-side,
including the sub_40424c body kuna had been absorbing, is
docs/features/peimportcall/before-after.txt.

Mechanism (three parts, one gate)

  1. externref over the IAT slots.
    kuna-analysis/src/loader/kuna_peimportcall.rs (PeImportCallPass) reports one
    [slot, slot+ptr) range per import-descriptor entry (pe_iat::resolve_pe_import_slots,
    reusing the existing INT/IAT lockstep walk), and the commit ORs
    Varnode::externref over each in the symbol-table property map — the same
    Database::set_property_range the loader's read-only section ranges already use.
    Scope::queryProperties folds the property map into every global Varnode covering
    the range, so the slot read now carries persist|externref and ActionDeindirect
    resolves it against the FunctionSymbol pe_iat already registered at that same
    slot VA. No second symbol is mapped: kuna's query_function keys on the Varnode's
    own address where upstream indirects through ExternRefSymbol::refaddr, and the
    import FunctionSymbol's map entry is 1 byte (min_funcsymbol_size), so a
    pointer-width slot read never finds it as a container and always takes the property
    branch. externref is read in exactly one place in the whole workspace
    (p9_emit/coreaction_render.rs:1177), so the blast radius is bounded by construction.

  2. The callee's no-return flag reaches the deindirect — a separate port gap,
    see the section below. Database::build_global_query now carries
    SymbolKind::Function { no_return } into GlobalEntry::func_no_return, and
    Architecture::query_function puts it on the prototype it hands ActionDeindirect.

  3. Upstream's PE-only no-return API list.
    Ghidra/Features/Base/data/PEFunctionsThatDoNotReturn is vendored verbatim at
    decompiler/crates/kuna-analysis/data/PEFunctionsThatDoNotReturn and matched against
    a PE/COFF object only. kuna merges the PE and Mach-O name sets into one shipped
    file (PeMacFunctionsThatDoNotReturn, 8 shared CRT names) where upstream keeps them
    separate; rather than widen that merged file with ExitProcess/ExitThread/
    KeBugCheck/the MSVC-mangled ?_Xbad_alloc@std@@YAXXZ family — Windows names a
    Mach-O would then be matched against — the Windows list stays its own file on its own
    format arm. (kuna's Mach-O list is still missing upstream's MachOFunctionsThatDoNotReturn
    names: a separate, out-of-scope gap, recorded in the bundle.)

Each part alone can change emitted C on some target, so all three sit behind the one
option. p9_emit/coreaction_render.rs (ActionDeindirect) and p4_calls/fspec.rs
(FuncCallSpecs::deindirect) are unchanged consumers, verified against.

The filed mechanism was refuted before any code was written. The triage record
proposed a new P2 pass in p2_lift/flow.rs matching a CALLIND through a global; a
pre-pipeline IR dump (load addr + print raw, no decompile) shows the target is a
free unique temp and every varnode is (free) at that seam — raw flow IR carries no
def-use links, so the backward walk it needs is unavailable. Nothing new is added in
p2_lift.

Second, separate finding: query_function never reported a callee's no-return

This one was not in the brief and is worth reading on its own, because it is a
general port gap that happens to be load-bearing here.

Database::build_global_query flattens the global scope into a read-only GlobalQuery
snapshot for the per-function ArchHandle. It copied SymbolKind::Function's
inject_id but not its no_return, so Architecture::query_function — the only
caller of which is ActionDeindirect — returned a prototype with is_no_return() == false for every callee, including one the no-return analysis pass had explicitly
flagged. Upstream never had to carry the bit: Scope::queryFunction returns the
callee's live Funcdata, whose getFuncProto().isNoReturn() is simply true.

The consequence is not "the call is missing a comment". FuncCallSpecs::deindirect
branches on it:

if (!newproto_no_return && !newproto_inline) {   // fspec.cc:5448
    ...lateRestriction... -> commit the merged prototype and RETURN (no restart)
}
data.set_restart_pending(true);                  // only reached for no-return/inline

With the flag lost, deindirect always took the lateRestriction success path, rewrote
the CALLIND to a CALL in place, and returned without scheduling a restart — so
the flow, which had already walked past the call when the function was first followed,
was never recomputed. decomp_dbg's restarts reported "No restart events recorded
for sub_4041e2"
even after a successful deindirect.

Proved by A/B rather than inferred: with externref forced on and this bit still
missing, the call renders ExitThread(0) and the entire absorbed body is still
there
— and so it is even under the explicit option noreturn ExitThread override
(the same counterfactual the triage record reported as evidence that "no name is ever
queried", which turns out to have had a second cause). Naming was necessary but not
sufficient; this is the half that fixes the boundary.

The carry is gated by the same option, because query_function is format-neutral: a
constant-folded indirect call on any target (e.g. the MIPS $gp/GOT const-range path)
could now resolve to a known no-return callee. Measured as inert on every ELF tested.

Follow-up filed (campaign-wide, not this PR): decbench cannot rescore PE cases

scripts.decbench.rescore invokes kuna decompile-all --addr 0x<address_hex> using the
address stored in the mined pools. For a PE those pools store an RVA (0x41e2)
while kuna — like IDA and Ghidra — uses the image-based VA (0x4041e2), so every PE
case fails with no fresh code: Unable to load 512 bytes at r0x000041e2 before any
comparison happens. This silently blocks GED rescoring for the whole PE half of the
corpus (mydoom and dexter), which is exactly the half this PR moves.

Still present after the results-tree refresh and pool re-mine — I re-checked on the
current pools and address_hex is still the RVA 0x41e2, so this is not something the
refresh fixed. The two mydoom entries were corrected in a throwaway local edit to take
the numbers above and then reverted — docs/decbench/triage-queue*.json are unmodified
by this PR
(git status on docs/decbench/ is clean). The real fix (normalise the
pool address to the loader's base, or teach rescore to add the PE ImageBase) belongs
in the decbench tooling, not here.

The option

--option peimportcall on|off, P1 / external-refinement, default-ON (DIV-57),
tier = transform, change_kind = correctness-fix. PE/COFF only — the pass is
registered only for those formats and self-gates in run, so every other object
format's pass set is byte-identical (pinned by
passes::tests::peimportcall_pass_is_pe_coff_gated).

Ablation and the default decision

Ablation (option ON) Speed Ship as
0 / 675 upstream assertions change within budget (negative whole-binary) default-ON, DIV-57

make test is PARITY OK 675/675 with the flip and no re-pin and no per-test
opt-out
. make test-stages is PARITY OK 386/386 (the delta is purely the 5 new
keys).

Regression sweep — both PE binaries, whole-binary

kuna decompile-all, option OFF vs ON:

mydoom.exe dexter.dll
functions 156 → 156 109 → 109
emitted lines 5,247 → 4,768 3,422 → 3,115
unnamed (*dat_…)() calls 501 → 4 426 → 4
distinct Win32 API names in the C 0 → 71 0 → 90
// no-return marks 9 → 14 7 → 10
while loops 65 → 60 24 → 25
goto 23 → 23 20 → 19
bodies: shrank / grew / renamed-same-length 48 / 2 / 64 31 / 0 / 28

927 unnamed Windows API call sites → 8. No function is gained or lost in either
binary and gotos never increase. Beyond the five mydoom functions the triage named,
three dexter functions also stop overrunning: the largest single win is dexter
Uninstall 152 → 19 lines, now 16 statements ending ExitProcess(0); // no-return.
Others: mydoom sub_402a62 169 → 64, sub_402eda 96 → 28, sub_407107 87 → 50,
sub_40451c 40 → 7, sub_4024c5 53 → 30; dexter HttpMain 118 → 91, TrackSearch
299 → 284, ScanMemory 88 → 72 (and it loses its one goto).

Exactly two functions grow, both by one line, and both for the same benign reason —
a named import now takes a typed argument through a temporary:
a1 = (*dat_411464)(*(unsigned short *)(a0+a1)); a1 &= 0x3fff; becomes
v2 = *(unsigned short *)(a0+a1); a1 = ntohs(v2) & 0x3fff;.

Shipped PE fixtures: pe_imports_stripped.exe 79 → 3 unnamed slot calls,
pe_dwarf.exe 50 → 0; msvc_rtti_x64/x86.exe, pdb_min.exe, pdb_prog.exe unchanged.

Controls. Option-ON output is byte-identical to option-OFF on every non-PE target
measured (coreutils b2sum, mirai, tar -O2 — same md5), and option-OFF is
byte-identical to the pre-change binary on both PEs (mydoom 49a1873b…, dexter
8dc4bd5b…).

All four PE md5s were re-measured on the final base 65543461 and are bit-for-bit
the numbers above: neither #252 (which does change emitted C — it drops phantom
.rodata stores) nor #253 (ternary rendering) touches these witnesses, and the ELF
control (b2sum, ON == OFF, 06df920f…) is likewise unchanged. Confirmed by
re-measurement, not from memory.

Benchmark (GED)

case before after
O0-mydoom-mydoom-mmsender_th 37 0 perfect — matches IDA / Ghidra / angr
O0-mydoom-mydoom-sync_visual_th 39 (recomputed; 34 recorded) 0 perfect — a second mined ida-pool row, closed by the same fix

Both re-measured on the refreshed decbench results tree and the re-mined pools, at
the final rebase (ged_kuna_commit 6d160156), not quoted from the pre-refresh run --
the numbers are unchanged. See the follow-up section above: the RVA/VA bug is still
present after the pool re-mine
(address_hex is still 0x41e2), so the measurement
still needs a local address fix-up first.

Speed

scripts.pipeline.timeit, target function, 15 repeats: 387.96 → 380.58 ms (-1.9%),
within the +5% budget. An earlier 7-repeat run on this (shared, loaded) box reported
+49% and did not reproduce — three re-runs at repeat=11 gave +0.67%, -0.99%,
-3.74% — so the interleaved form DIV-54 uses on this box is quoted alongside:

measurement off on delta
per-function interleaved, 11 pairs 338.0 ms 340.7 ms +0.79%
whole-binary decompile-all mydoom, 7 pairs 1,820 ms 1,689 ms -7.23%
whole-binary decompile-all dexter, 7 pairs 1,552 ms 1,520 ms -2.09%
whole-binary ELF control b2sum, 5 pairs 5,663 ms 5,575 ms -1.55%

Whole-binary is negative because the truncated functions are less work.

Test

tests/stages/ghdec-peimportcall.xml — a two-pass decompilertest over the real
load file → read symbols → decompile path on a new 6 KB PE fixture
(pe_noreturn_import.exe, built with MinGW-w64 in the kuna-dev container; source and
recipe committed beside it and documented in the fixtures README). It is purpose-built
for the one call shape pe_imports.exe lacks: a __declspec(dllimport)
call [__imp_ExitProcess] (the direct IAT-slot shape MSVC emits for every Win32 call),
with the next .text function deliberately containing a loop. Pass 1
(option peimportcall off) asserts the bug — (*dat_140005038)(0xc) and
(*dat_140005038)(), no // no-return. Pass 2 (option peimportcall on) asserts the
fix — ExitProcess(0xc); // no-return, ExitProcess(); // no-return, and exactly two
// no-return marks. 2 of the 5 assertions fail with the option off; 5/5 with it on.

Plus passes::tests::peimportcall_pass_is_pe_coff_gated (format gating) and the two
vendored-list guards in kuna_peimportcall.rs (the Win32 exits are present; the
returning APIs — CreateThread, GetTickCount, TerminateProcess, … — are not).

Gates

make test        -> datatests: 675/675 assertions passed   |  PARITY OK
make test-stages -> datatests: 386/386 assertions passed   |  PARITY OK
make rust-test   -> green (workspace suite)
make check-spec  -> check-spec OK (lenient mode) / check-spec OK (strict mode)
kuna catalog --check -> catalog OK: documents exactly the registered kuna options

All five re-run on the final base 65543461 (after #252/DIV-55 and #253/DIV-56).
Shared counters this PR moves: kuna-base/src/xml.rs corpus count 189 -> 190,
settables 86 -> 87, transform tier 40 -> 41, live-value 28 -> 29 (itecondlist
declares no live_field, so only this PR moves that last one).
tests/fixtures/phase_catalog.json was re-captured on the rebased tree rather than
carried forward, and docs/baseline-stages.json re-recorded, never hand-merged
(386 keys, data_footer [386, 386]).

Two counters git resolved without a conflict were nevertheless wrong and were fixed by
hand — worth flagging for the next PR in this queue: catalog_bytecompat.rs silently
kept 86 because both sides had made the identical 85 -> 86 edit, and my own
pre-emptive with_live bump to 30 was one too many. Both were caught only by running
the suite, not by the merge.

Docs

  • docs/spec/01-program-prep.md — new prose in §import resolution: why naming a
    pointer slot is not enough to bind a call through it, the property-map carrier, and
    the query_function no-return carry.
  • docs/history.md — DIV-57.
  • docs/options.md regenerated; tests/stages/README.md and the fixtures README gain
    their rows; docs/features/peimportcall/ bundle (analysis.md, plan.md,
    before-after.txt, record.json, pr_body.md).

🤖 Generated with Claude Code

… to its import (DIV-57)

A PE reaches its imports through an Import Address Table slot, which is *data*,
so `call dword ptr [slot]` lifts to a CALLIND through a global. The only pass
that resolves such a target - ActionDeindirect - gates on `Varnode::externref`,
and that flag was set NOWHERE in the workspace: Ghidra sets it from an
ExternRefSymbol (`Scope::addExternalRef`) the port never carried. So every
Windows API call in every PE stayed an unnamed `(*dat_4112c4)(0)` with no name,
no prototype and no no-return flow effect - a function ending in ExitThread kept
its fall-through and swallowed the whole of the next function.

Three parts behind one option (`peimportcall`, P1, default-ON, DIV-57):

1. A new PE/COFF-only analysis pass reports one `[slot, slot+ptr)` range per
   import-descriptor entry and the commit ORs `Varnode::externref` over each in
   the symbol-table property map - the same `set_property_range` the loader's
   read-only ranges use. No second symbol is mapped: kuna's `query_function`
   keys on the varnode's own address where upstream indirects through
   `ExternRefSymbol::refaddr`, and the import FunctionSymbol's 1-byte map entry
   never covers a pointer-width read, so `queryProperties` always takes the
   property branch.
2. `build_global_query` now carries the callee's no-return flag into
   `GlobalEntry`, which `query_function` puts on the prototype handed to
   ActionDeindirect. Without it `deindirect` took its lateRestriction success
   path and never scheduled the restart whose re-flow plants the artificial
   halt, so the boundary stayed wrong even once the call was named.
3. Upstream's PE-only `PEFunctionsThatDoNotReturn` is vendored verbatim and
   matched against a PE/COFF object only - kuna merged the PE and Mach-O name
   sets where upstream keeps them separate, and these names are Windows-only.

ActionDeindirect and FuncCallSpecs::deindirect are unchanged consumers. The
mechanism the triage record filed (a new P2 pass matching the CALLIND shape) was
refuted first: at that seam the target is a free unique temp and raw flow IR
carries no def-use links, so the backward walk it needs is unavailable.

Measurements: decbench `O0-mydoom-mydoom-mmsender_th` GED 37 -> 0 (perfect) and
its un-triaged sibling `sync_visual_th` 39 -> 0 (perfect); over both corpus PEs
927 unnamed IAT-slot calls -> 8 with 71/90 distinct Win32 API names recovered,
8 boundary overruns fixed, no function gained or lost, gotos never increase;
ELF/Mach-O byte-identical; timeit -1.9%, whole-binary -7.2% / -2.1%.

Rebased onto 6554346 (after #252/DIV-55 and #253/DIV-56): corpus file count 190,
settables 87 (transform tier 41, live-value 29), phase_catalog.json re-captured and
docs/baseline-stages.json re-recorded (386 keys) on the rebased tree rather than
hand-merged. Every measurement above re-run on that base; the PE and ELF witnesses are
bit-for-bit unchanged by either merge.

Gates: make test 675/675 PARITY OK (no re-pin, no per-test opt-out);
make test-stages 386/386 PARITY OK; make rust-test green;
make check-spec OK (lenient + strict); kuna catalog --check OK.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
@mahaloz
mahaloz force-pushed the fix/decbench-peimportcall branch from c775bb8 to c619246 Compare August 3, 2026 10:16
@mahaloz mahaloz changed the title [AUTOMATED] feat(p1): peimportcall - bind a Windows call [IAT slot] to its import (DIV-55) [AUTOMATED] feat(p1): peimportcall - bind a Windows call [IAT slot] to its import (DIV-57) Aug 3, 2026
@mahaloz
mahaloz merged commit 208bb15 into main Aug 3, 2026
9 checks passed
@mahaloz
mahaloz deleted the fix/decbench-peimportcall branch August 3, 2026 13:35
mahaloz added a commit that referenced this pull request Aug 3, 2026
…n entries on containment evidence

Step 2 of the approved ARM entry-recall sequence ([PROPOSAL] #239) and the one it
called the prize: 1,671 missed function entries, 56.8% of the whole ARM
entry-recall gap, every one of them reachable only through a code-pointer word
that `aif::code_pointer_table_seeds` already finds and then throws away.

The shipped Stage-3 scan requires a pointer's target to open with a Thumb
stack-frame prologue and to disassemble into more than two instructions. On
bare-metal firmware that is the wrong population: 93.3% of the missed entries
establish no frame at all and 41% are <= 8-byte leaves (`movs r0,#0; bx lr`, or a
bare `bx lr`, which is a valid Cortex-M exception handler every rival recovers).
Those two predicates reject 1,632 of the 1,671.

Deleting them is not shippable - the proposal measured the naive relaxation at 62%
ground truth with 21% of the new entries splitting a real function body, a failure
mode decbench structurally cannot see. So the whole of this change is the precision
model, and the model is CONTAINMENT rather than shape: reject a target when any
word that references it overlaps a decoded instruction (it is operand bytes, not a
table slot) or lies in the same discovered function as the target itself (that
pairing IS the `ldr pc,[pc,r]` switch table). Measured over 3,462 validated
candidates the two guards take splits from 1,261 to 0 for 17 ground-truth entries.
The `MIN_SUBROUTINE_INSNS` floor is replaced, not deleted, by a terminating-routine
check: the same speculative walk with the strict escape policy and no minimum
length.

This is kuna's form of the line Ghidra draws between `OperandReferenceAnalyzer`
(creates functions, from instruction operands) and `DataOperandReferenceAnalyzer`,
which overrides `createFunctions` to a no-op - "don't ever create a function from a
data pointer". kuna cannot use Ghidra's version directly because the Listing tier
records only control-flow references, so the containment pair recovers the same
discrimination from the code/data partition the walk leaves behind.

Measured on the 48-image decbench Cortex-M corpus (41,378 DWARF ground-truth
addresses), `kuna functions`:

  recall 38,238 (92.4%) -> 39,851 (96.3%), +1,613
  1,694 new entries, 1,613 ground truth (95.2%)
  0 splitting a real function body, 81 outside any DWARF body
  0 entries lost, 0 ground-truth entries lost

`--option listing off` is structurally inert (ptrentry is a Listing consumer): 0
new, 0 lost. Whole-binary `decompile-all --json` is sha256-identical off vs on for
x86-64, ARM Linux and the Cortex-M images with no admissible candidate.

Two things the proposal asked for that measurement rejected, both built and
measured rather than argued (tables in docs/features/ptrentry/):

  - table-run corroboration: a switch table IS a run, so it removes no additional
    split, and it costs 311 ground-truth functions (1,302 vs 1,613);
  - re-seeding the recursive-descent walk (what Stages 2-3 do): +13 ground-truth
    entries but 974 split bodies and 734 dropped entries, through the same
    tail-call absorption that constrained step 1. The pass therefore emits entry
    facts only, which makes "never removes an entry" a property of the wiring
    rather than of a heuristic. That also settles the proposal's optional AIF
    gap-start re-walk fold-in: closing it IS a walk re-seed, so it stays with
    step 3.

Default-OFF and not auto-injected by any driver: it discovers more functions, so it
changes emitted C by construction, and the precision numbers want a human read
before a flip. No DIV row (default output is byte-identical).

Tests: `kuna-console/tests/verify_ptrentry.rs` is the two-pass e2e over a new
hand-assembled fixture carrying both shapes - the pointer-only leaf that must be
recovered and the switch-table case that must stay rejected with the option ON -
plus three unit tests and a superset-property pin. No `tests/stages/*.xml`: the
harness embeds raw `<bytechunk>`s and never builds a load image or a Listing, the
same reason every sibling analysis-tier discovery flag ships a cross-crate
`verify_*` gate.

Gates on the rebased tree (origin/main 208bb15, after #252/#253/#254): make test
PARITY OK 675/675; make test-stages PARITY OK 386/386; make rust-test green
(295/295 result blocks); make check-spec green in strict mode; kuna catalog
--check OK.

Every shared counter is derived from a fresh `phase catalog` capture and a green
run on the rebased tree, not by arithmetic: settables 87 -> 88, analysis tier
26 -> 27, catalog JSON rows 86 -> 87, bytecompat fixture 87 -> 88, and the
live-value count stays at 29 because this row declares no codegen live_field.
The `kuna-base/src/xml.rs` corpus count was verified by counting the files (83
datatests + 107 stages = 190, unchanged), and `docs/baseline-stages.json` is
untouched because this PR adds no stages XML. The recall/precision table and the
off-vs-on sha256 ablation were re-measured on the rebased build and are
unchanged, with 0 of 48 per-binary entry sets differing from the pre-rebase run.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
mahaloz added a commit that referenced this pull request Aug 3, 2026
…n entries on containment evidence (#255)

Step 2 of the approved ARM entry-recall sequence ([PROPOSAL] #239) and the one it
called the prize: 1,671 missed function entries, 56.8% of the whole ARM
entry-recall gap, every one of them reachable only through a code-pointer word
that `aif::code_pointer_table_seeds` already finds and then throws away.

The shipped Stage-3 scan requires a pointer's target to open with a Thumb
stack-frame prologue and to disassemble into more than two instructions. On
bare-metal firmware that is the wrong population: 93.3% of the missed entries
establish no frame at all and 41% are <= 8-byte leaves (`movs r0,#0; bx lr`, or a
bare `bx lr`, which is a valid Cortex-M exception handler every rival recovers).
Those two predicates reject 1,632 of the 1,671.

Deleting them is not shippable - the proposal measured the naive relaxation at 62%
ground truth with 21% of the new entries splitting a real function body, a failure
mode decbench structurally cannot see. So the whole of this change is the precision
model, and the model is CONTAINMENT rather than shape: reject a target when any
word that references it overlaps a decoded instruction (it is operand bytes, not a
table slot) or lies in the same discovered function as the target itself (that
pairing IS the `ldr pc,[pc,r]` switch table). Measured over 3,462 validated
candidates the two guards take splits from 1,261 to 0 for 17 ground-truth entries.
The `MIN_SUBROUTINE_INSNS` floor is replaced, not deleted, by a terminating-routine
check: the same speculative walk with the strict escape policy and no minimum
length.

This is kuna's form of the line Ghidra draws between `OperandReferenceAnalyzer`
(creates functions, from instruction operands) and `DataOperandReferenceAnalyzer`,
which overrides `createFunctions` to a no-op - "don't ever create a function from a
data pointer". kuna cannot use Ghidra's version directly because the Listing tier
records only control-flow references, so the containment pair recovers the same
discrimination from the code/data partition the walk leaves behind.

Measured on the 48-image decbench Cortex-M corpus (41,378 DWARF ground-truth
addresses), `kuna functions`:

  recall 38,238 (92.4%) -> 39,851 (96.3%), +1,613
  1,694 new entries, 1,613 ground truth (95.2%)
  0 splitting a real function body, 81 outside any DWARF body
  0 entries lost, 0 ground-truth entries lost

`--option listing off` is structurally inert (ptrentry is a Listing consumer): 0
new, 0 lost. Whole-binary `decompile-all --json` is sha256-identical off vs on for
x86-64, ARM Linux and the Cortex-M images with no admissible candidate.

Two things the proposal asked for that measurement rejected, both built and
measured rather than argued (tables in docs/features/ptrentry/):

  - table-run corroboration: a switch table IS a run, so it removes no additional
    split, and it costs 311 ground-truth functions (1,302 vs 1,613);
  - re-seeding the recursive-descent walk (what Stages 2-3 do): +13 ground-truth
    entries but 974 split bodies and 734 dropped entries, through the same
    tail-call absorption that constrained step 1. The pass therefore emits entry
    facts only, which makes "never removes an entry" a property of the wiring
    rather than of a heuristic. That also settles the proposal's optional AIF
    gap-start re-walk fold-in: closing it IS a walk re-seed, so it stays with
    step 3.

Default-OFF and not auto-injected by any driver: it discovers more functions, so it
changes emitted C by construction, and the precision numbers want a human read
before a flip. No DIV row (default output is byte-identical).

Tests: `kuna-console/tests/verify_ptrentry.rs` is the two-pass e2e over a new
hand-assembled fixture carrying both shapes - the pointer-only leaf that must be
recovered and the switch-table case that must stay rejected with the option ON -
plus three unit tests and a superset-property pin. No `tests/stages/*.xml`: the
harness embeds raw `<bytechunk>`s and never builds a load image or a Listing, the
same reason every sibling analysis-tier discovery flag ships a cross-crate
`verify_*` gate.

Gates on the rebased tree (origin/main 208bb15, after #252/#253/#254): make test
PARITY OK 675/675; make test-stages PARITY OK 386/386; make rust-test green
(295/295 result blocks); make check-spec green in strict mode; kuna catalog
--check OK.

Every shared counter is derived from a fresh `phase catalog` capture and a green
run on the rebased tree, not by arithmetic: settables 87 -> 88, analysis tier
26 -> 27, catalog JSON rows 86 -> 87, bytecompat fixture 87 -> 88, and the
live-value count stays at 29 because this row declares no codegen live_field.
The `kuna-base/src/xml.rs` corpus count was verified by counting the files (83
datatests + 107 stages = 190, unchanged), and `docs/baseline-stages.json` is
untouched because this PR adds no stages XML. The recall/precision table and the
off-vs-on sha256 ablation were re-measured on the rebased build and are
unchanged, with 0 of 48 per-binary entry sets differing from the pre-rebase run.


Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mahaloz added a commit that referenced this pull request Aug 3, 2026
…cost this round

Docs-only. No .rs, no phases.toml, no baselines, no tests.

Round 2 shipped, and the benchmark signal was refreshed on 2026-08-03 (all three
opt levels re-decompiled from pinned kuna 9623dc2). Several documented claims
were provably stale and several hard-won operational facts existed only in agent
transcripts. Both fixed, every number re-verified against the live tree.

docs/decbench-loop.md
- Standings replaced and widened: GED ida 36.06 / kuna 35.93 / angr 34.20,
  overall ida 38.01 / kuna 37.91 / angr 36.98, byte_match kuna 3.41 (first).
  Stated plainly that kuna's column is current while the rivals' are from their
  own last runs, so the tree is a MINING INSTRUMENT, not a leaderboard.
- Recall pool: 6,540 (7.3%) -> 1,420 vs angr / 1,552 vs ida, 0 whole-binary
  failures, now almost entirely embedded ARM Cortex-M. All three named causes
  corrected: "u-boot 100% / freertos 100%" was a decbench .text-filter artifact
  and never a kuna discovery failure (angr and ida score nothing there);
  "betaflight 22%" is 6.0%; the coreutils `main` empty-body/panic is fixed
  (comm/join/timeout/uniq all produce full bodies today).
- The `--mode auto` degrades-to-fast warning is moot for this corpus: the
  largest stripped binary is O0 bash at 1,513,904 B (1.44 MiB), so all 803
  binaries resolve 768 aggressive / 35 reliable / 0 fast. The aggressive-vs-
  reliable distinction is kept and sharpened; the stale 21-of-24 default-off
  count is now 20 of 25, with the five exclusions named.
- Two operational traps recorded for the first time:
  (a) byte_match RECOMPILES with an arch-matched toolchain and this box has
      neither arm-none-eabi-gcc nor MinGW, so deleting kuna's (never
      auto-invalidated) checkpoints destroys kuna's ARM/PE scores while every
      rival keeps theirs. The coverage guard caught 34 slices; O2 and
      O2-noinline are still damaged from an earlier DECBENCH_ALLOW_DROPS=1 run
      with no surviving copy. Rule: never pass DECBENCH_ALLOW_DROPS=1 without
      reading every [guard] line.
  (b) The pools store a PE address as an RVA where kuna uses the VA, so
      scripts.decbench.rescore fails on every PE case (119 across the three
      pools). Recorded with a fix direction.
- Pointed at the durable refresh recipe at ~/decbench-campaign-state/ and its
  two pinning rules, plus the non-obvious one: the GED baseline must drop kuna's
  published scores for EVERY re-decompiled opt level, not just the one being
  refreshed (an O0-only baseline died with "cannot reproduce published fallback
  58.0" on an O2 slice).

Method corrections (decbench-loop.md + improvement-pipeline.md standing rules)
- "Not a no-op" is not "correct". On paramcopyhoist a refuter proved the
  proposed hook reached the printer and it was still the wrong site: it deleted
  an assignment, lost an early return, and made another function return the
  wrong parameter. The refute brief now carries an explicit "would this produce
  WRONG output?" axis.
- Diff every changed function, not the witness. Those designs all passed on
  their witness. Round 2's PRs swept 3,031 / 12,241 / 14,720 / 15,386 functions;
  two caught real problems that way.
- The tally, honestly: round 1's filed mechanisms were 2-for-5, round 2's
  refuters overturned the filed diagnosis on 3 of 8, and the symptom stood in
  every case.

docs/decbench/features.md
- Round-1 menu replaced by round-2 outcomes, keeping the file's shape and its
  rank-by-correctness thesis: #248 cortexmvectors, #249 funcptralign,
  #250 paramcopyhoist, #251 subright, #252 returncopysplit, #253 itecondlist
  (merged) and #254 peimportcall (IN FLIGHT), each with its measured effect.
- Named the structural finding that outlives them: three separate ported passes
  were dead -- RuleSubRight (stub body), RuleFuncPtrEncoding (live body, stubbed
  input) and ActionDeindirect (live body, a gate bit set nowhere). Each was
  invisible to every test and each had large breadth, so "grep for
  registered-but-unreachable passes" is now a mining route of its own.
- Carried forward what did not ship: undefname-leak (283 functions, 221 with
  uninitialised reads) and catalog-upstream-options (38 upstream-inherited
  ArchOptions invisible to `kuna catalog`).

Re-mined pool tables regenerated against the refreshed tree (snapshot
2026-08-03): backlog.md, backlog-ida.md, novel.md, triage-queue*.json.

Gates: make check-spec OK (lenient and strict); make test 675/675 PARITY OK;
make test-stages 381/381 PARITY OK.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
mahaloz added a commit that referenced this pull request Aug 3, 2026
…cost this round

Docs-only. No .rs, no phases.toml, no baselines, no tests.
Rebased onto origin/main 4c2b59b (after #254, #255 and #257).

Round 2 shipped, and the benchmark signal was refreshed on 2026-08-03 (all three
opt levels re-decompiled from pinned kuna 9623dc2). Several documented claims
were provably stale and several hard-won operational facts existed only in agent
transcripts. Both fixed, every number re-verified against the live tree.

docs/decbench-loop.md
- Standings replaced and widened: GED ida 36.06 / kuna 35.93 / angr 34.20,
  overall ida 38.01 / kuna 37.91 / angr 36.98, byte_match kuna 3.41 (first).
  Stated plainly that kuna's column is current while the rivals' are from their
  own last runs, so the tree is a MINING INSTRUMENT, not a leaderboard.
- Recall pool: 6,540 (7.3%) -> 1,420 vs angr / 1,552 vs ida, 0 whole-binary
  failures, now almost entirely embedded ARM Cortex-M. All three named causes
  corrected: "u-boot 100% / freertos 100%" was a decbench .text-filter artifact
  and never a kuna discovery failure (angr and ida score nothing there);
  "betaflight 22%" is 6.0%; the coreutils `main` empty-body/panic is fixed
  (comm/join/timeout/uniq all produce full bodies today).
- The `--mode auto` degrades-to-fast warning is moot for this corpus: the
  largest stripped binary is O0 bash at 1,513,904 B (1.44 MiB), so all 803
  binaries resolve 768 aggressive / 35 reliable / 0 fast. The aggressive-vs-
  reliable distinction is kept and sharpened; the stale 21-of-24 default-off
  count is now 20 of 25, with the five exclusions named.
- Two operational traps recorded for the first time:
  (a) byte_match RECOMPILES with an arch-matched toolchain and this box has
      neither arm-none-eabi-gcc nor MinGW, so deleting kuna's (never
      auto-invalidated) checkpoints destroys kuna's ARM/PE scores while every
      rival keeps theirs. The coverage guard caught 34 slices; O2 and
      O2-noinline are still damaged from an earlier DECBENCH_ALLOW_DROPS=1 run
      with no surviving copy. Rule: never pass DECBENCH_ALLOW_DROPS=1 without
      reading every [guard] line.
  (b) The pools store a PE address as an RVA where kuna uses the VA, so
      scripts.decbench.rescore fails on every PE case (119 across the three
      pools). Recorded with a fix direction.
- Pointed at the durable refresh recipe at ~/decbench-campaign-state/ and its
  two pinning rules, plus the non-obvious one: the GED baseline must drop kuna's
  published scores for EVERY re-decompiled opt level, not just the one being
  refreshed (an O0-only baseline died with "cannot reproduce published fallback
  58.0" on an O2 slice).

Method corrections (decbench-loop.md + improvement-pipeline.md standing rules)
- "Not a no-op" is not "correct". On paramcopyhoist a refuter proved the
  proposed hook reached the printer and it was still the wrong site: it deleted
  an assignment, lost an early return, and made another function return the
  wrong parameter. The refute brief now carries an explicit "would this produce
  WRONG output?" axis.
- Diff every changed function, not the witness. Those designs all passed on
  their witness. Round 2's PRs swept 3,031 / 12,241 / 14,720 / 15,386 functions;
  two caught real problems that way.
- The tally, honestly: round 1's filed mechanisms were 2-for-5, round 2's
  refuters overturned the filed diagnosis on 3 of 8, and the symptom stood in
  every case.

Shared counters in a busy queue (decbench-loop.md + improvement-pipeline.md)
- Round 2 ran up to four output-changing PRs over the same hard-coded counters
  and produced three failure shapes, only one of which announced itself: a
  conflict (#257's DIV number raced 55 -> 56 -> 57 -> 58); a SILENT
  identical-edit auto-merge (catalog_bytecompat.rs kept 86 because both sides
  made the same 85 -> 86 edit); and a SILENT keep-both auto-merge (a stale
  baseline-stages.json data_footer, and five rounds of keep-both duplicating a
  row in tests/stages/README.md).
- Rules written down: derive every shared counter from a fresh capture and a
  green run on the rebased tree, never by arithmetic; diff every keep-both
  resolution against main asserting you removed nothing and added nothing twice;
  DIV numbers are claimed on merge; re-run the gates AFTER the rebase.
- New standing requirement 9: re-measure after every rebase, never carry a
  number forward. #257's placeholder count moved 2,143 -> 2,142 because #254
  landed underneath it, caught only by re-measuring.

docs/decbench/features.md
- Round-1 menu replaced by round-2 outcomes, keeping the file's shape and its
  rank-by-correctness thesis. NINE merged PRs: #248 cortexmvectors,
  #249 funcptralign, #250 paramcopyhoist, #251 subright, #252 returncopysplit,
  #253 itecondlist, #254 peimportcall (DIV-57), #255 ptrentry and #257 undefname
  (DIV-58) -- seven of the eight round-2 candidates plus steps 1 and 2 of the
  ARM entry-recall sequence (#239). Only three of the nine move GED on a mined
  case; four are correctness fixes the metric cannot see and two are recall.
- The dead-pass finding is now three DISTINCT shapes to grep for, not one
  anecdote: stub body (RuleSubRight), live body with a permanently-zero input
  (RuleFuncPtrEncoding's hard-coded funcptr_align() = 0), and live body with a
  gate bit that has no writer anywhere (ActionDeindirect / externref). The third
  had a second gap in the same chain -- GlobalEntry::func_no_return never copied
  the callee's no-return flag into the snapshot -- so one dead gate can hide
  another.
- The ARM sequence is cross-referenced to the live table on PR #239 rather than
  duplicated here, so it cannot go stale in-repo.
- Carried forward as the one still-open candidate: catalog-upstream-options
  (38 upstream-inherited ArchOptions invisible to `kuna catalog`).

Re-mined pool tables regenerated against the refreshed tree (snapshot
2026-08-03): backlog.md, backlog-ida.md, novel.md, triage-queue*.json.

Gates on the rebased base: make check-spec OK (lenient and strict);
make test 675/675 PARITY OK; make test-stages 394/394 PARITY OK.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
mahaloz added a commit that referenced this pull request Aug 3, 2026
…cost this round (#256)

Docs-only. No .rs, no phases.toml, no baselines, no tests.
Rebased onto origin/main 4c2b59b (after #254, #255 and #257).

Round 2 shipped, and the benchmark signal was refreshed on 2026-08-03 (all three
opt levels re-decompiled from pinned kuna 9623dc2). Several documented claims
were provably stale and several hard-won operational facts existed only in agent
transcripts. Both fixed, every number re-verified against the live tree.

docs/decbench-loop.md
- Standings replaced and widened: GED ida 36.06 / kuna 35.93 / angr 34.20,
  overall ida 38.01 / kuna 37.91 / angr 36.98, byte_match kuna 3.41 (first).
  Stated plainly that kuna's column is current while the rivals' are from their
  own last runs, so the tree is a MINING INSTRUMENT, not a leaderboard.
- Recall pool: 6,540 (7.3%) -> 1,420 vs angr / 1,552 vs ida, 0 whole-binary
  failures, now almost entirely embedded ARM Cortex-M. All three named causes
  corrected: "u-boot 100% / freertos 100%" was a decbench .text-filter artifact
  and never a kuna discovery failure (angr and ida score nothing there);
  "betaflight 22%" is 6.0%; the coreutils `main` empty-body/panic is fixed
  (comm/join/timeout/uniq all produce full bodies today).
- The `--mode auto` degrades-to-fast warning is moot for this corpus: the
  largest stripped binary is O0 bash at 1,513,904 B (1.44 MiB), so all 803
  binaries resolve 768 aggressive / 35 reliable / 0 fast. The aggressive-vs-
  reliable distinction is kept and sharpened; the stale 21-of-24 default-off
  count is now 20 of 25, with the five exclusions named.
- Two operational traps recorded for the first time:
  (a) byte_match RECOMPILES with an arch-matched toolchain and this box has
      neither arm-none-eabi-gcc nor MinGW, so deleting kuna's (never
      auto-invalidated) checkpoints destroys kuna's ARM/PE scores while every
      rival keeps theirs. The coverage guard caught 34 slices; O2 and
      O2-noinline are still damaged from an earlier DECBENCH_ALLOW_DROPS=1 run
      with no surviving copy. Rule: never pass DECBENCH_ALLOW_DROPS=1 without
      reading every [guard] line.
  (b) The pools store a PE address as an RVA where kuna uses the VA, so
      scripts.decbench.rescore fails on every PE case (119 across the three
      pools). Recorded with a fix direction.
- Pointed at the durable refresh recipe at ~/decbench-campaign-state/ and its
  two pinning rules, plus the non-obvious one: the GED baseline must drop kuna's
  published scores for EVERY re-decompiled opt level, not just the one being
  refreshed (an O0-only baseline died with "cannot reproduce published fallback
  58.0" on an O2 slice).

Method corrections (decbench-loop.md + improvement-pipeline.md standing rules)
- "Not a no-op" is not "correct". On paramcopyhoist a refuter proved the
  proposed hook reached the printer and it was still the wrong site: it deleted
  an assignment, lost an early return, and made another function return the
  wrong parameter. The refute brief now carries an explicit "would this produce
  WRONG output?" axis.
- Diff every changed function, not the witness. Those designs all passed on
  their witness. Round 2's PRs swept 3,031 / 12,241 / 14,720 / 15,386 functions;
  two caught real problems that way.
- The tally, honestly: round 1's filed mechanisms were 2-for-5, round 2's
  refuters overturned the filed diagnosis on 3 of 8, and the symptom stood in
  every case.

Shared counters in a busy queue (decbench-loop.md + improvement-pipeline.md)
- Round 2 ran up to four output-changing PRs over the same hard-coded counters
  and produced three failure shapes, only one of which announced itself: a
  conflict (#257's DIV number raced 55 -> 56 -> 57 -> 58); a SILENT
  identical-edit auto-merge (catalog_bytecompat.rs kept 86 because both sides
  made the same 85 -> 86 edit); and a SILENT keep-both auto-merge (a stale
  baseline-stages.json data_footer, and five rounds of keep-both duplicating a
  row in tests/stages/README.md).
- Rules written down: derive every shared counter from a fresh capture and a
  green run on the rebased tree, never by arithmetic; diff every keep-both
  resolution against main asserting you removed nothing and added nothing twice;
  DIV numbers are claimed on merge; re-run the gates AFTER the rebase.
- New standing requirement 9: re-measure after every rebase, never carry a
  number forward. #257's placeholder count moved 2,143 -> 2,142 because #254
  landed underneath it, caught only by re-measuring.

docs/decbench/features.md
- Round-1 menu replaced by round-2 outcomes, keeping the file's shape and its
  rank-by-correctness thesis. NINE merged PRs: #248 cortexmvectors,
  #249 funcptralign, #250 paramcopyhoist, #251 subright, #252 returncopysplit,
  #253 itecondlist, #254 peimportcall (DIV-57), #255 ptrentry and #257 undefname
  (DIV-58) -- seven of the eight round-2 candidates plus steps 1 and 2 of the
  ARM entry-recall sequence (#239). Only three of the nine move GED on a mined
  case; four are correctness fixes the metric cannot see and two are recall.
- The dead-pass finding is now three DISTINCT shapes to grep for, not one
  anecdote: stub body (RuleSubRight), live body with a permanently-zero input
  (RuleFuncPtrEncoding's hard-coded funcptr_align() = 0), and live body with a
  gate bit that has no writer anywhere (ActionDeindirect / externref). The third
  had a second gap in the same chain -- GlobalEntry::func_no_return never copied
  the callee's no-return flag into the snapshot -- so one dead gate can hide
  another.
- The ARM sequence is cross-referenced to the live table on PR #239 rather than
  duplicated here, so it cannot go stale in-repo.
- Carried forward as the one still-open candidate: catalog-upstream-options
  (38 upstream-inherited ArchOptions invisible to `kuna catalog`).

Re-mined pool tables regenerated against the refreshed tree (snapshot
2026-08-03): backlog.md, backlog-ida.md, novel.md, triage-queue*.json.

Gates on the rebased base: make check-spec OK (lenient and strict);
make test 675/675 PARITY OK; make test-stages 394/394 PARITY OK.


Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mahaloz added a commit that referenced this pull request Sep 8, 2026
…es a UINT, so its peimportcall assertion does too

`ghdec-peimportcall` PEIMPORTCALL #5 pinned `ExitProcess\(\); // no-return` on
the `bail` function of `pe_noreturn_import.exe`.  That empty-parens spelling was
frozen in by DIV-57 (#254), when kuna carried no Windows API prototype at all
and the call's one argument was simply lost.

`win32sigs` (DIV-141) supplies the import's `void __stdcall ExitProcess(UINT)`,
and the fixture's source is `void bail(int code) { ExitProcess(code); }`, so the
site now renders `ExitProcess(a0)` and `bail` recovers its parameter.  The
assertion is the stale side of that; what the test exists to protect -- the
`FF 25`/IAT-slot call binding to its import name and both `// no-return` flow
effects surviving -- is asserted by the other four stringmatches and unchanged.

The assertion name is untouched, so `docs/baseline-stages.json` needs no
re-record; `docs/baseline.json` is byte-identical to origin/main.

make test 675/675 PARITY OK, make test-stages 704/704 PARITY OK,
make test-cli 99/99, make check-spec OK, kuna catalog --check OK.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
mahaloz added a commit that referenced this pull request Sep 8, 2026
…in32 imports their signatures (win32sigs, DIV-141) (#520)

* [AUTOMATED] feat(analysis): resource-loader-c-retains — give a PE's Win32 imports their signatures (win32sigs, DIV-141)

kuna's whole prototype knowledge base was libc, so on a PE every LoadLibraryExW /
WriteFile / VirtualQuery call reached ActionDefaultParams with an empty prototype
and call-site trial scoring was the only thing between the pushes and the call.
Where that scoring loses, the arguments are dropped and the outgoing slots
`callsitestackargs` already mapped survive as stack-local debris.

`win32sigs` supplies the Windows half of the `.gdt` stand-in `libproto` already
is: ~130 WINAPI exports ranked by an import histogram over the 54 PE images of
the RE arena corpus, plus the resource/loader family the need was filed against.
Signatures are reduced to the same width-stable vocabulary the libc tables use,
and a slot with no honest spelling is rejected rather than approximated.

The prototypes are parked by ENTRY ADDRESS. A PE import is two FunctionSymbols --
the size-0 IAT slot and the `FF 25` thunk veneer a direct `call` targets -- the
global by-name query answers with the slot, and ActionDefaultParams asks about
the thunk, so the by-name park is a silent no-op on exactly the calls that need
it. A new AnalysisOutput::prototypes_at stream carries the address.

Sweep over 22 PE images / 3,029 functions: 168 changed, 0 added, 0 removed, every
changed function containing a call to a table name; 35 call sites gain arguments
to the documented arity and 16 shed invented ones. Speed -16.9%.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [AUTOMATED] test(p0): resource-loader-c-retains — list win32sigs among the analysis-tier gates with no codegen live reader

`option_values_live_value_present_for_58_suppressed_for_101` enumerates the
options whose live state is read console-side rather than through the codegen
`live_value`. Like `libproto`/`libcsigs`/`declaredlibcproto`, `win32sigs` is an
analysis-pass gate and belongs in that list.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* [AUTOMATED] test(stages): resource-loader-c-retains — ExitProcess takes a UINT, so its peimportcall assertion does too

`ghdec-peimportcall` PEIMPORTCALL #5 pinned `ExitProcess\(\); // no-return` on
the `bail` function of `pe_noreturn_import.exe`.  That empty-parens spelling was
frozen in by DIV-57 (#254), when kuna carried no Windows API prototype at all
and the call's one argument was simply lost.

`win32sigs` (DIV-141) supplies the import's `void __stdcall ExitProcess(UINT)`,
and the fixture's source is `void bail(int code) { ExitProcess(code); }`, so the
site now renders `ExitProcess(a0)` and `bail` recovers its parameter.  The
assertion is the stale side of that; what the test exists to protect -- the
`FF 25`/IAT-slot call binding to its import name and both `// no-return` flow
effects surviving -- is asserted by the other four stringmatches and unchanged.

The assertion name is untouched, so `docs/baseline-stages.json` needs no
re-record; `docs/baseline.json` is byte-identical to origin/main.

make test 675/675 PARITY OK, make test-stages 704/704 PARITY OK,
make test-cli 99/99, make check-spec OK, kuna catalog --check OK.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

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