Line data Source code
1 : //! Module for the Mach-O file format support in LIEF.
2 : //!
3 : //! To get started, one can use [`crate::macho::parse`], [`crate::macho::FatBinary::parse`] or
4 : //! [`crate::Binary::parse`] to instantiate a [`crate::macho::FatBinary`].
5 : //!
6 : //! Even though the targeted Mach-O binary is not FAT, LIEF **always** return a [`crate::macho::FatBinary`]
7 : //! which can wrap a single [`Binary`].
8 : //!
9 : //! ```
10 : //! let fat = lief::macho::parse("non-fat.macho").unwrap();
11 : //! assert!(fat.iter().len() == 1);
12 : //!
13 : //! let fat = lief::macho::parse("real-fat.macho").unwrap();
14 : //! assert!(fat.iter().len() > 1);
15 : //! ```
16 : //!
17 : //! The [`Binary`] structure exposes the main interface to inspect or modify Mach-O binaries:
18 : //!
19 : //! ```
20 : //! fn inspect_macho(macho: &lief::macho::Binary) {
21 : //! for cmd in macho.commands() {
22 : //! println!("{:?}", cmd);
23 : //! }
24 : //! }
25 : //! ```
26 : //!
27 : pub mod binary;
28 : pub mod binding_info;
29 : pub mod commands;
30 : pub mod export_info;
31 : pub mod fat_binary;
32 : pub mod relocation;
33 : pub mod section;
34 : pub mod symbol;
35 : pub mod header;
36 : pub mod stub;
37 : pub mod builder;
38 :
39 : #[doc(inline)]
40 : pub use binary::Binary;
41 : #[doc(inline)]
42 : pub use binding_info::BindingInfo;
43 : #[doc(inline)]
44 : pub use export_info::ExportInfo;
45 : #[doc(inline)]
46 : pub use fat_binary::FatBinary;
47 : #[doc(inline)]
48 : pub use relocation::Relocation;
49 : #[doc(inline)]
50 : pub use section::Section;
51 : #[doc(inline)]
52 : pub use symbol::Symbol;
53 : #[doc(inline)]
54 : pub use commands::Commands;
55 : #[doc(inline)]
56 : pub use header::Header;
57 : #[doc(inline)]
58 : pub use stub::Stub;
59 :
60 : /// Parse a Mach-O file from the given file path
61 0 : pub fn parse(path: &str) -> Option<FatBinary> {
62 0 : FatBinary::parse(path)
63 0 : }
|