Repository navigation
Conversation
Add SPARC (SPARC v9, 64-bit, big-endian) to the per-arch PLT decoder in
elf_plt.rs (decode_sparc), the last common Linux/SysV machine with a regular
.plt whose imports kuna still rendered as sub_<addr>. The arch auto-detect
(sparc:BE:64:default) was already wired in language_id_for, but
decode_plt_section had no SPARC arm, so the GOT-name map never reached the
call targets.
SPARC is the odd one out: its .rela.plt R_SPARC_JMP_SLOT relocation r_offset
IS the PLT entry address itself (the dynamic linker rewrites the in-place
32-byte stub at resolution time, per Ghidra's SPARC64_ElfRelocationHandler),
not a separate .got slot. So build_got_name_map's keys are already the call
targets; decode_sparc strides the .plt in 32-byte steps, gates each entry on
the canonical `sethi %hi(...),%g1` veneer head (BE 0x03xxxxxx), and records any
entry that is a known relocation (record(entry, entry, ...)). The reserved
PLT0 header and non-symbol slots fall out by the same self-correcting
cross-check the other arches use.
Fixture plt_sparc64 (source vendored): dynamic SPARC v9 / ELF64 / BE EXEC built
with sparc64-linux-gnu-gcc -O0; main(0x100750) calls puts@plt(0x2021c0) and
printf@plt(0x2021a0). Build needs libc6-dev-sparc64-cross installed in the
kuna-dev container (provenance in fixtures/README.md).
Before: SPARC imports render sub_2021c0(...)/sub_2021a0(...).
After: puts("hello"); printf("%d\n",(int8)a0);
Clean port, not a documented seam. The change is purely additive on the
real-ELF path; the XML datatest oracle is structurally untouched.
Tests: kuna-analysis +1 unit (elf_plt::tests::sparc_plt_decode); kuna-console
+1 e2e (verify_sparc_plt, real decode not skipped). make test 675/675 PARITY
OK; make test-stages 158/158 PARITY OK; make rust-test green.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb
This was referenced Jun 23, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb
mahaloz
added a commit
that referenced
this pull request
Jun 24, 2026
PPC64 ELFv2 (little-endian) was grouped in docs/missing-analyses.md §1 as a "documented seam" — ELFv2 has no `.plt` *code* section (`.plt` is a NOBITS data table, the runtime GOT for imports) and the linker synthesizes the call stubs inline in `.text`. Investigating the real layout (like SPARC, PR #20) shows it is fully tractable at the static load tier: a clean port, not a seam. Each `.text` stub is the canonical ELFv2 veneer std r2,24(r1) addis r12,r2,off@ha ld r12,off@l(r12) mtctr r12 bctr loading a `.plt` slot `TOC_base + (off@ha << 16) + off@l`, where the ELFv2 TOC base is `.got` vma + 0x8000. That slot is named by an `R_PPC64_JMP_SLOT` reloc — the same `got_slot → name` map `build_got_name_map` already builds. Added a PowerPC arm to elf_plt.rs (`decode_ppc_text` / `decode_ppc64_stubs`): after the `.plt*`-section scan, it computes the TOC base, scans `.text` for the 5-instruction stub, reconstructs the slot, and records the stub entry (the `std r2,24(r1)` — the `bl` target) against the matched name. Words are read honoring file endianness so a PPC32/BE arm can slot in later; gated on PowerPc64. No-ops cleanly on every other arch. The `.symtab` carries synthetic `.plt_call.*` symbols at the stub addresses, but `object` classifies them SymbolKind::Unknown (not Text), so the loader's symtab pass skips them — leaving the stub addresses free for the clean puts/printf names. No collision. BEFORE → AFTER (kuna decompile plt_ppc64le main): before: sub_680(v1 + 0x17c); sub_660(v2 + -0x274c0,(int8)a0); after: puts((char *)(v1 + 0x17c)); printf((char *)(v2 + -0x274c0),(int8)a0); Fixture: plt_ppc64le (linked dynamic PPC64le ELFv2 PIE, built in-container with powerpc64le-linux-gnu-gcc -O0 + libc6-dev-ppc64el-cross). Tests: - elf_plt::tests::ppc64_plt_decode (LE real-fixture bytes + a BE word-layout case) - kuna-console/tests/verify_ppc64_plt.rs (e2e, real decode, not skipped) Docs: analysis-port-log Increment 26, plt-got work-list row, missing-analyses §1 PPC note (now resolved), fixtures/README provenance. Gates: make test 675/675 PARITY OK; make test-stages 158/158 PARITY OK; make rust-test green. Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
mahaloz
added a commit
to borancar/kuna
that referenced
this pull request
Nov 16, 2026
A pop its returns prove is applied only when every call in the function has one, so a function with a call the walk cannot settle leaves all of them to the solver, which guesses that an internal callee pops nothing. Stating the block call's pop can settle the last such call, but the other calls' proven pops stayed guesses: in Crackme Noelo-Lab#4 0x41cb90 a `__thiscall` call ending in `ret 4` was taken to pop nothing, every slot after it moved by 4, and the expanded call printed `&Stack00000000` for the out parameter MSVC keeps in a dead parameter slot, with `return 0` folded from the store before the call. Once the stated pops leave every call settled, the proven ones are stated too: that function now prints `a1 = NULL; sub_4217a0(&a0[0xb],&a1,...,&v1,0); return (unsigned int)a1;`, as the disassembly reads. byvalreuse_pe_i386 gains settle/note; REPFRAMECOPY Noelo-Lab#20 fails without this. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz
added a commit
that referenced
this pull request
Nov 22, 2026
pushan_vm2_x86_64 gets a SEL handler that computes the next VPC
arithmetically from the low bit of the top of stack and from a comparison
below it (no flag test, as VMProtect's vJCC), and f_sel: x = a0 < 5 stored as
1 or 0 on two paths that join, then SEL on x and a1 < 3. The join merges x
into a symbol recorded as {0, 1}; without the symbol split the VPC stays an
ite over a byte of it and the next dispatch is unresolved (bin before
5e1e0ab0a: "incomplete: 1 unresolved computed jump"); with it all three
returns are recovered. New opcode and program are appended so every other
program's bytes, the data symbols and the existing outputs are unchanged.
Stage kuna-pushan-sound #23 pins the three returns, #20 now counts 17
devirtualized functions; baseline-stages re-recorded (4955 passing keys).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQR2hseBprKvbvZRUv
mahaloz
added a commit
that referenced
this pull request
Nov 24, 2026
[AUTOMATED] Themida decodes a VM-context offset k through a key as x ^ ((x & ~k) + (~x & k)) with x = key + c, which is k whatever the key holds. When the key is a merge symbol (one non-pointer variable), ExprArena::affine_probe's three probe points never accept a constant and the identity test was not consulted for one variable, so the access went to an unknown address. The emitter kept it as a load of the cell's memory, the decompiler's own rules placed that load on the cell, and every store to the cell had been privatized into a register: the body read the cell's file contents. newstar_infect_themida passed dat_4651ac - 0x32c to CopyFileW instead of the frame buffer; just_if_themida lost the store of &input into the VM register that becomes RDX, so the emulated scanf got the caller's RDX (plus a .themida global store). - affine_probe: a one-variable expression the points leave open goes to identity_probe, and only a constant answer is taken from it (as for several variables). Mirrors angr's CFGVMDeobfuscation._ctf_eval_state_one (solver.eval_upto(expr, 2): an address with a single solution is that constant). - Emitter::access_addr: privatization (plan_private, private_vn) uses the address the emulation's load/store placed through the probe, not only a literal constant, so the two views of a cell cannot mix that way. - Fixture f_ctx (value in a context cell of .vmp0, read back through a key-decoded offset) and stage assertion #30; #20 count 23. Before: `return *(ulong *)(((v1 + 0x3350fa94U ^ ...) & 0x18) + 0x4044b0)`; after: `return a0 + 1;`. Baseline 5046. - Debug: KUNA_PUSHAN_LOG_SYM adds each unplaced access's probe result and address expression to the KUNA_PUSHAN_LOG_INSNS node dump. Co-Authored-By: Claude Fable 5.2 <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Nov 24, 2026
… context accesses keep their cells memory [AUTOMATED] A devirtualized body that still reads or writes the protector's own memory computes with VM state as if it were program data. Before, nothing said so: newstar_infect_themida, just_if_themida, netsky_themida and zlib_themida (and, run to completion, libpng/smt/ netsky/zlib themida) printed with no incomplete warning. - warn_protector_state (kuna_pushan.rs), run once the body is decompiled next to warn_unshown_escapes: counts, over the final ops, reads/writes of memory inside PushanProgram::protector (the candidate interpreter sections the exploration ran VM code in) and loads/stores whose address is a constant inside them plus an offset; MULTIEQUAL and INDIRECT/COPY that keep a location in place count nothing, and import slots a call went through (PushanProgram::slots) are the program's own. Header: "pushan: incomplete: N reads and M writes of the protector's own memory left in the body". No option: a strict correctness report. - Emitter::access_window: an access the emulation could not place whose address is a constant inside the protector's sections plus terms with bounded possible bits blocks privatization of every cell of that window, so a VM cell an unplaced access may reach is never split between a private register and memory. - Data (48 targets, default; Tigress sub30): with the net alone (no fixes) it fires on exactly the four unwarned WRONG Themida rows above and on already-warned rows; never on a VMProtect row, a SAME/WEAKER Themida row (newstar_backdoor, blaster dolphin/tiger, just_if dolphin/tiger, loop) or a Tigress sample. - Fixture f_ctxi (two context cells, one read at an offset the argument selects) and stage assertion #31; #19 count 4, #20 count 24. Baseline 5047. Co-Authored-By: Claude Fable 5.2 <[email protected]>
mahaloz
added a commit
to sjkim1127/kuna
that referenced
this pull request
Nov 24, 2026
The alignment-pad exception read a store of the last argument register beneath a higher register anywhere in the entry as proof the function is not variadic. clang -Oz reserves stack by pushing dead registers and then saves the variadic registers: `sub sp, Noelo-Lab#12; push {r3, r4, lr}; stm r0!, {r1, r2, r3}` (or `str r3, [sp, Noelo-Lab#20]`). Its sqlite3_mprintf then handed sqlite3_vmprintf its save area and took r1-r3 as three more parameters. The entry walk now also records the register bytes a multi-register store writes as its highest register, and the pad counts only when the register is stored no other way (not alone, not as the highest of a store). The check is only ever narrower than before, so every call it changes returns to the output it had before the pad exception. Stage gh1922-pushpad-caller-readarg-thumb.xml gains #4, a clang -Oz shaped variadic caller (pad push plus stm save) that must still decline. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
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
Adds SPARC (SPARC v9, 64-bit, big-endian) to the per-arch PLT decoder in
elf_plt.rs(decode_sparc), so a SPARC ELF's libc imports render by name instead ofsub_<addr>. SPARC was the last common Linux/SysV machine with a regular.pltwhose imports kuna still left anonymous. The arch auto-detect (sparc:BE:64:default) was already wired inloadimage_object::language_id_for; this fills the missingdecode_plt_sectionarm.Why SPARC is the odd one out (clean port, not a seam)
Every other supported arch decodes the stub's indirect jump to find a separate
.gotslot, then matches that slot against the dynamic-relocation name map. SPARC doesn't work that way: its.rela.pltR_SPARC_JMP_SLOTrelocationr_offsetis the PLT entry address itself — the dynamic linker rewrites the in-place 32-byte stub at resolution time rather than redirecting through a GOT word (confirmed against Ghidra'sSPARC64_ElfRelocationHandler). Sobuild_got_name_map's keys are already the call targets the decompiler sees.decode_sparcwalks the.pltin 32-byte strides, gates each entry on the canonicalsethi %hi(...),%g1veneer head (BE0x03xxxxxx), and records any entry that is a known relocation (record(entry, entry, …)). The 4-slot (0x80-byte) reserved PLT0 header and the non-symbol slots fall out by the same self-correcting cross-check the other arches use.This is a clean win, not a documented seam — SPARC's
.pltis regular and statically decodable.Before / After
kuna decompile plt_sparc64 main:Before (no SPARC decoder — hits the PPC/MIPS
_ => {}fallthrough):After:
Fixture
plt_sparc64(sourceplt_sparc64.cvendored alongside): a dynamic SPARC v9 / ELF64 / big-endian EXEC built withsparc64-linux-gnu-gcc -O0(not stripped).main(0x100750) callsputs@plt(0x2021c0) andprintf@plt(0x2021a0); both areR_SPARC_JMP_SLOTrelocations in.rela.pltwhoser_offsetequals the entry address. Thekuna-devimage shipssparc64-linux-gnu-gccbut not the SPARC libc dev package; the build installslibc6-dev-sparc64-crossin a single--user rootcontainer invocation (provenance infixtures/README.md).Tests (e2e actually decoded, not skipped)
kuna-analysis+1 unit:elf_plt::tests::sparc_plt_decode(the 32-byte strider over a header + three synthetic veneers).kuna-console+1 e2e:verify_sparc_plt::sparc_plt_calls_are_named_in_decompiled_c, modeled onverify_riscv64_plt.rs, same specs-absent skip guard. It assertsmaindecoded (real, not skipped) andputs(/printf(are named whilesub_2021c0/sub_2021a0are gone. The SPARC.slais built, so the skip guard was not hit.Gates
make test— 675/675 PARITY OKmake test-stages— 158/158 PARITY OKmake rust-test— green (incl. the newverify_sparc_plt+sparc_plt_decode)The change is purely additive on the real-ELF path (a new
decode_sparcarm + a new fixture + a new console e2e), so the XML datatest oracle is structurally untouched.Docs
docs/analysis-port-log.md—### Increment 24 — SPARC PLT import-name recovery;plt-gotwork-list row updated.docs/missing-analyses.md§1 — SPARC moved off the PPC64/MIPS seam row to the decoded list.fixtures/README.md—plt_sparc64row + provenance (sparc64-linux-gnu-gcc).🤖 Generated with Claude Code
https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb