+#define PAGE_SIZE_FOR_SR_SLIDE 4096
+
+/* Documentation for the slide info format can be found in the dyld project in
+ * the file 'launch-cache/dyld_cache_format.h'. */
+
+
+typedef struct vm_shared_region_slide_info_entry_v2 *vm_shared_region_slide_info_entry_v2_t;
+struct vm_shared_region_slide_info_entry_v2 {
+ uint32_t version;
+ uint32_t page_size;
+ uint32_t page_starts_offset;
+ uint32_t page_starts_count;
+ uint32_t page_extras_offset;
+ uint32_t page_extras_count;
+ uint64_t delta_mask; // which (contiguous) set of bits contains the delta to the next rebase location
+ uint64_t value_add;
+ // uint16_t page_starts[page_starts_count];
+ // uint16_t page_extras[page_extras_count];
+};
+
+#define DYLD_CACHE_SLIDE_PAGE_ATTRS 0xC000 // high bits of uint16_t are flags
+#define DYLD_CACHE_SLIDE_PAGE_ATTR_EXTRA 0x8000 // index is into extras array (not starts array)
+#define DYLD_CACHE_SLIDE_PAGE_ATTR_NO_REBASE 0x4000 // page has no rebasing
+#define DYLD_CACHE_SLIDE_PAGE_ATTR_END 0x8000 // last chain entry for page
+#define DYLD_CACHE_SLIDE_PAGE_VALUE 0x3FFF // bitwise negation of DYLD_CACHE_SLIDE_PAGE_ATTRS
+#define DYLD_CACHE_SLIDE_PAGE_OFFSET_SHIFT 2
+
+typedef struct vm_shared_region_slide_info_entry_v3 *vm_shared_region_slide_info_entry_v3_t;
+struct vm_shared_region_slide_info_entry_v3 {
+ uint32_t version; // currently 3
+ uint32_t page_size; // currently 4096 (may also be 16384)
+ uint32_t page_starts_count;
+ uint64_t value_add;
+ uint16_t page_starts[] /* page_starts_count */;
+};
+
+#define DYLD_CACHE_SLIDE_V3_PAGE_ATTR_NO_REBASE 0xFFFF // page has no rebasing
+
+
+typedef struct vm_shared_region_slide_info_entry_v4 *vm_shared_region_slide_info_entry_v4_t;
+struct vm_shared_region_slide_info_entry_v4 {
+ uint32_t version; // currently 4
+ uint32_t page_size; // currently 4096 (may also be 16384)
+ uint32_t page_starts_offset;
+ uint32_t page_starts_count;
+ uint32_t page_extras_offset;
+ uint32_t page_extras_count;
+ uint64_t delta_mask; // which (contiguous) set of bits contains the delta to the next rebase location (0xC0000000)
+ uint64_t value_add; // base address of cache
+ // uint16_t page_starts[page_starts_count];
+ // uint16_t page_extras[page_extras_count];
+};
+
+#define DYLD_CACHE_SLIDE4_PAGE_NO_REBASE 0xFFFF // page has no rebasing
+#define DYLD_CACHE_SLIDE4_PAGE_INDEX 0x7FFF // index into starts or extras
+#define DYLD_CACHE_SLIDE4_PAGE_USE_EXTRA 0x8000 // index is into extras array (not starts array)
+#define DYLD_CACHE_SLIDE4_PAGE_EXTRA_END 0x8000 // last chain entry for page
+
+
+
+typedef union vm_shared_region_slide_info_entry *vm_shared_region_slide_info_entry_t;
+union vm_shared_region_slide_info_entry {
+ uint32_t version;
+ struct vm_shared_region_slide_info_entry_v2 v2;
+ struct vm_shared_region_slide_info_entry_v3 v3;
+ struct vm_shared_region_slide_info_entry_v4 v4;
+};
+
+#define MIN_SLIDE_INFO_SIZE \
+ MIN(sizeof(struct vm_shared_region_slide_info_entry_v2), \
+ MIN(sizeof(struct vm_shared_region_slide_info_entry_v3), \
+ sizeof(struct vm_shared_region_slide_info_entry_v4)))
+
+/*
+ * This is the information used by the shared cache pager for sub-sections
+ * which must be modified for relocations and/or pointer authentications
+ * before it can be used. The shared_region_pager gets source pages from
+ * the shared cache file and modifies them -- see shared_region_pager_data_request().
+ *
+ * A single pager may be used from multiple shared regions provided:
+ * - same si_slide_object, si_start, si_end, si_slide, si_ptrauth and si_jop_key
+ * - The size and contents of si_slide_info_entry are the same.
+ */
+typedef struct vm_shared_region_slide_info {
+ uint32_t si_slide; /* the distance that the file data is relocated */
+ bool si_slid;
+#if __has_feature(ptrauth_calls)
+ bool si_ptrauth;
+ uint64_t si_jop_key;
+ struct vm_shared_region *si_shared_region; /* so we can ref/dealloc for authenticated slide info */
+#endif /* __has_feature(ptrauth_calls) */
+ mach_vm_address_t si_slid_address;
+ mach_vm_offset_t si_start; /* start offset in si_slide_object */
+ mach_vm_offset_t si_end;
+ vm_object_t si_slide_object; /* The source object for the pages to be modified */
+ mach_vm_size_t si_slide_info_size; /* size of dyld provided relocation information */
+ vm_shared_region_slide_info_entry_t si_slide_info_entry; /* dyld provided relocation information */
+} *vm_shared_region_slide_info_t;
+
+/*
+ * Data structure that represents a unique shared cache region.
+ */