Try to integrate @abarbu patches.

This commit is contained in:
Galen Huntington
2019-03-15 21:43:48 -07:00
parent f569b82460
commit ff6d053a4c
3 changed files with 57 additions and 11 deletions

View File

@ -474,10 +474,17 @@ loadFunction__ :: Maybe String
-> String
-> IO (Maybe a)
loadFunction__ pkg m valsym
= do let symbol = prefixUnderscore++(maybe "" (\p -> zEncodeString p++"_") pkg)
++zEncodeString m++"_"++(zEncodeString valsym)++"_closure"
= do let encode = zEncodeString
p <- case pkg of
Just p -> do
prefix <- pkgManglingPrefix p
return $ encode (maybe p id prefix)++"_"
Nothing -> return ""
let symbol = prefixUnderscore++p++encode m++"_"++(encode valsym)++"_closure"
#if DEBUG
putStrLn $ "Looking for <<"++symbol++">>"
initLinker
#endif
ptr@(Ptr addr) <- withCString symbol c_lookupSymbol
if (ptr == nullPtr)
@ -596,10 +603,15 @@ unloadObj (Module { path = p, kind = k, key = ky }) = case k of
-- Load a .so type object file.
--
loadShared :: FilePath -> IO Module
loadShared str = do
loadShared str' = do
#if DEBUG
putStrLn $ " shared: " ++ str
putStrLn $ " shared: " ++ str'
#endif
let str = case str' of
-- TODO My GHC segfaults because libm.so is a linker script
"libm.so" -> "/lib/x86_64-linux-gnu/libm.so.6"
"libpthread.so" -> "/lib/x86_64-linux-gnu/libpthread.so.0"
x -> x
maybe_errmsg <- withCString str $ \dll -> c_addDLL dll
if maybe_errmsg == nullPtr
then return (Module str (mkModid str) Shared undefined (Package (mkModid str)))
@ -618,6 +630,7 @@ loadShared str = do
--
loadPackage :: String -> IO ()
loadPackage p = do
initLinker
#if DEBUG
putStr (' ':p) >> hFlush stdout
#endif