Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Classes | |
struct | section_t |
struct | symbol_t |
struct | import_t |
struct | reloc_t |
struct | addr_t |
struct | lib_t |
struct | blob_index_t |
struct | blob_t |
struct | super_blob_t |
#define CSMAGIC_DETACHED_SIGNATURE 0xfade0cc1 /* multi-arch collection of embedded signatures */ |
#define CSMAGIC_REQUIREMENT 0xfade0c00 /* single Requirement blob */ |
#define CSMAGIC_REQUIREMENTS 0xfade0c01 /* Requirements vector (internal requirements) */ |
#define MACH0_VFILE_NAME_REBASED_STRIPPED "rebased_stripped" |
Definition at line 3262 of file mach0.c.
References i, MH_DYLINKER, MH_EXECUTE, and MH_FILESET.
Definition at line 3288 of file mach0.c.
References bits(), CPU_TYPE_ARM, get_bits_from_hdr(), and MACH0_().
int MACH0_() get_bits_from_hdr | ( | struct MACH0_(mach_header) * | hdr | ) |
Definition at line 3299 of file mach0.c.
References CPU_SUBTYPE_ARM_V7K, CPU_SUBTYPE_MASK, CPU_TYPE_ARM64_32, MH_CIGAM_64, and MH_MAGIC_64.
Referenced by fill_metadata_info_from_hdr(), get_bits(), get_symbols(), get_symbols_list(), and reloc_target_size().
Definition at line 3546 of file mach0.c.
References get_cpusubtype_from_hdr(), MACH0_(), and strdup().
Referenced by info().
char* MACH0_() get_cpusubtype_from_hdr | ( | struct MACH0_(mach_header) * | hdr | ) |
Definition at line 3541 of file mach0.c.
References cpusubtype_tostring(), NULL, rz_return_val_if_fail, and strdup().
Referenced by fill_metadata_info_from_hdr(), and get_cpusubtype().
Definition at line 3383 of file mach0.c.
References get_cputype_from_hdr(), and MACH0_().
Referenced by info().
const char* MACH0_() get_cputype_from_hdr | ( | struct MACH0_(mach_header) * | hdr | ) |
Definition at line 3336 of file mach0.c.
References CPU_TYPE_ARM, CPU_TYPE_ARM64, CPU_TYPE_ARM64_32, CPU_TYPE_HPPA, CPU_TYPE_I386, CPU_TYPE_I860, CPU_TYPE_MC680x0, CPU_TYPE_MC88000, CPU_TYPE_MC98000, CPU_TYPE_MIPS, CPU_TYPE_POWERPC, CPU_TYPE_POWERPC64, CPU_TYPE_SPARC, CPU_TYPE_VAX, CPU_TYPE_X86_64, and eprintf.
Referenced by _patch_reloc(), fill_metadata_info_from_hdr(), and get_cputype().
Definition at line 3196 of file mach0.c.
References entry_to_vaddr(), eprintf, i, if(), MACH0_(), NULL, RZ_NEW0, rz_return_val_if_fail, sdb_num_get(), sdb_num_set(), ut64(), UT64_MAX, and vaddr_to_paddr().
Referenced by entries(), and get_main().
Definition at line 3578 of file mach0.c.
References get_filetype_from_hdr(), MACH0_(), and strdup().
Referenced by info().
char* MACH0_() get_filetype_from_hdr | ( | struct MACH0_(mach_header) * | hdr | ) |
Definition at line 3559 of file mach0.c.
References MH_BUNDLE, MH_CORE, MH_DSYM, MH_DYLIB, MH_DYLIB_STUB, MH_DYLINKER, MH_EXECUTE, MH_FILESET, MH_FVMLIB, MH_KEXT_BUNDLE, MH_OBJECT, MH_PRELOAD, and strdup().
Referenced by fill_metadata_info_from_hdr(), and get_filetype().
Definition at line 3146 of file mach0.c.
References bprintf, calloc(), free(), get_name(), i, setup::idx, imports(), MACH0_(), NULL, RZ_BIN_MACH0_STRING_LENGTH, rz_return_val_if_fail, and rz_str_ncpy().
Referenced by imports().
Definition at line 3582 of file mach0.c.
References addr, b, delta, free(), get_entrypoint(), get_symbols(), get_symbols_list(), i, LC_MAIN, MACH0_(), rz_buf_read_at(), ut64(), UT64_MAX, and vaddr_to_paddr().
Referenced by binsym().
Definition at line 2252 of file mach0.c.
References get_maps_unpatched(), MACH0_(), MACH0_VFILE_NAME_PATCHED, MACH0_VFILE_NAME_RELOC_TARGETS, NULL, patch_relocs(), reloc_targets_map_base(), reloc_targets_vfile_size(), and rz_bin_relocs_patch_maps().
Referenced by maps().
Definition at line 2217 of file mach0.c.
References i, MACH0_(), MACH0_VFILE_NAME_REBASED_STRIPPED, map(), NULL, prot2perm(), rz_bin_map_free(), rz_list_append(), rz_list_newf(), RZ_NEW0, rz_return_val_if_fail, rz_str_filter(), rz_str_ndup(), segment_needs_rebasing_and_stripping(), and strdup().
Referenced by get_maps(), and reloc_targets_map_base().
Get a string from the string table referenced by the LC_SYMTAB command.
stridx | the index into the string table, such as n_strx from a nlist symbol entry |
filter | whether to call rz_str_filter() on the string before returning |
Definition at line 2563 of file mach0.c.
References i, len, NULL, rz_str_filter(), and rz_str_ndup().
Referenced by get_imports(), get_operator_code(), get_symbols(), get_symbols_list(), and parse_relocation_info().
RZ_BORROW RzSkipList* MACH0_() get_relocs | ( | struct MACH0_(obj_t) * | bin | ) |
Definition at line 120 of file mach0_relocs.c.
References reloc_t::addend, dyld_chained_ptr_arm64e_bind::addend, addr, reloc_t::addr, BIND_IMMEDIATE_MASK, BIND_OPCODE_ADD_ADDR_ULEB, BIND_OPCODE_DO_BIND, BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED, BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB, BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB, BIND_OPCODE_DONE, BIND_OPCODE_MASK, BIND_OPCODE_SET_ADDEND_SLEB, BIND_OPCODE_SET_DYLIB_ORDINAL_IMM, BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB, BIND_OPCODE_SET_DYLIB_SPECIAL_IMM, BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB, BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM, BIND_OPCODE_SET_TYPE_IMM, BIND_OPCODE_THREADED, BIND_SUBOPCODE_THREADED_APPLY, BIND_SUBOPCODE_THREADED_SET_BIND_ORDINAL_TABLE_SIZE_ULEB, calloc(), CASE, count, delta, DO_BIND, done, test_evm::end, found, free(), imm, is_valid_ordinal_table_size(), len, NULL, reloc_t::offset, opcodes, reloc_t::ord, dyld_chained_ptr_arm64e_bind::ordinal, dyld_chained_ptr_arm64e_auth_bind::ordinal, p, parse_import_ptr(), parse_relocation_info(), PFMT64x, reloc_comparator(), relocs(), RZ_ARRAY_SIZE, rz_buf_read_at(), RZ_FREE, RZ_LOG_ERROR, RZ_NEW0, rz_pvector_at(), rz_pvector_free(), rz_pvector_len(), rz_pvector_new_with_len(), rz_read_le64(), rz_return_val_if_fail, rz_skiplist_free(), rz_skiplist_insert(), rz_skiplist_new(), rz_sleb128(), skip(), st64, st8, autogen_x86imm::tmp, type, UT16_MAX, UT32_MAX, and ut64().
Referenced by get_patchable_relocs(), parse_classes(), and relocs().
Definition at line 2411 of file mach0.c.
References addr, calloc(), i, NULL, prot2perm(), RZ_MIN, rz_return_val_if_fail, rz_str_filter(), rz_strf, S_ZEROFILL, sections(), snprintf, to, and ut64().
Referenced by carve_kexts(), classes(), estimate_slide(), get_prelink_info_range_from_mach0(), get_stubs_info(), parse_categories(), parse_classes(), process_constructors(), process_kmod_init_term(), rebase_info_populate(), resolve_mig_subsystem(), resolve_syscalls(), rz_dyldcache_get_objc_opt_info(), rz_kext_fill_text_range(), rz_rebase_info_new_from_mach0(), sections_from_bin(), and sections_from_mach0().
Definition at line 2267 of file mach0.c.
References __isDataSection(), free(), i, list(), NULL, PFMT64d, prot2perm(), rz_bin_section_free(), rz_bin_section_new(), rz_list_append(), rz_list_newf(), RZ_MIN, RZ_NEW0, rz_str_filter(), rz_str_ndup(), rz_str_newf(), s, S_ZEROFILL, and ut64().
Referenced by sections().
Definition at line 2959 of file mach0.c.
References addr, assign_export_symbol_t(), bits(), bprintf, calloc(), eprintf, free(), from, get_bits_from_hdr(), get_name(), RSymCtx::hash, i, inSymtab(), RSymCtx::j, MACH0_(), N_ARM_THUMB_DEF, N_EXT, N_STAB, NULL, parse_import_stub(), RZ_BIN_MACH0_SYMBOL_TYPE_EXT, RZ_BIN_MACH0_SYMBOL_TYPE_LOCAL, RZ_FREE, RZ_MAX, RZ_MIN, rz_return_val_if_fail, rz_str_newf(), s, ST32_MAX, st64, RSymCtx::symbols, symbols(), RSymCtx::symbols_count, to, vaddr_to_paddr(), and walk_exports().
Referenced by get_main(), symbols(), symbols_from_bin(), and symbols_from_mach0().
Definition at line 2761 of file mach0.c.
References symbol_t::addr, rz_bin_symbol_t::bits, bits(), bprintf, calloc(), eprintf, fill_exports_list(), free(), from, get_bits_from_hdr(), get_name(), i, inSymtab(), symbol_t::is_imported, rz_bin_symbol_t::is_imported, list(), MACH0_(), N_ARM_THUMB_DEF, N_EXT, symbol_t::name, rz_bin_symbol_t::name, NULL, symbol_t::offset, rz_bin_symbol_t::paddr, parse_import_stub(), rz_bin_symbol_free(), rz_list_append(), rz_list_length(), rz_list_newf(), RZ_MAX, RZ_MIN, RZ_NEW0, rz_return_val_if_fail, rz_str_newf(), s, symbols(), to, rz_bin_symbol_t::type, UT64_MAX, rz_bin_symbol_t::vaddr, vaddr_to_paddr(), and walk_exports().
Referenced by get_main().
Definition at line 2162 of file mach0.c.
References rz_bin_virtual_file_t::buf, rz_bin_virtual_file_t::buf_owned, MACH0_(), MACH0_VFILE_NAME_PATCHED, MACH0_VFILE_NAME_REBASED_STRIPPED, MACH0_VFILE_NAME_RELOC_TARGETS, rz_bin_virtual_file_t::name, needs_rebasing_and_stripping(), new_rebasing_and_stripping_buf(), NULL, patch_relocs(), reloc_targets_vfile_size(), rz_bin_virtual_file_free(), rz_buf_free(), rz_buf_new_empty(), rz_list_newf(), rz_list_push(), RZ_NEW0, rz_return_val_if_fail, strdup(), and ut64().
Referenced by virtual_files().
Definition at line 3554 of file mach0.c.
References MH_EXECUTE, and MH_NO_HEAP_EXECUTION.
Referenced by info().
Definition at line 3312 of file mach0.c.
References cpu, CPU_TYPE_POWERPC, and CPU_TYPE_POWERPC64.
Referenced by info(), and rz_debruijn_offset().
struct MACH0_ | ( | mach_header | ) |
Definition at line 3969 of file mach0.c.
References addr, cmd_to_pf_definition(), cmd_to_string(), CPU_TYPE_POWERPC, CPU_TYPE_POWERPC64, eprintf, f, free(), i, LC_BUILD_VERSION, LC_SEGMENT, LC_SEGMENT_64, length, MACH0_(), n, NULL, off, pa2va(), rz_bin_field_free(), rz_bin_field_new(), rz_buf_read_le32_at, rz_buf_size(), rz_list_append(), rz_list_newf(), sdb_fmt(), and ut64().
struct MACH0_ | ( | obj_t | ) |
< lazily loaded, use only MACH0_(get_relocs)() to access this
< whether relocs have already been parsed and relocs is filled (or NULL on error)
< weak pointers to relocs in relocs
which should be patched
Definition at line 1 of file mach0.h.
Definition at line 2057 of file mach0.c.
References free(), i, NULL, rz_buf_free(), rz_hash_free(), rz_pvector_free(), and rz_skiplist_free().
Referenced by classes(), destroy(), estimate_slide(), rz_dyldcache_get_objc_opt_info(), rz_kernel_cache_free(), rz_kext_free(), sections_from_bin(), and symbols_from_bin().
Definition at line 3969 of file mach0.c.
Definition at line 3633 of file mach0.c.
References addr, build_version_platform_to_string(), build_version_tool_to_string(), cmd_to_pf_definition(), cmd_to_string(), CPU_TYPE_POWERPC, CPU_TYPE_POWERPC64, eprintf, free(), i, LC_BUILD_VERSION, LC_CODE_SIGNATURE, LC_ENCRYPTION_INFO, LC_ENCRYPTION_INFO_64, LC_ID_DYLIB, LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, LC_MAIN, LC_RPATH, LC_SEGMENT, LC_SEGMENT_64, LC_SYMTAB, LC_UUID, length, MACH0_(), n, off, pa2va(), PFMT32x, PFMT64x, printf(), READWORD, rz_buf_get_string(), rz_buf_read8_at(), rz_buf_read_at(), rz_buf_read_le16_at, rz_buf_read_le32_at, rz_buf_size(), rz_read_ble32(), rz_read_ble64(), and ut64().
Definition at line 228 of file mach0_rebase.c.
Referenced by get_virtual_files(), and parse_classes().
Definition at line 532 of file mach0_relocs.c.
References get_patchable_relocs(), rz_pvector_len(), and rz_return_val_if_fail.
Referenced by patch_relocs().
Definition at line 224 of file mach0_rebase.c.
References buf_methods, and rz_buf_new_with_methods().
Referenced by get_virtual_files(), and parse_classes().
Definition at line 67 of file mach0.c.
Referenced by assign_export_symbol_t(), fill_exports_list(), init_items(), pa2va(), and parse_relocation_info().
Patching of external relocs in a sparse overlay buffer.
see also mach0_rebase.c for additional modification of the data that might happen.
Definition at line 614 of file mach0_relocs.c.
References _patch_reloc(), get_patchable_relocs(), MACH0_, needs_reloc_patching(), reloc_t::ord, reloc_target_size(), reloc_targets_map_base(), reloc_targets_vfile_size(), rz_bin_reloc_target_builder_free(), rz_bin_reloc_target_builder_get_target(), rz_bin_reloc_target_builder_new(), rz_buf_new_sparse_overlay(), rz_buf_sparse_set_write_mode(), RZ_BUF_SPARSE_WRITE_MODE_SPARSE, RZ_BUF_SPARSE_WRITE_MODE_THROUGH, rz_pvector_foreach, rz_return_if_fail, reloc_t::target, and ut64().
Referenced by get_maps(), get_virtual_files(), rz_bflt_init(), rz_bflt_new_buf(), rz_bin_options_init(), rz_bin_reload(), and rz_core_bin_options_init().
Definition at line 24 of file mach0_rebase.c.
References bind, count, delta, DYLD_CHAINED_PTR_64_KERNEL_CACHE, DYLD_CHAINED_PTR_64_OFFSET, DYLD_CHAINED_PTR_ARM64E, DYLD_CHAINED_PTR_ARM64E_KERNEL, DYLD_CHAINED_PTR_ARM64E_USERLAND24, DYLD_CHAINED_PTR_START_NONE, test_evm::end, i, in_buf, IS_PTR_AUTH, IS_PTR_BIND, off, p, PFMT64x, rz_buf_read_at(), RZ_LOG_WARN, RZ_MAX, RZ_MIN, rz_read_le64(), rz_return_if_fail, rz_write_le64(), start, autogen_x86imm::tmp, and ut64().
Referenced by buf_read().
base vaddr where to map the artificial reloc target vfile
Definition at line 556 of file mach0_relocs.c.
References get_maps_unpatched(), MACH0_, maps(), reloc_target_size(), rz_bin_relocs_patch_find_targets_map_base(), and rz_list_free().
Referenced by get_maps(), and patch_relocs().
size of the artificial reloc target vfile
Definition at line 547 of file mach0_relocs.c.
References get_patchable_relocs(), reloc_target_size(), and rz_pvector_len().
Referenced by get_maps(), get_virtual_files(), and patch_relocs().
Definition at line 2378 of file mach0.c.
Definition at line 2347 of file mach0.c.
References PFMT64x, rz_str_new(), rz_str_newf(), S_4BYTE_LITERALS, S_COALESCED, S_CSTRING_LITERALS, S_GB_ZEROFILL, S_LAZY_SYMBOL_POINTERS, S_LITERAL_POINTERS, S_MOD_INIT_FUNC_POINTERS, S_MOD_TERM_FUNC_POINTERS, S_NON_LAZY_SYMBOL_POINTERS, S_REGULAR, S_SYMBOL_STUBS, S_ZEROFILL, and type.
RZ_API bool MACH0_() segment_needs_rebasing_and_stripping | ( | struct MACH0_(obj_t) * | obj, |
size_t | seg_index | ||
) |
Definition at line 53 of file mach0.c.
References addr, i, and ut64().
Referenced by get_entrypoint(), get_main(), get_symbols(), and get_symbols_list().