]>
Commit | Line | Data |
---|---|---|
d696c285 A |
1 | /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*- |
2 | * | |
a645023d | 3 | * Copyright (c) 2005-2010 Apple Inc. All rights reserved. |
d696c285 A |
4 | * |
5 | * @APPLE_LICENSE_HEADER_START@ | |
6 | * | |
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 | |
12 | * file. | |
13 | * | |
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. | |
21 | * | |
22 | * @APPLE_LICENSE_HEADER_END@ | |
23 | */ | |
24 | #ifndef __MACH_O_FILE_ABSTRACTION__ | |
25 | #define __MACH_O_FILE_ABSTRACTION__ | |
26 | ||
27 | #include <mach-o/loader.h> | |
28 | #include <mach-o/nlist.h> | |
29 | #include <mach-o/reloc.h> | |
2f2f92e4 A |
30 | #include <mach-o/fat.h> |
31 | #include <mach-o/stab.h> | |
32 | #include <mach-o/reloc.h> | |
2f2f92e4 | 33 | #include <mach-o/x86_64/reloc.h> |
55e3d2f6 | 34 | #include <mach-o/compact_unwind_encoding.h> |
d696c285 | 35 | #include <mach/machine.h> |
afe874b1 | 36 | #include <stddef.h> |
f80fe69f | 37 | #include <libunwind.h> |
d696c285 | 38 | |
d696c285 | 39 | #include "FileAbstraction.hpp" |
55e3d2f6 | 40 | |
ebf6f434 | 41 | #include "configure.h" |
d696c285 | 42 | |
2f2f92e4 | 43 | // stuff that will eventually go away once newer cctools headers are widespread |
a645023d A |
44 | #ifndef LC_LOAD_UPWARD_DYLIB |
45 | #define LC_LOAD_UPWARD_DYLIB (0x23|LC_REQ_DYLD) /* load of dylib whose initializers run later */ | |
46 | #endif | |
47 | ||
2f2f92e4 A |
48 | #ifndef CPU_SUBTYPE_ARM_V5TEJ |
49 | #define CPU_SUBTYPE_ARM_V5TEJ ((cpu_subtype_t) 7) | |
50 | #endif | |
51 | #ifndef CPU_SUBTYPE_ARM_XSCALE | |
52 | #define CPU_SUBTYPE_ARM_XSCALE ((cpu_subtype_t) 8) | |
53 | #endif | |
54 | #ifndef CPU_SUBTYPE_ARM_V7 | |
55 | #define CPU_SUBTYPE_ARM_V7 ((cpu_subtype_t) 9) | |
56 | #endif | |
afe874b1 | 57 | |
2f2f92e4 A |
58 | #ifndef N_ARM_THUMB_DEF |
59 | #define N_ARM_THUMB_DEF 0x0008 | |
60 | #endif | |
55e3d2f6 A |
61 | #ifndef MH_DEAD_STRIPPABLE_DYLIB |
62 | #define MH_DEAD_STRIPPABLE_DYLIB 0x400000 | |
63 | #endif | |
64 | #ifndef MH_KEXT_BUNDLE | |
65 | #define MH_KEXT_BUNDLE 11 | |
2f2f92e4 | 66 | #endif |
55e3d2f6 A |
67 | #ifndef LC_DYLD_INFO |
68 | #define LC_DYLD_INFO 0x22 /* compressed dyld information */ | |
69 | #define LC_DYLD_INFO_ONLY (0x22|LC_REQ_DYLD) /* compressed dyld information only */ | |
70 | ||
71 | struct dyld_info_command { | |
72 | uint32_t cmd; /* LC_DYLD_INFO or LC_DYLD_INFO_ONLY */ | |
73 | uint32_t cmdsize; /* sizeof(struct dyld_info_command) */ | |
74 | uint32_t rebase_off; /* file offset to rebase info */ | |
75 | uint32_t rebase_size; /* size of rebase info */ | |
76 | uint32_t bind_off; /* file offset to binding info */ | |
77 | uint32_t bind_size; /* size of binding info */ | |
78 | uint32_t weak_bind_off; /* file offset to weak binding info */ | |
79 | uint32_t weak_bind_size; /* size of weak binding info */ | |
80 | uint32_t lazy_bind_off; /* file offset to lazy binding info */ | |
81 | uint32_t lazy_bind_size; /* size of lazy binding infs */ | |
82 | uint32_t export_off; /* file offset to lazy binding info */ | |
83 | uint32_t export_size; /* size of lazy binding infs */ | |
84 | }; | |
85 | ||
86 | #define REBASE_TYPE_POINTER 1 | |
87 | #define REBASE_TYPE_TEXT_ABSOLUTE32 2 | |
88 | #define REBASE_TYPE_TEXT_PCREL32 3 | |
89 | ||
90 | #define REBASE_OPCODE_MASK 0xF0 | |
91 | #define REBASE_IMMEDIATE_MASK 0x0F | |
92 | #define REBASE_OPCODE_DONE 0x00 | |
93 | #define REBASE_OPCODE_SET_TYPE_IMM 0x10 | |
94 | #define REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x20 | |
95 | #define REBASE_OPCODE_ADD_ADDR_ULEB 0x30 | |
96 | #define REBASE_OPCODE_ADD_ADDR_IMM_SCALED 0x40 | |
97 | #define REBASE_OPCODE_DO_REBASE_IMM_TIMES 0x50 | |
98 | #define REBASE_OPCODE_DO_REBASE_ULEB_TIMES 0x60 | |
99 | #define REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB 0x70 | |
100 | #define REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB 0x80 | |
101 | ||
102 | #define BIND_TYPE_POINTER 1 | |
103 | #define BIND_TYPE_TEXT_ABSOLUTE32 2 | |
104 | #define BIND_TYPE_TEXT_PCREL32 3 | |
105 | ||
106 | #define BIND_SPECIAL_DYLIB_SELF 0 | |
107 | #define BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE -1 | |
108 | #define BIND_SPECIAL_DYLIB_FLAT_LOOKUP -2 | |
109 | ||
110 | #define BIND_SYMBOL_FLAGS_WEAK_IMPORT 0x1 | |
111 | #define BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION 0x8 | |
112 | ||
113 | #define BIND_OPCODE_MASK 0xF0 | |
114 | #define BIND_IMMEDIATE_MASK 0x0F | |
115 | #define BIND_OPCODE_DONE 0x00 | |
116 | #define BIND_OPCODE_SET_DYLIB_ORDINAL_IMM 0x10 | |
117 | #define BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB 0x20 | |
118 | #define BIND_OPCODE_SET_DYLIB_SPECIAL_IMM 0x30 | |
119 | #define BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM 0x40 | |
120 | #define BIND_OPCODE_SET_TYPE_IMM 0x50 | |
121 | #define BIND_OPCODE_SET_ADDEND_SLEB 0x60 | |
122 | #define BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x70 | |
123 | #define BIND_OPCODE_ADD_ADDR_ULEB 0x80 | |
124 | #define BIND_OPCODE_DO_BIND 0x90 | |
125 | #define BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xA0 | |
126 | #define BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xB0 | |
127 | #define BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xC0 | |
128 | ||
129 | #define EXPORT_SYMBOL_FLAGS_KIND_MASK 0x03 | |
130 | #define EXPORT_SYMBOL_FLAGS_KIND_REGULAR 0x00 | |
131 | #define EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL 0x01 | |
132 | #define EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION 0x04 | |
133 | #define EXPORT_SYMBOL_FLAGS_INDIRECT_DEFINITION 0x08 | |
134 | #define EXPORT_SYMBOL_FLAGS_HAS_SPECIALIZATIONS 0x10 | |
135 | ||
136 | #endif | |
d696c285 | 137 | |
a645023d A |
138 | #ifndef S_THREAD_LOCAL_REGULAR |
139 | #define S_THREAD_LOCAL_REGULAR 0x11 | |
140 | #endif | |
141 | ||
142 | #ifndef S_THREAD_LOCAL_ZEROFILL | |
143 | #define S_THREAD_LOCAL_ZEROFILL 0x12 | |
144 | #endif | |
145 | ||
146 | #ifndef S_THREAD_LOCAL_VARIABLES | |
147 | #define S_THREAD_LOCAL_VARIABLES 0x13 | |
148 | #endif | |
149 | ||
150 | #ifndef S_THREAD_LOCAL_VARIABLE_POINTERS | |
151 | #define S_THREAD_LOCAL_VARIABLE_POINTERS 0x14 | |
152 | #endif | |
153 | ||
154 | #ifndef S_THREAD_LOCAL_INIT_FUNCTION_POINTERS | |
155 | #define S_THREAD_LOCAL_INIT_FUNCTION_POINTERS 0x15 | |
156 | #endif | |
157 | ||
158 | #ifndef MH_HAS_TLV_DESCRIPTORS | |
159 | #define MH_HAS_TLV_DESCRIPTORS 0x800000 | |
160 | #endif | |
161 | ||
162 | #ifndef X86_64_RELOC_TLV | |
163 | #define X86_64_RELOC_TLV 9 | |
164 | #endif | |
165 | ||
166 | #define GENERIC_RLEOC_TLV 5 | |
167 | ||
168 | #ifndef EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER | |
169 | #define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER 0x10 | |
170 | #endif | |
171 | ||
172 | #ifndef EXPORT_SYMBOL_FLAGS_REEXPORT | |
173 | #define EXPORT_SYMBOL_FLAGS_REEXPORT 0x08 | |
174 | #endif | |
175 | ||
176 | // type internal to linker | |
177 | #define BIND_TYPE_OVERRIDE_OF_WEAKDEF_IN_DYLIB 0 | |
178 | ||
179 | #ifndef LC_VERSION_MIN_MACOSX | |
180 | #define LC_VERSION_MIN_MACOSX 0x24 | |
181 | #define LC_VERSION_MIN_IPHONEOS 0x25 | |
182 | ||
183 | struct version_min_command { | |
184 | uint32_t cmd; /* LC_VERSION_MIN_MACOSX or LC_VERSION_MIN_IPHONEOS */ | |
185 | uint32_t cmdsize; /* sizeof(struct min_version_command) */ | |
186 | uint32_t version; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */ | |
187 | uint32_t reserved; /* zero */ | |
188 | }; | |
189 | #endif | |
190 | ||
191 | #ifndef N_SYMBOL_RESOLVER | |
192 | #define N_SYMBOL_RESOLVER 0x100 | |
193 | #endif | |
194 | ||
195 | #ifndef LC_FUNCTION_STARTS | |
196 | #define LC_FUNCTION_STARTS 0x26 | |
197 | #endif | |
198 | ||
199 | #ifndef MH_NO_HEAP_EXECUTION | |
200 | #define MH_NO_HEAP_EXECUTION 0x1000000 | |
201 | #endif | |
202 | ||
203 | #ifndef LC_DYLD_ENVIRONMENT | |
204 | #define LC_DYLD_ENVIRONMENT 0x27 | |
205 | #endif | |
206 | ||
ebf6f434 A |
207 | #ifndef LC_DATA_IN_CODE |
208 | #define LC_DATA_IN_CODE 0x29 /* table of non-instructions in __text */ | |
f80fe69f | 209 | struct data_in_code_entry { |
ebf6f434 A |
210 | uint32_t offset; |
211 | uint16_t length; | |
212 | uint16_t kind; | |
213 | }; | |
214 | #endif | |
215 | ||
216 | #ifndef LC_DYLIB_CODE_SIGN_DRS | |
217 | #define LC_DYLIB_CODE_SIGN_DRS 0x2B | |
218 | #endif | |
a645023d | 219 | |
f80fe69f A |
220 | #ifndef LC_ENCRYPTION_INFO_64 |
221 | #define LC_ENCRYPTION_INFO_64 0x2C | |
222 | struct encryption_info_command_64 { | |
223 | uint32_t cmd; | |
224 | uint32_t cmdsize; | |
225 | uint32_t cryptoff; | |
226 | uint32_t cryptsize; | |
227 | uint32_t cryptid; | |
228 | uint32_t pad; | |
229 | }; | |
230 | #endif | |
231 | ||
232 | ||
233 | ||
afe874b1 A |
234 | #ifndef CPU_SUBTYPE_ARM_V7F |
235 | #define CPU_SUBTYPE_ARM_V7F ((cpu_subtype_t) 10) | |
236 | #endif | |
237 | #ifndef CPU_SUBTYPE_ARM_V7K | |
238 | #define CPU_SUBTYPE_ARM_V7K ((cpu_subtype_t) 12) | |
239 | #endif | |
b1f7435d A |
240 | #ifndef CPU_SUBTYPE_ARM_V7S |
241 | #define CPU_SUBTYPE_ARM_V7S ((cpu_subtype_t) 11) | |
242 | #endif | |
afe874b1 | 243 | |
ebf6f434 | 244 | |
f80fe69f A |
245 | |
246 | // hack until arm64 headers are worked out | |
247 | #define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64) | |
248 | #define CPU_SUBTYPE_ARM64_ALL 0 | |
249 | #define CPU_SUBTYPE_ARM64_V8 1 | |
250 | ||
251 | #define ARM64_RELOC_UNSIGNED 0 // for pointers | |
252 | #define ARM64_RELOC_SUBTRACTOR 1 // must be followed by a ARM64_RELOC_UNSIGNED | |
253 | #define ARM64_RELOC_BRANCH26 2 // a B/BL instruction with 26-bit displacement | |
254 | #define ARM64_RELOC_PAGE21 3 // pc-rel distance to page of target | |
255 | #define ARM64_RELOC_PAGEOFF12 4 // offset within page, scaled by r_length | |
256 | #define ARM64_RELOC_GOT_LOAD_PAGE21 5 // pc-rel distance to page of GOT slot | |
257 | #define ARM64_RELOC_GOT_LOAD_PAGEOFF12 6 // offset within page of GOT slot, scaled by r_length | |
258 | #define ARM64_RELOC_POINTER_TO_GOT 7 // for pointers to GOT slots | |
259 | #define ARM64_RELOC_TLVP_LOAD_PAGE21 8 // pc-rel distance to page of TLVP slot | |
260 | #define ARM64_RELOC_TLVP_LOAD_PAGEOFF12 9 // offset within page of TLVP slot, scaled by r_length | |
261 | #define ARM64_RELOC_ADDEND 10 // r_symbolnum is addend for next reloc | |
262 | ||
263 | ||
264 | ||
265 | #define UNW_ARM64_X0 0 | |
266 | #define UNW_ARM64_X1 1 | |
267 | #define UNW_ARM64_X2 2 | |
268 | #define UNW_ARM64_X3 3 | |
269 | #define UNW_ARM64_X4 4 | |
270 | #define UNW_ARM64_X5 5 | |
271 | #define UNW_ARM64_X6 6 | |
272 | #define UNW_ARM64_X7 7 | |
273 | #define UNW_ARM64_X8 8 | |
274 | #define UNW_ARM64_X9 9 | |
275 | #define UNW_ARM64_X10 10 | |
276 | #define UNW_ARM64_X11 11 | |
277 | #define UNW_ARM64_X12 12 | |
278 | #define UNW_ARM64_X13 13 | |
279 | #define UNW_ARM64_X14 14 | |
280 | #define UNW_ARM64_X15 15 | |
281 | #define UNW_ARM64_X16 16 | |
282 | #define UNW_ARM64_X17 17 | |
283 | #define UNW_ARM64_X18 18 | |
284 | #define UNW_ARM64_X19 19 | |
285 | #define UNW_ARM64_X20 20 | |
286 | #define UNW_ARM64_X21 21 | |
287 | #define UNW_ARM64_X22 22 | |
288 | #define UNW_ARM64_X23 23 | |
289 | #define UNW_ARM64_X24 24 | |
290 | #define UNW_ARM64_X25 25 | |
291 | #define UNW_ARM64_X26 26 | |
292 | #define UNW_ARM64_X27 27 | |
293 | #define UNW_ARM64_X28 28 | |
294 | #define UNW_ARM64_X29 29 | |
295 | #define UNW_ARM64_FP 29 | |
296 | #define UNW_ARM64_X30 30 | |
297 | #define UNW_ARM64_LR 30 | |
298 | #define UNW_ARM64_X31 31 | |
299 | #define UNW_ARM64_SP 31 | |
300 | #define UNW_ARM64_D0 64 | |
301 | #define UNW_ARM64_D1 65 | |
302 | #define UNW_ARM64_D2 66 | |
303 | #define UNW_ARM64_D3 67 | |
304 | #define UNW_ARM64_D4 68 | |
305 | #define UNW_ARM64_D5 69 | |
306 | #define UNW_ARM64_D6 70 | |
307 | #define UNW_ARM64_D7 71 | |
308 | #define UNW_ARM64_D8 72 | |
309 | #define UNW_ARM64_D9 73 | |
310 | #define UNW_ARM64_D10 74 | |
311 | #define UNW_ARM64_D11 75 | |
312 | #define UNW_ARM64_D12 76 | |
313 | #define UNW_ARM64_D13 77 | |
314 | #define UNW_ARM64_D14 78 | |
315 | #define UNW_ARM64_D15 79 | |
316 | #define UNW_ARM64_D16 80 | |
317 | #define UNW_ARM64_D17 81 | |
318 | #define UNW_ARM64_D18 82 | |
319 | #define UNW_ARM64_D19 83 | |
320 | #define UNW_ARM64_D20 84 | |
321 | #define UNW_ARM64_D21 85 | |
322 | #define UNW_ARM64_D22 86 | |
323 | #define UNW_ARM64_D23 87 | |
324 | #define UNW_ARM64_D24 88 | |
325 | #define UNW_ARM64_D25 89 | |
326 | #define UNW_ARM64_D26 90 | |
327 | #define UNW_ARM64_D27 91 | |
328 | #define UNW_ARM64_D28 92 | |
329 | #define UNW_ARM64_D29 93 | |
330 | #define UNW_ARM64_D30 94 | |
331 | #define UNW_ARM64_D31 95 | |
332 | ||
333 | #define UNWIND_ARM64_MODE_MASK 0x0F000000 | |
334 | #define UNWIND_ARM64_MODE_FRAME_OLD 0x01000000 | |
335 | #define UNWIND_ARM64_MODE_FRAMELESS 0x02000000 | |
336 | #define UNWIND_ARM64_MODE_DWARF 0x03000000 | |
337 | #define UNWIND_ARM64_MODE_FRAME 0x04000000 | |
338 | ||
339 | #define UNWIND_ARM64_FRAME_X19_X20_PAIR 0x00000001 | |
340 | #define UNWIND_ARM64_FRAME_X21_X22_PAIR 0x00000002 | |
341 | #define UNWIND_ARM64_FRAME_X23_X24_PAIR 0x00000004 | |
342 | #define UNWIND_ARM64_FRAME_X25_X26_PAIR 0x00000008 | |
343 | #define UNWIND_ARM64_FRAME_X27_X28_PAIR 0x00000010 | |
344 | #define UNWIND_ARM64_FRAME_D8_D9_PAIR 0x00000100 | |
345 | #define UNWIND_ARM64_FRAME_D10_D11_PAIR 0x00000200 | |
346 | #define UNWIND_ARM64_FRAME_D12_D13_PAIR 0x00000400 | |
347 | #define UNWIND_ARM64_FRAME_D14_D15_PAIR 0x00000800 | |
348 | ||
349 | #define UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK 0x00FFF000 | |
350 | ||
351 | #define UNWIND_ARM64_FRAME_X21_X22_PAIR_OLD 0x00000001 | |
352 | #define UNWIND_ARM64_FRAME_X23_X24_PAIR_OLD 0x00000002 | |
353 | #define UNWIND_ARM64_FRAME_X25_X26_PAIR_OLD 0x00000004 | |
354 | #define UNWIND_ARM64_FRAME_X27_X28_PAIR_OLD 0x00000008 | |
355 | #define UNWIND_ARM64_FRAME_D8_D9_PAIR_OLD 0x00000010 | |
356 | #define UNWIND_ARM64_FRAME_D10_D11_PAIR_OLD 0x00000020 | |
357 | #define UNWIND_ARM64_FRAME_D12_D13_PAIR_OLD 0x00000040 | |
358 | #define UNWIND_ARM64_FRAME_D14_D15_PAIR_OLD 0x00000080 | |
359 | ||
360 | ||
361 | #define UNWIND_ARM64_DWARF_SECTION_OFFSET 0x00FFFFFF | |
362 | ||
ebf6f434 A |
363 | #ifndef LC_SOURCE_VERSION |
364 | #define LC_SOURCE_VERSION 0x2A | |
365 | struct source_version_command { | |
366 | uint32_t cmd; /* LC_SOURCE_VERSION */ | |
367 | uint32_t cmdsize; /* 16 */ | |
368 | uint64_t version; /* A.B.C.D.E packed as a24.b10.c10.d10.e10 */ | |
369 | }; | |
370 | #endif | |
371 | ||
372 | #ifndef LC_MAIN | |
373 | #define LC_MAIN (0x28|LC_REQ_DYLD) /* replacement for LC_UNIXTHREAD */ | |
374 | struct entry_point_command { | |
375 | uint32_t cmd; /* LC_MAIN only used in MH_EXECUTE filetypes */ | |
376 | uint32_t cmdsize; /* 24 */ | |
377 | uint64_t entryoff; /* file (__TEXT) offset of main() */ | |
378 | uint64_t stacksize;/* if not zero, initial stack size */ | |
379 | }; | |
380 | #endif | |
381 | ||
382 | #ifndef LC_DYLIB_CODE_SIGN_DRS | |
383 | #define LC_DYLIB_CODE_SIGN_DRS 0x2B | |
384 | #endif | |
385 | ||
f80fe69f A |
386 | #ifndef LC_LINKER_OPTION |
387 | #define LC_LINKER_OPTION 0x2D | |
388 | ||
389 | struct linker_option_command { | |
390 | uint32_t cmd; /*LC_LINKER_OPTION only used in MH_OBJECT filetypes */ | |
391 | uint32_t cmdsize; | |
392 | uint32_t count; /* number of strings */ | |
393 | /* concatenation of zero terminated UTF8 strings. Zero filled at end to align */ | |
394 | }; | |
395 | #endif | |
396 | ||
9543cb2f A |
397 | #ifndef LC_LINKER_OPTIMIZATION_HINTS |
398 | #define LC_LINKER_OPTIMIZATION_HINTS 0x2E | |
399 | #define LOH_ARM64_ADRP_ADRP 1 | |
400 | #define LOH_ARM64_ADRP_LDR 2 | |
401 | #define LOH_ARM64_ADRP_ADD_LDR 3 | |
402 | #define LOH_ARM64_ADRP_LDR_GOT_LDR 4 | |
403 | #define LOH_ARM64_ADRP_ADD_STR 5 | |
404 | #define LOH_ARM64_ADRP_LDR_GOT_STR 6 | |
405 | #define LOH_ARM64_ADRP_ADD 7 | |
406 | #define LOH_ARM64_ADRP_LDR_GOT 8 | |
407 | #endif | |
408 | ||
f80fe69f A |
409 | #ifndef EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE |
410 | #define EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE 0x02 | |
411 | #endif | |
412 | ||
413 | ||
414 | #ifndef CPU_SUBTYPE_ARM_V8 | |
415 | #define CPU_SUBTYPE_ARM_V8 ((cpu_subtype_t) 13) | |
416 | #endif | |
417 | ||
418 | #ifndef CPU_SUBTYPE_ARM_V6M | |
419 | #define CPU_SUBTYPE_ARM_V6M ((cpu_subtype_t) 14) | |
420 | #endif | |
421 | ||
422 | #ifndef CPU_SUBTYPE_ARM_V7M | |
423 | #define CPU_SUBTYPE_ARM_V7M ((cpu_subtype_t) 15) | |
424 | #endif | |
425 | ||
426 | #ifndef CPU_SUBTYPE_ARM_V7EM | |
427 | #define CPU_SUBTYPE_ARM_V7EM ((cpu_subtype_t) 16) | |
428 | #endif | |
429 | ||
9543cb2f A |
430 | #ifndef CPU_SUBTYPE_X86_64_H |
431 | #define CPU_SUBTYPE_X86_64_H ((cpu_subtype_t) 8) | |
432 | #endif | |
ebf6f434 A |
433 | |
434 | struct ArchInfo { | |
435 | const char* archName; | |
436 | cpu_type_t cpuType; | |
437 | cpu_subtype_t cpuSubType; | |
afe874b1 | 438 | const char* llvmTriplePrefix; |
ebf6f434 A |
439 | const char* llvmTriplePrefixAlt; |
440 | bool isSubType; | |
afe874b1 A |
441 | bool supportsThumb2; |
442 | }; | |
443 | ||
ebf6f434 A |
444 | static const ArchInfo archInfoArray[] = { |
445 | #if SUPPORT_ARCH_x86_64 | |
9543cb2f A |
446 | { "x86_64", CPU_TYPE_X86_64, CPU_SUBTYPE_X86_64_ALL, "x86_64-", "", true, false }, |
447 | #endif | |
448 | #if SUPPORT_ARCH_x86_64h | |
449 | { "x86_64h", CPU_TYPE_X86_64, CPU_SUBTYPE_X86_64_H, "x86_64h-", "", true, false }, | |
ebf6f434 A |
450 | #endif |
451 | #if SUPPORT_ARCH_i386 | |
452 | { "i386", CPU_TYPE_I386, CPU_SUBTYPE_I386_ALL, "i386-", "", false, false }, | |
453 | #endif | |
454 | #if SUPPORT_ARCH_armv4t | |
455 | { "armv4t", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V4T, "armv4t-", "", true, false }, | |
456 | #define SUPPORT_ARCH_arm_any 1 | |
457 | #endif | |
458 | #if SUPPORT_ARCH_armv5 | |
459 | { "armv5", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V5TEJ, "armv5e-", "", true, false }, | |
460 | #define SUPPORT_ARCH_arm_any 1 | |
461 | #endif | |
462 | #if SUPPORT_ARCH_armv6 | |
463 | { "armv6", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V6, "armv6-", "", true, false }, | |
464 | #define SUPPORT_ARCH_arm_any 1 | |
465 | #endif | |
466 | #if SUPPORT_ARCH_armv7 | |
467 | { "armv7", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7, "thumbv7-", "armv7-", true, true }, | |
468 | #define SUPPORT_ARCH_arm_any 1 | |
b1f7435d A |
469 | #endif |
470 | #if SUPPORT_ARCH_armv7f | |
471 | { "armv7f", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7F, "thumbv7f-", "", true, true }, | |
472 | #define SUPPORT_ARCH_arm_any 1 | |
473 | #endif | |
474 | #if SUPPORT_ARCH_armv7k | |
475 | { "armv7k", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7K, "thumbv7k-", "", true, true }, | |
476 | #define SUPPORT_ARCH_arm_any 1 | |
477 | #endif | |
478 | #if SUPPORT_ARCH_armv7s | |
479 | { "armv7s", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7S, "thumbv7s-", "armv7s", true, true }, | |
480 | #define SUPPORT_ARCH_arm_any 1 | |
f80fe69f A |
481 | #endif |
482 | #if SUPPORT_ARCH_armv6m | |
483 | { "armv6m", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V6M, "thumbv6m-", "", true, false }, | |
484 | #define SUPPORT_ARCH_arm_any 1 | |
485 | #endif | |
486 | #if SUPPORT_ARCH_armv7m | |
487 | { "armv7m", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7M, "thumbv7m-", "armv7m", true, true }, | |
488 | #define SUPPORT_ARCH_arm_any 1 | |
489 | #endif | |
490 | #if SUPPORT_ARCH_armv7em | |
491 | { "armv7em", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7EM, "thumbv7em-", "armv7em", true, true }, | |
492 | #define SUPPORT_ARCH_arm_any 1 | |
493 | #endif | |
494 | #if SUPPORT_ARCH_armv8 | |
495 | { "armv8", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V8, "thumbv8-", "armv8", true, true }, | |
496 | #define SUPPORT_ARCH_arm_any 1 | |
497 | #endif | |
498 | #if SUPPORT_ARCH_arm64 | |
499 | { "arm64", CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64_ALL, "arm64-", "", false, false }, | |
500 | #endif | |
501 | #if SUPPORT_ARCH_arm64v8 | |
502 | { "arm64v8", CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64_V8, "arm64v8-", "", true, false }, | |
ebf6f434 A |
503 | #endif |
504 | { NULL, 0, 0, NULL, NULL, false, false } | |
afe874b1 A |
505 | }; |
506 | ||
f80fe69f | 507 | |
ebf6f434 A |
508 | // weird, but this include must wait until after SUPPORT_ARCH_arm_any is set up |
509 | #if SUPPORT_ARCH_arm_any | |
510 | #include <mach-o/arm/reloc.h> | |
511 | #endif | |
512 | ||
513 | // hack until newer <mach-o/arm/reloc.h> everywhere | |
514 | #define ARM_RELOC_HALF 8 | |
515 | #define ARM_RELOC_HALF_SECTDIFF 9 | |
516 | ||
afe874b1 | 517 | |
d696c285 A |
518 | |
519 | // | |
520 | // This abstraction layer makes every mach-o file look like a 64-bit mach-o file with native endianness | |
521 | // | |
522 | ||
523 | ||
524 | ||
525 | // | |
526 | // mach-o file header | |
527 | // | |
528 | template <typename P> struct macho_header_content {}; | |
529 | template <> struct macho_header_content<Pointer32<BigEndian> > { mach_header fields; }; | |
530 | template <> struct macho_header_content<Pointer64<BigEndian> > { mach_header_64 fields; }; | |
531 | template <> struct macho_header_content<Pointer32<LittleEndian> > { mach_header fields; }; | |
532 | template <> struct macho_header_content<Pointer64<LittleEndian> > { mach_header_64 fields; }; | |
533 | ||
534 | template <typename P> | |
535 | class macho_header { | |
536 | public: | |
537 | uint32_t magic() const INLINE { return E::get32(header.fields.magic); } | |
538 | void set_magic(uint32_t value) INLINE { E::set32(header.fields.magic, value); } | |
539 | ||
540 | uint32_t cputype() const INLINE { return E::get32(header.fields.cputype); } | |
541 | void set_cputype(uint32_t value) INLINE { E::set32((uint32_t&)header.fields.cputype, value); } | |
542 | ||
543 | uint32_t cpusubtype() const INLINE { return E::get32(header.fields.cpusubtype); } | |
544 | void set_cpusubtype(uint32_t value) INLINE { E::set32((uint32_t&)header.fields.cpusubtype, value); } | |
545 | ||
546 | uint32_t filetype() const INLINE { return E::get32(header.fields.filetype); } | |
547 | void set_filetype(uint32_t value) INLINE { E::set32(header.fields.filetype, value); } | |
548 | ||
549 | uint32_t ncmds() const INLINE { return E::get32(header.fields.ncmds); } | |
550 | void set_ncmds(uint32_t value) INLINE { E::set32(header.fields.ncmds, value); } | |
551 | ||
552 | uint32_t sizeofcmds() const INLINE { return E::get32(header.fields.sizeofcmds); } | |
553 | void set_sizeofcmds(uint32_t value) INLINE { E::set32(header.fields.sizeofcmds, value); } | |
554 | ||
555 | uint32_t flags() const INLINE { return E::get32(header.fields.flags); } | |
556 | void set_flags(uint32_t value) INLINE { E::set32(header.fields.flags, value); } | |
557 | ||
558 | uint32_t reserved() const INLINE { return E::get32(header.fields.reserved); } | |
559 | void set_reserved(uint32_t value) INLINE { E::set32(header.fields.reserved, value); } | |
560 | ||
561 | typedef typename P::E E; | |
562 | private: | |
563 | macho_header_content<P> header; | |
564 | }; | |
565 | ||
566 | ||
567 | // | |
568 | // mach-o load command | |
569 | // | |
570 | template <typename P> | |
571 | class macho_load_command { | |
572 | public: | |
573 | uint32_t cmd() const INLINE { return E::get32(command.cmd); } | |
574 | void set_cmd(uint32_t value) INLINE { E::set32(command.cmd, value); } | |
575 | ||
576 | uint32_t cmdsize() const INLINE { return E::get32(command.cmdsize); } | |
577 | void set_cmdsize(uint32_t value) INLINE { E::set32(command.cmdsize, value); } | |
578 | ||
579 | typedef typename P::E E; | |
580 | private: | |
581 | load_command command; | |
582 | }; | |
583 | ||
584 | ||
585 | // | |
586 | // mach-o segment load command | |
587 | // | |
588 | template <typename P> struct macho_segment_content {}; | |
589 | template <> struct macho_segment_content<Pointer32<BigEndian> > { segment_command fields; enum { CMD = LC_SEGMENT }; }; | |
590 | template <> struct macho_segment_content<Pointer64<BigEndian> > { segment_command_64 fields; enum { CMD = LC_SEGMENT_64 }; }; | |
591 | template <> struct macho_segment_content<Pointer32<LittleEndian> > { segment_command fields; enum { CMD = LC_SEGMENT }; }; | |
592 | template <> struct macho_segment_content<Pointer64<LittleEndian> > { segment_command_64 fields; enum { CMD = LC_SEGMENT_64 }; }; | |
593 | ||
594 | template <typename P> | |
595 | class macho_segment_command { | |
596 | public: | |
597 | uint32_t cmd() const INLINE { return E::get32(segment.fields.cmd); } | |
598 | void set_cmd(uint32_t value) INLINE { E::set32(segment.fields.cmd, value); } | |
599 | ||
600 | uint32_t cmdsize() const INLINE { return E::get32(segment.fields.cmdsize); } | |
601 | void set_cmdsize(uint32_t value) INLINE { E::set32(segment.fields.cmdsize, value); } | |
602 | ||
603 | const char* segname() const INLINE { return segment.fields.segname; } | |
69a49097 | 604 | void set_segname(const char* value) INLINE { strncpy(segment.fields.segname, value, 16); } |
d696c285 A |
605 | |
606 | uint64_t vmaddr() const INLINE { return P::getP(segment.fields.vmaddr); } | |
607 | void set_vmaddr(uint64_t value) INLINE { P::setP(segment.fields.vmaddr, value); } | |
608 | ||
609 | uint64_t vmsize() const INLINE { return P::getP(segment.fields.vmsize); } | |
610 | void set_vmsize(uint64_t value) INLINE { P::setP(segment.fields.vmsize, value); } | |
611 | ||
612 | uint64_t fileoff() const INLINE { return P::getP(segment.fields.fileoff); } | |
613 | void set_fileoff(uint64_t value) INLINE { P::setP(segment.fields.fileoff, value); } | |
614 | ||
615 | uint64_t filesize() const INLINE { return P::getP(segment.fields.filesize); } | |
616 | void set_filesize(uint64_t value) INLINE { P::setP(segment.fields.filesize, value); } | |
617 | ||
618 | uint32_t maxprot() const INLINE { return E::get32(segment.fields.maxprot); } | |
619 | void set_maxprot(uint32_t value) INLINE { E::set32((uint32_t&)segment.fields.maxprot, value); } | |
620 | ||
621 | uint32_t initprot() const INLINE { return E::get32(segment.fields.initprot); } | |
622 | void set_initprot(uint32_t value) INLINE { E::set32((uint32_t&)segment.fields.initprot, value); } | |
623 | ||
624 | uint32_t nsects() const INLINE { return E::get32(segment.fields.nsects); } | |
625 | void set_nsects(uint32_t value) INLINE { E::set32(segment.fields.nsects, value); } | |
626 | ||
627 | uint32_t flags() const INLINE { return E::get32(segment.fields.flags); } | |
628 | void set_flags(uint32_t value) INLINE { E::set32(segment.fields.flags, value); } | |
629 | ||
630 | enum { | |
631 | CMD = macho_segment_content<P>::CMD | |
632 | }; | |
633 | ||
634 | typedef typename P::E E; | |
635 | private: | |
636 | macho_segment_content<P> segment; | |
637 | }; | |
638 | ||
639 | ||
640 | // | |
641 | // mach-o section | |
642 | // | |
643 | template <typename P> struct macho_section_content {}; | |
644 | template <> struct macho_section_content<Pointer32<BigEndian> > { section fields; }; | |
645 | template <> struct macho_section_content<Pointer64<BigEndian> > { section_64 fields; }; | |
646 | template <> struct macho_section_content<Pointer32<LittleEndian> > { section fields; }; | |
647 | template <> struct macho_section_content<Pointer64<LittleEndian> > { section_64 fields; }; | |
648 | ||
649 | template <typename P> | |
650 | class macho_section { | |
651 | public: | |
652 | const char* sectname() const INLINE { return section.fields.sectname; } | |
69a49097 | 653 | void set_sectname(const char* value) INLINE { strncpy(section.fields.sectname, value, 16); } |
d696c285 A |
654 | |
655 | const char* segname() const INLINE { return section.fields.segname; } | |
69a49097 | 656 | void set_segname(const char* value) INLINE { strncpy(section.fields.segname, value, 16); } |
d696c285 A |
657 | |
658 | uint64_t addr() const INLINE { return P::getP(section.fields.addr); } | |
659 | void set_addr(uint64_t value) INLINE { P::setP(section.fields.addr, value); } | |
660 | ||
661 | uint64_t size() const INLINE { return P::getP(section.fields.size); } | |
662 | void set_size(uint64_t value) INLINE { P::setP(section.fields.size, value); } | |
663 | ||
664 | uint32_t offset() const INLINE { return E::get32(section.fields.offset); } | |
665 | void set_offset(uint32_t value) INLINE { E::set32(section.fields.offset, value); } | |
666 | ||
667 | uint32_t align() const INLINE { return E::get32(section.fields.align); } | |
668 | void set_align(uint32_t value) INLINE { E::set32(section.fields.align, value); } | |
669 | ||
670 | uint32_t reloff() const INLINE { return E::get32(section.fields.reloff); } | |
671 | void set_reloff(uint32_t value) INLINE { E::set32(section.fields.reloff, value); } | |
672 | ||
673 | uint32_t nreloc() const INLINE { return E::get32(section.fields.nreloc); } | |
674 | void set_nreloc(uint32_t value) INLINE { E::set32(section.fields.nreloc, value); } | |
675 | ||
676 | uint32_t flags() const INLINE { return E::get32(section.fields.flags); } | |
677 | void set_flags(uint32_t value) INLINE { E::set32(section.fields.flags, value); } | |
678 | ||
679 | uint32_t reserved1() const INLINE { return E::get32(section.fields.reserved1); } | |
680 | void set_reserved1(uint32_t value) INLINE { E::set32(section.fields.reserved1, value); } | |
681 | ||
682 | uint32_t reserved2() const INLINE { return E::get32(section.fields.reserved2); } | |
683 | void set_reserved2(uint32_t value) INLINE { E::set32(section.fields.reserved2, value); } | |
684 | ||
685 | typedef typename P::E E; | |
686 | private: | |
687 | macho_section_content<P> section; | |
688 | }; | |
689 | ||
690 | ||
691 | // | |
692 | // mach-o dylib load command | |
693 | // | |
694 | template <typename P> | |
695 | class macho_dylib_command { | |
696 | public: | |
697 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
698 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
699 | ||
700 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
701 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
702 | ||
703 | uint32_t name_offset() const INLINE { return E::get32(fields.dylib.name.offset); } | |
704 | void set_name_offset(uint32_t value) INLINE { E::set32(fields.dylib.name.offset, value); } | |
705 | ||
706 | uint32_t timestamp() const INLINE { return E::get32(fields.dylib.timestamp); } | |
707 | void set_timestamp(uint32_t value) INLINE { E::set32(fields.dylib.timestamp, value); } | |
708 | ||
709 | uint32_t current_version() const INLINE { return E::get32(fields.dylib.current_version); } | |
710 | void set_current_version(uint32_t value) INLINE { E::set32(fields.dylib.current_version, value); } | |
711 | ||
712 | uint32_t compatibility_version() const INLINE { return E::get32(fields.dylib.compatibility_version); } | |
713 | void set_compatibility_version(uint32_t value) INLINE { E::set32(fields.dylib.compatibility_version, value); } | |
714 | ||
715 | const char* name() const INLINE { return (const char*)&fields + name_offset(); } | |
716 | void set_name_offset() INLINE { set_name_offset(sizeof(fields)); } | |
717 | ||
718 | typedef typename P::E E; | |
719 | private: | |
720 | dylib_command fields; | |
721 | }; | |
722 | ||
723 | ||
724 | // | |
725 | // mach-o dylinker load command | |
726 | // | |
727 | template <typename P> | |
728 | class macho_dylinker_command { | |
729 | public: | |
730 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
731 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
732 | ||
733 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
734 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
735 | ||
736 | uint32_t name_offset() const INLINE { return E::get32(fields.name.offset); } | |
737 | void set_name_offset(uint32_t value) INLINE { E::set32(fields.name.offset, value); } | |
738 | ||
739 | const char* name() const INLINE { return (const char*)&fields + name_offset(); } | |
740 | void set_name_offset() INLINE { set_name_offset(sizeof(fields)); } | |
741 | ||
742 | typedef typename P::E E; | |
743 | private: | |
744 | dylinker_command fields; | |
745 | }; | |
746 | ||
747 | ||
748 | // | |
749 | // mach-o sub_framework load command | |
750 | // | |
751 | template <typename P> | |
752 | class macho_sub_framework_command { | |
753 | public: | |
754 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
755 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
756 | ||
757 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
758 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
759 | ||
760 | uint32_t umbrella_offset() const INLINE { return E::get32(fields.umbrella.offset); } | |
761 | void set_umbrella_offset(uint32_t value) INLINE { E::set32(fields.umbrella.offset, value); } | |
762 | ||
763 | const char* umbrella() const INLINE { return (const char*)&fields + umbrella_offset(); } | |
764 | void set_umbrella_offset() INLINE { set_umbrella_offset(sizeof(fields)); } | |
765 | ||
766 | typedef typename P::E E; | |
767 | private: | |
768 | sub_framework_command fields; | |
769 | }; | |
770 | ||
771 | ||
772 | // | |
773 | // mach-o sub_client load command | |
774 | // | |
775 | template <typename P> | |
776 | class macho_sub_client_command { | |
777 | public: | |
778 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
779 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
780 | ||
781 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
782 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
783 | ||
784 | uint32_t client_offset() const INLINE { return E::get32(fields.client.offset); } | |
785 | void set_client_offset(uint32_t value) INLINE { E::set32(fields.client.offset, value); } | |
786 | ||
787 | const char* client() const INLINE { return (const char*)&fields + client_offset(); } | |
788 | void set_client_offset() INLINE { set_client_offset(sizeof(fields)); } | |
789 | ||
790 | typedef typename P::E E; | |
791 | private: | |
792 | sub_client_command fields; | |
793 | }; | |
794 | ||
795 | ||
796 | // | |
797 | // mach-o sub_umbrella load command | |
798 | // | |
799 | template <typename P> | |
800 | class macho_sub_umbrella_command { | |
801 | public: | |
802 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
803 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
804 | ||
805 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
806 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
807 | ||
808 | uint32_t sub_umbrella_offset() const INLINE { return E::get32(fields.sub_umbrella.offset); } | |
809 | void set_sub_umbrella_offset(uint32_t value) INLINE { E::set32(fields.sub_umbrella.offset, value); } | |
810 | ||
811 | const char* sub_umbrella() const INLINE { return (const char*)&fields + sub_umbrella_offset(); } | |
812 | void set_sub_umbrella_offset() INLINE { set_sub_umbrella_offset(sizeof(fields)); } | |
813 | ||
814 | typedef typename P::E E; | |
815 | private: | |
816 | sub_umbrella_command fields; | |
817 | }; | |
818 | ||
819 | ||
820 | // | |
821 | // mach-o sub_library load command | |
822 | // | |
823 | template <typename P> | |
824 | class macho_sub_library_command { | |
825 | public: | |
826 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
827 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
828 | ||
829 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
830 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
831 | ||
832 | uint32_t sub_library_offset() const INLINE { return E::get32(fields.sub_library.offset); } | |
833 | void set_sub_library_offset(uint32_t value) INLINE { E::set32(fields.sub_library.offset, value); } | |
834 | ||
835 | const char* sub_library() const INLINE { return (const char*)&fields + sub_library_offset(); } | |
836 | void set_sub_library_offset() INLINE { set_sub_library_offset(sizeof(fields)); } | |
837 | ||
838 | typedef typename P::E E; | |
839 | private: | |
840 | sub_library_command fields; | |
841 | }; | |
842 | ||
843 | ||
844 | // | |
845 | // mach-o uuid load command | |
846 | // | |
847 | template <typename P> | |
848 | class macho_uuid_command { | |
849 | public: | |
850 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
851 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
852 | ||
853 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
854 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
855 | ||
856 | const uint8_t* uuid() const INLINE { return fields.uuid; } | |
a645023d | 857 | void set_uuid(const uint8_t u[16]) INLINE { memcpy(&fields.uuid, u, 16); } |
d696c285 A |
858 | |
859 | typedef typename P::E E; | |
860 | private: | |
861 | uuid_command fields; | |
862 | }; | |
863 | ||
864 | ||
865 | // | |
866 | // mach-o routines load command | |
867 | // | |
868 | template <typename P> struct macho_routines_content {}; | |
869 | template <> struct macho_routines_content<Pointer32<BigEndian> > { routines_command fields; enum { CMD = LC_ROUTINES }; }; | |
870 | template <> struct macho_routines_content<Pointer64<BigEndian> > { routines_command_64 fields; enum { CMD = LC_ROUTINES_64 }; }; | |
871 | template <> struct macho_routines_content<Pointer32<LittleEndian> > { routines_command fields; enum { CMD = LC_ROUTINES }; }; | |
872 | template <> struct macho_routines_content<Pointer64<LittleEndian> > { routines_command_64 fields; enum { CMD = LC_ROUTINES_64 }; }; | |
873 | ||
874 | template <typename P> | |
875 | class macho_routines_command { | |
876 | public: | |
877 | uint32_t cmd() const INLINE { return E::get32(routines.fields.cmd); } | |
878 | void set_cmd(uint32_t value) INLINE { E::set32(routines.fields.cmd, value); } | |
879 | ||
880 | uint32_t cmdsize() const INLINE { return E::get32(routines.fields.cmdsize); } | |
881 | void set_cmdsize(uint32_t value) INLINE { E::set32(routines.fields.cmdsize, value); } | |
882 | ||
883 | uint64_t init_address() const INLINE { return P::getP(routines.fields.init_address); } | |
884 | void set_init_address(uint64_t value) INLINE { P::setP(routines.fields.init_address, value); } | |
885 | ||
886 | uint64_t init_module() const INLINE { return P::getP(routines.fields.init_module); } | |
887 | void set_init_module(uint64_t value) INLINE { P::setP(routines.fields.init_module, value); } | |
888 | ||
889 | uint64_t reserved1() const INLINE { return P::getP(routines.fields.reserved1); } | |
890 | void set_reserved1(uint64_t value) INLINE { P::setP(routines.fields.reserved1, value); } | |
891 | ||
892 | uint64_t reserved2() const INLINE { return P::getP(routines.fields.reserved2); } | |
893 | void set_reserved2(uint64_t value) INLINE { P::setP(routines.fields.reserved2, value); } | |
894 | ||
895 | uint64_t reserved3() const INLINE { return P::getP(routines.fields.reserved3); } | |
896 | void set_reserved3(uint64_t value) INLINE { P::setP(routines.fields.reserved3, value); } | |
897 | ||
898 | uint64_t reserved4() const INLINE { return P::getP(routines.fields.reserved4); } | |
899 | void set_reserved4(uint64_t value) INLINE { P::setP(routines.fields.reserved4, value); } | |
900 | ||
901 | uint64_t reserved5() const INLINE { return P::getP(routines.fields.reserved5); } | |
902 | void set_reserved5(uint64_t value) INLINE { P::setP(routines.fields.reserved5, value); } | |
903 | ||
904 | uint64_t reserved6() const INLINE { return P::getP(routines.fields.reserved6); } | |
905 | void set_reserved6(uint64_t value) INLINE { P::setP(routines.fields.reserved6, value); } | |
906 | ||
907 | typedef typename P::E E; | |
908 | enum { | |
909 | CMD = macho_routines_content<P>::CMD | |
910 | }; | |
911 | private: | |
912 | macho_routines_content<P> routines; | |
913 | }; | |
914 | ||
915 | ||
916 | // | |
917 | // mach-o symbol table load command | |
918 | // | |
919 | template <typename P> | |
920 | class macho_symtab_command { | |
921 | public: | |
922 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
923 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
924 | ||
925 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
926 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
927 | ||
928 | uint32_t symoff() const INLINE { return E::get32(fields.symoff); } | |
929 | void set_symoff(uint32_t value) INLINE { E::set32(fields.symoff, value); } | |
930 | ||
931 | uint32_t nsyms() const INLINE { return E::get32(fields.nsyms); } | |
932 | void set_nsyms(uint32_t value) INLINE { E::set32(fields.nsyms, value); } | |
933 | ||
934 | uint32_t stroff() const INLINE { return E::get32(fields.stroff); } | |
935 | void set_stroff(uint32_t value) INLINE { E::set32(fields.stroff, value); } | |
936 | ||
937 | uint32_t strsize() const INLINE { return E::get32(fields.strsize); } | |
938 | void set_strsize(uint32_t value) INLINE { E::set32(fields.strsize, value); } | |
939 | ||
940 | ||
941 | typedef typename P::E E; | |
942 | private: | |
943 | symtab_command fields; | |
944 | }; | |
945 | ||
946 | ||
947 | // | |
948 | // mach-o dynamic symbol table load command | |
949 | // | |
950 | template <typename P> | |
951 | class macho_dysymtab_command { | |
952 | public: | |
953 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
954 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
955 | ||
956 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
957 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
958 | ||
959 | uint32_t ilocalsym() const INLINE { return E::get32(fields.ilocalsym); } | |
960 | void set_ilocalsym(uint32_t value) INLINE { E::set32(fields.ilocalsym, value); } | |
961 | ||
962 | uint32_t nlocalsym() const INLINE { return E::get32(fields.nlocalsym); } | |
963 | void set_nlocalsym(uint32_t value) INLINE { E::set32(fields.nlocalsym, value); } | |
964 | ||
965 | uint32_t iextdefsym() const INLINE { return E::get32(fields.iextdefsym); } | |
966 | void set_iextdefsym(uint32_t value) INLINE { E::set32(fields.iextdefsym, value); } | |
967 | ||
968 | uint32_t nextdefsym() const INLINE { return E::get32(fields.nextdefsym); } | |
969 | void set_nextdefsym(uint32_t value) INLINE { E::set32(fields.nextdefsym, value); } | |
970 | ||
971 | uint32_t iundefsym() const INLINE { return E::get32(fields.iundefsym); } | |
972 | void set_iundefsym(uint32_t value) INLINE { E::set32(fields.iundefsym, value); } | |
973 | ||
974 | uint32_t nundefsym() const INLINE { return E::get32(fields.nundefsym); } | |
975 | void set_nundefsym(uint32_t value) INLINE { E::set32(fields.nundefsym, value); } | |
976 | ||
977 | uint32_t tocoff() const INLINE { return E::get32(fields.tocoff); } | |
978 | void set_tocoff(uint32_t value) INLINE { E::set32(fields.tocoff, value); } | |
979 | ||
980 | uint32_t ntoc() const INLINE { return E::get32(fields.ntoc); } | |
981 | void set_ntoc(uint32_t value) INLINE { E::set32(fields.ntoc, value); } | |
982 | ||
983 | uint32_t modtaboff() const INLINE { return E::get32(fields.modtaboff); } | |
984 | void set_modtaboff(uint32_t value) INLINE { E::set32(fields.modtaboff, value); } | |
985 | ||
986 | uint32_t nmodtab() const INLINE { return E::get32(fields.nmodtab); } | |
987 | void set_nmodtab(uint32_t value) INLINE { E::set32(fields.nmodtab, value); } | |
988 | ||
989 | uint32_t extrefsymoff() const INLINE { return E::get32(fields.extrefsymoff); } | |
990 | void set_extrefsymoff(uint32_t value) INLINE { E::set32(fields.extrefsymoff, value); } | |
991 | ||
992 | uint32_t nextrefsyms() const INLINE { return E::get32(fields.nextrefsyms); } | |
993 | void set_nextrefsyms(uint32_t value) INLINE { E::set32(fields.nextrefsyms, value); } | |
994 | ||
995 | uint32_t indirectsymoff() const INLINE { return E::get32(fields.indirectsymoff); } | |
996 | void set_indirectsymoff(uint32_t value) INLINE { E::set32(fields.indirectsymoff, value); } | |
997 | ||
998 | uint32_t nindirectsyms() const INLINE { return E::get32(fields.nindirectsyms); } | |
999 | void set_nindirectsyms(uint32_t value) INLINE { E::set32(fields.nindirectsyms, value); } | |
1000 | ||
1001 | uint32_t extreloff() const INLINE { return E::get32(fields.extreloff); } | |
1002 | void set_extreloff(uint32_t value) INLINE { E::set32(fields.extreloff, value); } | |
1003 | ||
1004 | uint32_t nextrel() const INLINE { return E::get32(fields.nextrel); } | |
1005 | void set_nextrel(uint32_t value) INLINE { E::set32(fields.nextrel, value); } | |
1006 | ||
1007 | uint32_t locreloff() const INLINE { return E::get32(fields.locreloff); } | |
1008 | void set_locreloff(uint32_t value) INLINE { E::set32(fields.locreloff, value); } | |
1009 | ||
1010 | uint32_t nlocrel() const INLINE { return E::get32(fields.nlocrel); } | |
1011 | void set_nlocrel(uint32_t value) INLINE { E::set32(fields.nlocrel, value); } | |
1012 | ||
1013 | typedef typename P::E E; | |
1014 | private: | |
1015 | dysymtab_command fields; | |
1016 | }; | |
1017 | ||
1018 | ||
a61fdf0a A |
1019 | |
1020 | ||
1021 | // | |
1022 | // mach-o module table entry (for compatibility with old ld/dyld) | |
1023 | // | |
1024 | template <typename P> struct macho_dylib_module_content {}; | |
1025 | template <> struct macho_dylib_module_content<Pointer32<BigEndian> > { struct dylib_module fields; }; | |
1026 | template <> struct macho_dylib_module_content<Pointer32<LittleEndian> > { struct dylib_module fields; }; | |
1027 | template <> struct macho_dylib_module_content<Pointer64<BigEndian> > { struct dylib_module_64 fields; }; | |
1028 | template <> struct macho_dylib_module_content<Pointer64<LittleEndian> > { struct dylib_module_64 fields; }; | |
1029 | ||
1030 | template <typename P> | |
1031 | class macho_dylib_module { | |
1032 | public: | |
1033 | uint32_t module_name() const INLINE { return E::get32(module.fields.module_name); } | |
1034 | void set_module_name(uint32_t value) INLINE { E::set32(module.fields.module_name, value); } | |
1035 | ||
1036 | uint32_t iextdefsym() const INLINE { return E::get32(module.fields.iextdefsym); } | |
1037 | void set_iextdefsym(uint32_t value) INLINE { E::set32(module.fields.iextdefsym, value); } | |
1038 | ||
1039 | uint32_t nextdefsym() const INLINE { return E::get32(module.fields.nextdefsym); } | |
1040 | void set_nextdefsym(uint32_t value) INLINE { E::set32(module.fields.nextdefsym, value); } | |
1041 | ||
1042 | uint32_t irefsym() const INLINE { return E::get32(module.fields.irefsym); } | |
1043 | void set_irefsym(uint32_t value) INLINE { E::set32(module.fields.irefsym, value); } | |
1044 | ||
1045 | uint32_t nrefsym() const INLINE { return E::get32(module.fields.nrefsym); } | |
1046 | void set_nrefsym(uint32_t value) INLINE { E::set32(module.fields.nrefsym, value); } | |
1047 | ||
1048 | uint32_t ilocalsym() const INLINE { return E::get32(module.fields.ilocalsym); } | |
1049 | void set_ilocalsym(uint32_t value) INLINE { E::set32(module.fields.ilocalsym, value); } | |
1050 | ||
1051 | uint32_t nlocalsym() const INLINE { return E::get32(module.fields.nlocalsym); } | |
1052 | void set_nlocalsym(uint32_t value) INLINE { E::set32(module.fields.nlocalsym, value); } | |
1053 | ||
1054 | uint32_t iextrel() const INLINE { return E::get32(module.fields.iextrel); } | |
1055 | void set_iextrel(uint32_t value) INLINE { E::set32(module.fields.iextrel, value); } | |
1056 | ||
1057 | uint32_t nextrel() const INLINE { return E::get32(module.fields.nextrel); } | |
1058 | void set_nextrel(uint32_t value) INLINE { E::set32(module.fields.nextrel, value); } | |
1059 | ||
1060 | uint16_t iinit() const INLINE { return E::get32(module.fields.iinit_iterm) & 0xFFFF; } | |
1061 | uint16_t iterm() const INLINE { return E::get32(module.fields.iinit_iterm) > 16; } | |
1062 | void set_iinit_iterm(uint16_t init, uint16_t term) INLINE { E::set32(module.fields.iinit_iterm, (term<<16) | (init &0xFFFF)); } | |
1063 | ||
1064 | uint16_t ninit() const INLINE { return E::get32(module.fields.ninit_nterm) & 0xFFFF; } | |
1065 | uint16_t nterm() const INLINE { return E::get32(module.fields.ninit_nterm) > 16; } | |
1066 | void set_ninit_nterm(uint16_t init, uint16_t term) INLINE { E::set32(module.fields.ninit_nterm, (term<<16) | (init &0xFFFF)); } | |
1067 | ||
1068 | uint64_t objc_module_info_addr() const INLINE { return P::getP(module.fields.objc_module_info_addr); } | |
1069 | void set_objc_module_info_addr(uint64_t value) INLINE { P::setP(module.fields.objc_module_info_addr, value); } | |
1070 | ||
1071 | uint32_t objc_module_info_size() const INLINE { return E::get32(module.fields.objc_module_info_size); } | |
1072 | void set_objc_module_info_size(uint32_t value) INLINE { E::set32(module.fields.objc_module_info_size, value); } | |
1073 | ||
1074 | ||
1075 | typedef typename P::E E; | |
1076 | private: | |
1077 | macho_dylib_module_content<P> module; | |
1078 | }; | |
1079 | ||
1080 | ||
1081 | // | |
1082 | // mach-o dylib_reference entry | |
1083 | // | |
1084 | template <typename P> | |
1085 | class macho_dylib_reference { | |
1086 | public: | |
1087 | uint32_t isym() const INLINE { return E::getBits(fields, 0, 24); } | |
1088 | void set_isym(uint32_t value) INLINE { E::setBits(fields, value, 0, 24); } | |
1089 | ||
1090 | uint8_t flags() const INLINE { return E::getBits(fields, 24, 8); } | |
1091 | void set_flags(uint8_t value) INLINE { E::setBits(fields, value, 24, 8); } | |
1092 | ||
1093 | typedef typename P::E E; | |
1094 | private: | |
1095 | uint32_t fields; | |
1096 | }; | |
1097 | ||
1098 | ||
1099 | ||
1100 | // | |
1101 | // mach-o two-level hints load command | |
1102 | // | |
1103 | template <typename P> | |
1104 | class macho_dylib_table_of_contents { | |
1105 | public: | |
1106 | uint32_t symbol_index() const INLINE { return E::get32(fields.symbol_index); } | |
1107 | void set_symbol_index(uint32_t value) INLINE { E::set32(fields.symbol_index, value); } | |
1108 | ||
1109 | uint32_t module_index() const INLINE { return E::get32(fields.module_index); } | |
1110 | void set_module_index(uint32_t value) INLINE { E::set32(fields.module_index, value); } | |
1111 | ||
1112 | typedef typename P::E E; | |
1113 | private: | |
1114 | dylib_table_of_contents fields; | |
1115 | }; | |
1116 | ||
1117 | ||
1118 | ||
d696c285 A |
1119 | // |
1120 | // mach-o two-level hints load command | |
1121 | // | |
1122 | template <typename P> | |
1123 | class macho_twolevel_hints_command { | |
1124 | public: | |
1125 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
1126 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
1127 | ||
1128 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
1129 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
1130 | ||
1131 | uint32_t offset() const INLINE { return E::get32(fields.offset); } | |
1132 | void set_offset(uint32_t value) INLINE { E::set32(fields.offset, value); } | |
1133 | ||
1134 | uint32_t nhints() const INLINE { return E::get32(fields.nhints); } | |
1135 | void set_nhints(uint32_t value) INLINE { E::set32(fields.nhints, value); } | |
1136 | ||
1137 | typedef typename P::E E; | |
1138 | private: | |
1139 | twolevel_hints_command fields; | |
1140 | }; | |
1141 | ||
1142 | ||
1143 | // | |
1144 | // mach-o threads load command | |
1145 | // | |
1146 | template <typename P> | |
1147 | class macho_thread_command { | |
1148 | public: | |
1149 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
1150 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
1151 | ||
1152 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
1153 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
1154 | ||
1155 | uint32_t flavor() const INLINE { return E::get32(fields_flavor); } | |
1156 | void set_flavor(uint32_t value) INLINE { E::set32(fields_flavor, value); } | |
1157 | ||
1158 | uint32_t count() const INLINE { return E::get32(fields_count); } | |
1159 | void set_count(uint32_t value) INLINE { E::set32(fields_count, value); } | |
1160 | ||
1161 | uint64_t thread_register(uint32_t index) const INLINE { return P::getP(thread_registers[index]); } | |
1162 | void set_thread_register(uint32_t index, uint64_t value) INLINE { P::setP(thread_registers[index], value); } | |
1163 | ||
1164 | typedef typename P::E E; | |
1165 | typedef typename P::uint_t pint_t; | |
1166 | private: | |
1167 | struct thread_command fields; | |
1168 | uint32_t fields_flavor; | |
1169 | uint32_t fields_count; | |
1170 | pint_t thread_registers[1]; | |
1171 | }; | |
1172 | ||
1173 | ||
a61fdf0a A |
1174 | // |
1175 | // mach-o misc data | |
1176 | // | |
1177 | template <typename P> | |
1178 | class macho_linkedit_data_command { | |
1179 | public: | |
1180 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
1181 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
1182 | ||
1183 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
1184 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
1185 | ||
1186 | uint32_t dataoff() const INLINE { return E::get32(fields.dataoff); } | |
1187 | void set_dataoff(uint32_t value) INLINE { E::set32(fields.dataoff, value); } | |
1188 | ||
1189 | uint32_t datasize() const INLINE { return E::get32(fields.datasize); } | |
1190 | void set_datasize(uint32_t value)INLINE { E::set32(fields.datasize, value); } | |
1191 | ||
1192 | ||
1193 | typedef typename P::E E; | |
1194 | private: | |
2f2f92e4 | 1195 | struct linkedit_data_command fields; |
a61fdf0a A |
1196 | }; |
1197 | ||
1198 | ||
1199 | // | |
1200 | // mach-o rpath | |
1201 | // | |
1202 | template <typename P> | |
1203 | class macho_rpath_command { | |
1204 | public: | |
1205 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
1206 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
1207 | ||
1208 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
1209 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
1210 | ||
1211 | uint32_t path_offset() const INLINE { return E::get32(fields.path.offset); } | |
1212 | void set_path_offset(uint32_t value) INLINE { E::set32(fields.path.offset, value); } | |
1213 | ||
1214 | const char* path() const INLINE { return (const char*)&fields + path_offset(); } | |
1215 | void set_path_offset() INLINE { set_path_offset(sizeof(fields)); } | |
1216 | ||
1217 | ||
1218 | typedef typename P::E E; | |
1219 | private: | |
2f2f92e4 | 1220 | struct rpath_command fields; |
a61fdf0a A |
1221 | }; |
1222 | ||
d696c285 A |
1223 | |
1224 | ||
1225 | // | |
1226 | // mach-o symbol table entry | |
1227 | // | |
1228 | template <typename P> struct macho_nlist_content {}; | |
1229 | template <> struct macho_nlist_content<Pointer32<BigEndian> > { struct nlist fields; }; | |
1230 | template <> struct macho_nlist_content<Pointer64<BigEndian> > { struct nlist_64 fields; }; | |
1231 | template <> struct macho_nlist_content<Pointer32<LittleEndian> > { struct nlist fields; }; | |
1232 | template <> struct macho_nlist_content<Pointer64<LittleEndian> > { struct nlist_64 fields; }; | |
1233 | ||
1234 | template <typename P> | |
1235 | class macho_nlist { | |
1236 | public: | |
1237 | uint32_t n_strx() const INLINE { return E::get32(entry.fields.n_un.n_strx); } | |
1238 | void set_n_strx(uint32_t value) INLINE { E::set32((uint32_t&)entry.fields.n_un.n_strx, value); } | |
1239 | ||
1240 | uint8_t n_type() const INLINE { return entry.fields.n_type; } | |
1241 | void set_n_type(uint8_t value) INLINE { entry.fields.n_type = value; } | |
1242 | ||
1243 | uint8_t n_sect() const INLINE { return entry.fields.n_sect; } | |
1244 | void set_n_sect(uint8_t value) INLINE { entry.fields.n_sect = value; } | |
1245 | ||
1246 | uint16_t n_desc() const INLINE { return E::get16(entry.fields.n_desc); } | |
1247 | void set_n_desc(uint16_t value) INLINE { E::set16((uint16_t&)entry.fields.n_desc, value); } | |
1248 | ||
1249 | uint64_t n_value() const INLINE { return P::getP(entry.fields.n_value); } | |
1250 | void set_n_value(uint64_t value) INLINE { P::setP(entry.fields.n_value, value); } | |
1251 | ||
1252 | typedef typename P::E E; | |
1253 | private: | |
1254 | macho_nlist_content<P> entry; | |
1255 | }; | |
1256 | ||
1257 | ||
1258 | ||
1259 | // | |
1260 | // mach-o relocation info | |
1261 | // | |
1262 | template <typename P> | |
1263 | class macho_relocation_info { | |
1264 | public: | |
1265 | uint32_t r_address() const INLINE { return E::get32(address); } | |
1266 | void set_r_address(uint32_t value) INLINE { E::set32(address, value); } | |
1267 | ||
1268 | uint32_t r_symbolnum() const INLINE { return E::getBits(other, 0, 24); } | |
1269 | void set_r_symbolnum(uint32_t value) INLINE { E::setBits(other, value, 0, 24); } | |
1270 | ||
1271 | bool r_pcrel() const INLINE { return E::getBits(other, 24, 1); } | |
1272 | void set_r_pcrel(bool value) INLINE { E::setBits(other, value, 24, 1); } | |
1273 | ||
1274 | uint8_t r_length() const INLINE { return E::getBits(other, 25, 2); } | |
1275 | void set_r_length(uint8_t value) INLINE { E::setBits(other, value, 25, 2); } | |
1276 | ||
1277 | bool r_extern() const INLINE { return E::getBits(other, 27, 1); } | |
1278 | void set_r_extern(bool value) INLINE { E::setBits(other, value, 27, 1); } | |
1279 | ||
1280 | uint8_t r_type() const INLINE { return E::getBits(other, 28, 4); } | |
1281 | void set_r_type(uint8_t value) INLINE { E::setBits(other, value, 28, 4); } | |
1282 | ||
1283 | void set_r_length() INLINE { set_r_length((sizeof(typename P::uint_t)==8) ? 3 : 2); } | |
1284 | ||
1285 | typedef typename P::E E; | |
1286 | private: | |
1287 | uint32_t address; | |
1288 | uint32_t other; | |
1289 | }; | |
1290 | ||
1291 | ||
1292 | // | |
1293 | // mach-o scattered relocation info | |
1294 | // The bit fields are always in big-endian order (see mach-o/reloc.h) | |
1295 | // | |
1296 | template <typename P> | |
1297 | class macho_scattered_relocation_info { | |
1298 | public: | |
1299 | bool r_scattered() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 0, 1); } | |
1300 | void set_r_scattered(bool x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 0, 1); E::set32(other, temp); } | |
1301 | ||
1302 | bool r_pcrel() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 1, 1); } | |
1303 | void set_r_pcrel(bool x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 1, 1); E::set32(other, temp); } | |
1304 | ||
1305 | uint8_t r_length() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 2, 2); } | |
1306 | void set_r_length(uint8_t x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 2, 2); E::set32(other, temp); } | |
1307 | ||
1308 | uint8_t r_type() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 4, 4); } | |
1309 | void set_r_type(uint8_t x) INLINE { uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 4, 4); E::set32(other, temp); } | |
1310 | ||
1311 | uint32_t r_address() const INLINE { return BigEndian::getBitsRaw(E::get32(other), 8, 24); } | |
a61fdf0a A |
1312 | void set_r_address(uint32_t x) { if ( x > 0x00FFFFFF ) throw "scattered reloc r_address too large"; |
1313 | uint32_t temp = E::get32(other); BigEndian::setBitsRaw(temp, x, 8, 24); E::set32(other, temp); } | |
d696c285 A |
1314 | |
1315 | uint32_t r_value() const INLINE { return E::get32(value); } | |
1316 | void set_r_value(uint32_t x) INLINE { E::set32(value, x); } | |
1317 | ||
1318 | uint32_t r_other() const INLINE { return other; } | |
1319 | ||
a61fdf0a A |
1320 | void set_r_length() INLINE { set_r_length((sizeof(typename P::uint_t)==8) ? 3 : 2); } |
1321 | ||
d696c285 A |
1322 | typedef typename P::E E; |
1323 | private: | |
1324 | uint32_t other; | |
1325 | uint32_t value; | |
1326 | }; | |
1327 | ||
1328 | ||
1329 | ||
2f2f92e4 A |
1330 | // |
1331 | // mach-o encyrption info load command | |
1332 | // | |
f80fe69f A |
1333 | template <typename P> struct macho_encryption_info_content {}; |
1334 | template <> struct macho_encryption_info_content<Pointer32<BigEndian> > { struct encryption_info_command fields; }; | |
1335 | template <> struct macho_encryption_info_content<Pointer64<BigEndian> > { struct encryption_info_command_64 fields; }; | |
1336 | template <> struct macho_encryption_info_content<Pointer32<LittleEndian> > { struct encryption_info_command fields; }; | |
1337 | template <> struct macho_encryption_info_content<Pointer64<LittleEndian> > { struct encryption_info_command_64 fields; }; | |
1338 | ||
1339 | ||
2f2f92e4 A |
1340 | template <typename P> |
1341 | class macho_encryption_info_command { | |
1342 | public: | |
f80fe69f A |
1343 | uint32_t cmd() const INLINE { return E::get32(entry.fields.cmd); } |
1344 | void set_cmd(uint32_t value) INLINE { E::set32(entry.fields.cmd, value); } | |
2f2f92e4 | 1345 | |
f80fe69f A |
1346 | uint32_t cmdsize() const INLINE { return E::get32(entry.fields.cmdsize); } |
1347 | void set_cmdsize(uint32_t value) INLINE { E::set32(entry.fields.cmdsize, value); } | |
2f2f92e4 | 1348 | |
f80fe69f A |
1349 | uint32_t cryptoff() const INLINE { return E::get32(entry.fields.cryptoff); } |
1350 | void set_cryptoff(uint32_t value) INLINE { E::set32(entry.fields.cryptoff, value); } | |
2f2f92e4 | 1351 | |
f80fe69f A |
1352 | uint32_t cryptsize() const INLINE { return E::get32(entry.fields.cryptsize); } |
1353 | void set_cryptsize(uint32_t value) INLINE { E::set32(entry.fields.cryptsize, value); } | |
2f2f92e4 | 1354 | |
f80fe69f A |
1355 | uint32_t cryptid() const INLINE { return E::get32(entry.fields.cryptid); } |
1356 | void set_cryptid(uint32_t value) INLINE { E::set32(entry.fields.cryptid, value); } | |
2f2f92e4 | 1357 | |
f80fe69f A |
1358 | uint32_t pad() const INLINE { return E::get32(entry.fields.pad); } |
1359 | void set_pad(uint32_t value) INLINE { E::set32(entry.fields.pad, value); } | |
1360 | ||
2f2f92e4 A |
1361 | typedef typename P::E E; |
1362 | private: | |
f80fe69f | 1363 | macho_encryption_info_content<P> entry; |
2f2f92e4 | 1364 | }; |
d696c285 A |
1365 | |
1366 | ||
55e3d2f6 A |
1367 | // |
1368 | // start of __unwind_info section | |
1369 | // | |
1370 | template <typename P> | |
1371 | class macho_unwind_info_section_header { | |
1372 | public: | |
1373 | uint32_t version() const INLINE { return E::get32(fields.version); } | |
1374 | void set_version(uint32_t value) INLINE { E::set32(fields.version, value); } | |
1375 | ||
1376 | uint32_t commonEncodingsArraySectionOffset() const INLINE { return E::get32(fields.commonEncodingsArraySectionOffset); } | |
1377 | void set_commonEncodingsArraySectionOffset(uint32_t value) INLINE { E::set32(fields.commonEncodingsArraySectionOffset, value); } | |
1378 | ||
1379 | uint32_t commonEncodingsArrayCount() const INLINE { return E::get32(fields.commonEncodingsArrayCount); } | |
1380 | void set_commonEncodingsArrayCount(uint32_t value) INLINE { E::set32(fields.commonEncodingsArrayCount, value); } | |
1381 | ||
1382 | uint32_t personalityArraySectionOffset() const INLINE { return E::get32(fields.personalityArraySectionOffset); } | |
1383 | void set_personalityArraySectionOffset(uint32_t value) INLINE { E::set32(fields.personalityArraySectionOffset, value); } | |
1384 | ||
1385 | uint32_t personalityArrayCount() const INLINE { return E::get32(fields.personalityArrayCount); } | |
1386 | void set_personalityArrayCount(uint32_t value) INLINE { E::set32(fields.personalityArrayCount, value); } | |
1387 | ||
1388 | uint32_t indexSectionOffset() const INLINE { return E::get32(fields.indexSectionOffset); } | |
1389 | void set_indexSectionOffset(uint32_t value) INLINE { E::set32(fields.indexSectionOffset, value); } | |
1390 | ||
1391 | uint32_t indexCount() const INLINE { return E::get32(fields.indexCount); } | |
1392 | void set_indexCount(uint32_t value) INLINE { E::set32(fields.indexCount, value); } | |
1393 | ||
1394 | typedef typename P::E E; | |
1395 | private: | |
1396 | unwind_info_section_header fields; | |
1397 | }; | |
1398 | ||
1399 | ||
1400 | ||
1401 | // | |
1402 | // uwind first level index entry | |
1403 | // | |
1404 | template <typename P> | |
1405 | class macho_unwind_info_section_header_index_entry { | |
1406 | public: | |
1407 | uint32_t functionOffset() const INLINE { return E::get32(fields.functionOffset); } | |
1408 | void set_functionOffset(uint32_t value) INLINE { E::set32(fields.functionOffset, value); } | |
1409 | ||
1410 | uint32_t secondLevelPagesSectionOffset() const INLINE { return E::get32(fields.secondLevelPagesSectionOffset); } | |
1411 | void set_secondLevelPagesSectionOffset(uint32_t value) INLINE { E::set32(fields.secondLevelPagesSectionOffset, value); } | |
1412 | ||
1413 | uint32_t lsdaIndexArraySectionOffset() const INLINE { return E::get32(fields.lsdaIndexArraySectionOffset); } | |
1414 | void set_lsdaIndexArraySectionOffset(uint32_t value) INLINE { E::set32(fields.lsdaIndexArraySectionOffset, value); } | |
1415 | ||
1416 | typedef typename P::E E; | |
1417 | private: | |
1418 | unwind_info_section_header_index_entry fields; | |
1419 | }; | |
1420 | ||
1421 | ||
1422 | // | |
1423 | // LSDA table entry | |
1424 | // | |
1425 | template <typename P> | |
1426 | class macho_unwind_info_section_header_lsda_index_entry { | |
1427 | public: | |
1428 | uint32_t functionOffset() const INLINE { return E::get32(fields.functionOffset); } | |
1429 | void set_functionOffset(uint32_t value) INLINE { E::set32(fields.functionOffset, value); } | |
1430 | ||
1431 | uint32_t lsdaOffset() const INLINE { return E::get32(fields.lsdaOffset); } | |
1432 | void set_lsdaOffset(uint32_t value) INLINE { E::set32(fields.lsdaOffset, value); } | |
1433 | ||
1434 | typedef typename P::E E; | |
1435 | private: | |
1436 | unwind_info_section_header_lsda_index_entry fields; | |
1437 | }; | |
1438 | ||
1439 | ||
1440 | // | |
1441 | // regular second level entry | |
1442 | // | |
1443 | template <typename P> | |
1444 | class macho_unwind_info_regular_second_level_entry { | |
1445 | public: | |
1446 | uint32_t functionOffset() const INLINE { return E::get32(fields.functionOffset); } | |
1447 | void set_functionOffset(uint32_t value) INLINE { E::set32(fields.functionOffset, value); } | |
1448 | ||
1449 | uint32_t encoding() const INLINE { return E::get32(fields.encoding); } | |
1450 | void set_encoding(uint32_t value) INLINE { E::set32(fields.encoding, value); } | |
1451 | ||
1452 | typedef typename P::E E; | |
1453 | private: | |
1454 | unwind_info_regular_second_level_entry fields; | |
1455 | }; | |
1456 | ||
1457 | ||
1458 | // | |
1459 | // start of second level regular page | |
1460 | // | |
1461 | template <typename P> | |
1462 | class macho_unwind_info_regular_second_level_page_header { | |
1463 | public: | |
1464 | uint32_t kind() const INLINE { return E::get32(fields.kind); } | |
1465 | void set_kind(uint32_t value) INLINE { E::set32(fields.kind, value); } | |
1466 | ||
1467 | uint16_t entryPageOffset() const INLINE { return E::get16(fields.entryPageOffset); } | |
1468 | void set_entryPageOffset(uint16_t value) INLINE { E::set16((uint16_t&)fields.entryPageOffset, value); } | |
1469 | ||
1470 | uint16_t entryCount() const INLINE { return E::get16(fields.entryCount); } | |
1471 | void set_entryCount(uint16_t value) INLINE { E::set16((uint16_t&)fields.entryCount, value); } | |
1472 | ||
1473 | typedef typename P::E E; | |
1474 | private: | |
1475 | unwind_info_regular_second_level_page_header fields; | |
1476 | }; | |
1477 | ||
1478 | ||
1479 | // | |
1480 | // start of second level compressed page | |
1481 | // | |
1482 | template <typename P> | |
1483 | class macho_unwind_info_compressed_second_level_page_header { | |
1484 | public: | |
1485 | uint32_t kind() const INLINE { return E::get32(fields.kind); } | |
1486 | void set_kind(uint32_t value) INLINE { E::set32(fields.kind, value); } | |
1487 | ||
1488 | uint16_t entryPageOffset() const INLINE { return E::get16(fields.entryPageOffset); } | |
1489 | void set_entryPageOffset(uint16_t value) INLINE { E::set16((uint16_t&)fields.entryPageOffset, value); } | |
1490 | ||
1491 | uint16_t entryCount() const INLINE { return E::get16(fields.entryCount); } | |
1492 | void set_entryCount(uint16_t value) INLINE { E::set16((uint16_t&)fields.entryCount, value); } | |
1493 | ||
1494 | uint16_t encodingsPageOffset() const INLINE { return E::get16(fields.encodingsPageOffset); } | |
1495 | void set_encodingsPageOffset(uint16_t value) INLINE { E::set16((uint16_t&)fields.encodingsPageOffset, value); } | |
1496 | ||
1497 | uint16_t encodingsCount() const INLINE { return E::get16(fields.encodingsCount); } | |
1498 | void set_encodingsCount(uint16_t value) INLINE { E::set16((uint16_t&)fields.encodingsCount, value); } | |
1499 | ||
1500 | typedef typename P::E E; | |
1501 | private: | |
1502 | unwind_info_compressed_second_level_page_header fields; | |
1503 | }; | |
1504 | ||
1505 | ||
1506 | // | |
1507 | // compressed dyld info load command | |
1508 | // | |
1509 | template <typename P> | |
1510 | class macho_dyld_info_command { | |
1511 | public: | |
1512 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
1513 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
1514 | ||
1515 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
1516 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
1517 | ||
1518 | uint32_t rebase_off() const INLINE { return E::get32(fields.rebase_off); } | |
1519 | void set_rebase_off(uint32_t value) INLINE { E::set32(fields.rebase_off, value); } | |
1520 | ||
1521 | uint32_t rebase_size() const INLINE { return E::get32(fields.rebase_size); } | |
1522 | void set_rebase_size(uint32_t value) INLINE { E::set32(fields.rebase_size, value); } | |
1523 | ||
1524 | uint32_t bind_off() const INLINE { return E::get32(fields.bind_off); } | |
1525 | void set_bind_off(uint32_t value) INLINE { E::set32(fields.bind_off, value); } | |
1526 | ||
1527 | uint32_t bind_size() const INLINE { return E::get32(fields.bind_size); } | |
1528 | void set_bind_size(uint32_t value) INLINE { E::set32(fields.bind_size, value); } | |
1529 | ||
1530 | uint32_t weak_bind_off() const INLINE { return E::get32(fields.weak_bind_off); } | |
1531 | void set_weak_bind_off(uint32_t value) INLINE { E::set32(fields.weak_bind_off, value); } | |
1532 | ||
1533 | uint32_t weak_bind_size() const INLINE { return E::get32(fields.weak_bind_size); } | |
1534 | void set_weak_bind_size(uint32_t value) INLINE { E::set32(fields.weak_bind_size, value); } | |
1535 | ||
1536 | uint32_t lazy_bind_off() const INLINE { return E::get32(fields.lazy_bind_off); } | |
1537 | void set_lazy_bind_off(uint32_t value) INLINE { E::set32(fields.lazy_bind_off, value); } | |
1538 | ||
1539 | uint32_t lazy_bind_size() const INLINE { return E::get32(fields.lazy_bind_size); } | |
1540 | void set_lazy_bind_size(uint32_t value) INLINE { E::set32(fields.lazy_bind_size, value); } | |
1541 | ||
1542 | uint32_t export_off() const INLINE { return E::get32(fields.export_off); } | |
1543 | void set_export_off(uint32_t value) INLINE { E::set32(fields.export_off, value); } | |
1544 | ||
1545 | uint32_t export_size() const INLINE { return E::get32(fields.export_size); } | |
1546 | void set_export_size(uint32_t value) INLINE { E::set32(fields.export_size, value); } | |
1547 | ||
1548 | ||
1549 | typedef typename P::E E; | |
1550 | private: | |
1551 | dyld_info_command fields; | |
1552 | }; | |
1553 | ||
1554 | ||
a645023d A |
1555 | // |
1556 | // mach-o version load command | |
1557 | // | |
1558 | template <typename P> | |
1559 | class macho_version_min_command { | |
1560 | public: | |
1561 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
1562 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
1563 | ||
1564 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
1565 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
1566 | ||
1567 | uint32_t version() const INLINE { return fields.version; } | |
1568 | void set_version(uint32_t value) INLINE { E::set32(fields.version, value); } | |
1569 | ||
ebf6f434 | 1570 | #ifdef DICE_KIND_DATA |
b2fa67a8 A |
1571 | uint32_t sdk() const INLINE { return fields.sdk; } |
1572 | void set_sdk(uint32_t value) INLINE { E::set32(fields.sdk, value); } | |
1573 | #else | |
1574 | uint32_t sdk() const INLINE { return fields.reserved; } | |
1575 | void set_sdk(uint32_t value) INLINE { E::set32(fields.reserved, value); } | |
1576 | #endif | |
a645023d A |
1577 | |
1578 | typedef typename P::E E; | |
1579 | private: | |
1580 | version_min_command fields; | |
1581 | }; | |
1582 | ||
55e3d2f6 | 1583 | |
afe874b1 A |
1584 | // |
1585 | // mach-o __LD, __compact_unwind section in object files | |
1586 | // | |
1587 | template <typename P> | |
1588 | class macho_compact_unwind_entry { | |
1589 | public: | |
1590 | typedef typename P::E E; | |
1591 | typedef typename P::uint_t pint_t; | |
1592 | ||
1593 | pint_t codeStart() const INLINE { return P::getP(_codeStart); } | |
1594 | void set_codeStart(pint_t value) INLINE { P::setP(_codeStart, value); } | |
1595 | ||
1596 | uint32_t codeLen() const INLINE { return E::get32(_codeLen); } | |
1597 | void set_codeLen(uint32_t value) INLINE { E::set32(_codeLen, value); } | |
1598 | ||
1599 | uint32_t compactUnwindInfo() const INLINE { return E::get32(_compactUnwindInfo); } | |
1600 | void set_compactUnwindInfo(uint32_t value) INLINE { E::set32(_compactUnwindInfo, value); } | |
1601 | ||
1602 | pint_t personality() const INLINE { return P::getP(_personality); } | |
1603 | void set_personality(pint_t value) INLINE { P::setP(_personality, value); } | |
1604 | ||
1605 | pint_t lsda() const INLINE { return P::getP(_lsda); } | |
1606 | void set_lsda(pint_t value) INLINE { P::setP(_lsda, value); } | |
1607 | ||
1608 | static uint32_t codeStartFieldOffset() INLINE { return offsetof(macho_compact_unwind_entry<P>,_codeStart); } | |
1609 | static uint32_t personalityFieldOffset() INLINE { return offsetof(macho_compact_unwind_entry<P>,_personality); } | |
1610 | static uint32_t lsdaFieldOffset() INLINE { return offsetof(macho_compact_unwind_entry<P>,_lsda); } | |
1611 | ||
1612 | private: | |
1613 | pint_t _codeStart; | |
1614 | uint32_t _codeLen; | |
1615 | uint32_t _compactUnwindInfo; | |
1616 | pint_t _personality; | |
1617 | pint_t _lsda; | |
1618 | }; | |
1619 | ||
d696c285 | 1620 | |
ebf6f434 A |
1621 | // |
1622 | // mach-o source version load command | |
1623 | // | |
1624 | template <typename P> | |
1625 | class macho_source_version_command { | |
1626 | public: | |
1627 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
1628 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
1629 | ||
1630 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
1631 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
1632 | ||
1633 | uint64_t version() const INLINE { return fields.version; } | |
1634 | void set_version(uint64_t value) INLINE { E::set64(fields.version, value); } | |
1635 | ||
1636 | typedef typename P::E E; | |
1637 | private: | |
1638 | source_version_command fields; | |
1639 | }; | |
1640 | ||
1641 | ||
1642 | // | |
1643 | // mach-o source version load command | |
1644 | // | |
1645 | template <typename P> | |
1646 | class macho_entry_point_command { | |
1647 | public: | |
1648 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
1649 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
1650 | ||
1651 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
1652 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
1653 | ||
1654 | uint64_t entryoff() const INLINE { return fields.entryoff; } | |
1655 | void set_entryoff(uint64_t value) INLINE { E::set64(fields.entryoff, value); } | |
1656 | ||
1657 | uint64_t stacksize() const INLINE { return fields.stacksize; } | |
1658 | void set_stacksize(uint64_t value) INLINE { E::set64(fields.stacksize, value); } | |
1659 | ||
1660 | typedef typename P::E E; | |
1661 | private: | |
1662 | entry_point_command fields; | |
1663 | }; | |
1664 | ||
1665 | ||
1666 | ||
1667 | template <typename P> | |
1668 | class macho_data_in_code_entry { | |
1669 | public: | |
1670 | uint32_t offset() const INLINE { return E::get32(fields.offset); } | |
1671 | void set_offset(uint32_t value) INLINE { E::set32(fields.offset, value); } | |
1672 | ||
1673 | uint16_t length() const INLINE { return E::get16(fields.length); } | |
1674 | void set_length(uint16_t value) INLINE { E::set16((uint16_t&)fields.length, value); } | |
1675 | ||
1676 | uint16_t kind() const INLINE { return E::get16(fields.kind); } | |
1677 | void set_kind(uint16_t value) INLINE { E::set16((uint16_t&)fields.kind, value); } | |
1678 | ||
1679 | typedef typename P::E E; | |
1680 | private: | |
1681 | data_in_code_entry fields; | |
1682 | }; | |
1683 | ||
f80fe69f A |
1684 | #ifndef DICE_KIND_DATA |
1685 | #define DICE_KIND_DATA 0x0001 | |
1686 | #define DICE_KIND_JUMP_TABLE8 0x0002 | |
1687 | #define DICE_KIND_JUMP_TABLE16 0x0003 | |
1688 | #define DICE_KIND_JUMP_TABLE32 0x0004 | |
1689 | #define DICE_KIND_ABS_JUMP_TABLE32 0x0005 | |
1690 | #endif | |
1691 | ||
1692 | template <typename P> | |
1693 | class macho_linker_option_command { | |
1694 | public: | |
1695 | uint32_t cmd() const INLINE { return E::get32(fields.cmd); } | |
1696 | void set_cmd(uint32_t value) INLINE { E::set32(fields.cmd, value); } | |
1697 | ||
1698 | uint32_t cmdsize() const INLINE { return E::get32(fields.cmdsize); } | |
1699 | void set_cmdsize(uint32_t value) INLINE { E::set32(fields.cmdsize, value); } | |
1700 | ||
1701 | uint64_t count() const INLINE { return fields.count; } | |
1702 | void set_count(uint32_t value) INLINE { E::set32(fields.count, value); } | |
1703 | ||
1704 | const char* buffer() const INLINE { return ((char*)&fields) + sizeof(linker_option_command); } | |
1705 | char* buffer() INLINE { return ((char*)&fields) + sizeof(linker_option_command); } | |
1706 | ||
1707 | typedef typename P::E E; | |
1708 | private: | |
1709 | linker_option_command fields; | |
1710 | }; | |
1711 | ||
1712 | ||
1713 | ||
ebf6f434 | 1714 | |
d425e388 | 1715 | |
d696c285 A |
1716 | #endif // __MACH_O_FILE_ABSTRACTION__ |
1717 | ||
1718 |