]> git.saurik.com Git - apple/dyld.git/blob - include/mach-o/dyld_images.h
1f7b96b87a0e830781e9439954988bceececa51e
[apple/dyld.git] / include / mach-o / dyld_images.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 #ifndef _DYLD_IMAGES_
24 #define _DYLD_IMAGES_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30
31 /*
32 * Beginning in Mac OS X 10.4, this is how gdb discovers which mach-o images are loaded in a process.
33 *
34 * gdb looks for the symbol "_dyld_all_image_infos" in dyld. It contains the fields below.
35 *
36 * For a snashot of what images are currently loaded, the infoArray fields contain a pointer
37 * to an array of all images. If infoArray is NULL, it means it is being modified, come back later.
38 *
39 * To be notified of changes, gdb sets a break point on the address pointed to by the notificationn
40 * field. The function it points to is called by dyld with an array of information about what images
41 * have been added (dyld_image_adding) or are about to be removed (dyld_image_removing).
42 *
43 * The notification is called after infoArray is updated. This means that if gdb attaches to a process
44 * and infoArray is NULL, gdb can set a break point on notification and let the proccess continue to
45 * run until the break point. Then gdb can inspect the full infoArray.
46 */
47
48 enum dyld_image_mode { dyld_image_adding=0, dyld_image_removing=1 };
49
50 struct dyld_image_info {
51 const struct mach_header* imageLoadAddress; /* base address image is mapped into */
52 const char* imageFilePath; /* path dyld used to load the image */
53 uintptr_t imageFileModDate; /* time_t of image file */
54 /* if stat().st_mtime of imageFilePath does not match imageFileModDate, */
55 /* then file has been modified since dyld loaded it */
56 };
57
58 typedef void (*dyld_image_notifier)(enum dyld_image_mode mode, uint32_t infoCount, const struct dyld_image_info info[]);
59
60 struct dyld_all_image_infos {
61 uint32_t version; /* == 1 in Mac OS X 10.4 */
62 uint32_t infoArrayCount;
63 const struct dyld_image_info* infoArray;
64 dyld_image_notifier notification;
65 bool processDetachedFromSharedRegion;
66 };
67 extern struct dyld_all_image_infos dyld_all_image_infos;
68
69
70
71
72 /*
73 * Beginning in Mac OS X 10.5, this is how gdb discovers where the shared cache is in a process.
74 * Images that are in the shared cache have their segments rearranged, so when using imageFilePath
75 * to load the file from disk, you have to know to adjust addresses based on how their segment
76 * was rearranged.
77 *
78 * gdb looks for the symbol "_dyld_shared_region_ranges" in dyld.
79 *
80 * It contains information the count of shared regions used by the process. The count is
81 * the number of start/length pairs.
82 */
83 struct dyld_shared_cache_ranges {
84 uintptr_t sharedRegionsCount; /* how many ranges follow */
85 struct {
86 uintptr_t start;
87 uintptr_t length;
88 } ranges[4]; /* max regions */
89 };
90 extern struct dyld_shared_cache_ranges dyld_shared_cache_ranges;
91
92
93
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif /* _DYLD_IMAGES_ */