Repository navigation
[AUTOMATED] fix(p3): (NOVEL) honour the cspec's <funcptr align> on indirect-call targets - #249
Merged
Merged
Conversation
…direct-call targets
`RuleFuncPtrEncoding` is a line-for-line port of upstream `ruleaction.cc:9928`
and has been registered in the P3 rule pool since W8, but its only input was a
hard-coded `funcptr_align() = 0` STUB(W4), so the rule could never fire on any
architecture. Read the value live from the architecture, exactly as
`p2_lift/jumptable.rs` and `RulePtrsubUndo::preserve_thumb_funcptr` already do.
That is the whole behavioural change; the cspec-side plumbing has existed since
W4 and the stub's premise was stale.
Cost of the stub: SLEIGH lowers every Thumb indirect call through `BXWritePC`
(`local tmp = addr & 0xfffffffe`) and every MIPS `jalr` through `JXWritePC`
(`tmp = -2 & addr`), so an INT_AND fed the CALLIND. kuna emitted that ISA-mode
bookkeeping as a real C operation the program never performs, AND the mask
blocked the pointer-to-code type from back-propagating onto the LOAD, so every
call site also needed an extra `(code *)` cast:
(*(code *)(*(uint4 *)(a0 + 0x44) & 0xfffffffe))(a0) before
(**(code **)(a0 + 0x44))(a0) after == ghidra
Not gated. The alignment width is declared by the processor cspec
(`<funcptr align="N"/>`), not by kuna; upstream honours it unconditionally; and
the pre-fix C stated an operation the program does not perform. This removes a
divergence rather than creating one, so it is recorded under **Convergences** in
`docs/history.md`, not as a DIV row.
AARCH64 (`align="4"`, i.e. a 2-bit address-alignment mask rather than a mode
bit) was verified rather than assumed: upstream's `applyOp` has a single code
path with no align special-case and an exact comparison; `blr` emits no mask at
all, so the rule is inert on ordinary AArch64 code; and stock Ghidra 12.1
headless on a purpose-built probe strips a program-written `& ~3` and prints
byte-for-byte what kuna now prints.
Evidence: 675/675 PARITY OK and stages PARITY OK with no re-pin and no per-test
opt-out. Whole-binary `decompile-all`, masks / `(code *)` / `(code **)`:
crazyflie cf2.elf 264->15 / 255->46 / 0->205, nuttx 459->40 / 435->42 / 0->397,
libopencm3 msc.elf 56->6 / 50->10 / 0->41, chibios ch.elf 38->13 / 40->30 /
0->16 -- every ARM project in the corpus had zero `(code **)` before. x86-64
and i386 whole-binary output is byte-identical (zlib, gzip, bash, coreutils
head, x0r-usb.exe: 0 changed lines), since their cspecs declare no `<funcptr>`.
Speed, interleaved medians: libopencm3 +0.84%, coreutils head +1.40% (that
binary's output is byte-identical, so it is noise), crazyflie cf2.elf -12.99%.
GED is flat (18 -> 18 on msc_data_rx_cb) -- a CFG metric cannot see an
expression/type change, exactly as the cluster record predicted.
Bundle: docs/features/funcptralign/. Test: tests/stages/ghdec-funcptralign.xml
(0/2 pre-fix, 2/2 post-fix).
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017dPFaKJanfLSf7mWGhkzkL
This was referenced Aug 3, 2026
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]>
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.
What
RuleFuncPtrEncoding— the rule that erases the ISA-mode / alignment bit-clearSLEIGH puts on an indirect-call target — was fully ported and registered, but its
only input was a hard-coded stub:
and the rule's first two lines are
let align = funcptr_align(data); if align == 0 { return 0; }.The rule could never fire on any architecture. This PR reads the value live,
data.get_arch().funcptr_align— the same accessorp2_lift/jumptable.rs:3661andp3_dataflow/ruleaction_6.rs:609already use. That is the whole behavioural change.The stub's premise was stale:
infra/architecture.rs:2105 decode_funcptr_align()hasparsed the cspec's
<funcptr align="N"/>into the field since W4,:3902calls it duringparse_compiler_config, and:1869copies it into the ArchSeamFuncdatareads.Root-cause analysis and the full evidence:
docs/features/funcptralign/analysis.md(campaign record:
docs/decbench/triage/novel-code-ptr-cluster.md).Before / after
ARM / Thumb —
crazyfliecf2.elf@0x804001c(dwHandleInterrupt), the witnessSLEIGH lowers every Thumb indirect call through
BXWritePC(ARM.sinc:221), whose bodyis
local tmp = addr & 0xfffffffe, so anINT_ANDfeeds theCALLIND.The source performs no bit-clear —
libdw1000.i,dwHandleInterrupt:if(dwIsClockProblem(dev) && dev->handleError != 0) { (*dev->handleError)(dev); }.The fields are
dwHandler_tfunction pointers. kuna was asserting an operation theprogram does not perform, and the mask also blocked the pointer-to-code type from
back-propagating onto the LOAD, which is why every call site needed the extra
(code *).AARCH64
align=4— verified explicitly against stock GhidraThe five AARCH64 cspecs declare
<funcptr align="4"/>, i.e.funcptr_align = 2, so theseam strips a 2-bit address-alignment mask rather than a mode bit. Probe built with
clang --target=aarch64-linux-gnu -O1 -ffreestanding -c:handledoes a plainblr x8,handle_maskedreally executesand x8, x8, #0xfffffffffffffffc; blr x8.handle(no mask)handle_masked(& ~3)(**(code **)&a0[2])()(*(code *)(*(uint8 *)&a0[2] & 0xfffffffffffffffc))(*a0)(**(code **)&a0[2])()(**(code **)&a0[2])(*a0)(**(code **)(param_1 + 2))()(**(code **)(param_1 + 2))(*param_1)Three reasons this is right and not just convenient:
RuleFuncPtrEncoding::applyOp(ruleaction.cc:9928) is one code path —slide = ~0 << align; if ((testmask & slide) == val) { opRemoveInput; opSetOpcode(COPY); }.There is no
align == 1branch, and the comparison is exact: on AARCH64 a& ~3matches and a
& ~1does not. kuna's port is the same arithmetic.AARCH64base.sinc:887,:blr Rn_GPR64 { pc = Rn_GPR64; x30 = inst_start + 4; call [pc]; }— so the rule isinert on ordinary AArch64 code and only ever fires on a mask the program wrote.
form (table above).
Pinned at the rule level by a new unit test,
funcptrencoding_strips_aarch64_word_alignment(align=2 strips
& ~3and declines& ~1), alongside..._strips_thumb_mode_bitand..._noops_without_cspec_funcptr.MIPS is the ARM shape:
mips.sinc:925 JXWritePCunderISA_VARIANT(everymips32*/mips64*slaspec) doestmp = -2 & addr, sojalrcarries the mask too.Breadth
kuna decompile-all, whole binary, occurrences of& 0xfffffffe/(code *)/(code **):(code *)(code **)cf2.elf(ARM Cortex-M4)nuttx(ARM Cortex-M)msc.elf(ARM Cortex-M)ch.elf(ARM Cortex-M)Every ARM project in the corpus had zero
(code **)before this change, because amask sat on every indirect-call target. The triage measured the class corpus-wide at
4,027 Thumb-masked indirect calls in 2,496 function-instances across 97 binary-instances
in 9 ARM projects (crazyflie 986 fns, betaflight 694, cleanflight 384, libopencm3 221,
nuttx 144, chibios 48, riot-os 13, freertos 4, u-boot 2).
x86-64 / i386 controls are byte-identical — their cspecs declare no
<funcptr>, sofuncptr_align == 0and the rule stays inert. Whole-binarydecompile-all(
--max-fn-seconds 0) diffs, before vs after:minigzip(x86-64)gzip(x86-64)bash(x86-64)x0r-usb.exe(i386 PE)head(x86-64)Ablation
kuna test --all --baseline docs/baseline.json→ PARITY OK, 675/675, with the fixlive and no re-pin, no per-test opt-out. The corpus's two
ARM:LE:32:v8and sixMIPS:*:32:defaultdatatests contain no masked indirect call.make test-stages→ PARITY OK; the stages baseline was re-recorded only to add thetwo new keys.
That clean ablation, plus the fact that the alignment width is declared by the processor
cspec rather than by kuna and that upstream honours it unconditionally, is why this ships
without an option:
CLAUDE.md— "a strict bug fix that only corrects wrong outputneeds no flag". It is recorded in
docs/history.mdunder Convergences (upstreambehavior restored — not divergences), which is exactly where the registry puts a port
defect whose fix moves kuna back onto upstream's default.
Speed
Interleaved
decompile-allmedians, two builds of this tree (pre-fix stub vs live read),on a box running three sibling agents:
msc.elf(ARM)head(x86-64)cf2.elf(ARM)Worst case +1.40%, well inside the +5% budget — and that binary's emitted C is
byte-identical before and after, so the number is measurement noise, not cost. The ARM
witness gets materially faster: one op leaves the graph at every indirect call.
(
scripts.pipeline.timeitis not usable here — it measures a feature by flipping itsoption, and this change has none. The equivalent measurement is two builds of this tree,
interleaved OFF/ON, medians.)
Benchmark delta — measured, and it is zero
scripts.decbench.rescoreonO2-noinline-libopencm3-msc-msc_data_rx_cb(the siblingthumb-mask case whose
case_idexists in the pool onmain):GED is flat, exactly as the cluster record predicted ("it has zero GED value"). GED is a
CFG edit distance; this fix removes an
INT_ANDfrom an expression and retypes aLOAD—it changes no basic block and no edge, so the metric cannot see it. Reported rather than
hidden.
The headline witness
O2-noinline-crazyflie-*-dwHandleInterruptis not scoreable:rescoreresolves its source tocrtp_localization_service.i(the function is inlibdw1000.i) and gets a 1-node degenerate source CFG, so before and after both come outinf. That is the degenerate-source-CFG artifactdocs/decbench-loop.mdwarns about, nota result —
record.jsonstores it asnullwith the explanation.The win here is correctness and readability, and it is measured directly instead: kuna's
post-fix C is byte-for-byte Ghidra's on both the ARM witness and the AArch64 probe, the
invented bit-clear is gone, and the callee type is finally recovered.
Test
tests/stages/ghdec-funcptralign.xml— two-pass, hand-laid ARM Thumb-2 dispatcher(
push {r4,lr}; mov r4,r0; ldr r3,[r0,#4]; cmp r3,#0; beq +1; mov r0,r4; blx r3; pop {r4,pc}),the reduced
dwHandleInterruptshape. Pass 1 is the default pipeline; pass 2 re-runs withoption thumbfuncptr off, the other livefuncptr_alignreader (GH-8471 / DIV-2), sothe documented interaction risk is pinned: the mask must stay stripped either way.
0 of 2 assertions pass pre-fix, 2/2 post-fix.
Gates
docs/baseline.jsonis untouched.docs/baseline-stages.jsongains exactly the twonew keys and the 356 → 358 count — no existing assertion moved:
Note: the first
make rust-testrun reported1 target failed: -p kuna-cli --test decompile_all_cliwhile five concurrent cargo workspaces and two Joern runs shared thebox. That target passes in isolation (18/18) and the clean full re-run above is green —
it was a load flake in the wall-clock-sensitive watchdog tests, not this change (which
cannot reach an x86-64 CLI path:
funcptr_align == 0there).🤖 Generated with Claude Code