2 % (c) The University of Glasgow, 2000
4 \section[Linker]{The In-Memory Object File Linker}
7 {-# OPTIONS -#include "Linker.h" #-}
9 loadObj, -- :: String -> IO ()
10 unloadObj, -- :: String -> IO ()
11 lookupSymbol, -- :: String -> IO (Maybe Addr)
12 resolveObjs, -- :: IO ()
20 import PrelPack (packString)
21 import Panic ( panic )
23 #if __GLASGOW_HASKELL__ <= 408
24 loadObj = bogus "loadObj"
25 unloadObj = bogus "unloadObj"
26 lookupSymbol = bogus "lookupSymbol"
27 resolveObjs = bogus "resolveObjs"
28 linkPrelude = bogus "linkPrelude"
29 bogus f = panic ("Linker." ++ f ++ ": this hsc was built without an interpreter.")
34 hPutStr stderr "Loading HSstd_cbits.o..."
35 loadObj "/home/simonmar/builds/i386-unknown-linux-boot/ghc/lib/std/cbits/HSstd_cbits.o"
36 hPutStr stderr "done.\n"
37 hPutStr stderr "Resolving..."
39 hPutStr stderr "done.\n"
40 hPutStr stderr "Loading HSstd.o..."
41 loadObj "/home/simonmar/builds/i386-unknown-linux-boot/ghc/lib/std/HSstd.o"
42 hPutStr stderr "done.\n"
43 hPutStr stderr "Resolving..."
45 hPutStr stderr "done.\n"
47 hPutStr stderr "Unloading HSstd.o..."
48 unloadObj "/home/simonmar/builds/i386-unknown-linux-boot/ghc/lib/std/HSstd.o"
49 hPutStr stderr "done.\n"
50 unloadObj "/home/simonmar/builds/i386-unknown-linux-boot/ghc/lib/std/cbits/HSstd_cbits.o"
51 hPutStr stderr "done.\n"
54 -- ---------------------------------------------------------------------------
55 -- RTS Linker Interface
56 -- ---------------------------------------------------------------------------
59 addr <- c_lookupSymbol (packString str)
62 else return (Just addr)
65 r <- c_loadObj (packString str)
67 then error "loadObj: failed"
71 r <- c_unloadObj (packString str)
73 then error "unloadObj: failed"
79 then error "resolveObjs: failed"
83 type PackedString = ByteArray Int
85 foreign import "lookupSymbol" unsafe
86 c_lookupSymbol :: PackedString -> IO Addr
88 foreign import "loadObj" unsafe
89 c_loadObj :: PackedString -> IO Int
91 foreign import "unloadObj" unsafe
92 c_unloadObj :: PackedString -> IO Int
94 foreign import "resolveObjs" unsafe
95 c_resolveObjs :: IO Int
97 #endif /* __GLASGOW_HASKELL__ <= 408 */