[][src]Module goblin::mach::load_command

Load commands tell the kernel and dynamic linker anything from how to load this binary into memory, what the entry point is, apple specific information, to which libraries it requires for dynamic linking

Structs

DataInCodeEntry

The LC_DATA_IN_CODE load commands uses a linkedit_data_command to point to an array of data_in_code_entry entries. Each entry describes a range of data in a code section.

DyldInfoCommand
Dylib

A dynamically linked shared library (fipub constype == MH_DYLIB in the mach header) contains a dylib_command (cmd == LC_ID_DYLIB) to identify the library. An object that uses a dynamically linked shared library also contains a dylib_command (cmd == LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, or LC_REEXPORT_DYLIB) for each library it uses.

DylibCommand
DylibModule

a module table entry

DylibModule64

a 64-bit module table entry

DylibReference

The entries in the reference symbol table are used when loading the module (both by the static and dynamic link editors) and if the module is unloaded or replaced. Therefore all external symbols (defined and undefined) are listed in the module's reference table. The flags describe the type of reference that is being made. The constants for the flags are defined in <mach-o/nlist.h> as they are also used for symbol table entries.

DylibTableOfContents

a table of contents entry

DylinkerCommand

The name of the dynamic linker

DysymtabCommand

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

EncryptionInfoCommand32

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

EncryptionInfoCommand64

The encryption_info_command_64 contains the file offset and size of an of an encrypted segment (for use in x86_64 targets).

EntryPointCommand

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.

FvmfileCommand

The fvmfile_command contains a reference to a file to be loaded at the specified virtual address. (Presently, this command is reserved for internal use. The kernel ignores this command when loading a program into memory).

Fvmlib

Fixed virtual memory shared libraries are identified by two things. The target pathname (the name of the library as found for execution), and the minor version number. The address of where the headers are loaded is in header_addr. (THIS IS OBSOLETE and no longer supported).

FvmlibCommand

A fixed virtual shared library (fipub constype == MH_FVMLIB in the mach header) contains a fvmlib_command (cmd == LC_IDFVMLIB) to identify the library. An object that uses a fixed virtual shared library also contains a fvmlib_command (cmd == LC_LOADFVMLIB) for each library it uses. (THIS IS OBSOLETE and no longer supported).

IdentCommand

The ident_command contains a free format string table following the ident_command structure. The strings are null terminated and the size of the command is padded out with zero bytes to a multiple of 4 bytes/ (THIS IS OBSOLETE and no longer supported).

LinkeditDataCommand

The linkedit_data_command contains the offsets and sizes of a blob of data in the __LINKEDIT segment.

LinkerOptionCommand

The linker_option_command contains linker options embedded in object files.

LoadCommand

A tagged LoadCommand union

LoadCommandHeader

Occurs at the beginning of every load command to serve as a sort of tagged union/enum discriminant

PrebindCksumCommand

The prebind_cksum_command contains the value of the original check sum for prebound files or zero. When a prebound file is first created or modified for other than updating its prebinding information the value of the check sum is set to zero. When the file has it prebinding re-done and if the value of the check sum is zero the original check sum is calculated and stored in cksum field of this load command in the output file. If when the prebinding is re-done and the cksum field is non-zero it is left unchanged from the input file.

PreboundDylibCommand

A program (type == MH_EXECUTE) that is prebound to its dynamic libraries has one of these for each library that the static linker used in prebinding. It contains a bit vector for the modules in the library. The bits indicate which modules are bound (1) and which are not (0) from the library. The bit for module 0 is the low bit of the first byte. So the bit for the Nth module is: (linked_modules[N/8] >> N%8) & 1

RoutinesCommand32

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.

RoutinesCommand64

The 64-bit routines command. Same use as above.

RpathCommand

The rpath_command contains a path which at runtime should be added to the current run path used to find @rpath prefixed dylibs.

Section32
Section64

for 64-bit architectures

SegmentCommand32
SegmentCommand64
SourceVersionCommand

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

SubClientCommand

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".

SubFrameworkCommand

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.

SubLibraryCommand

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".

SubUmbrellaCommand

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.

SymsegCommand

The symseg_command contains the offset and size of the GNU style symbol table information as described in the header file <symseg.h>. The symbol roots of the symbol segments must also be aligned properly in the file. So the requirement of keeping the offsets aligned to a multiple of a 4 bytes translates to the length field of the symbol roots also being a multiple of a long. Also the padding must again be zeroed. (THIS IS OBSOLETE and no longer supported).

SymtabCommand
ThreadCommand

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 uint32_t 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.

TwolevelHint

The entries in the two-level namespace lookup hints table are twolevel_hint structs. These provide hints to the dynamic link editor where to start looking for an undefined symbol in a two-level namespace image. The isub_image field is an index into the sub-images (sub-frameworks and sub-umbrellas list) that made up the two-level image that the undefined symbol was found in when it was built by the static link editor. If isub-image is 0 the the symbol is expected to be defined in library and not in the sub-images. If isub-image is non-zero it is an index into the array of sub-images for the umbrella with the first index in the sub-images being

TwolevelHintsCommand

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

UuidCommand

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

VersionMinCommand

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

Enums

CommandVariant

The various load commands as a cast-free variant/enum

Constants

LC_CODE_SIGNATURE
LC_DATA_IN_CODE
LC_DYLD_ENVIRONMENT
LC_DYLD_INFO
LC_DYLD_INFO_ONLY
LC_DYLIB_CODE_SIGN_DRS
LC_DYSYMTAB
LC_ENCRYPTION_INFO
LC_ENCRYPTION_INFO_64
LC_FUNCTION_STARTS
LC_FVMFILE
LC_IDENT
LC_IDFVMLIB
LC_ID_DYLIB
LC_ID_DYLINKER
LC_LAZY_LOAD_DYLIB
LC_LINKER_OPTIMIZATION_HINT
LC_LINKER_OPTION
LC_LOADFVMLIB
LC_LOAD_DYLIB
LC_LOAD_DYLINKER
LC_LOAD_UPWARD_DYLIB
LC_LOAD_WEAK_DYLIB
LC_MAIN
LC_PREBIND_CKSUM
LC_PREBOUND_DYLIB
LC_PREPAGE
LC_REEXPORT_DYLIB
LC_REQ_DYLD
LC_ROUTINES
LC_ROUTINES_64
LC_RPATH
LC_SEGMENT
LC_SEGMENT_64
LC_SEGMENT_SPLIT_INFO
LC_SOURCE_VERSION
LC_SUB_CLIENT
LC_SUB_FRAMEWORK
LC_SUB_LIBRARY
LC_SUB_UMBRELLA
LC_SYMSEG
LC_SYMTAB
LC_THREAD
LC_TWOLEVEL_HINTS
LC_UNIXTHREAD
LC_UUID
LC_VERSION_MIN_IPHONEOS
LC_VERSION_MIN_MACOSX
SIZEOF_DYLIB
SIZEOF_DYLIB_COMMAND
SIZEOF_DYLIB_INFO_COMMAND
SIZEOF_DYLINKER_COMMAND
SIZEOF_DYSYMTAB_COMMAND
SIZEOF_ENCRYPTION_INFO_COMMAND_32
SIZEOF_ENCRYPTION_INFO_COMMAND_64
SIZEOF_ENTRY_POINT_COMMAND
SIZEOF_FVMFILE_COMMAND
SIZEOF_FVMLIB
SIZEOF_FVMLIB_COMMAND
SIZEOF_IDENT_COMMAND
SIZEOF_LC_STR
SIZEOF_LINKEDIT_DATA_COMMAND
SIZEOF_LINKER_OPTION_COMMAND
SIZEOF_LOAD_COMMAND
SIZEOF_PREBOUND_DYLIB_COMMAND
SIZEOF_RPATH_COMMAND
SIZEOF_SECTION_32
SIZEOF_SECTION_64
SIZEOF_SEGMENT_COMMAND_32
SIZEOF_SEGMENT_COMMAND_64
SIZEOF_SUB_CLIENT_COMMAND
SIZEOF_SUB_FRAMEWORK_COMMAND
SIZEOF_SUB_LIBRARY_COMMAND
SIZEOF_SUB_UMBRELLA_COMMAND
SIZEOF_SYMSEG_COMMAND
SIZEOF_SYMTAB_COMMAND
SIZEOF_UUID_COMMAND
SIZEOF_VERSION_MIN_COMMAND

Functions

cmd_to_str

Type Definitions

LcStr