2 * Copyright © 2009 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
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@
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
,
46 extern void print_ar_hdr(
47 struct ar_hdr
*ar_hdr
,
49 uint32_t member_name_size
,
52 extern void print_library_toc(
53 struct ar_hdr
*toc_ar_hdr
,
55 uint32_t toc_name_size
,
58 enum byte_sex toc_byte_sex
,
61 uint32_t library_size
,
65 extern void print_mach_header(
68 cpu_subtype_t cpusubtype
,
75 extern void print_loadcmds(
76 struct load_command
*load_commands
,
81 enum byte_sex load_commands_byte_sex
,
84 enum bool very_verbose
);
86 extern void print_libraries(
87 struct load_command
*load_commands
,
90 enum byte_sex load_commands_byte_sex
,
94 extern void print_reloc(
95 struct load_command
*load_commands
,
99 enum byte_sex load_commands_byte_sex
,
101 uint32_t object_size
,
102 struct nlist
*symbols
,
103 struct nlist_64
*symbols64
,
106 uint32_t strings_size
,
109 extern void print_toc(
110 struct load_command
*load_commands
,
113 enum byte_sex load_commands_byte_sex
,
115 uint32_t object_size
,
116 struct dylib_table_of_contents
*tocs
,
118 struct dylib_module
*mods
,
119 struct dylib_module_64
*mods64
,
121 struct nlist
*symbols
,
122 struct nlist_64
*symbols64
,
125 uint32_t strings_size
,
128 extern void print_module_table(
129 struct dylib_module
*mods
,
132 uint32_t strings_size
,
135 extern void print_module_table_64(
136 struct dylib_module_64
*mods64
,
139 uint32_t strings_size
,
143 struct dylib_reference
*refs
,
145 struct dylib_module
*mods
,
146 struct dylib_module_64
*mods64
,
148 struct nlist
*symbols
,
149 struct nlist_64
*symbols64
,
152 uint32_t strings_size
,
155 extern void print_indirect_symbols(
156 struct load_command
*load_commands
,
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
,
167 uint32_t strings_size
,
170 extern void print_hints(
171 struct load_command
*load_commands
,
174 enum byte_sex load_commands_byte_sex
,
175 struct twolevel_hint
*hints
,
177 struct nlist
*symbols
,
178 struct nlist_64
*symbols64
,
181 uint32_t strings_size
,
184 extern void print_segment_command(
196 uint32_t object_size
,
199 extern void print_section(
214 uint32_t object_size
,
217 extern void print_symtab_command(
218 struct symtab_command
*sg
,
220 uint32_t object_size
);
222 extern void print_dysymtab_command(
223 struct dysymtab_command
*dyst
,
225 uint32_t object_size
,
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
,
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(
309 enum byte_sex thread_states_byte_sex
);
311 extern void print_cstring_section(
315 enum bool print_addresses
);
317 extern void print_literal4_section(
321 enum byte_sex literal_byte_sex
,
322 enum bool print_addresses
);
324 extern void print_literal8_section(
328 enum byte_sex literal_byte_sex
,
329 enum bool print_addresses
);
331 extern void print_literal16_section(
335 enum byte_sex literal_byte_sex
,
336 enum bool print_addresses
);
338 extern void print_literal_pointer_section(
339 struct load_command
*lc
,
342 enum byte_sex object_byte_sex
,
348 struct nlist
*symbols
,
349 struct nlist_64
*symbols64
,
352 uint32_t strings_size
,
353 struct relocation_info
*relocs
,
355 enum bool print_addresses
);
357 extern void print_init_term_pointer_section(
362 enum byte_sex object_byte_sex
,
363 struct symbol
*sorted_symbols
,
364 uint32_t nsorted_symbols
,
367 extern void print_shlib_init(
368 enum byte_sex object_byte_sex
,
372 struct symbol
*sorted_symbols
,
373 uint32_t nsorted_symbols
,
374 struct nlist
*symbols
,
375 struct nlist_64
*symbols64
,
378 uint32_t strings_size
,
379 struct relocation_info
*relocs
,
383 extern enum bool print_symbol(
387 struct relocation_info
*sorted_relocs
,
388 uint32_t nsorted_relocs
,
389 struct nlist
*symbols
,
390 struct nlist_64
*symbols64
,
392 struct symbol
*sorted_symbols
,
393 uint32_t nsorted_symbols
,
395 uint32_t strings_size
,
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
,
416 const uint32_t strings_size
);
418 extern void print_sect(
420 enum byte_sex object_byte_sex
,
425 extern enum bool print_objc_segment(
426 cpu_type_t mh_cputype
,
427 struct load_command
*load_commands
,
430 enum byte_sex object_byte_sex
,
432 uint32_t object_size
,
433 struct symbol
*sorted_symbols
,
434 uint32_t nsorted_symbols
,
437 extern void print_objc2_64bit(
439 struct load_command
*load_commands
,
442 enum byte_sex object_byte_sex
,
444 uint32_t object_size
,
445 struct nlist_64
*symbols64
,
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
,
458 extern void print_objc2_32bit(
460 struct load_command
*load_commands
,
463 enum byte_sex object_byte_sex
,
465 uint32_t object_size
,
466 struct nlist
*symbols
,
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
,
478 extern void print_objc_protocol_section(
479 struct load_command
*load_commands
,
482 enum byte_sex object_byte_sex
,
484 uint32_t object_size
,
487 extern void print_objc_string_object_section(
489 struct load_command
*load_commands
,
492 enum byte_sex object_byte_sex
,
494 uint32_t object_size
,
497 extern void print_objc_string_object_section_64(
499 struct load_command
*load_commands
,
502 enum byte_sex object_byte_sex
,
504 uint32_t object_size
,
506 struct nlist_64
*symbols64
,
509 const uint32_t strings_size
,
510 struct symbol
*sorted_symbols
,
511 uint32_t nsorted_symbols
,
514 extern void print_objc_runtime_setup_section(
515 struct load_command
*load_commands
,
518 enum byte_sex object_byte_sex
,
520 uint32_t object_size
,
523 extern void print_coff_reloc_section(
524 struct load_command
*load_commands
,
528 enum byte_sex object_byte_sex
,
530 uint32_t object_size
,
533 extern void print_label(
535 enum bool colon_and_newline
,
536 struct symbol
*sorted_symbols
,
537 uint32_t nsorted_symbols
);
539 extern enum bool get_sect_info(
542 struct load_command
*load_commands
,
546 enum byte_sex load_commands_byte_sex
,
548 uint32_t object_size
,
552 struct relocation_info
**sect_relocs
,
553 uint32_t *sect_nrelocs
,
554 uint32_t *sect_flags
);