Skip to content

[AUTOMATED] Add the format and isolate assertion directives - #1679

Merged
mahaloz merged 19 commits into
Noelo-Lab:mainfrom
coleleavitt:fix/assert-format-isolate
Nov 19, 2026
Merged

mahaloz merged 19 commits into
Noelo-Lab:mainfrom
coleleavitt:fix/assert-format-isolate

Conversation

@coleleavitt

Copy link
Copy Markdown
Contributor

[AUTOMATED]

What this makes possible

--assert can now set the form one constant is printed in, and keep one local from being merged with another. Before, both were console-only (map convert needs a dataflow hash, and isolate was not implemented).

int is_rwx(unsigned m) { return (m & 0777) == 0755; }
clang -O2 -c mode.c -o mode.o && ld.lld -shared -o mode.so mode.o
kuna decompile mode.so is_rwx
kuna decompile mode.so is_rwx --assert 'format 0x1304 oct' --assert 'format 0x130c oct'
  return (a0 & 0x1ff) == 0x1ed;        # before, and without the directives

error: --assert "format 0x1304 oct": unknown directive "format" (want one of ...)   # before

  return (a0 & 0777) == 0755;          # after

isolate, on int triple(int a) { int t = a; p(&t); h(t); a = a * 3; h(a); h(a + t); return a; } (clang -O1):

  a0 *= 3;            # kuna decompile t.so triple
  v2 = a0 * 3;        # kuna decompile t.so triple --assert 'isolate a0'

The change

  • format [<func>::]<addr> hex|dec|oct|bin|char [<value>] names the constant by the address of the instruction that reads it. When that instruction reads several constants, <value> picks one, and the rejection without it lists them. An address that reads no integer constant is rejected.
  • isolate [<func>::]<symbol> resolves its name as name does, so it reaches register locals, stack locals and parameters.
  • Both lower to console commands, so the text and --json surfaces agree: a new force constant <addr> <format> [<value>], and isolate <name>, which now works (it returned "not available").
  • The constant gets the same equate Symbol force varnode builds, so the format reaches the second pass with the other dynamic Symbols. If the second pass does not find the constant again, the directive is reported refused instead of applied.
  • An isolated stack local or parameter is rebuilt by the next decompile, a parameter only after the merges have run, so its isolation is carried by storage and width (p6_variables/kuna_isolated.rs) and the merge test reads that set. The set is empty unless such a local was isolated.
  • No option: a directive is a fact the caller states, like name and type.

Tests

  • kuna-cli/tests/assert_format_isolate.rs, on a 3 KB ELF built from the C beside it, runs every case on both surfaces: oct prints 0777 and 0755, dec prints 511, an address with no constant is rejected (and fails under --assert-strict), a value picks one of two constants, @file, and isolate on a register local and on a parameter.
  • tests/stages/kuna-assert-format-isolate.xml pins the console commands, before and after, and that an isolated parameter stays isolated through a later rename and decompile.
  • No existing expectation moved (675/675 datatests, stage baseline gains 7 keys). A decompile with no directive executes the same number of instructions as before (826.7 M on the repro, both builds); decompile-all /usr/bin/ls --json output is byte-identical.

Fixes #1642

coleleavitt and others added 13 commits November 18, 2026 16:03
…nd print ACLE intrinsics

AARCH64.pspec leaves the ShowMemTag context at 0, under which irg, addg, subg, gmi and ldg lift
as a pointer copy or add and the stg family as nothing, so
`return __arm_mte_create_random_tag(p, 0);` decompiled to `return a0;`. Barriers and hints
printed under their SLEIGH instruction names (`DataMemoryBarrier(2,3)`) instead of the
<arm_acle.h> intrinsic the source called (`__dmb(11)`).

The new option `acleintrinsics` (on|off, default on, AArch64 only) does two things:

- `p2_lift/kuna_memtag.rs` sets ShowMemTag to 1 over the code space before a function is
  lifted. Only the memory-tagging constructors read that context, so code without those
  instructions lifts as before. The ShowMemTag=1 constructors now make the tagged pointer the
  result of the user op (new ops AddPtrTag, ExcludePtrTag, LoadPtrTag, StorePtrTag), and no
  longer branch to AlignmentFault() before a tag store.
- `p9_emit/kuna_acleintrinsics.rs` prints the barrier, hint and memory-tagging user ops as
  __dmb, __dsb, __isb, __wfi, __wfe, __yield, __sev, __sevl and __arm_mte_create_random_tag,
  _increment_tag, _exclude_tag, _get_tag and _set_tag. A barrier's domain and type operands
  recombine into CRm; isb's CRm is read from the instruction. A tag load or store that names
  another granule keeps its user-op name.

`off` restores the previous output byte for byte. make test stays 675/675 with the option on;
the dmb control in kuna-syscallregs-aarch64.xml now reads __dmb(11). The AArch64 compiler
digest and the ccmp lift fixture (unique-space offsets only) are regenerated.

Fixes Noelo-Lab#1626
`--assert 'format [<func>::]<addr> hex|dec|oct|bin|char [<value>]'` prints
the constant the instruction at <addr> reads in that form, and
`--assert 'isolate [<func>::]<symbol>'` keeps a local from being merged
with another. Both report applied or rejected like the other directives
and work in an @file.

format lowers to a new console command, `force constant`, which names
the constant by its instruction address where `force varnode` needs a
p-code sequence number. isolate lowers to the console's `isolate`, which
is now implemented. An isolated stack local or parameter reaches the next
decompile by its storage (p6_variables/kuna_isolated.rs).

Fixes Noelo-Lab#1642
A new directive, `callee [<func>::]<callsite> <name|address>`, and the
console command `override indirect <callsite> <name|address>` plant the
per-function indirect-call override before flow, so the call is built as
a direct call and takes the callee's name and prototype. An indirect
jump at the call site is taken as a tail call: no jump-table recovery,
a call and a return.

A direct call, an instruction that is not a call or an indirect jump,
and a destination that is not a function are rejected with the reason.
A call site the function's flow does not reach is recorded after the
follow and reported as a refused directive.

Fixes Noelo-Lab#1644
…alls, restated sites

- A destination that is a PLT stub bound to a local definition was applied
  but then refused after flow (exit 1): the call spec is built at the
  definition, so the audit now also accepts the spec's PLT stub.
- A stated indirect jump to a no-return callee printed a dead `return;`
  after the call; the stated tail call now ends there, as a direct tail
  call to the same callee does (stage assertions #6-#7).
- Two `callee` directives for one call site both reported applied; the
  earlier is now reported rejected on both the text and JSON surfaces.
- `callee` is listed in the `--assert` usage vocabulary; the fixture recipe
  records -fcf-protection=full, which the committed ELF was built with.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…ter reads contradict

The shared-push rule took a declared parameter at the pushed slot as proof the
push is an argument on both arms. MinGW GCC passes a static function's
arguments in EAX/EDX/ECX while its debug information lists them as ordinary
parameters, so wine's MSVCRT_longjmp handed the padding slot GCC re-reserves
after IsBadReadPtr to the indirect unwind call: `(*jmp->UnwindFunc)(jmp,frame)`.
A declared list with no register parameter, for a direct callee whose entry
reads EAX, ECX or EDX before writing it, no longer counts as that proof.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…ead of refusing any

A MinGW thiscall member declared from its mangled name lists `this` as a
stack parameter while its code reads ECX and takes the rest on the stack, so
refusing every declared list whose callee reads an argument register dropped
the speculative-devirtualization gains of the shared-push rule
(std::ctype::do_tolower's virtual call). The callee's stack arguments are the
declared parameters after the r it takes in registers; only a slot above them
is refused. Adds a thiscall control to the fixture and stage test.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
The option turns ShowMemTag on, so the EL1 bulk tag instructions now lift
with upstream's ShowMemTag=1 LoadMemTag/StoreMemTag loops instead of
ldgm reading as zero; the chapter said they were unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Resolves the stage-corpus count in kuna-base/src/xml.rs (782) and
re-synthesizes docs/baseline-stages.json (main's 4516 plus this PR's 13).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Resolves the stage corpus count in kuna-base/src/xml.rs (main 781 + this
PR's kuna-assert-format-isolate = 782) and re-synthesizes
docs/baseline-stages.json from both sides (main 4516 + 7 = 4523).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…reporting it applied

Three inputs were accepted, reported applied, and left the C as it was
or printed it falsely:
- a `ret` (or any branch/call) address: the RETURN op's target slot
  `#0x0` was taken as the constant; flow-op slot 0 is now excluded;
- a constant whose read-facing type is an enum: it prints as the
  enum's name whatever its format; it is now rejected ("prints as a
  name of <enum>, not as a number"), and the replay check no longer
  counts such a constant as holding the format;
- `char` on a constant wider than 32 bits: the character literal keeps
  only the low 32 bits (0x100000041 printed as L'A'); it is now rejected.

CLI tests pin all three; docs/cli.md and the assertion-plane spec say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
@mahaloz

mahaloz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

[AUTOMATED] Pushed two commits on top of 30050aa:

  • 3bd54fc merges origin/main. Only the stage corpus count in kuna-base/src/xml.rs and docs/baseline-stages.json conflicted.

  • 33178e0: format now rejects three inputs it used to report as applied:

    • A ret, branch or call address. The RETURN op's #0x0 target slot was taken as the constant, so format 0x1471 oct on is_rwx was applied and changed nothing.
    • A constant that prints as an enum name (c == BLUE). It is now rejected with "prints as a name of color, not as a number".
    • char on a constant wider than 32 bits, which printed false C (x == 0x100000041 became x == L'A').

    Each case has a CLI test in assert_format_isolate.rs, and docs/cli.md and spec chapter 00 describe them.

mahaloz and others added 6 commits November 19, 2026 04:19
@mahaloz
mahaloz merged commit a447bee into Noelo-Lab:main Nov 19, 2026
mahaloz added a commit to coleleavitt/kuna that referenced this pull request Nov 19, 2026
Main gained callee (Noelo-Lab#1676) and format/isolate (Noelo-Lab#1679) beside callproto in
the same assertion files: every directive list, Body variant and match arm
keeps both sides, assertions.rs keeps record_rejected_callee_overrides and
record_unbound_call_prototypes whole, project.rs calls both, and
assertion_outcomes runs both restatement passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
@coleleavitt
coleleavitt deleted the fix/assert-format-isolate branch November 21, 2026 06:26
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.

[AUTOMATED] --assert cannot set a constant's display format or keep a variable from merging

2 participants