From b60e1ecceb74c754d1a578c109af5903eabf9e71 Mon Sep 17 00:00:00 2001 From: wargio Date: Wed, 17 Jan 2024 16:06:40 +0800 Subject: [PATCH] Build rz_arch --- binrz/rizin/meson.build | 3 +- binrz/rz-diff/meson.build | 3 +- librz/arch/README.md | 0 librz/arch/README2.md | 0 librz/arch/analysis.c | 6 +- librz/arch/arch/arm/arm_cs.h | 2 +- librz/arch/arch/arm/arm_it.h | 1 + librz/arch/arch/arm/asm-arm.h | 2 +- librz/arch/arch/avr/avr_il.h | 2 +- librz/arch/arch/gb/gbdis.c | 2 - librz/arch/arch/lh5801/lh5801.h | 2 +- librz/arch/arch/luac/v53/arch_53.h | 2 +- librz/arch/arch/luac/v54/arch_54.h | 2 +- librz/arch/arch/riscv/riscv.c | 203 ++++---- librz/arch/arch/sh/sh_il.c | 2 +- librz/arch/arch/sh/sh_il.h | 2 +- librz/arch/arch/tricore/tricore_il.c | 2 +- librz/arch/arch/wasm/wasm.h | 2 - librz/arch/asm.c | 22 +- librz/arch/class.c | 3 +- librz/arch/d/meson.build | 114 ++++- librz/arch/d/meson2.build | 109 ----- librz/arch/meson.build | 443 +++++++++++++----- librz/arch/meson2.build | 327 ------------- librz/arch/p/analysis_6502.c | 12 +- librz/arch/p/analysis_8051.c | 2 +- librz/arch/p/analysis_amd29k.c | 2 +- .../p/{analysis_arc.c => analysis_arc_gnu.c} | 0 librz/arch/p/analysis_arm_cs.c | 2 +- librz/arch/p/analysis_avr.c | 2 +- librz/arch/p/analysis_cil.c | 2 +- .../{analysis_cris.c => analysis_cris_gnu.c} | 4 +- librz/arch/p/analysis_dalvik.c | 2 +- librz/arch/p/analysis_gb.c | 3 +- librz/arch/p/analysis_i4004.c | 53 +-- librz/arch/p/analysis_i8080.c | 2 +- librz/arch/p/analysis_java.c | 2 +- librz/arch/p/analysis_luac.c | 2 +- librz/arch/p/analysis_mcore.c | 2 +- ...{analysis_nios2.c => analysis_nios2_gnu.c} | 0 librz/arch/p/analysis_pic.c | 2 +- librz/arch/p/analysis_ppc_cs.c | 2 +- librz/arch/p/analysis_pyc.c | 2 +- ...{analysis_riscv.c => analysis_riscv_gnu.c} | 19 +- librz/arch/p/analysis_rl78.c | 4 +- librz/arch/p/analysis_rsp.c | 2 +- librz/arch/p/analysis_snes.c | 4 +- librz/arch/p/analysis_spc700.c | 2 +- librz/arch/p/analysis_tms320.c | 82 +++- librz/arch/p/analysis_tms320_c55x_plus.c | 79 ---- librz/arch/p/analysis_tricore_cs.c | 2 +- .../p/{analysis_vax.c => analysis_vax_gnu.c} | 0 librz/arch/p/analysis_wasm.c | 5 +- librz/arch/p/analysis_x86_cs.c | 8 +- librz/arch/p/analysis_xap.c | 2 +- ...nalysis_xtensa.c => analysis_xtensa_gnu.c} | 0 .../p/{analysis_z80.c => analysis_z80_gnu.c} | 2 +- librz/arch/p/arch_6502.c | 10 + librz/arch/p/arch_8051.c | 10 + librz/arch/p/arch_amd29k.c | 10 + librz/arch/p/arch_arc_gnu.c | 10 + librz/arch/p/arch_arm_as.c | 9 + librz/arch/p/arch_arm_cs.c | 10 + librz/arch/p/arch_avr.c | 10 + librz/arch/p/arch_bf.c | 10 + librz/arch/p/arch_chip8.c | 10 + librz/arch/p/arch_cil.c | 10 + librz/arch/p/arch_cr16.c | 10 + librz/arch/p/arch_cris_gnu.c | 10 + librz/arch/p/arch_dalvik.c | 10 + librz/arch/p/arch_dcpu16.c | 9 + librz/arch/p/arch_ebc.c | 10 + librz/arch/p/arch_gb.c | 10 + librz/arch/p/arch_h8300.c | 10 + librz/arch/p/arch_helper.h | 41 ++ librz/arch/p/arch_hexagon.c | 10 + librz/arch/p/arch_hppa_gnu.c | 9 + librz/arch/p/arch_i4004.c | 10 + librz/arch/p/arch_i8080.c | 10 + librz/arch/p/arch_java.c | 10 + librz/arch/p/arch_lanai_gnu.c | 9 + librz/arch/p/arch_lh5801.c | 9 + librz/arch/p/arch_lm32.c | 9 + librz/arch/p/arch_luac.c | 10 + librz/arch/p/arch_m680x_cs.c | 10 + librz/arch/p/arch_m68k_cs.c | 10 + librz/arch/p/arch_malbolge.c | 10 + librz/arch/p/arch_mcore.c | 10 + librz/arch/p/arch_mcs96.c | 9 + librz/arch/p/arch_mips_cs.c | 10 + librz/arch/p/arch_mips_gnu.c | 10 + librz/arch/p/arch_msp430.c | 10 + librz/arch/p/arch_nios2_gnu.c | 10 + librz/arch/p/arch_null.c | 10 + librz/arch/p/arch_or1k.c | 10 + librz/arch/p/arch_pic.c | 10 + librz/arch/p/arch_ppc_as.c | 9 + librz/arch/p/arch_ppc_cs.c | 10 + librz/arch/p/arch_propeller.c | 10 + librz/arch/p/arch_pyc.c | 10 + librz/arch/p/arch_riscv_cs.c | 10 + librz/arch/p/arch_riscv_gnu.c | 10 + librz/arch/p/arch_rl78.c | 10 + librz/arch/p/arch_rsp.c | 10 + librz/arch/p/arch_sh.c | 10 + librz/arch/p/arch_snes.c | 10 + librz/arch/p/arch_sparc_cs.c | 10 + librz/arch/p/arch_sparc_gnu.c | 10 + librz/arch/p/arch_spc700.c | 10 + librz/arch/p/arch_sysz.c | 10 + librz/arch/p/arch_tms320.c | 10 + librz/arch/p/arch_tms320c64x.c | 12 + librz/arch/p/arch_tricore_cs.c | 10 + librz/arch/p/arch_v810.c | 10 + librz/arch/p/arch_v850.c | 10 + librz/arch/p/arch_vax_gnu.c | 10 + librz/arch/p/arch_wasm.c | 10 + librz/arch/p/arch_x86_as.c | 9 + librz/arch/p/arch_x86_cs.c | 10 + librz/arch/p/arch_x86_nasm.c | 9 + librz/arch/p/arch_x86_nz.c | 9 + librz/arch/p/arch_xap.c | 10 + librz/arch/p/arch_xcore_cs.c | 10 + librz/arch/p/arch_xtensa_gnu.c | 10 + librz/arch/p/arch_z80_gnu.c | 10 + librz/arch/p/asm_8051.c | 1 - librz/arch/p/{asm_arc.c => asm_arc_gnu.c} | 0 librz/arch/p/asm_arm_cs.c | 24 +- librz/arch/p/asm_arm_hacks.inc | 16 +- librz/arch/p/asm_gb.c | 1 - librz/arch/p/asm_i4004.c | 1 - librz/arch/p/asm_i8080.c | 1 - librz/arch/p/asm_java.c | 20 +- librz/arch/p/asm_lh5801.c | 2 +- librz/arch/p/asm_luac.c | 2 +- librz/arch/p/{asm_nios2.c => asm_nios2_gnu.c} | 0 librz/arch/p/asm_or1k.c | 12 - librz/arch/p/asm_pyc.c | 21 +- librz/arch/p/{asm_riscv.c => asm_riscv_gnu.c} | 2 - librz/arch/p/asm_spc700.c | 1 - librz/arch/p/asm_tms320.c | 8 +- librz/arch/p/asm_tricore_cs.c | 7 +- librz/arch/p/{asm_vax.c => asm_vax_gnu.c} | 0 librz/arch/p/asm_xap.c | 5 +- .../arch/p/{asm_xtensa.c => asm_xtensa_gnu.c} | 0 librz/arch/p/{asm_z80.c => asm_z80_gnu.c} | 0 librz/arch/platforms/meson.build | 2 +- librz/bin/p/bin_java.c | 2 +- librz/config.h.in | 3 +- librz/core/libs.c | 33 ++ librz/core/meson.build | 6 +- librz/debug/meson.build | 4 +- librz/egg/meson.build | 4 +- librz/include/meson.build | 1 + librz/include/rz_analysis.h | 61 --- librz/include/rz_arch.h | 101 ++++ librz/include/rz_asm.h | 70 --- librz/include/rz_core.h | 1 + librz/include/rz_lib.h | 1 + librz/main/meson.build | 5 +- librz/main/rz-asm.c | 25 +- librz/sign/meson.build | 4 +- meson.build | 6 +- sys/clang-format.py | 18 +- test/integration/meson.build | 3 +- test/unit/meson.build | 3 +- 166 files changed, 1626 insertions(+), 1118 deletions(-) delete mode 100644 librz/arch/README.md delete mode 100644 librz/arch/README2.md delete mode 100644 librz/arch/d/meson2.build delete mode 100644 librz/arch/meson2.build rename librz/arch/p/{analysis_arc.c => analysis_arc_gnu.c} (100%) rename librz/arch/p/{analysis_cris.c => analysis_cris_gnu.c} (98%) rename librz/arch/p/{analysis_nios2.c => analysis_nios2_gnu.c} (100%) rename librz/arch/p/{analysis_riscv.c => analysis_riscv_gnu.c} (98%) delete mode 100644 librz/arch/p/analysis_tms320_c55x_plus.c rename librz/arch/p/{analysis_vax.c => analysis_vax_gnu.c} (100%) rename librz/arch/p/{analysis_xtensa.c => analysis_xtensa_gnu.c} (100%) rename librz/arch/p/{analysis_z80.c => analysis_z80_gnu.c} (99%) create mode 100644 librz/arch/p/arch_6502.c create mode 100644 librz/arch/p/arch_8051.c create mode 100644 librz/arch/p/arch_amd29k.c create mode 100644 librz/arch/p/arch_arc_gnu.c create mode 100644 librz/arch/p/arch_arm_as.c create mode 100644 librz/arch/p/arch_arm_cs.c create mode 100644 librz/arch/p/arch_avr.c create mode 100644 librz/arch/p/arch_bf.c create mode 100644 librz/arch/p/arch_chip8.c create mode 100644 librz/arch/p/arch_cil.c create mode 100644 librz/arch/p/arch_cr16.c create mode 100644 librz/arch/p/arch_cris_gnu.c create mode 100644 librz/arch/p/arch_dalvik.c create mode 100644 librz/arch/p/arch_dcpu16.c create mode 100644 librz/arch/p/arch_ebc.c create mode 100644 librz/arch/p/arch_gb.c create mode 100644 librz/arch/p/arch_h8300.c create mode 100644 librz/arch/p/arch_helper.h create mode 100644 librz/arch/p/arch_hexagon.c create mode 100644 librz/arch/p/arch_hppa_gnu.c create mode 100644 librz/arch/p/arch_i4004.c create mode 100644 librz/arch/p/arch_i8080.c create mode 100644 librz/arch/p/arch_java.c create mode 100644 librz/arch/p/arch_lanai_gnu.c create mode 100644 librz/arch/p/arch_lh5801.c create mode 100644 librz/arch/p/arch_lm32.c create mode 100644 librz/arch/p/arch_luac.c create mode 100644 librz/arch/p/arch_m680x_cs.c create mode 100644 librz/arch/p/arch_m68k_cs.c create mode 100644 librz/arch/p/arch_malbolge.c create mode 100644 librz/arch/p/arch_mcore.c create mode 100644 librz/arch/p/arch_mcs96.c create mode 100644 librz/arch/p/arch_mips_cs.c create mode 100644 librz/arch/p/arch_mips_gnu.c create mode 100644 librz/arch/p/arch_msp430.c create mode 100644 librz/arch/p/arch_nios2_gnu.c create mode 100644 librz/arch/p/arch_null.c create mode 100644 librz/arch/p/arch_or1k.c create mode 100644 librz/arch/p/arch_pic.c create mode 100644 librz/arch/p/arch_ppc_as.c create mode 100644 librz/arch/p/arch_ppc_cs.c create mode 100644 librz/arch/p/arch_propeller.c create mode 100644 librz/arch/p/arch_pyc.c create mode 100644 librz/arch/p/arch_riscv_cs.c create mode 100644 librz/arch/p/arch_riscv_gnu.c create mode 100644 librz/arch/p/arch_rl78.c create mode 100644 librz/arch/p/arch_rsp.c create mode 100644 librz/arch/p/arch_sh.c create mode 100644 librz/arch/p/arch_snes.c create mode 100644 librz/arch/p/arch_sparc_cs.c create mode 100644 librz/arch/p/arch_sparc_gnu.c create mode 100644 librz/arch/p/arch_spc700.c create mode 100644 librz/arch/p/arch_sysz.c create mode 100644 librz/arch/p/arch_tms320.c create mode 100644 librz/arch/p/arch_tms320c64x.c create mode 100644 librz/arch/p/arch_tricore_cs.c create mode 100644 librz/arch/p/arch_v810.c create mode 100644 librz/arch/p/arch_v850.c create mode 100644 librz/arch/p/arch_vax_gnu.c create mode 100644 librz/arch/p/arch_wasm.c create mode 100644 librz/arch/p/arch_x86_as.c create mode 100644 librz/arch/p/arch_x86_cs.c create mode 100644 librz/arch/p/arch_x86_nasm.c create mode 100644 librz/arch/p/arch_x86_nz.c create mode 100644 librz/arch/p/arch_xap.c create mode 100644 librz/arch/p/arch_xcore_cs.c create mode 100644 librz/arch/p/arch_xtensa_gnu.c create mode 100644 librz/arch/p/arch_z80_gnu.c rename librz/arch/p/{asm_arc.c => asm_arc_gnu.c} (100%) rename librz/arch/p/{asm_nios2.c => asm_nios2_gnu.c} (100%) rename librz/arch/p/{asm_riscv.c => asm_riscv_gnu.c} (90%) rename librz/arch/p/{asm_vax.c => asm_vax_gnu.c} (100%) rename librz/arch/p/{asm_xtensa.c => asm_xtensa_gnu.c} (100%) rename librz/arch/p/{asm_z80.c => asm_z80_gnu.c} (100%) create mode 100644 librz/include/rz_arch.h diff --git a/binrz/rizin/meson.build b/binrz/rizin/meson.build index 626bc83cd12..a773375b8fd 100644 --- a/binrz/rizin/meson.build +++ b/binrz/rizin/meson.build @@ -9,13 +9,12 @@ rizin_exe = executable('rizin', 'rizin.c', rz_bin_dep, rz_flag_dep, rz_cons_dep, - rz_asm_dep, + rz_arch_dep, rz_debug_dep, rz_config_dep, rz_bp_dep, rz_reg_dep, rz_syscall_dep, - rz_analysis_dep, rz_parse_dep, rz_egg_dep, rz_search_dep, diff --git a/binrz/rz-diff/meson.build b/binrz/rz-diff/meson.build index 31a82d93e04..8299004301e 100644 --- a/binrz/rz-diff/meson.build +++ b/binrz/rz-diff/meson.build @@ -8,8 +8,7 @@ executable('rz-diff', 'rz-diff.c', rz_cons_dep, rz_core_dep, rz_bin_dep, - rz_analysis_dep, - rz_asm_dep, + rz_arch_dep, rz_hash_dep, rz_config_dep ], diff --git a/librz/arch/README.md b/librz/arch/README.md deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/librz/arch/README2.md b/librz/arch/README2.md deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/librz/arch/analysis.c b/librz/arch/analysis.c index 4b80a007adb..995fcd14460 100644 --- a/librz/arch/analysis.c +++ b/librz/arch/analysis.c @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: 2009-2020 nibble // SPDX-License-Identifier: LGPL-3.0-only -#include +#include #include #include #include @@ -11,7 +11,7 @@ RZ_LIB_VERSION(rz_analysis); -static RzAnalysisPlugin *analysis_static_plugins[] = { RZ_ANALYSIS_STATIC_PLUGINS }; +static RzArchPlugin *analysis_static_plugins[] = { RZ_ARCH_STATIC_PLUGINS }; /** * \brief Returns the default size byte width of memory access operations. @@ -130,7 +130,7 @@ RZ_API RzAnalysis *rz_analysis_new(void) { analysis->plugins = rz_list_new(); if (analysis->plugins) { for (i = 0; i < RZ_ARRAY_SIZE(analysis_static_plugins); i++) { - rz_analysis_plugin_add(analysis, analysis_static_plugins[i]); + rz_analysis_plugin_add(analysis, analysis_static_plugins[i]->p_analysis); } } analysis->ht_global_var = ht_pp_new(NULL, global_kv_free, NULL); diff --git a/librz/arch/arch/arm/arm_cs.h b/librz/arch/arch/arm/arm_cs.h index 44159459fa0..a2c55eb8f86 100644 --- a/librz/arch/arch/arm/arm_cs.h +++ b/librz/arch/arch/arm/arm_cs.h @@ -6,7 +6,7 @@ #include #include -#include "../../asm/arch/arm/aarch64_meta_macros.h" +#include "aarch64_meta_macros.h" RZ_IPI int rz_arm_cs_analysis_op_32_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn, bool thumb); RZ_IPI int rz_arm_cs_analysis_op_64_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn); diff --git a/librz/arch/arch/arm/arm_it.h b/librz/arch/arch/arm/arm_it.h index 183d6efa42d..58df5d119ae 100644 --- a/librz/arch/arch/arm/arm_it.h +++ b/librz/arch/arch/arm/arm_it.h @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-only #ifndef RZ_ARM_IT_H +#define RZ_ARM_IT_H /** * \file diff --git a/librz/arch/arch/arm/asm-arm.h b/librz/arch/arch/arm/asm-arm.h index 7ee8d8267e1..1cd11e600fb 100644 --- a/librz/arch/arch/arm/asm-arm.h +++ b/librz/arch/arch/arm/asm-arm.h @@ -5,7 +5,7 @@ #define _INCLUDE_ARMASS_H_ #include -#include "../arch/arm/aarch64_meta_macros.h" +#include "aarch64_meta_macros.h" int armass_assemble(const char *str, ut64 off, int thumb); diff --git a/librz/arch/arch/avr/avr_il.h b/librz/arch/arch/avr/avr_il.h index 9f71da15ed1..ad7313b2cf8 100644 --- a/librz/arch/arch/avr/avr_il.h +++ b/librz/arch/arch/avr/avr_il.h @@ -6,7 +6,7 @@ #define RZIL_ANALYSIS_AVR_H #include -#include "../../../asm/arch/avr/disassembler.h" +#include "disassembler.h" RZ_IPI bool rz_avr_il_opcode(RzAnalysis *analysis, RzAnalysisOp *op, ut64 pc, AVROp *aop, AVROp *next_op); RZ_IPI RzAnalysisILConfig *rz_avr_il_config(RZ_NONNULL RzAnalysis *analysis); diff --git a/librz/arch/arch/gb/gbdis.c b/librz/arch/arch/gb/gbdis.c index 082dda8eef5..d9e3c992716 100644 --- a/librz/arch/arch/gb/gbdis.c +++ b/librz/arch/arch/gb/gbdis.c @@ -150,7 +150,6 @@ static void gb_hardware_register_name(char *reg, ut8 offset) { } } -#ifndef GB_DIS_LEN_ONLY static int gbDisass(RzAsmOp *op, const ut8 *buf, int len) { int foo = gbOpLength(gb_op[buf[0]].type); if (len < foo) { @@ -180,4 +179,3 @@ static int gbDisass(RzAsmOp *op, const ut8 *buf, int len) { rz_strbuf_set(&op->buf_asm, buf_asm); return foo; } -#endif diff --git a/librz/arch/arch/lh5801/lh5801.h b/librz/arch/arch/lh5801/lh5801.h index f514dca7c27..914b6083f27 100644 --- a/librz/arch/arch/lh5801/lh5801.h +++ b/librz/arch/arch/lh5801/lh5801.h @@ -6,9 +6,9 @@ * (system manual) as published by Günter Holtkötter GmbH. */ +#include #include #include -typedef uint8_t ut8; /* Instruction classes. That's for example "add with carry". */ enum lh5801_insn_class { diff --git a/librz/arch/arch/luac/v53/arch_53.h b/librz/arch/arch/luac/v53/arch_53.h index bb6c818d97c..020bc92591f 100644 --- a/librz/arch/arch/luac/v53/arch_53.h +++ b/librz/arch/arch/luac/v53/arch_53.h @@ -8,7 +8,7 @@ #include #include #include -#include "librz/asm/arch/luac/lua_arch.h" +#include "../lua_arch.h" /*=========================================================================== We assume that instructions are unsigned numbers. diff --git a/librz/arch/arch/luac/v54/arch_54.h b/librz/arch/arch/luac/v54/arch_54.h index 44e2aa3ab09..54c50a3138e 100644 --- a/librz/arch/arch/luac/v54/arch_54.h +++ b/librz/arch/arch/luac/v54/arch_54.h @@ -6,7 +6,7 @@ #include #include -#include "librz/asm/arch/luac/lua_arch.h" +#include "../lua_arch.h" /*=========================================================================== We assume that instructions are unsigned 32-bit integers. diff --git a/librz/arch/arch/riscv/riscv.c b/librz/arch/arch/riscv/riscv.c index 84c1552e6da..8f5c7ee3bee 100644 --- a/librz/arch/arch/riscv/riscv.c +++ b/librz/arch/arch/riscv/riscv.c @@ -36,23 +36,23 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) // TODO : an conf to chose between abi or numeric -static const char * const *riscv_gpr_names = riscv_gpr_names_abi; -static const char * const *riscv_fpr_names = riscv_fpr_names_abi; -static int init = 0; +static const char *const *riscv_gpr_names = riscv_gpr_names_abi; +static const char *const *riscv_fpr_names = riscv_fpr_names_abi; +static bool init = 0; -static void arg_p (char *buf, unsigned long val, const char* const* array, size_t size) { +static void arg_p(char *buf, unsigned long val, const char *const *array, size_t size) { const char *s = val >= size || array[val] ? array[val] : "unknown"; - sprintf (buf+strlen (buf), "%s", s); + sprintf(buf + strlen(buf), "%s", s); } /* Print insn arguments for 32/64-bit code. */ -static void get_insn_args (char *buf, const char *d, insn_t l, uint64_t pc) { +static void get_insn_args(char *buf, const char *d, insn_t l, uint64_t pc) { int rs1 = (l >> OP_SH_RS1) & OP_MASK_RS1; int rd = (l >> OP_SH_RD) & OP_MASK_RD; uint64_t target; if (*d != '\0') { - sprintf (buf+strlen (buf), " "); + sprintf(buf + strlen(buf), " "); } for (; *d != '\0'; d++) { @@ -61,16 +61,16 @@ static void get_insn_args (char *buf, const char *d, insn_t l, uint64_t pc) { case '^': switch (*++d) { case 'd': - sprintf (buf+strlen (buf), "%d", rd); + sprintf(buf + strlen(buf), "%d", rd); break; case 's': - sprintf (buf+strlen (buf), "%d", rs1); + sprintf(buf + strlen(buf), "%d", rs1); break; case 't': - sprintf (buf+strlen (buf), "%d", (int) EXTRACT_OPERAND (RS2, l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_OPERAND(RS2, l)); break; case 'j': - sprintf (buf+strlen (buf), "%d", (int) EXTRACT_OPERAND (CUSTOM_IMM, l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_OPERAND(CUSTOM_IMM, l)); break; } break; @@ -79,244 +79,243 @@ static void get_insn_args (char *buf, const char *d, insn_t l, uint64_t pc) { switch (*++d) { case 's': /* RS1 x8-x15 */ case 'w': /* RS1 x8-x15 */ - sprintf (buf+strlen (buf), "%s", - riscv_gpr_names[EXTRACT_OPERAND (CRS1S, l) + 8]); + sprintf(buf + strlen(buf), "%s", + riscv_gpr_names[EXTRACT_OPERAND(CRS1S, l) + 8]); break; case 't': /* RS2 x8-x15 */ case 'x': /* RS2 x8-x15 */ - sprintf (buf+strlen (buf), "%s", - riscv_gpr_names[EXTRACT_OPERAND (CRS2S, l) + 8]); + sprintf(buf + strlen(buf), "%s", + riscv_gpr_names[EXTRACT_OPERAND(CRS2S, l) + 8]); break; case 'U': /* RS1, constrained to equal RD */ - sprintf (buf+strlen (buf), "%s", riscv_gpr_names[rd]); + sprintf(buf + strlen(buf), "%s", riscv_gpr_names[rd]); break; case 'c': /* RS1, constrained to equal sp */ - sprintf (buf+strlen (buf), "%s", riscv_gpr_names[X_SP]); + sprintf(buf + strlen(buf), "%s", riscv_gpr_names[X_SP]); break; case 'V': /* RS2 */ - sprintf (buf+strlen (buf), "%s", - riscv_gpr_names[EXTRACT_OPERAND (CRS2, l)]); + sprintf(buf + strlen(buf), "%s", + riscv_gpr_names[EXTRACT_OPERAND(CRS2, l)]); break; case 'i': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_SIMM3 (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_SIMM3(l)); break; case 'j': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_IMM(l)); break; case 'k': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_LW_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_LW_IMM(l)); break; case 'l': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_LD_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_LD_IMM(l)); break; case 'm': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_LWSP_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_LWSP_IMM(l)); break; case 'n': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_LDSP_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_LDSP_IMM(l)); break; case 'K': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_ADDI4SPN_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_ADDI4SPN_IMM(l)); break; case 'L': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_ADDI16SP_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_ADDI16SP_IMM(l)); break; case 'M': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_SWSP_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_SWSP_IMM(l)); break; case 'N': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_SDSP_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_SDSP_IMM(l)); break; case 'p': - target = EXTRACT_RVC_B_IMM (l) + pc; - sprintf (buf+strlen (buf), "0x%"PFMT64x, (ut64) target); + target = EXTRACT_RVC_B_IMM(l) + pc; + sprintf(buf + strlen(buf), "0x%" PFMT64x, (ut64)target); break; case 'a': - target = EXTRACT_RVC_J_IMM (l) + pc; - sprintf (buf+strlen (buf), "0x%"PFMT64x, (ut64)target); + target = EXTRACT_RVC_J_IMM(l) + pc; + sprintf(buf + strlen(buf), "0x%" PFMT64x, (ut64)target); break; case 'u': - sprintf (buf+strlen (buf), "0x%x", - (int) (EXTRACT_RVC_IMM (l) & (RISCV_BIGIMM_REACH-1))); + sprintf(buf + strlen(buf), "0x%x", + (int)(EXTRACT_RVC_IMM(l) & (RISCV_BIGIMM_REACH - 1))); break; case '>': - sprintf (buf+strlen (buf), "0x%x", (int) EXTRACT_RVC_IMM (l) & 0x3f); + sprintf(buf + strlen(buf), "0x%x", (int)EXTRACT_RVC_IMM(l) & 0x3f); break; case '<': - sprintf (buf+strlen (buf), "0x%x", (int) EXTRACT_RVC_IMM (l) & 0x1f); + sprintf(buf + strlen(buf), "0x%x", (int)EXTRACT_RVC_IMM(l) & 0x1f); break; case 'T': /* floating-point RS2 */ - sprintf (buf+strlen (buf), "%s", - riscv_fpr_names[EXTRACT_OPERAND (CRS2, l)]); + sprintf(buf + strlen(buf), "%s", + riscv_fpr_names[EXTRACT_OPERAND(CRS2, l)]); break; case 'D': /* floating-point RS2 x8-x15 */ - sprintf (buf+strlen (buf), "%s", - riscv_fpr_names[EXTRACT_OPERAND (CRS2S, l) + 8]); + sprintf(buf + strlen(buf), "%s", + riscv_fpr_names[EXTRACT_OPERAND(CRS2S, l) + 8]); break; } break; case ',': - sprintf (buf+strlen (buf), "%c ", *d); + sprintf(buf + strlen(buf), "%c ", *d); break; case '(': case ')': case '[': case ']': - sprintf (buf+strlen (buf), "%c", *d); + sprintf(buf + strlen(buf), "%c", *d); break; case '0': /* Only print constant 0 if it is the last argument */ if (!d[1]) { - sprintf (buf+strlen (buf), "0"); + sprintf(buf + strlen(buf), "0"); } break; case 'b': case 's': - sprintf (buf+strlen (buf), "%s", riscv_gpr_names[rs1]); + sprintf(buf + strlen(buf), "%s", riscv_gpr_names[rs1]); break; case 't': - sprintf (buf+strlen (buf), "%s", - riscv_gpr_names[EXTRACT_OPERAND (RS2, l)]); + sprintf(buf + strlen(buf), "%s", + riscv_gpr_names[EXTRACT_OPERAND(RS2, l)]); break; case 'u': - sprintf (buf+strlen (buf), "0x%x", - (unsigned) EXTRACT_UTYPE_IMM (l) >> RISCV_IMM_BITS); + sprintf(buf + strlen(buf), "0x%x", + (unsigned)EXTRACT_UTYPE_IMM(l) >> RISCV_IMM_BITS); break; case 'm': - arg_p (buf, EXTRACT_OPERAND (RM, l), - riscv_rm, ARRAY_SIZE (riscv_rm)); + arg_p(buf, EXTRACT_OPERAND(RM, l), + riscv_rm, ARRAY_SIZE(riscv_rm)); break; case 'P': - arg_p (buf, EXTRACT_OPERAND (PRED, l), - riscv_pred_succ, ARRAY_SIZE (riscv_pred_succ)); + arg_p(buf, EXTRACT_OPERAND(PRED, l), + riscv_pred_succ, ARRAY_SIZE(riscv_pred_succ)); break; case 'Q': - arg_p (buf, EXTRACT_OPERAND (SUCC, l), - riscv_pred_succ, ARRAY_SIZE (riscv_pred_succ)); + arg_p(buf, EXTRACT_OPERAND(SUCC, l), + riscv_pred_succ, ARRAY_SIZE(riscv_pred_succ)); break; case 'o': case 'j': - sprintf (buf+strlen (buf), "%d", (int) EXTRACT_ITYPE_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_ITYPE_IMM(l)); break; case 'q': - sprintf (buf+strlen (buf), "%d", (int) EXTRACT_STYPE_IMM (l)); + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_STYPE_IMM(l)); break; case 'a': - target = EXTRACT_UJTYPE_IMM (l) + pc; - sprintf (buf+strlen (buf), "0x%"PFMT64x, (ut64)target); + target = EXTRACT_UJTYPE_IMM(l) + pc; + sprintf(buf + strlen(buf), "0x%" PFMT64x, (ut64)target); break; case 'p': - target = EXTRACT_SBTYPE_IMM (l) + pc; - sprintf (buf+strlen (buf), "0x%"PFMT64x, (ut64)target); + target = EXTRACT_SBTYPE_IMM(l) + pc; + sprintf(buf + strlen(buf), "0x%" PFMT64x, (ut64)target); break; case 'd': - sprintf (buf+strlen (buf), "%s", riscv_gpr_names[rd]); + sprintf(buf + strlen(buf), "%s", riscv_gpr_names[rd]); break; case 'z': - sprintf (buf+strlen (buf), "%s", riscv_gpr_names[0]); + sprintf(buf + strlen(buf), "%s", riscv_gpr_names[0]); break; case '>': - sprintf (buf+strlen (buf), "0x%x", (int) EXTRACT_OPERAND (SHAMT, l)); + sprintf(buf + strlen(buf), "0x%x", (int)EXTRACT_OPERAND(SHAMT, l)); break; case '<': - sprintf (buf+strlen (buf), "0x%x", (int) EXTRACT_OPERAND (SHAMTW, l)); + sprintf(buf + strlen(buf), "0x%x", (int)EXTRACT_OPERAND(SHAMTW, l)); break; case 'S': case 'U': - sprintf (buf+strlen (buf), "%s", riscv_fpr_names[rs1]); + sprintf(buf + strlen(buf), "%s", riscv_fpr_names[rs1]); break; case 'T': - sprintf (buf+strlen (buf), "%s", riscv_fpr_names[EXTRACT_OPERAND (RS2, l)]); + sprintf(buf + strlen(buf), "%s", riscv_fpr_names[EXTRACT_OPERAND(RS2, l)]); break; case 'D': - sprintf (buf+strlen (buf), "%s", riscv_fpr_names[rd]); + sprintf(buf + strlen(buf), "%s", riscv_fpr_names[rd]); break; case 'R': - sprintf (buf+strlen (buf), "%s", riscv_fpr_names[EXTRACT_OPERAND (RS3, l)]); + sprintf(buf + strlen(buf), "%s", riscv_fpr_names[EXTRACT_OPERAND(RS3, l)]); break; - case 'E': - { - const char* csr_name = NULL; - unsigned int csr = EXTRACT_OPERAND (CSR, l); - switch (csr) - { -#define DECLARE_CSR(name, num) case num: csr_name = #name; break; + case 'E': { + const char *csr_name = NULL; + unsigned int csr = EXTRACT_OPERAND(CSR, l); + switch (csr) { +#define DECLARE_CSR(name, num) \ + case num: csr_name = #name; break; #include "riscv-opc.h" #undef DECLARE_CSR - } - if (csr_name) { - sprintf (buf+strlen (buf), "%s", csr_name); - } else { - sprintf (buf+strlen (buf), "0x%x", csr); - } - break; } + if (csr_name) { + sprintf(buf + strlen(buf), "%s", csr_name); + } else { + sprintf(buf + strlen(buf), "0x%x", csr); + } + break; + } case 'Z': - sprintf (buf+strlen (buf), "%d", rs1); + sprintf(buf + strlen(buf), "%d", rs1); break; default: /* xgettext:c-format */ - sprintf (buf+strlen (buf), "# internal error, undefined modifier (%c)", - *d); + sprintf(buf + strlen(buf), "# internal error, undefined modifier (%c)", + *d); return; } } } -static struct riscv_opcode *get_opcode (insn_t word) { +static struct riscv_opcode *get_opcode(insn_t word) { struct riscv_opcode *op; - static const struct riscv_opcode *riscv_hash[OP_MASK_OP + 1] = {0}; + static const struct riscv_opcode *riscv_hash[OP_MASK_OP + 1] = { 0 }; -#define OP_HASH_IDX(i) ((i) & (riscv_insn_length (i) == 2 ? 3 : OP_MASK_OP)) +#define OP_HASH_IDX(i) ((i) & (riscv_insn_length(i) == 2 ? 3 : OP_MASK_OP)) if (!init) { - for (op=riscv_opcodes; op < &riscv_opcodes[NUMOPCODES]; op++) { - if (!riscv_hash[OP_HASH_IDX (op->match)]) { - riscv_hash[OP_HASH_IDX (op->match)] = op; + for (op = riscv_opcodes; op < &riscv_opcodes[NUMOPCODES]; op++) { + if (!riscv_hash[OP_HASH_IDX(op->match)]) { + riscv_hash[OP_HASH_IDX(op->match)] = op; } - } + } init = 1; } - return (struct riscv_opcode *)riscv_hash[OP_HASH_IDX (word)]; + return (struct riscv_opcode *)riscv_hash[OP_HASH_IDX(word)]; } static int riscv_disassemble(RzAsm *a, RzAsmOp *rop, insn_t word, int xlen, int len) { const bool no_alias = false; - const struct riscv_opcode *op = get_opcode (word); + const struct riscv_opcode *op = get_opcode(word); if (!op) { return -1; } for (; op < &riscv_opcodes[NUMOPCODES]; op++) { - if ( !(op->match_func)(op, word) ) { + if (!(op->match_func)(op, word)) { continue; } if (no_alias && (op->pinfo & INSN_ALIAS)) { continue; } - if (isdigit ((ut8)op->subset[0]) && atoi (op->subset) != xlen ) { + if (isdigit((ut8)op->subset[0]) && atoi(op->subset) != xlen) { continue; } if (op->name && op->args) { - rz_asm_op_set_asm (rop, op->name); - get_insn_args (rz_asm_op_get_asm (rop), op->args, word, a->pc); + rz_asm_op_set_asm(rop, op->name); + get_insn_args(rz_asm_op_get_asm(rop), op->args, word, a->pc); return 0; } - rz_asm_op_set_asm (rop, sdb_fmt ("invalid word(%"PFMT64x")", (ut64)word)); + rz_asm_op_set_asm(rop, sdb_fmt("invalid word(%" PFMT64x ")", (ut64)word)); return -1; } return 0; } static int riscv_dis(RzAsm *a, RzAsmOp *rop, const ut8 *buf, ut64 len) { - insn_t insn = {0}; + insn_t insn = { 0 }; if (len < 2) { return -1; } @@ -329,6 +328,6 @@ static int riscv_dis(RzAsm *a, RzAsmOp *rop, const ut8 *buf, ut64 len) { if (len < insn_len) { return -1; } - riscv_disassemble (a, rop, insn, a->bits, len); + riscv_disassemble(a, rop, insn, a->bits, len); return insn_len; } diff --git a/librz/arch/arch/sh/sh_il.c b/librz/arch/arch/sh/sh_il.c index 12b9307acb1..4580be81f89 100644 --- a/librz/arch/arch/sh/sh_il.c +++ b/librz/arch/arch/sh/sh_il.c @@ -3,7 +3,7 @@ #include "sh_il.h" #include -#include "../../../asm/arch/sh/regs.h" +#include "regs.h" /** * \file sh_il.c diff --git a/librz/arch/arch/sh/sh_il.h b/librz/arch/arch/sh/sh_il.h index 27b7b29a2e8..35f9b7234d3 100644 --- a/librz/arch/arch/sh/sh_il.h +++ b/librz/arch/arch/sh/sh_il.h @@ -5,7 +5,7 @@ #define SH_RZIL_H #include -#include "../../../asm/arch/sh/disassembler.h" +#include "disassembler.h" /** * \brief To store the context of the IL lifter ; Used to pass around information outside effects diff --git a/librz/arch/arch/tricore/tricore_il.c b/librz/arch/arch/tricore/tricore_il.c index 9f94815186c..553491b5f31 100644 --- a/librz/arch/arch/tricore/tricore_il.c +++ b/librz/arch/arch/tricore/tricore_il.c @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-only #include -#include "../../asm/arch/tricore/tricore.inc" +#include "tricore.inc" #include "tricore_il.h" diff --git a/librz/arch/arch/wasm/wasm.h b/librz/arch/arch/wasm/wasm.h index f081510eaef..866f5195edf 100644 --- a/librz/arch/arch/wasm/wasm.h +++ b/librz/arch/arch/wasm/wasm.h @@ -499,9 +499,7 @@ typedef struct { size_t min, max; } WasmOpDef; -#ifndef WASM_NO_ASM RZ_IPI int wasm_asm(const char *str, unsigned char *buf, int buf_len); -#endif RZ_IPI int wasm_dis(WasmOp *op, const unsigned char *buf, int buf_len); #endif diff --git a/librz/arch/asm.c b/librz/arch/asm.c index 23f12c8f792..6f94a251fe5 100644 --- a/librz/arch/asm.c +++ b/librz/arch/asm.c @@ -2,18 +2,18 @@ // SPDX-FileCopyrightText: 2009-2021 nibble // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_util/rz_print.h" -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include #include #include -#include -#include +#include +#include +#include +#include +#include #define USE_R2 1 #include #include @@ -111,7 +111,7 @@ static char *directives[] = { ".else", ".set", ".get", NULL }; -static RzAsmPlugin *asm_static_plugins[] = { RZ_ASM_STATIC_PLUGINS }; +static RzArchPlugin *asm_static_plugins[] = { RZ_ARCH_STATIC_PLUGINS }; static void parseHeap(RzParse *p, RzStrBuf *s) { char *op_buf_asm = rz_strbuf_get(s); @@ -295,7 +295,7 @@ RZ_API RzAsm *rz_asm_new(void) { return NULL; } for (i = 0; i < RZ_ARRAY_SIZE(asm_static_plugins); i++) { - rz_asm_plugin_add(a, asm_static_plugins[i]); + rz_asm_plugin_add(a, asm_static_plugins[i]->p_asm); } return a; } diff --git a/librz/arch/class.c b/librz/arch/class.c index 124fa8c4b23..cea87c5a217 100644 --- a/librz/arch/class.c +++ b/librz/arch/class.c @@ -5,8 +5,7 @@ #include #include #include -#include "../include/rz_analysis.h" -#include "../include/rz_util/rz_graph.h" +#include static void rz_analysis_class_base_delete_class(RzAnalysis *analysis, const char *class_name); static void rz_analysis_class_method_delete_class(RzAnalysis *analysis, const char *class_name); diff --git a/librz/arch/d/meson.build b/librz/arch/d/meson.build index dcff03dd7aa..3f86c9dcb6a 100644 --- a/librz/arch/d/meson.build +++ b/librz/arch/d/meson.build @@ -1,4 +1,4 @@ -sdb_files = [ +sdb_opcodes_files = [ '6502', '8051', 'arc', @@ -30,7 +30,86 @@ sdb_files = [ 'z80', ] -foreach file : sdb_files +sdb_types_files = [ + 'cc-arm-16', + 'cc-arm-32', + 'cc-arm-64', + 'cc-avr-8', + 'cc-hexagon-32', + 'cc-m68k-32', + 'cc-mips-32', + 'cc-mips-64', + 'cc-ppc-32', + 'cc-ppc-64', + 'cc-riscv-64', + 'cc-sparc-32', + 'cc-spc700-16', + 'cc-sysz-64', + 'cc-tricore-32', + 'cc-x86-16', + 'cc-x86-32', + 'cc-x86-64', + 'cc-xtensa-32', + 'spec', + 'types-16', + 'types-32', + 'types-64', + 'types-arm-ios-16', + 'types-arm-ios-32', + 'types-arm-ios-64', + 'types-android', + 'types-atomic', + 'types-libc', + 'types-linux', + 'types-macos', + 'types-windows', + 'types-x86-macos-64', + 'types-x86-windows-32', + 'types-x86-windows-64', + 'functions-android', + 'functions-libc', + 'functions-linux', + 'functions-macos', + 'functions-windows' +] + +win_types_extra = [ + 'bcrypt', + 'cfgmgr32', + 'combaseapi', + 'commctrl', + 'consoleapi2', + 'dbghelp', + 'evntrace', + 'fileapi', + 'libloaderapi', + 'memoryapi', + 'ncrypt', + 'objbase', + 'oleauto', + 'processthreadsapi', + 'psapi', + 'securitybaseapi', + 'shellapi', + 'shlwapi', + 'synchapi', + 'sysinfoapi', + 'threadpoolapiset', + 'userenv', + 'winbase', + 'wincred', + 'wincrypt', + 'winhttp', + 'winldap', + 'winnls', + 'winreg', + 'winsock2', + 'winsvc', + 'winuser', + 'ws2spi', +] + +foreach file : sdb_opcodes_files outfile = '@0@.sdb'.format(file) custom_target(outfile, input: '@0@.sdb.txt'.format(file), @@ -42,3 +121,34 @@ foreach file : sdb_files install_dir: join_paths(rizin_sdb, 'opcodes') ) endforeach + +fs = import('fs') +types_build_dir = meson.current_build_dir() +types_files = [] + +foreach file : sdb_types_files + outfile = '@0@.sdb'.format(file) + infiles = ['@0@.sdb.txt'.format(file)] + if file == 'types-windows' + foreach f : win_types_extra + win_file = 'types-windows_@0@.sdb.txt'.format(f) + if fs.exists(win_file) + infiles += win_file + endif + endforeach + endif + if file == 'functions-windows' + foreach f : win_types_extra + infiles += 'functions-windows_@0@.sdb.txt'.format(f) + endforeach + endif + types_files += [custom_target(outfile, + input: infiles, + output: outfile, + command: sdb_gen_cmd, + depends: sdb_exe, + build_by_default: true, + install: true, + install_dir: join_paths(rizin_sdb, 'types') + )] +endforeach diff --git a/librz/arch/d/meson2.build b/librz/arch/d/meson2.build deleted file mode 100644 index e498c129812..00000000000 --- a/librz/arch/d/meson2.build +++ /dev/null @@ -1,109 +0,0 @@ -sdb_files = [ - 'cc-arm-16', - 'cc-arm-32', - 'cc-arm-64', - 'cc-avr-8', - 'cc-hexagon-32', - 'cc-m68k-32', - 'cc-mips-32', - 'cc-mips-64', - 'cc-ppc-32', - 'cc-ppc-64', - 'cc-riscv-64', - 'cc-sparc-32', - 'cc-spc700-16', - 'cc-sysz-64', - 'cc-tricore-32', - 'cc-x86-16', - 'cc-x86-32', - 'cc-x86-64', - 'cc-xtensa-32', - 'spec', - 'types-16', - 'types-32', - 'types-64', - 'types-arm-ios-16', - 'types-arm-ios-32', - 'types-arm-ios-64', - 'types-android', - 'types-atomic', - 'types-libc', - 'types-linux', - 'types-macos', - 'types-windows', - 'types-x86-macos-64', - 'types-x86-windows-32', - 'types-x86-windows-64', - 'functions-android', - 'functions-libc', - 'functions-linux', - 'functions-macos', - 'functions-windows' -] - -win_types_extra = [ - 'bcrypt', - 'cfgmgr32', - 'combaseapi', - 'commctrl', - 'consoleapi2', - 'dbghelp', - 'evntrace', - 'fileapi', - 'libloaderapi', - 'memoryapi', - 'ncrypt', - 'objbase', - 'oleauto', - 'processthreadsapi', - 'psapi', - 'securitybaseapi', - 'shellapi', - 'shlwapi', - 'synchapi', - 'sysinfoapi', - 'threadpoolapiset', - 'userenv', - 'winbase', - 'wincred', - 'wincrypt', - 'winhttp', - 'winldap', - 'winnls', - 'winreg', - 'winsock2', - 'winsvc', - 'winuser', - 'ws2spi', -] - -fs = import('fs') -types_build_dir = meson.current_build_dir() -types_files = [] - -foreach file : sdb_files - outfile = '@0@.sdb'.format(file) - infiles = ['@0@.sdb.txt'.format(file)] - if file == 'types-windows' - foreach f : win_types_extra - win_file = 'types-windows_@0@.sdb.txt'.format(f) - if fs.exists(win_file) - infiles += win_file - endif - endforeach - endif - if file == 'functions-windows' - foreach f : win_types_extra - infiles += 'functions-windows_@0@.sdb.txt'.format(f) - endforeach - endif - types_files += [custom_target(outfile, - input: infiles, - output: outfile, - command: sdb_gen_cmd, - depends: sdb_exe, - build_by_default: true, - install: true, - install_dir: join_paths(rizin_sdb, 'types') - )] -endforeach diff --git a/librz/arch/meson.build b/librz/arch/meson.build index bc3f5336da3..cb848671640 100644 --- a/librz/arch/meson.build +++ b/librz/arch/meson.build @@ -1,4 +1,4 @@ -asm_plugins_list = [ +arch_plugins_list = [ '6502', '8051', 'amd29k', @@ -56,12 +56,12 @@ asm_plugins_list = [ ] if capstone_dep.version() == 'next' or capstone_dep.version().split('.')[0].to_int() > 4 - asm_plugins_list += 'riscv_cs' - asm_plugins_list += 'tricore' + arch_plugins_list += 'riscv_cs' + arch_plugins_list += 'tricore_cs' endif if get_option('use_gpl') - asm_plugins_list += [ + arch_plugins_list += [ 'arc', 'cris_gnu', 'hppa_gnu', @@ -76,114 +76,117 @@ if get_option('use_gpl') ] endif -asm_plugins = { - 'conf_name': 'plugins_asm', - 'base_cname': 'rz_asm_plugin_', - 'list': asm_plugins_list, +arch_plugins = { + 'conf_name': 'plugins_arch', + 'base_cname': 'rz_arch_plugin_', + 'list': arch_plugins_list, } -rz_asm_sources = [ - 'asm.c', - 'aop.c', +rz_arch_sources = [ 'acode.c', + 'analysis.c', + 'aop.c', + 'asm.c', 'binutils_as.c', - 'p/asm_6502.c', - 'p/asm_8051.c', - 'p/asm_amd29k.c', - 'p/asm_arm_as.c', - 'p/asm_arm_cs.c', - 'p/asm_avr.c', - 'p/asm_bf.c', - 'p/asm_chip8.c', - 'p/asm_cil.c', - 'p/asm_cr16.c', - 'p/asm_dalvik.c', - 'p/asm_dcpu16.c', - 'p/asm_ebc.c', - 'p/asm_gb.c', - 'p/asm_h8300.c', - 'p/asm_hexagon.c', - 'p/asm_i4004.c', - 'p/asm_i8080.c', - 'p/asm_java.c', - 'p/asm_lh5801.c', - 'p/asm_lm32.c', - 'p/asm_luac.c', - 'p/asm_m68k_cs.c', - 'p/asm_m680x_cs.c', - 'p/asm_malbolge.c', - 'p/asm_mcs96.c', - 'p/asm_mips_cs.c', - 'p/asm_msp430.c', - 'p/asm_null.c', - 'p/asm_or1k.c', - 'p/asm_pic.c', - 'p/asm_mcore.c', - 'p/asm_ppc_as.c', - 'p/asm_ppc_cs.c', - 'p/asm_propeller.c', - 'p/asm_pyc.c', - 'p/asm_rl78.c', - 'p/asm_rsp.c', - 'p/asm_sh.c', - 'p/asm_snes.c', - 'p/asm_sparc_cs.c', - 'p/asm_spc700.c', - 'p/asm_sysz.c', - 'p/asm_tms320.c', - 'p/asm_tms320c64x.c', - 'p/asm_v810.c', - 'p/asm_v850.c', - 'p/asm_wasm.c', - 'p/asm_x86_as.c', - 'p/asm_x86_cs.c', - 'p/asm_x86_nasm.c', - 'p/asm_x86_nz.c', - #'p/asm_x86_vm.c', - 'p/asm_xap.c', - 'p/asm_xcore_cs.c', + 'block.c', + 'cc.c', + 'class.c', + 'cond.c', + 'cycles.c', + 'data.c', + 'dwarf_process.c', + 'esil/esil.c', + 'esil/esil_interrupt.c', + 'esil/esil_sources.c', + 'esil/esil_stats.c', + 'esil/esil_trace.c', + 'fcn.c', + 'function.c', + 'hint.c', + 'il/analysis_il.c', + 'il/analysis_il_trace.c', + 'il_trace.c', + 'jmptbl.c', + 'labels.c', + 'meta.c', + 'op.c', + 'pdb_process.c', + 'platform_profile.c', + 'platform_target_index.c', + 'reflines.c', + 'rtti.c', + 'rtti_itanium.c', + 'rtti_msvc.c', + 'serialize_analysis.c', + 'similarity.c', + 'switch.c', + 'types.c', + 'value.c', + 'var.c', + 'var_global.c', + 'vtable.c', + 'xrefs.c', #'arch/6502/6502dis.c', - 'arch/amd29k/amd29k.c', #'arch/8051/8051_disas.c', + #'arch/dcpu16/asm.c', + #'arch/dcpu16/dis.c', + #'arch/dcpu16/main.c', + #'arch/gb/gbasm.c', + #'arch/gb/gbdis.c', + #'arch/gb/meta_gb_cmt.c', + #'arch/i4004/i4004dis.c', + #'arch/i8080/i8080dis.c', + #'arch/snes/snesdis.c', + #'arch/spc700/spc700dis.c', + #'arch/tms320/c55x_plus/hashvector.c', + #'arch/xap/dis.c', 'arch/8051/8051_ass.c', + 'arch/8051/8051_il.c', + 'arch/8051/8051_parse.c', + 'arch/amd29k/amd29k.c', + 'arch/arm/arm_esil32.c', + 'arch/arm/arm_esil64.c', + 'arch/arm/arm_il32.c', + 'arch/arm/arm_il64.c', + 'arch/arm/arm_it.c', 'arch/arm/armass.c', 'arch/arm/armass64.c', - 'arch/arm/arm_it.c', - 'arch/avr/disassembler.c', 'arch/avr/assembler.c', + 'arch/avr/avr_esil.c', + 'arch/avr/avr_il.c', + 'arch/avr/disassembler.c', 'arch/cil/cil_dis.c', 'arch/cr16/cr16_disas.c', - #'arch/dcpu16/asm.c', - #'arch/dcpu16/dis.c', - #'arch/dcpu16/main.c', 'arch/ebc/ebc_disas.c', - #'arch/gb/gbasm.c', - #'arch/gb/gbdis.c', 'arch/h8300/h8300_disas.c', 'arch/hexagon/hexagon.c', 'arch/hexagon/hexagon_arch.c', 'arch/hexagon/hexagon_disas.c', - #'arch/i4004/i4004dis.c', - #'arch/i8080/i8080dis.c', - 'arch/java/jvm.c', 'arch/java/assembler.c', + 'arch/java/jvm.c', 'arch/luac/lua_arch.c', - 'arch/luac/v54/opcode_54.c', - 'arch/luac/v54/disassembly_54.c', - 'arch/luac/v54/assembly_54.c', - 'arch/luac/v53/opcode_53.c', - 'arch/luac/v53/disassembly_53.c', + 'arch/luac/v53/analysis_53.c', 'arch/luac/v53/assembly_53.c', + 'arch/luac/v53/disassembly_53.c', + 'arch/luac/v53/opcode_53.c', + 'arch/luac/v54/analysis_54.c', + 'arch/luac/v54/assembly_54.c', + 'arch/luac/v54/disassembly_54.c', + 'arch/luac/v54/opcode_54.c', + 'arch/mcore/mcore.c', 'arch/mips/mipsasm.c', 'arch/msp430/msp430_disas.c', 'arch/or1k/or1k_disas.c', 'arch/pic/pic_baseline.c', 'arch/pic/pic_midrange.c', 'arch/pic/pic_pic18.c', - 'arch/mcore/mcore.c', - 'arch/ppc/libvle/vle.c', 'arch/ppc/libps/libps.c', + 'arch/ppc/libvle/vle.c', + 'arch/ppc/ppc_il.c', + 'arch/ppc/ppc_il_flag_ops.c', + 'arch/ppc/ppc_il_ops.c', 'arch/propeller/propeller_disas.c', + 'arch/pyc/opcode.c', 'arch/pyc/opcode_10.c', 'arch/pyc/opcode_11.c', 'arch/pyc/opcode_12.c', @@ -202,6 +205,7 @@ rz_asm_sources = [ 'arch/pyc/opcode_2x.c', 'arch/pyc/opcode_30.c', 'arch/pyc/opcode_31.c', + 'arch/pyc/opcode_310.c', 'arch/pyc/opcode_32.c', 'arch/pyc/opcode_33.c', 'arch/pyc/opcode_34.c', @@ -210,44 +214,203 @@ rz_asm_sources = [ 'arch/pyc/opcode_37.c', 'arch/pyc/opcode_38.c', 'arch/pyc/opcode_39.c', - 'arch/pyc/opcode_310.c', 'arch/pyc/opcode_3x.c', 'arch/pyc/opcode_analysis.c', 'arch/pyc/opcode_arg_fmt.c', - 'arch/pyc/opcode.c', 'arch/pyc/pyc_dis.c', + 'arch/rl78/rl78.c', 'arch/rl78/rl78_instr.c', 'arch/rl78/rl78_maps.c', 'arch/rl78/rl78_operand.c', - 'arch/rl78/rl78.c', 'arch/rsp/rsp_idec.c', - 'arch/sh/disassembler.c', 'arch/sh/assembler.c', + 'arch/sh/disassembler.c', 'arch/sh/lookup.c', - #'arch/snes/snesdis.c', - #'arch/spc700/spc700dis.c', + 'arch/sh/sh_il.c', 'arch/tms320/c55x_plus/c55plus.c', 'arch/tms320/c55x_plus/c55plus_decode.c', 'arch/tms320/c55x_plus/decode_funcs.c', 'arch/tms320/c55x_plus/hashtable.c', - #'arch/tms320/c55x_plus/hashvector.c', 'arch/tms320/c55x_plus/ins.c', 'arch/tms320/c55x_plus/utils.c', 'arch/tms320/tms320_dasm.c', 'arch/v810/v810_disas.c', + 'arch/v810/v810_il.c', 'arch/v850/v850_disas.c', 'arch/wasm/wasm.c', - #'arch/xap/dis.c', + 'arch/x86/common.c', + 'arch/x86/x86_il.c', 'arch/z80/z80.c', + + #'p/analysis_6502.c', + #'p/analysis_8051.c', + #'p/analysis_amd29k.c', + #'p/analysis_arm_cs.c', + #'p/analysis_avr.c', + #'p/analysis_bf.c', + #'p/analysis_chip8.c', + #'p/analysis_cil.c', + #'p/analysis_cr16.c', + #'p/analysis_dalvik.c', + #'p/analysis_ebc.c', + #'p/analysis_gb.c', + #'p/analysis_h8300.c', + #'p/analysis_hexagon.c', + #'p/analysis_i4004.c', + #'p/analysis_i8080.c', + #'p/analysis_java.c', + #'p/analysis_luac.c', + #'p/analysis_m680x_cs.c', + #'p/analysis_m68k_cs.c', + #'p/analysis_malbolge.c', + #'p/analysis_mcore.c', + #'p/analysis_mips_cs.c', + #'p/analysis_msp430.c', + #'p/analysis_null.c', + #'p/analysis_or1k.c', + #'p/analysis_pic.c', + #'p/analysis_ppc_cs.c', + #'p/analysis_propeller.c', + #'p/analysis_pyc.c', + #'p/analysis_rl78.c', + #'p/analysis_rsp.c', + #'p/analysis_snes.c', + #'p/analysis_sparc_cs.c', + #'p/analysis_spc700.c', + #'p/analysis_sysz.c', + #'p/analysis_tms320.c', + #'p/analysis_tms320_c55x_plus.c', + ##'p/analysis_tms320c64x.c', + #'p/analysis_v810.c', + #'p/analysis_v850.c', + #'p/analysis_wasm.c', + #'p/analysis_x86_cs.c', + #'p/analysis_xap.c', + #'p/analysis_xcore_cs.c', + #'p/asm_6502.c', + #'p/asm_8051.c', + #'p/asm_amd29k.c', + #'p/asm_arm_as.c', + #'p/asm_arm_cs.c', + #'p/asm_avr.c', + #'p/asm_bf.c', + #'p/asm_chip8.c', + #'p/asm_cil.c', + #'p/asm_cr16.c', + #'p/asm_dalvik.c', + #'p/asm_dcpu16.c', + #'p/asm_ebc.c', + #'p/asm_gb.c', + #'p/asm_h8300.c', + #'p/asm_hexagon.c', + #'p/asm_i4004.c', + #'p/asm_i8080.c', + #'p/asm_java.c', + #'p/asm_lh5801.c', + #'p/asm_lm32.c', + #'p/asm_luac.c', + #'p/asm_m680x_cs.c', + #'p/asm_m68k_cs.c', + #'p/asm_malbolge.c', + #'p/asm_mcore.c', + #'p/asm_mcs96.c', + #'p/asm_mips_cs.c', + #'p/asm_msp430.c', + #'p/asm_null.c', + #'p/asm_or1k.c', + #'p/asm_pic.c', + #'p/asm_ppc_as.c', + #'p/asm_ppc_cs.c', + #'p/asm_propeller.c', + #'p/asm_pyc.c', + #'p/asm_rl78.c', + #'p/asm_rsp.c', + #'p/asm_sh.c', + #'p/asm_snes.c', + #'p/asm_sparc_cs.c', + #'p/asm_spc700.c', + #'p/asm_sysz.c', + #'p/asm_tms320.c', + #'p/asm_tms320c64x.c', + #'p/asm_v810.c', + #'p/asm_v850.c', + #'p/asm_wasm.c', + #'p/asm_x86_as.c', + #'p/asm_x86_cs.c', + #'p/asm_x86_nasm.c', + #'p/asm_x86_nz.c', + ##'p/asm_x86_vm.c', + #'p/asm_xap.c', + #'p/asm_xcore_cs.c', + + 'p/arch_6502.c', + 'p/arch_8051.c', + 'p/arch_amd29k.c', + 'p/arch_arm_as.c', + 'p/arch_arm_cs.c', + 'p/arch_avr.c', + 'p/arch_bf.c', + 'p/arch_chip8.c', + 'p/arch_cil.c', + 'p/arch_cr16.c', + 'p/arch_dalvik.c', + 'p/arch_dcpu16.c', + 'p/arch_ebc.c', + 'p/arch_gb.c', + 'p/arch_h8300.c', + 'p/arch_hexagon.c', + 'p/arch_i4004.c', + 'p/arch_i8080.c', + 'p/arch_java.c', + 'p/arch_lh5801.c', + 'p/arch_lm32.c', + 'p/arch_luac.c', + 'p/arch_m680x_cs.c', + 'p/arch_m68k_cs.c', + 'p/arch_malbolge.c', + 'p/arch_mcore.c', + 'p/arch_mcs96.c', + 'p/arch_mips_cs.c', + 'p/arch_msp430.c', + 'p/arch_null.c', + 'p/arch_or1k.c', + 'p/arch_pic.c', + 'p/arch_ppc_as.c', + 'p/arch_ppc_cs.c', + 'p/arch_propeller.c', + 'p/arch_pyc.c', + 'p/arch_rl78.c', + 'p/arch_rsp.c', + 'p/arch_sh.c', + 'p/arch_snes.c', + 'p/arch_sparc_cs.c', + 'p/arch_spc700.c', + 'p/arch_sysz.c', + 'p/arch_tms320.c', + 'p/arch_tms320c64x.c', + 'p/arch_v810.c', + 'p/arch_v850.c', + 'p/arch_wasm.c', + 'p/arch_x86_as.c', + 'p/arch_x86_cs.c', + 'p/arch_x86_nasm.c', + 'p/arch_x86_nz.c', + 'p/arch_xap.c', + 'p/arch_xcore_cs.c', ] if capstone_dep.version() == 'next' or capstone_dep.version().split('.')[0].to_int() > 4 - rz_asm_sources += 'p/asm_riscv_cs.c' - rz_asm_sources += 'p/asm_tricore_cs.c' + #rz_arch_sources += 'p/asm_riscv_cs.c' + #rz_arch_sources += 'p/analysis_riscv_cs.c' + rz_arch_sources += 'p/arch_riscv_cs.c' + #rz_arch_sources += 'p/asm_tricore_cs.c' + #rz_arch_sources += 'p/analysis_tricore_cs.c' + rz_arch_sources += 'p/arch_tricore_cs.c' + rz_arch_sources += 'arch/tricore/tricore_il.c' endif if get_option('use_gpl') - rz_asm_sources += [ + rz_arch_sources += [ 'arch/arc/gnu/arc-dis.c', 'arch/arc/gnu/arc-ext.c', 'arch/arc/gnu/arc-opc.c', @@ -273,21 +436,43 @@ if get_option('use_gpl') 'arch/xtensa/gnu/xtensa-modules.c', #'arch/z80/expressions.c', #'arch/z80/z80asm.c', - 'p/asm_arc.c', - 'p/asm_cris_gnu.c', - 'p/asm_hppa_gnu.c', - 'p/asm_lanai_gnu.c', - 'p/asm_mips_gnu.c', - 'p/asm_nios2.c', - 'p/asm_riscv.c', - 'p/asm_sparc_gnu.c', - 'p/asm_vax.c', - 'p/asm_xtensa.c', - 'p/asm_z80.c', + #'p/analysis_arc.c', + #'p/analysis_cris.c', + #'p/analysis_mips_gnu.c', + #'p/analysis_nios2.c', + #'p/analysis_riscv.c', + #'p/analysis_sh.c', + #'p/analysis_sparc_gnu.c', + #'p/analysis_vax.c', + #'p/analysis_xtensa.c', + #'p/analysis_z80.c', + #'p/asm_arc.c', + #'p/asm_cris_gnu.c', + #'p/asm_hppa_gnu.c', + #'p/asm_lanai_gnu.c', + #'p/asm_mips_gnu.c', + #'p/asm_nios2.c', + #'p/asm_riscv.c', + #'p/asm_sparc_gnu.c', + #'p/asm_vax.c', + #'p/asm_xtensa.c', + #'p/asm_z80.c', + + 'p/arch_arc_gnu.c', + 'p/arch_cris_gnu.c', + 'p/arch_hppa_gnu.c', + 'p/arch_lanai_gnu.c', + 'p/arch_mips_gnu.c', + 'p/arch_nios2_gnu.c', + 'p/arch_riscv_gnu.c', + 'p/arch_sparc_gnu.c', + 'p/arch_vax_gnu.c', + 'p/arch_xtensa_gnu.c', + 'p/arch_z80_gnu.c', ] endif -rz_asm_inc = [ +rz_arch_inc = [ platform_inc, include_directories( 'arch/include', @@ -305,18 +490,27 @@ rz_asm_inc = [ 'arch/v810', 'arch/or1k', 'arch/tricore', + 'arch/gb', ) ] -rz_asm = library('rz_asm', rz_asm_sources, - include_directories: rz_asm_inc, +rz_arch = library('rz_arch', rz_arch_sources, + include_directories: rz_arch_inc, dependencies: [ rz_util_dep, - rz_config_dep, + rz_crypto_dep, + rz_reg_dep, rz_syscall_dep, + rz_search_dep, + rz_config_dep, + rz_cons_dep, rz_flag_dep, + rz_hash_dep, + rz_diff_dep, rz_parse_dep, rz_bin_dep, + rz_type_dep, + rz_il_dep, capstone_dep, dependency('rzspp'), ], @@ -329,14 +523,29 @@ rz_asm = library('rz_asm', rz_asm_sources, name_prefix: lib_name_prefix, ) -rz_asm_dep = declare_dependency(link_with: rz_asm, - include_directories: rz_asm_inc) -meson.override_dependency('rz_asm', rz_asm_dep) +rz_arch_dep = declare_dependency(link_with: rz_arch, + include_directories: rz_arch_inc) +meson.override_dependency('rz_arch', rz_arch_dep) -modules += { 'rz_asm': { - 'target': rz_asm, - 'dependencies': ['rz_util', 'rz_config', 'rz_syscall', 'rz_flag', 'rz_parse', 'rz_bin'], - 'plugins': [asm_plugins] +modules += { 'rz_arch': { + 'target': rz_arch, + 'dependencies': [ + 'rz_bin', + 'rz_config', + 'rz_cons', + 'rz_crypto', + 'rz_diff', + 'rz_flag', + 'rz_hash', + 'rz_il', + 'rz_parse', + 'rz_reg', + 'rz_search', + 'rz_syscall', + 'rz_type', + 'rz_util', + ], + 'plugins': [arch_plugins] }} subdir('d') diff --git a/librz/arch/meson2.build b/librz/arch/meson2.build deleted file mode 100644 index 441b7efaa22..00000000000 --- a/librz/arch/meson2.build +++ /dev/null @@ -1,327 +0,0 @@ -analysis_plugins_list = [ - '6502', - '8051', - 'amd29k', - 'arm_cs', - 'avr', - 'bf', - 'chip8', - 'cil', - 'cr16', - 'dalvik', - 'ebc', - 'gb', - 'h8300', - 'hexagon', - 'i4004', - 'i8080', - 'java', - 'luac', - 'm68k_cs', - 'm680x_cs', - 'malbolge', - 'mcore', - 'mips_cs', - 'msp430', - 'null', - 'or1k', - 'pic', - 'ppc_cs', - 'propeller', - 'pyc', - 'rl78', - 'rsp', - 'snes', - 'sparc_cs', - 'spc700', - 'sysz', - 'tms320', - #'tms320c64x', - 'v810', - 'v850', - 'wasm', - 'x86_cs', - 'xap', - 'xcore_cs', -] -if capstone_dep.version() == 'next' or capstone_dep.version().split('.')[0].to_int() > 4 - analysis_plugins_list += 'riscv_cs' - analysis_plugins_list += 'tricore_cs' -endif - -if get_option('use_gpl') - analysis_plugins_list += [ - 'arc', - 'cris', - 'mips_gnu', - 'nios2', - 'riscv', - 'sh', - 'sparc_gnu', - 'vax', - 'xtensa', - 'z80', - ] -endif - -analysis_plugins = { - 'conf_name': 'plugins_analysis', - 'base_cname': 'rz_analysis_plugin_', - 'list': analysis_plugins_list, -} - -rz_analysis_sources = [ - 'analysis.c', - 'block.c', - 'cc.c', - 'class.c', - 'cond.c', - 'cycles.c', - 'data.c', - 'dwarf_process.c', - 'esil/esil.c', - 'esil/esil_interrupt.c', - 'esil/esil_sources.c', - 'esil/esil_stats.c', - 'esil/esil_trace.c', - 'fcn.c', - 'function.c', - 'hint.c', - 'il/analysis_il.c', - 'il/analysis_il_trace.c', - 'il_trace.c', - 'jmptbl.c', - 'labels.c', - 'meta.c', - 'op.c', - 'platform_profile.c', - 'platform_target_index.c', - 'reflines.c', - 'rtti.c', - 'rtti_itanium.c', - 'rtti_msvc.c', - 'serialize_analysis.c', - 'similarity.c', - 'switch.c', - 'pdb_process.c', - 'types.c', - 'value.c', - 'var.c', - 'var_global.c', - 'vtable.c', - 'xrefs.c', - 'p/analysis_6502.c', - 'p/analysis_8051.c', - 'p/analysis_amd29k.c', - 'p/analysis_arm_cs.c', - 'p/analysis_avr.c', - 'p/analysis_bf.c', - 'p/analysis_chip8.c', - 'p/analysis_cil.c', - 'p/analysis_cr16.c', - 'p/analysis_dalvik.c', - 'p/analysis_ebc.c', - 'p/analysis_gb.c', - 'p/analysis_h8300.c', - 'p/analysis_hexagon.c', - 'p/analysis_i4004.c', - 'p/analysis_i8080.c', - 'p/analysis_java.c', - 'p/analysis_luac.c', - 'p/analysis_m68k_cs.c', - 'p/analysis_m680x_cs.c', - 'p/analysis_malbolge.c', - 'p/analysis_mcore.c', - 'p/analysis_mips_cs.c', - 'p/analysis_msp430.c', - 'p/analysis_null.c', - 'p/analysis_or1k.c', - 'p/analysis_pic.c', - 'p/analysis_ppc_cs.c', - 'p/analysis_propeller.c', - 'p/analysis_pyc.c', - 'p/analysis_rl78.c', - 'p/analysis_rsp.c', - 'p/analysis_snes.c', - 'p/analysis_sparc_cs.c', - 'p/analysis_spc700.c', - 'p/analysis_sysz.c', - 'p/analysis_tms320.c', - 'p/analysis_tms320_c55x_plus.c', - #'p/analysis_tms320c64x.c', - 'p/analysis_v810.c', - 'p/analysis_v850.c', - 'p/analysis_wasm.c', - 'p/analysis_x86_cs.c', - 'p/analysis_xap.c', - 'p/analysis_xcore_cs.c', - #'arch/gb/meta_gb_cmt.c', - 'arch/arm/arm_esil32.c', - 'arch/arm/arm_esil64.c', - 'arch/avr/avr_esil.c', - 'arch/avr/avr_il.c', - 'arch/arm/arm_il32.c', - 'arch/arm/arm_il64.c', - 'arch/ppc/ppc_il.c', - 'arch/ppc/ppc_il_ops.c', - 'arch/ppc/ppc_il_flag_ops.c', - 'arch/sh/sh_il.c', - 'arch/x86/common.c', - 'arch/x86/x86_il.c', - 'arch/8051/8051_il.c', - 'arch/8051/8051_parse.c', - 'arch/v810/v810_il.c', - '../asm/arch/amd29k/amd29k.c', - '../asm/arch/avr/disassembler.c', - '../asm/arch/cil/cil_dis.c', - '../asm/arch/cr16/cr16_disas.c', - '../asm/arch/ebc/ebc_disas.c', - '../asm/arch/h8300/h8300_disas.c', - '../asm/arch/java/jvm.c', - '../asm/arch/mcore/mcore.c', - '../asm/arch/msp430/msp430_disas.c', - '../asm/arch/or1k/or1k_disas.c', - '../asm/arch/pic/pic_midrange.c', - '../asm/arch/ppc/libvle/vle.c', - '../asm/arch/propeller/propeller_disas.c', - '../asm/arch/rsp/rsp_idec.c', - '../asm/arch/sh/disassembler.c', - '../asm/arch/sh/lookup.c', - '../asm/arch/tms320/tms320_dasm.c', - '../asm/arch/tms320/c55x_plus/ins.c', - '../asm/arch/tms320/c55x_plus/c55plus.c', - '../asm/arch/tms320/c55x_plus/c55plus_decode.c', - '../asm/arch/tms320/c55x_plus/decode_funcs.c', - '../asm/arch/tms320/c55x_plus/hashtable.c', - '../asm/arch/tms320/c55x_plus/utils.c', - '../asm/arch/v810/v810_disas.c', - '../asm/arch/v850/v850_disas.c', - '../asm/arch/wasm/wasm.c', - '../asm/arch/pyc/opcode_10.c', - '../asm/arch/pyc/opcode_11.c', - '../asm/arch/pyc/opcode_12.c', - '../asm/arch/pyc/opcode_13.c', - '../asm/arch/pyc/opcode_14.c', - '../asm/arch/pyc/opcode_15.c', - '../asm/arch/pyc/opcode_16.c', - '../asm/arch/pyc/opcode_20.c', - '../asm/arch/pyc/opcode_21.c', - '../asm/arch/pyc/opcode_22.c', - '../asm/arch/pyc/opcode_23.c', - '../asm/arch/pyc/opcode_24.c', - '../asm/arch/pyc/opcode_25.c', - '../asm/arch/pyc/opcode_26.c', - '../asm/arch/pyc/opcode_27.c', - '../asm/arch/pyc/opcode_2x.c', - '../asm/arch/pyc/opcode_30.c', - '../asm/arch/pyc/opcode_31.c', - '../asm/arch/pyc/opcode_32.c', - '../asm/arch/pyc/opcode_33.c', - '../asm/arch/pyc/opcode_34.c', - '../asm/arch/pyc/opcode_35.c', - '../asm/arch/pyc/opcode_36.c', - '../asm/arch/pyc/opcode_37.c', - '../asm/arch/pyc/opcode_38.c', - '../asm/arch/pyc/opcode_39.c', - '../asm/arch/pyc/opcode_310.c', - '../asm/arch/pyc/opcode_3x.c', - '../asm/arch/pyc/opcode_analysis.c', - '../asm/arch/pyc/opcode_arg_fmt.c', - '../asm/arch/pyc/opcode.c', - '../asm/arch/pyc/pyc_dis.c', - '../asm/arch/luac/lua_arch.c', - '../asm/arch/luac/v54/analysis_54.c', - '../asm/arch/luac/v54/opcode_54.c', - '../asm/arch/luac/v53/analysis_53.c', - '../asm/arch/luac/v53/opcode_53.c', - '../asm/arch/rl78/rl78_instr.c', - '../asm/arch/rl78/rl78_maps.c', - '../asm/arch/rl78/rl78_operand.c', - '../asm/arch/rl78/rl78.c' -] - -if capstone_dep.version() == 'next' or capstone_dep.version().split('.')[0].to_int() > 4 - rz_analysis_sources += 'p/analysis_riscv_cs.c' - rz_analysis_sources += 'p/analysis_tricore_cs.c' - rz_analysis_sources +='arch/tricore/tricore_il.c' -endif - -if get_option('use_gpl') - rz_analysis_sources += [ - 'p/analysis_arc.c', - 'p/analysis_cris.c', - 'p/analysis_mips_gnu.c', - 'p/analysis_nios2.c', - 'p/analysis_riscv.c', - 'p/analysis_sh.c', - 'p/analysis_sparc_gnu.c', - 'p/analysis_vax.c', - 'p/analysis_xtensa.c', - 'p/analysis_z80.c', - '../asm/arch/xtensa/gnu/xtensa-dis.c', - '../asm/arch/xtensa/gnu/elf32-xtensa.c', - '../asm/arch/xtensa/gnu/xtensa-isa.c', - '../asm/arch/xtensa/gnu/xtensa-modules.c', - ] -endif -rz_analysis_inc = [ - platform_inc, - include_directories( - 'arch/gb', - ) -] - -rz_analysis = library('rz_analysis', rz_analysis_sources, - include_directories: rz_analysis_inc, - dependencies: [ - rz_util_dep, - rz_crypto_dep, - rz_reg_dep, - rz_syscall_dep, - rz_search_dep, - rz_cons_dep, - rz_flag_dep, - rz_hash_dep, - rz_diff_dep, - rz_parse_dep, - rz_asm_dep, - rz_bin_dep, - rz_type_dep, - rz_il_dep, - capstone_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_analysis_dep = declare_dependency(link_with: rz_analysis, - include_directories: rz_analysis_inc) -meson.override_dependency('rz_analysis', rz_analysis_dep) - -modules += { 'rz_analysis': { - 'target': rz_analysis, - 'dependencies': [ - 'rz_util', - 'rz_crypto', - 'rz_reg', - 'rz_syscall', - 'rz_search', - 'rz_cons', - 'rz_flag', - 'rz_hash', - 'rz_diff', - 'rz_parse', - 'rz_asm', - 'rz_bin', - 'rz_type', - 'rz_il', - ], - 'plugins': [analysis_plugins] -}} - -subdir('d') diff --git a/librz/arch/p/analysis_6502.c b/librz/arch/p/analysis_6502.c index 1221f2a99e7..134faa629ed 100644 --- a/librz/arch/p/analysis_6502.c +++ b/librz/arch/p/analysis_6502.c @@ -16,8 +16,8 @@ #include #include #include -#include "../../asm/arch/snes/snes_op_table.h" -#include "../../asm/arch/6502/6502_il.inc" +#include "../arch/snes/snes_op_table.h" +#include "../arch/6502/6502_il.inc" enum { _6502_FLAGS_C = (1 << 0), @@ -1218,11 +1218,3 @@ RzAnalysisPlugin rz_analysis_plugin_6502 = { .esil_fini = esil_6502_fini, .il_config = il_config }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_6502, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p/analysis_8051.c b/librz/arch/p/analysis_8051.c index d2311a9d571..e8f94c8b580 100644 --- a/librz/arch/p/analysis_8051.c +++ b/librz/arch/p/analysis_8051.c @@ -10,7 +10,7 @@ #include #include <8051_ops.h> -#include "../asm/arch/8051/8051_disas.c" +#include "../arch/8051/8051_disas.c" #include "../arch/8051/8051_il.h" static const i8051_cpu_model cpu_models[] = { diff --git a/librz/arch/p/analysis_amd29k.c b/librz/arch/p/analysis_amd29k.c index b7942467d21..0d7682b832a 100644 --- a/librz/arch/p/analysis_amd29k.c +++ b/librz/arch/p/analysis_amd29k.c @@ -3,7 +3,7 @@ #include #include -#include "../../asm/arch/amd29k/amd29k.h" +#include "../arch/amd29k/amd29k.h" static char *get_reg_profile(RzAnalysis *analysis) { const char *p = diff --git a/librz/arch/p/analysis_arc.c b/librz/arch/p/analysis_arc_gnu.c similarity index 100% rename from librz/arch/p/analysis_arc.c rename to librz/arch/p/analysis_arc_gnu.c diff --git a/librz/arch/p/analysis_arm_cs.c b/librz/arch/p/analysis_arm_cs.c index 587e075fa45..fdf03832f92 100644 --- a/librz/arch/p/analysis_arm_cs.c +++ b/librz/arch/p/analysis_arm_cs.c @@ -12,7 +12,7 @@ #include "../arch/arm/arm_cs.h" #include "../arch/arm/arm_accessors32.h" #include "../arch/arm/arm_accessors64.h" -#include "../../asm/arch/arm/arm_it.h" +#include "../arch/arm/arm_it.h" #if CS_NEXT_VERSION < 6 inline static const char *ARMCondCodeToString(arm_cc cc) { diff --git a/librz/arch/p/analysis_avr.c b/librz/arch/p/analysis_avr.c index 4cd6cc277be..f933fa463f0 100644 --- a/librz/arch/p/analysis_avr.c +++ b/librz/arch/p/analysis_avr.c @@ -4,7 +4,7 @@ #include -#include "../../asm/arch/avr/disassembler.h" +#include "../arch/avr/disassembler.h" #include "../arch/avr/avr_esil.h" #include "../arch/avr/avr_il.h" diff --git a/librz/arch/p/analysis_cil.c b/librz/arch/p/analysis_cil.c index 99888d1f999..afad4148c8f 100644 --- a/librz/arch/p/analysis_cil.c +++ b/librz/arch/p/analysis_cil.c @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-only #include -#include "../../asm/arch/cil/cil_dis.h" +#include "../arch/cil/cil_dis.h" /** * Resolves InlineMethod token to paddr diff --git a/librz/arch/p/analysis_cris.c b/librz/arch/p/analysis_cris_gnu.c similarity index 98% rename from librz/arch/p/analysis_cris.c rename to librz/arch/p/analysis_cris_gnu.c index 191da21b6bf..c95f548bc8f 100644 --- a/librz/arch/p/analysis_cris.c +++ b/librz/arch/p/analysis_cris_gnu.c @@ -275,7 +275,7 @@ static char *get_reg_profile(RzAnalysis *analysis) { return strdup(p); } -RzAnalysisPlugin rz_analysis_plugin_cris = { +RzAnalysisPlugin rz_analysis_plugin_cris_gnu = { .name = "cris", .desc = "Axis Communications 32-bit embedded processor", .license = "LGPL3", @@ -289,7 +289,7 @@ RzAnalysisPlugin rz_analysis_plugin_cris = { #ifndef RZ_PLUGIN_INCORE RZ_API RzLibStruct rizin_plugin = { .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_cris, + .data = &rz_analysis_plugin_cris_gnu, .version = RZ_VERSION }; #endif diff --git a/librz/arch/p/analysis_dalvik.c b/librz/arch/p/analysis_dalvik.c index f6e736dd00f..e7b5555ac23 100644 --- a/librz/arch/p/analysis_dalvik.c +++ b/librz/arch/p/analysis_dalvik.c @@ -7,7 +7,7 @@ #include #include -#include "../../asm/arch/dalvik/opcode.h" +#include "../arch/dalvik/opcode.h" #include "../../bin/format/dex/dex.h" static const char *getCond(ut8 cond) { diff --git a/librz/arch/p/analysis_gb.c b/librz/arch/p/analysis_gb.c index df8801161ff..7bc26aa0e3b 100644 --- a/librz/arch/p/analysis_gb.c +++ b/librz/arch/p/analysis_gb.c @@ -11,8 +11,7 @@ #include #include #include -#define GB_DIS_LEN_ONLY -#include "../../asm/arch/gb/gbdis.c" +#include "../arch/gb/gbdis.c" #include "../arch/gb/gb_makros.h" #include "../arch/gb/meta_gb_cmt.c" #include "../arch/gb/gb_il.inc" diff --git a/librz/arch/p/analysis_i4004.c b/librz/arch/p/analysis_i4004.c index 7bc1ea778f2..39829c76f29 100644 --- a/librz/arch/p/analysis_i4004.c +++ b/librz/arch/p/analysis_i4004.c @@ -7,6 +7,7 @@ #include #include #include +#include "../arch/i4004/i4004dis.c" #define AVR_SOFTCAST(x, y) ((x) + ((y)*0x100)) @@ -44,58 +45,6 @@ static char *get_reg_profile(RzAnalysis *analysis) { return strdup(p); } -/* That 3 is a hack */ -static const int i4004_ins_len[16] = { - 1, 2, 3, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1 -}; - -static const char *i4004_e[16] = { - "wrm", - "wmp", - "wrr", - "wpm", - "wr0", - "wr1", - "wr2", - "wr3", - "sbm", - "rdm", - "rdr", - "adm", - "rd0", - "rd1", - "rd2", - "rd3" -}; - -static const char *i4004_f[16] = { - "clb", - "clc", - "iac", - "cmc", - "cma", - "ral", - "rar", - "tcc", - "dac", // decrement - "tcs", - "stc", - "daa", - "kbp", - "dcl", - "invalid", - "invalid" -}; - -static int i4004_get_ins_len(ut8 hex) { - ut8 high = (hex & 0xf0) >> 4; - int ret = i4004_ins_len[high]; - if (ret == 3) { - ret = (hex & 1) ? 1 : 2; - } - return ret; -} - static int i4004_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { char basm[128]; const size_t basz = sizeof(basm) - 1; diff --git a/librz/arch/p/analysis_i8080.c b/librz/arch/p/analysis_i8080.c index 1e88cf0d8f2..bf751112e21 100644 --- a/librz/arch/p/analysis_i8080.c +++ b/librz/arch/p/analysis_i8080.c @@ -10,7 +10,7 @@ #include #include // hack -#include "../../asm/arch/i8080/i8080dis.c" +#include "../arch/i8080/i8080dis.c" static int i8080_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask) { char out[32]; diff --git a/librz/arch/p/analysis_java.c b/librz/arch/p/analysis_java.c index 5446819a1fe..4be75c4ce2a 100644 --- a/librz/arch/p/analysis_java.c +++ b/librz/arch/p/analysis_java.c @@ -5,7 +5,7 @@ #include #include -#include "../../asm/arch/java/jvm.h" +#include "../arch/java/jvm.h" typedef struct java_analysis_context_t { LookupSwitch ls; diff --git a/librz/arch/p/analysis_luac.c b/librz/arch/p/analysis_luac.c index 3afc139ea36..af32d37af59 100644 --- a/librz/arch/p/analysis_luac.c +++ b/librz/arch/p/analysis_luac.c @@ -4,7 +4,7 @@ #include #include -#include "librz/asm/arch/luac/lua_arch.h" +#include "../arch/luac/lua_arch.h" int rz_lua_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask) { if (!analysis->cpu) { diff --git a/librz/arch/p/analysis_mcore.c b/librz/arch/p/analysis_mcore.c index a3c234dfed9..5afeb47fc7c 100644 --- a/librz/arch/p/analysis_mcore.c +++ b/librz/arch/p/analysis_mcore.c @@ -4,7 +4,7 @@ #include #include #include -#include "../../asm/arch/mcore/mcore.h" +#include "../arch/mcore/mcore.h" static int mcore_analysis(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { mcore_handle handle = { 0 }; diff --git a/librz/arch/p/analysis_nios2.c b/librz/arch/p/analysis_nios2_gnu.c similarity index 100% rename from librz/arch/p/analysis_nios2.c rename to librz/arch/p/analysis_nios2_gnu.c diff --git a/librz/arch/p/analysis_pic.c b/librz/arch/p/analysis_pic.c index 22fa2fa2425..70764ea75d3 100644 --- a/librz/arch/p/analysis_pic.c +++ b/librz/arch/p/analysis_pic.c @@ -7,7 +7,7 @@ #include #include -#include "../../asm/arch/pic/pic_midrange.h" +#include "../arch/pic/pic_midrange.h" typedef struct _pic_midrange_op_args_val { ut16 f; diff --git a/librz/arch/p/analysis_ppc_cs.c b/librz/arch/p/analysis_ppc_cs.c index 8e3a40fcb32..81470bad63e 100644 --- a/librz/arch/p/analysis_ppc_cs.c +++ b/librz/arch/p/analysis_ppc_cs.c @@ -5,7 +5,7 @@ #include #include #include -#include "../../asm/arch/ppc/libvle/vle.h" +#include "../arch/ppc/libvle/vle.h" #include "../arch/ppc/ppc_analysis.h" #include "../arch/ppc/ppc_il.h" #include "rz_util/rz_strbuf.h" diff --git a/librz/arch/p/analysis_pyc.c b/librz/arch/p/analysis_pyc.c index bb9230a9306..95969cb862f 100644 --- a/librz/arch/p/analysis_pyc.c +++ b/librz/arch/p/analysis_pyc.c @@ -6,7 +6,7 @@ #include #include -#include "../../asm/arch/pyc/pyc_dis.h" +#include "../arch/pyc/pyc_dis.h" #define JMP_OFFSET(ops, v) ((ops)->jump_use_instruction_offset ? (v)*2 : (v)) diff --git a/librz/arch/p/analysis_riscv.c b/librz/arch/p/analysis_riscv_gnu.c similarity index 98% rename from librz/arch/p/analysis_riscv.c rename to librz/arch/p/analysis_riscv_gnu.c index fb7eb7ef1b1..c28ce7594e4 100644 --- a/librz/arch/p/analysis_riscv.c +++ b/librz/arch/p/analysis_riscv_gnu.c @@ -6,17 +6,14 @@ #include #include #include -#include "../../asm/arch/riscv/riscv-opc.c" -#include "../../asm/arch/riscv/riscv.h" +#include "../arch/riscv/riscv-opc.c" +#include "../arch/riscv/riscv.h" +#include "../arch/riscv/riscv.c" #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) #define RISCVARGSMAX (8) #define RISCVARGSIZE (64) #define RISCVARGN(x) ((x)->arg[(x)->num++]) -static bool init = false; -static const char *const *riscv_gpr_names = riscv_gpr_names_abi; -static const char *const *riscv_fpr_names = riscv_fpr_names_abi; - typedef struct riscv_args { int num; char arg[RISCVARGSMAX][RISCVARGSIZE]; @@ -46,7 +43,7 @@ static void arg_p2(char *buf, unsigned long val, const char *const *array, size_ snprintf(buf, RISCVARGSIZE, "%s", s); } -static struct riscv_opcode *get_opcode(insn_t word) { +static struct riscv_opcode *get_opcode_analysis(insn_t word) { struct riscv_opcode *op; static const struct riscv_opcode *riscv_hash[OP_MASK_OP + 1] = { 0 }; @@ -65,7 +62,7 @@ static struct riscv_opcode *get_opcode(insn_t word) { } /* Print insn arguments for 32/64-bit code. */ -static void get_insn_args(riscv_args_t *args, const char *d, insn_t l, uint64_t pc) { +static void get_insn_args_analysis(riscv_args_t *args, const char *d, insn_t l, uint64_t pc) { int rs1 = (l >> OP_SH_RS1) & OP_MASK_RS1; int rd = (l >> OP_SH_RD) & OP_MASK_RD; uint64_t target; @@ -262,7 +259,7 @@ static void get_insn_args(riscv_args_t *args, const char *d, insn_t l, uint64_t case num: \ csr_name = #name; \ break; -#include "../../asm/arch/riscv/riscv-opc.h" +#include "../arch/riscv/riscv-opc.h" #undef DECLARE_CSR } if (csr_name) { @@ -309,7 +306,7 @@ static int riscv_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 return -1; } - struct riscv_opcode *o = get_opcode(word); + struct riscv_opcode *o = get_opcode_analysis(word); for (; o && o < &riscv_opcodes[NUMOPCODES]; o++) { if (!(o->match_func)(o, word)) { continue; @@ -343,7 +340,7 @@ static int riscv_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 op->size = 2; } #define ARG(x) (arg_n(&args, (x))) - get_insn_args(&args, o->args, word, addr); + get_insn_args_analysis(&args, o->args, word, addr); if (!strcmp(name, "nop")) { esilprintf(op, ","); } diff --git a/librz/arch/p/analysis_rl78.c b/librz/arch/p/analysis_rl78.c index 760c15a177a..775e0b537df 100644 --- a/librz/arch/p/analysis_rl78.c +++ b/librz/arch/p/analysis_rl78.c @@ -6,8 +6,8 @@ #include #include #include -#include "../../asm/arch/rl78/rl78_instr.h" -#include "../../asm/arch/rl78/rl78.h" +#include "../arch/rl78/rl78_instr.h" +#include "../arch/rl78/rl78.h" static int rl78_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask); diff --git a/librz/arch/p/analysis_rsp.c b/librz/arch/p/analysis_rsp.c index f1ca847e3bb..094b353ab4d 100644 --- a/librz/arch/p/analysis_rsp.c +++ b/librz/arch/p/analysis_rsp.c @@ -9,7 +9,7 @@ #include #include #include -#include "../../asm/arch/rsp/rsp_idec.h" +#include "../arch/rsp/rsp_idec.h" static int rsp_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *b, int len, RzAnalysisOpMask mask) { int i; diff --git a/librz/arch/p/analysis_snes.c b/librz/arch/p/analysis_snes.c index 39c1ddcb4ef..7bc5921307f 100644 --- a/librz/arch/p/analysis_snes.c +++ b/librz/arch/p/analysis_snes.c @@ -6,8 +6,8 @@ #include #include #include -#include "../../asm/arch/snes/snes_op_table.h" -#include "../../asm/p/asm_snes.h" +#include "../arch/snes/snes_op_table.h" +#include "asm_snes.h" static int snes_anop(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask) { struct snes_asm_flags *snesflags = (struct snes_asm_flags *)analysis->plugin_data; diff --git a/librz/arch/p/analysis_spc700.c b/librz/arch/p/analysis_spc700.c index d4d9f52d462..fefa902e134 100644 --- a/librz/arch/p/analysis_spc700.c +++ b/librz/arch/p/analysis_spc700.c @@ -6,7 +6,7 @@ #include #include #include -#include "../../asm/arch/spc700/spc700dis.c" +#include "../arch/spc700/spc700dis.c" static int op(RzAnalysis *analysis, RzAnalysisOp *rz_op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { // TODO: fill this with the actual info diff --git a/librz/arch/p/analysis_tms320.c b/librz/arch/p/analysis_tms320.c index d77776ea6c4..c68cb146e9a 100644 --- a/librz/arch/p/analysis_tms320.c +++ b/librz/arch/p/analysis_tms320.c @@ -2,19 +2,89 @@ // SPDX-License-Identifier: LGPL-3.0-only #include -#include "analysis_tms320c64x.c" -#include "../../asm/arch/tms320/tms320_dasm.h" +#include "../arch/tms320/c55x_plus/c55plus.h" +#include "../arch/tms320/c55x_plus/ins.h" +#include "../arch/tms320/tms320_dasm.h" typedef int (*TMS_ANALYSIS_OP_FN)(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len); -int tms320_c54x_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len); -int tms320_c55x_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len); -int tms320_c55x_plus_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len); +static int tms320_c54x_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len); +static int tms320_c55x_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len); +static int tms320_c55x_plus_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len); static bool match(const char *str, const char *token) { return !strncasecmp(str, token, strlen(token)); } +static int tms320_c55x_plus_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len) { + ut16 *ins = (ut16 *)buf; + ut32 ins_len; + + if (!buf || len <= 0) { + return 0; + } + + ins_len = get_ins_len(buf[0]); + if (ins_len == 0) { + return 0; + } + + op->addr = addr; + op->size = ins_len; + + if (ins_len == 1) { + if (*ins == 0x20) { + op->type = RZ_ANALYSIS_OP_TYPE_NOP; + } else if (*ins == 0x21) { + op->type = RZ_ANALYSIS_OP_TYPE_RET; + } + } else if (ins_len >= 4 && buf[0] == 0xD8) { + // BCC conditional absolute jump + op->type = RZ_ANALYSIS_OP_TYPE_CJMP; + op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3]; + } else if (ins_len >= 2 && buf[0] == 0x6A) { + // BCC conditional relative jump + op->type = RZ_ANALYSIS_OP_TYPE_CJMP; + op->jump = addr + ((st8)buf[1]) + ins_len; + } else if (ins_len >= 3 && buf[0] == 0x9A) { + // BCC conditional relative jump + op->type = RZ_ANALYSIS_OP_TYPE_CJMP; + op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len; + } else if (ins_len >= 4 && buf[0] == 0x9C) { + // B unconditional absolute jump + op->type = RZ_ANALYSIS_OP_TYPE_JMP; + op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3]; + } else if (ins_len >= 3 && buf[0] == 0x68) { + // B unconditional relative jump + op->type = RZ_ANALYSIS_OP_TYPE_JMP; + op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len; + } else if (ins_len == 2 && buf[0] == 0x02) { + // CALL unconditional absolute call with acumulator register ACx + + op->type = RZ_ANALYSIS_OP_TYPE_UCALL; + op->fail = addr + ins_len; + } else if (ins_len >= 3 && buf[0] == 0x69) { + // CALL unconditional relative call + op->type = RZ_ANALYSIS_OP_TYPE_CALL; + op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len; + } else if (ins_len >= 3 && buf[0] == 0x9D) { + // CALL unconditional absolute call + op->type = RZ_ANALYSIS_OP_TYPE_CALL; + op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3]; + } else if (ins_len >= 3 && buf[0] == 0x9B) { + // CALLCC conditional relative call + op->type = RZ_ANALYSIS_OP_TYPE_CALL; + op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len; + } else if (ins_len >= 4 && buf[0] == 0xD9) { + // CALLCC conditional absolute call + op->type = RZ_ANALYSIS_OP_TYPE_CALL; + op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3]; + } else { + op->type = RZ_ANALYSIS_OP_TYPE_UNK; + } + return op->size; +} + int tms320_c54x_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len) { // TODO: add the implementation return 0; @@ -74,7 +144,7 @@ int tms320_c55x_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 return op->size; } -int tms320_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { +static int tms320_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { TMS_ANALYSIS_OP_FN aop = tms320_c55x_op; if (analysis->cpu && rz_str_casecmp(analysis->cpu, "c64x") == 0) { diff --git a/librz/arch/p/analysis_tms320_c55x_plus.c b/librz/arch/p/analysis_tms320_c55x_plus.c deleted file mode 100644 index 7926a7c470d..00000000000 --- a/librz/arch/p/analysis_tms320_c55x_plus.c +++ /dev/null @@ -1,79 +0,0 @@ -// SPDX-FileCopyrightText: 2014 montekki -// SPDX-License-Identifier: LGPL-3.0-only - -#include -#include -#include -#include -#include - -ut32 get_ins_len(ut8 opcode); - -int tms320_c55x_plus_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len) { - ut16 *ins = (ut16 *)buf; - ut32 ins_len; - - if (!buf || len <= 0) { - return 0; - } - - ins_len = get_ins_len(buf[0]); - if (ins_len == 0) { - return 0; - } - - op->addr = addr; - op->size = ins_len; - - if (ins_len == 1) { - if (*ins == 0x20) { - op->type = RZ_ANALYSIS_OP_TYPE_NOP; - } else if (*ins == 0x21) { - op->type = RZ_ANALYSIS_OP_TYPE_RET; - } - } else if (ins_len >= 4 && buf[0] == 0xD8) { - // BCC conditional absolute jump - op->type = RZ_ANALYSIS_OP_TYPE_CJMP; - op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3]; - } else if (ins_len >= 2 && buf[0] == 0x6A) { - // BCC conditional relative jump - op->type = RZ_ANALYSIS_OP_TYPE_CJMP; - op->jump = addr + ((st8)buf[1]) + ins_len; - } else if (ins_len >= 3 && buf[0] == 0x9A) { - // BCC conditional relative jump - op->type = RZ_ANALYSIS_OP_TYPE_CJMP; - op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len; - } else if (ins_len >= 4 && buf[0] == 0x9C) { - // B unconditional absolute jump - op->type = RZ_ANALYSIS_OP_TYPE_JMP; - op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3]; - } else if (ins_len >= 3 && buf[0] == 0x68) { - // B unconditional relative jump - op->type = RZ_ANALYSIS_OP_TYPE_JMP; - op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len; - } else if (ins_len == 2 && buf[0] == 0x02) { - // CALL unconditional absolute call with acumulator register ACx - - op->type = RZ_ANALYSIS_OP_TYPE_UCALL; - op->fail = addr + ins_len; - } else if (ins_len >= 3 && buf[0] == 0x69) { - // CALL unconditional relative call - op->type = RZ_ANALYSIS_OP_TYPE_CALL; - op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len; - } else if (ins_len >= 3 && buf[0] == 0x9D) { - // CALL unconditional absolute call - op->type = RZ_ANALYSIS_OP_TYPE_CALL; - op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3]; - } else if (ins_len >= 3 && buf[0] == 0x9B) { - // CALLCC conditional relative call - op->type = RZ_ANALYSIS_OP_TYPE_CALL; - op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len; - } else if (ins_len >= 4 && buf[0] == 0xD9) { - // CALLCC conditional absolute call - op->type = RZ_ANALYSIS_OP_TYPE_CALL; - op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3]; - } else { - op->type = RZ_ANALYSIS_OP_TYPE_UNK; - } - return op->size; -} diff --git a/librz/arch/p/analysis_tricore_cs.c b/librz/arch/p/analysis_tricore_cs.c index 4f374737d4b..3f7424df3db 100644 --- a/librz/arch/p/analysis_tricore_cs.c +++ b/librz/arch/p/analysis_tricore_cs.c @@ -7,7 +7,7 @@ #include #include -#include "../../asm/arch/tricore/tricore.inc" +#include "../arch/tricore/tricore.inc" RZ_IPI RzAnalysisLiftedILOp tricore_il_op(RzAsmTriCoreContext *ctx, RzAnalysis *a); RZ_IPI RzAnalysisILConfig *tricore_il_config(RZ_NONNULL RzAnalysis *analysis); diff --git a/librz/arch/p/analysis_vax.c b/librz/arch/p/analysis_vax_gnu.c similarity index 100% rename from librz/arch/p/analysis_vax.c rename to librz/arch/p/analysis_vax_gnu.c diff --git a/librz/arch/p/analysis_wasm.c b/librz/arch/p/analysis_wasm.c index baa2b169ed9..6a9cc3ef8ad 100644 --- a/librz/arch/p/analysis_wasm.c +++ b/librz/arch/p/analysis_wasm.c @@ -8,10 +8,9 @@ #include #include #undef RZ_IPI -#define RZ_IPI static -#define WASM_NO_ASM // to get rid of a warning +#define RZ_IPI static #include "../../bin/format/wasm/wasm.h" -#include "../../asm/arch/wasm/wasm.c" +#include "../arch/wasm/wasm.c" #define WASM_STACK_SIZE 256 diff --git a/librz/arch/p/analysis_x86_cs.c b/librz/arch/p/analysis_x86_cs.c index 8d050cc092c..6525096b87e 100644 --- a/librz/arch/p/analysis_x86_cs.c +++ b/librz/arch/p/analysis_x86_cs.c @@ -3231,7 +3231,7 @@ static int esil_x86_cs_init(RzAnalysisEsil *esil) { return true; } -static bool x86_init(void **user) { +static bool x86_analysis_init(void **user) { X86CSContext *ctx = RZ_NEW0(X86CSContext); if (!ctx) { return false; @@ -3240,7 +3240,7 @@ static bool x86_init(void **user) { return true; } -static bool x86_fini(void *user) { +static bool x86_analysis_fini(void *user) { rz_return_val_if_fail(user, false); X86CSContext *ctx = (X86CSContext *)user; cs_close(&ctx->handle); @@ -3760,8 +3760,8 @@ RzAnalysisPlugin rz_analysis_plugin_x86_cs = { .preludes = analysis_preludes, .archinfo = archinfo, .get_reg_profile = &get_reg_profile, - .init = x86_init, - .fini = x86_fini, + .init = x86_analysis_init, + .fini = x86_analysis_fini, .esil_init = esil_x86_cs_init, .esil_fini = esil_x86_cs_fini, .il_config = rz_x86_il_config, diff --git a/librz/arch/p/analysis_xap.c b/librz/arch/p/analysis_xap.c index e8be7c70058..ce545648f37 100644 --- a/librz/arch/p/analysis_xap.c +++ b/librz/arch/p/analysis_xap.c @@ -6,7 +6,7 @@ #include #include #include -#include "../asm/arch/xap/dis.c" +#include "../arch/xap/dis.c" static int label_off(struct directive *d) { int off = d->d_operand; diff --git a/librz/arch/p/analysis_xtensa.c b/librz/arch/p/analysis_xtensa_gnu.c similarity index 100% rename from librz/arch/p/analysis_xtensa.c rename to librz/arch/p/analysis_xtensa_gnu.c diff --git a/librz/arch/p/analysis_z80.c b/librz/arch/p/analysis_z80_gnu.c similarity index 99% rename from librz/arch/p/analysis_z80.c rename to librz/arch/p/analysis_z80_gnu.c index 446dfc4b367..4efba57b279 100644 --- a/librz/arch/p/analysis_z80.c +++ b/librz/arch/p/analysis_z80_gnu.c @@ -7,7 +7,7 @@ #include #include #include -#include "../../asm/arch/z80/z80_tab.h" +#include "../arch/z80/z80_tab.h" static void z80_op_size(const ut8 *data, int len, int *size, int *size_prefix) { int type = 0; diff --git a/librz/arch/p/arch_6502.c b/librz/arch/p/arch_6502.c new file mode 100644 index 00000000000..3a6070adfaa --- /dev/null +++ b/librz/arch/p/arch_6502.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_6502.c" +#include "asm_6502.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(6502); diff --git a/librz/arch/p/arch_8051.c b/librz/arch/p/arch_8051.c new file mode 100644 index 00000000000..f3027edf39e --- /dev/null +++ b/librz/arch/p/arch_8051.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_8051.c" +#include "asm_8051.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(8051); diff --git a/librz/arch/p/arch_amd29k.c b/librz/arch/p/arch_amd29k.c new file mode 100644 index 00000000000..47eb08919bc --- /dev/null +++ b/librz/arch/p/arch_amd29k.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_amd29k.c" +#include "asm_amd29k.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(amd29k); diff --git a/librz/arch/p/arch_arc_gnu.c b/librz/arch/p/arch_arc_gnu.c new file mode 100644 index 00000000000..9495a2696fa --- /dev/null +++ b/librz/arch/p/arch_arc_gnu.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_arc_gnu.c" +#include "asm_arc_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(arc); diff --git a/librz/arch/p/arch_arm_as.c b/librz/arch/p/arch_arm_as.c new file mode 100644 index 00000000000..004a3173d6e --- /dev/null +++ b/librz/arch/p/arch_arm_as.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_arm_as.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(arm_as); diff --git a/librz/arch/p/arch_arm_cs.c b/librz/arch/p/arch_arm_cs.c new file mode 100644 index 00000000000..ea9c7964e34 --- /dev/null +++ b/librz/arch/p/arch_arm_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_arm_cs.c" +#include "asm_arm_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(arm_cs); diff --git a/librz/arch/p/arch_avr.c b/librz/arch/p/arch_avr.c new file mode 100644 index 00000000000..a6159f152b3 --- /dev/null +++ b/librz/arch/p/arch_avr.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_avr.c" +#include "asm_avr.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(avr); diff --git a/librz/arch/p/arch_bf.c b/librz/arch/p/arch_bf.c new file mode 100644 index 00000000000..2d9457be5d6 --- /dev/null +++ b/librz/arch/p/arch_bf.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_bf.c" +#include "asm_bf.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(bf); diff --git a/librz/arch/p/arch_chip8.c b/librz/arch/p/arch_chip8.c new file mode 100644 index 00000000000..43bdfbdd1c0 --- /dev/null +++ b/librz/arch/p/arch_chip8.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_chip8.c" +#include "asm_chip8.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(chip8); diff --git a/librz/arch/p/arch_cil.c b/librz/arch/p/arch_cil.c new file mode 100644 index 00000000000..5fdc0f394d7 --- /dev/null +++ b/librz/arch/p/arch_cil.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_cil.c" +#include "asm_cil.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(cil); diff --git a/librz/arch/p/arch_cr16.c b/librz/arch/p/arch_cr16.c new file mode 100644 index 00000000000..6e62b96ac34 --- /dev/null +++ b/librz/arch/p/arch_cr16.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_cr16.c" +#include "asm_cr16.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(cr16); diff --git a/librz/arch/p/arch_cris_gnu.c b/librz/arch/p/arch_cris_gnu.c new file mode 100644 index 00000000000..786a8da74da --- /dev/null +++ b/librz/arch/p/arch_cris_gnu.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_cris_gnu.c" +#include "asm_cris_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(cris_gnu); diff --git a/librz/arch/p/arch_dalvik.c b/librz/arch/p/arch_dalvik.c new file mode 100644 index 00000000000..07061d330a8 --- /dev/null +++ b/librz/arch/p/arch_dalvik.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_dalvik.c" +#include "asm_dalvik.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(dalvik); diff --git a/librz/arch/p/arch_dcpu16.c b/librz/arch/p/arch_dcpu16.c new file mode 100644 index 00000000000..61525f6db3e --- /dev/null +++ b/librz/arch/p/arch_dcpu16.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_dcpu16.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(dcpu16); diff --git a/librz/arch/p/arch_ebc.c b/librz/arch/p/arch_ebc.c new file mode 100644 index 00000000000..78effdfb605 --- /dev/null +++ b/librz/arch/p/arch_ebc.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_ebc.c" +#include "asm_ebc.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(ebc); diff --git a/librz/arch/p/arch_gb.c b/librz/arch/p/arch_gb.c new file mode 100644 index 00000000000..68dcf13b000 --- /dev/null +++ b/librz/arch/p/arch_gb.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_gb.c" +#include "asm_gb.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(gb); diff --git a/librz/arch/p/arch_h8300.c b/librz/arch/p/arch_h8300.c new file mode 100644 index 00000000000..fa27ed79c1f --- /dev/null +++ b/librz/arch/p/arch_h8300.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_h8300.c" +#include "asm_h8300.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(h8300); diff --git a/librz/arch/p/arch_helper.h b/librz/arch/p/arch_helper.h new file mode 100644 index 00000000000..d142df892ed --- /dev/null +++ b/librz/arch/p/arch_helper.h @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef LIB_ARCH_HELPER_H +#define LIB_ARCH_HELPER_H + +#include + +#define DEPRECATED_OLD_ARCH_PLUGIN(name) \ + RzArchPlugin rz_arch_plugin_##name = { \ + .p_asm = &rz_asm_plugin_##name, \ + .p_analysis = &rz_analysis_plugin_##name, \ + } + +#define DEPRECATED_OLD_ARCH_ASM_ONLY_PLUGIN(name) \ + RzArchPlugin rz_arch_plugin_##name = { \ + .p_asm = &rz_asm_plugin_##name, \ + .p_analysis = NULL, \ + } + +#ifndef RZ_PLUGIN_INCORE +#define ARCH_PLUGIN_LIB_STRUCT(name) \ + RZ_API RzLibStruct rizin_plugin = { \ + .type = RZ_LIB_TYPE_ANALYSIS, \ + .data = &rz_arch_plugin_##name, \ + .version = RZ_VERSION \ + } +#else +#define ARCH_PLUGIN_LIB_STRUCT(name) +#endif + +#define RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(name) \ + DEPRECATED_OLD_ARCH_PLUGIN(name); \ + ARCH_PLUGIN_LIB_STRUCT(name) + +#define RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(name) \ + DEPRECATED_OLD_ARCH_ASM_ONLY_PLUGIN(name); \ + ARCH_PLUGIN_LIB_STRUCT(name) + +#endif /* LIB_ARCH_HELPER_H */ \ No newline at end of file diff --git a/librz/arch/p/arch_hexagon.c b/librz/arch/p/arch_hexagon.c new file mode 100644 index 00000000000..9fb23d11e41 --- /dev/null +++ b/librz/arch/p/arch_hexagon.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_hexagon.c" +#include "asm_hexagon.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(hexagon); diff --git a/librz/arch/p/arch_hppa_gnu.c b/librz/arch/p/arch_hppa_gnu.c new file mode 100644 index 00000000000..96613a34dad --- /dev/null +++ b/librz/arch/p/arch_hppa_gnu.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_hppa_gnu.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(hppa_gnu); diff --git a/librz/arch/p/arch_i4004.c b/librz/arch/p/arch_i4004.c new file mode 100644 index 00000000000..98b86a24ce9 --- /dev/null +++ b/librz/arch/p/arch_i4004.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_i4004.c" +#include "asm_i4004.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(i4004); diff --git a/librz/arch/p/arch_i8080.c b/librz/arch/p/arch_i8080.c new file mode 100644 index 00000000000..2efdd5f3e5d --- /dev/null +++ b/librz/arch/p/arch_i8080.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_i8080.c" +#include "asm_i8080.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(i8080); diff --git a/librz/arch/p/arch_java.c b/librz/arch/p/arch_java.c new file mode 100644 index 00000000000..5c3020c4fe8 --- /dev/null +++ b/librz/arch/p/arch_java.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_java.c" +#include "asm_java.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(java); diff --git a/librz/arch/p/arch_lanai_gnu.c b/librz/arch/p/arch_lanai_gnu.c new file mode 100644 index 00000000000..a22ed4c23a1 --- /dev/null +++ b/librz/arch/p/arch_lanai_gnu.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_lanai_gnu.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(lanai_gnu); diff --git a/librz/arch/p/arch_lh5801.c b/librz/arch/p/arch_lh5801.c new file mode 100644 index 00000000000..60073594c99 --- /dev/null +++ b/librz/arch/p/arch_lh5801.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_lh5801.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(lh5801); diff --git a/librz/arch/p/arch_lm32.c b/librz/arch/p/arch_lm32.c new file mode 100644 index 00000000000..f30cf255179 --- /dev/null +++ b/librz/arch/p/arch_lm32.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_lm32.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(lm32); diff --git a/librz/arch/p/arch_luac.c b/librz/arch/p/arch_luac.c new file mode 100644 index 00000000000..9e43faebc8d --- /dev/null +++ b/librz/arch/p/arch_luac.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_luac.c" +#include "asm_luac.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(luac); diff --git a/librz/arch/p/arch_m680x_cs.c b/librz/arch/p/arch_m680x_cs.c new file mode 100644 index 00000000000..7f61ab0c7ea --- /dev/null +++ b/librz/arch/p/arch_m680x_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_m680x_cs.c" +#include "asm_m680x_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(m680x_cs); diff --git a/librz/arch/p/arch_m68k_cs.c b/librz/arch/p/arch_m68k_cs.c new file mode 100644 index 00000000000..761666dd47f --- /dev/null +++ b/librz/arch/p/arch_m68k_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_m68k_cs.c" +#include "asm_m68k_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(m68k_cs); diff --git a/librz/arch/p/arch_malbolge.c b/librz/arch/p/arch_malbolge.c new file mode 100644 index 00000000000..e103d65194d --- /dev/null +++ b/librz/arch/p/arch_malbolge.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_malbolge.c" +#include "asm_malbolge.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(malbolge); diff --git a/librz/arch/p/arch_mcore.c b/librz/arch/p/arch_mcore.c new file mode 100644 index 00000000000..55e5cc1db89 --- /dev/null +++ b/librz/arch/p/arch_mcore.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_mcore.c" +#include "asm_mcore.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(mcore); diff --git a/librz/arch/p/arch_mcs96.c b/librz/arch/p/arch_mcs96.c new file mode 100644 index 00000000000..5c75d187590 --- /dev/null +++ b/librz/arch/p/arch_mcs96.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_mcs96.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(mcs96); diff --git a/librz/arch/p/arch_mips_cs.c b/librz/arch/p/arch_mips_cs.c new file mode 100644 index 00000000000..9722869e9df --- /dev/null +++ b/librz/arch/p/arch_mips_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_mips_cs.c" +#include "asm_mips_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(mips_cs); diff --git a/librz/arch/p/arch_mips_gnu.c b/librz/arch/p/arch_mips_gnu.c new file mode 100644 index 00000000000..96556547003 --- /dev/null +++ b/librz/arch/p/arch_mips_gnu.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_mips_gnu.c" +#include "asm_mips_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(mips_gnu); diff --git a/librz/arch/p/arch_msp430.c b/librz/arch/p/arch_msp430.c new file mode 100644 index 00000000000..be36eab1543 --- /dev/null +++ b/librz/arch/p/arch_msp430.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_msp430.c" +#include "asm_msp430.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(msp430); diff --git a/librz/arch/p/arch_nios2_gnu.c b/librz/arch/p/arch_nios2_gnu.c new file mode 100644 index 00000000000..b5c014a8d23 --- /dev/null +++ b/librz/arch/p/arch_nios2_gnu.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_nios2_gnu.c" +#include "asm_nios2_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(nios2); diff --git a/librz/arch/p/arch_null.c b/librz/arch/p/arch_null.c new file mode 100644 index 00000000000..b8ba09474a2 --- /dev/null +++ b/librz/arch/p/arch_null.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_null.c" +#include "asm_null.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(null); diff --git a/librz/arch/p/arch_or1k.c b/librz/arch/p/arch_or1k.c new file mode 100644 index 00000000000..06b1fdaf766 --- /dev/null +++ b/librz/arch/p/arch_or1k.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_or1k.c" +#include "asm_or1k.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(or1k); diff --git a/librz/arch/p/arch_pic.c b/librz/arch/p/arch_pic.c new file mode 100644 index 00000000000..659887fe06b --- /dev/null +++ b/librz/arch/p/arch_pic.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_pic.c" +#include "asm_pic.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(pic); diff --git a/librz/arch/p/arch_ppc_as.c b/librz/arch/p/arch_ppc_as.c new file mode 100644 index 00000000000..1f49ed448d7 --- /dev/null +++ b/librz/arch/p/arch_ppc_as.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_ppc_as.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(ppc_as); diff --git a/librz/arch/p/arch_ppc_cs.c b/librz/arch/p/arch_ppc_cs.c new file mode 100644 index 00000000000..1b89b4cc2f4 --- /dev/null +++ b/librz/arch/p/arch_ppc_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_ppc_cs.c" +#include "asm_ppc_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(ppc_cs); diff --git a/librz/arch/p/arch_propeller.c b/librz/arch/p/arch_propeller.c new file mode 100644 index 00000000000..167c2c9b162 --- /dev/null +++ b/librz/arch/p/arch_propeller.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_propeller.c" +#include "asm_propeller.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(propeller); diff --git a/librz/arch/p/arch_pyc.c b/librz/arch/p/arch_pyc.c new file mode 100644 index 00000000000..e083f36467a --- /dev/null +++ b/librz/arch/p/arch_pyc.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_pyc.c" +#include "asm_pyc.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(pyc); diff --git a/librz/arch/p/arch_riscv_cs.c b/librz/arch/p/arch_riscv_cs.c new file mode 100644 index 00000000000..036d234de5b --- /dev/null +++ b/librz/arch/p/arch_riscv_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_riscv_cs.c" +#include "asm_riscv_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(riscv_cs); diff --git a/librz/arch/p/arch_riscv_gnu.c b/librz/arch/p/arch_riscv_gnu.c new file mode 100644 index 00000000000..2010e75f9d9 --- /dev/null +++ b/librz/arch/p/arch_riscv_gnu.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_riscv_gnu.c" +#include "asm_riscv_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(riscv); diff --git a/librz/arch/p/arch_rl78.c b/librz/arch/p/arch_rl78.c new file mode 100644 index 00000000000..1ecd2a8d131 --- /dev/null +++ b/librz/arch/p/arch_rl78.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_rl78.c" +#include "asm_rl78.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(rl78); diff --git a/librz/arch/p/arch_rsp.c b/librz/arch/p/arch_rsp.c new file mode 100644 index 00000000000..54be4608784 --- /dev/null +++ b/librz/arch/p/arch_rsp.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_rsp.c" +#include "asm_rsp.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(rsp); diff --git a/librz/arch/p/arch_sh.c b/librz/arch/p/arch_sh.c new file mode 100644 index 00000000000..c71db62dcc1 --- /dev/null +++ b/librz/arch/p/arch_sh.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_sh.c" +#include "asm_sh.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(sh); diff --git a/librz/arch/p/arch_snes.c b/librz/arch/p/arch_snes.c new file mode 100644 index 00000000000..057c38f9fa3 --- /dev/null +++ b/librz/arch/p/arch_snes.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_snes.c" +#include "asm_snes.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(snes); diff --git a/librz/arch/p/arch_sparc_cs.c b/librz/arch/p/arch_sparc_cs.c new file mode 100644 index 00000000000..ebc3ff5453b --- /dev/null +++ b/librz/arch/p/arch_sparc_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_sparc_cs.c" +#include "asm_sparc_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(sparc_cs); diff --git a/librz/arch/p/arch_sparc_gnu.c b/librz/arch/p/arch_sparc_gnu.c new file mode 100644 index 00000000000..c9bdfca72e7 --- /dev/null +++ b/librz/arch/p/arch_sparc_gnu.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_sparc_gnu.c" +#include "asm_sparc_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(sparc_gnu); diff --git a/librz/arch/p/arch_spc700.c b/librz/arch/p/arch_spc700.c new file mode 100644 index 00000000000..c298171d811 --- /dev/null +++ b/librz/arch/p/arch_spc700.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_spc700.c" +#include "asm_spc700.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(spc700); diff --git a/librz/arch/p/arch_sysz.c b/librz/arch/p/arch_sysz.c new file mode 100644 index 00000000000..02a12d527b3 --- /dev/null +++ b/librz/arch/p/arch_sysz.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_sysz.c" +#include "asm_sysz.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(sysz); diff --git a/librz/arch/p/arch_tms320.c b/librz/arch/p/arch_tms320.c new file mode 100644 index 00000000000..46154fb5d43 --- /dev/null +++ b/librz/arch/p/arch_tms320.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_tms320.c" +#include "asm_tms320.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(tms320); diff --git a/librz/arch/p/arch_tms320c64x.c b/librz/arch/p/arch_tms320c64x.c new file mode 100644 index 00000000000..8f01e262344 --- /dev/null +++ b/librz/arch/p/arch_tms320c64x.c @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#define rz_analysis_plugin_tms320 rz_analysis_plugin_tms320c64x + +#include "analysis_tms320.c" +#include "asm_tms320c64x.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(tms320c64x); diff --git a/librz/arch/p/arch_tricore_cs.c b/librz/arch/p/arch_tricore_cs.c new file mode 100644 index 00000000000..50c5cfa1ab5 --- /dev/null +++ b/librz/arch/p/arch_tricore_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_tricore_cs.c" +#include "asm_tricore_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(tricore_cs); diff --git a/librz/arch/p/arch_v810.c b/librz/arch/p/arch_v810.c new file mode 100644 index 00000000000..344f70c1595 --- /dev/null +++ b/librz/arch/p/arch_v810.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_v810.c" +#include "asm_v810.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(v810); diff --git a/librz/arch/p/arch_v850.c b/librz/arch/p/arch_v850.c new file mode 100644 index 00000000000..9f38f6d2da9 --- /dev/null +++ b/librz/arch/p/arch_v850.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_v850.c" +#include "asm_v850.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(v850); diff --git a/librz/arch/p/arch_vax_gnu.c b/librz/arch/p/arch_vax_gnu.c new file mode 100644 index 00000000000..03e5022b7fe --- /dev/null +++ b/librz/arch/p/arch_vax_gnu.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_vax_gnu.c" +#include "asm_vax_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(vax); diff --git a/librz/arch/p/arch_wasm.c b/librz/arch/p/arch_wasm.c new file mode 100644 index 00000000000..cb44de4b100 --- /dev/null +++ b/librz/arch/p/arch_wasm.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_wasm.c" +#include "asm_wasm.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(wasm); diff --git a/librz/arch/p/arch_x86_as.c b/librz/arch/p/arch_x86_as.c new file mode 100644 index 00000000000..abfd2bb1050 --- /dev/null +++ b/librz/arch/p/arch_x86_as.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_x86_as.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(x86_as); diff --git a/librz/arch/p/arch_x86_cs.c b/librz/arch/p/arch_x86_cs.c new file mode 100644 index 00000000000..6d3e3895655 --- /dev/null +++ b/librz/arch/p/arch_x86_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_x86_cs.c" +#include "asm_x86_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(x86_cs); diff --git a/librz/arch/p/arch_x86_nasm.c b/librz/arch/p/arch_x86_nasm.c new file mode 100644 index 00000000000..faf930b94c1 --- /dev/null +++ b/librz/arch/p/arch_x86_nasm.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_x86_nasm.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(x86_nasm); diff --git a/librz/arch/p/arch_x86_nz.c b/librz/arch/p/arch_x86_nz.c new file mode 100644 index 00000000000..508cebb44cb --- /dev/null +++ b/librz/arch/p/arch_x86_nz.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "asm_x86_nz.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(x86_nz); diff --git a/librz/arch/p/arch_xap.c b/librz/arch/p/arch_xap.c new file mode 100644 index 00000000000..cab4bcf6176 --- /dev/null +++ b/librz/arch/p/arch_xap.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_xap.c" +#include "asm_xap.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(xap); diff --git a/librz/arch/p/arch_xcore_cs.c b/librz/arch/p/arch_xcore_cs.c new file mode 100644 index 00000000000..70c55b9af1b --- /dev/null +++ b/librz/arch/p/arch_xcore_cs.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_xcore_cs.c" +#include "asm_xcore_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(xcore_cs); diff --git a/librz/arch/p/arch_xtensa_gnu.c b/librz/arch/p/arch_xtensa_gnu.c new file mode 100644 index 00000000000..aba52a5ea72 --- /dev/null +++ b/librz/arch/p/arch_xtensa_gnu.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_xtensa_gnu.c" +#include "asm_xtensa_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(xtensa); diff --git a/librz/arch/p/arch_z80_gnu.c b/librz/arch/p/arch_z80_gnu.c new file mode 100644 index 00000000000..5f0ac5d36df --- /dev/null +++ b/librz/arch/p/arch_z80_gnu.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include "arch_helper.h" + +#include "analysis_z80_gnu.c" +#include "asm_z80_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(z80); diff --git a/librz/arch/p/asm_8051.c b/librz/arch/p/asm_8051.c index cc924954ced..1b24b9416f8 100644 --- a/librz/arch/p/asm_8051.c +++ b/librz/arch/p/asm_8051.c @@ -11,7 +11,6 @@ #include #include <8051_ass.h> -#include "../arch/8051/8051_disas.c" static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { int dlen = 0; diff --git a/librz/arch/p/asm_arc.c b/librz/arch/p/asm_arc_gnu.c similarity index 100% rename from librz/arch/p/asm_arc.c rename to librz/arch/p/asm_arc_gnu.c diff --git a/librz/arch/p/asm_arm_cs.c b/librz/arch/p/asm_arm_cs.c index dd231fe40f1..745a7ccc76a 100644 --- a/librz/arch/p/asm_arm_cs.c +++ b/librz/arch/p/asm_arm_cs.c @@ -7,14 +7,14 @@ #include #include "../arch/arm/asm-arm.h" #include "../arch/arm/arm_it.h" -#include "./asm_arm_hacks.inc" +#include "asm_arm_hacks.inc" -typedef struct arm_cs_context_t { +typedef struct arm_cs_context_asm_t { RzArmITContext it; csh cd; int omode; int obits; -} ArmCSContext; +} ArmCSContextAsm; #if CS_NEXT_VERSION < 6 inline static const char *ARMCondCodeToString(arm_cc cc) { @@ -59,7 +59,7 @@ inline static const char *ARMCondCodeToString(arm_cc cc) { bool arm64ass(const char *str, ut64 addr, ut32 *op); static bool check_features(RzAsm *a, cs_insn *insn) { - ArmCSContext *ctx = (ArmCSContext *)a->plugin_data; + ArmCSContextAsm *ctx = (ArmCSContextAsm *)a->plugin_data; int i; if (!insn || !insn->detail) { return true; @@ -94,7 +94,7 @@ static bool check_features(RzAsm *a, cs_insn *insn) { } static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { - ArmCSContext *ctx = (ArmCSContext *)a->plugin_data; + ArmCSContextAsm *ctx = (ArmCSContextAsm *)a->plugin_data; bool disp_hash = a->immdisp; cs_insn *insn = NULL; @@ -256,8 +256,8 @@ static int assemble(RzAsm *a, RzAsmOp *op, const char *buf) { return opsize; } -static bool arm_init(void **user) { - ArmCSContext *ctx = RZ_NEW0(ArmCSContext); +static bool arm_asm_init(void **user) { + ArmCSContextAsm *ctx = RZ_NEW0(ArmCSContextAsm); if (!ctx) { return false; } @@ -269,9 +269,9 @@ static bool arm_init(void **user) { return true; } -static bool arm_fini(void *user) { +static bool arm_asm_fini(void *user) { rz_return_val_if_fail(user, false); - ArmCSContext *ctx = (ArmCSContext *)user; + ArmCSContextAsm *ctx = (ArmCSContextAsm *)user; cs_close(&ctx->cd); rz_arm_it_context_fini(&ctx->it); free(ctx); @@ -279,7 +279,7 @@ static bool arm_fini(void *user) { } static char *mnemonics(RzAsm *a, int id, bool json) { - ArmCSContext *ctx = (ArmCSContext *)a->plugin_data; + ArmCSContextAsm *ctx = (ArmCSContextAsm *)a->plugin_data; int i; a->cur->disassemble(a, NULL, NULL, -1); if (id != -1) { @@ -328,8 +328,8 @@ RzAsmPlugin rz_asm_plugin_arm_cs = { .disassemble = &disassemble, .mnemonics = mnemonics, .assemble = &assemble, - .init = &arm_init, - .fini = &arm_fini, + .init = &arm_asm_init, + .fini = &arm_asm_fini, #if 0 // arm32 and arm64 "crypto,databarrier,divide,fparmv8,multpro,neon,t2extractpack," diff --git a/librz/arch/p/asm_arm_hacks.inc b/librz/arch/p/asm_arm_hacks.inc index b3d25653b00..a5e25996cae 100644 --- a/librz/arch/p/asm_arm_hacks.inc +++ b/librz/arch/p/asm_arm_hacks.inc @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2020 phakeobj // SPDX-License-Identifier: LGPL-3.0-only -static char *hack_handle_dp_imm(ut32 insn) { +static char *hack_handle_dp_imm_asm(ut32 insn) { char *buf_asm = NULL; char *mnemonic = NULL; const ut8 op0 = (insn >> 23) & 0x7; @@ -33,7 +33,7 @@ static char *hack_handle_dp_imm(ut32 insn) { return NULL; } -static char *hack_handle_br_exc_sys(ut32 insn) { +static char *hack_handle_br_exc_sys_asm(ut32 insn) { char *buf_asm = NULL; const char *mnemonic = "bti"; const ut8 op0 = (insn >> 29) & 0x7; @@ -64,7 +64,7 @@ static char *hack_handle_br_exc_sys(ut32 insn) { return buf_asm; } -static char *hack_handle_dp_reg(ut32 insn) { +static char *hack_handle_dp_reg_asm(ut32 insn) { char *buf_asm = NULL; char *mnemonic = NULL; const bool op0 = (insn >> 30) & 0x1; @@ -109,7 +109,7 @@ static char *hack_handle_dp_reg(ut32 insn) { return NULL; } -static char *hack_handle_ldst(ut32 insn) { +static char *hack_handle_ldst_asm(ut32 insn) { char *buf_asm = NULL; char *mnemonic = NULL; bool ignore_imm9 = false; @@ -231,19 +231,19 @@ static int hackyArmAsm(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { case 5: case 13: // irg, subp, gmi, subps - buf_asm = hack_handle_dp_reg(insn); + buf_asm = hack_handle_dp_reg_asm(insn); break; // Data Processing -- Immediate case 8: case 9: // addg, subg - buf_asm = hack_handle_dp_imm(insn); + buf_asm = hack_handle_dp_imm_asm(insn); break; // Branches, Exception generating, and System instructions case 10: case 11: // bti - buf_asm = hack_handle_br_exc_sys(insn); + buf_asm = hack_handle_br_exc_sys_asm(insn); break; // Loads and Stores case 4: @@ -251,7 +251,7 @@ static int hackyArmAsm(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { case 12: case 14: // stg, stzgm, ldg, stzg, st2g, stgm, stz2g, ldgm, stgp - buf_asm = hack_handle_ldst(insn); + buf_asm = hack_handle_ldst_asm(insn); break; default: break; diff --git a/librz/arch/p/asm_gb.c b/librz/arch/p/asm_gb.c index b32c28379c3..58d7b6be428 100644 --- a/librz/arch/p/asm_gb.c +++ b/librz/arch/p/asm_gb.c @@ -8,7 +8,6 @@ #include #include #include -#include "../arch/gb/gbdis.c" #include "../arch/gb/gbasm.c" static int disassemble(RzAsm *a, RzAsmOp *rz_op, const ut8 *buf, int len) { diff --git a/librz/arch/p/asm_i4004.c b/librz/arch/p/asm_i4004.c index 4c46a719d5f..99001d5dc99 100644 --- a/librz/arch/p/asm_i4004.c +++ b/librz/arch/p/asm_i4004.c @@ -6,7 +6,6 @@ #include #include #include -#include "../arch/i4004/i4004dis.c" static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return i4004dis(op, buf, len); diff --git a/librz/arch/p/asm_i8080.c b/librz/arch/p/asm_i8080.c index 35dfb307930..32c845e5353 100644 --- a/librz/arch/p/asm_i8080.c +++ b/librz/arch/p/asm_i8080.c @@ -5,7 +5,6 @@ #include #include #include -#include "../arch/i8080/i8080dis.c" static int do_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { int dlen = i8080_disasm(buf, rz_strbuf_get(&op->buf_asm), len); diff --git a/librz/arch/p/asm_java.c b/librz/arch/p/asm_java.c index 3c19d422423..b9d808ef502 100644 --- a/librz/arch/p/asm_java.c +++ b/librz/arch/p/asm_java.c @@ -10,7 +10,7 @@ #include "../arch/java/jvm.h" #include "../arch/java/assembler.h" -typedef struct java_analysis_context_t { +typedef struct java_asm_context_t { LookupSwitch ls; TableSwitch ts; ut16 switchop; @@ -19,7 +19,7 @@ typedef struct java_analysis_context_t { ut32 count; } JavaAsmContext; -static void update_context(JavaAsmContext *ctx) { +static void update_context_asm(JavaAsmContext *ctx) { ctx->count++; if (ctx->switchop == BYTECODE_AA_TABLESWITCH && ctx->count > ctx->ts.length) { ctx->switchop = BYTECODE_00_NOP; @@ -28,7 +28,7 @@ static void update_context(JavaAsmContext *ctx) { } } -static ut64 find_method(RzAsm *a) { +static ut64 find_method_asm(RzAsm *a) { ut64 addr = a->pc; if (!a->binb.bin) { return addr; @@ -69,7 +69,7 @@ static int java_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { op->size = 4; ut64 jump = ctx->pc + rz_read_be32(buf); rz_strbuf_setf(&op->buf_asm, "case %d: goto 0x%" PFMT64x, ctx->count + ctx->ts.low, jump); - update_context(ctx); + update_context_asm(ctx); return op->size; } case BYTECODE_AB_LOOKUPSWITCH: { @@ -81,7 +81,7 @@ static int java_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { st32 number = (st32)rz_read_be32(buf); ut64 jump = ctx->pc + rz_read_at_be32(buf, 4); rz_strbuf_setf(&op->buf_asm, "case %d: goto 0x%" PFMT64x, number, jump); - update_context(ctx); + update_context_asm(ctx); return op->size; } default: @@ -93,7 +93,7 @@ static int java_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { rz_strbuf_set(&op->buf_asm, "invalid"); - ut64 section = find_method(a); + ut64 section = find_method_asm(a); if (!jvm_init(&vm, buf, len, a->pc, section)) { RZ_LOG_ERROR("[!] java_disassemble: bad or invalid data.\n"); return -1; @@ -121,7 +121,7 @@ static int java_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return op->size; } -static bool java_init(void **user) { +static bool java_asm_init(void **user) { JavaAsmContext *ctx = RZ_NEW0(JavaAsmContext); if (!ctx) { return false; @@ -130,7 +130,7 @@ static bool java_init(void **user) { return true; } -static bool java_fini(void *user) { +static bool java_asm_fini(void *user) { if (!user) { return false; } @@ -160,8 +160,8 @@ RzAsmPlugin rz_asm_plugin_java = { .author = "deroad", .bits = 32, .endian = RZ_SYS_ENDIAN_BIG, - .init = java_init, - .fini = java_fini, + .init = java_asm_init, + .fini = java_asm_fini, .disassemble = &java_disassemble, .assemble = &java_assemble, }; diff --git a/librz/arch/p/asm_lh5801.c b/librz/arch/p/asm_lh5801.c index 799a45a5f46..ad6026b70b6 100644 --- a/librz/arch/p/asm_lh5801.c +++ b/librz/arch/p/asm_lh5801.c @@ -1,10 +1,10 @@ // SPDX-FileCopyrightText: 2014-2015 jn // SPDX-License-Identifier: LGPL-3.0-only -#include "../../arch/lh5801/lh5801.c" #include #include #include +#include "../arch/lh5801/lh5801.c" static int disassemble(RzAsm *as, RzAsmOp *op, const ut8 *buf, int len) { struct lh5801_insn insn = { 0 }; diff --git a/librz/arch/p/asm_luac.c b/librz/arch/p/asm_luac.c index 5ecfdc461a7..88af589e7b2 100644 --- a/librz/arch/p/asm_luac.c +++ b/librz/arch/p/asm_luac.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-only // SPDX-FileCopyrightText: 2021 Heersin -#include "librz/asm/arch/luac/lua_arch.h" +#include "../arch/luac/lua_arch.h" int rz_luac_disasm(RzAsm *a, RzAsmOp *opstruct, const ut8 *buf, int len) { LuaOpNameList oplist = NULL; diff --git a/librz/arch/p/asm_nios2.c b/librz/arch/p/asm_nios2_gnu.c similarity index 100% rename from librz/arch/p/asm_nios2.c rename to librz/arch/p/asm_nios2_gnu.c diff --git a/librz/arch/p/asm_or1k.c b/librz/arch/p/asm_or1k.c index f7156bdcc1f..1f1705b4340 100644 --- a/librz/arch/p/asm_or1k.c +++ b/librz/arch/p/asm_or1k.c @@ -5,18 +5,6 @@ #include #include "../arch/or1k/or1k_disas.h" -struct operands { - ut32 rd; - ut32 ra; - ut32 rb; - ut32 n; - ut32 k1; - ut32 k2; - ut32 k; - ut32 i; - ut32 l; -}; - static int insn_to_str(RzAsm *a, char **line, insn_t *descr, insn_extra_t *extra, ut32 insn) { struct operands o = { 0 }; char *name; diff --git a/librz/arch/p/asm_pyc.c b/librz/arch/p/asm_pyc.c index a4ede22ce91..eb8fb5c8d1a 100644 --- a/librz/arch/p/asm_pyc.c +++ b/librz/arch/p/asm_pyc.c @@ -9,9 +9,8 @@ #include "../arch/pyc/pyc_dis.h" -static pyc_opcodes *opcodes_cache = NULL; - static int disassemble(RzAsm *a, RzAsmOp *opstruct, const ut8 *buf, int len) { + pyc_opcodes *opcodes_cache = (pyc_opcodes *)a->plugin_data; RzList *shared = NULL; RzBin *bin = a->binb.bin; @@ -32,7 +31,7 @@ static int disassemble(RzAsm *a, RzAsmOp *opstruct, const ut8 *buf, int len) { } if (!opcodes_cache || !pyc_opcodes_equal(opcodes_cache, a->cpu)) { - opcodes_cache = get_opcode_by_version(a->cpu); + a->plugin_data = opcodes_cache = get_opcode_by_version(a->cpu); if (opcodes_cache == NULL) { RZ_LOG_ERROR("disassembler: pyc: unsupported pyc opcode cpu/version (asm.cpu=%s).\n", a->cpu); return len; @@ -44,11 +43,16 @@ static int disassemble(RzAsm *a, RzAsmOp *opstruct, const ut8 *buf, int len) { return r; } -static bool finish(void *user) { - if (opcodes_cache) { - free_opcode(opcodes_cache); - opcodes_cache = NULL; +static bool pyc_asm_init(void **user) { + *user = NULL; + return true; +} + +static bool pyc_asm_fini(void *user) { + if (!user) { + return false; } + free_opcode((pyc_opcodes *)user); return true; } @@ -59,7 +63,8 @@ RzAsmPlugin rz_asm_plugin_pyc = { .bits = 16 | 8, .desc = "PYC disassemble plugin", .disassemble = &disassemble, - .fini = &finish, + .init = &pyc_asm_init, + .fini = &pyc_asm_fini, }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p/asm_riscv.c b/librz/arch/p/asm_riscv_gnu.c similarity index 90% rename from librz/arch/p/asm_riscv.c rename to librz/arch/p/asm_riscv_gnu.c index 72bc76e56a6..07b1eda5145 100644 --- a/librz/arch/p/asm_riscv.c +++ b/librz/arch/p/asm_riscv_gnu.c @@ -5,8 +5,6 @@ #include #include #include -#include "../arch/riscv/riscv-opc.c" -#include "../arch/riscv/riscv.c" static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return op->size = riscv_dis(a, op, buf, len); diff --git a/librz/arch/p/asm_spc700.c b/librz/arch/p/asm_spc700.c index 552c5c550f1..b30850150be 100644 --- a/librz/arch/p/asm_spc700.c +++ b/librz/arch/p/asm_spc700.c @@ -6,7 +6,6 @@ #include #include #include -#include "../arch/spc700/spc700dis.c" static int disassemble(RzAsm *a, RzAsmOp *rz_op, const ut8 *buf, int len) { size_t dlen = spc700_disas(&rz_op->buf_asm, a->pc, buf, len); diff --git a/librz/arch/p/asm_tms320.c b/librz/arch/p/asm_tms320.c index 403fd70a60c..d556d454965 100644 --- a/librz/arch/p/asm_tms320.c +++ b/librz/arch/p/asm_tms320.c @@ -97,7 +97,7 @@ static int tms320_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return op->size; } -static bool tms320_init(void **user) { +static bool tms320_asm_init(void **user) { TmsContext *ctx = RZ_NEW0(TmsContext); if (!ctx) { return false; @@ -107,7 +107,7 @@ static bool tms320_init(void **user) { return true; } -static bool tms320_fini(void *user) { +static bool tms320_asm_fini(void *user) { rz_return_val_if_fail(user, false); TmsContext *ctx = (TmsContext *)user; #if CAPSTONE_HAS_TMS320C64X @@ -131,8 +131,8 @@ RzAsmPlugin rz_asm_plugin_tms320 = { .license = "LGPLv3", .bits = 32, .endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG, - .init = tms320_init, - .fini = tms320_fini, + .init = tms320_asm_init, + .fini = tms320_asm_fini, .disassemble = &tms320_disassemble, }; diff --git a/librz/arch/p/asm_tricore_cs.c b/librz/arch/p/asm_tricore_cs.c index dfec1133345..7804e2dc15a 100644 --- a/librz/arch/p/asm_tricore_cs.c +++ b/librz/arch/p/asm_tricore_cs.c @@ -8,8 +8,7 @@ #include #include #include - -#include "../arch/tricore/tricore.inc" +#include "../arch/tricore/tricore.h" #define TRICORE_LONGEST_INSTRUCTION 4 #define TRICORE_SHORTEST_INSTRUCTION 2 @@ -109,7 +108,7 @@ static bool fini(void *u) { return true; } -RzAsmPlugin rz_asm_plugin_tricore = { +RzAsmPlugin rz_asm_plugin_tricore_cs = { .name = "tricore", .arch = "tricore", .author = "billow", @@ -125,7 +124,7 @@ RzAsmPlugin rz_asm_plugin_tricore = { #ifndef RZ_PLUGIN_INCORE RZ_API RzLibStruct rizin_plugin = { .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_tricore, + .data = &rz_asm_plugin_tricore_cs, .version = RZ_VERSION }; #endif diff --git a/librz/arch/p/asm_vax.c b/librz/arch/p/asm_vax_gnu.c similarity index 100% rename from librz/arch/p/asm_vax.c rename to librz/arch/p/asm_vax_gnu.c diff --git a/librz/arch/p/asm_xap.c b/librz/arch/p/asm_xap.c index 1b4a684c30f..628d8cc7c37 100644 --- a/librz/arch/p/asm_xap.c +++ b/librz/arch/p/asm_xap.c @@ -6,7 +6,6 @@ #include #include #include -#include "xap/dis.c" static int arch_xap_disasm(char *str, const unsigned char *buf, ut64 seek) { struct state *s = get_state(); @@ -31,7 +30,7 @@ static int arch_xap_disasm(char *str, const unsigned char *buf, ut64 seek) { #endif return 0; } -static int disassemble(RzAsm *a, struct rz_asm_op_t *op, const ut8 *buf, int len) { +static int xap_disassemble(RzAsm *a, struct rz_asm_op_t *op, const ut8 *buf, int len) { char *buf_asm = rz_strbuf_get(&op->buf_asm); arch_xap_disasm(buf_asm, buf, a->pc); return (op->size = 2); @@ -44,7 +43,7 @@ RzAsmPlugin rz_asm_plugin_xap = { .bits = 16, .endian = RZ_SYS_ENDIAN_LITTLE, .desc = "XAP4 RISC (CSR)", - .disassemble = &disassemble + .disassemble = &xap_disassemble }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p/asm_xtensa.c b/librz/arch/p/asm_xtensa_gnu.c similarity index 100% rename from librz/arch/p/asm_xtensa.c rename to librz/arch/p/asm_xtensa_gnu.c diff --git a/librz/arch/p/asm_z80.c b/librz/arch/p/asm_z80_gnu.c similarity index 100% rename from librz/arch/p/asm_z80.c rename to librz/arch/p/asm_z80_gnu.c diff --git a/librz/arch/platforms/meson.build b/librz/arch/platforms/meson.build index 00bd5889eec..0799074de98 100644 --- a/librz/arch/platforms/meson.build +++ b/librz/arch/platforms/meson.build @@ -14,6 +14,6 @@ foreach file : sdb_files depends: sdb_exe, build_by_default: true, install: true, - install_dir: join_paths(rizin_sdb, 'asm/platforms') + install_dir: join_paths(rizin_sdb, 'arch/platforms') ) endforeach diff --git a/librz/bin/p/bin_java.c b/librz/bin/p/bin_java.c index 8e472f5cd70..112d410b13f 100644 --- a/librz/bin/p/bin_java.c +++ b/librz/bin/p/bin_java.c @@ -8,7 +8,7 @@ #include #include "../format/java/class_bin.h" -#include "../../asm/arch/java/const.h" +#include "../../arch/arch/java/const.h" #define rz_bin_file_get_java_class(bf) ((RzBinJavaClass *)bf->o->bin_obj) diff --git a/librz/config.h.in b/librz/config.h.in index f55c135a6cd..2c036ce97b5 100644 --- a/librz/config.h.in +++ b/librz/config.h.in @@ -18,8 +18,7 @@ #define RZ_IO_STATIC_PLUGINS @plugins_io@ #define RZ_DEBUG_STATIC_PLUGINS @plugins_debug@ #define RZ_BP_STATIC_PLUGINS @plugins_bp@ -#define RZ_ASM_STATIC_PLUGINS @plugins_asm@ -#define RZ_ANALYSIS_STATIC_PLUGINS @plugins_analysis@ +#define RZ_ARCH_STATIC_PLUGINS @plugins_arch@ #define RZ_CORE_STATIC_PLUGINS @plugins_core@ #define RZ_LANG_STATIC_PLUGINS @plugins_lang@ #define RZ_HASH_STATIC_PLUGINS @plugins_hash@ diff --git a/librz/core/libs.c b/librz/core/libs.c index c44f9719370..4bd670a4122 100644 --- a/librz/core/libs.c +++ b/librz/core/libs.c @@ -40,6 +40,38 @@ CB(demangler, bin->demangler) CB(egg, egg) CB(hash, hash) +static bool lib_arch_cb(RzLibPlugin *pl, void *user, void *data) { + struct rz_arch_plugin_t *hand = (struct rz_arch_plugin_t *)data; + RzCore *core = (RzCore *)user; + if (!hand->p_asm && !hand->p_analysis) { + // TODO: add new structure. + // return rz_arch_plugin_add(core->arch, hand); + return false; + } + if (hand->p_asm && !rz_asm_plugin_add(core->rasm, hand->p_asm)) { + // deprecated structure + return false; + } + if (hand->p_analysis && !rz_analysis_plugin_add(core->analysis, hand->p_analysis)) { + // deprecated structure + return false; + } + return true; +} + +static bool lib_arch_dt(RzLibPlugin *pl, void *user, void *data) { + struct rz_arch_plugin_t *hand = (struct rz_arch_plugin_t *)data; + RzCore *core = (RzCore *)user; + if (hand->p_asm && hand->p_analysis) { + // deprecated structure + return rz_asm_plugin_del(core->rasm, hand->p_asm) && + rz_analysis_plugin_del(core->analysis, hand->p_analysis); + } + // TODO: add new structure. + // return rz_arch_plugin_del(core->arch, hand); + return false; +} + static void loadSystemPlugins(RzCore *core, int where) { #if RZ_LOADLIBS const char *dir_plugins = rz_config_get(core->config, "dir.plugins"); @@ -90,6 +122,7 @@ RZ_API void rz_core_loadlibs_init(RzCore *core) { DF(BIN, "bin plugins", bin); DF(EGG, "egg plugins", egg); DF(HASH, "hash plugins", hash); + DF(ARCH, "(dis)assembler & analysis plugins", arch); core->times->loadlibs_init_time = rz_time_now_mono() - prev; } diff --git a/librz/core/meson.build b/librz/core/meson.build index 45ce7b68104..b92a14c1fbd 100644 --- a/librz/core/meson.build +++ b/librz/core/meson.build @@ -146,12 +146,11 @@ rz_core_deps = [ rz_bp_dep, rz_syscall_dep, rz_parse_dep, - rz_asm_dep, + rz_arch_dep, rz_egg_dep, rz_search_dep, rz_sign_dep, rz_il_dep, - rz_analysis_dep, rz_type_dep, rz_debug_dep, rz_config_dep, @@ -191,7 +190,6 @@ modules += { 'rz_core': { 'rz_syscall', 'rz_search', 'rz_cons', - 'rz_analysis', 'rz_socket', 'rz_type', 'rz_io', @@ -204,7 +202,7 @@ modules += { 'rz_core': { 'rz_crypto', 'rz_config', 'rz_bin', - 'rz_asm', + 'rz_arch', 'rz_bp', 'rz_sign', 'rz_il' diff --git a/librz/debug/meson.build b/librz/debug/meson.build index e2ca00700ff..200522c6e9d 100644 --- a/librz/debug/meson.build +++ b/librz/debug/meson.build @@ -70,7 +70,7 @@ rz_debug_deps = [ rz_bp_dep, rz_syscall_dep, rz_egg_dep, - rz_analysis_dep, + rz_arch_dep, rz_type_dep, platform_deps ] @@ -157,7 +157,7 @@ modules += { 'rz_debug': { 'rz_hash', 'rz_reg', 'rz_syscall', - 'rz_analysis', + 'rz_arch', 'rz_io', 'rz_bin', 'rz_bp', diff --git a/librz/egg/meson.build b/librz/egg/meson.build index 1d5782ef575..1a3c38d41a8 100644 --- a/librz/egg/meson.build +++ b/librz/egg/meson.build @@ -29,7 +29,7 @@ rz_egg = library('rz_egg', rz_egg_sources, dependencies: [ rz_util_dep, rz_syscall_dep, - rz_asm_dep, + rz_arch_dep, mpc_dep ], install: true, @@ -47,6 +47,6 @@ meson.override_dependency('rz_egg', rz_egg_dep) modules += { 'rz_egg': { 'target': rz_egg, - 'dependencies': ['rz_util', 'rz_asm', 'rz_syscall'], + 'dependencies': ['rz_util', 'rz_arch', 'rz_syscall'], 'plugins': [egg_plugins] }} diff --git a/librz/include/meson.build b/librz/include/meson.build index 349e7e4d21d..1a0d71459e2 100644 --- a/librz/include/meson.build +++ b/librz/include/meson.build @@ -1,6 +1,7 @@ include_files = [ 'rz_agraph.h', 'rz_analysis.h', + 'rz_arch.h', 'rz_asm.h', 'rz_basefind.h', 'rz_bin.h', diff --git a/librz/include/rz_analysis.h b/librz/include/rz_analysis.h index 3ae3fd503af..f52acaf1ae1 100644 --- a/librz/include/rz_analysis.h +++ b/librz/include/rz_analysis.h @@ -2417,67 +2417,6 @@ RZ_API bool rz_serialize_analysis_cc_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnaly RZ_API void rz_serialize_analysis_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis); RZ_API bool rz_serialize_analysis_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzSerializeResultInfo *res); -/* plugin pointers */ -extern RzAnalysisPlugin rz_analysis_plugin_null; -extern RzAnalysisPlugin rz_analysis_plugin_6502; -extern RzAnalysisPlugin rz_analysis_plugin_8051; -extern RzAnalysisPlugin rz_analysis_plugin_amd29k; -extern RzAnalysisPlugin rz_analysis_plugin_arc; -extern RzAnalysisPlugin rz_analysis_plugin_arm_cs; -extern RzAnalysisPlugin rz_analysis_plugin_avr; -extern RzAnalysisPlugin rz_analysis_plugin_bf; -extern RzAnalysisPlugin rz_analysis_plugin_chip8; -extern RzAnalysisPlugin rz_analysis_plugin_cil; -extern RzAnalysisPlugin rz_analysis_plugin_cr16; -extern RzAnalysisPlugin rz_analysis_plugin_cris; -extern RzAnalysisPlugin rz_analysis_plugin_dalvik; -extern RzAnalysisPlugin rz_analysis_plugin_ebc; -extern RzAnalysisPlugin rz_analysis_plugin_gb; -extern RzAnalysisPlugin rz_analysis_plugin_h8300; -extern RzAnalysisPlugin rz_analysis_plugin_hexagon; -extern RzAnalysisPlugin rz_analysis_plugin_i4004; -extern RzAnalysisPlugin rz_analysis_plugin_i8080; -extern RzAnalysisPlugin rz_analysis_plugin_java; -extern RzAnalysisPlugin rz_analysis_plugin_m68k_cs; -extern RzAnalysisPlugin rz_analysis_plugin_m680x_cs; -extern RzAnalysisPlugin rz_analysis_plugin_malbolge; -extern RzAnalysisPlugin rz_analysis_plugin_mcore; -extern RzAnalysisPlugin rz_analysis_plugin_mips_cs; -extern RzAnalysisPlugin rz_analysis_plugin_mips_gnu; -extern RzAnalysisPlugin rz_analysis_plugin_msp430; -extern RzAnalysisPlugin rz_analysis_plugin_nios2; -extern RzAnalysisPlugin rz_analysis_plugin_or1k; -extern RzAnalysisPlugin rz_analysis_plugin_pic; -extern RzAnalysisPlugin rz_analysis_plugin_ppc_cs; -extern RzAnalysisPlugin rz_analysis_plugin_propeller; -extern RzAnalysisPlugin rz_analysis_plugin_riscv; -extern RzAnalysisPlugin rz_analysis_plugin_riscv_cs; -extern RzAnalysisPlugin rz_analysis_plugin_rl78; -extern RzAnalysisPlugin rz_analysis_plugin_rsp; -extern RzAnalysisPlugin rz_analysis_plugin_sh; -extern RzAnalysisPlugin rz_analysis_plugin_snes; -extern RzAnalysisPlugin rz_analysis_plugin_sparc_cs; -extern RzAnalysisPlugin rz_analysis_plugin_sparc_gnu; -extern RzAnalysisPlugin rz_analysis_plugin_spc700; -extern RzAnalysisPlugin rz_analysis_plugin_sysz; -extern RzAnalysisPlugin rz_analysis_plugin_tms320; -extern RzAnalysisPlugin rz_analysis_plugin_tms320c64x; -extern RzAnalysisPlugin rz_analysis_plugin_tricore_cs; -extern RzAnalysisPlugin rz_analysis_plugin_v810; -extern RzAnalysisPlugin rz_analysis_plugin_v850; -extern RzAnalysisPlugin rz_analysis_plugin_vax; -extern RzAnalysisPlugin rz_analysis_plugin_wasm; -extern RzAnalysisPlugin rz_analysis_plugin_x86; -extern RzAnalysisPlugin rz_analysis_plugin_x86_cs; -extern RzAnalysisPlugin rz_analysis_plugin_x86_im; -extern RzAnalysisPlugin rz_analysis_plugin_x86_simple; -extern RzAnalysisPlugin rz_analysis_plugin_x86_udis; -extern RzAnalysisPlugin rz_analysis_plugin_xap; -extern RzAnalysisPlugin rz_analysis_plugin_xcore_cs; -extern RzAnalysisPlugin rz_analysis_plugin_xtensa; -extern RzAnalysisPlugin rz_analysis_plugin_z80; -extern RzAnalysisPlugin rz_analysis_plugin_pyc; -extern RzAnalysisPlugin rz_analysis_plugin_luac; #ifdef __cplusplus } #endif diff --git a/librz/include/rz_arch.h b/librz/include/rz_arch.h new file mode 100644 index 00000000000..fff08297ff4 --- /dev/null +++ b/librz/include/rz_arch.h @@ -0,0 +1,101 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RZ_ARCH_H +#define RZ_ARCH_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rz_arch_plugin_t { + RZ_DEPRECATE RzAsmPlugin *p_asm; ///< Assembly Plugin + RZ_DEPRECATE RzAnalysisPlugin *p_analysis; ///< Analysis Plugin +} RzArchPlugin; + +/* plugin pointers */ +extern RzArchPlugin rz_arch_plugin_6502; +extern RzArchPlugin rz_arch_plugin_8051; +extern RzArchPlugin rz_arch_plugin_amd29k; +extern RzArchPlugin rz_arch_plugin_arc; +extern RzArchPlugin rz_arch_plugin_arm_as; +extern RzArchPlugin rz_arch_plugin_arm_cs; +extern RzArchPlugin rz_arch_plugin_avr; +extern RzArchPlugin rz_arch_plugin_bf; +extern RzArchPlugin rz_arch_plugin_chip8; +extern RzArchPlugin rz_arch_plugin_cil; +extern RzArchPlugin rz_arch_plugin_cr16; +extern RzArchPlugin rz_arch_plugin_cris; +extern RzArchPlugin rz_arch_plugin_cris_gnu; +extern RzArchPlugin rz_arch_plugin_dalvik; +extern RzArchPlugin rz_arch_plugin_dcpu16; +extern RzArchPlugin rz_arch_plugin_ebc; +extern RzArchPlugin rz_arch_plugin_gb; +extern RzArchPlugin rz_arch_plugin_h8300; +extern RzArchPlugin rz_arch_plugin_hexagon; +extern RzArchPlugin rz_arch_plugin_hexagon_gnu; +extern RzArchPlugin rz_arch_plugin_hppa_gnu; +extern RzArchPlugin rz_arch_plugin_i4004; +extern RzArchPlugin rz_arch_plugin_i8080; +extern RzArchPlugin rz_arch_plugin_java; +extern RzArchPlugin rz_arch_plugin_lanai_gnu; +extern RzArchPlugin rz_arch_plugin_lh5801; +extern RzArchPlugin rz_arch_plugin_lm32; +extern RzArchPlugin rz_arch_plugin_luac; +extern RzArchPlugin rz_arch_plugin_m680x_cs; +extern RzArchPlugin rz_arch_plugin_m68k_cs; +extern RzArchPlugin rz_arch_plugin_malbolge; +extern RzArchPlugin rz_arch_plugin_mcore; +extern RzArchPlugin rz_arch_plugin_mcs96; +extern RzArchPlugin rz_arch_plugin_mips_cs; +extern RzArchPlugin rz_arch_plugin_mips_gnu; +extern RzArchPlugin rz_arch_plugin_msp430; +extern RzArchPlugin rz_arch_plugin_nios2; +extern RzArchPlugin rz_arch_plugin_null; +extern RzArchPlugin rz_arch_plugin_or1k; +extern RzArchPlugin rz_arch_plugin_pic; +extern RzArchPlugin rz_arch_plugin_ppc_as; +extern RzArchPlugin rz_arch_plugin_ppc_cs; +extern RzArchPlugin rz_arch_plugin_propeller; +extern RzArchPlugin rz_arch_plugin_pyc; +extern RzArchPlugin rz_arch_plugin_riscv; +extern RzArchPlugin rz_arch_plugin_riscv_cs; +extern RzArchPlugin rz_arch_plugin_rl78; +extern RzArchPlugin rz_arch_plugin_rsp; +extern RzArchPlugin rz_arch_plugin_sh; +extern RzArchPlugin rz_arch_plugin_snes; +extern RzArchPlugin rz_arch_plugin_sparc_cs; +extern RzArchPlugin rz_arch_plugin_sparc_gnu; +extern RzArchPlugin rz_arch_plugin_spc700; +extern RzArchPlugin rz_arch_plugin_sysz; +extern RzArchPlugin rz_arch_plugin_tms320; +extern RzArchPlugin rz_arch_plugin_tms320c64x; +extern RzArchPlugin rz_arch_plugin_tricore; +extern RzArchPlugin rz_arch_plugin_tricore_cs; +extern RzArchPlugin rz_arch_plugin_v810; +extern RzArchPlugin rz_arch_plugin_v850; +extern RzArchPlugin rz_arch_plugin_vax; +extern RzArchPlugin rz_arch_plugin_wasm; +extern RzArchPlugin rz_arch_plugin_x86; +extern RzArchPlugin rz_arch_plugin_x86_as; +extern RzArchPlugin rz_arch_plugin_x86_cs; +extern RzArchPlugin rz_arch_plugin_x86_im; +extern RzArchPlugin rz_arch_plugin_x86_nasm; +extern RzArchPlugin rz_arch_plugin_x86_nz; +extern RzArchPlugin rz_arch_plugin_x86_simple; +extern RzArchPlugin rz_arch_plugin_x86_udis; +extern RzArchPlugin rz_arch_plugin_xap; +extern RzArchPlugin rz_arch_plugin_xcore_cs; +extern RzArchPlugin rz_arch_plugin_xtensa; +extern RzArchPlugin rz_arch_plugin_z80; + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_ARCH_H */ diff --git a/librz/include/rz_asm.h b/librz/include/rz_asm.h index 39b6707d08e..84bb0a0f444 100644 --- a/librz/include/rz_asm.h +++ b/librz/include/rz_asm.h @@ -213,76 +213,6 @@ RZ_API RZ_OWN RzAsmParseParam *rz_asm_get_parse_param(RZ_NULLABLE const RzReg *r RZ_DEPRECATE RZ_API RZ_OWN RzAsmTokenString *rz_asm_tokenize_asm_string(RZ_BORROW RzStrBuf *asm_str, RZ_NULLABLE const RzAsmParseParam *param); RZ_DEPRECATE RZ_API RZ_OWN RzStrBuf *rz_asm_colorize_asm_str(RZ_BORROW RzStrBuf *asm_str, RZ_BORROW RzPrint *p, RZ_NULLABLE const RzAsmParseParam *param, RZ_NULLABLE const RzAsmTokenString *toks); -/* plugin pointers */ -extern RzAsmPlugin rz_asm_plugin_6502; -extern RzAsmPlugin rz_asm_plugin_8051; -extern RzAsmPlugin rz_asm_plugin_amd29k; -extern RzAsmPlugin rz_asm_plugin_arc; -extern RzAsmPlugin rz_asm_plugin_arm_as; -extern RzAsmPlugin rz_asm_plugin_arm_cs; -extern RzAsmPlugin rz_asm_plugin_avr; -extern RzAsmPlugin rz_asm_plugin_bf; -extern RzAsmPlugin rz_asm_plugin_null; -extern RzAsmPlugin rz_asm_plugin_chip8; -extern RzAsmPlugin rz_asm_plugin_cil; -extern RzAsmPlugin rz_asm_plugin_cr16; -extern RzAsmPlugin rz_asm_plugin_cris_gnu; -extern RzAsmPlugin rz_asm_plugin_dalvik; -extern RzAsmPlugin rz_asm_plugin_dcpu16; -extern RzAsmPlugin rz_asm_plugin_ebc; -extern RzAsmPlugin rz_asm_plugin_gb; -extern RzAsmPlugin rz_asm_plugin_h8300; -extern RzAsmPlugin rz_asm_plugin_hexagon; -extern RzAsmPlugin rz_asm_plugin_hexagon_gnu; -extern RzAsmPlugin rz_asm_plugin_hppa_gnu; -extern RzAsmPlugin rz_asm_plugin_i4004; -extern RzAsmPlugin rz_asm_plugin_i8080; -extern RzAsmPlugin rz_asm_plugin_java; -extern RzAsmPlugin rz_asm_plugin_lanai_gnu; -extern RzAsmPlugin rz_asm_plugin_lh5801; -extern RzAsmPlugin rz_asm_plugin_lm32; -extern RzAsmPlugin rz_asm_plugin_luac; -extern RzAsmPlugin rz_asm_plugin_m68k_cs; -extern RzAsmPlugin rz_asm_plugin_m680x_cs; -extern RzAsmPlugin rz_asm_plugin_malbolge; -extern RzAsmPlugin rz_asm_plugin_mcore; -extern RzAsmPlugin rz_asm_plugin_mcs96; -extern RzAsmPlugin rz_asm_plugin_mips_cs; -extern RzAsmPlugin rz_asm_plugin_mips_gnu; -extern RzAsmPlugin rz_asm_plugin_msp430; -extern RzAsmPlugin rz_asm_plugin_nios2; -extern RzAsmPlugin rz_asm_plugin_or1k; -extern RzAsmPlugin rz_asm_plugin_pic; -extern RzAsmPlugin rz_asm_plugin_ppc_as; -extern RzAsmPlugin rz_asm_plugin_ppc_cs; -extern RzAsmPlugin rz_asm_plugin_propeller; -extern RzAsmPlugin rz_asm_plugin_riscv; -extern RzAsmPlugin rz_asm_plugin_riscv_cs; -extern RzAsmPlugin rz_asm_plugin_rl78; -extern RzAsmPlugin rz_asm_plugin_rsp; -extern RzAsmPlugin rz_asm_plugin_sh; -extern RzAsmPlugin rz_asm_plugin_snes; -extern RzAsmPlugin rz_asm_plugin_sparc_cs; -extern RzAsmPlugin rz_asm_plugin_sparc_gnu; -extern RzAsmPlugin rz_asm_plugin_spc700; -extern RzAsmPlugin rz_asm_plugin_sysz; -extern RzAsmPlugin rz_asm_plugin_tms320; -extern RzAsmPlugin rz_asm_plugin_tms320c64x; -extern RzAsmPlugin rz_asm_plugin_tricore; -extern RzAsmPlugin rz_asm_plugin_v810; -extern RzAsmPlugin rz_asm_plugin_v850; -extern RzAsmPlugin rz_asm_plugin_vax; -extern RzAsmPlugin rz_asm_plugin_wasm; -extern RzAsmPlugin rz_asm_plugin_x86_as; -extern RzAsmPlugin rz_asm_plugin_x86_cs; -extern RzAsmPlugin rz_asm_plugin_x86_nasm; -extern RzAsmPlugin rz_asm_plugin_x86_nz; -extern RzAsmPlugin rz_asm_plugin_xap; -extern RzAsmPlugin rz_asm_plugin_xcore_cs; -extern RzAsmPlugin rz_asm_plugin_xtensa; -extern RzAsmPlugin rz_asm_plugin_z80; -extern RzAsmPlugin rz_asm_plugin_pyc; - #endif #ifdef __cplusplus diff --git a/librz/include/rz_core.h b/librz/include/rz_core.h index 893ac01d290..f68a1cb44e8 100644 --- a/librz/include/rz_core.h +++ b/librz/include/rz_core.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/librz/include/rz_lib.h b/librz/include/rz_lib.h index dba4c4ca233..5b3d2116b65 100644 --- a/librz/include/rz_lib.h +++ b/librz/include/rz_lib.h @@ -50,6 +50,7 @@ typedef enum { RZ_LIB_TYPE_CORE, ///< RzCore commands RZ_LIB_TYPE_EGG, ///< rz_egg plugin RZ_LIB_TYPE_DEMANGLER, ///< demanglers + RZ_LIB_TYPE_ARCH, ///< arch RZ_LIB_TYPE_UNKNOWN } RzLibType; diff --git a/librz/main/meson.build b/librz/main/meson.build index 90db2ea5b5c..66371ed2981 100644 --- a/librz/main/meson.build +++ b/librz/main/meson.build @@ -27,10 +27,9 @@ rz_main_deps = [ rz_bp_dep, rz_syscall_dep, rz_parse_dep, - rz_asm_dep, + rz_arch_dep, rz_egg_dep, rz_search_dep, - rz_analysis_dep, rz_debug_dep, rz_config_dep, rz_bin_dep, @@ -61,7 +60,7 @@ modules += { 'rz_main': { 'dependencies': [ 'rz_core', 'rz_demangler', - 'rz_asm', + 'rz_arch', 'rz_sign', 'rz_diff', 'rz_syscall' diff --git a/librz/main/rz-asm.c b/librz/main/rz-asm.c index 42f937ebea7..f24d8cae393 100644 --- a/librz/main/rz-asm.c +++ b/librz/main/rz-asm.c @@ -476,6 +476,26 @@ static bool lib_analysis_cb(RzLibPlugin *pl, void *user, void *data) { return rz_analysis_plugin_add(as->analysis, hand); } +/* arch callback */ +static bool lib_arch_cb(RzLibPlugin *pl, void *user, void *data) { + RzArchPlugin *hand = (RzArchPlugin *)data; + RzAsmState *as = (RzAsmState *)user; + if (!hand->p_asm && !hand->p_analysis) { + // TODO: add new structure. + // return rz_arch_plugin_add(as->a, hand); + return false; + } + if (hand->p_asm && !rz_asm_plugin_add(as->a, hand->p_asm)) { + // deprecated structure + return false; + } + if (hand->p_analysis && !rz_analysis_plugin_add(as->analysis, hand->p_analysis)) { + // deprecated structure + return false; + } + return true; +} + static int print_assembly_output(RzAsmState *as, const char *buf, ut64 offset, ut64 len, int bits, int bin, bool use_spp, bool rad, bool hexwords, const char *arch) { if (rad) { @@ -501,8 +521,9 @@ static void __load_plugins(RzAsmState *as) { free(tmp); return; } - rz_lib_add_handler(as->l, RZ_LIB_TYPE_ASM, "(dis)assembly plugins", &lib_asm_cb, NULL, as); - rz_lib_add_handler(as->l, RZ_LIB_TYPE_ANALYSIS, "analysis/emulation plugins", &lib_analysis_cb, NULL, as); + rz_lib_add_handler(as->l, RZ_LIB_TYPE_ASM, "(dis)assembly plugins (deprecated)", &lib_asm_cb, NULL, as); + rz_lib_add_handler(as->l, RZ_LIB_TYPE_ANALYSIS, "analysis/emulation plugins (deprecated)", &lib_analysis_cb, NULL, as); + rz_lib_add_handler(as->l, RZ_LIB_TYPE_ARCH, "(dis)assembly/analysis/emulation plugins", &lib_arch_cb, NULL, as); char *path = rz_sys_getenv(RZ_LIB_ENV); if (!RZ_STR_ISEMPTY(path)) { diff --git a/librz/sign/meson.build b/librz/sign/meson.build index 4da38a586ab..3f509881821 100644 --- a/librz/sign/meson.build +++ b/librz/sign/meson.build @@ -12,7 +12,7 @@ rz_sign_inc = [ rz_sign_deps = [ rz_util_dep, - rz_analysis_dep, + rz_arch_dep, rz_diff_dep, rz_hash_dep, rz_type_dep, @@ -40,7 +40,7 @@ modules += { 'rz_sign': { 'target': rz_sign, 'dependencies': [ 'rz_util', - 'rz_analysis', + 'rz_arch', 'rz_diff', 'rz_hash', 'rz_type', diff --git a/meson.build b/meson.build index 5b68819aab2..bfc2fa612e6 100644 --- a/meson.build +++ b/meson.build @@ -661,8 +661,7 @@ test_env_common_path = [] build_root = meson.current_build_dir() if host_machine.system() == 'windows' test_env_common_path += [ - build_root / 'librz' / 'analysis', - build_root / 'librz' / 'asm', + build_root / 'librz' / 'arch', build_root / 'librz' / 'bin', build_root / 'librz' / 'bp', build_root / 'librz' / 'config', @@ -789,8 +788,7 @@ foreach plugin : hash_plugins.get('list') endforeach summary({ - 'Analysis Plugins': analysis_plugins.get('list'), - 'Assembler Plugins': asm_plugins.get('list'), + 'Arch Plugins': arch_plugins.get('list'), 'Binary Plugins': bin_plugins.get('list'), 'BinXtr Plugins': bin_xtr_plugins.get('list'), 'Breakpoint Plugins': bp_plugins.get('list'), diff --git a/sys/clang-format.py b/sys/clang-format.py index 509c1792887..2dff9309dbc 100755 --- a/sys/clang-format.py +++ b/sys/clang-format.py @@ -25,20 +25,20 @@ skiplist = [ "/gnu/", - "librz/asm/arch/vax/", - "librz/asm/arch/riscv/", - "librz/asm/arch/sh/gnu/", - "librz/asm/arch/i8080/", - "librz/asm/arch/z80/", - "librz/asm/arch/avr/", - "librz/asm/arch/arm/aarch64/", + "librz/arch/arch/vax/", + "librz/arch/arch/riscv/", + "librz/arch/arch/sh/gnu/", + "librz/arch/arch/i8080/", + "librz/arch/arch/z80/", + "librz/arch/arch/avr/", + "librz/arch/arch/arm/aarch64/", "librz/hash/xxhash/", "librz/bin/mangling/cxx/", "librz/bin/d/jni.h", "librz/util/bdiff.c", - "librz/asm/arch/tms320/c55x/table.h", + "librz/arch/arch/tms320/c55x/table.h", "librz/include/sflib/", - "librz/asm/arch/include/opcode/", + "librz/arch/arch/include/opcode/", ] patterns = ["*.c", "*.cpp", "*.h", "*.hpp", "*.inc"] diff --git a/test/integration/meson.build b/test/integration/meson.build index 2743147d2d5..a355b997be6 100644 --- a/test/integration/meson.build +++ b/test/integration/meson.build @@ -46,14 +46,13 @@ if get_option('enable_tests') rz_bin_dep, rz_flag_dep, rz_cons_dep, - rz_asm_dep, + rz_arch_dep, rz_debug_dep, rz_config_dep, rz_bp_dep, rz_reg_dep, rz_syscall_dep, rz_type_dep, - rz_analysis_dep, rz_parse_dep, rz_egg_dep, rz_search_dep, diff --git a/test/unit/meson.build b/test/unit/meson.build index ed7ac4c7653..b558be36973 100644 --- a/test/unit/meson.build +++ b/test/unit/meson.build @@ -131,14 +131,13 @@ if get_option('enable_tests') rz_bin_dep, rz_flag_dep, rz_cons_dep, - rz_asm_dep, + rz_arch_dep, rz_debug_dep, rz_config_dep, rz_bp_dep, rz_reg_dep, rz_syscall_dep, rz_type_dep, - rz_analysis_dep, rz_parse_dep, rz_egg_dep, rz_search_dep,