xref: /xnu-8020.101.4/osfmk/kdp/kdp_dyld.h (revision e7776783b89a353188416a9a346c6cdb4928faad)
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 
38 #define DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT 8
39 #define DYLD_PROCESS_INFO_NOTIFY_MAGIC 0x49414E46
40 
41 /* Re-use dyld format for kext load addresses */
42 #if __LP64__
43 typedef struct user64_dyld_uuid_info kernel_uuid_info;
44 #else
45 typedef struct user32_dyld_uuid_info kernel_uuid_info;
46 #endif
47 
48 struct user32_dyld_image_info {
49 	user32_addr_t   imageLoadAddress;       /* base address image is mapped int */
50 	user32_addr_t   imageFilePath;          /* path dyld used to load the image */
51 	user32_ulong_t  imageFileModDate;       /* time_t of image file */
52 };
53 
54 struct user64_dyld_image_info {
55 	user64_addr_t   imageLoadAddress;       /* base address image is mapped int */
56 	user64_addr_t   imageFilePath;          /* path dyld used to load the image */
57 	user64_ulong_t  imageFileModDate;       /* time_t of image file */
58 };
59 
60 // FIXME: dyld is in C++, and some of the fields in dyld_all_image_infos are C++
61 // native booleans.  There must be a better way...
62 typedef uint8_t dyld_bool;
63 
64 struct user32_dyld_all_image_infos {
65 	uint32_t                                        version;
66 	uint32_t                                        infoArrayCount;
67 	user32_addr_t                           infoArray;
68 	user32_addr_t                           notification;
69 	dyld_bool                                       processDetachedFromSharedRegion;
70 	dyld_bool                                       libSystemInitialized;
71 	user32_addr_t                           dyldImageLoadAddress;
72 	user32_addr_t                           jitInfo;
73 	user32_addr_t                           dyldVersion;
74 	user32_addr_t                           errorMessage;
75 	user32_addr_t                           terminationFlags;
76 	user32_addr_t                           coreSymbolicationShmPage;
77 	user32_addr_t                           systemOrderFlag;
78 	user32_size_t uuidArrayCount; // dyld defines this as a uintptr_t despite it being a count
79 	user32_addr_t uuidArray;
80 	user32_addr_t dyldAllImageInfosAddress;
81 
82 	/* the following field is only in version 10 (Mac OS X 10.7, iOS 4.2) and later */
83 	user32_addr_t initialImageCount;
84 	/* the following field is only in version 11 (Mac OS X 10.7, iOS 4.2) and later */
85 	user32_addr_t errorKind;
86 	user32_addr_t errorClientOfDylibPath;
87 	user32_addr_t errorTargetDylibPath;
88 	user32_addr_t errorSymbol;
89 	/* the following field is only in version 12 (Mac OS X 10.7, iOS 4.3) and later */
90 	user32_addr_t sharedCacheSlide;
91 	/* the following field is only in version 13 (Mac OS X 10.9, iOS 7.0) and later */
92 	uint8_t sharedCacheUUID[16];
93 	/* the following field is only in version 15 (Mac OS X 10.12, iOS 10.0) and later */
94 	user32_addr_t   sharedCacheBaseAddress;
95 	uint64_t        timestamp;
96 	user32_addr_t   dyldpath;
97 	mach_port_name_t notifyMachPorts[DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT];
98 	user32_addr_t   reserved[5];
99 	/* the following fields are only in version 16 (macOS 10.13, iOS 12.0) and later */
100 	user32_addr_t compact_dyld_image_info_addr;
101 	user32_size_t compact_dyld_image_info_size;
102 };
103 
104 struct user64_dyld_all_image_infos {
105 	uint32_t                                        version;
106 	uint32_t                                        infoArrayCount;
107 	user64_addr_t                           infoArray;
108 	user64_addr_t                           notification;
109 	dyld_bool                                       processDetachedFromSharedRegion;
110 	dyld_bool                                       libSystemInitialized;
111 	user64_addr_t                           dyldImageLoadAddress;
112 	user64_addr_t                           jitInfo;
113 	user64_addr_t                           dyldVersion;
114 	user64_addr_t                           errorMessage;
115 	user64_addr_t                           terminationFlags;
116 	user64_addr_t                           coreSymbolicationShmPage;
117 	user64_addr_t                           systemOrderFlag;
118 	user64_size_t uuidArrayCount; // dyld defines this as a uintptr_t despite it being a count
119 	user64_addr_t uuidArray;
120 	user64_addr_t dyldAllImageInfosAddress;
121 
122 	/* the following field is only in version 10 (Mac OS X 10.7, iOS 4.2) and later */
123 	user64_addr_t initialImageCount;
124 	/* the following field is only in version 11 (Mac OS X 10.7, iOS 4.2) and later */
125 	user64_addr_t errorKind;
126 	user64_addr_t errorClientOfDylibPath;
127 	user64_addr_t errorTargetDylibPath;
128 	user64_addr_t errorSymbol;
129 	/* the following field is only in version 12 (Mac OS X 10.7, iOS 4.3) and later */
130 	user64_addr_t sharedCacheSlide;
131 	/* the following field is only in version 13 (Mac OS X 10.9, iOS 7.0) and later */
132 	uint8_t sharedCacheUUID[16];
133 	/* the following field is only in version 15 (macOS 10.12, iOS 10.0) and later */
134 	user64_addr_t   sharedCacheBaseAddress;
135 	uint64_t        timestamp;
136 	user64_addr_t   dyldPath;
137 	mach_port_name_t notifyMachPorts[DYLD_MAX_PROCESS_INFO_NOTIFY_COUNT];
138 	user64_addr_t   reserved[9];
139 	/* the following fields are only in version 16 (macOS 10.13, iOS 12.0) and later */
140 	user64_addr_t compact_dyld_image_info_addr;
141 	user64_size_t compact_dyld_image_info_size;
142 	uint32_t        platform;
143 	/* the following fields are only in version 17 (macOS 10.16) and later */
144 	uint32_t                                aotInfoArrayCount;
145 	user64_addr_t                           aotInfoArray;
146 	uint64_t                                aotTimestamp;
147 };
148