XXNU Source Handbook Download offline version from here
Part 02 · Chapter 02.02

Structure layouts

Key structures · Task storage · Recount accounting

Explore a structure's size, alignment and field offsets for a selected source configuration. The HTML handbook includes an interactive layout browser here; it works offline, including when opened directly from the extracted handbook ZIP. JavaScript is required for the browser below.

EXPLORE A STRUCTURE
SIZEOF—ALIGNMENT—
Directives ↗
Requested preprocessor directives

Analysis runs locally in a dedicated worker. Manual directives are explicit what-if configurations.

Loading offline compiler…

↳Expanded declarations are layout previews. Pointers store an address. Opening an available referent starts a new object with offsets from zero. Dependency coverage is partial; unvisited branches remain unknown.

Documented structure coverage

This finite survey covers the listed C roots in each generated iPhoneOS source profile. Available layouts use PAC-enabled arm64e analysis contexts. Returned embedded records do not expand the surveyed inventory. Unsupported cells retain their exact compiler diagnostics in coverage data.

Structurerelease-t8103development-t8103release-vmappledevelopment-vmapple
taskAvailableAvailableAvailableAvailable
recount_trackAvailableAvailableAvailableAvailable
recount_usageAvailableAvailableAvailableAvailable
recount_metricsAvailableAvailableAvailableAvailable
recount_threadAvailableAvailableAvailableAvailable
recount_taskAvailableAvailableAvailableAvailable
procAvailableAvailableAvailableAvailable
proc_roAvailableAvailableAvailableAvailable
proc_ro_dataAvailableAvailableAvailableAvailable
task_ro_dataAvailableAvailableAvailableAvailable
threadAvailableAvailableAvailableAvailable
thread_roAvailableAvailableAvailableAvailable
uthreadAvailableAvailableAvailableAvailable
ucredAvailableAvailableAvailableAvailable
posix_credAvailableAvailableAvailableAvailable
ucred_rwAvailableAvailableAvailableAvailable
labelAvailableAvailableAvailableAvailable
ipc_spaceAvailableAvailableAvailableAvailable
ipc_entryAvailableAvailableAvailableAvailable
ipc_portAvailableAvailableAvailableAvailable
ipc_kmsgAvailableAvailableAvailableAvailable
vm_mapAvailableAvailableAvailableAvailable
vm_map_entryAvailableAvailableAvailableAvailable
vm_objectAvailableAvailableAvailableAvailable
vm_pageAvailableAvailableAvailableAvailable
vm_named_entryAvailableAvailableAvailableAvailable
vm_map_copyAvailableAvailableAvailableAvailable
pmapAvailableAvailableAvailableAvailable
filedescAvailableAvailableAvailableAvailable
fileprocAvailableAvailableAvailableAvailable
fileglobAvailableAvailableAvailableAvailable
vnodeAvailableAvailableAvailableAvailable
ubc_infoAvailableAvailableAvailableAvailable
cs_blobAvailableAvailableAvailableAvailable
vnode_pagerAvailableAvailableAvailableAvailable
socketAvailableAvailableAvailableAvailable
sockbufAvailableAvailableAvailableAvailable
inpcbAvailableAvailableAvailableAvailable
tcpcbAvailableAvailableAvailableAvailable
mbufAvailableAvailableAvailableAvailable
m_extAvailableAvailableAvailableAvailable
ext_refAvailableAvailableAvailableAvailable
machine_threadAvailableAvailableAvailableAvailable
arm_saved_state64AvailableAvailableAvailableAvailable
thread_groupAvailableAvailableAvailableAvailable
in6_addrAvailableAvailableAvailableAvailable
sockaddr_in6AvailableAvailableAvailableAvailable
ip6_hdrAvailableAvailableAvailableAvailable
ip6_hbhAvailableAvailableAvailableAvailable
ip6_destAvailableAvailableAvailableAvailable
ip6_rthdrAvailableAvailableAvailableAvailable
ip6_fragAvailableAvailableAvailableAvailable
ip6_pktoptsAvailableAvailableAvailableAvailable
ip6_exthdrsAvailableAvailableAvailableAvailable
ip6_out_argsAvailableAvailableAvailableAvailable
ip6qAvailableAvailableAvailableAvailable
ip6_moptionsAvailableAvailableAvailableAvailable
route_in6AvailableAvailableAvailableAvailable
in6_ifaddrAvailableAvailableAvailableAvailable
in6_multiAvailableAvailableAvailableAvailable
in6_mfilterAvailableAvailableAvailableAvailable
nd_ifinfoAvailableAvailableAvailableAvailable
nd_defrouterAvailableAvailableAvailableAvailable
nd_prefixAvailableAvailableAvailableAvailable
llinfo_nd6AvailableAvailableAvailableAvailable
mld_ifinfoAvailableAvailableAvailableAvailable

Find a field and its offset

Start from the task layout, thread machine state, a thread group, an IPv6 interface address, the IPv6 header or the Recount track layout. Select a configuration, expand embedded structures and choose an array index to follow the storage occupied by a field. Search narrows the available structures or field paths.

The declaration gutter shows offsets from the root object in hexadecimal, such as (+0x30). The selected-field panel also shows the offset from its immediate parent. For an embedded array element, the root offset includes the containing fields and the selected index multiplied by the element stride. The decimal control changes the display without changing the layout.

A pointer occupies storage for an address. Following an available pointer target opens a separate object whose offsets start at zero. It does not add the pointee's fields to the containing allocation. Union members can overlap; bitfield positions include a bit remainder and width. A flexible array has a tail offset and element stride, but its allocation length is not determined by sizeof.

Choose the preprocessing configuration

The supplied profiles target arm64e-apple-ios: RELEASE and DEVELOPMENT configurations generated from XNU's iPhoneOS rules, with T8103 and VMAPPLE board selections. These are source-analysis contexts, not identified shipped iPhone or iPad kernels. Directives shows requested macro definitions and the effective values observed by the compiler. An absent override, an explicit #undef, and #define FLAG 0 are different: an #ifdef FLAG branch remains selected when the replacement is zero.

The iOS baseline explicitly defines XNU_TARGET_OS_IOS=1 and XNU_PLATFORM_iPhoneOS=1, following XNU's deployment-target rules. It also uses the matching iPhoneOS configuration options, rather than changing a single macro on a MacOSX configuration. XNU_TARGET_OS_OSX is undefined. This matters for MAC labels: defining the OSX macro even as zero selects seven policy slots; the iOS branch selects three or four according to CONFIG_VNGUARD. The profiles do not supply a complete SDK deployment environment or reproduce Apple-private compiler behavior.

Pointer-authentication intrinsics and calls are enabled in every supplied profile, so PAC-dependent fields remain present. Manual overrides that disable the required PAC context are rejected. For layout analysis, the entry source applies #define __ptrauth(...) with an empty replacement: this removes pointer-authentication qualifiers while retaining the pointer fields and their storage. The bundled upstream compiler cannot parse all of XNU's qualifier forms. The applied compatibility directive is visible in the configuration; it does not model pointer signing or authentication at runtime.

The two Recount shortcuts illustrate fields controlled by configuration:

Control Preprocessor flag Effect on Recount storage
CPI metrics CONFIG_PERVASIVE_CPI Includes rm_instructions and rm_cycles, the instruction and CPU-cycle counters used for cycles-per-instruction accounting.
Energy CONFIG_PERVASIVE_ENERGY Includes ru_energy_nj, CPU energy measured in nanojoules.

These fields are conditional in the Recount declaration. The switches change the source layout being analyzed; they do not start performance or energy monitoring in the browser. Other structures can depend on different flags. Source-dependency evidence explains known relationships, while unvisited branches and arbitrary flag combinations remain outside the verified profile set.

Changes to the supplied profiles are labeled as what-if configurations. A requested value may be redefined by an included header; inspect the effective value before interpreting the result. The selected target and CPU do not imply that private Apple compiler features are enabled.

Compare and reopen a selection

Comparison starts from the selected profile's baseline. Pin the current result to compare subsequent changes against it. Added and excluded fields, changed field types and shifted offsets are marked; an excluded field has no current offset or size. Array element-size changes can move nested fields even when their local offsets stay the same.

The page URL preserves the selected root, field, array indices, profile, overrides and display options. Copy it to reopen that selection, or use browser Back and Forward. Pinned comparisons last only for the current session and are not included in the URL. A field known only from a pinned configuration may therefore be unavailable after reopening. Invalid or unavailable selections show a diagnostic instead of reusing prior offsets; reset the profile to recover.

Scope and source evidence

The thread_group context parses the complete original osfmk/kern/thread_group.c, where its private definition lives. The entry source suppresses only that include's -Wstatic-in-inline warnings; linking and code generation are outside layout analysis. Macro-generated declaration names retain their macro invocation and expansion provenance, so token-pasted aliases do not prevent layouts such as proc, vnode or in6_ifaddr from opening.

The ucred_rw context parses the complete original bsd/kern/kern_credential.c with sys/sysproto.h generated by XNU's own syscall script. Two Apple-only allocator builtins receive explicit, scoped layout-only replacements: __builtin_xnu_type_summary(...) becomes 0, and __builtin_xnu_type_signature(...) becomes an empty string. These replacements affect allocator metadata, not the four field declarations or their types. The browser supports this structure's layout, not the resulting allocator flags, signatures or behavior. Directives displays the complete analysis entry, including these definitions and their scope.

The vnode_pager context parses the complete original osfmk/vm/bsd_vm.c. Its Mach interface headers are generated locally from XNU's original .defs files with a pinned Linux-compatible Apple MIG source build. The prepared browser package includes the generated headers and their provenance; readers need no MIG installation. The original pager declaration remains unchanged.

The ubc_info and cs_blob context preserves the complete original headers and their PAC and code-signing-monitor guards. Its dependencies include older Apple-published TrustCache headers with their original notices, plus minimal, explicitly synthetic CoreEntitlements declarations used only to parse unrelated metadata records. These are layout-only parser placeholders, not reconstructed CoreEntitlements layouts or implementations. Neither target structure embeds those types. Changing the placeholder size and alignment leaves the returned target layouts unchanged. The context rejects outputs that expose placeholder-dependent types, and Directives shows the compatibility declarations. Original KDK headers are not included in the handbook package.

The HTML coverage table lists the inventoried structures and their availability in each base configuration. Available entries open the corresponding header context; unavailable entries explain the compiler, missing-header or declaration boundary. Separate contexts keep kernel, VM, BSD, IPC and networking header selections explicit, including IPv6 wire headers, options, routes, neighbor discovery and multicast state. Complete embedded records returned with an available root can also be explored. This finite inventory does not cover every structure in XNU. Results describe the bundled xnu-12377.121.6 source, pinned upstream compiler and explicit configuration; they are not a claim about an unidentified shipped kernel or Apple-private LLVM behavior.

Source actions open the matching handbook source view where available, or download the exact analyzed header. Compilation and dependency analysis run locally in a worker; they need no installed compiler, server or network connection. Traced XNU analysis can use substantial memory. The worker is released after a request when its WebAssembly capacity exceeds the reuse threshold; that threshold does not limit memory during compilation. Cancelling an analysis stops that worker and clears the pending layout.

The build guide explains artifact preparation, provenance and stale-input checks. Structure offsets complement the allocation and lifetime explanations in this section; they do not establish that an arbitrary pointer is valid or that a field can be accessed without synchronization.

Search the handbook

Search every chapter, interface and code excerpt.

    Diagram

    Source preview

    Open full file