Repository navigation
incorrect-duplication-chcon-a0e113: name-match known-no-return externs in ET_REL .o (noreturn_externmatch, DIV-12) - #91
Conversation
…s in ET_REL .o (option noreturn_externmatch, DIV-12) Closes the angr test_decompiling_incorrect_duplication_chcon_main gap on coreutils chcon.o::main: kuna emitted ~90 lines of garbage after the no-return __stack_chk_fail() call (inter-function alignment padding 00 00 -> add [rax],al decoded as live code). angr emits none. Root cause: __stack_chk_fail is in the vendored ELF known-no-return list, but in an ET_REL .o it is an undefined extern (symtab address()==0, no PLT), so the address-keyed noreturn_known scan emits no fact. relocobjects installs a FunctionSymbol at a synthetic target (the call prints the name) but no no-return flag, so flow runs into the padding. New option noreturn_externmatch (S2 flow-follow, ElementId 4103): the query_call_no_return seam also reports no-return when the callee name matches the same vendored list (include_str! of kuna-analysis/data/ElfFunctionsThatDoNotReturn, same leading-_ strip + global/std namespace guard). flow.rs ORs it at the artificial-halt site. A no-op on a normal ELF (proto flag already set); reaches the ET_REL extern the address scan structurally misses. Default-ON (DIV-12): clean 0/675 ablation, 23% faster on the target (less dead padding to decompile), correctness fix, no risk class beyond the already default-on noreturn_known. Gates: catalog OK; datatest PARITY OK (675/675); test-stages PARITY OK (193/193, +3 via ghangr-incorrect-duplication-chcon-a0e113.xml); rust-test green (3 new matcher unit tests; count/golden fixtures bumped). PE multiformat test updated to disable both name-based no-return gates to see raw dead code. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
#90 ( Key differences for the reviewer to weigh:
Suggested resolution: keep ONE option (one name, one default decision) and close/rebase the other. If default-ON is accepted, this PR's DIV-12 + the |
) Union-resolve so noreturn_externmatch coexists with #90's noreturn_extern (both name-match the ELF no-return list at the same flow seam). Deconflicted: - ElementId 4103 -> 4104 (4103 taken by #90's noreturn_extern on main) - DIV-12 -> DIV-13 (DIV-12 taken by main's region structurer); renumbered in divergences.md, architecture.rs, stages.toml, the module, the testcase XML, UPSTREAM.md, stage-mapping.md, PROGRESS.md, feature record/plan/pr_body - decompile_drive.rs query_call_no_return: BOTH gated checks kept (noreturn_extern_match + noreturn_extern_calls) - s2_lift/mod.rs: both modules declared - stages.toml header surface=95, settable=56 (33 stage-model knobs); +1 surface +1 settable - kuna_stages/tests.rs: settable 56, surface 95, json-comma 55, live-value 25; test fns renamed (settable_count_is_56 / live_value_present_for_25_suppressed_for_31) - catalog_bytecompat.rs: fixture_has_all_56_settables - kuna-base/xml.rs corpus count 147 (83 datatests + 64 stage tests) - kuna-catalog.xml: source_decompiler angr count 16 (both noreturn_extern + externmatch) - #90's ghangr-noreturn_extern.xml: pass 1 now also sets `noreturn_externmatch off` to isolate the noreturn_extern toggle (externmatch default-on else bounds it first) - regenerated stage_catalog.json fixture, docs/assertions.md, baseline-stages.json (208 keys) Gates green: kuna catalog --check OK; make test 675/675 PARITY OK; make test-stages 208/208 PARITY OK. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
…uplication-chcon-a0e113
Union-resolve so crossjumprevert (opt-in default-off) coexists with #90's noreturn_extern and #91's noreturn_externmatch on main. Deconflicted: - ElementId 4103 -> 4105 (4103=noreturn_extern, 4104=noreturn_externmatch on main) - stages.toml header surface=95, settable=57 (34 stage-model knobs); +1 settable - kuna_stages/tests.rs: settable 57, surface 95, json-comma 56, live-value 25 (crossjumprevert has no live reader, in the suppressed allowlist); test fns renamed (settable_count_is_57 / live_value_present_for_25_suppressed_for_32) - catalog_bytecompat.rs: fixture_has_all_57_settables - kuna-base/xml.rs corpus count 148 (83 datatests + 65 stage tests) - kuna-catalog.xml: source_decompiler angr 17, change_kind structure-recovery 9 (both add crossjumprevert) - verify_w8_fw_universalaction.rs auto-merged: 262 leaves (252 C++ + branchflip + gotoreduce + crossjumprevert + 7 headers); universalaction/seams/architecture/block wiring of revert_cross_jumps preserved alongside the noreturn_extern* additions - regenerated stage_catalog.json fixture, docs/assertions.md, baseline-stages.json (212 keys) Gates green: kuna catalog --check OK; make test 675/675 PARITY OK; make test-stages 212/212 PARITY OK. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
incorrect-duplication-chcon: name-match known-no-return externs in ET_REL
.ofilesCloses the gap angr's
test_decompiling_incorrect_duplication_chcon_mainexposes on coreutilschcon.o(main): kuna emitted ~90 lines of garbage after the no-return__stack_chk_fail()call — the inter-function alignment padding (
00 00 …, decoded asadd byte ptr [rax], al)decompiled as live code. angr emits none.
See
docs/features/incorrect-duplication-chcon-a0e113/analysis.mdfor the full analysis.
Root cause
stack_chk_failis in kuna's vendored ELF known-no-return list (option noreturn_known,default-on), so on a normal dynamically-linked ELF the call is marked no-return and the dead
fall-through never decoded. But in an ET_REL
.o,__stack_chk_failis an undefined extern:its
.symtabentry hasaddress()==0and there is no PLT stub, so the address-keyednoreturn_knownscan emits no fact for it. Therelocobjectsloader installs aFunctionSymbolnamed
__stack_chk_failat a synthetic target (the call prints the name) but no no-return flag isset — so flow runs off the end into the padding.
Mechanism
New
option noreturn_externmatch(S2 flow-follow, ElementId 4103). When set, theFlowEnvironment::query_call_no_returnseam (infra/decompile_drive.rs) also reports no-returnfor a callee whose name matches the same vendored ELF list —
flow.rsORs this with the protoflag at the artificial-halt site, so a name match plants the halt and the trailing padding is never
decoded. The matcher (
s2_lift/kuna_noreturn_externmatch.rs)include_str!s the same listnoreturn_knownuses (kuna-analysis/data/ElfFunctionsThatDoNotReturn) and applies the sameleading-
_strip + global/stdnamespace guard, so it adds no risk class beyond the alreadydefault-on
noreturn_known; it merely reaches the ET_REL extern the address scan structurallymisses. A no-op on a normal ELF (the proto flag is already set).
Option & default
option noreturn_externmatch on|off— flip viakuna decompile … --option noreturn_externmatch off.change with it default-ON, and it is ~23% faster on the target (
chcon.o::mainmedian449.8 ms → 344.3 ms, n=5 — there is less dead padding to decompile). Set OFF to restore the prior
byte-identical rendering.
option noreturn_known offno longer alone restores the post-exit/__stack_chk_faildead code (this feature is a second name-based gate); disable both to see the raw fall-through.
Verification
kuna catalog --check→ catalog OKkuna test --datatests --baseline docs/baseline.json→ PARITY OK (675/675)make test-stages→ PARITY OK (193/193;tests/stages/ghangr-incorrect-duplication-chcon-a0e113.xml, +3)make rust-test→ green (3 new matcher unit tests; count/golden fixtures bumped)🤖 Generated with Claude Code
Before / after —
maininchcon.oReal captured kuna output on the function this feature was built for, with
option noreturn_externmatchflipped. Ported from angr — test_decompiling_incorrect_duplication_chcon_main; angr CLE/CFGFast extern no-return tagging; main.noreturn_externmatch offnoreturn_externmatch on(default)kuna — before (
option noreturn_externmatch off)kuna — after (
option noreturn_externmatch on)angr reference (the goal, v9.2.213)