LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Support/MachO.h
Go to the documentation of this file.
1 //===-- llvm/Support/MachO.h - The MachO file format ------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines manifest constants for the MachO object file format.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_SUPPORT_MACHO_H
15 #define LLVM_SUPPORT_MACHO_H
16 
17 #include "llvm/Support/Compiler.h"
18 #include "llvm/Support/DataTypes.h"
19 #include "llvm/Support/Host.h"
20 
21 namespace llvm {
22  namespace MachO {
23  // Enums from <mach-o/loader.h>
24  enum LLVM_ENUM_INT_TYPE(uint32_t) {
25  // Constants for the "magic" field in llvm::MachO::mach_header and
26  // llvm::MachO::mach_header_64
27  MH_MAGIC = 0xFEEDFACEu,
28  MH_CIGAM = 0xCEFAEDFEu,
29  MH_MAGIC_64 = 0xFEEDFACFu,
30  MH_CIGAM_64 = 0xCFFAEDFEu,
31  FAT_MAGIC = 0xCAFEBABEu,
32  FAT_CIGAM = 0xBEBAFECAu
33  };
34 
36  // Constants for the "filetype" field in llvm::MachO::mach_header and
37  // llvm::MachO::mach_header_64
38  MH_OBJECT = 0x1u,
39  MH_EXECUTE = 0x2u,
40  MH_FVMLIB = 0x3u,
41  MH_CORE = 0x4u,
42  MH_PRELOAD = 0x5u,
43  MH_DYLIB = 0x6u,
44  MH_DYLINKER = 0x7u,
45  MH_BUNDLE = 0x8u,
46  MH_DYLIB_STUB = 0x9u,
47  MH_DSYM = 0xAu,
49  };
50 
51  enum {
52  // Constant bits for the "flags" field in llvm::MachO::mach_header and
53  // llvm::MachO::mach_header_64
54  MH_NOUNDEFS = 0x00000001u,
55  MH_INCRLINK = 0x00000002u,
56  MH_DYLDLINK = 0x00000004u,
57  MH_BINDATLOAD = 0x00000008u,
58  MH_PREBOUND = 0x00000010u,
59  MH_SPLIT_SEGS = 0x00000020u,
60  MH_LAZY_INIT = 0x00000040u,
61  MH_TWOLEVEL = 0x00000080u,
62  MH_FORCE_FLAT = 0x00000100u,
63  MH_NOMULTIDEFS = 0x00000200u,
64  MH_NOFIXPREBINDING = 0x00000400u,
65  MH_PREBINDABLE = 0x00000800u,
66  MH_ALLMODSBOUND = 0x00001000u,
68  MH_CANONICAL = 0x00004000u,
69  MH_WEAK_DEFINES = 0x00008000u,
70  MH_BINDS_TO_WEAK = 0x00010000u,
71  MH_ALLOW_STACK_EXECUTION = 0x00020000u,
72  MH_ROOT_SAFE = 0x00040000u,
73  MH_SETUID_SAFE = 0x00080000u,
74  MH_NO_REEXPORTED_DYLIBS = 0x00100000u,
75  MH_PIE = 0x00200000u,
77  };
78 
79  enum LLVM_ENUM_INT_TYPE(uint32_t) {
80  // Flags for the "cmd" field in llvm::MachO::load_command
81  LC_REQ_DYLD = 0x80000000u
82  };
83 
84  enum LoadCommandType LLVM_ENUM_INT_TYPE(uint32_t) {
85  // Constants for the "cmd" field in llvm::MachO::load_command
86  LC_SEGMENT = 0x00000001u,
87  LC_SYMTAB = 0x00000002u,
88  LC_SYMSEG = 0x00000003u,
89  LC_THREAD = 0x00000004u,
90  LC_UNIXTHREAD = 0x00000005u,
91  LC_LOADFVMLIB = 0x00000006u,
92  LC_IDFVMLIB = 0x00000007u,
93  LC_IDENT = 0x00000008u,
94  LC_FVMFILE = 0x00000009u,
95  LC_PREPAGE = 0x0000000Au,
96  LC_DYSYMTAB = 0x0000000Bu,
97  LC_LOAD_DYLIB = 0x0000000Cu,
98  LC_ID_DYLIB = 0x0000000Du,
99  LC_LOAD_DYLINKER = 0x0000000Eu,
100  LC_ID_DYLINKER = 0x0000000Fu,
101  LC_PREBOUND_DYLIB = 0x00000010u,
102  LC_ROUTINES = 0x00000011u,
103  LC_SUB_FRAMEWORK = 0x00000012u,
104  LC_SUB_UMBRELLA = 0x00000013u,
105  LC_SUB_CLIENT = 0x00000014u,
106  LC_SUB_LIBRARY = 0x00000015u,
107  LC_TWOLEVEL_HINTS = 0x00000016u,
108  LC_PREBIND_CKSUM = 0x00000017u,
109  LC_LOAD_WEAK_DYLIB = 0x80000018u,
110  LC_SEGMENT_64 = 0x00000019u,
111  LC_ROUTINES_64 = 0x0000001Au,
112  LC_UUID = 0x0000001Bu,
113  LC_RPATH = 0x8000001Cu,
114  LC_CODE_SIGNATURE = 0x0000001Du,
115  LC_SEGMENT_SPLIT_INFO = 0x0000001Eu,
116  LC_REEXPORT_DYLIB = 0x8000001Fu,
117  LC_LAZY_LOAD_DYLIB = 0x00000020u,
118  LC_ENCRYPTION_INFO = 0x00000021u,
119  LC_DYLD_INFO = 0x00000022u,
120  LC_DYLD_INFO_ONLY = 0x80000022u,
121  LC_LOAD_UPWARD_DYLIB = 0x80000023u,
122  LC_VERSION_MIN_MACOSX = 0x00000024u,
123  LC_VERSION_MIN_IPHONEOS = 0x00000025u,
124  LC_FUNCTION_STARTS = 0x00000026u,
125  LC_DYLD_ENVIRONMENT = 0x00000027u,
126  LC_MAIN = 0x80000028u,
127  LC_DATA_IN_CODE = 0x00000029u,
128  LC_SOURCE_VERSION = 0x0000002Au,
129  LC_DYLIB_CODE_SIGN_DRS = 0x0000002Bu,
130  // 0x0000002Cu,
131  LC_LINKER_OPTIONS = 0x0000002Du
132  };
133 
134  enum LLVM_ENUM_INT_TYPE(uint32_t) {
135  // Constant bits for the "flags" field in llvm::MachO::segment_command
136  SG_HIGHVM = 0x1u,
137  SG_FVMLIB = 0x2u,
138  SG_NORELOC = 0x4u,
139  SG_PROTECTED_VERSION_1 = 0x8u,
140 
141 
142  // Constant masks for the "flags" field in llvm::MachO::section and
143  // llvm::MachO::section_64
144  SECTION_TYPE = 0x000000ffu, // SECTION_TYPE
145  SECTION_ATTRIBUTES = 0xffffff00u, // SECTION_ATTRIBUTES
146  SECTION_ATTRIBUTES_USR = 0xff000000u, // SECTION_ATTRIBUTES_USR
147  SECTION_ATTRIBUTES_SYS = 0x00ffff00u // SECTION_ATTRIBUTES_SYS
148  };
149 
150  enum SectionType {
151  // Constant masks for the "flags[7:0]" field in llvm::MachO::section and
152  // llvm::MachO::section_64 (mask "flags" with SECTION_TYPE)
153  S_REGULAR = 0x00u,
154  S_ZEROFILL = 0x01u,
161  S_SYMBOL_STUBS = 0x08u,
164  S_COALESCED = 0x0bu,
165  S_GB_ZEROFILL = 0x0cu,
166  S_INTERPOSING = 0x0du,
168  S_DTRACE_DOF = 0x0fu,
175  };
176 
177  enum LLVM_ENUM_INT_TYPE(uint32_t) {
178  // Constant masks for the "flags[31:24]" field in llvm::MachO::section and
179  // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR)
180  S_ATTR_PURE_INSTRUCTIONS = 0x80000000u,
181  S_ATTR_NO_TOC = 0x40000000u,
182  S_ATTR_STRIP_STATIC_SYMS = 0x20000000u,
183  S_ATTR_NO_DEAD_STRIP = 0x10000000u,
184  S_ATTR_LIVE_SUPPORT = 0x08000000u,
185  S_ATTR_SELF_MODIFYING_CODE = 0x04000000u,
186  S_ATTR_DEBUG = 0x02000000u,
187 
188  // Constant masks for the "flags[23:8]" field in llvm::MachO::section and
189  // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS)
190  S_ATTR_SOME_INSTRUCTIONS = 0x00000400u,
191  S_ATTR_EXT_RELOC = 0x00000200u,
192  S_ATTR_LOC_RELOC = 0x00000100u,
193 
194  // Constant masks for the value of an indirect symbol in an indirect
195  // symbol table
196  INDIRECT_SYMBOL_LOCAL = 0x80000000u,
197  INDIRECT_SYMBOL_ABS = 0x40000000u
198  };
199 
201  // Constants for the "kind" field in a data_in_code_entry structure
207  };
208 
209  enum RebaseType {
213  };
214 
215  enum {
218  };
219 
230  };
231 
232  enum BindType {
236  };
237 
242  };
243 
244  enum {
247 
250  };
251 
252  enum BindOpcode {
266  };
267 
268  enum {
273  };
274 
278  };
279 
280 
281  enum {
282  // Constant masks for the "n_type" field in llvm::MachO::nlist and
283  // llvm::MachO::nlist_64
284  N_STAB = 0xe0,
285  N_PEXT = 0x10,
286  N_TYPE = 0x0e,
287  N_EXT = 0x01
288  };
289 
290  enum NListType {
291  // Constants for the "n_type & N_TYPE" llvm::MachO::nlist and
292  // llvm::MachO::nlist_64
293  N_UNDF = 0x0u,
294  N_ABS = 0x2u,
295  N_SECT = 0xeu,
296  N_PBUD = 0xcu,
297  N_INDR = 0xau
298  };
299 
301  // Constants for the "n_sect" field in llvm::MachO::nlist and
302  // llvm::MachO::nlist_64
303  NO_SECT = 0u,
304  MAX_SECT = 0xffu
305  };
306 
307  enum {
308  // Constant masks for the "n_desc" field in llvm::MachO::nlist and
309  // llvm::MachO::nlist_64
310  N_ARM_THUMB_DEF = 0x0008u,
311  N_NO_DEAD_STRIP = 0x0020u,
312  N_WEAK_REF = 0x0040u,
313  N_WEAK_DEF = 0x0080u,
315  };
316 
317  enum StabType {
318  // Constant values for the "n_type" field in llvm::MachO::nlist and
319  // llvm::MachO::nlist_64 when "(n_type & NlistMaskStab) != 0"
320  N_GSYM = 0x20u,
321  N_FNAME = 0x22u,
322  N_FUN = 0x24u,
323  N_STSYM = 0x26u,
324  N_LCSYM = 0x28u,
325  N_BNSYM = 0x2Eu,
326  N_OPT = 0x3Cu,
327  N_RSYM = 0x40u,
328  N_SLINE = 0x44u,
329  N_ENSYM = 0x4Eu,
330  N_SSYM = 0x60u,
331  N_SO = 0x64u,
332  N_OSO = 0x66u,
333  N_LSYM = 0x80u,
334  N_BINCL = 0x82u,
335  N_SOL = 0x84u,
336  N_PARAMS = 0x86u,
337  N_VERSION = 0x88u,
338  N_OLEVEL = 0x8Au,
339  N_PSYM = 0xA0u,
340  N_EINCL = 0xA2u,
341  N_ENTRY = 0xA4u,
342  N_LBRAC = 0xC0u,
343  N_EXCL = 0xC2u,
344  N_RBRAC = 0xE0u,
345  N_BCOMM = 0xE2u,
346  N_ECOMM = 0xE4u,
347  N_ECOML = 0xE8u,
348  N_LENG = 0xFEu
349  };
350 
351  enum LLVM_ENUM_INT_TYPE(uint32_t) {
352  // Constant values for the r_symbolnum field in an
353  // llvm::MachO::relocation_info structure when r_extern is 0.
354  R_ABS = 0,
355 
356  // Constant bits for the r_address field in an
357  // llvm::MachO::relocation_info structure.
358  R_SCATTERED = 0x80000000
359  };
360 
362  // Constant values for the r_type field in an
363  // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
364  // structure.
371 
372  // Constant values for the r_type field in a PowerPC architecture
373  // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
374  // structure.
391 
392  // Constant values for the r_type field in an ARM architecture
393  // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
394  // structure.
402  ARM_THUMB_32BIT_BRANCH = 7, // obsolete
405 
406  // Constant values for the r_type field in an x86_64 architecture
407  // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
408  // structure
419  };
420 
421  // Values for segment_command.initprot.
422  // From <mach/vm_prot.h>
423  enum {
427  };
428 
429 
430  // Structs from <mach-o/loader.h>
431 
432  struct mach_header {
433  uint32_t magic;
434  uint32_t cputype;
435  uint32_t cpusubtype;
436  uint32_t filetype;
437  uint32_t ncmds;
438  uint32_t sizeofcmds;
439  uint32_t flags;
440  };
441 
442  struct mach_header_64 {
443  uint32_t magic;
444  uint32_t cputype;
445  uint32_t cpusubtype;
446  uint32_t filetype;
447  uint32_t ncmds;
448  uint32_t sizeofcmds;
449  uint32_t flags;
450  uint32_t reserved;
451  };
452 
453  struct load_command {
454  uint32_t cmd;
455  uint32_t cmdsize;
456  };
457 
459  uint32_t cmd;
460  uint32_t cmdsize;
461  char segname[16];
462  uint32_t vmaddr;
463  uint32_t vmsize;
464  uint32_t fileoff;
465  uint32_t filesize;
466  uint32_t maxprot;
467  uint32_t initprot;
468  uint32_t nsects;
469  uint32_t flags;
470  };
471 
473  uint32_t cmd;
474  uint32_t cmdsize;
475  char segname[16];
476  uint64_t vmaddr;
477  uint64_t vmsize;
478  uint64_t fileoff;
479  uint64_t filesize;
480  uint32_t maxprot;
481  uint32_t initprot;
482  uint32_t nsects;
483  uint32_t flags;
484  };
485 
486  struct section {
487  char sectname[16];
488  char segname[16];
489  uint32_t addr;
490  uint32_t size;
491  uint32_t offset;
492  uint32_t align;
493  uint32_t reloff;
494  uint32_t nreloc;
495  uint32_t flags;
496  uint32_t reserved1;
497  uint32_t reserved2;
498  };
499 
500  struct section_64 {
501  char sectname[16];
502  char segname[16];
503  uint64_t addr;
504  uint64_t size;
505  uint32_t offset;
506  uint32_t align;
507  uint32_t reloff;
508  uint32_t nreloc;
509  uint32_t flags;
510  uint32_t reserved1;
511  uint32_t reserved2;
512  uint32_t reserved3;
513  };
514 
515  struct fvmlib {
516  uint32_t name;
517  uint32_t minor_version;
518  uint32_t header_addr;
519  };
520 
521  struct fvmlib_command {
522  uint32_t cmd;
523  uint32_t cmdsize;
524  struct fvmlib fvmlib;
525  };
526 
527  struct dylib {
528  uint32_t name;
529  uint32_t timestamp;
530  uint32_t current_version;
532  };
533 
534  struct dylib_command {
535  uint32_t cmd;
536  uint32_t cmdsize;
537  struct dylib dylib;
538  };
539 
541  uint32_t cmd;
542  uint32_t cmdsize;
543  uint32_t umbrella;
544  };
545 
547  uint32_t cmd;
548  uint32_t cmdsize;
549  uint32_t client;
550  };
551 
553  uint32_t cmd;
554  uint32_t cmdsize;
555  uint32_t sub_umbrella;
556  };
557 
559  uint32_t cmd;
560  uint32_t cmdsize;
561  uint32_t sub_library;
562  };
563 
565  uint32_t cmd;
566  uint32_t cmdsize;
567  uint32_t name;
568  uint32_t nmodules;
569  uint32_t linked_modules;
570  };
571 
573  uint32_t cmd;
574  uint32_t cmdsize;
575  uint32_t name;
576  };
577 
578  struct thread_command {
579  uint32_t cmd;
580  uint32_t cmdsize;
581  };
582 
584  uint32_t cmd;
585  uint32_t cmdsize;
586  uint32_t init_address;
587  uint32_t init_module;
588  uint32_t reserved1;
589  uint32_t reserved2;
590  uint32_t reserved3;
591  uint32_t reserved4;
592  uint32_t reserved5;
593  uint32_t reserved6;
594  };
595 
597  uint32_t cmd;
598  uint32_t cmdsize;
599  uint64_t init_address;
600  uint64_t init_module;
601  uint64_t reserved1;
602  uint64_t reserved2;
603  uint64_t reserved3;
604  uint64_t reserved4;
605  uint64_t reserved5;
606  uint64_t reserved6;
607  };
608 
609  struct symtab_command {
610  uint32_t cmd;
611  uint32_t cmdsize;
612  uint32_t symoff;
613  uint32_t nsyms;
614  uint32_t stroff;
615  uint32_t strsize;
616  };
617 
619  uint32_t cmd;
620  uint32_t cmdsize;
621  uint32_t ilocalsym;
622  uint32_t nlocalsym;
623  uint32_t iextdefsym;
624  uint32_t nextdefsym;
625  uint32_t iundefsym;
626  uint32_t nundefsym;
627  uint32_t tocoff;
628  uint32_t ntoc;
629  uint32_t modtaboff;
630  uint32_t nmodtab;
631  uint32_t extrefsymoff;
632  uint32_t nextrefsyms;
633  uint32_t indirectsymoff;
634  uint32_t nindirectsyms;
635  uint32_t extreloff;
636  uint32_t nextrel;
637  uint32_t locreloff;
638  uint32_t nlocrel;
639  };
640 
642  uint32_t symbol_index;
643  uint32_t module_index;
644  };
645 
646  struct dylib_module {
647  uint32_t module_name;
648  uint32_t iextdefsym;
649  uint32_t nextdefsym;
650  uint32_t irefsym;
651  uint32_t nrefsym;
652  uint32_t ilocalsym;
653  uint32_t nlocalsym;
654  uint32_t iextrel;
655  uint32_t nextrel;
656  uint32_t iinit_iterm;
657  uint32_t ninit_nterm;
660  };
661 
663  uint32_t module_name;
664  uint32_t iextdefsym;
665  uint32_t nextdefsym;
666  uint32_t irefsym;
667  uint32_t nrefsym;
668  uint32_t ilocalsym;
669  uint32_t nlocalsym;
670  uint32_t iextrel;
671  uint32_t nextrel;
672  uint32_t iinit_iterm;
673  uint32_t ninit_nterm;
676  };
677 
679  uint32_t isym:24,
680  flags:8;
681  };
682 
683 
685  uint32_t cmd;
686  uint32_t cmdsize;
687  uint32_t offset;
688  uint32_t nhints;
689  };
690 
691  struct twolevel_hint {
692  uint32_t isub_image:8,
693  itoc:24;
694  };
695 
697  uint32_t cmd;
698  uint32_t cmdsize;
699  uint32_t cksum;
700  };
701 
702  struct uuid_command {
703  uint32_t cmd;
704  uint32_t cmdsize;
705  uint8_t uuid[16];
706  };
707 
708  struct rpath_command {
709  uint32_t cmd;
710  uint32_t cmdsize;
711  uint32_t path;
712  };
713 
715  uint32_t cmd;
716  uint32_t cmdsize;
717  uint32_t dataoff;
718  uint32_t datasize;
719  };
720 
722  uint32_t offset;
723  uint16_t length;
724  uint16_t kind;
725  };
726 
728  uint32_t cmd;
729  uint32_t cmdsize;
730  uint64_t version;
731  };
732 
734  uint32_t cmd;
735  uint32_t cmdsize;
736  uint32_t cryptoff;
737  uint32_t cryptsize;
738  uint32_t cryptid;
739  };
740 
742  uint32_t cmd;
743  uint32_t cmdsize;
744  uint32_t version;
745  uint32_t reserved;
746  };
747 
749  uint32_t cmd;
750  uint32_t cmdsize;
751  uint32_t rebase_off;
752  uint32_t rebase_size;
753  uint32_t bind_off;
754  uint32_t bind_size;
755  uint32_t weak_bind_off;
756  uint32_t weak_bind_size;
757  uint32_t lazy_bind_off;
758  uint32_t lazy_bind_size;
759  uint32_t export_off;
760  uint32_t export_size;
761  };
762 
764  uint32_t cmd;
765  uint32_t cmdsize;
766  uint32_t count;
767  };
768 
769  struct symseg_command {
770  uint32_t cmd;
771  uint32_t cmdsize;
772  uint32_t offset;
773  uint32_t size;
774  };
775 
776  struct ident_command {
777  uint32_t cmd;
778  uint32_t cmdsize;
779  };
780 
782  uint32_t cmd;
783  uint32_t cmdsize;
784  uint32_t name;
785  uint32_t header_addr;
786  };
787 
789  uint32_t thunk;
790  uint32_t key;
791  uint32_t offset;
792  };
793 
795  uint64_t thunk;
796  uint64_t key;
797  uint64_t offset;
798  };
799 
800  struct tlv_descriptor {
801  uintptr_t thunk;
802  uintptr_t key;
803  uintptr_t offset;
804  };
805 
807  uint32_t cmd;
808  uint32_t cmdsize;
809  uint64_t entryoff;
810  uint64_t stacksize;
811  };
812 
813 
814  // Structs from <mach-o/fat.h>
815  struct fat_header {
816  uint32_t magic;
817  uint32_t nfat_arch;
818  };
819 
820  struct fat_arch {
821  uint32_t cputype;
822  uint32_t cpusubtype;
823  uint32_t offset;
824  uint32_t size;
825  uint32_t align;
826  };
827 
828  // Structs from <mach-o/reloc.h>
830  int32_t r_address;
831  uint32_t r_symbolnum:24,
832  r_pcrel:1,
833  r_length:2,
834  r_extern:1,
835  r_type:4;
836  };
837 
839 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)
840  uint32_t r_scattered:1,
841  r_pcrel:1,
842  r_length:2,
843  r_type:4,
844  r_address:24;
845 #else
846  uint32_t r_address:24,
847  r_type:4,
848  r_length:2,
849  r_pcrel:1,
850  r_scattered:1;
851 #endif
852  int32_t r_value;
853  };
854 
855  // Structs NOT from <mach-o/reloc.h>, but that make LLVM's life easier
857  uint32_t r_word0, r_word1;
858  };
859 
860  // Structs from <mach-o/nlist.h>
861  struct nlist {
862  uint32_t n_strx;
863  uint8_t n_type;
864  uint8_t n_sect;
865  int16_t n_desc;
866  uint32_t n_value;
867  };
868 
869  struct nlist_64 {
870  uint32_t n_strx;
871  uint8_t n_type;
872  uint8_t n_sect;
873  uint16_t n_desc;
874  uint64_t n_value;
875  };
876 
877  // Get/Set functions from <mach-o/nlist.h>
878 
879  static inline uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc) {
880  return (((n_desc) >> 8u) & 0xffu);
881  }
882 
883  static inline void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal) {
884  n_desc = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8));
885  }
886 
887  static inline uint8_t GET_COMM_ALIGN (uint16_t n_desc) {
888  return (n_desc >> 8u) & 0x0fu;
889  }
890 
891  static inline void SET_COMM_ALIGN (uint16_t &n_desc, uint8_t align) {
892  n_desc = ((n_desc & 0xf0ffu) | ((align & 0x0fu) << 8u));
893  }
894 
895  // Enums from <mach/machine.h>
896  enum LLVM_ENUM_INT_TYPE(uint32_t) {
897  // Capability bits used in the definition of cpu_type.
898  CPU_ARCH_MASK = 0xff000000, // Mask for architecture bits
899  CPU_ARCH_ABI64 = 0x01000000 // 64 bit ABI
900  };
901 
902  // Constants for the cputype field.
903  enum CPUType {
907  CPU_TYPE_X86_64 = CPU_TYPE_X86 | CPU_ARCH_ABI64,
908  /* CPU_TYPE_MIPS = 8, */
909  CPU_TYPE_MC98000 = 10, // Old Motorola PowerPC
914  };
915 
916  enum LLVM_ENUM_INT_TYPE(uint32_t) {
917  // Capability bits used in the definition of cpusubtype.
918  CPU_SUB_TYPE_MASK = 0xff000000, // Mask for architecture bits
919  CPU_SUB_TYPE_LIB64 = 0x80000000, // 64 bit libraries
920 
921  // Special CPU subtype constants.
922  CPU_SUBTYPE_MULTIPLE = ~0u
923  };
924 
925  // Constants for the cpusubtype field.
948 
953  };
954  static inline int CPU_SUBTYPE_INTEL(int Family, int Model) {
955  return Family | (Model << 4);
956  }
958  return ((int)ST) & 0x0f;
959  }
961  return ((int)ST) >> 4;
962  }
963  enum {
966  };
967 
982  };
983 
986  };
987 
1002 
1005  };
1006  } // end namespace MachO
1007 } // end namespace llvm
1008 
1009 #endif
enum LLVM_ENUM_INT_TYPE(uint32_t)
Definition: Support/MachO.h:24
uint16_t length
static void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal)
static uint8_t GET_COMM_ALIGN(uint16_t n_desc)
uint32_t offset
static uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc)
uint16_t kind
static int CPU_SUBTYPE_INTEL(int Family, int Model)
static void SET_COMM_ALIGN(uint16_t &n_desc, uint8_t align)
static int CPU_SUBTYPE_INTEL_MODEL(CPUSubTypeX86 ST)
static int CPU_SUBTYPE_INTEL_FAMILY(CPUSubTypeX86 ST)
uint32_t current_version
uint32_t compatibility_version