# CoreIK offsets, per simulator build

CoreIK's private C entry points are not in the framework's exports trie, so we
can't resolve them with `dlsym()`. 

Instead, we take the byte offset that `nm --demangle` prints for each symbol (accounting for C++ name managling), add the runtime ASLR slide, and cast the resulting address to a C function pointer. The offsets are specific to the exact CoreIK binary you're running against,  every new simulator build produces a different binary with a different layout.

This directory holds the human-readable offsets for each build I've verified against. The Swift and C source files each carry a compile-time table keyed by build tag — at runtime they read `/tmp/CoreIK.framework/BUILD` (written by `setup.sh`) and look up the right offsets for the CoreIK binary that was actually staged.

## Supported builds

| Build tag | visionOS | Source |
|-----------|----------|--------|
| `23N301`  | 26.2     | the version the tribunal demo was verified against |

## Adding a new build

1. Install the new visionOS simulator runtime via Xcode → Settings → Platforms.
2. Run `./deploy/setup.sh --version <new-os-version>` — this copies the new
   build's CoreIK to `/tmp/CoreIK.framework/`.
3. Run `./deploy/derive_offsets.sh /tmp/CoreIK.framework/CoreIK`. It prints
   three blocks: a plain-text record for this directory, a Swift dictionary
   entry, and a C table entry.
4. Save the plain-text block to `deploy/coreik_offsets/<BUILD>.txt`.
5. Paste the Swift block into `HelloVisionOS/CoreIKBridge.swift` inside
   `kCoreIKOffsets`.
6. Paste the C block into `cli/main.c` inside `kCoreIKOffsetsTable`.
7. Rebuild and launch — the apps will pick the new build automatically based
   on what `setup.sh` staged.

If any symbol is missing from `derive_offsets.sh` output, Apple has renamed or
removed it in that build. 
