]> git.saurik.com Git - apple/dyld.git/blame - include/mach-o/dyld_priv.h
dyld-97.1.tar.gz
[apple/dyld.git] / include / mach-o / dyld_priv.h
CommitLineData
bac542e6
A
1/* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
2 *
3 * Copyright (c) 2003-2006 Apple Computer, Inc. All rights reserved.
0959b6d4
A
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
28#include <mach-o/dyld.h>
bac542e6 29#include <mach-o/dyld_images.h>
0959b6d4
A
30
31#if __cplusplus
32extern "C" {
33#endif /* __cplusplus */
34
35
36/*
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.
42 *
43 * First appeared in Mac OS X 10.3
44 *
45 * SPI: currently only used by ZeroLink to detect +load methods
46 */
47bool
48NSFindSectionAndOffsetInObjectFileImage(
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 */
54
55
bac542e6
A
56//
57// Possible state changes for which you can register to be notified
58//
59enum dyld_image_states
60{
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
68};
69
70//
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
75//
76typedef const char* (*dyld_image_state_change_handler)(enum dyld_image_states state, uint32_t infoCount, const struct dyld_image_info info[]);
77
78//
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
85// requested state.
86//
87extern void
88dyld_register_image_state_change_handler(enum dyld_image_states state, bool batch, dyld_image_state_change_handler handler);
89
90
91//
92//
93//
94extern void
95_dyld_library_locator(const char* (*handler)(const char*));
96
97extern void* dlord(void* handle, uint32_t ordinal); /* Mac OS X 10.5 and later */
98
99
100#define RTLD_MAIN_ONLY ((void *) -5) /* Search main executable only (Mac OS X 10.5 and later) */
101
102
0959b6d4
A
103
104
105#if __cplusplus
106}
107#endif /* __cplusplus */
108
109#endif /* _MACH_O_DYLD_PRIV_H_ */