1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===-- llvm/Support/MachO.h - The MachO file format ------------*- C++ -*-===//
2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//                     The LLVM Compiler Infrastructure
4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is distributed under the University of Illinois Open Source
6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// License. See LICENSE.TXT for details.
7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===//
9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file defines manifest constants for the MachO object file format.
11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===//
13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef LLVM_SUPPORT_MACHO_H
15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define LLVM_SUPPORT_MACHO_H
16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
1719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman#include "llvm/Support/DataTypes.h"
18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// NOTE: The enums in this file are intentially named to be different than those
20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// in the headers in /usr/include/mach (on darwin systems) to avoid conflicts
21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// with those macros.
22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace llvm {
23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  namespace MachO {
24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    // Enums from <mach-o/loader.h>
25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    enum {
2619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      // Constants for the "magic" field in llvm::MachO::mach_header and
27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::mach_header_64
28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderMagic32         = 0xFEEDFACEu, // MH_MAGIC
29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderMagic32Swapped  = 0xCEFAEDFEu, // MH_CIGAM
30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderMagic64         = 0xFEEDFACFu, // MH_MAGIC_64
31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderMagic64Swapped  = 0xCFFAEDFEu, // MH_CIGAM_64
32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      UniversalMagic        = 0xCAFEBABEu, // FAT_MAGIC
33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      UniversalMagicSwapped = 0xBEBAFECAu, // FAT_CIGAM
34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constants for the "filetype" field in llvm::MachO::mach_header and
36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::mach_header_64
37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeObject              = 0x1u, // MH_OBJECT
38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeExecutable          = 0x2u, // MH_EXECUTE
39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeFixedVMShlib        = 0x3u, // MH_FVMLIB
40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeCore                = 0x4u, // MH_CORE
41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypePreloadedExecutable = 0x5u, // MH_PRELOAD
42894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeDynamicShlib        = 0x6u, // MH_DYLIB
43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeDynamicLinkEditor   = 0x7u, // MH_DYLINKER
44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeBundle              = 0x8u, // MH_BUNDLE
45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeDynamicShlibStub    = 0x9u, // MH_DYLIB_STUB
46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeDSYM                = 0xAu, // MH_DSYM
47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFileTypeKextBundle          = 0xBu, // MH_KEXT_BUNDLE
48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constant bits for the "flags" field in llvm::MachO::mach_header and
50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::mach_header_64
51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitNoUndefinedSymbols     = 0x00000001u, // MH_NOUNDEFS
52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitIsIncrementalLinkObject= 0x00000002u, // MH_INCRLINK
53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitIsDynamicLinkObject    = 0x00000004u, // MH_DYLDLINK
54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitBindAtLoad             = 0x00000008u, // MH_BINDATLOAD
55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitPrebound               = 0x00000010u, // MH_PREBOUND
56894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitSplitSegments          = 0x00000020u, // MH_SPLIT_SEGS
57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitLazyInit               = 0x00000040u, // MH_LAZY_INIT
58894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitTwoLevelNamespace      = 0x00000080u, // MH_TWOLEVEL
59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitForceFlatNamespace     = 0x00000100u, // MH_FORCE_FLAT
60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitNoMultipleDefintions   = 0x00000200u, // MH_NOMULTIDEFS
61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitNoFixPrebinding        = 0x00000400u, // MH_NOFIXPREBINDING
62894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitPrebindable            = 0x00000800u, // MH_PREBINDABLE
63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitAllModulesBound        = 0x00001000u, // MH_ALLMODSBOUND
64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitSubsectionsViaSymbols  = 0x00002000u, // MH_SUBSECTIONS_VIA_SYMBOLS
65894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitCanonical              = 0x00004000u, // MH_CANONICAL
66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitWeakDefines            = 0x00008000u, // MH_WEAK_DEFINES
67894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitBindsToWeak            = 0x00010000u, // MH_BINDS_TO_WEAK
68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitAllowStackExecution    = 0x00020000u, // MH_ALLOW_STACK_EXECUTION
69894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitRootSafe               = 0x00040000u, // MH_ROOT_SAFE
70894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitSetUIDSafe             = 0x00080000u, // MH_SETUID_SAFE
71894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitNoReexportedDylibs     = 0x00100000u, // MH_NO_REEXPORTED_DYLIBS
72894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitPIE                    = 0x00200000u, // MH_PIE
73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      HeaderFlagBitDeadStrippableDylib    = 0x00400000u, // MH_DEAD_STRIPPABLE_DYLIB
7419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
75894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constants for the "cmd" field in llvm::MachO::load_command
76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDynamicLinkerRequired    = 0x80000000u, // LC_REQ_DYLD
77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandSegment32                = 0x00000001u, // LC_SEGMENT
78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandSymtab                   = 0x00000002u, // LC_SYMTAB
79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandSymSeg                   = 0x00000003u, // LC_SYMSEG
80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandThread                   = 0x00000004u, // LC_THREAD
81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandUnixThread               = 0x00000005u, // LC_UNIXTHREAD
82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandFixedVMShlibLoad         = 0x00000006u, // LC_LOADFVMLIB
83894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandFixedVMShlibIdent        = 0x00000007u, // LC_IDFVMLIB
84894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandIdent                    = 0x00000008u, // LC_IDENT
85894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandFixedVMFileInclusion     = 0x00000009u, // LC_FVMFILE
86894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandPrePage                  = 0x0000000Au, // LC_PREPAGE
87894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDynamicSymtabInfo        = 0x0000000Bu, // LC_DYSYMTAB
88894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDylibLoad                = 0x0000000Cu, // LC_LOAD_DYLIB
89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDylibIdent               = 0x0000000Du, // LC_ID_DYLIB
90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDynamicLinkerLoad        = 0x0000000Eu, // LC_LOAD_DYLINKER
91894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDynamicLinkerIdent       = 0x0000000Fu, // LC_ID_DYLINKER
92894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDylibPrebound            = 0x00000010u, // LC_PREBOUND_DYLIB
93894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandRoutines32               = 0x00000011u, // LC_ROUTINES
94894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandSubFramework             = 0x00000012u, // LC_SUB_FRAMEWORK
95894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandSubUmbrella              = 0x00000013u, // LC_SUB_UMBRELLA
96894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandSubClient                = 0x00000014u, // LC_SUB_CLIENT
97894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandSubLibrary               = 0x00000015u, // LC_SUB_LIBRARY
98894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandTwoLevelHints            = 0x00000016u, // LC_TWOLEVEL_HINTS
99894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandPreBindChecksum          = 0x00000017u, // LC_PREBIND_CKSUM
100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDylibLoadWeak            = 0x80000018u, // LC_LOAD_WEAK_DYLIB
101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandSegment64                = 0x00000019u, // LC_SEGMENT_64
102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandRoutines64               = 0x0000001Au, // LC_ROUTINES_64
103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandUUID                     = 0x0000001Bu, // LC_UUID
104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandRunpath                  = 0x8000001Cu, // LC_RPATH
105894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandCodeSignature            = 0x0000001Du, // LC_CODE_SIGNATURE
106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandSegmentSplitInfo         = 0x0000001Eu, // LC_SEGMENT_SPLIT_INFO
107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDylibReexport            = 0x8000001Fu, // LC_REEXPORT_DYLIB
108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDylibLazyLoad            = 0x00000020u, // LC_LAZY_LOAD_DYLIB
109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandEncryptionInfo           = 0x00000021u, // LC_ENCRYPTION_INFO
110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDynamicLinkerInfo        = 0x00000022u, // LC_DYLD_INFO
111894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDynamicLinkerInfoOnly    = 0x80000022u, // LC_DYLD_INFO_ONLY
112894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      LoadCommandDylibLoadUpward          = 0x80000023u, // LC_LOAD_UPWARD_DYLIB
11319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      LoadCommandVersionMinMacOSX         = 0x00000024u, // LC_VERSION_MIN_MACOSX
11419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      LoadCommandVersionMinIPhoneOS       = 0x00000025u, // LC_VERSION_MIN_IPHONEOS
11519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      LoadCommandFunctionStarts           = 0x00000026u, // LC_FUNCTION_STARTS
11619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      LoadCommandDyldEnvironment          = 0x00000027u, // LC_DYLD_ENVIRONMENT
11719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constant bits for the "flags" field in llvm::MachO::segment_command
119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SegmentCommandFlagBitHighVM             = 0x1u, // SG_HIGHVM
120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SegmentCommandFlagBitFixedVMLibrary     = 0x2u, // SG_FVMLIB
121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SegmentCommandFlagBitNoRelocations      = 0x4u, // SG_NORELOC
122894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SegmentCommandFlagBitProtectedVersion1  = 0x8u, // SG_PROTECTED_VERSION_1
123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constant masks for the "flags" field in llvm::MachO::section and
126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::section_64
127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionFlagMaskSectionType      = 0x000000ffu, // SECTION_TYPE
128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionFlagMaskAllAttributes    = 0xffffff00u, // SECTION_ATTRIBUTES
129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionFlagMaskUserAttributes   = 0xff000000u, // SECTION_ATTRIBUTES_USR
130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionFlagMaskSystemAttributes = 0x00ffff00u, // SECTION_ATTRIBUTES_SYS
131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
132894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constant masks for the "flags[7:0]" field in llvm::MachO::section and
133894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::section_64 (mask "flags" with SECTION_TYPE)
134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeRegular                    = 0x00u, // S_REGULAR
135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeZeroFill                   = 0x01u, // S_ZEROFILL
136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeCStringLiterals            = 0x02u, // S_CSTRING_LITERALS
137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionType4ByteLiterals              = 0x03u, // S_4BYTE_LITERALS
138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionType8ByteLiterals              = 0x04u, // S_8BYTE_LITERALS
139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeLiteralPointers            = 0x05u, // S_LITERAL_POINTERS
140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeNonLazySymbolPointers      = 0x06u, // S_NON_LAZY_SYMBOL_POINTERS
141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeLazySymbolPointers         = 0x07u, // S_LAZY_SYMBOL_POINTERS
142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeSymbolStubs                = 0x08u, // S_SYMBOL_STUBS
143894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeModuleInitFunctionPointers = 0x09u, // S_MOD_INIT_FUNC_POINTERS
144894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeModuleTermFunctionPointers = 0x0au, // S_MOD_TERM_FUNC_POINTERS
145894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeCoalesced                  = 0x0bu, // S_COALESCED
146894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeZeroFillLarge              = 0x0cu, // S_GB_ZEROFILL
147894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeInterposing                = 0x0du, // S_INTERPOSING
148894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionType16ByteLiterals             = 0x0eu, // S_16BYTE_LITERALS
149894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeDTraceObjectFormat         = 0x0fu, // S_DTRACE_DOF
150894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionTypeLazyDylibSymbolPointers    = 0x10u, // S_LAZY_DYLIB_SYMBOL_POINTERS
151894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
152894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constant masks for the "flags[31:24]" field in llvm::MachO::section and
153894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR)
154894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrUserPureInstructions       = 0x80000000u, // S_ATTR_PURE_INSTRUCTIONS
155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrUserNoTableOfContents      = 0x40000000u, // S_ATTR_NO_TOC
156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrUserCanStripStaticSymbols  = 0x20000000u, // S_ATTR_STRIP_STATIC_SYMS
157894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrUserNoDeadStrip            = 0x10000000u, // S_ATTR_NO_DEAD_STRIP
158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrUserLiveSupport            = 0x08000000u, // S_ATTR_LIVE_SUPPORT
159894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrUserSelfModifyingCode      = 0x04000000u, // S_ATTR_SELF_MODIFYING_CODE
160894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrUserDebug                  = 0x02000000u, // S_ATTR_DEBUG
161894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constant masks for the "flags[23:8]" field in llvm::MachO::section and
163894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS)
164894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrSytemSomeInstructions      = 0x00000400u, // S_ATTR_SOME_INSTRUCTIONS
165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrSytemHasExternalRelocations= 0x00000200u, // S_ATTR_EXT_RELOC
166894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      SectionAttrSytemHasLocalRelocations   = 0x00000100u, // S_ATTR_LOC_RELOC
167894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
168894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      IndirectSymbolLocal                   = 0x80000000u, // INDIRECT_SYMBOL_LOCAL
169894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      IndirectSymbolAbsolute                = 0x40000000u, // INDIRECT_SYMBOL_ABS
170894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
171894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseTypePointer                     = 1u, // REBASE_TYPE_POINTER
172894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseTypeTextAbsolute32              = 2u, // REBASE_TYPE_TEXT_ABSOLUTE32
173894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseTypeTextPCRelative32	    = 3u, // REBASE_TYPE_TEXT_PCREL32
174894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
175894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeMask                          = 0xF0u, // REBASE_OPCODE_MASK
176894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseImmediateMask                       = 0x0Fu, // REBASE_IMMEDIATE_MASK
177894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeDone                          = 0x00u, // REBASE_OPCODE_DONE
178894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeSetTypeImmediate              = 0x10u, // REBASE_OPCODE_SET_TYPE_IMM
179894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeSetSegmentAndOffsetULEB	= 0x20u, // REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeAddAddressULEB                = 0x30u, // REBASE_OPCODE_ADD_ADDR_ULEB
181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeAddAddressImmediateScaled	= 0x40u, // REBASE_OPCODE_ADD_ADDR_IMM_SCALED
182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeDoRebaseImmediateTimes	= 0x50u, // REBASE_OPCODE_DO_REBASE_IMM_TIMES
183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeDoRebaseULEBTimes             = 0x60u, // REBASE_OPCODE_DO_REBASE_ULEB_TIMES
184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeDoRebaseAddAddressULEB        = 0x70u, // REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB
185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      RebaseOpcodeDoRebaseULEBTimesSkippingULEB = 0x80u, // REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB
186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindTypePointer           = 1u, // BIND_TYPE_POINTER
189894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindTypeTextAbsolute32	= 2u, // BIND_TYPE_TEXT_ABSOLUTE32
190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindTypeTextPCRelative32	= 3u, // BIND_TYPE_TEXT_PCREL32
191894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
192894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindSpecialDylibSelf            =  0u, // BIND_SPECIAL_DYLIB_SELF
193894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindSpecialDylibMainExecutable  = -1u, // BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE
194894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindSpecialDylibFlatLookup      = -2u, // BIND_SPECIAL_DYLIB_FLAT_LOOKUP
195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
196894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindSymbolFlagsWeakImport         = 0x1u, // BIND_SYMBOL_FLAGS_WEAK_IMPORT
197894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindSymbolFlagsNonWeakDefinition	= 0x8u, // BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION
198894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
199894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeMask                            = 0xF0u, // BIND_OPCODE_MASK
200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindImmediateMask                         = 0x0Fu, // BIND_IMMEDIATE_MASK
201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeDone                            = 0x00u, // BIND_OPCODE_DONE
202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeSetDylibOrdinalImmediate        = 0x10u, // BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
203894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeSetDylibOrdinalULEB             = 0x20u, // BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB
204894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeSetDylibSpecialImmediate	= 0x30u, // BIND_OPCODE_SET_DYLIB_SPECIAL_IMM
205894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeSetSymbolTrailingFlagsImmediate	= 0x40u, // BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
206894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeSetTypeImmediate		= 0x50u, // BIND_OPCODE_SET_TYPE_IMM
207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeSetAppendSLEB                   = 0x60u, // BIND_OPCODE_SET_ADDEND_SLEB
208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeSetSegmentAndOffsetULEB         = 0x70u, // BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
209894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeAddAddressULEB                  = 0x80u, // BIND_OPCODE_ADD_ADDR_ULEB
210894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeDoBind                          = 0x90u, // BIND_OPCODE_DO_BIND
211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeDoBindAddAddressULEB		= 0xA0u, // BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB
212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeDoBindAddAddressImmediateScaled	= 0xB0u, // BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED
213894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      BindOpcodeDoBindULEBTimesSkippingULEB     = 0xC0u, // BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB
214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      ExportSymbolFlagsKindMask           = 0x03u, // EXPORT_SYMBOL_FLAGS_KIND_MASK
216894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      ExportSymbolFlagsKindRegular	  = 0x00u, // EXPORT_SYMBOL_FLAGS_KIND_REGULAR
217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      ExportSymbolFlagsKindThreadLocal    = 0x01u, // EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL
218894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      ExportSymbolFlagsWeakDefinition     = 0x04u, // EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION
219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      ExportSymbolFlagsIndirectDefinition = 0x08u, // EXPORT_SYMBOL_FLAGS_INDIRECT_DEFINITION
220894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      ExportSymbolFlagsHasSpecializations = 0x10u, // EXPORT_SYMBOL_FLAGS_HAS_SPECIALIZATIONS
221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
222894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
223894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constant masks for the "n_type" field in llvm::MachO::nlist and
224894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::nlist_64
225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NlistMaskStab             = 0xe0, // N_STAB
226894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NlistMaskPrivateExternal	= 0x10, // N_PEXT
227894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NlistMaskType             = 0x0e, // N_TYPE
228894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NlistMaskExternal         = 0x01, // N_EXT
229894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
230894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constants for the "n_type & N_TYPE" llvm::MachO::nlist and
231894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::nlist_64
232894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NListTypeUndefined          = 0x0u, // N_UNDF
233894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NListTypeAbsolute           = 0x2u, // N_ABS
234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NListTypeSection            = 0xeu, // N_SECT
235894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NListTypePreboundUndefined  = 0xcu, // N_PBUD
236894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NListTypeIndirect           = 0xau, // N_INDR
237894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
238894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constant masks for the "n_sect" field in llvm::MachO::nlist and
239894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::nlist_64
240894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NListSectionNoSection     = 0u, // NO_SECT
241894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      NListSectionMaxSection    = 0xffu, // MAX_SECT
242894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
243894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constant values for the "n_type" field in llvm::MachO::nlist and
244894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // llvm::MachO::nlist_64 when "(n_type & NlistMaskStab) != 0"
245894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabGlobalSymbol          = 0x20u,  // N_GSYM
246894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabFunctionName          = 0x22u,  // N_FNAME
247894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabFunction              = 0x24u,  // N_FUN
248894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabStaticSymbol          = 0x26u,  // N_STSYM
249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabLocalCommon           = 0x28u,  // N_LCSYM
25019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      StabBeginSymbol           = 0x2Eu,  // N_BNSYM
251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabSourceFileOptions     = 0x3Cu,  // N_OPT
252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabRegisterSymbol        = 0x40u,  // N_RSYM
253894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabSourceLine            = 0x44u,  // N_SLINE
25419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      StabEndSymbol             = 0x4Eu,  // N_ENSYM
255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabStructureType         = 0x60u,  // N_SSYM
256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabSourceFileName        = 0x64u,  // N_SO
257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabObjectFileName        = 0x66u,  // N_OSO
258894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabLocalSymbol           = 0x80u,  // N_LSYM
259894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabBeginIncludeFileName  = 0x82u,  // N_BINCL
260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabIncludeFileName       = 0x84u,  // N_SOL
26119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      StabCompilerParameters    = 0x86u,  // N_PARAMS
26219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      StabCompilerVersion       = 0x88u,  // N_VERSION
26319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      StabCompilerOptLevel      = 0x8Au,  // N_OLEVEL
264894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabParameter             = 0xA0u,  // N_PSYM
265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabEndIncludeFile        = 0xA2u,  // N_EINCL
266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabAlternateEntry        = 0xA4u,  // N_ENTRY
267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabLeftBracket           = 0xC0u,  // N_LBRAC
268894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabDeletedIncludeFile    = 0xC2u,  // N_EXCL
269894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabRightBracket          = 0xE0u,  // N_RBRAC
270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabBeginCommon           = 0xE2u,  // N_BCOMM
271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabEndCommon             = 0xE4u,  // N_ECOMM
272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabEndCommonLocal        = 0xE8u,  // N_ECOML
273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      StabLength                = 0xFEu   // N_LENG
274894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
27619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    // Structs from <mach-o/loader.h>
27819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
279894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct mach_header {
280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t magic;
281894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cputype;
282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cpusubtype;
283894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t filetype;
284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t ncmds;
285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t sizeofcmds;
286894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t flags;
287894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
288894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
289894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct mach_header_64 {
290894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t magic;
291894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cputype;
292894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cpusubtype;
293894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t filetype;
294894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t ncmds;
295894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t sizeofcmds;
296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t flags;
297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved;
298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
300894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct load_command {
301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
302894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
303894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
304894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
305894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct segment_command {
306894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
307894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
308894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      char segname[16];
309894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t vmaddr;
310894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t vmsize;
311894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t fileoff;
312894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t filesize;
313894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t maxprot;
314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t initprot;
315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nsects;
316894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t flags;
317894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
318894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
319894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct segment_command_64 {
320894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      char segname[16];
323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t vmaddr;
324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t vmsize;
325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t fileoff;
326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t filesize;
327894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t maxprot;
328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t initprot;
329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nsects;
330894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t flags;
331894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
332894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
333894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct section {
334894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      char sectname[16];
335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      char segname[16];
336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t addr;
337894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t size;
338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t offset;
339894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t align;
340894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reloff;
341894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nreloc;
342894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t flags;
343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved1;
344894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved2;
345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
346894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct section_64 {
348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      char sectname[16];
349894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      char segname[16];
350894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t addr;
351894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t size;
352894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t offset;
353894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t align;
354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reloff;
355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nreloc;
356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t flags;
357894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved1;
358894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved2;
359894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved3;
360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct fvmlib {
363894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t name;
364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t minor_version;
365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t header_addr;
366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
367894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
368894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct fvmlib_command {
369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t  cmd;
370894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
371894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      struct fvmlib fvmlib;
372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
374894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct dylib {
375894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t name;
376894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t timestamp;
377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t current_version;
378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t compatibility_version;
379894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
381894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct dylib_command {
382894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
383894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
384894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      struct dylib dylib;
385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
386894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct sub_framework_command {
388894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
389894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t umbrella;
391894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
393894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct sub_client_command {
394894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
395894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
396894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t client;
397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
398894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
399894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct sub_umbrella_command {
400894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
401894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
402894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t sub_umbrella;
403894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
404894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
405894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct sub_library_command {
406894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t sub_library;
409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
411894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct prebound_dylib_command {
412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
413894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
414894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t name;
415894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nmodules;
416894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t linked_modules;
417894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
418894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct dylinker_command {
420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
421894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
422894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t name;
423894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct thread_command {
426894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
427894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
428894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
429894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
430894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct routines_command {
431894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
432894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
433894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t init_address;
434894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t init_module;
435894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved1;
436894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved2;
437894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved3;
438894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved4;
439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved5;
440894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t reserved6;
441894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
442894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
443894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct routines_command_64 {
444894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
445894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
446894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t init_address;
447894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t init_module;
448894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t reserved1;
449894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t reserved2;
450894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t reserved3;
451894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t reserved4;
452894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t reserved5;
453894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t reserved6;
454894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
455894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
456894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct symtab_command {
457894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
458894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
459894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t symoff;
460894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nsyms;
461894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t stroff;
462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t strsize;
463894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
464894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
465894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct dysymtab_command {
466894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
467894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
468894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t ilocalsym;
469894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nlocalsym;
470894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t iextdefsym;
471894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nextdefsym;
472894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t iundefsym;
473894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nundefsym;
474894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t tocoff;
475894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t ntoc;
476894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t modtaboff;
477894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nmodtab;
478894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t extrefsymoff;
479894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nextrefsyms;
480894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t indirectsymoff;
481894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nindirectsyms;
482894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t extreloff;
483894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nextrel;
484894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t locreloff;
485894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nlocrel;
486894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
487894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
488894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct dylib_table_of_contents {
489894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t symbol_index;
490894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t module_index;
491894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
492894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
493894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct dylib_module {
494894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t module_name;
495894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t iextdefsym;
496894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nextdefsym;
497894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t irefsym;
498894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nrefsym;
499894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t ilocalsym;
500894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nlocalsym;
501894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t iextrel;
502894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nextrel;
503894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t iinit_iterm;
504894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t ninit_nterm;
505894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t objc_module_info_addr;
506894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t objc_module_info_size;
507894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
508894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
509894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct dylib_module_64 {
510894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t module_name;
511894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t iextdefsym;
512894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nextdefsym;
513894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t irefsym;
514894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nrefsym;
515894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t ilocalsym;
516894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nlocalsym;
517894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t iextrel;
518894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nextrel;
519894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t iinit_iterm;
520894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t ninit_nterm;
521894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t objc_module_info_size;
522894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t objc_module_info_addr;
523894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
524894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
525894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct dylib_reference {
526894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t isym:24,
527894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman               flags:8;
528894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
529894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
530894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
531894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct twolevel_hints_command {
532894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
533894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
534894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t offset;
535894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nhints;
536894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
537894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
538894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct twolevel_hint {
539894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t isub_image:8,
540894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman               itoc:24;
541894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
542894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
543894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct prebind_cksum_command {
544894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
545894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
546894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cksum;
547894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
548894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
549894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct uuid_command {
550894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
551894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
552894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint8_t uuid[16];
553894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
554894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
555894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct rpath_command {
556894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
557894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
558894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t path;
559894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
560894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
561894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct linkedit_data_command {
562894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
563894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
564894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t dataoff;
565894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t datasize;
566894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
567894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
568894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct encryption_info_command {
569894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
570894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
571894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cryptoff;
572894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cryptsize;
573894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cryptid;
574894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
575894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
57619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    struct version_min_command {
57719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      uint32_t cmd;
57819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      uint32_t cmdsize;
57919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      uint32_t version;
58019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      uint32_t reserved;
58119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    };
58219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
583894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct dyld_info_command {
584894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
585894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
586894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t rebase_off;
587894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t rebase_size;
588894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t bind_off;
589894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t bind_size;
590894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t weak_bind_off;
591894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t weak_bind_size;
592894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t lazy_bind_off;
593894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t lazy_bind_size;
594894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t export_off;
595894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t export_size;
596894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
597894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
598894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct symseg_command {
599894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
600894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
601894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t offset;
602894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t size;
603894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
604894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
605894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct ident_command {
606894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
607894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
608894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
609894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
610894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct fvmfile_command {
611894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmd;
612894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cmdsize;
613894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t name;
614894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t header_addr;
615894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
616894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
617894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
618894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    // Structs from <mach-o/fat.h>
619894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct fat_header {
620894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t magic;
621894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t nfat_arch;
622894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
623894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
624894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct fat_arch {
625894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cputype;
626894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t cpusubtype;
627894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t offset;
628894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t size;
629894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t align;
630894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
631894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
632894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    // Structs from <mach-o/fat.h>
633894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct nlist {
634894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t n_strx;
635894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint8_t n_type;
636894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint8_t n_sect;
637894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      int16_t n_desc;
638894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t n_value;
639894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
640894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
641894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    struct nlist_64 {
642894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint32_t n_strx;
643894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint8_t n_type;
644894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint8_t n_sect;
645894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint16_t n_desc;
646894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      uint64_t n_value;
647894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
648894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
649894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    // Get/Set functions from <mach-o/nlist.h>
65019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
651894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    static inline uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc)
652894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    {
653894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      return (((n_desc) >> 8u) & 0xffu);
654894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    }
65519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
656894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    static inline void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal)
657894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    {
658894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      n_desc = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8));
659894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    }
660894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
661894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    static inline uint8_t GET_COMM_ALIGN (uint16_t n_desc)
662894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    {
663894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      return (n_desc >> 8u) & 0x0fu;
664894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    }
66519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
666894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    static inline void SET_COMM_ALIGN (uint16_t &n_desc, uint8_t align)
667894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    {
668894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      n_desc = ((n_desc & 0xf0ffu) | ((align & 0x0fu) << 8u));
669894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    }
670894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
671894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    // Enums from <mach/machine.h>
672894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    enum {
673894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Capability bits used in the definition of cpu_type.
674894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUArchMask = 0xff000000,   // Mask for architecture bits
675894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUArchABI64 = 0x01000000,  // 64 bit ABI
67619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
677894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constants for the cputype field.
678894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUTypeI386      = 7,
679894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUTypeX86_64    = CPUTypeI386 | CPUArchABI64,
680894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUTypeARM       = 12,
681894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUTypeSPARC     = 14,
682894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUTypePowerPC   = 18,
683894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUTypePowerPC64 = CPUTypePowerPC | CPUArchABI64,
684894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
685894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
686894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // Constants for the cpusubtype field.
68719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
688894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // X86
689894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUSubType_I386_ALL    = 3,
690894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUSubType_X86_64_ALL  = 3,
69119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
692894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // ARM
693894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUSubType_ARM_ALL     = 0,
694894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUSubType_ARM_V4T     = 5,
69519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      CPUSubType_ARM_V5      = 7,
696894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUSubType_ARM_V6      = 6,
69719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman      CPUSubType_ARM_V7      = 9,
698894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
699894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      // PowerPC
700894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUSubType_POWERPC_ALL = 0,
70119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
702894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      CPUSubType_SPARC_ALL   = 0
703894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    };
704894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  } // end namespace MachO
705894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} // end namespace llvm
706894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
707894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
708