2 % (c) The University of Glasgow, 2000
4 \section[Linker]{The In-Memory Object File Linker}
7 {-# OPTIONS -#include "Linker.h" #-}
9 initLinker, -- :: IO ()
10 loadObj, -- :: String -> IO ()
11 unloadObj, -- :: String -> IO ()
12 lookupSymbol, -- :: String -> IO (Maybe (Ptr a))
13 resolveObjs, -- :: IO ()
14 addDLL -- :: String -> IO Bool
17 import Foreign ( Ptr, nullPtr )
19 import PrelPack (packString)
20 import Panic ( panic )
22 -- ---------------------------------------------------------------------------
23 -- RTS Linker Interface
24 -- ---------------------------------------------------------------------------
27 addr <- c_lookupSymbol (packString str)
30 else return (Just addr)
33 r <- c_loadObj (packString str)
35 then panic "loadObj: failed"
39 r <- c_unloadObj (packString str)
41 then panic "unloadObj: failed"
47 then panic "resolveObjs: failed"
51 r <- c_addDLL (packString str)
54 type PackedString = ByteArray Int
56 foreign import "lookupSymbol" unsafe
57 c_lookupSymbol :: PackedString -> IO (Ptr a)
59 foreign import "loadObj" unsafe
60 c_loadObj :: PackedString -> IO Int
62 foreign import "unloadObj" unsafe
63 c_unloadObj :: PackedString -> IO Int
65 foreign import "resolveObjs" unsafe
66 c_resolveObjs :: IO Int
68 foreign import "initLinker" unsafe
71 foreign import "addDLL" unsafe
72 c_addDLL :: PackedString -> IO Int