]> git.saurik.com Git - apple/dyld.git/blob - src/dyld.h
dyld-44.4.tar.gz
[apple/dyld.git] / src / dyld.h
1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
2 *
3 * Copyright (c) 2004-2005 Apple Computer, 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
25 #include <stdint.h>
26
27 #include "ImageLoader.h"
28
29
30
31 //
32 // dyld functions available when implementing dyld API's
33 //
34 //
35 namespace dyld {
36
37 struct LoadContext
38 {
39 bool useSearchPaths;
40 bool useLdLibraryPath;
41 bool matchByInstallName;
42 bool dontLoad;
43 bool mustBeBundle;
44 bool mustBeDylib;
45 const char* origin; // path for expanding @loader_path
46 const char** rpath; // future support of -rpath
47 };
48
49
50
51 typedef void (*ImageCallback)(const struct mach_header* mh, intptr_t slide);
52 typedef void (*BundleNotificationCallBack)(const char* imageName, ImageLoader* image);
53 typedef ImageLoader* (*BundleLocatorCallBack)(const char* symbolName);
54 typedef void (*UndefinedHandler)(const char* symbolName);
55
56
57 extern ImageLoader::LinkContext gLinkContext;
58 extern bool gLogAPIs;
59 extern const struct ThreadingHelpers* gThreadHelpers;
60
61
62 extern void registerAddCallback(ImageCallback func);
63 extern void registerRemoveCallback(ImageCallback func);
64 extern void registerZeroLinkHandlers(BundleNotificationCallBack, BundleLocatorCallBack);
65 extern void registerUndefinedHandler(UndefinedHandler);
66 extern void initializeMainExecutable();
67 extern void link(ImageLoader* image, ImageLoader::BindingLaziness bindness, ImageLoader::InitializerRunning runInitializers);
68 extern void runTerminators();
69 extern const char* getExecutablePath();
70 extern bool validImage(ImageLoader*);
71 extern ImageLoader* getIndexedImage(uint32_t index);
72 extern uint32_t getImageCount();
73 extern ImageLoader* findImageByMachHeader(const struct mach_header* target);
74 extern ImageLoader* findImageContainingAddress(const void* addr);
75 extern ImageLoader* findImageByName(const char* path);
76 extern ImageLoader* findLoadedImageByInstallPath(const char* path);
77 extern bool flatFindExportedSymbol(const char* name, const ImageLoader::Symbol** sym, ImageLoader** image);
78 extern bool flatFindExportedSymbolWithHint(const char* name, const char* librarySubstring, const ImageLoader::Symbol** sym, ImageLoader** image);
79 extern ImageLoader* load(const char* path, const LoadContext& context);
80 extern ImageLoader* loadFromMemory(const uint8_t* mem, uint64_t len, const char* moduleName);
81 extern void removeImage(ImageLoader* image);
82 extern ImageLoader* cloneImage(ImageLoader* image);
83 extern void forEachImageDo( void (*)(ImageLoader*, void*), void*);
84 extern uintptr_t _main(const struct mach_header* mainExecutableMH, int argc, const char* argv[], const char* envp[], const char* apple[]);
85 extern void halt(const char* message) __attribute__((noreturn));
86 extern void setErrorMessage(const char* msg);
87 extern const char* getErrorMessage();
88 extern void clearErrorMessage();
89 extern bool mainExecutablePrebound();
90 extern ImageLoader* mainExecutable();
91 extern void processDyldEnvironmentVarible(const char* key, const char* value);
92
93 };
94