dldota 0.1.0

Load shared libraries from statically linked programs by bootstrapping the system's own dynamic loader
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
/// Current thread pointer (FS base). Both glibc and musl keep a self-pointer
/// at `%fs:0`, so this avoids an `arch_prctl` syscall.
#[allow(dead_code)]
#[inline(always)]
pub(crate) fn thread_pointer() -> usize {
    let tp: usize;
    // SAFETY: reads the TCB self-pointer, which every Linux x86_64 libc sets up.
    unsafe {
        core::arch::asm!("mov {}, fs:0", out(reg) tp, options(nostack, readonly, preserves_flags))
    };
    tp
}