intercept-preload/README.md
This crate provides a dynamic library for Unix systems that can be used with Bear for intercepting system calls via the LD_PRELOAD mechanism (or DYLD_INSERT_LIBRARIES on macOS).
libexec is designed to work with the Bear compilation database generator. It intercepts system calls like execve to track command execution during builds.
The library is split into a C shim (src/c/shim.c) and Rust implementation (src/implementation.rs). This separation exists because:
execl family)dlsym(RTLD_NEXT, ...)) avoids recursive interception issuesLD_PRELOAD and ELF version scripts for symbol visibilityDYLD_INSERT_LIBRARIES and -exported_symbols_list for symbol visibilityOn unsupported platforms, the build process will display a warning and skip library generation.
exec family calls, posix_spawn, popen, and systemexec callsTo build libexec in debug mode:
cargo build -p intercept-preload
For the release version:
cargo build -p intercept-preload --release
The resulting shared library will be in target/debug/libexec.so (or .dylib on macOS) and target/release/libexec.so respectively.