Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

mach-o.h File Reference


Detailed Description

Mach-0 structures, types and defines.

Definition in file mach-o.h.

#include <k/kDefs.h>
#include <k/kTypes.h>

Go to the source code of this file.

Classes

struct  fat_arch
struct  fat_header
struct  lc_str
struct  load_command
struct  mach_header_32
struct  mach_header_64
struct  macho_nlist_32
struct  macho_nlist_64
struct  macho_relocation_info
struct  scattered_relocation_info
struct  section_32
struct  section_64
struct  segment_command_32
struct  segment_command_64
struct  symtab_command
struct  thread_command
struct  uuid_command

Defines

#define IMAGE_FAT_SIGNATURE   KU32_C(0xcafebabe)
#define IMAGE_FAT_SIGNATURE_OE   KU32_C(0xbebafeca)
#define IMAGE_MACHO32_SIGNATURE   KU32_C(0xfeedface)
#define IMAGE_MACHO32_SIGNATURE_OE   KU32_C(0xcefaedfe)
#define IMAGE_MACHO64_SIGNATURE   KU32_C(0xfeedfacf)
#define IMAGE_MACHO64_SIGNATURE_OE   KU32_C(0xfefaedfe)
#define MH_CIGAM   IMAGE_MACHO32_SIGNATURE_OE
#define MH_CIGAM_64   IMAGE_MACHO64_SIGNATURE_OE
#define MH_MAGIC   IMAGE_MACHO32_SIGNATURE
#define MH_MAGIC_64   IMAGE_MACHO64_SIGNATURE
#define R_ABS   0
#define R_SCATTERED   KU32_C(0x80000000)
CPU types / bits (mach_header_64::cputype, mach_header_32::cputype, fat_arch::cputype)
#define CPU_ARCH_ABI64   KI32_C(0x01000000)
#define CPU_ARCH_MASK   KI32_C(0xff000000)
#define CPU_TYPE_ANY   KI32_C(-1)
#define CPU_TYPE_HPPA   KI32_C(11)
#define CPU_TYPE_I386   CPU_TYPE_X86
#define CPU_TYPE_I860   KI32_C(15)
#define CPU_TYPE_MC680x0   KI32_C(6)
#define CPU_TYPE_MC88000   KI32_C(13)
#define CPU_TYPE_MC98000   KI32_C(10)
#define CPU_TYPE_POWERPC   KI32_C(18)
#define CPU_TYPE_POWERPC64   (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
#define CPU_TYPE_SPARC   KI32_C(14)
#define CPU_TYPE_VAX   KI32_C(1)
#define CPU_TYPE_X86   KI32_C(7)
#define CPU_TYPE_X86_64   (CPU_TYPE_X86 | CPU_ARCH_ABI64)
CPU subtypes (mach_header_64::cpusubtype, mach_header_32::cpusubtype, fat_arch::cpusubtype)
#define CPU_SUBTYPE_386   CPU_SUBTYPE_INTEL(3, 0)
#define CPU_SUBTYPE_486   CPU_SUBTYPE_INTEL(4, 0)
#define CPU_SUBTYPE_486SX   CPU_SUBTYPE_INTEL(4, 8)
#define CPU_SUBTYPE_586   CPU_SUBTYPE_INTEL(5, 0)
#define CPU_SUBTYPE_BIG_ENDIAN   KI32_C(1)
#define CPU_SUBTYPE_CELERON   CPU_SUBTYPE_INTEL(7, 6)
#define CPU_SUBTYPE_CELERON_MOBILE   CPU_SUBTYPE_INTEL(7, 7)
#define CPU_SUBTYPE_HPPA_7100   KI32_C(0)
#define CPU_SUBTYPE_HPPA_7100LC   KI32_C(1)
#define CPU_SUBTYPE_HPPA_ALL   KI32_C(0)
#define CPU_SUBTYPE_I386_ALL   CPU_SUBTYPE_INTEL(3, 0)
#define CPU_SUBTYPE_I860_860   KI32_C(1)
#define CPU_SUBTYPE_I860_ALL   KI32_C(0)
#define CPU_SUBTYPE_INTEL(fam, model)   ( (KI32)(((model) << 4) | (fam)) )
#define CPU_SUBTYPE_INTEL_FAMILY(subtype)   ( (subtype) & 0xf )
#define CPU_SUBTYPE_INTEL_FAMILY_MAX   0xf
#define CPU_SUBTYPE_INTEL_MODEL(subtype)   ( (subtype) >> 4 )
#define CPU_SUBTYPE_INTEL_MODEL_ALL   0
#define CPU_SUBTYPE_ITANIUM   CPU_SUBTYPE_INTEL(11, 0)
#define CPU_SUBTYPE_ITANIUM_2   CPU_SUBTYPE_INTEL(11, 1)
#define CPU_SUBTYPE_LITTLE_ENDIAN   KI32_C(0)
#define CPU_SUBTYPE_MC68030   KI32_C(1)
#define CPU_SUBTYPE_MC68030_ONLY   KI32_C(3)
#define CPU_SUBTYPE_MC68040   KI32_C(2)
#define CPU_SUBTYPE_MC680x0_ALL   KI32_C(1)
#define CPU_SUBTYPE_MC88000_ALL   KI32_C(0)
#define CPU_SUBTYPE_MC88100   KI32_C(1)
#define CPU_SUBTYPE_MC88110   KI32_C(2)
#define CPU_SUBTYPE_MC98000_ALL   KI32_C(0)
#define CPU_SUBTYPE_MC98601   KI32_C(1)
#define CPU_SUBTYPE_MIPS_ALL   KI32_C(0)
#define CPU_SUBTYPE_MIPS_R2000   KI32_C(5)
#define CPU_SUBTYPE_MIPS_R2000a   KI32_C(4)
#define CPU_SUBTYPE_MIPS_R2300   KI32_C(1)
#define CPU_SUBTYPE_MIPS_R2600   KI32_C(2)
#define CPU_SUBTYPE_MIPS_R2800   KI32_C(3)
#define CPU_SUBTYPE_MIPS_R3000   KI32_C(7)
#define CPU_SUBTYPE_MIPS_R3000a   KI32_C(6)
#define CPU_SUBTYPE_MULTIPLE   KI32_C(-1)
#define CPU_SUBTYPE_PENT   CPU_SUBTYPE_INTEL(5, 0)
#define CPU_SUBTYPE_PENTII_M3   CPU_SUBTYPE_INTEL(6, 3)
#define CPU_SUBTYPE_PENTII_M5   CPU_SUBTYPE_INTEL(6, 5)
#define CPU_SUBTYPE_PENTIUM_3   CPU_SUBTYPE_INTEL(8, 0)
#define CPU_SUBTYPE_PENTIUM_3_M   CPU_SUBTYPE_INTEL(8, 1)
#define CPU_SUBTYPE_PENTIUM_3_XEON   CPU_SUBTYPE_INTEL(8, 2)
#define CPU_SUBTYPE_PENTIUM_4   CPU_SUBTYPE_INTEL(10, 0)
#define CPU_SUBTYPE_PENTIUM_4_M   CPU_SUBTYPE_INTEL(10, 1)
#define CPU_SUBTYPE_PENTIUM_M   CPU_SUBTYPE_INTEL(9, 0)
#define CPU_SUBTYPE_PENTPRO   CPU_SUBTYPE_INTEL(6, 1)
#define CPU_SUBTYPE_POWERPC_601   KI32_C(1)
#define CPU_SUBTYPE_POWERPC_602   KI32_C(2)
#define CPU_SUBTYPE_POWERPC_603   KI32_C(3)
#define CPU_SUBTYPE_POWERPC_603e   KI32_C(4)
#define CPU_SUBTYPE_POWERPC_603ev   KI32_C(5)
#define CPU_SUBTYPE_POWERPC_604   KI32_C(6)
#define CPU_SUBTYPE_POWERPC_604e   KI32_C(7)
#define CPU_SUBTYPE_POWERPC_620   KI32_C(8)
#define CPU_SUBTYPE_POWERPC_7400   KI32_C(10)
#define CPU_SUBTYPE_POWERPC_7450   KI32_C(11)
#define CPU_SUBTYPE_POWERPC_750   KI32_C(9)
#define CPU_SUBTYPE_POWERPC_970   KI32_C(100)
#define CPU_SUBTYPE_POWERPC_ALL   KI32_C(0)
#define CPU_SUBTYPE_POWERPC_Max   KI32_C(10)
#define CPU_SUBTYPE_POWERPC_SCVger   KI32_C(11)
#define CPU_SUBTYPE_SPARC_ALL   KI32_C(0)
#define CPU_SUBTYPE_UVAXI   KI32_C(5)
#define CPU_SUBTYPE_UVAXII   KI32_C(6)
#define CPU_SUBTYPE_UVAXIII   KI32_C(12)
#define CPU_SUBTYPE_VAX730   KI32_C(4)
#define CPU_SUBTYPE_VAX750   KI32_C(3)
#define CPU_SUBTYPE_VAX780   KI32_C(1)
#define CPU_SUBTYPE_VAX785   KI32_C(2)
#define CPU_SUBTYPE_VAX8200   KI32_C(7)
#define CPU_SUBTYPE_VAX8500   KI32_C(8)
#define CPU_SUBTYPE_VAX8600   KI32_C(9)
#define CPU_SUBTYPE_VAX8650   KI32_C(10)
#define CPU_SUBTYPE_VAX8800   KI32_C(11)
#define CPU_SUBTYPE_VAX_ALL   KI32_C(0)
#define CPU_SUBTYPE_X86_64_ALL   KI32_C(3)
#define CPU_SUBTYPE_X86_ALL   KI32_C(3)
#define CPU_SUBTYPE_X86_ARCH1   KI32_C(4)
#define CPU_SUBTYPE_XEON   CPU_SUBTYPE_INTEL(12, 0)
#define CPU_SUBTYPE_XEON_MP   CPU_SUBTYPE_INTEL(12, 1)
Symbol Description Bits (macho_nlist_32_t::n_desc, macho_nlist_64_t::n_desc)
Mach-O puts the n_desc field to a number of uses, like lazy binding , library ordinal numbers for -twolevel_namespace, stripping and weak symbol handling.

Remarks:
The REFERENCE_FLAGS_* are really not flags in the normal sense (bit), they are more like enum values.


#define DYNAMIC_LOOKUP_ORDINAL   0xfe
#define EXECUTABLE_ORDINAL   0xff
#define GET_LIBRARY_ORDINAL(n_desc)   (((n_desc) >> 8) & 0xff)
#define MAX_LIBRARY_ORDINAL   0xfd
#define N_DESC_DISCARDED   KU16_C(0x0020)
#define N_NO_DEAD_STRIP   KU16_C(0x0020)
#define N_REF_TO_WEAK   KU16_C(0x0080)
#define N_WEAK_DEF   KU16_C(0x0080)
#define N_WEAK_REF   KU16_C(0x0040)
#define REFERENCE_FLAG_DEFINED   2
#define REFERENCE_FLAG_PRIVATE_DEFINED   3
#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY   5
#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY   4
#define REFERENCE_FLAG_UNDEFINED_LAZY   1
#define REFERENCE_FLAG_UNDEFINED_NON_LAZY   0
#define REFERENCE_TYPE   KU16_C(0x000f)
#define REFERENCED_DYNAMICALLY   KU16_C(0x0010)
#define SELF_LIBRARY_ORDINAL   0x00
#define SET_LIBRARY_ORDINAL(n_desc, ordinal)   (n_desc) = (((n_desc) & 0xff) | (((ordinal) & 0xff) << 8))
Load Command IDs (load_command::cmd)
#define LC_DYSYMTAB   KU32_C(0x0b)
#define LC_FVMFILE   KU32_C(0x09)
#define LC_ID_DYLIB   KU32_C(0x0d)
#define LC_ID_DYLINKER   KU32_C(0x0f)
#define LC_IDENT   KU32_C(0x08)
#define LC_IDFVMLIB   KU32_C(0x07)
#define LC_LOAD_DYLIB   KU32_C(0x0c)
#define LC_LOAD_DYLINKER   KU32_C(0x0e)
#define LC_LOAD_WEAK_DYLIB   (KU32_C(0x18) | LC_REQ_DYLD)
#define LC_LOADFVMLIB   KU32_C(0x06)
#define LC_PREBIND_CKSUM   KU32_C(0x17)
#define LC_PREBOUND_DYLIB   KU32_C(0x10)
#define LC_PREPAGE   KU32_C(0x0a)
#define LC_REQ_DYLD   KU32_C(0x80000000)
#define LC_ROUTINES   KU32_C(0x11)
#define LC_ROUTINES_64   KU32_C(0x1a)
#define LC_SEGMENT_32   KU32_C(0x01)
#define LC_SEGMENT_64   KU32_C(0x19)
#define LC_SUB_CLIENT   KU32_C(0x14)
#define LC_SUB_FRAMEWORK   KU32_C(0x12)
#define LC_SUB_LIBRARY   KU32_C(0x15)
#define LC_SUB_UMBRELLA   KU32_C(0x13)
#define LC_SYMSEG   KU32_C(0x03)
#define LC_SYMTAB   KU32_C(0x02)
#define LC_THREAD   KU32_C(0x04)
#define LC_TWOLEVEL_HINTS   KU32_C(0x16)
#define LC_UNIXTHREAD   KU32_C(0x05)
#define LC_UUID   KU32_C(0x1b)
Symbol Type Constants (macho_nlist_32_t::n_type, macho_nlist_64_t::n_type)
In the Mach-O world n_type is somewhat similar to a.out, meaning N_EXT, N_UNDF, N_ABS and the debug symbols are essentially the same, but the remaining stuff is different. The main reason for this is that the encoding of section has been moved to n_sect to permit up to 255 sections instead of the fixed 3 a.out sections (not counting the abs symbols and set vectors).

To avoid confusion with a.out the Mach-O constants has been fitted with a MACHO_ prefix here.

Common symbols (aka communal symbols and comdefs) are represented by n_type = MACHO_N_EXT | MACHO_N_UNDF, n_sect = NO_SECT and n_value giving the size.

Symbol table entries can be inserted directly in the assembly code using this notation:

      .stabs "n_name", n_type, n_sect, n_desc, n_value

(1) The line number is optional, GCC doesn't set it. (2) The type is optional, GCC doesn't set it. (3) The binutil header is "skeptical" about the line. I'm skeptical about the whole thing... :-) (M) Mach-O specific? (S) Sun specific?

#define MACHO_N_ABS   KU8_C(0x02)
#define MACHO_N_BCOMM   KU8_C(0xe2)
#define MACHO_N_BINCL   KU8_C(0x82)
#define MACHO_N_BNSYM   KU8_C(0x2e)
#define MACHO_N_ECOML   KU8_C(0xe8)
#define MACHO_N_ECOMM   KU8_C(0xe4)
#define MACHO_N_EINCL   KU8_C(0xa2)
#define MACHO_N_ENSYM   KU8_C(0x4e)
#define MACHO_N_ENTRY   KU8_C(0xa4)
#define MACHO_N_EXCL   KU8_C(0xc2)
#define MACHO_N_EXT   KU8_C(0x01)
#define MACHO_N_FNAME   KU8_C(0x22)
#define MACHO_N_FUN   KU8_C(0x24)
#define MACHO_N_GSYM   KU8_C(0x20)
#define MACHO_N_INDR   KU8_C(0x0a)
#define MACHO_N_LBRAC   KU8_C(0xc0)
#define MACHO_N_LCSYM   KU8_C(0x28)
#define MACHO_N_LENG   KU8_C(0xfe)
#define MACHO_N_LSYM   KU8_C(0x80)
#define MACHO_N_OLEVEL   KU8_C(0x8A)
#define MACHO_N_OPT   KU8_C(0x3c)
#define MACHO_N_OSO   KU8_C(0x66)
#define MACHO_N_PARAMS   KU8_C(0x86)
#define MACHO_N_PBUD   KU8_C(0x0c)
#define MACHO_N_PC   KU8_C(0x30)
#define MACHO_N_PEXT   KU8_C(0x10)
#define MACHO_N_PSYM   KU8_C(0xa0)
#define MACHO_N_RBRAC   KU8_C(0xe0)
#define MACHO_N_RSYM   KU8_C(0x40)
#define MACHO_N_SECT   KU8_C(0x0e)
#define MACHO_N_SLINE   KU8_C(0x44)
#define MACHO_N_SO   KU8_C(0x64)
#define MACHO_N_SOL   KU8_C(0x84)
#define MACHO_N_SSYM   KU8_C(0x60)
#define MACHO_N_STAB   KU8_C(0xe0)
#define MACHO_N_STSYM   KU8_C(0x26)
#define MACHO_N_TYPE   KU8_C(0x0e)
#define MACHO_N_UNDF   KU8_C(0x00)
#define MACHO_N_VERSION   KU8_C(0x88)
Mach-O Header flags (mach_header_64::flags, mach_header_32::flags)
#define MH_ALLMODSBOUND   KU32_C(0x00001000)
#define MH_ALLOW_STACK_EXECUTION   KU32_C(0x00020000)
#define MH_BINDATLOAD   KU32_C(0x00000008)
#define MH_BINDS_TO_WEAK   KU32_C(0x00010000)
#define MH_CANONICAL   KU32_C(0x00004000)
#define MH_DYLDLINK   KU32_C(0x00000004)
#define MH_FORCE_FLAT   KU32_C(0x00000100)
#define MH_INCRLINK   KU32_C(0x00000002)
#define MH_LAZY_INIT   KU32_C(0x00000040)
#define MH_NOFIXPREBINDING   KU32_C(0x00000400)
#define MH_NOMULTIDEFS   KU32_C(0x00000200)
#define MH_NOUNDEFS   KU32_C(0x00000001)
#define MH_PREBINDABLE   KU32_C(0x00000800)
#define MH_PREBOUND   KU32_C(0x00000010)
#define MH_SPLIT_SEGS   KU32_C(0x00000020)
#define MH_SUBSECTIONS_VIA_SYMBOLS   KU32_C(0x00002000)
#define MH_TWOLEVEL   KU32_C(0x00000080)
#define MH_VALID_FLAGS   KU32_C(0x0003ffff)
#define MH_WEAK_DEFINES   KU32_C(0x00008000)
File types (mach_header_64::filetype, mach_header_32::filetype)
#define MH_BUNDLE   KU32_C(8)
#define MH_CORE   KU32_C(4)
#define MH_DSYM   KU32_C(10)
#define MH_DYLIB   KU32_C(6)
#define MH_DYLIB_STUB   KU32_C(9)
#define MH_DYLINKER   KU32_C(7)
#define MH_EXECUTE   KU32_C(2)
#define MH_FVMLIB   KU32_C(3)
#define MH_OBJECT   KU32_C(1)
#define MH_PRELOAD   KU32_C(5)
Section flags (section_64::flags, section_32::flags)
#define S_16BYTE_LITERALS   0xe
#define S_4BYTE_LITERALS   0x3
#define S_8BYTE_LITERALS   0x4
#define S_ATTR_DEBUG   KU32_C(0x02000000)
#define S_ATTR_EXT_RELOC   KU32_C(0x00000200)
#define S_ATTR_LIVE_SUPPORT   KU32_C(0x08000000)
#define S_ATTR_LOC_RELOC   KU32_C(0x00000100)
#define S_ATTR_NO_DEAD_STRIP   KU32_C(0x10000000)
#define S_ATTR_NO_TOC   KU32_C(0x40000000)
#define S_ATTR_PURE_INSTRUCTIONS   KU32_C(0x80000000)
#define S_ATTR_SELF_MODIFYING_CODE   KU32_C(0x04000000)
#define S_ATTR_SOME_INSTRUCTIONS   KU32_C(0x00000400)
#define S_ATTR_STRIP_STATIC_SYMS   KU32_C(0x20000000)
#define S_COALESCED   0xb
#define S_CSTRING_LITERALS   0x2
#define S_GB_ZEROFILL   0xc
#define S_INTERPOSING   0xd
#define S_LAZY_SYMBOL_POINTERS   0x7
#define S_LITERAL_POINTERS   0x5
#define S_MOD_INIT_FUNC_POINTERS   0x9
#define S_MOD_TERM_FUNC_POINTERS   0xa
#define S_NON_LAZY_SYMBOL_POINTERS   0x6
#define S_REGULAR   0x0
#define S_SYMBOL_STUBS   0x8
#define S_ZEROFILL   0x1
#define SECTION_ATTRIBUTES   KU32_C(0xffffff00)
#define SECTION_ATTRIBUTES_SYS   KU32_C(0x00ffff00)
#define SECTION_ATTRIBUTES_USR   KU32_C(0xff000000)
#define SECTION_TYPE   KU32_C(0x000000ff)
Known Segment and Section Names.
Some of these implies special linker behaviour.

#define SECT_BSS   "__bss"
#define SECT_COMMON   "__common"
#define SECT_DATA   "__data"
#define SECT_FVMLIB_INIT0   "__fvmlib_init0"
#define SECT_FVMLIB_INIT1   "__fvmlib_init1"
#define SECT_ICON_HEADER   "__header"
#define SECT_ICON_TIFF   "__tiff"
#define SECT_OBJC_MODULES   "__module_info"
#define SECT_OBJC_REFS   "__selector_refs"
#define SECT_OBJC_STRINGS   "__selector_strs"
#define SECT_OBJC_SYMBOLS   "__symbol_table"
#define SECT_TEXT   "__text"
#define SEG_DATA   "__DATA"
#define SEG_ICON   "__ICON"
#define SEG_IMPORT   "__IMPORT"
#define SEG_LINKEDIT   "__LINKEDIT"
#define SEG_OBJC   "__OBJC"
#define SEG_PAGEZERO   "__PAGEZERO"
#define SEG_TEXT   "__TEXT"
#define SEG_UNIXSTACK   "__UNIXSTACK"
Segment flags (segment_command_64::flags, segment_command_32::flags)
#define SG_FVMLIB   KU32_C(0x00000002)
#define SG_HIGHVM   KU32_C(0x00000001)
#define SG_NORELOC   KU32_C(0x00000004)
#define SG_PROTECTED_VERSION_1   KU32_C(0x00000008)

Typedefs

typedef struct fat_arch fat_arch_t
typedef struct fat_header fat_header_t
typedef struct lc_str lc_str_t
typedef struct load_command load_command_t
typedef struct mach_header_32 mach_header_32_t
typedef struct mach_header_64 mach_header_64_t
typedef struct macho_nlist_32 macho_nlist_32_t
typedef struct macho_nlist_64 macho_nlist_64_t
typedef struct
macho_relocation_info 
macho_relocation_info_t
typedef enum reloc_type_generic reloc_type_generic_t
typedef struct
scattered_relocation_info 
scattered_relocation_info_t
typedef struct section_32 section_32_t
typedef struct section_64 section_64_t
typedef struct segment_command_32 segment_command_32_t
typedef struct segment_command_64 segment_command_64_t
typedef struct symtab_command symtab_command_t
typedef struct thread_command thread_command_t
typedef struct uuid_command uuid_command_t

Enumerations

enum  reloc_type_generic {
  GENERIC_RELOC_VANILLA = 0, GENERIC_RELOC_PAIR, GENERIC_RELOC_SECTDIFF, GENERIC_RELOC_PB_LA_PTR,
  GENERIC_RELOC_LOCAL_SECTDIFF
}


Generated by  Doxygen 1.6.0   Back to index