1. Everything is based off of Microsoft's PE format documentation [found here](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format) 2. Up until now, imports were used for relocations in the PE & MDMP format, which is wrong. PE uses base relocations. 3. PE relocations do not have symbols associated with them, and thus have no name. In order to still have flags in relocs flagspace, dummy symbols were allocated with generic names composed of the relocation's virtual address space. * Remove old code of setting import entries to PE relocations * Parse PE base relocations * Implement converting from the specific RzBinPeRelocEnt type to the general RzBinReloc type * Implement corrent type naming of PE relocations * Add missing `PE_IMAGE_FILE_MACHINE` types * Add PE base relocation types * Fix PE format 'has_canary' function * Remove 'RzBinPEObj.endian' and use 'RzBinPEObj.big_endian' instead * Removed a.exe and b.exe tests, as they don't contain base relocations and swapped them with correct tests * Corrected old PE relocation tests * Add new PE base relocation tests
340 lines
6.8 KiB
Meson
340 lines
6.8 KiB
Meson
bin_plugins_list = [
|
|
'any',
|
|
'art',
|
|
'avr',
|
|
'bf',
|
|
'bflt',
|
|
'bios',
|
|
'bootimg',
|
|
'cgc',
|
|
'coff',
|
|
'dex',
|
|
'dmp64',
|
|
'dol',
|
|
'dyldcache',
|
|
'elf',
|
|
'elf64',
|
|
'java',
|
|
'le',
|
|
'luac',
|
|
'mach0',
|
|
'mach064',
|
|
'mbn',
|
|
'mdmp',
|
|
'menuet',
|
|
'mz',
|
|
'ne',
|
|
'nes',
|
|
'nin3ds',
|
|
'ninds',
|
|
'ningb',
|
|
'ningba',
|
|
'nro',
|
|
'nso',
|
|
'omf',
|
|
'qnx',
|
|
'p9',
|
|
'pe',
|
|
'pe64',
|
|
'pebble',
|
|
'prg',
|
|
'psxexe',
|
|
'pyc',
|
|
'sfc',
|
|
'smd',
|
|
'sms',
|
|
'spc700',
|
|
'symbols',
|
|
'te',
|
|
'vsf',
|
|
'wasm',
|
|
'xbe',
|
|
'xnu_kernelcache',
|
|
'z64',
|
|
'zimg',
|
|
]
|
|
|
|
bin_xtr_plugins_list = [
|
|
'fatmach0',
|
|
'sep64',
|
|
# this was never built.
|
|
# 'pemixed',
|
|
]
|
|
|
|
bin_plugins = {
|
|
'base_name': 'rz_bin',
|
|
'base_struct': 'RzBinPlugin',
|
|
'list': bin_plugins_list,
|
|
}
|
|
|
|
bin_xtr_plugins = {
|
|
'base_name': 'rz_bin_xtr',
|
|
'base_struct': 'RzBinXtrPlugin',
|
|
'list': bin_xtr_plugins_list,
|
|
}
|
|
|
|
rz_bin_sources = [
|
|
'bfile.c',
|
|
'bfile_string.c',
|
|
'bin.c',
|
|
'bin_demangle.c',
|
|
'bin_language.c',
|
|
'bobj.c',
|
|
'bobj_process.c',
|
|
'bobj_process_class.c',
|
|
'bobj_process_entry.c',
|
|
'bobj_process_field.c',
|
|
'bobj_process_file.c',
|
|
'bobj_process_import.c',
|
|
'bobj_process_map.c',
|
|
'bobj_process_section.c',
|
|
'bobj_process_string.c',
|
|
'bobj_process_symbol.c',
|
|
'bobj_process_reloc.c',
|
|
'dbginfo.c',
|
|
'filter.c',
|
|
'golang.c',
|
|
'relocs_patch.c',
|
|
'p/bin_any.c',
|
|
'p/bin_art.c',
|
|
'p/bin_avr.c',
|
|
'p/bin_bf.c',
|
|
'p/bin_bflt.c',
|
|
'p/bin_bios.c',
|
|
'p/bin_bootimg.c',
|
|
'p/bin_cgc.c',
|
|
'p/bin_coff.c',
|
|
'p/bin_dex.c',
|
|
'p/bin_dmp64.c',
|
|
'p/bin_dol.c',
|
|
'p/bin_dyldcache.c',
|
|
'p/bin_elf.c',
|
|
'p/bin_elf64.c',
|
|
'p/bin_java.c',
|
|
'p/bin_le.c',
|
|
'p/bin_luac.c',
|
|
'p/bin_mach0.c',
|
|
'p/bin_mach064.c',
|
|
'p/bin_mbn.c',
|
|
'p/bin_mdmp.c',
|
|
'p/bin_menuet.c',
|
|
'p/bin_mz.c',
|
|
'p/bin_ne.c',
|
|
'p/bin_nes.c',
|
|
'p/bin_nin3ds.c',
|
|
'p/bin_ninds.c',
|
|
'p/bin_ningb.c',
|
|
'p/bin_ningba.c',
|
|
'p/bin_nro.c',
|
|
'p/bin_nso.c',
|
|
'p/bin_omf.c',
|
|
'p/bin_p9.c',
|
|
'p/bin_pe.c',
|
|
'p/bin_pe64.c',
|
|
'p/bin_pebble.c',
|
|
'p/bin_prg.c',
|
|
'p/bin_psxexe.c',
|
|
'p/bin_pyc.c',
|
|
'p/bin_qnx.c',
|
|
'p/bin_sfc.c',
|
|
'p/bin_smd.c',
|
|
'p/bin_sms.c',
|
|
'p/bin_spc700.c',
|
|
'p/bin_symbols.c',
|
|
'p/bin_te.c',
|
|
'p/bin_vsf.c',
|
|
'p/bin_wasm.c',
|
|
'p/bin_xbe.c',
|
|
'p/bin_xnu_kernelcache.c',
|
|
'p/bin_xtr_fatmach0.c',
|
|
# this was never built.
|
|
# 'p/bin_xtr_pemixed.c',
|
|
'p/bin_xtr_sep64.c',
|
|
'p/bin_z64.c',
|
|
'p/bin_zimg.c',
|
|
|
|
|
|
'format/bflt/bflt.c',
|
|
'format/coff/coff.c',
|
|
'format/coff/coff_reloc.c',
|
|
'format/dex/dex.c',
|
|
'format/dmp/dmp64.c',
|
|
'format/elf/elf.c',
|
|
'format/elf/elf64.c',
|
|
'format/elf/elf_arm.c',
|
|
'format/elf/elf64_arm.c',
|
|
'format/elf/elf_corefile.c',
|
|
'format/elf/elf64_corefile.c',
|
|
'format/elf/elf_dynamic.c',
|
|
'format/elf/elf64_dynamic.c',
|
|
'format/elf/elf_ehdr.c',
|
|
'format/elf/elf64_ehdr.c',
|
|
'format/elf/elf_hash.c',
|
|
'format/elf/elf64_hash.c',
|
|
'format/elf/elf_imports.c',
|
|
'format/elf/elf64_imports.c',
|
|
'format/elf/elf_map.c',
|
|
'format/elf/elf64_map.c',
|
|
'format/elf/elf_info.c',
|
|
'format/elf/elf64_info.c',
|
|
'format/elf/elf_misc.c',
|
|
'format/elf/elf64_misc.c',
|
|
'format/elf/elf_notes.c',
|
|
'format/elf/elf64_notes.c',
|
|
'format/elf/elf_relocs.c',
|
|
'format/elf/elf64_relocs.c',
|
|
'format/elf/elf_sections.c',
|
|
'format/elf/elf64_sections.c',
|
|
'format/elf/elf_segments.c',
|
|
'format/elf/elf64_segments.c',
|
|
'format/elf/elf_strtab.c',
|
|
'format/elf/elf64_strtab.c',
|
|
'format/elf/elf_symbols.c',
|
|
'format/elf/elf64_symbols.c',
|
|
'format/java/class_attribute.c',
|
|
'format/java/class_const_pool.c',
|
|
'format/java/class_interface.c',
|
|
'format/java/class_bin.c',
|
|
'format/java/class_field.c',
|
|
'format/java/class_method.c',
|
|
'format/mach0/mach0_common.c',
|
|
'format/mach0/dyldcache.c',
|
|
'format/mach0/dyldcache_rebase.c',
|
|
'format/mach0/coresymbolication.c',
|
|
'format/mach0/fatmach0.c',
|
|
'format/mach0/kernelcache.c',
|
|
'format/mach0/mach0.c',
|
|
'format/mach0/mach0_relocs.c',
|
|
'format/mach0/mach0_chained_fixups.c',
|
|
'format/mach0/mach064.c',
|
|
'format/mach0/mach064_relocs.c',
|
|
'format/mach0/mach064_chained_fixups.c',
|
|
'format/xnu/rz_cf_dict.c',
|
|
'format/mdmp/mdmp.c',
|
|
'format/mdmp/mdmp_pe.c',
|
|
'format/mdmp/mdmp_pe64.c',
|
|
'format/le/le.c',
|
|
'format/luac/luac_common.c',
|
|
'format/luac/luac_bin.c',
|
|
'format/luac/v54/parse_54.c',
|
|
'format/luac/v53/parse_53.c',
|
|
'format/ne/ne.c',
|
|
'format/mz/mz.c',
|
|
'format/nxo/nxo.c',
|
|
'format/objc/mach064_classes.c',
|
|
'format/objc/mach0_classes.c',
|
|
'format/omf/omf.c',
|
|
'format/p9/p9bin.c',
|
|
'format/pe/dotnet.c',
|
|
'format/pe/pe.c',
|
|
'format/pe/pe64.c',
|
|
'format/pe/pe_info.c',
|
|
'format/pe/pe64_info.c',
|
|
'format/pe/pe_overlay.c',
|
|
'format/pe/pe64_overlay.c',
|
|
'format/pe/pe_hdr.c',
|
|
'format/pe/pe64_hdr.c',
|
|
'format/pe/pe_imports.c',
|
|
'format/pe/pe64_imports.c',
|
|
'format/pe/pe_relocs.c',
|
|
'format/pe/pe64_relocs.c',
|
|
'format/pe/pe_exports.c',
|
|
'format/pe/pe64_exports.c',
|
|
'format/pe/pe_rsrc.c',
|
|
'format/pe/pe64_rsrc.c',
|
|
'format/pe/pe_tls.c',
|
|
'format/pe/pe64_tls.c',
|
|
'format/pe/pe_security.c',
|
|
'format/pe/pe64_security.c',
|
|
'format/pe/pe_section.c',
|
|
'format/pe/pe64_section.c',
|
|
'format/pe/pe_clr.c',
|
|
'format/pe/pe64_clr.c',
|
|
'format/pe/pe_debug.c',
|
|
'format/pe/pe64_debug.c',
|
|
'format/pe/pemixed.c',
|
|
'format/pyc/marshal.c',
|
|
'format/pyc/pyc.c',
|
|
'format/pyc/pyc_magic.c',
|
|
'format/te/te.c',
|
|
'format/wasm/wasm.c',
|
|
'format/zimg/zimg.c',
|
|
|
|
'pdb/cab_extract.c',
|
|
'pdb/dbi.c',
|
|
'pdb/gdata.c',
|
|
'pdb/omap.c',
|
|
'pdb/pdb.c',
|
|
'pdb/pdb_downloader.c',
|
|
'pdb/stream_pe.c',
|
|
'pdb/tpi.c',
|
|
'pdb/symbol.c',
|
|
'pdb/modi.c',
|
|
|
|
'dwarf/abbrev.c',
|
|
'dwarf/addr.c',
|
|
'dwarf/aranges.c',
|
|
'dwarf/attr.c',
|
|
'dwarf/block.c',
|
|
'dwarf/enum.c',
|
|
'dwarf/endian_reader.c',
|
|
'dwarf/lists.c',
|
|
'dwarf/line.c',
|
|
'dwarf/line_str.c',
|
|
'dwarf/loclists.c',
|
|
'dwarf/op.c',
|
|
'dwarf/rnglists.c',
|
|
'dwarf/unit.c',
|
|
'dwarf/value.c',
|
|
'dwarf/str.c',
|
|
'dwarf/str_offsets.c',
|
|
'dwarf/dwarf.c',
|
|
]
|
|
|
|
rz_bin_inc = [platform_inc, include_directories('format')]
|
|
|
|
rz_bin = library('rz_bin', rz_bin_sources,
|
|
include_directories: rz_bin_inc,
|
|
c_args: ['-DRZ_API_BIN_ONLY=1'],
|
|
dependencies: [
|
|
lz4_dep,
|
|
libzstd_dep,
|
|
yxml_dep,
|
|
rz_util_dep,
|
|
rz_demangler_dep,
|
|
rz_socket_dep,
|
|
rz_magic_dep,
|
|
rz_hash_dep,
|
|
rz_syscall_dep,
|
|
rz_cons_dep,
|
|
rz_io_dep,
|
|
rz_type_dep,
|
|
libmspack_dep,
|
|
],
|
|
install: true,
|
|
implicit_include_directories: false,
|
|
install_rpath: rpath_lib,
|
|
soversion: rizin_libversion,
|
|
version: rizin_version,
|
|
name_suffix: lib_name_suffix,
|
|
name_prefix: lib_name_prefix,
|
|
)
|
|
|
|
rz_bin_dep = declare_dependency(link_with: rz_bin,
|
|
include_directories: rz_bin_inc)
|
|
meson.override_dependency('rz_bin', rz_bin_dep)
|
|
|
|
modules += { 'rz_bin': {
|
|
'target': rz_bin,
|
|
'dependencies': [
|
|
'rz_magic',
|
|
'rz_util',
|
|
'rz_io',
|
|
'rz_socket',
|
|
'rz_syscall',
|
|
'rz_type'
|
|
],
|
|
'plugins': [bin_plugins, bin_xtr_plugins]
|
|
}}
|
|
|
|
subdir('d')
|