#include <mach-o/loader.h>

mach-o/loader.h Kernel.framework

This file describes the format of mach object files.
includes: Kernel/stdint.h, Kernel/mach/machine.h, Kernel/mach/vm_prot.h, Kernel/mach/machine/thread_status.h, Kernel/architecture/byte_order.h
4 structs · 4 macros

structmach_header

The 32-bit mach header appears at the very beginning of the object file for 32-bit architectures.
size 28, align 4
uint32_tmagicmach magic number identifier
cpu_type_tcputypecpu specifier
cpu_subtype_tcpusubtypemachine specifier
uint32_tfiletypetype of file
uint32_tncmdsnumber of load commands
uint32_tsizeofcmdsthe size of all the load commands
uint32_tflagsflags

structmach_header_64

The 64-bit mach header appears at the very beginning of object files for 64-bit architectures.
size 32, align 4
uint32_tmagicmach magic number identifier
cpu_type_tcputypecpu specifier
cpu_subtype_tcpusubtypemachine specifier
uint32_tfiletypetype of file
uint32_tncmdsnumber of load commands
uint32_tsizeofcmdsthe size of all the load commands
uint32_tflagsflags
uint32_treservedreserved

structsegment_command

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.
size 56, align 4
uint32_tcmdLC_SEGMENT
uint32_tcmdsizeincludes sizeof section structs
char[16]segnamesegment name
uint32_tvmaddrmemory address of this segment
uint32_tvmsizememory size of this segment
uint32_tfileofffile offset of this segment
uint32_tfilesizeamount to map from the file
vm_prot_tmaxprotmaximum VM protection
vm_prot_tinitprotinitial VM protection
uint32_tnsectsnumber of sections in segment
uint32_tflagsflags

structsegment_command_64

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.
size 72, align 8
uint32_tcmdLC_SEGMENT_64
uint32_tcmdsizeincludes sizeof section_64 structs
char[16]segnamesegment name
uint64_tvmaddrmemory address of this segment
uint64_tvmsizememory size of this segment
uint64_tfileofffile offset of this segment
uint64_tfilesizeamount to map from the file
vm_prot_tmaxprotmaximum VM protection
vm_prot_tinitprotinitial VM protection
uint32_tnsectsnumber of sections in segment
uint32_tflagsflags

macroSEG_LINKINFO

#define SEG_LINKINFO "__LINKINFO"
the segment overlapping with linkedit

macroPLATFORM_XROS

#define PLATFORM_XROS 11

macroPLATFORM_XROSSIMULATOR

#define PLATFORM_XROSSIMULATOR 12

macroPLATFORM_MAX

#define PLATFORM_MAX PLATFORM_XROSSIMULATOR