]> git.saurik.com Git - apple/dyld.git/blob - src/dyld.h
4ccbdd7db887895ea9f6abded52bd84e78c92aa0
[apple/dyld.git] / src / dyld.h
1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
2 *
3 * Copyright (c) 2004-2006 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 #include "mach-o/dyld_priv.h"
29
30
31
32 //
33 // dyld functions available when implementing dyld API's
34 //
35 //
36 namespace dyld {
37
38 struct LoadContext
39 {
40 bool useSearchPaths;
41 bool useLdLibraryPath;
42 bool implicitRPath;
43 bool matchByInstallName;
44 bool dontLoad;
45 bool mustBeBundle;
46 bool mustBeDylib;
47 bool findDLL;
48 const char* origin; // path for expanding @loader_path
49 const ImageLoader::RPathChain* rpath; // paths for expanding @rpath
50 };
51
52
53
54 typedef void (*ImageCallback)(const struct mach_header* mh, intptr_t slide);
55 typedef void (*BundleNotificationCallBack)(const char* imageName, ImageLoader* image);
56 typedef ImageLoader* (*BundleLocatorCallBack)(const char* symbolName);
57 typedef void (*UndefinedHandler)(const char* symbolName);
58 typedef const char* (*ImageLocator)(const char* dllName);
59
60
61 extern ImageLoader::LinkContext gLinkContext;
62 extern bool gLogAPIs;
63 extern bool gSharedCacheNotFound;
64 extern bool gSharedCacheNeedsUpdating;
65 extern bool gSharedCacheDontNotify;
66 extern const struct LibSystemHelpers* gLibSystemHelpers;
67 #if SUPPORT_OLD_CRT_INITIALIZATION
68 extern bool gRunInitializersOldWay;
69 #endif
70 extern void registerAddCallback(ImageCallback func);
71 extern void registerRemoveCallback(ImageCallback func);
72 extern void registerZeroLinkHandlers(BundleNotificationCallBack, BundleLocatorCallBack);
73 extern void registerUndefinedHandler(UndefinedHandler);
74 extern void initializeMainExecutable();
75 extern void preflight(ImageLoader* image, const ImageLoader::RPathChain& loaderRPaths);
76 extern void link(ImageLoader* image, bool forceLazysBound, const ImageLoader::RPathChain& loaderRPaths);
77 extern void runInitializers(ImageLoader* image);
78 extern void runTerminators(void*);
79 extern const char* getExecutablePath();
80 extern bool validImage(const ImageLoader*);
81 extern ImageLoader* getIndexedImage(uint32_t index);
82 extern uint32_t getImageCount();
83 extern ImageLoader* findImageByMachHeader(const struct mach_header* target);
84 extern ImageLoader* findImageContainingAddress(const void* addr);
85 extern ImageLoader* findImageByName(const char* path);
86 extern ImageLoader* findLoadedImageByInstallPath(const char* path);
87 extern bool flatFindExportedSymbol(const char* name, const ImageLoader::Symbol** sym, const ImageLoader** image);
88 extern bool flatFindExportedSymbolWithHint(const char* name, const char* librarySubstring, const ImageLoader::Symbol** sym, const ImageLoader** image);
89 extern ImageLoader* load(const char* path, const LoadContext& context);
90 extern ImageLoader* loadFromMemory(const uint8_t* mem, uint64_t len, const char* moduleName);
91 extern void removeImage(ImageLoader* image);
92 extern ImageLoader* cloneImage(ImageLoader* image);
93 extern void forEachImageDo( void (*)(ImageLoader*, void*), void*);
94 extern uintptr_t _main(const struct mach_header* mainExecutableMH, uintptr_t mainExecutableSlide, int argc, const char* argv[], const char* envp[], const char* apple[]);
95 extern void halt(const char* message) __attribute__((noreturn));
96 extern void setErrorMessage(const char* msg);
97 extern const char* getErrorMessage();
98 extern void clearErrorMessage();
99 extern bool mainExecutablePrebound();
100 extern ImageLoader* mainExecutable();
101 extern void processDyldEnvironmentVarible(const char* key, const char* value);
102 extern void registerImageStateSingleChangeHandler(dyld_image_states state, dyld_image_state_change_handler handler);
103 extern void registerImageStateBatchChangeHandler(dyld_image_states state, dyld_image_state_change_handler handler);
104 extern void garbageCollectImages();
105
106 };
107