1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29/*
30 * Data structure definitions copied from dyld so that we can read dyld's saved UUID information
31 * for each binary image not loaded from the shared cache during stackshots.
32 */
33
34/* Some clients check the dyld version at runtime */
35#define DYLD_ALL_IMAGE_INFOS_ADDRESS_MINIMUM_VERSION 9
36#define DYLD_ALL_IMAGE_INFOS_TIMESTAMP_MINIMUM_VERSION 15
37#define DYLD_ALL_IMAGE_INFOS_COMPACTINFO_MINIMUM_VERSION 16
38
39#define DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT 8
40#define DYLD_PROCESS_INFO_NOTIFY_MAGIC 0x49414E46
41
42/* Re-use dyld format for kext load addresses */
43#if __LP64__
44typedef struct user64_dyld_uuid_info kernel_uuid_info;
45#else
46typedef struct user32_dyld_uuid_info kernel_uuid_info;
47#endif
48
49struct user32_dyld_image_info {
50 user32_addr_t imageLoadAddress; /* base address image is mapped int */
51 user32_addr_t imageFilePath; /* path dyld used to load the image */
52 user32_ulong_t imageFileModDate; /* time_t of image file */
53};
54
55struct user64_dyld_image_info {
56 user64_addr_t imageLoadAddress; /* base address image is mapped int */
57 user64_addr_t imageFilePath; /* path dyld used to load the image */
58 user64_ulong_t imageFileModDate; /* time_t of image file */
59};
60
61// FIXME: dyld is in C++, and some of the fields in dyld_all_image_infos are C++
62// native booleans. There must be a better way...
63typedef uint8_t dyld_bool;
64
65struct user32_dyld_all_image_infos {
66 uint32_t version;
67 uint32_t infoArrayCount;
68 user32_addr_t infoArray;
69 user32_addr_t notification;
70 dyld_bool processDetachedFromSharedRegion;
71 dyld_bool libSystemInitialized;
72 user32_addr_t dyldImageLoadAddress;
73 user32_addr_t jitInfo;
74 user32_addr_t dyldVersion;
75 user32_addr_t errorMessage;
76 user32_addr_t terminationFlags;
77 user32_addr_t coreSymbolicationShmPage;
78 user32_addr_t systemOrderFlag;
79 user32_size_t uuidArrayCount; // dyld defines this as a uintptr_t despite it being a count
80 user32_addr_t uuidArray;
81 user32_addr_t dyldAllImageInfosAddress;
82
83 /* the following field is only in version 10 (Mac OS X 10.7, iOS 4.2) and later */
84 user32_addr_t initialImageCount;
85 /* the following field is only in version 11 (Mac OS X 10.7, iOS 4.2) and later */
86 user32_addr_t errorKind;
87 user32_addr_t errorClientOfDylibPath;
88 user32_addr_t errorTargetDylibPath;
89 user32_addr_t errorSymbol;
90 /* the following field is only in version 12 (Mac OS X 10.7, iOS 4.3) and later */
91 user32_addr_t sharedCacheSlide;
92 /* the following field is only in version 13 (Mac OS X 10.9, iOS 7.0) and later */
93 uint8_t sharedCacheUUID[16];
94 /* the following field is only in version 15 (Mac OS X 10.12, iOS 10.0) and later */
95 user32_addr_t sharedCacheBaseAddress;
96 uint64_t timestamp;
97 user32_addr_t dyldpath;
98 mach_port_name_t notifyMachPorts[DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT];
99 user32_addr_t reserved[5];
100 /* the following fields are only in version 16 (macOS 10.13, iOS 12.0) and later */
101 user32_addr_t compact_dyld_image_info_addr;
102 user32_size_t compact_dyld_image_info_size;
103};
104
105struct user64_dyld_all_image_infos {
106 uint32_t version;
107 uint32_t infoArrayCount;
108 user64_addr_t infoArray;
109 user64_addr_t notification;
110 dyld_bool processDetachedFromSharedRegion;
111 dyld_bool libSystemInitialized;
112 user64_addr_t dyldImageLoadAddress;
113 user64_addr_t jitInfo;
114 user64_addr_t dyldVersion;
115 user64_addr_t errorMessage;
116 user64_addr_t terminationFlags;
117 user64_addr_t coreSymbolicationShmPage;
118 user64_addr_t systemOrderFlag;
119 user64_size_t uuidArrayCount; // dyld defines this as a uintptr_t despite it being a count
120 user64_addr_t uuidArray;
121 user64_addr_t dyldAllImageInfosAddress;
122
123 /* the following field is only in version 10 (Mac OS X 10.7, iOS 4.2) and later */
124 user64_addr_t initialImageCount;
125 /* the following field is only in version 11 (Mac OS X 10.7, iOS 4.2) and later */
126 user64_addr_t errorKind;
127 user64_addr_t errorClientOfDylibPath;
128 user64_addr_t errorTargetDylibPath;
129 user64_addr_t errorSymbol;
130 /* the following field is only in version 12 (Mac OS X 10.7, iOS 4.3) and later */
131 user64_addr_t sharedCacheSlide;
132 /* the following field is only in version 13 (Mac OS X 10.9, iOS 7.0) and later */
133 uint8_t sharedCacheUUID[16];
134 /* the following field is only in version 15 (macOS 10.12, iOS 10.0) and later */
135 user64_addr_t sharedCacheBaseAddress;
136 uint64_t timestamp;
137 user64_addr_t dyldPath;
138 mach_port_name_t notifyMachPorts[DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT];
139 user64_addr_t reserved[9];
140 /* the following fields are only in version 16 (macOS 10.13, iOS 12.0) and later */
141 user64_addr_t compact_dyld_image_info_addr;
142 user64_size_t compact_dyld_image_info_size;
143 uint32_t platform;
144 /* the following fields are only in version 17 (macOS 10.16) and later */
145 uint32_t aotInfoArrayCount;
146 user64_addr_t aotInfoArray;
147 uint64_t aotTimestamp;
148};
149