Trac #9878: Make the static form illegal in interpreted mode.
[ghc.git] / includes / rts / Linker.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2009
4 *
5 * RTS Object Linker
6 *
7 * Do not #include this file directly: #include "Rts.h" instead.
8 *
9 * To understand the structure of the RTS headers, see the wiki:
10 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #ifndef RTS_LINKER_H
15 #define RTS_LINKER_H
16
17 #if defined(mingw32_HOST_OS)
18 typedef wchar_t pathchar;
19 #define PATH_FMT "ls"
20 #else
21 typedef char pathchar;
22 #define PATH_FMT "s"
23 #endif
24
25 /* Initialize the object linker. Equivalent to initLinker_(1). */
26 void initLinker (void);
27
28 /* Initialize the object linker.
29 * The retain_cafs argument is:
30 *
31 * non-zero => Retain CAFs unconditionally in linked Haskell code.
32 * Note that this prevents any code from being unloaded.
33 * It should not be necessary unless you are GHCi or
34 * hs-plugins, which needs to be able call any function
35 * in the compiled code.
36 *
37 * zero => Do not retain CAFs. Everything reachable from foreign
38 * exports will be retained, due to the StablePtrs
39 * created by the module initialisation code. unloadObj
40 * frees these StablePtrs, which will allow the CAFs to
41 * be GC'd and the code to be removed.
42 */
43 void initLinker_ (int retain_cafs);
44
45 /* insert a symbol in the hash table */
46 HsInt insertSymbol(pathchar* obj_name, char* key, void* data);
47
48 /* lookup a symbol in the hash table */
49 void *lookupSymbol( char *lbl );
50
51 /* delete an object from the pool */
52 HsInt unloadObj( pathchar *path );
53
54 /* purge an object's symbols from the symbol table, but don't unload it */
55 HsInt purgeObj( pathchar *path );
56
57 /* add an obj (populate the global symbol table, but don't resolve yet) */
58 HsInt loadObj( pathchar *path );
59
60 /* add an arch (populate the global symbol table, but don't resolve yet) */
61 HsInt loadArchive( pathchar *path );
62
63 /* resolve all the currently unlinked objects in memory */
64 HsInt resolveObjs( void );
65
66 /* load a dynamic library */
67 const char *addDLL( pathchar* dll_name );
68
69 /* called by the initialization code for a module, not a user API */
70 StgStablePtr foreignExportStablePtr (StgPtr p);
71
72 #endif /* RTS_LINKER_H */