Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Everything in this section except `SwiftSymbols` is external: since 0.25.0 these
- **MachOFoundation** (external, MachOKitExtensions) — `MachOBase` + `MachOSymbols` + `MachODependencies`: the umbrella for everything above the ABI model, which imports `SwiftSymbols` beside it.
- **MachOReading / MachOResolving** (external, MachOKitExtensions) — reading abstractions; address/offset resolution. `MachOResolving` also holds the symbol *value* types (`Symbol`, `Symbols`, `SymbolOrElement`), which carry no lookup behavior — "the symbols at this offset" is a query, not a read. Implementation note: MachOKitExtensions' `Documentations/Internal/ReadingContextAbstraction.md`.
- **MachOPointers** (external, MachOKitExtensions) — relative and indirect pointer types, plus `SymbolOrElementPointer`.
- **MachOSymbols** (external, MachOKitExtensions) — the language-neutral half of the symbol index: the 16-byte-row `SymbolTable`, `SymbolRowBucket`, `SymbolValueOffsetConverter`, the `NlistProtocol` checks, `SymbolLanguage`, the one-pass sweep over symbol table and export trie (`SymbolSweep`, steered by a `SymbolTableRouting`), and a `SymbolIndexStore` that holds C / C++ / Objective-C names only (eviction group `.symbolStore`). The building blocks this repo uses are `@_spi(Internals)`. [SymbolIndex.md](https://github.com/MxIris-Reverse-Engineering/MachOKitExtensions/blob/main/Documentations/Internal/SymbolIndex.md).
- **MachOSymbols** (external, MachOKitExtensions) — the language-neutral half of the symbol index: the 16-byte-row `SymbolTable`, `SymbolRowBucket`, `SymbolValueOffsetConverter`, the `NlistProtocol` checks, `SymbolLanguage` with its `SymbolLanguageRegistry` (C++ is recognized there; Swift is registered by this repo's `SwiftSymbols`, which defines `.swift`, from the C target `SwiftSymbolsRegistration`'s load-time constructor), the one-pass sweep over symbol table and export trie (`SymbolSweep`, steered by a `SymbolTableRouting`), and a `SymbolIndexStore` that holds C and C++ names only, keeping registered languages' symbols as offsets alone (eviction group `.symbolStore`). The building blocks this repo uses are `@_spi(Internals)`. [SymbolIndex.md](https://github.com/MxIris-Reverse-Engineering/MachOKitExtensions/blob/main/Documentations/Internal/SymbolIndex.md).
- **SwiftSymbols** (this repo, `Sources/Symbols/SwiftSymbols`) — the Swift symbol index: `SwiftSymbolIndexStore` routes the sweep through `SwiftSymbolTableRouting`, then demangles, classifies and holds the per-image node stores; also `LargeStackTaskExecution`, and the image's `_symbolic` symbols in a table of their own that no offset or name query sees (`symbolicManglingSymbols(in:)`). Eviction group `.swiftSymbolStore`, dependency key `swiftSymbolIndexStore`. [Modules/SwiftSymbols.md](Documentations/Internal/Modules/SwiftSymbols.md).
- **MachOCaches** (external, MachOKitExtensions) — the per-image cache primitive, NOT dyld shared cache support (that is `MachOKitExtensions` and `MachODependencies`): `SharedCache` (get-or-build per image, one build shared by concurrent callers, the build closure supplied at the call site), `SharedCacheKey` (hashes a file on its UUID alone, an image read from a dyld cache on its own and its cache's) and `SharedCacheRegistry` + `SharedCacheEvictionGroup` (which caches an indexer claims for an image and what its last live instance evicts). [SharedCache.md](https://github.com/MxIris-Reverse-Engineering/MachOKitExtensions/blob/main/Documentations/Internal/SharedCache.md).
- **MachODependencies** (external, MachOKitExtensions) — the one dependency-resolution implementation every feature shares (`DependencyClosure`, the in-process and file locators, `DependencySearchPath`, `SharedDependencyClosure` for consumers of one root that resolve lazily). The file locator filters dyld-cache candidates by platform (`DependencyPlatforms`, from `LC_BUILD_VERSION`): the host's macOS cache is every root's default search path and carries Mac Catalyst UIKit / SwiftUI under `/System/iOSSupport`, which an iOS root used to resolve to by bare name. Reach the host's cache through `FullDyldCache.cachedHost` (MachOKitExtensions), never `FullDyldCache.host`: `host` opens and maps all 82 files of a macOS 27 cache on every read, and a locator is built per root — an evolution over 51 archived caches held 51 copies open (`FileDependencyLocatorTests` in MachOKitExtensions pins the sharing). [DependencyResolution.md](https://github.com/MxIris-Reverse-Engineering/MachOKitExtensions/blob/main/Documentations/Internal/DependencyResolution.md).
Expand Down Expand Up @@ -207,7 +207,7 @@ Each of these fails **silently**, and several produce a real, fully-qualified, *
- **Resolving one type's members/info/attributes must use the node-taking overloads** (`memberSymbols(of:for:node:in:)` and friends). The name-only forms flatten every sub-bucket on purpose: the name key is printed with `.interfaceTypeBuilderOnly`, which strips private discriminators, so same-named private types share a bucket (issue #115).
- **Never let a demangle or print hop while you hold a lock.** On a 512 KB thread each call hops to a large-stack worker and blocks on it, so every thread waiting on the lock waits behind the hop — without bound once the pool saturates (`SwiftSymbolIndexStore.lateDemangledNode`, 2026-08-03). Under a lock, either be on a large stack already — inside a `LargeStackTaskExecution.run` entry point, or past one `StackSafeExecutor.withLargeStack` taken *before* locking (`IndexerConformanceProvider.classHierarchy()`) — or demangle outside the lock and insert-if-absent under it. A synchronous API runs on whatever thread its host calls it from. The sites that rely on their entry point's executor: [ReviewAdjudications A61](Documentations/Internal/ReviewAdjudications.md).
- **A `MachOFile` symbol's `offset` is its raw `n_value` — an address, not the file offset MachOKit's doc comment claims.** Into the index it goes through `SymbolValueOffsetConverter` (MachOKitExtensions' `MachOSymbols`); as an address it is used as is (`ImageAddressSpace.address(forSymbolValue:)`, MachOKitExtensions' `MachOAddressResolution`). A dylib's `__TEXT` at 0 makes the two look interchangeable; a main executable's at 0x100000000 does not. **A STABS entry (`nlist.isDebuggingEntry`) never supplies an offset or an address**: an `N_GSYM` carries the value 0 under the very name of the symbol it describes. MachOKitExtensions' `SymbolSweep` lets one only reserve its name's row, which keeps members in source order — dropping the entries outright reorders 42 SymbolTestsCore snapshots. `ExecutableImageSymbolOffsetTests` pins the offsets.
- **The Swift symbol index is `SwiftSymbolIndexStore`; never write a bare `SymbolIndexStore` in this repo.** That name is MachOKitExtensions' C / C++ / Objective-C store, whose queries share the Swift store's method names — a wrong name compiles and finds no Swift symbol. Likewise the eviction group is `.swiftSymbolStore` (`.symbolStore` is the C/C++ store's) and the dependency key `\.swiftSymbolIndexStore`. `SymbolIndexStoreNamingScanTests` fails on a bare one.
- **The Swift symbol index is `SwiftSymbolIndexStore`; never write a bare `SymbolIndexStore` in this repo.** That name is MachOKitExtensions' C / C++ store, whose queries share the Swift store's method names — a wrong name compiles and finds no Swift symbol. Code that does mean the C / C++ store (a test checking it leaves Swift names out) spells it `MachOSymbols.SymbolIndexStore`, which the scan allows. Likewise the eviction group is `.swiftSymbolStore` (`.symbolStore` is the C/C++ store's) and the dependency key `\.swiftSymbolIndexStore`. `SymbolIndexStoreNamingScanTests` fails on a bare one.
- **Changing a struct layout in `SwiftSymbols` (or in MachOKitExtensions' `MachOSymbols`) needs `swift package clean`.** Incremental builds have been observed linking stale downstream objects (runtime SIGSEGV in `outlined destroy`). Moving a public type across modules or flipping a dependency edge does the same. Clean first, diagnose second.

Detail: [Modules/SwiftSymbols.md](Documentations/Internal/Modules/SwiftSymbols.md), MachOKitExtensions' [SymbolIndex.md](https://github.com/MxIris-Reverse-Engineering/MachOKitExtensions/blob/main/Documentations/Internal/SymbolIndex.md), [NodeStoreMigrationPlan.md](Documentations/Internal/NodeStoreMigrationPlan.md), [SharedNodeStoreMigration.md](Documentations/Internal/SharedNodeStoreMigration.md).
Expand Down
2 changes: 1 addition & 1 deletion AgentPlugins/swift-section/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swift-section",
"version": "0.25.0",
"version": "0.26.0",
"description": "Teaches coding agents to drive the swift-section CLI: Swift and Objective-C declarations, memory layout and ABI diffs recovered from a Mach-O binary or a dyld shared cache.",
"author": {
"name": "MxIris-Reverse-Engineering",
Expand Down
2 changes: 1 addition & 1 deletion AgentPlugins/swift-section/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swift-section",
"version": "0.25.0",
"version": "0.26.0",
"description": "Teaches coding agents to drive the swift-section CLI: Swift and Objective-C declarations, memory layout and ABI diffs recovered from a Mach-O binary or a dyld shared cache.",
"author": {
"name": "MxIris-Reverse-Engineering",
Expand Down
10 changes: 10 additions & 0 deletions Changelogs/0.26.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 0.26.0

## Breaking

- Requires MachOKitExtensions 3.0.0 and MachOObjCSection 0.8.208.
- `SymbolLanguage.swift` now comes from `SwiftSymbols`; import it to compare a symbol's language with `.swift`.

## Improved

- MachOKitExtensions' C and C++ symbol index no longer mistakes an address in Swift code for the C function before it.
Loading
Loading