Repository navigation
[AUTOMATED] feat(p1): fdeinterior - a C++ landing pad is not a function, it is a point inside one (-1030 spurious entries, 0 real lost) - #263
Merged
Conversation
mahaloz
force-pushed
the
feat/fdeinterior
branch
3 times, most recently
from
August 5, 2026 05:36
6ec5564 to
902b9fa
Compare
…on, it is a point inside one (-1030 spurious entries, 0 real lost) A kuna FunctionSymbol is an entry address with no extent: Database::add_function takes an address and find_function answers "is a function registered AT this address", never "is this address INSIDE one". Every discovery oracle's dedup is therefore an equality test, and a candidate 12 bytes into a body passes it. Three oracles do exactly that on ordinary compiler output, and --mode auto turns all three on for anything under 500 KiB by resolving to `aggressive`: eh_frame_full promotes each .gcc_except_table landing pad to a top-level function (it is designed to), aif starts one at the first undecoded byte of an unwinder-only region (routinely not an instruction boundary), and the prologue patterns match an aligned `push rbp; mov rbp,rsp` inside a larger body. On a g++ -O0 probe, probe_try_catch [0x2acf,0x2ba7) yields sub_2b0b / sub_2b1a / sub_2b8a, all three surviving stripping, and sub_2b0b decompiles with an uninitialised rbp so every local is a garbage dereference. IDA Pro 9.2 gives get_func(0x2b0b).start_ea == 0x2acf; that is the model. .eh_frame carries the missing extent: each FDE records ONE function's [pcBegin, pcBegin+pcRange). kuna_fdeinterior.rs reuses scan_eh_frame_starts's record walk and adds the one field it skips - pcRange, decoded with the CIE R encoding's format bits only, since it is a length - and the commit filters the FULLY MERGED entry set, after the deferred Listing consumers, because one producer is aif. Not every FDE describes one function: the linker gives the whole PLT a single FDE and every stub inside it is real (the first prototype deleted every import). A range is used only when no other named function start, no other FDE pcBegin, and no .plt/.plt.sec/.plt.got/.iplt/.MIPS.stubs section falls inside it. An entry AT an FDE start is never suppressed, so oracle 3's own product is preserved. Gated and default-ON (DIV-61) because the measurement leaves no judgment call. kuna functions off vs on over 72 stripped decbench x86-64 binaries, every dropped entry classified against the matching unstripped binary's FUNC symbols (address and size): 36,568 -> 35,538 entries, 1,030 dropped, 0 added, ZERO that are a real function's entry, ZERO that carry a name, all 1,030 strictly inside a real body, 52 not even an instruction boundary. C++: big_O0.stripped 599 -> 449 (25% of the list was junk), probe_O0.stripped 189 -> 162. Static glibc --mode aggressive 1,358 -> 1,087 with 0 real and 0 named lost. PE and ET_REL are inert. Whole-binary decompile-all on eight binaries: 0 functions added, 0 surviving bodies changed and 0 surviving names changed. #259 (tailcallentry) non-regression, measured on its own corpus and surface with --option tailcallentry on: all 98 ARM images, entries 57,578 -> 57,578, zero images changed - bare-metal ARM unwinds through .ARM.exidx and only 3 of 98 carry any .eh_frame FDE. The same argument covers draft PR #239. Disclosed interaction: eh_frame_full's landing-pad product is now constrained by this gate, so verify_eh_frame_full's option-on arm flips fdeinterior off to keep testing what the LSDA decode produces. Rebased onto 890096b (#264 cppproto, DIV-60) on 1cff8ec (#262 cppcallnames, DIV-59), and fully re-measured on that tree rather than carried forward, because neither is inert here. #264 recovers out-of-line C++ member and namespace definitions from DWARF, so an unstripped C++ binary now carries far more named function symbols - the input to this option's "range holds no other named function start" condition. The invariant holds against the new symbol set: big_O0 now has 447 of its 450 surviving entries named (probe_O0 161 of 163) and the filter still drops 150 with 0 real and 0 named lost, while the stripped counterparts are unchanged at 449 / 162 (verified, not assumed - no DWARF there). Both arms of every comparison are the same build, so #262's renaming and #264's MAX_TYPE_DEPTH change cancel; coreutils fmt, the binary #264 altered, was decompiled whole in both arms to keep the two unconflated (198 -> 191 entries, 0 surviving bodies changed; fmt-O2 151 -> 151). Catalog counters were DERIVED from a fresh post-rebase catalog capture, not incremented: 91 settables, 20 core / 41 transform / 30 analysis, 90 catalog rows. #264 and this PR had made an identical off-by-one edit to the same three assertions, so the merge resolution would have shipped the wrong number had it been trusted. phase_catalog.json re-captured and docs/options.md regenerated from the post-rebase build; no stages XML added, so no corpus count or stages baseline moves. Bundle: docs/features/fdeinterior/. Gates: make test 675/675 PARITY OK (no re-pin, no per-test opt-out), make test-stages 394/394 PARITY OK, make rust-test green, make check-spec OK (strict), kuna catalog --check OK. Speed: timeit -29.28% (15 samples); interleaved medians -21.68% to +0.06% (functions) and -4.22% / -4.89% (decompile-all). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01McQC7imaNfzj5k5AVumSYN
mahaloz
force-pushed
the
feat/fdeinterior
branch
from
August 5, 2026 05:39
902b9fa to
2ba9bff
Compare
This was referenced Aug 5, 2026
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.
A kuna
FunctionSymbolis an entry address with no extent.Database::add_functiontakes an address and
find_functionanswers is a function registered AT this address,never is this address INSIDE one — so every discovery oracle's dedup is an equality test,
and a candidate 12 bytes into a body sails through it.
Three oracles do exactly that on ordinary compiler output, and
--mode autoturns all threeon for anything under 500 KiB by resolving to
aggressive:eh_frame_fullpromotes each.gcc_except_tablelanding pad to a top-level function— it is designed to ("a landing pad sits mid-function"),
aifstarts one at the first undecoded byte of an unwinder-only region, which isroutinely not an instruction boundary,
push rbp; mov rbp,rspinside a larger body.On a
g++ -O0probe,probe_try_catch[0x2acf, 0x2ba7)yields three extra entries, andthey survive stripping, so a per-function benchmark scores them:
A mid-frame entry inherits its parent's live frame pointer, so every local is a
dereference of an undefined value:
The rivals: IDA Pro 9.2 gives
get_func(0x2b0b).start_ea == 0x2acf— the pad belongs tothe function whose FDE covers it. Ghidra 12.1 returns no containing function at all here
(its
GccExceptionAnalyzererrored on this PIE — a Ghidra bug, not a model). IDA's model isthe target.
The fix
.eh_framecarries the extent kuna lacks: each FDE records one function's[pcBegin, pcBegin + pcRange)by construction (one.cfi_startproc/.cfi_endprocpair).So a discovered entry strictly inside an FDE body is not a function, on the unwinder's own
authority.
analyzers/entry/kuna_fdeinterior.rsreusesscan_eh_frame_starts's record walk and addsthe one field it skips —
pcRange, decoded with the CIERencoding's format bits only(it is a length, so the pc-relative application must not be applied). The commit filters the
fully merged entry set, after the deferred Listing consumers, because one of the three
producers is
aif.Not every FDE describes one function: the linker gives the whole PLT a single FDE and
every stub inside it is real. The first prototype deleted every import. A range is therefore
used only when no other named function start, no other FDE
pcBegin, and no.plt/.plt.sec/.plt.got/.iplt/.MIPS.stubssection falls inside it. An entry at anFDE start is never suppressed, so oracle 3's own product is preserved.
Option decision: gated, default-ON (DIV-61)
Changing which functions exist is output-changing, so it ships behind a named option rather
than as a bare bug fix. It is default-ON because the measurement leaves no judgment call:
across 72 C binaries, 8 C++ probes, a static glibc image, 2 PEs, an ET_REL
.oand 98 ARMimages, not one removed entry is a real function and not one carries a name, and nothing
is ever added.
--option fdeinterior offrestores the previous discovery set exactly(asserted end-to-end).
The sweep — every disappearing entry classified
kuna functionsoff vs on over 72 stripped x86-64 ELF binaries (decbench O0+O2: coreutils,bash, gzip, tar, grep, diffutils, openssh, e2fsprogs, gnutls, dpkg, zlib, bzip2, findutils,
kmod). Each dropped entry is classified against the matching unstripped binary's
FUNCsymbols — address and size, so "inside a real body" is checkable.
C++ (where the landing pads are):
probe_O0.strippedprobe_O2.strippedbig_O0.stripped(STL + exceptions)big_O2.stripped(--mode aggressive)25% of
big_O0's reported function list was junk.--mode aggressive.plt/.ipltuntouchedmydoom.exe(PE)dexter.dll(PE)big.o(ET_REL,relocobjects)pcBeginis section-relative 0, so the overlapping set is dropped wholesaleEmitted C — whole-binary
decompile-all, comparing every surviving function:big_O0.stripped(C++)big_O0(C++, unstripped)probe_O0.stripped(C++)probe_O0(C++, unstripped)gzip(C, O0)b2sum(C, O0)fmt(C, O0) — the #264MAX_TYPE_DEPTHtargetfmt(C, O2)A pure removal: of the functions that survive, not one changes its text or its name.
#259 (
tailcallentry) non-regression — measuredSame corpus and same surface
docs/features/tailcallentry/used(
kuna functions --mode aggressive), with--option tailcallentry on,fdeinterioroff vs on, over every ARM image in the three decbench optimisation trees:
Byte-identical entry sets on all 98 images. Structural rather than lucky: bare-metal ARM
unwinds through
.ARM.exidx, and only 3 of 98 images carry any.eh_frameFDE (riot-oshello-world.elf, 2 FDEs, containing no discovered entry). The same argument covers thein-flight ARM entry-granularity work in draft PR #239 — it operates on a population this
option cannot see.
Rebased onto #264, and re-measured rather than carried forward
This branch sits on
890096b6(#264cppproto, DIV-60), itself on1cff8ecb(#262cppcallnames, DIV-59). Neither is inert with respect to this change, so both werere-measured:
[AUTOMATED] feat(p1): cppproto - ingest C++ function prototypes from DWARF #264 ingests C++ prototypes from DWARF through
DW_AT_specification, recoveringout-of-line member and namespace definitions that were previously dropped entirely. On
an unstripped C++ binary far more addresses now carry a real named function symbol — which
is exactly the input to this option's "range holds no other named function start"
condition. The invariant holds against the new symbol set:
big_O0big_O2probe_O0probe_O2The stripped counterparts are verified unchanged at 449 and 162 entries (no DWARF for
cppprototo read), not assumed.[AUTOMATED] fix(p9): cppcallnames - render a C++ callee's qualified name at the call site (DIV-59) #262 changed C++ callee-name rendering everywhere. Both arms of every off/on comparison
are the same build, so it cancels; the
surviving_names_changed/NAMED_LOSTcountersare 0 everywhere.
[AUTOMATED] feat(p1): cppproto - ingest C++ function prototypes from DWARF #264 also altered 9 plain-C functions in coreutils
fmtviaMAX_TYPE_DEPTH, sofmtwas decompiled whole in both arms specifically to keep the two effects unconflated —
198 → 191 entries with 0 surviving bodies changed, and
fmt-O2 151 → 151 with none.Catalog counters were derived, not incremented. #264 and this PR had made an identical
off-by-one edit to the same three assertions, so the merge resolution would have shipped the
wrong number had it been trusted. Captured from a fresh post-rebase
phase catalogandcounted: 91 settables, 20 core / 41 transform / 30 analysis, 90 catalog rows (the naive
merge would have left 90/29/89).
phase_catalog.jsonre-captured anddocs/options.mdregenerated from the post-rebase build; the assertions were then verified by running them.
No
tests/stages/*.xmlis added, so neither the corpus file count nordocs/baseline-stages.jsonmoves.Disclosed interaction
eh_frame_full's product is now constrained by this gate: with both on, a landing pad insidea single-function FDE is no longer committed. That is the intended composition (the pad is
the thing being rejected). The existing
verify_eh_frame_fulle2e test now flipsfdeinterior offin its option-on arm so it keeps testing what the LSDA decode produces.Gates (all re-run after the #264 rebase)
make testmake test-stagesmake rust-testmake check-spec--strict)kuna catalog --checkThe datatest corpus is structurally untouched: the XML
<binaryimage>bootstrap never runsthe analyzer tier.
Speed
The added work is one linear
.eh_framerecord walk — the same section the always-onFDE-pcBegin oracle already reads — plus one binary search per discovered entry. The savings
are the suppressed entries never being decompiled, so every measurement is negative or
neutral.
scripts.pipeline.timeit,probe_O0probe_try_catch, 15 sampleskuna functionsgzip-O0, 15 pairskuna functionstar-O0, 15 pairskuna functionsbig_O0.stripped, 15 pairskuna functionsstatic glibc, 11 pairsdecompile-allgzip, 9 pairsdecompile-allb2sum, 9 pairsHonest caveat: an 11-sample
timeitrun taken while the workspace suite was saturating thebox reported +4.67% and did not reproduce on an idle box.
Tests
decompiler/crates/kuna-console/tests/verify_fdeinterior.rs, two-pass over the vendoredeh_lsda_x86_64fixture (guarded= FDE[0x4012d6, 0x40137a), catch dispatch at0x4012e2),eh_frame_fullon in both arms:fdeinterior off—sub_4012e2registers and decompiles (the bug, and the proof thatoffrestores the old set),sub_4012e2is absent while its FDE ownersub_4012d6still decompiles,Plus module unit tests for the strictness of
is_interiorand the empty-bodies no-op. Notests/stages/*.xml: the XML datatest path never runs the analyzer tier, so the corpuscannot express this — the same reason
tailcallentry(#259) andcortexmvectorsshippedcross-crate e2e tests instead.
Bundle:
docs/features/fdeinterior/. Spec:docs/spec/01-program-prep.md§1.5. DIV-61.Captured before / after — the vendored
eh_lsda_x86_64fixtureThe visible product of this feature is which functions exist, so the capture is the
function list, not one body at a forced address. (
scripts.pipeline.prdemodecompiles with--addr, which produces a body at an address whether or not it is in the discovered set, soits two panes would be identical here by construction — this replaces it.)
guardedoccupies the FDE[0x4012d6, 0x40137a); its.gcc_except_tableLSDA names thecatch dispatch at
0x4012e2. Both runs pass--option eh_frame_full on.before —
kuna functions eh_lsda_x86_64 --option eh_frame_full on --option fdeinterior off(25 entries)after — the same with
--option fdeinterior on(the default, 21 entries)Removed:
0x4012bf,0x4012e2,0x401352,0x401366— every one strictly inside asingle-function FDE body. Added: none.
0x4012d6(the FDE start,guarded) and every namedPLT stub survive.