#include <mach/shared_region.h> not included by <mach/mach.h> — include it explicitly

mach/shared_region.h

File: mach/shared_region.h protos and struct definitions for shared region
54 macros · 3 structs · 3 functions · 1 typedef

macroSHARED_REGION_BASE_I386

#define SHARED_REGION_BASE_I386 0x90000000ULL

macroSHARED_REGION_SIZE_I386

#define SHARED_REGION_SIZE_I386 0x20000000ULL

macroSHARED_REGION_NESTING_BASE_I386

#define SHARED_REGION_NESTING_BASE_I386 0x90000000ULL

macroSHARED_REGION_NESTING_SIZE_I386

#define SHARED_REGION_NESTING_SIZE_I386 0x20000000ULL

macroSHARED_REGION_NESTING_MIN_I386

#define SHARED_REGION_NESTING_MIN_I386 0x00200000ULL

macroSHARED_REGION_NESTING_MAX_I386

#define SHARED_REGION_NESTING_MAX_I386 0xFFE00000ULL

macroSHARED_REGION_BASE_X86_64

Note the shared region size here seems odd for x86. The size is chosen to end the address space at a boundary that the arm64 pmap uses for pmap->max. We use this limit to prevent problems with Rosetta. Given how large the region is now, the few fewer megabytes shouldn't matter.
#define SHARED_REGION_BASE_X86_64 0x00007FF800000000ULL

macroSHARED_REGION_SIZE_X86_64

#define SHARED_REGION_SIZE_X86_64 0x00000007FE000000ULL

macroSHARED_REGION_NESTING_BASE_X86_64

#define SHARED_REGION_NESTING_BASE_X86_64 0x00007FF800000000ULL

macroSHARED_REGION_NESTING_SIZE_X86_64

#define SHARED_REGION_NESTING_SIZE_X86_64 0x00000007FE000000ULL

macroSHARED_REGION_NESTING_MIN_X86_64

#define SHARED_REGION_NESTING_MIN_X86_64 0x0000000000200000ULL

macroSHARED_REGION_NESTING_MAX_X86_64

#define SHARED_REGION_NESTING_MAX_X86_64 0xFFFFFFFFFFE00000ULL

macroSHARED_REGION_BASE_PPC

#define SHARED_REGION_BASE_PPC 0x90000000ULL

macroSHARED_REGION_SIZE_PPC

#define SHARED_REGION_SIZE_PPC 0x20000000ULL

macroSHARED_REGION_NESTING_BASE_PPC

#define SHARED_REGION_NESTING_BASE_PPC 0x90000000ULL

macroSHARED_REGION_NESTING_SIZE_PPC

#define SHARED_REGION_NESTING_SIZE_PPC 0x10000000ULL

macroSHARED_REGION_NESTING_MIN_PPC

#define SHARED_REGION_NESTING_MIN_PPC 0x10000000ULL

macroSHARED_REGION_NESTING_MAX_PPC

#define SHARED_REGION_NESTING_MAX_PPC 0x10000000ULL

macroSHARED_REGION_BASE_PPC64

#define SHARED_REGION_BASE_PPC64 0x00007FFF60000000ULL

macroSHARED_REGION_SIZE_PPC64

#define SHARED_REGION_SIZE_PPC64 0x00000000A0000000ULL

macroSHARED_REGION_NESTING_BASE_PPC64

#define SHARED_REGION_NESTING_BASE_PPC64 0x00007FFF60000000ULL

macroSHARED_REGION_NESTING_SIZE_PPC64

#define SHARED_REGION_NESTING_SIZE_PPC64 0x00000000A0000000ULL

macroSHARED_REGION_NESTING_MIN_PPC64

#define SHARED_REGION_NESTING_MIN_PPC64 0x0000000010000000ULL

macroSHARED_REGION_NESTING_MAX_PPC64

#define SHARED_REGION_NESTING_MAX_PPC64 0x0000000010000000ULL

macroSHARED_REGION_BASE_ARM

#define SHARED_REGION_BASE_ARM 0x40000000ULL

macroSHARED_REGION_SIZE_ARM

#define SHARED_REGION_SIZE_ARM 0x40000000ULL

macroSHARED_REGION_NESTING_BASE_ARM

#define SHARED_REGION_NESTING_BASE_ARM 0x40000000ULL

macroSHARED_REGION_NESTING_SIZE_ARM

#define SHARED_REGION_NESTING_SIZE_ARM 0x40000000ULL

macroSHARED_REGION_NESTING_MIN_ARM

#define SHARED_REGION_NESTING_MIN_ARM ?

macroSHARED_REGION_NESTING_MAX_ARM

#define SHARED_REGION_NESTING_MAX_ARM ?

macroSHARED_REGION_BASE_ARM64_32

#define SHARED_REGION_BASE_ARM64_32 0x1A000000ULL

macroSHARED_REGION_SIZE_ARM64_32

#define SHARED_REGION_SIZE_ARM64_32 0x88000000ULL
up to 0xA2000000

macroSHARED_REGION_NESTING_BASE_ARM64_32

#define SHARED_REGION_NESTING_BASE_ARM64_32 0x1A000000ULL

macroSHARED_REGION_NESTING_SIZE_ARM64_32

#define SHARED_REGION_NESTING_SIZE_ARM64_32 0x88000000ULL

macroSHARED_REGION_NESTING_MIN_ARM64_32

#define SHARED_REGION_NESTING_MIN_ARM64_32 ?

macroSHARED_REGION_NESTING_MAX_ARM64_32

#define SHARED_REGION_NESTING_MAX_ARM64_32 ?

macroSHARED_REGION_BASE_ARM64

#define SHARED_REGION_BASE_ARM64 0x180000000ULL

macroSHARED_REGION_SIZE_ARM64

#define SHARED_REGION_SIZE_ARM64 0x180000000ULL

macroSHARED_REGION_NESTING_BASE_ARM64

#define SHARED_REGION_NESTING_BASE_ARM64 SHARED_REGION_BASE_ARM64

macroSHARED_REGION_NESTING_SIZE_ARM64

#define SHARED_REGION_NESTING_SIZE_ARM64 SHARED_REGION_SIZE_ARM64

macroSHARED_REGION_NESTING_MIN_ARM64

#define SHARED_REGION_NESTING_MIN_ARM64 ?

macroSHARED_REGION_NESTING_MAX_ARM64

#define SHARED_REGION_NESTING_MAX_ARM64 ?

macroSHARED_REGION_BASE

#define SHARED_REGION_BASE SHARED_REGION_BASE_ARM64

macroSHARED_REGION_SIZE

#define SHARED_REGION_SIZE SHARED_REGION_SIZE_ARM64

macroSHARED_REGION_NESTING_BASE

#define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_ARM64

macroSHARED_REGION_NESTING_SIZE

#define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_ARM64

macroSHARED_REGION_NESTING_MIN

#define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_ARM64

macroSHARED_REGION_NESTING_MAX

#define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_ARM64

structshared_file_mapping_np

This was used for the no longer present shared_region_map_and_slide_np() interface. The struct got used by other external projects to represent shared cache info, so it's left behind for now.
size 32, align 8
mach_vm_address_tsfm_address
mach_vm_size_tsfm_size
mach_vm_offset_tsfm_file_offset
vm_prot_tsfm_max_prot
vm_prot_tsfm_init_prot

structshared_file_mapping_slide_np

size 48, align 8
mach_vm_address_tsms_addressaddress at which to create mapping
mach_vm_size_tsms_sizesize of region to map
mach_vm_offset_tsms_file_offsetoffset into file to be mapped
user_addr_tsms_slide_sizesize of data at sms_slide_start
user_addr_tsms_slide_startaddress from which to get relocation data
vm_prot_tsms_max_protprotections, plus flags, see below
vm_prot_tsms_init_prot

typedefshared_file_mapping_slide_np_t

typedef struct shared_file_mapping_slide_np shared_file_mapping_slide_np_t;

structshared_file_np

size 12, align 4
intsf_fdfile to be mapped into shared region
uint32_tsf_mappings_countnumber of mappings
uint32_tsf_slidedistance in bytes of the slide

macroVM_PROT_COW

Extensions to sfm_max_prot that identify how to handle each mapping. These must not interfere with normal prot assignments. VM_PROT_COW - copy on write pages VM_PROT_ZF - zero fill pages VM_PROT_SLIDE - file pages which require relocation and, on arm64e, signing these will be unique per shared region. VM_PROT_NOAUTH - file pages which don't require signing. When combined with VM_PROT_SLIDE, pages are shareable across different shared regions which map the same file with the same relocation info.
#define VM_PROT_COW 0x08

macroVM_PROT_ZF

#define VM_PROT_ZF 0x10

macroVM_PROT_SLIDE

#define VM_PROT_SLIDE 0x20

macroVM_PROT_NOAUTH

#define VM_PROT_NOAUTH 0x40

macroVM_PROT_TRANSLATED_ALLOW_EXECUTE

#define VM_PROT_TRANSLATED_ALLOW_EXECUTE 0x80

functionshared_region_check_np

int shared_region_check_np(uint64_t *startaddress)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/vm/vm_unix.c
System call intended for dyld. Called at process start to learn whether the process's shared region (the dyld shared cache) is already set up: stores the base address of the shared region's first mapping through startaddress, and dyld then checks what is mapped there. If the shared region is empty, dyld maps the shared cache with shared_region_map_and_slide_2_np. A NULL argument tells the kernel that dyld has unmapped the shared region, dropping the task's reference to it. Errors: EINVAL if the task has no shared region, ENOMEM if it is empty, EFAULT for a bad startaddress pointer.

functionshared_region_map_np

int shared_region_map_np(
	int fd,
	uint32_t mappingCount,
	const struct shared_file_mapping_np *mappings
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/kern/syscalls.master, osfmk/mach/shared_region.h
Obsolete; the system call was removed (its slot returns nosys). Formerly dyld's call to map the given ranges of the file open on fd into the process's shared region. Superseded by shared_region_map_and_slide_np and, currently, shared_region_map_and_slide_2_np.

functionshared_region_slide_np

int shared_region_slide_np(void)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/kern/syscalls.master, osfmk/mach/shared_region.h
Obsolete; the system call was removed (its slot returns nosys). It belonged to the original shared-cache sliding (ASLR) interface; sliding is now requested as part of shared_region_map_and_slide_2_np.