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 ()
16 import Foreign ( Ptr, nullPtr )
18 import PrelPack (packString)
19 import Panic ( panic )
21 -- ---------------------------------------------------------------------------
22 -- RTS Linker Interface
23 -- ---------------------------------------------------------------------------
26 addr <- c_lookupSymbol (packString str)
29 else return (Just addr)
32 r <- c_loadObj (packString str)
34 then panic "loadObj: failed"
38 r <- c_unloadObj (packString str)
40 then panic "unloadObj: failed"
46 then panic "resolveObjs: failed"
50 type PackedString = ByteArray Int
52 foreign import "lookupSymbol" unsafe
53 c_lookupSymbol :: PackedString -> IO (Ptr a)
55 foreign import "loadObj" unsafe
56 c_loadObj :: PackedString -> IO Int
58 foreign import "unloadObj" unsafe
59 c_unloadObj :: PackedString -> IO Int
61 foreign import "resolveObjs" unsafe
62 c_resolveObjs :: IO Int
64 foreign import "initLinker" unsafe