source: trunk/kLdr/kLdrModMachO.h@ 2951

Last change on this file since 2951 was 2951, checked in by bird, 19 years ago

The command structures essential to MH_OBJECT.

File size: 26.8 KB
RevLine 
[2949]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 */
23typedef struct fat_header
24{
25 uint32_t magic;
26 uint32_t nfat_arch;
[2950]27} fat_header_t;
[2949]28
29/**
30 * Description of fat file item.
31 */
32struct 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. */
[2950]39} fat_arch_t;
[2949]40
41
42
43#ifdef IMAGE_MACHO32_SIGNATURE
44/** The 32-bit Mach-O signature. */
45# define IMAGE_MACHO32_SIGNATURE UINT32_C(0xfeedface)
46#endif
47#ifdef 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 */
59typedef 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;
[2950]68} mach_header_32_t;
[2949]69
70
71
72#ifdef IMAGE_MACHO64_SIGNATURE
73/** The 64-bit Mach-O signature. */
74# define IMAGE_MACHO64_SIGNATURE UINT32_C(0xfeedfacf)
75#endif
76#ifdef 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 */
88typedef 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) */
[2950]98} mach_header_64_t;
[2949]99
100
[2950]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. */
[2949]114
[2950]115/** @} */
116
117
118/** @name Mach-O Header flags (mach_header_64::flags, mach_header_32::flags)
[2949]119 * @{
120 */
[2950]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/** @} */
140
141
142/** @name CPU types / bits (mach_header_64::cputype, mach_header_32::cputype, fat_arch::cputype)
143 * @{
144 */
[2949]145#define CPU_ARCH_MASK INT32_C(0xff000000)
146#define CPU_ARCH_ABI64 INT32_C(0x01000000)
147#define CPU_TYPE_ANY INT32_C(-1)
148#define CPU_TYPE_VAX INT32_C(1)
149#define CPU_TYPE_MC680x0 INT32_C(6)
150#define CPU_TYPE_X86 INT32_C(7)
151#define CPU_TYPE_I386 CPU_TYPE_X86
152#define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64)
153#define CPU_TYPE_MC98000 INT32_C(10)
154#define CPU_TYPE_HPPA INT32_C(11)
155#define CPU_TYPE_MC88000 INT32_C(13)
156#define CPU_TYPE_SPARC INT32_C(14)
157#define CPU_TYPE_I860 INT32_C(15)
158#define CPU_TYPE_POWERPC INT32_C(18)
159#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
160/** @} */
161
[2950]162
163/** @name CPU subtypes (mach_header_64::cpusubtype, mach_header_32::cpusubtype, fat_arch::cpusubtype)
[2949]164 * @{ */
165#define CPU_SUBTYPE_MULTIPLE INT32_C(-1)
166#define CPU_SUBTYPE_LITTLE_ENDIAN INT32_C(0) /**< figure this one out. */
167#define CPU_SUBTYPE_BIG_ENDIAN INT32_C(1) /**< ditto */
168
169/* VAX */
170#define CPU_SUBTYPE_VAX_ALL INT32_C(0)
171#define CPU_SUBTYPE_VAX780 INT32_C(1)
172#define CPU_SUBTYPE_VAX785 INT32_C(2)
173#define CPU_SUBTYPE_VAX750 INT32_C(3)
174#define CPU_SUBTYPE_VAX730 INT32_C(4)
175#define CPU_SUBTYPE_UVAXI INT32_C(5)
176#define CPU_SUBTYPE_UVAXII INT32_C(6)
177#define CPU_SUBTYPE_VAX8200 INT32_C(7)
178#define CPU_SUBTYPE_VAX8500 INT32_C(8)
179#define CPU_SUBTYPE_VAX8600 INT32_C(9)
180#define CPU_SUBTYPE_VAX8650 INT32_C(10)
181#define CPU_SUBTYPE_VAX8800 INT32_C(11)
182#define CPU_SUBTYPE_UVAXIII INT32_C(12)
183
184/* MC680xx */
185#define CPU_SUBTYPE_MC680x0_ALL INT32_C(1)
186#define CPU_SUBTYPE_MC68030 INT32_C(1)
187#define CPU_SUBTYPE_MC68040 INT32_C(2)
188#define CPU_SUBTYPE_MC68030_ONLY INT32_C(3)
189
190/* I386 */
191#define CPU_SUBTYPE_INTEL(fam, model) ( (int32_t)(((model) << 4) | (fam)) )
192#define CPU_SUBTYPE_INTEL_FAMILY(subtype) ( (subtype) & 0xf )
193#define CPU_SUBTYPE_INTEL_MODEL(subtype) ( (subtype) >> 4 )
194#define CPU_SUBTYPE_INTEL_FAMILY_MAX 0xf
195#define CPU_SUBTYPE_INTEL_MODEL_ALL 0
196
197#define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0)
198#define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0)
199#define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0)
200#define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8)
201#define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0)
202#define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0)
203#define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1)
204#define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3)
205#define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5)
206#define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6)
207#define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7)
208#define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0)
209#define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1)
210#define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2)
211#define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0)
212#define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0)
213#define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1)
214#define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0)
215#define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1)
216#define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0)
217#define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1)
218
219/* X86 */
220#define CPU_SUBTYPE_X86_ALL INT32_C(3) /* CPU_SUBTYPE_I386_ALL */
221#define CPU_SUBTYPE_X86_64_ALL INT32_C(3) /* CPU_SUBTYPE_I386_ALL */
222#define CPU_SUBTYPE_X86_ARCH1 INT32_C(4) /* CPU_SUBTYPE_I486_ALL */
223
224/* MIPS */
225#define CPU_SUBTYPE_MIPS_ALL INT32_C(0)
226#define CPU_SUBTYPE_MIPS_R2300 INT32_C(1)
227#define CPU_SUBTYPE_MIPS_R2600 INT32_C(2)
228#define CPU_SUBTYPE_MIPS_R2800 INT32_C(3)
229#define CPU_SUBTYPE_MIPS_R2000a INT32_C(4)
230#define CPU_SUBTYPE_MIPS_R2000 INT32_C(5)
231#define CPU_SUBTYPE_MIPS_R3000a INT32_C(6)
232#define CPU_SUBTYPE_MIPS_R3000 INT32_C(7)
233
234/* MC98000 (PowerPC) */
235#define CPU_SUBTYPE_MC98000_ALL INT32_C(0)
236#define CPU_SUBTYPE_MC98601 INT32_C(1)
237
238/* HP-PA */
239#define CPU_SUBTYPE_HPPA_ALL INT32_C(0)
240#define CPU_SUBTYPE_HPPA_7100 INT32_C(0)
241#define CPU_SUBTYPE_HPPA_7100LC INT32_C(1)
242
243/* MC88000 */
244#define CPU_SUBTYPE_MC88000_ALL INT32_C(0)
245#define CPU_SUBTYPE_MC88100 INT32_C(1)
246#define CPU_SUBTYPE_MC88110 INT32_C(2)
247
248/* SPARC */
249#define CPU_SUBTYPE_SPARC_ALL INT32_C(0)
250
251/* I860 */
252#define CPU_SUBTYPE_I860_ALL INT32_C(0)
253#define CPU_SUBTYPE_I860_860 INT32_C(1)
254
255/* PowerPC */
256#define CPU_SUBTYPE_POWERPC_ALL INT32_C(0)
257#define CPU_SUBTYPE_POWERPC_601 INT32_C(1)
258#define CPU_SUBTYPE_POWERPC_602 INT32_C(2)
259#define CPU_SUBTYPE_POWERPC_603 INT32_C(3)
260#define CPU_SUBTYPE_POWERPC_603e INT32_C(4)
261#define CPU_SUBTYPE_POWERPC_603ev INT32_C(5)
262#define CPU_SUBTYPE_POWERPC_604 INT32_C(6)
263#define CPU_SUBTYPE_POWERPC_604e INT32_C(7)
264#define CPU_SUBTYPE_POWERPC_620 INT32_C(8)
265#define CPU_SUBTYPE_POWERPC_750 INT32_C(9)
266#define CPU_SUBTYPE_POWERPC_7400 INT32_C(10)
267#define CPU_SUBTYPE_POWERPC_7450 INT32_C(11)
268#define CPU_SUBTYPE_POWERPC_Max INT32_C(10)
269#define CPU_SUBTYPE_POWERPC_SCVger INT32_C(11)
270#define CPU_SUBTYPE_POWERPC_970 INT32_C(100)
271
272/** @} */
273
[2950]274
275/**
276 * The load command common core structure.
277 *
278 * After the Mach-O header follows an array of variable sized
279 * load command which all has this header in common.
280 */
281typedef struct load_command
282{
283 uint32_t cmd; /**< The load command id. */
284 uint32_t cmdsize; /**< The size of the command (including this header?). */
285} load_command_t;
286
287/** @name Load Command IDs (load_command::cmd)
288 * @{
289 */
290/** Flag that when set requires the dynamic linker to fail if it doesn't
291 * grok the command. The dynamic linker will otherwise ignore commands it
292 * doesn't understand. Introduced with Mac OS X 10.1. */
293#define LC_REQ_DYLD UINT32_C(0x80000000)
294
295#define LC_SEGMENT_32 UINT32_C(0x01) /**< Segment to be mapped (32-bit). See segment_command_32. */
296#define LC_SYMTAB UINT32_C(0x02) /**< 'stab' symbol table. See symtab_command. */
297#define LC_SYMSEG UINT32_C(0x03) /**< Obsoleted gdb symbol table. */
298#define LC_THREAD UINT32_C(0x04) /**< Thread. See thread_command. */
299#define LC_UNIXTHREAD UINT32_C(0x05) /**< Unix thread (includes stack and stuff). See thread_command. */
300#define LC_LOADFVMLIB UINT32_C(0x06) /**< Load a specified fixed VM shared library (obsolete?). See fvmlib_command. */
301#define LC_IDFVMLIB UINT32_C(0x07) /**< Fixed VM shared library id (obsolete?). See fvmlib_command. */
302#define LC_IDENT UINT32_C(0x08) /**< Identification info (obsolete). See ident_command. */
303#define LC_FVMFILE UINT32_C(0x09) /**< Fixed VM file inclusion (internal). See fvmfile_command. */
304#define LC_PREPAGE UINT32_C(0x0a) /**< Prepage command (internal). See ?? */
305#define LC_DYSYMTAB UINT32_C(0x0b) /**< Symbol table for dynamic linking. See dysymtab_command. */
306#define LC_LOAD_DYLIB UINT32_C(0x0c) /**< Load a dynamically linked shared library. See dylib_command. */
307#define LC_ID_DYLIB UINT32_C(0x0d) /**< Dynamically linked share library ident. See dylib_command. */
308#define LC_LOAD_DYLINKER UINT32_C(0x0e) /**< Load a dynamical link editor. See dylinker_command. */
309#define LC_ID_DYLINKER UINt32_C(0x0f) /**< Dynamic link editor ident. See dylinker_command. */
310#define LC_PREBOUND_DYLIB UINT32_C(0x10) /**< Prebound modules for dynamically linking of a shared lib. See prebound_dylib_command. */
311#define LC_ROUTINES UINT32_C(0x11) /**< Image routines. See routines_command_32. */
312#define LC_SUB_FRAMEWORK UINT32_C(0x12) /**< Sub framework. See sub_framework_command. */
313#define LC_SUB_UMBRELLA UINT32_C(0x13) /**< Sub umbrella. See sub_umbrella_command. */
[2951]314#define LC_SUB_CLIENT UINT32_C(0x14) /**< Sub client. See sub_client_command. */
[2950]315#define LC_SUB_LIBRARY UINT32_C(0x15) /**< Sub library. See sub_library_command. */
316#define LC_TWOLEVEL_HINTS UINT32_C(0x16) /**< Two-level namespace lookup hints. See twolevel_hints_command. */
317#define LC_PREBIND_CKSUM UINT32_C(0x17) /**< Prebind checksum. See prebind_cksum_command. */
318#define LC_LOAD_WEAK_DYLIB (UINT32_C(0x18) | LC_REQ_DYLD) /**< Dylib that can be missing, all symbols weak. See dylib_command. */
319#define LC_SEGMENT_64 UINT32_C(0x19) /**< segment to be mapped (64-bit). See segment_command_32. */
320#define LC_ROUTINES_64 UINT32_C(0x1a) /**< Image routines (64-bit). See routines_command_32. */
321#define LC_UUID UINT32_C(0x1b) /**< The UUID of the object module. See uuid_command. */
322/** @} */
323
[2951]324
325/**
326 * Load Command String.
327 */
328typedef struct lc_str
329{
330 /** Offset of the string relative to the load_command structure.
331 * The string is zero-terminated. the size of the load command
332 * is zero padded up to a multiple of 4 bytes. */
333 uint32_t offset;
334} lc_str_t;
335
336
337/**
338 * Segment load command (32-bit).
339 */
340typedef struct segment_command_32
341{
342 uint32_t cmd; /**< LC_SEGMENT */
343 uint32_t cmdsize; /**< sizeof(self) + sections. */
344 char segname[16]; /**< The segment name. */
345 uint32_t vmaddr; /**< Memory address of this segment. */
346 uint32_t vmsize; /**< Size of this segment. */
347 uint32_t fileoff; /**< The file location of the segment. */
348 uint32_t filesize; /**< The file size of the segment. */
349 uint32_t maxprot; /**< Maximum VM protection. */
350 uint32_t initprot; /**< Initial VM protection. */
351 uint32_t nsects; /**< Number of section desciptors following this structure. */
352 uint32_t flags; /**< Flags (SG_*). */
353} segment_command_32_t;
354
355
356/**
357 * Segment load command (64-bit).
358 * Same as segment_command_32 except 4 members has been blown up to 64-bit.
359 */
360typedef struct segment_command_64
361{
362 uint32_t cmd; /**< LC_SEGMENT */
363 uint32_t cmdsize; /**< sizeof(self) + sections. */
364 char segname[16]; /**< The segment name. */
365 uint64_t vmaddr; /**< Memory address of this segment. */
366 uint64_t vmsize; /**< Size of this segment. */
367 uint64_t fileoff; /**< The file location of the segment. */
368 uint64_t filesize; /**< The file size of the segment. */
369 uint32_t maxprot; /**< Maximum VM protection. */
370 uint32_t initprot; /**< Initial VM protection. */
371 uint32_t nsects; /**< Number of section desciptors following this structure. */
372 uint32_t flags; /**< Flags (SG_*). */
373} segment_command_64_t;
374
375/** @name Segment flags (segment_command_64::flags, segment_command_32::flags)
376 * @{ */
377/** Map the file bits in the top end of the memory area for the segment
378 * instead of the low end. Intended for stacks in core dumps.
379 * The part of the segment memory not covered by file bits will be zeroed. */
380#define SG_HIGHVM UINT32_C(0x00000001)
381/** This segment is the virtual memory allocated by a fixed VM library.
382 * (Used for overlap checking in the linker.) */
383#define SG_FVMLIB UINT32_C(0x00000002)
384/** No relocations for or symbols that's relocated to in this segment.
385 * The segment can therefore safely be replaced. */
386#define SG_NORELOC UINT32_C(0x00000004)
387/** The segment is protected.
388 * The first page isn't protected if it starts at file offset 0
389 * (so that the mach header and this load command can be easily mapped). */
390#define SG_PROTECTED_VERSION_1 UINT32_C(0x00000008)
391/** @} */
392
393
394/**
395 * 32-bit section (part of a segment load command).
396 */
397typedef struct section_32
398{
399 char sectname[16]; /**< The section name. */
400 char segname[16]; /**< The name of the segment this section goes into. */
401 uint32_t addr; /**< The memory address of this section. */
402 uint32_t size; /**< The size of this section. */
403 uint32_t offset; /**< The file offset of this section. */
404 uint32_t align; /**< The section alignment (**2). */
405 uint32_t reloff; /**< The file offset of the relocations. */
406 uint32_t nreloc; /**< The number of relocations. */
407 uint32_t flags; /**< The section flags; section type and attribs */
408 uint32_t reserved1; /**< Reserved / offset / index. */
409 uint32_t reserved2; /**< Reserved / count / sizeof. */
410} section_32_t;
411
412/**
413 * 64-bit section (part of a segment load command).
414 */
415typedef struct section_64
416{
417 char sectname[16]; /**< The section name. */
418 char segname[16]; /**< The name of the segment this section goes into. */
419 uint64_t addr; /**< The memory address of this section. */
420 uint64_t size; /**< The size of this section. */
421 uint32_t offset; /**< The file offset of this section. */
422 uint32_t align; /**< The section alignment (**2). */
423 uint32_t reloff; /**< The file offset of the relocations. */
424 uint32_t nreloc; /**< The number of relocations. */
425 uint32_t flags; /**< The section flags; section type and attribs */
426 uint32_t reserved1; /**< Reserved / offset / index. */
427 uint32_t reserved2; /**< Reserved / count / sizeof. */
428 uint32_t reserved3; /**< (Just) Reserved. */
429} section_64_t;
430
431/** @name Section flags (section_64::flags, section_32::flags)
432 * @{
433 */
434/** Section type mask. */
435#define SECTION_TYPE UINT32_C(0x000000ff)
436/** Regular section. */
437#define S_REGULAR 0x0
438/** Zero filled section. */
439#define S_ZEROFILL 0x1
440/** C literals. */
441#define S_CSTRING_LITERALS 0x2
442/** 4 byte literals. */
443#define S_4BYTE_LITERALS 0x3
444/** 8 byte literals. */
445#define S_8BYTE_LITERALS 0x4
446/** Pointer to literals. */
447#define S_LITERAL_POINTERS 0x5
448/** Section containing non-lazy symbol pointers.
449 * Reserved1 == start index in the indirect symbol table. */
450#define S_NON_LAZY_SYMBOL_POINTERS 0x6
451/** Section containing lazy symbol pointers.
452 * Reserved1 == start index in the indirect symbol table. */
453#define S_LAZY_SYMBOL_POINTERS 0x7
454/** Section containing symbol stubs.
455 * Reserved2 == stub size. */
456#define S_SYMBOL_STUBS 0x8
457/** Section containing function pointers for module initialization. . */
458#define S_MOD_INIT_FUNC_POINTERS 0x9
459/** Section containing function pointers for module termination. . */
460#define S_MOD_TERM_FUNC_POINTERS 0xa
461/** Section containing symbols that are to be coalesced. */
462#define S_COALESCED 0xb
463/** Zero filled section that be larger than 4GB. */
464#define S_GB_ZEROFILL 0xc
465/** Section containing pairs of function pointers for interposing. */
466#define S_INTERPOSING 0xd
467/** 16 byte literals. */
468#define S_16BYTE_LITERALS 0xe
469
470/** Section attribute mask. */
471#define SECTION_ATTRIBUTES UINT32_C(0xffffff00)
472
473/** User settable attribute mask. */
474#define SECTION_ATTRIBUTES_USR UINT32_C(0xff000000)
475/** Pure instruction (code). */
476#define S_ATTR_PURE_INSTRUCTIONS UINT32_C(0x80000000)
477/** ranlib, ignore my symbols... */
478#define S_ATTR_NO_TOC UINT32_C(0x40000000)
479/** May strip static symbols when linking int a MH_DYLDLINK file. */
480#define S_ATTR_STRIP_STATIC_SYMS UINT32_C(0x20000000)
481/** No dead stripping. */
482#define S_ATTR_NO_DEAD_STRIP UINT32_C(0x10000000)
483/** Live support. */
484#define S_ATTR_LIVE_SUPPORT UINT32_C(0x08000000)
485/** Contains self modifying code (generally i386 code stub for dyld). */
486#define S_ATTR_SELF_MODIFYING_CODE UINT32_C(0x04000000)
487/** Debug info (DWARF usually). */
488#define S_ATTR_DEBUG UINT32_C(0x02000000)
489
490/** System settable attribute mask. */
491#define SECTION_ATTRIBUTES_SYS UINT32_C(0x00ffff00)
492/** Contains some instructions (code). */
493#define S_ATTR_SOME_INSTRUCTIONS UINT32_C(0x00000400)
494/** Has external relocations. */
495#define S_ATTR_EXT_RELOC UINT32_C(0x00000200)
496/** Has internal (local) relocations. */
497#define S_ATTR_LOC_RELOC UINT32_C(0x00000100)
498/** @} */
499
500/** @name Known Segment and Section Names.
501 * Some of these implies special linker behaviour.
502 * @{
503 */
504/** Page zero - not-present page for catching invalid access. (MH_EXECUTE typically) */
505#define SEG_PAGEZERO "__PAGEZERO"
506/** Traditional UNIX text segment.
507 * Defaults to R-X. */
508#define SEG_TEXT "__TEXT"
509/** The text part of SEG_TEXT. */
510#define SECT_TEXT "__text"
511/** The fvmlib initialization. */
512#define SECT_FVMLIB_INIT0 "__fvmlib_init0"
513/** The section following the fvmlib initialization. */
514#define SECT_FVMLIB_INIT1 "__fvmlib_init1"
515/** The traditional UNIX data segment. (DGROUP to DOS and OS/2 people.) */
516#define SEG_DATA "__DATA"
517/** The initialized data section. */
518#define SECT_DATA "__data"
519/** The uninitialized data section. */
520#define SECT_BSS "__bss"
521/** The common symbol section. */
522#define SECT_COMMON "__common"
523/** Objective-C runtime segment. */
524#define SEG_OBJC "__OBJC"
525/** Objective-C symbol table section. */
526#define SECT_OBJC_SYMBOLS "__symbol_table"
527/** Objective-C module information section. */
528#define SECT_OBJC_MODULES "__module_info"
529/** Objective-C string table section. */
530#define SECT_OBJC_STRINGS "__selector_strs"
531/** Objective-C string table section. */
532#define SECT_OBJC_REFS "__selector_refs"
533/** Icon segment. */
534#define SEG_ICON "__ICON"
535/** The icon headers. */
536#define SECT_ICON_HEADER "__header"
537/** The icons in the TIFF format. */
538#define SECT_ICON_TIFF "__tiff"
539/** ld -seglinkedit segment containing all the structs create and maintained
540 * by the linker. MH_EXECUTE and MH_FVMLIB only. */
541#define SEG_LINKEDIT "__LINKEDIT"
542/** The unix stack segment. */
543#define SEG_UNIXSTACK "__UNIXSTACK"
544/** The segment for the self modifying code for dynamic linking.
545 * Implies RWX permissions. */
546#define SEG_IMPORT "__IMPORT"
547/** @} */
548
549
550/** @todo fvmlib */
551/** @todo fvmlib_command (LC_IDFVMLIB or LC_LOADFVMLIB) */
552/** @todo dylib */
553/** @todo dylib_command (LC_ID_DYLIB, LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB) */
554/** @todo sub_framework_command (LC_SUB_FRAMEWORK) */
555/** @todo sub_client_command (LC_SUB_CLIENT) */
556/** @todo sub_umbrella_command (LC_SUB_UMBRELLA) */
557/** @todo sub_library_command (LC_SUB_LIBRARY) */
558/** @todo prebound_dylib_command (LC_PREBOUND_DYLIB) */
559/** @todo dylinker_command (LC_ID_DYLINKER or LC_LOAD_DYLINKER) */
560
561
562/**
563 * Thread command.
564 *
565 * State description of a thread that is to be created. The description
566 * is made up of a number of state structures preceded by a 32-bit flavor
567 * and 32-bit count field stating the kind of stat structure and it's size
568 * in uint32_t items respecitvly.
569 *
570 * LC_UNIXTHREAD differs from LC_THREAD in that it implies stack creation
571 * and that it's started with the typical main(int, char **, char **) frame
572 * on the stack.
573 */
574typedef struct thread_command
575{
576 uint32_t cmd; /**< LC_UNIXTHREAD or LC_THREAD. */
577 uint32_t cmdsize; /**< The size of the command (including this header). */
578} thread_command_t;
579
580
581/** @todo routines_command (LC_ROUTINES) */
582/** @todo routines_command_64 (LC_ROUTINES_64) */
583
584
585/**
586 * Symbol table command.
587 * Contains a.out style symbol table with some tricks.
588 */
589typedef struct symtab_command
590{
591 uint32_t cmd; /**< LC_SYMTAB */
592 uint32_t cmdsize; /** sizeof(symtab_command_t) */
593 uint32_t symoff; /** The file offset of the symbol table. */
594 uint32_t nsyms; /** The number of symbols in the symbol table. */
595 uint32_t stroff; /** The file offset of the string table. */
596 uint32_t strsize; /** The size of the string table. */
597} symtab_command_t;
598
599
600/** @todo dysymtab_command (LC_DYSYMTAB) */
601/** @todo dylib_table_of_contents */
602/** @todo dylib_module_32 */
603/** @todo dylib_module_64 */
604/** @todo dylib_reference */
605/** @todo twolevel_hints_command (LC_TWOLEVEL_HINTS) */
606/** @todo twolevel_hint */
607/** @todo prebind_cksum_command (LC_PREBIND_CKSUM) */
608
609
610/**
611 * UUID generated by ld.
612 */
613typedef struct uuid_command
614{
615 uint32_t cmd; /**< LC_UUID */
616 uint32_t cmdsize; /**< sizeof(uuid_command_t) */
617 uint8_t uuid[16]; /** The UUID bytes. */
618} uuid_command_t;
619
620
621/** @todo symseg_command (LC_SYMSEG) */
622/** @todo ident_command (LC_IDENT)
623/** @todo fvmfile_command (LC_FVMFILE) */
[2949]624#endif
625
Note: See TracBrowser for help on using the repository browser.