[project @ 2001-09-20 13:32:15 by simonmar]
[ghc-hetmet.git] / ghc / compiler / ghci / Linker.lhs
index 8b0d15a..238d009 100644 (file)
@@ -5,12 +5,13 @@
 
 \begin{code}
 {-# OPTIONS -#include "Linker.h" #-}
+
 module Linker ( 
    initLinker,  -- :: IO ()
    loadObj,      -- :: String -> IO ()
    unloadObj,    -- :: String -> IO ()
    lookupSymbol, -- :: String -> IO (Maybe (Ptr a))
-   resolveObjs,  -- :: IO ()
+   resolveObjs,  -- :: IO Bool
    addDLL       -- :: String -> IO (Ptr CChar)
   )  where
 
@@ -19,12 +20,14 @@ import Foreign              ( Ptr, nullPtr )
 import PrelByteArr
 import PrelPack        (packString)
 import Panic           ( panic )
+import DriverUtil       ( prefixUnderscore )
 
 -- ---------------------------------------------------------------------------
 -- RTS Linker Interface
 -- ---------------------------------------------------------------------------
 
-lookupSymbol str = do
+lookupSymbol str_in = do
+   let str = prefixUnderscore str_in
    addr <- c_lookupSymbol (packString str)
    if addr == nullPtr
        then return Nothing
@@ -44,12 +47,10 @@ unloadObj str = do
 
 resolveObjs = do
    r <- c_resolveObjs
-   if (r == 0)
-       then panic "resolveObjs: failed"
-       else return ()
+   return (r /= 0)  -- returns True <=> success
 
-addDLL str = do
-   maybe_errmsg <- c_addDLL (packString str)
+addDLL path lib = do
+   maybe_errmsg <- c_addDLL (packString path) (packString lib)
    return maybe_errmsg
 
 type PackedString = ByteArray Int
@@ -70,6 +71,5 @@ foreign import "initLinker" unsafe
    initLinker :: IO ()
 
 foreign import "addDLL" unsafe 
-   c_addDLL :: PackedString -> IO (Ptr CChar)
-
+   c_addDLL :: PackedString -> PackedString -> IO (Ptr CChar)
 \end{code}