795
[darwin-xtools.git] / cctools / otool / ofile_print.h
blob237b26e12539ef421823369cadab2ecdcfa71c9d
1 /*
2 * Copyright © 2009 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
15 * contributors may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * @APPLE_LICENSE_HEADER_END@
31 #import <ar.h>
32 #import <mach-o/fat.h>
33 #import <mach-o/loader.h>
34 #import <mach-o/nlist.h>
35 #import <mach-o/reloc.h>
36 #import <stuff/bytesex.h>
37 #import <stuff/bool.h>
38 #include "stuff/symbol.h"
40 extern void print_fat_headers(
41 struct fat_header *fat_header,
42 struct fat_arch *fat_archs,
43 uint32_t size,
44 enum bool verbose);
46 extern void print_ar_hdr(
47 struct ar_hdr *ar_hdr,
48 char *member_name,
49 uint32_t member_name_size,
50 enum bool verbose);
52 extern void print_library_toc(
53 struct ar_hdr *toc_ar_hdr,
54 char *toc_name,
55 uint32_t toc_name_size,
56 char *toc_addr,
57 uint32_t toc_size,
58 enum byte_sex toc_byte_sex,
59 char *library_name,
60 char *library_addr,
61 uint32_t library_size,
62 char *arch_name,
63 enum bool verbose);
65 extern void print_mach_header(
66 uint32_t magic,
67 cpu_type_t cputype,
68 cpu_subtype_t cpusubtype,
69 uint32_t filetype,
70 uint32_t ncmds,
71 uint32_t sizeofcmds,
72 uint32_t flags,
73 enum bool verbose);
75 extern void print_loadcmds(
76 struct load_command *load_commands,
77 uint32_t ncmds,
78 uint32_t sizeofcmds,
79 cpu_type_t cputype,
80 uint32_t filetype,
81 enum byte_sex load_commands_byte_sex,
82 uint32_t object_size,
83 enum bool verbose,
84 enum bool very_verbose);
86 extern void print_libraries(
87 struct load_command *load_commands,
88 uint32_t ncmds,
89 uint32_t sizeofcmds,
90 enum byte_sex load_commands_byte_sex,
91 enum bool just_id,
92 enum bool verbose);
94 extern void print_reloc(
95 struct load_command *load_commands,
96 uint32_t ncmds,
97 uint32_t sizeofcmds,
98 cpu_type_t cputype,
99 enum byte_sex load_commands_byte_sex,
100 char *object_addr,
101 uint32_t object_size,
102 struct nlist *symbols,
103 struct nlist_64 *symbols64,
104 uint32_t nsymbols,
105 char *strings,
106 uint32_t strings_size,
107 enum bool verbose);
109 extern void print_toc(
110 struct load_command *load_commands,
111 uint32_t ncmds,
112 uint32_t sizeofcmds,
113 enum byte_sex load_commands_byte_sex,
114 char *object_addr,
115 uint32_t object_size,
116 struct dylib_table_of_contents *tocs,
117 uint32_t ntocs,
118 struct dylib_module *mods,
119 struct dylib_module_64 *mods64,
120 uint32_t nmods,
121 struct nlist *symbols,
122 struct nlist_64 *symbols64,
123 uint32_t nsymbols,
124 char *strings,
125 uint32_t strings_size,
126 enum bool verbose);
128 extern void print_module_table(
129 struct dylib_module *mods,
130 uint32_t nmods,
131 char *strings,
132 uint32_t strings_size,
133 enum bool verbose);
135 extern void print_module_table_64(
136 struct dylib_module_64 *mods64,
137 uint32_t nmods,
138 char *strings,
139 uint32_t strings_size,
140 enum bool verbose);
142 void print_refs(
143 struct dylib_reference *refs,
144 uint32_t nrefs,
145 struct dylib_module *mods,
146 struct dylib_module_64 *mods64,
147 uint32_t nmods,
148 struct nlist *symbols,
149 struct nlist_64 *symbols64,
150 uint32_t nsymbols,
151 char *strings,
152 uint32_t strings_size,
153 enum bool verbose);
155 extern void print_indirect_symbols(
156 struct load_command *load_commands,
157 uint32_t ncmds,
158 uint32_t sizeofcmds,
159 cpu_type_t cputype,
160 enum byte_sex load_commands_byte_sex,
161 uint32_t *indirect_symbols,
162 uint32_t nindirect_symbols,
163 struct nlist *symbols,
164 struct nlist_64 *symbols64,
165 uint32_t nsymbols,
166 char *strings,
167 uint32_t strings_size,
168 enum bool verbose);
170 extern void print_hints(
171 struct load_command *load_commands,
172 uint32_t ncmds,
173 uint32_t sizeofcmds,
174 enum byte_sex load_commands_byte_sex,
175 struct twolevel_hint *hints,
176 uint32_t nhints,
177 struct nlist *symbols,
178 struct nlist_64 *symbols64,
179 uint32_t nsymbols,
180 char *strings,
181 uint32_t strings_size,
182 enum bool verbose);
184 extern void print_segment_command(
185 uint32_t cmd,
186 uint32_t cmdsize,
187 char *segname,
188 uint64_t vmaddr,
189 uint64_t vmsize,
190 uint64_t fileoff,
191 uint64_t filesize,
192 vm_prot_t maxprot,
193 vm_prot_t initprot,
194 uint32_t nsects,
195 uint32_t flags,
196 uint32_t object_size,
197 enum bool verbose);
199 extern void print_section(
200 char *sectname,
201 char *segname,
202 uint64_t addr,
203 uint64_t size,
204 uint32_t offset,
205 uint32_t align,
206 uint32_t reloff,
207 uint32_t nreloc,
208 uint32_t flags,
209 uint32_t reserved1,
210 uint32_t reserved2,
211 uint32_t cmd,
212 char *sg_segname,
213 uint32_t filetype,
214 uint32_t object_size,
215 enum bool verbose);
217 extern void print_symtab_command(
218 struct symtab_command *sg,
219 cpu_type_t cputype,
220 uint32_t object_size);
222 extern void print_dysymtab_command(
223 struct dysymtab_command *dyst,
224 uint32_t nsyms,
225 uint32_t object_size,
226 cpu_type_t cputype);
228 extern void print_symseg_command(
229 struct symseg_command *ss,
230 uint32_t object_size);
232 extern void print_fvmlib_command(
233 struct fvmlib_command *fl,
234 struct load_command *lc);
236 extern void print_dylib_command(
237 struct dylib_command *dl,
238 struct load_command *lc);
240 extern void print_sub_framework_command(
241 struct sub_framework_command *sub,
242 struct load_command *lc);
244 extern void print_sub_umbrella_command(
245 struct sub_umbrella_command *usub,
246 struct load_command *lc);
248 extern void print_sub_library_command(
249 struct sub_library_command *lsub,
250 struct load_command *lc);
252 extern void print_sub_client_command(
253 struct sub_client_command *csub,
254 struct load_command *lc);
256 extern void print_prebound_dylib_command(
257 struct prebound_dylib_command *pbdylib,
258 struct load_command *lc,
259 enum bool verbose);
261 extern void print_dylinker_command(
262 struct dylinker_command *dyld,
263 struct load_command *lc);
265 extern void print_fvmfile_command(
266 struct fvmfile_command *ff,
267 struct load_command *lc);
269 extern void print_routines_command(
270 struct routines_command *rc);
272 extern void print_routines_command_64(
273 struct routines_command_64 *rc64);
275 extern void print_twolevel_hints_command(
276 struct twolevel_hints_command *hints,
277 uint32_t object_size);
279 extern void print_prebind_cksum_command(
280 struct prebind_cksum_command *cksum);
282 extern void print_uuid_command(
283 struct uuid_command *uuid);
285 extern void print_linkedit_data_command(
286 struct linkedit_data_command *ld,
287 uint32_t object_size);
289 extern void print_version_min_command(
290 struct version_min_command *vd,
291 uint32_t object_size);
293 extern void print_rpath_command(
294 struct rpath_command *rpath,
295 struct load_command *lc);
297 extern void print_encryption_info_command(
298 struct encryption_info_command *ec,
299 uint32_t object_size);
301 extern void print_dyld_info_info_command(
302 struct dyld_info_command *dc,
303 uint32_t object_size);
305 extern void print_thread_states(
306 char *begin,
307 char *end,
308 cpu_type_t cputype,
309 enum byte_sex thread_states_byte_sex);
311 extern void print_cstring_section(
312 char *sect,
313 uint32_t sect_size,
314 uint32_t sect_addr,
315 enum bool print_addresses);
317 extern void print_literal4_section(
318 char *sect,
319 uint32_t sect_size,
320 uint32_t sect_addr,
321 enum byte_sex literal_byte_sex,
322 enum bool print_addresses);
324 extern void print_literal8_section(
325 char *sect,
326 uint32_t sect_size,
327 uint32_t sect_addr,
328 enum byte_sex literal_byte_sex,
329 enum bool print_addresses);
331 extern void print_literal16_section(
332 char *sect,
333 uint32_t sect_size,
334 uint32_t sect_addr,
335 enum byte_sex literal_byte_sex,
336 enum bool print_addresses);
338 extern void print_literal_pointer_section(
339 struct load_command *lc,
340 uint32_t ncmds,
341 uint32_t sizeofcmds,
342 enum byte_sex object_byte_sex,
343 char *addr,
344 uint32_t size,
345 char *sect,
346 uint32_t sect_size,
347 uint32_t sect_addr,
348 struct nlist *symbols,
349 struct nlist_64 *symbols64,
350 uint32_t nsymbols,
351 char *strings,
352 uint32_t strings_size,
353 struct relocation_info *relocs,
354 uint32_t nrelocs,
355 enum bool print_addresses);
357 extern void print_init_term_pointer_section(
358 cpu_type_t cputype,
359 char *sect,
360 uint32_t sect_size,
361 uint64_t sect_addr,
362 enum byte_sex object_byte_sex,
363 struct symbol *sorted_symbols,
364 uint32_t nsorted_symbols,
365 enum bool verbose);
367 extern void print_shlib_init(
368 enum byte_sex object_byte_sex,
369 char *sect,
370 uint32_t sect_size,
371 uint32_t sect_addr,
372 struct symbol *sorted_symbols,
373 uint32_t nsorted_symbols,
374 struct nlist *symbols,
375 struct nlist_64 *symbols64,
376 uint32_t nsymbols,
377 char *strings,
378 uint32_t strings_size,
379 struct relocation_info *relocs,
380 uint32_t nrelocs,
381 enum bool verbose);
383 extern enum bool print_symbol(
384 uint64_t value,
385 uint32_t r_address,
386 uint32_t dot_value,
387 struct relocation_info *sorted_relocs,
388 uint32_t nsorted_relocs,
389 struct nlist *symbols,
390 struct nlist_64 *symbols64,
391 uint32_t nsymbols,
392 struct symbol *sorted_symbols,
393 uint32_t nsorted_symbols,
394 char *strings,
395 uint32_t strings_size,
396 enum bool verbose);
398 extern const char *guess_symbol(
399 const uint64_t value,
400 const struct symbol *sorted_symbols,
401 const uint32_t nsorted_symbols,
402 const enum bool verbose);
404 extern const char * guess_indirect_symbol(
405 const uint64_t value,
406 const uint32_t ncmds,
407 const uint32_t sizeofcmds,
408 const struct load_command *load_commands,
409 const enum byte_sex load_commands_byte_sex,
410 const uint32_t *indirect_symbols,
411 const uint32_t nindirect_symbols,
412 const struct nlist *symbols,
413 const struct nlist_64 *symbols64,
414 const uint32_t nsymbols,
415 const char *strings,
416 const uint32_t strings_size);
418 extern void print_sect(
419 cpu_type_t cputype,
420 enum byte_sex object_byte_sex,
421 char *sect,
422 uint64_t size,
423 uint64_t addr);
425 extern enum bool print_objc_segment(
426 cpu_type_t mh_cputype,
427 struct load_command *load_commands,
428 uint32_t ncmds,
429 uint32_t sizeofcmds,
430 enum byte_sex object_byte_sex,
431 char *object_addr,
432 uint32_t object_size,
433 struct symbol *sorted_symbols,
434 uint32_t nsorted_symbols,
435 enum bool verbose);
437 extern void print_objc2_64bit(
438 cpu_type_t cputype,
439 struct load_command *load_commands,
440 uint32_t ncmds,
441 uint32_t sizeofcmds,
442 enum byte_sex object_byte_sex,
443 char *object_addr,
444 uint32_t object_size,
445 struct nlist_64 *symbols64,
446 uint32_t nsymbols,
447 char *strings,
448 uint32_t strings_size,
449 struct symbol *sorted_symbols,
450 uint32_t nsorted_symbols,
451 struct relocation_info *ext_relocs,
452 uint32_t next_relocs,
453 struct relocation_info *loc_relocs,
454 uint32_t nloc_relocs,
455 enum bool verbose,
456 enum bool Vflag);
458 extern void print_objc2_32bit(
459 cpu_type_t cputype,
460 struct load_command *load_commands,
461 uint32_t ncmds,
462 uint32_t sizeofcmds,
463 enum byte_sex object_byte_sex,
464 char *object_addr,
465 uint32_t object_size,
466 struct nlist *symbols,
467 uint32_t nsymbols,
468 char *strings,
469 uint32_t strings_size,
470 struct symbol *sorted_symbols,
471 uint32_t nsorted_symbols,
472 struct relocation_info *ext_relocs,
473 uint32_t next_relocs,
474 struct relocation_info *loc_relocs,
475 uint32_t nloc_relocs,
476 enum bool verbose);
478 extern void print_objc_protocol_section(
479 struct load_command *load_commands,
480 uint32_t ncmds,
481 uint32_t sizeofcmds,
482 enum byte_sex object_byte_sex,
483 char *object_addr,
484 uint32_t object_size,
485 enum bool verbose);
487 extern void print_objc_string_object_section(
488 char *sectname,
489 struct load_command *load_commands,
490 uint32_t ncmds,
491 uint32_t sizeofcmds,
492 enum byte_sex object_byte_sex,
493 char *object_addr,
494 uint32_t object_size,
495 enum bool verbose);
497 extern void print_objc_string_object_section_64(
498 char *sectname,
499 struct load_command *load_commands,
500 uint32_t ncmds,
501 uint32_t sizeofcmds,
502 enum byte_sex object_byte_sex,
503 char *object_addr,
504 uint32_t object_size,
505 cpu_type_t cputype,
506 struct nlist_64 *symbols64,
507 uint32_t nsymbols,
508 char *strings,
509 const uint32_t strings_size,
510 struct symbol *sorted_symbols,
511 uint32_t nsorted_symbols,
512 enum bool verbose);
514 extern void print_objc_runtime_setup_section(
515 struct load_command *load_commands,
516 uint32_t ncmds,
517 uint32_t sizeofcmds,
518 enum byte_sex object_byte_sex,
519 char *object_addr,
520 uint32_t object_size,
521 enum bool verbose);
523 extern void print_coff_reloc_section(
524 struct load_command *load_commands,
525 uint32_t ncmds,
526 uint32_t sizeofcmds,
527 uint32_t filetype,
528 enum byte_sex object_byte_sex,
529 char *object_addr,
530 uint32_t object_size,
531 enum bool verbose);
533 extern void print_label(
534 uint64_t addr,
535 enum bool colon_and_newline,
536 struct symbol *sorted_symbols,
537 uint32_t nsorted_symbols);
539 extern enum bool get_sect_info(
540 char *segname,
541 char *sectname,
542 struct load_command *load_commands,
543 uint32_t ncmds,
544 uint32_t sizeofcmds,
545 uint32_t filetype,
546 enum byte_sex load_commands_byte_sex,
547 char *object_addr,
548 uint32_t object_size,
549 char **sect_pointer,
550 uint64_t *sect_size,
551 uint64_t *sect_addr,
552 struct relocation_info **sect_relocs,
553 uint32_t *sect_nrelocs,
554 uint32_t *sect_flags);