module LLVM.Internal.Linking
( loadLibraryPermanently
, getSymbolAddressInProcess
)where
import LLVM.Prelude
import qualified Data.ByteString as BS
import Foreign.C.String
import Foreign.Ptr
import LLVM.Internal.Coding
import qualified LLVM.Internal.FFI.DynamicLibrary as DL
import qualified LLVM.Internal.FFI.RTDyldMemoryManager as Dyld
import LLVM.Internal.OrcJIT
getSymbolAddressInProcess
:: MangledSymbol -> IO WordPtr
getSymbolAddressInProcess (MangledSymbol sym)
= fromIntegral <$> BS.useAsCString sym Dyld.getSymbolAddressInProcess
loadLibraryPermanently
:: Maybe FilePath
-> IO Bool
loadLibraryPermanently (Just fp) = decodeM =<< withCString fp DL.loadLibraryPermanently
loadLibraryPermanently Nothing = decodeM =<< DL.loadLibraryPermanently nullPtr