Repository navigation
[AUTOMATED] Name Mach-O exports from the export trie, so a stripped dylib keeps its names - #1365
Merged
Merged
Conversation
…he nlist A dylib stripped with `strip -N` (or a Swift framework that keeps a few external nlist entries) still exports every name through its export trie, but kuna read exports from `object`'s `exports()`, which walks the LC_DYSYMTAB external-defined nlist range. So `kuna functions` listed `sub_328` and `kuna decompile x audit_exported_function` failed while the address worked. The loader now walks LC_DYLD_EXPORTS_TRIE / the LC_DYLD_INFO export range and adds each trie name the nlist does not already hold. A name in a code section is a function entry spelled as the symbol table spells it (`_audit_exported_function`), so the stripped image lists what the unstripped one lists; any other is a data name and a datasym, per the #1351 rule. Re-exports are skipped, a stub-and-resolver names its stub, absolute exports are never entries. The walk is bounded by the trie: each node entered once, ULEB128s capped at 64 bits, offsets checked, reads capped at 4 and names at 16 bytes per trie byte. The export list is cached per image bytes, so loading a 50k-export dylib is no slower. On 53 real Mach-O images: 202 functions in three Swift frameworks gain their names, a stripped LC_UNIXTHREAD executable's crt `start` is found, and dyld_ios15's LC_MAIN entry is named `_main` from its trie (as unstripped images are). ELF/PE output is byte-identical. Fixes #1349. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
A partly stripped image (a Swift framework that keeps a few external nlist entries) can export a second name at an entry its nlist still names. That name is now a lookup alias of the entry instead of being dropped. New fixture macho_trie_partial_arm64 pins both shapes: the trie names the entry the nlist lost, and its other name at the entry it kept selects that entry. Part of #1349. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
The export trie marks a Thumb function with the low address bit, so the walk cleared it on every regular export of a 32-bit ARM image. An exported byte at an odd data address then moved onto its even neighbour: `odd_data` at 0xc9e5 was reported as data at 0xc9e4. Clear the bit only where the even address lies in a code section. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
`push_loader_aliases` checked each loader alias against the entry's list with `Vec::contains`, quadratic in the aliases one address holds. A Mach-O export trie (or a symbol table) that puts tens of thousands of long names at one entry took 47 s to list (`kuna functions`); a hash set makes it 1.5 s with the same output. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
Contributor
Author
|
[AUTOMATED] Pushed two commits.
|
…e from its witness (CPython eval loop oppool1 758 s -> 137 s) (#1361) RuleMultiCollapse walked the same failed phi web again on every pass: on CPython 3.11's _PyEval_EvalFrameDefault, whose dispatch joins have about 190 inputs, one pass made 17.2M applications. A failed walk now records a witness path, and the next application re-derives the defining branch from the current IR and re-checks each link of that path before walking. The walk reads inputs in place instead of copying them. Output is byte-identical (a side-by-side build that ran the old walk before every application agreed on 32.7M applications); oppool1 on the eval loop drops from 758 s to 137 s, and ordinary code runs 0.14% fewer instructions. Part of #1034. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
…ers it at an input (CPython eval loop infertypes 722 s -> 44 s) (#1362) Type propagation entered a MULTIEQUAL or INDIRECT at one input and then tried every other input slot, each of which propagate_type refuses: 29.5 B slot attempts per run on CPython 3.11's _PyEval_EvalFrameDefault. Once the walk enters a join at an input, it now skips the join's other input slots when the entering type needs no union resolution. Output is byte-identical (38.6M skips re-run against the old code took 0 edges and changed 0 types); infertypes on the eval loop drops from 722 s to 44 s, and ordinary code runs 0.37% fewer instructions. Part of #1034. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
…ady known (CPython eval loop mergerequired 1,884 s -> 953 s) (#1367) merge_op re-ran cover tests whose answers were already known, on 187-input joins into a stack slot with 19k instances in CPython 3.11's _PyEval_EvalFrameDefault. It now tests each distinct earlier high once, lists each high once per test pass, indexes highs with 64 or more instances by block during a pass, and skips a re-test pass when the recorded refusal reads neither the trimmed high nor its piece partners. bank_symbol and stackvalueorder skip a member at the same storage as the one before it. Output is byte-identical (an old-vs-new differential over 26,426 functions found 0 mismatches) and memory is unchanged; mergerequired on the eval loop drops by about half (1,884 s to 953 s). Unit tests cover the block index and the trim-skip rule. Part of #1034. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
…as a lookup alias (#1368) Mach-O and PE now keep every extra symbol-table name at a function entry as a lookup alias, as ELF already did; there is still one row and one decompile per address, and the reported name is the first symbol-table entry. A Mach-O export's C spelling is not added as an alias at an entry the symbol table already names. The `_` retry narrows by the decorated name, so `audit_shared` picks the function actually named `_audit_shared` over another entry's alias, and a name that is only an alias at two entries is still reported as ambiguous. MinGW PE pairs (`fpreset`/`_fpreset`) had the same gap. The console's per-function alias merge is now linear (a 16 MB image with 30,000 names at one address: 9.3 s to 1.2 s, same output). Fixes #1357. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
Add `kuna raw-pcode`: each instruction's SLEIGH p-code with its bytes, before any decompiler pass, using `disassemble`'s target resolution, JSON envelope (same `truncated` meaning) and windowed load. It lifts linearly and stops at the first lift that fails (exit 1, prefix kept). `--follow` walks direct flow by the decompiler's xrefControlFlow rule into blocks with successors and issues, each failed lift reported once. An odd ARM32 address lifts as Thumb at the even address, in a query-scoped context. No other command's output changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
mahaloz
added a commit
that referenced
this pull request
Nov 1, 2026
Brings in #1346 (truncptrflow) and the stage tests landed with #1303, #1316, #1365, #1366, #1368 and #1370. clonephiorder now sits on top of truncptrflow; every count is re-derived from phases.toml and the stage directory: 354 settables, tiers 127 core / 135 transform / 92 analysis, 162 with a live field, 353 "},\n" separators, 354 fixture rows, KUNA-CATALOG #15 = 360, corpus 623 files (83 datatests + 540 stages). docs/options.md and phase_catalog.json regenerated with the merged build. docs/baseline-stages.json re-recorded on the merged tree: main's set plus RETCOPYCLONE #1-#9, with KUNA-CATALOG #15 renamed (3408 assertions). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE
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 Mach-O dylib stripped of its symbol table (
strip -N, orllvm-strip --strip-all) still exports its names through its export trie, but kuna listssub_328and cannot decompile by name. The repro builds the issue's source with clang and theld64.lldrustup ships; no macOS needed.The fix:
object'sexports()reads theLC_DYSYMTABexternal-definednlistrange, not the trie. The loader now walksLC_DYLD_EXPORTS_TRIE(or theLC_DYLD_INFOexport range) itself and adds every trie name thenlistdoes not already hold at that address._audit_exported_function), so the stripped dylib lists and decompiles exactly what the unstripped one does:return _audit_exported_function(a0) + _audit_exported_data;. A trie name at an entry the nlist names differently becomes a lookup alias of it. Any other name is a data name and a data symbol. Re-exports are skipped, a stub-and-resolver names its stub, absolute exports are never entries. On 32-bit ARM the trie's Thumb bit is cleared only on a code address, so an exported byte at an odd data address keeps it.resolve_importsreaches the export list about twenty times per load, so the list is cached by the bytes it is read from. A 50,000-export dylib loads no slower than before (1.14 s vs 1.16 s).Tests:
macho_trie_exports_arm64(the repro) andmacho_trie_exports_info_arm64(classicLC_DYLD_INFO_ONLYtrie, noLC_FUNCTION_STARTS, where main finds no functions at all), prebuilt with a.provenancefile, plusmacho_trie_partial_arm64, whose nlist keeps one of three exports. A loader test andmacho_trie_names_clipin the names, both spellings, the caller's C and the data answer; they fail without the fix. Unit tests cover every export kind plus hostile tries: cycles, ULEB overflow, truncation, quadratic chains, overlapping nodes, and 20,000 mutated tries. Across 53 real Mach-O images, 202 functions in three Swift frameworks get their names, a strippedLC_UNIXTHREADexecutable's crtstartis found, anddyld_ios15's entry is named_mainfrom its trie, as an unstripped image names it, instead ofmachomain'sint main(int argc, char **argv). ELF and PE output is byte-identical.Fixes #1349
🤖 Generated with Claude Code
https://claude.ai/code/session_013BBaWRVoTEYHNosYwYRoSE