MC/Mach-O: Introduce Object/MachOFormat for describing purely platform / machine
[oota-llvm.git] / include / llvm / Object / MachOFormat.h
1 //===- MachOFormat.h - Mach-O Format Structures And Constants ---*- 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 declares various structures and constants which are platform
11 // independent and can be shared by any client which wishes to interact with
12 // Mach object files.
13 //
14 // The definitions here are purposely chosen to match the LLVM style as opposed
15 // to following the platform specific definition of the format.
16 //
17 // On a Mach system, see the <mach-o/...> includes for more information, in
18 // particular <mach-o/loader.h>.
19 //
20 //===----------------------------------------------------------------------===//
21
22 #ifndef LLVM_OBJECT_MACHOFORMAT_H
23 #define LLVM_OBJECT_MACHOFORMAT_H
24
25 namespace llvm {
26 namespace object {
27
28 /// General Mach platform information.
29 namespace mach {
30   /// @name CPU Type and Subtype Information
31   /// {
32
33   /// \brief Capability bits used in CPU type encoding.
34   enum CPUTypeFlagsMask {
35     CTFM_ArchMask =  0xFF000000,
36     CTFM_ArchABI64 = 0x01000000
37   };
38
39   /// \brief Machine type IDs used in CPU type encoding.
40   enum CPUTypeMachine {
41     CTM_i386      = 7,
42     CTM_x86_64    = CTM_i386 | CTFM_ArchABI64,
43     CTM_ARM       = 12,
44     CTM_SPARC     = 14,
45     CTM_PowerPC   = 18,
46     CTM_PowerPC64 = CTM_PowerPC | CTFM_ArchABI64
47   };
48
49   /// \brief Capability bits used in CPU subtype encoding.
50   enum CPUSubtypeFlagsMask {
51     CSFM_SubtypeMask =  0xFF000000,
52     CSFM_SubtypeLib64 = 0x80000000
53   };
54
55   /// \brief ARM Machine Subtypes.
56   enum CPUSubtypeARM {
57     CSARM_ALL    = 0,
58     CSARM_V4T    = 5,
59     CSARM_V6     = 6,
60     CSARM_V5TEJ  = 7,
61     CSARM_XSCALE = 8,
62     CSARM_V7     = 9
63   };
64
65   /// \brief PowerPC Machine Subtypes.
66   enum CPUSubtypePowerPC {
67     CSPPC_ALL = 0
68   };
69
70   /// \brief SPARC Machine Subtypes.
71   enum CPUSubtypeSPARC {
72     CSSPARC_ALL = 0
73   };
74
75   /// \brief x86 Machine Subtypes.
76   enum CPUSubtypeX86 {
77     CSX86_ALL = 3
78   };
79
80   /// @}
81
82 } // end namespace mach
83
84 /// Format information for Mach object files.
85 namespace macho {
86   /// \brief Constants for header magic field.
87   enum HeaderMagic {
88     HM_Object32 = 0xFEEDFACE,  ///< 32-bit mach object file
89     HM_Object64 = 0xFEEDFACF,  ///< 64-bit mach object file
90     HM_Universal = 0xCAFEBABE  ///< Universal object file
91   };
92
93   /// \brief Constants for structure sizes.
94   enum StructureSizes {
95     Header32Size = 28,
96     Header64Size = 32,
97     SegmentLoadCommand32Size = 56,
98     SegmentLoadCommand64Size = 72,
99     Section32Size = 68,
100     Section64Size = 80,
101     SymtabLoadCommandSize = 24,
102     DysymtabLoadCommandSize = 80,
103     Nlist32Size = 12,
104     Nlist64Size = 16,
105     RelocationInfoSize = 8
106   };
107 } // end namespace macho
108
109 } // end namespace object
110 } // end namespace llvm
111
112 #endif