Struct goblin::mach::MachO

source ·
pub struct MachO<'a> {
    pub header: Header,
    pub load_commands: Vec<LoadCommand>,
    pub segments: Segments<'a>,
    pub symbols: Option<Symbols<'a>>,
    pub libs: Vec<&'a str>,
    pub rpaths: Vec<&'a str>,
    pub entry: u64,
    pub old_style_entry: bool,
    pub name: Option<&'a str>,
    pub little_endian: bool,
    pub is_64: bool,
    /* private fields */
}
Expand description

A cross-platform, zero-copy, endian-aware, 32/64 bit Mach-o binary parser

Fields§

§header: Header

The mach-o header

§load_commands: Vec<LoadCommand>

The load commands tell the kernel and dynamic linker how to use/interpret this binary

§segments: Segments<'a>

The load command “segments” - typically the pieces of the binary that are loaded into memory

§symbols: Option<Symbols<'a>>

The “Nlist” style symbols in this binary - strippable

§libs: Vec<&'a str>

The dylibs this library depends on

§rpaths: Vec<&'a str>

The runtime search paths for dylibs this library depends on

§entry: u64

The entry point (as a virtual memory address), 0 if none

§old_style_entry: bool

Whether entry refers to an older LC_UNIXTHREAD instead of the newer LC_MAIN entrypoint

§name: Option<&'a str>

The name of the dylib, if any

§little_endian: bool

Are we a little-endian binary?

§is_64: bool

Are we a 64-bit binary

Implementations§

source§

impl<'a> MachO<'a>

source

pub fn is_object_file(&self) -> bool

Is this a relocatable object file?

source

pub fn symbols(&self) -> SymbolIterator<'a>

Return an iterator over all the symbols in this binary

source

pub fn relocations( &self ) -> Result<Vec<(usize, RelocationIterator<'_>, Section)>>

Return a vector of the relocations in this binary

source

pub fn exports(&self) -> Result<Vec<Export<'_>>>

Return the exported symbols in this binary (if any)

source

pub fn imports(&self) -> Result<Vec<Import<'_>>>

Return the imported symbols in this binary that dyld knows about (if any)

source

pub fn parse(bytes: &'a [u8], offset: usize) -> Result<MachO<'a>>

Parses the Mach-o binary from bytes at offset

source

pub fn parse_lossy(bytes: &'a [u8], offset: usize) -> Result<MachO<'a>>

Parses the Mach-o binary from bytes at offset in lossy mode

Trait Implementations§

source§

impl<'a> Debug for MachO<'a>

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for MachO<'a>

§

impl<'a> RefUnwindSafe for MachO<'a>

§

impl<'a> Send for MachO<'a>

§

impl<'a> Sync for MachO<'a>

§

impl<'a> Unpin for MachO<'a>

§

impl<'a> UnwindSafe for MachO<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.