dyld-832.7.1.tar.gz
[apple/dyld.git] / include / mach-o / dyld_priv.h
1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
2 *
3 * Copyright (c) 2003-2010 Apple Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 #ifndef _MACH_O_DYLD_PRIV_H_
25 #define _MACH_O_DYLD_PRIV_H_
26
27 #include <assert.h>
28 #include <stdbool.h>
29 #include <unistd.h>
30 #include <Availability.h>
31 #include <TargetConditionals.h>
32 #include <mach-o/dyld.h>
33 #include <uuid/uuid.h>
34
35 #if __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39
40
41 //
42 // private interface between libSystem.dylib and dyld
43 //
44 extern void _dyld_atfork_prepare(void);
45 extern void _dyld_atfork_parent(void);
46 extern void _dyld_fork_child(void);
47
48
49
50 typedef void (*_dyld_objc_notify_mapped)(unsigned count, const char* const paths[], const struct mach_header* const mh[]);
51 typedef void (*_dyld_objc_notify_init)(const char* path, const struct mach_header* mh);
52 typedef void (*_dyld_objc_notify_unmapped)(const char* path, const struct mach_header* mh);
53
54
55 //
56 // Note: only for use by objc runtime
57 // Register handlers to be called when objc images are mapped, unmapped, and initialized.
58 // Dyld will call back the "mapped" function with an array of images that contain an objc-image-info section.
59 // Those images that are dylibs will have the ref-counts automatically bumped, so objc will no longer need to
60 // call dlopen() on them to keep them from being unloaded. During the call to _dyld_objc_notify_register(),
61 // dyld will call the "mapped" function with already loaded objc images. During any later dlopen() call,
62 // dyld will also call the "mapped" function. Dyld will call the "init" function when dyld would be called
63 // initializers in that image. This is when objc calls any +load methods in that image.
64 //
65 void _dyld_objc_notify_register(_dyld_objc_notify_mapped mapped,
66 _dyld_objc_notify_init init,
67 _dyld_objc_notify_unmapped unmapped);
68
69
70 //
71 // get slide for a given loaded mach_header
72 // Mac OS X 10.6 and later
73 //
74 extern intptr_t _dyld_get_image_slide(const struct mach_header* mh);
75
76
77
78 struct dyld_unwind_sections
79 {
80 const struct mach_header* mh;
81 const void* dwarf_section;
82 uintptr_t dwarf_section_length;
83 const void* compact_unwind_section;
84 uintptr_t compact_unwind_section_length;
85 };
86
87
88 //
89 // Returns true iff some loaded mach-o image contains "addr".
90 // info->mh mach header of image containing addr
91 // info->dwarf_section pointer to start of __TEXT/__eh_frame section
92 // info->dwarf_section_length length of __TEXT/__eh_frame section
93 // info->compact_unwind_section pointer to start of __TEXT/__unwind_info section
94 // info->compact_unwind_section_length length of __TEXT/__unwind_info section
95 //
96 // Exists in Mac OS X 10.6 and later
97 #if !__USING_SJLJ_EXCEPTIONS__
98 extern bool _dyld_find_unwind_sections(void* addr, struct dyld_unwind_sections* info);
99 #endif
100
101
102 //
103 // This is an optimized form of dladdr() that only returns the dli_fname field.
104 //
105 // Exists in Mac OS X 10.6 and later
106 extern const char* dyld_image_path_containing_address(const void* addr);
107
108
109 //
110 // This is an optimized form of dladdr() that only returns the dli_fbase field.
111 // Return NULL, if address is not in any image tracked by dyld.
112 //
113 // Exists in Mac OS X 10.11 and later
114 extern const struct mach_header* dyld_image_header_containing_address(const void* addr);
115
116 //
117 // Return the mach header of the process
118 //
119 // Exists in Mac OS X 10.16 and later
120 extern const struct mach_header* _dyld_get_prog_image_header(void);
121
122 typedef uint32_t dyld_platform_t;
123
124 typedef struct {
125 dyld_platform_t platform;
126 uint32_t version;
127 } dyld_build_version_t;
128
129 // Returns the active platform of the process
130 extern dyld_platform_t dyld_get_active_platform(void) __API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0), bridgeos(3.0));
131
132 // Base platforms are platforms that have version numbers (macOS, iOS, watchos, tvOS, bridgeOS)
133 // All other platforms are mapped to a base platform for version checks
134
135 // It is intended that most code in the OS will use the version set constants, which will correctly deal with secret and future
136 // platforms. For example:
137
138 // if (dyld_program_sdk_at_least(dyld_fall_2018_os_versions)) {
139 // New behaviour for programs built against the iOS 12, tvOS 12, watchOS 5, macOS 10.14, or bridgeOS 3 (or newer) SDKs
140 // } else {
141 // Old behaviour
142 // }
143
144 // In cases where more precise control is required (such as APIs that were added to varions platforms in different years)
145 // the os specific values may be used instead. Unlike the version set constants, the platform specific ones will only ever
146 // return true if the running binary is the platform being testsed, allowing conditions to be built for specific platforms
147 // and releases that came out at different times. For example:
148
149 // if (dyld_program_sdk_at_least(dyld_platform_version_iOS_12_0)
150 // || dyld_program_sdk_at_least(dyld_platform_version_watchOS_6_0)) {
151 // New behaviour for programs built against the iOS 12 (fall 2018), watchOS 6 (fall 2019) (or newer) SDKs
152 // } else {
153 // Old behaviour all other platforms, as well as older iOSes and watchOSes
154 // }
155
156 extern dyld_platform_t dyld_get_base_platform(dyld_platform_t platform) __API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0), bridgeos(3.0));
157
158 // SPI to ask if a platform is a simulation platform
159 extern bool dyld_is_simulator_platform(dyld_platform_t platform) __API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0), bridgeos(3.0));
160
161 // Takes a version and returns if the image was built againt that SDK or newer
162 // In the case of multi_plaform mach-o's it tests against the active platform
163 extern bool dyld_sdk_at_least(const struct mach_header* mh, dyld_build_version_t version) __API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0), bridgeos(3.0));
164
165 // Takes a version and returns if the image was built with that minos version or newer
166 // In the case of multi_plaform mach-o's it tests against the active platform
167 extern bool dyld_minos_at_least(const struct mach_header* mh, dyld_build_version_t version) __API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0), bridgeos(3.0));
168
169 // Convenience versions of the previous two functions that run against the the main executable
170 extern bool dyld_program_sdk_at_least(dyld_build_version_t version) __API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0), bridgeos(3.0));
171 extern bool dyld_program_minos_at_least(dyld_build_version_t version) __API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0), bridgeos(3.0));
172
173 // Function that walks through the load commands and calls the internal block for every version found
174 // Intended as a fallback for very complex (and rare) version checks, or for tools that need to
175 // print our everything for diagnostic reasons
176 extern void dyld_get_image_versions(const struct mach_header* mh, void (^callback)(dyld_platform_t platform, uint32_t sdk_version, uint32_t min_version)) __API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0), bridgeos(3.0));
177
178 // Convienence constants for dyld version SPIs.
179
180 // Because we now have so many different OSes with different versions these version set values are intended to
181 // to provide a more convenient way to version check. They may be used instead of platform specific version in
182 // dyld_sdk_at_least(), dyld_minos_at_least(), dyld_program_sdk_at_least(), and dyld_program_minos_at_least().
183 // Since they are references into a lookup table they MUST NOT be used by any code that does not ship as part of
184 // the OS, as the values may change and the tables in older OSes may not have the necessary values for back
185 // deployed binaries. These values are future proof against new platforms being added, and any checks against
186 // platforms that did not exist at the epoch of a version set will return true since all versions of that platform
187 // are inherently newer.
188
189 //@VERSION_DEFS@
190
191 //
192 // This finds the SDK version a binary was built against.
193 // Returns zero on error, or if SDK version could not be determined.
194 //
195 // Exists in Mac OS X 10.8 and later
196 // Exists in iOS 6.0 and later
197 extern uint32_t dyld_get_sdk_version(const struct mach_header* mh);
198
199
200 //
201 // This finds the SDK version that the main executable was built against.
202 // Returns zero on error, or if SDK version could not be determined.
203 //
204 // Note on watchOS, this returns the equivalent iOS SDK version number
205 // (i.e an app built against watchOS 2.0 SDK returne 9.0). To see the
206 // platform specific sdk version use dyld_get_program_sdk_watch_os_version().
207 //
208 // Exists in Mac OS X 10.8 and later
209 // Exists in iOS 6.0 and later
210 extern uint32_t dyld_get_program_sdk_version(void);
211
212 #if TARGET_OS_WATCH
213 // watchOS only.
214 // This finds the Watch OS SDK version that the main executable was built against.
215 // Exists in Watch OS 2.0 and later
216 extern uint32_t dyld_get_program_sdk_watch_os_version(void) __API_AVAILABLE(watchos(2.0));
217
218
219 // watchOS only.
220 // This finds the Watch min OS version that the main executable was built to run on.
221 // Note: dyld_get_program_min_os_version() returns the iOS equivalent (e.g. 9.0)
222 // whereas this returns the raw watchOS version (e.g. 2.0).
223 // Exists in Watch OS 3.0 and later
224 extern uint32_t dyld_get_program_min_watch_os_version(void) __API_AVAILABLE(watchos(3.0));
225 #endif
226
227 #if TARGET_OS_BRIDGE
228 // bridgeOS only.
229 // This finds the bridgeOS SDK version that the main executable was built against.
230 // Exists in bridgeOSOS 2.0 and later
231 extern uint32_t dyld_get_program_sdk_bridge_os_version(void) __API_AVAILABLE(bridgeos(2.0));
232
233 // bridgeOS only.
234 // This finds the Watch min OS version that the main executable was built to run on.
235 // Note: dyld_get_program_min_os_version() returns the iOS equivalent (e.g. 9.0)
236 // whereas this returns the raw bridgeOS version (e.g. 2.0).
237 // Exists in bridgeOS 2.0 and later
238 extern uint32_t dyld_get_program_min_bridge_os_version(void) __API_AVAILABLE(bridgeos(2.0));
239 #endif
240
241 //
242 // This finds the min OS version a binary was built to run on.
243 // Returns zero on error, or if no min OS recorded in binary.
244 //
245 // Exists in Mac OS X 10.8 and later
246 // Exists in iOS 6.0 and later
247 extern uint32_t dyld_get_min_os_version(const struct mach_header* mh);
248
249
250 //
251 // This finds the min OS version the main executable was built to run on.
252 // Returns zero on error, or if no min OS recorded in binary.
253 //
254 // Exists in Mac OS X 10.8 and later
255 // Exists in iOS 6.0 and later
256 extern uint32_t dyld_get_program_min_os_version(void);
257
258
259
260
261 //
262 // Returns if any OS dylib has overridden its copy in the shared cache
263 //
264 // Exists in iPhoneOS 3.1 and later
265 // Exists in Mac OS X 10.10 and later
266 extern bool dyld_shared_cache_some_image_overridden(void);
267
268
269
270 //
271 // Returns if the process is setuid or is code signed with entitlements.
272 // NOTE: It is safe to call this prior to malloc being initialized. This function
273 // is guaranteed to not call malloc, or depend on its state.
274 //
275 // Exists in Mac OS X 10.9 and later
276 extern bool dyld_process_is_restricted(void);
277
278
279
280 //
281 // Returns path used by dyld for standard dyld shared cache file for the current arch.
282 //
283 // Exists in Mac OS X 10.11 and later
284 extern const char* dyld_shared_cache_file_path(void);
285
286
287
288 //
289 // Returns if there are any inserted (via DYLD_INSERT_LIBRARIES) or interposing libraries.
290 //
291 // Exists in Mac OS X 10.15 and later
292 extern bool dyld_has_inserted_or_interposing_libraries(void);
293
294 //
295 // Return true if dyld contains a fix for a specific identifier. Intended for staging breaking SPI
296 // changes
297 //
298 // Exists in macOS 10.16, iOS 14, tvOS14, watchOS 7 and later
299
300 extern bool _dyld_has_fix_for_radar(const char *rdar);
301
302
303 //
304 // <rdar://problem/13820686> for OpenGL to tell dyld it is ok to deallocate a memory based image when done.
305 //
306 // Exists in Mac OS X 10.9 and later
307 #define NSLINKMODULE_OPTION_CAN_UNLOAD 0x20
308
309
310 //
311 // Update all bindings on specified image.
312 // Looks for uses of 'replacement' and changes it to 'replacee'.
313 // NOTE: this is less safe than using static interposing via DYLD_INSERT_LIBRARIES
314 // because the running program may have already copy the pointer values to other
315 // locations that dyld does not know about.
316 //
317 struct dyld_interpose_tuple {
318 const void* replacement;
319 const void* replacee;
320 };
321 extern void dyld_dynamic_interpose(const struct mach_header* mh, const struct dyld_interpose_tuple array[], size_t count);
322
323
324 struct dyld_shared_cache_dylib_text_info {
325 uint64_t version; // current version 2
326 // following fields all exist in version 1
327 uint64_t loadAddressUnslid;
328 uint64_t textSegmentSize;
329 uuid_t dylibUuid;
330 const char* path; // pointer invalid at end of iterations
331 // following fields all exist in version 2
332 uint64_t textSegmentOffset; // offset from start of cache
333 };
334 typedef struct dyld_shared_cache_dylib_text_info dyld_shared_cache_dylib_text_info;
335
336
337 #ifdef __BLOCKS__
338 //
339 // Given the UUID of a dyld shared cache file, this function will attempt to locate the cache
340 // file and if found iterate all images, returning info about each one. Returns 0 on success.
341 //
342 // Exists in Mac OS X 10.11 and later
343 // iOS 9.0 and later
344 extern int dyld_shared_cache_iterate_text(const uuid_t cacheUuid, void (^callback)(const dyld_shared_cache_dylib_text_info* info));
345
346
347 //
348 // Given the UUID of a dyld shared cache file, and a NULL terminated array of extra directory paths to search,
349 // this function will scan the standard and extra directories looking for a cache file that matches the UUID
350 // and if found iterate all images, returning info about each one. Returns 0 on success.
351 //
352 // Exists in Mac OS X 10.12 and later
353 // iOS 10.0 and later
354 extern int dyld_shared_cache_find_iterate_text(const uuid_t cacheUuid, const char* extraSearchDirs[], void (^callback)(const dyld_shared_cache_dylib_text_info* info));
355 #endif /* __BLOCKS */
356
357
358 //
359 // Returns if the specified address range is in a dyld owned memory
360 // that is mapped read-only and will never be unloaded.
361 //
362 // Exists in Mac OS X 10.12 and later
363 // iOS 10.0 and later
364 extern bool _dyld_is_memory_immutable(const void* addr, size_t length);
365
366
367 //
368 // Finds the UUID (from LC_UUID load command) of given image.
369 // Returns false if LC_UUID is missing or mach_header is malformed.
370 //
371 // Exists in Mac OS X 10.12 and later
372 // Exists in iOS 10.0 and later
373 extern bool _dyld_get_image_uuid(const struct mach_header* mh, uuid_t uuid);
374
375
376 //
377 // Gets the UUID of the dyld shared cache in the current process.
378 // Returns false if there is no dyld shared cache in use by the processes.
379 //
380 // Exists in Mac OS X 10.12 and later
381 // Exists in iOS 10.0 and later
382 extern bool _dyld_get_shared_cache_uuid(uuid_t uuid);
383
384
385 //
386 // Returns the start address of the dyld cache in the process and sets length to the size of the cache.
387 // Returns NULL if the process is not using a dyld shared cache
388 //
389 // Exists in Mac OS X 10.13 and later
390 // Exists in iOS 11.0 and later
391 extern const void* _dyld_get_shared_cache_range(size_t* length);
392
393
394 //
395 // Returns if the currently active dyld shared cache is optimized.
396 // Note: macOS does not use optimized caches and will always return false.
397 //
398 // Exists in Mac OS X 10.15 and later
399 // Exists in iOS 13.0 and later
400 extern bool _dyld_shared_cache_optimized(void);
401
402
403 //
404 // Returns if the currently active dyld shared cache was built locally.
405 //
406 // Exists in Mac OS X 10.15 and later
407 // Exists in iOS 13.0 and later
408 extern bool _dyld_shared_cache_is_locally_built(void);
409
410 //
411 // Returns if the given app needs a closure built.
412 //
413 // Exists in Mac OS X 10.15 and later
414 // Exists in iOS 13.0 and later
415 extern bool dyld_need_closure(const char* execPath, const char* dataContainerRootDir);
416
417
418 struct dyld_image_uuid_offset {
419 uuid_t uuid;
420 uint64_t offsetInImage;
421 const struct mach_header* image;
422 };
423
424 //
425 // Given an array of addresses, returns info about each address.
426 // Common usage is the array or addresses was produced by a stack backtrace.
427 // For each address, returns the where that image was loaded, the offset
428 // of the address in the image, and the image's uuid. If a specified
429 // address is unknown to dyld, all fields will be returned a zeros.
430 //
431 // Exists in macOS 10.14 and later
432 // Exists in iOS 12.0 and later
433 extern void _dyld_images_for_addresses(unsigned count, const void* addresses[], struct dyld_image_uuid_offset infos[]);
434
435
436 //
437 // Lets you register a callback which is called each time an image is loaded and provides the mach_header*, path, and
438 // whether the image may be unloaded later. During the call to _dyld_register_for_image_loads(), the callback is called
439 // once for each image currently loaded.
440 //
441 // Exists in macOS 10.14 and later
442 // Exists in iOS 12.0 and later
443 extern void _dyld_register_for_image_loads(void (*func)(const struct mach_header* mh, const char* path, bool unloadable));
444
445
446
447
448 //
449 // Lets you register a callback which is called for bulk notifications of images loaded. During the call to
450 // _dyld_register_for_bulk_image_loads(), the callback is called once with all images currently loaded.
451 // Then later during dlopen() the callback is called once with all newly images.
452 //
453 // Exists in macOS 10.15 and later
454 // Exists in iOS 13.0 and later
455 extern void _dyld_register_for_bulk_image_loads(void (*func)(unsigned imageCount, const struct mach_header* mhs[], const char* paths[]));
456
457
458 //
459 // DriverKit main executables do not have an LC_MAIN. Instead DriverKit.framework's initializer calls
460 // _dyld_register_driverkit_main() with a function pointer that dyld should call into instead
461 // of using LC_MAIN.
462 //
463 extern void _dyld_register_driverkit_main(void (*mainFunc)(void));
464
465
466 //
467 // This is similar to _dyld_shared_cache_contains_path(), except that it returns the canonical
468 // shared cache path for the given path.
469 //
470 // Exists in macOS 10.16 and later
471 // Exists in iOS 14.0 and later
472 extern const char* _dyld_shared_cache_real_path(const char* path);
473
474
475 //
476 // Dyld has a number of modes. This function returns the mode for the current process.
477 // dyld2 is the classic "interpreter" way to run.
478 // dyld3 runs by compiling down and caching what dyld needs to do into a "closure".
479 //
480 // Exists in macOS 10.16 and later
481 // Exists in iOS 14.0 and later
482 //
483 #define DYLD_LAUNCH_MODE_USING_CLOSURE 0x00000001 // if 0, then running in classic dyld2 mode
484 #define DYLD_LAUNCH_MODE_BUILT_CLOSURE_AT_LAUNCH 0x00000002 // launch was slow, to build closure
485 #define DYLD_LAUNCH_MODE_CLOSURE_SAVED_TO_FILE 0x00000004 // next launch will be faster
486 #define DYLD_LAUNCH_MODE_CLOSURE_FROM_OS 0x00000008 // closure built into dyld cache
487 #define DYLD_LAUNCH_MODE_MINIMAL_CLOSURE 0x00000010 // closure does not contain fix ups
488 extern uint32_t _dyld_launch_mode(void);
489
490
491 //
492 // When dyld must terminate a process because of a required dependent dylib
493 // could not be loaded or a symbol is missing, dyld calls abort_with_reason()
494 // using one of the following error codes.
495 //
496 #define DYLD_EXIT_REASON_DYLIB_MISSING 1
497 #define DYLD_EXIT_REASON_DYLIB_WRONG_ARCH 2
498 #define DYLD_EXIT_REASON_DYLIB_WRONG_VERSION 3
499 #define DYLD_EXIT_REASON_SYMBOL_MISSING 4
500 #define DYLD_EXIT_REASON_CODE_SIGNATURE 5
501 #define DYLD_EXIT_REASON_FILE_SYSTEM_SANDBOX 6
502 #define DYLD_EXIT_REASON_MALFORMED_MACHO 7
503 #define DYLD_EXIT_REASON_OTHER 9
504
505 //
506 // When it has more information about the termination, dyld will use abort_with_payload().
507 // The payload is a dyld_abort_payload structure. The fixed fields are offsets into the
508 // payload for the corresponding string. If the offset is zero, that string is not available.
509 //
510 struct dyld_abort_payload {
511 uint32_t version; // first version is 1
512 uint32_t flags; // 0x00000001 means dyld terminated at launch, backtrace not useful
513 uint32_t targetDylibPathOffset; // offset in payload of path string to dylib that could not be loaded
514 uint32_t clientPathOffset; // offset in payload of path string to image requesting dylib
515 uint32_t symbolOffset; // offset in payload of symbol string that could not be found
516 // string data
517 };
518 typedef struct dyld_abort_payload dyld_abort_payload;
519
520
521 // These global variables are implemented in libdyld.dylib
522 // Old programs that used crt1.o also defined these globals.
523 // The ones in dyld are not used when an old program is run.
524 extern int NXArgc;
525 extern const char** NXArgv;
526 extern char** environ; // POSIX says this not const, because it pre-dates const
527 extern const char* __progname;
528
529
530 // called by libSystem_initializer only
531 extern void _dyld_initializer(void);
532
533 // never called from source code. Used by static linker to implement lazy binding
534 extern void dyld_stub_binder(void) __asm__("dyld_stub_binder");
535
536 // never call from source code. Used by closure builder to bind missing lazy symbols to
537 extern void _dyld_missing_symbol_abort(void);
538
539 // Called only by objc to see if dyld has uniqued this selector.
540 // Returns the value if dyld has uniqued it, or nullptr if it has not.
541 // Note, this function must be called after _dyld_objc_notify_register.
542 //
543 // Exists in Mac OS X 10.15 and later
544 // Exists in iOS 13.0 and later
545 extern const char* _dyld_get_objc_selector(const char* selName);
546
547
548 // Called only by objc to see if dyld has pre-optimized classes with this name.
549 // The callback will be called once for each class with the given name where
550 // isLoaded is true if that class is in a binary which has been previously passed
551 // to the objc load notifier.
552 // Note you can set stop to true to stop iterating.
553 // Also note, this function must be called after _dyld_objc_notify_register.
554 //
555 // Exists in Mac OS X 10.15 and later
556 // Exists in iOS 13.0 and later
557 extern void _dyld_for_each_objc_class(const char* className,
558 void (^callback)(void* classPtr, bool isLoaded, bool* stop));
559
560
561 // Called only by objc to see if dyld has pre-optimized protocols with this name.
562 // The callback will be called once for each protocol with the given name where
563 // isLoaded is true if that protocol is in a binary which has been previously passed
564 // to the objc load notifier.
565 // Note you can set stop to true to stop iterating.
566 // Also note, this function must be called after _dyld_objc_notify_register.
567 //
568 // Exists in Mac OS X 10.15 and later
569 // Exists in iOS 13.0 and later
570 extern void _dyld_for_each_objc_protocol(const char* protocolName,
571 void (^callback)(void* protocolPtr, bool isLoaded, bool* stop));
572
573
574 // called by exit() before it calls cxa_finalize() so that thread_local
575 // objects are destroyed before global objects.
576 extern void _tlv_exit(void);
577
578 typedef enum {
579 dyld_objc_string_kind
580 } DyldObjCConstantKind;
581
582 // CF constants such as CFString's can be moved in to a contiguous range of
583 // shared cache memory. This returns true if the given pointer is to an object of
584 // the given kind.
585 //
586 // Exists in Mac OS X 10.16 and later
587 // Exists in iOS 14.0 and later
588 extern bool _dyld_is_objc_constant(DyldObjCConstantKind kind, const void* addr);
589
590
591 // temp exports to keep tapi happy, until ASan stops using dyldVersionNumber
592 extern double dyldVersionNumber;
593 extern const char* dyldVersionString;
594
595 #if __cplusplus
596 }
597 #endif /* __cplusplus */
598
599 #endif /* _MACH_O_DYLD_PRIV_H_ */