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

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
  • Mach-O magic values
  • Enum that represents the different to encode/represent a relocation in a Mach-O file
  • Enum that wraps all the Mach-O section types, dispatching to the appropriate concrete type when extra semantics are available.

Traits

Functions

  • Check that the layout of the given FAT binary is correct from the loader perspective
  • Check that the layout of the given binary is correct from the loader perspective
  • Check if the given file is a 64-bit Mach-O
  • Check if the given file is a FAT Mach-O
  • Parse a Mach-O file from the given file path
  • Parse a Mach-O file from the given file path with the provided parser configuration