lddtree-rs
Read the dynamic library dependency tree. Supports ELF (Linux), Mach-O (macOS), and PE (Windows) binaries.
This does not work like ldd in that we do not execute/load code (only read files on disk).
The binary format is detected automatically from the file header.
This is roughly a Rust port of lddtree.py from auditwheel, extended with Mach-O and PE support. It's used in maturin for automatic wheel repair on Linux, macOS, and Windows.
Features
- ELF: rpath/runpath resolution,
LD_LIBRARY_PATH,ld.so.confparsing, sysroot support - Mach-O:
@rpath,@loader_path,@executable_pathresolution,DYLD_LIBRARY_PATH/DYLD_FALLBACK_LIBRARY_PATH, fat/universal binary support - PE: case-insensitive DLL lookup, API set DLL skipping (
api-ms-win-*,ext-ms-win-*), Windows system directory search order, sysroot/Wine prefix support
Installation
Add it to your Cargo.toml:
[]
= "0.5"
Usage
use DependencyAnalyzer;
// Analyze with default settings (root = "/")
let deps = default
.analyze
.unwrap;
println!;
println!;
for in &deps.libraries
use DependencyAnalyzer;
use PathBuf;
// Analyze with a custom sysroot and additional library paths
let deps = new
.library_paths
.analyze
.unwrap;
Command line utility
There is also a simple CLI utility which can be installed via:
Usage: lddtree <pathname> [root]
pathnameis the path to a shared library or executable (ELF, Mach-O, or PE).rootis an optional path to a sysroot directory.
License
This work is released under the MIT license. A copy of the license is provided in the LICENSE file.