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 (Ptr CChar)
17 import CTypes ( CChar )
18 import Foreign ( Ptr, nullPtr )
20 import PrelPack (packString)
21 import Panic ( panic )
23 -- ---------------------------------------------------------------------------
24 -- RTS Linker Interface
25 -- ---------------------------------------------------------------------------
28 addr <- c_lookupSymbol (packString str)
31 else return (Just addr)
34 r <- c_loadObj (packString str)
36 then panic "loadObj: failed"
40 r <- c_unloadObj (packString str)
42 then panic "unloadObj: failed"
48 then panic "resolveObjs: failed"
52 maybe_errmsg <- c_addDLL (packString str)
55 type PackedString = ByteArray Int
57 foreign import "lookupSymbol" unsafe
58 c_lookupSymbol :: PackedString -> IO (Ptr a)
60 foreign import "loadObj" unsafe
61 c_loadObj :: PackedString -> IO Int
63 foreign import "unloadObj" unsafe
64 c_unloadObj :: PackedString -> IO Int
66 foreign import "resolveObjs" unsafe
67 c_resolveObjs :: IO Int
69 foreign import "initLinker" unsafe
72 foreign import "addDLL" unsafe
73 c_addDLL :: PackedString -> IO (Ptr CChar)