Repository navigation
Conversation
`ipsw kernel extract --kdk <kernelcache>` writes the kernel and every KEXT
of an MH_FILESET kernelcache as standalone Mach-Os that kmutil can link
into a new kernelcache, laid out like a KDK
(KDK_<version>_<build>.kdk/System/Library/{Kernels,Extensions}) with the
KEXTs' Info.plists, codeless KEXTs, the kernel's pseudo-extensions and a
SystemVersion.plist.
The kernel collection builder resolves every reference between the
images and strips their chained fixups and split-segment info. For each
image, the new package pkg/kernelcache/kdk recovers its references
(pointers from the collection's chained fixups; ADRP pages and the
ADD/LDR/STR that complete them, followed across branches, jump tables,
calls that preserve the register and functions that do not return;
branches leaving a section; deltas in __eh_frame, __static_if and
__copyio_vectors; image offsets in __unwind_info) and passes them to
go-macho's File.Export, which rebuilds the image like ld64.
Stripped kernelcaches lack the symbols the KEXTs link against: link
symbols are then synthesized from the dependency graph, and --symbols
takes known names from `ipsw kernel symbolicate --json`.
--all and single KEXT extraction are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Are you still interested in pushing this forward? I think I saw that you guys implemented your own solution in Swift now or something. |
Author
|
I think it is a cool functionality fitting nicely to ipsw. You're right that Jacky ported the functionality to Swift, so we have no pressure to merge it anymore. However, your suggestions for improving this PR towards merging it into ipsw are welcome. |
This branch has not been deployed
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.
Summary
ipsw kernel extract --kdk <kernelcache>writes the kernel and every KEXT of anMH_FILESETkernelcache as standalone Mach-Os that kmutil can link into a new kernelcache. The output is laid out like a KDK (KDK_<version>_<build>.kdk/System/Library/{Kernels,Extensions}), with the KEXTs' Info.plists, the codeless KEXTs, the kernel's pseudo-extensions and aSystemVersion.plist.This makes it possible to build kernelcaches Apple does not ship, for example the cloudOS research kernel mixed with KEXTs taken from another kernelcache.
How it works: the kernel collection builder resolves every reference between images and strips their chained fixups and split-segment info. For each image, the new package
pkg/kernelcache/kdkrecovers those references:__eh_frame,__static_ifand__copyio_vectors;__unwind_info.It then passes them to go-macho's
File.Export(..., WithReferences(...)), which rebuilds the image as ld64 would have.Stripped kernelcaches lack the symbols the KEXTs link against. Link symbols are then synthesised from the dependency graph, and
--symbols <map.json>adds known names, for example fromipsw kernel symbolicate --json.--alland single-KEXT extraction are unchanged.Dependencies
This needs these changes in three libraries:
Exportwith references;.eh_frameparser.go.modstill points at the released versions; I'll bump it once those are merged and tagged. Until then, the branch builds with a local-modfilethat replaces the three modules.Testing
go test ./pkg/kernelcache/kdk/...--symbols) into mixed kernelcaches.