Skip to content

[AUTOMATED] Stop discovering function entries in the middle of real functions on stripped ARM images - #1900

Merged
mahaloz merged 7 commits into
mainfrom
feat/falseentry
Nov 23, 2026
Merged

mahaloz merged 7 commits into
mainfrom
feat/falseentry

Conversation

@mahaloz

@mahaloz mahaloz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

On stripped ARM images, function discovery plants entries in the middle of real functions: a frame push after an early test, a block the compiler moved past the return, a switch case. The real function is cut at that entry and the rest is decompiled as a separate function.

$ kuna functions decompiler/crates/kuna-analysis/tests/fixtures/cortexm_falseentry_le32 | cut -f1 | tr '\n' ' '
0x8008000 0x8008020 0x8008026 0x8008040 0x8008046 0x8008060 0x8008068 0x8008070 0x8008084
$ kuna decompile-all decompiler/crates/kuna-analysis/tests/fixtures/cortexm_falseentry_le32
// Function: sub_8008026 @ 0x8008026          <- the second half of sub_8008020
int sub_8008026(int a0)
{
  return a0 * (a0 + 1);
}
// Function: sub_8008084 @ 0x8008084          <- the handler at 0x8008080, without its null test
unsigned int sub_8008084(unsigned int a0,unsigned int a1,unsigned int a2,void (*a3)(void))
{
  (*a3)();
  return a0;
}

With this change 0x8008026, 0x8008046 and 0x8008084 are no longer listed, and the handler decompiles from its real start:

// Function: sub_8008080 @ 0x8008080
void * sub_8008080(void *a0)
{
  if (((void (**)(void))a0)[1]) {
    (*((void (**)(void))a0)[1])();
    return a0;
  }
  return NULL;
}
  • A new discovery pass (listing/kuna_falseentry.rs) runs after all entry oracles and drops an entry that nothing in the image vouches for (no direct call, symbol, entry oracle, code pointer or call table) when live code runs into it by fall-through or a predicated skip, or when the preceding function's own flow reaches it by a conditional branch or a switch case (or runs into it while also branching past it).
  • Code is live only through fall-throughs that provably continue, so a literal pool after a call that never returns does not run into the next function, and b to the next address stays a tail call.
  • When the code that runs into a dropped entry starts at a code pointer no oracle accepted, that pointer target becomes the entry.
  • It applies where the walk's functions are committed (listing + funcstart_patterns, the non-x86-64 driver default). x86-64 output does not change.

Tests: kuna-console/tests/verify_falseentry.rs and tests/cli/false-entry-inside-shrink-wrapped-function.json on the new fixture (both fail on main), plus unit tests in the module and in kuna_poolextents. On 63 stripped ARM decbench binaries checked against their unstripped twins, discovered entries at no symbol drop from 1,616 to 708, no symbol start is lost and 10 are added. On the decbench O2 corpus 71 more functions match the source's control flow exactly (gained 76, lost 5; four of the five lost were empty truncated bodies that matched by accident), and functions carrying the funcboundflow truncation warning drop from 336 to 94 (most of the rest follow a call that never returns).

Model: anthropic/claude-opus-5-5

🤖 Generated with Claude Code

https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU

mahaloz and others added 7 commits November 23, 2026 10:08
The prologue-pattern scan, the ARM frame scan and the aif gap walk plant
entries inside real functions on stripped images (shrink-wrapped frame
pushes, variadic register saves, switch cases, blocks moved past the
return). funcboundflow then cut the real function at the planted entry.

A new Listing consumer (listing/kuna_falseentry.rs) reads the finished
partition and every entry stream and names, for the commit to drop, each
unattested entry that live code runs into, that the preceding entry's own
flow reaches by a conditional branch or switch case, or that it runs into
while branching past it. A code pointer whose code runs into a dropped
entry becomes the entry in its place. Always on where the walk's
functions are committed (non-x86-64 drivers); no option.

[AUTOMATED]

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
A function that dispatches through a table (`blx r3`) or tail-jumps
through a register never proved a return under the pool-extent trust
notion, so the code after a call to it was not live and the case labels
and shrink-wrapped pushes behind it stayed entries. The interior-entry
scan now uses a lenient variant of that notion; pool extents keep the
strict one. Also shortens the CLI probe's notes to the schema limit.

[AUTOMATED]

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
…'s cut

The scan cached each decoded step by value and cloned it on every read;
it now shares them and hashes its visited sets, which halves its cost on
large Cortex-M images.

function_warnings_cli pinned register_tm_clones being cut at the
`sub esp,4` inside it, an entry the prologue scan planted and that is no
longer discovered. The test now declares that entry, so it keeps
checking where the drained funcboundflow warning lands.

[AUTOMATED]

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
The second half of an_empty_body_s_drained_warning_is_a_body_warning_in_every_language
decompiles register_tm_clones again without the declared entry; it now
passes the same --define-function.

[AUTOMATED]

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
@mahaloz
mahaloz merged commit 14af284 into main Nov 23, 2026
9 checks passed
@mahaloz
mahaloz deleted the feat/falseentry branch November 23, 2026 11:51
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