VirtualBox

source: vbox/trunk/include/iprt/formats/mach-o.h@ 74334

Last change on this file since 74334 was 72691, checked in by vboxsync, 7 years ago

iprt/formats/mach-o.h,dbgkrnlinfo-r0drv-darwin.cpp: Deal with new load commands.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.1 KB
Line 
1/* $Id: mach-o.h 72691 2018-06-26 10:16:49Z vboxsync $ */
2/** @file
3 * IPRT - Mach-O Structures and Constants.
4 */
5
6/*
7 * Copyright (C) 2011-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___internal_ldrMach_O_h
28#define ___internal_ldrMach_O_h
29
30#include <iprt/types.h>
31
32#ifndef CPU_ARCH_MASK
33
34/* cputype */
35#define CPU_ARCH_MASK INT32_C(0xff000000)
36#define CPU_ARCH_ABI64 INT32_C(0x01000000)
37#define CPU_TYPE_ANY INT32_C(-1)
38#define CPU_TYPE_VAX INT32_C(1)
39#define CPU_TYPE_MC680x0 INT32_C(6)
40#define CPU_TYPE_X86 INT32_C(7)
41#define CPU_TYPE_I386 CPU_TYPE_X86
42#define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64)
43#define CPU_TYPE_MC98000 INT32_C(10)
44#define CPU_TYPE_HPPA INT32_C(11)
45#define CPU_TYPE_MC88000 INT32_C(13)
46#define CPU_TYPE_SPARC INT32_C(14)
47#define CPU_TYPE_I860 INT32_C(15)
48#define CPU_TYPE_POWERPC INT32_C(18)
49#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
50
51/* cpusubtype */
52#define CPU_SUBTYPE_MULTIPLE INT32_C(-1)
53#define CPU_SUBTYPE_LITTLE_ENDIAN INT32_C(0)
54#define CPU_SUBTYPE_BIG_ENDIAN INT32_C(1)
55
56#define CPU_SUBTYPE_VAX_ALL INT32_C(0)
57#define CPU_SUBTYPE_VAX780 INT32_C(1)
58#define CPU_SUBTYPE_VAX785 INT32_C(2)
59#define CPU_SUBTYPE_VAX750 INT32_C(3)
60#define CPU_SUBTYPE_VAX730 INT32_C(4)
61#define CPU_SUBTYPE_UVAXI INT32_C(5)
62#define CPU_SUBTYPE_UVAXII INT32_C(6)
63#define CPU_SUBTYPE_VAX8200 INT32_C(7)
64#define CPU_SUBTYPE_VAX8500 INT32_C(8)
65#define CPU_SUBTYPE_VAX8600 INT32_C(9)
66#define CPU_SUBTYPE_VAX8650 INT32_C(10)
67#define CPU_SUBTYPE_VAX8800 INT32_C(11)
68#define CPU_SUBTYPE_UVAXIII INT32_C(12)
69
70#define CPU_SUBTYPE_MC680x0_ALL INT32_C(1)
71#define CPU_SUBTYPE_MC68030 INT32_C(1)
72#define CPU_SUBTYPE_MC68040 INT32_C(2)
73#define CPU_SUBTYPE_MC68030_ONLY INT32_C(3)
74
75#define CPU_SUBTYPE_INTEL(fam, model) ( (int32_t )(((model) << 4) | (fam)) )
76#define CPU_SUBTYPE_INTEL_FAMILY(subtype) ( (subtype) & 0xf )
77#define CPU_SUBTYPE_INTEL_MODEL(subtype) ( (subtype) >> 4 )
78#define CPU_SUBTYPE_INTEL_FAMILY_MAX 0xf
79#define CPU_SUBTYPE_INTEL_MODEL_ALL 0
80
81#define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0)
82#define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0)
83#define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0)
84#define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8)
85#define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0)
86#define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0)
87#define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1)
88#define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3)
89#define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5)
90#define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6)
91#define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7)
92#define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0)
93#define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1)
94#define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2)
95#define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0)
96#define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0)
97#define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1)
98#define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0)
99#define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1)
100#define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0)
101#define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1)
102
103#define CPU_SUBTYPE_X86_ALL INT32_C(3)
104#define CPU_SUBTYPE_X86_64_ALL INT32_C(3)
105#define CPU_SUBTYPE_X86_ARCH1 INT32_C(4)
106
107#define CPU_SUBTYPE_MIPS_ALL INT32_C(0)
108#define CPU_SUBTYPE_MIPS_R2300 INT32_C(1)
109#define CPU_SUBTYPE_MIPS_R2600 INT32_C(2)
110#define CPU_SUBTYPE_MIPS_R2800 INT32_C(3)
111#define CPU_SUBTYPE_MIPS_R2000a INT32_C(4)
112#define CPU_SUBTYPE_MIPS_R2000 INT32_C(5)
113#define CPU_SUBTYPE_MIPS_R3000a INT32_C(6)
114#define CPU_SUBTYPE_MIPS_R3000 INT32_C(7)
115
116#define CPU_SUBTYPE_MC98000_ALL INT32_C(0)
117#define CPU_SUBTYPE_MC98601 INT32_C(1)
118
119#define CPU_SUBTYPE_HPPA_ALL INT32_C(0)
120#define CPU_SUBTYPE_HPPA_7100 INT32_C(0)
121#define CPU_SUBTYPE_HPPA_7100LC INT32_C(1)
122
123#define CPU_SUBTYPE_MC88000_ALL INT32_C(0)
124#define CPU_SUBTYPE_MC88100 INT32_C(1)
125#define CPU_SUBTYPE_MC88110 INT32_C(2)
126
127#define CPU_SUBTYPE_SPARC_ALL INT32_C(0)
128
129#define CPU_SUBTYPE_I860_ALL INT32_C(0)
130#define CPU_SUBTYPE_I860_860 INT32_C(1)
131
132#define CPU_SUBTYPE_POWERPC_ALL INT32_C(0)
133#define CPU_SUBTYPE_POWERPC_601 INT32_C(1)
134#define CPU_SUBTYPE_POWERPC_602 INT32_C(2)
135#define CPU_SUBTYPE_POWERPC_603 INT32_C(3)
136#define CPU_SUBTYPE_POWERPC_603e INT32_C(4)
137#define CPU_SUBTYPE_POWERPC_603ev INT32_C(5)
138#define CPU_SUBTYPE_POWERPC_604 INT32_C(6)
139#define CPU_SUBTYPE_POWERPC_604e INT32_C(7)
140#define CPU_SUBTYPE_POWERPC_620 INT32_C(8)
141#define CPU_SUBTYPE_POWERPC_750 INT32_C(9)
142#define CPU_SUBTYPE_POWERPC_7400 INT32_C(10)
143#define CPU_SUBTYPE_POWERPC_7450 INT32_C(11)
144#define CPU_SUBTYPE_POWERPC_Max INT32_C(10)
145#define CPU_SUBTYPE_POWERPC_SCVger INT32_C(11)
146#define CPU_SUBTYPE_POWERPC_970 INT32_C(100)
147
148#define CPU_SUBTYPE_MASK UINT32_C(0xff000000)
149#define CPU_SUBTYPE_LIB64 UINT32_C(0x80000000)
150
151#endif /* !CPU_ARCH_MASK */
152
153
154typedef struct fat_header
155{
156 uint32_t magic;
157 uint32_t nfat_arch;
158} fat_header_t;
159
160#ifndef IMAGE_FAT_SIGNATURE
161# define IMAGE_FAT_SIGNATURE UINT32_C(0xcafebabe)
162#endif
163#ifndef IMAGE_FAT_SIGNATURE_OE
164# define IMAGE_FAT_SIGNATURE_OE UINT32_C(0xbebafeca)
165#endif
166
167typedef struct fat_arch
168{
169 int32_t cputype;
170 int32_t cpusubtype;
171 uint32_t offset;
172 uint32_t size;
173 uint32_t align;
174} fat_arch_t;
175
176typedef struct mach_header_32
177{
178 uint32_t magic;
179 int32_t cputype;
180 int32_t cpusubtype;
181 uint32_t filetype;
182 uint32_t ncmds;
183 uint32_t sizeofcmds;
184 uint32_t flags;
185} mach_header_32_t;
186
187/* magic */
188#ifndef IMAGE_MACHO32_SIGNATURE
189# define IMAGE_MACHO32_SIGNATURE UINT32_C(0xfeedface)
190#endif
191#ifndef IMAGE_MACHO32_SIGNATURE_OE
192# define IMAGE_MACHO32_SIGNATURE_OE UINT32_C(0xcefaedfe)
193#endif
194#define MH_MAGIC IMAGE_MACHO32_SIGNATURE
195#define MH_CIGAM IMAGE_MACHO32_SIGNATURE_OE
196
197typedef struct mach_header_64
198{
199 uint32_t magic;
200 int32_t cputype;
201 int32_t cpusubtype;
202 uint32_t filetype;
203 uint32_t ncmds;
204 uint32_t sizeofcmds;
205 uint32_t flags;
206 uint32_t reserved;
207} mach_header_64_t;
208
209/* magic */
210#ifndef IMAGE_MACHO64_SIGNATURE
211# define IMAGE_MACHO64_SIGNATURE UINT32_C(0xfeedfacf)
212#endif
213#ifndef IMAGE_MACHO64_SIGNATURE_OE
214# define IMAGE_MACHO64_SIGNATURE_OE UINT32_C(0xfefaedfe)
215#endif
216#define MH_MAGIC_64 IMAGE_MACHO64_SIGNATURE
217#define MH_CIGAM_64 IMAGE_MACHO64_SIGNATURE_OE
218
219/* mach_header_* filetype */
220#define MH_OBJECT UINT32_C(1)
221#define MH_EXECUTE UINT32_C(2)
222#define MH_FVMLIB UINT32_C(3)
223#define MH_CORE UINT32_C(4)
224#define MH_PRELOAD UINT32_C(5)
225#define MH_DYLIB UINT32_C(6)
226#define MH_DYLINKER UINT32_C(7)
227#define MH_BUNDLE UINT32_C(8)
228#define MH_DYLIB_STUB UINT32_C(9)
229#define MH_DSYM UINT32_C(10)
230#define MH_KEXT_BUNDLE UINT32_C(11)
231
232/* mach_header_* flags */
233#define MH_NOUNDEFS UINT32_C(0x00000001)
234#define MH_INCRLINK UINT32_C(0x00000002)
235#define MH_DYLDLINK UINT32_C(0x00000004)
236#define MH_BINDATLOAD UINT32_C(0x00000008)
237#define MH_PREBOUND UINT32_C(0x00000010)
238#define MH_SPLIT_SEGS UINT32_C(0x00000020)
239#define MH_LAZY_INIT UINT32_C(0x00000040)
240#define MH_TWOLEVEL UINT32_C(0x00000080)
241#define MH_FORCE_FLAT UINT32_C(0x00000100)
242#define MH_NOMULTIDEFS UINT32_C(0x00000200)
243#define MH_NOFIXPREBINDING UINT32_C(0x00000400)
244#define MH_PREBINDABLE UINT32_C(0x00000800)
245#define MH_ALLMODSBOUND UINT32_C(0x00001000)
246#define MH_SUBSECTIONS_VIA_SYMBOLS UINT32_C(0x00002000)
247#define MH_CANONICAL UINT32_C(0x00004000)
248#define MH_WEAK_DEFINES UINT32_C(0x00008000)
249#define MH_BINDS_TO_WEAK UINT32_C(0x00010000)
250#define MH_ALLOW_STACK_EXECUTION UINT32_C(0x00020000)
251#define MH_ROOT_SAFE UINT32_C(0x00040000)
252#define MH_SETUID_SAFE UINT32_C(0x00080000)
253#define MH_NO_REEXPORTED_DYLIBS UINT32_C(0x00100000)
254#define MH_PIE UINT32_C(0x00200000)
255#define MH_DEAD_STRIPPABLE_DYLIB UINT32_C(0x00400000)
256#define MH_HAS_TLV_DESCRIPTORS UINT32_C(0x00800000)
257#define MH_NO_HEAP_EXECUTION UINT32_C(0x01000000)
258#define MH_VALID_FLAGS UINT32_C(0x01ffffff)
259
260
261typedef struct load_command
262{
263 uint32_t cmd;
264 uint32_t cmdsize;
265} load_command_t;
266
267/* load cmd */
268#define LC_REQ_DYLD UINT32_C(0x80000000)
269#define LC_SEGMENT_32 UINT32_C(0x01)
270#define LC_SYMTAB UINT32_C(0x02)
271#define LC_SYMSEG UINT32_C(0x03)
272#define LC_THREAD UINT32_C(0x04)
273#define LC_UNIXTHREAD UINT32_C(0x05)
274#define LC_LOADFVMLIB UINT32_C(0x06)
275#define LC_IDFVMLIB UINT32_C(0x07)
276#define LC_IDENT UINT32_C(0x08)
277#define LC_FVMFILE UINT32_C(0x09)
278#define LC_PREPAGE UINT32_C(0x0a)
279#define LC_DYSYMTAB UINT32_C(0x0b)
280#define LC_LOAD_DYLIB UINT32_C(0x0c)
281#define LC_ID_DYLIB UINT32_C(0x0d)
282#define LC_LOAD_DYLINKER UINT32_C(0x0e)
283#define LC_ID_DYLINKER UINT32_C(0x0f)
284#define LC_PREBOUND_DYLIB UINT32_C(0x10)
285#define LC_ROUTINES UINT32_C(0x11)
286#define LC_SUB_FRAMEWORK UINT32_C(0x12)
287#define LC_SUB_UMBRELLA UINT32_C(0x13)
288#define LC_SUB_CLIENT UINT32_C(0x14)
289#define LC_SUB_LIBRARY UINT32_C(0x15)
290#define LC_TWOLEVEL_HINTS UINT32_C(0x16)
291#define LC_PREBIND_CKSUM UINT32_C(0x17)
292#define LC_LOAD_WEAK_DYLIB (UINT32_C(0x18) | LC_REQ_DYLD)
293#define LC_SEGMENT_64 UINT32_C(0x19)
294#define LC_ROUTINES_64 UINT32_C(0x1a)
295#define LC_UUID UINT32_C(0x1b)
296#define LC_RPATH (UINT32_C(0x1c) | LC_REQ_DYLD)
297#define LC_CODE_SIGNATURE UINT32_C(0x1d)
298#define LC_SEGMENT_SPLIT_INFO UINT32_C(0x1e)
299#define LC_REEXPORT_DYLIB (UINT32_C(0x1f) | LC_REQ_DYLD)
300#define LC_LAZY_LOAD_DYLIB UINT32_C(0x20)
301#define LC_ENCRYPTION_INFO UINT32_C(0x21)
302#define LC_DYLD_INFO UINT32_C(0x22)
303#define LC_DYLD_INFO_ONLY (UINT32_C(0x22) | LC_REQ_DYLD)
304#define LC_LOAD_UPWARD_DYLIB (UINT32_C(0x23) | LC_REQ_DYLD)
305#define LC_VERSION_MIN_MACOSX UINT32_C(0x24)
306#define LC_VERSION_MIN_IPHONEOS UINT32_C(0x25)
307#define LC_FUNCTION_STARTS UINT32_C(0x26)
308#define LC_DYLD_ENVIRONMENT UINT32_C(0x27)
309#define LC_MAIN (UINT32_C(0x28) | LC_REQ_DYLD)
310#define LC_DATA_IN_CODE UINT32_C(0x29)
311#define LC_SOURCE_VERSION UINT32_C(0x2a)
312#define LC_DYLIB_CODE_SIGN_DRS UINT32_C(0x2b)
313#define LC_ENCRYPTION_INFO_64 UINT32_C(0x2c)
314#define LC_LINKER_OPTION UINT32_C(0x2d)
315#define LC_LINKER_OPTIMIZATION_HINT UINT32_C(0x2e)
316#define LC_VERSION_MIN_TVOS UINT32_C(0x2f)
317#define LC_VERSION_MIN_WATCHOS UINT32_C(0x30)
318#define LC_NOTE UINT32_C(0x31)
319#define LC_BUILD_VERSION UINT32_C(0x32)
320
321
322typedef struct lc_str
323{
324 uint32_t offset;
325} lc_str_t;
326
327typedef struct segment_command_32
328{
329 uint32_t cmd;
330 uint32_t cmdsize;
331 char segname[16];
332 uint32_t vmaddr;
333 uint32_t vmsize;
334 uint32_t fileoff;
335 uint32_t filesize;
336 uint32_t maxprot;
337 uint32_t initprot;
338 uint32_t nsects;
339 uint32_t flags;
340} segment_command_32_t;
341
342typedef struct segment_command_64
343{
344 uint32_t cmd;
345 uint32_t cmdsize;
346 char segname[16];
347 uint64_t vmaddr;
348 uint64_t vmsize;
349 uint64_t fileoff;
350 uint64_t filesize;
351 uint32_t maxprot;
352 uint32_t initprot;
353 uint32_t nsects;
354 uint32_t flags;
355} segment_command_64_t;
356
357/* segment flags */
358#define SG_HIGHVM UINT32_C(0x00000001)
359#define SG_FVMLIB UINT32_C(0x00000002)
360#define SG_NORELOC UINT32_C(0x00000004)
361#define SG_PROTECTED_VERSION_1 UINT32_C(0x00000008)
362
363/* maxprot/initprot */
364#ifndef VM_PROT_NONE
365# define VM_PROT_NONE UINT32_C(0x00000000)
366# define VM_PROT_READ UINT32_C(0x00000001)
367# define VM_PROT_WRITE UINT32_C(0x00000002)
368# define VM_PROT_EXECUTE UINT32_C(0x00000004)
369# define VM_PROT_ALL UINT32_C(0x00000007)
370#endif
371
372typedef struct section_32
373{
374 char sectname[16];
375 char segname[16];
376 uint32_t addr;
377 uint32_t size;
378 uint32_t offset;
379 uint32_t align;
380 uint32_t reloff;
381 uint32_t nreloc;
382 uint32_t flags;
383 uint32_t reserved1;
384 uint32_t reserved2;
385} section_32_t;
386
387typedef struct section_64
388{
389 char sectname[16];
390 char segname[16];
391 uint64_t addr;
392 uint64_t size;
393 uint32_t offset;
394 uint32_t align;
395 uint32_t reloff;
396 uint32_t nreloc;
397 uint32_t flags;
398 uint32_t reserved1;
399 uint32_t reserved2;
400 uint32_t reserved3;
401} section_64_t;
402
403/* section flags */
404#define SECTION_TYPE UINT32_C(0x000000ff)
405#define S_REGULAR 0x0
406#define S_ZEROFILL 0x1
407#define S_CSTRING_LITERALS 0x2
408#define S_4BYTE_LITERALS 0x3
409#define S_8BYTE_LITERALS 0x4
410#define S_LITERAL_POINTERS 0x5
411#define S_NON_LAZY_SYMBOL_POINTERS 0x6
412#define S_LAZY_SYMBOL_POINTERS 0x7
413#define S_SYMBOL_STUBS 0x8
414#define S_MOD_INIT_FUNC_POINTERS 0x9
415#define S_MOD_TERM_FUNC_POINTERS 0xa
416#define S_COALESCED 0xb
417#define S_GB_ZEROFILL 0xc
418#define S_INTERPOSING 0xd
419#define S_16BYTE_LITERALS 0xe
420#define S_DTRACE_DOF 0xf
421#define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10
422
423#define SECTION_ATTRIBUTES UINT32_C(0xffffff00)
424#define SECTION_ATTRIBUTES_USR UINT32_C(0xff000000)
425#define S_ATTR_PURE_INSTRUCTIONS UINT32_C(0x80000000)
426#define S_ATTR_NO_TOC UINT32_C(0x40000000)
427#define S_ATTR_STRIP_STATIC_SYMS UINT32_C(0x20000000)
428#define S_ATTR_NO_DEAD_STRIP UINT32_C(0x10000000)
429#define S_ATTR_LIVE_SUPPORT UINT32_C(0x08000000)
430#define S_ATTR_SELF_MODIFYING_CODE UINT32_C(0x04000000)
431#define S_ATTR_DEBUG UINT32_C(0x02000000)
432#define SECTION_ATTRIBUTES_SYS UINT32_C(0x00ffff00)
433#define S_ATTR_SOME_INSTRUCTIONS UINT32_C(0x00000400)
434#define S_ATTR_EXT_RELOC UINT32_C(0x00000200)
435#define S_ATTR_LOC_RELOC UINT32_C(0x00000100)
436
437/* standard section names */
438#define SEG_PAGEZERO "__PAGEZERO"
439#define SEG_TEXT "__TEXT"
440#define SECT_TEXT "__text"
441#define SECT_FVMLIB_INIT0 "__fvmlib_init0"
442#define SECT_FVMLIB_INIT1 "__fvmlib_init1"
443#define SEG_DATA "__DATA"
444#define SECT_DATA "__data"
445#define SECT_BSS "__bss"
446#define SECT_COMMON "__common"
447#define SEG_OBJC "__OBJC"
448#define SECT_OBJC_SYMBOLS "__symbol_table"
449#define SECT_OBJC_MODULES "__module_info"
450#define SECT_OBJC_STRINGS "__selector_strs"
451#define SECT_OBJC_REFS "__selector_refs"
452#define SEG_ICON "__ICON"
453#define SECT_ICON_HEADER "__header"
454#define SECT_ICON_TIFF "__tiff"
455#define SEG_LINKEDIT "__LINKEDIT"
456#define SEG_UNIXSTACK "__UNIXSTACK"
457#define SEG_IMPORT "__IMPORT"
458
459typedef struct thread_command
460{
461 uint32_t cmd;
462 uint32_t cmdsize;
463} thread_command_t;
464
465typedef struct symtab_command
466{
467 uint32_t cmd;
468 uint32_t cmdsize;
469 uint32_t symoff;
470 uint32_t nsyms;
471 uint32_t stroff;
472 uint32_t strsize;
473} symtab_command_t;
474
475typedef struct uuid_command
476{
477 uint32_t cmd;
478 uint32_t cmdsize;
479 uint8_t uuid[16];
480} uuid_command_t;
481
482typedef struct macho_nlist_32
483{
484 union
485 {
486 int32_t n_strx;
487 } n_un;
488 uint8_t n_type;
489 uint8_t n_sect;
490 int16_t n_desc;
491 uint32_t n_value;
492} macho_nlist_32_t;
493
494
495typedef struct macho_nlist_64
496{
497 union
498 {
499 uint32_t n_strx;
500 } n_un;
501 uint8_t n_type;
502 uint8_t n_sect;
503 int16_t n_desc;
504 uint64_t n_value;
505} macho_nlist_64_t;
506
507#define MACHO_N_EXT UINT8_C(0x01)
508#define MACHO_N_PEXT UINT8_C(0x10)
509
510#define MACHO_N_TYPE UINT8_C(0x0e)
511#define MACHO_N_UNDF UINT8_C(0x00)
512#define MACHO_N_ABS UINT8_C(0x02)
513#define MACHO_N_INDR UINT8_C(0x0a)
514#define MACHO_N_PBUD UINT8_C(0x0c)
515#define MACHO_N_SECT UINT8_C(0x0e)
516
517#define MACHO_N_STAB UINT8_C(0xe0)
518#define MACHO_N_GSYM UINT8_C(0x20)
519#define MACHO_N_FNAME UINT8_C(0x22)
520#define MACHO_N_FUN UINT8_C(0x24)
521#define MACHO_N_STSYM UINT8_C(0x26)
522#define MACHO_N_LCSYM UINT8_C(0x28)
523#define MACHO_N_BNSYM UINT8_C(0x2e)
524#define MACHO_N_PC UINT8_C(0x30)
525#define MACHO_N_OPT UINT8_C(0x3c)
526#define MACHO_N_RSYM UINT8_C(0x40)
527#define MACHO_N_SLINE UINT8_C(0x44)
528#define MACHO_N_ENSYM UINT8_C(0x4e)
529#define MACHO_N_SSYM UINT8_C(0x60)
530#define MACHO_N_SO UINT8_C(0x64)
531#define MACHO_N_OSO UINT8_C(0x66)
532#define MACHO_N_LSYM UINT8_C(0x80)
533#define MACHO_N_BINCL UINT8_C(0x82)
534#define MACHO_N_SOL UINT8_C(0x84)
535#define MACHO_N_PARAMS UINT8_C(0x86)
536#define MACHO_N_VERSION UINT8_C(0x88)
537#define MACHO_N_OLEVEL UINT8_C(0x8A)
538#define MACHO_N_PSYM UINT8_C(0xa0)
539#define MACHO_N_EINCL UINT8_C(0xa2)
540#define MACHO_N_ENTRY UINT8_C(0xa4)
541#define MACHO_N_LBRAC UINT8_C(0xc0)
542#define MACHO_N_EXCL UINT8_C(0xc2)
543#define MACHO_N_RBRAC UINT8_C(0xe0)
544#define MACHO_N_BCOMM UINT8_C(0xe2)
545#define MACHO_N_ECOMM UINT8_C(0xe4)
546#define MACHO_N_ECOML UINT8_C(0xe8)
547#define MACHO_N_LENG UINT8_C(0xfe)
548
549#define MACHO_NO_SECT UINT8_C(0x00)
550#define MACHO_MAX_SECT UINT8_C(0xff)
551
552#define REFERENCE_TYPE UINT16_C(0x000f)
553#define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0
554#define REFERENCE_FLAG_UNDEFINED_LAZY 1
555#define REFERENCE_FLAG_DEFINED 2
556#define REFERENCE_FLAG_PRIVATE_DEFINED 3
557#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4
558#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5
559#define REFERENCED_DYNAMICALLY UINT16_C(0x0010)
560
561#define GET_LIBRARY_ORDINAL(a_n_desc) \
562 RT_BYTE2(a_n_desc)
563#define SET_LIBRARY_ORDINAL(a_n_desc, a_ordinal) \
564 do { (a_n_desc) = RT_MAKE_U16(RT_BYTE1(a_n_desc), a_ordinal); } while (0)
565
566#define SELF_LIBRARY_ORDINAL 0x00
567#define MAX_LIBRARY_ORDINAL 0xfd
568#define DYNAMIC_LOOKUP_ORDINAL 0xfe
569#define EXECUTABLE_ORDINAL 0xff
570
571#define N_NO_DEAD_STRIP UINT16_C(0x0020)
572#define N_DESC_DISCARDED UINT16_C(0x0020)
573#define N_WEAK_REF UINT16_C(0x0040)
574#define N_WEAK_DEF UINT16_C(0x0080)
575#define N_REF_TO_WEAK UINT16_C(0x0080)
576#define N_SYMBOL_RESOLVER UINT16_C(0x0100)
577#define N_ALT_ENTRY UINT16_C(0x0200)
578
579typedef struct macho_relocation_info
580{
581 int32_t r_address;
582 uint32_t r_symbolnum : 24;
583 uint32_t r_pcrel : 1;
584 uint32_t r_length : 2;
585 uint32_t r_extern : 1;
586 uint32_t r_type : 4;
587} macho_relocation_info_t;
588
589#define R_ABS 0
590#define R_SCATTERED UINT32_C(0x80000000)
591
592typedef struct scattered_relocation_info
593{
594#ifdef RT_LITTLE_ENDIAN
595 uint32_t r_address : 24;
596 uint32_t r_type : 4;
597 uint32_t r_length : 2;
598 uint32_t r_pcrel : 1;
599 uint32_t r_scattered : 1;
600#elif defined(RT_BIG_ENDIAN)
601 uint32_t r_scattered : 1;
602 uint32_t r_pcrel : 1;
603 uint32_t r_length : 2;
604 uint32_t r_type : 4;
605 uint32_t r_address : 24;
606#else
607# error "Neither K_ENDIAN isn't LITTLE or BIG!"
608#endif
609 int32_t r_value;
610} scattered_relocation_info_t;
611
612typedef enum reloc_type_generic
613{
614 GENERIC_RELOC_VANILLA = 0,
615 GENERIC_RELOC_PAIR,
616 GENERIC_RELOC_SECTDIFF,
617 GENERIC_RELOC_PB_LA_PTR,
618 GENERIC_RELOC_LOCAL_SECTDIFF
619} reloc_type_generic_t;
620
621typedef enum reloc_type_x86_64
622{
623 X86_64_RELOC_UNSIGNED = 0,
624 X86_64_RELOC_SIGNED,
625 X86_64_RELOC_BRANCH,
626 X86_64_RELOC_GOT_LOAD,
627 X86_64_RELOC_GOT,
628 X86_64_RELOC_SUBTRACTOR,
629 X86_64_RELOC_SIGNED_1,
630 X86_64_RELOC_SIGNED_2,
631 X86_64_RELOC_SIGNED_4
632} reloc_type_x86_64_t;
633
634#endif
635
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette