Repository navigation
[AUTOMATED] feat(analysis): datasyms - import ELF OBJECT symbols so libc globals render by name (DIV-76) - #305
Merged
Merged
Conversation
…hat names libc globals (DIV-76) [AUTOMATED] Completes GH-184. The mechanism -- reading the STT_OBJECT half of the .symtab/.dynsym walks and installing each defined, named, non-zero-st_size entry as a named undefined<size> global, so a copy-relocated libc extern (stderr, stdout, stdin, optind, optarg, __progname) and a stripped/DWARF-less binary's own statics render by name instead of dat_<addr> -- landed flagless in 7517e39 (DIV-26), against the standing anything-that-changes-emitted-C rule, with no catalog row, no witness tests, and spec prose reading "carries no flag". This PR adds the gate and the missing collateral: - New settable option `datasyms` (P1/external-refinement, analysis tier, default-ON, DIV-76). Gate shape: the stream is collected at `load file` but committed at `read symbols` (commit_analysis_output arm 4a), AFTER the CLI's option lines on both paths, so the gate is the plain Architecture::analysis_datasyms flag -- no env bridge (unlike relocobjects/i386_pie_plt, which gate load-time layout). The stash drains either way so a second `read symbols` cannot re-commit; off restores the pre-DIV-26 rendering exactly. - kuna-analysis unit test over a vendored copy of tests/bug-repro/faillog (datasyms_faillog_x86_64, md5-identical): pins the fact stream to exactly stdout@0x6160/8, stderr@0x61a0/8, optind@0x6168/4, optarg@0x6180/8 -- no zero-size linker markers, no UND placeholders, no @Version leakage. - kuna-console e2e two-pass pair in verify_loader_data_symbols.rs: default asserts `stderr` (and no dat_61a0) at faillog 0x3320; `datasyms off` asserts dat_61a0 (and no stderr). No stage XML is possible -- the datatest path never constructs an ObjectLoadImage -- so the cargo suite hosts the pair. - Docs: spec 01-program-prep re-worded for the gate; missing-ghidra-analyses §2 records the data-symbol half; history.md DIV-76 row (+ DIV-26 row annotated); options.md regenerated. - Counters re-derived from the built artifact: live catalog 107, catalog_bytecompat 107 + regenerated phase_catalog.json, kuna_phases tests 107 / tiers (23,47,37) / "},\n" 106 / live readers 33 (datasyms joins the PASS_GATES kuna_live_value set); kuna-catalog.xml unmoved (ranged buckets). Verified: default output byte-identical to base on decompile-all --json of faillog/grep/sort/libselinux.so.1; on/off proven on BOTH the in-process decompile-all path and the subprocess decompile path. Gates: make test 675/675 PARITY OK, make test-stages 460/460 PARITY OK, make rust-test green, make check-spec OK, kuna catalog --check OK. Fixes #184 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VBn8vgwoHqPFnnV4ZMApfq
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.
Fixes #184
What this PR does
Completes GH-184 end-to-end. The core mechanism the issue asked for — reading the data half (
STT_OBJECT) of the.symtab/.dynsymwalks and installing each defined, named, non-zero-st_sizeentry as a namedundefined<size>global — already landed on main in 7517e39 (DIV-26), which shipped flagless with the rationale "kuna has never made 'name what the symbol table names' optional". That left the issue open against the repo's standing requirements: no settable option, no catalog row, no faillog-witness tests, and two docs (docs/spec/01-program-prep.mdexplicitly saying "carries no flag",docs/missing-ghidra-analyses.md§2 still functions-only). This PR closes those gaps:datasyms(P1/external-refinement, analysis tier, default-ON, DIV-76) gating the loader data-symbol commit arm. Off restores the pre-DIV-26 rawdat_<addr>rendering exactly.relocobjects/i386_pie_plt(which gate load-time layout), the data-symbol stream is collected atload filebut committed atread symbols(commit_analysis_output, arm 4a), which runs after the CLI'soptionlines on both paths. The gate is the plainArchitecture::analysis_datasymsflag consulted at the commit — the same stash-at-load/gate-at-commit shape ascppprotoand the analysis-pass gates. The stash is drained either way so a secondread symbolscannot re-commit.ObjectLoadImage, so the cargo suite is the gate):kuna-analysisunit testfaillog_data_symbols_carry_the_copy_reloc_externsover a vendored copy oftests/bug-repro/faillog(datasyms_faillog_x86_64, md53bab801d856c5fdb175fecf069c2b4f5, identical bytes): asserts the emitted facts are exactlystdout@0x6160/8,stderr@0x61a0/8,optind@0x6168/4,optarg@0x6180/8— no zero-size linker markers, no UND placeholders, no@VERSIONleakage.kuna-consolee2efaillog_stderr_renders_by_name_by_default+option_datasyms_off_restores_dat_addr(inverify_loader_data_symbols.rs): decompiletests/bug-repro/faillog @ 0x3320in-process; default assertsstderrand nodat_61a0, the off arm assertsdat_61a0and nostderr— the two-pass bug/fix pair the standing requirements ask for, hosted in the suite instead of a stage XML.docs/spec/01-program-prep.mdre-worded to describe thedatasymsgate;docs/missing-ghidra-analyses.md§2 records the data-symbol half now covered;docs/history.mdgains the DIV-76 row and DIV-26's row is annotated;docs/options.mdregenerated.Root cause (of the original issue)
The loader's
.symtaband.dynsymwalks both filteredSymbolKind::Text, so no ELF data (STT_OBJECT) symbol was ever imported; the only producer of named data globals was the DWARF pass, which structurally cannot reach a copy-relocated (R_X86_64_COPY) libc extern — it has a real.bssaddress and a.dynsymentry but no DIE in the program's own.debug_info. Every libc global (stderr,stdout,stdin,optind,optarg,__progname) and every stripped/DWARF-less binary's own statics rendereddat_<addr>where all four rival decompilers print the name.Before / after (the issue's vendored witness)
kuna decompile-all tests/bug-repro/faillog --addr 0x3320, both call sites:Whole-binary spot-checks (default):
grepnamesstderr×11,optarg×27,__progname×1;sortnamesstderr×12,optarg×23,optind×14,__progname×1. The issue's second witness (iproute2 ip @ 0x5c180) is not vendored in-repo and was not re-run.On/off proof on BOTH CLI paths
kuna decompile-all tests/bug-repro/faillog --addr 0x3320→ 2×stderr;... --option datasyms off→ 2×dat_61a0, 0×stderr.decomp_dbgscript):kuna decompile tests/bug-repro/faillog 0x3320 --addr→ 2×stderr;... --option datasyms off→ 2×dat_61a0, 0×stderr. (The script emitsoptionlines beforeread symbols, where the commit consults the flag — verified, nodecompile.rschange needed.)Collateral audit
Base (origin/main 2b5117f release binary) vs this branch,
decompile-all --jsonat default, byte-compared:tests/bug-repro/faillog,grep,sort,libselinux.so.1— all four IDENTICAL. Expected: the gate is default-ON over an unchanged mechanism, so the default output is a structural no-op; the off arm is the only behavior change and is opt-in.Datatest evidence
Trivially 0/675 (and 0/460 stages): the XML datatest path bypasses the ELF loader entirely (
<binaryimage>never constructs anObjectLoadImage), so no baseline is touched. No re-pin.Gates
make test— PARITY OK (675/675)make test-stages— PARITY OK (460/460)make rust-test— green (this is an internal-branch PR, so CI skips the workspace suite; it was run locally)make check-spec— OKkuna catalog --check— OK ("documents exactly the registered kuna options")Counters re-derived from the built artifact
live catalog 107;
catalog_bytecompat.rs107 (×3) + regeneratedphase_catalog.jsonfixture (captured viadecomp_dbgopenfile write+phase catalog);kuna_phases/tests.rs107 / tiers (23, 47, 37) /},\n106 / live readers 33 (datasyms joins thePASS_GATESno-codegen-live-reader allowlist, read console-side viakuna_live_value);docs/options.mdregenerated.tests/stages/kuna-catalog.xmlneeds no bump: #5/#9 are ranged (min=10 max=160) and datasyms joins neither the angr-provenance (#6) nor structure-recovery (#7) nor opt-in-tool (#8) exact buckets. No new scheduled Action ⇒ the action-tree oracle/leaf/adjacency tests are unmoved (confirmed by the suite).Speed
Interleaved, minimum of 11 per side,
kuna decompile-all tests/bug-repro/grep --json > /dev/null: base 15.797 s vs gated 15.669 s (-0.81% — the gated arm is faster, i.e. the one-bool-per-commit cost is below the noise floor).Judgment calls
__bss_start,_edata,_end) are exactly the zero-size entries and would plant a name on the first byte of an unrelated object; there is also no extent to size the coveringSymbolEntryagainst..symtabwalked before.dynsym(kept from DIV-26) — mirrors the funcsym stream's discipline; a WEAK alias sharing an address (e.g.program_invocation_short_name=__progname) keeps the first table entry.HashSet<u64>+ oneVecover defined OBJECT entries).reloc_objectrebases only the function half; a.okeeps its previous behavior.🤖 Generated with Claude Code
https://claude.ai/code/session_01VBn8vgwoHqPFnnV4ZMApfq