Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Dyld shared cache

From ReverseEngineering.wiki
Format
Vendor Apple
Platforms macOS, iOS, tvOS, watchOS
Magic "dyld_v1 arm64e" (16 bytes: dyld_v1, spaces, arch name, NUL)
On this wiki Facts · Code · Notes · Topics

The prelinked cache of nearly all system libraries on macOS, iOS, tvOS and watchOS (dyld_shared_cache_arm64e and subcaches): a file starting with ASCII "dyld_v1" padded with spaces and the architecture, a header with mapping, image and subcache tables, then merged Mach-O images whose __LINKEDIT is shared.

Overview

Recent Apple systems do not keep the system dylibs as separate files on disk but merged into a shared cache that dyld maps into every process. The file begins with a 16-byte magic dyld_v1 + spaces + architecture name, e.g. dyld_v1 x86_64, dyld_v1 arm64, dyld_v1 arm64e, dyld_v1arm64_32; the builder pads so the string is 15 characters plus NUL (SubCache.cpp: "dyld_v1" + spaces + arch name, asserted to be 15 characters). All other fields are little-endian.

Header (struct dyld_cache_header, grows with each OS)

First fields: magic[16]; mappingOffset u32 (usually 0x138 or larger); mappingCount u32; imagesOffsetOld, imagesCountOld (unused); dyldBaseAddress u64; codeSignatureOffset/Size u64; slideInfo (unused); localSymbolsOffset/Size u64; uuid[16]; cacheType u64 (0 development, 1 production, 2 multi-cache); branchPools; dyldInCacheMH, dyldInCacheEntry; imagesTextOffset/Count; patchInfoAddr/Size; ...; platform u32 (1 macOS, 2 iOS ...); a bit-field word (formatVersion 8 bits, dylibsExpectedOnDisk, simulator, locallyBuiltCache, builtFromChainedFixups, newFormatTLVs); sharedRegionStart, sharedRegionSize, maxSlide; ...; osVersion; subCacheArrayOffset/Count; symbolFileUUID; ...; imagesOffset/Count (the live image table in new caches); objcOptsOffset/Size; cacheAtlas; dynamicData; tproMappings; functionVariantInfo; prewarming data. Because the header grows, always use mappingOffset (the first table that follows the header) as the header size, and check fields against it.

Tables

  • dyld_cache_mapping_info (32 bytes): address, size, fileOffset, maxProt, initProt. Typical: __TEXT (r-x), __DATA (rw-), __LINKEDIT (r--). Newer dyld_cache_mapping_and_slide_info adds slideInfoFileOffset/Size and flags (AUTH_DATA 1, DIRTY_DATA 2, CONST_DATA 4, TEXT_STUBS 8, DYNAMIC_CONFIG_DATA 0x10, READ_ONLY_DATA 0x20, CONST_TPRO_DATA 0x40).
  • dyld_cache_image_info (32 bytes): address (of the dylib mach_header), modTime, inode, pathFileOffset, pad. The path is a C string in the cache file.
  • dyld_cache_image_text_info: uuid, loadAddress, textSegmentSize, pathOffset.
  • dyld_subcache_entry (v1: uuid[16] and cacheVMOffset u64 only, 24 bytes; current: plus fileSuffix[32], 56 bytes): the main file's header lists them through subCacheArrayOffset/Count; header fields symbolFileUUID names the .symbols file. Large caches (iOS 15+, macOS 12+) are split into a main file plus subcache files and a .symbols file, all parsed together. Suffix rules in dyld cache_builder/SubCache.cpp: main cache has no suffix (.development in a universal cache), symbols file .symbols, then .<index> (decimal, from 1) followed by .dylddata, .dyldreadonly or .dyldlinkedit for data-only, read-only-only or linkedit-only subcaches, and .development variants (.<index>.development, .<index>.development.dylddata) for development caches; simulators, x86_64 and driverKit use plain .<index>. Unverified: which suffix style a given OS release uses; list the directory to see.
  • Local symbols (dyld_cache_local_symbols_info: nlistOffset/Count, stringsOffset/Size, entriesOffset/Count) hold the non-exported symbols stripped from the images; entries map each dylib offset to a range of nlist records. In split caches they are in the .symbols subcache.

Slide info (rebasing)

Data pages hold pointers that dyld slides at map time. Versions: 1 (bitmap), 2 (page_starts and extras, delta_mask), 3 (arm64e authenticated pointers, dyld_cache_slide_pointer3), 4, 5 (newest, arm64e). Pointers read straight from a __DATA mapping are therefore tagged until the chain is decoded.

Extracting images

Images inside the cache have been optimized: __LINKEDIT is shared and stripped, stubs are redirected, ObjC metadata is merged into the cache-wide tables (objcOpts). Extractors (dsc_extractor from dyld, ipsw, DyldExtractor, LIEF) rebuild standalone Mach-O files. Cache files are found in /System/Library/dyld/ (macOS Big Sur and later: /System/Volumes/Preboot/Cryptexes/OS/System/Library/dyld/) and in iOS firmware images.

Related

Images are ordinary Format:Mach-O files flagged MH_DYLIB_IN_CACHE (0x80000000); the cache is covered by its own code signature at codeSignatureOffset (see Format:Mach-O/Code signature).

Code & repositories

  • https://github.com/apple-oss-distributions/dyld @ fd8d0c4d52320ebf64db34f3cb280310d905c5ae · license: APSL-2.0 (declared by the contributor; GitHub's detector did not recognize a license file)
    Apple dyld source: include/mach-o/dyld_cache_format.h (cache header, mappings, slide info) and the cache builder
    Tested on: source read, not run: headers read only · checked 2026-10-18
  • https://github.com/blacktop/ipsw @ a9eae76e8b1e901e4a03dd530defac8a1b33f91a · license: MIT
    ipsw (MIT): pkg/img4 (IMG4/IM4P/IM4M/IM4R parser), pkg/ota/pbzx (pbzx reader), pkg/dyld (shared cache reader), pkg/kernelcache
    Tested on: source read, not run: source read, not run: Go sources read only · checked 2026-10-19; last activity 2026-10-16; Note: the latest release ships binaries; the wiki links only the source, never the binaries