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 :
38 : #[doc(inline)]
39 : pub use binary::Binary;
40 : #[doc(inline)]
41 : pub use binding_info::BindingInfo;
42 : #[doc(inline)]
43 : pub use export_info::ExportInfo;
44 : #[doc(inline)]
45 : pub use fat_binary::FatBinary;
46 : #[doc(inline)]
47 : pub use relocation::Relocation;
48 : #[doc(inline)]
49 : pub use section::Section;
50 : #[doc(inline)]
51 : pub use symbol::Symbol;
52 : #[doc(inline)]
53 : pub use commands::Commands;
54 : #[doc(inline)]
55 : pub use header::Header;
56 : #[doc(inline)]
57 : pub use stub::Stub;
58 :
59 : /// Parse a Mach-O file from the given file path
60 0 : pub fn parse(path: &str) -> Option<FatBinary> {
61 0 : FatBinary::parse(path)
62 0 : }
|