Crate lief
Expand description
LIEF
This package provides Rust bindings for LIEF. It exposes most of the LIEF API to read these formats:
- ELF
- PE
- Mach-O
The bindings require at least Rust version 1.74.0 with the 2021 edition and support:
- Windows x86-64 (support
/MT
and/MD
linking) - Linux x86-64/aarch64 (Ubuntu 20.04, Almalinux 9, Debian 11.5, Fedora 29)
- macOS (
x86-64
andaarch64
with at least OSX Big Sur: 11.0) - iOS (
aarch64
)
Getting Started
[package]
name = "my-awesome-project"
version = "0.0.1"
edition = "2021"
[dependencies]
# For nightly
lief = { git = "https://github.com/lief-project/LIEF", branch = "main" }
# For releases
lief = 0.15.0
fn main() {
let path = std::env::args().last().unwrap();
let mut file = std::fs::File::open(path).expect("Can't open the file");
match lief::Binary::from(&mut file) {
Some(lief::Binary::ELF(elf)) => {
// Process ELF file
},
Some(lief::Binary::PE(pe)) => {
// Process PE file
},
Some(lief::Binary::MachO(macho)) => {
// Process Mach-O file (including FatMachO)
},
None => {
// Parsing error
}
}
return;
}
Note that the generic
module implements the different traits shared by different structure
of executable formats (symbols, relocations, …)
Modules
- Module for the ELF format
- Module for LIEF’s error
- Executable formats generic traits (LIEF’s abstract layer)
- LIEF’s logging API
- Module for the Mach-O format
- Module for the PE format
Structs
- This structure represents a location in the different debug formats (DWARF/PDB)
Enums
- Enum that wraps all the executable formats supported by LIEF
- This enum wraps either a PDB or a DWARF debug info
Traits
Functions
- Whether it is an extended version of LIEF