1 | /* $Id $ */
|
---|
2 | /** @file
|
---|
3 | * Mach-0 structures, types and defines.
|
---|
4 | */
|
---|
5 |
|
---|
6 | #ifndef __kLdrModMachO_h__
|
---|
7 | #define __kLdrModMachO_h__
|
---|
8 |
|
---|
9 |
|
---|
10 | #ifndef IMAGE_FAT_SIGNATURE
|
---|
11 | /** The FAT signature (universal binaries). */
|
---|
12 | # define IMAGE_FAT_SIGNATURE UINT32_C(0xcafebabe)
|
---|
13 | #endif
|
---|
14 | #ifndef IMAGE_FAT_SIGNATURE_OE
|
---|
15 | /** The FAT signature (universal binaries), other endian. */
|
---|
16 | # define IMAGE_FAT_SIGNATURE_OE UINT32_C(0xbebafeca)
|
---|
17 | #endif
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * The fat header found at the start of universal binaries.
|
---|
21 | * It is followed by \a nfat_arch numbers of \a fat_arch structures.
|
---|
22 | */
|
---|
23 | typedef struct fat_header
|
---|
24 | {
|
---|
25 | uint32_t magic;
|
---|
26 | uint32_t nfat_arch;
|
---|
27 | } fat_header_t;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Description of fat file item.
|
---|
31 | */
|
---|
32 | struct fat_arch
|
---|
33 | {
|
---|
34 | int32_t cputype;
|
---|
35 | int32_t cpusubtype;
|
---|
36 | uint32_t offset;
|
---|
37 | uint32_t size;
|
---|
38 | uint32_t align; /**< Power of 2. */
|
---|
39 | } fat_arch_t;
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | #ifndef IMAGE_MACHO32_SIGNATURE
|
---|
44 | /** The 32-bit Mach-O signature. */
|
---|
45 | # define IMAGE_MACHO32_SIGNATURE UINT32_C(0xfeedface)
|
---|
46 | #endif
|
---|
47 | #ifndef IMAGE_MACHO32_SIGNATURE_OE
|
---|
48 | /** The 32-bit Mach-O signature, other endian. */
|
---|
49 | # define IMAGE_MACHO32_SIGNATURE_OE UINT32_C(0xcefaedfe)
|
---|
50 | #endif
|
---|
51 | #define MH_MAGIC IMAGE_MACHO32_SIGNATURE
|
---|
52 | #define MH_CIGAM IMAGE_MACHO32_SIGNATURE_OE
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * 32-bit Mach-O header.
|
---|
56 | * This is followed by \a ncmds number of load commands.
|
---|
57 | * @see mach_header_64
|
---|
58 | */
|
---|
59 | typedef struct mach_header_32
|
---|
60 | {
|
---|
61 | uint32_t magic;
|
---|
62 | int32_t cputype;
|
---|
63 | int32_t cpusubtype;
|
---|
64 | uint32_t filetype;
|
---|
65 | uint32_t ncmds;
|
---|
66 | uint32_t sizeofcmds;
|
---|
67 | uint32_t flags;
|
---|
68 | } mach_header_32_t;
|
---|
69 |
|
---|
70 |
|
---|
71 |
|
---|
72 | #ifndef IMAGE_MACHO64_SIGNATURE
|
---|
73 | /** The 64-bit Mach-O signature. */
|
---|
74 | # define IMAGE_MACHO64_SIGNATURE UINT32_C(0xfeedfacf)
|
---|
75 | #endif
|
---|
76 | #ifndef IMAGE_MACHO64_SIGNATURE_OE
|
---|
77 | /** The 64-bit Mach-O signature, other endian. */
|
---|
78 | # define IMAGE_MACHO64_SIGNATURE_OE UINT32_C(0xfefaedfe)
|
---|
79 | #endif
|
---|
80 | #define MH_MAGIC_64 IMAGE_MACHO64_SIGNATURE
|
---|
81 | #define MH_CIGAM_64 IMAGE_MACHO64_SIGNATURE_OE
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * 64-bit Mach-O header.
|
---|
85 | * This is followed by \a ncmds number of load commands.
|
---|
86 | * @see mach_header
|
---|
87 | */
|
---|
88 | typedef struct mach_header_64
|
---|
89 | {
|
---|
90 | uint32_t magic;
|
---|
91 | int32_t cputype;
|
---|
92 | int32_t cpusubtype;
|
---|
93 | uint32_t filetype;
|
---|
94 | uint32_t ncmds;
|
---|
95 | uint32_t sizeofcmds;
|
---|
96 | uint32_t flags;
|
---|
97 | uint32_t reserved; /**< (for proper struct and command alignment I guess) */
|
---|
98 | } mach_header_64_t;
|
---|
99 |
|
---|
100 |
|
---|
101 | /** @name File types (mach_header_64::filetype, mach_header_32::filetype)
|
---|
102 | * @{
|
---|
103 | */
|
---|
104 | #define MH_OBJECT UINT32_C(1) /**< Object (relocatable). */
|
---|
105 | #define MH_EXECUTE UINT32_C(2) /**< Executable (demand paged). */
|
---|
106 | #define MH_FVMLIB UINT32_C(3) /**< Fixed VM shared library. */
|
---|
107 | #define MH_CORE UINT32_C(4) /**< Core file. */
|
---|
108 | #define MH_PRELOAD UINT32_C(5) /**< Preloaded executable. */
|
---|
109 | #define MH_DYLIB UINT32_C(6) /**< Dynamically bound shared library. */
|
---|
110 | #define MH_DYLINKER UINT32_C(7) /**< Dynamic linker. */
|
---|
111 | #define MH_BUNDLE UINT32_C(8) /**< Dymamically bound bundle. */
|
---|
112 | #define MH_DYLIB_STUB UINT32_C(9) /**< Shared library stub for static linking. */
|
---|
113 | #define MH_DSYM UINT32_C(10)/**< Debug symbols. */
|
---|
114 |
|
---|
115 | /** @} */
|
---|
116 |
|
---|
117 |
|
---|
118 | /** @name Mach-O Header flags (mach_header_64::flags, mach_header_32::flags)
|
---|
119 | * @{
|
---|
120 | */
|
---|
121 | #define MH_NOUNDEFS UINT32_C(0x00000001) /**< No undefined symbols. */
|
---|
122 | #define MH_INCRLINK UINT32_C(0x00000002) /**< Partial increment link output. */
|
---|
123 | #define MH_DYLDLINK UINT32_C(0x00000004) /**< Food for the dynamic linker, not for ld. */
|
---|
124 | #define MH_BINDATLOAD UINT32_C(0x00000008) /**< Bind all undefined symbols at load time. */
|
---|
125 | #define MH_PREBOUND UINT32_C(0x00000010) /**< Contains prebound undefined symbols. */
|
---|
126 | #define MH_SPLIT_SEGS UINT32_C(0x00000020) /**< Read-only and read-write segments are split. */
|
---|
127 | #define MH_LAZY_INIT UINT32_C(0x00000040) /**< Obsolete flag for doing lazy init when data is written. */
|
---|
128 | #define MH_TWOLEVEL UINT32_C(0x00000080) /**< Uses two-level name space bindings. */
|
---|
129 | #define MH_FORCE_FLAT UINT32_C(0x00000100) /**< Task: The executable forces all images to use flat name space bindings. */
|
---|
130 | #define MH_NOMULTIDEFS UINT32_C(0x00000200) /**< No multiple symbol definitions, safe to use two-level namespace hints. */
|
---|
131 | #define MH_NOFIXPREBINDING UINT32_C(0x00000400) /**< The dynamic linker should not notify the prebinding agent about this executable. */
|
---|
132 | #define MH_PREBINDABLE UINT32_C(0x00000800) /**< Not prebound, but it can be. Invalid if MH_PREBOUND is set. */
|
---|
133 | #define MH_ALLMODSBOUND UINT32_C(0x00001000) /**< Binds to all two-level namespace modules of preqs. Requires MH_PREBINDABLE and MH_TWOLEVEL to be set. */
|
---|
134 | #define MH_SUBSECTIONS_VIA_SYMBOLS UINT32_C(0x00002000) /**< Safe to divide sections into sub-sections via symbols for dead code stripping. */
|
---|
135 | #define MH_CANONICAL UINT32_C(0x00004000) /**< Canonicalized via unprebind. */
|
---|
136 | #define MH_WEAK_DEFINES UINT32_C(0x00008000) /**< The (finally) linked image has weak symbols. */
|
---|
137 | #define MH_BINDS_TO_WEAK UINT32_C(0x00010000) /**< The (finally) linked image uses weak symbols. */
|
---|
138 | #define MH_ALLOW_STACK_EXECUTION UINT32_C(0x00020000) /**< Task: allow stack execution. (MH_EXECUTE only) */
|
---|
139 | #define MH_VALID_FLAGS UINT32_C(0x0003ffff) /**< Mask containing the defined flags. */
|
---|
140 | /** @} */
|
---|
141 |
|
---|
142 |
|
---|
143 | /** @name CPU types / bits (mach_header_64::cputype, mach_header_32::cputype, fat_arch::cputype)
|
---|
144 | * @{
|
---|
145 | */
|
---|
146 | #define CPU_ARCH_MASK INT32_C(0xff000000)
|
---|
147 | #define CPU_ARCH_ABI64 INT32_C(0x01000000)
|
---|
148 | #define CPU_TYPE_ANY INT32_C(-1)
|
---|
149 | #define CPU_TYPE_VAX INT32_C(1)
|
---|
150 | #define CPU_TYPE_MC680x0 INT32_C(6)
|
---|
151 | #define CPU_TYPE_X86 INT32_C(7)
|
---|
152 | #define CPU_TYPE_I386 CPU_TYPE_X86
|
---|
153 | #define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64)
|
---|
154 | #define CPU_TYPE_MC98000 INT32_C(10)
|
---|
155 | #define CPU_TYPE_HPPA INT32_C(11)
|
---|
156 | #define CPU_TYPE_MC88000 INT32_C(13)
|
---|
157 | #define CPU_TYPE_SPARC INT32_C(14)
|
---|
158 | #define CPU_TYPE_I860 INT32_C(15)
|
---|
159 | #define CPU_TYPE_POWERPC INT32_C(18)
|
---|
160 | #define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
|
---|
161 | /** @} */
|
---|
162 |
|
---|
163 |
|
---|
164 | /** @name CPU subtypes (mach_header_64::cpusubtype, mach_header_32::cpusubtype, fat_arch::cpusubtype)
|
---|
165 | * @{ */
|
---|
166 | #define CPU_SUBTYPE_MULTIPLE INT32_C(-1)
|
---|
167 | #define CPU_SUBTYPE_LITTLE_ENDIAN INT32_C(0) /**< figure this one out. */
|
---|
168 | #define CPU_SUBTYPE_BIG_ENDIAN INT32_C(1) /**< ditto */
|
---|
169 |
|
---|
170 | /* VAX */
|
---|
171 | #define CPU_SUBTYPE_VAX_ALL INT32_C(0)
|
---|
172 | #define CPU_SUBTYPE_VAX780 INT32_C(1)
|
---|
173 | #define CPU_SUBTYPE_VAX785 INT32_C(2)
|
---|
174 | #define CPU_SUBTYPE_VAX750 INT32_C(3)
|
---|
175 | #define CPU_SUBTYPE_VAX730 INT32_C(4)
|
---|
176 | #define CPU_SUBTYPE_UVAXI INT32_C(5)
|
---|
177 | #define CPU_SUBTYPE_UVAXII INT32_C(6)
|
---|
178 | #define CPU_SUBTYPE_VAX8200 INT32_C(7)
|
---|
179 | #define CPU_SUBTYPE_VAX8500 INT32_C(8)
|
---|
180 | #define CPU_SUBTYPE_VAX8600 INT32_C(9)
|
---|
181 | #define CPU_SUBTYPE_VAX8650 INT32_C(10)
|
---|
182 | #define CPU_SUBTYPE_VAX8800 INT32_C(11)
|
---|
183 | #define CPU_SUBTYPE_UVAXIII INT32_C(12)
|
---|
184 |
|
---|
185 | /* MC680xx */
|
---|
186 | #define CPU_SUBTYPE_MC680x0_ALL INT32_C(1)
|
---|
187 | #define CPU_SUBTYPE_MC68030 INT32_C(1)
|
---|
188 | #define CPU_SUBTYPE_MC68040 INT32_C(2)
|
---|
189 | #define CPU_SUBTYPE_MC68030_ONLY INT32_C(3)
|
---|
190 |
|
---|
191 | /* I386 */
|
---|
192 | #define CPU_SUBTYPE_INTEL(fam, model) ( (int32_t)(((model) << 4) | (fam)) )
|
---|
193 | #define CPU_SUBTYPE_INTEL_FAMILY(subtype) ( (subtype) & 0xf )
|
---|
194 | #define CPU_SUBTYPE_INTEL_MODEL(subtype) ( (subtype) >> 4 )
|
---|
195 | #define CPU_SUBTYPE_INTEL_FAMILY_MAX 0xf
|
---|
196 | #define CPU_SUBTYPE_INTEL_MODEL_ALL 0
|
---|
197 |
|
---|
198 | #define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0)
|
---|
199 | #define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0)
|
---|
200 | #define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0)
|
---|
201 | #define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8)
|
---|
202 | #define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0)
|
---|
203 | #define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0)
|
---|
204 | #define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1)
|
---|
205 | #define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3)
|
---|
206 | #define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5)
|
---|
207 | #define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6)
|
---|
208 | #define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7)
|
---|
209 | #define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0)
|
---|
210 | #define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1)
|
---|
211 | #define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2)
|
---|
212 | #define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0)
|
---|
213 | #define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0)
|
---|
214 | #define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1)
|
---|
215 | #define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0)
|
---|
216 | #define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1)
|
---|
217 | #define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0)
|
---|
218 | #define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1)
|
---|
219 |
|
---|
220 | /* X86 */
|
---|
221 | #define CPU_SUBTYPE_X86_ALL INT32_C(3) /* CPU_SUBTYPE_I386_ALL */
|
---|
222 | #define CPU_SUBTYPE_X86_64_ALL INT32_C(3) /* CPU_SUBTYPE_I386_ALL */
|
---|
223 | #define CPU_SUBTYPE_X86_ARCH1 INT32_C(4) /* CPU_SUBTYPE_I486_ALL */
|
---|
224 |
|
---|
225 | /* MIPS */
|
---|
226 | #define CPU_SUBTYPE_MIPS_ALL INT32_C(0)
|
---|
227 | #define CPU_SUBTYPE_MIPS_R2300 INT32_C(1)
|
---|
228 | #define CPU_SUBTYPE_MIPS_R2600 INT32_C(2)
|
---|
229 | #define CPU_SUBTYPE_MIPS_R2800 INT32_C(3)
|
---|
230 | #define CPU_SUBTYPE_MIPS_R2000a INT32_C(4)
|
---|
231 | #define CPU_SUBTYPE_MIPS_R2000 INT32_C(5)
|
---|
232 | #define CPU_SUBTYPE_MIPS_R3000a INT32_C(6)
|
---|
233 | #define CPU_SUBTYPE_MIPS_R3000 INT32_C(7)
|
---|
234 |
|
---|
235 | /* MC98000 (PowerPC) */
|
---|
236 | #define CPU_SUBTYPE_MC98000_ALL INT32_C(0)
|
---|
237 | #define CPU_SUBTYPE_MC98601 INT32_C(1)
|
---|
238 |
|
---|
239 | /* HP-PA */
|
---|
240 | #define CPU_SUBTYPE_HPPA_ALL INT32_C(0)
|
---|
241 | #define CPU_SUBTYPE_HPPA_7100 INT32_C(0)
|
---|
242 | #define CPU_SUBTYPE_HPPA_7100LC INT32_C(1)
|
---|
243 |
|
---|
244 | /* MC88000 */
|
---|
245 | #define CPU_SUBTYPE_MC88000_ALL INT32_C(0)
|
---|
246 | #define CPU_SUBTYPE_MC88100 INT32_C(1)
|
---|
247 | #define CPU_SUBTYPE_MC88110 INT32_C(2)
|
---|
248 |
|
---|
249 | /* SPARC */
|
---|
250 | #define CPU_SUBTYPE_SPARC_ALL INT32_C(0)
|
---|
251 |
|
---|
252 | /* I860 */
|
---|
253 | #define CPU_SUBTYPE_I860_ALL INT32_C(0)
|
---|
254 | #define CPU_SUBTYPE_I860_860 INT32_C(1)
|
---|
255 |
|
---|
256 | /* PowerPC */
|
---|
257 | #define CPU_SUBTYPE_POWERPC_ALL INT32_C(0)
|
---|
258 | #define CPU_SUBTYPE_POWERPC_601 INT32_C(1)
|
---|
259 | #define CPU_SUBTYPE_POWERPC_602 INT32_C(2)
|
---|
260 | #define CPU_SUBTYPE_POWERPC_603 INT32_C(3)
|
---|
261 | #define CPU_SUBTYPE_POWERPC_603e INT32_C(4)
|
---|
262 | #define CPU_SUBTYPE_POWERPC_603ev INT32_C(5)
|
---|
263 | #define CPU_SUBTYPE_POWERPC_604 INT32_C(6)
|
---|
264 | #define CPU_SUBTYPE_POWERPC_604e INT32_C(7)
|
---|
265 | #define CPU_SUBTYPE_POWERPC_620 INT32_C(8)
|
---|
266 | #define CPU_SUBTYPE_POWERPC_750 INT32_C(9)
|
---|
267 | #define CPU_SUBTYPE_POWERPC_7400 INT32_C(10)
|
---|
268 | #define CPU_SUBTYPE_POWERPC_7450 INT32_C(11)
|
---|
269 | #define CPU_SUBTYPE_POWERPC_Max INT32_C(10)
|
---|
270 | #define CPU_SUBTYPE_POWERPC_SCVger INT32_C(11)
|
---|
271 | #define CPU_SUBTYPE_POWERPC_970 INT32_C(100)
|
---|
272 |
|
---|
273 | /** @} */
|
---|
274 |
|
---|
275 |
|
---|
276 | /**
|
---|
277 | * The load command common core structure.
|
---|
278 | *
|
---|
279 | * After the Mach-O header follows an array of variable sized
|
---|
280 | * load command which all has this header in common.
|
---|
281 | */
|
---|
282 | typedef struct load_command
|
---|
283 | {
|
---|
284 | uint32_t cmd; /**< The load command id. */
|
---|
285 | uint32_t cmdsize; /**< The size of the command (including this header). */
|
---|
286 | } load_command_t;
|
---|
287 |
|
---|
288 | /** @name Load Command IDs (load_command::cmd)
|
---|
289 | * @{
|
---|
290 | */
|
---|
291 | /** Flag that when set requires the dynamic linker to fail if it doesn't
|
---|
292 | * grok the command. The dynamic linker will otherwise ignore commands it
|
---|
293 | * doesn't understand. Introduced with Mac OS X 10.1. */
|
---|
294 | #define LC_REQ_DYLD UINT32_C(0x80000000)
|
---|
295 |
|
---|
296 | #define LC_SEGMENT_32 UINT32_C(0x01) /**< Segment to be mapped (32-bit). See segment_command_32. */
|
---|
297 | #define LC_SYMTAB UINT32_C(0x02) /**< 'stab' symbol table. See symtab_command. */
|
---|
298 | #define LC_SYMSEG UINT32_C(0x03) /**< Obsoleted gdb symbol table. */
|
---|
299 | #define LC_THREAD UINT32_C(0x04) /**< Thread. See thread_command. */
|
---|
300 | #define LC_UNIXTHREAD UINT32_C(0x05) /**< Unix thread (includes stack and stuff). See thread_command. */
|
---|
301 | #define LC_LOADFVMLIB UINT32_C(0x06) /**< Load a specified fixed VM shared library (obsolete?). See fvmlib_command. */
|
---|
302 | #define LC_IDFVMLIB UINT32_C(0x07) /**< Fixed VM shared library id (obsolete?). See fvmlib_command. */
|
---|
303 | #define LC_IDENT UINT32_C(0x08) /**< Identification info (obsolete). See ident_command. */
|
---|
304 | #define LC_FVMFILE UINT32_C(0x09) /**< Fixed VM file inclusion (internal). See fvmfile_command. */
|
---|
305 | #define LC_PREPAGE UINT32_C(0x0a) /**< Prepage command (internal). See ?? */
|
---|
306 | #define LC_DYSYMTAB UINT32_C(0x0b) /**< Symbol table for dynamic linking. See dysymtab_command. */
|
---|
307 | #define LC_LOAD_DYLIB UINT32_C(0x0c) /**< Load a dynamically linked shared library. See dylib_command. */
|
---|
308 | #define LC_ID_DYLIB UINT32_C(0x0d) /**< Dynamically linked share library ident. See dylib_command. */
|
---|
309 | #define LC_LOAD_DYLINKER UINT32_C(0x0e) /**< Load a dynamical link editor. See dylinker_command. */
|
---|
310 | #define LC_ID_DYLINKER UINT32_C(0x0f) /**< Dynamic link editor ident. See dylinker_command. */
|
---|
311 | #define LC_PREBOUND_DYLIB UINT32_C(0x10) /**< Prebound modules for dynamically linking of a shared lib. See prebound_dylib_command. */
|
---|
312 | #define LC_ROUTINES UINT32_C(0x11) /**< Image routines. See routines_command_32. */
|
---|
313 | #define LC_SUB_FRAMEWORK UINT32_C(0x12) /**< Sub framework. See sub_framework_command. */
|
---|
314 | #define LC_SUB_UMBRELLA UINT32_C(0x13) /**< Sub umbrella. See sub_umbrella_command. */
|
---|
315 | #define LC_SUB_CLIENT UINT32_C(0x14) /**< Sub client. See sub_client_command. */
|
---|
316 | #define LC_SUB_LIBRARY UINT32_C(0x15) /**< Sub library. See sub_library_command. */
|
---|
317 | #define LC_TWOLEVEL_HINTS UINT32_C(0x16) /**< Two-level namespace lookup hints. See twolevel_hints_command. */
|
---|
318 | #define LC_PREBIND_CKSUM UINT32_C(0x17) /**< Prebind checksum. See prebind_cksum_command. */
|
---|
319 | #define LC_LOAD_WEAK_DYLIB (UINT32_C(0x18) | LC_REQ_DYLD) /**< Dylib that can be missing, all symbols weak. See dylib_command. */
|
---|
320 | #define LC_SEGMENT_64 UINT32_C(0x19) /**< segment to be mapped (64-bit). See segment_command_32. */
|
---|
321 | #define LC_ROUTINES_64 UINT32_C(0x1a) /**< Image routines (64-bit). See routines_command_32. */
|
---|
322 | #define LC_UUID UINT32_C(0x1b) /**< The UUID of the object module. See uuid_command. */
|
---|
323 | /** @} */
|
---|
324 |
|
---|
325 |
|
---|
326 | /**
|
---|
327 | * Load Command String.
|
---|
328 | */
|
---|
329 | typedef struct lc_str
|
---|
330 | {
|
---|
331 | /** Offset of the string relative to the load_command structure.
|
---|
332 | * The string is zero-terminated. the size of the load command
|
---|
333 | * is zero padded up to a multiple of 4 bytes. */
|
---|
334 | uint32_t offset;
|
---|
335 | } lc_str_t;
|
---|
336 |
|
---|
337 |
|
---|
338 | /**
|
---|
339 | * Segment load command (32-bit).
|
---|
340 | */
|
---|
341 | typedef struct segment_command_32
|
---|
342 | {
|
---|
343 | uint32_t cmd; /**< LC_SEGMENT */
|
---|
344 | uint32_t cmdsize; /**< sizeof(self) + sections. */
|
---|
345 | char segname[16]; /**< The segment name. */
|
---|
346 | uint32_t vmaddr; /**< Memory address of this segment. */
|
---|
347 | uint32_t vmsize; /**< Size of this segment. */
|
---|
348 | uint32_t fileoff; /**< The file location of the segment. */
|
---|
349 | uint32_t filesize; /**< The file size of the segment. */
|
---|
350 | uint32_t maxprot; /**< Maximum VM protection. */
|
---|
351 | uint32_t initprot; /**< Initial VM protection. */
|
---|
352 | uint32_t nsects; /**< Number of section desciptors following this structure. */
|
---|
353 | uint32_t flags; /**< Flags (SG_*). */
|
---|
354 | } segment_command_32_t;
|
---|
355 |
|
---|
356 |
|
---|
357 | /**
|
---|
358 | * Segment load command (64-bit).
|
---|
359 | * Same as segment_command_32 except 4 members has been blown up to 64-bit.
|
---|
360 | */
|
---|
361 | typedef struct segment_command_64
|
---|
362 | {
|
---|
363 | uint32_t cmd; /**< LC_SEGMENT */
|
---|
364 | uint32_t cmdsize; /**< sizeof(self) + sections. */
|
---|
365 | char segname[16]; /**< The segment name. */
|
---|
366 | uint64_t vmaddr; /**< Memory address of this segment. */
|
---|
367 | uint64_t vmsize; /**< Size of this segment. */
|
---|
368 | uint64_t fileoff; /**< The file location of the segment. */
|
---|
369 | uint64_t filesize; /**< The file size of the segment. */
|
---|
370 | uint32_t maxprot; /**< Maximum VM protection. */
|
---|
371 | uint32_t initprot; /**< Initial VM protection. */
|
---|
372 | uint32_t nsects; /**< Number of section desciptors following this structure. */
|
---|
373 | uint32_t flags; /**< Flags (SG_*). */
|
---|
374 | } segment_command_64_t;
|
---|
375 |
|
---|
376 | /** @name Segment flags (segment_command_64::flags, segment_command_32::flags)
|
---|
377 | * @{ */
|
---|
378 | /** Map the file bits in the top end of the memory area for the segment
|
---|
379 | * instead of the low end. Intended for stacks in core dumps.
|
---|
380 | * The part of the segment memory not covered by file bits will be zeroed. */
|
---|
381 | #define SG_HIGHVM UINT32_C(0x00000001)
|
---|
382 | /** This segment is the virtual memory allocated by a fixed VM library.
|
---|
383 | * (Used for overlap checking in the linker.) */
|
---|
384 | #define SG_FVMLIB UINT32_C(0x00000002)
|
---|
385 | /** No relocations for or symbols that's relocated to in this segment.
|
---|
386 | * The segment can therefore safely be replaced. */
|
---|
387 | #define SG_NORELOC UINT32_C(0x00000004)
|
---|
388 | /** The segment is protected.
|
---|
389 | * The first page isn't protected if it starts at file offset 0
|
---|
390 | * (so that the mach header and this load command can be easily mapped). */
|
---|
391 | #define SG_PROTECTED_VERSION_1 UINT32_C(0x00000008)
|
---|
392 | /** @} */
|
---|
393 |
|
---|
394 |
|
---|
395 | /**
|
---|
396 | * 32-bit section (part of a segment load command).
|
---|
397 | */
|
---|
398 | typedef struct section_32
|
---|
399 | {
|
---|
400 | char sectname[16]; /**< The section name. */
|
---|
401 | char segname[16]; /**< The name of the segment this section goes into. */
|
---|
402 | uint32_t addr; /**< The memory address of this section. */
|
---|
403 | uint32_t size; /**< The size of this section. */
|
---|
404 | uint32_t offset; /**< The file offset of this section. */
|
---|
405 | uint32_t align; /**< The section alignment (**2). */
|
---|
406 | uint32_t reloff; /**< The file offset of the relocations. */
|
---|
407 | uint32_t nreloc; /**< The number of relocations. */
|
---|
408 | uint32_t flags; /**< The section flags; section type and attribs */
|
---|
409 | uint32_t reserved1; /**< Reserved / offset / index. */
|
---|
410 | uint32_t reserved2; /**< Reserved / count / sizeof. */
|
---|
411 | } section_32_t;
|
---|
412 |
|
---|
413 | /**
|
---|
414 | * 64-bit section (part of a segment load command).
|
---|
415 | */
|
---|
416 | typedef struct section_64
|
---|
417 | {
|
---|
418 | char sectname[16]; /**< The section name. */
|
---|
419 | char segname[16]; /**< The name of the segment this section goes into. */
|
---|
420 | uint64_t addr; /**< The memory address of this section. */
|
---|
421 | uint64_t size; /**< The size of this section. */
|
---|
422 | uint32_t offset; /**< The file offset of this section. */
|
---|
423 | uint32_t align; /**< The section alignment (**2). */
|
---|
424 | uint32_t reloff; /**< The file offset of the relocations. */
|
---|
425 | uint32_t nreloc; /**< The number of relocations. */
|
---|
426 | uint32_t flags; /**< The section flags; section type and attribs */
|
---|
427 | uint32_t reserved1; /**< Reserved / offset / index. */
|
---|
428 | uint32_t reserved2; /**< Reserved / count / sizeof. */
|
---|
429 | uint32_t reserved3; /**< (Just) Reserved. */
|
---|
430 | } section_64_t;
|
---|
431 |
|
---|
432 | /** @name Section flags (section_64::flags, section_32::flags)
|
---|
433 | * @{
|
---|
434 | */
|
---|
435 | /** Section type mask. */
|
---|
436 | #define SECTION_TYPE UINT32_C(0x000000ff)
|
---|
437 | /** Regular section. */
|
---|
438 | #define S_REGULAR 0x0
|
---|
439 | /** Zero filled section. */
|
---|
440 | #define S_ZEROFILL 0x1
|
---|
441 | /** C literals. */
|
---|
442 | #define S_CSTRING_LITERALS 0x2
|
---|
443 | /** 4 byte literals. */
|
---|
444 | #define S_4BYTE_LITERALS 0x3
|
---|
445 | /** 8 byte literals. */
|
---|
446 | #define S_8BYTE_LITERALS 0x4
|
---|
447 | /** Pointer to literals. */
|
---|
448 | #define S_LITERAL_POINTERS 0x5
|
---|
449 | /** Section containing non-lazy symbol pointers.
|
---|
450 | * Reserved1 == start index in the indirect symbol table. */
|
---|
451 | #define S_NON_LAZY_SYMBOL_POINTERS 0x6
|
---|
452 | /** Section containing lazy symbol pointers.
|
---|
453 | * Reserved1 == start index in the indirect symbol table. */
|
---|
454 | #define S_LAZY_SYMBOL_POINTERS 0x7
|
---|
455 | /** Section containing symbol stubs.
|
---|
456 | * Reserved2 == stub size. */
|
---|
457 | #define S_SYMBOL_STUBS 0x8
|
---|
458 | /** Section containing function pointers for module initialization. . */
|
---|
459 | #define S_MOD_INIT_FUNC_POINTERS 0x9
|
---|
460 | /** Section containing function pointers for module termination. . */
|
---|
461 | #define S_MOD_TERM_FUNC_POINTERS 0xa
|
---|
462 | /** Section containing symbols that are to be coalesced. */
|
---|
463 | #define S_COALESCED 0xb
|
---|
464 | /** Zero filled section that be larger than 4GB. */
|
---|
465 | #define S_GB_ZEROFILL 0xc
|
---|
466 | /** Section containing pairs of function pointers for interposing. */
|
---|
467 | #define S_INTERPOSING 0xd
|
---|
468 | /** 16 byte literals. */
|
---|
469 | #define S_16BYTE_LITERALS 0xe
|
---|
470 |
|
---|
471 | /** Section attribute mask. */
|
---|
472 | #define SECTION_ATTRIBUTES UINT32_C(0xffffff00)
|
---|
473 |
|
---|
474 | /** User settable attribute mask. */
|
---|
475 | #define SECTION_ATTRIBUTES_USR UINT32_C(0xff000000)
|
---|
476 | /** Pure instruction (code). */
|
---|
477 | #define S_ATTR_PURE_INSTRUCTIONS UINT32_C(0x80000000)
|
---|
478 | /** ranlib, ignore my symbols... */
|
---|
479 | #define S_ATTR_NO_TOC UINT32_C(0x40000000)
|
---|
480 | /** May strip static symbols when linking int a MH_DYLDLINK file. */
|
---|
481 | #define S_ATTR_STRIP_STATIC_SYMS UINT32_C(0x20000000)
|
---|
482 | /** No dead stripping. */
|
---|
483 | #define S_ATTR_NO_DEAD_STRIP UINT32_C(0x10000000)
|
---|
484 | /** Live support. */
|
---|
485 | #define S_ATTR_LIVE_SUPPORT UINT32_C(0x08000000)
|
---|
486 | /** Contains self modifying code (generally i386 code stub for dyld). */
|
---|
487 | #define S_ATTR_SELF_MODIFYING_CODE UINT32_C(0x04000000)
|
---|
488 | /** Debug info (DWARF usually). */
|
---|
489 | #define S_ATTR_DEBUG UINT32_C(0x02000000)
|
---|
490 |
|
---|
491 | /** System settable attribute mask. */
|
---|
492 | #define SECTION_ATTRIBUTES_SYS UINT32_C(0x00ffff00)
|
---|
493 | /** Contains some instructions (code). */
|
---|
494 | #define S_ATTR_SOME_INSTRUCTIONS UINT32_C(0x00000400)
|
---|
495 | /** Has external relocations. */
|
---|
496 | #define S_ATTR_EXT_RELOC UINT32_C(0x00000200)
|
---|
497 | /** Has internal (local) relocations. */
|
---|
498 | #define S_ATTR_LOC_RELOC UINT32_C(0x00000100)
|
---|
499 | /** @} */
|
---|
500 |
|
---|
501 | /** @name Known Segment and Section Names.
|
---|
502 | * Some of these implies special linker behaviour.
|
---|
503 | * @{
|
---|
504 | */
|
---|
505 | /** Page zero - not-present page for catching invalid access. (MH_EXECUTE typically) */
|
---|
506 | #define SEG_PAGEZERO "__PAGEZERO"
|
---|
507 | /** Traditional UNIX text segment.
|
---|
508 | * Defaults to R-X. */
|
---|
509 | #define SEG_TEXT "__TEXT"
|
---|
510 | /** The text part of SEG_TEXT. */
|
---|
511 | #define SECT_TEXT "__text"
|
---|
512 | /** The fvmlib initialization. */
|
---|
513 | #define SECT_FVMLIB_INIT0 "__fvmlib_init0"
|
---|
514 | /** The section following the fvmlib initialization. */
|
---|
515 | #define SECT_FVMLIB_INIT1 "__fvmlib_init1"
|
---|
516 | /** The traditional UNIX data segment. (DGROUP to DOS and OS/2 people.) */
|
---|
517 | #define SEG_DATA "__DATA"
|
---|
518 | /** The initialized data section. */
|
---|
519 | #define SECT_DATA "__data"
|
---|
520 | /** The uninitialized data section. */
|
---|
521 | #define SECT_BSS "__bss"
|
---|
522 | /** The common symbol section. */
|
---|
523 | #define SECT_COMMON "__common"
|
---|
524 | /** Objective-C runtime segment. */
|
---|
525 | #define SEG_OBJC "__OBJC"
|
---|
526 | /** Objective-C symbol table section. */
|
---|
527 | #define SECT_OBJC_SYMBOLS "__symbol_table"
|
---|
528 | /** Objective-C module information section. */
|
---|
529 | #define SECT_OBJC_MODULES "__module_info"
|
---|
530 | /** Objective-C string table section. */
|
---|
531 | #define SECT_OBJC_STRINGS "__selector_strs"
|
---|
532 | /** Objective-C string table section. */
|
---|
533 | #define SECT_OBJC_REFS "__selector_refs"
|
---|
534 | /** Icon segment. */
|
---|
535 | #define SEG_ICON "__ICON"
|
---|
536 | /** The icon headers. */
|
---|
537 | #define SECT_ICON_HEADER "__header"
|
---|
538 | /** The icons in the TIFF format. */
|
---|
539 | #define SECT_ICON_TIFF "__tiff"
|
---|
540 | /** ld -seglinkedit segment containing all the structs create and maintained
|
---|
541 | * by the linker. MH_EXECUTE and MH_FVMLIB only. */
|
---|
542 | #define SEG_LINKEDIT "__LINKEDIT"
|
---|
543 | /** The unix stack segment. */
|
---|
544 | #define SEG_UNIXSTACK "__UNIXSTACK"
|
---|
545 | /** The segment for the self modifying code for dynamic linking.
|
---|
546 | * Implies RWX permissions. */
|
---|
547 | #define SEG_IMPORT "__IMPORT"
|
---|
548 | /** @} */
|
---|
549 |
|
---|
550 |
|
---|
551 | /** @todo fvmlib */
|
---|
552 | /** @todo fvmlib_command (LC_IDFVMLIB or LC_LOADFVMLIB) */
|
---|
553 | /** @todo dylib */
|
---|
554 | /** @todo dylib_command (LC_ID_DYLIB, LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB) */
|
---|
555 | /** @todo sub_framework_command (LC_SUB_FRAMEWORK) */
|
---|
556 | /** @todo sub_client_command (LC_SUB_CLIENT) */
|
---|
557 | /** @todo sub_umbrella_command (LC_SUB_UMBRELLA) */
|
---|
558 | /** @todo sub_library_command (LC_SUB_LIBRARY) */
|
---|
559 | /** @todo prebound_dylib_command (LC_PREBOUND_DYLIB) */
|
---|
560 | /** @todo dylinker_command (LC_ID_DYLINKER or LC_LOAD_DYLINKER) */
|
---|
561 |
|
---|
562 |
|
---|
563 | /**
|
---|
564 | * Thread command.
|
---|
565 | *
|
---|
566 | * State description of a thread that is to be created. The description
|
---|
567 | * is made up of a number of state structures preceded by a 32-bit flavor
|
---|
568 | * and 32-bit count field stating the kind of stat structure and it's size
|
---|
569 | * in uint32_t items respecitvly.
|
---|
570 | *
|
---|
571 | * LC_UNIXTHREAD differs from LC_THREAD in that it implies stack creation
|
---|
572 | * and that it's started with the typical main(int, char **, char **) frame
|
---|
573 | * on the stack.
|
---|
574 | */
|
---|
575 | typedef struct thread_command
|
---|
576 | {
|
---|
577 | uint32_t cmd; /**< LC_UNIXTHREAD or LC_THREAD. */
|
---|
578 | uint32_t cmdsize; /**< The size of the command (including this header). */
|
---|
579 | } thread_command_t;
|
---|
580 |
|
---|
581 |
|
---|
582 | /** @todo routines_command (LC_ROUTINES) */
|
---|
583 | /** @todo routines_command_64 (LC_ROUTINES_64) */
|
---|
584 |
|
---|
585 |
|
---|
586 | /**
|
---|
587 | * Symbol table command.
|
---|
588 | * Contains a.out style symbol table with some tricks.
|
---|
589 | */
|
---|
590 | typedef struct symtab_command
|
---|
591 | {
|
---|
592 | uint32_t cmd; /**< LC_SYMTAB */
|
---|
593 | uint32_t cmdsize; /** sizeof(symtab_command_t) */
|
---|
594 | uint32_t symoff; /** The file offset of the symbol table. */
|
---|
595 | uint32_t nsyms; /** The number of symbols in the symbol table. */
|
---|
596 | uint32_t stroff; /** The file offset of the string table. */
|
---|
597 | uint32_t strsize; /** The size of the string table. */
|
---|
598 | } symtab_command_t;
|
---|
599 |
|
---|
600 |
|
---|
601 | /** @todo dysymtab_command (LC_DYSYMTAB) */
|
---|
602 | /** @todo dylib_table_of_contents */
|
---|
603 | /** @todo dylib_module_32 */
|
---|
604 | /** @todo dylib_module_64 */
|
---|
605 | /** @todo dylib_reference */
|
---|
606 | /** @todo twolevel_hints_command (LC_TWOLEVEL_HINTS) */
|
---|
607 | /** @todo twolevel_hint */
|
---|
608 | /** @todo prebind_cksum_command (LC_PREBIND_CKSUM) */
|
---|
609 |
|
---|
610 |
|
---|
611 | /**
|
---|
612 | * UUID generated by ld.
|
---|
613 | */
|
---|
614 | typedef struct uuid_command
|
---|
615 | {
|
---|
616 | uint32_t cmd; /**< LC_UUID */
|
---|
617 | uint32_t cmdsize; /**< sizeof(uuid_command_t) */
|
---|
618 | uint8_t uuid[16]; /** The UUID bytes. */
|
---|
619 | } uuid_command_t;
|
---|
620 |
|
---|
621 |
|
---|
622 | /** @todo symseg_command (LC_SYMSEG) */
|
---|
623 | /** @todo ident_command (LC_IDENT)
|
---|
624 | /** @todo fvmfile_command (LC_FVMFILE) */
|
---|
625 |
|
---|
626 |
|
---|
627 |
|
---|
628 |
|
---|
629 |
|
---|
630 |
|
---|
631 | /**
|
---|
632 | * The 32-bit Mach-O version of the nlist structure.
|
---|
633 | *
|
---|
634 | * This differs from the a.out nlist struct in that the unused n_other field
|
---|
635 | * was renamed to n_sect and used for keeping the relevant section number.
|
---|
636 | * @remark This structure is not name mach_nlist_32 in the Apple headers, but nlist.
|
---|
637 | */
|
---|
638 | typedef struct macho_nlist_32
|
---|
639 | {
|
---|
640 | union
|
---|
641 | {
|
---|
642 | int32_t n_strx; /**< Offset (index) into the string table. 0 means "". */
|
---|
643 | } n_un;
|
---|
644 | uint8_t n_type; /**< Symbol type. */
|
---|
645 | uint8_t n_sect; /**< Section number of NO_SECT. */
|
---|
646 | int16_t n_desc; /**< Type specific, debug info details mostly.*/
|
---|
647 | uint32_t n_value; /**< The symbol value or stab offset. */
|
---|
648 | } macho_nlist_32_t;
|
---|
649 |
|
---|
650 |
|
---|
651 | /**
|
---|
652 | * The 64-bit Mach-O version of the nlist structure.
|
---|
653 | * @see macho_nlist_32
|
---|
654 | */
|
---|
655 | typedef struct macho_nlist_64
|
---|
656 | {
|
---|
657 | union
|
---|
658 | {
|
---|
659 | int32_t n_strx; /**< Offset (index) into the string table. 0 means "". */
|
---|
660 | } n_un;
|
---|
661 | uint8_t n_type; /**< Symbol type. */
|
---|
662 | uint8_t n_sect; /**< Section number of NO_SECT. */
|
---|
663 | int16_t n_desc; /**< Type specific, debug info details mostly.*/
|
---|
664 | uint64_t n_value; /**< The symbol value or stab offset. */
|
---|
665 | } macho_nlist_64_t;
|
---|
666 |
|
---|
667 |
|
---|
668 | /** @name Symbol Type Constants (macho_nlist_32_t::n_type, macho_nlist_64_t::n_type)
|
---|
669 | *
|
---|
670 | * In the Mach-O world n_type is somewhat similar to a.out, meaning N_EXT, N_UNDF, N_ABS
|
---|
671 | * and the debug symbols are essentially the same, but the remaining stuff is different.
|
---|
672 | * The main reason for this is that the encoding of section has been moved to n_sect
|
---|
673 | * to permit up to 255 sections instead of the fixed 3 a.out sections (not counting
|
---|
674 | * the abs symbols and set vectors).
|
---|
675 | *
|
---|
676 | * To avoid confusion with a.out the Mach-O constants has been fitted with a MACHO_
|
---|
677 | * prefix here.
|
---|
678 | *
|
---|
679 | * Common symbols (aka communal symbols and comdefs) are represented by
|
---|
680 | * n_type = MACHO_N_EXT | MACHO_N_UNDF, n_sect = NO_SECT and n_value giving
|
---|
681 | * the size.
|
---|
682 | *
|
---|
683 | *
|
---|
684 | * Symbol table entries can be inserted directly in the assembly code using
|
---|
685 | * this notation:
|
---|
686 | * @code
|
---|
687 | * .stabs "n_name", n_type, n_sect, n_desc, n_value
|
---|
688 | * @endcode
|
---|
689 | *
|
---|
690 | * (1) The line number is optional, GCC doesn't set it.
|
---|
691 | * (2) The type is optional, GCC doesn't set it.
|
---|
692 | * (3) The binutil header is "skeptical" about the line. I'm skeptical about the whole thing... :-)
|
---|
693 | * (M) Mach-O specific?
|
---|
694 | * (S) Sun specific?
|
---|
695 | * @{
|
---|
696 | */
|
---|
697 |
|
---|
698 | /* Base masks. */
|
---|
699 | #define MACHO_N_EXT UINT8_C(0x01) /**< External symbol (when set) (N_EXT). */
|
---|
700 | #define MACHO_N_TYPE UINT8_C(0x0e) /**< Symbol type (N_TYPE without the 8th bit). */
|
---|
701 | #define MACHO_N_PEXT UINT8_C(0x10) /**< Private extern symbol (when set). Mach-O specific. */
|
---|
702 | #define MACHO_N_STAB UINT8_C(0xe0) /**< Debug symbol mask (N_STAB). */
|
---|
703 |
|
---|
704 | /* MACHO_N_TYPE values. */
|
---|
705 | #define MACHO_N_UNDF UINT8_C(0x00) /**< MACHO_N_TYPE: Undefined symbol (N_UNDF). n_sect = NO_SECT. */
|
---|
706 | #define MACHO_N_ABS UINT8_C(0x02) /**< MACHO_N_TYPE: Absolute symbol (N_UNDF). n_sect = NO_SECT. */
|
---|
707 | #define MACHO_N_INDR UINT8_C(0x0a) /**< MACHO_N_TYPE: Indirect symbol, n_value is the index of the symbol. Mach-O specific. */
|
---|
708 | #define MACHO_N_PBUD UINT8_C(0x0c) /**< MACHO_N_TYPE: Prebound undefined symbo (defined in a dylib). Mach-O specific. */
|
---|
709 | #define MACHO_N_SECT UINT8_C(0x0e) /**< MACHO_N_TYPE: Defined in the section given by n_sects. Mach-O specific. */
|
---|
710 |
|
---|
711 | /* Debug symbols. */
|
---|
712 | #define MACHO_N_GSYM UINT8_C(0x20) /**< Global variable. "name",, NO_SECT, type, 0 (2) */
|
---|
713 | #define MACHO_N_FNAME UINT8_C(0x22) /**< Function name (F77). "name",, NO_SECT, 0, 0 */
|
---|
714 | #define MACHO_N_FUN UINT8_C(0x24) /**< Function / text var. "name",, section, line, address (1) */
|
---|
715 | #define MACHO_N_STSYM UINT8_C(0x26) /**< Static data symbol. "name",, section, type, address (2) */
|
---|
716 | #define MACHO_N_LCSYM UINT8_C(0x28) /**< static bss symbol. "name",, section, type, address (2) */
|
---|
717 | /* omits N_MAIN and N_ROSYM. */
|
---|
718 | #define MACHO_N_BNSYM UINT8_C(0x2e) /**< Begin nsect symbol. 0,, section, 0, address (M) */
|
---|
719 | #define MACHO_N_PC UINT8_C(0x30) /**< Global pascal symbol. "name",, NO_SECT, subtype?, line (3) */
|
---|
720 | /* omits N_NSYMS, N_NOMAP and N_OBJ. */
|
---|
721 | #define MACHO_N_OPT UINT8_C(0x3c) /**< Options for the debugger related to the language of the
|
---|
722 | source file. "options?",,,, */
|
---|
723 | #define MACHO_N_RSYM UINT8_C(0x40) /**< Register variable. "name",, NO_SECT, type, register */
|
---|
724 | /* omits N_M2C */
|
---|
725 | #define MACHO_N_SLINE UINT8_C(0x44) /**< Source line. 0,, section, line, address */
|
---|
726 | /* omits N_DSLINE, N_BSLINE / N_BROWS, N_DEFD and N_FLINE. */
|
---|
727 | #define MACHO_N_ENSYM UINT8_C(0x4e) /**< End nsect symbol. 0,, section, 0, address (M) */
|
---|
728 | /* omits N_EHDECL / N_MOD2 and N_CATCH. */
|
---|
729 | #define MACHO_N_SSYM UINT8_C(0x60) /**< Struct/union element. "name",, NO_SECT, type, offset */
|
---|
730 | /* omits N_ENDM */
|
---|
731 | #define MACHO_N_SO UINT8_C(0x64) /**< Source file name. "fname",, section, 0, address */
|
---|
732 | #define MACHO_N_OSO UINT8_C(0x66) /**< Object file name. "fname",, 0, 0, st_mtime (M?) */
|
---|
733 | /* omits N_ALIAS */
|
---|
734 | #define MACHO_N_LSYM UINT8_C(0x80) /**< Stack variable. "name",, NO_SECT, type, frame_offset */
|
---|
735 | #define MACHO_N_BINCL UINT8_C(0x82) /**< Begin #include. "fname",, NO_SECT, 0, sum? */
|
---|
736 | #define MACHO_N_SOL UINT8_C(0x84) /**< #included file. "fname",, section, 0, start_address (S) */
|
---|
737 | #define MACHO_N_PARAMS UINT8_C(0x86) /**< Compiler params. "params",, NO_SECT, 0, 0 */
|
---|
738 | #define MACHO_N_VERSION UINT8_C(0x88) /**< Compiler version. "version",, NO_SECT, 0, 0 */
|
---|
739 | #define MACHO_N_OLEVEL UINT8_C(0x8A) /**< Compiler -O level. "level",, NO_SECT, 0, 0 */
|
---|
740 | #define MACHO_N_PSYM UINT8_C(0xa0) /**< Parameter variable. "name",, NO_SECT, type, frame_offset */
|
---|
741 | #define MACHO_N_EINCL UINT8_C(0xa2) /**< End #include. "fname",, NO_SECT, 0, 0 (S) */
|
---|
742 | #define MACHO_N_ENTRY UINT8_C(0xa4) /**< Alternate entry point. "name",, section, line, address */
|
---|
743 | #define MACHO_N_LBRAC UINT8_C(0xc0) /**< Left bracket. 0,, NO_SECT, nesting_level, address */
|
---|
744 | #define MACHO_N_EXCL UINT8_C(0xc2) /**< Deleted include file. "fname",, NO_SECT, 0, sum? (S) */
|
---|
745 | /* omits N_SCOPE */
|
---|
746 | #define MACHO_N_RBRAC UINT8_C(0xe0) /**< Right bracket. 0,, NO_SECT, nesting_level, address */
|
---|
747 | #define MACHO_N_BCOMM UINT8_C(0xe2) /**< Begin common. "name",, NO_SECT?, 0, 0 */
|
---|
748 | #define MACHO_N_ECOMM UINT8_C(0xe4) /**< End common. "name",, section, 0, 0 */
|
---|
749 | #define MACHO_N_ECOML UINT8_C(0xe8) /**< End local common. 0,, section, 0, address */
|
---|
750 | #define MACHO_N_LENG UINT8_C(0xfe) /**< Length-value of the preceding entry.
|
---|
751 | "name",, NO_SECT, 0, length */
|
---|
752 |
|
---|
753 | /** @} */
|
---|
754 |
|
---|
755 | /** @name Symbol Description Bits (macho_nlist_32_t::n_desc, macho_nlist_64_t::n_desc)
|
---|
756 | *
|
---|
757 | * Mach-O puts the n_desc field to a number of uses, like lazy binding , library
|
---|
758 | * ordinal numbers for -twolevel_namespace, stripping and weak symbol handling.
|
---|
759 | *
|
---|
760 | * @remark The REFERENCE_FLAGS_* are really not flags in the normal sense (bit),
|
---|
761 | * they are more like enum values.
|
---|
762 | * @{
|
---|
763 | */
|
---|
764 |
|
---|
765 | #define REFERENCE_TYPE UINT16_C(0x000f) /**< The reference type mask. */
|
---|
766 | #define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0 /**< Normal undefined symbol. */
|
---|
767 | #define REFERENCE_FLAG_UNDEFINED_LAZY 1 /**< Lazy undefined symbol. */
|
---|
768 | #define REFERENCE_FLAG_DEFINED 2 /**< Defined symbol (dynamic linking). */
|
---|
769 | #define REFERENCE_FLAG_PRIVATE_DEFINED 3 /**< Defined private symbol (dynamic linking). */
|
---|
770 | #define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4 /**< Normal undefined private symbol. */
|
---|
771 | #define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5 /**< Lazy undefined private symbol. */
|
---|
772 |
|
---|
773 | #define REFERENCED_DYNAMICALLY UINT16_C(0x0010) /**< Don't strip. */
|
---|
774 |
|
---|
775 |
|
---|
776 | /** Get the dynamic library ordinal. */
|
---|
777 | #define GET_LIBRARY_ORDINAL(n_desc) \
|
---|
778 | (((n_desc) >> 8) & 0xff)
|
---|
779 | /** Set the dynamic library ordinal. */
|
---|
780 | #define SET_LIBRARY_ORDINAL(n_desc, ordinal) \
|
---|
781 | (n_desc) = (((n_desc) & 0xff) | (((ordinal) & 0xff) << 8))
|
---|
782 | #define SELF_LIBRARY_ORDINAL 0x00 /**< Special ordinal for refering to onself. */
|
---|
783 | #define MAX_LIBRARY_ORDINAL 0xfd /**< Maximum ordinal number. */
|
---|
784 | #define DYNAMIC_LOOKUP_ORDINAL 0xfe /**< Special ordinal number for dynamic lookup. (Mac OS X 10.3 and later) */
|
---|
785 | #define EXECUTABLE_ORDINAL 0xff /**< Special ordinal number for the executable. */
|
---|
786 |
|
---|
787 |
|
---|
788 | /** Only MH_OBJECT: Never dead strip me! */
|
---|
789 | #define N_NO_DEAD_STRIP UINT16_C(0x0020)
|
---|
790 | /** Not MH_OBJECT: Discarded symbol. */
|
---|
791 | #define N_DESC_DISCARDED UINT16_C(0x0020)
|
---|
792 | /** Weak external symbol. Symbol can be missing, in which case it's will have the value 0. */
|
---|
793 | #define N_WEAK_REF UINT16_C(0x0040)
|
---|
794 | /** Weak symbol definition. The symbol can be overridden by another weak
|
---|
795 | * symbol already present or by a non-weak (strong) symbol definition.
|
---|
796 | * Currently only supported for coalesed symbols.
|
---|
797 | * @remark This bit means something differently for undefined symbols, see N_REF_TO_WEAK.
|
---|
798 | */
|
---|
799 | #define N_WEAK_DEF UINT16_C(0x0080)
|
---|
800 | /** Reference to a weak symbol, resolve using flat namespace searching.
|
---|
801 | * @remark This bit means something differently for defined symbols, see N_WEAK_DEF. */
|
---|
802 | #define N_REF_TO_WEAK UINT16_C(0x0080)
|
---|
803 |
|
---|
804 | /** @} */
|
---|
805 |
|
---|
806 | #endif
|
---|
807 |
|
---|