1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
3 * Copyright (c) 2005-2008 Apple Inc. All rights reserved.
5 * @APPLE_LICENSE_HEADER_START@
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
22 * @APPLE_LICENSE_HEADER_END@
24 #ifndef __MACH_O_FILE_ABSTRACTION__
25 #define __MACH_O_FILE_ABSTRACTION__
27 #include <mach-o/loader.h>
28 #include <mach-o/nlist.h>
29 #include <mach-o/reloc.h>
30 #include <mach-o/fat.h>
31 #include <mach-o/stab.h>
32 #include <mach-o/reloc.h>
33 #include <mach-o/ppc/reloc.h>
34 #include <mach-o/x86_64/reloc.h>
35 #include <mach-o/arm/reloc.h>
36 #include <mach-o/compact_unwind_encoding.h>
37 #include <mach/machine.h>
39 #include "FileAbstraction.hpp"
42 // stuff that will eventually go away once newer cctools headers are widespread
43 #ifndef CPU_SUBTYPE_ARM_V5TEJ
44 #define CPU_SUBTYPE_ARM_V5TEJ ((cpu_subtype_t) 7)
46 #ifndef CPU_SUBTYPE_ARM_XSCALE
47 #define CPU_SUBTYPE_ARM_XSCALE ((cpu_subtype_t) 8)
49 #ifndef CPU_SUBTYPE_ARM_V7
50 #define CPU_SUBTYPE_ARM_V7 ((cpu_subtype_t) 9)
52 #ifndef ARM_THUMB_32BIT_BRANCH
53 #define ARM_THUMB_32BIT_BRANCH 7
55 #ifndef N_ARM_THUMB_DEF
56 #define N_ARM_THUMB_DEF 0x0008
58 #ifndef MH_DEAD_STRIPPABLE_DYLIB
59 #define MH_DEAD_STRIPPABLE_DYLIB 0x400000
61 #ifndef MH_KEXT_BUNDLE
62 #define MH_KEXT_BUNDLE 11
65 #define LC_DYLD_INFO 0x22 /* compressed dyld information */
66 #define LC_DYLD_INFO_ONLY (0x22|LC_REQ_DYLD) /* compressed dyld information only */
68 struct dyld_info_command {
69 uint32_t cmd; /* LC_DYLD_INFO or LC_DYLD_INFO_ONLY */
70 uint32_t cmdsize; /* sizeof(struct dyld_info_command) */
71 uint32_t rebase_off; /* file offset to rebase info */
72 uint32_t rebase_size; /* size of rebase info */
73 uint32_t bind_off; /* file offset to binding info */
74 uint32_t bind_size; /* size of binding info */
75 uint32_t weak_bind_off; /* file offset to weak binding info */
76 uint32_t weak_bind_size; /* size of weak binding info */
77 uint32_t lazy_bind_off; /* file offset to lazy binding info */
78 uint32_t lazy_bind_size; /* size of lazy binding infs */
79 uint32_t export_off; /* file offset to lazy binding info */
80 uint32_t export_size; /* size of lazy binding infs */
83 #define REBASE_TYPE_POINTER 1
84 #define REBASE_TYPE_TEXT_ABSOLUTE32 2
85 #define REBASE_TYPE_TEXT_PCREL32 3
87 #define REBASE_OPCODE_MASK 0xF0
88 #define REBASE_IMMEDIATE_MASK 0x0F
89 #define REBASE_OPCODE_DONE 0x00
90 #define REBASE_OPCODE_SET_TYPE_IMM 0x10
91 #define REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x20
92 #define REBASE_OPCODE_ADD_ADDR_ULEB 0x30
93 #define REBASE_OPCODE_ADD_ADDR_IMM_SCALED 0x40
94 #define REBASE_OPCODE_DO_REBASE_IMM_TIMES 0x50
95 #define REBASE_OPCODE_DO_REBASE_ULEB_TIMES 0x60
96 #define REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB 0x70
97 #define REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB 0x80
99 #define BIND_TYPE_POINTER 1
100 #define BIND_TYPE_TEXT_ABSOLUTE32 2
101 #define BIND_TYPE_TEXT_PCREL32 3
103 #define BIND_SPECIAL_DYLIB_SELF 0
104 #define BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE -1
105 #define BIND_SPECIAL_DYLIB_FLAT_LOOKUP -2
107 #define BIND_SYMBOL_FLAGS_WEAK_IMPORT 0x1
108 #define BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION 0x8
110 #define BIND_OPCODE_MASK 0xF0
111 #define BIND_IMMEDIATE_MASK 0x0F
112 #define BIND_OPCODE_DONE 0x00
113 #define BIND_OPCODE_SET_DYLIB_ORDINAL_IMM 0x10
114 #define BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB 0x20
115 #define BIND_OPCODE_SET_DYLIB_SPECIAL_IMM 0x30
116 #define BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM 0x40
117 #define BIND_OPCODE_SET_TYPE_IMM 0x50
118 #define BIND_OPCODE_SET_ADDEND_SLEB 0x60
119 #define BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x70
120 #define BIND_OPCODE_ADD_ADDR_ULEB 0x80
121 #define BIND_OPCODE_DO_BIND 0x90
122 #define BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xA0
123 #define BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xB0
124 #define BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xC0
126 #define EXPORT_SYMBOL_FLAGS_KIND_MASK 0x03
127 #define EXPORT_SYMBOL_FLAGS_KIND_REGULAR 0x00
128 #define EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL 0x01
129 #define EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION 0x04
130 #define EXPORT_SYMBOL_FLAGS_INDIRECT_DEFINITION 0x08
131 #define EXPORT_SYMBOL_FLAGS_HAS_SPECIALIZATIONS 0x10
137 // This abstraction layer makes every mach-o file look like a 64-bit mach-o file with native endianness
143 // mach-o file header
145 template <typename P> struct macho_header_content {};
146 template <> struct macho_header_content<Pointer32<BigEndian> > { mach_header fields; };
147 template <> struct macho_header_content<Pointer64<BigEndian> > { mach_header_64 fields; };
148 template <> struct macho_header_content<Pointer32<LittleEndian> > { mach_header fields; };
149 template <> struct macho_header_content<Pointer64<LittleEndian> > { mach_header_64 fields; };
151 template <typename P>
154 uint32_t magic() const INLINE { return E::get32(header.fields.magic); }
155 void set_magic(uint32_t value) INLINE { E::set32(header.fields.magic, value); }
157 uint32_t cputype() const INLINE { return E::get32(header.fields.cputype); }
158 void set_cputype(uint32_t value) INLINE { E::set32((uint32_t&)header.fields.cputype, value); }
160 uint32_t cpusubtype() const INLINE { return E::get32(header.fields.cpusubtype); }
161 void set_cpusubtype(uint32_t value) INLINE { E::set32((uint32_t&)header.fields.cpusubtype, value); }
163 uint32_t filetype() const INLINE { return E::get32(header.fields.filetype); }
164 void set_filetype(uint32_t value) INLINE { E::set32(header.fields.filetype, value); }
166 uint32_t ncmds() const INLINE { return E::get32(header.fields.ncmds); }
167 void set_ncmds(uint32_t value) INLINE { E::set32(header.fields.ncmds, value); }
169 uint32_t sizeofcmds() const INLINE { return E::get32(header.fields.sizeofcmds); }
170 void set_sizeofcmds(uint32_t value) INLINE { E::set32(header.fields.sizeofcmds, value); }
172 uint32_t flags() const INLINE { return E::get32(header.fields.flags); }
173 void set_flags(uint32_t value) INLINE { E::set32(header.fields.flags, value); }
175 uint32_t reserved() const INLINE { return E::get32(header.fields.reserved); }
176 void set_reserved(uint32_t value) INLINE { E::set32(header.fields.reserved, value); }
178 typedef typename P::E E;
180 macho_header_content<P> header;
185 // mach-o load command
187 template <typename P>
188 class macho_load_command {
190 uint32_t cmd() const INLINE { return E::get32(command.cmd); }
191 void set_cmd(uint32_t value) INLINE { E::set32(command.cmd, value); }
193 uint32_t cmdsize() const INLINE { return E::get32(command.cmdsize); }
194 void set_cmdsize(uint32_t value) INLINE { E::set32(command.cmdsize, value); }
196 typedef typename P::E E;
198 load_command command;
203 // mach-o segment load command
205 template <typename P> struct macho_segment_content {};
206 template <> struct macho_segment_content<Pointer32<BigEndian> > { segment_command fields; enum { CMD = LC_SEGMENT }; };
207 template <> struct macho_segment_content<Pointer64<BigEndian> > { segment_command_64 fields; enum { CMD = LC_SEGMENT_64 }; };
208 template <> struct macho_segment_content<Pointer32<LittleEndian> > { segment_command fields; enum { CMD = LC_SEGMENT }; };
209 template <> struct macho_segment_content<Pointer64<LittleEndian> > { segment_command_64 fields; enum { CMD = LC_SEGMENT_64 }; };
211 template <typename P>
212 class macho_segment_command {
214 uint32_t cmd() const INLINE { return E::get32(segment.fields.cmd); }
215 void set_cmd(uint32_t value) INLINE { E::set32(segment.fields.cmd, value); }
217 uint32_t cmdsize() const INLINE { return E::get32(segment.fields.cmdsize); }
218 void set_cmdsize(uint32_t value) INLINE { E::set32(segment.fields.cmdsize, value); }
220 const char* segname() const INLINE { return segment.fields.segname; }
221 void set_segname(const char* value) INLINE { strncpy(segment.fields.segname, value, 16); }
223 uint64_t vmaddr() const INLINE { return P::getP(segment.fields.vmaddr); }
224 void set_vmaddr(uint64_t value) INLINE { P::setP(segment.fields.vmaddr, value); }
226 uint64_t vmsize() const INLINE { return P::getP(segment.fields.vmsize); }
227 void set_vmsize(uint64_t value) INLINE { P::setP(segment.fields.vmsize, value); }
229 uint64_t fileoff() const INLINE { return P::getP(segment.fields.fileoff); }
230 void set_fileoff(uint64_t value) INLINE { P::setP(segment.fields.fileoff, value); }
232 uint64_t filesize() const INLINE { return P::getP(segment.fields.filesize); }
233 void set_filesize(uint64_t value) INLINE { P::setP(segment.fields.filesize, value); }
235 uint32_t maxprot() const INLINE { return E::get32(segment.fields.maxprot); }
236 void set_maxprot(uint32_t value) INLINE { E::set32((uint32_t&)segment.fields.maxprot, value); }
238 uint32_t initprot() const INLINE { return E::get32(segment.fields.initprot); }
239 void set_initprot(uint32_t value) INLINE { E::set32((uint32_t&)segment.fields.initprot, value); }
241 uint32_t nsects() const INLINE { return E::get32(segment.fields.nsects); }
242 void set_nsects(uint32_t value) INLINE { E::set32(segment.fields.nsects, value); }
244 uint32_t flags() const INLINE { return E::get32(segment.fields.flags); }
245 void set_flags(uint32_t value) INLINE { E::set32(segment.fields.flags, value); }
248 CMD = macho_segment_content<P>::CMD
251 typedef typename P::E E;
253 macho_segment_content<P> segment;
260 template <typename P> struct macho_section_content {};
261 template <> struct macho_section_content<Pointer32<BigEndian> > { section fields; };
262 template <> struct macho_section_content<Pointer64<BigEndian> > { section_64 fields; };
263 template <> struct macho_section_content<Pointer32<LittleEndian> > { section fields; };
264 template <> struct macho_section_content<Pointer64<LittleEndian> > { section_64 fields; };
266 template <typename P>
267 class macho_section {
269 const char* sectname() const INLINE { return section.fields.sectname; }
270 void set_sectname(const char* value) INLINE { strncpy(section.fields.sectname, value, 16); }
272 const char* segname() const INLINE { return section.fields.segname; }
273 void set_segname(const char* value) INLINE { strncpy(section.fields.segname, value, 16); }
275 uint64_t addr() const INLINE { return P::getP(section.fields.addr); }
276 void set_addr(uint64_t value) INLINE { P::setP(section.fields.addr, value); }
278 uint64_t size() const INLINE { return P::getP(section.fields.size); }
279 void set_size(uint64_t value) INLINE { P::setP(section.fields.size, value); }
281 uint32_t offset() const INLINE { return E::get32(section.fields.offset); }
282 void set_offset(uint32_t value) INLINE { E::set32(section.fields.offset, value); }
284 uint32_t align() const INLINE { return E::get32(section.fields.align); }
285 void set_align(uint32_t value) INLINE { E::set32(section.fields.align, value); }
287 uint32_t reloff() const INLINE { return E::get32(section.fields.reloff); }
288 void set_reloff(uint32_t value) INLINE { E::set32(section.fields.reloff, value); }
290 uint32_t nreloc() const INLINE { return E::get32(section.fields.nreloc); }
291 void set_nreloc(uint32_t value) INLINE { E::set32(section.fields.nreloc, value); }
293 uint32_t flags() const INLINE { return E::get32(section.fields.flags); }
294 void set_flags(uint32_t value) INLINE { E::set32(section.fields.flags, value); }
296 uint32_t reserved1() const INLINE { return E::get32(section.fields.reserved1); }
297 void set_reserved1(uint32_t value) INLINE { E::set32(section.fields.reserved1, value); }
299 uint32_t reserved2() const INLINE { return E::get32(section.fields.reserved2); }
300 void set_reserved2(uint32_t value) INLINE { E::set32(section.fields.reserved2, value); }
302 typedef typename P::E E;
304 macho_section_content<P> section;
309 // mach-o dylib load command
311 template <typename P>
312 class macho_dylib_command {
314 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
315 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
317 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
318 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
320 uint32_t name_offset() const INLINE { return E::get32(fields.dylib.name.offset); }
321 void set_name_offset(uint32_t value) INLINE { E::set32(fields.dylib.name.offset, value); }
323 uint32_t timestamp() const INLINE { return E::get32(fields.dylib.timestamp); }
324 void set_timestamp(uint32_t value) INLINE { E::set32(fields.dylib.timestamp, value); }
326 uint32_t current_version() const INLINE { return E::get32(fields.dylib.current_version); }
327 void set_current_version(uint32_t value) INLINE { E::set32(fields.dylib.current_version, value); }
329 uint32_t compatibility_version() const INLINE { return E::get32(fields.dylib.compatibility_version); }
330 void set_compatibility_version(uint32_t value) INLINE { E::set32(fields.dylib.compatibility_version, value); }
332 const char* name() const INLINE { return (const char*)&fields + name_offset(); }
333 void set_name_offset() INLINE { set_name_offset(sizeof(fields)); }
335 typedef typename P::E E;
337 dylib_command fields;
342 // mach-o dylinker load command
344 template <typename P>
345 class macho_dylinker_command {
347 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
348 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
350 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
351 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
353 uint32_t name_offset() const INLINE { return E::get32(fields.name.offset); }
354 void set_name_offset(uint32_t value) INLINE { E::set32(fields.name.offset, value); }
356 const char* name() const INLINE { return (const char*)&fields + name_offset(); }
357 void set_name_offset() INLINE { set_name_offset(sizeof(fields)); }
359 typedef typename P::E E;
361 dylinker_command fields;
366 // mach-o sub_framework load command
368 template <typename P>
369 class macho_sub_framework_command {
371 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
372 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
374 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
375 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
377 uint32_t umbrella_offset() const INLINE { return E::get32(fields.umbrella.offset); }
378 void set_umbrella_offset(uint32_t value) INLINE { E::set32(fields.umbrella.offset, value); }
380 const char* umbrella() const INLINE { return (const char*)&fields + umbrella_offset(); }
381 void set_umbrella_offset() INLINE { set_umbrella_offset(sizeof(fields)); }
383 typedef typename P::E E;
385 sub_framework_command fields;
390 // mach-o sub_client load command
392 template <typename P>
393 class macho_sub_client_command {
395 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
396 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
398 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
399 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
401 uint32_t client_offset() const INLINE { return E::get32(fields.client.offset); }
402 void set_client_offset(uint32_t value) INLINE { E::set32(fields.client.offset, value); }
404 const char* client() const INLINE { return (const char*)&fields + client_offset(); }
405 void set_client_offset() INLINE { set_client_offset(sizeof(fields)); }
407 typedef typename P::E E;
409 sub_client_command fields;
414 // mach-o sub_umbrella load command
416 template <typename P>
417 class macho_sub_umbrella_command {
419 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
420 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
422 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
423 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
425 uint32_t sub_umbrella_offset() const INLINE { return E::get32(fields.sub_umbrella.offset); }
426 void set_sub_umbrella_offset(uint32_t value) INLINE { E::set32(fields.sub_umbrella.offset, value); }
428 const char* sub_umbrella() const INLINE { return (const char*)&fields + sub_umbrella_offset(); }
429 void set_sub_umbrella_offset() INLINE { set_sub_umbrella_offset(sizeof(fields)); }
431 typedef typename P::E E;
433 sub_umbrella_command fields;
438 // mach-o sub_library load command
440 template <typename P>
441 class macho_sub_library_command {
443 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
444 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
446 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
447 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
449 uint32_t sub_library_offset() const INLINE { return E::get32(fields.sub_library.offset); }
450 void set_sub_library_offset(uint32_t value) INLINE { E::set32(fields.sub_library.offset, value); }
452 const char* sub_library() const INLINE { return (const char*)&fields + sub_library_offset(); }
453 void set_sub_library_offset() INLINE { set_sub_library_offset(sizeof(fields)); }
455 typedef typename P::E E;
457 sub_library_command fields;
462 // mach-o uuid load command
464 template <typename P>
465 class macho_uuid_command {
467 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
468 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
470 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
471 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
473 const uint8_t* uuid() const INLINE { return fields.uuid; }
474 void set_uuid(uint8_t u[16]) INLINE { memcpy(&fields.uuid, u, 16); }
476 typedef typename P::E E;
483 // mach-o routines load command
485 template <typename P> struct macho_routines_content {};
486 template <> struct macho_routines_content<Pointer32<BigEndian> > { routines_command fields; enum { CMD = LC_ROUTINES }; };
487 template <> struct macho_routines_content<Pointer64<BigEndian> > { routines_command_64 fields; enum { CMD = LC_ROUTINES_64 }; };
488 template <> struct macho_routines_content<Pointer32<LittleEndian> > { routines_command fields; enum { CMD = LC_ROUTINES }; };
489 template <> struct macho_routines_content<Pointer64<LittleEndian> > { routines_command_64 fields; enum { CMD = LC_ROUTINES_64 }; };
491 template <typename P>
492 class macho_routines_command {
494 uint32_t cmd() const INLINE { return E::get32(routines.fields.cmd); }
495 void set_cmd(uint32_t value) INLINE { E::set32(routines.fields.cmd, value); }
497 uint32_t cmdsize() const INLINE { return E::get32(routines.fields.cmdsize); }
498 void set_cmdsize(uint32_t value) INLINE { E::set32(routines.fields.cmdsize, value); }
500 uint64_t init_address() const INLINE { return P::getP(routines.fields.init_address); }
501 void set_init_address(uint64_t value) INLINE { P::setP(routines.fields.init_address, value); }
503 uint64_t init_module() const INLINE { return P::getP(routines.fields.init_module); }
504 void set_init_module(uint64_t value) INLINE { P::setP(routines.fields.init_module, value); }
506 uint64_t reserved1() const INLINE { return P::getP(routines.fields.reserved1); }
507 void set_reserved1(uint64_t value) INLINE { P::setP(routines.fields.reserved1, value); }
509 uint64_t reserved2() const INLINE { return P::getP(routines.fields.reserved2); }
510 void set_reserved2(uint64_t value) INLINE { P::setP(routines.fields.reserved2, value); }
512 uint64_t reserved3() const INLINE { return P::getP(routines.fields.reserved3); }
513 void set_reserved3(uint64_t value) INLINE { P::setP(routines.fields.reserved3, value); }
515 uint64_t reserved4() const INLINE { return P::getP(routines.fields.reserved4); }
516 void set_reserved4(uint64_t value) INLINE { P::setP(routines.fields.reserved4, value); }
518 uint64_t reserved5() const INLINE { return P::getP(routines.fields.reserved5); }
519 void set_reserved5(uint64_t value) INLINE { P::setP(routines.fields.reserved5, value); }
521 uint64_t reserved6() const INLINE { return P::getP(routines.fields.reserved6); }
522 void set_reserved6(uint64_t value) INLINE { P::setP(routines.fields.reserved6, value); }
524 typedef typename P::E E;
526 CMD = macho_routines_content<P>::CMD
529 macho_routines_content<P> routines;
534 // mach-o symbol table load command
536 template <typename P>
537 class macho_symtab_command {
539 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
540 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
542 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
543 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
545 uint32_t symoff() const INLINE { return E::get32(fields.symoff); }
546 void set_symoff(uint32_t value) INLINE { E::set32(fields.symoff, value); }
548 uint32_t nsyms() const INLINE { return E::get32(fields.nsyms); }
549 void set_nsyms(uint32_t value) INLINE { E::set32(fields.nsyms, value); }
551 uint32_t stroff() const INLINE { return E::get32(fields.stroff); }
552 void set_stroff(uint32_t value) INLINE { E::set32(fields.stroff, value); }
554 uint32_t strsize() const INLINE { return E::get32(fields.strsize); }
555 void set_strsize(uint32_t value) INLINE { E::set32(fields.strsize, value); }
558 typedef typename P::E E;
560 symtab_command fields;
565 // mach-o dynamic symbol table load command
567 template <typename P>
568 class macho_dysymtab_command {
570 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
571 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
573 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
574 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
576 uint32_t ilocalsym() const INLINE { return E::get32(fields.ilocalsym); }
577 void set_ilocalsym(uint32_t value) INLINE { E::set32(fields.ilocalsym, value); }
579 uint32_t nlocalsym() const INLINE { return E::get32(fields.nlocalsym); }
580 void set_nlocalsym(uint32_t value) INLINE { E::set32(fields.nlocalsym, value); }
582 uint32_t iextdefsym() const INLINE { return E::get32(fields.iextdefsym); }
583 void set_iextdefsym(uint32_t value) INLINE { E::set32(fields.iextdefsym, value); }
585 uint32_t nextdefsym() const INLINE { return E::get32(fields.nextdefsym); }
586 void set_nextdefsym(uint32_t value) INLINE { E::set32(fields.nextdefsym, value); }
588 uint32_t iundefsym() const INLINE { return E::get32(fields.iundefsym); }
589 void set_iundefsym(uint32_t value) INLINE { E::set32(fields.iundefsym, value); }
591 uint32_t nundefsym() const INLINE { return E::get32(fields.nundefsym); }
592 void set_nundefsym(uint32_t value) INLINE { E::set32(fields.nundefsym, value); }
594 uint32_t tocoff() const INLINE { return E::get32(fields.tocoff); }
595 void set_tocoff(uint32_t value) INLINE { E::set32(fields.tocoff, value); }
597 uint32_t ntoc() const INLINE { return E::get32(fields.ntoc); }
598 void set_ntoc(uint32_t value) INLINE { E::set32(fields.ntoc, value); }
600 uint32_t modtaboff() const INLINE { return E::get32(fields.modtaboff); }
601 void set_modtaboff(uint32_t value) INLINE { E::set32(fields.modtaboff, value); }
603 uint32_t nmodtab() const INLINE { return E::get32(fields.nmodtab); }
604 void set_nmodtab(uint32_t value) INLINE { E::set32(fields.nmodtab, value); }
606 uint32_t extrefsymoff() const INLINE { return E::get32(fields.extrefsymoff); }
607 void set_extrefsymoff(uint32_t value) INLINE { E::set32(fields.extrefsymoff, value); }
609 uint32_t nextrefsyms() const INLINE { return E::get32(fields.nextrefsyms); }
610 void set_nextrefsyms(uint32_t value) INLINE { E::set32(fields.nextrefsyms, value); }
612 uint32_t indirectsymoff() const INLINE { return E::get32(fields.indirectsymoff); }
613 void set_indirectsymoff(uint32_t value) INLINE { E::set32(fields.indirectsymoff, value); }
615 uint32_t nindirectsyms() const INLINE { return E::get32(fields.nindirectsyms); }
616 void set_nindirectsyms(uint32_t value) INLINE { E::set32(fields.nindirectsyms, value); }
618 uint32_t extreloff() const INLINE { return E::get32(fields.extreloff); }
619 void set_extreloff(uint32_t value) INLINE { E::set32(fields.extreloff, value); }
621 uint32_t nextrel() const INLINE { return E::get32(fields.nextrel); }
622 void set_nextrel(uint32_t value) INLINE { E::set32(fields.nextrel, value); }
624 uint32_t locreloff() const INLINE { return E::get32(fields.locreloff); }
625 void set_locreloff(uint32_t value) INLINE { E::set32(fields.locreloff, value); }
627 uint32_t nlocrel() const INLINE { return E::get32(fields.nlocrel); }
628 void set_nlocrel(uint32_t value) INLINE { E::set32(fields.nlocrel, value); }
630 typedef typename P::E E;
632 dysymtab_command fields;
639 // mach-o module table entry (for compatibility with old ld/dyld)
641 template <typename P> struct macho_dylib_module_content {};
642 template <> struct macho_dylib_module_content<Pointer32<BigEndian> > { struct dylib_module fields; };
643 template <> struct macho_dylib_module_content<Pointer32<LittleEndian> > { struct dylib_module fields; };
644 template <> struct macho_dylib_module_content<Pointer64<BigEndian> > { struct dylib_module_64 fields; };
645 template <> struct macho_dylib_module_content<Pointer64<LittleEndian> > { struct dylib_module_64 fields; };
647 template <typename P>
648 class macho_dylib_module {
650 uint32_t module_name() const INLINE { return E::get32(module.fields.module_name); }
651 void set_module_name(uint32_t value) INLINE { E::set32(module.fields.module_name, value); }
653 uint32_t iextdefsym() const INLINE { return E::get32(module.fields.iextdefsym); }
654 void set_iextdefsym(uint32_t value) INLINE { E::set32(module.fields.iextdefsym, value); }
656 uint32_t nextdefsym() const INLINE { return E::get32(module.fields.nextdefsym); }
657 void set_nextdefsym(uint32_t value) INLINE { E::set32(module.fields.nextdefsym, value); }
659 uint32_t irefsym() const INLINE { return E::get32(module.fields.irefsym); }
660 void set_irefsym(uint32_t value) INLINE { E::set32(module.fields.irefsym, value); }
662 uint32_t nrefsym() const INLINE { return E::get32(module.fields.nrefsym); }
663 void set_nrefsym(uint32_t value) INLINE { E::set32(module.fields.nrefsym, value); }
665 uint32_t ilocalsym() const INLINE { return E::get32(module.fields.ilocalsym); }
666 void set_ilocalsym(uint32_t value) INLINE { E::set32(module.fields.ilocalsym, value); }
668 uint32_t nlocalsym() const INLINE { return E::get32(module.fields.nlocalsym); }
669 void set_nlocalsym(uint32_t value) INLINE { E::set32(module.fields.nlocalsym, value); }
671 uint32_t iextrel() const INLINE { return E::get32(module.fields.iextrel); }
672 void set_iextrel(uint32_t value) INLINE { E::set32(module.fields.iextrel, value); }
674 uint32_t nextrel() const INLINE { return E::get32(module.fields.nextrel); }
675 void set_nextrel(uint32_t value) INLINE { E::set32(module.fields.nextrel, value); }
677 uint16_t iinit() const INLINE { return E::get32(module.fields.iinit_iterm) & 0xFFFF; }
678 uint16_t iterm() const INLINE { return E::get32(module.fields.iinit_iterm) > 16; }
679 void set_iinit_iterm(uint16_t init, uint16_t term) INLINE { E::set32(module.fields.iinit_iterm, (term<<16) | (init &0xFFFF)); }
681 uint16_t ninit() const INLINE { return E::get32(module.fields.ninit_nterm) & 0xFFFF; }
682 uint16_t nterm() const INLINE { return E::get32(module.fields.ninit_nterm) > 16; }
683 void set_ninit_nterm(uint16_t init, uint16_t term) INLINE { E::set32(module.fields.ninit_nterm, (term<<16) | (init &0xFFFF)); }
685 uint64_t objc_module_info_addr() const INLINE { return P::getP(module.fields.objc_module_info_addr); }
686 void set_objc_module_info_addr(uint64_t value) INLINE { P::setP(module.fields.objc_module_info_addr, value); }
688 uint32_t objc_module_info_size() const INLINE { return E::get32(module.fields.objc_module_info_size); }
689 void set_objc_module_info_size(uint32_t value) INLINE { E::set32(module.fields.objc_module_info_size, value); }
692 typedef typename P::E E;
694 macho_dylib_module_content<P> module;
699 // mach-o dylib_reference entry
701 template <typename P>
702 class macho_dylib_reference {
704 uint32_t isym() const INLINE { return E::getBits(fields, 0, 24); }
705 void set_isym(uint32_t value) INLINE { E::setBits(fields, value, 0, 24); }
707 uint8_t flags() const INLINE { return E::getBits(fields, 24, 8); }
708 void set_flags(uint8_t value) INLINE { E::setBits(fields, value, 24, 8); }
710 typedef typename P::E E;
718 // mach-o two-level hints load command
720 template <typename P>
721 class macho_dylib_table_of_contents {
723 uint32_t symbol_index() const INLINE { return E::get32(fields.symbol_index); }
724 void set_symbol_index(uint32_t value) INLINE { E::set32(fields.symbol_index, value); }
726 uint32_t module_index() const INLINE { return E::get32(fields.module_index); }
727 void set_module_index(uint32_t value) INLINE { E::set32(fields.module_index, value); }
729 typedef typename P::E E;
731 dylib_table_of_contents fields;
737 // mach-o two-level hints load command
739 template <typename P>
740 class macho_twolevel_hints_command {
742 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
743 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
745 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
746 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
748 uint32_t offset() const INLINE { return E::get32(fields.offset); }
749 void set_offset(uint32_t value) INLINE { E::set32(fields.offset, value); }
751 uint32_t nhints() const INLINE { return E::get32(fields.nhints); }
752 void set_nhints(uint32_t value) INLINE { E::set32(fields.nhints, value); }
754 typedef typename P::E E;
756 twolevel_hints_command fields;
761 // mach-o threads load command
763 template <typename P>
764 class macho_thread_command {
766 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
767 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
769 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
770 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
772 uint32_t flavor() const INLINE { return E::get32(fields_flavor); }
773 void set_flavor(uint32_t value) INLINE { E::set32(fields_flavor, value); }
775 uint32_t count() const INLINE { return E::get32(fields_count); }
776 void set_count(uint32_t value) INLINE { E::set32(fields_count, value); }
778 uint64_t thread_register(uint32_t index) const INLINE { return P::getP(thread_registers[index]); }
779 void set_thread_register(uint32_t index, uint64_t value) INLINE { P::setP(thread_registers[index], value); }
781 typedef typename P::E E;
782 typedef typename P::uint_t pint_t;
784 struct thread_command fields;
785 uint32_t fields_flavor;
786 uint32_t fields_count;
787 pint_t thread_registers[1];
794 template <typename P>
795 class macho_linkedit_data_command {
797 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
798 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
800 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
801 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
803 uint32_t dataoff() const INLINE { return E::get32(fields.dataoff); }
804 void set_dataoff(uint32_t value) INLINE { E::set32(fields.dataoff, value); }
806 uint32_t datasize() const INLINE { return E::get32(fields.datasize); }
807 void set_datasize(uint32_t value)INLINE { E::set32(fields.datasize, value); }
810 typedef typename P::E E;
812 struct linkedit_data_command fields;
819 template <typename P>
820 class macho_rpath_command {
822 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
823 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
825 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
826 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
828 uint32_t path_offset() const INLINE { return E::get32(fields.path.offset); }
829 void set_path_offset(uint32_t value) INLINE { E::set32(fields.path.offset, value); }
831 const char* path() const INLINE { return (const char*)&fields + path_offset(); }
832 void set_path_offset() INLINE { set_path_offset(sizeof(fields)); }
835 typedef typename P::E E;
837 struct rpath_command fields;
843 // mach-o symbol table entry
845 template <typename P> struct macho_nlist_content {};
846 template <> struct macho_nlist_content<Pointer32<BigEndian> > { struct nlist fields; };
847 template <> struct macho_nlist_content<Pointer64<BigEndian> > { struct nlist_64 fields; };
848 template <> struct macho_nlist_content<Pointer32<LittleEndian> > { struct nlist fields; };
849 template <> struct macho_nlist_content<Pointer64<LittleEndian> > { struct nlist_64 fields; };
851 template <typename P>
854 uint32_t n_strx() const INLINE { return E::get32(entry.fields.n_un.n_strx); }
855 void set_n_strx(uint32_t value) INLINE { E::set32((uint32_t&)entry.fields.n_un.n_strx, value); }
857 uint8_t n_type() const INLINE { return entry.fields.n_type; }
858 void set_n_type(uint8_t value) INLINE { entry.fields.n_type = value; }
860 uint8_t n_sect() const INLINE { return entry.fields.n_sect; }
861 void set_n_sect(uint8_t value) INLINE { entry.fields.n_sect = value; }
863 uint16_t n_desc() const INLINE { return E::get16(entry.fields.n_desc); }
864 void set_n_desc(uint16_t value) INLINE { E::set16((uint16_t&)entry.fields.n_desc, value); }
866 uint64_t n_value() const INLINE { return P::getP(entry.fields.n_value); }
867 void set_n_value(uint64_t value) INLINE { P::setP(entry.fields.n_value, value); }
869 typedef typename P::E E;
871 macho_nlist_content<P> entry;
877 // mach-o relocation info
879 template <typename P>
880 class macho_relocation_info {
882 uint32_t r_address() const INLINE { return E::get32(address); }
883 void set_r_address(uint32_t value) INLINE { E::set32(address, value); }
885 uint32_t r_symbolnum() const INLINE { return E::getBits(other, 0, 24); }
886 void set_r_symbolnum(uint32_t value) INLINE { E::setBits(other, value, 0, 24); }
888 bool r_pcrel() const INLINE { return E::getBits(other, 24, 1); }
889 void set_r_pcrel(bool value) INLINE { E::setBits(other, value, 24, 1); }
891 uint8_t r_length() const INLINE { return E::getBits(other, 25, 2); }
892 void set_r_length(uint8_t value) INLINE { E::setBits(other, value, 25, 2); }
894 bool r_extern() const INLINE { return E::getBits(other, 27, 1); }
895 void set_r_extern(bool value) INLINE { E::setBits(other, value, 27, 1); }
897 uint8_t r_type() const INLINE { return E::getBits(other, 28, 4); }
898 void set_r_type(uint8_t value) INLINE { E::setBits(other, value, 28, 4); }
900 void set_r_length() INLINE { set_r_length((sizeof(typename P::uint_t)==8) ? 3 : 2); }
902 typedef typename P::E E;
910 // mach-o scattered relocation info
911 // The bit fields are always in big-endian order (see mach-o/reloc.h)
913 template <typename P>
914 class macho_scattered_relocation_info {
916 bool r_scattered() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 0, 1); }
917 void set_r_scattered(bool x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 0, 1); E::set32(other, temp); }
919 bool r_pcrel() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 1, 1); }
920 void set_r_pcrel(bool x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 1, 1); E::set32(other, temp); }
922 uint8_t r_length() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 2, 2); }
923 void set_r_length(uint8_t x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 2, 2); E::set32(other, temp); }
925 uint8_t r_type() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 4, 4); }
926 void set_r_type(uint8_t x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 4, 4); E::set32(other, temp); }
928 uint32_t r_address() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 8, 24); }
929 void set_r_address(uint32_t x) { if ( x > 0x00FFFFFF ) throw "scattered reloc r_address too large";
930 uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 8, 24); E::set32(other, temp); }
932 uint32_t r_value() const INLINE { return E::get32(value); }
933 void set_r_value(uint32_t x) INLINE { E::set32(value, x); }
935 uint32_t r_other() const INLINE { return other; }
937 void set_r_length() INLINE { set_r_length((sizeof(typename P::uint_t)==8) ? 3 : 2); }
939 typedef typename P::E E;
948 // mach-o encyrption info load command
950 template <typename P>
951 class macho_encryption_info_command {
953 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
954 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
956 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
957 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
959 uint32_t cryptoff() const INLINE { return E::get32(fields.cryptoff); }
960 void set_cryptoff(uint32_t value) INLINE { E::set32(fields.cryptoff, value); }
962 uint32_t cryptsize() const INLINE { return E::get32(fields.cryptsize); }
963 void set_cryptsize(uint32_t value) INLINE { E::set32(fields.cryptsize, value); }
965 uint32_t cryptid() const INLINE { return E::get32(fields.cryptid); }
966 void set_cryptid(uint32_t value) INLINE { E::set32(fields.cryptid, value); }
968 typedef typename P::E E;
970 encryption_info_command fields;
975 // start of __unwind_info section
977 template <typename P>
978 class macho_unwind_info_section_header {
980 uint32_t version() const INLINE { return E::get32(fields.version); }
981 void set_version(uint32_t value) INLINE { E::set32(fields.version, value); }
983 uint32_t commonEncodingsArraySectionOffset() const INLINE { return E::get32(fields.commonEncodingsArraySectionOffset); }
984 void set_commonEncodingsArraySectionOffset(uint32_t value) INLINE { E::set32(fields.commonEncodingsArraySectionOffset, value); }
986 uint32_t commonEncodingsArrayCount() const INLINE { return E::get32(fields.commonEncodingsArrayCount); }
987 void set_commonEncodingsArrayCount(uint32_t value) INLINE { E::set32(fields.commonEncodingsArrayCount, value); }
989 uint32_t personalityArraySectionOffset() const INLINE { return E::get32(fields.personalityArraySectionOffset); }
990 void set_personalityArraySectionOffset(uint32_t value) INLINE { E::set32(fields.personalityArraySectionOffset, value); }
992 uint32_t personalityArrayCount() const INLINE { return E::get32(fields.personalityArrayCount); }
993 void set_personalityArrayCount(uint32_t value) INLINE { E::set32(fields.personalityArrayCount, value); }
995 uint32_t indexSectionOffset() const INLINE { return E::get32(fields.indexSectionOffset); }
996 void set_indexSectionOffset(uint32_t value) INLINE { E::set32(fields.indexSectionOffset, value); }
998 uint32_t indexCount() const INLINE { return E::get32(fields.indexCount); }
999 void set_indexCount(uint32_t value) INLINE { E::set32(fields.indexCount, value); }
1001 typedef typename P::E E;
1003 unwind_info_section_header fields;
1009 // uwind first level index entry
1011 template <typename P>
1012 class macho_unwind_info_section_header_index_entry {
1014 uint32_t functionOffset() const INLINE { return E::get32(fields.functionOffset); }
1015 void set_functionOffset(uint32_t value) INLINE { E::set32(fields.functionOffset, value); }
1017 uint32_t secondLevelPagesSectionOffset() const INLINE { return E::get32(fields.secondLevelPagesSectionOffset); }
1018 void set_secondLevelPagesSectionOffset(uint32_t value) INLINE { E::set32(fields.secondLevelPagesSectionOffset, value); }
1020 uint32_t lsdaIndexArraySectionOffset() const INLINE { return E::get32(fields.lsdaIndexArraySectionOffset); }
1021 void set_lsdaIndexArraySectionOffset(uint32_t value) INLINE { E::set32(fields.lsdaIndexArraySectionOffset, value); }
1023 typedef typename P::E E;
1025 unwind_info_section_header_index_entry fields;
1032 template <typename P>
1033 class macho_unwind_info_section_header_lsda_index_entry {
1035 uint32_t functionOffset() const INLINE { return E::get32(fields.functionOffset); }
1036 void set_functionOffset(uint32_t value) INLINE { E::set32(fields.functionOffset, value); }
1038 uint32_t lsdaOffset() const INLINE { return E::get32(fields.lsdaOffset); }
1039 void set_lsdaOffset(uint32_t value) INLINE { E::set32(fields.lsdaOffset, value); }
1041 typedef typename P::E E;
1043 unwind_info_section_header_lsda_index_entry fields;
1048 // regular second level entry
1050 template <typename P>
1051 class macho_unwind_info_regular_second_level_entry {
1053 uint32_t functionOffset() const INLINE { return E::get32(fields.functionOffset); }
1054 void set_functionOffset(uint32_t value) INLINE { E::set32(fields.functionOffset, value); }
1056 uint32_t encoding() const INLINE { return E::get32(fields.encoding); }
1057 void set_encoding(uint32_t value) INLINE { E::set32(fields.encoding, value); }
1059 typedef typename P::E E;
1061 unwind_info_regular_second_level_entry fields;
1066 // start of second level regular page
1068 template <typename P>
1069 class macho_unwind_info_regular_second_level_page_header {
1071 uint32_t kind() const INLINE { return E::get32(fields.kind); }
1072 void set_kind(uint32_t value) INLINE { E::set32(fields.kind, value); }
1074 uint16_t entryPageOffset() const INLINE { return E::get16(fields.entryPageOffset); }
1075 void set_entryPageOffset(uint16_t value) INLINE { E::set16((uint16_t&)fields.entryPageOffset, value); }
1077 uint16_t entryCount() const INLINE { return E::get16(fields.entryCount); }
1078 void set_entryCount(uint16_t value) INLINE { E::set16((uint16_t&)fields.entryCount, value); }
1080 typedef typename P::E E;
1082 unwind_info_regular_second_level_page_header fields;
1087 // start of second level compressed page
1089 template <typename P>
1090 class macho_unwind_info_compressed_second_level_page_header {
1092 uint32_t kind() const INLINE { return E::get32(fields.kind); }
1093 void set_kind(uint32_t value) INLINE { E::set32(fields.kind, value); }
1095 uint16_t entryPageOffset() const INLINE { return E::get16(fields.entryPageOffset); }
1096 void set_entryPageOffset(uint16_t value) INLINE { E::set16((uint16_t&)fields.entryPageOffset, value); }
1098 uint16_t entryCount() const INLINE { return E::get16(fields.entryCount); }
1099 void set_entryCount(uint16_t value) INLINE { E::set16((uint16_t&)fields.entryCount, value); }
1101 uint16_t encodingsPageOffset() const INLINE { return E::get16(fields.encodingsPageOffset); }
1102 void set_encodingsPageOffset(uint16_t value) INLINE { E::set16((uint16_t&)fields.encodingsPageOffset, value); }
1104 uint16_t encodingsCount() const INLINE { return E::get16(fields.encodingsCount); }
1105 void set_encodingsCount(uint16_t value) INLINE { E::set16((uint16_t&)fields.encodingsCount, value); }
1107 typedef typename P::E E;
1109 unwind_info_compressed_second_level_page_header fields;
1114 // compressed dyld info load command
1116 template <typename P>
1117 class macho_dyld_info_command {
1119 uint32_t cmd() const INLINE { return E::get32(fields.cmd); }
1120 void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); }
1122 uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); }
1123 void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); }
1125 uint32_t rebase_off() const INLINE { return E::get32(fields.rebase_off); }
1126 void set_rebase_off(uint32_t value) INLINE { E::set32(fields.rebase_off, value); }
1128 uint32_t rebase_size() const INLINE { return E::get32(fields.rebase_size); }
1129 void set_rebase_size(uint32_t value) INLINE { E::set32(fields.rebase_size, value); }
1131 uint32_t bind_off() const INLINE { return E::get32(fields.bind_off); }
1132 void set_bind_off(uint32_t value) INLINE { E::set32(fields.bind_off, value); }
1134 uint32_t bind_size() const INLINE { return E::get32(fields.bind_size); }
1135 void set_bind_size(uint32_t value) INLINE { E::set32(fields.bind_size, value); }
1137 uint32_t weak_bind_off() const INLINE { return E::get32(fields.weak_bind_off); }
1138 void set_weak_bind_off(uint32_t value) INLINE { E::set32(fields.weak_bind_off, value); }
1140 uint32_t weak_bind_size() const INLINE { return E::get32(fields.weak_bind_size); }
1141 void set_weak_bind_size(uint32_t value) INLINE { E::set32(fields.weak_bind_size, value); }
1143 uint32_t lazy_bind_off() const INLINE { return E::get32(fields.lazy_bind_off); }
1144 void set_lazy_bind_off(uint32_t value) INLINE { E::set32(fields.lazy_bind_off, value); }
1146 uint32_t lazy_bind_size() const INLINE { return E::get32(fields.lazy_bind_size); }
1147 void set_lazy_bind_size(uint32_t value) INLINE { E::set32(fields.lazy_bind_size, value); }
1149 uint32_t export_off() const INLINE { return E::get32(fields.export_off); }
1150 void set_export_off(uint32_t value) INLINE { E::set32(fields.export_off, value); }
1152 uint32_t export_size() const INLINE { return E::get32(fields.export_size); }
1153 void set_export_size(uint32_t value) INLINE { E::set32(fields.export_size, value); }
1156 typedef typename P::E E;
1158 dyld_info_command fields;
1164 #endif // __MACH_O_FILE_ABSTRACTION__