VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/ldrMach-O.h@ 44528

Last change on this file since 44528 was 43192, checked in by vboxsync, 12 years ago

typo

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.6 KB
Line 
1/* $Id: ldrMach-O.h 43192 2012-09-05 10:05:20Z vboxsync $ */
2/** @file
3 * IPRT - Mach-O Structures and Constants.
4 */
5
6/*
7 * Copyright (C) 2011-2012 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
231/* mach_header_* flags */
232#define MH_NOUNDEFS UINT32_C(0x00000001)
233#define MH_INCRLINK UINT32_C(0x00000002)
234#define MH_DYLDLINK UINT32_C(0x00000004)
235#define MH_BINDATLOAD UINT32_C(0x00000008)
236#define MH_PREBOUND UINT32_C(0x00000010)
237#define MH_SPLIT_SEGS UINT32_C(0x00000020)
238#define MH_LAZY_INIT UINT32_C(0x00000040)
239#define MH_TWOLEVEL UINT32_C(0x00000080)
240#define MH_FORCE_FLAT UINT32_C(0x00000100)
241#define MH_NOMULTIDEFS UINT32_C(0x00000200)
242#define MH_NOFIXPREBINDING UINT32_C(0x00000400)
243#define MH_PREBINDABLE UINT32_C(0x00000800)
244#define MH_ALLMODSBOUND UINT32_C(0x00001000)
245#define MH_SUBSECTIONS_VIA_SYMBOLS UINT32_C(0x00002000)
246#define MH_CANONICAL UINT32_C(0x00004000)
247#define MH_WEAK_DEFINES UINT32_C(0x00008000)
248#define MH_BINDS_TO_WEAK UINT32_C(0x00010000)
249#define MH_ALLOW_STACK_EXECUTION UINT32_C(0x00020000)
250#define MH_ROOT_SAFE UINT32_C(0x00040000)
251#define MH_SETUID_SAFE UINT32_C(0x00080000)
252#define MH_NO_REEXPORTED_DYLIBS UINT32_C(0x00100000)
253#define MH_PIE UINT32_C(0x00200000)
254#define MH_DEAD_STRIPPABLE_DYLIB UINT32_C(0x00400000)
255#define MH_HAS_TLV_DESCRIPTORS UINT32_C(0x00800000)
256#define MH_NO_HEAP_EXECUTION UINT32_C(0x01000000)
257#define MH_VALID_FLAGS UINT32_C(0x01ffffff)
258
259
260typedef struct load_command
261{
262 uint32_t cmd;
263 uint32_t cmdsize;
264} load_command_t;
265
266/* load cmd */
267#define LC_REQ_DYLD UINT32_C(0x80000000)
268#define LC_SEGMENT_32 UINT32_C(0x01)
269#define LC_SYMTAB UINT32_C(0x02)
270#define LC_SYMSEG UINT32_C(0x03)
271#define LC_THREAD UINT32_C(0x04)
272#define LC_UNIXTHREAD UINT32_C(0x05)
273#define LC_LOADFVMLIB UINT32_C(0x06)
274#define LC_IDFVMLIB UINT32_C(0x07)
275#define LC_IDENT UINT32_C(0x08)
276#define LC_FVMFILE UINT32_C(0x09)
277#define LC_PREPAGE UINT32_C(0x0a)
278#define LC_DYSYMTAB UINT32_C(0x0b)
279#define LC_LOAD_DYLIB UINT32_C(0x0c)
280#define LC_ID_DYLIB UINT32_C(0x0d)
281#define LC_LOAD_DYLINKER UINT32_C(0x0e)
282#define LC_ID_DYLINKER UINT32_C(0x0f)
283#define LC_PREBOUND_DYLIB UINT32_C(0x10)
284#define LC_ROUTINES UINT32_C(0x11)
285#define LC_SUB_FRAMEWORK UINT32_C(0x12)
286#define LC_SUB_UMBRELLA UINT32_C(0x13)
287#define LC_SUB_CLIENT UINT32_C(0x14)
288#define LC_SUB_LIBRARY UINT32_C(0x15)
289#define LC_TWOLEVEL_HINTS UINT32_C(0x16)
290#define LC_PREBIND_CKSUM UINT32_C(0x17)
291#define LC_LOAD_WEAK_DYLIB (UINT32_C(0x18) | LC_REQ_DYLD)
292#define LC_SEGMENT_64 UINT32_C(0x19)
293#define LC_ROUTINES_64 UINT32_C(0x1a)
294#define LC_UUID UINT32_C(0x1b)
295#define LC_RPATH (UINT32_C(0x1c) | LC_REQ_DYLD)
296#define LC_CODE_SIGNATURE UINT32_C(0x1d)
297#define LC_SEGMENT_SPLIT_INFO UINT32_C(0x1e)
298#define LC_REEXPORT_DYLIB (UINT32_C(0x1f) | LC_REQ_DYLD)
299#define LC_LAZY_LOAD_DYLIB UINT32_C(0x20)
300#define LC_ENCRYPTION_INFO UINT32_C(0x21)
301#define LC_DYLD_INFO UINT32_C(0x22)
302#define LC_DYLD_INFO_ONLY (UINT32_C(0x22) | LC_REQ_DYLD)
303#define LC_LOAD_UPWARD_DYLIB (UINT32_C(0x23) | LC_REQ_DYLD)
304#define LC_VERSION_MIN_MACOSX UINT32_C(0x24)
305#define LC_VERSION_MIN_IPHONEOS UINT32_C(0x25)
306#define LC_FUNCTION_STARTS UINT32_C(0x26)
307#define LC_DYLD_ENVIRONMENT UINT32_C(0x27)
308#define LC_MAIN (UINT32_C(0x28) | LC_REQ_DYLD)
309#define LC_DATA_IN_CODE UINT32_C(0x29)
310#define LC_SOURCE_VERSION UINT32_C(0x2a)
311#define LC_DYLIB_CODE_SIGN_DRS UINT32_C(0x2b)
312
313
314typedef struct lc_str
315{
316 uint32_t offset;
317} lc_str_t;
318
319typedef struct segment_command_32
320{
321 uint32_t cmd;
322 uint32_t cmdsize;
323 char segname[16];
324 uint32_t vmaddr;
325 uint32_t vmsize;
326 uint32_t fileoff;
327 uint32_t filesize;
328 uint32_t maxprot;
329 uint32_t initprot;
330 uint32_t nsects;
331 uint32_t flags;
332} segment_command_32_t;
333
334typedef struct segment_command_64
335{
336 uint32_t cmd;
337 uint32_t cmdsize;
338 char segname[16];
339 uint64_t vmaddr;
340 uint64_t vmsize;
341 uint64_t fileoff;
342 uint64_t filesize;
343 uint32_t maxprot;
344 uint32_t initprot;
345 uint32_t nsects;
346 uint32_t flags;
347} segment_command_64_t;
348
349/* segment flags */
350#define SG_HIGHVM UINT32_C(0x00000001)
351#define SG_FVMLIB UINT32_C(0x00000002)
352#define SG_NORELOC UINT32_C(0x00000004)
353#define SG_PROTECTED_VERSION_1 UINT32_C(0x00000008)
354
355/* maxprot/initprot */
356#ifndef VM_PROT_NONE
357# define VM_PROT_NONE UINT32_C(0x00000000)
358# define VM_PROT_READ UINT32_C(0x00000001)
359# define VM_PROT_WRITE UINT32_C(0x00000002)
360# define VM_PROT_EXECUTE UINT32_C(0x00000004)
361# define VM_PROT_ALL UINT32_C(0x00000007)
362#endif
363
364typedef struct section_32
365{
366 char sectname[16];
367 char segname[16];
368 uint32_t addr;
369 uint32_t size;
370 uint32_t offset;
371 uint32_t align;
372 uint32_t reloff;
373 uint32_t nreloc;
374 uint32_t flags;
375 uint32_t reserved1;
376 uint32_t reserved2;
377} section_32_t;
378
379typedef struct section_64
380{
381 char sectname[16];
382 char segname[16];
383 uint64_t addr;
384 uint64_t size;
385 uint32_t offset;
386 uint32_t align;
387 uint32_t reloff;
388 uint32_t nreloc;
389 uint32_t flags;
390 uint32_t reserved1;
391 uint32_t reserved2;
392 uint32_t reserved3;
393} section_64_t;
394
395/* section flags */
396#define SECTION_TYPE UINT32_C(0x000000ff)
397#define S_REGULAR 0x0
398#define S_ZEROFILL 0x1
399#define S_CSTRING_LITERALS 0x2
400#define S_4BYTE_LITERALS 0x3
401#define S_8BYTE_LITERALS 0x4
402#define S_LITERAL_POINTERS 0x5
403#define S_NON_LAZY_SYMBOL_POINTERS 0x6
404#define S_LAZY_SYMBOL_POINTERS 0x7
405#define S_SYMBOL_STUBS 0x8
406#define S_MOD_INIT_FUNC_POINTERS 0x9
407#define S_MOD_TERM_FUNC_POINTERS 0xa
408#define S_COALESCED 0xb
409#define S_GB_ZEROFILL 0xc
410#define S_INTERPOSING 0xd
411#define S_16BYTE_LITERALS 0xe
412#define S_DTRACE_DOF 0xf
413#define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10
414
415#define SECTION_ATTRIBUTES UINT32_C(0xffffff00)
416#define SECTION_ATTRIBUTES_USR UINT32_C(0xff000000)
417#define S_ATTR_PURE_INSTRUCTIONS UINT32_C(0x80000000)
418#define S_ATTR_NO_TOC UINT32_C(0x40000000)
419#define S_ATTR_STRIP_STATIC_SYMS UINT32_C(0x20000000)
420#define S_ATTR_NO_DEAD_STRIP UINT32_C(0x10000000)
421#define S_ATTR_LIVE_SUPPORT UINT32_C(0x08000000)
422#define S_ATTR_SELF_MODIFYING_CODE UINT32_C(0x04000000)
423#define S_ATTR_DEBUG UINT32_C(0x02000000)
424#define SECTION_ATTRIBUTES_SYS UINT32_C(0x00ffff00)
425#define S_ATTR_SOME_INSTRUCTIONS UINT32_C(0x00000400)
426#define S_ATTR_EXT_RELOC UINT32_C(0x00000200)
427#define S_ATTR_LOC_RELOC UINT32_C(0x00000100)
428
429/* standard section names */
430#define SEG_PAGEZERO "__PAGEZERO"
431#define SEG_TEXT "__TEXT"
432#define SECT_TEXT "__text"
433#define SECT_FVMLIB_INIT0 "__fvmlib_init0"
434#define SECT_FVMLIB_INIT1 "__fvmlib_init1"
435#define SEG_DATA "__DATA"
436#define SECT_DATA "__data"
437#define SECT_BSS "__bss"
438#define SECT_COMMON "__common"
439#define SEG_OBJC "__OBJC"
440#define SECT_OBJC_SYMBOLS "__symbol_table"
441#define SECT_OBJC_MODULES "__module_info"
442#define SECT_OBJC_STRINGS "__selector_strs"
443#define SECT_OBJC_REFS "__selector_refs"
444#define SEG_ICON "__ICON"
445#define SECT_ICON_HEADER "__header"
446#define SECT_ICON_TIFF "__tiff"
447#define SEG_LINKEDIT "__LINKEDIT"
448#define SEG_UNIXSTACK "__UNIXSTACK"
449#define SEG_IMPORT "__IMPORT"
450
451typedef struct thread_command
452{
453 uint32_t cmd;
454 uint32_t cmdsize;
455} thread_command_t;
456
457typedef struct symtab_command
458{
459 uint32_t cmd;
460 uint32_t cmdsize;
461 uint32_t symoff;
462 uint32_t nsyms;
463 uint32_t stroff;
464 uint32_t strsize;
465} symtab_command_t;
466
467typedef struct uuid_command
468{
469 uint32_t cmd;
470 uint32_t cmdsize;
471 uint8_t uuid[16];
472} uuid_command_t;
473
474typedef struct macho_nlist_32
475{
476 union
477 {
478 int32_t n_strx;
479 } n_un;
480 uint8_t n_type;
481 uint8_t n_sect;
482 int16_t n_desc;
483 uint32_t n_value;
484} macho_nlist_32_t;
485
486
487typedef struct macho_nlist_64
488{
489 union
490 {
491 uint32_t n_strx;
492 } n_un;
493 uint8_t n_type;
494 uint8_t n_sect;
495 int16_t n_desc;
496 uint64_t n_value;
497} macho_nlist_64_t;
498
499#define MACHO_N_EXT UINT8_C(0x01)
500#define MACHO_N_PEXT UINT8_C(0x10)
501
502#define MACHO_N_TYPE UINT8_C(0x0e)
503#define MACHO_N_UNDF UINT8_C(0x00)
504#define MACHO_N_ABS UINT8_C(0x02)
505#define MACHO_N_INDR UINT8_C(0x0a)
506#define MACHO_N_PBUD UINT8_C(0x0c)
507#define MACHO_N_SECT UINT8_C(0x0e)
508
509#define MACHO_N_STAB UINT8_C(0xe0)
510#define MACHO_N_GSYM UINT8_C(0x20)
511#define MACHO_N_FNAME UINT8_C(0x22)
512#define MACHO_N_FUN UINT8_C(0x24)
513#define MACHO_N_STSYM UINT8_C(0x26)
514#define MACHO_N_LCSYM UINT8_C(0x28)
515#define MACHO_N_BNSYM UINT8_C(0x2e)
516#define MACHO_N_PC UINT8_C(0x30)
517#define MACHO_N_OPT UINT8_C(0x3c)
518#define MACHO_N_RSYM UINT8_C(0x40)
519#define MACHO_N_SLINE UINT8_C(0x44)
520#define MACHO_N_ENSYM UINT8_C(0x4e)
521#define MACHO_N_SSYM UINT8_C(0x60)
522#define MACHO_N_SO UINT8_C(0x64)
523#define MACHO_N_OSO UINT8_C(0x66)
524#define MACHO_N_LSYM UINT8_C(0x80)
525#define MACHO_N_BINCL UINT8_C(0x82)
526#define MACHO_N_SOL UINT8_C(0x84)
527#define MACHO_N_PARAMS UINT8_C(0x86)
528#define MACHO_N_VERSION UINT8_C(0x88)
529#define MACHO_N_OLEVEL UINT8_C(0x8A)
530#define MACHO_N_PSYM UINT8_C(0xa0)
531#define MACHO_N_EINCL UINT8_C(0xa2)
532#define MACHO_N_ENTRY UINT8_C(0xa4)
533#define MACHO_N_LBRAC UINT8_C(0xc0)
534#define MACHO_N_EXCL UINT8_C(0xc2)
535#define MACHO_N_RBRAC UINT8_C(0xe0)
536#define MACHO_N_BCOMM UINT8_C(0xe2)
537#define MACHO_N_ECOMM UINT8_C(0xe4)
538#define MACHO_N_ECOML UINT8_C(0xe8)
539#define MACHO_N_LENG UINT8_C(0xfe)
540
541#define MACHO_NO_SECT UINT8_C(0x00)
542#define MACHO_MAX_SECT UINT8_C(0xff)
543
544#define REFERENCE_TYPE UINT16_C(0x000f)
545#define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0
546#define REFERENCE_FLAG_UNDEFINED_LAZY 1
547#define REFERENCE_FLAG_DEFINED 2
548#define REFERENCE_FLAG_PRIVATE_DEFINED 3
549#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4
550#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5
551#define REFERENCED_DYNAMICALLY UINT16_C(0x0010)
552
553#define GET_LIBRARY_ORDINAL(a_n_desc) \
554 RT_BYTE2(a_n_desc)
555#define SET_LIBRARY_ORDINAL(a_n_desc, a_ordinal) \
556 do { (a_n_desc) = RT_MAKE_U16(RT_BYTE1(a_n_desc), a_ordinal); } while (0)
557
558#define SELF_LIBRARY_ORDINAL 0x00
559#define MAX_LIBRARY_ORDINAL 0xfd
560#define DYNAMIC_LOOKUP_ORDINAL 0xfe
561#define EXECUTABLE_ORDINAL 0xff
562
563#define N_NO_DEAD_STRIP UINT16_C(0x0020)
564#define N_DESC_DISCARDED UINT16_C(0x0020)
565#define N_WEAK_REF UINT16_C(0x0040)
566#define N_WEAK_DEF UINT16_C(0x0080)
567#define N_REF_TO_WEAK UINT16_C(0x0080)
568
569typedef struct macho_relocation_info
570{
571 int32_t r_address;
572 uint32_t r_symbolnum : 24;
573 uint32_t r_pcrel : 1;
574 uint32_t r_length : 2;
575 uint32_t r_extern : 1;
576 uint32_t r_type : 4;
577} macho_relocation_info_t;
578
579#define R_ABS 0
580#define R_SCATTERED UINT32_C(0x80000000)
581
582typedef struct scattered_relocation_info
583{
584#ifdef RT_LITTLE_ENDIAN
585 uint32_t r_address : 24;
586 uint32_t r_type : 4;
587 uint32_t r_length : 2;
588 uint32_t r_pcrel : 1;
589 uint32_t r_scattered : 1;
590#elif defined(RT_BIG_ENDIAN)
591 uint32_t r_scattered : 1;
592 uint32_t r_pcrel : 1;
593 uint32_t r_length : 2;
594 uint32_t r_type : 4;
595 uint32_t r_address : 24;
596#else
597# error "Neither K_ENDIAN isn't LITTLE or BIG!"
598#endif
599 int32_t r_value;
600} scattered_relocation_info_t;
601
602typedef enum reloc_type_generic
603{
604 GENERIC_RELOC_VANILLA = 0,
605 GENERIC_RELOC_PAIR,
606 GENERIC_RELOC_SECTDIFF,
607 GENERIC_RELOC_PB_LA_PTR,
608 GENERIC_RELOC_LOCAL_SECTDIFF
609} reloc_type_generic_t;
610
611typedef enum reloc_type_x86_64
612{
613 X86_64_RELOC_UNSIGNED = 0,
614 X86_64_RELOC_SIGNED,
615 X86_64_RELOC_BRANCH,
616 X86_64_RELOC_GOT_LOAD,
617 X86_64_RELOC_GOT,
618 X86_64_RELOC_SUBTRACTOR,
619 X86_64_RELOC_SIGNED_1,
620 X86_64_RELOC_SIGNED_2,
621 X86_64_RELOC_SIGNED_4
622} reloc_type_x86_64_t;
623
624#endif
625
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