1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
3 * Copyright (c) 2003-2006 Apple Computer, Inc. All rights reserved.
5 * @APPLE_LICENSE_HEADER_START@
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
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.
22 * @APPLE_LICENSE_HEADER_END@
24 #ifndef _MACH_O_DYLD_PRIV_H_
25 #define _MACH_O_DYLD_PRIV_H_
28 #include <mach-o/dyld.h>
29 #include <mach-o/dyld_images.h>
33 #endif /* __cplusplus */
37 * Given an imageOffset into an ObjectFileImage, returns
38 * the segment/section name and offset into that section of
39 * that imageOffset. Returns FALSE if the imageOffset is not
40 * in any section. You can used the resulting sectionOffset to
41 * index into the data returned by NSGetSectionDataInObjectFileImage.
43 * First appeared in Mac OS X 10.3
45 * SPI: currently only used by ZeroLink to detect +load methods
48 NSFindSectionAndOffsetInObjectFileImage(
49 NSObjectFileImage objectFileImage
,
50 unsigned long imageOffset
,
51 const char** segmentName
, /* can be NULL */
52 const char** sectionName
, /* can be NULL */
53 unsigned long* sectionOffset
); /* can be NULL */
57 // Possible state changes for which you can register to be notified
59 enum dyld_image_states
61 dyld_image_state_mapped
= 10, // No batch notification for this
62 dyld_image_state_dependents_mapped
= 20, // Only batch notification for this
63 dyld_image_state_rebased
= 30,
64 dyld_image_state_bound
= 40,
65 dyld_image_state_dependents_initialized
= 45, // Only single notification for this
66 dyld_image_state_initialized
= 50,
67 dyld_image_state_terminated
= 60 // FIX ME - only called if image has termination routine
71 // Callback that provides a bottom-up array of images
72 // For dyld_image_state_[dependents_]mapped state only, returning non-NULL will cause dyld to abort loading all those images
73 // and append the returned string to its load failure error message. dyld does not free the string, so
74 // it should be a literal string or a static buffer
76 typedef const char* (*dyld_image_state_change_handler
)(enum dyld_image_states state
, uint32_t infoCount
, const struct dyld_image_info info
[]);
79 // Register a handler to be called when any image changes to the requested state.
80 // If 'batch' is true, the callback is called with an array of all images that are in the requested state sorted by dependency.
81 // If 'batch' is false, the callback is called with one image at a time as each image transitions to the the requested state.
82 // During the call to this function, the handler may be called back with existing images and the handler should
83 // not return a string, since there is no load to abort. In batch mode, existing images at or past the request
84 // state supplied in the callback. In non-batch mode, the callback is called for each image exactly in the
88 dyld_register_image_state_change_handler(enum dyld_image_states state
, bool batch
, dyld_image_state_change_handler handler
);
95 _dyld_library_locator(const char* (*handler
)(const char*));
97 extern void* dlord(void* handle
, uint32_t ordinal
); /* Mac OS X 10.5 and later */
100 #define RTLD_MAIN_ONLY ((void *) -5) /* Search main executable only (Mac OS X 10.5 and later) */
107 #endif /* __cplusplus */
109 #endif /* _MACH_O_DYLD_PRIV_H_ */