2 % (c) The University of Glasgow, 2000
4 \section[Linker]{The In-Memory Object File Linker}
7 {-# OPTIONS -#include "Linker.h" #-}
10 loadObj, -- :: String -> IO ()
11 unloadObj, -- :: String -> IO ()
12 lookupSymbol, -- :: String -> IO (Maybe Addr)
13 resolveObjs, -- :: IO ()
22 import PrelPack (packString)
26 hPutStr stderr "Loading HSstd_cbits.o..."
27 loadObj "/home/simonmar/builds/i386-unknown-linux-boot/ghc/lib/std/cbits/HSstd_cbits.o"
28 hPutStr stderr "done.\n"
29 hPutStr stderr "Resolving..."
31 hPutStr stderr "done.\n"
32 hPutStr stderr "Loading HSstd.o..."
33 loadObj "/home/simonmar/builds/i386-unknown-linux-boot/ghc/lib/std/HSstd.o"
34 hPutStr stderr "done.\n"
35 hPutStr stderr "Resolving..."
37 hPutStr stderr "done.\n"
39 hPutStr stderr "Unloading HSstd.o..."
40 unloadObj "/home/simonmar/builds/i386-unknown-linux-boot/ghc/lib/std/HSstd.o"
41 hPutStr stderr "done.\n"
42 unloadObj "/home/simonmar/builds/i386-unknown-linux-boot/ghc/lib/std/cbits/HSstd_cbits.o"
43 hPutStr stderr "done.\n"
46 -- ---------------------------------------------------------------------------
47 -- RTS Linker Interface
48 -- ---------------------------------------------------------------------------
51 addr <- c_lookupSymbol (packString str)
54 else return (Just addr)
57 r <- c_loadObj (packString str)
59 then error "loadObj: failed"
63 r <- c_unloadObj (packString str)
65 then error "unloadObj: failed"
71 then error "resolveObjs: failed"
75 type PackedString = ByteArray Int
77 foreign import "lookupSymbol" unsafe
78 c_lookupSymbol :: PackedString -> IO Addr
80 foreign import "loadObj" unsafe
81 c_loadObj :: PackedString -> IO Int
83 foreign import "unloadObj" unsafe
84 c_unloadObj :: PackedString -> IO Int
86 foreign import "resolveObjs" unsafe
87 c_resolveObjs :: IO Int