[][src]Enum mach_object::LoadCommand

pub enum LoadCommand {
    Segment {
        segname: String,
        vmaddr: usize,
        vmsize: usize,
        fileoff: usize,
        filesize: usize,
        maxprot: vm_prot_t,
        initprot: vm_prot_t,
        flags: SegmentFlags,
        sections: Vec<Rc<Section>>,
    },
    Segment64 {
        segname: String,
        vmaddr: usize,
        vmsize: usize,
        fileoff: usize,
        filesize: usize,
        maxprot: vm_prot_t,
        initprot: vm_prot_t,
        flags: SegmentFlags,
        sections: Vec<Rc<Section>>,
    },
    IdFvmLib(FvmLib),
    LoadFvmLib(FvmLib),
    IdDyLib(DyLib),
    LoadDyLib(DyLib),
    LoadWeakDyLib(DyLib),
    ReexportDyLib(DyLib),
    LoadUpwardDylib(DyLib),
    LazyLoadDylib(DyLib),
    Rpath(String),
    IdDyLinker(LcString),
    LoadDyLinker(LcString),
    DyLdEnv(LcString),
    SymTab {
        symoff: u32,
        nsyms: u32,
        stroff: u32,
        strsize: u32,
    },
    DySymTab {
        ilocalsym: u32,
        nlocalsym: u32,
        iextdefsym: u32,
        nextdefsym: u32,
        iundefsym: u32,
        nundefsym: u32,
        tocoff: u32,
        ntoc: u32,
        modtaboff: u32,
        nmodtab: u32,
        extrefsymoff: u32,
        nextrefsyms: u32,
        indirectsymoff: u32,
        nindirectsyms: u32,
        extreloff: u32,
        nextrel: u32,
        locreloff: u32,
        nlocrel: u32,
    },
    Uuid(Uuid),
    CodeSignature(LinkEditData),
    SegmentSplitInfo(LinkEditData),
    FunctionStarts(LinkEditData),
    DataInCode(LinkEditData),
    DylibCodeSignDrs(LinkEditData),
    LinkerOptimizationHint(LinkEditData),
    VersionMin {
        target: BuildTarget,
        version: VersionTag,
        sdk: VersionTag,
    },
    DyldInfo {
        rebase_off: u32,
        rebase_size: u32,
        bind_off: u32,
        bind_size: u32,
        weak_bind_off: u32,
        weak_bind_size: u32,
        lazy_bind_off: u32,
        lazy_bind_size: u32,
        export_off: u32,
        export_size: u32,
    },
    EntryPoint {
        entryoff: u64,
        stacksize: u64,
    },
    SourceVersion(SourceVersionTag),
    UnixThread {
        flavor: u32,
        count: u32,
        state: ThreadState,
    },
    SubFramework(LcString),
    SubUmbrella(LcString),
    SubClient(LcString),
    SubLibrary(LcString),
    LinkerOption(Vec<String>),
    Routines {
        init_address: u32,
        init_module: u32,
    },
    Routines64 {
        init_address: u64,
        init_module: u64,
    },
    EncryptionInfo {
        offset: u32,
        size: u32,
        id: u32,
    },
    EncryptionInfo64 {
        offset: u32,
        size: u32,
        id: u32,
    },
    TwoLevelHints {
        offset: u32,
        nhints: u32,
    },
    BuildVersion(BuildVersion),
    Command {
        cmd: u32,
        payload: Vec<u8>,
    },
}

The load commands directly follow the mach header.

Variants

Segment

The segment load command indicates that a part of this file is to be mapped into the task's address space.

The size of this segment in memory, vmsize, maybe equal to or larger than the amount to map from this file, filesize. The file is mapped starting at fileoff to the beginning of the segment in memory, vmaddr. The rest of the memory of the segment, if any, is allocated zero fill on demand. The segment's maximum virtual memory protection and initial virtual memory protection are specified by the maxprot and initprot fields. If the segment has sections then the section structures directly follow the segment command and their size is reflected in cmdsize.

Fields of Segment

segname: String

segment name

vmaddr: usize

memory address of this segment

vmsize: usize

memory size of this segment

fileoff: usize

file offset of this segment

filesize: usize

amount to map from the file

maxprot: vm_prot_t

maximum VM protection

initprot: vm_prot_t

initial VM protection

flags: SegmentFlags

flags

sections: Vec<Rc<Section>>

sections

Segment64

The 64-bit segment load command indicates that a part of this file is to be mapped into a 64-bit task's address space.

If the 64-bit segment has sections then section_64 structures directly follow the 64-bit segment command and their size is reflected in cmdsize.

Fields of Segment64

segname: String

segment name

vmaddr: usize

memory address of this segment

vmsize: usize

memory size of this segment

fileoff: usize

file offset of this segment

filesize: usize

amount to map from the file

maxprot: vm_prot_t

maximum VM protection

initprot: vm_prot_t

initial VM protection

flags: SegmentFlags

flags

sections: Vec<Rc<Section>>

sections

IdFvmLib(FvmLib)

fixed VM shared library identification

LoadFvmLib(FvmLib)

load a specified fixed VM shared library

IdDyLib(DyLib)

dynamically linked shared lib ident

LoadDyLib(DyLib)

load a dynamically linked shared library

LoadWeakDyLib(DyLib)

load a dynamically linked shared library that is allowed to be missing (all symbols are weak imported).

ReexportDyLib(DyLib)

load and re-export dylib

LoadUpwardDylib(DyLib)

load upward dylib

LazyLoadDylib(DyLib)

delay load of dylib until first use

Rpath(String)

add a runtime search path for shared libraries

IdDyLinker(LcString)

dynamic linker identification

LoadDyLinker(LcString)

load a dynamic linker

DyLdEnv(LcString)

string for dyld to treat like environment variable

SymTab

The symtab_command contains the offsets and sizes of the link-edit 4.3BSD "stab" style symbol table information as described in the header files <nlist.h> and <stab.h>.

Fields of SymTab

symoff: u32

symbol table offset

nsyms: u32

number of symbol table entries

stroff: u32

string table offset

strsize: u32

string table size in bytes

DySymTab

This is the second set of the symbolic information which is used to support the data structures for the dynamically link editor.

The original set of symbolic information in the symtab_command which contains the symbol and string tables must also be present when this load command is present. When this load command is present the symbol table is organized into three groups of symbols: local symbols (static and debugging symbols) - grouped by module defined external symbols - grouped by module (sorted by name if not lib) undefined external symbols (sorted by name if MH_BINDATLOAD is not set, and in order the were seen by the static linker if MH_BINDATLOAD is set) In this load command there are offsets and counts to each of the three groups of symbols.

This load command contains a the offsets and sizes of the following new symbolic information tables: table of contents module table reference symbol table indirect symbol table The first three tables above (the table of contents, module table and reference symbol table) are only present if the file is a dynamically linked shared library. For executable and object modules, which are files containing only one module, the information that would be in these three tables is determined as follows: table of contents - the defined external symbols are sorted by name module table - the file contains only one module so everything in the file is part of the module. reference symbol table - is the defined and undefined external symbols

For dynamically linked shared library files this load command also contains offsets and sizes to the pool of relocation entries for all sections separated into two groups: external relocation entries local relocation entries For executable and object modules the relocation entries continue to hang off the section structures.

Fields of DySymTab

ilocalsym: u32

index to local symbols

nlocalsym: u32

number of local symbols

iextdefsym: u32

index to externally defined symbols

nextdefsym: u32

number of externally defined symbols

iundefsym: u32

index to undefined symbols

nundefsym: u32

number of undefined symbols

tocoff: u32

file offset to table of contents

ntoc: u32

number of entries in table of contents

modtaboff: u32

file offset to module table

nmodtab: u32

number of module table entries

extrefsymoff: u32

offset to referenced symbol table

nextrefsyms: u32

number of referenced symbol table entries

indirectsymoff: u32

file offset to the indirect symbol table

nindirectsyms: u32

number of indirect symbol table entries

extreloff: u32

offset to external relocation entries

nextrel: u32

number of external relocation entries

locreloff: u32

offset to local relocation entries

nlocrel: u32

number of local relocation entries

Uuid(Uuid)

The uuid load command contains a single 128-bit unique random number that identifies an object produced by the static link editor.

CodeSignature(LinkEditData)

local of code signature

SegmentSplitInfo(LinkEditData)

local of info to split segments

FunctionStarts(LinkEditData)

compressed table of function start addresses

DataInCode(LinkEditData)

table of non-instructions in __text

DylibCodeSignDrs(LinkEditData)

Code signing DRs copied from linked dylibs

LinkerOptimizationHint(LinkEditData)

optimization hints in MH_OBJECT files

VersionMin

The version_min_command contains the min OS version on which this binary was built to run.

Fields of VersionMin

target: BuildTargetversion: VersionTagsdk: VersionTag
DyldInfo

The dyld_info_command contains the file offsets and sizes of the new compressed form of the information dyld needs to load the image. This information is used by dyld on Mac OS X 10.6 and later. All information pointed to by this command is encoded using byte streams, so no endian swapping is needed to interpret it.

Fields of DyldInfo

rebase_off: u32

file offset to rebase info

rebase_size: u32

size of rebase info

bind_off: u32

file offset to binding info

bind_size: u32

size of binding info

weak_bind_off: u32

file offset to weak binding info

weak_bind_size: u32

size of weak binding info

lazy_bind_off: u32

file offset to lazy binding info

lazy_bind_size: u32

size of lazy binding infs

export_off: u32

file offset to lazy binding info

export_size: u32

size of lazy binding infs

EntryPoint

The entry_point_command is a replacement for thread_command. It is used for main executables to specify the location (file offset) of main(). If -stack_size was used at link time, the stacksize field will contain the stack size need for the main thread.

Fields of EntryPoint

entryoff: u64

file (__TEXT) offset of main()

stacksize: u64

if not zero, initial stack size

SourceVersion(SourceVersionTag)

The source_version_command is an optional load command containing the version of the sources used to build the binary.

UnixThread

Thread commands contain machine-specific data structures suitable for use in the thread state primitives. The machine specific data structures follow the struct thread_command as follows. Each flavor of machine specific data structure is preceded by an unsigned long constant for the flavor of that data structure, an that is the count of longs of the size of the state data structure and then the state data structure follows. This triple may be repeated for many flavors. The constants for the flavors, counts and state data structure definitions are expected to be in the header file <machine/thread_status.h>. These machine specific data structures sizes must be multiples of 4 bytes The cmdsize reflects the total size of the thread_command and all of the sizes of the constants for the flavors, counts and state data structures.

Fields of UnixThread

flavor: u32

flavor of thread state

count: u32

count of longs in thread state

state: ThreadState

thread state for this flavor

SubFramework(LcString)

A dynamically linked shared library may be a subframework of an umbrella framework. If so it will be linked with "-umbrella umbrella_name" where Where "umbrella_name" is the name of the umbrella framework. A subframework can only be linked against by its umbrella framework or other subframeworks that are part of the same umbrella framework. Otherwise the static link editor produces an error and states to link against the umbrella framework. The name of the umbrella framework for subframeworks is recorded in the following structure.

SubUmbrella(LcString)

A dynamically linked shared library may be a sub_umbrella of an umbrella framework. If so it will be linked with "-sub_umbrella umbrella_name" where Where "umbrella_name" is the name of the sub_umbrella framework. When staticly linking when -twolevel_namespace is in effect a twolevel namespace umbrella framework will only cause its subframeworks and those frameworks listed as sub_umbrella frameworks to be implicited linked in. Any other dependent dynamic libraries will not be linked it when -twolevel_namespace is in effect. The primary library recorded by the static linker when resolving a symbol in these libraries will be the umbrella framework. Zero or more sub_umbrella frameworks may be use by an umbrella framework. The name of a sub_umbrella framework is recorded in the following structure.

SubClient(LcString)

For dynamically linked shared libraries that are subframework of an umbrella framework they can allow clients other than the umbrella framework or other subframeworks in the same umbrella framework. To do this the subframework is built with "-allowable_client client_name" and an LC_SUB_CLIENT load command is created for each -allowable_client flag. The client_name is usually a framework name. It can also be a name used for bundles clients where the bundle is built with "-client_name client_name".

SubLibrary(LcString)

A dynamically linked shared library may be a sub_library of another shared library. If so it will be linked with "-sub_library library_name" where Where "library_name" is the name of the sub_library shared library. When staticly linking when -twolevel_namespace is in effect a twolevel namespace shared library will only cause its subframeworks and those frameworks listed as sub_umbrella frameworks and libraries listed as sub_libraries to be implicited linked in. Any other dependent dynamic libraries will not be linked it when -twolevel_namespace is in effect. The primary library recorded by the static linker when resolving a symbol in these libraries will be the umbrella framework (or dynamic library). Zero or more sub_library shared libraries may be use by an umbrella framework or (or dynamic library). The name of a sub_library framework is recorded in the following structure. For example /usr/lib/libobjc_profile.A.dylib would be recorded as "libobjc".

LinkerOption(Vec<String>)

The linker_option_command contains linker options embedded in object files.

Routines

The routines command contains the address of the dynamic shared library initialization routine and an index into the module table for the module that defines the routine. Before any modules are used from the library the dynamic linker fully binds the module that defines the initialization routine and then calls it. This gets called before any module initialization routines (used for C++ static constructors) in the library.

Fields of Routines

init_address: u32

address of initialization routine

init_module: u32

index into the module table that the init routine is defined in

Routines64

Fields of Routines64

init_address: u64

address of initialization routine

init_module: u64

index into the module table that the init routine is defined in

EncryptionInfo

The encryption_info_command contains the file offset and size of an of an encrypted segment.

Fields of EncryptionInfo

offset: u32

file offset of encrypted range

size: u32

file size of encrypted range

id: u32

which enryption system, 0 means not-encrypted yet

EncryptionInfo64

Fields of EncryptionInfo64

offset: u32

file offset of encrypted range

size: u32

file size of encrypted range

id: u32

which enryption system, 0 means not-encrypted yet

TwoLevelHints

The twolevel_hints_command contains the offset and number of hints in the two-level namespace lookup hints table.

Fields of TwoLevelHints

offset: u32

offset to the hint table

nhints: u32

number of hints in the hint table

BuildVersion(BuildVersion)

The build_version_command contains the min OS version on which this binary was built to run for its platform. The list of known platforms and tool values following it.

Command

Fields of Command

cmd: u32

type of load command

payload: Vec<u8>

command in bytes

Methods

impl LoadCommand[src]

pub fn parse<O: ByteOrder, T: AsRef<[u8]>>(
    header: &MachHeader,
    buf: &mut Cursor<T>
) -> Result<(LoadCommand, usize), Error>
[src]

pub fn cmd(&self) -> u32[src]

pub fn name(&self) -> &'static str[src]

Trait Implementations

impl Clone for LoadCommand[src]

impl Debug for LoadCommand[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]