| Crates.io | leviso-elf |
| lib.rs | leviso-elf |
| version | 0.1.6 |
| created_at | 2026-01-23 16:12:30.451584+00 |
| updated_at | 2026-01-24 15:43:30.471626+00 |
| description | ELF binary analysis and library dependency copying utilities using readelf |
| homepage | https://github.com/LevitateOS/leviso-elf |
| repository | https://github.com/LevitateOS/leviso-elf |
| max_upload_size | |
| id | 2064893 |
| size | 20,799 |
ELF binary analysis and library dependency copying utilities. Uses readelf for cross-compilation safe dependency detection (unlike ldd which executes binaries).
| Metric | Value |
|---|---|
| Stage | Beta |
| Target | x86_64 Linux |
| Last verified | 2026-01-23 |
[Waiting for human input]
readelf -d output to find shared library dependenciesuse leviso_elf::{get_all_dependencies, copy_library_to, find_binary, find_library};
use std::path::Path;
let source_root = Path::new("/path/to/source/rootfs");
let dest_root = Path::new("/path/to/dest/rootfs");
// Find all library dependencies for a binary (recursive)
let binary_path = source_root.join("usr/bin/bash");
let deps = get_all_dependencies(source_root, &binary_path, &["usr/libexec/sudo"])?;
// Copy a library to target directory with configurable paths
copy_library_to(
source_root,
"libc.so.6",
dest_root,
"usr/lib64", // dest lib64 path
"usr/lib", // dest lib path
&["usr/libexec/sudo"], // extra search paths
&["systemd"], // private lib dirs (use &[] for musl/OpenRC)
)?;
// Find a binary in standard paths
if let Some(path) = find_binary(source_root, "bash") {
println!("Found bash at: {}", path.display());
}
// Find a library with extra search paths
if let Some(path) = find_library(source_root, "libpam.so.0", &[]) {
println!("Found libpam at: {}", path.display());
}
ldd executes the binary to resolve dependencies, which fails for cross-compiled binaries and can be a security risk. readelf -d parses the ELF headers directly without execution.
MIT