loader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2010 Apple Inc. All Rights Reserved.
3  *
4  * @APPLE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. Please obtain a copy of the License at
10  * http://www.opensource.apple.com/apsl/ and read it before using this
11  * file.
12  *
13  * The Original Code and all software distributed under the License are
14  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18  * Please see the License for the specific language governing rights and
19  * limitations under the License.
20  *
21  * @APPLE_LICENSE_HEADER_END@
22  */
23 #ifndef _MACHO_LOADER_H_
24 #define _MACHO_LOADER_H_
25 
26 /*
27  * This file describes the format of mach object files.
28  */
29 #include <stdint.h>
30 
31 /*
32  * <mach/machine.h> is needed here for the cpu_type_t and cpu_subtype_t types
33  * and contains the constants for the possible values of these types.
34  */
36 
37 /*
38  * <mach/vm_prot.h> is needed here for the vm_prot_t type and contains the
39  * constants that are or'ed together for the possible values of this type.
40  */
42 
43 /*
44  * The 32-bit mach header appears at the very beginning of the object file for
45  * 32-bit architectures.
46  */
47 struct mach_header {
48  uint32_t magic; /* mach magic number identifier */
49  cpu_type_t cputype; /* cpu specifier */
50  cpu_subtype_t cpusubtype; /* machine specifier */
51  uint32_t filetype; /* type of file */
52  uint32_t ncmds; /* number of load commands */
53  uint32_t sizeofcmds; /* the size of all the load commands */
54  uint32_t flags; /* flags */
55 };
56 
57 /* Constant for the magic field of the mach_header (32-bit architectures) */
58 #define MH_MAGIC 0xfeedface /* the mach magic number */
59 #define MH_CIGAM 0xcefaedfe /* NXSwapInt(MH_MAGIC) */
60 
61 /*
62  * The 64-bit mach header appears at the very beginning of object files for
63  * 64-bit architectures.
64  */
66  uint32_t magic; /* mach magic number identifier */
67  cpu_type_t cputype; /* cpu specifier */
68  cpu_subtype_t cpusubtype; /* machine specifier */
69  uint32_t filetype; /* type of file */
70  uint32_t ncmds; /* number of load commands */
71  uint32_t sizeofcmds; /* the size of all the load commands */
72  uint32_t flags; /* flags */
73  uint32_t reserved; /* reserved */
74 };
75 
76 /* Constant for the magic field of the mach_header_64 (64-bit architectures) */
77 #define MH_MAGIC_64 0xfeedfacf /* the 64-bit mach magic number */
78 #define MH_CIGAM_64 0xcffaedfe /* NXSwapInt(MH_MAGIC_64) */
79 
80 /*
81  * The layout of the file depends on the filetype. For all but the MH_OBJECT
82  * file type the segments are padded out and aligned on a segment alignment
83  * boundary for efficient demand pageing. The MH_EXECUTE, MH_FVMLIB, MH_DYLIB,
84  * MH_DYLINKER and MH_BUNDLE file types also have the headers included as part
85  * of their first segment.
86  *
87  * The file type MH_OBJECT is a compact format intended as output of the
88  * assembler and input (and possibly output) of the link editor (the .o
89  * format). All sections are in one unnamed segment with no segment padding.
90  * This format is used as an executable format when the file is so small the
91  * segment padding greatly increases its size.
92  *
93  * The file type MH_PRELOAD is an executable format intended for things that
94  * are not executed under the kernel (proms, stand alones, kernels, etc). The
95  * format can be executed under the kernel but may demand paged it and not
96  * preload it before execution.
97  *
98  * A core file is in MH_CORE format and can be any in an arbritray legal
99  * Mach-O file.
100  *
101  * Constants for the filetype field of the mach_header
102  */
103 #define MH_OBJECT 0x1 /* relocatable object file */
104 #define MH_EXECUTE 0x2 /* demand paged executable file */
105 #define MH_FVMLIB 0x3 /* fixed VM shared library file */
106 #define MH_CORE 0x4 /* core file */
107 #define MH_PRELOAD 0x5 /* preloaded executable file */
108 #define MH_DYLIB 0x6 /* dynamically bound shared library */
109 #define MH_DYLINKER 0x7 /* dynamic link editor */
110 #define MH_BUNDLE 0x8 /* dynamically bound bundle file */
111 #define MH_DYLIB_STUB 0x9 /* shared library stub for static */
112  /* linking only, no section contents */
113 #define MH_DSYM 0xa /* companion file with only debug */
114  /* sections */
115 #define MH_KEXT_BUNDLE 0xb /* x86_64 kexts */
116 
117 /* Constants for the flags field of the mach_header */
118 #define MH_NOUNDEFS 0x1 /* the object file has no undefined
119  references */
120 #define MH_INCRLINK 0x2 /* the object file is the output of an
121  incremental link against a base file
122  and can't be link edited again */
123 #define MH_DYLDLINK 0x4 /* the object file is input for the
124  dynamic linker and can't be staticly
125  link edited again */
126 #define MH_BINDATLOAD 0x8 /* the object file's undefined
127  references are bound by the dynamic
128  linker when loaded. */
129 #define MH_PREBOUND 0x10 /* the file has its dynamic undefined
130  references prebound. */
131 #define MH_SPLIT_SEGS 0x20 /* the file has its read-only and
132  read-write segments split */
133 #define MH_LAZY_INIT 0x40 /* the shared library init routine is
134  to be run lazily via catching memory
135  faults to its writeable segments
136  (obsolete) */
137 #define MH_TWOLEVEL 0x80 /* the image is using two-level name
138  space bindings */
139 #define MH_FORCE_FLAT 0x100 /* the executable is forcing all images
140  to use flat name space bindings */
141 #define MH_NOMULTIDEFS 0x200 /* this umbrella guarantees no multiple
142  defintions of symbols in its
143  sub-images so the two-level namespace
144  hints can always be used. */
145 #define MH_NOFIXPREBINDING 0x400 /* do not have dyld notify the
146  prebinding agent about this
147  executable */
148 #define MH_PREBINDABLE 0x800 /* the binary is not prebound but can
149  have its prebinding redone. only used
150  when MH_PREBOUND is not set. */
151 #define MH_ALLMODSBOUND 0x1000 /* indicates that this binary binds to
152  all two-level namespace modules of
153  its dependent libraries. only used
154  when MH_PREBINDABLE and MH_TWOLEVEL
155  are both set. */
156 #define MH_SUBSECTIONS_VIA_SYMBOLS 0x2000/* safe to divide up the sections into
157  sub-sections via symbols for dead
158  code stripping */
159 #define MH_CANONICAL 0x4000 /* the binary has been canonicalized
160  via the unprebind operation */
161 #define MH_WEAK_DEFINES 0x8000 /* the final linked image contains
162  external weak symbols */
163 #define MH_BINDS_TO_WEAK 0x10000 /* the final linked image uses
164  weak symbols */
165 
166 #define MH_ALLOW_STACK_EXECUTION 0x20000/* When this bit is set, all stacks
167  in the task will be given stack
168  execution privilege. Only used in
169  MH_EXECUTE filetypes. */
170 #define MH_ROOT_SAFE 0x40000 /* When this bit is set, the binary
171  declares it is safe for use in
172  processes with uid zero */
173 
174 #define MH_SETUID_SAFE 0x80000 /* When this bit is set, the binary
175  declares it is safe for use in
176  processes when issetugid() is true */
177 
178 #define MH_NO_REEXPORTED_DYLIBS 0x100000 /* When this bit is set on a dylib,
179  the static linker does not need to
180  examine dependent dylibs to see
181  if any are re-exported */
182 #define MH_PIE 0x200000 /* When this bit is set, the OS will
183  load the main executable at a
184  random address. Only used in
185  MH_EXECUTE filetypes. */
186 #define MH_DEAD_STRIPPABLE_DYLIB 0x400000 /* Only for use on dylibs. When
187  linking against a dylib that
188  has this bit set, the static linker
189  will automatically not create a
190  LC_LOAD_DYLIB load command to the
191  dylib if no symbols are being
192  referenced from the dylib. */
193 #define MH_HAS_TLV_DESCRIPTORS 0x800000 /* Contains a section of type
194  S_THREAD_LOCAL_VARIABLES */
195 
196 #define MH_NO_HEAP_EXECUTION 0x1000000 /* When this bit is set, the OS will
197  run the main executable with
198  a non-executable heap even on
199  platforms (e.g. i386) that don't
200  require it. Only used in MH_EXECUTE
201  filetypes. */
202 
203 #define MH_APP_EXTENSION_SAFE 0x02000000 /* The code was linked for use in an
204  application extension. */
205 
206 /*
207  * The load commands directly follow the mach_header. The total size of all
208  * of the commands is given by the sizeofcmds field in the mach_header. All
209  * load commands must have as their first two fields cmd and cmdsize. The cmd
210  * field is filled in with a constant for that command type. Each command type
211  * has a structure specifically for it. The cmdsize field is the size in bytes
212  * of the particular load command structure plus anything that follows it that
213  * is a part of the load command (i.e. section structures, strings, etc.). To
214  * advance to the next load command the cmdsize can be added to the offset or
215  * pointer of the current load command. The cmdsize for 32-bit architectures
216  * MUST be a multiple of 4 bytes and for 64-bit architectures MUST be a multiple
217  * of 8 bytes (these are forever the maximum alignment of any load commands).
218  * The padded bytes must be zero. All tables in the object file must also
219  * follow these rules so the file can be memory mapped. Otherwise the pointers
220  * to these tables will not work well or at all on some machines. With all
221  * padding zeroed like objects will compare byte for byte.
222  */
223 struct load_command {
224  uint32_t cmd; /* type of load command */
225  uint32_t cmdsize; /* total size of command in bytes */
226 };
227 
228 /*
229  * After MacOS X 10.1 when a new load command is added that is required to be
230  * understood by the dynamic linker for the image to execute properly the
231  * LC_REQ_DYLD bit will be or'ed into the load command constant. If the dynamic
232  * linker sees such a load command it it does not understand will issue a
233  * "unknown load command required for execution" error and refuse to use the
234  * image. Other load commands without this bit that are not understood will
235  * simply be ignored.
236  */
237 #define LC_REQ_DYLD 0x80000000
238 
239 /* Constants for the cmd field of all load commands, the type */
240 #define LC_SEGMENT 0x1 /* segment of this file to be mapped */
241 #define LC_SYMTAB 0x2 /* link-edit stab symbol table info */
242 #define LC_SYMSEG 0x3 /* link-edit gdb symbol table info (obsolete) */
243 #define LC_THREAD 0x4 /* thread */
244 #define LC_UNIXTHREAD 0x5 /* unix thread (includes a stack) */
245 #define LC_LOADFVMLIB 0x6 /* load a specified fixed VM shared library */
246 #define LC_IDFVMLIB 0x7 /* fixed VM shared library identification */
247 #define LC_IDENT 0x8 /* object identification info (obsolete) */
248 #define LC_FVMFILE 0x9 /* fixed VM file inclusion (internal use) */
249 #define LC_PREPAGE 0xa /* prepage command (internal use) */
250 #define LC_DYSYMTAB 0xb /* dynamic link-edit symbol table info */
251 #define LC_LOAD_DYLIB 0xc /* load a dynamically linked shared library */
252 #define LC_ID_DYLIB 0xd /* dynamically linked shared lib ident */
253 #define LC_LOAD_DYLINKER 0xe /* load a dynamic linker */
254 #define LC_ID_DYLINKER 0xf /* dynamic linker identification */
255 #define LC_PREBOUND_DYLIB 0x10 /* modules prebound for a dynamically */
256  /* linked shared library */
257 #define LC_ROUTINES 0x11 /* image routines */
258 #define LC_SUB_FRAMEWORK 0x12 /* sub framework */
259 #define LC_SUB_UMBRELLA 0x13 /* sub umbrella */
260 #define LC_SUB_CLIENT 0x14 /* sub client */
261 #define LC_SUB_LIBRARY 0x15 /* sub library */
262 #define LC_TWOLEVEL_HINTS 0x16 /* two-level namespace lookup hints */
263 #define LC_PREBIND_CKSUM 0x17 /* prebind checksum */
264 
265 /*
266  * load a dynamically linked shared library that is allowed to be missing
267  * (all symbols are weak imported).
268  */
269 #define LC_LOAD_WEAK_DYLIB (0x18 | LC_REQ_DYLD)
270 
271 #define LC_SEGMENT_64 0x19 /* 64-bit segment of this file to be
272  mapped */
273 #define LC_ROUTINES_64 0x1a /* 64-bit image routines */
274 #define LC_UUID 0x1b /* the uuid */
275 #define LC_RPATH (0x1c | LC_REQ_DYLD) /* runpath additions */
276 #define LC_CODE_SIGNATURE 0x1d /* local of code signature */
277 #define LC_SEGMENT_SPLIT_INFO 0x1e /* local of info to split segments */
278 #define LC_REEXPORT_DYLIB (0x1f | LC_REQ_DYLD) /* load and re-export dylib */
279 #define LC_LAZY_LOAD_DYLIB 0x20 /* delay load of dylib until first use */
280 #define LC_ENCRYPTION_INFO 0x21 /* encrypted segment information */
281 #define LC_DYLD_INFO 0x22 /* compressed dyld information */
282 #define LC_DYLD_INFO_ONLY (0x22|LC_REQ_DYLD) /* compressed dyld information only */
283 #define LC_LOAD_UPWARD_DYLIB (0x23 | LC_REQ_DYLD) /* load upward dylib */
284 #define LC_VERSION_MIN_MACOSX 0x24 /* build for MacOSX min OS version */
285 #define LC_VERSION_MIN_IPHONEOS 0x25 /* build for iPhoneOS min OS version */
286 #define LC_FUNCTION_STARTS 0x26 /* compressed table of function start addresses */
287 #define LC_DYLD_ENVIRONMENT 0x27 /* string for dyld to treat
288  like environment variable */
289 #define LC_MAIN (0x28|LC_REQ_DYLD) /* replacement for LC_UNIXTHREAD */
290 #define LC_DATA_IN_CODE 0x29 /* table of non-instructions in __text */
291 #define LC_SOURCE_VERSION 0x2A /* source version used to build binary */
292 #define LC_DYLIB_CODE_SIGN_DRS 0x2B /* Code signing DRs copied from linked dylibs */
293 #define LC_ENCRYPTION_INFO_64 0x2C /* 64-bit encrypted segment information */
294 #define LC_LINKER_OPTION 0x2D /* linker options in MH_OBJECT files */
295 #define LC_LINKER_OPTIMIZATION_HINT 0x2E /* optimization hints in MH_OBJECT files */
296 #define LC_VERSION_MIN_TVOS 0x2F /* build for AppleTV min OS version */
297 #define LC_VERSION_MIN_WATCHOS 0x30 /* build for Watch min OS version */
298 #define LC_NOTE 0x31 /* arbitrary data included within a Mach-O file */
299 #define LC_BUILD_VERSION 0x32 /* build for platform min OS version */
300 
301 /*
302  * A variable length string in a load command is represented by an lc_str
303  * union. The strings are stored just after the load command structure and
304  * the offset is from the start of the load command structure. The size
305  * of the string is reflected in the cmdsize field of the load command.
306  * Once again any padded bytes to bring the cmdsize field to a multiple
307  * of 4 bytes must be zero.
308  */
309 union lc_str {
310  uint32_t offset; /* offset to the string */
311 #ifndef __LP64__
312  char *ptr; /* pointer to the string */
313 #endif
314 };
315 
316 /*
317  * The segment load command indicates that a part of this file is to be
318  * mapped into the task's address space. The size of this segment in memory,
319  * vmsize, maybe equal to or larger than the amount to map from this file,
320  * filesize. The file is mapped starting at fileoff to the beginning of
321  * the segment in memory, vmaddr. The rest of the memory of the segment,
322  * if any, is allocated zero fill on demand. The segment's maximum virtual
323  * memory protection and initial virtual memory protection are specified
324  * by the maxprot and initprot fields. If the segment has sections then the
325  * section structures directly follow the segment command and their size is
326  * reflected in cmdsize.
327  */
328 struct segment_command { /* for 32-bit architectures */
329  uint32_t cmd; /* LC_SEGMENT */
330  uint32_t cmdsize; /* includes sizeof section structs */
331  char segname[16]; /* segment name */
332  uint32_t vmaddr; /* memory address of this segment */
333  uint32_t vmsize; /* memory size of this segment */
334  uint32_t fileoff; /* file offset of this segment */
335  uint32_t filesize; /* amount to map from the file */
336  vm_prot_t maxprot; /* maximum VM protection */
337  vm_prot_t initprot; /* initial VM protection */
338  uint32_t nsects; /* number of sections in segment */
339  uint32_t flags; /* flags */
340 };
341 
342 /*
343  * The 64-bit segment load command indicates that a part of this file is to be
344  * mapped into a 64-bit task's address space. If the 64-bit segment has
345  * sections then section_64 structures directly follow the 64-bit segment
346  * command and their size is reflected in cmdsize.
347  */
348 struct segment_command_64 { /* for 64-bit architectures */
349  uint32_t cmd; /* LC_SEGMENT_64 */
350  uint32_t cmdsize; /* includes sizeof section_64 structs */
351  char segname[16]; /* segment name */
352  uint64_t vmaddr; /* memory address of this segment */
353  uint64_t vmsize; /* memory size of this segment */
354  uint64_t fileoff; /* file offset of this segment */
355  uint64_t filesize; /* amount to map from the file */
356  vm_prot_t maxprot; /* maximum VM protection */
357  vm_prot_t initprot; /* initial VM protection */
358  uint32_t nsects; /* number of sections in segment */
359  uint32_t flags; /* flags */
360 };
361 
362 /* Constants for the flags field of the segment_command */
363 #define SG_HIGHVM 0x1 /* the file contents for this segment is for
364  the high part of the VM space, the low part
365  is zero filled (for stacks in core files) */
366 #define SG_FVMLIB 0x2 /* this segment is the VM that is allocated by
367  a fixed VM library, for overlap checking in
368  the link editor */
369 #define SG_NORELOC 0x4 /* this segment has nothing that was relocated
370  in it and nothing relocated to it, that is
371  it maybe safely replaced without relocation*/
372 #define SG_PROTECTED_VERSION_1 0x8 /* This segment is protected. If the
373  segment starts at file offset 0, the
374  first page of the segment is not
375  protected. All other pages of the
376  segment are protected. */
377 
378 /*
379  * A segment is made up of zero or more sections. Non-MH_OBJECT files have
380  * all of their segments with the proper sections in each, and padded to the
381  * specified segment alignment when produced by the link editor. The first
382  * segment of a MH_EXECUTE and MH_FVMLIB format file contains the mach_header
383  * and load commands of the object file before its first section. The zero
384  * fill sections are always last in their segment (in all formats). This
385  * allows the zeroed segment padding to be mapped into memory where zero fill
386  * sections might be. The gigabyte zero fill sections, those with the section
387  * type S_GB_ZEROFILL, can only be in a segment with sections of this type.
388  * These segments are then placed after all other segments.
389  *
390  * The MH_OBJECT format has all of its sections in one segment for
391  * compactness. There is no padding to a specified segment boundary and the
392  * mach_header and load commands are not part of the segment.
393  *
394  * Sections with the same section name, sectname, going into the same segment,
395  * segname, are combined by the link editor. The resulting section is aligned
396  * to the maximum alignment of the combined sections and is the new section's
397  * alignment. The combined sections are aligned to their original alignment in
398  * the combined section. Any padded bytes to get the specified alignment are
399  * zeroed.
400  *
401  * The format of the relocation entries referenced by the reloff and nreloc
402  * fields of the section structure for mach object files is described in the
403  * header file <reloc.h>.
404  */
405 struct section { /* for 32-bit architectures */
406  char sectname[16]; /* name of this section */
407  char segname[16]; /* segment this section goes in */
408  uint32_t addr; /* memory address of this section */
409  uint32_t size; /* size in bytes of this section */
410  uint32_t offset; /* file offset of this section */
411  uint32_t align; /* section alignment (power of 2) */
412  uint32_t reloff; /* file offset of relocation entries */
413  uint32_t nreloc; /* number of relocation entries */
414  uint32_t flags; /* flags (section type and attributes)*/
415  uint32_t reserved1; /* reserved (for offset or index) */
416  uint32_t reserved2; /* reserved (for count or sizeof) */
417 };
418 
419 struct section_64 { /* for 64-bit architectures */
420  char sectname[16]; /* name of this section */
421  char segname[16]; /* segment this section goes in */
422  uint64_t addr; /* memory address of this section */
423  uint64_t size; /* size in bytes of this section */
424  uint32_t offset; /* file offset of this section */
425  uint32_t align; /* section alignment (power of 2) */
426  uint32_t reloff; /* file offset of relocation entries */
427  uint32_t nreloc; /* number of relocation entries */
428  uint32_t flags; /* flags (section type and attributes)*/
429  uint32_t reserved1; /* reserved (for offset or index) */
430  uint32_t reserved2; /* reserved (for count or sizeof) */
431  uint32_t reserved3; /* reserved */
432 };
433 
434 /*
435  * The flags field of a section structure is separated into two parts a section
436  * type and section attributes. The section types are mutually exclusive (it
437  * can only have one type) but the section attributes are not (it may have more
438  * than one attribute).
439  */
440 #define SECTION_TYPE 0x000000ff /* 256 section types */
441 #define SECTION_ATTRIBUTES 0xffffff00 /* 24 section attributes */
442 
443 /* Constants for the type of a section */
444 #define S_REGULAR 0x0 /* regular section */
445 #define S_ZEROFILL 0x1 /* zero fill on demand section */
446 #define S_CSTRING_LITERALS 0x2 /* section with only literal C strings*/
447 #define S_4BYTE_LITERALS 0x3 /* section with only 4 byte literals */
448 #define S_8BYTE_LITERALS 0x4 /* section with only 8 byte literals */
449 #define S_LITERAL_POINTERS 0x5 /* section with only pointers to */
450  /* literals */
451 /*
452  * For the two types of symbol pointers sections and the symbol stubs section
453  * they have indirect symbol table entries. For each of the entries in the
454  * section the indirect symbol table entries, in corresponding order in the
455  * indirect symbol table, start at the index stored in the reserved1 field
456  * of the section structure. Since the indirect symbol table entries
457  * correspond to the entries in the section the number of indirect symbol table
458  * entries is inferred from the size of the section divided by the size of the
459  * entries in the section. For symbol pointers sections the size of the entries
460  * in the section is 4 bytes and for symbol stubs sections the byte size of the
461  * stubs is stored in the reserved2 field of the section structure.
462  */
463 #define S_NON_LAZY_SYMBOL_POINTERS 0x6 /* section with only non-lazy
464  symbol pointers */
465 #define S_LAZY_SYMBOL_POINTERS 0x7 /* section with only lazy symbol
466  pointers */
467 #define S_SYMBOL_STUBS 0x8 /* section with only symbol
468  stubs, byte size of stub in
469  the reserved2 field */
470 #define S_MOD_INIT_FUNC_POINTERS 0x9 /* section with only function
471  pointers for initialization*/
472 #define S_MOD_TERM_FUNC_POINTERS 0xa /* section with only function
473  pointers for termination */
474 #define S_COALESCED 0xb /* section contains symbols that
475  are to be coalesced */
476 #define S_GB_ZEROFILL 0xc /* zero fill on demand section
477  (that can be larger than 4
478  gigabytes) */
479 #define S_INTERPOSING 0xd /* section with only pairs of
480  function pointers for
481  interposing */
482 #define S_16BYTE_LITERALS 0xe /* section with only 16 byte
483  literals */
484 #define S_DTRACE_DOF 0xf /* section contains
485  DTrace Object Format */
486 #define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10 /* section with only lazy
487  symbol pointers to lazy
488  loaded dylibs */
489 /*
490  * Section types to support thread local variables
491  */
492 #define S_THREAD_LOCAL_REGULAR 0x11 /* template of initial
493  values for TLVs */
494 #define S_THREAD_LOCAL_ZEROFILL 0x12 /* template of initial
495  values for TLVs */
496 #define S_THREAD_LOCAL_VARIABLES 0x13 /* TLV descriptors */
497 #define S_THREAD_LOCAL_VARIABLE_POINTERS 0x14 /* pointers to TLV
498  descriptors */
499 #define S_THREAD_LOCAL_INIT_FUNCTION_POINTERS 0x15 /* functions to call
500  to initialize TLV
501  values */
502 
503 /*
504  * Constants for the section attributes part of the flags field of a section
505  * structure.
506  */
507 #define SECTION_ATTRIBUTES_USR 0xff000000 /* User setable attributes */
508 #define S_ATTR_PURE_INSTRUCTIONS 0x80000000 /* section contains only true
509  machine instructions */
510 #define S_ATTR_NO_TOC 0x40000000 /* section contains coalesced
511  symbols that are not to be
512  in a ranlib table of
513  contents */
514 #define S_ATTR_STRIP_STATIC_SYMS 0x20000000 /* ok to strip static symbols
515  in this section in files
516  with the MH_DYLDLINK flag */
517 #define S_ATTR_NO_DEAD_STRIP 0x10000000 /* no dead stripping */
518 #define S_ATTR_LIVE_SUPPORT 0x08000000 /* blocks are live if they
519  reference live blocks */
520 #define S_ATTR_SELF_MODIFYING_CODE 0x04000000 /* Used with i386 code stubs
521  written on by dyld */
522 /*
523  * If a segment contains any sections marked with S_ATTR_DEBUG then all
524  * sections in that segment must have this attribute. No section other than
525  * a section marked with this attribute may reference the contents of this
526  * section. A section with this attribute may contain no symbols and must have
527  * a section type S_REGULAR. The static linker will not copy section contents
528  * from sections with this attribute into its output file. These sections
529  * generally contain DWARF debugging info.
530  */
531 #define S_ATTR_DEBUG 0x02000000 /* a debug section */
532 #define SECTION_ATTRIBUTES_SYS 0x00ffff00 /* system setable attributes */
533 #define S_ATTR_SOME_INSTRUCTIONS 0x00000400 /* section contains some
534  machine instructions */
535 #define S_ATTR_EXT_RELOC 0x00000200 /* section has external
536  relocation entries */
537 #define S_ATTR_LOC_RELOC 0x00000100 /* section has local
538  relocation entries */
539 
540 
541 /*
542  * The names of segments and sections in them are mostly meaningless to the
543  * link-editor. But there are few things to support traditional UNIX
544  * executables that require the link-editor and assembler to use some names
545  * agreed upon by convention.
546  *
547  * The initial protection of the "__TEXT" segment has write protection turned
548  * off (not writeable).
549  *
550  * The link-editor will allocate common symbols at the end of the "__common"
551  * section in the "__DATA" segment. It will create the section and segment
552  * if needed.
553  */
554 
555 /* The currently known segment names and the section names in those segments */
556 
557 #define SEG_PAGEZERO "__PAGEZERO" /* the pagezero segment which has no */
558  /* protections and catches NULL */
559  /* references for MH_EXECUTE files */
560 
561 
562 #define SEG_TEXT "__TEXT" /* the tradition UNIX text segment */
563 #define SECT_TEXT "__text" /* the real text part of the text */
564  /* section no headers, and no padding */
565 #define SECT_FVMLIB_INIT0 "__fvmlib_init0" /* the fvmlib initialization */
566  /* section */
567 #define SECT_FVMLIB_INIT1 "__fvmlib_init1" /* the section following the */
568  /* fvmlib initialization */
569  /* section */
570 
571 #define SEG_DATA "__DATA" /* the tradition UNIX data segment */
572 #define SECT_DATA "__data" /* the real initialized data section */
573  /* no padding, no bss overlap */
574 #define SECT_BSS "__bss" /* the real uninitialized data section*/
575  /* no padding */
576 #define SECT_COMMON "__common" /* the section common symbols are */
577  /* allocated in by the link editor */
578 
579 #define SEG_OBJC "__OBJC" /* objective-C runtime segment */
580 #define SECT_OBJC_SYMBOLS "__symbol_table" /* symbol table */
581 #define SECT_OBJC_MODULES "__module_info" /* module information */
582 #define SECT_OBJC_STRINGS "__selector_strs" /* string table */
583 #define SECT_OBJC_REFS "__selector_refs" /* string table */
584 
585 #define SEG_ICON "__ICON" /* the icon segment */
586 #define SECT_ICON_HEADER "__header" /* the icon headers */
587 #define SECT_ICON_TIFF "__tiff" /* the icons in tiff format */
588 
589 #define SEG_LINKEDIT "__LINKEDIT" /* the segment containing all structs */
590  /* created and maintained by the link */
591  /* editor. Created with -seglinkedit */
592  /* option to ld(1) for MH_EXECUTE and */
593  /* FVMLIB file types only */
594 
595 #define SEG_UNIXSTACK "__UNIXSTACK" /* the unix stack segment */
596 
597 #define SEG_IMPORT "__IMPORT" /* the segment for the self (dyld) */
598  /* modifing code stubs that has read, */
599  /* write and execute permissions */
600 
601 /*
602  * Fixed virtual memory shared libraries are identified by two things. The
603  * target pathname (the name of the library as found for execution), and the
604  * minor version number. The address of where the headers are loaded is in
605  * header_addr. (THIS IS OBSOLETE and no longer supported).
606  */
607 struct fvmlib {
608  union lc_str name; /* library's target pathname */
609  uint32_t minor_version; /* library's minor version number */
610  uint32_t header_addr; /* library's header address */
611 };
612 
613 /*
614  * A fixed virtual shared library (filetype == MH_FVMLIB in the mach header)
615  * contains a fvmlib_command (cmd == LC_IDFVMLIB) to identify the library.
616  * An object that uses a fixed virtual shared library also contains a
617  * fvmlib_command (cmd == LC_LOADFVMLIB) for each library it uses.
618  * (THIS IS OBSOLETE and no longer supported).
619  */
620 struct fvmlib_command {
621  uint32_t cmd; /* LC_IDFVMLIB or LC_LOADFVMLIB */
622  uint32_t cmdsize; /* includes pathname string */
623  struct fvmlib fvmlib; /* the library identification */
624 };
625 
626 /*
627  * Dynamicly linked shared libraries are identified by two things. The
628  * pathname (the name of the library as found for execution), and the
629  * compatibility version number. The pathname must match and the compatibility
630  * number in the user of the library must be greater than or equal to the
631  * library being used. The time stamp is used to record the time a library was
632  * built and copied into user so it can be use to determined if the library used
633  * at runtime is exactly the same as used to built the program.
634  */
635 struct dylib {
636  union lc_str name; /* library's path name */
637  uint32_t timestamp; /* library's build time stamp */
638  uint32_t current_version; /* library's current version number */
639  uint32_t compatibility_version; /* library's compatibility vers number*/
640 };
641 
642 /*
643  * A dynamically linked shared library (filetype == MH_DYLIB in the mach header)
644  * contains a dylib_command (cmd == LC_ID_DYLIB) to identify the library.
645  * An object that uses a dynamically linked shared library also contains a
646  * dylib_command (cmd == LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, or
647  * LC_REEXPORT_DYLIB) for each library it uses.
648  */
649 struct dylib_command {
650  uint32_t cmd; /* LC_ID_DYLIB, LC_LOAD_{,WEAK_}DYLIB,
651  LC_REEXPORT_DYLIB */
652  uint32_t cmdsize; /* includes pathname string */
653  struct dylib dylib; /* the library identification */
654 };
655 
656 /*
657  * A dynamically linked shared library may be a subframework of an umbrella
658  * framework. If so it will be linked with "-umbrella umbrella_name" where
659  * Where "umbrella_name" is the name of the umbrella framework. A subframework
660  * can only be linked against by its umbrella framework or other subframeworks
661  * that are part of the same umbrella framework. Otherwise the static link
662  * editor produces an error and states to link against the umbrella framework.
663  * The name of the umbrella framework for subframeworks is recorded in the
664  * following structure.
665  */
666 struct sub_framework_command {
667  uint32_t cmd; /* LC_SUB_FRAMEWORK */
668  uint32_t cmdsize; /* includes umbrella string */
669  union lc_str umbrella; /* the umbrella framework name */
670 };
671 
672 /*
673  * For dynamically linked shared libraries that are subframework of an umbrella
674  * framework they can allow clients other than the umbrella framework or other
675  * subframeworks in the same umbrella framework. To do this the subframework
676  * is built with "-allowable_client client_name" and an LC_SUB_CLIENT load
677  * command is created for each -allowable_client flag. The client_name is
678  * usually a framework name. It can also be a name used for bundles clients
679  * where the bundle is built with "-client_name client_name".
680  */
682  uint32_t cmd; /* LC_SUB_CLIENT */
683  uint32_t cmdsize; /* includes client string */
684  union lc_str client; /* the client name */
685 };
686 
687 /*
688  * A dynamically linked shared library may be a sub_umbrella of an umbrella
689  * framework. If so it will be linked with "-sub_umbrella umbrella_name" where
690  * Where "umbrella_name" is the name of the sub_umbrella framework. When
691  * staticly linking when -twolevel_namespace is in effect a twolevel namespace
692  * umbrella framework will only cause its subframeworks and those frameworks
693  * listed as sub_umbrella frameworks to be implicited linked in. Any other
694  * dependent dynamic libraries will not be linked it when -twolevel_namespace
695  * is in effect. The primary library recorded by the static linker when
696  * resolving a symbol in these libraries will be the umbrella framework.
697  * Zero or more sub_umbrella frameworks may be use by an umbrella framework.
698  * The name of a sub_umbrella framework is recorded in the following structure.
699  */
701  uint32_t cmd; /* LC_SUB_UMBRELLA */
702  uint32_t cmdsize; /* includes sub_umbrella string */
703  union lc_str sub_umbrella; /* the sub_umbrella framework name */
704 };
705 
706 /*
707  * A dynamically linked shared library may be a sub_library of another shared
708  * library. If so it will be linked with "-sub_library library_name" where
709  * Where "library_name" is the name of the sub_library shared library. When
710  * staticly linking when -twolevel_namespace is in effect a twolevel namespace
711  * shared library will only cause its subframeworks and those frameworks
712  * listed as sub_umbrella frameworks and libraries listed as sub_libraries to
713  * be implicited linked in. Any other dependent dynamic libraries will not be
714  * linked it when -twolevel_namespace is in effect. The primary library
715  * recorded by the static linker when resolving a symbol in these libraries
716  * will be the umbrella framework (or dynamic library). Zero or more sub_library
717  * shared libraries may be use by an umbrella framework or (or dynamic library).
718  * The name of a sub_library framework is recorded in the following structure.
719  * For example /usr/lib/libobjc_profile.A.dylib would be recorded as "libobjc".
720  */
722  uint32_t cmd; /* LC_SUB_LIBRARY */
723  uint32_t cmdsize; /* includes sub_library string */
724  union lc_str sub_library; /* the sub_library name */
725 };
726 
727 /*
728  * A program (filetype == MH_EXECUTE) that is
729  * prebound to its dynamic libraries has one of these for each library that
730  * the static linker used in prebinding. It contains a bit vector for the
731  * modules in the library. The bits indicate which modules are bound (1) and
732  * which are not (0) from the library. The bit for module 0 is the low bit
733  * of the first byte. So the bit for the Nth module is:
734  * (linked_modules[N/8] >> N%8) & 1
735  */
737  uint32_t cmd; /* LC_PREBOUND_DYLIB */
738  uint32_t cmdsize; /* includes strings */
739  union lc_str name; /* library's path name */
740  uint32_t nmodules; /* number of modules in library */
741  union lc_str linked_modules; /* bit vector of linked modules */
742 };
743 
744 /*
745  * A program that uses a dynamic linker contains a dylinker_command to identify
746  * the name of the dynamic linker (LC_LOAD_DYLINKER). And a dynamic linker
747  * contains a dylinker_command to identify the dynamic linker (LC_ID_DYLINKER).
748  * A file can have at most one of these.
749  * This struct is also used for the LC_DYLD_ENVIRONMENT load command and
750  * contains string for dyld to treat like environment variable.
751  */
752 struct dylinker_command {
753  uint32_t cmd; /* LC_ID_DYLINKER, LC_LOAD_DYLINKER or
754  LC_DYLD_ENVIRONMENT */
755  uint32_t cmdsize; /* includes pathname string */
756  union lc_str name; /* dynamic linker's path name */
757 };
758 
759 /*
760  * Thread commands contain machine-specific data structures suitable for
761  * use in the thread state primitives. The machine specific data structures
762  * follow the struct thread_command as follows.
763  * Each flavor of machine specific data structure is preceded by an unsigned
764  * long constant for the flavor of that data structure, an uint32_t
765  * that is the count of longs of the size of the state data structure and then
766  * the state data structure follows. This triple may be repeated for many
767  * flavors. The constants for the flavors, counts and state data structure
768  * definitions are expected to be in the header file <machine/thread_status.h>.
769  * These machine specific data structures sizes must be multiples of
770  * 4 bytes The cmdsize reflects the total size of the thread_command
771  * and all of the sizes of the constants for the flavors, counts and state
772  * data structures.
773  *
774  * For executable objects that are unix processes there will be one
775  * thread_command (cmd == LC_UNIXTHREAD) created for it by the link-editor.
776  * This is the same as a LC_THREAD, except that a stack is automatically
777  * created (based on the shell's limit for the stack size). Command arguments
778  * and environment variables are copied onto that stack.
779  */
780 struct thread_command {
781  uint32_t cmd; /* LC_THREAD or LC_UNIXTHREAD */
782  uint32_t cmdsize; /* total size of this command */
783  /* uint32_t flavor flavor of thread state */
784  /* uint32_t count count of longs in thread state */
785  /* struct XXX_thread_state state thread state for this flavor */
786  /* ... */
787 };
788 
789 /*
790  * The routines command contains the address of the dynamic shared library
791  * initialization routine and an index into the module table for the module
792  * that defines the routine. Before any modules are used from the library the
793  * dynamic linker fully binds the module that defines the initialization routine
794  * and then calls it. This gets called before any module initialization
795  * routines (used for C++ static constructors) in the library.
796  */
797 struct routines_command { /* for 32-bit architectures */
798  uint32_t cmd; /* LC_ROUTINES */
799  uint32_t cmdsize; /* total size of this command */
800  uint32_t init_address; /* address of initialization routine */
801  uint32_t init_module; /* index into the module table that */
802  /* the init routine is defined in */
809 };
810 
811 /*
812  * The 64-bit routines command. Same use as above.
813  */
814 struct routines_command_64 { /* for 64-bit architectures */
815  uint32_t cmd; /* LC_ROUTINES_64 */
816  uint32_t cmdsize; /* total size of this command */
817  uint64_t init_address; /* address of initialization routine */
818  uint64_t init_module; /* index into the module table that */
819  /* the init routine is defined in */
826 };
827 
828 /*
829  * The symtab_command contains the offsets and sizes of the link-edit 4.3BSD
830  * "stab" style symbol table information as described in the header files
831  * <nlist.h> and <stab.h>.
832  */
833 struct symtab_command {
834  uint32_t cmd; /* LC_SYMTAB */
835  uint32_t cmdsize; /* sizeof(struct symtab_command) */
836  uint32_t symoff; /* symbol table offset */
837  uint32_t nsyms; /* number of symbol table entries */
838  uint32_t stroff; /* string table offset */
839  uint32_t strsize; /* string table size in bytes */
840 };
841 
842 /*
843  * This is the second set of the symbolic information which is used to support
844  * the data structures for the dynamically link editor.
845  *
846  * The original set of symbolic information in the symtab_command which contains
847  * the symbol and string tables must also be present when this load command is
848  * present. When this load command is present the symbol table is organized
849  * into three groups of symbols:
850  * local symbols (static and debugging symbols) - grouped by module
851  * defined external symbols - grouped by module (sorted by name if not lib)
852  * undefined external symbols (sorted by name if MH_BINDATLOAD is not set,
853  * and in order the were seen by the static
854  * linker if MH_BINDATLOAD is set)
855  * In this load command there are offsets and counts to each of the three groups
856  * of symbols.
857  *
858  * This load command contains a the offsets and sizes of the following new
859  * symbolic information tables:
860  * table of contents
861  * module table
862  * reference symbol table
863  * indirect symbol table
864  * The first three tables above (the table of contents, module table and
865  * reference symbol table) are only present if the file is a dynamically linked
866  * shared library. For executable and object modules, which are files
867  * containing only one module, the information that would be in these three
868  * tables is determined as follows:
869  * table of contents - the defined external symbols are sorted by name
870  * module table - the file contains only one module so everything in the
871  * file is part of the module.
872  * reference symbol table - is the defined and undefined external symbols
873  *
874  * For dynamically linked shared library files this load command also contains
875  * offsets and sizes to the pool of relocation entries for all sections
876  * separated into two groups:
877  * external relocation entries
878  * local relocation entries
879  * For executable and object modules the relocation entries continue to hang
880  * off the section structures.
881  */
882 struct dysymtab_command {
883  uint32_t cmd; /* LC_DYSYMTAB */
884  uint32_t cmdsize; /* sizeof(struct dysymtab_command) */
885 
886  /*
887  * The symbols indicated by symoff and nsyms of the LC_SYMTAB load command
888  * are grouped into the following three groups:
889  * local symbols (further grouped by the module they are from)
890  * defined external symbols (further grouped by the module they are from)
891  * undefined symbols
892  *
893  * The local symbols are used only for debugging. The dynamic binding
894  * process may have to use them to indicate to the debugger the local
895  * symbols for a module that is being bound.
896  *
897  * The last two groups are used by the dynamic binding process to do the
898  * binding (indirectly through the module table and the reference symbol
899  * table when this is a dynamically linked shared library file).
900  */
901  uint32_t ilocalsym; /* index to local symbols */
902  uint32_t nlocalsym; /* number of local symbols */
903 
904  uint32_t iextdefsym;/* index to externally defined symbols */
905  uint32_t nextdefsym;/* number of externally defined symbols */
906 
907  uint32_t iundefsym; /* index to undefined symbols */
908  uint32_t nundefsym; /* number of undefined symbols */
909 
910  /*
911  * For the for the dynamic binding process to find which module a symbol
912  * is defined in the table of contents is used (analogous to the ranlib
913  * structure in an archive) which maps defined external symbols to modules
914  * they are defined in. This exists only in a dynamically linked shared
915  * library file. For executable and object modules the defined external
916  * symbols are sorted by name and is use as the table of contents.
917  */
918  uint32_t tocoff; /* file offset to table of contents */
919  uint32_t ntoc; /* number of entries in table of contents */
920 
921  /*
922  * To support dynamic binding of "modules" (whole object files) the symbol
923  * table must reflect the modules that the file was created from. This is
924  * done by having a module table that has indexes and counts into the merged
925  * tables for each module. The module structure that these two entries
926  * refer to is described below. This exists only in a dynamically linked
927  * shared library file. For executable and object modules the file only
928  * contains one module so everything in the file belongs to the module.
929  */
930  uint32_t modtaboff; /* file offset to module table */
931  uint32_t nmodtab; /* number of module table entries */
932 
933  /*
934  * To support dynamic module binding the module structure for each module
935  * indicates the external references (defined and undefined) each module
936  * makes. For each module there is an offset and a count into the
937  * reference symbol table for the symbols that the module references.
938  * This exists only in a dynamically linked shared library file. For
939  * executable and object modules the defined external symbols and the
940  * undefined external symbols indicates the external references.
941  */
942  uint32_t extrefsymoff; /* offset to referenced symbol table */
943  uint32_t nextrefsyms; /* number of referenced symbol table entries */
944 
945  /*
946  * The sections that contain "symbol pointers" and "routine stubs" have
947  * indexes and (implied counts based on the size of the section and fixed
948  * size of the entry) into the "indirect symbol" table for each pointer
949  * and stub. For every section of these two types the index into the
950  * indirect symbol table is stored in the section header in the field
951  * reserved1. An indirect symbol table entry is simply a 32bit index into
952  * the symbol table to the symbol that the pointer or stub is referring to.
953  * The indirect symbol table is ordered to match the entries in the section.
954  */
955  uint32_t indirectsymoff; /* file offset to the indirect symbol table */
956  uint32_t nindirectsyms; /* number of indirect symbol table entries */
957 
958  /*
959  * To support relocating an individual module in a library file quickly the
960  * external relocation entries for each module in the library need to be
961  * accessed efficiently. Since the relocation entries can't be accessed
962  * through the section headers for a library file they are separated into
963  * groups of local and external entries further grouped by module. In this
964  * case the presents of this load command who's extreloff, nextrel,
965  * locreloff and nlocrel fields are non-zero indicates that the relocation
966  * entries of non-merged sections are not referenced through the section
967  * structures (and the reloff and nreloc fields in the section headers are
968  * set to zero).
969  *
970  * Since the relocation entries are not accessed through the section headers
971  * this requires the r_address field to be something other than a section
972  * offset to identify the item to be relocated. In this case r_address is
973  * set to the offset from the vmaddr of the first LC_SEGMENT command.
974  * For MH_SPLIT_SEGS images r_address is set to the the offset from the
975  * vmaddr of the first read-write LC_SEGMENT command.
976  *
977  * The relocation entries are grouped by module and the module table
978  * entries have indexes and counts into them for the group of external
979  * relocation entries for that the module.
980  *
981  * For sections that are merged across modules there must not be any
982  * remaining external relocation entries for them (for merged sections
983  * remaining relocation entries must be local).
984  */
985  uint32_t extreloff; /* offset to external relocation entries */
986  uint32_t nextrel; /* number of external relocation entries */
987 
988  /*
989  * All the local relocation entries are grouped together (they are not
990  * grouped by their module since they are only used if the object is moved
991  * from it staticly link edited address).
992  */
993  uint32_t locreloff; /* offset to local relocation entries */
994  uint32_t nlocrel; /* number of local relocation entries */
995 
996 };
997 
998 /*
999  * An indirect symbol table entry is simply a 32bit index into the symbol table
1000  * to the symbol that the pointer or stub is refering to. Unless it is for a
1001  * non-lazy symbol pointer section for a defined symbol which strip(1) as
1002  * removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the
1003  * symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that.
1004  */
1005 #define INDIRECT_SYMBOL_LOCAL 0x80000000
1006 #define INDIRECT_SYMBOL_ABS 0x40000000
1007 
1008 
1009 /* a table of contents entry */
1010 struct dylib_table_of_contents {
1011  uint32_t symbol_index; /* the defined external symbol
1012  (index into the symbol table) */
1013  uint32_t module_index; /* index into the module table this symbol
1014  is defined in */
1015 };
1016 
1017 /* a module table entry */
1018 struct dylib_module {
1019  uint32_t module_name; /* the module name (index into string table) */
1020 
1021  uint32_t iextdefsym; /* index into externally defined symbols */
1022  uint32_t nextdefsym; /* number of externally defined symbols */
1023  uint32_t irefsym; /* index into reference symbol table */
1024  uint32_t nrefsym; /* number of reference symbol table entries */
1025  uint32_t ilocalsym; /* index into symbols for local symbols */
1026  uint32_t nlocalsym; /* number of local symbols */
1027 
1028  uint32_t iextrel; /* index into external relocation entries */
1029  uint32_t nextrel; /* number of external relocation entries */
1031  uint32_t iinit_iterm; /* low 16 bits are the index into the init
1032  section, high 16 bits are the index into
1033  the term section */
1034  uint32_t ninit_nterm; /* low 16 bits are the number of init section
1035  entries, high 16 bits are the number of
1036  term section entries */
1037 
1038  uint32_t /* for this module address of the start of */
1039  objc_module_info_addr; /* the (__OBJC,__module_info) section */
1040  uint32_t /* for this module size of */
1041  objc_module_info_size; /* the (__OBJC,__module_info) section */
1042 };
1043 
1044 /* a 64-bit module table entry */
1045 struct dylib_module_64 {
1046  uint32_t module_name; /* the module name (index into string table) */
1047 
1048  uint32_t iextdefsym; /* index into externally defined symbols */
1049  uint32_t nextdefsym; /* number of externally defined symbols */
1050  uint32_t irefsym; /* index into reference symbol table */
1051  uint32_t nrefsym; /* number of reference symbol table entries */
1052  uint32_t ilocalsym; /* index into symbols for local symbols */
1053  uint32_t nlocalsym; /* number of local symbols */
1054 
1055  uint32_t iextrel; /* index into external relocation entries */
1056  uint32_t nextrel; /* number of external relocation entries */
1057 
1058  uint32_t iinit_iterm; /* low 16 bits are the index into the init
1059  section, high 16 bits are the index into
1060  the term section */
1061  uint32_t ninit_nterm; /* low 16 bits are the number of init section
1062  entries, high 16 bits are the number of
1063  term section entries */
1065  uint32_t /* for this module size of */
1066  objc_module_info_size; /* the (__OBJC,__module_info) section */
1067  uint64_t /* for this module address of the start of */
1068  objc_module_info_addr; /* the (__OBJC,__module_info) section */
1069 };
1070 
1071 /*
1072  * The entries in the reference symbol table are used when loading the module
1073  * (both by the static and dynamic link editors) and if the module is unloaded
1074  * or replaced. Therefore all external symbols (defined and undefined) are
1075  * listed in the module's reference table. The flags describe the type of
1076  * reference that is being made. The constants for the flags are defined in
1077  * <mach-o/nlist.h> as they are also used for symbol table entries.
1078  */
1079 struct dylib_reference {
1080  uint32_t isym:24, /* index into the symbol table */
1081  flags:8; /* flags to indicate the type of reference */
1082 };
1083 
1084 /*
1085  * The twolevel_hints_command contains the offset and number of hints in the
1086  * two-level namespace lookup hints table.
1087  */
1089  uint32_t cmd; /* LC_TWOLEVEL_HINTS */
1090  uint32_t cmdsize; /* sizeof(struct twolevel_hints_command) */
1091  uint32_t offset; /* offset to the hint table */
1092  uint32_t nhints; /* number of hints in the hint table */
1093 };
1094 
1095 /*
1096  * The entries in the two-level namespace lookup hints table are twolevel_hint
1097  * structs. These provide hints to the dynamic link editor where to start
1098  * looking for an undefined symbol in a two-level namespace image. The
1099  * isub_image field is an index into the sub-images (sub-frameworks and
1100  * sub-umbrellas list) that made up the two-level image that the undefined
1101  * symbol was found in when it was built by the static link editor. If
1102  * isub-image is 0 the the symbol is expected to be defined in library and not
1103  * in the sub-images. If isub-image is non-zero it is an index into the array
1104  * of sub-images for the umbrella with the first index in the sub-images being
1105  * 1. The array of sub-images is the ordered list of sub-images of the umbrella
1106  * that would be searched for a symbol that has the umbrella recorded as its
1107  * primary library. The table of contents index is an index into the
1108  * library's table of contents. This is used as the starting point of the
1109  * binary search or a directed linear search.
1110  */
1111 struct twolevel_hint {
1112  uint32_t
1113  isub_image:8, /* index into the sub images */
1114  itoc:24; /* index into the table of contents */
1115 };
1117 /*
1118  * The prebind_cksum_command contains the value of the original check sum for
1119  * prebound files or zero. When a prebound file is first created or modified
1120  * for other than updating its prebinding information the value of the check sum
1121  * is set to zero. When the file has it prebinding re-done and if the value of
1122  * the check sum is zero the original check sum is calculated and stored in
1123  * cksum field of this load command in the output file. If when the prebinding
1124  * is re-done and the cksum field is non-zero it is left unchanged from the
1125  * input file.
1126  */
1128  uint32_t cmd; /* LC_PREBIND_CKSUM */
1129  uint32_t cmdsize; /* sizeof(struct prebind_cksum_command) */
1130  uint32_t cksum; /* the check sum or zero */
1131 };
1133 /*
1134  * The uuid load command contains a single 128-bit unique random number that
1135  * identifies an object produced by the static link editor.
1136  */
1138  uint32_t cmd; /* LC_UUID */
1139  uint32_t cmdsize; /* sizeof(struct uuid_command) */
1140  uint8_t uuid[16]; /* the 128-bit uuid */
1141 };
1142 
1143 /*
1144  * The rpath_command contains a path which at runtime should be added to
1145  * the current run path used to find @rpath prefixed dylibs.
1146  */
1147 struct rpath_command {
1148  uint32_t cmd; /* LC_RPATH */
1149  uint32_t cmdsize; /* includes string */
1150  union lc_str path; /* path to add to run path */
1151 };
1152 
1153 /*
1154  * The linkedit_data_command contains the offsets and sizes of a blob
1155  * of data in the __LINKEDIT segment.
1156  */
1157 struct linkedit_data_command {
1158  uint32_t cmd; /* LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO,
1159  LC_FUNCTION_STARTS, LC_DATA_IN_CODE,
1160  LC_DYLIB_CODE_SIGN_DRS or
1161  LC_LINKER_OPTIMIZATION_HINT. */
1162  uint32_t cmdsize; /* sizeof(struct linkedit_data_command) */
1163  uint32_t dataoff; /* file offset of data in __LINKEDIT segment */
1164  uint32_t datasize; /* file size of data in __LINKEDIT segment */
1165 };
1166 
1167 /*
1168  * The encryption_info_command contains the file offset and size of an
1169  * of an encrypted segment.
1170  */
1171 struct encryption_info_command {
1172  uint32_t cmd; /* LC_ENCRYPTION_INFO */
1173  uint32_t cmdsize; /* sizeof(struct encryption_info_command) */
1174  uint32_t cryptoff; /* file offset of encrypted range */
1175  uint32_t cryptsize; /* file size of encrypted range */
1176  uint32_t cryptid; /* which enryption system,
1177  0 means not-encrypted yet */
1178 };
1180 /*
1181  * The encryption_info_command_64 contains the file offset and size of an
1182  * of an encrypted segment (for use in x86_64 targets).
1183  */
1185  uint32_t cmd; /* LC_ENCRYPTION_INFO_64 */
1186  uint32_t cmdsize; /* sizeof(struct encryption_info_command_64) */
1187  uint32_t cryptoff; /* file offset of encrypted range */
1188  uint32_t cryptsize; /* file size of encrypted range */
1189  uint32_t cryptid; /* which enryption system,
1190  0 means not-encrypted yet */
1191  uint32_t pad; /* padding to make this struct's size a multiple
1192  of 8 bytes */
1193 };
1194 
1195 /*
1196  * The version_min_command contains the min OS version on which this
1197  * binary was built to run.
1198  */
1199 struct version_min_command {
1200  uint32_t cmd; /* LC_VERSION_MIN_MACOSX or
1201  LC_VERSION_MIN_IPHONEOS or
1202  LC_VERSION_MIN_WATCHOS or
1203  LC_VERSION_MIN_TVOS */
1204  uint32_t cmdsize; /* sizeof(struct min_version_command) */
1205  uint32_t version; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
1206  uint32_t sdk; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
1207 };
1208 
1209 /*
1210  * The build_version_command contains the min OS version on which this
1211  * binary was built to run for its platform. The list of known platforms and
1212  * tool values following it.
1213  */
1214 struct build_version_command {
1215  uint32_t cmd; /* LC_BUILD_VERSION */
1216  uint32_t cmdsize; /* sizeof(struct build_version_command) plus */
1217  /* ntools * sizeof(struct build_tool_version) */
1218  uint32_t platform; /* platform */
1219  uint32_t minos; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
1220  uint32_t sdk; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
1221  uint32_t ntools; /* number of tool entries following this */
1222 };
1223 
1224 struct build_tool_version {
1225  uint32_t tool; /* enum for the tool */
1226  uint32_t version; /* version number of the tool */
1227 };
1228 
1229 /* Known values for the platform field above. */
1230 #define PLATFORM_MACOS 1
1231 #define PLATFORM_IOS 2
1232 #define PLATFORM_TVOS 3
1233 #define PLATFORM_WATCHOS 4
1234 
1235 /* Known values for the tool field above. */
1236 #define TOOL_CLANG 1
1237 #define TOOL_SWIFT 2
1238 #define TOOL_LD 3
1239 
1240 /*
1241  * The dyld_info_command contains the file offsets and sizes of
1242  * the new compressed form of the information dyld needs to
1243  * load the image. This information is used by dyld on Mac OS X
1244  * 10.6 and later. All information pointed to by this command
1245  * is encoded using byte streams, so no endian swapping is needed
1246  * to interpret it.
1247  */
1249  uint32_t cmd; /* LC_DYLD_INFO or LC_DYLD_INFO_ONLY */
1250  uint32_t cmdsize; /* sizeof(struct dyld_info_command) */
1251 
1252  /*
1253  * Dyld rebases an image whenever dyld loads it at an address different
1254  * from its preferred address. The rebase information is a stream
1255  * of byte sized opcodes whose symbolic names start with REBASE_OPCODE_.
1256  * Conceptually the rebase information is a table of tuples:
1257  * <seg-index, seg-offset, type>
1258  * The opcodes are a compressed way to encode the table by only
1259  * encoding when a column changes. In addition simple patterns
1260  * like "every n'th offset for m times" can be encoded in a few
1261  * bytes.
1262  */
1263  uint32_t rebase_off; /* file offset to rebase info */
1264  uint32_t rebase_size; /* size of rebase info */
1266  /*
1267  * Dyld binds an image during the loading process, if the image
1268  * requires any pointers to be initialized to symbols in other images.
1269  * The bind information is a stream of byte sized
1270  * opcodes whose symbolic names start with BIND_OPCODE_.
1271  * Conceptually the bind information is a table of tuples:
1272  * <seg-index, seg-offset, type, symbol-library-ordinal, symbol-name, addend>
1273  * The opcodes are a compressed way to encode the table by only
1274  * encoding when a column changes. In addition simple patterns
1275  * like for runs of pointers initialzed to the same value can be
1276  * encoded in a few bytes.
1277  */
1278  uint32_t bind_off; /* file offset to binding info */
1279  uint32_t bind_size; /* size of binding info */
1281  /*
1282  * Some C++ programs require dyld to unique symbols so that all
1283  * images in the process use the same copy of some code/data.
1284  * This step is done after binding. The content of the weak_bind
1285  * info is an opcode stream like the bind_info. But it is sorted
1286  * alphabetically by symbol name. This enable dyld to walk
1287  * all images with weak binding information in order and look
1288  * for collisions. If there are no collisions, dyld does
1289  * no updating. That means that some fixups are also encoded
1290  * in the bind_info. For instance, all calls to "operator new"
1291  * are first bound to libstdc++.dylib using the information
1292  * in bind_info. Then if some image overrides operator new
1293  * that is detected when the weak_bind information is processed
1294  * and the call to operator new is then rebound.
1295  */
1296  uint32_t weak_bind_off; /* file offset to weak binding info */
1297  uint32_t weak_bind_size; /* size of weak binding info */
1299  /*
1300  * Some uses of external symbols do not need to be bound immediately.
1301  * Instead they can be lazily bound on first use. The lazy_bind
1302  * are contains a stream of BIND opcodes to bind all lazy symbols.
1303  * Normal use is that dyld ignores the lazy_bind section when
1304  * loading an image. Instead the static linker arranged for the
1305  * lazy pointer to initially point to a helper function which
1306  * pushes the offset into the lazy_bind area for the symbol
1307  * needing to be bound, then jumps to dyld which simply adds
1308  * the offset to lazy_bind_off to get the information on what
1309  * to bind.
1310  */
1311  uint32_t lazy_bind_off; /* file offset to lazy binding info */
1312  uint32_t lazy_bind_size; /* size of lazy binding infs */
1313 
1314  /*
1315  * The symbols exported by a dylib are encoded in a trie. This
1316  * is a compact representation that factors out common prefixes.
1317  * It also reduces LINKEDIT pages in RAM because it encodes all
1318  * information (name, address, flags) in one small, contiguous range.
1319  * The export area is a stream of nodes. The first node sequentially
1320  * is the start node for the trie.
1321  *
1322  * Nodes for a symbol start with a uleb128 that is the length of
1323  * the exported symbol information for the string so far.
1324  * If there is no exported symbol, the node starts with a zero byte.
1325  * If there is exported info, it follows the length.
1326  *
1327  * First is a uleb128 containing flags. Normally, it is followed by
1328  * a uleb128 encoded offset which is location of the content named
1329  * by the symbol from the mach_header for the image. If the flags
1330  * is EXPORT_SYMBOL_FLAGS_REEXPORT, then following the flags is
1331  * a uleb128 encoded library ordinal, then a zero terminated
1332  * UTF8 string. If the string is zero length, then the symbol
1333  * is re-export from the specified dylib with the same name.
1334  * If the flags is EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER, then following
1335  * the flags is two uleb128s: the stub offset and the resolver offset.
1336  * The stub is used by non-lazy pointers. The resolver is used
1337  * by lazy pointers and must be called to get the actual address to use.
1338  *
1339  * After the optional exported symbol information is a byte of
1340  * how many edges (0-255) that this node has leaving it,
1341  * followed by each edge.
1342  * Each edge is a zero terminated UTF8 of the addition chars
1343  * in the symbol, followed by a uleb128 offset for the node that
1344  * edge points to.
1345  *
1346  */
1347  uint32_t export_off; /* file offset to lazy binding info */
1348  uint32_t export_size; /* size of lazy binding infs */
1349 };
1350 
1351 /*
1352  * The following are used to encode rebasing information
1353  */
1354 #define REBASE_TYPE_POINTER 1
1355 #define REBASE_TYPE_TEXT_ABSOLUTE32 2
1356 #define REBASE_TYPE_TEXT_PCREL32 3
1357 
1358 #define REBASE_OPCODE_MASK 0xF0
1359 #define REBASE_IMMEDIATE_MASK 0x0F
1360 #define REBASE_OPCODE_DONE 0x00
1361 #define REBASE_OPCODE_SET_TYPE_IMM 0x10
1362 #define REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x20
1363 #define REBASE_OPCODE_ADD_ADDR_ULEB 0x30
1364 #define REBASE_OPCODE_ADD_ADDR_IMM_SCALED 0x40
1365 #define REBASE_OPCODE_DO_REBASE_IMM_TIMES 0x50
1366 #define REBASE_OPCODE_DO_REBASE_ULEB_TIMES 0x60
1367 #define REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB 0x70
1368 #define REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB 0x80
1369 
1370 
1371 /*
1372  * The following are used to encode binding information
1373  */
1374 #define BIND_TYPE_POINTER 1
1375 #define BIND_TYPE_TEXT_ABSOLUTE32 2
1376 #define BIND_TYPE_TEXT_PCREL32 3
1377 
1378 #define BIND_SPECIAL_DYLIB_SELF 0
1379 #define BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE -1
1380 #define BIND_SPECIAL_DYLIB_FLAT_LOOKUP -2
1381 
1382 #define BIND_SYMBOL_FLAGS_WEAK_IMPORT 0x1
1383 #define BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION 0x8
1385 #define BIND_OPCODE_MASK 0xF0
1386 #define BIND_IMMEDIATE_MASK 0x0F
1387 #define BIND_OPCODE_DONE 0x00
1388 #define BIND_OPCODE_SET_DYLIB_ORDINAL_IMM 0x10
1389 #define BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB 0x20
1390 #define BIND_OPCODE_SET_DYLIB_SPECIAL_IMM 0x30
1391 #define BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM 0x40
1392 #define BIND_OPCODE_SET_TYPE_IMM 0x50
1393 #define BIND_OPCODE_SET_ADDEND_SLEB 0x60
1394 #define BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x70
1395 #define BIND_OPCODE_ADD_ADDR_ULEB 0x80
1396 #define BIND_OPCODE_DO_BIND 0x90
1397 #define BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xA0
1398 #define BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xB0
1399 #define BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xC0
1400 
1402 /*
1403  * The following are used on the flags byte of a terminal node
1404  * in the export information.
1405  */
1406 #define EXPORT_SYMBOL_FLAGS_KIND_MASK 0x03
1407 #define EXPORT_SYMBOL_FLAGS_KIND_REGULAR 0x00
1408 #define EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL 0x01
1409 #define EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION 0x04
1410 #define EXPORT_SYMBOL_FLAGS_REEXPORT 0x08
1411 #define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER 0x10
1412 
1413 /*
1414  * The linker_option_command contains linker options embedded in object files.
1415  */
1417  uint32_t cmd; /* LC_LINKER_OPTION only used in MH_OBJECT filetypes */
1418  uint32_t cmdsize;
1419  uint32_t count; /* number of strings */
1420  /* concatenation of zero terminated UTF8 strings.
1421  Zero filled at end to align */
1422 };
1423 
1424 /*
1425  * The symseg_command contains the offset and size of the GNU style
1426  * symbol table information as described in the header file <symseg.h>.
1427  * The symbol roots of the symbol segments must also be aligned properly
1428  * in the file. So the requirement of keeping the offsets aligned to a
1429  * multiple of a 4 bytes translates to the length field of the symbol
1430  * roots also being a multiple of a long. Also the padding must again be
1431  * zeroed. (THIS IS OBSOLETE and no longer supported).
1432  */
1433 struct symseg_command {
1434  uint32_t cmd; /* LC_SYMSEG */
1435  uint32_t cmdsize; /* sizeof(struct symseg_command) */
1436  uint32_t offset; /* symbol segment offset */
1437  uint32_t size; /* symbol segment size in bytes */
1438 };
1439 
1440 /*
1441  * The ident_command contains a free format string table following the
1442  * ident_command structure. The strings are null terminated and the size of
1443  * the command is padded out with zero bytes to a multiple of 4 bytes/
1444  * (THIS IS OBSOLETE and no longer supported).
1445  */
1446 struct ident_command {
1447  uint32_t cmd; /* LC_IDENT */
1448  uint32_t cmdsize; /* strings that follow this command */
1449 };
1450 
1451 /*
1452  * The fvmfile_command contains a reference to a file to be loaded at the
1453  * specified virtual address. (Presently, this command is reserved for
1454  * internal use. The kernel ignores this command when loading a program into
1455  * memory).
1456  */
1457 struct fvmfile_command {
1458  uint32_t cmd; /* LC_FVMFILE */
1459  uint32_t cmdsize; /* includes pathname string */
1460  union lc_str name; /* files pathname */
1461  uint32_t header_addr; /* files virtual address */
1462 };
1463 
1464 
1465 /*
1466  * The entry_point_command is a replacement for thread_command.
1467  * It is used for main executables to specify the location (file offset)
1468  * of main(). If -stack_size was used at link time, the stacksize
1469  * field will contain the stack size need for the main thread.
1470  */
1471 struct entry_point_command {
1472  uint32_t cmd; /* LC_MAIN only used in MH_EXECUTE filetypes */
1473  uint32_t cmdsize; /* 24 */
1474  uint64_t entryoff; /* file (__TEXT) offset of main() */
1475  uint64_t stacksize;/* if not zero, initial stack size */
1476 };
1477 
1478 
1479 /*
1480  * The source_version_command is an optional load command containing
1481  * the version of the sources used to build the binary.
1482  */
1483 struct source_version_command {
1484  uint32_t cmd; /* LC_SOURCE_VERSION */
1485  uint32_t cmdsize; /* 16 */
1486  uint64_t version; /* A.B.C.D.E packed as a24.b10.c10.d10.e10 */
1487 };
1488 
1489 
1490 /*
1491  * The LC_DATA_IN_CODE load commands uses a linkedit_data_command
1492  * to point to an array of data_in_code_entry entries. Each entry
1493  * describes a range of data in a code section.
1494  */
1495 struct data_in_code_entry {
1496  uint32_t offset; /* from mach_header to start of data range*/
1497  uint16_t length; /* number of bytes in data range */
1498  uint16_t kind; /* a DICE_KIND_* value */
1499 };
1500 #define DICE_KIND_DATA 0x0001
1501 #define DICE_KIND_JUMP_TABLE8 0x0002
1502 #define DICE_KIND_JUMP_TABLE16 0x0003
1503 #define DICE_KIND_JUMP_TABLE32 0x0004
1504 #define DICE_KIND_ABS_JUMP_TABLE32 0x0005
1505 
1506 
1507 
1508 /*
1509  * Sections of type S_THREAD_LOCAL_VARIABLES contain an array
1510  * of tlv_descriptor structures.
1511  */
1512 struct tlv_descriptor
1513 {
1514  void* (*thunk)(struct tlv_descriptor*);
1515  unsigned long key;
1516  unsigned long offset;
1517 };
1518 
1519 /*
1520  * LC_NOTE commands describe a region of arbitrary data included in a Mach-O
1521  * file. Its initial use is to record extra data in MH_CORE files.
1522  */
1523 struct note_command {
1524  uint32_t cmd; /* LC_NOTE */
1525  uint32_t cmdsize; /* sizeof(struct note_command) */
1526  char data_owner[16]; /* owner name for this LC_NOTE */
1527  uint64_t offset; /* file offset of this data */
1528  uint64_t size; /* length of data region */
1529 };
1530 
1531 #endif /* _MACHO_LOADER_H_ */
uuid_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1040
dylib_module::irefsym
uint32_t irefsym
Definition: loader.h:924
symseg_command
Definition: loader.h:1334
version_min_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1105
section::addr
uint32_t addr
Definition: loader.h:340
segment_command_64
Definition: loader.h:290
note_command::size
uint64_t size
Definition: loader.h:1429
symtab_command::stroff
uint32_t stroff
Definition: loader.h:739
segment_command::fileoff
uint32_t fileoff
Definition: loader.h:276
twolevel_hint
Definition: loader.h:1012
segment_command_64::nsects
uint32_t nsects
Definition: loader.h:300
segment_command_64::fileoff
uint64_t fileoff
Definition: loader.h:296
linker_option_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1319
dyld_info_command::weak_bind_size
uint32_t weak_bind_size
Definition: loader.h:1198
dyld_info_command::rebase_size
uint32_t rebase_size
Definition: loader.h:1165
lc_str
Definition: loader.h:251
sub_client_command
Definition: loader.h:582
rpath_command::path
union lc_str path
Definition: loader.h:1051
dylib_module_64
Definition: loader.h:946
dyld_info_command::weak_bind_off
uint32_t weak_bind_off
Definition: loader.h:1197
segment_command::flags
uint32_t flags
Definition: loader.h:281
encryption_info_command_64::cmdsize
uint32_t cmdsize
Definition: loader.h:1087
mach_header
Definition: loader.h:47
routines_command::cmd
uint32_t cmd
Definition: loader.h:699
section::nreloc
uint32_t nreloc
Definition: loader.h:345
mach_header_64::ncmds
uint32_t ncmds
Definition: loader.h:70
dysymtab_command
Definition: loader.h:783
section_64::nreloc
uint32_t nreloc
Definition: loader.h:359
prebound_dylib_command
Definition: loader.h:637
segment_command_64::segname
char segname[16]
Definition: loader.h:293
dylib_module_64::ilocalsym
uint32_t ilocalsym
Definition: loader.h:953
fvmfile_command
Definition: loader.h:1358
build_tool_version
Definition: loader.h:1125
note_command::data_owner
char data_owner[16]
Definition: loader.h:1427
source_version_command
Definition: loader.h:1384
dysymtab_command::nindirectsyms
uint32_t nindirectsyms
Definition: loader.h:857
dyld_info_command::cmd
uint32_t cmd
Definition: loader.h:1150
dyld_info_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1151
dylib_table_of_contents
Definition: loader.h:911
fvmlib_command
Definition: loader.h:521
sub_framework_command::umbrella
union lc_str umbrella
Definition: loader.h:570
dysymtab_command::locreloff
uint32_t locreloff
Definition: loader.h:894
dylib::timestamp
uint32_t timestamp
Definition: loader.h:538
entry_point_command::entryoff
uint64_t entryoff
Definition: loader.h:1375
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
dylib_module::iextrel
uint32_t iextrel
Definition: loader.h:929
uuid_command
Definition: loader.h:1038
cpu_type_t
integer_t cpu_type_t
Definition: machine.h:70
segment_command_64::cmd
uint32_t cmd
Definition: loader.h:291
sub_library_command::cmdsize
uint32_t cmdsize
Definition: loader.h:624
dylib_command::cmd
uint32_t cmd
Definition: loader.h:551
note_command::offset
uint64_t offset
Definition: loader.h:1428
dysymtab_command::extreloff
uint32_t extreloff
Definition: loader.h:886
client
Definition: examples/python/async_streaming/client.py:1
prebound_dylib_command::cmdsize
uint32_t cmdsize
Definition: loader.h:639
sub_framework_command::cmdsize
uint32_t cmdsize
Definition: loader.h:569
fvmlib::header_addr
uint32_t header_addr
Definition: loader.h:511
dylinker_command::name
union lc_str name
Definition: loader.h:657
dysymtab_command::iextdefsym
uint32_t iextdefsym
Definition: loader.h:805
note_command::cmd
uint32_t cmd
Definition: loader.h:1425
dylib_module::iextdefsym
uint32_t iextdefsym
Definition: loader.h:922
routines_command_64::reserved4
uint64_t reserved4
Definition: loader.h:724
dyld_info_command::export_off
uint32_t export_off
Definition: loader.h:1248
mach_header::magic
uint32_t magic
Definition: loader.h:48
symseg_command::cmd
uint32_t cmd
Definition: loader.h:1335
symtab_command
Definition: loader.h:734
routines_command_64::init_address
uint64_t init_address
Definition: loader.h:718
sub_framework_command
Definition: loader.h:567
dylib_module::objc_module_info_addr
uint32_t objc_module_info_addr
Definition: loader.h:940
version_min_command::version
uint32_t version
Definition: loader.h:1106
linkedit_data_command::cmd
uint32_t cmd
Definition: loader.h:1059
section::flags
uint32_t flags
Definition: loader.h:346
build_tool_version::tool
uint32_t tool
Definition: loader.h:1126
twolevel_hint::isub_image
uint32_t isub_image
Definition: loader.h:1014
dylib_module_64::iinit_iterm
uint32_t iinit_iterm
Definition: loader.h:959
mach_header_64::filetype
uint32_t filetype
Definition: loader.h:69
section::segname
char segname[16]
Definition: loader.h:339
build_version_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1117
section_64::sectname
char sectname[16]
Definition: loader.h:352
dylib::compatibility_version
uint32_t compatibility_version
Definition: loader.h:540
dylib_reference::flags
uint32_t flags
Definition: loader.h:982
mach_header::sizeofcmds
uint32_t sizeofcmds
Definition: loader.h:53
mach_header::cputype
cpu_type_t cputype
Definition: loader.h:49
dylib_command::cmdsize
uint32_t cmdsize
Definition: loader.h:553
entry_point_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1374
dylib_module::module_name
uint32_t module_name
Definition: loader.h:920
dylinker_command::cmdsize
uint32_t cmdsize
Definition: loader.h:656
prebound_dylib_command::name
union lc_str name
Definition: loader.h:640
thread_command::cmd
uint32_t cmd
Definition: loader.h:682
dylib_reference
Definition: loader.h:980
section::sectname
char sectname[16]
Definition: loader.h:338
dysymtab_command::tocoff
uint32_t tocoff
Definition: loader.h:819
linkedit_data_command::dataoff
uint32_t dataoff
Definition: loader.h:1064
cpu_subtype_t
integer_t cpu_subtype_t
Definition: machine.h:71
section_64::reserved3
uint32_t reserved3
Definition: loader.h:363
version_min_command
Definition: loader.h:1100
dyld_info_command::lazy_bind_off
uint32_t lazy_bind_off
Definition: loader.h:1212
dylib_table_of_contents::module_index
uint32_t module_index
Definition: loader.h:914
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
fvmfile_command::name
union lc_str name
Definition: loader.h:1361
build_version_command::minos
uint32_t minos
Definition: loader.h:1120
linkedit_data_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1063
build_version_command
Definition: loader.h:1115
dylib_module_64::ninit_nterm
uint32_t ninit_nterm
Definition: loader.h:962
dylinker_command::cmd
uint32_t cmd
Definition: loader.h:654
routines_command_64::init_module
uint64_t init_module
Definition: loader.h:719
prebind_cksum_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1030
dysymtab_command::nmodtab
uint32_t nmodtab
Definition: loader.h:832
routines_command::reserved6
uint32_t reserved6
Definition: loader.h:709
dysymtab_command::nextdefsym
uint32_t nextdefsym
Definition: loader.h:806
encryption_info_command::cmd
uint32_t cmd
Definition: loader.h:1073
section_64::segname
char segname[16]
Definition: loader.h:353
routines_command_64::reserved3
uint64_t reserved3
Definition: loader.h:723
dylib_module::nrefsym
uint32_t nrefsym
Definition: loader.h:925
sub_umbrella_command::sub_umbrella
union lc_str sub_umbrella
Definition: loader.h:604
mach_header_64
Definition: loader.h:65
segment_command::maxprot
vm_prot_t maxprot
Definition: loader.h:278
prebound_dylib_command::linked_modules
union lc_str linked_modules
Definition: loader.h:642
mach_header_64::cputype
cpu_type_t cputype
Definition: loader.h:67
dylib_module::ninit_nterm
uint32_t ninit_nterm
Definition: loader.h:935
routines_command::init_module
uint32_t init_module
Definition: loader.h:702
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
dylib_module_64::nextdefsym
uint32_t nextdefsym
Definition: loader.h:950
symtab_command::cmdsize
uint32_t cmdsize
Definition: loader.h:736
data_in_code_entry::length
uint16_t length
Definition: loader.h:1398
section::size
uint32_t size
Definition: loader.h:341
dyld_info_command
Definition: loader.h:1149
dylib_module_64::nlocalsym
uint32_t nlocalsym
Definition: loader.h:954
fvmlib::name
union lc_str name
Definition: loader.h:509
dyld_info_command::bind_off
uint32_t bind_off
Definition: loader.h:1179
prebound_dylib_command::nmodules
uint32_t nmodules
Definition: loader.h:641
fvmlib_command::cmd
uint32_t cmd
Definition: loader.h:522
encryption_info_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1074
prebind_cksum_command
Definition: loader.h:1028
encryption_info_command
Definition: loader.h:1072
prebind_cksum_command::cmd
uint32_t cmd
Definition: loader.h:1029
section_64::flags
uint32_t flags
Definition: loader.h:360
dyld_info_command::lazy_bind_size
uint32_t lazy_bind_size
Definition: loader.h:1213
mach_header_64::flags
uint32_t flags
Definition: loader.h:72
version_min_command::sdk
uint32_t sdk
Definition: loader.h:1107
fvmlib
Definition: loader.h:508
segment_command_64::initprot
vm_prot_t initprot
Definition: loader.h:299
segment_command::vmaddr
uint32_t vmaddr
Definition: loader.h:274
dysymtab_command::modtaboff
uint32_t modtaboff
Definition: loader.h:831
encryption_info_command::cryptoff
uint32_t cryptoff
Definition: loader.h:1075
segment_command
Definition: loader.h:270
encryption_info_command_64::cmd
uint32_t cmd
Definition: loader.h:1086
section::reloff
uint32_t reloff
Definition: loader.h:344
uuid_command::cmd
uint32_t cmd
Definition: loader.h:1039
fvmfile_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1360
sub_umbrella_command::cmd
uint32_t cmd
Definition: loader.h:602
dylib_command
Definition: loader.h:550
routines_command_64::cmdsize
uint32_t cmdsize
Definition: loader.h:717
rpath_command
Definition: loader.h:1048
routines_command::cmdsize
uint32_t cmdsize
Definition: loader.h:700
segment_command_64::cmdsize
uint32_t cmdsize
Definition: loader.h:292
source_version_command::cmd
uint32_t cmd
Definition: loader.h:1385
dylib_module_64::irefsym
uint32_t irefsym
Definition: loader.h:951
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
vm_prot.h
rpath_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1050
linkedit_data_command
Definition: loader.h:1058
machine.h
prebound_dylib_command::cmd
uint32_t cmd
Definition: loader.h:638
fvmlib::minor_version
uint32_t minor_version
Definition: loader.h:510
load_command::cmdsize
uint32_t cmdsize
Definition: loader.h:169
tlv_descriptor::key
unsigned long key
Definition: loader.h:1416
sub_umbrella_command::cmdsize
uint32_t cmdsize
Definition: loader.h:603
segment_command::initprot
vm_prot_t initprot
Definition: loader.h:279
section_64::size
uint64_t size
Definition: loader.h:355
mach_header::ncmds
uint32_t ncmds
Definition: loader.h:52
encryption_info_command_64
Definition: loader.h:1085
dysymtab_command::nextrel
uint32_t nextrel
Definition: loader.h:887
routines_command::reserved1
uint32_t reserved1
Definition: loader.h:704
note_command
Definition: loader.h:1424
source_version_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1386
encryption_info_command_64::pad
uint32_t pad
Definition: loader.h:1092
lc_str::ptr
char * ptr
Definition: loader.h:254
routines_command_64::reserved5
uint64_t reserved5
Definition: loader.h:725
entry_point_command::stacksize
uint64_t stacksize
Definition: loader.h:1376
dyld_info_command::rebase_off
uint32_t rebase_off
Definition: loader.h:1164
dylib::name
union lc_str name
Definition: loader.h:537
segment_command::cmd
uint32_t cmd
Definition: loader.h:271
ident_command::cmd
uint32_t cmd
Definition: loader.h:1348
sub_library_command
Definition: loader.h:622
mach_header_64::magic
uint32_t magic
Definition: loader.h:66
routines_command_64::reserved1
uint64_t reserved1
Definition: loader.h:721
routines_command::reserved4
uint32_t reserved4
Definition: loader.h:707
dysymtab_command::cmd
uint32_t cmd
Definition: loader.h:784
dylib_module::nextdefsym
uint32_t nextdefsym
Definition: loader.h:923
prebind_cksum_command::cksum
uint32_t cksum
Definition: loader.h:1031
symseg_command::offset
uint32_t offset
Definition: loader.h:1337
dysymtab_command::nundefsym
uint32_t nundefsym
Definition: loader.h:809
dysymtab_command::nlocalsym
uint32_t nlocalsym
Definition: loader.h:803
mach_header_64::cpusubtype
cpu_subtype_t cpusubtype
Definition: loader.h:68
section_64::reserved2
uint32_t reserved2
Definition: loader.h:362
rpath_command::cmd
uint32_t cmd
Definition: loader.h:1049
encryption_info_command::cryptid
uint32_t cryptid
Definition: loader.h:1077
stdint.h
segment_command::vmsize
uint32_t vmsize
Definition: loader.h:275
segment_command_64::flags
uint32_t flags
Definition: loader.h:301
segment_command::nsects
uint32_t nsects
Definition: loader.h:280
section
Definition: loader.h:337
dylib
Definition: loader.h:536
routines_command_64::reserved6
uint64_t reserved6
Definition: loader.h:726
section_64
Definition: loader.h:351
section_64::offset
uint32_t offset
Definition: loader.h:356
twolevel_hints_command::offset
uint32_t offset
Definition: loader.h:992
symtab_command::nsyms
uint32_t nsyms
Definition: loader.h:738
dylib_module::iinit_iterm
uint32_t iinit_iterm
Definition: loader.h:932
data_in_code_entry
Definition: loader.h:1396
dyld_info_command::export_size
uint32_t export_size
Definition: loader.h:1249
linker_option_command::count
uint32_t count
Definition: loader.h:1320
twolevel_hints_command::nhints
uint32_t nhints
Definition: loader.h:993
segment_command_64::vmsize
uint64_t vmsize
Definition: loader.h:295
dylib_module::nlocalsym
uint32_t nlocalsym
Definition: loader.h:927
section::reserved1
uint32_t reserved1
Definition: loader.h:347
section::reserved2
uint32_t reserved2
Definition: loader.h:348
routines_command_64::cmd
uint32_t cmd
Definition: loader.h:716
lc_str::offset
uint32_t offset
Definition: loader.h:252
dysymtab_command::ntoc
uint32_t ntoc
Definition: loader.h:820
fvmfile_command::cmd
uint32_t cmd
Definition: loader.h:1359
segment_command::segname
char segname[16]
Definition: loader.h:273
entry_point_command
Definition: loader.h:1372
dylib_module_64::iextrel
uint32_t iextrel
Definition: loader.h:956
encryption_info_command::cryptsize
uint32_t cryptsize
Definition: loader.h:1076
data_in_code_entry::kind
uint16_t kind
Definition: loader.h:1399
fvmfile_command::header_addr
uint32_t header_addr
Definition: loader.h:1362
thread_command
Definition: loader.h:681
section::align
uint32_t align
Definition: loader.h:343
segment_command::cmdsize
uint32_t cmdsize
Definition: loader.h:272
twolevel_hints_command::cmdsize
uint32_t cmdsize
Definition: loader.h:991
twolevel_hint::itoc
uint32_t itoc
Definition: loader.h:1015
dylinker_command
Definition: loader.h:653
routines_command::reserved3
uint32_t reserved3
Definition: loader.h:706
dylib::current_version
uint32_t current_version
Definition: loader.h:539
symseg_command::size
uint32_t size
Definition: loader.h:1338
dysymtab_command::cmdsize
uint32_t cmdsize
Definition: loader.h:785
twolevel_hints_command::cmd
uint32_t cmd
Definition: loader.h:990
vm_prot_t
int vm_prot_t
Definition: vm_prot.h:75
build_version_command::ntools
uint32_t ntools
Definition: loader.h:1122
sub_umbrella_command
Definition: loader.h:601
encryption_info_command_64::cryptid
uint32_t cryptid
Definition: loader.h:1090
segment_command_64::maxprot
vm_prot_t maxprot
Definition: loader.h:298
routines_command::reserved2
uint32_t reserved2
Definition: loader.h:705
section_64::reserved1
uint32_t reserved1
Definition: loader.h:361
build_version_command::platform
uint32_t platform
Definition: loader.h:1119
build_version_command::sdk
uint32_t sdk
Definition: loader.h:1121
build_tool_version::version
uint32_t version
Definition: loader.h:1127
dylib_module::nextrel
uint32_t nextrel
Definition: loader.h:930
dysymtab_command::nextrefsyms
uint32_t nextrefsyms
Definition: loader.h:844
dylib_module::objc_module_info_size
uint32_t objc_module_info_size
Definition: loader.h:942
segment_command_64::vmaddr
uint64_t vmaddr
Definition: loader.h:294
routines_command_64::reserved2
uint64_t reserved2
Definition: loader.h:722
routines_command
Definition: loader.h:698
encryption_info_command_64::cryptoff
uint32_t cryptoff
Definition: loader.h:1088
load_command
Definition: loader.h:167
dysymtab_command::nlocrel
uint32_t nlocrel
Definition: loader.h:895
load_command::cmd
uint32_t cmd
Definition: loader.h:168
sub_library_command::cmd
uint32_t cmd
Definition: loader.h:623
mach_header::cpusubtype
cpu_subtype_t cpusubtype
Definition: loader.h:50
dylib_module_64::module_name
uint32_t module_name
Definition: loader.h:947
uuid_command::uuid
uint8_t uuid[16]
Definition: loader.h:1041
section_64::addr
uint64_t addr
Definition: loader.h:354
routines_command_64
Definition: loader.h:715
dylib_module_64::objc_module_info_size
uint32_t objc_module_info_size
Definition: loader.h:967
segment_command_64::filesize
uint64_t filesize
Definition: loader.h:297
symseg_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1336
twolevel_hints_command
Definition: loader.h:989
dysymtab_command::indirectsymoff
uint32_t indirectsymoff
Definition: loader.h:856
linker_option_command::cmd
uint32_t cmd
Definition: loader.h:1318
routines_command::init_address
uint32_t init_address
Definition: loader.h:701
dylib_module_64::nextrel
uint32_t nextrel
Definition: loader.h:957
sub_framework_command::cmd
uint32_t cmd
Definition: loader.h:568
sub_library_command::sub_library
union lc_str sub_library
Definition: loader.h:625
build_version_command::cmd
uint32_t cmd
Definition: loader.h:1116
version_min_command::cmd
uint32_t cmd
Definition: loader.h:1101
tlv_descriptor
Definition: loader.h:1413
routines_command::reserved5
uint32_t reserved5
Definition: loader.h:708
dysymtab_command::extrefsymoff
uint32_t extrefsymoff
Definition: loader.h:843
tlv_descriptor::offset
unsigned long offset
Definition: loader.h:1417
section::offset
uint32_t offset
Definition: loader.h:342
symtab_command::strsize
uint32_t strsize
Definition: loader.h:740
section_64::reloff
uint32_t reloff
Definition: loader.h:358
ident_command
Definition: loader.h:1347
fvmlib_command::cmdsize
uint32_t cmdsize
Definition: loader.h:523
segment_command::filesize
uint32_t filesize
Definition: loader.h:277
dylib_module::ilocalsym
uint32_t ilocalsym
Definition: loader.h:926
data_in_code_entry::offset
uint32_t offset
Definition: loader.h:1397
dylib_module_64::objc_module_info_addr
uint64_t objc_module_info_addr
Definition: loader.h:969
symtab_command::cmd
uint32_t cmd
Definition: loader.h:735
dylib_module_64::nrefsym
uint32_t nrefsym
Definition: loader.h:952
mach_header_64::sizeofcmds
uint32_t sizeofcmds
Definition: loader.h:71
symtab_command::symoff
uint32_t symoff
Definition: loader.h:737
mach_header::filetype
uint32_t filetype
Definition: loader.h:51
encryption_info_command_64::cryptsize
uint32_t cryptsize
Definition: loader.h:1089
dylib_table_of_contents::symbol_index
uint32_t symbol_index
Definition: loader.h:912
ident_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1349
dysymtab_command::iundefsym
uint32_t iundefsym
Definition: loader.h:808
mach_header::flags
uint32_t flags
Definition: loader.h:54
linkedit_data_command::datasize
uint32_t datasize
Definition: loader.h:1065
dylib_module_64::iextdefsym
uint32_t iextdefsym
Definition: loader.h:949
mach_header_64::reserved
uint32_t reserved
Definition: loader.h:73
section_64::align
uint32_t align
Definition: loader.h:357
source_version_command::version
uint64_t version
Definition: loader.h:1387
note_command::cmdsize
uint32_t cmdsize
Definition: loader.h:1426
dyld_info_command::bind_size
uint32_t bind_size
Definition: loader.h:1180
dylib_module
Definition: loader.h:919
dylib_reference::isym
uint32_t isym
Definition: loader.h:981
linker_option_command
Definition: loader.h:1317
entry_point_command::cmd
uint32_t cmd
Definition: loader.h:1373
thread_command::cmdsize
uint32_t cmdsize
Definition: loader.h:683
dysymtab_command::ilocalsym
uint32_t ilocalsym
Definition: loader.h:802


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:29