ppad-censor-0.6.0: Anytime-valid sequential constant-time testing.
Copyright(c) 2026 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Censor.Runner.DL

Description

Minimal dlopen/dlsym bindings for driving a foreign constant-time target that lives in a shared library. Used by the censor executable to resolve a symbol at runtime and hand it to Censor.FFI as an ffiTarget.

The underlying handle is opened with RTLD_NOW | RTLD_LOCAL: any unresolved symbols surface immediately (so bad shims are caught at withLibrary entry, not at first call), and the library's own symbols do not pollute the global namespace. Not available on Windows.

Synopsis

Library handle

data Library Source #

An opened shared library. Bracketed by withLibrary; do not retain the value past its callback.

withLibrary :: FilePath -> (Library -> IO a) -> IO a Source #

Open a shared library for the duration of the callback and close it on exit. Throws DLOpenFailed if the library cannot be loaded.

Resolving targets

resolveTarget :: Library -> String -> IO (Ptr Word8 -> IO ()) Source #

Resolve a symbol as a void(uint8_t *) target action. Throws DLSymFailed if the symbol is absent from the library.

The resolved FunPtr is not retained past the enclosing withLibrary scope; do not call the returned action after the library has been closed.

Errors

data DLError Source #

Why a dynamic-linker operation failed. The String payload is the dlerror message at the moment of failure.

Constructors

DLOpenFailed !FilePath !String

dlopen returned null while opening this path.

DLSymFailed !String !String

dlsym returned null for this symbol name.

Instances

Instances details
Exception DLError Source # 
Instance details

Defined in Censor.Runner.DL

Show DLError Source # 
Instance details

Defined in Censor.Runner.DL

Eq DLError Source # 
Instance details

Defined in Censor.Runner.DL

Methods

(==) :: DLError -> DLError -> Bool #

(/=) :: DLError -> DLError -> Bool #