5 .Nm _dyld_get_image_header,
6 .Nm _dyld_get_image_vmaddr_slide,
7 .Nm _dyld_get_image_name,
8 .Nm _dyld_register_func_for_add_image,
9 .Nm _dyld_register_func_for_remove_image,
10 .Nm NSVersionOfRunTimeLibrary,
11 .Nm NSVersionOfLinkTimeLibrary
12 .Nm _NSGetExecutablePath
19 .Ft const struct mach_header*
20 .Fo _dyld_get_image_header
21 .Fa "uint32_t image_index"
24 .Fo _dyld_get_image_vmaddr_slide
25 .Fa "uint32_t image_index"
28 .Fo _dyld_get_image_name
29 .Fa "uint32_t image_index"
32 .Fo _dyld_register_func_for_add_image
33 .Fa "void \*[lp]*func\*[rp]\*[lp]const struct mach_header* mh, intptr_t vmaddr_slide\*[rp]"
36 .Fo _dyld_register_func_for_remove_image
37 .Fa "void \*[lp]*func\*[rp]\*[lp]const struct mach_header* mh, intptr_t vmaddr_slide\*[rp]"
40 .Fo NSVersionOfRunTimeLibrary
41 .Fa "const char* libraryName"
44 .Fo NSVersionOfLinkTimeLibrary
45 .Fa "const char* libraryName"
48 .Fo _NSGetExecutablePath
50 .Fa "uint32_t* bufsize"
53 These routines provide additional introspection of dyld beyond that provided by
60 returns the current number of images mapped in by dyld. Note that using this
61 count to iterate all images is not thread safe, because another thread
62 may be adding or removing images during the iteration.
64 .Fn _dyld_get_image_header
65 returns a pointer to the mach header of the image indexed by image_index. If
67 is out of range, NULL is returned.
69 .Fn _dyld_get_image_vmaddr_slide
70 returns the virtural memory address slide amount of the image indexed by
74 is out of range zero is returned.
76 .Fn _dyld_get_image_name
77 returns the name of the image indexed by
79 The C-string continues to be owned by dyld and should not deleted.
82 is out of range NULL is returned.
84 .Fn _dyld_register_func_for_add_image
85 registers the specified function to be called when a new image is added
86 (a bundle or a dynamic shared library) to the program. When this function is
87 first registered it is called for once for each image that is currently part of
88 the process. The function is called with the dyld lock held. This blocks other
89 threads from using dlopen(). Therefore, the function should do minimal work and
92 .Fn _dyld_register_func_for_remove_image
93 registers the specified function to be called when an image is removed
94 (a bundle or a dynamic shared library) from the process.
96 .Fn NSVersionOfRunTimeLibrary
97 returns the current_version number of the currently loaded dylib
98 specifed by the libraryName. The libraryName parameter would be "bar" for /path/libbar.3.dylib and
99 "Foo" for /path/Foo.framework/Versions/A/Foo. This function returns -1 if no such library is loaded.
101 .Fn NSVersionOfLinkTimeLibrary
102 returns the current_version number that the main executable was linked
103 against at build time. The libraryName parameter would be "bar" for /path/libbar.3.dylib and
104 "Foo" for /path/Foo.framework/Versions/A/Foo. This function returns -1 if the main executable did not link
105 against the specified library.
107 .Fn _NSGetExecutablePath
108 copies the path of the main executable into the buffer
112 parameter should initially be the size of the buffer. This function returns 0 if the path was successfully copied,
116 It returns -1 if the buffer is not large enough, and *
118 is set to the size required.
120 .Fn _NSGetExecutablePath
121 will return "a path" to the executable not a "real path" to the executable.
122 That is, the path may be a symbolic link and not the real file. With deep directories the total bufsize
123 needed could be more than MAXPATHLEN.
128 https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/MachOTopics/0-Introduction/introduction.html