Module lief::macho

Expand description

Module for the Mach-O file format support in LIEF.

To get started, one can use crate::macho::parse, crate::macho::FatBinary::parse or crate::Binary::parse to instantiate a crate::macho::FatBinary.

Even though the targeted Mach-O binary is not FAT, LIEF always return a crate::macho::FatBinary which can wrap a single Binary.

let fat = lief::macho::parse("non-fat.macho").unwrap();
assert!(fat.iter().len() == 1);

let fat = lief::macho::parse("real-fat.macho").unwrap();
assert!(fat.iter().len() > 1);

The Binary structure exposes the main interface to inspect or modify Mach-O binaries:

fn inspect_macho(macho: &lief::macho::Binary) {
    for cmd in macho.commands() {
        println!("{:?}", cmd);
    }
}

Modules

Structs

  • This is the main interface to read and write Mach-O binary attributes.
  • This structure represents an export (info) in a Mach-O binary
  • This structure represents a FAT Mach-O
  • Structure that represents the main Mach-O header (at the beginning of the file)
  • This class represents a stub entry in sections like __stubs,__auth_stubs.
  • Structure that represents a Symbol in a Mach-O file.

Enums

  • This enum exposes all the different types of binding operations that we can find in a Mach-O binary. BindingInfo::Dyld exposes the bindings info wrapped in the LC_DYLD_INFO command while BindingInfo::Chained exposes the new chained bindings implemented in the DYLD_CHAINED_FIXUPS command.
  • Enum that wraps all the different Mach-O load commands (LC_xxx). Note that all these commands implements the trait: Command
  • Enum that represents the different to encode/represent a relocation in a Mach-O file

Functions

  • Parse a Mach-O file from the given file path