]> git.saurik.com Git - apple/dyld.git/blob - dyld3/APIs.h
dyld-551.4.tar.gz
[apple/dyld.git] / dyld3 / APIs.h
1 /*
2 * Copyright (c) 2017 Apple 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
24
25
26 #ifndef __DYLD_APIS_H__
27 #define __DYLD_APIS_H__
28
29 #include <string.h>
30 #include <stdint.h>
31
32 #include "dlfcn.h"
33 #include "dyld_priv.h"
34
35
36 #define TEMP_HIDDEN __attribute__((visibility("hidden")))
37
38 namespace dyld3 {
39
40
41 uint32_t _dyld_image_count() TEMP_HIDDEN;
42
43 const mach_header* _dyld_get_image_header(uint32_t imageIndex) TEMP_HIDDEN;
44
45 intptr_t _dyld_get_image_slide(const mach_header* mh) TEMP_HIDDEN;
46
47 intptr_t _dyld_get_image_vmaddr_slide(uint32_t imageIndex) TEMP_HIDDEN;
48
49 const char* _dyld_get_image_name(uint32_t imageIndex) TEMP_HIDDEN;
50
51 int32_t NSVersionOfLinkTimeLibrary(const char* libraryName) TEMP_HIDDEN;
52
53 int32_t NSVersionOfRunTimeLibrary(const char* libraryName) TEMP_HIDDEN;
54
55 #if __WATCH_OS_VERSION_MIN_REQUIRED
56 uint32_t dyld_get_program_sdk_watch_os_version() TEMP_HIDDEN;
57
58 uint32_t dyld_get_program_min_watch_os_version() TEMP_HIDDEN;
59 #endif
60
61 #if TARGET_OS_BRIDGE
62 uint32_t dyld_get_program_sdk_bridge_os_version() TEMP_HIDDEN;
63
64 uint32_t dyld_get_program_min_bridge_os_version() TEMP_HIDDEN;
65 #endif
66
67
68 uint32_t dyld_get_sdk_version(const mach_header* mh) TEMP_HIDDEN;
69
70
71 uint32_t dyld_get_program_sdk_version() TEMP_HIDDEN;
72 uint32_t dyld_get_min_os_version(const mach_header* mh) TEMP_HIDDEN;
73
74 uint32_t dyld_get_program_min_os_version() TEMP_HIDDEN;
75
76
77 bool _dyld_get_image_uuid(const mach_header* mh, uuid_t uuid) TEMP_HIDDEN;
78
79 int _NSGetExecutablePath(char* buf, uint32_t* bufsize) TEMP_HIDDEN;
80
81 void _dyld_register_func_for_add_image(void (*func)(const mach_header *mh, intptr_t vmaddr_slide)) TEMP_HIDDEN;
82
83 void _dyld_register_func_for_remove_image(void (*func)(const mach_header *mh, intptr_t vmaddr_slide)) TEMP_HIDDEN;
84
85 void _dyld_objc_notify_register(_dyld_objc_notify_mapped mapped,
86 _dyld_objc_notify_init init,
87 _dyld_objc_notify_unmapped unmapped) TEMP_HIDDEN;
88
89 const mach_header* dyld_image_header_containing_address(const void* addr) TEMP_HIDDEN;
90
91 const mach_header* _dyld_get_image_header_containing_address(const void* address) TEMP_HIDDEN;
92
93 bool _dyld_image_containing_address(const void* address) TEMP_HIDDEN;
94
95 const char* dyld_image_path_containing_address(const void* addr) TEMP_HIDDEN;
96
97 bool _dyld_is_memory_immutable(const void* addr, size_t length) TEMP_HIDDEN;
98
99
100 int dladdr(const void* addr, Dl_info* info) TEMP_HIDDEN;
101
102 char* dlerror() TEMP_HIDDEN;
103
104 int dlclose(void* handle) TEMP_HIDDEN;
105
106 void* dlopen(const char* path, int mode) TEMP_HIDDEN;
107
108 bool dlopen_preflight(const char* path) TEMP_HIDDEN;
109
110 void* dlsym(void* handle, const char* symbolName) TEMP_HIDDEN;
111
112 const struct dyld_all_image_infos* _dyld_get_all_image_infos() TEMP_HIDDEN;
113
114 bool dyld_shared_cache_some_image_overridden() TEMP_HIDDEN;
115
116 bool _dyld_get_shared_cache_uuid(uuid_t uuid) TEMP_HIDDEN;
117
118 const void* _dyld_get_shared_cache_range(size_t* length) TEMP_HIDDEN;
119
120 bool _dyld_find_unwind_sections(void* addr, dyld_unwind_sections* info) TEMP_HIDDEN;
121
122 bool dyld_process_is_restricted() TEMP_HIDDEN;
123
124 const char* dyld_shared_cache_file_path() TEMP_HIDDEN;
125
126 void dyld_dynamic_interpose(const mach_header* mh, const dyld_interpose_tuple array[], size_t count) TEMP_HIDDEN;
127
128 int dyld_shared_cache_find_iterate_text(const uuid_t cacheUuid, const char* extraSearchDirs[], void (^callback)(const dyld_shared_cache_dylib_text_info* info)) TEMP_HIDDEN;
129
130 int dyld_shared_cache_iterate_text(const uuid_t cacheUuid, void (^callback)(const dyld_shared_cache_dylib_text_info* info)) TEMP_HIDDEN;
131
132 void _dyld_fork_child() TEMP_HIDDEN;
133
134 // only in macOS and deprecated
135 #if __MAC_OS_X_VERSION_MIN_REQUIRED
136 NSObjectFileImageReturnCode NSCreateObjectFileImageFromFile(const char* pathName, NSObjectFileImage *objectFileImage) TEMP_HIDDEN;
137 NSObjectFileImageReturnCode NSCreateObjectFileImageFromMemory(const void *address, size_t size, NSObjectFileImage *objectFileImage) TEMP_HIDDEN;
138 bool NSDestroyObjectFileImage(NSObjectFileImage objectFileImage) TEMP_HIDDEN;
139 uint32_t NSSymbolDefinitionCountInObjectFileImage(NSObjectFileImage objectFileImage) TEMP_HIDDEN;
140 const char* NSSymbolDefinitionNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal) TEMP_HIDDEN;
141 uint32_t NSSymbolReferenceCountInObjectFileImage(NSObjectFileImage objectFileImage) TEMP_HIDDEN;
142 const char* NSSymbolReferenceNameInObjectFileImage(NSObjectFileImage objectFileImage, uint32_t ordinal, bool *tentative_definition) TEMP_HIDDEN;
143 bool NSIsSymbolDefinedInObjectFileImage(NSObjectFileImage objectFileImage, const char* symbolName) TEMP_HIDDEN;
144 void* NSGetSectionDataInObjectFileImage(NSObjectFileImage objectFileImage, const char* segmentName, const char* sectionName, size_t *size) TEMP_HIDDEN;
145 const char* NSNameOfModule(NSModule m) TEMP_HIDDEN;
146 const char* NSLibraryNameForModule(NSModule m) TEMP_HIDDEN;
147 NSModule NSLinkModule(NSObjectFileImage objectFileImage, const char* moduleName, uint32_t options) TEMP_HIDDEN;
148 bool NSUnLinkModule(NSModule module, uint32_t options) TEMP_HIDDEN;
149 bool NSIsSymbolNameDefined(const char* symbolName) TEMP_HIDDEN;
150 bool NSIsSymbolNameDefinedWithHint(const char* symbolName, const char* libraryNameHint) TEMP_HIDDEN;
151 bool NSIsSymbolNameDefinedInImage(const struct mach_header* image, const char* symbolName) TEMP_HIDDEN;
152 NSSymbol NSLookupAndBindSymbol(const char* symbolName) TEMP_HIDDEN;
153 NSSymbol NSLookupAndBindSymbolWithHint(const char* symbolName, const char* libraryNameHint) TEMP_HIDDEN;
154 NSSymbol NSLookupSymbolInModule(NSModule module, const char* symbolName) TEMP_HIDDEN;
155 NSSymbol NSLookupSymbolInImage(const struct mach_header* image, const char* symbolName, uint32_t options) TEMP_HIDDEN;
156 const char* NSNameOfSymbol(NSSymbol symbol) TEMP_HIDDEN;
157 void* NSAddressOfSymbol(NSSymbol symbol) TEMP_HIDDEN;
158 NSModule NSModuleForSymbol(NSSymbol symbol) TEMP_HIDDEN;
159 void NSLinkEditError(NSLinkEditErrors *c, int *errorNumber, const char** fileName, const char** errorString) TEMP_HIDDEN;
160 bool NSAddLibrary(const char* pathName) TEMP_HIDDEN;
161 bool NSAddLibraryWithSearching(const char* pathName) TEMP_HIDDEN;
162 const struct mach_header* NSAddImage(const char* image_name, uint32_t options) TEMP_HIDDEN;
163 void NSInstallLinkEditErrorHandlers(const NSLinkEditErrorHandlers *handlers) TEMP_HIDDEN;
164 bool _dyld_present(void) TEMP_HIDDEN;
165 bool _dyld_launched_prebound(void) TEMP_HIDDEN;
166 bool _dyld_all_twolevel_modules_prebound(void) TEMP_HIDDEN;
167 bool _dyld_bind_fully_image_containing_address(const void* address) TEMP_HIDDEN;
168 bool _dyld_image_containing_address(const void* address) TEMP_HIDDEN;
169 void _dyld_lookup_and_bind(const char* symbol_name, void **address, NSModule* module) TEMP_HIDDEN;
170 void _dyld_lookup_and_bind_with_hint(const char* symbol_name, const char* library_name_hint, void** address, NSModule* module) TEMP_HIDDEN;
171 void _dyld_lookup_and_bind_fully(const char* symbol_name, void** address, NSModule* module) TEMP_HIDDEN;
172 const struct mach_header* _dyld_get_image_header_containing_address(const void* address) TEMP_HIDDEN;
173 #endif
174
175 } // namespace dyld3
176
177 #endif // __DYLD_APIS_H__
178
179