Skip to main content

Crate dldota

Crate dldota 

Source
Expand description

Load the host system’s shared libraries from a statically linked program.

A statically linked program has no dynamic loader, so dlopen is either a stub (musl) or only works against the exact glibc it was built with. dldota maps the system’s own dynamic loader (ld-linux-*.so, ld-musl-*.so) into the process, boots it as the kernel would, and hands out its dlopen/dlsym. Calls into the loaded code go through trampolines that switch the thread pointer, so the host runtime and the system libc can coexist.

See docs/design.md for the rationale and the known hazards.

ⓘ
use dldota::{Context, OpenFlags};

let ctx = Context::new()?;
let libz = ctx.open(c"libz.so.1", OpenFlags::NOW)?;
let version = unsafe { libz.symbol::<unsafe extern "C" fn() -> *const core::ffi::c_char>(c"zlibVersion")? };

Modules§

ffi
C ABI exported by libdldota.a; mirrored by include/dldota.h.

Structs§

Callback
A host function made callable from foreign code by Context::callback. Derefs to the thunk, to be passed to foreign code.
Context
A booted foreign dynamic loader, with its own libc and heap.
ContextBuilder
HeapUsage
Snapshot of a context’s foreign heap.
Library
A library opened through a Context; dlclosed on drop.
OpenFlags
dlopen mode flags. The values are identical in glibc and musl.
Symbol
A symbol borrowed from a Library; cannot outlive it.

Enums§

Error

Type Aliases§

Result