diff options
author | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
commit | 1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch) | |
tree | 7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/object/src/read/macho/mod.rs | |
parent | 5ecd8cf2cba827454317368b68571df0d13d7842 (diff) | |
download | fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip |
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/object/src/read/macho/mod.rs')
-rw-r--r-- | vendor/object/src/read/macho/mod.rs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/vendor/object/src/read/macho/mod.rs b/vendor/object/src/read/macho/mod.rs new file mode 100644 index 0000000..ab51ff3 --- /dev/null +++ b/vendor/object/src/read/macho/mod.rs @@ -0,0 +1,72 @@ +//! Support for reading Mach-O files. +//! +//! Traits are used to abstract over the difference between 32-bit and 64-bit Mach-O +//! files. The primary trait for this is [`MachHeader`]. +//! +//! ## High level API +//! +//! [`MachOFile`] implements the [`Object`](crate::read::Object) trait for Mach-O files. +//! [`MachOFile`] is parameterised by [`MachHeader`] to allow reading both 32-bit and +//! 64-bit Mach-O files. There are type aliases for these parameters ([`MachOFile32`] and +//! [`MachOFile64`]). +//! +//! ## Low level API +//! +//! The [`MachHeader`] trait can be directly used to parse both [`macho::MachHeader32`] +//! and [`macho::MachHeader64`]. Additionally, [`FatHeader`] and the [`FatArch`] trait +//! can be used to iterate images in multi-architecture binaries, and [`DyldCache`] can +//! be used to locate images in a dyld shared cache. +//! +//! ### Example for low level API +//! ```no_run +//! use object::macho; +//! use object::read::macho::{MachHeader, Nlist}; +//! use std::error::Error; +//! use std::fs; +//! +//! /// Reads a file and displays the name of each symbol. +//! fn main() -> Result<(), Box<dyn Error>> { +//! # #[cfg(feature = "std")] { +//! let data = fs::read("path/to/binary")?; +//! let header = macho::MachHeader64::<object::Endianness>::parse(&*data, 0)?; +//! let endian = header.endian()?; +//! let mut commands = header.load_commands(endian, &*data, 0)?; +//! while let Some(command) = commands.next()? { +//! if let Some(symtab_command) = command.symtab()? { +//! let symbols = symtab_command.symbols::<macho::MachHeader64<_>, _>(endian, &*data)?; +//! for symbol in symbols.iter() { +//! let name = symbol.name(endian, symbols.strings())?; +//! println!("{}", String::from_utf8_lossy(name)); +//! } +//! } +//! } +//! # } +//! Ok(()) +//! } +//! ``` +#[cfg(doc)] +use crate::macho; + +mod dyld_cache; +pub use dyld_cache::*; + +mod fat; +pub use fat::*; + +mod file; +pub use file::*; + +mod load_command; +pub use load_command::*; + +mod segment; +pub use segment::*; + +mod section; +pub use section::*; + +mod symbol; +pub use symbol::*; + +mod relocation; +pub use relocation::*; |