Crate lief

Crate lief 

Expand description

§LIEF

LIEF Design

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/musl (Ubuntu 19.10, Almalinux 8, Debian 10, Fedora 29)
  • macOS (x86-64 and aarch64 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.17.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)
       },
       Some(lief::Binary::COFF(coff)) => {
           // Process coff file
       },
       None => {
           // Parsing error
       }
   }
   return;
}

Note that the generic module implements the different traits shared by different structure of executable formats (symbols, relocations, …)

§Additional Information

For more details about the install procedure and the configuration, please check: https://lief.re/doc/latest/api/rust/index.html

Modules§

assembly
Assembly/Disassembly Module
coff
Module for the COFF file format support in LIEF.
debug_info
dsc
Module for Dyld shared cache support
dwarf
Module for processing DWARF debug info
elf
Module for the ELF file format support in LIEF.
error
Module for LIEF’s error
generic
Executable formats generic traits (LIEF’s abstract layer)
logging
LIEF’s logging API
macho
Module for the Mach-O file format support in LIEF.
objc
Module for Objective-C metadata
pdb
Module for processing PDB file
pe
Module for the PE file format support in LIEF.

Structs§

DebugLocation
This structure represents a location in the different debug formats (DWARF/PDB)
Function
Structure that represents a binary’s function
Range
Version

Enums§

Binary
Enum that wraps all the executable formats supported by LIEF
DebugInfo
This enum wraps either a PDB or a DWARF debug info
Error

Traits§

Relocation

Functions§

demangle
Try to demangle the given input.
dump
Hexdump the provided buffer.
dump_with_limit
Same as dump but with a limit on the number of bytes to dump
extended_version
Return the extended version
extended_version_info
Return details about the extended version
is_extended
Whether it is an extended version of LIEF
version
Return the current version