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/analysis.c b/librz/arch/analysis.c index 4b80a007adb..f80cffd44a0 100644 --- a/librz/arch/analysis.c +++ b/librz/arch/analysis.c @@ -6,12 +6,8 @@ #include #include #include +#include #include -#include - -RZ_LIB_VERSION(rz_analysis); - -static RzAnalysisPlugin *analysis_static_plugins[] = { RZ_ANALYSIS_STATIC_PLUGINS }; /** * \brief Returns the default size byte width of memory access operations. @@ -76,7 +72,6 @@ static void global_kv_free(HtPPKv *kv) { } RZ_API RzAnalysis *rz_analysis_new(void) { - int i; RzAnalysis *analysis = RZ_NEW0(RzAnalysis); if (!analysis) { return NULL; @@ -129,8 +124,13 @@ RZ_API RzAnalysis *rz_analysis_new(void) { rz_analysis_set_bits(analysis, 32); 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]); + const size_t n_plugins = rz_arch_get_n_plugins(); + for (size_t i = 0; i < n_plugins; i++) { + RzAnalysisPlugin *plugin = rz_arch_get_analysis_plugin(i); + if (!plugin) { + continue; + } + rz_analysis_plugin_add(analysis, plugin); } } analysis->ht_global_var = ht_pp_new(NULL, global_kv_free, NULL); diff --git a/librz/arch/arch-asm/i4004/i4004dis.c b/librz/arch/arch-asm/i4004/i4004dis.c deleted file mode 100644 index ecec65f73d7..00000000000 --- a/librz/arch/arch-asm/i4004/i4004dis.c +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-FileCopyrightText: 2014-2018 condret -// SPDX-FileCopyrightText: 2014-2018 pancake -// SPDX-License-Identifier: LGPL-3.0-only - -#include -#include -#include -#include - -/* 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", - "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 i4004dis(RzAsmOp *op, const ut8 *buf, int len) { - int rlen = i4004_get_ins_len(*buf); - ut8 high = (*buf & 0xf0) >> 4; - ut8 low = (*buf & 0xf); - if (rlen > len) { - return op->size = 0; - } - switch (high) { - case 0: rz_asm_op_set_asm(op, low ? "invalid" : "nop"); break; - case 1: rz_asm_op_setf_asm(op, "jcn %d 0x%02x", low, buf[1]); break; - case 2: - if (rlen == 1) { - rz_asm_op_setf_asm(op, "src r%d", (low & 0xe)); - } else { - rz_asm_op_setf_asm(op, "fim r%d, 0x%02x", (low & 0xe), buf[1]); - } - break; - case 3: - if ((low & 1) == 1) { - rz_asm_op_setf_asm(op, "jin r%d", (low & 0xe)); - } else { - rz_asm_op_setf_asm(op, "fin r%d", (low & 0xe)); - } - break; - case 4: rz_asm_op_setf_asm(op, "jun 0x%03x", ((ut16)(low << 8) | buf[1])); break; - case 5: rz_asm_op_setf_asm(op, "jms 0x%03x", ((ut16)(low << 8) | buf[1])); break; - case 6: rz_asm_op_setf_asm(op, "inc r%d", low); break; - case 7: rz_asm_op_setf_asm(op, "isz r%d, 0x%02x", low, buf[1]); break; - case 8: rz_asm_op_setf_asm(op, "add r%d", low); break; - case 9: rz_asm_op_setf_asm(op, "sub r%d", low); break; - case 10: rz_asm_op_setf_asm(op, "ld r%d", low); break; - case 11: rz_asm_op_setf_asm(op, "xch r%d", low); break; - case 12: rz_asm_op_setf_asm(op, "bbl %d", low); break; - case 13: rz_asm_op_setf_asm(op, "ldm %d", low); break; - case 14: rz_asm_op_set_asm(op, i4004_e[low]); break; - case 15: rz_asm_op_set_asm(op, i4004_f[low]); break; - default: rz_asm_op_set_asm(op, "invalid"); break; - } - return op->size = rlen; -} diff --git a/librz/arch/arch-asm/i8080/i8080dis.c b/librz/arch/arch-asm/i8080/i8080dis.c deleted file mode 100644 index a69f146e1c4..00000000000 --- a/librz/arch/arch-asm/i8080/i8080dis.c +++ /dev/null @@ -1,147 +0,0 @@ -// SPDX-FileCopyrightText: 2012 Alexander Demin -// SPDX-License-Identifier: MIT - -// This file is part of Radio-86RK Tools project. -// -// Intel 8080 disassembler. -// -// https://github.com/begoon/rk86-tools -// -// Copyright (C) 2012 Alexander Demin -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files -// (the "Software"), to deal in the Software without restriction, -// including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, -// and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#include -#include -#include - -static char *reg[] = { "b", "c", "d", "e", "h", "l", "m", "a" }; -static char *rp[] = { "b", "d", "h", "sp" }; -static char *push_rp[] = { "b", "d", "h", "psw" }; -static char *cond[] = { "nz", "z", "nc", "c", "po", "pe", "p", "m" }; -static char *rst[] = { "0", "1", "2", "3", "4", "5", "6", "7" }; - -struct arg_t { - int type; /* 1 - next byte, 2 - next word, 3 - in opcode */ - int shift; - int mask; - char **fmt; -}; - -static struct opcode_t { - unsigned char cmd; - int size; - char *name; - struct arg_t arg1, arg2; -} opcodes[] = { - { 0x76, 1, "hlt" }, - { 0x06, 2, "mvi", { 3, 3, 7, reg }, { 1 } }, - { 0xc3, 3, "jmp", { 2 } }, - { 0x40, 1, "mov", { 3, 3, 7, reg }, { 3, 0, 7, reg } }, - { 0x01, 3, "lxi", { 3, 4, 3, rp }, { 2 } }, - { 0x32, 3, "sta", { 2 } }, - { 0x3a, 3, "lda", { 2 } }, - { 0x2a, 3, "lhld", { 2 } }, - { 0x22, 3, "shld", { 2 } }, - { 0x0a, 1, "ldax", { 3, 4, 1, rp } }, - { 0x02, 1, "stax", { 3, 4, 1, rp } }, - { 0xeb, 1, "xchg" }, - { 0xf9, 1, "sphl" }, - { 0xe3, 1, "xthl" }, - { 0xc5, 1, "push", { 3, 4, 3, push_rp } }, - { 0xc1, 1, "pop", { 3, 4, 3, push_rp } }, - { 0xdb, 2, "in", { 1 } }, - { 0xd3, 2, "out", { 1 } }, - { 0x03, 1, "inx", { 3, 4, 3, rp } }, - { 0x0b, 1, "dcx", { 3, 4, 3, rp } }, - { 0x04, 1, "inr", { 3, 3, 7, reg } }, - { 0x05, 1, "dcr", { 3, 3, 7, reg } }, - { 0x09, 1, "dad", { 3, 4, 3, rp } }, - { 0x2f, 1, "cma" }, - { 0x07, 1, "rlc" }, - { 0x0f, 1, "rrc" }, - { 0x17, 1, "ral" }, - { 0x1f, 1, "rar" }, - { 0xfb, 1, "ei" }, - { 0xf3, 1, "di" }, - { 0x00, 1, "nop" }, - { 0x37, 1, "stc" }, - { 0x3f, 1, "cmc" }, - { 0xe9, 1, "pchl" }, - { 0x27, 1, "daa" }, - { 0xcd, 3, "call", { 2 } }, - { 0xc9, 1, "ret" }, - { 0xc7, 1, "rst", { 3, 3, 7, rst } }, - { 0xc0, 1, "r", { 3, 3, 7, cond } }, - { 0xc2, 3, "j", { 3, 3, 7, cond }, { 2 } }, - { 0xc4, 3, "c", { 3, 3, 7, cond }, { 2 } }, - { 0x80, 1, "add", { 3, 0, 7, reg } }, - { 0x80|0x46, 2, "adi", { 1 } }, - { 0x88, 1, "adc", { 3, 0, 7, reg } }, - { 0x88|0x46, 2, "aci", { 1 } }, - { 0x90, 1, "sub", { 3, 0, 7, reg } }, - { 0x90|0x46, 2, "sui", { 1 } }, - { 0x98, 1, "sbb", { 3, 0, 7, reg } }, - { 0x98|0x46, 2, "sbi", { 1 } }, - { 0xa0, 1, "ana", { 3, 0, 7, reg } }, - { 0xa0|0x46, 2, "ani", { 1 } }, - { 0xa8, 1, "xra", { 3, 0, 7, reg } }, - { 0xa8|0x46, 2, "xri", { 1 } }, - { 0xb0, 1, "ora", { 3, 0, 7, reg } }, - { 0xb0|0x46, 2, "ori", { 1 } }, - { 0xb8, 1, "cmp", { 3, 0, 7, reg } }, - { 0xb8|0x46, 2, "cpi", { 1 } }, - { 0x00, 1, "nop" }, - { 0x00, 0 } -}; - -static void arg(char* s, int const cmd, struct arg_t const* arg, int val) { - if (arg->type == 3) { - strcat(s, arg->fmt[(cmd >> arg->shift) & arg->mask]); - } else { - if (arg->type == 1) - sprintf(s, "%02X", val & 0xff); - else if (arg->type == 2) - sprintf(s, "%04X", val); - } -} - -static int i8080_disasm(unsigned char const* const code, char* text, int text_sz) { - int const cmd = code[0]; - int const p = code[1] | (code[2] << 8); - - struct opcode_t const *op; - for (op = &opcodes[0]; op->size; ++op) { - int const grp = cmd & - ~((op->arg1.mask << op->arg1.shift) | - (op->arg2.mask << op->arg2.shift)); - int const branch = (grp == 0xc0 || grp == 0xc2 || grp == 0xc4); - if (grp == op->cmd) { - strcpy(text, op->name); - if (!branch) strcat(text, " "); - arg(text + strlen(text), cmd, &op->arg1, p); - if (op->arg2.type != 0) strcat(text, (branch ? " " : ", ")); - arg(text + strlen(text), cmd, &op->arg2, p); - return op->size; - } - } - snprintf(text, text_sz, "db @ 0x%02x", cmd); - return 1; -} diff --git a/librz/arch/arch-asm/riscv/riscv.c b/librz/arch/arch-asm/riscv/riscv.c deleted file mode 100644 index 9cfb53313b2..00000000000 --- a/librz/arch/arch-asm/riscv/riscv.c +++ /dev/null @@ -1,334 +0,0 @@ -// SPDX-FileCopyrightText: 2011-2015 Free Software Foundation, Inc. -// SPDX-License-Identifier: GPL-3.0-or-later - -/* RISC-V disassembler - Copyright 2011-2015 Free Software Foundation, Inc. - Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. - Based on MIPS target. - This file is part of the GNU opcodes library. - This library is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - It is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING3. If not, - see . - - - Code changes to make r2 friendly (qnix@0x80.org) -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "riscv-opc.h" -#include "riscv.h" - -#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 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); -} - -/* Print insn arguments for 32/64-bit code. */ -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), " "); - } - - for (; *d != '\0'; d++) { - switch (*d) { - /* Xcustom */ - case '^': - switch (*++d) { - case 'd': - sprintf (buf+strlen (buf), "%d", rd); - break; - case 's': - sprintf (buf+strlen (buf), "%d", rs1); - break; - case 't': - sprintf (buf+strlen (buf), "%d", (int) EXTRACT_OPERAND (RS2, l)); - break; - case 'j': - sprintf (buf+strlen (buf), "%d", (int) EXTRACT_OPERAND (CUSTOM_IMM, l)); - break; - } - break; - - case 'C': /* RVC */ - 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]); - break; - case 't': /* RS2 x8-x15 */ - case 'x': /* RS2 x8-x15 */ - 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]); - break; - case 'c': /* RS1, constrained to equal 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)]); - break; - case 'i': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_SIMM3 (l)); - break; - case 'j': - sprintf (buf+strlen (buf), "%d", (int)EXTRACT_RVC_IMM (l)); - break; - case 'k': - 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)); - break; - case 'm': - 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)); - break; - case 'K': - 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)); - break; - case 'M': - 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)); - break; - case 'p': - 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); - break; - case 'u': - 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); - break; - case '<': - 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)]); - break; - case 'D': /* floating-point RS2 x8-x15 */ - sprintf (buf+strlen (buf), "%s", - riscv_fpr_names[EXTRACT_OPERAND (CRS2S, l) + 8]); - break; - } - break; - - case ',': - sprintf (buf+strlen (buf), "%c ", *d); - break; - case '(': - case ')': - case '[': - case ']': - 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"); - } - break; - - case 'b': - case 's': - sprintf (buf+strlen (buf), "%s", riscv_gpr_names[rs1]); - break; - - case 't': - 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); - break; - - case 'm': - 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)); - break; - - case 'Q': - 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)); - break; - case 'q': - 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); - break; - case 'p': - 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]); - break; - case 'z': - sprintf (buf+strlen (buf), "%s", riscv_gpr_names[0]); - break; - case '>': - sprintf (buf+strlen (buf), "0x%x", (int) EXTRACT_OPERAND (SHAMT, l)); - break; - case '<': - 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]); - break; - case 'T': - sprintf (buf+strlen (buf), "%s", riscv_fpr_names[EXTRACT_OPERAND (RS2, l)]); - break; - case 'D': - sprintf (buf+strlen (buf), "%s", riscv_fpr_names[rd]); - break; - case 'R': - 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; -#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; - } - case 'Z': - sprintf (buf+strlen (buf), "%d", rs1); - break; - default: - /* xgettext:c-format */ - sprintf (buf+strlen (buf), "# internal error, undefined modifier (%c)", - *d); - return; - } - } -} - -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}; - -#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; - } - } - init = 1; - } - - 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); - if (!op) { - return -1; - } - for (; op < &riscv_opcodes[NUMOPCODES]; op++) { - 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 ) { - 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); - return 0; - } - rz_asm_op_setf_asm (rop, "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}; - if (len < 2) { - return -1; - } - // Read <= 8 bytes into 8-byte buffer in little endian fashion - RZ_STATIC_ASSERT(sizeof(insn) == 8); - ut8 tmp[8] = { 0 }; - memcpy(&tmp, buf, RZ_MIN(sizeof(insn), len)); - insn = rz_read_le64(tmp); - int insn_len = riscv_insn_length(insn); - if (len < insn_len) { - return -1; - } - riscv_disassemble (a, rop, insn, a->bits, len); - return insn_len; -} diff --git a/librz/arch/arch.c b/librz/arch/arch.c new file mode 100644 index 00000000000..fd5b398d043 --- /dev/null +++ b/librz/arch/arch.c @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include +#include + +#include "rz_arch_plugins.h" + +RZ_LIB_VERSION(rz_arch); + +static RzArchPlugin *arch_static_plugins[] = { RZ_ARCH_STATIC_PLUGINS }; + +RZ_DEPRECATE RZ_API const size_t rz_arch_get_n_plugins() { + return RZ_ARRAY_SIZE(arch_static_plugins); +} + +RZ_DEPRECATE RZ_API RZ_BORROW RzAsmPlugin *rz_arch_get_asm_plugin(size_t index) { + if (index >= RZ_ARRAY_SIZE(arch_static_plugins)) { + return NULL; + } + return arch_static_plugins[index]->p_asm; +} + +RZ_DEPRECATE RZ_API RZ_BORROW RzAnalysisPlugin *rz_arch_get_analysis_plugin(size_t index) { + if (index >= RZ_ARRAY_SIZE(arch_static_plugins)) { + return NULL; + } + return arch_static_plugins[index]->p_analysis; +} diff --git a/librz/arch/asm.c b/librz/arch/asm.c index 956abfc5a96..cbd4e316265 100644 --- a/librz/arch/asm.c +++ b/librz/arch/asm.c @@ -16,9 +16,6 @@ #include #define USE_R2 1 #include -#include - -RZ_LIB_VERSION(rz_asm); /** * \brief Checks if the first character of \p c is a digit character @@ -111,8 +108,6 @@ static char *directives[] = { ".else", ".set", ".get", NULL }; -static RzAsmPlugin *asm_static_plugins[] = { RZ_ASM_STATIC_PLUGINS }; - static void parseHeap(RzParse *p, RzStrBuf *s) { char *op_buf_asm = rz_strbuf_get(s); char *out = rz_parse_pseudocode(p, op_buf_asm); @@ -280,7 +275,6 @@ static void plugin_fini(RzAsm *a) { } RZ_API RzAsm *rz_asm_new(void) { - int i; RzAsm *a = RZ_NEW0(RzAsm); if (!a) { return NULL; @@ -294,8 +288,14 @@ RZ_API RzAsm *rz_asm_new(void) { free(a); return NULL; } - for (i = 0; i < RZ_ARRAY_SIZE(asm_static_plugins); i++) { - rz_asm_plugin_add(a, asm_static_plugins[i]); + + const size_t n_plugins = rz_arch_get_n_plugins(); + for (size_t i = 0; i < n_plugins; i++) { + RzAsmPlugin *plugin = rz_arch_get_asm_plugin(i); + if (!plugin) { + continue; + } + rz_asm_plugin_add(a, plugin); } return a; } diff --git a/librz/arch/cpus-asm/avr-ATTiny48.sdb.txt b/librz/arch/cpus/avr-ATTiny48.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATTiny48.sdb.txt rename to librz/arch/cpus/avr-ATTiny48.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATTiny88.sdb.txt b/librz/arch/cpus/avr-ATTiny88.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATTiny88.sdb.txt rename to librz/arch/cpus/avr-ATTiny88.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATmega1280.sdb.txt b/librz/arch/cpus/avr-ATmega1280.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATmega1280.sdb.txt rename to librz/arch/cpus/avr-ATmega1280.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATmega1281.sdb.txt b/librz/arch/cpus/avr-ATmega1281.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATmega1281.sdb.txt rename to librz/arch/cpus/avr-ATmega1281.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATmega16.sdb.txt b/librz/arch/cpus/avr-ATmega16.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATmega16.sdb.txt rename to librz/arch/cpus/avr-ATmega16.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATmega168.sdb.txt b/librz/arch/cpus/avr-ATmega168.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATmega168.sdb.txt rename to librz/arch/cpus/avr-ATmega168.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATmega2560.sdb.txt b/librz/arch/cpus/avr-ATmega2560.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATmega2560.sdb.txt rename to librz/arch/cpus/avr-ATmega2560.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATmega2561.sdb.txt b/librz/arch/cpus/avr-ATmega2561.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATmega2561.sdb.txt rename to librz/arch/cpus/avr-ATmega2561.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATmega640.sdb.txt b/librz/arch/cpus/avr-ATmega640.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATmega640.sdb.txt rename to librz/arch/cpus/avr-ATmega640.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATmega8.sdb.txt b/librz/arch/cpus/avr-ATmega8.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATmega8.sdb.txt rename to librz/arch/cpus/avr-ATmega8.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATmega88.sdb.txt b/librz/arch/cpus/avr-ATmega88.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATmega88.sdb.txt rename to librz/arch/cpus/avr-ATmega88.sdb.txt diff --git a/librz/arch/cpus-asm/avr-ATxmega128a4u.sdb.txt b/librz/arch/cpus/avr-ATxmega128a4u.sdb.txt similarity index 100% rename from librz/arch/cpus-asm/avr-ATxmega128a4u.sdb.txt rename to librz/arch/cpus/avr-ATxmega128a4u.sdb.txt diff --git a/librz/arch/cpus-asm/meson.build b/librz/arch/cpus/meson.build similarity index 91% rename from librz/arch/cpus-asm/meson.build rename to librz/arch/cpus/meson.build index 587de63ed36..e7d8bbb0299 100644 --- a/librz/arch/cpus-asm/meson.build +++ b/librz/arch/cpus/meson.build @@ -1,4 +1,4 @@ -sdb_files = [ +sdb_cpus_files = [ 'avr-ATmega1280', 'avr-ATmega1281', 'avr-ATxmega128a4u', @@ -13,7 +13,7 @@ sdb_files = [ 'avr-ATTiny88', ] -foreach file : sdb_files +foreach file : sdb_cpus_files outfile = '@0@.sdb'.format(file) custom_target(outfile, input: '@0@.sdb.txt'.format(file), diff --git a/librz/arch/deprecated_arch_helper.h b/librz/arch/deprecated_arch_helper.h new file mode 100644 index 00000000000..aaebd189184 --- /dev/null +++ b/librz/arch/deprecated_arch_helper.h @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef DEPRECATED_ARCH_HELPER_H +#define DEPRECATED_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_ARCH, \ + .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 /* DEPRECATED_ARCH_HELPER_H */ \ No newline at end of file diff --git a/librz/arch/dwarf_process.c b/librz/arch/dwarf_process.c index cc52fa2cd48..0715d03e5dd 100644 --- a/librz/arch/dwarf_process.c +++ b/librz/arch/dwarf_process.c @@ -457,15 +457,15 @@ static const char *map_dwarf_reg_to_riscv_reg(ut32 reg_num) { #define KASE(_num, _reg) \ case _num: return #_reg; -#include "librz/analysis/arch/arm/arm_dwarf_regnum_table.h" -#include "hexagon_dwarf_reg_num_table.inc" -#include "librz/analysis/arch/ppc/ppc_dwarf_regnum_table.h" -#include "librz/analysis/arch/v850/v850_dwarf_reg_num_table.h" -#include "librz/analysis/arch/rl78/rl78_dwarf_reg.h" -#include "librz/analysis/arch/rx/rx_dwarf_regnum_table.h" -#include "librz/analysis/arch/sh/sh_dwarf_regnum_table.h" -#include "librz/analysis/arch/tricore/tricore_dwarf_regnum_table.h" -#include "librz/analysis/arch/x86/x86_dwarf_regnum_table.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include /** * \brief Returns a function that maps a DWARF register number to a register name diff --git a/librz/arch/esil-analysis/esil.c b/librz/arch/esil/esil.c similarity index 100% rename from librz/arch/esil-analysis/esil.c rename to librz/arch/esil/esil.c diff --git a/librz/arch/esil-analysis/esil_interrupt.c b/librz/arch/esil/esil_interrupt.c similarity index 100% rename from librz/arch/esil-analysis/esil_interrupt.c rename to librz/arch/esil/esil_interrupt.c diff --git a/librz/arch/esil-analysis/esil_sources.c b/librz/arch/esil/esil_sources.c similarity index 100% rename from librz/arch/esil-analysis/esil_sources.c rename to librz/arch/esil/esil_sources.c diff --git a/librz/arch/esil-analysis/esil_stats.c b/librz/arch/esil/esil_stats.c similarity index 100% rename from librz/arch/esil-analysis/esil_stats.c rename to librz/arch/esil/esil_stats.c diff --git a/librz/arch/esil-analysis/esil_trace.c b/librz/arch/esil/esil_trace.c similarity index 100% rename from librz/arch/esil-analysis/esil_trace.c rename to librz/arch/esil/esil_trace.c diff --git a/librz/arch/il-analysis/analysis_il.c b/librz/arch/il/analysis_il.c similarity index 100% rename from librz/arch/il-analysis/analysis_il.c rename to librz/arch/il/analysis_il.c diff --git a/librz/arch/il-analysis/analysis_il_trace.c b/librz/arch/il/analysis_il_trace.c similarity index 100% rename from librz/arch/il-analysis/analysis_il_trace.c rename to librz/arch/il/analysis_il_trace.c diff --git a/librz/arch/arch-asm/6502/6502_il.inc b/librz/arch/isa/6502/6502_il.inc similarity index 100% rename from librz/arch/arch-asm/6502/6502_il.inc rename to librz/arch/isa/6502/6502_il.inc diff --git a/librz/arch/arch-asm/6502/6502dis.c b/librz/arch/isa/6502/6502dis.c similarity index 97% rename from librz/arch/arch-asm/6502/6502dis.c rename to librz/arch/isa/6502/6502dis.c index 4721b37856e..0a447014cd3 100644 --- a/librz/arch/arch-asm/6502/6502dis.c +++ b/librz/arch/isa/6502/6502dis.c @@ -7,7 +7,7 @@ #include #include #include -#include "../snes/snesdis.c" +#include static struct { ut8 op; @@ -139,7 +139,7 @@ static struct { { -1, NULL, 0 } }; -static int _6502Disass(ut64 pc, RzAsmOp *op, const ut8 *buf, ut64 len) { +int disass_6502(ut64 pc, RzAsmOp *op, const ut8 *buf, ut64 len) { int i; for (i = 0; ops[i].name != NULL; i++) { if (ops[i].op == buf[0]) { diff --git a/librz/arch/isa/6502/6502dis.h b/librz/arch/isa/6502/6502dis.h new file mode 100644 index 00000000000..ecb657b9f4e --- /dev/null +++ b/librz/arch/isa/6502/6502dis.h @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef DISASSEMBLE_6502_H +#define DISASSEMBLE_6502_H + +#include + +int disass_6502(ut64 pc, RzAsmOp *op, const ut8 *buf, ut64 len); + +#endif /* DISASSEMBLE_6502_H */ diff --git a/librz/arch/arch-asm/8051/8051_ass.c b/librz/arch/isa/8051/8051_ass.c similarity index 100% rename from librz/arch/arch-asm/8051/8051_ass.c rename to librz/arch/isa/8051/8051_ass.c diff --git a/librz/arch/arch-asm/8051/8051_ass.h b/librz/arch/isa/8051/8051_ass.h similarity index 68% rename from librz/arch/arch-asm/8051/8051_ass.h rename to librz/arch/isa/8051/8051_ass.h index 2f53ca126c7..0c596827aa5 100644 --- a/librz/arch/arch-asm/8051/8051_ass.h +++ b/librz/arch/isa/8051/8051_ass.h @@ -1,10 +1,11 @@ // SPDX-FileCopyrightText: 2019 hmht // SPDX-License-Identifier: LGPL-3.0-only -#ifndef _8051_ASS_H -#define _8051_ASS_H +#ifndef ASSEMBLE_8051_H +#define ASSEMBLE_8051_H #include + int assemble_8051(RzAsm *a, RzAsmOp *op, char const *user_asm); -#endif +#endif /* ASSEMBLE_8051_H */ diff --git a/librz/arch/arch-asm/8051/8051_disas.c b/librz/arch/isa/8051/8051_disas.c similarity index 98% rename from librz/arch/arch-asm/8051/8051_disas.c rename to librz/arch/isa/8051/8051_disas.c index 346a5ff71a8..527f2b68147 100644 --- a/librz/arch/arch-asm/8051/8051_disas.c +++ b/librz/arch/isa/8051/8051_disas.c @@ -5,10 +5,10 @@ // SPDX-FileCopyrightText: 2015-2019 astuder // SPDX-License-Identifier: LGPL-3.0-only -#include #include #include +#include "8051_disas.h" #include "8051_ops.h" static const char *_8051_regs[] = { @@ -66,7 +66,7 @@ static char *_replace_register(char *disasm, ut8 arg, ut8 val) { return disasm; } -static char *rz_8051_disas(ut64 pc, const ut8 *buf, int len, int *olen) { +char *rz_8051_disas(ut64 pc, const ut8 *buf, int len, int *olen) { int i = 0; while (_8051_ops[i].string && _8051_ops[i].op != (buf[0] & ~_8051_ops[i].mask)) { i++; diff --git a/librz/arch/isa/8051/8051_disas.h b/librz/arch/isa/8051/8051_disas.h new file mode 100644 index 00000000000..bad63b6f953 --- /dev/null +++ b/librz/arch/isa/8051/8051_disas.h @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef DISASSEMBLE_8051_H +#define DISASSEMBLE_8051_H + +#include + +char *rz_8051_disas(ut64 pc, const ut8 *buf, int len, int *olen); + +#endif /* DISASSEMBLE_8051_H */ diff --git a/librz/arch/arch-analysis/8051/8051_il.c b/librz/arch/isa/8051/8051_il.c similarity index 100% rename from librz/arch/arch-analysis/8051/8051_il.c rename to librz/arch/isa/8051/8051_il.c diff --git a/librz/arch/arch-analysis/8051/8051_il.h b/librz/arch/isa/8051/8051_il.h similarity index 100% rename from librz/arch/arch-analysis/8051/8051_il.h rename to librz/arch/isa/8051/8051_il.h diff --git a/librz/arch/arch-asm/8051/8051_ops.h b/librz/arch/isa/8051/8051_ops.h similarity index 100% rename from librz/arch/arch-asm/8051/8051_ops.h rename to librz/arch/isa/8051/8051_ops.h diff --git a/librz/arch/arch-analysis/8051/8051_parse.c b/librz/arch/isa/8051/8051_parse.c similarity index 100% rename from librz/arch/arch-analysis/8051/8051_parse.c rename to librz/arch/isa/8051/8051_parse.c diff --git a/librz/arch/arch-asm/amd29k/amd29k.c b/librz/arch/isa/amd29k/amd29k.c similarity index 100% rename from librz/arch/arch-asm/amd29k/amd29k.c rename to librz/arch/isa/amd29k/amd29k.c diff --git a/librz/arch/arch-asm/amd29k/amd29k.h b/librz/arch/isa/amd29k/amd29k.h similarity index 100% rename from librz/arch/arch-asm/amd29k/amd29k.h rename to librz/arch/isa/amd29k/amd29k.h diff --git a/librz/arch/arch-asm/amd29k/amd29k_internal.h b/librz/arch/isa/amd29k/amd29k_internal.h similarity index 100% rename from librz/arch/arch-asm/amd29k/amd29k_internal.h rename to librz/arch/isa/amd29k/amd29k_internal.h diff --git a/librz/arch/arch-asm/arm/aarch64_meta_macros.h b/librz/arch/isa/arm/aarch64_meta_macros.h similarity index 100% rename from librz/arch/arch-asm/arm/aarch64_meta_macros.h rename to librz/arch/isa/arm/aarch64_meta_macros.h diff --git a/librz/arch/arch-analysis/arm/arm_accessors32.h b/librz/arch/isa/arm/arm_accessors32.h similarity index 100% rename from librz/arch/arch-analysis/arm/arm_accessors32.h rename to librz/arch/isa/arm/arm_accessors32.h diff --git a/librz/arch/arch-analysis/arm/arm_accessors64.h b/librz/arch/isa/arm/arm_accessors64.h similarity index 100% rename from librz/arch/arch-analysis/arm/arm_accessors64.h rename to librz/arch/isa/arm/arm_accessors64.h diff --git a/librz/arch/arch-analysis/arm/arm_cs.h b/librz/arch/isa/arm/arm_cs.h similarity index 96% rename from librz/arch/arch-analysis/arm/arm_cs.h rename to librz/arch/isa/arm/arm_cs.h index 44159459fa0..a2c55eb8f86 100644 --- a/librz/arch/arch-analysis/arm/arm_cs.h +++ b/librz/arch/isa/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-analysis/arm/arm_dwarf_regnum_table.h b/librz/arch/isa/arm/arm_dwarf_regnum_table.h similarity index 100% rename from librz/arch/arch-analysis/arm/arm_dwarf_regnum_table.h rename to librz/arch/isa/arm/arm_dwarf_regnum_table.h diff --git a/librz/arch/arch-analysis/arm/arm_esil32.c b/librz/arch/isa/arm/arm_esil32.c similarity index 100% rename from librz/arch/arch-analysis/arm/arm_esil32.c rename to librz/arch/isa/arm/arm_esil32.c diff --git a/librz/arch/arch-analysis/arm/arm_esil64.c b/librz/arch/isa/arm/arm_esil64.c similarity index 100% rename from librz/arch/arch-analysis/arm/arm_esil64.c rename to librz/arch/isa/arm/arm_esil64.c diff --git a/librz/arch/arch-analysis/arm/arm_il32.c b/librz/arch/isa/arm/arm_il32.c similarity index 100% rename from librz/arch/arch-analysis/arm/arm_il32.c rename to librz/arch/isa/arm/arm_il32.c diff --git a/librz/arch/arch-analysis/arm/arm_il64.c b/librz/arch/isa/arm/arm_il64.c similarity index 100% rename from librz/arch/arch-analysis/arm/arm_il64.c rename to librz/arch/isa/arm/arm_il64.c diff --git a/librz/arch/arch-analysis/arm/arm_il_common.inc b/librz/arch/isa/arm/arm_il_common.inc similarity index 100% rename from librz/arch/arch-analysis/arm/arm_il_common.inc rename to librz/arch/isa/arm/arm_il_common.inc diff --git a/librz/arch/arch-asm/arm/arm_it.c b/librz/arch/isa/arm/arm_it.c similarity index 100% rename from librz/arch/arch-asm/arm/arm_it.c rename to librz/arch/isa/arm/arm_it.c diff --git a/librz/arch/arch-asm/arm/arm_it.h b/librz/arch/isa/arm/arm_it.h similarity index 95% rename from librz/arch/arch-asm/arm/arm_it.h rename to librz/arch/isa/arm/arm_it.h index 183d6efa42d..f9df235d7ed 100644 --- a/librz/arch/arch-asm/arm/arm_it.h +++ b/librz/arch/isa/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 @@ -25,4 +26,4 @@ RZ_API void rz_arm_it_update_block(RzArmITContext *ctx, cs_insn *insn); RZ_API void rz_arm_it_update_nonblock(RzArmITContext *ctx, cs_insn *insn); RZ_API bool rz_arm_it_apply_cond(RzArmITContext *ctx, cs_insn *insn); -#endif +#endif /* RZ_ARM_IT_H */ diff --git a/librz/arch/arch-asm/arm/armass.c b/librz/arch/isa/arm/armass.c similarity index 100% rename from librz/arch/arch-asm/arm/armass.c rename to librz/arch/isa/arm/armass.c diff --git a/librz/arch/arch-asm/arm/armass16_const.h b/librz/arch/isa/arm/armass16_const.h similarity index 100% rename from librz/arch/arch-asm/arm/armass16_const.h rename to librz/arch/isa/arm/armass16_const.h diff --git a/librz/arch/arch-asm/arm/armass64.c b/librz/arch/isa/arm/armass64.c similarity index 100% rename from librz/arch/arch-asm/arm/armass64.c rename to librz/arch/isa/arm/armass64.c diff --git a/librz/arch/arch-asm/arm/armass64_const.h b/librz/arch/isa/arm/armass64_const.h similarity index 100% rename from librz/arch/arch-asm/arm/armass64_const.h rename to librz/arch/isa/arm/armass64_const.h diff --git a/librz/arch/arch-asm/arm/asm-arm.h b/librz/arch/isa/arm/asm-arm.h similarity index 85% rename from librz/arch/arch-asm/arm/asm-arm.h rename to librz/arch/isa/arm/asm-arm.h index 7ee8d8267e1..1cd11e600fb 100644 --- a/librz/arch/arch-asm/arm/asm-arm.h +++ b/librz/arch/isa/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-asm/avr/assembler.c b/librz/arch/isa/avr/assembler.c similarity index 100% rename from librz/arch/arch-asm/avr/assembler.c rename to librz/arch/isa/avr/assembler.c diff --git a/librz/arch/arch-asm/avr/assembler.h b/librz/arch/isa/avr/assembler.h similarity index 100% rename from librz/arch/arch-asm/avr/assembler.h rename to librz/arch/isa/avr/assembler.h diff --git a/librz/arch/arch-analysis/avr/avr_esil.c b/librz/arch/isa/avr/avr_esil.c similarity index 100% rename from librz/arch/arch-analysis/avr/avr_esil.c rename to librz/arch/isa/avr/avr_esil.c diff --git a/librz/arch/arch-analysis/avr/avr_esil.h b/librz/arch/isa/avr/avr_esil.h similarity index 100% rename from librz/arch/arch-analysis/avr/avr_esil.h rename to librz/arch/isa/avr/avr_esil.h diff --git a/librz/arch/arch-analysis/avr/avr_il.c b/librz/arch/isa/avr/avr_il.c similarity index 100% rename from librz/arch/arch-analysis/avr/avr_il.c rename to librz/arch/isa/avr/avr_il.c diff --git a/librz/arch/arch-analysis/avr/avr_il.h b/librz/arch/isa/avr/avr_il.h similarity index 90% rename from librz/arch/arch-analysis/avr/avr_il.h rename to librz/arch/isa/avr/avr_il.h index 9f71da15ed1..ad7313b2cf8 100644 --- a/librz/arch/arch-analysis/avr/avr_il.h +++ b/librz/arch/isa/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-asm/avr/common.h b/librz/arch/isa/avr/common.h similarity index 100% rename from librz/arch/arch-asm/avr/common.h rename to librz/arch/isa/avr/common.h diff --git a/librz/arch/arch-asm/avr/disassembler.c b/librz/arch/isa/avr/disassembler.c similarity index 100% rename from librz/arch/arch-asm/avr/disassembler.c rename to librz/arch/isa/avr/disassembler.c diff --git a/librz/arch/arch-asm/avr/disassembler.h b/librz/arch/isa/avr/disassembler.h similarity index 100% rename from librz/arch/arch-asm/avr/disassembler.h rename to librz/arch/isa/avr/disassembler.h diff --git a/librz/arch/arch-asm/cil/cil_dis.c b/librz/arch/isa/cil/cil_dis.c similarity index 100% rename from librz/arch/arch-asm/cil/cil_dis.c rename to librz/arch/isa/cil/cil_dis.c diff --git a/librz/arch/arch-asm/cil/cil_dis.h b/librz/arch/isa/cil/cil_dis.h similarity index 100% rename from librz/arch/arch-asm/cil/cil_dis.h rename to librz/arch/isa/cil/cil_dis.h diff --git a/librz/arch/arch-asm/cil/opcode.def b/librz/arch/isa/cil/opcode.def similarity index 100% rename from librz/arch/arch-asm/cil/opcode.def rename to librz/arch/isa/cil/opcode.def diff --git a/librz/arch/arch-asm/cil/opcodes_double.def b/librz/arch/isa/cil/opcodes_double.def similarity index 100% rename from librz/arch/arch-asm/cil/opcodes_double.def rename to librz/arch/isa/cil/opcodes_double.def diff --git a/librz/arch/arch-asm/cil/opcodes_prefix.def b/librz/arch/isa/cil/opcodes_prefix.def similarity index 100% rename from librz/arch/arch-asm/cil/opcodes_prefix.def rename to librz/arch/isa/cil/opcodes_prefix.def diff --git a/librz/arch/arch-asm/cil/opcodes_single.def b/librz/arch/isa/cil/opcodes_single.def similarity index 100% rename from librz/arch/arch-asm/cil/opcodes_single.def rename to librz/arch/isa/cil/opcodes_single.def diff --git a/librz/arch/arch-asm/cr16/cr16_disas.c b/librz/arch/isa/cr16/cr16_disas.c similarity index 100% rename from librz/arch/arch-asm/cr16/cr16_disas.c rename to librz/arch/isa/cr16/cr16_disas.c diff --git a/librz/arch/arch-asm/cr16/cr16_disas.h b/librz/arch/isa/cr16/cr16_disas.h similarity index 100% rename from librz/arch/arch-asm/cr16/cr16_disas.h rename to librz/arch/isa/cr16/cr16_disas.h diff --git a/librz/arch/arch-asm/dalvik/opcode.h b/librz/arch/isa/dalvik/opcode.h similarity index 100% rename from librz/arch/arch-asm/dalvik/opcode.h rename to librz/arch/isa/dalvik/opcode.h diff --git a/librz/arch/arch-asm/dcpu16/asm.c b/librz/arch/isa/dcpu16/asm.c similarity index 100% rename from librz/arch/arch-asm/dcpu16/asm.c rename to librz/arch/isa/dcpu16/asm.c diff --git a/librz/arch/arch-asm/dcpu16/dcpu16.h b/librz/arch/isa/dcpu16/dcpu16.h similarity index 100% rename from librz/arch/arch-asm/dcpu16/dcpu16.h rename to librz/arch/isa/dcpu16/dcpu16.h diff --git a/librz/arch/arch-asm/dcpu16/dis.c b/librz/arch/isa/dcpu16/dis.c similarity index 99% rename from librz/arch/arch-asm/dcpu16/dis.c rename to librz/arch/isa/dcpu16/dis.c index 7695b9234b1..24ce251244c 100644 --- a/librz/arch/arch-asm/dcpu16/dis.c +++ b/librz/arch/isa/dcpu16/dis.c @@ -7,6 +7,7 @@ #include #include +#include #include "dcpu16.h" struct op_code { diff --git a/librz/arch/arch-asm/ebc/ebc_disas.c b/librz/arch/isa/ebc/ebc_disas.c similarity index 100% rename from librz/arch/arch-asm/ebc/ebc_disas.c rename to librz/arch/isa/ebc/ebc_disas.c diff --git a/librz/arch/arch-asm/ebc/ebc_disas.h b/librz/arch/isa/ebc/ebc_disas.h similarity index 100% rename from librz/arch/arch-asm/ebc/ebc_disas.h rename to librz/arch/isa/ebc/ebc_disas.h diff --git a/librz/arch/arch-analysis/gb/gb.h b/librz/arch/isa/gb/gb.h similarity index 87% rename from librz/arch/arch-analysis/gb/gb.h rename to librz/arch/isa/gb/gb.h index 4e6509867f3..e4fbe60a575 100644 --- a/librz/arch/arch-analysis/gb/gb.h +++ b/librz/arch/isa/gb/gb.h @@ -4,6 +4,7 @@ #ifndef GB_H #define GB_H #include +#include typedef struct gb_user_t { ut8 mbc_id; @@ -66,4 +67,7 @@ enum { RAM8K, RAM32K }; + +int gbDisass(RzAsmOp *op, const ut8 *buf, int len); +int gbAsm(RzAsm *a, RzAsmOp *op, const char *buf); #endif diff --git a/librz/arch/arch-analysis/gb/gb_il.inc b/librz/arch/isa/gb/gb_il.inc similarity index 100% rename from librz/arch/arch-analysis/gb/gb_il.inc rename to librz/arch/isa/gb/gb_il.inc diff --git a/librz/arch/arch-analysis/gb/gb_makros.h b/librz/arch/isa/gb/gb_makros.h similarity index 100% rename from librz/arch/arch-analysis/gb/gb_makros.h rename to librz/arch/isa/gb/gb_makros.h diff --git a/librz/arch/arch-asm/gb/gb_op_table.h b/librz/arch/isa/gb/gb_op_table.h similarity index 100% rename from librz/arch/arch-asm/gb/gb_op_table.h rename to librz/arch/isa/gb/gb_op_table.h diff --git a/librz/arch/arch-asm/gb/gbasm.c b/librz/arch/isa/gb/gbasm.c similarity index 99% rename from librz/arch/arch-asm/gb/gbasm.c rename to librz/arch/isa/gb/gbasm.c index 53f76aff784..ef00462958a 100644 --- a/librz/arch/arch-asm/gb/gbasm.c +++ b/librz/arch/isa/gb/gbasm.c @@ -203,7 +203,7 @@ static bool gb_parse_ld3(ut8 *buf, char *buf_asm) { return true; } -static int gbAsm(RzAsm *a, RzAsmOp *op, const char *buf) { +int gbAsm(RzAsm *a, RzAsmOp *op, const char *buf) { int mn_len, j, len = 1; ut32 mn = 0; ut64 num; diff --git a/librz/arch/arch-asm/gb/gbdis.c b/librz/arch/isa/gb/gbdis.c similarity index 98% rename from librz/arch/arch-asm/gb/gbdis.c rename to librz/arch/isa/gb/gbdis.c index 86ddf07aa04..6278f314de4 100644 --- a/librz/arch/arch-asm/gb/gbdis.c +++ b/librz/arch/isa/gb/gbdis.c @@ -150,8 +150,7 @@ 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 gbDisass(RzAsmOp *op, const ut8 *buf, int len) { int foo = gbOpLength(gb_op[buf[0]].type); if (len < foo) { return 0; @@ -181,4 +180,3 @@ static int gbDisass(RzAsmOp *op, const ut8 *buf, int len) { } return foo; } -#endif diff --git a/librz/arch/arch-analysis/gb/meta_gb_cmt.c b/librz/arch/isa/gb/meta_gb_cmt.c similarity index 100% rename from librz/arch/arch-analysis/gb/meta_gb_cmt.c rename to librz/arch/isa/gb/meta_gb_cmt.c diff --git a/librz/arch/arch-asm/h8300/h8300_disas.c b/librz/arch/isa/h8300/h8300_disas.c similarity index 100% rename from librz/arch/arch-asm/h8300/h8300_disas.c rename to librz/arch/isa/h8300/h8300_disas.c diff --git a/librz/arch/arch-asm/h8300/h8300_disas.h b/librz/arch/isa/h8300/h8300_disas.h similarity index 100% rename from librz/arch/arch-asm/h8300/h8300_disas.h rename to librz/arch/isa/h8300/h8300_disas.h diff --git a/librz/arch/arch-asm/hexagon/hexagon.c b/librz/arch/isa/hexagon/hexagon.c similarity index 100% rename from librz/arch/arch-asm/hexagon/hexagon.c rename to librz/arch/isa/hexagon/hexagon.c diff --git a/librz/arch/arch-asm/hexagon/hexagon.h b/librz/arch/isa/hexagon/hexagon.h similarity index 100% rename from librz/arch/arch-asm/hexagon/hexagon.h rename to librz/arch/isa/hexagon/hexagon.h diff --git a/librz/arch/arch-asm/hexagon/hexagon_arch.c b/librz/arch/isa/hexagon/hexagon_arch.c similarity index 100% rename from librz/arch/arch-asm/hexagon/hexagon_arch.c rename to librz/arch/isa/hexagon/hexagon_arch.c diff --git a/librz/arch/arch-asm/hexagon/hexagon_arch.h b/librz/arch/isa/hexagon/hexagon_arch.h similarity index 100% rename from librz/arch/arch-asm/hexagon/hexagon_arch.h rename to librz/arch/isa/hexagon/hexagon_arch.h diff --git a/librz/arch/arch-asm/hexagon/hexagon_disas.c b/librz/arch/isa/hexagon/hexagon_disas.c similarity index 100% rename from librz/arch/arch-asm/hexagon/hexagon_disas.c rename to librz/arch/isa/hexagon/hexagon_disas.c diff --git a/librz/arch/hexagon_dwarf_reg_num_table.inc b/librz/arch/isa/hexagon/hexagon_dwarf_reg_num_table.inc similarity index 100% rename from librz/arch/hexagon_dwarf_reg_num_table.inc rename to librz/arch/isa/hexagon/hexagon_dwarf_reg_num_table.inc diff --git a/librz/arch/arch-asm/hexagon/hexagon_insn.h b/librz/arch/isa/hexagon/hexagon_insn.h similarity index 100% rename from librz/arch/arch-asm/hexagon/hexagon_insn.h rename to librz/arch/isa/hexagon/hexagon_insn.h diff --git a/librz/arch/p-analysis/analysis_i4004.c b/librz/arch/isa/i4004/i4004dis.c similarity index 64% rename from librz/arch/p-analysis/analysis_i4004.c rename to librz/arch/isa/i4004/i4004dis.c index 7bc1ea778f2..7bae9291b15 100644 --- a/librz/arch/p-analysis/analysis_i4004.c +++ b/librz/arch/isa/i4004/i4004dis.c @@ -1,48 +1,13 @@ -// SPDX-FileCopyrightText: 2016-2020 pancake +// SPDX-FileCopyrightText: 2014-2018 condret +// SPDX-FileCopyrightText: 2014-2018 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include -#include -#include -#include #include -#include - -#define AVR_SOFTCAST(x, y) ((x) + ((y)*0x100)) +#include +#include +#include -static char *get_reg_profile(RzAnalysis *analysis) { - const char *p = - "=PC PC\n" - /* syntax not yet supported */ - // "=SP &PC1\n" - "=A0 r0\n" - "=A1 r1\n" - "=A2 r2\n" - "=A3 r3\n" - "=R0 r0\n" - "gpr r0 .4 0 0\n" - "gpr r1 .4 1 0\n" - "gpr r2 .4 2 0\n" - "gpr r3 .4 3 0\n" - "gpr r4 .4 4 0\n" - "gpr r5 .4 5 0\n" - "gpr r6 .4 6 0\n" - "gpr r7 .4 7 0\n" - "gpr r8 .4 8 0\n" - "gpr r9 .4 9 0\n" - "gpr r10 .4 10 0\n" - "gpr r11 .4 11 0\n" - "gpr r12 .4 12 0\n" - "gpr r13 .4 13 0\n" - "gpr r14 .4 14 0\n" - "gpr r15 .4 15 0\n" - "gpr PC .64 32 0\n" - /* stack */ - "gpr PC1 .64 34 0\n" - "gpr PC2 .64 34 0\n" - "gpr PC3 .64 34 0\n"; - return strdup(p); -} +#include "i4004dis.h" /* That 3 is a hack */ static const int i4004_ins_len[16] = { @@ -77,7 +42,7 @@ static const char *i4004_f[16] = { "ral", "rar", "tcc", - "dac", // decrement + "dac", "tcs", "stc", "daa", @@ -87,16 +52,56 @@ static const char *i4004_f[16] = { "invalid" }; -static int i4004_get_ins_len(ut8 hex) { +int i4004_get_ins_len(ut8 hex) { ut8 high = (hex & 0xf0) >> 4; int ret = i4004_ins_len[high]; - if (ret == 3) { + 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) { +int i4004dis(RzAsmOp *op, const ut8 *buf, int len) { + int rlen = i4004_get_ins_len(*buf); + ut8 high = (*buf & 0xf0) >> 4; + ut8 low = (*buf & 0xf); + if (rlen > len) { + return op->size = 0; + } + switch (high) { + case 0: rz_asm_op_set_asm(op, low ? "invalid" : "nop"); break; + case 1: rz_asm_op_setf_asm(op, "jcn %d 0x%02x", low, buf[1]); break; + case 2: + if (rlen == 1) { + rz_asm_op_setf_asm(op, "src r%d", (low & 0xe)); + } else { + rz_asm_op_setf_asm(op, "fim r%d, 0x%02x", (low & 0xe), buf[1]); + } + break; + case 3: + if ((low & 1) == 1) { + rz_asm_op_setf_asm(op, "jin r%d", (low & 0xe)); + } else { + rz_asm_op_setf_asm(op, "fin r%d", (low & 0xe)); + } + break; + case 4: rz_asm_op_setf_asm(op, "jun 0x%03x", ((ut16)(low << 8) | buf[1])); break; + case 5: rz_asm_op_setf_asm(op, "jms 0x%03x", ((ut16)(low << 8) | buf[1])); break; + case 6: rz_asm_op_setf_asm(op, "inc r%d", low); break; + case 7: rz_asm_op_setf_asm(op, "isz r%d, 0x%02x", low, buf[1]); break; + case 8: rz_asm_op_setf_asm(op, "add r%d", low); break; + case 9: rz_asm_op_setf_asm(op, "sub r%d", low); break; + case 10: rz_asm_op_setf_asm(op, "ld r%d", low); break; + case 11: rz_asm_op_setf_asm(op, "xch r%d", low); break; + case 12: rz_asm_op_setf_asm(op, "bbl %d", low); break; + case 13: rz_asm_op_setf_asm(op, "ldm %d", low); break; + case 14: rz_asm_op_set_asm(op, i4004_e[low]); break; + case 15: rz_asm_op_set_asm(op, i4004_f[low]); break; + default: rz_asm_op_set_asm(op, "invalid"); break; + } + return op->size = rlen; +} + +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; int rlen = i4004_get_ins_len(*buf); @@ -199,22 +204,3 @@ static int i4004_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 } return op->size = rlen; } - -RzAnalysisPlugin rz_analysis_plugin_i4004 = { - .name = "i4004", - .desc = "i4004 code analysis plugin", - .license = "LGPL3", - .arch = "i4004", - .esil = false, - .bits = 8, - .op = &i4004_op, - .get_reg_profile = &get_reg_profile -}; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_i4004, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/isa/i4004/i4004dis.h b/librz/arch/isa/i4004/i4004dis.h new file mode 100644 index 00000000000..2ab6007fccc --- /dev/null +++ b/librz/arch/isa/i4004/i4004dis.h @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef DISASSEMBLE_I4004_H +#define DISASSEMBLE_I4004_H + +#include +#include + +int i4004dis(RzAsmOp *op, const ut8 *buf, int len); +int i4004_get_ins_len(ut8 hex); +int i4004_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask); + +#endif /* DISASSEMBLE_I4004_H */ diff --git a/librz/arch/isa/i8080/i8080dis.c b/librz/arch/isa/i8080/i8080dis.c new file mode 100644 index 00000000000..fff9ac44463 --- /dev/null +++ b/librz/arch/isa/i8080/i8080dis.c @@ -0,0 +1,149 @@ +// SPDX-FileCopyrightText: 2012 Alexander Demin +// SPDX-License-Identifier: MIT + +// This file is part of Radio-86RK Tools project. +// +// Intel 8080 disassembler. +// +// https://github.com/begoon/rk86-tools +// +// Copyright (C) 2012 Alexander Demin +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files +// (the "Software"), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#include +#include +#include + +static char *reg[] = { "b", "c", "d", "e", "h", "l", "m", "a" }; +static char *rp[] = { "b", "d", "h", "sp" }; +static char *push_rp[] = { "b", "d", "h", "psw" }; +static char *cond[] = { "nz", "z", "nc", "c", "po", "pe", "p", "m" }; +static char *rst[] = { "0", "1", "2", "3", "4", "5", "6", "7" }; + +struct arg_t { + int type; /* 1 - next byte, 2 - next word, 3 - in opcode */ + int shift; + int mask; + char **fmt; +}; + +static struct opcode_t { + unsigned char cmd; + int size; + char *name; + struct arg_t arg1, arg2; +} opcodes[] = { + { 0x76, 1, "hlt" }, + { 0x06, 2, "mvi", { 3, 3, 7, reg }, { 1 } }, + { 0xc3, 3, "jmp", { 2 } }, + { 0x40, 1, "mov", { 3, 3, 7, reg }, { 3, 0, 7, reg } }, + { 0x01, 3, "lxi", { 3, 4, 3, rp }, { 2 } }, + { 0x32, 3, "sta", { 2 } }, + { 0x3a, 3, "lda", { 2 } }, + { 0x2a, 3, "lhld", { 2 } }, + { 0x22, 3, "shld", { 2 } }, + { 0x0a, 1, "ldax", { 3, 4, 1, rp } }, + { 0x02, 1, "stax", { 3, 4, 1, rp } }, + { 0xeb, 1, "xchg" }, + { 0xf9, 1, "sphl" }, + { 0xe3, 1, "xthl" }, + { 0xc5, 1, "push", { 3, 4, 3, push_rp } }, + { 0xc1, 1, "pop", { 3, 4, 3, push_rp } }, + { 0xdb, 2, "in", { 1 } }, + { 0xd3, 2, "out", { 1 } }, + { 0x03, 1, "inx", { 3, 4, 3, rp } }, + { 0x0b, 1, "dcx", { 3, 4, 3, rp } }, + { 0x04, 1, "inr", { 3, 3, 7, reg } }, + { 0x05, 1, "dcr", { 3, 3, 7, reg } }, + { 0x09, 1, "dad", { 3, 4, 3, rp } }, + { 0x2f, 1, "cma" }, + { 0x07, 1, "rlc" }, + { 0x0f, 1, "rrc" }, + { 0x17, 1, "ral" }, + { 0x1f, 1, "rar" }, + { 0xfb, 1, "ei" }, + { 0xf3, 1, "di" }, + { 0x00, 1, "nop" }, + { 0x37, 1, "stc" }, + { 0x3f, 1, "cmc" }, + { 0xe9, 1, "pchl" }, + { 0x27, 1, "daa" }, + { 0xcd, 3, "call", { 2 } }, + { 0xc9, 1, "ret" }, + { 0xc7, 1, "rst", { 3, 3, 7, rst } }, + { 0xc0, 1, "r", { 3, 3, 7, cond } }, + { 0xc2, 3, "j", { 3, 3, 7, cond }, { 2 } }, + { 0xc4, 3, "c", { 3, 3, 7, cond }, { 2 } }, + { 0x80, 1, "add", { 3, 0, 7, reg } }, + { 0x80 | 0x46, 2, "adi", { 1 } }, + { 0x88, 1, "adc", { 3, 0, 7, reg } }, + { 0x88 | 0x46, 2, "aci", { 1 } }, + { 0x90, 1, "sub", { 3, 0, 7, reg } }, + { 0x90 | 0x46, 2, "sui", { 1 } }, + { 0x98, 1, "sbb", { 3, 0, 7, reg } }, + { 0x98 | 0x46, 2, "sbi", { 1 } }, + { 0xa0, 1, "ana", { 3, 0, 7, reg } }, + { 0xa0 | 0x46, 2, "ani", { 1 } }, + { 0xa8, 1, "xra", { 3, 0, 7, reg } }, + { 0xa8 | 0x46, 2, "xri", { 1 } }, + { 0xb0, 1, "ora", { 3, 0, 7, reg } }, + { 0xb0 | 0x46, 2, "ori", { 1 } }, + { 0xb8, 1, "cmp", { 3, 0, 7, reg } }, + { 0xb8 | 0x46, 2, "cpi", { 1 } }, + { 0x00, 1, "nop" }, + { 0x00, 0 } +}; + +static void arg(char *s, int const cmd, struct arg_t const *arg, int val) { + if (arg->type == 3) { + strcat(s, arg->fmt[(cmd >> arg->shift) & arg->mask]); + } else { + if (arg->type == 1) + sprintf(s, "%02X", val & 0xff); + else if (arg->type == 2) + sprintf(s, "%04X", val); + } +} + +int i8080_disasm(unsigned char const *const code, char *text, int text_sz) { + int const cmd = code[0]; + int const p = code[1] | (code[2] << 8); + + struct opcode_t const *op; + for (op = &opcodes[0]; op->size; ++op) { + int const grp = cmd & + ~((op->arg1.mask << op->arg1.shift) | + (op->arg2.mask << op->arg2.shift)); + int const branch = (grp == 0xc0 || grp == 0xc2 || grp == 0xc4); + if (grp == op->cmd) { + strcpy(text, op->name); + if (!branch) + strcat(text, " "); + arg(text + strlen(text), cmd, &op->arg1, p); + if (op->arg2.type != 0) + strcat(text, (branch ? " " : ", ")); + arg(text + strlen(text), cmd, &op->arg2, p); + return op->size; + } + } + snprintf(text, text_sz, "db @ 0x%02x", cmd); + return 1; +} diff --git a/librz/arch/arch-asm/i8080/i8080dis.h b/librz/arch/isa/i8080/i8080dis.h similarity index 100% rename from librz/arch/arch-asm/i8080/i8080dis.h rename to librz/arch/isa/i8080/i8080dis.h diff --git a/librz/arch/arch-asm/java/assembler.c b/librz/arch/isa/java/assembler.c similarity index 100% rename from librz/arch/arch-asm/java/assembler.c rename to librz/arch/isa/java/assembler.c diff --git a/librz/arch/arch-asm/java/assembler.h b/librz/arch/isa/java/assembler.h similarity index 100% rename from librz/arch/arch-asm/java/assembler.h rename to librz/arch/isa/java/assembler.h diff --git a/librz/arch/arch-asm/java/bytecode.h b/librz/arch/isa/java/bytecode.h similarity index 100% rename from librz/arch/arch-asm/java/bytecode.h rename to librz/arch/isa/java/bytecode.h diff --git a/librz/arch/arch-asm/java/const.h b/librz/arch/isa/java/const.h similarity index 100% rename from librz/arch/arch-asm/java/const.h rename to librz/arch/isa/java/const.h diff --git a/librz/arch/arch-asm/java/jvm.c b/librz/arch/isa/java/jvm.c similarity index 100% rename from librz/arch/arch-asm/java/jvm.c rename to librz/arch/isa/java/jvm.c diff --git a/librz/arch/arch-asm/java/jvm.h b/librz/arch/isa/java/jvm.h similarity index 100% rename from librz/arch/arch-asm/java/jvm.h rename to librz/arch/isa/java/jvm.h diff --git a/librz/arch/arch-asm/lh5801/lh5801.c b/librz/arch/isa/lh5801/lh5801.c similarity index 100% rename from librz/arch/arch-asm/lh5801/lh5801.c rename to librz/arch/isa/lh5801/lh5801.c diff --git a/librz/arch/arch-asm/lh5801/lh5801.h b/librz/arch/isa/lh5801/lh5801.h similarity index 95% rename from librz/arch/arch-asm/lh5801/lh5801.h rename to librz/arch/isa/lh5801/lh5801.h index f514dca7c27..ecc348d59b0 100644 --- a/librz/arch/arch-asm/lh5801/lh5801.h +++ b/librz/arch/isa/lh5801/lh5801.h @@ -8,7 +8,7 @@ #include #include -typedef uint8_t ut8; +#include /* Instruction classes. That's for example "add with carry". */ enum lh5801_insn_class { @@ -93,9 +93,6 @@ struct lh5801_insn_class_desc { /* TODO: rizin insn type? */ }; -const struct lh5801_insn_class_desc - lh5801_insn_class_descs[LH5801_INSNC_NUMBER]; - /* A decoded instruction */ struct lh5801_insn { ut8 iclass; /* an index into lh5801_insn_class_descs */ diff --git a/librz/arch/arch-asm/lm32/lm32_isa.h b/librz/arch/isa/lm32/lm32_isa.h similarity index 100% rename from librz/arch/arch-asm/lm32/lm32_isa.h rename to librz/arch/isa/lm32/lm32_isa.h diff --git a/librz/arch/arch-asm/luac/lua_arch.c b/librz/arch/isa/luac/lua_arch.c similarity index 100% rename from librz/arch/arch-asm/luac/lua_arch.c rename to librz/arch/isa/luac/lua_arch.c diff --git a/librz/arch/arch-asm/luac/lua_arch.h b/librz/arch/isa/luac/lua_arch.h similarity index 100% rename from librz/arch/arch-asm/luac/lua_arch.h rename to librz/arch/isa/luac/lua_arch.h diff --git a/librz/arch/arch-asm/luac/v53/analysis_53.c b/librz/arch/isa/luac/v53/analysis_53.c similarity index 100% rename from librz/arch/arch-asm/luac/v53/analysis_53.c rename to librz/arch/isa/luac/v53/analysis_53.c diff --git a/librz/arch/arch-asm/luac/v53/arch_53.h b/librz/arch/isa/luac/v53/arch_53.h similarity index 99% rename from librz/arch/arch-asm/luac/v53/arch_53.h rename to librz/arch/isa/luac/v53/arch_53.h index bb6c818d97c..020bc92591f 100644 --- a/librz/arch/arch-asm/luac/v53/arch_53.h +++ b/librz/arch/isa/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-asm/luac/v53/assembly_53.c b/librz/arch/isa/luac/v53/assembly_53.c similarity index 100% rename from librz/arch/arch-asm/luac/v53/assembly_53.c rename to librz/arch/isa/luac/v53/assembly_53.c diff --git a/librz/arch/arch-asm/luac/v53/disassembly_53.c b/librz/arch/isa/luac/v53/disassembly_53.c similarity index 100% rename from librz/arch/arch-asm/luac/v53/disassembly_53.c rename to librz/arch/isa/luac/v53/disassembly_53.c diff --git a/librz/arch/arch-asm/luac/v53/opcode_53.c b/librz/arch/isa/luac/v53/opcode_53.c similarity index 100% rename from librz/arch/arch-asm/luac/v53/opcode_53.c rename to librz/arch/isa/luac/v53/opcode_53.c diff --git a/librz/arch/arch-asm/luac/v54/analysis_54.c b/librz/arch/isa/luac/v54/analysis_54.c similarity index 100% rename from librz/arch/arch-asm/luac/v54/analysis_54.c rename to librz/arch/isa/luac/v54/analysis_54.c diff --git a/librz/arch/arch-asm/luac/v54/arch_54.h b/librz/arch/isa/luac/v54/arch_54.h similarity index 99% rename from librz/arch/arch-asm/luac/v54/arch_54.h rename to librz/arch/isa/luac/v54/arch_54.h index 44e2aa3ab09..54c50a3138e 100644 --- a/librz/arch/arch-asm/luac/v54/arch_54.h +++ b/librz/arch/isa/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-asm/luac/v54/assembly_54.c b/librz/arch/isa/luac/v54/assembly_54.c similarity index 100% rename from librz/arch/arch-asm/luac/v54/assembly_54.c rename to librz/arch/isa/luac/v54/assembly_54.c diff --git a/librz/arch/arch-asm/luac/v54/disassembly_54.c b/librz/arch/isa/luac/v54/disassembly_54.c similarity index 100% rename from librz/arch/arch-asm/luac/v54/disassembly_54.c rename to librz/arch/isa/luac/v54/disassembly_54.c diff --git a/librz/arch/arch-asm/luac/v54/opcode_54.c b/librz/arch/isa/luac/v54/opcode_54.c similarity index 100% rename from librz/arch/arch-asm/luac/v54/opcode_54.c rename to librz/arch/isa/luac/v54/opcode_54.c diff --git a/librz/arch/arch-asm/mcore/mcore.c b/librz/arch/isa/mcore/mcore.c similarity index 100% rename from librz/arch/arch-asm/mcore/mcore.c rename to librz/arch/isa/mcore/mcore.c diff --git a/librz/arch/arch-asm/mcore/mcore.h b/librz/arch/isa/mcore/mcore.h similarity index 100% rename from librz/arch/arch-asm/mcore/mcore.h rename to librz/arch/isa/mcore/mcore.h diff --git a/librz/arch/arch-asm/mcs96/mcs96.h b/librz/arch/isa/mcs96/mcs96.h similarity index 100% rename from librz/arch/arch-asm/mcs96/mcs96.h rename to librz/arch/isa/mcs96/mcs96.h diff --git a/librz/arch/arch-asm/mips/mipsasm.c b/librz/arch/isa/mips/mips_assembler.c similarity index 98% rename from librz/arch/arch-asm/mips/mipsasm.c rename to librz/arch/isa/mips/mips_assembler.c index 6a804d6f244..37f821aa2a7 100644 --- a/librz/arch/arch-asm/mips/mipsasm.c +++ b/librz/arch/isa/mips/mips_assembler.c @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-only #include -#include +#include static const char *const regs[33] = { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", @@ -145,7 +145,7 @@ static int getreg(const char *p) { return -1; } -RZ_IPI int mips_assemble(const char *str, ut64 pc, ut8 *out) { +RZ_IPI int mips_assemble_opcode(const char *str, ut64 pc, ut8 *out) { int i, hasp; char w0[32], w1[32], w2[32], w3[32]; char *s = strdup(str); diff --git a/librz/arch/isa/mips/mips_assembler.h b/librz/arch/isa/mips/mips_assembler.h new file mode 100644 index 00000000000..f3100135b90 --- /dev/null +++ b/librz/arch/isa/mips/mips_assembler.h @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2012-2018 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef ASSEMBLE_MIPS_H +#define ASSEMBLE_MIPS_H + +#include + +RZ_IPI int mips_assemble_opcode(const char *str, ut64 pc, ut8 *out); + +#endif /* ASSEMBLE_MIPS_H */ diff --git a/librz/arch/arch-asm/msp430/msp430_disas.c b/librz/arch/isa/msp430/msp430_disas.c similarity index 100% rename from librz/arch/arch-asm/msp430/msp430_disas.c rename to librz/arch/isa/msp430/msp430_disas.c diff --git a/librz/arch/arch-asm/msp430/msp430_disas.h b/librz/arch/isa/msp430/msp430_disas.h similarity index 100% rename from librz/arch/arch-asm/msp430/msp430_disas.h rename to librz/arch/isa/msp430/msp430_disas.h diff --git a/librz/arch/arch-asm/or1k/or1k_disas.c b/librz/arch/isa/or1k/or1k_disas.c similarity index 100% rename from librz/arch/arch-asm/or1k/or1k_disas.c rename to librz/arch/isa/or1k/or1k_disas.c diff --git a/librz/arch/arch-asm/or1k/or1k_disas.h b/librz/arch/isa/or1k/or1k_disas.h similarity index 97% rename from librz/arch/arch-asm/or1k/or1k_disas.h rename to librz/arch/isa/or1k/or1k_disas.h index 35e2b701281..7e081eedaf8 100644 --- a/librz/arch/arch-asm/or1k/or1k_disas.h +++ b/librz/arch/isa/or1k/or1k_disas.h @@ -179,4 +179,16 @@ static inline insn_type_t type_of_opcode(insn_t *descr, insn_extra_t *extra_desc } } +struct operands { + ut32 rd; + ut32 ra; + ut32 rb; + ut32 n; + ut32 k1; + ut32 k2; + ut32 k; + ut32 i; + ut32 l; +}; + #endif /* OR1K_DISAS_H */ diff --git a/librz/arch/arch-asm/pic/pic_baseline.c b/librz/arch/isa/pic/pic_baseline.c similarity index 100% rename from librz/arch/arch-asm/pic/pic_baseline.c rename to librz/arch/isa/pic/pic_baseline.c diff --git a/librz/arch/arch-asm/pic/pic_baseline.h b/librz/arch/isa/pic/pic_baseline.h similarity index 100% rename from librz/arch/arch-asm/pic/pic_baseline.h rename to librz/arch/isa/pic/pic_baseline.h diff --git a/librz/arch/arch-asm/pic/pic_midrange.c b/librz/arch/isa/pic/pic_midrange.c similarity index 100% rename from librz/arch/arch-asm/pic/pic_midrange.c rename to librz/arch/isa/pic/pic_midrange.c diff --git a/librz/arch/arch-asm/pic/pic_midrange.h b/librz/arch/isa/pic/pic_midrange.h similarity index 100% rename from librz/arch/arch-asm/pic/pic_midrange.h rename to librz/arch/isa/pic/pic_midrange.h diff --git a/librz/arch/arch-asm/pic/pic_pic18.c b/librz/arch/isa/pic/pic_pic18.c similarity index 100% rename from librz/arch/arch-asm/pic/pic_pic18.c rename to librz/arch/isa/pic/pic_pic18.c diff --git a/librz/arch/arch-asm/pic/pic_pic18.h b/librz/arch/isa/pic/pic_pic18.h similarity index 100% rename from librz/arch/arch-asm/pic/pic_pic18.h rename to librz/arch/isa/pic/pic_pic18.h diff --git a/librz/arch/arch-asm/ppc/libps/libps.c b/librz/arch/isa/ppc/libps/libps.c similarity index 100% rename from librz/arch/arch-asm/ppc/libps/libps.c rename to librz/arch/isa/ppc/libps/libps.c diff --git a/librz/arch/arch-asm/ppc/libps/libps.h b/librz/arch/isa/ppc/libps/libps.h similarity index 100% rename from librz/arch/arch-asm/ppc/libps/libps.h rename to librz/arch/isa/ppc/libps/libps.h diff --git a/librz/arch/arch-asm/ppc/libps/libps_internal.h b/librz/arch/isa/ppc/libps/libps_internal.h similarity index 100% rename from librz/arch/arch-asm/ppc/libps/libps_internal.h rename to librz/arch/isa/ppc/libps/libps_internal.h diff --git a/librz/arch/arch-asm/ppc/libvle/vle.c b/librz/arch/isa/ppc/libvle/vle.c similarity index 100% rename from librz/arch/arch-asm/ppc/libvle/vle.c rename to librz/arch/isa/ppc/libvle/vle.c diff --git a/librz/arch/arch-asm/ppc/libvle/vle.h b/librz/arch/isa/ppc/libvle/vle.h similarity index 100% rename from librz/arch/arch-asm/ppc/libvle/vle.h rename to librz/arch/isa/ppc/libvle/vle.h diff --git a/librz/arch/arch-asm/ppc/libvle/vle_internal.h b/librz/arch/isa/ppc/libvle/vle_internal.h similarity index 100% rename from librz/arch/arch-asm/ppc/libvle/vle_internal.h rename to librz/arch/isa/ppc/libvle/vle_internal.h diff --git a/librz/arch/arch-analysis/ppc/ppc_analysis.h b/librz/arch/isa/ppc/ppc_analysis.h similarity index 100% rename from librz/arch/arch-analysis/ppc/ppc_analysis.h rename to librz/arch/isa/ppc/ppc_analysis.h diff --git a/librz/arch/arch-analysis/ppc/ppc_dwarf_regnum_table.h b/librz/arch/isa/ppc/ppc_dwarf_regnum_table.h similarity index 100% rename from librz/arch/arch-analysis/ppc/ppc_dwarf_regnum_table.h rename to librz/arch/isa/ppc/ppc_dwarf_regnum_table.h diff --git a/librz/arch/arch-analysis/ppc/ppc_il.c b/librz/arch/isa/ppc/ppc_il.c similarity index 100% rename from librz/arch/arch-analysis/ppc/ppc_il.c rename to librz/arch/isa/ppc/ppc_il.c diff --git a/librz/arch/arch-analysis/ppc/ppc_il.h b/librz/arch/isa/ppc/ppc_il.h similarity index 100% rename from librz/arch/arch-analysis/ppc/ppc_il.h rename to librz/arch/isa/ppc/ppc_il.h diff --git a/librz/arch/arch-analysis/ppc/ppc_il_flag_ops.c b/librz/arch/isa/ppc/ppc_il_flag_ops.c similarity index 100% rename from librz/arch/arch-analysis/ppc/ppc_il_flag_ops.c rename to librz/arch/isa/ppc/ppc_il_flag_ops.c diff --git a/librz/arch/arch-analysis/ppc/ppc_il_ops.c b/librz/arch/isa/ppc/ppc_il_ops.c similarity index 100% rename from librz/arch/arch-analysis/ppc/ppc_il_ops.c rename to librz/arch/isa/ppc/ppc_il_ops.c diff --git a/librz/arch/arch-asm/propeller/propeller_disas.c b/librz/arch/isa/propeller/propeller_disas.c similarity index 100% rename from librz/arch/arch-asm/propeller/propeller_disas.c rename to librz/arch/isa/propeller/propeller_disas.c diff --git a/librz/arch/arch-asm/propeller/propeller_disas.h b/librz/arch/isa/propeller/propeller_disas.h similarity index 100% rename from librz/arch/arch-asm/propeller/propeller_disas.h rename to librz/arch/isa/propeller/propeller_disas.h diff --git a/librz/arch/arch-asm/pyc/opcode.c b/librz/arch/isa/pyc/opcode.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode.c rename to librz/arch/isa/pyc/opcode.c diff --git a/librz/arch/arch-asm/pyc/opcode.h b/librz/arch/isa/pyc/opcode.h similarity index 100% rename from librz/arch/arch-asm/pyc/opcode.h rename to librz/arch/isa/pyc/opcode.h diff --git a/librz/arch/arch-asm/pyc/opcode_10.c b/librz/arch/isa/pyc/opcode_10.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_10.c rename to librz/arch/isa/pyc/opcode_10.c diff --git a/librz/arch/arch-asm/pyc/opcode_11.c b/librz/arch/isa/pyc/opcode_11.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_11.c rename to librz/arch/isa/pyc/opcode_11.c diff --git a/librz/arch/arch-asm/pyc/opcode_12.c b/librz/arch/isa/pyc/opcode_12.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_12.c rename to librz/arch/isa/pyc/opcode_12.c diff --git a/librz/arch/arch-asm/pyc/opcode_13.c b/librz/arch/isa/pyc/opcode_13.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_13.c rename to librz/arch/isa/pyc/opcode_13.c diff --git a/librz/arch/arch-asm/pyc/opcode_14.c b/librz/arch/isa/pyc/opcode_14.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_14.c rename to librz/arch/isa/pyc/opcode_14.c diff --git a/librz/arch/arch-asm/pyc/opcode_15.c b/librz/arch/isa/pyc/opcode_15.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_15.c rename to librz/arch/isa/pyc/opcode_15.c diff --git a/librz/arch/arch-asm/pyc/opcode_16.c b/librz/arch/isa/pyc/opcode_16.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_16.c rename to librz/arch/isa/pyc/opcode_16.c diff --git a/librz/arch/arch-asm/pyc/opcode_20.c b/librz/arch/isa/pyc/opcode_20.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_20.c rename to librz/arch/isa/pyc/opcode_20.c diff --git a/librz/arch/arch-asm/pyc/opcode_21.c b/librz/arch/isa/pyc/opcode_21.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_21.c rename to librz/arch/isa/pyc/opcode_21.c diff --git a/librz/arch/arch-asm/pyc/opcode_22.c b/librz/arch/isa/pyc/opcode_22.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_22.c rename to librz/arch/isa/pyc/opcode_22.c diff --git a/librz/arch/arch-asm/pyc/opcode_23.c b/librz/arch/isa/pyc/opcode_23.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_23.c rename to librz/arch/isa/pyc/opcode_23.c diff --git a/librz/arch/arch-asm/pyc/opcode_24.c b/librz/arch/isa/pyc/opcode_24.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_24.c rename to librz/arch/isa/pyc/opcode_24.c diff --git a/librz/arch/arch-asm/pyc/opcode_25.c b/librz/arch/isa/pyc/opcode_25.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_25.c rename to librz/arch/isa/pyc/opcode_25.c diff --git a/librz/arch/arch-asm/pyc/opcode_26.c b/librz/arch/isa/pyc/opcode_26.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_26.c rename to librz/arch/isa/pyc/opcode_26.c diff --git a/librz/arch/arch-asm/pyc/opcode_27.c b/librz/arch/isa/pyc/opcode_27.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_27.c rename to librz/arch/isa/pyc/opcode_27.c diff --git a/librz/arch/arch-asm/pyc/opcode_2x.c b/librz/arch/isa/pyc/opcode_2x.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_2x.c rename to librz/arch/isa/pyc/opcode_2x.c diff --git a/librz/arch/arch-asm/pyc/opcode_30.c b/librz/arch/isa/pyc/opcode_30.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_30.c rename to librz/arch/isa/pyc/opcode_30.c diff --git a/librz/arch/arch-asm/pyc/opcode_31.c b/librz/arch/isa/pyc/opcode_31.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_31.c rename to librz/arch/isa/pyc/opcode_31.c diff --git a/librz/arch/arch-asm/pyc/opcode_310.c b/librz/arch/isa/pyc/opcode_310.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_310.c rename to librz/arch/isa/pyc/opcode_310.c diff --git a/librz/arch/arch-asm/pyc/opcode_32.c b/librz/arch/isa/pyc/opcode_32.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_32.c rename to librz/arch/isa/pyc/opcode_32.c diff --git a/librz/arch/arch-asm/pyc/opcode_33.c b/librz/arch/isa/pyc/opcode_33.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_33.c rename to librz/arch/isa/pyc/opcode_33.c diff --git a/librz/arch/arch-asm/pyc/opcode_34.c b/librz/arch/isa/pyc/opcode_34.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_34.c rename to librz/arch/isa/pyc/opcode_34.c diff --git a/librz/arch/arch-asm/pyc/opcode_35.c b/librz/arch/isa/pyc/opcode_35.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_35.c rename to librz/arch/isa/pyc/opcode_35.c diff --git a/librz/arch/arch-asm/pyc/opcode_36.c b/librz/arch/isa/pyc/opcode_36.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_36.c rename to librz/arch/isa/pyc/opcode_36.c diff --git a/librz/arch/arch-asm/pyc/opcode_37.c b/librz/arch/isa/pyc/opcode_37.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_37.c rename to librz/arch/isa/pyc/opcode_37.c diff --git a/librz/arch/arch-asm/pyc/opcode_38.c b/librz/arch/isa/pyc/opcode_38.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_38.c rename to librz/arch/isa/pyc/opcode_38.c diff --git a/librz/arch/arch-asm/pyc/opcode_39.c b/librz/arch/isa/pyc/opcode_39.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_39.c rename to librz/arch/isa/pyc/opcode_39.c diff --git a/librz/arch/arch-asm/pyc/opcode_3x.c b/librz/arch/isa/pyc/opcode_3x.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_3x.c rename to librz/arch/isa/pyc/opcode_3x.c diff --git a/librz/arch/arch-asm/pyc/opcode_analysis.c b/librz/arch/isa/pyc/opcode_analysis.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_analysis.c rename to librz/arch/isa/pyc/opcode_analysis.c diff --git a/librz/arch/arch-asm/pyc/opcode_arg_fmt.c b/librz/arch/isa/pyc/opcode_arg_fmt.c similarity index 100% rename from librz/arch/arch-asm/pyc/opcode_arg_fmt.c rename to librz/arch/isa/pyc/opcode_arg_fmt.c diff --git a/librz/arch/arch-asm/pyc/pyc_dis.c b/librz/arch/isa/pyc/pyc_dis.c similarity index 100% rename from librz/arch/arch-asm/pyc/pyc_dis.c rename to librz/arch/isa/pyc/pyc_dis.c diff --git a/librz/arch/arch-asm/pyc/pyc_dis.h b/librz/arch/isa/pyc/pyc_dis.h similarity index 100% rename from librz/arch/arch-asm/pyc/pyc_dis.h rename to librz/arch/isa/pyc/pyc_dis.h diff --git a/librz/arch/arch-asm/rl78/rl78.c b/librz/arch/isa/rl78/rl78.c similarity index 100% rename from librz/arch/arch-asm/rl78/rl78.c rename to librz/arch/isa/rl78/rl78.c diff --git a/librz/arch/arch-asm/rl78/rl78.h b/librz/arch/isa/rl78/rl78.h similarity index 100% rename from librz/arch/arch-asm/rl78/rl78.h rename to librz/arch/isa/rl78/rl78.h diff --git a/librz/arch/arch-analysis/rl78/rl78_dwarf_reg.h b/librz/arch/isa/rl78/rl78_dwarf_reg.h similarity index 100% rename from librz/arch/arch-analysis/rl78/rl78_dwarf_reg.h rename to librz/arch/isa/rl78/rl78_dwarf_reg.h diff --git a/librz/arch/arch-asm/rl78/rl78_instr.c b/librz/arch/isa/rl78/rl78_instr.c similarity index 100% rename from librz/arch/arch-asm/rl78/rl78_instr.c rename to librz/arch/isa/rl78/rl78_instr.c diff --git a/librz/arch/arch-asm/rl78/rl78_instr.h b/librz/arch/isa/rl78/rl78_instr.h similarity index 100% rename from librz/arch/arch-asm/rl78/rl78_instr.h rename to librz/arch/isa/rl78/rl78_instr.h diff --git a/librz/arch/arch-asm/rl78/rl78_maps.c b/librz/arch/isa/rl78/rl78_maps.c similarity index 100% rename from librz/arch/arch-asm/rl78/rl78_maps.c rename to librz/arch/isa/rl78/rl78_maps.c diff --git a/librz/arch/arch-asm/rl78/rl78_maps.h b/librz/arch/isa/rl78/rl78_maps.h similarity index 100% rename from librz/arch/arch-asm/rl78/rl78_maps.h rename to librz/arch/isa/rl78/rl78_maps.h diff --git a/librz/arch/arch-asm/rl78/rl78_operand.c b/librz/arch/isa/rl78/rl78_operand.c similarity index 100% rename from librz/arch/arch-asm/rl78/rl78_operand.c rename to librz/arch/isa/rl78/rl78_operand.c diff --git a/librz/arch/arch-asm/rl78/rl78_operand.h b/librz/arch/isa/rl78/rl78_operand.h similarity index 100% rename from librz/arch/arch-asm/rl78/rl78_operand.h rename to librz/arch/isa/rl78/rl78_operand.h diff --git a/librz/arch/arch-asm/rsp/rsp_idec.c b/librz/arch/isa/rsp/rsp_idec.c similarity index 100% rename from librz/arch/arch-asm/rsp/rsp_idec.c rename to librz/arch/isa/rsp/rsp_idec.c diff --git a/librz/arch/arch-asm/rsp/rsp_idec.h b/librz/arch/isa/rsp/rsp_idec.h similarity index 100% rename from librz/arch/arch-asm/rsp/rsp_idec.h rename to librz/arch/isa/rsp/rsp_idec.h diff --git a/librz/arch/arch-asm/rx/rx.c b/librz/arch/isa/rx/rx.c similarity index 100% rename from librz/arch/arch-asm/rx/rx.c rename to librz/arch/isa/rx/rx.c diff --git a/librz/arch/arch-asm/rx/rx.h b/librz/arch/isa/rx/rx.h similarity index 100% rename from librz/arch/arch-asm/rx/rx.h rename to librz/arch/isa/rx/rx.h diff --git a/librz/arch/arch-analysis/rx/rx_dwarf_regnum_table.h b/librz/arch/isa/rx/rx_dwarf_regnum_table.h similarity index 100% rename from librz/arch/arch-analysis/rx/rx_dwarf_regnum_table.h rename to librz/arch/isa/rx/rx_dwarf_regnum_table.h diff --git a/librz/arch/arch-asm/rx/rx_inst.c b/librz/arch/isa/rx/rx_inst.c similarity index 100% rename from librz/arch/arch-asm/rx/rx_inst.c rename to librz/arch/isa/rx/rx_inst.c diff --git a/librz/arch/arch-asm/rx/rx_inst.h b/librz/arch/isa/rx/rx_inst.h similarity index 100% rename from librz/arch/arch-asm/rx/rx_inst.h rename to librz/arch/isa/rx/rx_inst.h diff --git a/librz/arch/arch-asm/rx/rx_opcode_detail.c b/librz/arch/isa/rx/rx_opcode_detail.c similarity index 100% rename from librz/arch/arch-asm/rx/rx_opcode_detail.c rename to librz/arch/isa/rx/rx_opcode_detail.c diff --git a/librz/arch/arch-asm/rx/rx_opcode_detail.h b/librz/arch/isa/rx/rx_opcode_detail.h similarity index 100% rename from librz/arch/arch-asm/rx/rx_opcode_detail.h rename to librz/arch/isa/rx/rx_opcode_detail.h diff --git a/librz/arch/arch-asm/rx/rx_str.inc b/librz/arch/isa/rx/rx_str.inc similarity index 100% rename from librz/arch/arch-asm/rx/rx_str.inc rename to librz/arch/isa/rx/rx_str.inc diff --git a/librz/arch/arch-asm/sh/assembler.c b/librz/arch/isa/sh/assembler.c similarity index 100% rename from librz/arch/arch-asm/sh/assembler.c rename to librz/arch/isa/sh/assembler.c diff --git a/librz/arch/arch-asm/sh/assembler.h b/librz/arch/isa/sh/assembler.h similarity index 100% rename from librz/arch/arch-asm/sh/assembler.h rename to librz/arch/isa/sh/assembler.h diff --git a/librz/arch/arch-asm/sh/common.h b/librz/arch/isa/sh/common.h similarity index 100% rename from librz/arch/arch-asm/sh/common.h rename to librz/arch/isa/sh/common.h diff --git a/librz/arch/arch-asm/sh/disassembler.c b/librz/arch/isa/sh/disassembler.c similarity index 100% rename from librz/arch/arch-asm/sh/disassembler.c rename to librz/arch/isa/sh/disassembler.c diff --git a/librz/arch/arch-asm/sh/disassembler.h b/librz/arch/isa/sh/disassembler.h similarity index 100% rename from librz/arch/arch-asm/sh/disassembler.h rename to librz/arch/isa/sh/disassembler.h diff --git a/librz/arch/arch-asm/sh/lookup.c b/librz/arch/isa/sh/lookup.c similarity index 100% rename from librz/arch/arch-asm/sh/lookup.c rename to librz/arch/isa/sh/lookup.c diff --git a/librz/arch/arch-asm/sh/regs.h b/librz/arch/isa/sh/regs.h similarity index 100% rename from librz/arch/arch-asm/sh/regs.h rename to librz/arch/isa/sh/regs.h diff --git a/librz/arch/arch-analysis/sh/sh_dwarf_regnum_table.h b/librz/arch/isa/sh/sh_dwarf_regnum_table.h similarity index 100% rename from librz/arch/arch-analysis/sh/sh_dwarf_regnum_table.h rename to librz/arch/isa/sh/sh_dwarf_regnum_table.h diff --git a/librz/arch/arch-analysis/sh/sh_il.c b/librz/arch/isa/sh/sh_il.c similarity index 99% rename from librz/arch/arch-analysis/sh/sh_il.c rename to librz/arch/isa/sh/sh_il.c index 12b9307acb1..4580be81f89 100644 --- a/librz/arch/arch-analysis/sh/sh_il.c +++ b/librz/arch/isa/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-analysis/sh/sh_il.h b/librz/arch/isa/sh/sh_il.h similarity index 95% rename from librz/arch/arch-analysis/sh/sh_il.h rename to librz/arch/isa/sh/sh_il.h index 27b7b29a2e8..35f9b7234d3 100644 --- a/librz/arch/arch-analysis/sh/sh_il.h +++ b/librz/arch/isa/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/p-asm/asm_snes.h b/librz/arch/isa/snes/snes.h similarity index 60% rename from librz/arch/p-asm/asm_snes.h rename to librz/arch/isa/snes/snes.h index f4ea7852702..d6dd46d95c8 100644 --- a/librz/arch/p-asm/asm_snes.h +++ b/librz/arch/isa/snes/snes.h @@ -2,12 +2,15 @@ // SPDX-FileCopyrightText: 2012-2015 pancake // SPDX-License-Identifier: LGPL-3.0-only -#ifndef ASM_P_ASM_SNES_H -#define ASM_P_ASM_SNES_H +#ifndef SNES_H +#define SNES_H +#include struct snes_asm_flags { unsigned char M; unsigned char X; }; -#endif +int snesDisass(int M_flag, int X_flag, ut64 pc, RzAsmOp *op, const ut8 *buf, int len); + +#endif /* SNES_H */ diff --git a/librz/arch/arch-asm/snes/snes_op_table.h b/librz/arch/isa/snes/snes_op_table.h similarity index 100% rename from librz/arch/arch-asm/snes/snes_op_table.h rename to librz/arch/isa/snes/snes_op_table.h diff --git a/librz/arch/arch-asm/snes/snesdis.c b/librz/arch/isa/snes/snesdis.c similarity index 94% rename from librz/arch/arch-asm/snes/snesdis.c rename to librz/arch/isa/snes/snesdis.c index 3323f9e73eb..58a8ad2c636 100644 --- a/librz/arch/arch-asm/snes/snesdis.c +++ b/librz/arch/isa/snes/snesdis.c @@ -9,7 +9,7 @@ #include #include "snes_op_table.h" -static int snesDisass(int M_flag, int X_flag, ut64 pc, RzAsmOp *op, const ut8 *buf, int len) { +int snesDisass(int M_flag, int X_flag, ut64 pc, RzAsmOp *op, const ut8 *buf, int len) { snes_op_t *s_op = &snes_op[buf[0]]; int op_len = snes_op_get_size(M_flag, X_flag, s_op); if (len < op_len) { diff --git a/librz/arch/arch-asm/spc700/spc700_opcode_table.h b/librz/arch/isa/spc700/spc700_opcode_table.h similarity index 100% rename from librz/arch/arch-asm/spc700/spc700_opcode_table.h rename to librz/arch/isa/spc700/spc700_opcode_table.h diff --git a/librz/arch/arch-asm/spc700/spc700dis.c b/librz/arch/isa/spc700/spc700dis.c similarity index 95% rename from librz/arch/arch-asm/spc700/spc700dis.c rename to librz/arch/isa/spc700/spc700dis.c index c937949afb5..2fd95d9afec 100644 --- a/librz/arch/arch-asm/spc700/spc700dis.c +++ b/librz/arch/isa/spc700/spc700dis.c @@ -33,7 +33,7 @@ static ut64 spc700_resolve_relative(ut64 pc, ut8 r) { return (ut64)spc; } -static size_t spc700_disas(RzStrBuf *out, ut64 pc, const ut8 *buf, size_t bufsz) { +size_t spc700_disas(RzStrBuf *out, ut64 pc, const ut8 *buf, size_t bufsz) { if (!bufsz) { return 0; } diff --git a/librz/arch/isa/spc700/spc700dis.h b/librz/arch/isa/spc700/spc700dis.h new file mode 100644 index 00000000000..9d77658795f --- /dev/null +++ b/librz/arch/isa/spc700/spc700dis.h @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef DISASSEMBLE_SPC700_H +#define DISASSEMBLE_SPC700_H + +#include + +size_t spc700_disas(RzStrBuf *out, ut64 pc, const ut8 *buf, size_t bufsz); + +#endif /* DISASSEMBLE_SPC700_H */ diff --git a/librz/arch/arch-asm/tms320/c55x/table.h b/librz/arch/isa/tms320/c55x/table.h similarity index 100% rename from librz/arch/arch-asm/tms320/c55x/table.h rename to librz/arch/isa/tms320/c55x/table.h diff --git a/librz/arch/arch-asm/tms320/c55x_plus/c55plus.c b/librz/arch/isa/tms320/c55x_plus/c55plus.c similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/c55plus.c rename to librz/arch/isa/tms320/c55x_plus/c55plus.c diff --git a/librz/arch/arch-asm/tms320/c55x_plus/c55plus.h b/librz/arch/isa/tms320/c55x_plus/c55plus.h similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/c55plus.h rename to librz/arch/isa/tms320/c55x_plus/c55plus.h diff --git a/librz/arch/p-analysis/analysis_tms320_c55x_plus.c b/librz/arch/isa/tms320/c55x_plus/c55plus_analysis.c similarity index 98% rename from librz/arch/p-analysis/analysis_tms320_c55x_plus.c rename to librz/arch/isa/tms320/c55x_plus/c55plus_analysis.c index 7926a7c470d..7c092e82690 100644 --- a/librz/arch/p-analysis/analysis_tms320_c55x_plus.c +++ b/librz/arch/isa/tms320/c55x_plus/c55plus_analysis.c @@ -7,7 +7,8 @@ #include #include -ut32 get_ins_len(ut8 opcode); +#include "c55plus_analysis.h" +#include "ins.h" int tms320_c55x_plus_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len) { ut16 *ins = (ut16 *)buf; diff --git a/librz/arch/isa/tms320/c55x_plus/c55plus_analysis.h b/librz/arch/isa/tms320/c55x_plus/c55plus_analysis.h new file mode 100644 index 00000000000..c8921327514 --- /dev/null +++ b/librz/arch/isa/tms320/c55x_plus/c55plus_analysis.h @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef ANALYSIS_C55_PLUS_H +#define ANALYSIS_C55_PLUS_H + +#include + +int tms320_c55x_plus_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len); + +#endif /* ANALYSIS_C55_PLUS_H */ diff --git a/librz/arch/arch-asm/tms320/c55x_plus/c55plus_decode.c b/librz/arch/isa/tms320/c55x_plus/c55plus_decode.c similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/c55plus_decode.c rename to librz/arch/isa/tms320/c55x_plus/c55plus_decode.c diff --git a/librz/arch/arch-asm/tms320/c55x_plus/decode.h b/librz/arch/isa/tms320/c55x_plus/decode.h similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/decode.h rename to librz/arch/isa/tms320/c55x_plus/decode.h diff --git a/librz/arch/arch-asm/tms320/c55x_plus/decode_funcs.c b/librz/arch/isa/tms320/c55x_plus/decode_funcs.c similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/decode_funcs.c rename to librz/arch/isa/tms320/c55x_plus/decode_funcs.c diff --git a/librz/arch/arch-asm/tms320/c55x_plus/decode_funcs.h b/librz/arch/isa/tms320/c55x_plus/decode_funcs.h similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/decode_funcs.h rename to librz/arch/isa/tms320/c55x_plus/decode_funcs.h diff --git a/librz/arch/arch-asm/tms320/c55x_plus/hashtable.c b/librz/arch/isa/tms320/c55x_plus/hashtable.c similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/hashtable.c rename to librz/arch/isa/tms320/c55x_plus/hashtable.c diff --git a/librz/arch/arch-asm/tms320/c55x_plus/hashtable.h b/librz/arch/isa/tms320/c55x_plus/hashtable.h similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/hashtable.h rename to librz/arch/isa/tms320/c55x_plus/hashtable.h diff --git a/librz/arch/arch-asm/tms320/c55x_plus/hashvector.c b/librz/arch/isa/tms320/c55x_plus/hashvector.c similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/hashvector.c rename to librz/arch/isa/tms320/c55x_plus/hashvector.c diff --git a/librz/arch/arch-asm/tms320/c55x_plus/hashvector.h b/librz/arch/isa/tms320/c55x_plus/hashvector.h similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/hashvector.h rename to librz/arch/isa/tms320/c55x_plus/hashvector.h diff --git a/librz/arch/arch-asm/tms320/c55x_plus/ins.c b/librz/arch/isa/tms320/c55x_plus/ins.c similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/ins.c rename to librz/arch/isa/tms320/c55x_plus/ins.c diff --git a/librz/arch/arch-asm/tms320/c55x_plus/ins.h b/librz/arch/isa/tms320/c55x_plus/ins.h similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/ins.h rename to librz/arch/isa/tms320/c55x_plus/ins.h diff --git a/librz/arch/arch-asm/tms320/c55x_plus/utils.c b/librz/arch/isa/tms320/c55x_plus/utils.c similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/utils.c rename to librz/arch/isa/tms320/c55x_plus/utils.c diff --git a/librz/arch/arch-asm/tms320/c55x_plus/utils.h b/librz/arch/isa/tms320/c55x_plus/utils.h similarity index 100% rename from librz/arch/arch-asm/tms320/c55x_plus/utils.h rename to librz/arch/isa/tms320/c55x_plus/utils.h diff --git a/librz/arch/p-analysis/analysis_tms320c64x.c b/librz/arch/isa/tms320/c64x/c64x.c similarity index 64% rename from librz/arch/p-analysis/analysis_tms320c64x.c rename to librz/arch/isa/tms320/c64x/c64x.c index 5beaa38a5d0..a97952be8c8 100644 --- a/librz/arch/p-analysis/analysis_tms320c64x.c +++ b/librz/arch/isa/tms320/c64x/c64x.c @@ -1,23 +1,123 @@ // SPDX-FileCopyrightText: 2017 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include -#include -#include - +#include "c64x.h" #ifdef CAPSTONE_TMS320C64X_H -#define CAPSTONE_HAS_TMS320C64X 1 -#else -#define CAPSTONE_HAS_TMS320C64X 0 -#warning Cannot find capstone-tms320c64x support -#endif - -#if CAPSTONE_HAS_TMS320C64X #define INSOP(n) insn->detail->tms320c64x.operands[n] #define INSCC insn->detail->tms320c64x.cc -static void opex(RzStrBuf *buf, csh handle, cs_insn *insn) { +typedef struct { + cs_mode omode; + int obits; + csh handle; +} TMSContext; + +void *tms320_c64x_new() { + TMSContext *ctx = RZ_NEW0(TMSContext); + if (!ctx) { + return false; + } + ctx->omode = -1; + ctx->handle = 0; + return ctx; +} + +void tms320_c64x_free(void *p) { + if (!p) { + } + TMSContext *ctx = (TMSContext *)p; + if (ctx->handle) { + cs_close(&ctx->handle); + } + free(ctx); +} + +int tms320_c64x_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len, void *c64x) { + TMSContext *ctx = (TMSContext *)c64x; + + cs_insn *insn; + int n = -1, ret = -1; + if (op) { + memset(op, 0, sizeof(RzAsmOp)); + op->size = 4; + } + if (ctx->omode != 0) { + cs_close(&ctx->handle); + ctx->omode = -1; + } + if (!ctx->handle) { + ret = cs_open(CS_ARCH_TMS320C64X, 0, &ctx->handle); + if (ret) { + goto fin; + } + ctx->omode = 0; + cs_option(ctx->handle, CS_OPT_DETAIL, CS_OPT_OFF); + } + if (!op) { + return 0; + } + n = cs_disasm(ctx->handle, buf, len, a->pc, 1, &insn); + if (n < 1) { + rz_asm_op_set_asm(op, "invalid"); + op->size = 4; + ret = -1; + goto fin; + } else { + ret = 4; + } + if (insn->size < 1) { + goto fin; + } + op->size = insn->size; + rz_asm_op_setf_asm(op, "%s%s%s", insn->mnemonic, insn->op_str[0] ? " " : "", insn->op_str); + char *str = rz_asm_op_get_asm(op); + if (str) { + rz_str_replace_char(str, '%', 0); + rz_str_case(str, false); + } + cs_free(insn, n); +fin: + return ret; +} + +char *tms320_c64x_mnemonics(RzAsm *a, int id, bool json, void *c64x) { + TMSContext *ctx = (TMSContext *)c64x; + a->cur->disassemble(a, NULL, NULL, -1); + if (id != -1) { + const char *vname = cs_insn_name(ctx->handle, id); + if (json) { + return vname ? rz_str_newf("[\"%s\"]\n", vname) : NULL; + } + return vname ? strdup(vname) : NULL; + } + RzStrBuf *buf = rz_strbuf_new(""); + if (json) { + rz_strbuf_append(buf, "["); + } + for (int i = 1;; i++) { + const char *op = cs_insn_name(ctx->handle, i); + if (!op) { + break; + } + if (json) { + rz_strbuf_append(buf, "\""); + } + rz_strbuf_append(buf, op); + if (json) { + if (cs_insn_name(ctx->handle, i + 1)) { + rz_strbuf_append(buf, "\","); + } else { + rz_strbuf_append(buf, "\"]\n"); + } + } else { + rz_strbuf_append(buf, "\n"); + } + } + return rz_strbuf_drain(buf); +} + +static void tms320_c64x_opex(RzStrBuf *buf, csh handle, cs_insn *insn) { int i; PJ *pj = pj_new(); if (!pj) { @@ -59,21 +159,8 @@ static void opex(RzStrBuf *buf, csh handle, cs_insn *insn) { pj_free(pj); } -typedef struct { - csh handle; - int omode; -} TMSContext; - -static bool tmsctx_init(void **user) { - TMSContext *ctx = RZ_NEW0(TMSContext); - rz_return_val_if_fail(ctx, false); - ctx->handle = 0; - *user = ctx; - return true; -} - -static int tms320c64x_analyze_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { - TMSContext *ctx = (TMSContext *)a->plugin_data; +int tms320_c64x_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask, void *c64x) { + TMSContext *ctx = (TMSContext *)c64x; cs_insn *insn; int mode = 0, n, ret; @@ -95,7 +182,7 @@ static int tms320c64x_analyze_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, con op->type = RZ_ANALYSIS_OP_TYPE_ILL; } else { if (mask & RZ_ANALYSIS_OP_MASK_OPEX) { - opex(&op->opex, ctx->handle, insn); + tms320_c64x_opex(&op->opex, ctx->handle, insn); } op->size = insn->size; op->id = insn->id; @@ -192,32 +279,5 @@ static int tms320c64x_analyze_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, con } return op->size; } -#endif - -static bool tmsctx_fini(void *user) { - TMSContext *ctx = (TMSContext *)user; - if (ctx) { - RZ_FREE(ctx); - } - return true; -} - -RzAnalysisPlugin rz_analysis_plugin_tms320c64x = { - .name = "tms320c64x", - .desc = "Capstone TMS320C64X analysis", - .license = "BSD", - .esil = false, - .arch = "tms320c64x", - .bits = 32, - .op = &tms320c64x_analyze_op, - .init = tmsctx_init, - .fini = tmsctx_fini, -}; -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_tms320c64x, - .version = RZ_VERSION -}; -#endif +#endif /* CAPSTONE_TMS320C64X_H */ diff --git a/librz/arch/isa/tms320/c64x/c64x.h b/librz/arch/isa/tms320/c64x/c64x.h new file mode 100644 index 00000000000..c98715381cf --- /dev/null +++ b/librz/arch/isa/tms320/c64x/c64x.h @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef TMS320_C64X_CAPSTONE_H +#define TMS320_C64X_CAPSTONE_H + +#include +#include +#include + +#ifdef CAPSTONE_TMS320C64X_H + +void *tms320_c64x_new(); +void tms320_c64x_free(void *p); +int tms320_c64x_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len, void *c64x); +char *tms320_c64x_mnemonics(RzAsm *a, int id, bool json, void *c64x); +int tms320_c64x_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask, void *c64x); + +#else + +/** + * The supplied capstone (4 or lower) does not have + * commit ae6f2d141118680a04a949b31e9e82e7b70f10b8 + * https://github.com/capstone-engine/capstone/commit/ae6f2d141118680a04a949b31e9e82e7b70f10b8 + */ + +#warning Capstone does not support tms320c64x + +#define tms320_c64x_new() (NULL) +#define tms320_c64x_free(x) +#define tms320_c64x_disassemble(a, op, buf, len, c64x) (-1) +#define tms320_c64x_mnemonics(a, id, json, c64x) (NULL) +#define tms320_c64x_op(a, op, addr, buf, le, mask, c64x) (-1) + +#endif /* CAPSTONE_TMS320C64X_H */ + +#endif /* TMS320_C64X_CAPSTONE_H */ diff --git a/librz/arch/arch-asm/tms320/scripts/c55x_gen_tbl.pl b/librz/arch/isa/tms320/scripts/c55x_gen_tbl.pl similarity index 100% rename from librz/arch/arch-asm/tms320/scripts/c55x_gen_tbl.pl rename to librz/arch/isa/tms320/scripts/c55x_gen_tbl.pl diff --git a/librz/arch/arch-asm/tms320/tms320_dasm.c b/librz/arch/isa/tms320/tms320_dasm.c similarity index 100% rename from librz/arch/arch-asm/tms320/tms320_dasm.c rename to librz/arch/isa/tms320/tms320_dasm.c diff --git a/librz/arch/arch-asm/tms320/tms320_dasm.h b/librz/arch/isa/tms320/tms320_dasm.h similarity index 100% rename from librz/arch/arch-asm/tms320/tms320_dasm.h rename to librz/arch/isa/tms320/tms320_dasm.h diff --git a/librz/arch/arch-asm/tricore/README.md b/librz/arch/isa/tricore/README.md similarity index 100% rename from librz/arch/arch-asm/tricore/README.md rename to librz/arch/isa/tricore/README.md diff --git a/librz/arch/arch-asm/tricore/tricore.h b/librz/arch/isa/tricore/tricore.h similarity index 100% rename from librz/arch/arch-asm/tricore/tricore.h rename to librz/arch/isa/tricore/tricore.h diff --git a/librz/arch/arch-asm/tricore/tricore.inc b/librz/arch/isa/tricore/tricore.inc similarity index 100% rename from librz/arch/arch-asm/tricore/tricore.inc rename to librz/arch/isa/tricore/tricore.inc diff --git a/librz/arch/arch-analysis/tricore/tricore_dwarf_regnum_table.h b/librz/arch/isa/tricore/tricore_dwarf_regnum_table.h similarity index 100% rename from librz/arch/arch-analysis/tricore/tricore_dwarf_regnum_table.h rename to librz/arch/isa/tricore/tricore_dwarf_regnum_table.h diff --git a/librz/arch/arch-analysis/tricore/tricore_il.c b/librz/arch/isa/tricore/tricore_il.c similarity index 99% rename from librz/arch/arch-analysis/tricore/tricore_il.c rename to librz/arch/isa/tricore/tricore_il.c index 9f94815186c..553491b5f31 100644 --- a/librz/arch/arch-analysis/tricore/tricore_il.c +++ b/librz/arch/isa/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-analysis/tricore/tricore_il.h b/librz/arch/isa/tricore/tricore_il.h similarity index 100% rename from librz/arch/arch-analysis/tricore/tricore_il.h rename to librz/arch/isa/tricore/tricore_il.h diff --git a/librz/arch/arch-analysis/v810/v810.h b/librz/arch/isa/v810/v810.h similarity index 96% rename from librz/arch/arch-analysis/v810/v810.h rename to librz/arch/isa/v810/v810.h index 9cab2ea8182..2372befea5f 100644 --- a/librz/arch/arch-analysis/v810/v810.h +++ b/librz/arch/isa/v810/v810.h @@ -5,7 +5,7 @@ #define RIZIN_V810_H #include -#include +#include "v810_disas.h" enum { C_BGT = 0b1111, diff --git a/librz/arch/arch-asm/v810/v810_disas.c b/librz/arch/isa/v810/v810_disas.c similarity index 100% rename from librz/arch/arch-asm/v810/v810_disas.c rename to librz/arch/isa/v810/v810_disas.c diff --git a/librz/arch/arch-asm/v810/v810_disas.h b/librz/arch/isa/v810/v810_disas.h similarity index 100% rename from librz/arch/arch-asm/v810/v810_disas.h rename to librz/arch/isa/v810/v810_disas.h diff --git a/librz/arch/arch-analysis/v810/v810_il.c b/librz/arch/isa/v810/v810_il.c similarity index 100% rename from librz/arch/arch-analysis/v810/v810_il.c rename to librz/arch/isa/v810/v810_il.c diff --git a/librz/arch/arch-asm/v850/v850_disas.c b/librz/arch/isa/v850/v850_disas.c similarity index 100% rename from librz/arch/arch-asm/v850/v850_disas.c rename to librz/arch/isa/v850/v850_disas.c diff --git a/librz/arch/arch-asm/v850/v850_disas.h b/librz/arch/isa/v850/v850_disas.h similarity index 100% rename from librz/arch/arch-asm/v850/v850_disas.h rename to librz/arch/isa/v850/v850_disas.h diff --git a/librz/arch/arch-analysis/v850/v850_dwarf_reg_num_table.h b/librz/arch/isa/v850/v850_dwarf_reg_num_table.h similarity index 100% rename from librz/arch/arch-analysis/v850/v850_dwarf_reg_num_table.h rename to librz/arch/isa/v850/v850_dwarf_reg_num_table.h diff --git a/librz/arch/arch-analysis/v850/v850_esil.inc b/librz/arch/isa/v850/v850_esil.inc similarity index 100% rename from librz/arch/arch-analysis/v850/v850_esil.inc rename to librz/arch/isa/v850/v850_esil.inc diff --git a/librz/arch/arch-analysis/v850/v850_il.c b/librz/arch/isa/v850/v850_il.c similarity index 100% rename from librz/arch/arch-analysis/v850/v850_il.c rename to librz/arch/isa/v850/v850_il.c diff --git a/librz/arch/arch-analysis/v850/v850_il.h b/librz/arch/isa/v850/v850_il.h similarity index 96% rename from librz/arch/arch-analysis/v850/v850_il.h rename to librz/arch/isa/v850/v850_il.h index dac8022f14e..26c8b576bf4 100644 --- a/librz/arch/arch-analysis/v850/v850_il.h +++ b/librz/arch/isa/v850/v850_il.h @@ -5,7 +5,7 @@ #define RIZIN_V850_IL_H #include -#include +#include "v850_disas.h" enum { C_BGT = 0b1111, diff --git a/librz/arch/arch-asm/wasm/wasm.c b/librz/arch/isa/wasm/wasm.c similarity index 100% rename from librz/arch/arch-asm/wasm/wasm.c rename to librz/arch/isa/wasm/wasm.c diff --git a/librz/arch/arch-asm/wasm/wasm.h b/librz/arch/isa/wasm/wasm.h similarity index 99% rename from librz/arch/arch-asm/wasm/wasm.h rename to librz/arch/isa/wasm/wasm.h index f081510eaef..866f5195edf 100644 --- a/librz/arch/arch-asm/wasm/wasm.h +++ b/librz/arch/isa/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/arch-analysis/x86/common.c b/librz/arch/isa/x86/common.c similarity index 100% rename from librz/arch/arch-analysis/x86/common.c rename to librz/arch/isa/x86/common.c diff --git a/librz/arch/arch-analysis/x86/common.h b/librz/arch/isa/x86/common.h similarity index 100% rename from librz/arch/arch-analysis/x86/common.h rename to librz/arch/isa/x86/common.h diff --git a/librz/arch/arch-analysis/x86/il_fp_ops.inc b/librz/arch/isa/x86/il_fp_ops.inc similarity index 100% rename from librz/arch/arch-analysis/x86/il_fp_ops.inc rename to librz/arch/isa/x86/il_fp_ops.inc diff --git a/librz/arch/arch-analysis/x86/il_ops.inc b/librz/arch/isa/x86/il_ops.inc similarity index 100% rename from librz/arch/arch-analysis/x86/il_ops.inc rename to librz/arch/isa/x86/il_ops.inc diff --git a/librz/arch/arch-analysis/x86/x86_dwarf_regnum_table.h b/librz/arch/isa/x86/x86_dwarf_regnum_table.h similarity index 100% rename from librz/arch/arch-analysis/x86/x86_dwarf_regnum_table.h rename to librz/arch/isa/x86/x86_dwarf_regnum_table.h diff --git a/librz/arch/arch-analysis/x86/x86_il.c b/librz/arch/isa/x86/x86_il.c similarity index 100% rename from librz/arch/arch-analysis/x86/x86_il.c rename to librz/arch/isa/x86/x86_il.c diff --git a/librz/arch/arch-analysis/x86/x86_il.h b/librz/arch/isa/x86/x86_il.h similarity index 100% rename from librz/arch/arch-analysis/x86/x86_il.h rename to librz/arch/isa/x86/x86_il.h diff --git a/librz/arch/arch-asm/xap/dis.c b/librz/arch/isa/xap/dis.c similarity index 100% rename from librz/arch/arch-asm/xap/dis.c rename to librz/arch/isa/xap/dis.c diff --git a/librz/arch/arch-asm/xap/dis.h b/librz/arch/isa/xap/dis.h similarity index 100% rename from librz/arch/arch-asm/xap/dis.h rename to librz/arch/isa/xap/dis.h diff --git a/librz/arch/arch-asm/arc/gnu/arc-dis.c b/librz/arch/isa_gnu/arc/arc-dis.c similarity index 99% rename from librz/arch/arch-asm/arc/gnu/arc-dis.c rename to librz/arch/isa_gnu/arc/arc-dis.c index 89ac6919b7d..cd1c5915242 100644 --- a/librz/arch/arch-asm/arc/gnu/arc-dis.c +++ b/librz/arch/isa_gnu/arc/arc-dis.c @@ -22,21 +22,22 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "ansidecl.h" -#include "libiberty.h" -#include "disas-asm.h" -//#include "opcode/arc.h" -#include "elf-bfd.h" -#include "arc.h" -#include -#include "opintl.h" +#include +#include +#include +#include +#include +#include +#include #include +#include + #include "arc-dis.h" #include "arc-ext.h" #include "arcompact-dis.h" +#include "arc.h" -#include /* Classification of the opcodes for the decoder to print the instructions. */ diff --git a/librz/arch/arch-asm/arc/gnu/arc-dis.h b/librz/arch/isa_gnu/arc/arc-dis.h similarity index 100% rename from librz/arch/arch-asm/arc/gnu/arc-dis.h rename to librz/arch/isa_gnu/arc/arc-dis.h diff --git a/librz/arch/arch-asm/arc/gnu/arc-ext.c b/librz/arch/isa_gnu/arc/arc-ext.c similarity index 99% rename from librz/arch/arch-asm/arc/gnu/arc-ext.c rename to librz/arch/isa_gnu/arc/arc-ext.c index bc8bd748e49..087601e43c0 100644 --- a/librz/arch/arch-asm/arc/gnu/arc-ext.c +++ b/librz/arch/isa_gnu/arc/arc-ext.c @@ -33,8 +33,8 @@ // the const prefix is used bellow for api definitions. // If u define the new value of const this dont match with previus const int arc-ext.h api definition // giving a compiler error under MSVC -#include "libiberty.h" -#include "sysdep.h" +#include +#include #endif /******************************************************************************/ diff --git a/librz/arch/arch-asm/arc/gnu/arc-ext.h b/librz/arch/isa_gnu/arc/arc-ext.h similarity index 100% rename from librz/arch/arch-asm/arc/gnu/arc-ext.h rename to librz/arch/isa_gnu/arc/arc-ext.h diff --git a/librz/arch/arch-asm/arc/gnu/arc-opc-cgen.h b/librz/arch/isa_gnu/arc/arc-opc-cgen.h similarity index 100% rename from librz/arch/arch-asm/arc/gnu/arc-opc-cgen.h rename to librz/arch/isa_gnu/arc/arc-opc-cgen.h diff --git a/librz/arch/arch-asm/arc/gnu/arc-opc.c b/librz/arch/isa_gnu/arc/arc-opc.c similarity index 99% rename from librz/arch/arch-asm/arc/gnu/arc-opc.c rename to librz/arch/isa_gnu/arc/arc-opc.c index d017a212896..f0debcfdd5b 100644 --- a/librz/arch/arch-asm/arc/gnu/arc-opc.c +++ b/librz/arch/isa_gnu/arc/arc-opc.c @@ -24,12 +24,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "sysdep.h" +#include #include #include -#include "ansidecl.h" +#include #include "arc.h" -#include "opintl.h" +#include /* -------------------------------------------------------------------------- */ diff --git a/librz/arch/arch-asm/arc/gnu/arc-opc.h b/librz/arch/isa_gnu/arc/arc-opc.h similarity index 100% rename from librz/arch/arch-asm/arc/gnu/arc-opc.h rename to librz/arch/isa_gnu/arc/arc-opc.h diff --git a/librz/arch/arch-asm/arc/gnu/arc.h b/librz/arch/isa_gnu/arc/arc.h similarity index 100% rename from librz/arch/arch-asm/arc/gnu/arc.h rename to librz/arch/isa_gnu/arc/arc.h diff --git a/librz/arch/arch-asm/arc/gnu/arcompact-dis.c b/librz/arch/isa_gnu/arc/arcompact-dis.c similarity index 99% rename from librz/arch/arch-asm/arc/gnu/arcompact-dis.c rename to librz/arch/isa_gnu/arc/arcompact-dis.c index 7f17dc17fee..d92d430de27 100644 --- a/librz/arch/arch-asm/arc/gnu/arcompact-dis.c +++ b/librz/arch/isa_gnu/arc/arcompact-dis.c @@ -22,16 +22,16 @@ #include #include -#include #include #include -#include "disas-asm.h" +#include +#include #include "arc.h" #include "arc-ext.h" #include "arc-dis.h" #include "arcompact-dis.h" -#include "elf-bfd.h" +#include static bfd_vma bfd_getm32(unsigned int); static bfd_vma bfd_getm32_ac(unsigned int) ATTRIBUTE_UNUSED; diff --git a/librz/arch/arch-asm/arc/gnu/arcompact-dis.h b/librz/arch/isa_gnu/arc/arcompact-dis.h similarity index 100% rename from librz/arch/arch-asm/arc/gnu/arcompact-dis.h rename to librz/arch/isa_gnu/arc/arcompact-dis.h diff --git a/librz/arch/arch-asm/include/ansidecl.h b/librz/arch/isa_gnu/common_gnu/ansidecl.h similarity index 100% rename from librz/arch/arch-asm/include/ansidecl.h rename to librz/arch/isa_gnu/common_gnu/ansidecl.h diff --git a/librz/arch/arch-asm/include/bfdlink.h b/librz/arch/isa_gnu/common_gnu/bfdlink.h similarity index 99% rename from librz/arch/arch-asm/include/bfdlink.h rename to librz/arch/isa_gnu/common_gnu/bfdlink.h index 4c9507d22c1..49939139668 100644 --- a/librz/arch/arch-asm/include/bfdlink.h +++ b/librz/arch/isa_gnu/common_gnu/bfdlink.h @@ -25,7 +25,7 @@ #ifndef BFDLINK_H #define BFDLINK_H -#include "mybfd.h" +#include /* Which symbols to strip during a link. */ enum bfd_link_strip { diff --git a/librz/arch/arch-asm/include/disas-asm.h b/librz/arch/isa_gnu/common_gnu/disas-asm.h similarity index 99% rename from librz/arch/arch-asm/include/disas-asm.h rename to librz/arch/isa_gnu/common_gnu/disas-asm.h index f13a5bdbd0f..dbe7274a85d 100644 --- a/librz/arch/arch-asm/include/disas-asm.h +++ b/librz/arch/isa_gnu/common_gnu/disas-asm.h @@ -36,7 +36,7 @@ extern "C" { #include #include -#include "mybfd.h" +#include #define bfd_zalloc calloc #define bfd_malloc malloc diff --git a/librz/arch/arch-asm/include/elf-bfd.h b/librz/arch/isa_gnu/common_gnu/elf-bfd.h similarity index 99% rename from librz/arch/arch-asm/include/elf-bfd.h rename to librz/arch/isa_gnu/common_gnu/elf-bfd.h index 2b1b4054ef6..b9ae1bd56a7 100644 --- a/librz/arch/arch-asm/include/elf-bfd.h +++ b/librz/arch/isa_gnu/common_gnu/elf-bfd.h @@ -29,7 +29,7 @@ #include "elf/common.h" #include "elf/internal.h" #include "elf/external.h" -#include "bfdlink.h" +#include /* The number of entries in a section is its size divided by the size of a single entry. This is normally only applicable to reloc and diff --git a/librz/arch/arch-asm/include/elf/common.h b/librz/arch/isa_gnu/common_gnu/elf/common.h similarity index 100% rename from librz/arch/arch-asm/include/elf/common.h rename to librz/arch/isa_gnu/common_gnu/elf/common.h diff --git a/librz/arch/arch-asm/include/elf/external.h b/librz/arch/isa_gnu/common_gnu/elf/external.h similarity index 100% rename from librz/arch/arch-asm/include/elf/external.h rename to librz/arch/isa_gnu/common_gnu/elf/external.h diff --git a/librz/arch/arch-asm/include/elf/internal.h b/librz/arch/isa_gnu/common_gnu/elf/internal.h similarity index 100% rename from librz/arch/arch-asm/include/elf/internal.h rename to librz/arch/isa_gnu/common_gnu/elf/internal.h diff --git a/librz/arch/arch-asm/include/elf/mips.h b/librz/arch/isa_gnu/common_gnu/elf/mips.h similarity index 100% rename from librz/arch/arch-asm/include/elf/mips.h rename to librz/arch/isa_gnu/common_gnu/elf/mips.h diff --git a/librz/arch/arch-asm/include/elf/reloc-macros.h b/librz/arch/isa_gnu/common_gnu/elf/reloc-macros.h similarity index 100% rename from librz/arch/arch-asm/include/elf/reloc-macros.h rename to librz/arch/isa_gnu/common_gnu/elf/reloc-macros.h diff --git a/librz/arch/arch-asm/include/elf/xtensa.h b/librz/arch/isa_gnu/common_gnu/elf/xtensa.h similarity index 99% rename from librz/arch/arch-asm/include/elf/xtensa.h rename to librz/arch/isa_gnu/common_gnu/elf/xtensa.h index 62c0e787d06..4abf11a6044 100644 --- a/librz/arch/arch-asm/include/elf/xtensa.h +++ b/librz/arch/isa_gnu/common_gnu/elf/xtensa.h @@ -27,7 +27,7 @@ #ifndef _ELF_XTENSA_H #define _ELF_XTENSA_H -#include "elf/reloc-macros.h" +#include "reloc-macros.h" /* Relocations. */ START_RELOC_NUMBERS(elf_xtensa_reloc_type) diff --git a/librz/arch/arch-asm/include/libiberty.h b/librz/arch/isa_gnu/common_gnu/libiberty.h similarity index 99% rename from librz/arch/arch-asm/include/libiberty.h rename to librz/arch/isa_gnu/common_gnu/libiberty.h index d7f2375c2a5..cdcbe05efef 100644 --- a/librz/arch/arch-asm/include/libiberty.h +++ b/librz/arch/isa_gnu/common_gnu/libiberty.h @@ -42,7 +42,7 @@ extern "C" { #endif -#include "ansidecl.h" +#include /* Get a definition for size_t. */ #include diff --git a/librz/arch/arch-asm/include/mybfd.h b/librz/arch/isa_gnu/common_gnu/mybfd.h similarity index 99% rename from librz/arch/arch-asm/include/mybfd.h rename to librz/arch/isa_gnu/common_gnu/mybfd.h index 9cd6134b4ec..c8fe6ebf6b9 100644 --- a/librz/arch/arch-asm/include/mybfd.h +++ b/librz/arch/isa_gnu/common_gnu/mybfd.h @@ -39,7 +39,7 @@ extern "C" { #endif -#include "ansidecl.h" +#include #include "symcat.h" #if defined(__STDC__) || defined(ALMOST_STDC) || defined(HAVE_STRINGIZE) #ifndef SABER diff --git a/librz/arch/arch-asm/include/opcode/cris.h b/librz/arch/isa_gnu/common_gnu/opcode/cris.h similarity index 100% rename from librz/arch/arch-asm/include/opcode/cris.h rename to librz/arch/isa_gnu/common_gnu/opcode/cris.h diff --git a/librz/arch/arch-asm/include/opcode/hppa.h b/librz/arch/isa_gnu/common_gnu/opcode/hppa.h similarity index 100% rename from librz/arch/arch-asm/include/opcode/hppa.h rename to librz/arch/isa_gnu/common_gnu/opcode/hppa.h diff --git a/librz/arch/arch-asm/include/opcode/lanai.h b/librz/arch/isa_gnu/common_gnu/opcode/lanai.h similarity index 100% rename from librz/arch/arch-asm/include/opcode/lanai.h rename to librz/arch/isa_gnu/common_gnu/opcode/lanai.h diff --git a/librz/arch/arch-asm/include/opcode/mips.h b/librz/arch/isa_gnu/common_gnu/opcode/mips.h similarity index 100% rename from librz/arch/arch-asm/include/opcode/mips.h rename to librz/arch/isa_gnu/common_gnu/opcode/mips.h diff --git a/librz/arch/arch-asm/include/opcode/nios2.h b/librz/arch/isa_gnu/common_gnu/opcode/nios2.h similarity index 99% rename from librz/arch/arch-asm/include/opcode/nios2.h rename to librz/arch/isa_gnu/common_gnu/opcode/nios2.h index ffbac03cf0e..a335e592151 100644 --- a/librz/arch/arch-asm/include/opcode/nios2.h +++ b/librz/arch/isa_gnu/common_gnu/opcode/nios2.h @@ -26,7 +26,7 @@ #ifndef _NIOS2_H_ #define _NIOS2_H_ -#include "mybfd.h" +#include /**************************************************************************** * This file contains structures, bit masks and shift counts used diff --git a/librz/arch/arch-asm/include/opcode/ppc.h b/librz/arch/isa_gnu/common_gnu/opcode/ppc.h similarity index 100% rename from librz/arch/arch-asm/include/opcode/ppc.h rename to librz/arch/isa_gnu/common_gnu/opcode/ppc.h diff --git a/librz/arch/arch-asm/include/opcode/sparc.h b/librz/arch/isa_gnu/common_gnu/opcode/sparc.h similarity index 99% rename from librz/arch/arch-asm/include/opcode/sparc.h rename to librz/arch/isa_gnu/common_gnu/opcode/sparc.h index fe519b46936..e66192720bf 100644 --- a/librz/arch/arch-asm/include/opcode/sparc.h +++ b/librz/arch/isa_gnu/common_gnu/opcode/sparc.h @@ -23,7 +23,7 @@ the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "ansidecl.h" +#include /* The SPARC opcode table (and other related data) is defined in the opcodes library in sparc-opc.c. If you change anything here, make diff --git a/librz/arch/arch-asm/include/opintl.h b/librz/arch/isa_gnu/common_gnu/opintl.h similarity index 100% rename from librz/arch/arch-asm/include/opintl.h rename to librz/arch/isa_gnu/common_gnu/opintl.h diff --git a/librz/arch/arch-asm/include/safe-ctype.h b/librz/arch/isa_gnu/common_gnu/safe-ctype.h similarity index 100% rename from librz/arch/arch-asm/include/safe-ctype.h rename to librz/arch/isa_gnu/common_gnu/safe-ctype.h diff --git a/librz/arch/arch-asm/include/symcat.h b/librz/arch/isa_gnu/common_gnu/symcat.h similarity index 100% rename from librz/arch/arch-asm/include/symcat.h rename to librz/arch/isa_gnu/common_gnu/symcat.h diff --git a/librz/arch/arch-asm/include/sysdep.h b/librz/arch/isa_gnu/common_gnu/sysdep.h similarity index 97% rename from librz/arch/arch-asm/include/sysdep.h rename to librz/arch/isa_gnu/common_gnu/sysdep.h index 37fb1a3f205..d0f6eb6af6f 100644 --- a/librz/arch/arch-asm/include/sysdep.h +++ b/librz/arch/isa_gnu/common_gnu/sysdep.h @@ -29,7 +29,7 @@ trying to replace often did that. If it can be dropped from this file (check in a non-ANSI environment!), it should be. */ -#include "ansidecl.h" +#include #ifdef HAVE_STDLIB_H #include diff --git a/librz/arch/arch-asm/cris/gnu/cris-dis.c b/librz/arch/isa_gnu/cris/cris-dis.c similarity index 99% rename from librz/arch/arch-asm/cris/gnu/cris-dis.c rename to librz/arch/isa_gnu/cris/cris-dis.c index e6fd11b9a6b..4cd5bf6e98c 100644 --- a/librz/arch/arch-asm/cris/gnu/cris-dis.c +++ b/librz/arch/isa_gnu/cris/cris-dis.c @@ -24,10 +24,10 @@ #include #include #include -#include "disas-asm.h" -#include "sysdep.h" -#include "opcode/cris.h" -#include "libiberty.h" +#include +#include +#include +#include /* Return TRUE if the start of STR matches PREFIX, FALSE otherwise. */ diff --git a/librz/arch/arch-asm/cris/gnu/cris-opc.c b/librz/arch/isa_gnu/cris/cris-opc.c similarity index 99% rename from librz/arch/arch-asm/cris/gnu/cris-opc.c rename to librz/arch/isa_gnu/cris/cris-opc.c index c031c9b0d28..819f00ab13d 100644 --- a/librz/arch/arch-asm/cris/gnu/cris-opc.c +++ b/librz/arch/isa_gnu/cris/cris-opc.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "opcode/cris.h" +#include #ifndef NULL #define NULL (0) diff --git a/librz/arch/arch-asm/hppa/gnu/hppa-dis.c b/librz/arch/isa_gnu/hppa/hppa-dis.c similarity index 99% rename from librz/arch/arch-asm/hppa/gnu/hppa-dis.c rename to librz/arch/isa_gnu/hppa/hppa-dis.c index dfffd1a40d4..aa53f0af5be 100644 --- a/librz/arch/arch-asm/hppa/gnu/hppa-dis.c +++ b/librz/arch/isa_gnu/hppa/hppa-dis.c @@ -21,10 +21,10 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "sysdep.h" -#include "disas-asm.h" +#include +#include #include "libhppa.h" -#include "opcode/hppa.h" +#include #include #include diff --git a/librz/arch/arch-asm/include/libhppa.h b/librz/arch/isa_gnu/hppa/libhppa.h similarity index 100% rename from librz/arch/arch-asm/include/libhppa.h rename to librz/arch/isa_gnu/hppa/libhppa.h diff --git a/librz/arch/arch-asm/lanai/gnu/lanai-dis.c b/librz/arch/isa_gnu/lanai/lanai-dis.c similarity index 99% rename from librz/arch/arch-asm/lanai/gnu/lanai-dis.c rename to librz/arch/isa_gnu/lanai/lanai-dis.c index e3fb8cdce2a..02ec77f54b3 100644 --- a/librz/arch/arch-asm/lanai/gnu/lanai-dis.c +++ b/librz/arch/isa_gnu/lanai/lanai-dis.c @@ -58,9 +58,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include -#include "ansidecl.h" -#include "opcode/lanai.h" -#include "disas-asm.h" +#include +#include +#include static char *reg_names[] = { "r0", diff --git a/librz/arch/arch-asm/lanai/gnu/lanai-opc.c b/librz/arch/isa_gnu/lanai/lanai-opc.c similarity index 99% rename from librz/arch/arch-asm/lanai/gnu/lanai-opc.c rename to librz/arch/isa_gnu/lanai/lanai-opc.c index ba7a3bab498..042e77e2837 100644 --- a/librz/arch/arch-asm/lanai/gnu/lanai-opc.c +++ b/librz/arch/isa_gnu/lanai/lanai-opc.c @@ -65,8 +65,8 @@ `casx', `clrx', `clruw' synthetic instructions for v9. */ #include -#include "ansidecl.h" -#include "opcode/lanai.h" +#include +#include const char *architecture_pname[] = { "v0", diff --git a/librz/arch/arch-asm/mips/gnu/mips-dis.c b/librz/arch/isa_gnu/mips/mips-dis.c similarity index 99% rename from librz/arch/arch-asm/mips/gnu/mips-dis.c rename to librz/arch/isa_gnu/mips/mips-dis.c index f36eea2b430..6dd086cd5a1 100644 --- a/librz/arch/arch-asm/mips/gnu/mips-dis.c +++ b/librz/arch/isa_gnu/mips/mips-dis.c @@ -24,22 +24,22 @@ #include #include #include -#include "ansidecl.h" -#include "sysdep.h" -#include "disas-asm.h" -#include "libiberty.h" -#include "elf/mips.h" -#include "opintl.h" +#include +#include +#include +#include +#include +#include /* FIXME: These are needed to figure out if the code is mips16 or not. The low bit of the address is often a good indicator. No symbol table is available when this code runs out in an embedded system as when it is used for disassembler support in a monitor. */ -#include "opcode/mips.h" +#include #if !defined(EMBEDDED_ENV) #define SYMTAB_AVAILABLE 1 -#include "elf-bfd.h" +#include #endif /* Mips instructions are at maximum this many bytes long. */ diff --git a/librz/arch/arch-asm/mips/gnu/mips-opc.c b/librz/arch/isa_gnu/mips/mips-opc.c similarity index 99% rename from librz/arch/arch-asm/mips/gnu/mips-opc.c rename to librz/arch/isa_gnu/mips/mips-opc.c index e4bdb20d5db..9161652e4ce 100644 --- a/librz/arch/arch-asm/mips/gnu/mips-opc.c +++ b/librz/arch/isa_gnu/mips/mips-opc.c @@ -25,8 +25,8 @@ MA 02110-1301, USA. */ #include -#include "sysdep.h" -#include "opcode/mips.h" +#include +#include /* Short hand so the lines aren't too long. */ diff --git a/librz/arch/arch-asm/mips/gnu/mips16-opc.c b/librz/arch/isa_gnu/mips/mips16-opc.c similarity index 99% rename from librz/arch/arch-asm/mips/gnu/mips16-opc.c rename to librz/arch/isa_gnu/mips/mips16-opc.c index 233518535d0..a1eaeb3b325 100644 --- a/librz/arch/arch-asm/mips/gnu/mips16-opc.c +++ b/librz/arch/isa_gnu/mips/mips16-opc.c @@ -20,8 +20,8 @@ MA 02110-1301, USA. */ #include -#include "sysdep.h" -#include "opcode/mips.h" +#include +#include /* This is the opcodes table for the mips16 processor. The format of this table is intentionally identical to the one in mips-opc.c. diff --git a/librz/arch/arch-asm/nios/gnu/nios2-dis.c b/librz/arch/isa_gnu/nios/nios2-dis.c similarity index 98% rename from librz/arch/arch-asm/nios/gnu/nios2-dis.c rename to librz/arch/isa_gnu/nios/nios2-dis.c index 7bc597fd19d..bc4f574de1b 100644 --- a/librz/arch/arch-asm/nios/gnu/nios2-dis.c +++ b/librz/arch/isa_gnu/nios/nios2-dis.c @@ -20,10 +20,10 @@ Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "sysdep.h" -#include "disas-asm.h" -#include "opcode/nios2.h" -#include "libiberty.h" +#include +#include +#include +#include #include #include #include @@ -32,7 +32,7 @@ system as when it is used for disassembler support in a monitor. */ #if !defined(EMBEDDED_ENV) #define SYMTAB_AVAILABLE 1 -#include "elf-bfd.h" +#include //#include "elf/nios2.h" #endif diff --git a/librz/arch/arch-asm/nios/gnu/nios2-opc.c b/librz/arch/isa_gnu/nios/nios2-opc.c similarity index 99% rename from librz/arch/arch-asm/nios/gnu/nios2-opc.c rename to librz/arch/isa_gnu/nios/nios2-opc.c index 83cf1898aff..7184c8f6539 100644 --- a/librz/arch/arch-asm/nios/gnu/nios2-opc.c +++ b/librz/arch/isa_gnu/nios/nios2-opc.c @@ -20,9 +20,9 @@ Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "sysdep.h" +#include #include -#include "opcode/nios2.h" +#include /* Register string table */ diff --git a/librz/arch/arch-asm/riscv/riscv-opc.c b/librz/arch/isa_gnu/riscv/riscv-opc.c similarity index 100% rename from librz/arch/arch-asm/riscv/riscv-opc.c rename to librz/arch/isa_gnu/riscv/riscv-opc.c diff --git a/librz/arch/arch-asm/riscv/riscv-opc.h b/librz/arch/isa_gnu/riscv/riscv-opc.h similarity index 100% rename from librz/arch/arch-asm/riscv/riscv-opc.h rename to librz/arch/isa_gnu/riscv/riscv-opc.h diff --git a/librz/arch/isa_gnu/riscv/riscv.c b/librz/arch/isa_gnu/riscv/riscv.c new file mode 100644 index 00000000000..9af87e2bf49 --- /dev/null +++ b/librz/arch/isa_gnu/riscv/riscv.c @@ -0,0 +1,333 @@ +// SPDX-FileCopyrightText: 2011-2015 Free Software Foundation, Inc. +// SPDX-License-Identifier: GPL-3.0-or-later + +/* RISC-V disassembler + Copyright 2011-2015 Free Software Foundation, Inc. + Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. + Based on MIPS target. + This file is part of the GNU opcodes library. + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING3. If not, + see . + + - Code changes to make r2 friendly (qnix@0x80.org) +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "riscv-opc.h" +#include "riscv.h" + +#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 bool init_asm = 0; + +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); +} + +/* Print insn arguments for 32/64-bit code. */ +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), " "); + } + + for (; *d != '\0'; d++) { + switch (*d) { + /* Xcustom */ + case '^': + switch (*++d) { + case 'd': + sprintf(buf + strlen(buf), "%d", rd); + break; + case 's': + sprintf(buf + strlen(buf), "%d", rs1); + break; + case 't': + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_OPERAND(RS2, l)); + break; + case 'j': + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_OPERAND(CUSTOM_IMM, l)); + break; + } + break; + + case 'C': /* RVC */ + 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]); + break; + case 't': /* RS2 x8-x15 */ + case 'x': /* RS2 x8-x15 */ + 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]); + break; + case 'c': /* RS1, constrained to equal 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)]); + break; + case 'i': + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_SIMM3(l)); + break; + case 'j': + sprintf(buf + strlen(buf), "%d", (int)EXTRACT_RVC_IMM(l)); + break; + case 'k': + 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)); + break; + case 'm': + 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)); + break; + case 'K': + 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)); + break; + case 'M': + 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)); + break; + case 'p': + 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); + break; + case 'u': + 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); + break; + case '<': + 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)]); + break; + case 'D': /* floating-point RS2 x8-x15 */ + sprintf(buf + strlen(buf), "%s", + riscv_fpr_names[EXTRACT_OPERAND(CRS2S, l) + 8]); + break; + } + break; + + case ',': + sprintf(buf + strlen(buf), "%c ", *d); + break; + case '(': + case ')': + case '[': + case ']': + 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"); + } + break; + + case 'b': + case 's': + sprintf(buf + strlen(buf), "%s", riscv_gpr_names[rs1]); + break; + + case 't': + 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); + break; + + case 'm': + 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)); + break; + + case 'Q': + 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)); + break; + case 'q': + 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); + break; + case 'p': + 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]); + break; + case 'z': + sprintf(buf + strlen(buf), "%s", riscv_gpr_names[0]); + break; + case '>': + sprintf(buf + strlen(buf), "0x%x", (int)EXTRACT_OPERAND(SHAMT, l)); + break; + case '<': + 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]); + break; + case 'T': + sprintf(buf + strlen(buf), "%s", riscv_fpr_names[EXTRACT_OPERAND(RS2, l)]); + break; + case 'D': + sprintf(buf + strlen(buf), "%s", riscv_fpr_names[rd]); + break; + case 'R': + 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; +#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; + } + case 'Z': + sprintf(buf + strlen(buf), "%d", rs1); + break; + default: + /* xgettext:c-format */ + sprintf(buf + strlen(buf), "# internal error, undefined modifier (%c)", + *d); + return; + } + } +} + +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 }; + +#define OP_HASH_IDX(i) ((i) & (riscv_insn_length(i) == 2 ? 3 : OP_MASK_OP)) + + if (!init_asm) { + 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_asm = 1; + } + + 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); + if (!op) { + return -1; + } + for (; op < &riscv_opcodes[NUMOPCODES]; op++) { + 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) { + 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); + return 0; + } + return -1; + } + return 0; +} + +static int riscv_dis(RzAsm *a, RzAsmOp *rop, const ut8 *buf, ut64 len) { + insn_t insn = { 0 }; + rz_asm_op_set_asm(rop, "invalid"); + if (len < 2) { + return -1; + } + // Read <= 8 bytes into 8-byte buffer in little endian fashion + RZ_STATIC_ASSERT(sizeof(insn) == 8); + ut8 tmp[8] = { 0 }; + memcpy(&tmp, buf, RZ_MIN(sizeof(insn), len)); + insn = rz_read_le64(tmp); + int insn_len = riscv_insn_length(insn); + if (len < insn_len) { + return -1; + } + riscv_disassemble(a, rop, insn, a->bits, len); + return insn_len; +} diff --git a/librz/arch/arch-asm/riscv/riscv.h b/librz/arch/isa_gnu/riscv/riscv.h similarity index 93% rename from librz/arch/arch-asm/riscv/riscv.h rename to librz/arch/isa_gnu/riscv/riscv.h index e7b1769120a..dcf70306981 100644 --- a/librz/arch/arch-asm/riscv/riscv.h +++ b/librz/arch/isa_gnu/riscv/riscv.h @@ -196,35 +196,35 @@ static const char * const riscv_pred_succ[16] = /* RV fields. */ -#define OP_MASK_OP 0x7f -#define OP_SH_OP 0 -#define OP_MASK_RS2 0x1f -#define OP_SH_RS2 20 -#define OP_MASK_RS1 0x1f -#define OP_SH_RS1 15 -#define OP_MASK_RS3 0x1f -#define OP_SH_RS3 27 -#define OP_MASK_RD 0x1f -#define OP_SH_RD 7 -#define OP_MASK_SHAMT 0x3f -#define OP_SH_SHAMT 20 -#define OP_MASK_SHAMTW 0x1f -#define OP_SH_SHAMTW 20 -#define OP_MASK_RM 0x7 -#define OP_SH_RM 12 -#define OP_MASK_PRED 0xf -#define OP_SH_PRED 24 -#define OP_MASK_SUCC 0xf -#define OP_SH_SUCC 20 -#define OP_MASK_AQ 0x1 -#define OP_SH_AQ 26 -#define OP_MASK_RL 0x1 -#define OP_SH_RL 25 - -#define OP_MASK_CUSTOM_IMM 0x7f -#define OP_SH_CUSTOM_IMM 25 -#define OP_MASK_CSR 0xfff -#define OP_SH_CSR 20 +#define OP_MASK_OP 0x7f +#define OP_SH_OP 0 +#define OP_MASK_RS2 0x1f +#define OP_SH_RS2 20 +#define OP_MASK_RS1 0x1f +#define OP_SH_RS1 15 +#define OP_MASK_RS3 0x1f +#define OP_SH_RS3 27 +#define OP_MASK_RD 0x1f +#define OP_SH_RD 7 +#define OP_MASK_SHAMT 0x3f +#define OP_SH_SHAMT 20 +#define OP_MASK_SHAMTW 0x1f +#define OP_SH_SHAMTW 20 +#define OP_MASK_RM 0x7 +#define OP_SH_RM 12 +#define OP_MASK_PRED 0xf +#define OP_SH_PRED 24 +#define OP_MASK_SUCC 0xf +#define OP_SH_SUCC 20 +#define OP_MASK_AQ 0x1 +#define OP_SH_AQ 26 +#define OP_MASK_RL 0x1 +#define OP_SH_RL 25 + +#define OP_MASK_CUSTOM_IMM 0x7f +#define OP_SH_CUSTOM_IMM 25 +#define OP_MASK_CSR 0xfff +#define OP_SH_CSR 20 /* RVC fields. */ @@ -253,7 +253,7 @@ static const char * const riscv_pred_succ[16] = VALUE << SHIFT. VALUE is evaluated exactly once. */ #define INSERT_BITS(STRUCT, VALUE, MASK, SHIFT) \ (STRUCT) = (((STRUCT) & ~((insn_t)(MASK) << (SHIFT))) \ - | ((insn_t)((VALUE) & (MASK)) << (SHIFT))) + | ((insn_t)((VALUE) & (MASK)) << (SHIFT))) /* Extract bits MASK << SHIFT from STRUCT and shift them right SHIFT places. */ @@ -294,10 +294,10 @@ struct riscv_opcode }; /* Instruction is a simple alias (e.g. "mv" for "addi"). */ -#define INSN_ALIAS 0x00000001 +#define INSN_ALIAS 0x00000001 /* Instruction is actually a macro. It should be ignored by the disassembler, and requires special treatment by the assembler. */ -#define INSN_MACRO 0xffffffff +#define INSN_MACRO 0xffffffff /* This is a list of macro expanded instructions. diff --git a/librz/arch/isa_gnu/riscv/riscv_inc.h b/librz/arch/isa_gnu/riscv/riscv_inc.h new file mode 100644 index 00000000000..21c6fec9eea --- /dev/null +++ b/librz/arch/isa_gnu/riscv/riscv_inc.h @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#ifndef RISCV_INC_H +#define RISCV_INC_H + +#include + +int riscv_dis(RzAsm *a, RzAsmOp *rop, const ut8 *buf, ut64 len); + +#endif /* RISCV_INC_H */ \ No newline at end of file diff --git a/librz/arch/arch-asm/sparc/gnu/sparc-dis.c b/librz/arch/isa_gnu/sparc/sparc-dis.c similarity index 99% rename from librz/arch/arch-asm/sparc/gnu/sparc-dis.c rename to librz/arch/isa_gnu/sparc/sparc-dis.c index 4cc7036d7d3..ef40982ae5c 100644 --- a/librz/arch/arch-asm/sparc/gnu/sparc-dis.c +++ b/librz/arch/isa_gnu/sparc/sparc-dis.c @@ -26,11 +26,11 @@ #include #include -#include "sysdep.h" -#include "opcode/sparc.h" -#include "disas-asm.h" +#include +#include +#include #ifndef _MSC_VER -#include "libiberty.h" +#include #else #include #define XNEWVEC(T, N) ((T *) malloc (sizeof (T) * (N))) @@ -38,7 +38,7 @@ #define XNEW(T) ((T *) malloc (sizeof (T))) #define xmalloc malloc #endif -#include "opintl.h" +#include /* Bitmask of v9 architectures. */ #define MASK_V9 ((1 << SPARC_OPCODE_ARCH_V9) \ diff --git a/librz/arch/arch-asm/sparc/gnu/sparc-opc.c b/librz/arch/isa_gnu/sparc/sparc-opc.c similarity index 99% rename from librz/arch/arch-asm/sparc/gnu/sparc-opc.c rename to librz/arch/isa_gnu/sparc/sparc-opc.c index dcf11adec9d..22a90acfdec 100644 --- a/librz/arch/arch-asm/sparc/gnu/sparc-opc.c +++ b/librz/arch/isa_gnu/sparc/sparc-opc.c @@ -27,8 +27,8 @@ #include #include -#include "sysdep.h" -#include "opcode/sparc.h" +#include +#include /* Some defines to make life easy. */ #define MASK_V6 SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V6) diff --git a/librz/arch/arch-asm/vax/vax-dis.c b/librz/arch/isa_gnu/vax/vax-dis.c similarity index 99% rename from librz/arch/arch-asm/vax/vax-dis.c rename to librz/arch/isa_gnu/vax/vax-dis.c index 81bf2d99fe1..670bb147843 100644 --- a/librz/arch/arch-asm/vax/vax-dis.c +++ b/librz/arch/isa_gnu/vax/vax-dis.c @@ -23,13 +23,13 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "sysdep.h" +#include #include #include #include #include #include "vax.h" -#include "disas-asm.h" +#include static char *reg_names[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", diff --git a/librz/arch/arch-asm/vax/vax.h b/librz/arch/isa_gnu/vax/vax.h similarity index 100% rename from librz/arch/arch-asm/vax/vax.h rename to librz/arch/isa_gnu/vax/vax.h diff --git a/librz/arch/arch-asm/xtensa/gnu/elf32-xtensa.c b/librz/arch/isa_gnu/xtensa/elf32-xtensa.c similarity index 99% rename from librz/arch/arch-asm/xtensa/gnu/elf32-xtensa.c rename to librz/arch/isa_gnu/xtensa/elf32-xtensa.c index 46e7a9f4256..fd0d7dc0b4d 100644 --- a/librz/arch/arch-asm/xtensa/gnu/elf32-xtensa.c +++ b/librz/arch/isa_gnu/xtensa/elf32-xtensa.c @@ -18,19 +18,17 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "sysdep.h" -#include "disas-asm.h" +#include +#include +#include +#include +#include + #include #include #include -#include "bfdlink.h" -//#include "libbfd.h" -#include "elf-bfd.h" -#include "elf/xtensa.h" -//#include "splay-tree.h" #include "xtensa-isa.h" -//#include "xtensa-config.h" #define XTENSA_NO_NOP_REMOVAL 0 diff --git a/librz/arch/arch-asm/xtensa/gnu/xtensa-dis.c b/librz/arch/isa_gnu/xtensa/xtensa-dis.c similarity index 98% rename from librz/arch/arch-asm/xtensa/gnu/xtensa-dis.c rename to librz/arch/isa_gnu/xtensa/xtensa-dis.c index 12e54cbb916..ba31e2b6de4 100644 --- a/librz/arch/arch-asm/xtensa/gnu/xtensa-dis.c +++ b/librz/arch/isa_gnu/xtensa/xtensa-dis.c @@ -19,16 +19,18 @@ Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "sysdep.h" +#include +#include +#include +#include + #include #include #include #include -#include "xtensa-isa.h" -#include "ansidecl.h" #include -#include "disas-asm.h" -#include "libiberty.h" + +#include "xtensa-isa.h" #if defined(_MSC_VER) diff --git a/librz/arch/arch-asm/include/xtensa-isa-internal.h b/librz/arch/isa_gnu/xtensa/xtensa-isa-internal.h similarity index 100% rename from librz/arch/arch-asm/include/xtensa-isa-internal.h rename to librz/arch/isa_gnu/xtensa/xtensa-isa-internal.h diff --git a/librz/arch/arch-asm/xtensa/gnu/xtensa-isa.c b/librz/arch/isa_gnu/xtensa/xtensa-isa.c similarity index 99% rename from librz/arch/arch-asm/xtensa/gnu/xtensa-isa.c rename to librz/arch/isa_gnu/xtensa/xtensa-isa.c index d385fb9ebe7..a54327c97ba 100644 --- a/librz/arch/arch-asm/xtensa/gnu/xtensa-isa.c +++ b/librz/arch/isa_gnu/xtensa/xtensa-isa.c @@ -18,18 +18,15 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ - #include #include #include #include -#include "../../include/disas-asm.h" -#include "../../include/sysdep.h" -//#include "bfd.h" -//#include "libbfd.h" -#include "../../include/xtensa-isa.h" -#include "../../include/xtensa-isa-internal.h" +#include +#include +#include "xtensa-isa.h" +#include "xtensa-isa-internal.h" extern int filename_cmp (const char *s1, const char *s2); xtensa_isa_status xtisa_errno; diff --git a/librz/arch/arch-asm/include/xtensa-isa.h b/librz/arch/isa_gnu/xtensa/xtensa-isa.h similarity index 99% rename from librz/arch/arch-asm/include/xtensa-isa.h rename to librz/arch/isa_gnu/xtensa/xtensa-isa.h index 68cd0b49a3c..8fd13f87587 100644 --- a/librz/arch/arch-asm/include/xtensa-isa.h +++ b/librz/arch/isa_gnu/xtensa/xtensa-isa.h @@ -24,7 +24,7 @@ #ifndef XTENSA_LIBISA_H #define XTENSA_LIBISA_H -#include "rz_types.h" +#include #ifdef __cplusplus extern "C" { diff --git a/librz/arch/arch-asm/xtensa/gnu/xtensa-modules.c b/librz/arch/isa_gnu/xtensa/xtensa-modules.c similarity index 99% rename from librz/arch/arch-asm/xtensa/gnu/xtensa-modules.c rename to librz/arch/isa_gnu/xtensa/xtensa-modules.c index 603e2685536..afa0c794f0c 100644 --- a/librz/arch/arch-asm/xtensa/gnu/xtensa-modules.c +++ b/librz/arch/isa_gnu/xtensa/xtensa-modules.c @@ -21,9 +21,8 @@ #ifndef ATTRIBUTE_UNUSED #define ATTRIBUTE_UNUSED #endif -//#include "ansidecl.h" -#include "../../include/xtensa-isa.h" -#include "../../include/xtensa-isa-internal.h" +#include "xtensa-isa.h" +#include "xtensa-isa-internal.h" /* Sysregs. */ diff --git a/librz/arch/arch-asm/z80/expressions.c b/librz/arch/isa_gnu/z80/expressions.c similarity index 100% rename from librz/arch/arch-asm/z80/expressions.c rename to librz/arch/isa_gnu/z80/expressions.c diff --git a/librz/arch/arch-asm/z80/z80.c b/librz/arch/isa_gnu/z80/z80.c similarity index 100% rename from librz/arch/arch-asm/z80/z80.c rename to librz/arch/isa_gnu/z80/z80.c diff --git a/librz/arch/arch-asm/z80/z80_tab.h b/librz/arch/isa_gnu/z80/z80_tab.h similarity index 100% rename from librz/arch/arch-asm/z80/z80_tab.h rename to librz/arch/isa_gnu/z80/z80_tab.h diff --git a/librz/arch/arch-asm/z80/z80asm.c b/librz/arch/isa_gnu/z80/z80asm.c similarity index 100% rename from librz/arch/arch-asm/z80/z80asm.c rename to librz/arch/isa_gnu/z80/z80asm.c diff --git a/librz/arch/arch-asm/z80/z80asm.h b/librz/arch/isa_gnu/z80/z80asm.h similarity index 100% rename from librz/arch/arch-asm/z80/z80asm.h rename to librz/arch/isa_gnu/z80/z80asm.h diff --git a/librz/arch/meson-analysis.build b/librz/arch/meson-analysis.build deleted file mode 100644 index 9ef0054d406..00000000000 --- a/librz/arch/meson-analysis.build +++ /dev/null @@ -1,330 +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', - 'rx', - '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_rx.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', - 'arch/v850/v850_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/meson-asm.build b/librz/arch/meson-asm.build deleted file mode 100644 index d0f6ea0b999..00000000000 --- a/librz/arch/meson-asm.build +++ /dev/null @@ -1,349 +0,0 @@ -asm_plugins_list = [ - '6502', - '8051', - 'amd29k', - 'arm_as', - 'arm_cs', - 'avr', - 'bf', - 'chip8', - 'cil', - 'cr16', - 'dalvik', - 'dcpu16', - 'ebc', - 'gb', - 'h8300', - 'hexagon', - 'i4004', - 'i8080', - 'java', - 'lh5801', - 'lm32', - 'luac', - 'm68k_cs', - 'm680x_cs', - 'malbolge', - 'mcore', - 'mcs96', - 'mips_cs', - 'msp430', - 'null', - 'or1k', - 'pic', - 'ppc_as', - 'ppc_cs', - 'propeller', - 'pyc', - 'rl78', - 'rsp', - 'rx', - 'sh', - 'snes', - 'sparc_cs', - 'spc700', - 'sysz', - 'tms320', - 'tms320c64x', - 'v810', - 'v850', - 'wasm', - 'x86_as', - 'x86_cs', - 'x86_nasm', - 'x86_nz', - 'xap', - 'xcore_cs', -] - -if capstone_dep.version() == 'next' or capstone_dep.version().split('.')[0].to_int() > 4 - asm_plugins_list += 'riscv_cs' - asm_plugins_list += 'tricore' -endif - -if get_option('use_gpl') - asm_plugins_list += [ - 'arc', - 'cris_gnu', - 'hppa_gnu', - 'lanai_gnu', - 'mips_gnu', - 'nios2', - 'riscv', - 'sparc_gnu', - 'vax', - 'xtensa', - 'z80', - ] -endif - -asm_plugins = { - 'conf_name': 'plugins_asm', - 'base_cname': 'rz_asm_plugin_', - 'list': asm_plugins_list, -} - -rz_asm_sources = [ - 'asm.c', - 'aop.c', - 'acode.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_rx.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', - #'arch/6502/6502dis.c', - 'arch/amd29k/amd29k.c', - #'arch/8051/8051_disas.c', - 'arch/8051/8051_ass.c', - 'arch/arm/armass.c', - 'arch/arm/armass64.c', - 'arch/arm/arm_it.c', - 'arch/avr/disassembler.c', - 'arch/avr/assembler.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/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/assembly_53.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/propeller/propeller_disas.c', - 'arch/pyc/opcode_10.c', - 'arch/pyc/opcode_11.c', - 'arch/pyc/opcode_12.c', - 'arch/pyc/opcode_13.c', - 'arch/pyc/opcode_14.c', - 'arch/pyc/opcode_15.c', - 'arch/pyc/opcode_16.c', - 'arch/pyc/opcode_20.c', - 'arch/pyc/opcode_21.c', - 'arch/pyc/opcode_22.c', - 'arch/pyc/opcode_23.c', - 'arch/pyc/opcode_24.c', - 'arch/pyc/opcode_25.c', - 'arch/pyc/opcode_26.c', - 'arch/pyc/opcode_27.c', - 'arch/pyc/opcode_2x.c', - 'arch/pyc/opcode_30.c', - 'arch/pyc/opcode_31.c', - 'arch/pyc/opcode_32.c', - 'arch/pyc/opcode_33.c', - 'arch/pyc/opcode_34.c', - 'arch/pyc/opcode_35.c', - 'arch/pyc/opcode_36.c', - '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_instr.c', - 'arch/rl78/rl78_maps.c', - 'arch/rl78/rl78_operand.c', - 'arch/rl78/rl78.c', - 'arch/rx/rx.c', - 'arch/rx/rx_opcode_detail.c', - 'arch/rx/rx_inst.c', - 'arch/rsp/rsp_idec.c', - 'arch/sh/disassembler.c', - 'arch/sh/assembler.c', - 'arch/sh/lookup.c', - #'arch/snes/snesdis.c', - #'arch/spc700/spc700dis.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/v850/v850_disas.c', - 'arch/wasm/wasm.c', - #'arch/xap/dis.c', - 'arch/z80/z80.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' -endif - -if get_option('use_gpl') - rz_asm_sources += [ - 'arch/arc/gnu/arc-dis.c', - 'arch/arc/gnu/arc-ext.c', - 'arch/arc/gnu/arc-opc.c', - 'arch/arc/gnu/arcompact-dis.c', - 'arch/cris/gnu/cris-dis.c', - 'arch/cris/gnu/cris-opc.c', - 'arch/hppa/gnu/hppa-dis.c', - 'arch/lanai/gnu/lanai-dis.c', - 'arch/lanai/gnu/lanai-opc.c', - 'arch/mips/gnu/mips-dis.c', - 'arch/mips/gnu/mips-opc.c', - 'arch/mips/gnu/mips16-opc.c', - 'arch/nios/gnu/nios2-dis.c', - 'arch/nios/gnu/nios2-opc.c', - #'arch/riscv/riscv-opc.c', - #'arch/riscv/riscv.c', - 'arch/sparc/gnu/sparc-dis.c', - 'arch/sparc/gnu/sparc-opc.c', - 'arch/vax/vax-dis.c', - 'arch/xtensa/gnu/elf32-xtensa.c', - 'arch/xtensa/gnu/xtensa-dis.c', - 'arch/xtensa/gnu/xtensa-isa.c', - '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', - ] -endif - -rz_asm_inc = [ - platform_inc, - include_directories( - 'arch/include', - 'arch', - 'arch/h8300', - 'arch/hexagon', - 'arch/msp430', - 'arch/rsp', - 'arch/mcore', - 'arch/v850', - 'arch/propeller', - 'arch/ebc', - 'arch/cr16', - 'arch/8051', - 'arch/v810', - 'arch/or1k', - 'arch/tricore', - ) -] - -rz_asm = library('rz_asm', rz_asm_sources, - include_directories: rz_asm_inc, - dependencies: [ - rz_util_dep, - rz_config_dep, - rz_syscall_dep, - rz_flag_dep, - rz_parse_dep, - rz_bin_dep, - capstone_dep, - dependency('rzspp'), - ], - 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_asm_dep = declare_dependency(link_with: rz_asm, - include_directories: rz_asm_inc) -meson.override_dependency('rz_asm', rz_asm_dep) - -modules += { 'rz_asm': { - 'target': rz_asm, - 'dependencies': ['rz_util', 'rz_config', 'rz_syscall', 'rz_flag', 'rz_parse', 'rz_bin'], - 'plugins': [asm_plugins] -}} - -subdir('d') -subdir('cpus') -subdir('platforms') diff --git a/librz/arch/meson.build b/librz/arch/meson.build new file mode 100644 index 00000000000..40c3c08849a --- /dev/null +++ b/librz/arch/meson.build @@ -0,0 +1,456 @@ +subdir('opcodes') +subdir('types') +subdir('cpus') +subdir('platforms') + +arch_plugins_list = [ + '6502', + '8051', + 'amd29k', + 'arm_as', + 'arm_cs', + 'avr', + 'bf', + 'chip8', + 'cil', + 'cr16', + 'dalvik', + 'dcpu16', + 'ebc', + 'gb', + 'h8300', + 'hexagon', + 'i4004', + 'i8080', + 'java', + 'lh5801', + 'lm32', + 'luac', + 'm680x_cs', + 'm68k_cs', + 'malbolge', + 'mcore', + 'mcs96', + 'mips_cs', + 'msp430', + 'null', + 'or1k', + 'pic', + 'ppc_as', + 'ppc_cs', + 'propeller', + 'pyc', + 'rl78', + 'rsp', + 'rx', + 'sh', + 'snes', + 'sparc_cs', + 'spc700', + 'sysz', + 'tms320', + 'v810', + 'v850', + 'wasm', + 'x86_as', + 'x86_cs', + 'x86_nasm', + 'x86_nz', + 'xap', + 'xcore_cs', +] + +arch_plugin_sources = [ + '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_riscv_cs.c', + 'p/arch_rl78.c', + 'p/arch_rsp.c', + 'p/arch_rx.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_tricore_cs.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', +] + +arch_esil_sources = [ + 'esil/esil.c', + 'esil/esil_interrupt.c', + 'esil/esil_sources.c', + 'esil/esil_stats.c', + 'esil/esil_trace.c', +] + +arch_il_sources = [ + 'il/analysis_il.c', + 'il/analysis_il_trace.c', +] + +arch_isa_sources = [ + 'isa/6502/6502dis.c', + 'isa/8051/8051_ass.c', + 'isa/8051/8051_disas.c', + 'isa/8051/8051_il.c', + 'isa/8051/8051_parse.c', + 'isa/amd29k/amd29k.c', + 'isa/arm/arm_esil32.c', + 'isa/arm/arm_esil64.c', + 'isa/arm/arm_il32.c', + 'isa/arm/arm_il64.c', + 'isa/arm/arm_it.c', + 'isa/arm/armass.c', + 'isa/arm/armass64.c', + 'isa/avr/assembler.c', + 'isa/avr/avr_esil.c', + 'isa/avr/avr_il.c', + 'isa/avr/disassembler.c', + 'isa/cil/cil_dis.c', + 'isa/cr16/cr16_disas.c', + 'isa/dcpu16/asm.c', + 'isa/dcpu16/dis.c', + 'isa/ebc/ebc_disas.c', + 'isa/gb/gbasm.c', + # 'isa/gb/gbdis.c', + # 'isa/gb/meta_gb_cmt.c', + 'isa/h8300/h8300_disas.c', + 'isa/hexagon/hexagon.c', + 'isa/hexagon/hexagon_arch.c', + 'isa/hexagon/hexagon_disas.c', + 'isa/i4004/i4004dis.c', + 'isa/i8080/i8080dis.c', + 'isa/java/assembler.c', + 'isa/java/jvm.c', + 'isa/lh5801/lh5801.c', + 'isa/luac/lua_arch.c', + 'isa/luac/v53/analysis_53.c', + 'isa/luac/v53/assembly_53.c', + 'isa/luac/v53/disassembly_53.c', + 'isa/luac/v53/opcode_53.c', + 'isa/luac/v54/analysis_54.c', + 'isa/luac/v54/assembly_54.c', + 'isa/luac/v54/disassembly_54.c', + 'isa/luac/v54/opcode_54.c', + 'isa/mcore/mcore.c', + 'isa/mips/mips_assembler.c', + 'isa/msp430/msp430_disas.c', + 'isa/or1k/or1k_disas.c', + 'isa/pic/pic_baseline.c', + 'isa/pic/pic_midrange.c', + 'isa/pic/pic_pic18.c', + 'isa/ppc/libps/libps.c', + 'isa/ppc/libvle/vle.c', + 'isa/ppc/ppc_il.c', + 'isa/ppc/ppc_il_flag_ops.c', + 'isa/ppc/ppc_il_ops.c', + 'isa/propeller/propeller_disas.c', + 'isa/pyc/opcode.c', + 'isa/pyc/opcode_10.c', + 'isa/pyc/opcode_11.c', + 'isa/pyc/opcode_12.c', + 'isa/pyc/opcode_13.c', + 'isa/pyc/opcode_14.c', + 'isa/pyc/opcode_15.c', + 'isa/pyc/opcode_16.c', + 'isa/pyc/opcode_20.c', + 'isa/pyc/opcode_21.c', + 'isa/pyc/opcode_22.c', + 'isa/pyc/opcode_23.c', + 'isa/pyc/opcode_24.c', + 'isa/pyc/opcode_25.c', + 'isa/pyc/opcode_26.c', + 'isa/pyc/opcode_27.c', + 'isa/pyc/opcode_2x.c', + 'isa/pyc/opcode_30.c', + 'isa/pyc/opcode_31.c', + 'isa/pyc/opcode_310.c', + 'isa/pyc/opcode_32.c', + 'isa/pyc/opcode_33.c', + 'isa/pyc/opcode_34.c', + 'isa/pyc/opcode_35.c', + 'isa/pyc/opcode_36.c', + 'isa/pyc/opcode_37.c', + 'isa/pyc/opcode_38.c', + 'isa/pyc/opcode_39.c', + 'isa/pyc/opcode_3x.c', + 'isa/pyc/opcode_analysis.c', + 'isa/pyc/opcode_arg_fmt.c', + 'isa/pyc/pyc_dis.c', + 'isa/rl78/rl78.c', + 'isa/rl78/rl78_instr.c', + 'isa/rl78/rl78_maps.c', + 'isa/rl78/rl78_operand.c', + 'isa/rsp/rsp_idec.c', + 'isa/rx/rx.c', + 'isa/rx/rx_inst.c', + 'isa/rx/rx_opcode_detail.c', + 'isa/sh/assembler.c', + 'isa/sh/disassembler.c', + 'isa/sh/lookup.c', + 'isa/sh/sh_il.c', + 'isa/snes/snesdis.c', + 'isa/spc700/spc700dis.c', + 'isa/tms320/c55x_plus/c55plus.c', + 'isa/tms320/c55x_plus/c55plus_analysis.c', + 'isa/tms320/c55x_plus/c55plus_decode.c', + 'isa/tms320/c55x_plus/decode_funcs.c', + 'isa/tms320/c55x_plus/hashtable.c', + 'isa/tms320/c55x_plus/hashvector.c', + 'isa/tms320/c55x_plus/ins.c', + 'isa/tms320/c55x_plus/utils.c', + 'isa/tms320/c64x/c64x.c', + 'isa/tms320/tms320_dasm.c', + 'isa/v810/v810_disas.c', + 'isa/v810/v810_il.c', + 'isa/v850/v850_disas.c', + 'isa/v850/v850_il.c', + 'isa/wasm/wasm.c', + 'isa/x86/common.c', + 'isa/x86/x86_il.c', + # 'isa/xap/dis.c', +] + +arch_isa_includes = [ + 'isa', +] + +if capstone_dep.version() == 'next' or capstone_dep.version().split('.')[0].to_int() > 4 + # plugins + arch_plugins_list += [ + 'riscv_cs', + 'tricore_cs', + ] + + # plugins sources + arch_plugin_sources += [ + 'p/arch_riscv_cs.c', + 'p/arch_tricore_cs.c', + ] + + # isa sources + arch_isa_sources += [ + 'isa/tricore/tricore_il.c', + ] +endif + +if get_option('use_gpl') + # GPL plugins + arch_plugins_list += [ + 'arc_gnu', + 'cris_gnu', + 'hppa_gnu', + 'lanai_gnu', + 'mips_gnu', + 'nios2_gnu', + 'riscv_gnu', + 'sparc_gnu', + 'vax_gnu', + 'xtensa_gnu', + 'z80_gnu', + ] + + # GPL plugins sources + arch_plugin_sources += [ + 'p_gnu/arch_arc.c', + 'p_gnu/arch_cris.c', + 'p_gnu/arch_hppa.c', + 'p_gnu/arch_lanai.c', + 'p_gnu/arch_mips.c', + 'p_gnu/arch_nios2.c', + 'p_gnu/arch_riscv.c', + 'p_gnu/arch_sparc.c', + 'p_gnu/arch_vax.c', + 'p_gnu/arch_xtensa.c', + 'p_gnu/arch_z80.c', + ] + + # GPL isa sources + arch_isa_sources += [ + 'isa_gnu/arc/arc-dis.c', + 'isa_gnu/arc/arc-ext.c', + 'isa_gnu/arc/arc-opc.c', + 'isa_gnu/arc/arcompact-dis.c', + 'isa_gnu/cris/cris-dis.c', + 'isa_gnu/cris/cris-opc.c', + 'isa_gnu/hppa/hppa-dis.c', + 'isa_gnu/lanai/lanai-dis.c', + 'isa_gnu/lanai/lanai-opc.c', + 'isa_gnu/mips/mips-dis.c', + 'isa_gnu/mips/mips-opc.c', + 'isa_gnu/mips/mips16-opc.c', + 'isa_gnu/nios/nios2-dis.c', + 'isa_gnu/nios/nios2-opc.c', + # 'isa_gnu/riscv/riscv-opc.c', + # 'isa_gnu/riscv/riscv.c', + 'isa_gnu/sparc/sparc-dis.c', + 'isa_gnu/sparc/sparc-opc.c', + 'isa_gnu/vax/vax-dis.c', + 'isa_gnu/xtensa/elf32-xtensa.c', + 'isa_gnu/xtensa/xtensa-dis.c', + 'isa_gnu/xtensa/xtensa-isa.c', + 'isa_gnu/xtensa/xtensa-modules.c', + # 'isa_gnu/z80/expressions.c', + # 'isa_gnu/z80/z80.c', + # 'isa_gnu/z80/z80asm.c', + ] + + # GPL isa includes + arch_isa_includes += [ + 'isa_gnu', + ] +endif + +arch_common_sources = [ + 'acode.c', + 'analysis.c', + 'aop.c', + 'arch.c', + 'asm.c', + 'binutils_as.c', + 'block.c', + 'cc.c', + 'class.c', + 'cond.c', + 'cycles.c', + 'data.c', + 'dwarf_process.c', + 'fcn.c', + 'function.c', + 'hint.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_common_includes = [ + '.', +] + +arch_plugins = { + 'base_name': 'rz_arch', + 'base_struct': 'RzArchPlugin', + 'list': arch_plugins_list, +} + +rz_arch_inc = [ + platform_inc, + include_directories(arch_isa_includes + arch_common_includes) +] + +rz_arch_sources = arch_isa_sources + arch_il_sources + arch_esil_sources + arch_plugin_sources + arch_common_sources + +rz_arch = library('rz_arch', rz_arch_sources, + include_directories: rz_arch_inc, + dependencies: [ + rz_util_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'), + ], + 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_arch_dep = declare_dependency(link_with: rz_arch, include_directories: rz_arch_inc) +meson.override_dependency('rz_arch', rz_arch_dep) + +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] +}} diff --git a/librz/arch/d-asm/6502.sdb.txt b/librz/arch/opcodes/6502.sdb.txt similarity index 100% rename from librz/arch/d-asm/6502.sdb.txt rename to librz/arch/opcodes/6502.sdb.txt diff --git a/librz/arch/d-asm/8051.sdb.txt b/librz/arch/opcodes/8051.sdb.txt similarity index 100% rename from librz/arch/d-asm/8051.sdb.txt rename to librz/arch/opcodes/8051.sdb.txt diff --git a/librz/arch/d-asm/LH5801.sdb.txt b/librz/arch/opcodes/LH5801.sdb.txt similarity index 100% rename from librz/arch/d-asm/LH5801.sdb.txt rename to librz/arch/opcodes/LH5801.sdb.txt diff --git a/librz/arch/d-asm/arc.sdb.txt b/librz/arch/opcodes/arc.sdb.txt similarity index 100% rename from librz/arch/d-asm/arc.sdb.txt rename to librz/arch/opcodes/arc.sdb.txt diff --git a/librz/arch/d-asm/arm.sdb.txt b/librz/arch/opcodes/arm.sdb.txt similarity index 100% rename from librz/arch/d-asm/arm.sdb.txt rename to librz/arch/opcodes/arm.sdb.txt diff --git a/librz/arch/d-asm/avr.sdb.txt b/librz/arch/opcodes/avr.sdb.txt similarity index 100% rename from librz/arch/d-asm/avr.sdb.txt rename to librz/arch/opcodes/avr.sdb.txt diff --git a/librz/arch/d-asm/chip8.sdb.txt b/librz/arch/opcodes/chip8.sdb.txt similarity index 100% rename from librz/arch/d-asm/chip8.sdb.txt rename to librz/arch/opcodes/chip8.sdb.txt diff --git a/librz/arch/d-asm/dalvik.sdb.txt b/librz/arch/opcodes/dalvik.sdb.txt similarity index 100% rename from librz/arch/d-asm/dalvik.sdb.txt rename to librz/arch/opcodes/dalvik.sdb.txt diff --git a/librz/arch/d-asm/i4004.sdb.txt b/librz/arch/opcodes/i4004.sdb.txt similarity index 100% rename from librz/arch/d-asm/i4004.sdb.txt rename to librz/arch/opcodes/i4004.sdb.txt diff --git a/librz/arch/d-asm/i8080.sdb.txt b/librz/arch/opcodes/i8080.sdb.txt similarity index 100% rename from librz/arch/d-asm/i8080.sdb.txt rename to librz/arch/opcodes/i8080.sdb.txt diff --git a/librz/arch/d-asm/java.sdb.txt b/librz/arch/opcodes/java.sdb.txt similarity index 100% rename from librz/arch/d-asm/java.sdb.txt rename to librz/arch/opcodes/java.sdb.txt diff --git a/librz/arch/d-asm/lm32.sdb.txt b/librz/arch/opcodes/lm32.sdb.txt similarity index 100% rename from librz/arch/d-asm/lm32.sdb.txt rename to librz/arch/opcodes/lm32.sdb.txt diff --git a/librz/arch/d-asm/m68k.sdb.txt b/librz/arch/opcodes/m68k.sdb.txt similarity index 100% rename from librz/arch/d-asm/m68k.sdb.txt rename to librz/arch/opcodes/m68k.sdb.txt diff --git a/librz/arch/d-asm/malbolge.sdb.txt b/librz/arch/opcodes/malbolge.sdb.txt similarity index 100% rename from librz/arch/d-asm/malbolge.sdb.txt rename to librz/arch/opcodes/malbolge.sdb.txt diff --git a/librz/arch/d-asm/meson.build b/librz/arch/opcodes/meson.build similarity index 91% rename from librz/arch/d-asm/meson.build rename to librz/arch/opcodes/meson.build index dcff03dd7aa..5c1cc0f96a5 100644 --- a/librz/arch/d-asm/meson.build +++ b/librz/arch/opcodes/meson.build @@ -1,4 +1,4 @@ -sdb_files = [ +sdb_opcodes_files = [ '6502', '8051', 'arc', @@ -30,7 +30,7 @@ sdb_files = [ 'z80', ] -foreach file : sdb_files +foreach file : sdb_opcodes_files outfile = '@0@.sdb'.format(file) custom_target(outfile, input: '@0@.sdb.txt'.format(file), diff --git a/librz/arch/d-asm/mips.sdb.txt b/librz/arch/opcodes/mips.sdb.txt similarity index 100% rename from librz/arch/d-asm/mips.sdb.txt rename to librz/arch/opcodes/mips.sdb.txt diff --git a/librz/arch/d-asm/msp430.sdb.txt b/librz/arch/opcodes/msp430.sdb.txt similarity index 100% rename from librz/arch/d-asm/msp430.sdb.txt rename to librz/arch/opcodes/msp430.sdb.txt diff --git a/librz/arch/d-asm/pic18c.sdb.txt b/librz/arch/opcodes/pic18c.sdb.txt similarity index 100% rename from librz/arch/d-asm/pic18c.sdb.txt rename to librz/arch/opcodes/pic18c.sdb.txt diff --git a/librz/arch/d-asm/ppc.sdb.txt b/librz/arch/opcodes/ppc.sdb.txt similarity index 100% rename from librz/arch/d-asm/ppc.sdb.txt rename to librz/arch/opcodes/ppc.sdb.txt diff --git a/librz/arch/d-asm/propeller.sdb.txt b/librz/arch/opcodes/propeller.sdb.txt similarity index 100% rename from librz/arch/d-asm/propeller.sdb.txt rename to librz/arch/opcodes/propeller.sdb.txt diff --git a/librz/arch/d-asm/riscv.sdb.txt b/librz/arch/opcodes/riscv.sdb.txt similarity index 100% rename from librz/arch/d-asm/riscv.sdb.txt rename to librz/arch/opcodes/riscv.sdb.txt diff --git a/librz/arch/d-asm/rl78.sdb.txt b/librz/arch/opcodes/rl78.sdb.txt similarity index 100% rename from librz/arch/d-asm/rl78.sdb.txt rename to librz/arch/opcodes/rl78.sdb.txt diff --git a/librz/arch/d-asm/sh.sdb.txt b/librz/arch/opcodes/sh.sdb.txt similarity index 100% rename from librz/arch/d-asm/sh.sdb.txt rename to librz/arch/opcodes/sh.sdb.txt diff --git a/librz/arch/d-asm/sparc.sdb.txt b/librz/arch/opcodes/sparc.sdb.txt similarity index 100% rename from librz/arch/d-asm/sparc.sdb.txt rename to librz/arch/opcodes/sparc.sdb.txt diff --git a/librz/arch/d-asm/sysz.sdb.txt b/librz/arch/opcodes/sysz.sdb.txt similarity index 100% rename from librz/arch/d-asm/sysz.sdb.txt rename to librz/arch/opcodes/sysz.sdb.txt diff --git a/librz/arch/d-asm/tms320.sdb.txt b/librz/arch/opcodes/tms320.sdb.txt similarity index 100% rename from librz/arch/d-asm/tms320.sdb.txt rename to librz/arch/opcodes/tms320.sdb.txt diff --git a/librz/arch/d-asm/tricore.sdb.txt b/librz/arch/opcodes/tricore.sdb.txt similarity index 100% rename from librz/arch/d-asm/tricore.sdb.txt rename to librz/arch/opcodes/tricore.sdb.txt diff --git a/librz/arch/d-asm/v810.sdb.txt b/librz/arch/opcodes/v810.sdb.txt similarity index 100% rename from librz/arch/d-asm/v810.sdb.txt rename to librz/arch/opcodes/v810.sdb.txt diff --git a/librz/arch/d-asm/v850.sdb.txt b/librz/arch/opcodes/v850.sdb.txt similarity index 100% rename from librz/arch/d-asm/v850.sdb.txt rename to librz/arch/opcodes/v850.sdb.txt diff --git a/librz/arch/d-asm/x86.sdb.txt b/librz/arch/opcodes/x86.sdb.txt similarity index 100% rename from librz/arch/d-asm/x86.sdb.txt rename to librz/arch/opcodes/x86.sdb.txt diff --git a/librz/arch/d-asm/xtensa.sdb.txt b/librz/arch/opcodes/xtensa.sdb.txt similarity index 100% rename from librz/arch/d-asm/xtensa.sdb.txt rename to librz/arch/opcodes/xtensa.sdb.txt diff --git a/librz/arch/d-asm/z80.sdb.txt b/librz/arch/opcodes/z80.sdb.txt similarity index 100% rename from librz/arch/d-asm/z80.sdb.txt rename to librz/arch/opcodes/z80.sdb.txt diff --git a/librz/arch/p-asm/asm_gas.c b/librz/arch/p-asm/asm_gas.c deleted file mode 100644 index 4100dccd192..00000000000 --- a/librz/arch/p-asm/asm_gas.c +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-FileCopyrightText: 2010-2019 pancake -// SPDX-License-Identifier: LGPL-3.0-only - -#include -#include -#include -#include - -static int assemble(RzAsm *a, RzAsmOp *op, const char *buf) { - int len = 0; - ut8 *out; - char *cmd = rz_str_newf( - "gas /dev/stdin -o /dev/stdout <<__\n" - "BITS %i\nORG 0x%" PFMT64x "\n%s\n__", - a->bits, a->pc, buf); - ut8 *out = (ut8 *)rz_sys_cmd_str(cmd, "", &len); - if (out) { - rz_asm_op_set_buf(op, out, len); - free(out); - } - op->size = len; - free(cmd); - return len; -} - -RzAsmPlugin rz_asm_plugin_x86_gas = { - .name = "x86.gas", - .license = "LGPL3", - .desc = "GNU Assembler (gas)", - .bits = 16 | 32 | 64, - .endian = RZ_SYS_ENDIAN_LITTLE, - .assemble = &assemble -}; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_x86_gas, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_tms320.c b/librz/arch/p-asm/asm_tms320.c deleted file mode 100644 index 5ecbc8c63b5..00000000000 --- a/librz/arch/p-asm/asm_tms320.c +++ /dev/null @@ -1,144 +0,0 @@ -// SPDX-FileCopyrightText: 2014 Ilya V. Matveychikov -// SPDX-License-Identifier: LGPL-3.0-only - -#include -#include -#include -#include -#include - -#ifdef CAPSTONE_TMS320C64X_H -#define CAPSTONE_HAS_TMS320C64X 1 -// #include "cs_mnemonics.c" -#else -#define CAPSTONE_HAS_TMS320C64X 0 -#warning Cannot find capstone-tms320c64x support -#endif - -#include "../arch/tms320/tms320_dasm.h" - -typedef struct tms_cs_context_t { -#if CAPSTONE_HAS_TMS320C64X - csh cd; -#endif - tms320_dasm_t engine; -} TmsContext; - -#if CAPSTONE_HAS_TMS320C64X - -static int tms320c64x_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { - TmsContext *ctx = (TmsContext *)a->plugin_data; - - cs_insn *insn; - int n = -1, ret = -1; - if (op) { - memset(op, 0, sizeof(RzAsmOp)); - op->size = 4; - } - if (ctx->cd != 0) { - cs_close(&ctx->cd); - ctx->cd = 0; - } - if (!ctx->cd) { - ret = cs_open(CS_ARCH_TMS320C64X, 0, &ctx->cd); - if (ret) { - goto fin; - } - cs_option(ctx->cd, CS_OPT_DETAIL, CS_OPT_OFF); - } - if (!op) { - return 0; - } - n = cs_disasm(ctx->cd, buf, len, a->pc, 1, &insn); - if (n < 1) { - rz_asm_op_set_asm(op, "invalid"); - op->size = 4; - ret = -1; - goto fin; - } else { - ret = 4; - } - if (insn->size < 1) { - goto fin; - } - op->size = insn->size; - rz_asm_op_setf_asm(op, "%s%s%s", insn->mnemonic, insn->op_str[0] ? " " : "", insn->op_str); - char *str = rz_asm_op_get_asm(op); - if (str) { - rz_str_replace_char(str, '%', 0); - rz_str_case(str, false); - } - cs_free(insn, n); -fin: - return ret; -} -#endif - -static int tms320_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { - TmsContext *ctx = (TmsContext *)a->plugin_data; - if (a->cpu && rz_str_casecmp(a->cpu, "c54x") == 0) { - tms320_f_set_cpu(&ctx->engine, TMS320_F_CPU_C54X); - } else if (a->cpu && rz_str_casecmp(a->cpu, "c55x+") == 0) { - tms320_f_set_cpu(&ctx->engine, TMS320_F_CPU_C55X_PLUS); - } else if (a->cpu && rz_str_casecmp(a->cpu, "c55x") == 0) { - tms320_f_set_cpu(&ctx->engine, TMS320_F_CPU_C55X); - } else { -#if CAPSTONE_HAS_TMS320C64X - if (a->cpu && !rz_str_casecmp(a->cpu, "c64x")) { - return tms320c64x_disassemble(a, op, buf, len); - } -#endif - rz_asm_op_set_asm(op, "unknown asm.cpu"); - return op->size = -1; - } - op->size = tms320_dasm(&ctx->engine, buf, len); - rz_asm_op_set_asm(op, ctx->engine.syntax); - return op->size; -} - -static bool tms320_init(void **user) { - TmsContext *ctx = RZ_NEW0(TmsContext); - if (!ctx) { - return false; - } - tms320_dasm_init(&ctx->engine); - *user = ctx; - return true; -} - -static bool tms320_fini(void *user) { - rz_return_val_if_fail(user, false); - TmsContext *ctx = (TmsContext *)user; -#if CAPSTONE_HAS_TMS320C64X - cs_close(&ctx->cd); -#endif - tms320_dasm_fini(&ctx->engine); - free(ctx); - return true; -} - -RzAsmPlugin rz_asm_plugin_tms320 = { - .name = "tms320", - .arch = "tms320", -#if CAPSTONE_HAS_TMS320C64X - .cpus = "c54x,c55x,c55x+,c64x", - .desc = "TMS320 DSP family (c54x,c55x,c55x+,c64x)", -#else - .cpus = "c54x,c55x,c55x+", - .desc = "TMS320 DSP family (c54x,c55x,c55x+)", -#endif - .license = "LGPLv3", - .bits = 32, - .endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG, - .init = tms320_init, - .fini = tms320_fini, - .disassemble = &tms320_disassemble, -}; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_tms320, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_tms320c64x.c b/librz/arch/p-asm/asm_tms320c64x.c deleted file mode 100644 index dee428190a2..00000000000 --- a/librz/arch/p-asm/asm_tms320c64x.c +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-FileCopyrightText: 2017-2018 pancake -// SPDX-License-Identifier: LGPL-3.0-only - -#include -#include -#include - -#ifdef CAPSTONE_TMS320C64X_H -#define CAPSTONE_HAS_TMS320C64X 1 -#else -#define CAPSTONE_HAS_TMS320C64X 0 -#warning Cannot find capstone-tms320c64x support -#endif - -#if CAPSTONE_HAS_TMS320C64X -#include "cs_helper.h" - -CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(tms320c64x); - -static int tms320c64x_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { - CapstoneContext *ctx = (CapstoneContext *)a->plugin_data; - - cs_insn *insn; - int n = -1, ret = -1; - if (op) { - memset(op, 0, sizeof(RzAsmOp)); - op->size = 4; - } - if (ctx->omode != 0) { - cs_close(&ctx->handle); - ctx->omode = -1; - } - if (!ctx->handle) { - ret = cs_open(CS_ARCH_TMS320C64X, 0, &ctx->handle); - if (ret) { - goto fin; - } - ctx->omode = 0; - cs_option(ctx->handle, CS_OPT_DETAIL, CS_OPT_OFF); - } - if (!op) { - return 0; - } - n = cs_disasm(ctx->handle, buf, len, a->pc, 1, &insn); - if (n < 1) { - rz_asm_op_set_asm(op, "invalid"); - op->size = 4; - ret = -1; - goto fin; - } else { - ret = 4; - } - if (insn->size < 1) { - goto fin; - } - op->size = insn->size; - rz_asm_op_setf_asm(op, "%s%s%s", insn->mnemonic, insn->op_str[0] ? " " : "", insn->op_str); - char *str = rz_asm_op_get_asm(op); - if (str) { - rz_str_replace_char(str, '%', 0); - rz_str_case(str, false); - } - cs_free(insn, n); -fin: - return ret; -} - -RzAsmPlugin rz_asm_plugin_tms320c64x = { - .name = "tms320c64x", - .desc = "Capstone TMS320c64x disassembler", - .license = "BSD", - .arch = "tms320c64x", - .bits = 32, - .endian = RZ_SYS_ENDIAN_BIG | RZ_SYS_ENDIAN_LITTLE, - .init = tms320c64x_init, - .fini = tms320c64x_fini, - .disassemble = &tms320c64x_disassemble, - .mnemonics = tms320c64x_mnemonics, -}; - -#else - -RzAsmPlugin rz_asm_plugin_tms320c64x = { - .name = "tms320c64x", - .desc = "Capstone TMS320c64x disassembler (unsupported)", - .license = "BSD", - .arch = "tms320c64x", - .bits = 32, - .endian = RZ_SYS_ENDIAN_LITTLE, -}; - -#endif - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_tms320c64x, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_6502.c b/librz/arch/p/analysis/analysis_6502.c similarity index 99% rename from librz/arch/p-analysis/analysis_6502.c rename to librz/arch/p/analysis/analysis_6502.c index 1221f2a99e7..084cd4c99aa 100644 --- a/librz/arch/p-analysis/analysis_6502.c +++ b/librz/arch/p/analysis/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 "snes/snes_op_table.h" +#include "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/analysis_8051.c b/librz/arch/p/analysis/analysis_8051.c similarity index 99% rename from librz/arch/p-analysis/analysis_8051.c rename to librz/arch/p/analysis/analysis_8051.c index d2311a9d571..50f76c0d8af 100644 --- a/librz/arch/p-analysis/analysis_8051.c +++ b/librz/arch/p/analysis/analysis_8051.c @@ -9,9 +9,9 @@ #include #include -#include <8051_ops.h> -#include "../asm/arch/8051/8051_disas.c" -#include "../arch/8051/8051_il.h" +#include <8051/8051_ops.h> +#include <8051/8051_disas.h> +#include <8051/8051_il.h> static const i8051_cpu_model cpu_models[] = { { .name = "8051-generic", @@ -1286,11 +1286,3 @@ RzAnalysisPlugin rz_analysis_plugin_8051 = { .fini = &i8051_fini, .il_config = rz_8051_il_config, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_8051, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_amd29k.c b/librz/arch/p/analysis/analysis_amd29k.c similarity index 97% rename from librz/arch/p-analysis/analysis_amd29k.c rename to librz/arch/p/analysis/analysis_amd29k.c index b7942467d21..72452054a63 100644 --- a/librz/arch/p-analysis/analysis_amd29k.c +++ b/librz/arch/p/analysis/analysis_amd29k.c @@ -3,7 +3,7 @@ #include #include -#include "../../asm/arch/amd29k/amd29k.h" +#include "amd29k/amd29k.h" static char *get_reg_profile(RzAnalysis *analysis) { const char *p = @@ -345,11 +345,3 @@ RzAnalysisPlugin rz_analysis_plugin_amd29k = { .op = &analyze_op, .get_reg_profile = &get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_amd29k, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_arm_cs.c b/librz/arch/p/analysis/analysis_arm_cs.c similarity index 99% rename from librz/arch/p-analysis/analysis_arm_cs.c rename to librz/arch/p/analysis/analysis_arm_cs.c index f31c36b5d25..2a5068d822a 100644 --- a/librz/arch/p-analysis/analysis_arm_cs.c +++ b/librz/arch/p/analysis/analysis_arm_cs.c @@ -9,10 +9,10 @@ #include #include "./analysis_arm_hacks.inc" -#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 "arm/arm_cs.h" +#include "arm/arm_accessors32.h" +#include "arm/arm_accessors64.h" +#include "arm/arm_it.h" #if CS_NEXT_VERSION < 6 inline static const char *ARMCondCodeToString(arm_cc cc) { @@ -62,12 +62,12 @@ static inline bool is_alias32(cs_insn *insn, arm_insn alias_id) { } #endif /* CS_NEXT_VERSION < 6 */ -typedef struct arm_cs_context_t { +typedef struct analysis_arm_cs_context_t { RzArmITContext it; ///< Save IT values between instruction disassembly. csh handle; ///< The Capstone handle used. int omode; ///< Capstone mode flags. int obits; ///< Architecture bits. -} ArmCSContext; +} AnalysisArmCSContext; static const char *shift_type_name(arm_shifter type) { switch (type) { @@ -707,7 +707,7 @@ static bool is_system_hint(const cs_insn *insn) { } #endif -static void anop64(ArmCSContext *ctx, RzAnalysisOp *op, cs_insn *insn) { +static void anop64(AnalysisArmCSContext *ctx, RzAnalysisOp *op, cs_insn *insn) { csh handle = ctx->handle; ut64 addr = op->addr; @@ -1243,7 +1243,7 @@ inline static void set_ret(const cs_insn *insn, RZ_BORROW RzAnalysisOp *op) { } static void anop32(RzAnalysis *a, csh handle, RzAnalysisOp *op, cs_insn *insn, bool thumb, const ut8 *buf, int len) { - ArmCSContext *ctx = (ArmCSContext *)a->plugin_data; + AnalysisArmCSContext *ctx = (AnalysisArmCSContext *)a->plugin_data; const ut64 addr = op->addr; const int pcdelta = thumb ? 4 : 8; int i; @@ -2039,7 +2039,7 @@ static void patch_capstone_bugs(cs_insn *insn, int bits, bool big_endian) { #endif static int analysis_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { - ArmCSContext *ctx = (ArmCSContext *)a->plugin_data; + AnalysisArmCSContext *ctx = (AnalysisArmCSContext *)a->plugin_data; cs_insn *insn = NULL; int mode = (a->bits == 16) ? CS_MODE_THUMB : CS_MODE_ARM; @@ -2694,7 +2694,7 @@ static int address_bits(RzAnalysis *analysis, int bits) { } static bool init(void **user) { - ArmCSContext *ctx = RZ_NEW0(ArmCSContext); + AnalysisArmCSContext *ctx = RZ_NEW0(AnalysisArmCSContext); if (!ctx) { return false; } @@ -2708,7 +2708,7 @@ static bool init(void **user) { static bool fini(void *user) { rz_return_val_if_fail(user, false); - ArmCSContext *ctx = (ArmCSContext *)user; + AnalysisArmCSContext *ctx = (AnalysisArmCSContext *)user; cs_close(&ctx->handle); rz_arm_it_context_fini(&ctx->it); free(ctx); @@ -2739,11 +2739,3 @@ RzAnalysisPlugin rz_analysis_plugin_arm_cs = { .init = &init, .fini = &fini, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_arm_cs, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_arm_hacks.inc b/librz/arch/p/analysis/analysis_arm_hacks.inc similarity index 100% rename from librz/arch/p-analysis/analysis_arm_hacks.inc rename to librz/arch/p/analysis/analysis_arm_hacks.inc diff --git a/librz/arch/p-analysis/analysis_avr.c b/librz/arch/p/analysis/analysis_avr.c similarity index 97% rename from librz/arch/p-analysis/analysis_avr.c rename to librz/arch/p/analysis/analysis_avr.c index 4cd6cc277be..4c6fab3cea6 100644 --- a/librz/arch/p-analysis/analysis_avr.c +++ b/librz/arch/p/analysis/analysis_avr.c @@ -4,9 +4,9 @@ #include -#include "../../asm/arch/avr/disassembler.h" -#include "../arch/avr/avr_esil.h" -#include "../arch/avr/avr_il.h" +#include "avr/disassembler.h" +#include "avr/avr_esil.h" +#include "avr/avr_il.h" static void set_invalid_op(RzAnalysisOp *op, ut64 addr) { // Unknown or invalid instruction. @@ -483,11 +483,3 @@ RzAnalysisPlugin rz_analysis_plugin_avr = { .il_config = rz_avr_il_config, .analysis_mask = analysis_mask_avr, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_avr, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_bf.c b/librz/arch/p/analysis/analysis_bf.c similarity index 98% rename from librz/arch/p-analysis/analysis_bf.c rename to librz/arch/p/analysis/analysis_bf.c index 986ed45b0c1..76cae9fd46d 100644 --- a/librz/arch/p-analysis/analysis_bf.c +++ b/librz/arch/p/analysis/analysis_bf.c @@ -301,11 +301,3 @@ RzAnalysisPlugin rz_analysis_plugin_bf = { .get_reg_profile = get_reg_profile, .il_config = il_config }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_bf, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_chip8.c b/librz/arch/p/analysis/analysis_chip8.c similarity index 95% rename from librz/arch/p-analysis/analysis_chip8.c rename to librz/arch/p/analysis/analysis_chip8.c index 4e992d01dea..63264c65e97 100644 --- a/librz/arch/p-analysis/analysis_chip8.c +++ b/librz/arch/p/analysis/analysis_chip8.c @@ -159,11 +159,3 @@ RzAnalysisPlugin rz_analysis_plugin_chip8 = { .bits = 32, .op = &chip8_anop, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_chip8, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_cil.c b/librz/arch/p/analysis/analysis_cil.c similarity index 98% rename from librz/arch/p-analysis/analysis_cil.c rename to librz/arch/p/analysis/analysis_cil.c index 99888d1f999..788243e530a 100644 --- a/librz/arch/p-analysis/analysis_cil.c +++ b/librz/arch/p/analysis/analysis_cil.c @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-only #include -#include "../../asm/arch/cil/cil_dis.h" +#include /** * Resolves InlineMethod token to paddr @@ -291,8 +291,9 @@ static int cil_analyze_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, con RzAnalysisPlugin rz_analysis_plugin_cil = { .name = "cil", - .desc = "dotnet CIL code analysis plugin", + .desc = ".NET Common Intermediate Language", .license = "LGPL3", .arch = "cil", - .op = cil_analyze_op, + .bits = 16 | 32 | 64, + .op = &cil_analyze_op, }; diff --git a/librz/arch/p-analysis/analysis_cr16.c b/librz/arch/p/analysis/analysis_cr16.c similarity index 93% rename from librz/arch/p-analysis/analysis_cr16.c rename to librz/arch/p/analysis/analysis_cr16.c index 599c58e3b26..c0c14d10309 100644 --- a/librz/arch/p-analysis/analysis_cr16.c +++ b/librz/arch/p/analysis/analysis_cr16.c @@ -9,7 +9,7 @@ #include #include -#include +#include static int cr16_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { @@ -127,11 +127,3 @@ RzAnalysisPlugin rz_analysis_plugin_cr16 = { .bits = 16, .op = cr16_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_cr16, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_dalvik.c b/librz/arch/p/analysis/analysis_dalvik.c similarity index 99% rename from librz/arch/p-analysis/analysis_dalvik.c rename to librz/arch/p/analysis/analysis_dalvik.c index f6e736dd00f..a0429d16973 100644 --- a/librz/arch/p-analysis/analysis_dalvik.c +++ b/librz/arch/p/analysis/analysis_dalvik.c @@ -7,7 +7,7 @@ #include #include -#include "../../asm/arch/dalvik/opcode.h" +#include "dalvik/opcode.h" #include "../../bin/format/dex/dex.h" static const char *getCond(ut8 cond) { @@ -785,11 +785,3 @@ RzAnalysisPlugin rz_analysis_plugin_dalvik = { .op = &dalvik_op, .archinfo = archinfo, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_dalvik, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_ebc.c b/librz/arch/p/analysis/analysis_ebc.c similarity index 95% rename from librz/arch/p-analysis/analysis_ebc.c rename to librz/arch/p/analysis/analysis_ebc.c index e2c0852d104..432318df912 100644 --- a/librz/arch/p-analysis/analysis_ebc.c +++ b/librz/arch/p/analysis/analysis_ebc.c @@ -8,7 +8,7 @@ #include #include -#include +#include static void ebc_analysis_jmp8(RzAnalysisOp *op, ut64 addr, const ut8 *buf) { int jmpadr = (int8_t)buf[1]; @@ -170,11 +170,3 @@ RzAnalysisPlugin rz_analysis_plugin_ebc = { .bits = 64, .op = &ebc_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_ebc, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_gb.c b/librz/arch/p/analysis/analysis_gb.c similarity index 99% rename from librz/arch/p-analysis/analysis_gb.c rename to librz/arch/p/analysis/analysis_gb.c index df8801161ff..f4f7c1646a2 100644 --- a/librz/arch/p-analysis/analysis_gb.c +++ b/librz/arch/p/analysis/analysis_gb.c @@ -11,12 +11,11 @@ #include #include #include -#define GB_DIS_LEN_ONLY -#include "../../asm/arch/gb/gbdis.c" -#include "../arch/gb/gb_makros.h" -#include "../arch/gb/meta_gb_cmt.c" -#include "../arch/gb/gb_il.inc" -#include +#include +#include +#include +#include +#include // lookup tables for disassembly static const char *regs_1[] = { "Z", "N", "H", "C" }; @@ -2057,11 +2056,3 @@ RzAnalysisPlugin rz_analysis_plugin_gb = { .esil_fini = esil_gb_fini, .il_config = il_config }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_gb, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_h8300.c b/librz/arch/p/analysis/analysis_h8300.c similarity index 98% rename from librz/arch/p-analysis/analysis_h8300.c rename to librz/arch/p/analysis/analysis_h8300.c index fab933db011..1a2e2e04a6e 100644 --- a/librz/arch/p-analysis/analysis_h8300.c +++ b/librz/arch/p/analysis/analysis_h8300.c @@ -10,7 +10,7 @@ #include #include -#include +#include #define emit(frag) rz_strbuf_appendf(&op->esil, frag) #define emitf(...) rz_strbuf_appendf(&op->esil, __VA_ARGS__) @@ -727,11 +727,3 @@ RzAnalysisPlugin rz_analysis_plugin_h8300 = { .esil = true, .get_reg_profile = get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -struct rz_lib_struct_t rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_h8300, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_hexagon.c b/librz/arch/p/analysis/analysis_hexagon.c similarity index 98% rename from librz/arch/p-analysis/analysis_hexagon.c rename to librz/arch/p/analysis/analysis_hexagon.c index 550a571632d..ba527ddee89 100644 --- a/librz/arch/p-analysis/analysis_hexagon.c +++ b/librz/arch/p/analysis/analysis_hexagon.c @@ -14,9 +14,9 @@ #include #include #include -#include "hexagon.h" -#include "hexagon_insn.h" -#include "hexagon_arch.h" +#include +#include +#include RZ_API int hexagon_v6_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { rz_return_val_if_fail(analysis && op && buf, -1); @@ -703,11 +703,3 @@ RzAnalysisPlugin rz_analysis_plugin_hexagon = { .esil = false, .get_reg_profile = get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_hexagon_v6, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p/analysis/analysis_i4004.c b/librz/arch/p/analysis/analysis_i4004.c new file mode 100644 index 00000000000..356c919dbd5 --- /dev/null +++ b/librz/arch/p/analysis/analysis_i4004.c @@ -0,0 +1,57 @@ +// SPDX-FileCopyrightText: 2016-2020 pancake +// SPDX-License-Identifier: LGPL-3.0-only + +#include +#include +#include +#include +#include +#include +#include + +#define AVR_SOFTCAST(x, y) ((x) + ((y)*0x100)) + +static char *get_reg_profile(RzAnalysis *analysis) { + const char *p = + "=PC PC\n" + /* syntax not yet supported */ + // "=SP &PC1\n" + "=A0 r0\n" + "=A1 r1\n" + "=A2 r2\n" + "=A3 r3\n" + "=R0 r0\n" + "gpr r0 .4 0 0\n" + "gpr r1 .4 1 0\n" + "gpr r2 .4 2 0\n" + "gpr r3 .4 3 0\n" + "gpr r4 .4 4 0\n" + "gpr r5 .4 5 0\n" + "gpr r6 .4 6 0\n" + "gpr r7 .4 7 0\n" + "gpr r8 .4 8 0\n" + "gpr r9 .4 9 0\n" + "gpr r10 .4 10 0\n" + "gpr r11 .4 11 0\n" + "gpr r12 .4 12 0\n" + "gpr r13 .4 13 0\n" + "gpr r14 .4 14 0\n" + "gpr r15 .4 15 0\n" + "gpr PC .64 32 0\n" + /* stack */ + "gpr PC1 .64 34 0\n" + "gpr PC2 .64 34 0\n" + "gpr PC3 .64 34 0\n"; + return strdup(p); +} + +RzAnalysisPlugin rz_analysis_plugin_i4004 = { + .name = "i4004", + .desc = "i4004 code analysis plugin", + .license = "LGPL3", + .arch = "i4004", + .esil = false, + .bits = 8, + .op = &i4004_op, + .get_reg_profile = &get_reg_profile +}; diff --git a/librz/arch/p-analysis/analysis_i8080.c b/librz/arch/p/analysis/analysis_i8080.c similarity index 94% rename from librz/arch/p-analysis/analysis_i8080.c rename to librz/arch/p/analysis/analysis_i8080.c index 1e88cf0d8f2..bedeb0832d2 100644 --- a/librz/arch/p-analysis/analysis_i8080.c +++ b/librz/arch/p/analysis/analysis_i8080.c @@ -10,7 +10,7 @@ #include #include // hack -#include "../../asm/arch/i8080/i8080dis.c" +#include "i8080/i8080dis.h" static int i8080_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask) { char out[32]; @@ -196,11 +196,3 @@ RzAnalysisPlugin rz_analysis_plugin_i8080 = { .bits = 16, .op = &i8080_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_i8080, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_java.c b/librz/arch/p/analysis/analysis_java.c similarity index 88% rename from librz/arch/p-analysis/analysis_java.c rename to librz/arch/p/analysis/analysis_java.c index 5446819a1fe..865cddb0ed8 100644 --- a/librz/arch/p-analysis/analysis_java.c +++ b/librz/arch/p/analysis/analysis_java.c @@ -5,7 +5,7 @@ #include #include -#include "../../asm/arch/java/jvm.h" +#include "java/jvm.h" typedef struct java_analysis_context_t { LookupSwitch ls; @@ -15,7 +15,7 @@ typedef struct java_analysis_context_t { ut32 count; } JavaAnalysisContext; -static void update_context(JavaAnalysisContext *ctx) { +static void java_analysis_update_context(JavaAnalysisContext *ctx) { ctx->count++; if (ctx->switchop == BYTECODE_AA_TABLESWITCH && ctx->count > ctx->ts.length) { ctx->switchop = BYTECODE_00_NOP; @@ -24,7 +24,7 @@ static void update_context(JavaAnalysisContext *ctx) { } } -static ut64 find_method(RzAnalysis *a, ut64 addr) { +static ut64 java_analysis_find_method(RzAnalysis *a, ut64 addr) { if (!a->binb.bin) { return addr; } @@ -60,7 +60,7 @@ static int java_analysis(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, cons op->jump = ctx->pc + rz_read_be32(buf); op->fail = addr + op->size; op->type = RZ_ANALYSIS_OP_TYPE_CJMP; - update_context(ctx); + java_analysis_update_context(ctx); return op->size; case BYTECODE_AB_LOOKUPSWITCH: if (len < 8) { @@ -71,7 +71,7 @@ static int java_analysis(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, cons op->jump = ctx->pc + rz_read_at_be32(buf, 4); op->fail = addr + op->size; op->type = RZ_ANALYSIS_OP_TYPE_CJMP; - update_context(ctx); + java_analysis_update_context(ctx); return op->size; default: break; @@ -80,7 +80,7 @@ static int java_analysis(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, cons JavaVM vm = { 0 }; Bytecode bc = { 0 }; - ut64 section = find_method(analysis, addr); + ut64 section = java_analysis_find_method(analysis, addr); if (!jvm_init(&vm, buf, len, addr, section)) { RZ_LOG_ERROR("[!] java_analysis: bad or invalid data.\n"); return -1; @@ -161,7 +161,7 @@ static int archinfo(RzAnalysis *a, RzAnalysisInfoType query) { } } -static bool java_init(void **user) { +static bool java_analysis_init(void **user) { JavaAnalysisContext *ctx = RZ_NEW0(JavaAnalysisContext); if (!ctx) { return false; @@ -170,7 +170,7 @@ static bool java_init(void **user) { return true; } -static bool java_fini(void *user) { +static bool java_analysis_fini(void *user) { if (!user) { return false; } @@ -186,15 +186,7 @@ RzAnalysisPlugin rz_analysis_plugin_java = { .bits = 32, .op = &java_analysis, .archinfo = archinfo, - .init = java_init, - .fini = java_fini, + .init = java_analysis_init, + .fini = java_analysis_fini, .get_reg_profile = &get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_java, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_luac.c b/librz/arch/p/analysis/analysis_luac.c similarity index 81% rename from librz/arch/p-analysis/analysis_luac.c rename to librz/arch/p/analysis/analysis_luac.c index 3afc139ea36..aa78250a29d 100644 --- a/librz/arch/p-analysis/analysis_luac.c +++ b/librz/arch/p/analysis/analysis_luac.c @@ -4,7 +4,7 @@ #include #include -#include "librz/asm/arch/luac/lua_arch.h" +#include int rz_lua_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask) { if (!analysis->cpu) { @@ -30,11 +30,3 @@ RzAnalysisPlugin rz_analysis_plugin_luac = { .op = &rz_lua_analysis_op, .esil = false }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_luac, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_m680x_cs.c b/librz/arch/p/analysis/analysis_m680x_cs.c similarity index 98% rename from librz/arch/p-analysis/analysis_m680x_cs.c rename to librz/arch/p/analysis/analysis_m680x_cs.c index 5fa51d76e18..27dc8d6c124 100644 --- a/librz/arch/p-analysis/analysis_m680x_cs.c +++ b/librz/arch/p/analysis/analysis_m680x_cs.c @@ -51,7 +51,7 @@ typedef struct { int obits; } M680XContext; -static bool m680x_init(void **user) { +static bool m680x_analysis_init(void **user) { M680XContext *ctx = RZ_NEW0(M680XContext); rz_return_val_if_fail(ctx, false); ctx->handle = 0; @@ -527,7 +527,7 @@ static char *get_reg_profile(RzAnalysis *analysis) { return strdup(p); } -static bool m680x_fini(void *user) { +static bool m680x_analysis_fini(void *user) { M680XContext *ctx = (M680XContext *)user; if (ctx) { RZ_FREE(ctx); @@ -544,8 +544,8 @@ RzAnalysisPlugin rz_analysis_plugin_m680x_cs = { .get_reg_profile = &get_reg_profile, .bits = 16 | 32, .op = &analyze_op, - .init = m680x_init, - .fini = m680x_fini, + .init = m680x_analysis_init, + .fini = m680x_analysis_fini, }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p-analysis/analysis_m68k_cs.c b/librz/arch/p/analysis/analysis_m68k_cs.c similarity index 100% rename from librz/arch/p-analysis/analysis_m68k_cs.c rename to librz/arch/p/analysis/analysis_m68k_cs.c diff --git a/librz/arch/p-analysis/analysis_malbolge.c b/librz/arch/p/analysis/analysis_malbolge.c similarity index 86% rename from librz/arch/p-analysis/analysis_malbolge.c rename to librz/arch/p/analysis/analysis_malbolge.c index 849444d1ea9..1d0dfc17068 100644 --- a/librz/arch/p-analysis/analysis_malbolge.c +++ b/librz/arch/p/analysis/analysis_malbolge.c @@ -45,11 +45,3 @@ RzAnalysisPlugin rz_analysis_plugin_malbolge = { .bits = 32, .op = &mal_analysis, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_malbolge, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_mcore.c b/librz/arch/p/analysis/analysis_mcore.c similarity index 94% rename from librz/arch/p-analysis/analysis_mcore.c rename to librz/arch/p/analysis/analysis_mcore.c index a3c234dfed9..b5d2f6b401e 100644 --- a/librz/arch/p-analysis/analysis_mcore.c +++ b/librz/arch/p/analysis/analysis_mcore.c @@ -4,7 +4,7 @@ #include #include #include -#include "../../asm/arch/mcore/mcore.h" +#include "mcore/mcore.h" static int mcore_analysis(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { mcore_handle handle = { 0 }; @@ -137,11 +137,3 @@ RzAnalysisPlugin rz_analysis_plugin_mcore = { .archinfo = archinfo, .get_reg_profile = &get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_mcore, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_mips_cs.c b/librz/arch/p/analysis/analysis_mips_cs.c similarity index 100% rename from librz/arch/p-analysis/analysis_mips_cs.c rename to librz/arch/p/analysis/analysis_mips_cs.c diff --git a/librz/arch/p-analysis/analysis_msp430.c b/librz/arch/p/analysis/analysis_msp430.c similarity index 98% rename from librz/arch/p-analysis/analysis_msp430.c rename to librz/arch/p/analysis/analysis_msp430.c index 1413a61947e..9dff545e3e2 100644 --- a/librz/arch/p-analysis/analysis_msp430.c +++ b/librz/arch/p/analysis/analysis_msp430.c @@ -8,7 +8,7 @@ #include #include -#include +#include static int msp430_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { int ret; diff --git a/librz/arch/p-analysis/analysis_null.c b/librz/arch/p/analysis/analysis_null.c similarity index 82% rename from librz/arch/p-analysis/analysis_null.c rename to librz/arch/p/analysis/analysis_null.c index a58863f420a..d150715931b 100644 --- a/librz/arch/p-analysis/analysis_null.c +++ b/librz/arch/p/analysis/analysis_null.c @@ -24,11 +24,3 @@ RzAnalysisPlugin rz_analysis_plugin_null = { .op = &null_analysis, .get_reg_profile = &null_get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_null, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_or1k.c b/librz/arch/p/analysis/analysis_or1k.c similarity index 94% rename from librz/arch/p-analysis/analysis_or1k.c rename to librz/arch/p/analysis/analysis_or1k.c index c05527385f1..9b35850a99c 100644 --- a/librz/arch/p-analysis/analysis_or1k.c +++ b/librz/arch/p/analysis/analysis_or1k.c @@ -4,19 +4,7 @@ #include #include #include -#include - -struct operands { - ut32 rd; - ut32 ra; - ut32 rb; - ut32 n; - ut32 k1; - ut32 k2; - ut32 k; - ut32 i; - ut32 l; -}; +#include static ut32 cpu[32] = { 0 }; /* register contents */ static ut32 cpu_enable; /* allows to treat only registers with known value as @@ -195,11 +183,3 @@ RzAnalysisPlugin rz_analysis_plugin_or1k = { .esil = false, .op = &or1k_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_or1k, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_pic.c b/librz/arch/p/analysis/analysis_pic.c similarity index 99% rename from librz/arch/p-analysis/analysis_pic.c rename to librz/arch/p/analysis/analysis_pic.c index 0e6f88c0352..d27497ef10c 100644 --- a/librz/arch/p-analysis/analysis_pic.c +++ b/librz/arch/p/analysis/analysis_pic.c @@ -7,7 +7,7 @@ #include #include -#include "../../asm/arch/pic/pic_midrange.h" +#include "pic/pic_midrange.h" typedef struct _pic_midrange_op_args_val { ut16 f; @@ -1218,11 +1218,3 @@ RzAnalysisPlugin rz_analysis_plugin_pic = { .get_reg_profile = &analysis_pic_get_reg_profile, .esil = true }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_pic, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_ppc_cs.c b/librz/arch/p/analysis/analysis_ppc_cs.c similarity index 99% rename from librz/arch/p-analysis/analysis_ppc_cs.c rename to librz/arch/p/analysis/analysis_ppc_cs.c index a2591ba7360..1a8258739be 100644 --- a/librz/arch/p-analysis/analysis_ppc_cs.c +++ b/librz/arch/p/analysis/analysis_ppc_cs.c @@ -5,9 +5,9 @@ #include #include #include -#include "../../asm/arch/ppc/libvle/vle.h" -#include "../arch/ppc/ppc_analysis.h" -#include "../arch/ppc/ppc_il.h" +#include "ppc/libvle/vle.h" +#include "ppc/ppc_analysis.h" +#include "ppc/ppc_il.h" #include "rz_util/rz_strbuf.h" #define SPR_HID0 0x3f0 /* Hardware Implementation Register 0 */ diff --git a/librz/arch/p-analysis/analysis_propeller.c b/librz/arch/p/analysis/analysis_propeller.c similarity index 98% rename from librz/arch/p-analysis/analysis_propeller.c rename to librz/arch/p/analysis/analysis_propeller.c index bc837f9c6fb..0026d92bf33 100644 --- a/librz/arch/p-analysis/analysis_propeller.c +++ b/librz/arch/p/analysis/analysis_propeller.c @@ -9,7 +9,7 @@ #include #include -#include +#include static int propeller_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { rz_return_val_if_fail(analysis && op && buf, -1); diff --git a/librz/arch/p-analysis/analysis_pyc.c b/librz/arch/p/analysis/analysis_pyc.c similarity index 93% rename from librz/arch/p-analysis/analysis_pyc.c rename to librz/arch/p/analysis/analysis_pyc.c index bb9230a9306..eedec2fe7d3 100644 --- a/librz/arch/p-analysis/analysis_pyc.c +++ b/librz/arch/p/analysis/analysis_pyc.c @@ -6,7 +6,7 @@ #include #include -#include "../../asm/arch/pyc/pyc_dis.h" +#include "pyc/pyc_dis.h" #define JMP_OFFSET(ops, v) ((ops)->jump_use_instruction_offset ? (v)*2 : (v)) @@ -136,7 +136,7 @@ static int pyc_op(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *data, i return op->size; } -static bool finish(void *user) { +static bool pyc_analysis_finish(void *user) { pyc_opcodes *ops = (user); free_opcode(ops); return true; @@ -152,13 +152,5 @@ RzAnalysisPlugin rz_analysis_plugin_pyc = { .get_reg_profile = get_reg_profile, .op = &pyc_op, .esil = false, - .fini = &finish, + .fini = &pyc_analysis_finish, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_pyc, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_riscv_cs.c b/librz/arch/p/analysis/analysis_riscv_cs.c similarity index 100% rename from librz/arch/p-analysis/analysis_riscv_cs.c rename to librz/arch/p/analysis/analysis_riscv_cs.c diff --git a/librz/arch/p-analysis/analysis_rl78.c b/librz/arch/p/analysis/analysis_rl78.c similarity index 96% rename from librz/arch/p-analysis/analysis_rl78.c rename to librz/arch/p/analysis/analysis_rl78.c index 760c15a177a..435ff042dd6 100644 --- a/librz/arch/p-analysis/analysis_rl78.c +++ b/librz/arch/p/analysis/analysis_rl78.c @@ -6,8 +6,8 @@ #include #include #include -#include "../../asm/arch/rl78/rl78_instr.h" -#include "../../asm/arch/rl78/rl78.h" +#include "rl78/rl78_instr.h" +#include "rl78/rl78.h" static int rl78_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask); @@ -265,11 +265,3 @@ RzAnalysisPlugin rz_analysis_plugin_rl78 = { .op = &rl78_op, .get_reg_profile = &get_reg_profile }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_rl78, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_rsp.c b/librz/arch/p/analysis/analysis_rsp.c similarity index 98% rename from librz/arch/p-analysis/analysis_rsp.c rename to librz/arch/p/analysis/analysis_rsp.c index f1ca847e3bb..26e6f56542a 100644 --- a/librz/arch/p-analysis/analysis_rsp.c +++ b/librz/arch/p/analysis/analysis_rsp.c @@ -9,7 +9,7 @@ #include #include #include -#include "../../asm/arch/rsp/rsp_idec.h" +#include "rsp/rsp_idec.h" static int rsp_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *b, int len, RzAnalysisOpMask mask) { int i; @@ -660,11 +660,3 @@ RzAnalysisPlugin rz_analysis_plugin_rsp = { .archinfo = &archinfo, .get_reg_profile = &get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_rsp, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_rx.c b/librz/arch/p/analysis/analysis_rx.c similarity index 99% rename from librz/arch/p-analysis/analysis_rx.c rename to librz/arch/p/analysis/analysis_rx.c index cc6c1bc1912..08058130589 100644 --- a/librz/arch/p-analysis/analysis_rx.c +++ b/librz/arch/p/analysis/analysis_rx.c @@ -1,12 +1,12 @@ // SPDX-FileCopyrightText: 2024 heersin // SPDX-License-Identifier: LGPL-3.0-only -#include #include #include #include #include #include +#include static void calculate_jmp_addr(RxInst *inst, RzAnalysisOp *op) { if (inst->v0.kind == RX_OPERAND_COND) { diff --git a/librz/arch/p-analysis/analysis_sh.c b/librz/arch/p/analysis/analysis_sh.c similarity index 99% rename from librz/arch/p-analysis/analysis_sh.c rename to librz/arch/p/analysis/analysis_sh.c index 3f028c88df9..23d60397f09 100644 --- a/librz/arch/p-analysis/analysis_sh.c +++ b/librz/arch/p/analysis/analysis_sh.c @@ -6,7 +6,7 @@ #include #include #include -#include "../arch/sh/sh_il.h" +#include "sh/sh_il.h" #define API static @@ -1204,11 +1204,3 @@ RzAnalysisPlugin rz_analysis_plugin_sh = { .il_config = rz_sh_il_config }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_sh, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_snes.c b/librz/arch/p/analysis/analysis_snes.c similarity index 96% rename from librz/arch/p-analysis/analysis_snes.c rename to librz/arch/p/analysis/analysis_snes.c index 39c1ddcb4ef..3bc1c7c7270 100644 --- a/librz/arch/p-analysis/analysis_snes.c +++ b/librz/arch/p/analysis/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 +#include 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; @@ -400,11 +400,3 @@ RzAnalysisPlugin rz_analysis_plugin_snes = { .fini = snes_analysis_fini, .op = &snes_anop, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_snes, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_sparc_cs.c b/librz/arch/p/analysis/analysis_sparc_cs.c similarity index 100% rename from librz/arch/p-analysis/analysis_sparc_cs.c rename to librz/arch/p/analysis/analysis_sparc_cs.c diff --git a/librz/arch/p-analysis/analysis_spc700.c b/librz/arch/p/analysis/analysis_spc700.c similarity index 85% rename from librz/arch/p-analysis/analysis_spc700.c rename to librz/arch/p/analysis/analysis_spc700.c index d4d9f52d462..1f964e8a191 100644 --- a/librz/arch/p-analysis/analysis_spc700.c +++ b/librz/arch/p/analysis/analysis_spc700.c @@ -6,7 +6,7 @@ #include #include #include -#include "../../asm/arch/spc700/spc700dis.c" +#include static int op(RzAnalysis *analysis, RzAnalysisOp *rz_op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { // TODO: fill this with the actual info @@ -50,11 +50,3 @@ RzAnalysisPlugin rz_analysis_plugin_spc700 = { .op = &op, .get_reg_profile = &get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_spc700, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_sysz.c b/librz/arch/p/analysis/analysis_sysz.c similarity index 96% rename from librz/arch/p-analysis/analysis_sysz.c rename to librz/arch/p/analysis/analysis_sysz.c index 30c8e6ee03e..bb9b9822492 100644 --- a/librz/arch/p-analysis/analysis_sysz.c +++ b/librz/arch/p/analysis/analysis_sysz.c @@ -208,11 +208,3 @@ RzAnalysisPlugin rz_analysis_plugin_sysz = { .archinfo = archinfo, .get_reg_profile = &get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_sysz, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_tms320.c b/librz/arch/p/analysis/analysis_tms320.c similarity index 85% rename from librz/arch/p-analysis/analysis_tms320.c rename to librz/arch/p/analysis/analysis_tms320.c index d77776ea6c4..039b48f7dd1 100644 --- a/librz/arch/p-analysis/analysis_tms320.c +++ b/librz/arch/p/analysis/analysis_tms320.c @@ -1,27 +1,23 @@ +// SPDX-FileCopyrightText: 2024 deroad // SPDX-FileCopyrightText: 2014 Ilya V. Matveychikov // SPDX-License-Identifier: LGPL-3.0-only #include -#include "analysis_tms320c64x.c" -#include "../../asm/arch/tms320/tms320_dasm.h" +#include -typedef int (*TMS_ANALYSIS_OP_FN)(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len); +#include +#include -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); +typedef struct tms320_ctx_t { + void *c64x; + tms320_dasm_t engine; +} Tms320Context; static bool match(const char *str, const char *token) { return !strncasecmp(str, token, strlen(token)); } -int tms320_c54x_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len) { - // TODO: add the implementation - return 0; -} - -int tms320_c55x_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len) { - tms320_dasm_t *engine = (tms320_dasm_t *)analysis->plugin_data; +static int tms320_c55x_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, tms320_dasm_t *engine) { const char *str = engine->syntax; op->delay = 0; @@ -74,41 +70,36 @@ 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) { - TMS_ANALYSIS_OP_FN aop = tms320_c55x_op; +int tms320_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { + Tms320Context *context = (Tms320Context *)analysis->plugin_data; - if (analysis->cpu && rz_str_casecmp(analysis->cpu, "c64x") == 0) { -#ifdef CAPSTONE_TMS320C64X_H - return tms320c64x_analyze_op(analysis, op, addr, buf, len, mask); -#else - return -1; -#endif - } - if (analysis->cpu && rz_str_casecmp(analysis->cpu, "c54x") == 0) { - aop = tms320_c54x_op; - } else if (analysis->cpu && rz_str_casecmp(analysis->cpu, "c55x") == 0) { - aop = tms320_c55x_op; - } else if (analysis->cpu && rz_str_casecmp(analysis->cpu, "c55x+") == 0) { - aop = tms320_c55x_plus_op; + if (analysis->cpu && rz_str_casecmp(analysis->cpu, "c55x+") == 0) { + return tms320_c55x_plus_op(analysis, op, addr, buf, len); + } else if (analysis->cpu && rz_str_casecmp(analysis->cpu, "c64x") == 0) { + return tms320_c64x_op(analysis, op, addr, buf, len, mask, context->c64x); } - return aop(analysis, op, addr, buf, len); + return tms320_c55x_op(analysis, op, addr, buf, len, &context->engine); } -static bool tms320_init(void **user) { - tms320_dasm_t *engine = RZ_NEW0(tms320_dasm_t); - if (!engine) { +static bool tms320_analysis_init(void **user) { + Tms320Context *context = RZ_NEW0(Tms320Context); + if (!context) { return false; } - tms320_dasm_init(engine); - *user = engine; + + context->c64x = tms320_c64x_new(); + tms320_dasm_init(&context->engine); + *user = context; return true; } -static bool tms320_fini(void *user) { +static bool tms320_analysis_fini(void *user) { rz_return_val_if_fail(user, false); - tms320_dasm_t *engine = (tms320_dasm_t *)user; - tms320_dasm_fini(engine); - free(engine); + Tms320Context *context = (Tms320Context *)user; + + tms320_c64x_free(context->c64x); + tms320_dasm_fini(&context->engine); + free(context); return true; } @@ -359,17 +350,9 @@ RzAnalysisPlugin rz_analysis_plugin_tms320 = { .arch = "tms320", .bits = 32, .desc = "TMS320 DSP family code analysis plugin", - .init = tms320_init, - .fini = tms320_fini, + .init = tms320_analysis_init, + .fini = tms320_analysis_fini, .license = "LGPLv3", - .op = &tms320_op, + .op = &tms320_analysis_op, .get_reg_profile = get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_tms320, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_tricore_cs.c b/librz/arch/p/analysis/analysis_tricore_cs.c similarity index 99% rename from librz/arch/p-analysis/analysis_tricore_cs.c rename to librz/arch/p/analysis/analysis_tricore_cs.c index 883c2bbf7a5..c703ca29db5 100644 --- a/librz/arch/p-analysis/analysis_tricore_cs.c +++ b/librz/arch/p/analysis/analysis_tricore_cs.c @@ -7,7 +7,7 @@ #include #include -#include "../../asm/arch/tricore/tricore.inc" +#include 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/analysis_v810.c b/librz/arch/p/analysis/analysis_v810.c similarity index 98% rename from librz/arch/p-analysis/analysis_v810.c rename to librz/arch/p/analysis/analysis_v810.c index 36105e4cddb..d5a0d6b19b6 100644 --- a/librz/arch/p-analysis/analysis_v810.c +++ b/librz/arch/p/analysis/analysis_v810.c @@ -8,7 +8,7 @@ #include #include -#include "../arch/v810/v810.h" +#include "v810/v810.h" enum { V810_FLAG_CY = 1, @@ -573,11 +573,3 @@ RzAnalysisPlugin rz_analysis_plugin_v810 = { .il_config = v810_il_config, .get_reg_profile = get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_v810, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_v850.c b/librz/arch/p/analysis/analysis_v850.c similarity index 98% rename from librz/arch/p-analysis/analysis_v850.c rename to librz/arch/p/analysis/analysis_v850.c index d8acb56172e..a0b1f328f80 100644 --- a/librz/arch/p-analysis/analysis_v850.c +++ b/librz/arch/p/analysis/analysis_v850.c @@ -8,9 +8,9 @@ #include #include -#include -#include "../arch/v850/v850_esil.inc" -#include "../arch/v850/v850_il.h" +#include +#include +#include static int v850_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) { int ret = 0; @@ -485,11 +485,3 @@ RzAnalysisPlugin rz_analysis_plugin_v850 = { .get_reg_profile = get_reg_profile, .il_config = v850_il_config }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_v850, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_wasm.c b/librz/arch/p/analysis/analysis_wasm.c similarity index 98% rename from librz/arch/p-analysis/analysis_wasm.c rename to librz/arch/p/analysis/analysis_wasm.c index baa2b169ed9..02ae5077431 100644 --- a/librz/arch/p-analysis/analysis_wasm.c +++ b/librz/arch/p/analysis/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 "wasm/wasm.c" #define WASM_STACK_SIZE 256 @@ -468,11 +467,3 @@ RzAnalysisPlugin rz_analysis_plugin_wasm = { .get_reg_profile = get_reg_profile, .op = &wasm_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_wasm, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_x86_cs.c b/librz/arch/p/analysis/analysis_x86_cs.c similarity index 99% rename from librz/arch/p-analysis/analysis_x86_cs.c rename to librz/arch/p/analysis/analysis_x86_cs.c index e28adfe3d33..fdc187c594c 100644 --- a/librz/arch/p-analysis/analysis_x86_cs.c +++ b/librz/arch/p/analysis/analysis_x86_cs.c @@ -5,7 +5,7 @@ #include #include #include -#include "../arch/x86/x86_il.h" +#include "x86/x86_il.h" #if 0 CYCLES: diff --git a/librz/arch/p-analysis/analysis_xap.c b/librz/arch/p/analysis/analysis_xap.c similarity index 95% rename from librz/arch/p-analysis/analysis_xap.c rename to librz/arch/p/analysis/analysis_xap.c index e8be7c70058..1c34a43de64 100644 --- a/librz/arch/p-analysis/analysis_xap.c +++ b/librz/arch/p/analysis/analysis_xap.c @@ -6,7 +6,7 @@ #include #include #include -#include "../asm/arch/xap/dis.c" +#include "xap/dis.c" static int label_off(struct directive *d) { int off = d->d_operand; @@ -218,11 +218,3 @@ RzAnalysisPlugin rz_analysis_plugin_xap = { .bits = 16, .op = &xap_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_xap, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_xcore_cs.c b/librz/arch/p/analysis/analysis_xcore_cs.c similarity index 100% rename from librz/arch/p-analysis/analysis_xcore_cs.c rename to librz/arch/p/analysis/analysis_xcore_cs.c diff --git a/librz/arch/p/arch_6502.c b/librz/arch/p/arch_6502.c new file mode 100644 index 00000000000..f1735446de4 --- /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 + +#include "analysis/analysis_6502.c" +#include "asm/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..cdf7514f462 --- /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 + +#include "analysis/analysis_8051.c" +#include "asm/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..1a140c2817e --- /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 + +#include "analysis/analysis_amd29k.c" +#include "asm/asm_amd29k.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(amd29k); diff --git a/librz/arch/p/arch_arm_as.c b/librz/arch/p/arch_arm_as.c new file mode 100644 index 00000000000..28ade64e314 --- /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 + +#include "asm/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..63f1fa6b5ec --- /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 + +#include "analysis/analysis_arm_cs.c" +#include "asm/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..376085e4f8e --- /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 + +#include "analysis/analysis_avr.c" +#include "asm/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..3f45f264133 --- /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 + +#include "analysis/analysis_bf.c" +#include "asm/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..c6993256595 --- /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 + +#include "analysis/analysis_chip8.c" +#include "asm/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..899965cc27e --- /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 + +#include "analysis/analysis_cil.c" +#include "asm/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..1efde299eab --- /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 + +#include "analysis/analysis_cr16.c" +#include "asm/asm_cr16.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(cr16); diff --git a/librz/arch/p/arch_dalvik.c b/librz/arch/p/arch_dalvik.c new file mode 100644 index 00000000000..4dbd782c9cd --- /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 + +#include "analysis/analysis_dalvik.c" +#include "asm/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..c9d9d85638c --- /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 + +#include "asm/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..dbe14b15571 --- /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 + +#include "analysis/analysis_ebc.c" +#include "asm/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..58c0282b5c3 --- /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 + +#include "analysis/analysis_gb.c" +#include "asm/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..c5f0253e8a6 --- /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 + +#include "analysis/analysis_h8300.c" +#include "asm/asm_h8300.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(h8300); diff --git a/librz/arch/p/arch_hexagon.c b/librz/arch/p/arch_hexagon.c new file mode 100644 index 00000000000..426a539d79d --- /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 + +#include "analysis/analysis_hexagon.c" +#include "asm/asm_hexagon.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(hexagon); diff --git a/librz/arch/p/arch_i4004.c b/librz/arch/p/arch_i4004.c new file mode 100644 index 00000000000..d71af35d495 --- /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 + +#include "analysis/analysis_i4004.c" +#include "asm/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..07f350dfa36 --- /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 + +#include "analysis/analysis_i8080.c" +#include "asm/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..82c63de39b6 --- /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 + +#include "analysis/analysis_java.c" +#include "asm/asm_java.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(java); diff --git a/librz/arch/p/arch_lh5801.c b/librz/arch/p/arch_lh5801.c new file mode 100644 index 00000000000..41a0b4faea0 --- /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 + +#include "asm/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..e9481adf68c --- /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 + +#include "asm/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..1a9fb726b95 --- /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 + +#include "analysis/analysis_luac.c" +#include "asm/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..9f45a96142f --- /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 + +#include "analysis/analysis_m680x_cs.c" +#include "asm/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..1bc93bf31f2 --- /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 + +#include "analysis/analysis_m68k_cs.c" +#include "asm/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..cf803512642 --- /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 + +#include "analysis/analysis_malbolge.c" +#include "asm/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..3a220ce39fa --- /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 + +#include "analysis/analysis_mcore.c" +#include "asm/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..949b87d1261 --- /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 + +#include "asm/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..431647d49dc --- /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 + +#include "analysis/analysis_mips_cs.c" +#include "asm/asm_mips_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(mips_cs); diff --git a/librz/arch/p/arch_msp430.c b/librz/arch/p/arch_msp430.c new file mode 100644 index 00000000000..9ad16dd6b2a --- /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 + +#include "analysis/analysis_msp430.c" +#include "asm/asm_msp430.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(msp430); diff --git a/librz/arch/p/arch_null.c b/librz/arch/p/arch_null.c new file mode 100644 index 00000000000..ed47d7b89d1 --- /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 + +#include "analysis/analysis_null.c" +#include "asm/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..f03ad9ba5bf --- /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 + +#include "analysis/analysis_or1k.c" +#include "asm/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..2b8032eeb64 --- /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 + +#include "analysis/analysis_pic.c" +#include "asm/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..441b45d9e6f --- /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 + +#include "asm/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..b103ad1a5ec --- /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 + +#include "analysis/analysis_ppc_cs.c" +#include "asm/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..f4753c744fb --- /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 + +#include "analysis/analysis_propeller.c" +#include "asm/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..164e0945d0e --- /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 + +#include "analysis/analysis_pyc.c" +#include "asm/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..d58b5ddcca8 --- /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 + +#include "analysis/analysis_riscv_cs.c" +#include "asm/asm_riscv_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(riscv_cs); diff --git a/librz/arch/p/arch_rl78.c b/librz/arch/p/arch_rl78.c new file mode 100644 index 00000000000..c189f9e8fdb --- /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 + +#include "analysis/analysis_rl78.c" +#include "asm/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..1a8f29ba291 --- /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 + +#include "analysis/analysis_rsp.c" +#include "asm/asm_rsp.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(rsp); diff --git a/librz/arch/p/arch_rx.c b/librz/arch/p/arch_rx.c new file mode 100644 index 00000000000..76e6ae36209 --- /dev/null +++ b/librz/arch/p/arch_rx.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "analysis/analysis_rx.c" +#include "asm/asm_rx.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(rx); diff --git a/librz/arch/p/arch_sh.c b/librz/arch/p/arch_sh.c new file mode 100644 index 00000000000..840f2553921 --- /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 + +#include "analysis/analysis_sh.c" +#include "asm/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..c85560ed721 --- /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 + +#include "analysis/analysis_snes.c" +#include "asm/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..14275c9bf62 --- /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 + +#include "analysis/analysis_sparc_cs.c" +#include "asm/asm_sparc_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(sparc_cs); diff --git a/librz/arch/p/arch_spc700.c b/librz/arch/p/arch_spc700.c new file mode 100644 index 00000000000..2deb340b4cc --- /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 + +#include "analysis/analysis_spc700.c" +#include "asm/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..745976b759b --- /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 + +#include "analysis/analysis_sysz.c" +#include "asm/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..c65864f0d1f --- /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 + +#include "analysis/analysis_tms320.c" +#include "asm/asm_tms320.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(tms320); diff --git a/librz/arch/p/arch_tricore_cs.c b/librz/arch/p/arch_tricore_cs.c new file mode 100644 index 00000000000..79fb6f3b37e --- /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 + +#include "analysis/analysis_tricore_cs.c" +#include "asm/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..e6623332e0f --- /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 + +#include "analysis/analysis_v810.c" +#include "asm/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..4256ed9d2c3 --- /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 + +#include "analysis/analysis_v850.c" +#include "asm/asm_v850.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(v850); diff --git a/librz/arch/p/arch_wasm.c b/librz/arch/p/arch_wasm.c new file mode 100644 index 00000000000..0b82df22a0a --- /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 + +#include "analysis/analysis_wasm.c" +#include "asm/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..b78fc70a41d --- /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 + +#include "asm/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..830f1b813a4 --- /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 + +#include "analysis/analysis_x86_cs.c" +#include "asm/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..e6b82d62e95 --- /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 + +#include "asm/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..1895d0b80d3 --- /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 + +#include "asm/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..2ea40a03182 --- /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 + +#include "analysis/analysis_xap.c" +#include "asm/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..41082d938f6 --- /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 + +#include "analysis/analysis_xcore_cs.c" +#include "asm/asm_xcore_cs.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(xcore_cs); diff --git a/librz/arch/p-asm/asm_6502.c b/librz/arch/p/asm/asm_6502.c similarity index 72% rename from librz/arch/p-asm/asm_6502.c rename to librz/arch/p/asm/asm_6502.c index ad2032cc020..b106a00c8c9 100644 --- a/librz/arch/p-asm/asm_6502.c +++ b/librz/arch/p/asm/asm_6502.c @@ -7,10 +7,10 @@ #include #include #include -#include "../arch/6502/6502dis.c" +#include <6502/6502dis.h> static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { - int dlen = _6502Disass(a->pc, op, buf, len); + int dlen = disass_6502(a->pc, op, buf, len); return op->size = RZ_MAX(dlen, 0); } @@ -23,11 +23,3 @@ RzAsmPlugin rz_asm_plugin_6502 = { .license = "LGPL3", .disassemble = &disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_6502, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_8051.c b/librz/arch/p/asm/asm_8051.c similarity index 80% rename from librz/arch/p-asm/asm_8051.c rename to librz/arch/p/asm/asm_8051.c index cc924954ced..cab74cf5a67 100644 --- a/librz/arch/p-asm/asm_8051.c +++ b/librz/arch/p/asm/asm_8051.c @@ -10,8 +10,8 @@ #include #include -#include <8051_ass.h> -#include "../arch/8051/8051_disas.c" +#include <8051/8051_ass.h> +#include <8051/8051_disas.h> static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { int dlen = 0; @@ -40,11 +40,3 @@ RzAsmPlugin rz_asm_plugin_8051 = { "8051-generic," // First one is default "8051-shared-code-xdata" }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_8051, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_amd29k.c b/librz/arch/p/asm/asm_amd29k.c similarity index 82% rename from librz/arch/p-asm/asm_amd29k.c rename to librz/arch/p/asm/asm_amd29k.c index 52a9a7c8520..fb375fdc53e 100644 --- a/librz/arch/p-asm/asm_amd29k.c +++ b/librz/arch/p/asm/asm_amd29k.c @@ -6,7 +6,7 @@ #include #include #include -#include "../arch/amd29k/amd29k.h" +#include "amd29k/amd29k.h" static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { if (!a || !op || !buf || len < 4) { @@ -36,11 +36,3 @@ RzAsmPlugin rz_asm_plugin_amd29k = { .endian = RZ_SYS_ENDIAN_LITTLE, .disassemble = &disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_amd29k, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_arm_as.c b/librz/arch/p/asm/asm_arm_as.c similarity index 100% rename from librz/arch/p-asm/asm_arm_as.c rename to librz/arch/p/asm/asm_arm_as.c diff --git a/librz/arch/p-asm/asm_arm_cs.c b/librz/arch/p/asm/asm_arm_cs.c similarity index 95% rename from librz/arch/p-asm/asm_arm_cs.c rename to librz/arch/p/asm/asm_arm_cs.c index 6ba77c39ff4..ce42a4984f0 100644 --- a/librz/arch/p-asm/asm_arm_cs.c +++ b/librz/arch/p/asm/asm_arm_cs.c @@ -5,19 +5,19 @@ #include #include #include -#include "../arch/arm/asm-arm.h" -#include "../arch/arm/arm_it.h" +#include "arm/asm-arm.h" +#include "arm/arm_it.h" #if CS_NEXT_VERSION < 6 #include "./asm_arm_hacks.inc" #endif -typedef struct arm_cs_context_t { +typedef struct asm_arm_cs_context_t { RzArmITContext it; csh cd; int omode; int obits; -} ArmCSContext; +} AsmArmCSContext; #if CS_NEXT_VERSION < 6 inline static const char *ARMCondCodeToString(arm_cc cc) { @@ -62,7 +62,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; + AsmArmCSContext *ctx = (AsmArmCSContext *)a->plugin_data; int i; if (!insn || !insn->detail) { return true; @@ -97,7 +97,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; + AsmArmCSContext *ctx = (AsmArmCSContext *)a->plugin_data; bool disp_hash = a->immdisp; cs_insn *insn = NULL; @@ -257,7 +257,7 @@ static int assemble(RzAsm *a, RzAsmOp *op, const char *buf) { } static bool arm_init(void **user) { - ArmCSContext *ctx = RZ_NEW0(ArmCSContext); + AsmArmCSContext *ctx = RZ_NEW0(AsmArmCSContext); if (!ctx) { return false; } @@ -271,7 +271,7 @@ static bool arm_init(void **user) { static bool arm_fini(void *user) { rz_return_val_if_fail(user, false); - ArmCSContext *ctx = (ArmCSContext *)user; + AsmArmCSContext *ctx = (AsmArmCSContext *)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; + AsmArmCSContext *ctx = (AsmArmCSContext *)a->plugin_data; int i; a->cur->disassemble(a, NULL, NULL, -1); if (id != -1) { diff --git a/librz/arch/p-asm/asm_arm_hacks.inc b/librz/arch/p/asm/asm_arm_hacks.inc similarity index 100% rename from librz/arch/p-asm/asm_arm_hacks.inc rename to librz/arch/p/asm/asm_arm_hacks.inc diff --git a/librz/arch/p-asm/asm_avr.c b/librz/arch/p/asm/asm_avr.c similarity index 85% rename from librz/arch/p-asm/asm_avr.c rename to librz/arch/p/asm/asm_avr.c index 898dd9fa2e9..0cb20f4ceac 100644 --- a/librz/arch/p-asm/asm_avr.c +++ b/librz/arch/p/asm/asm_avr.c @@ -10,8 +10,8 @@ #include #include -#include "../arch/avr/assembler.h" -#include "../arch/avr/disassembler.h" +#include "avr/assembler.h" +#include "avr/disassembler.h" static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { AVROp aop = { 0 }; @@ -63,11 +63,3 @@ RzAsmPlugin rz_asm_plugin_avr = { "ATTiny48," "ATTiny88," }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_avr, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_bf.c b/librz/arch/p/asm/asm_bf.c similarity index 96% rename from librz/arch/p-asm/asm_bf.c rename to librz/arch/p/asm/asm_bf.c index 7a784a185e7..3d9bc21ff36 100644 --- a/librz/arch/p-asm/asm_bf.c +++ b/librz/arch/p/asm/asm_bf.c @@ -200,11 +200,3 @@ RzAsmPlugin rz_asm_plugin_bf = { .disassemble = &disassemble, .assemble = &assemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_bf, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_chip8.c b/librz/arch/p/asm/asm_chip8.c similarity index 96% rename from librz/arch/p-asm/asm_chip8.c rename to librz/arch/p/asm/asm_chip8.c index d412fc75932..8dc8b8187ce 100644 --- a/librz/arch/p-asm/asm_chip8.c +++ b/librz/arch/p/asm/asm_chip8.c @@ -94,11 +94,3 @@ RzAsmPlugin rz_asm_plugin_chip8 = { .desc = "Chip8 disassembler", .disassemble = &chip8_disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_chip8, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_cil.c b/librz/arch/p/asm/asm_cil.c similarity index 80% rename from librz/arch/p-asm/asm_cil.c rename to librz/arch/p/asm/asm_cil.c index 0a960c2f99e..7dd9821bd09 100644 --- a/librz/arch/p-asm/asm_cil.c +++ b/librz/arch/p/asm/asm_cil.c @@ -22,11 +22,3 @@ RzAsmPlugin rz_asm_plugin_cil = { .bits = 16 | 32 | 64, .disassemble = &disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_cil, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_cr16.c b/librz/arch/p/asm/asm_cr16.c similarity index 81% rename from librz/arch/p-asm/asm_cr16.c rename to librz/arch/p/asm/asm_cr16.c index 24a2eceb951..724369a197c 100644 --- a/librz/arch/p-asm/asm_cr16.c +++ b/librz/arch/p/asm/asm_cr16.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include static int cr16_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { struct cr16_cmd cmd = { 0 }; @@ -28,11 +28,3 @@ RzAsmPlugin rz_asm_plugin_cr16 = { .endian = RZ_SYS_ENDIAN_LITTLE, .disassemble = &cr16_disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_cr16, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_dalvik.c b/librz/arch/p/asm/asm_dalvik.c similarity index 99% rename from librz/arch/p-asm/asm_dalvik.c rename to librz/arch/p/asm/asm_dalvik.c index 308e9c87298..f8729b1d67a 100644 --- a/librz/arch/p-asm/asm_dalvik.c +++ b/librz/arch/p/asm/asm_dalvik.c @@ -554,11 +554,3 @@ RzAsmPlugin rz_asm_plugin_dalvik = { .disassemble = &dalvik_disassemble, .assemble = &dalvik_assemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_dalvik, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_dcpu16.c b/librz/arch/p/asm/asm_dcpu16.c similarity index 79% rename from librz/arch/p-asm/asm_dcpu16.c rename to librz/arch/p/asm/asm_dcpu16.c index 1c1abeb417e..d6aebe7a407 100644 --- a/librz/arch/p-asm/asm_dcpu16.c +++ b/librz/arch/p/asm/asm_dcpu16.c @@ -8,9 +8,7 @@ #include #include #include -#include "../arch/dcpu16/dcpu16.h" -#include "../arch/dcpu16/dis.c" -#include "../arch/dcpu16/asm.c" +#include static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { char buf_asm[96]; @@ -38,11 +36,3 @@ RzAsmPlugin rz_asm_plugin_dcpu16 = { .disassemble = &disassemble, .assemble = &assemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_dcpu16, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_ebc.c b/librz/arch/p/asm/asm_ebc.c similarity index 82% rename from librz/arch/p-asm/asm_ebc.c rename to librz/arch/p/asm/asm_ebc.c index c61d8aff115..672bfda45c4 100644 --- a/librz/arch/p-asm/asm_ebc.c +++ b/librz/arch/p/asm/asm_ebc.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { ebc_command_t cmd = { { 0 }, { 0 } }; @@ -30,11 +30,3 @@ RzAsmPlugin rz_asm_plugin_ebc = { .endian = RZ_SYS_ENDIAN_LITTLE, .disassemble = &disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_ebc, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_gb.c b/librz/arch/p/asm/asm_gb.c similarity index 76% rename from librz/arch/p-asm/asm_gb.c rename to librz/arch/p/asm/asm_gb.c index b32c28379c3..fe9578a31d4 100644 --- a/librz/arch/p-asm/asm_gb.c +++ b/librz/arch/p/asm/asm_gb.c @@ -2,14 +2,10 @@ // SPDX-FileCopyrightText: 2012-2018 condret // SPDX-License-Identifier: LGPL-3.0-only -// fork of asm_z80.c - #include #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) { int dlen = gbDisass(rz_op, buf, len); @@ -31,11 +27,3 @@ RzAsmPlugin rz_asm_plugin_gb = { .disassemble = &disassemble, .assemble = &assemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_gb, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_h8300.c b/librz/arch/p/asm/asm_h8300.c similarity index 78% rename from librz/arch/p-asm/asm_h8300.c rename to librz/arch/p/asm/asm_h8300.c index 43446afacad..92aaa88fdd8 100644 --- a/librz/arch/p-asm/asm_h8300.c +++ b/librz/arch/p/asm/asm_h8300.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { struct h8300_cmd cmd; @@ -24,11 +24,3 @@ RzAsmPlugin rz_asm_plugin_h8300 = { .endian = RZ_SYS_ENDIAN_BIG, .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_h8300, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_hexagon.c b/librz/arch/p/asm/asm_hexagon.c similarity index 98% rename from librz/arch/p-asm/asm_hexagon.c rename to librz/arch/p/asm/asm_hexagon.c index 71457cd3848..35c41864c9d 100644 --- a/librz/arch/p-asm/asm_hexagon.c +++ b/librz/arch/p/asm/asm_hexagon.c @@ -15,9 +15,9 @@ #include #include #include -#include "hexagon.h" -#include "hexagon_insn.h" -#include "hexagon_arch.h" +#include +#include +#include static RZ_OWN RzPVector /**/ *get_token_patterns(HexState *state) { RzPVector *pvec = state->token_patterns; diff --git a/librz/arch/p-asm/asm_i4004.c b/librz/arch/p/asm/asm_i4004.c similarity index 75% rename from librz/arch/p-asm/asm_i4004.c rename to librz/arch/p/asm/asm_i4004.c index 4c46a719d5f..bca75704d43 100644 --- a/librz/arch/p-asm/asm_i4004.c +++ b/librz/arch/p/asm/asm_i4004.c @@ -6,7 +6,7 @@ #include #include #include -#include "../arch/i4004/i4004dis.c" +#include static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return i4004dis(op, buf, len); @@ -21,11 +21,3 @@ RzAsmPlugin rz_asm_plugin_i4004 = { .endian = RZ_SYS_ENDIAN_NONE, .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_i4004, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_i8080.c b/librz/arch/p/asm/asm_i8080.c similarity index 75% rename from librz/arch/p-asm/asm_i8080.c rename to librz/arch/p/asm/asm_i8080.c index 35dfb307930..afb7634783a 100644 --- a/librz/arch/p-asm/asm_i8080.c +++ b/librz/arch/p/asm/asm_i8080.c @@ -5,7 +5,7 @@ #include #include #include -#include "../arch/i8080/i8080dis.c" +#include 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); @@ -21,11 +21,3 @@ RzAsmPlugin rz_asm_plugin_i8080 = { .endian = RZ_SYS_ENDIAN_NONE, .disassemble = &do_disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_i8080, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_java.c b/librz/arch/p/asm/asm_java.c similarity index 86% rename from librz/arch/p-asm/asm_java.c rename to librz/arch/p/asm/asm_java.c index 3c19d422423..032f1d7a653 100644 --- a/librz/arch/p-asm/asm_java.c +++ b/librz/arch/p/asm/asm_java.c @@ -7,10 +7,10 @@ #include #include -#include "../arch/java/jvm.h" -#include "../arch/java/assembler.h" +#include "java/jvm.h" +#include "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 java_asm_update_context(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 java_asm_find_method(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); + java_asm_update_context(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); + java_asm_update_context(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 = java_asm_find_method(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,16 +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, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_java, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_lh5801.c b/librz/arch/p/asm/asm_lh5801.c similarity index 82% rename from librz/arch/p-asm/asm_lh5801.c rename to librz/arch/p/asm/asm_lh5801.c index 799a45a5f46..7e0990108dc 100644 --- a/librz/arch/p-asm/asm_lh5801.c +++ b/librz/arch/p/asm/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 static int disassemble(RzAsm *as, RzAsmOp *op, const ut8 *buf, int len) { struct lh5801_insn insn = { 0 }; @@ -35,11 +35,3 @@ RzAsmPlugin rz_asm_plugin_lh5801 = { .desc = "SHARP LH5801 disassembler", .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_lh5801, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_lm32.c b/librz/arch/p/asm/asm_lm32.c similarity index 98% rename from librz/arch/p-asm/asm_lm32.c rename to librz/arch/p/asm/asm_lm32.c index e3452d8d7c5..dcdb1e0dd42 100644 --- a/librz/arch/p-asm/asm_lm32.c +++ b/librz/arch/p/asm/asm_lm32.c @@ -5,7 +5,7 @@ #include #include #include -#include "../arch/lm32/lm32_isa.h" +#include "lm32/lm32_isa.h" #define LM32_UNUSED 0 @@ -454,11 +454,3 @@ RzAsmPlugin rz_asm_plugin_lm32 = { .endian = RZ_SYS_ENDIAN_BIG, .disassemble = &disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_lm32, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_luac.c b/librz/arch/p/asm/asm_luac.c similarity index 97% rename from librz/arch/p-asm/asm_luac.c rename to librz/arch/p/asm/asm_luac.c index 5ecfdc461a7..30021525f76 100644 --- a/librz/arch/p-asm/asm_luac.c +++ b/librz/arch/p/asm/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 int rz_luac_disasm(RzAsm *a, RzAsmOp *opstruct, const ut8 *buf, int len) { LuaOpNameList oplist = NULL; diff --git a/librz/arch/p-asm/asm_m680x_cs.c b/librz/arch/p/asm/asm_m680x_cs.c similarity index 94% rename from librz/arch/p-asm/asm_m680x_cs.c rename to librz/arch/p/asm/asm_m680x_cs.c index 45dfdd059bb..4ed876357b6 100644 --- a/librz/arch/p-asm/asm_m680x_cs.c +++ b/librz/arch/p/asm/asm_m680x_cs.c @@ -5,7 +5,7 @@ #include #include "cs_helper.h" -CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(m680x); +CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(m680x_asm); static cs_mode m680x_mode(const char *str) { if (!str) { @@ -87,10 +87,10 @@ RzAsmPlugin rz_asm_plugin_m680x_cs = { .arch = "m680x", .bits = 8 | 32, .endian = RZ_SYS_ENDIAN_LITTLE, - .init = m680x_init, - .fini = m680x_fini, + .init = m680x_asm_init, + .fini = m680x_asm_fini, .disassemble = &m680x_disassemble, - .mnemonics = m680x_mnemonics, + .mnemonics = m680x_asm_mnemonics, }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p-asm/asm_m68k_cs.c b/librz/arch/p/asm/asm_m68k_cs.c similarity index 96% rename from librz/arch/p-asm/asm_m68k_cs.c rename to librz/arch/p/asm/asm_m68k_cs.c index 15679ac889f..ed319dea9e9 100644 --- a/librz/arch/p-asm/asm_m68k_cs.c +++ b/librz/arch/p/asm/asm_m68k_cs.c @@ -19,7 +19,7 @@ #if CAPSTONE_HAS_M68K #include "cs_helper.h" -CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(m68k); +CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(m68k_asm); // Size of the longest instruction in bytes #define M68K_LONGEST_INSTRUCTION 10 @@ -123,10 +123,10 @@ RzAsmPlugin rz_asm_plugin_m68k_cs = { .arch = "m68k", .bits = 32, .endian = RZ_SYS_ENDIAN_BIG, - .init = m68k_init, - .fini = m68k_fini, + .init = m68k_asm_init, + .fini = m68k_asm_fini, .disassemble = &m68k_disassemble, - .mnemonics = &m68k_mnemonics, + .mnemonics = &m68k_asm_mnemonics, }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p-asm/asm_malbolge.c b/librz/arch/p/asm/asm_malbolge.c similarity index 86% rename from librz/arch/p-asm/asm_malbolge.c rename to librz/arch/p/asm/asm_malbolge.c index ff7652ebf49..8fd397f6344 100644 --- a/librz/arch/p-asm/asm_malbolge.c +++ b/librz/arch/p/asm/asm_malbolge.c @@ -38,11 +38,3 @@ RzAsmPlugin rz_asm_plugin_malbolge = { .endian = RZ_SYS_ENDIAN_NONE, .disassemble = &__disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_malbolge, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_mcore.c b/librz/arch/p/asm/asm_mcore.c similarity index 81% rename from librz/arch/p-asm/asm_mcore.c rename to librz/arch/p/asm/asm_mcore.c index eb32f4a582b..e14d2cf9b0b 100644 --- a/librz/arch/p-asm/asm_mcore.c +++ b/librz/arch/p/asm/asm_mcore.c @@ -3,7 +3,7 @@ #include #include -#include "../arch/mcore/mcore.h" +#include "mcore/mcore.h" static mcore_handle handle = { 0 }; @@ -34,11 +34,3 @@ RzAsmPlugin rz_asm_plugin_mcore = { .endian = RZ_SYS_ENDIAN_BIG, .disassemble = &disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_mcore, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_mcs96.c b/librz/arch/p/asm/asm_mcs96.c similarity index 93% rename from librz/arch/p-asm/asm_mcs96.c rename to librz/arch/p/asm/asm_mcs96.c index ce4b8a0369a..7a6e3a34810 100644 --- a/librz/arch/p-asm/asm_mcs96.c +++ b/librz/arch/p/asm/asm_mcs96.c @@ -5,7 +5,7 @@ #include #include #include -#include "../arch/mcs96/mcs96.h" +#include "mcs96/mcs96.h" static int mcs96_len(const ut8 *buf, int len, RzStrBuf *asm_buf) { int ret = 1; @@ -116,11 +116,3 @@ RzAsmPlugin rz_asm_plugin_mcs96 = { .endian = RZ_SYS_ENDIAN_NONE, .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_mcs96, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_mips_cs.c b/librz/arch/p/asm/asm_mips_cs.c similarity index 88% rename from librz/arch/p-asm/asm_mips_cs.c rename to librz/arch/p/asm/asm_mips_cs.c index a51128b083c..94c675c24c4 100644 --- a/librz/arch/p-asm/asm_mips_cs.c +++ b/librz/arch/p/asm/asm_mips_cs.c @@ -3,11 +3,10 @@ #include #include +#include #include "cs_helper.h" -CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(mips); - -RZ_IPI int mips_assemble(const char *str, ut64 pc, ut8 *out); +CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(mips_asm); static int mips_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { CapstoneContext *ctx = (CapstoneContext *)a->plugin_data; @@ -71,9 +70,9 @@ static int mips_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return op->size; } -static int assemble(RzAsm *a, RzAsmOp *op, const char *str) { +static int mips_assemble(RzAsm *a, RzAsmOp *op, const char *str) { ut8 *opbuf = (ut8 *)rz_strbuf_get(&op->buf); - int ret = mips_assemble(str, a->pc, opbuf); + int ret = mips_assemble_opcode(str, a->pc, opbuf); if (a->big_endian) { ut8 *buf = opbuf; ut8 tmp = buf[0]; @@ -94,11 +93,11 @@ RzAsmPlugin rz_asm_plugin_mips_cs = { .cpus = "mips32/64,micro,r6,v3,v2", .bits = 16 | 32 | 64, .endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG, - .init = mips_init, - .fini = mips_fini, + .init = mips_asm_init, + .fini = mips_asm_fini, .disassemble = &mips_disassemble, - .mnemonics = mips_mnemonics, - .assemble = &assemble + .mnemonics = mips_asm_mnemonics, + .assemble = &mips_assemble }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p-asm/asm_msp430.c b/librz/arch/p/asm/asm_msp430.c similarity index 85% rename from librz/arch/p-asm/asm_msp430.c rename to librz/arch/p/asm/asm_msp430.c index ed0c14f3dd6..43ea2b12140 100644 --- a/librz/arch/p-asm/asm_msp430.c +++ b/librz/arch/p/asm/asm_msp430.c @@ -7,7 +7,7 @@ #include #include -#include +#include static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { struct msp430_cmd cmd; @@ -41,11 +41,3 @@ RzAsmPlugin rz_asm_plugin_msp430 = { .endian = RZ_SYS_ENDIAN_LITTLE, .disassemble = &disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_msp430, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_null.c b/librz/arch/p/asm/asm_null.c similarity index 82% rename from librz/arch/p-asm/asm_null.c rename to librz/arch/p/asm/asm_null.c index 01632298958..557f145e4fd 100644 --- a/librz/arch/p-asm/asm_null.c +++ b/librz/arch/p/asm/asm_null.c @@ -30,11 +30,3 @@ RzAsmPlugin rz_asm_plugin_null = { .disassemble = &disassemble, .assemble = &assemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_null, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_or1k.c b/librz/arch/p/asm/asm_or1k.c similarity index 96% rename from librz/arch/p-asm/asm_or1k.c rename to librz/arch/p/asm/asm_or1k.c index a7db3e608d3..ec0cc59c0d2 100644 --- a/librz/arch/p-asm/asm_or1k.c +++ b/librz/arch/p/asm/asm_or1k.c @@ -3,19 +3,7 @@ #include #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; -}; +#include static int insn_to_str(RzAsm *a, char **line, insn_t *descr, insn_extra_t *extra, ut32 insn) { struct operands o = { 0 }; diff --git a/librz/arch/p-asm/asm_pic.c b/librz/arch/p/asm/asm_pic.c similarity index 89% rename from librz/arch/p-asm/asm_pic.c rename to librz/arch/p/asm/asm_pic.c index 95c71d97ee7..ffe38be12d1 100644 --- a/librz/arch/p-asm/asm_pic.c +++ b/librz/arch/p/asm/asm_pic.c @@ -5,9 +5,9 @@ #include #include -#include "../arch/pic/pic_baseline.h" -#include "../arch/pic/pic_pic18.h" -#include "../arch/pic/pic_midrange.h" +#include "pic/pic_baseline.h" +#include "pic/pic_pic18.h" +#include "pic/pic_midrange.h" static int asm_pic_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *b, int l) { int res = -1; diff --git a/librz/arch/p-asm/asm_ppc_as.c b/librz/arch/p/asm/asm_ppc_as.c similarity index 100% rename from librz/arch/p-asm/asm_ppc_as.c rename to librz/arch/p/asm/asm_ppc_as.c diff --git a/librz/arch/p-asm/asm_ppc_cs.c b/librz/arch/p/asm/asm_ppc_cs.c similarity index 94% rename from librz/arch/p-asm/asm_ppc_cs.c rename to librz/arch/p/asm/asm_ppc_cs.c index fece75684d4..b48784d282d 100644 --- a/librz/arch/p-asm/asm_ppc_cs.c +++ b/librz/arch/p/asm/asm_ppc_cs.c @@ -3,12 +3,12 @@ #include #include -#include "../arch/ppc/libvle/vle.h" -#include "../arch/ppc/libps/libps.h" +#include "ppc/libvle/vle.h" +#include "ppc/libps/libps.h" #include "cs_helper.h" -CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(ppc); +CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(ppc_asm); static int decompile_vle(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { vle_t *instr = 0; @@ -125,10 +125,10 @@ RzAsmPlugin rz_asm_plugin_ppc_cs = { .cpus = "ppc,vle,ps,qpx", .bits = 32 | 64, .endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG, - .init = ppc_init, - .fini = ppc_fini, + .init = ppc_asm_init, + .fini = ppc_asm_fini, .disassemble = &ppc_disassemble, - .mnemonics = ppc_mnemonics, + .mnemonics = ppc_asm_mnemonics, }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p-asm/asm_propeller.c b/librz/arch/p/asm/asm_propeller.c similarity index 83% rename from librz/arch/p-asm/asm_propeller.c rename to librz/arch/p/asm/asm_propeller.c index d31b9fe9410..d34207f9f41 100644 --- a/librz/arch/p-asm/asm_propeller.c +++ b/librz/arch/p/asm/asm_propeller.c @@ -7,7 +7,7 @@ #include #include -#include +#include static int propeller_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { rz_return_val_if_fail(a && op && buf && len >= 4, -1); @@ -33,11 +33,3 @@ RzAsmPlugin rz_asm_plugin_propeller = { .endian = RZ_SYS_ENDIAN_BIG, .disassemble = &propeller_disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_propeller, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_pyc.c b/librz/arch/p/asm/asm_pyc.c similarity index 86% rename from librz/arch/p-asm/asm_pyc.c rename to librz/arch/p/asm/asm_pyc.c index a4ede22ce91..41a0ad1bf0a 100644 --- a/librz/arch/p-asm/asm_pyc.c +++ b/librz/arch/p/asm/asm_pyc.c @@ -7,11 +7,11 @@ #include #include -#include "../arch/pyc/pyc_dis.h" +#include "pyc/pyc_dis.h" static pyc_opcodes *opcodes_cache = NULL; -static int disassemble(RzAsm *a, RzAsmOp *opstruct, const ut8 *buf, int len) { +static int pyc_asm_disassemble(RzAsm *a, RzAsmOp *opstruct, const ut8 *buf, int len) { RzList *shared = NULL; RzBin *bin = a->binb.bin; @@ -44,7 +44,7 @@ static int disassemble(RzAsm *a, RzAsmOp *opstruct, const ut8 *buf, int len) { return r; } -static bool finish(void *user) { +static bool pyc_asm_finish(void *user) { if (opcodes_cache) { free_opcode(opcodes_cache); opcodes_cache = NULL; @@ -58,8 +58,8 @@ RzAsmPlugin rz_asm_plugin_pyc = { .license = "LGPL3", .bits = 16 | 8, .desc = "PYC disassemble plugin", - .disassemble = &disassemble, - .fini = &finish, + .disassemble = &pyc_asm_disassemble, + .fini = &pyc_asm_finish, }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p-asm/asm_riscv_cs.c b/librz/arch/p/asm/asm_riscv_cs.c similarity index 93% rename from librz/arch/p-asm/asm_riscv_cs.c rename to librz/arch/p/asm/asm_riscv_cs.c index 990e059e332..edf990ed1ca 100644 --- a/librz/arch/p-asm/asm_riscv_cs.c +++ b/librz/arch/p/asm/asm_riscv_cs.c @@ -5,7 +5,7 @@ #include #include "cs_helper.h" -CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(riscv); +CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(riscv_asm); static int riscv_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { CapstoneContext *ctx = (CapstoneContext *)a->plugin_data; @@ -62,10 +62,10 @@ RzAsmPlugin rz_asm_plugin_riscv_cs = { .cpus = "", .bits = 32 | 64, .endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG, - .init = riscv_init, - .fini = riscv_fini, + .init = riscv_asm_init, + .fini = riscv_asm_fini, .disassemble = &riscv_disassemble, - .mnemonics = riscv_mnemonics, + .mnemonics = riscv_asm_mnemonics, }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p-asm/asm_rl78.c b/librz/arch/p/asm/asm_rl78.c similarity index 85% rename from librz/arch/p-asm/asm_rl78.c rename to librz/arch/p/asm/asm_rl78.c index 9344082adea..4862c8b89a4 100644 --- a/librz/arch/p-asm/asm_rl78.c +++ b/librz/arch/p/asm/asm_rl78.c @@ -6,7 +6,7 @@ #include #include -#include "../arch/rl78/rl78.h" +#include "rl78/rl78.h" static int assemble(RzAsm *a, RzAsmOp *op, const char *buf) { return 0x69; @@ -44,11 +44,3 @@ RzAsmPlugin rz_asm_plugin_rl78 = { .assemble = &assemble, .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_rl78, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_rsp.c b/librz/arch/p/asm/asm_rsp.c similarity index 91% rename from librz/arch/p-asm/asm_rsp.c rename to librz/arch/p/asm/asm_rsp.c index ddc6428a092..7a4ec4bf4d6 100644 --- a/librz/arch/p-asm/asm_rsp.c +++ b/librz/arch/p/asm/asm_rsp.c @@ -10,9 +10,9 @@ #include #include -#include "rsp_idec.h" +#include -static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { +static int rsp_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { rsp_instruction rz_instr; int i; @@ -93,13 +93,5 @@ RzAsmPlugin rz_asm_plugin_rsp = { .bits = 32, .endian = RZ_SYS_ENDIAN_BI, /* For conveniance, we don't force BIG endian but allow both to be used */ .license = "LGPL3", - .disassemble = &disassemble + .disassemble = &rsp_disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_rsp, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_rx.c b/librz/arch/p/asm/asm_rx.c similarity index 96% rename from librz/arch/p-asm/asm_rx.c rename to librz/arch/p/asm/asm_rx.c index 586700ff980..8da42ab0248 100644 --- a/librz/arch/p-asm/asm_rx.c +++ b/librz/arch/p/asm/asm_rx.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { RxInst inst = { 0 }; diff --git a/librz/arch/p-asm/asm_sh.c b/librz/arch/p/asm/asm_sh.c similarity index 83% rename from librz/arch/p-asm/asm_sh.c rename to librz/arch/p/asm/asm_sh.c index 4639bf4d59f..69885d5dc2c 100644 --- a/librz/arch/p-asm/asm_sh.c +++ b/librz/arch/p/asm/asm_sh.c @@ -5,8 +5,8 @@ #include #include #include -#include "../arch/sh/disassembler.h" -#include "../arch/sh/assembler.h" +#include "sh/disassembler.h" +#include "sh/assembler.h" static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { SHOp *dis_op = sh_disassembler(rz_read_ble16(buf, a->big_endian)); @@ -46,11 +46,3 @@ RzAsmPlugin rz_asm_plugin_sh = { .disassemble = &disassemble, .assemble = &assemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_sh, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_snes.c b/librz/arch/p/asm/asm_snes.c similarity index 85% rename from librz/arch/p-asm/asm_snes.c rename to librz/arch/p/asm/asm_snes.c index 954d044dad2..459ae7da83a 100644 --- a/librz/arch/p-asm/asm_snes.c +++ b/librz/arch/p/asm/asm_snes.c @@ -6,8 +6,8 @@ #include #include #include -#include "../arch/snes/snesdis.c" -#include "asm_snes.h" +#include +#include static int dis(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { struct snes_asm_flags *snesflags = (struct snes_asm_flags *)a->plugin_data; @@ -56,11 +56,3 @@ RzAsmPlugin rz_asm_plugin_snes = { .license = "LGPL3", .disassemble = &dis }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_snes, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_sparc_cs.c b/librz/arch/p/asm/asm_sparc_cs.c similarity index 93% rename from librz/arch/p-asm/asm_sparc_cs.c rename to librz/arch/p/asm/asm_sparc_cs.c index cc763f4bc5e..510fe91c548 100644 --- a/librz/arch/p-asm/asm_sparc_cs.c +++ b/librz/arch/p/asm/asm_sparc_cs.c @@ -5,7 +5,7 @@ #include #include "cs_helper.h" -CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(sparc); +CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(sparc_asm); static int sparc_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { CapstoneContext *ctx = (CapstoneContext *)a->plugin_data; @@ -73,10 +73,10 @@ RzAsmPlugin rz_asm_plugin_sparc_cs = { .cpus = "v9", .bits = 32 | 64, .endian = RZ_SYS_ENDIAN_BIG | RZ_SYS_ENDIAN_LITTLE, - .init = sparc_init, - .fini = sparc_fini, + .init = sparc_asm_init, + .fini = sparc_asm_fini, .disassemble = &sparc_disassemble, - .mnemonics = sparc_mnemonics + .mnemonics = sparc_asm_mnemonics }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p-asm/asm_spc700.c b/librz/arch/p/asm/asm_spc700.c similarity index 77% rename from librz/arch/p-asm/asm_spc700.c rename to librz/arch/p/asm/asm_spc700.c index 552c5c550f1..9d815261a9c 100644 --- a/librz/arch/p-asm/asm_spc700.c +++ b/librz/arch/p/asm/asm_spc700.c @@ -6,7 +6,7 @@ #include #include #include -#include "../arch/spc700/spc700dis.c" +#include 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); @@ -23,11 +23,3 @@ RzAsmPlugin rz_asm_plugin_spc700 = { .endian = RZ_SYS_ENDIAN_LITTLE, .disassemble = &disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_spc700, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_sysz.c b/librz/arch/p/asm/asm_sysz.c similarity index 91% rename from librz/arch/p-asm/asm_sysz.c rename to librz/arch/p/asm/asm_sysz.c index 893eeb32936..2d09897ec95 100644 --- a/librz/arch/p-asm/asm_sysz.c +++ b/librz/arch/p/asm/asm_sysz.c @@ -66,11 +66,3 @@ RzAsmPlugin rz_asm_plugin_sysz = { .disassemble = &sysz_disassemble, .mnemonics = sysz_mnemonics, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_sysz, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p/asm/asm_tms320.c b/librz/arch/p/asm/asm_tms320.c new file mode 100644 index 00000000000..f5a971a2b83 --- /dev/null +++ b/librz/arch/p/asm/asm_tms320.c @@ -0,0 +1,76 @@ +// SPDX-FileCopyrightText: 2014 Ilya V. Matveychikov +// SPDX-License-Identifier: LGPL-3.0-only + +#include +#include +#include +#include +#include +#include + +typedef struct tms_cs_context_t { + void *c64x; + tms320_dasm_t engine; +} TmsContext; + +static int tms320_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { + TmsContext *ctx = (TmsContext *)a->plugin_data; + if (a->cpu && rz_str_casecmp(a->cpu, "c54x") == 0) { + tms320_f_set_cpu(&ctx->engine, TMS320_F_CPU_C54X); + } else if (a->cpu && rz_str_casecmp(a->cpu, "c55x+") == 0) { + tms320_f_set_cpu(&ctx->engine, TMS320_F_CPU_C55X_PLUS); + } else if (a->cpu && rz_str_casecmp(a->cpu, "c55x") == 0) { + tms320_f_set_cpu(&ctx->engine, TMS320_F_CPU_C55X); + } else if (a->cpu && !rz_str_casecmp(a->cpu, "c64x")) { + return tms320_c64x_disassemble(a, op, buf, len, ctx->c64x); + } else { + rz_asm_op_set_asm(op, "unknown asm.cpu"); + return op->size = -1; + } + op->size = tms320_dasm(&ctx->engine, buf, len); + rz_asm_op_set_asm(op, ctx->engine.syntax); + return op->size; +} + +static bool tms320_init(void **user) { + TmsContext *ctx = RZ_NEW0(TmsContext); + if (!ctx) { + return false; + } + + ctx->c64x = tms320_c64x_new(); + tms320_dasm_init(&ctx->engine); + *user = ctx; + return true; +} + +static bool tms320_fini(void *user) { + rz_return_val_if_fail(user, false); + TmsContext *ctx = (TmsContext *)user; + tms320_c64x_free(ctx->c64x); + tms320_dasm_fini(&ctx->engine); + free(ctx); + return true; +} + +static char *tms320_mnemonics(RzAsm *a, int id, bool json) { + TmsContext *ctx = (TmsContext *)a->plugin_data; + if (!a->cpu || rz_str_casecmp(a->cpu, "c64x")) { + return NULL; + } + return tms320_c64x_mnemonics(a, id, json, ctx->c64x); +} + +RzAsmPlugin rz_asm_plugin_tms320 = { + .name = "tms320", + .arch = "tms320", + .cpus = "c54x,c55x,c55x+,c64x", + .desc = "TMS320 DSP family (c54x,c55x,c55x+,c64x)", + .license = "LGPL3", + .bits = 32, + .endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG, + .init = tms320_init, + .fini = tms320_fini, + .disassemble = &tms320_disassemble, + .mnemonics = tms320_mnemonics, +}; diff --git a/librz/arch/p-asm/asm_tricore_cs.c b/librz/arch/p/asm/asm_tricore_cs.c similarity index 96% rename from librz/arch/p-asm/asm_tricore_cs.c rename to librz/arch/p/asm/asm_tricore_cs.c index 1b81b15f394..888ace1c5b2 100644 --- a/librz/arch/p-asm/asm_tricore_cs.c +++ b/librz/arch/p/asm/asm_tricore_cs.c @@ -9,8 +9,6 @@ #include #include -#include "../arch/tricore/tricore.inc" - #define TRICORE_LONGEST_INSTRUCTION 4 #define TRICORE_SHORTEST_INSTRUCTION 2 @@ -105,7 +103,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", @@ -121,7 +119,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/asm_v810.c b/librz/arch/p/asm/asm_v810.c similarity index 80% rename from librz/arch/p-asm/asm_v810.c rename to librz/arch/p/asm/asm_v810.c index 21c14d697af..153ba7fb8ba 100644 --- a/librz/arch/p-asm/asm_v810.c +++ b/librz/arch/p/asm/asm_v810.c @@ -7,7 +7,7 @@ #include #include -#include "../arch/v810/v810_disas.h" +#include "v810/v810_disas.h" static int v810_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { struct v810_cmd cmd = { @@ -34,11 +34,3 @@ RzAsmPlugin rz_asm_plugin_v810 = { .endian = RZ_SYS_ENDIAN_LITTLE, .disassemble = &v810_disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_v810, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_v850.c b/librz/arch/p/asm/asm_v850.c similarity index 81% rename from librz/arch/p-asm/asm_v850.c rename to librz/arch/p/asm/asm_v850.c index 835f26e29a9..7a1e238942d 100644 --- a/librz/arch/p-asm/asm_v850.c +++ b/librz/arch/p/asm/asm_v850.c @@ -7,7 +7,7 @@ #include #include -#include +#include static int v850_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { V850_Inst inst = { 0 }; @@ -33,11 +33,3 @@ RzAsmPlugin rz_asm_plugin_v850 = { .endian = RZ_SYS_ENDIAN_LITTLE, .disassemble = &v850_disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_v850, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_wasm.c b/librz/arch/p/asm/asm_wasm.c similarity index 84% rename from librz/arch/p-asm/asm_wasm.c rename to librz/arch/p/asm/asm_wasm.c index 437cb3ca125..87ac843f497 100644 --- a/librz/arch/p-asm/asm_wasm.c +++ b/librz/arch/p/asm/asm_wasm.c @@ -10,7 +10,7 @@ #include #include -#include "../arch/wasm/wasm.h" +#include static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { WasmOp wop = { { 0 } }; @@ -39,11 +39,3 @@ RzAsmPlugin rz_asm_plugin_wasm = { .disassemble = &disassemble, .assemble = &assemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_wasm, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_x86_as.c b/librz/arch/p/asm/asm_x86_as.c similarity index 100% rename from librz/arch/p-asm/asm_x86_as.c rename to librz/arch/p/asm/asm_x86_as.c diff --git a/librz/arch/p-asm/asm_x86_cs.c b/librz/arch/p/asm/asm_x86_cs.c similarity index 96% rename from librz/arch/p-asm/asm_x86_cs.c rename to librz/arch/p/asm/asm_x86_cs.c index 7ab82c4fefa..7babd9de109 100644 --- a/librz/arch/p-asm/asm_x86_cs.c +++ b/librz/arch/p/asm/asm_x86_cs.c @@ -5,14 +5,44 @@ #include #include -static bool check_features(RzAsm *a, cs_insn *insn); - #include "cs_helper.h" -CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(x86); +CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(x86_asm); #include "asm_x86_vm.c" +static bool check_features(RzAsm *a, cs_insn *insn) { + if (RZ_STR_ISEMPTY(a->features)) { + return true; + } + CapstoneContext *ctx = (CapstoneContext *)a->plugin_data; + const char *name; + int i; + if (!insn || !insn->detail) { + return true; + } + for (i = 0; i < insn->detail->groups_count; i++) { + int id = insn->detail->groups[i]; + if (id < 128) { + continue; + } + if (id == X86_GRP_MODE32) { + continue; + } + if (id == X86_GRP_MODE64) { + continue; + } + name = cs_group_name(ctx->handle, id); + if (!name) { + return true; + } + if (!strstr(a->features, name)) { + return false; + } + } + return true; +} + static int x86_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { CapstoneContext *ctx = (CapstoneContext *)a->plugin_data; int ret, n; @@ -110,47 +140,15 @@ RzAsmPlugin rz_asm_plugin_x86_cs = { .arch = "x86", .bits = 16 | 32 | 64, .endian = RZ_SYS_ENDIAN_LITTLE, - .init = x86_init, - .fini = x86_fini, - .mnemonics = x86_mnemonics, + .init = x86_asm_init, + .fini = x86_asm_fini, + .mnemonics = x86_asm_mnemonics, .disassemble = &x86_disassemble, .features = "vm,3dnow,aes,adx,avx,avx2,avx512,bmi,bmi2,cmov," "f16c,fma,fma4,fsgsbase,hle,mmx,rtm,sha,sse1,sse2," "sse3,sse41,sse42,sse4a,ssse3,pclmul,xop" }; -static bool check_features(RzAsm *a, cs_insn *insn) { - if (RZ_STR_ISEMPTY(a->features)) { - return true; - } - CapstoneContext *ctx = (CapstoneContext *)a->plugin_data; - const char *name; - int i; - if (!insn || !insn->detail) { - return true; - } - for (i = 0; i < insn->detail->groups_count; i++) { - int id = insn->detail->groups[i]; - if (id < 128) { - continue; - } - if (id == X86_GRP_MODE32) { - continue; - } - if (id == X86_GRP_MODE64) { - continue; - } - name = cs_group_name(ctx->handle, id); - if (!name) { - return true; - } - if (!strstr(a->features, name)) { - return false; - } - } - return true; -} - #ifndef RZ_PLUGIN_INCORE RZ_API RzLibStruct rizin_plugin = { .type = RZ_LIB_TYPE_ASM, diff --git a/librz/arch/p-asm/asm_x86_nasm.c b/librz/arch/p/asm/asm_x86_nasm.c similarity index 100% rename from librz/arch/p-asm/asm_x86_nasm.c rename to librz/arch/p/asm/asm_x86_nasm.c diff --git a/librz/arch/p-asm/asm_x86_nz.c b/librz/arch/p/asm/asm_x86_nz.c similarity index 100% rename from librz/arch/p-asm/asm_x86_nz.c rename to librz/arch/p/asm/asm_x86_nz.c diff --git a/librz/arch/p-asm/asm_x86_vm.c b/librz/arch/p/asm/asm_x86_vm.c similarity index 100% rename from librz/arch/p-asm/asm_x86_vm.c rename to librz/arch/p/asm/asm_x86_vm.c diff --git a/librz/arch/p-asm/asm_xap.c b/librz/arch/p/asm/asm_xap.c similarity index 86% rename from librz/arch/p-asm/asm_xap.c rename to librz/arch/p/asm/asm_xap.c index 1b4a684c30f..90316b4f33f 100644 --- a/librz/arch/p-asm/asm_xap.c +++ b/librz/arch/p/asm/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(); @@ -46,11 +45,3 @@ RzAsmPlugin rz_asm_plugin_xap = { .desc = "XAP4 RISC (CSR)", .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_xap, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_xcore_cs.c b/librz/arch/p/asm/asm_xcore_cs.c similarity index 92% rename from librz/arch/p-asm/asm_xcore_cs.c rename to librz/arch/p/asm/asm_xcore_cs.c index 01c8a3eb156..a7bcc277343 100644 --- a/librz/arch/p-asm/asm_xcore_cs.c +++ b/librz/arch/p/asm/asm_xcore_cs.c @@ -6,7 +6,7 @@ #include "cs_helper.h" -CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(xcore); +CAPSTONE_DEFINE_PLUGIN_FUNCTIONS(xcore_asm); static int xcore_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { CapstoneContext *ctx = (CapstoneContext *)a->plugin_data; @@ -63,10 +63,10 @@ RzAsmPlugin rz_asm_plugin_xcore_cs = { .arch = "xcore", .bits = 32, .endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG, - .init = &xcore_init, - .fini = &xcore_fini, + .init = &xcore_asm_init, + .fini = &xcore_asm_fini, .disassemble = &xcore_disassemble, - .mnemonics = &xcore_mnemonics, + .mnemonics = &xcore_asm_mnemonics, }; #ifndef RZ_PLUGIN_INCORE diff --git a/librz/arch/p-asm/cs_helper.h b/librz/arch/p/asm/cs_helper.h similarity index 91% rename from librz/arch/p-asm/cs_helper.h rename to librz/arch/p/asm/cs_helper.h index c74296b5f15..6a17cab856f 100644 --- a/librz/arch/p-asm/cs_helper.h +++ b/librz/arch/p/asm/cs_helper.h @@ -46,11 +46,11 @@ typedef struct { int i; \ a->cur->disassemble(a, NULL, NULL, -1); \ if (id != -1) { \ - const char *name = cs_insn_name(ctx->handle, id); \ + const char *vname = cs_insn_name(ctx->handle, id); \ if (json) { \ - return name ? rz_str_newf("[\"%s\"]\n", name) : NULL; \ + return vname ? rz_str_newf("[\"%s\"]\n", vname) : NULL; \ } \ - return name ? strdup(name) : NULL; \ + return vname ? strdup(vname) : NULL; \ } \ RzStrBuf *buf = rz_strbuf_new(""); \ if (json) { \ diff --git a/librz/arch/p-analysis/analysis_arc.c b/librz/arch/p_gnu/analysis/analysis_arc_gnu.c similarity index 99% rename from librz/arch/p-analysis/analysis_arc.c rename to librz/arch/p_gnu/analysis/analysis_arc_gnu.c index 4ec0b0316eb..f7c0caa8f2f 100644 --- a/librz/arch/p-analysis/analysis_arc.c +++ b/librz/arch/p_gnu/analysis/analysis_arc_gnu.c @@ -1130,7 +1130,7 @@ static char *get_reg_profile(RzAnalysis *analysis) { return strdup(p16); } -RzAnalysisPlugin rz_analysis_plugin_arc = { +RzAnalysisPlugin rz_analysis_plugin_arc_gnu = { .name = "arc", .arch = "arc", .license = "LGPL3", @@ -1140,11 +1140,3 @@ RzAnalysisPlugin rz_analysis_plugin_arc = { .archinfo = archinfo, .get_reg_profile = get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_arc, - .version = RZ_VERSION, -}; -#endif diff --git a/librz/arch/p-analysis/analysis_cris.c b/librz/arch/p_gnu/analysis/analysis_cris_gnu.c similarity index 96% rename from librz/arch/p-analysis/analysis_cris.c rename to librz/arch/p_gnu/analysis/analysis_cris_gnu.c index 191da21b6bf..874121dba4d 100644 --- a/librz/arch/p-analysis/analysis_cris.c +++ b/librz/arch/p_gnu/analysis/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", @@ -285,11 +285,3 @@ RzAnalysisPlugin rz_analysis_plugin_cris = { .bits = 32, .op = &analyze_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_cris, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_mips_gnu.c b/librz/arch/p_gnu/analysis/analysis_mips_gnu.c similarity index 99% rename from librz/arch/p-analysis/analysis_mips_gnu.c rename to librz/arch/p_gnu/analysis/analysis_mips_gnu.c index cdbe1eb3838..a59854cfd40 100644 --- a/librz/arch/p-analysis/analysis_mips_gnu.c +++ b/librz/arch/p_gnu/analysis/analysis_mips_gnu.c @@ -1798,10 +1798,3 @@ RzAnalysisPlugin rz_analysis_plugin_mips_gnu = { .op = &mips_op, .get_reg_profile = mips_get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_mips_gnu -}; -#endif diff --git a/librz/arch/p-analysis/analysis_nios2.c b/librz/arch/p_gnu/analysis/analysis_nios2_gnu.c similarity index 90% rename from librz/arch/p-analysis/analysis_nios2.c rename to librz/arch/p_gnu/analysis/analysis_nios2_gnu.c index d213112672a..0f38ed9f4d5 100644 --- a/librz/arch/p-analysis/analysis_nios2.c +++ b/librz/arch/p_gnu/analysis/analysis_nios2_gnu.c @@ -82,7 +82,7 @@ static int nios2_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 return op->size; } -RzAnalysisPlugin rz_analysis_plugin_nios2 = { +RzAnalysisPlugin rz_analysis_plugin_nios2_gnu = { .name = "nios2", .desc = "NIOS II code analysis plugin", .license = "LGPL3", @@ -91,11 +91,3 @@ RzAnalysisPlugin rz_analysis_plugin_nios2 = { .bits = 32, .op = &nios2_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_nios2, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_riscv.c b/librz/arch/p_gnu/analysis/analysis_riscv_gnu.c similarity index 97% rename from librz/arch/p-analysis/analysis_riscv.c rename to librz/arch/p_gnu/analysis/analysis_riscv_gnu.c index fb7eb7ef1b1..721d138a76e 100644 --- a/librz/arch/p-analysis/analysis_riscv.c +++ b/librz/arch/p_gnu/analysis/analysis_riscv_gnu.c @@ -6,22 +6,18 @@ #include #include #include -#include "../../asm/arch/riscv/riscv-opc.c" -#include "../../asm/arch/riscv/riscv.h" #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]; } riscv_args_t; +static bool init_analysis = false; + #define is_any(...) _is_any(o->name, __VA_ARGS__, NULL) static bool _is_any(const char *str, ...) { char *cur; @@ -46,26 +42,26 @@ 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 }; #define OP_HASH_IDX(i) ((i) & (riscv_insn_length(i) == 2 ? 3 : OP_MASK_OP)) - if (!init) { + if (!init_analysis) { 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 = true; + init_analysis = true; } return (struct riscv_opcode *)riscv_hash[OP_HASH_IDX(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 +258,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 #undef DECLARE_CSR } if (csr_name) { @@ -309,7 +305,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 +339,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, ","); } @@ -931,7 +927,7 @@ static int archinfo(RzAnalysis *a, RzAnalysisInfoType query) { } } -RzAnalysisPlugin rz_analysis_plugin_riscv = { +RzAnalysisPlugin rz_analysis_plugin_riscv_gnu = { .name = "riscv", .desc = "RISC-V analysis plugin", .license = "LGPL", @@ -942,11 +938,3 @@ RzAnalysisPlugin rz_analysis_plugin_riscv = { .get_reg_profile = &get_reg_profile, .esil = true, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_riscv, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_sparc_gnu.c b/librz/arch/p_gnu/analysis/analysis_sparc_gnu.c similarity index 98% rename from librz/arch/p-analysis/analysis_sparc_gnu.c rename to librz/arch/p_gnu/analysis/analysis_sparc_gnu.c index b24d7bffc55..403981bd3cf 100644 --- a/librz/arch/p-analysis/analysis_sparc_gnu.c +++ b/librz/arch/p_gnu/analysis/analysis_sparc_gnu.c @@ -624,11 +624,3 @@ RzAnalysisPlugin rz_analysis_plugin_sparc_gnu = { .archinfo = archinfo, .get_reg_profile = get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_sparc_gnu, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_vax.c b/librz/arch/p_gnu/analysis/analysis_vax_gnu.c similarity index 89% rename from librz/arch/p-analysis/analysis_vax.c rename to librz/arch/p_gnu/analysis/analysis_vax_gnu.c index 53613666a90..dcf880b17f0 100644 --- a/librz/arch/p-analysis/analysis_vax.c +++ b/librz/arch/p_gnu/analysis/analysis_vax_gnu.c @@ -80,7 +80,7 @@ static int vax_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 * return op->size; } -RzAnalysisPlugin rz_analysis_plugin_vax = { +RzAnalysisPlugin rz_analysis_plugin_vax_gnu = { .name = "vax", .desc = "VAX code analysis plugin", .license = "LGPL3", @@ -89,11 +89,3 @@ RzAnalysisPlugin rz_analysis_plugin_vax = { .bits = 8 | 32, .op = &vax_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_vax, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_xtensa.c b/librz/arch/p_gnu/analysis/analysis_xtensa_gnu.c similarity index 99% rename from librz/arch/p-analysis/analysis_xtensa.c rename to librz/arch/p_gnu/analysis/analysis_xtensa_gnu.c index 4a32d2037c8..097fdc4505d 100644 --- a/librz/arch/p-analysis/analysis_xtensa.c +++ b/librz/arch/p_gnu/analysis/analysis_xtensa_gnu.c @@ -7,7 +7,7 @@ #include #include -#include +#include #define CM "," #define XTENSA_MAX_LENGTH 8 @@ -2067,7 +2067,7 @@ static bool xtensa_fini(void *user) { return true; } -RzAnalysisPlugin rz_analysis_plugin_xtensa = { +RzAnalysisPlugin rz_analysis_plugin_xtensa_gnu = { .name = "xtensa", .desc = "Xtensa disassembler", .license = "LGPL3", @@ -2079,11 +2079,3 @@ RzAnalysisPlugin rz_analysis_plugin_xtensa = { .fini = xtensa_fini, .get_reg_profile = get_reg_profile, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_xtensa, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-analysis/analysis_z80.c b/librz/arch/p_gnu/analysis/analysis_z80_gnu.c similarity index 97% rename from librz/arch/p-analysis/analysis_z80.c rename to librz/arch/p_gnu/analysis/analysis_z80_gnu.c index 446dfc4b367..25c63d1ea66 100644 --- a/librz/arch/p-analysis/analysis_z80.c +++ b/librz/arch/p_gnu/analysis/analysis_z80_gnu.c @@ -7,7 +7,7 @@ #include #include #include -#include "../../asm/arch/z80/z80_tab.h" +#include "z80/z80_tab.h" static void z80_op_size(const ut8 *data, int len, int *size, int *size_prefix) { int type = 0; @@ -428,7 +428,7 @@ static int archinfo(RzAnalysis *a, RzAnalysisInfoType query) { } } -RzAnalysisPlugin rz_analysis_plugin_z80 = { +RzAnalysisPlugin rz_analysis_plugin_z80_gnu = { .name = "z80", .arch = "z80", .license = "LGPL3", @@ -438,11 +438,3 @@ RzAnalysisPlugin rz_analysis_plugin_z80 = { .archinfo = archinfo, .op = &z80_analysis_op, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ANALYSIS, - .data = &rz_analysis_plugin_z80, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p_gnu/arch_arc.c b/librz/arch/p_gnu/arch_arc.c new file mode 100644 index 00000000000..14e09f909a4 --- /dev/null +++ b/librz/arch/p_gnu/arch_arc.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "analysis/analysis_arc_gnu.c" +#include "asm/asm_arc_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(arc_gnu); diff --git a/librz/arch/p_gnu/arch_cris.c b/librz/arch/p_gnu/arch_cris.c new file mode 100644 index 00000000000..4707ee4efb5 --- /dev/null +++ b/librz/arch/p_gnu/arch_cris.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "analysis/analysis_cris_gnu.c" +#include "asm/asm_cris_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(cris_gnu); diff --git a/librz/arch/p_gnu/arch_hppa.c b/librz/arch/p_gnu/arch_hppa.c new file mode 100644 index 00000000000..4bff5bb54bb --- /dev/null +++ b/librz/arch/p_gnu/arch_hppa.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "asm/asm_hppa_gnu.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(hppa_gnu); diff --git a/librz/arch/p_gnu/arch_lanai.c b/librz/arch/p_gnu/arch_lanai.c new file mode 100644 index 00000000000..1187af5581f --- /dev/null +++ b/librz/arch/p_gnu/arch_lanai.c @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "asm/asm_lanai_gnu.c" + +RZ_ARCH_ASM_ONLY_PLUGIN_DEFINE_DEPRECATED(lanai_gnu); diff --git a/librz/arch/p_gnu/arch_mips.c b/librz/arch/p_gnu/arch_mips.c new file mode 100644 index 00000000000..b599554a903 --- /dev/null +++ b/librz/arch/p_gnu/arch_mips.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "analysis/analysis_mips_gnu.c" +#include "asm/asm_mips_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(mips_gnu); diff --git a/librz/arch/p_gnu/arch_nios2.c b/librz/arch/p_gnu/arch_nios2.c new file mode 100644 index 00000000000..f55c04e53c3 --- /dev/null +++ b/librz/arch/p_gnu/arch_nios2.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "analysis/analysis_nios2_gnu.c" +#include "asm/asm_nios2_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(nios2_gnu); diff --git a/librz/arch/p_gnu/arch_riscv.c b/librz/arch/p_gnu/arch_riscv.c new file mode 100644 index 00000000000..abec1477899 --- /dev/null +++ b/librz/arch/p_gnu/arch_riscv.c @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "../isa_gnu/riscv/riscv-opc.c" +#include +#include "../isa_gnu/riscv/riscv.c" + +#include "analysis/analysis_riscv_gnu.c" +#include "asm/asm_riscv_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(riscv_gnu); diff --git a/librz/arch/p_gnu/arch_sparc.c b/librz/arch/p_gnu/arch_sparc.c new file mode 100644 index 00000000000..ad91c19fd37 --- /dev/null +++ b/librz/arch/p_gnu/arch_sparc.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "analysis/analysis_sparc_gnu.c" +#include "asm/asm_sparc_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(sparc_gnu); diff --git a/librz/arch/p_gnu/arch_vax.c b/librz/arch/p_gnu/arch_vax.c new file mode 100644 index 00000000000..475a9f95f1c --- /dev/null +++ b/librz/arch/p_gnu/arch_vax.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "analysis/analysis_vax_gnu.c" +#include "asm/asm_vax_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(vax_gnu); diff --git a/librz/arch/p_gnu/arch_xtensa.c b/librz/arch/p_gnu/arch_xtensa.c new file mode 100644 index 00000000000..28be737e346 --- /dev/null +++ b/librz/arch/p_gnu/arch_xtensa.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "analysis/analysis_xtensa_gnu.c" +#include "asm/asm_xtensa_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(xtensa_gnu); diff --git a/librz/arch/p_gnu/arch_z80.c b/librz/arch/p_gnu/arch_z80.c new file mode 100644 index 00000000000..759b826e62d --- /dev/null +++ b/librz/arch/p_gnu/arch_z80.c @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-FileCopyrightText: 2024 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +#include + +#include "../isa_gnu/z80/z80.c" +#include "../isa_gnu/z80/z80asm.c" +#include "analysis/analysis_z80_gnu.c" +#include "asm/asm_z80_gnu.c" + +RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(z80_gnu); diff --git a/librz/arch/p-asm/asm_arc.c b/librz/arch/p_gnu/asm/asm_arc_gnu.c similarity index 92% rename from librz/arch/p-asm/asm_arc.c rename to librz/arch/p_gnu/asm/asm_arc_gnu.c index 0540ee87c7e..441672fc1f8 100644 --- a/librz/arch/p-asm/asm_arc.c +++ b/librz/arch/p_gnu/asm/asm_arc_gnu.c @@ -8,8 +8,8 @@ #include #include #include -#include "disas-asm.h" -#include +#include +#include /* extern */ int decodeInstr(bfd_vma address, disassemble_info *info); @@ -100,7 +100,7 @@ static bool the_end(void *p) { return true; } -RzAsmPlugin rz_asm_plugin_arc = { +RzAsmPlugin rz_asm_plugin_arc_gnu = { .name = "arc", .arch = "arc", .bits = 16 | 32, @@ -111,11 +111,3 @@ RzAsmPlugin rz_asm_plugin_arc = { .disassemble = &disassemble, .license = "GPL3" }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_arc, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_cris_gnu.c b/librz/arch/p_gnu/asm/asm_cris_gnu.c similarity index 95% rename from librz/arch/p-asm/asm_cris_gnu.c rename to librz/arch/p_gnu/asm/asm_cris_gnu.c index f4362116168..581fcdefb09 100644 --- a/librz/arch/p-asm/asm_cris_gnu.c +++ b/librz/arch/p_gnu/asm/asm_cris_gnu.c @@ -19,7 +19,7 @@ Documentation #include #include -#include "disas-asm.h" +#include static unsigned long Offset = 0; static RzStrBuf *buf_global = NULL; @@ -138,11 +138,3 @@ RzAsmPlugin rz_asm_plugin_cris_gnu = { .desc = "Axis Communications 32-bit embedded processor", .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_cris_gnu, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_hppa_gnu.c b/librz/arch/p_gnu/asm/asm_hppa_gnu.c similarity index 92% rename from librz/arch/p-asm/asm_hppa_gnu.c rename to librz/arch/p_gnu/asm/asm_hppa_gnu.c index 0da0cba9560..ea8ce5811aa 100644 --- a/librz/arch/p-asm/asm_hppa_gnu.c +++ b/librz/arch/p_gnu/asm/asm_hppa_gnu.c @@ -10,7 +10,7 @@ #include #include -#include "disas-asm.h" +#include static unsigned long Offset = 0; static RzStrBuf *buf_global = NULL; @@ -86,11 +86,3 @@ RzAsmPlugin rz_asm_plugin_hppa_gnu = { .desc = "HP PA-RISC", .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_hppa_gnu, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_lanai_gnu.c b/librz/arch/p_gnu/asm/asm_lanai_gnu.c similarity index 91% rename from librz/arch/p-asm/asm_lanai_gnu.c rename to librz/arch/p_gnu/asm/asm_lanai_gnu.c index 224d6234a55..3c0e6131cba 100644 --- a/librz/arch/p-asm/asm_lanai_gnu.c +++ b/librz/arch/p_gnu/asm/asm_lanai_gnu.c @@ -8,7 +8,7 @@ #include #include #include -#include "disas-asm.h" +#include static unsigned long Offset = 0; static RzStrBuf *buf_global = NULL; @@ -74,11 +74,3 @@ RzAsmPlugin rz_asm_plugin_lanai_gnu = { .desc = "LANAI", .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_lanai_gnu, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_mips_gnu.c b/librz/arch/p_gnu/asm/asm_mips_gnu.c similarity index 89% rename from librz/arch/p-asm/asm_mips_gnu.c rename to librz/arch/p_gnu/asm/asm_mips_gnu.c index c1c73e29051..86c24ada6d1 100644 --- a/librz/arch/p-asm/asm_mips_gnu.c +++ b/librz/arch/p_gnu/asm/asm_mips_gnu.c @@ -11,9 +11,10 @@ #include #include -#include "disas-asm.h" -#include "opcode/mips.h" -int mips_assemble(const char *str, ut64 pc, ut8 *out); +#include +#include + +#include static int mips_mode = 0; static unsigned long Offset = 0; @@ -49,7 +50,7 @@ typedef struct { struct disassemble_info disasm_obj; } MIPSGnuContext; -static int disassemble(struct rz_asm_t *a, struct rz_asm_op_t *op, const ut8 *buf, int len) { +static int mips_gnu_disassemble(struct rz_asm_t *a, struct rz_asm_op_t *op, const ut8 *buf, int len) { MIPSGnuContext *ctx = (MIPSGnuContext *)a->plugin_data; if (len < 4) { return -1; @@ -114,9 +115,9 @@ static int disassemble(struct rz_asm_t *a, struct rz_asm_op_t *op, const ut8 *bu return op->size; } -static int assemble(RzAsm *a, RzAsmOp *op, const char *str) { +static int mips_gnu_assemble(RzAsm *a, RzAsmOp *op, const char *str) { ut8 *opbuf = (ut8 *)rz_strbuf_get(&op->buf); - int ret = mips_assemble(str, a->pc, opbuf); + int ret = mips_assemble_opcode(str, a->pc, opbuf); if (a->big_endian) { ut8 tmp = opbuf[0]; opbuf[0] = opbuf[3]; @@ -152,14 +153,6 @@ RzAsmPlugin rz_asm_plugin_mips_gnu = { .desc = "MIPS CPU", .init = mips_gnu_init, .fini = mips_gnu_fini, - .disassemble = &disassemble, - .assemble = &assemble -}; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_mips_gnu, - .version = RZ_VERSION + .disassemble = &mips_gnu_disassemble, + .assemble = &mips_gnu_assemble }; -#endif diff --git a/librz/arch/p-asm/asm_nios2.c b/librz/arch/p_gnu/asm/asm_nios2_gnu.c similarity index 90% rename from librz/arch/p-asm/asm_nios2.c rename to librz/arch/p_gnu/asm/asm_nios2_gnu.c index 1d7dba3fb0c..45eaa5b5099 100644 --- a/librz/arch/p-asm/asm_nios2.c +++ b/librz/arch/p_gnu/asm/asm_nios2_gnu.c @@ -10,7 +10,7 @@ #include #include -#include "disas-asm.h" +#include int print_insn_big_nios2(bfd_vma address, disassemble_info *info); int print_insn_little_nios2(bfd_vma address, disassemble_info *info); @@ -66,7 +66,7 @@ static int disassemble(RzAsm *a, struct rz_asm_op_t *op, const ut8 *buf, int len return op->size; } -RzAsmPlugin rz_asm_plugin_nios2 = { +RzAsmPlugin rz_asm_plugin_nios2_gnu = { .name = "nios2", .arch = "nios2", .license = "GPL3", @@ -75,11 +75,3 @@ RzAsmPlugin rz_asm_plugin_nios2 = { .desc = "NIOS II Embedded Processor", .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_nios2, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_riscv.c b/librz/arch/p_gnu/asm/asm_riscv_gnu.c similarity index 51% rename from librz/arch/p-asm/asm_riscv.c rename to librz/arch/p_gnu/asm/asm_riscv_gnu.c index 72bc76e56a6..ac199e9974c 100644 --- a/librz/arch/p-asm/asm_riscv.c +++ b/librz/arch/p_gnu/asm/asm_riscv_gnu.c @@ -5,27 +5,17 @@ #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) { +static int riscv_gnu_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return op->size = riscv_dis(a, op, buf, len); } -RzAsmPlugin rz_asm_plugin_riscv = { +RzAsmPlugin rz_asm_plugin_riscv_gnu = { .name = "riscv", .desc = "RISC-V", .arch = "riscv", .bits = 32 | 64, .endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG, .license = "GPL3", - .disassemble = &disassemble, + .disassemble = &riscv_gnu_disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_riscv, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_sparc_gnu.c b/librz/arch/p_gnu/asm/asm_sparc_gnu.c similarity index 93% rename from librz/arch/p-asm/asm_sparc_gnu.c rename to librz/arch/p_gnu/asm/asm_sparc_gnu.c index 6cee8bd5651..38cf8150725 100644 --- a/librz/arch/p-asm/asm_sparc_gnu.c +++ b/librz/arch/p_gnu/asm/asm_sparc_gnu.c @@ -8,8 +8,8 @@ #include #include #include -#include "disas-asm.h" -#include +#include +#include static unsigned long Offset = 0; static RzStrBuf *buf_global = NULL; @@ -105,11 +105,3 @@ RzAsmPlugin rz_asm_plugin_sparc_gnu = { .desc = "Scalable Processor Architecture", .disassemble = &disassemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_sparc_gnu, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_vax.c b/librz/arch/p_gnu/asm/asm_vax_gnu.c similarity index 89% rename from librz/arch/p-asm/asm_vax.c rename to librz/arch/p_gnu/asm/asm_vax_gnu.c index c379822be3d..41733f86661 100644 --- a/librz/arch/p-asm/asm_vax.c +++ b/librz/arch/p_gnu/asm/asm_vax_gnu.c @@ -12,8 +12,8 @@ #include #include -#include "disas-asm.h" -#include "../arch/vax/vax.h" +#include +#include "vax/vax.h" static unsigned long Offset = 0; static RzStrBuf *buf_global = NULL; @@ -71,7 +71,7 @@ static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return op->size; } -RzAsmPlugin rz_asm_plugin_vax = { +RzAsmPlugin rz_asm_plugin_vax_gnu = { .name = "vax", .arch = "vax", .license = "GPL3", @@ -80,11 +80,3 @@ RzAsmPlugin rz_asm_plugin_vax = { .desc = "VAX", .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_vax, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_xtensa.c b/librz/arch/p_gnu/asm/asm_xtensa_gnu.c similarity index 90% rename from librz/arch/p-asm/asm_xtensa.c rename to librz/arch/p_gnu/asm/asm_xtensa_gnu.c index 182637e8b2b..33a0edf173f 100644 --- a/librz/arch/p-asm/asm_xtensa.c +++ b/librz/arch/p_gnu/asm/asm_xtensa_gnu.c @@ -10,7 +10,7 @@ #include #include -#include "disas-asm.h" +#include #define INSN_BUFFER_SIZE 4 @@ -66,7 +66,7 @@ static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return op->size; } -RzAsmPlugin rz_asm_plugin_xtensa = { +RzAsmPlugin rz_asm_plugin_xtensa_gnu = { .name = "xtensa", .arch = "xtensa", .license = "GPL3", @@ -75,11 +75,3 @@ RzAsmPlugin rz_asm_plugin_xtensa = { .desc = "XTensa CPU", .disassemble = &disassemble }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_xtensa, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/p-asm/asm_z80.c b/librz/arch/p_gnu/asm/asm_z80_gnu.c similarity index 72% rename from librz/arch/p-asm/asm_z80.c rename to librz/arch/p_gnu/asm/asm_z80_gnu.c index 67898c10175..7320a3aadef 100644 --- a/librz/arch/p-asm/asm_z80.c +++ b/librz/arch/p_gnu/asm/asm_z80_gnu.c @@ -6,9 +6,6 @@ #include #include -#include "../arch/z80/z80.c" -#include "../arch/z80/z80asm.c" - static int do_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) { return op->size = z80Disass(op, buf, len); } @@ -17,7 +14,7 @@ static int do_assemble(RzAsm *a, RzAsmOp *op, const char *buf) { return op->size = z80asm((ut8 *)rz_strbuf_get(&op->buf), buf); } -RzAsmPlugin rz_asm_plugin_z80 = { +RzAsmPlugin rz_asm_plugin_z80_gnu = { .name = "z80", .desc = "Zilog Z80", .license = "GPL3", @@ -28,11 +25,3 @@ RzAsmPlugin rz_asm_plugin_z80 = { .disassemble = &do_disassemble, .assemble = &do_assemble, }; - -#ifndef RZ_PLUGIN_INCORE -RZ_API RzLibStruct rizin_plugin = { - .type = RZ_LIB_TYPE_ASM, - .data = &rz_asm_plugin_z80, - .version = RZ_VERSION -}; -#endif diff --git a/librz/arch/platforms-asm/arm-arm1176-bcm2835.sdb.txt b/librz/arch/platforms/arm-arm1176-bcm2835.sdb.txt similarity index 100% rename from librz/arch/platforms-asm/arm-arm1176-bcm2835.sdb.txt rename to librz/arch/platforms/arm-arm1176-bcm2835.sdb.txt diff --git a/librz/arch/platforms-asm/arm-cortexA72-bcm2711.sdb.txt b/librz/arch/platforms/arm-cortexA72-bcm2711.sdb.txt similarity index 100% rename from librz/arch/platforms-asm/arm-cortexA72-bcm2711.sdb.txt rename to librz/arch/platforms/arm-cortexA72-bcm2711.sdb.txt diff --git a/librz/arch/platforms-asm/arm-cortexA8-omap3430.sdb.txt b/librz/arch/platforms/arm-cortexA8-omap3430.sdb.txt similarity index 100% rename from librz/arch/platforms-asm/arm-cortexA8-omap3430.sdb.txt rename to librz/arch/platforms/arm-cortexA8-omap3430.sdb.txt diff --git a/librz/arch/platforms-asm/meson.build b/librz/arch/platforms/meson.build similarity index 74% rename from librz/arch/platforms-asm/meson.build rename to librz/arch/platforms/meson.build index 00bd5889eec..fafd6b273fa 100644 --- a/librz/arch/platforms-asm/meson.build +++ b/librz/arch/platforms/meson.build @@ -1,11 +1,11 @@ -sdb_files = [ +sdb_platform_files = [ 'arm-arm1176-bcm2835', 'arm-cortexA72-bcm2711', 'arm-cortexA8-omap3430', 'x86-generic-generic', ] -foreach file : sdb_files +foreach file : sdb_platform_files outfile = '@0@.sdb'.format(file) custom_target(outfile, input: '@0@.sdb.txt'.format(file), @@ -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/arch/platforms-asm/x86-generic-generic.sdb.txt b/librz/arch/platforms/x86-generic-generic.sdb.txt similarity index 100% rename from librz/arch/platforms-asm/x86-generic-generic.sdb.txt rename to librz/arch/platforms/x86-generic-generic.sdb.txt diff --git a/librz/arch/d-analysis/cc-arm-16.sdb.txt b/librz/arch/types/cc-arm-16.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-arm-16.sdb.txt rename to librz/arch/types/cc-arm-16.sdb.txt diff --git a/librz/arch/d-analysis/cc-arm-32.sdb.txt b/librz/arch/types/cc-arm-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-arm-32.sdb.txt rename to librz/arch/types/cc-arm-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-arm-64.sdb.txt b/librz/arch/types/cc-arm-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-arm-64.sdb.txt rename to librz/arch/types/cc-arm-64.sdb.txt diff --git a/librz/arch/d-analysis/cc-avr-8.sdb.txt b/librz/arch/types/cc-avr-8.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-avr-8.sdb.txt rename to librz/arch/types/cc-avr-8.sdb.txt diff --git a/librz/arch/d-analysis/cc-hexagon-32.sdb.txt b/librz/arch/types/cc-hexagon-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-hexagon-32.sdb.txt rename to librz/arch/types/cc-hexagon-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-m68k-32.sdb.txt b/librz/arch/types/cc-m68k-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-m68k-32.sdb.txt rename to librz/arch/types/cc-m68k-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-mips-32.sdb.txt b/librz/arch/types/cc-mips-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-mips-32.sdb.txt rename to librz/arch/types/cc-mips-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-mips-64.sdb.txt b/librz/arch/types/cc-mips-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-mips-64.sdb.txt rename to librz/arch/types/cc-mips-64.sdb.txt diff --git a/librz/arch/d-analysis/cc-ppc-32.sdb.txt b/librz/arch/types/cc-ppc-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-ppc-32.sdb.txt rename to librz/arch/types/cc-ppc-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-ppc-64.sdb.txt b/librz/arch/types/cc-ppc-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-ppc-64.sdb.txt rename to librz/arch/types/cc-ppc-64.sdb.txt diff --git a/librz/arch/d-analysis/cc-riscv-64.sdb.txt b/librz/arch/types/cc-riscv-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-riscv-64.sdb.txt rename to librz/arch/types/cc-riscv-64.sdb.txt diff --git a/librz/arch/d-analysis/cc-rx-32.sdb.txt b/librz/arch/types/cc-rx-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-rx-32.sdb.txt rename to librz/arch/types/cc-rx-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-sh-32.sdb.txt b/librz/arch/types/cc-sh-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-sh-32.sdb.txt rename to librz/arch/types/cc-sh-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-sparc-32.sdb.txt b/librz/arch/types/cc-sparc-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-sparc-32.sdb.txt rename to librz/arch/types/cc-sparc-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-spc700-16.sdb.txt b/librz/arch/types/cc-spc700-16.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-spc700-16.sdb.txt rename to librz/arch/types/cc-spc700-16.sdb.txt diff --git a/librz/arch/d-analysis/cc-sysz-64.sdb.txt b/librz/arch/types/cc-sysz-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-sysz-64.sdb.txt rename to librz/arch/types/cc-sysz-64.sdb.txt diff --git a/librz/arch/d-analysis/cc-tricore-32.sdb.txt b/librz/arch/types/cc-tricore-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-tricore-32.sdb.txt rename to librz/arch/types/cc-tricore-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-x86-16.sdb.txt b/librz/arch/types/cc-x86-16.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-x86-16.sdb.txt rename to librz/arch/types/cc-x86-16.sdb.txt diff --git a/librz/arch/d-analysis/cc-x86-32.sdb.txt b/librz/arch/types/cc-x86-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-x86-32.sdb.txt rename to librz/arch/types/cc-x86-32.sdb.txt diff --git a/librz/arch/d-analysis/cc-x86-64.sdb.txt b/librz/arch/types/cc-x86-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-x86-64.sdb.txt rename to librz/arch/types/cc-x86-64.sdb.txt diff --git a/librz/arch/d-analysis/cc-xtensa-32.sdb.txt b/librz/arch/types/cc-xtensa-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/cc-xtensa-32.sdb.txt rename to librz/arch/types/cc-xtensa-32.sdb.txt diff --git a/librz/arch/d-analysis/functions-android.sdb.txt b/librz/arch/types/functions-android.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-android.sdb.txt rename to librz/arch/types/functions-android.sdb.txt diff --git a/librz/arch/d-analysis/functions-libc.sdb.txt b/librz/arch/types/functions-libc.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-libc.sdb.txt rename to librz/arch/types/functions-libc.sdb.txt diff --git a/librz/arch/d-analysis/functions-linux.sdb.txt b/librz/arch/types/functions-linux.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-linux.sdb.txt rename to librz/arch/types/functions-linux.sdb.txt diff --git a/librz/arch/d-analysis/functions-macos.sdb.txt b/librz/arch/types/functions-macos.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-macos.sdb.txt rename to librz/arch/types/functions-macos.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows.sdb.txt b/librz/arch/types/functions-windows.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows.sdb.txt rename to librz/arch/types/functions-windows.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_bcrypt.sdb.txt b/librz/arch/types/functions-windows_bcrypt.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_bcrypt.sdb.txt rename to librz/arch/types/functions-windows_bcrypt.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_cfgmgr32.sdb.txt b/librz/arch/types/functions-windows_cfgmgr32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_cfgmgr32.sdb.txt rename to librz/arch/types/functions-windows_cfgmgr32.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_combaseapi.sdb.txt b/librz/arch/types/functions-windows_combaseapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_combaseapi.sdb.txt rename to librz/arch/types/functions-windows_combaseapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_commctrl.sdb.txt b/librz/arch/types/functions-windows_commctrl.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_commctrl.sdb.txt rename to librz/arch/types/functions-windows_commctrl.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_consoleapi2.sdb.txt b/librz/arch/types/functions-windows_consoleapi2.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_consoleapi2.sdb.txt rename to librz/arch/types/functions-windows_consoleapi2.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_dbghelp.sdb.txt b/librz/arch/types/functions-windows_dbghelp.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_dbghelp.sdb.txt rename to librz/arch/types/functions-windows_dbghelp.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_evntrace.sdb.txt b/librz/arch/types/functions-windows_evntrace.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_evntrace.sdb.txt rename to librz/arch/types/functions-windows_evntrace.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_fileapi.sdb.txt b/librz/arch/types/functions-windows_fileapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_fileapi.sdb.txt rename to librz/arch/types/functions-windows_fileapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_libloaderapi.sdb.txt b/librz/arch/types/functions-windows_libloaderapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_libloaderapi.sdb.txt rename to librz/arch/types/functions-windows_libloaderapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_memoryapi.sdb.txt b/librz/arch/types/functions-windows_memoryapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_memoryapi.sdb.txt rename to librz/arch/types/functions-windows_memoryapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_ncrypt.sdb.txt b/librz/arch/types/functions-windows_ncrypt.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_ncrypt.sdb.txt rename to librz/arch/types/functions-windows_ncrypt.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_objbase.sdb.txt b/librz/arch/types/functions-windows_objbase.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_objbase.sdb.txt rename to librz/arch/types/functions-windows_objbase.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_oleauto.sdb.txt b/librz/arch/types/functions-windows_oleauto.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_oleauto.sdb.txt rename to librz/arch/types/functions-windows_oleauto.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_processthreadsapi.sdb.txt b/librz/arch/types/functions-windows_processthreadsapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_processthreadsapi.sdb.txt rename to librz/arch/types/functions-windows_processthreadsapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_psapi.sdb.txt b/librz/arch/types/functions-windows_psapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_psapi.sdb.txt rename to librz/arch/types/functions-windows_psapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_securitybaseapi.sdb.txt b/librz/arch/types/functions-windows_securitybaseapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_securitybaseapi.sdb.txt rename to librz/arch/types/functions-windows_securitybaseapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_shellapi.sdb.txt b/librz/arch/types/functions-windows_shellapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_shellapi.sdb.txt rename to librz/arch/types/functions-windows_shellapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_shlwapi.sdb.txt b/librz/arch/types/functions-windows_shlwapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_shlwapi.sdb.txt rename to librz/arch/types/functions-windows_shlwapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_synchapi.sdb.txt b/librz/arch/types/functions-windows_synchapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_synchapi.sdb.txt rename to librz/arch/types/functions-windows_synchapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_sysinfoapi.sdb.txt b/librz/arch/types/functions-windows_sysinfoapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_sysinfoapi.sdb.txt rename to librz/arch/types/functions-windows_sysinfoapi.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_threadpoolapiset.sdb.txt b/librz/arch/types/functions-windows_threadpoolapiset.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_threadpoolapiset.sdb.txt rename to librz/arch/types/functions-windows_threadpoolapiset.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_userenv.sdb.txt b/librz/arch/types/functions-windows_userenv.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_userenv.sdb.txt rename to librz/arch/types/functions-windows_userenv.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_winbase.sdb.txt b/librz/arch/types/functions-windows_winbase.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_winbase.sdb.txt rename to librz/arch/types/functions-windows_winbase.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_wincred.sdb.txt b/librz/arch/types/functions-windows_wincred.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_wincred.sdb.txt rename to librz/arch/types/functions-windows_wincred.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_wincrypt.sdb.txt b/librz/arch/types/functions-windows_wincrypt.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_wincrypt.sdb.txt rename to librz/arch/types/functions-windows_wincrypt.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_winhttp.sdb.txt b/librz/arch/types/functions-windows_winhttp.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_winhttp.sdb.txt rename to librz/arch/types/functions-windows_winhttp.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_winldap.sdb.txt b/librz/arch/types/functions-windows_winldap.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_winldap.sdb.txt rename to librz/arch/types/functions-windows_winldap.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_winnls.sdb.txt b/librz/arch/types/functions-windows_winnls.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_winnls.sdb.txt rename to librz/arch/types/functions-windows_winnls.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_winreg.sdb.txt b/librz/arch/types/functions-windows_winreg.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_winreg.sdb.txt rename to librz/arch/types/functions-windows_winreg.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_winsock2.sdb.txt b/librz/arch/types/functions-windows_winsock2.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_winsock2.sdb.txt rename to librz/arch/types/functions-windows_winsock2.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_winsvc.sdb.txt b/librz/arch/types/functions-windows_winsvc.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_winsvc.sdb.txt rename to librz/arch/types/functions-windows_winsvc.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_winuser.sdb.txt b/librz/arch/types/functions-windows_winuser.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_winuser.sdb.txt rename to librz/arch/types/functions-windows_winuser.sdb.txt diff --git a/librz/arch/d-analysis/functions-windows_ws2spi.sdb.txt b/librz/arch/types/functions-windows_ws2spi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/functions-windows_ws2spi.sdb.txt rename to librz/arch/types/functions-windows_ws2spi.sdb.txt diff --git a/librz/arch/d-analysis/meson.build b/librz/arch/types/meson.build similarity index 97% rename from librz/arch/d-analysis/meson.build rename to librz/arch/types/meson.build index e498c129812..3855570425a 100644 --- a/librz/arch/d-analysis/meson.build +++ b/librz/arch/types/meson.build @@ -1,4 +1,4 @@ -sdb_files = [ +sdb_types_files = [ 'cc-arm-16', 'cc-arm-32', 'cc-arm-64', @@ -81,7 +81,7 @@ fs = import('fs') types_build_dir = meson.current_build_dir() types_files = [] -foreach file : sdb_files +foreach file : sdb_types_files outfile = '@0@.sdb'.format(file) infiles = ['@0@.sdb.txt'.format(file)] if file == 'types-windows' diff --git a/librz/arch/d-analysis/spec.sdb.txt b/librz/arch/types/spec.sdb.txt similarity index 100% rename from librz/arch/d-analysis/spec.sdb.txt rename to librz/arch/types/spec.sdb.txt diff --git a/librz/arch/d-analysis/types-16.sdb.txt b/librz/arch/types/types-16.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-16.sdb.txt rename to librz/arch/types/types-16.sdb.txt diff --git a/librz/arch/d-analysis/types-32.sdb.txt b/librz/arch/types/types-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-32.sdb.txt rename to librz/arch/types/types-32.sdb.txt diff --git a/librz/arch/d-analysis/types-64.sdb.txt b/librz/arch/types/types-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-64.sdb.txt rename to librz/arch/types/types-64.sdb.txt diff --git a/librz/arch/d-analysis/types-android.sdb.txt b/librz/arch/types/types-android.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-android.sdb.txt rename to librz/arch/types/types-android.sdb.txt diff --git a/librz/arch/d-analysis/types-arm-ios-16.sdb.txt b/librz/arch/types/types-arm-ios-16.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-arm-ios-16.sdb.txt rename to librz/arch/types/types-arm-ios-16.sdb.txt diff --git a/librz/arch/d-analysis/types-arm-ios-32.sdb.txt b/librz/arch/types/types-arm-ios-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-arm-ios-32.sdb.txt rename to librz/arch/types/types-arm-ios-32.sdb.txt diff --git a/librz/arch/d-analysis/types-arm-ios-64.sdb.txt b/librz/arch/types/types-arm-ios-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-arm-ios-64.sdb.txt rename to librz/arch/types/types-arm-ios-64.sdb.txt diff --git a/librz/arch/d-analysis/types-atomic.sdb.txt b/librz/arch/types/types-atomic.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-atomic.sdb.txt rename to librz/arch/types/types-atomic.sdb.txt diff --git a/librz/arch/d-analysis/types-libc.sdb.txt b/librz/arch/types/types-libc.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-libc.sdb.txt rename to librz/arch/types/types-libc.sdb.txt diff --git a/librz/arch/d-analysis/types-linux.sdb.txt b/librz/arch/types/types-linux.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-linux.sdb.txt rename to librz/arch/types/types-linux.sdb.txt diff --git a/librz/arch/d-analysis/types-macos.sdb.txt b/librz/arch/types/types-macos.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-macos.sdb.txt rename to librz/arch/types/types-macos.sdb.txt diff --git a/librz/arch/d-analysis/types-windows.sdb.txt b/librz/arch/types/types-windows.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows.sdb.txt rename to librz/arch/types/types-windows.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_bcrypt.sdb.txt b/librz/arch/types/types-windows_bcrypt.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_bcrypt.sdb.txt rename to librz/arch/types/types-windows_bcrypt.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_combaseapi.sdb.txt b/librz/arch/types/types-windows_combaseapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_combaseapi.sdb.txt rename to librz/arch/types/types-windows_combaseapi.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_commctrl.sdb.txt b/librz/arch/types/types-windows_commctrl.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_commctrl.sdb.txt rename to librz/arch/types/types-windows_commctrl.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_dbghelp.sdb.txt b/librz/arch/types/types-windows_dbghelp.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_dbghelp.sdb.txt rename to librz/arch/types/types-windows_dbghelp.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_evntrace.sdb.txt b/librz/arch/types/types-windows_evntrace.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_evntrace.sdb.txt rename to librz/arch/types/types-windows_evntrace.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_fileapi.sdb.txt b/librz/arch/types/types-windows_fileapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_fileapi.sdb.txt rename to librz/arch/types/types-windows_fileapi.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_libloaderapi.sdb.txt b/librz/arch/types/types-windows_libloaderapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_libloaderapi.sdb.txt rename to librz/arch/types/types-windows_libloaderapi.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_memoryapi.sdb.txt b/librz/arch/types/types-windows_memoryapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_memoryapi.sdb.txt rename to librz/arch/types/types-windows_memoryapi.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_ncrypt.sdb.txt b/librz/arch/types/types-windows_ncrypt.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_ncrypt.sdb.txt rename to librz/arch/types/types-windows_ncrypt.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_objbase.sdb.txt b/librz/arch/types/types-windows_objbase.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_objbase.sdb.txt rename to librz/arch/types/types-windows_objbase.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_processthreadsapi.sdb.txt b/librz/arch/types/types-windows_processthreadsapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_processthreadsapi.sdb.txt rename to librz/arch/types/types-windows_processthreadsapi.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_shlwapi.sdb.txt b/librz/arch/types/types-windows_shlwapi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_shlwapi.sdb.txt rename to librz/arch/types/types-windows_shlwapi.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_wincrypt.sdb.txt b/librz/arch/types/types-windows_wincrypt.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_wincrypt.sdb.txt rename to librz/arch/types/types-windows_wincrypt.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_winhttp.sdb.txt b/librz/arch/types/types-windows_winhttp.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_winhttp.sdb.txt rename to librz/arch/types/types-windows_winhttp.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_winldap.sdb.txt b/librz/arch/types/types-windows_winldap.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_winldap.sdb.txt rename to librz/arch/types/types-windows_winldap.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_winsock2.sdb.txt b/librz/arch/types/types-windows_winsock2.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_winsock2.sdb.txt rename to librz/arch/types/types-windows_winsock2.sdb.txt diff --git a/librz/arch/d-analysis/types-windows_ws2spi.sdb.txt b/librz/arch/types/types-windows_ws2spi.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-windows_ws2spi.sdb.txt rename to librz/arch/types/types-windows_ws2spi.sdb.txt diff --git a/librz/arch/d-analysis/types-x86-macos-64.sdb.txt b/librz/arch/types/types-x86-macos-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-x86-macos-64.sdb.txt rename to librz/arch/types/types-x86-macos-64.sdb.txt diff --git a/librz/arch/d-analysis/types-x86-windows-32.sdb.txt b/librz/arch/types/types-x86-windows-32.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-x86-windows-32.sdb.txt rename to librz/arch/types/types-x86-windows-32.sdb.txt diff --git a/librz/arch/d-analysis/types-x86-windows-64.sdb.txt b/librz/arch/types/types-x86-windows-64.sdb.txt similarity index 100% rename from librz/arch/d-analysis/types-x86-windows-64.sdb.txt rename to librz/arch/types/types-x86-windows-64.sdb.txt diff --git a/librz/bin/bin.c b/librz/bin/bin.c index 8108c30450a..f45239a4cea 100644 --- a/librz/bin/bin.c +++ b/librz/bin/bin.c @@ -8,9 +8,12 @@ #include #include #include -#include #include "i/private.h" +// include both generated plugin lists. +#include "rz_bin_plugins.h" +#include "rz_bin_xtr_plugins.h" + RZ_LIB_VERSION(rz_bin); #define DB a->sdb; diff --git a/librz/bin/format/objc/mach0_classes.h b/librz/bin/format/objc/mach0_classes.h index 88ef5e6a223..efd9d943ff9 100644 --- a/librz/bin/format/objc/mach0_classes.h +++ b/librz/bin/format/objc/mach0_classes.h @@ -6,6 +6,7 @@ #include "mach0/mach0_specs.h" #include "mach0/mach0.h" +#include "rz_bin_plugins.h" #undef mach0_ut #undef rz_bin_plugin_mach diff --git a/librz/bin/meson.build b/librz/bin/meson.build index 7cc1a1c6f5e..c911dfeec3a 100644 --- a/librz/bin/meson.build +++ b/librz/bin/meson.build @@ -1,70 +1,76 @@ +bin_plugins_list = [ + 'any', + 'art', + 'avr', + 'bf', + 'bflt', + 'bios', + 'bootimg', + 'cgc', + 'coff', + 'dex', + 'dmp64', + 'dol', + 'dyldcache', + 'elf', + 'elf64', + 'java', + 'le', + 'luac', + 'mach0', + 'mach064', + 'mbn', + 'mdmp', + 'menuet', + 'mz', + 'ne', + 'nes', + 'nin3ds', + 'ninds', + 'ningb', + 'ningba', + 'nro', + 'nso', + 'omf', + 'qnx', + 'p9', + 'pe', + 'pe64', + 'pebble', + 'prg', + 'psxexe', + 'pyc', + 'sfc', + 'smd', + 'sms', + 'spc700', + 'symbols', + 'te', + 'vsf', + 'wasm', + 'xbe', + 'xnu_kernelcache', + 'z64', + 'zimg', +] + +bin_xtr_plugins_list = [ + 'fatmach0', + 'sep64', + # this was never built. + # 'pemixed', +] + bin_plugins = { - 'conf_name': 'plugins_bin', - 'base_cname': 'rz_bin_plugin_', - 'list': [ - 'any', - 'art', - 'avr', - 'bf', - 'bflt', - 'bios', - 'bootimg', - 'cgc', - 'coff', - 'dex', - 'dmp64', - 'dol', - 'dyldcache', - 'elf', - 'elf64', - 'java', - 'le', - 'luac', - 'mach0', - 'mach064', - 'mbn', - 'mdmp', - 'menuet', - 'mz', - 'ne', - 'nes', - 'nin3ds', - 'ninds', - 'ningb', - 'ningba', - 'nro', - 'nso', - 'omf', - 'qnx', - 'p9', - 'pe', - 'pe64', - 'pebble', - 'prg', - 'psxexe', - 'pyc', - 'sfc', - 'smd', - 'sms', - 'spc700', - 'symbols', - 'te', - 'vsf', - 'wasm', - 'xbe', - 'xnu_kernelcache', - 'z64', - 'zimg', - ], + 'base_name': 'rz_bin', + 'base_struct': 'RzBinPlugin', + 'list': bin_plugins_list, } bin_xtr_plugins = { - 'conf_name': 'plugins_bin_xtr', - 'base_cname': 'rz_bin_xtr_plugin_', - 'list': [ - 'xtr_fatmach0', - 'xtr_sep64', - ], + 'base_name': 'rz_bin_xtr', + 'base_struct': 'RzBinXtrPlugin', + 'list': bin_xtr_plugins_list, } rz_bin_sources = [ @@ -141,7 +147,8 @@ rz_bin_sources = [ 'p/bin_xbe.c', 'p/bin_xnu_kernelcache.c', 'p/bin_xtr_fatmach0.c', - 'p/bin_xtr_pemixed.c', + # this was never built. + # 'p/bin_xtr_pemixed.c', 'p/bin_xtr_sep64.c', 'p/bin_z64.c', 'p/bin_zimg.c', diff --git a/librz/bin/p/bin_java.c b/librz/bin/p/bin_java.c index b58e91cd1da..5275d98802f 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/isa/java/const.h" #define rz_bin_file_get_java_class(bf) ((RzBinJavaClass *)bf->o->bin_obj) diff --git a/librz/bin/p/bin_xnu_kernelcache.c b/librz/bin/p/bin_xnu_kernelcache.c index e1fab349a0c..d86d100d394 100644 --- a/librz/bin/p/bin_xnu_kernelcache.c +++ b/librz/bin/p/bin_xnu_kernelcache.c @@ -1943,7 +1943,7 @@ RzBinPlugin rz_bin_plugin_xnu_kernelcache = { #ifndef RZ_PLUGIN_INCORE RzLibStruct rizin_plugin = { .type = RZ_LIB_TYPE_BIN, - .data = &rz_bin_plugin_kernelcache, + .data = &rz_bin_plugin_xnu_kernelcache, .version = RZ_VERSION }; #endif diff --git a/librz/bin/p/bin_xtr_fatmach0.c b/librz/bin/p/bin_xtr_fatmach0.c index e62a280553d..c3617949980 100644 --- a/librz/bin/p/bin_xtr_fatmach0.c +++ b/librz/bin/p/bin_xtr_fatmach0.c @@ -148,7 +148,7 @@ static RzList /**/ *oneshotall_buffer(RzBin *bin, RzBuffer *b) { return NULL; } -RzBinXtrPlugin rz_bin_xtr_plugin_xtr_fatmach0 = { +RzBinXtrPlugin rz_bin_xtr_plugin_fatmach0 = { .name = "xtr.fatmach0", .desc = "fat mach0 bin extractor plugin", .license = "LGPL3", diff --git a/librz/bin/p/bin_xtr_pemixed.c b/librz/bin/p/bin_xtr_pemixed.c index 4f916bdcbcb..9e61c1a263f 100644 --- a/librz/bin/p/bin_xtr_pemixed.c +++ b/librz/bin/p/bin_xtr_pemixed.c @@ -103,7 +103,7 @@ static RzBinXtrData *oneshot(RzBin *bin, const ut8 *buf, ut64 size, int sub_bin_ return rz_bin_xtrdata_new(pe->b, 0, pe->size, 3, metadata); } -RzBinXtrPlugin rz_bin_xtr_plugin_xtr_pemixed = { +RzBinXtrPlugin rz_bin_xtr_plugin_pemixed = { .name = "xtr.pemixed", .desc = "Extract sub-binaries in PE files", .load = NULL, // not yet implemented diff --git a/librz/bin/p/bin_xtr_sep64.c b/librz/bin/p/bin_xtr_sep64.c index b49c57f5a7a..845b161d556 100644 --- a/librz/bin/p/bin_xtr_sep64.c +++ b/librz/bin/p/bin_xtr_sep64.c @@ -520,7 +520,7 @@ static bool read_arm64_ins(RzBuffer *b, int idx, ut64 *result) { return res; } -RzBinXtrPlugin rz_bin_xtr_plugin_xtr_sep64 = { +RzBinXtrPlugin rz_bin_xtr_plugin_sep64 = { .name = "xtr.sep64", .desc = "64-bit SEP bin extractor plugin", .license = "LGPL3", @@ -536,7 +536,7 @@ RzBinXtrPlugin rz_bin_xtr_plugin_xtr_sep64 = { #ifndef RZ_PLUGIN_INCORE RZ_API RzLibStruct rizin_plugin = { .type = RZ_LIB_TYPE_BIN_XTR, - .data = &rz_bin_xtr_plugin_xtr_sep64, + .data = &rz_bin_xtr_plugin_sep64, .version = RZ_VERSION }; #endif diff --git a/librz/bp/bp.c b/librz/bp/bp.c index 3d56c418c44..42b28682259 100644 --- a/librz/bp/bp.c +++ b/librz/bp/bp.c @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-only #include -#include +#include "rz_bp_plugins.h" RZ_LIB_VERSION(rz_bp); diff --git a/librz/bp/bp_io.c b/librz/bp/bp_io.c index f2131788f51..10fb6c28db1 100644 --- a/librz/bp/bp_io.c +++ b/librz/bp/bp_io.c @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LGPL-3.0-only #include -#include RZ_API void rz_bp_restore_one(RzBreakpoint *bp, RzBreakpointItem *b, bool set) { if (set) { diff --git a/librz/bp/meson.build b/librz/bp/meson.build index bd85720f64b..cc1cbc011e6 100644 --- a/librz/bp/meson.build +++ b/librz/bp/meson.build @@ -1,14 +1,16 @@ +bp_plugins_list = [ + 'arm', + 'bf', + 'mips', + 'ppc', + 'sh', + 'x86' +] + bp_plugins = { - 'conf_name': 'plugins_bp', - 'base_cname': 'rz_bp_plugin_', - 'list': [ - 'arm', - 'bf', - 'mips', - 'ppc', - 'sh', - 'x86' - ], + 'base_name': 'rz_bp', + 'base_struct': 'RzBreakpointPlugin', + 'list': bp_plugins_list, } rz_bp_sources = [ diff --git a/librz/config.h.in b/librz/config.h.in deleted file mode 100644 index f55c135a6cd..00000000000 --- a/librz/config.h.in +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-FileCopyrightText: 2021 RizinOrg -// SPDX-License-Identifier: LGPL-3.0-only - -#ifndef _INCLUDE_CONFIG_H_ -#define _INCLUDE_CONFIG_H_ - -#define RZ_DEBUG 0 -#define RZ_RTDEBUG 1 - -/* inlined APIs */ -#define RZ_INLINE 0 -#define RZ_LOADLIBS 1 - -// clang-format off -#define RZ_EGG_STATIC_PLUGINS @plugins_egg@ -#define RZ_BIN_STATIC_PLUGINS @plugins_bin@ -#define RZ_BIN_XTR_STATIC_PLUGINS @plugins_bin_xtr@ -#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_CORE_STATIC_PLUGINS @plugins_core@ -#define RZ_LANG_STATIC_PLUGINS @plugins_lang@ -#define RZ_HASH_STATIC_PLUGINS @plugins_hash@ -#define RZ_PARSE_STATIC_PLUGINS @plugins_parse@ -#define RZ_CRYPTO_STATIC_PLUGINS @plugins_crypto@ -#define RZ_DEMANGLER_STATIC_PLUGINS @plugins_demangler@ -// clang-format on - -#endif diff --git a/librz/core/core.c b/librz/core/core.c index 737b9a61cb9..69e3628fd5b 100644 --- a/librz/core/core.c +++ b/librz/core/core.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #if __UNIX__ #include diff --git a/librz/core/cplugin.c b/librz/core/cplugin.c index a4b1128a756..6047c1f3c3f 100644 --- a/librz/core/cplugin.c +++ b/librz/core/cplugin.c @@ -1,12 +1,12 @@ // SPDX-FileCopyrightText: 2010-2020 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include #include #include #include #include #include +#include "rz_core_plugins.h" static RzCorePlugin *core_static_plugins[] = { RZ_CORE_STATIC_PLUGINS }; diff --git a/librz/core/libs.c b/librz/core/libs.c index c44f9719370..078aef1ff73 100644 --- a/librz/core/libs.c +++ b/librz/core/libs.c @@ -3,7 +3,6 @@ #include #include -#include "config.h" #define CB(x, y) \ static bool lib_##x##_cb(RzLibPlugin *pl, void *user, void *data) { \ @@ -40,8 +39,39 @@ CB(demangler, bin->demangler) CB(egg, egg) CB(hash, hash) +static bool lib_arch_cb(RzLibPlugin *pl, void *user, void *data) { + RzArchPlugin *hand = (RzArchPlugin *)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) { + RzArchPlugin *hand = (RzArchPlugin *)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"); if (where & RZ_CORE_LOADLIBS_CONFIG) { rz_lib_opendir(core->lib, dir_plugins, false); @@ -70,7 +100,6 @@ static void loadSystemPlugins(RzCore *core, int where) { } free(epd); } -#endif } RZ_API void rz_core_loadlibs_init(RzCore *core) { @@ -90,6 +119,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 5ed472fb9b9..1019be246ef 100644 --- a/librz/core/meson.build +++ b/librz/core/meson.build @@ -1,10 +1,12 @@ +core_plugins_list = [ + 'java', + 'dex', +] + core_plugins = { - 'conf_name': 'plugins_core', - 'base_cname': 'rz_core_plugin_', - 'list': [ - 'java', - 'dex', - ], + 'base_name': 'rz_core', + 'base_struct': 'RzCorePlugin', + 'list': core_plugins_list, } subdir('cmd_descs') @@ -147,12 +149,11 @@ rz_core_deps = [ rz_bp_dep, rz_syscall_dep, rz_parse_dep, - rz_asm_dep, rz_egg_dep, rz_search_dep, rz_sign_dep, rz_il_dep, - rz_analysis_dep, + rz_arch_dep, rz_type_dep, rz_debug_dep, rz_config_dep, @@ -192,7 +193,6 @@ modules += { 'rz_core': { 'rz_syscall', 'rz_search', 'rz_cons', - 'rz_analysis', 'rz_socket', 'rz_type', 'rz_io', @@ -205,7 +205,7 @@ modules += { 'rz_core': { 'rz_crypto', 'rz_config', 'rz_bin', - 'rz_asm', + 'rz_arch', 'rz_bp', 'rz_sign', 'rz_il' diff --git a/librz/crypto/crypto.c b/librz/crypto/crypto.c index d6e59261dd6..1e42e9646ce 100644 --- a/librz/crypto/crypto.c +++ b/librz/crypto/crypto.c @@ -1,10 +1,10 @@ // SPDX-FileCopyrightText: 2009-2017 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "config.h" #include #include #include +#include "rz_crypto_plugins.h" #define RZ_CRYPTO_OUTPUT_SIZE 4096 diff --git a/librz/crypto/meson.build b/librz/crypto/meson.build index cf0b7336264..e5777e4012a 100644 --- a/librz/crypto/meson.build +++ b/librz/crypto/meson.build @@ -1,25 +1,27 @@ +crypto_plugins_list = [ + 'aes', + 'aes_cbc', + 'base64', + 'base91', + 'blowfish', + 'cps2', + 'des', + 'punycode', + 'rc2', + 'rc4', + 'rc6', + 'rol', + 'ror', + 'rot', + 'serpent', + 'xor', + 'sm4_ecb' +] + crypto_plugins = { - 'conf_name': 'plugins_crypto', - 'base_cname': 'rz_crypto_plugin_', - 'list': [ - 'aes', - 'aes_cbc', - 'base64', - 'base91', - 'blowfish', - 'cps2', - 'des', - 'punycode', - 'rc2', - 'rc4', - 'rc6', - 'rol', - 'ror', - 'rot', - 'serpent', - 'xor', - 'sm4_ecb' - ], + 'base_name': 'rz_crypto', + 'base_struct': 'RzCryptoPlugin', + 'list': crypto_plugins_list, } rz_crypto_sources = [ diff --git a/librz/debug/meson.build b/librz/debug/meson.build index e2ca00700ff..74773647013 100644 --- a/librz/debug/meson.build +++ b/librz/debug/meson.build @@ -8,22 +8,19 @@ debug_plugins_list = [ 'rap', 'winkd', ] + if get_option('use_gpl') debug_plugins_list += 'qnx' endif + if has_debugger debug_plugins_list += ['native'] endif + if host_machine.system() == 'windows' debug_plugins_list += 'windbg' endif -debug_plugins = { - 'conf_name': 'plugins_debug', - 'base_cname': 'rz_debug_plugin_', - 'list': debug_plugins_list, -} - rz_debug_sources = [ 'ddesc.c', 'debug.c', @@ -70,7 +67,7 @@ rz_debug_deps = [ rz_bp_dep, rz_syscall_dep, rz_egg_dep, - rz_analysis_dep, + rz_arch_dep, rz_type_dep, platform_deps ] @@ -134,6 +131,12 @@ rz_debug_inc = [ ) ] +debug_plugins = { + 'base_name': 'rz_debug', + 'base_struct': 'RzDebugPlugin', + 'list': debug_plugins_list, +} + rz_debug = library('rz_debug', rz_debug_sources, include_directories: rz_debug_inc, dependencies: rz_debug_deps, @@ -157,7 +160,7 @@ modules += { 'rz_debug': { 'rz_hash', 'rz_reg', 'rz_syscall', - 'rz_analysis', + 'rz_arch', 'rz_io', 'rz_bin', 'rz_bp', diff --git a/librz/debug/plugin.c b/librz/debug/plugin.c index 86cc89e2afe..4bb8428e2f5 100644 --- a/librz/debug/plugin.c +++ b/librz/debug/plugin.c @@ -3,7 +3,7 @@ #include #include -#include +#include "rz_debug_plugins.h" static RzDebugPlugin *debug_static_plugins[] = { RZ_DEBUG_STATIC_PLUGINS }; diff --git a/librz/demangler/demangler.c b/librz/demangler/demangler.c index 82cf0691818..4d07c40738a 100644 --- a/librz/demangler/demangler.c +++ b/librz/demangler/demangler.c @@ -6,13 +6,14 @@ #include #include #include -#include + +#include "rz_demangler_plugins.h" #define DEFINE_DEMANGLER_PLUGIN(name, lang, lic, auth, handler) \ static char *handler##_cast(const char *symbol, RzDemanglerFlag flags) { \ return handler(symbol, (RzDemangleOpts)flags); \ } \ - RZ_API RzDemanglerPlugin rz_demangler_plugin_##name = { \ + RzDemanglerPlugin rz_demangler_plugin_##name = { \ .language = lang, \ .license = lic, \ .author = auth, \ diff --git a/librz/demangler/meson.build b/librz/demangler/meson.build index 60dfc4aff51..97d753553ff 100644 --- a/librz/demangler/meson.build +++ b/librz/demangler/meson.build @@ -14,8 +14,8 @@ if get_option('use_swift_demangler') endif demangler_plugins = { - 'conf_name': 'plugins_demangler', - 'base_cname': 'rz_demangler_plugin_', + 'base_name': 'rz_demangler', + 'base_struct': 'RzDemanglerPlugin', 'list': demangler_plugins_list, } diff --git a/librz/egg/egg.c b/librz/egg/egg.c index e33b0a558f7..7ae6f6e23c3 100644 --- a/librz/egg/egg.c +++ b/librz/egg/egg.c @@ -3,7 +3,7 @@ #include #include -#include +#include "rz_egg_plugins.h" RZ_LIB_VERSION(rz_egg); diff --git a/librz/egg/meson.build b/librz/egg/meson.build index 1d5782ef575..c635865847e 100644 --- a/librz/egg/meson.build +++ b/librz/egg/meson.build @@ -1,11 +1,17 @@ +egg_plugins_list = [ + # commented plugins were never built. + #'bind', + #'cb', + 'exec', + #'reverse', + #'shya', + 'xor', +] + egg_plugins = { - 'conf_name': 'plugins_egg', - 'base_cname': 'rz_egg_plugin_', - 'list': [ - 'exec', - #'shya', - 'xor' - ], + 'base_name': 'rz_egg', + 'base_struct': 'RzEggPlugin', + 'list': egg_plugins_list, } rz_egg_sources = [ @@ -16,6 +22,7 @@ rz_egg_sources = [ 'emit_trace.c', 'emit_x64.c', 'emit_x86.c', + # commented plugins were never built. #'p/egg_bind.c', #'p/egg_cb.c', 'p/egg_exec.c', @@ -29,7 +36,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 +54,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/hash/hash.c b/librz/hash/hash.c index f72d58aefcd..06b43c2cb2e 100644 --- a/librz/hash/hash.c +++ b/librz/hash/hash.c @@ -1,12 +1,12 @@ // SPDX-FileCopyrightText: 2021 deroad // SPDX-License-Identifier: LGPL-3.0-only -#include "config.h" #include #include #include #include #include "algorithms/ssdeep/ssdeep.h" +#include "rz_hash_plugins.h" RZ_LIB_VERSION(rz_hash); diff --git a/librz/hash/meson.build b/librz/hash/meson.build index 007afd27b64..1bd5bb6482e 100644 --- a/librz/hash/meson.build +++ b/librz/hash/meson.build @@ -1,80 +1,82 @@ +hash_plugins_list = [ + 'md2', + 'md4', + 'md5', + 'sha1', + 'sha256', + 'sha384', + 'sha512', + 'sm3', + 'blake3', + 'fletcher8', + 'fletcher16', + 'fletcher32', + 'fletcher64', + 'adler32', + 'crca_crc8smbus', + 'crca_crc8cdma2000', + 'crca_crc8darc', + 'crca_crc8dvbs2', + 'crca_crc8ebu', + 'crca_crc8icode', + 'crca_crc8itu', + 'crca_crc8maxim', + 'crca_crc8rohc', + 'crca_crc8wcdma', + 'crca_crc15can', + 'crca_crc16', + 'crca_crc16citt', + 'crca_crc16usb', + 'crca_crc16hdlc', + 'crca_crc16augccitt', + 'crca_crc16buypass', + 'crca_crc16cdma2000', + 'crca_crc16dds110', + 'crca_crc16dectr', + 'crca_crc16dectx', + 'crca_crc16dnp', + 'crca_crc16en13757', + 'crca_crc16genibus', + 'crca_crc16maxim', + 'crca_crc16mcrf4xx', + 'crca_crc16riello', + 'crca_crc16t10dif', + 'crca_crc16teledisk', + 'crca_crc16tms37157', + 'crca_crca', + 'crca_crc16kermit', + 'crca_crc16modbus', + 'crca_crc16x25', + 'crca_crc16xmodem', + 'crca_crc24', + 'crca_crc32', + 'crca_crc32ecma267', + 'crca_crc32c', + 'crca_crc32bzip2', + 'crca_crc32d', + 'crca_crc32mpeg2', + 'crca_crc32posix', + 'crca_crc32q', + 'crca_crc32jamcrc', + 'crca_crc32xfer', + 'crca_crc64', + 'crca_crc64ecma182', + 'crca_crc64we', + 'crca_crc64xz', + 'crca_crc64iso', + 'xor8', + 'xor16', + 'xxhash32', + 'ssdeep', + 'parity', + 'entropy', + 'entropy_fract', +] + hash_plugins = { - 'conf_name': 'plugins_hash', - 'base_cname': 'rz_hash_plugin_', - 'list': [ - 'md2', - 'md4', - 'md5', - 'sha1', - 'sha256', - 'sha384', - 'sha512', - 'sm3', - 'blake3', - 'fletcher8', - 'fletcher16', - 'fletcher32', - 'fletcher64', - 'adler32', - 'crca_crc8smbus', - 'crca_crc8cdma2000', - 'crca_crc8darc', - 'crca_crc8dvbs2', - 'crca_crc8ebu', - 'crca_crc8icode', - 'crca_crc8itu', - 'crca_crc8maxim', - 'crca_crc8rohc', - 'crca_crc8wcdma', - 'crca_crc15can', - 'crca_crc16', - 'crca_crc16citt', - 'crca_crc16usb', - 'crca_crc16hdlc', - 'crca_crc16augccitt', - 'crca_crc16buypass', - 'crca_crc16cdma2000', - 'crca_crc16dds110', - 'crca_crc16dectr', - 'crca_crc16dectx', - 'crca_crc16dnp', - 'crca_crc16en13757', - 'crca_crc16genibus', - 'crca_crc16maxim', - 'crca_crc16mcrf4xx', - 'crca_crc16riello', - 'crca_crc16t10dif', - 'crca_crc16teledisk', - 'crca_crc16tms37157', - 'crca_crca', - 'crca_crc16kermit', - 'crca_crc16modbus', - 'crca_crc16x25', - 'crca_crc16xmodem', - 'crca_crc24', - 'crca_crc32', - 'crca_crc32ecma267', - 'crca_crc32c', - 'crca_crc32bzip2', - 'crca_crc32d', - 'crca_crc32mpeg2', - 'crca_crc32posix', - 'crca_crc32q', - 'crca_crc32jamcrc', - 'crca_crc32xfer', - 'crca_crc64', - 'crca_crc64ecma182', - 'crca_crc64we', - 'crca_crc64xz', - 'crca_crc64iso', - 'xor8', - 'xor16', - 'xxhash32', - 'ssdeep', - 'parity', - 'entropy', - 'entropy_fract', - ], + 'base_name': 'rz_hash', + 'base_struct': 'RzHashPlugin', + 'list': hash_plugins_list, } rz_hash_sources = [ diff --git a/librz/include/meson.build b/librz/include/meson.build index 1fda738f0d2..47a90bcfd4f 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 ad31d32d5f7..9ac157289b6 100644 --- a/librz/include/rz_analysis.h +++ b/librz/include/rz_analysis.h @@ -34,8 +34,6 @@ extern "C" { #endif -RZ_LIB_VERSION_HEADER(rz_analysis); - // TODO: save memory2 : fingerprints must be pointers to a buffer // containing a dupped file in memory @@ -2422,68 +2420,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_rx; -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..5e3ee72a144 --- /dev/null +++ b/librz/include/rz_arch.h @@ -0,0 +1,31 @@ +// 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 + +RZ_LIB_VERSION_HEADER(rz_arch); + +typedef struct rz_arch_plugin_t { + RZ_DEPRECATE RzAsmPlugin *p_asm; ///< Assembly Plugin + RZ_DEPRECATE RzAnalysisPlugin *p_analysis; ///< Analysis Plugin +} RzArchPlugin; + +RZ_DEPRECATE RZ_API const size_t rz_arch_get_n_plugins(); +RZ_DEPRECATE RZ_API RZ_BORROW RzAsmPlugin *rz_arch_get_asm_plugin(size_t index); +RZ_DEPRECATE RZ_API RZ_BORROW RzAnalysisPlugin *rz_arch_get_analysis_plugin(size_t index); + +#ifdef __cplusplus +} +#endif + +#endif /* RZ_ARCH_H */ diff --git a/librz/include/rz_asm.h b/librz/include/rz_asm.h index 5e2db154998..0014cab7a92 100644 --- a/librz/include/rz_asm.h +++ b/librz/include/rz_asm.h @@ -17,8 +17,6 @@ extern "C" { #endif -RZ_LIB_VERSION_HEADER(rz_asm); - /* backward compatibility */ #define RZ_ASM_ARCH_NONE RZ_SYS_ARCH_NONE #define RZ_ASM_ARCH_X86 RZ_SYS_ARCH_X86 @@ -214,77 +212,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_rx; -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_bin.h b/librz/include/rz_bin.h index 1477332d6dc..8b7f306ab2c 100644 --- a/librz/include/rz_bin.h +++ b/librz/include/rz_bin.h @@ -973,66 +973,6 @@ RZ_API void rz_bin_string_database_free(RZ_NULLABLE RzBinStrDb *db); RZ_API bool rz_bin_string_database_add(RZ_NONNULL RzBinStrDb *db, RZ_NONNULL RzBinString *bstr); RZ_API bool rz_bin_string_database_remove(RZ_NONNULL RzBinStrDb *db, ut64 address, bool is_va); -/* plugin pointers */ -extern RzBinPlugin rz_bin_plugin_any; -extern RzBinPlugin rz_bin_plugin_fs; -extern RzBinPlugin rz_bin_plugin_cgc; -extern RzBinPlugin rz_bin_plugin_elf; -extern RzBinPlugin rz_bin_plugin_elf64; -extern RzBinPlugin rz_bin_plugin_p9; -extern RzBinPlugin rz_bin_plugin_ne; -extern RzBinPlugin rz_bin_plugin_le; -extern RzBinPlugin rz_bin_plugin_luac; -extern RzBinPlugin rz_bin_plugin_pe; -extern RzBinPlugin rz_bin_plugin_mz; -extern RzBinPlugin rz_bin_plugin_pe64; -extern RzBinPlugin rz_bin_plugin_pebble; -extern RzBinPlugin rz_bin_plugin_bios; -extern RzBinPlugin rz_bin_plugin_bf; -extern RzBinPlugin rz_bin_plugin_te; -extern RzBinPlugin rz_bin_plugin_symbols; -extern RzBinPlugin rz_bin_plugin_mach0; -extern RzBinPlugin rz_bin_plugin_mach064; -extern RzBinPlugin rz_bin_plugin_mdmp; -extern RzBinPlugin rz_bin_plugin_java; -extern RzBinPlugin rz_bin_plugin_dex; -extern RzBinPlugin rz_bin_plugin_coff; -extern RzBinPlugin rz_bin_plugin_ningb; -extern RzBinPlugin rz_bin_plugin_ningba; -extern RzBinPlugin rz_bin_plugin_ninds; -extern RzBinPlugin rz_bin_plugin_nin3ds; -extern RzBinPlugin rz_bin_plugin_xbe; -extern RzBinPlugin rz_bin_plugin_bflt; -extern RzBinXtrPlugin rz_bin_xtr_plugin_xtr_fatmach0; -extern RzBinXtrPlugin rz_bin_xtr_plugin_xtr_dyldcache; -extern RzBinXtrPlugin rz_bin_xtr_plugin_xtr_pemixed; -extern RzBinXtrPlugin rz_bin_xtr_plugin_xtr_sep64; -extern RzBinPlugin rz_bin_plugin_zimg; -extern RzBinPlugin rz_bin_plugin_omf; -extern RzBinPlugin rz_bin_plugin_art; -extern RzBinPlugin rz_bin_plugin_bootimg; -extern RzBinPlugin rz_bin_plugin_dol; -extern RzBinPlugin rz_bin_plugin_nes; -extern RzBinPlugin rz_bin_plugin_qnx; -extern RzBinPlugin rz_bin_plugin_mbn; -extern RzBinPlugin rz_bin_plugin_smd; -extern RzBinPlugin rz_bin_plugin_sms; -extern RzBinPlugin rz_bin_plugin_psxexe; -extern RzBinPlugin rz_bin_plugin_spc700; -extern RzBinPlugin rz_bin_plugin_vsf; -extern RzBinPlugin rz_bin_plugin_dyldcache; -extern RzBinPlugin rz_bin_plugin_xnu_kernelcache; -extern RzBinPlugin rz_bin_plugin_avr; -extern RzBinPlugin rz_bin_plugin_menuet; -extern RzBinPlugin rz_bin_plugin_wasm; -extern RzBinPlugin rz_bin_plugin_nro; -extern RzBinPlugin rz_bin_plugin_nso; -extern RzBinPlugin rz_bin_plugin_sfc; -extern RzBinPlugin rz_bin_plugin_z64; -extern RzBinPlugin rz_bin_plugin_prg; -extern RzBinPlugin rz_bin_plugin_dmp64; -extern RzBinPlugin rz_bin_plugin_pyc; - #ifdef __cplusplus } #endif diff --git a/librz/include/rz_bp.h b/librz/include/rz_bp.h index 9c82d95dac5..912102c1eba 100644 --- a/librz/include/rz_bp.h +++ b/librz/include/rz_bp.h @@ -172,13 +172,6 @@ RZ_API void rz_serialize_bp_save(RZ_NONNULL Sdb *db, RZ_NONNULL RzBreakpoint *bp RZ_API RzSerializeBpParser rz_serialize_bp_parser_new(void); RZ_API bool rz_serialize_bp_load(RZ_NONNULL Sdb *db, RZ_NONNULL RzBreakpoint *bp, RZ_NULLABLE RzSerializeResultInfo *res); -/* plugin pointers */ -extern RzBreakpointPlugin rz_bp_plugin_x86; -extern RzBreakpointPlugin rz_bp_plugin_arm; -extern RzBreakpointPlugin rz_bp_plugin_mips; -extern RzBreakpointPlugin rz_bp_plugin_ppc; -extern RzBreakpointPlugin rz_bp_plugin_sh; -extern RzBreakpointPlugin rz_bp_plugin_bf; #endif #ifdef __cplusplus } diff --git a/librz/include/rz_build_version.h.in b/librz/include/rz_build_version.h.in index 0757265f1ca..fd149a9f8b7 100644 --- a/librz/include/rz_build_version.h.in +++ b/librz/include/rz_build_version.h.in @@ -8,4 +8,4 @@ #define RZ_VERSION "@RZ_VERSION@" #mesondefine RZ_PACKAGER_VERSION #mesondefine RZ_PACKAGER -#endif +#endif /* RZ_BUILD_VERSION_H */ diff --git a/librz/include/rz_core.h b/librz/include/rz_core.h index 4ebf4196ccb..b5a03741e83 100644 --- a/librz/include/rz_core.h +++ b/librz/include/rz_core.h @@ -5,6 +5,7 @@ #define RZ_CORE_H #include +#include #include #include #include @@ -1234,10 +1235,6 @@ RZ_API ut32 rz_core_flirt_file_from_option_list(RZ_NONNULL const char *file_list RZ_API ut16 rz_core_flirt_os_from_option_list(RZ_NONNULL const char *os_list); RZ_API ut16 rz_core_flirt_app_from_option_list(RZ_NONNULL const char *app_list); -/* PLUGINS */ -extern RzCorePlugin rz_core_plugin_java; -extern RzCorePlugin rz_core_plugin_dex; - /* DECOMPILER PRINTING FUNCTIONS */ /** * @brief Prints the data contained in the specified RzAnnotatedCode in JSON format. diff --git a/librz/include/rz_crypto.h b/librz/include/rz_crypto.h index 00933602100..6c08a57e8d8 100644 --- a/librz/include/rz_crypto.h +++ b/librz/include/rz_crypto.h @@ -71,25 +71,6 @@ RZ_API RZ_BORROW const char *rz_crypto_codec_name(const RzCryptoSelector bit); RZ_API RZ_BORROW const RzCryptoPlugin *rz_crypto_plugin_by_index(RZ_NONNULL RzCrypto *cry, size_t index); #endif -/* plugin pointers */ -extern RzCryptoPlugin rz_crypto_plugin_aes; -extern RzCryptoPlugin rz_crypto_plugin_des; -extern RzCryptoPlugin rz_crypto_plugin_rc4; -extern RzCryptoPlugin rz_crypto_plugin_xor; -extern RzCryptoPlugin rz_crypto_plugin_blowfish; -extern RzCryptoPlugin rz_crypto_plugin_rc2; -extern RzCryptoPlugin rz_crypto_plugin_rot; -extern RzCryptoPlugin rz_crypto_plugin_rol; -extern RzCryptoPlugin rz_crypto_plugin_ror; -extern RzCryptoPlugin rz_crypto_plugin_base64; -extern RzCryptoPlugin rz_crypto_plugin_base91; -extern RzCryptoPlugin rz_crypto_plugin_aes_cbc; -extern RzCryptoPlugin rz_crypto_plugin_punycode; -extern RzCryptoPlugin rz_crypto_plugin_rc6; -extern RzCryptoPlugin rz_crypto_plugin_cps2; -extern RzCryptoPlugin rz_crypto_plugin_serpent; -extern RzCryptoPlugin rz_crypto_plugin_sm4_ecb; - #define RZ_CRYPTO_NONE 0ULL #define RZ_CRYPTO_RC2 1ULL #define RZ_CRYPTO_RC4 1ULL << 1 diff --git a/librz/include/rz_debug.h b/librz/include/rz_debug.h index 72a7f3c4d76..289f3977a9e 100644 --- a/librz/include/rz_debug.h +++ b/librz/include/rz_debug.h @@ -613,19 +613,6 @@ static inline void *rz_debug_ptrace_func(RzDebug *dbg, void *(*func)(void *), vo } #endif -/* plugin pointers */ -extern RzDebugPlugin rz_debug_plugin_native; -extern RzDebugPlugin rz_debug_plugin_esil; -extern RzDebugPlugin rz_debug_plugin_dmp; -extern RzDebugPlugin rz_debug_plugin_rap; -extern RzDebugPlugin rz_debug_plugin_gdb; -extern RzDebugPlugin rz_debug_plugin_bf; -extern RzDebugPlugin rz_debug_plugin_io; -extern RzDebugPlugin rz_debug_plugin_winkd; -extern RzDebugPlugin rz_debug_plugin_windbg; -extern RzDebugPlugin rz_debug_plugin_bochs; -extern RzDebugPlugin rz_debug_plugin_qnx; -extern RzDebugPlugin rz_debug_plugin_null; #endif #ifdef __cplusplus diff --git a/librz/include/rz_egg.h b/librz/include/rz_egg.h index 03c320f62be..8a9a0098c64 100644 --- a/librz/include/rz_egg.h +++ b/librz/include/rz_egg.h @@ -215,10 +215,6 @@ RZ_API int rz_egg_lang_parsechar(RzEgg *egg, char c); RZ_API void rz_egg_lang_include_path(RzEgg *egg, const char *path); RZ_API void rz_egg_lang_include_init(RzEgg *egg); -/* plugin pointers */ -extern RzEggPlugin rz_egg_plugin_xor; -extern RzEggPlugin rz_egg_plugin_shya; -extern RzEggPlugin rz_egg_plugin_exec; #endif #ifdef __cplusplus diff --git a/librz/include/rz_io.h b/librz/include/rz_io.h index 5db605fe1cb..934a3f03340 100644 --- a/librz/include/rz_io.h +++ b/librz/include/rz_io.h @@ -446,38 +446,6 @@ RZ_API void *rz_io_ptrace_func(RzIO *io, void *(*func)(void *), void *user); RZ_API struct w32dbg_wrap_instance_t *rz_io_get_w32dbg_wrap(RzIO *io); #endif -extern RzIOPlugin rz_io_plugin_procpid; -extern RzIOPlugin rz_io_plugin_malloc; -extern RzIOPlugin rz_io_plugin_sparse; -extern RzIOPlugin rz_io_plugin_ptrace; -extern RzIOPlugin rz_io_plugin_w32dbg; -extern RzIOPlugin rz_io_plugin_windbg; -extern RzIOPlugin rz_io_plugin_mach; -extern RzIOPlugin rz_io_plugin_debug; -extern RzIOPlugin rz_io_plugin_dmp; -extern RzIOPlugin rz_io_plugin_shm; -extern RzIOPlugin rz_io_plugin_gdb; -extern RzIOPlugin rz_io_plugin_rap; -extern RzIOPlugin rz_io_plugin_http; -extern RzIOPlugin rz_io_plugin_bfdbg; -extern RzIOPlugin rz_io_plugin_w32; -extern RzIOPlugin rz_io_plugin_zip; -extern RzIOPlugin rz_io_plugin_default; -extern RzIOPlugin rz_io_plugin_ihex; -extern RzIOPlugin rz_io_plugin_srec; -extern RzIOPlugin rz_io_plugin_self; -extern RzIOPlugin rz_io_plugin_gzip; -extern RzIOPlugin rz_io_plugin_winkd; -extern RzIOPlugin rz_io_plugin_rzpipe; -extern RzIOPlugin rz_io_plugin_rzweb; -extern RzIOPlugin rz_io_plugin_qnx; -extern RzIOPlugin rz_io_plugin_tcp; -extern RzIOPlugin rz_io_plugin_bochs; -extern RzIOPlugin rz_io_plugin_null; -extern RzIOPlugin rz_io_plugin_ar; -extern RzIOPlugin rz_io_plugin_winedbg; -extern RzIOPlugin rz_io_plugin_fd; - #if __cplusplus } #endif diff --git a/librz/include/rz_lang.h b/librz/include/rz_lang.h index a51da6f584b..b4078d5aa77 100644 --- a/librz/include/rz_lang.h +++ b/librz/include/rz_lang.h @@ -67,13 +67,6 @@ RZ_API bool rz_lang_define(RzLang *lang, const char *type, const char *name, voi RZ_API void rz_lang_undef(RzLang *lang, const char *name); RZ_API void rz_lang_def_free(RzLangDef *def); -extern RzLangPlugin rz_lang_plugin_lib; -extern RzLangPlugin rz_lang_plugin_pipe; -extern RzLangPlugin rz_lang_plugin_rust; -extern RzLangPlugin rz_lang_plugin_vala; -extern RzLangPlugin rz_lang_plugin_c; -extern RzLangPlugin rz_lang_plugin_cpipe; - #endif #ifdef __cplusplus diff --git a/librz/include/rz_lib.h b/librz/include/rz_lib.h index 9cdf3241061..c25b0e64f88 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, ///< demanglers RZ_LIB_TYPE_UNKNOWN } RzLibType; diff --git a/librz/include/rz_parse.h b/librz/include/rz_parse.h index 8e5f6d3a4ff..5120cba1722 100644 --- a/librz/include/rz_parse.h +++ b/librz/include/rz_parse.h @@ -68,24 +68,6 @@ RZ_API bool rz_parse_filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hi RZ_API bool rz_parse_subvar(RzParse *p, RZ_NULLABLE RzAnalysisFunction *f, RZ_NONNULL RzAnalysisOp *op, RZ_NONNULL RZ_IN char *data, RZ_BORROW RZ_NONNULL RZ_OUT char *str, int len); RZ_API char *rz_parse_immtrim(char *opstr); -/* plugin pointers */ -extern RzParsePlugin rz_parse_plugin_6502_pseudo; -extern RzParsePlugin rz_parse_plugin_arm_pseudo; -extern RzParsePlugin rz_parse_plugin_att2intel; -extern RzParsePlugin rz_parse_plugin_avr_pseudo; -extern RzParsePlugin rz_parse_plugin_chip8_pseudo; -extern RzParsePlugin rz_parse_plugin_dalvik_pseudo; -extern RzParsePlugin rz_parse_plugin_dummy; -extern RzParsePlugin rz_parse_plugin_m68k_pseudo; -extern RzParsePlugin rz_parse_plugin_mips_pseudo; -extern RzParsePlugin rz_parse_plugin_ppc_pseudo; -extern RzParsePlugin rz_parse_plugin_sh_pseudo; -extern RzParsePlugin rz_parse_plugin_wasm_pseudo; -extern RzParsePlugin rz_parse_plugin_riscv_pseudo; -extern RzParsePlugin rz_parse_plugin_x86_pseudo; -extern RzParsePlugin rz_parse_plugin_z80_pseudo; -extern RzParsePlugin rz_parse_plugin_tms320_pseudo; -extern RzParsePlugin rz_parse_plugin_v850_pseudo; #endif #ifdef __cplusplus diff --git a/librz/include/rz_types.h b/librz/include/rz_types.h index 97423309ed7..f1c758adc79 100644 --- a/librz/include/rz_types.h +++ b/librz/include/rz_types.h @@ -243,8 +243,6 @@ typedef int (*PrintfCallback)(const char *str, ...) RZ_PRINTF_CHECK(1, 2); #endif #ifdef RZ_BINDINGS #define RZ_API __attribute__((annotate("RZ_API"))) -#elif RZ_INLINE -#define RZ_API inline #else #if defined(__GNUC__) && __GNUC__ >= 4 #define RZ_API __attribute__((visibility("default"))) diff --git a/librz/include/rz_userconf.h.in b/librz/include/rz_userconf.h.in index e33aeda944b..d6640187066 100644 --- a/librz/include/rz_userconf.h.in +++ b/librz/include/rz_userconf.h.in @@ -84,7 +84,7 @@ #define RZ_FLAGS "@FLAGS@" #define RZ_HUD "@HUD@" -#define RZ_SDB_ARCH_PLATFORMS RZ_JOIN_3_PATHS(RZ_SDB, "asm", "platforms") +#define RZ_SDB_ARCH_PLATFORMS RZ_JOIN_3_PATHS(RZ_SDB, "arch", "platforms") #define RZ_SDB_ARCH_CPUS RZ_JOIN_3_PATHS(RZ_SDB, "asm", "cpus") #define RZ_SDB_TYPES RZ_JOIN_2_PATHS(RZ_SDB, "types") #define RZ_SDB_OPCODES RZ_JOIN_2_PATHS(RZ_SDB, "opcodes") diff --git a/librz/io/io.c b/librz/io/io.c index 8d94f5e226d..24ef79ea7a2 100644 --- a/librz/io/io.c +++ b/librz/io/io.c @@ -5,7 +5,6 @@ #include #include -#include #include "io_private.h" #if __WINDOWS__ diff --git a/librz/io/io_plugin.c b/librz/io/io_plugin.c index 733ac8ed216..ab45d270828 100644 --- a/librz/io/io_plugin.c +++ b/librz/io/io_plugin.c @@ -1,11 +1,12 @@ // SPDX-FileCopyrightText: 2008-2018 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "config.h" #include #include #include +#include "rz_io_plugins.h" + static volatile RzIOPlugin *default_plugin = NULL; static RzIOPlugin *io_static_plugins[] = { RZ_IO_STATIC_PLUGINS }; diff --git a/librz/io/meson.build b/librz/io/meson.build index d89880842dd..c7fbbd155bd 100644 --- a/librz/io/meson.build +++ b/librz/io/meson.build @@ -41,8 +41,8 @@ if host_machine.system() == 'windows' endif io_plugins = { - 'conf_name': 'plugins_io', - 'base_cname': 'rz_io_plugin_', + 'base_name': 'rz_io', + 'base_struct': 'RzIOPlugin', 'list': io_plugins_list, } diff --git a/librz/io/p/io_ar.c b/librz/io/p/io_ar.c index 7c2b613eba0..517dbe19d8b 100644 --- a/librz/io/p/io_ar.c +++ b/librz/io/p/io_ar.c @@ -5,6 +5,7 @@ #include #include #include "ar.h" +#include "rz_io_plugins.h" static bool rz_io_ar_plugin_open(RzIO *io, const char *file, bool many) { return !strncmp("ar://", file, 5) || !strncmp("lib://", file, 6); diff --git a/librz/io/p/io_bfdbg.c b/librz/io/p/io_bfdbg.c index 2e308cf1816..61da3d2d553 100644 --- a/librz/io/p/io_bfdbg.c +++ b/librz/io/p/io_bfdbg.c @@ -1,8 +1,8 @@ // SPDX-FileCopyrightText: 2011-2013 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_io.h" -#include "rz_lib.h" +#include +#include #include #include #include @@ -11,6 +11,8 @@ #include "../debug/p/bfvm.h" #include "../debug/p/bfvm.c" +#include "rz_io_plugins.h" + typedef struct { ut32 magic; int fd; diff --git a/librz/io/p/io_bochs.c b/librz/io/p/io_bochs.c index 212a41ce32a..0c10f5b536d 100644 --- a/librz/io/p/io_bochs.c +++ b/librz/io/p/io_bochs.c @@ -34,6 +34,8 @@ #include #include +#include "rz_io_plugins.h" + #define BOCHS_URI_PREFIX "bochs://" #define BOCHS_URI_SIZE strlen(BOCHS_URI_PREFIX) #define BOCHS_STDIN_SIZE 256 diff --git a/librz/io/p/io_debug.c b/librz/io/p/io_debug.c index 158a542fd31..bc9de9d4bc7 100644 --- a/librz/io/p/io_debug.c +++ b/librz/io/p/io_debug.c @@ -11,6 +11,8 @@ #include /* only used for BSD PTRACE redefinitions */ #include +#include "rz_io_plugins.h" + #define USE_RARUN 0 #if __linux__ || __APPLE__ || __WINDOWS__ || __NetBSD__ || __KFBSD__ || __OpenBSD__ diff --git a/librz/io/p/io_default.c b/librz/io/p/io_default.c index 9d0dd7d248f..6574c5bcc79 100644 --- a/librz/io/p/io_default.c +++ b/librz/io/p/io_default.c @@ -6,6 +6,8 @@ #include #include +#include "rz_io_plugins.h" + typedef struct rz_io_mmo_t { char *filename; int mode; diff --git a/librz/io/p/io_dmp.c b/librz/io/p/io_dmp.c index dab95eae82f..376753abc95 100644 --- a/librz/io/p/io_dmp.c +++ b/librz/io/p/io_dmp.c @@ -5,6 +5,8 @@ #include #include "librz/bin/format/dmp/dmp_specs.h" +#include "rz_io_plugins.h" + static bool dmp_plugin_open(RzIO *io, const char *file, bool many) { return (!strncmp(file, "dmp://", 6)); } diff --git a/librz/io/p/io_fd.c b/librz/io/p/io_fd.c index 4cc166d1b4b..0b5c5f4bc63 100644 --- a/librz/io/p/io_fd.c +++ b/librz/io/p/io_fd.c @@ -1,13 +1,15 @@ // SPDX-FileCopyrightText: 2020 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_io.h" -#include "rz_lib.h" +#include +#include #include #include #include #include +#include "rz_io_plugins.h" + #if __WINDOWS__ #define FDURI "handle://" #else diff --git a/librz/io/p/io_gdb.c b/librz/io/p/io_gdb.c index c6859106abc..fc703c525ca 100644 --- a/librz/io/p/io_gdb.c +++ b/librz/io/p/io_gdb.c @@ -11,6 +11,8 @@ #include #include +#include "rz_io_plugins.h" + typedef struct { libgdbr_t desc; } RzIOGdb; diff --git a/librz/io/p/io_gzip.c b/librz/io/p/io_gzip.c index d38515acd03..34cc93b7702 100644 --- a/librz/io/p/io_gzip.c +++ b/librz/io/p/io_gzip.c @@ -1,12 +1,14 @@ // SPDX-FileCopyrightText: 2008-2017 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_io.h" -#include "rz_lib.h" +#include +#include #include #include #include +#include "rz_io_plugins.h" + typedef struct { ut8 *buf; ut32 size; diff --git a/librz/io/p/io_http.c b/librz/io/p/io_http.c index e701e138e9c..7cd42eae04a 100644 --- a/librz/io/p/io_http.c +++ b/librz/io/p/io_http.c @@ -8,6 +8,8 @@ #include #include "../io_memory.h" +#include "rz_io_plugins.h" + static bool __check(RzIO *io, const char *pathname, bool many) { return (!strncmp(pathname, "http://", 7)); } diff --git a/librz/io/p/io_ihex.c b/librz/io/p/io_ihex.c index 70717810113..96e1cf3870b 100644 --- a/librz/io/p/io_ihex.c +++ b/librz/io/p/io_ihex.c @@ -27,14 +27,16 @@ KK = 0 - (sum of all bytes) */ -#include "rz_io.h" -#include "rz_lib.h" -#include "rz_util.h" -#include //for INT_MAX +#include +#include +#include +#include #include #include #include +#include "rz_io_plugins.h" + // struct Rihex : holds sparse buffer + its own fd, for internal management typedef struct { int fd; diff --git a/librz/io/p/io_mach.c b/librz/io/p/io_mach.c index dbae9bf0713..573c327756b 100644 --- a/librz/io/p/io_mach.c +++ b/librz/io/p/io_mach.c @@ -7,6 +7,8 @@ #include #include +#include "rz_io_plugins.h" + #if __APPLE__ && DEBUGGER static int __get_pid(RzIODesc *desc); diff --git a/librz/io/p/io_malloc.c b/librz/io/p/io_malloc.c index 2190135b083..6700ee3a634 100644 --- a/librz/io/p/io_malloc.c +++ b/librz/io/p/io_malloc.c @@ -1,11 +1,13 @@ // SPDX-FileCopyrightText: 2008-2017 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_lib.h" +#include #include #include #include "../io_memory.h" +#include "rz_io_plugins.h" + static bool __check(RzIO *io, const char *pathname, bool many) { return (!strncmp(pathname, "malloc://", 9)) || (!strncmp(pathname, "hex://", 6)); } diff --git a/librz/io/p/io_null.c b/librz/io/p/io_null.c index 89556ca8dcd..15a11dc1eb3 100644 --- a/librz/io/p/io_null.c +++ b/librz/io/p/io_null.c @@ -5,6 +5,8 @@ #include #include +#include "rz_io_plugins.h" + typedef struct { ut64 size; ut64 offset; diff --git a/librz/io/p/io_procpid.c b/librz/io/p/io_procpid.c index f339abed30f..fb359216317 100644 --- a/librz/io/p/io_procpid.c +++ b/librz/io/p/io_procpid.c @@ -7,6 +7,8 @@ #include #include +#include "rz_io_plugins.h" + #if __linux__ #include diff --git a/librz/io/p/io_ptrace.c b/librz/io/p/io_ptrace.c index 0c1ca8e688c..0a490f60099 100644 --- a/librz/io/p/io_ptrace.c +++ b/librz/io/p/io_ptrace.c @@ -8,6 +8,8 @@ #include #include +#include "rz_io_plugins.h" + #if DEBUGGER && (__linux__ || __BSD__) #include diff --git a/librz/io/p/io_qnx.c b/librz/io/p/io_qnx.c index 6c4d713c952..80ee5453ebe 100644 --- a/librz/io/p/io_qnx.c +++ b/librz/io/p/io_qnx.c @@ -8,6 +8,8 @@ #define IRAPI static inline #include +#include "rz_io_plugins.h" + typedef struct { libqnxr_t desc; } RzIOQnx; diff --git a/librz/io/p/io_rap.c b/librz/io/p/io_rap.c index 1562dca6959..8298e1b5272 100644 --- a/librz/io/p/io_rap.c +++ b/librz/io/p/io_rap.c @@ -7,6 +7,8 @@ #include #include +#include "rz_io_plugins.h" + typedef struct { RzSocket *fd; RzSocket *client; diff --git a/librz/io/p/io_rzpipe.c b/librz/io/p/io_rzpipe.c index 01b195d2998..a1ea8fc2370 100644 --- a/librz/io/p/io_rzpipe.c +++ b/librz/io/p/io_rzpipe.c @@ -1,13 +1,15 @@ // SPDX-FileCopyrightText: 2015-2019 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_io.h" -#include "rz_lib.h" -#include "rz_socket.h" +#include +#include +#include #include #include #include +#include "rz_io_plugins.h" + /* --------------------------------------------------------- */ #define RZP(x) ((RzPipe *)(x)->data) diff --git a/librz/io/p/io_rzweb.c b/librz/io/p/io_rzweb.c index 6b8da0e7516..97b789abf0c 100644 --- a/librz/io/p/io_rzweb.c +++ b/librz/io/p/io_rzweb.c @@ -8,6 +8,8 @@ #include #include +#include "rz_io_plugins.h" + typedef struct { int fd; char *url; diff --git a/librz/io/p/io_self.c b/librz/io/p/io_self.c index bd770e7712a..6332a1eb996 100644 --- a/librz/io/p/io_self.c +++ b/librz/io/p/io_self.c @@ -6,6 +6,8 @@ #include #include +#include "rz_io_plugins.h" + #if DEBUGGER #if __APPLE__ #include diff --git a/librz/io/p/io_shm.c b/librz/io/p/io_shm.c index 4f44ab8cf84..3dc8821a997 100644 --- a/librz/io/p/io_shm.c +++ b/librz/io/p/io_shm.c @@ -1,10 +1,12 @@ // SPDX-FileCopyrightText: 2008-2019 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_io.h" -#include "rz_lib.h" +#include +#include #include +#include "rz_io_plugins.h" + #if HAVE_HEADER_LINUX_ASHMEM_H || HAVE_HEADER_SYS_SHM_H || __WINDOWS__ #if HAVE_HEADER_LINUX_ASHMEM_H #include diff --git a/librz/io/p/io_sparse.c b/librz/io/p/io_sparse.c index bc6d6ad063a..deae638eec9 100644 --- a/librz/io/p/io_sparse.c +++ b/librz/io/p/io_sparse.c @@ -1,13 +1,15 @@ // SPDX-FileCopyrightText: 2015-2016 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_io.h" -#include "rz_lib.h" -#include "rz_util.h" +#include +#include +#include #include #include #include +#include "rz_io_plugins.h" + typedef struct { int fd; RzBuffer *buf; diff --git a/librz/io/p/io_srec.c b/librz/io/p/io_srec.c index 8faf57ba576..035a4d7ff34 100644 --- a/librz/io/p/io_srec.c +++ b/librz/io/p/io_srec.c @@ -16,6 +16,8 @@ #include #include +#include "rz_io_plugins.h" + #define SREC_SIZE 64 #define NMAX 100 #define SREC_PATH_PREFIX "srec://" diff --git a/librz/io/p/io_tcp.c b/librz/io/p/io_tcp.c index 5f3366d3eb4..39f97a6a2c6 100644 --- a/librz/io/p/io_tcp.c +++ b/librz/io/p/io_tcp.c @@ -1,13 +1,15 @@ // SPDX-FileCopyrightText: 2016 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_io.h" -#include "rz_lib.h" +#include +#include #include #include #include #include "../io_memory.h" +#include "rz_io_plugins.h" + static bool __check(RzIO *io, const char *pathname, bool many) { return (!strncmp(pathname, "tcp://", 6)); } diff --git a/librz/io/p/io_w32.c b/librz/io/p/io_w32.c index f604832e647..4be5f2f22c0 100644 --- a/librz/io/p/io_w32.c +++ b/librz/io/p/io_w32.c @@ -1,8 +1,10 @@ // SPDX-FileCopyrightText: 2008-2011 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "rz_io.h" -#include "rz_lib.h" +#include +#include + +#include "rz_io_plugins.h" #if __WINDOWS__ #include diff --git a/librz/io/p/io_w32dbg.c b/librz/io/p/io_w32dbg.c index 780e8aed0f4..c476a7e993d 100644 --- a/librz/io/p/io_w32dbg.c +++ b/librz/io/p/io_w32dbg.c @@ -2,6 +2,9 @@ // SPDX-License-Identifier: LGPL-3.0-only #include +#include + +#include "rz_io_plugins.h" #if __WINDOWS__ #include diff --git a/librz/io/p/io_windbg.c b/librz/io/p/io_windbg.c index 83a06993563..0d530f37935 100644 --- a/librz/io/p/io_windbg.c +++ b/librz/io/p/io_windbg.c @@ -3,6 +3,8 @@ #define INITGUID #include +#include "rz_io_plugins.h" + #include typedef HRESULT(__stdcall *DebugCreate_t)( diff --git a/librz/io/p/io_winedbg.c b/librz/io/p/io_winedbg.c index d631e970ff0..9e18fc9c8f0 100644 --- a/librz/io/p/io_winedbg.c +++ b/librz/io/p/io_winedbg.c @@ -8,6 +8,8 @@ #include #include +#include "rz_io_plugins.h" + static RzSocket *gs = NULL; RZ_PACKED(struct winedbg_x86_32 { diff --git a/librz/io/p/io_winkd.c b/librz/io/p/io_winkd.c index ab141715bea..14f507ebfb9 100644 --- a/librz/io/p/io_winkd.c +++ b/librz/io/p/io_winkd.c @@ -23,6 +23,8 @@ #include #include +#include "rz_io_plugins.h" + typedef struct { RzIODesc *fd; } ReadAtCtx; diff --git a/librz/io/p/io_zip.c b/librz/io/p/io_zip.c index 7fe8550edcf..9372ab057bf 100644 --- a/librz/io/p/io_zip.c +++ b/librz/io/p/io_zip.c @@ -8,6 +8,8 @@ #include #include +#include "rz_io_plugins.h" + typedef enum { RZ_IO_PARENT_ZIP = 0x0001, RZ_IO_CHILD_FILE = 0x0002, diff --git a/librz/lang/lang.c b/librz/lang/lang.c index ef4b509f84f..2ea95af3ec4 100644 --- a/librz/lang/lang.c +++ b/librz/lang/lang.c @@ -1,11 +1,11 @@ // SPDX-FileCopyrightText: 2009-2018 pancake // SPDX-License-Identifier: LGPL-3.0-only -#include "config.h" #include #include #include #include +#include "rz_lang_plugins.h" RZ_LIB_VERSION(rz_lang); diff --git a/librz/lang/meson.build b/librz/lang/meson.build index 64da2ea7fff..b692b420b0e 100644 --- a/librz/lang/meson.build +++ b/librz/lang/meson.build @@ -10,8 +10,8 @@ if host_machine.system() != 'windows' endif lang_plugins = { - 'conf_name': 'plugins_lang', - 'base_cname': 'rz_lang_plugin_', + 'base_name': 'rz_lang', + 'base_struct': 'RzLangPlugin', 'list': lang_plugins_list, } 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/rizin.c b/librz/main/rizin.c index cb712befcc2..37bc78b0731 100644 --- a/librz/main/rizin.c +++ b/librz/main/rizin.c @@ -37,10 +37,9 @@ static int rz_main_version_verify(int show) { const char *name; vc callback; } vcs[] = { - { "rz_analysis", rz_analysis_version }, { "rz_lib", rz_lib_version }, { "rz_egg", rz_egg_version }, - { "rz_asm", rz_asm_version }, + { "rz_arch", rz_arch_version }, { "rz_bin", rz_bin_version }, { "rz_cons", rz_cons_version }, { "rz_flag", rz_flag_version }, diff --git a/librz/main/rz-asm.c b/librz/main/rz-asm.c index f14a95efaa7..3892eeea5a5 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/meson.build b/librz/meson.build index 5807171f18e..164d598fd4c 100644 --- a/librz/meson.build +++ b/librz/meson.build @@ -23,9 +23,8 @@ subdir('bin') subdir('config') subdir('parse') subdir('lang') -subdir('asm') subdir('il') -subdir('analysis') +subdir('arch') subdir('sign') subdir('egg') subdir('debug') @@ -33,7 +32,6 @@ subdir('core') subdir('main') -conf_data = configuration_data() foreach module_name, module : modules include_subdirs = ['librz'] if 'include_subdirs_extra' in module @@ -82,21 +80,28 @@ foreach module_name, module : modules # plugins if 'plugins' in module foreach plugin : module['plugins'] - l = [] - foreach p : plugin.get('list') - l += ['&' + plugin.get('base_cname') + p] + plugins_h = configuration_data() + static_plugins = [] + export_plugins = [] + base_name = plugin.get('base_name') + base_struct = plugin.get('base_struct') + foreach plugin_name : plugin.get('list') + plugin_var = base_name + '_plugin_' + plugin_name + static_plugins += ['&' + plugin_var] + export_plugins += ['extern ' + base_struct + ' ' + plugin_var + ';'] endforeach - conf_data.set(plugin.get('conf_name'), ', '.join(l)) + plugins_h.set('plugin_static', ', '.join(static_plugins)) + plugins_h.set('plugin_exports', '\n'.join(export_plugins)) + plugins_h.set('MODULE_NAME', base_name.to_upper()) + configure_file( + input: 'plugins.h.in', + output: base_name + '_plugins.h', + configuration: plugins_h + ) endforeach endif endforeach -config_h = configure_file( - input: 'config.h.in', - output: 'config.h', - configuration: conf_data -) - if not is_static_libs_only conf = configuration_data() conf.set('RZ_VERSION', rizin_version) diff --git a/librz/parse/filter.c b/librz/parse/filter.c index e21149aec82..6df5224bd59 100644 --- a/librz/parse/filter.c +++ b/librz/parse/filter.c @@ -9,7 +9,6 @@ #include #include -#include #define isx86separator(x) ( \ (x) == ' ' || (x) == '\t' || (x) == '\n' || (x) == '\r' || (x) == ' ' || \ diff --git a/librz/parse/meson.build b/librz/parse/meson.build index 6ac4b5bd350..9b102d3b606 100644 --- a/librz/parse/meson.build +++ b/librz/parse/meson.build @@ -4,28 +4,16 @@ parse_plugins_list = [ 'att2intel', 'avr_pseudo', 'chip8_pseudo', - 'tms320_pseudo', 'dalvik_pseudo', 'm68k_pseudo', 'mips_pseudo', 'ppc_pseudo', + 'sh_pseudo', + 'tms320_pseudo', 'v850_pseudo', 'wasm_pseudo', 'x86_pseudo', ] -if get_option('use_gpl') - parse_plugins_list += [ - 'sh_pseudo', - 'riscv_pseudo', - 'z80_pseudo' - ] -endif - -parse_plugins = { - 'conf_name': 'plugins_parse', - 'base_cname': 'rz_parse_plugin_', - 'list': parse_plugins_list, -} rz_parse_sources = [ 'filter.c', @@ -44,10 +32,26 @@ rz_parse_sources = [ 'p/parse_v850_pseudo.c', 'p/parse_wasm_pseudo.c', 'p/parse_x86_pseudo.c', - 'p/parse_riscv_pseudo.c', - 'p/parse_z80_pseudo.c' ] +if get_option('use_gpl') + parse_plugins_list += [ + 'riscv_pseudo', + 'z80_pseudo', + ] + + rz_parse_sources += [ + 'p/parse_riscv_pseudo.c', + 'p/parse_z80_pseudo.c', + ] +endif + +parse_plugins = { + 'base_name': 'rz_parse', + 'base_struct': 'RzParsePlugin', + 'list': parse_plugins_list, +} + rz_parse = library('rz_parse', rz_parse_sources, include_directories: platform_inc, dependencies: [ diff --git a/librz/parse/parse.c b/librz/parse/parse.c index b33d80ab70c..892e154530f 100644 --- a/librz/parse/parse.c +++ b/librz/parse/parse.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include "rz_parse_plugins.h" RZ_LIB_VERSION(rz_parse); diff --git a/librz/plugins.h.in b/librz/plugins.h.in new file mode 100644 index 00000000000..540341f1e93 --- /dev/null +++ b/librz/plugins.h.in @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: 2024 RizinOrg +// SPDX-License-Identifier: LGPL-3.0-only + +// clang-format off +#ifndef @MODULE_NAME@_PLUGINS_BUILD_H +#define @MODULE_NAME@_PLUGINS_BUILD_H + +#define @MODULE_NAME@_STATIC_PLUGINS @plugin_static@ + +@plugin_exports@ +// clang-format on + +#endif \ No newline at end of file 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 2ba7fcbd3b4..1197487a0bb 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('rizin', 'c', version: 'v0.8.0', license: 'LGPL3', - meson_version: '>=0.55.0', + meson_version: '>=0.57.0', default_options: [ 'buildtype=debugoptimized', 'b_vscrt=from_buildtype', @@ -686,8 +686,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', @@ -817,8 +816,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'), @@ -832,4 +830,3 @@ summary({ 'Parse Plugins': parse_plugins.get('list'), 'Demangler Plugins': demangler_plugins.get('list'), }, section: 'Plugins', list_sep: ', ') - diff --git a/sys/clang-format.py b/sys/clang-format.py index 509c1792887..144f27abf13 100755 --- a/sys/clang-format.py +++ b/sys/clang-format.py @@ -25,12 +25,8 @@ skiplist = [ "/gnu/", - "librz/asm/arch/vax/", - "librz/asm/arch/riscv/", - "librz/asm/arch/sh/gnu/", + "librz/arch/isa_gnu/", "librz/asm/arch/i8080/", - "librz/asm/arch/z80/", - "librz/asm/arch/avr/", "librz/asm/arch/arm/aarch64/", "librz/hash/xxhash/", "librz/bin/mangling/cxx/", @@ -38,7 +34,6 @@ "librz/util/bdiff.c", "librz/asm/arch/tms320/c55x/table.h", "librz/include/sflib/", - "librz/asm/arch/include/opcode/", ] patterns = ["*.c", "*.cpp", "*.h", "*.hpp", "*.inc"] diff --git a/test/db/analysis/tms320.c64x_32 b/test/db/analysis/tms320.c64x_32 index f1d3b00b06f..3ec80b1e749 100644 --- a/test/db/analysis/tms320.c64x_32 +++ b/test/db/analysis/tms320.c64x_32 @@ -211,8 +211,8 @@ RUN NAME=arp TMS320 FILE== CMDS=< [0x00000000]>  [0x00000000]> - [0x00000000]> [0x00000000]>   [0x00000000]> q [0x00000000]> q [0x00000000]> q -EOF -RUN - -NAME=prompt settings -FILE== -CMDS=!rizin -e cfg.fortunes=0 -e scr.color=0 -c "< \ne scr.prompt.file=true\ne scr.prompt.flag=true\nsd 1\ne scr.prompt.flag.only=true\ne scr.prompt.sect=true\nq\n" ./bins/elf/hello_world -EXPECT=< [0x000006a0]>  [0x000006a0]> - [0x000006a0]> [0x000006a0]>   [0x000006a0]> e [0x000006a0]> e  [0x000006a0]> e [0x000006a0]> e   [0x000006a0]> e s [0x000006a0]> e s  [0x000006a0]> e sc [0x000006a0]> e sc  [0x000006a0]> e scr [0x000006a0]> e scr  [0x000006a0]> e scr. [0x000006a0]> e scr.  [0x000006a0]> e scr.p [0x000006a0]> e scr.p  [0x000006a0]> e scr.pr [0x000006a0]> e scr.pr  [0x000006a0]> e scr.pro [0x000006a0]> e scr.pro  [0x000006a0]> e scr.prom [0x000006a0]> e scr.prom  [0x000006a0]> e scr.promp [0x000006a0]> e scr.promp  [0x000006a0]> e scr.prompt [0x000006a0]> e scr.prompt  [0x000006a0]> e scr.prompt. [0x000006a0]> e scr.prompt.  [0x000006a0]> e scr.prompt.f [0x000006a0]> e scr.prompt.f  [0x000006a0]> e scr.prompt.fi [0x000006a0]> e scr.prompt.fi  [0x000006a0]> e scr.prompt.fil [0x000006a0]> e scr.prompt.fil  [0x000006a0]> e scr.prompt.file [0x000006a0]> e scr.prompt.file  [0x000006a0]> e scr.prompt.file= [0x000006a0]> e scr.prompt.file=  [0x000006a0]> e scr.prompt.file=t [0x000006a0]> e scr.prompt.file=t  [0x000006a0]> e scr.prompt.file=tr [0x000006a0]> e scr.prompt.file=tr  [0x000006a0]> e scr.prompt.file=tru [0x000006a0]> e scr.prompt.file=tru  [0x000006a0]> e scr.prompt.file=true [0x000006a0]> e scr.prompt.file=true [0x000006a0]> e scr.prompt.file=true - [hello_world:0x000006a0]> [hello_world:0x000006a0]>   [hello_world:0x000006a0]> e [hello_world:0x000006a0]> e  [hello_world:0x000006a0]> e [hello_world:0x000006a0]> e   [hello_world:0x000006a0]> e s [hello_world:0x000006a0]> e s  [hello_world:0x000006a0]> e sc [hello_world:0x000006a0]> e sc  [hello_world:0x000006a0]> e scr [hello_world:0x000006a0]> e scr  [hello_world:0x000006a0]> e scr. [hello_world:0x000006a0]> e scr.  [hello_world:0x000006a0]> e scr.p [hello_world:0x000006a0]> e scr.p  [hello_world:0x000006a0]> e scr.pr [hello_world:0x000006a0]> e scr.pr  [hello_world:0x000006a0]> e scr.pro [hello_world:0x000006a0]> e scr.pro  [hello_world:0x000006a0]> e scr.prom [hello_world:0x000006a0]> e scr.prom  [hello_world:0x000006a0]> e scr.promp [hello_world:0x000006a0]> e scr.promp  [hello_world:0x000006a0]> e scr.prompt [hello_world:0x000006a0]> e scr.prompt  [hello_world:0x000006a0]> e scr.prompt. [hello_world:0x000006a0]> e scr.prompt.  [hello_world:0x000006a0]> e scr.prompt.f [hello_world:0x000006a0]> e scr.prompt.f  [hello_world:0x000006a0]> e scr.prompt.fl [hello_world:0x000006a0]> e scr.prompt.fl  [hello_world:0x000006a0]> e scr.prompt.fla [hello_world:0x000006a0]> e scr.prompt.fla  [hello_world:0x000006a0]> e scr.prompt.flag [hello_world:0x000006a0]> e scr.prompt.flag  [hello_world:0x000006a0]> e scr.prompt.flag= [hello_world:0x000006a0]> e scr.prompt.flag=  [hello_world:0x000006a0]> e scr.prompt.flag=t [hello_world:0x000006a0]> e scr.prompt.flag=t  [hello_world:0x000006a0]> e scr.prompt.flag=tr [hello_world:0x000006a0]> e scr.prompt.flag=tr  [hello_world:0x000006a0]> e scr.prompt.flag=tru [hello_world:0x000006a0]> e scr.prompt.flag=tru  [hello_world:0x000006a0]> e scr.prompt.flag=true [hello_world:0x000006a0]> e scr.prompt.flag=true [hello_world:0x000006a0]> e scr.prompt.flag=true - [hello_world:entry0:0x000006a0]> [hello_world:entry0:0x000006a0]>   [hello_world:entry0:0x000006a0]> s [hello_world:entry0:0x000006a0]> s  [hello_world:entry0:0x000006a0]> sd [hello_world:entry0:0x000006a0]> sd  [hello_world:entry0:0x000006a0]> sd [hello_world:entry0:0x000006a0]> sd   [hello_world:entry0:0x000006a0]> sd 1 [hello_world:entry0:0x000006a0]> sd 1 [hello_world:entry0:0x000006a0]> sd 1 - [hello_world:entry0 + 1:0x000006a1]> [hello_world:entry0 + 1:0x000006a1]>   [hello_world:entry0 + 1:0x000006a1]> e [hello_world:entry0 + 1:0x000006a1]> e  [hello_world:entry0 + 1:0x000006a1]> e [hello_world:entry0 + 1:0x000006a1]> e   [hello_world:entry0 + 1:0x000006a1]> e s [hello_world:entry0 + 1:0x000006a1]> e s  [hello_world:entry0 + 1:0x000006a1]> e sc [hello_world:entry0 + 1:0x000006a1]> e sc  [hello_world:entry0 + 1:0x000006a1]> e scr [hello_world:entry0 + 1:0x000006a1]> e scr  [hello_world:entry0 + 1:0x000006a1]> e scr. [hello_world:entry0 + 1:0x000006a1]> e scr.  [hello_world:entry0 + 1:0x000006a1]> e scr.p [hello_world:entry0 + 1:0x000006a1]> e scr.p  [hello_world:entry0 + 1:0x000006a1]> e scr.pr [hello_world:entry0 + 1:0x000006a1]> e scr.pr  [hello_world:entry0 + 1:0x000006a1]> e scr.pro [hello_world:entry0 + 1:0x000006a1]> e scr.pro  [hello_world:entry0 + 1:0x000006a1]> e scr.prom [hello_world:entry0 + 1:0x000006a1]> e scr.prom  [hello_world:entry0 + 1:0x000006a1]> e scr.promp [hello_world:entry0 + 1:0x000006a1]> e scr.promp  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt [hello_world:entry0 + 1:0x000006a1]> e scr.prompt  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt. [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.f [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.f  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.fl [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.fl  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.fla [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.fla  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag. [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.o [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.o  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.on [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.on  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.onl [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.onl  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only= [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=t [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=t  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=tr [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=tr  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=tru [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=tru  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=true [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=true [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=true - [hello_world:entry0 + 1]> [hello_world:entry0 + 1]>   [hello_world:entry0 + 1]> e [hello_world:entry0 + 1]> e  [hello_world:entry0 + 1]> e [hello_world:entry0 + 1]> e   [hello_world:entry0 + 1]> e s [hello_world:entry0 + 1]> e s  [hello_world:entry0 + 1]> e sc [hello_world:entry0 + 1]> e sc  [hello_world:entry0 + 1]> e scr [hello_world:entry0 + 1]> e scr  [hello_world:entry0 + 1]> e scr. [hello_world:entry0 + 1]> e scr.  [hello_world:entry0 + 1]> e scr.p [hello_world:entry0 + 1]> e scr.p  [hello_world:entry0 + 1]> e scr.pr [hello_world:entry0 + 1]> e scr.pr  [hello_world:entry0 + 1]> e scr.pro [hello_world:entry0 + 1]> e scr.pro  [hello_world:entry0 + 1]> e scr.prom [hello_world:entry0 + 1]> e scr.prom  [hello_world:entry0 + 1]> e scr.promp [hello_world:entry0 + 1]> e scr.promp  [hello_world:entry0 + 1]> e scr.prompt [hello_world:entry0 + 1]> e scr.prompt  [hello_world:entry0 + 1]> e scr.prompt. [hello_world:entry0 + 1]> e scr.prompt.  [hello_world:entry0 + 1]> e scr.prompt.s [hello_world:entry0 + 1]> e scr.prompt.s  [hello_world:entry0 + 1]> e scr.prompt.se [hello_world:entry0 + 1]> e scr.prompt.se  [hello_world:entry0 + 1]> e scr.prompt.sec [hello_world:entry0 + 1]> e scr.prompt.sec  [hello_world:entry0 + 1]> e scr.prompt.sect [hello_world:entry0 + 1]> e scr.prompt.sect  [hello_world:entry0 + 1]> e scr.prompt.sect= [hello_world:entry0 + 1]> e scr.prompt.sect=  [hello_world:entry0 + 1]> e scr.prompt.sect=t [hello_world:entry0 + 1]> e scr.prompt.sect=t  [hello_world:entry0 + 1]> e scr.prompt.sect=tr [hello_world:entry0 + 1]> e scr.prompt.sect=tr  [hello_world:entry0 + 1]> e scr.prompt.sect=tru [hello_world:entry0 + 1]> e scr.prompt.sect=tru  [hello_world:entry0 + 1]> e scr.prompt.sect=true [hello_world:entry0 + 1]> e scr.prompt.sect=true [hello_world:entry0 + 1]> e scr.prompt.sect=true - [hello_world:.text:entry0 + 1]> [hello_world:.text:entry0 + 1]>   [hello_world:.text:entry0 + 1]> q [hello_world:.text:entry0 + 1]> q [hello_world:.text:entry0 + 1]> q -EOF -RUN - -NAME=color prompt -FILE== -CMDS=!rizin -e cfg.fortunes=0 -e scr.color=1 -N -c "< \nq\n" = -EXPECT=< [0x00000000]>  [0x00000000]> - [0x00000000]> [0x00000000]>   [0x00000000]> q [0x00000000]> q [0x00000000]> q -EOF -RUN - -NAME=read from stdin -FILE=-- -CMDS=echo \r\n | rizin -N -e scr.color=0 -qc "px 16" - -EXPECT=< [0x00000000]>  [0x00000000]>  [0x00000000]> [0x00000000]>   [0x00000000]> q [0x00000000]> q [0x00000000]> q EOF RUN NAME=prompt settings FILE== CMDS=!rizin -e cfg.fortunes=0 -e scr.color=0 -c "< \ne scr.prompt.file=true\ne scr.prompt.flag=true\nsd 1\ne scr.prompt.flag.only=true\ne scr.prompt.sect=true\nq\n" ./bins/elf/hello_world EXPECT=< [0x000006a0]>  [0x000006a0]>  [0x000006a0]> [0x000006a0]>   [0x000006a0]> e [0x000006a0]> e  [0x000006a0]> e [0x000006a0]> e   [0x000006a0]> e s [0x000006a0]> e s  [0x000006a0]> e sc [0x000006a0]> e sc  [0x000006a0]> e scr [0x000006a0]> e scr  [0x000006a0]> e scr. [0x000006a0]> e scr.  [0x000006a0]> e scr.p [0x000006a0]> e scr.p  [0x000006a0]> e scr.pr [0x000006a0]> e scr.pr  [0x000006a0]> e scr.pro [0x000006a0]> e scr.pro  [0x000006a0]> e scr.prom [0x000006a0]> e scr.prom  [0x000006a0]> e scr.promp [0x000006a0]> e scr.promp  [0x000006a0]> e scr.prompt [0x000006a0]> e scr.prompt  [0x000006a0]> e scr.prompt. [0x000006a0]> e scr.prompt.  [0x000006a0]> e scr.prompt.f [0x000006a0]> e scr.prompt.f  [0x000006a0]> e scr.prompt.fi [0x000006a0]> e scr.prompt.fi  [0x000006a0]> e scr.prompt.fil [0x000006a0]> e scr.prompt.fil  [0x000006a0]> e scr.prompt.file [0x000006a0]> e scr.prompt.file  [0x000006a0]> e scr.prompt.file= [0x000006a0]> e scr.prompt.file=  [0x000006a0]> e scr.prompt.file=t [0x000006a0]> e scr.prompt.file=t  [0x000006a0]> e scr.prompt.file=tr [0x000006a0]> e scr.prompt.file=tr  [0x000006a0]> e scr.prompt.file=tru [0x000006a0]> e scr.prompt.file=tru  [0x000006a0]> e scr.prompt.file=true [0x000006a0]> e scr.prompt.file=true [0x000006a0]> e scr.prompt.file=true  [hello_world:0x000006a0]> [hello_world:0x000006a0]>   [hello_world:0x000006a0]> e [hello_world:0x000006a0]> e  [hello_world:0x000006a0]> e [hello_world:0x000006a0]> e   [hello_world:0x000006a0]> e s [hello_world:0x000006a0]> e s  [hello_world:0x000006a0]> e sc [hello_world:0x000006a0]> e sc  [hello_world:0x000006a0]> e scr [hello_world:0x000006a0]> e scr  [hello_world:0x000006a0]> e scr. [hello_world:0x000006a0]> e scr.  [hello_world:0x000006a0]> e scr.p [hello_world:0x000006a0]> e scr.p  [hello_world:0x000006a0]> e scr.pr [hello_world:0x000006a0]> e scr.pr  [hello_world:0x000006a0]> e scr.pro [hello_world:0x000006a0]> e scr.pro  [hello_world:0x000006a0]> e scr.prom [hello_world:0x000006a0]> e scr.prom  [hello_world:0x000006a0]> e scr.promp [hello_world:0x000006a0]> e scr.promp  [hello_world:0x000006a0]> e scr.prompt [hello_world:0x000006a0]> e scr.prompt  [hello_world:0x000006a0]> e scr.prompt. [hello_world:0x000006a0]> e scr.prompt.  [hello_world:0x000006a0]> e scr.prompt.f [hello_world:0x000006a0]> e scr.prompt.f  [hello_world:0x000006a0]> e scr.prompt.fl [hello_world:0x000006a0]> e scr.prompt.fl  [hello_world:0x000006a0]> e scr.prompt.fla [hello_world:0x000006a0]> e scr.prompt.fla  [hello_world:0x000006a0]> e scr.prompt.flag [hello_world:0x000006a0]> e scr.prompt.flag  [hello_world:0x000006a0]> e scr.prompt.flag= [hello_world:0x000006a0]> e scr.prompt.flag=  [hello_world:0x000006a0]> e scr.prompt.flag=t [hello_world:0x000006a0]> e scr.prompt.flag=t  [hello_world:0x000006a0]> e scr.prompt.flag=tr [hello_world:0x000006a0]> e scr.prompt.flag=tr  [hello_world:0x000006a0]> e scr.prompt.flag=tru [hello_world:0x000006a0]> e scr.prompt.flag=tru  [hello_world:0x000006a0]> e scr.prompt.flag=true [hello_world:0x000006a0]> e scr.prompt.flag=true [hello_world:0x000006a0]> e scr.prompt.flag=true  [hello_world:entry0:0x000006a0]> [hello_world:entry0:0x000006a0]>   [hello_world:entry0:0x000006a0]> s [hello_world:entry0:0x000006a0]> s  [hello_world:entry0:0x000006a0]> sd [hello_world:entry0:0x000006a0]> sd  [hello_world:entry0:0x000006a0]> sd [hello_world:entry0:0x000006a0]> sd   [hello_world:entry0:0x000006a0]> sd 1 [hello_world:entry0:0x000006a0]> sd 1 [hello_world:entry0:0x000006a0]> sd 1  [hello_world:entry0 + 1:0x000006a1]> [hello_world:entry0 + 1:0x000006a1]>   [hello_world:entry0 + 1:0x000006a1]> e [hello_world:entry0 + 1:0x000006a1]> e  [hello_world:entry0 + 1:0x000006a1]> e [hello_world:entry0 + 1:0x000006a1]> e   [hello_world:entry0 + 1:0x000006a1]> e s [hello_world:entry0 + 1:0x000006a1]> e s  [hello_world:entry0 + 1:0x000006a1]> e sc [hello_world:entry0 + 1:0x000006a1]> e sc  [hello_world:entry0 + 1:0x000006a1]> e scr [hello_world:entry0 + 1:0x000006a1]> e scr  [hello_world:entry0 + 1:0x000006a1]> e scr. [hello_world:entry0 + 1:0x000006a1]> e scr.  [hello_world:entry0 + 1:0x000006a1]> e scr.p [hello_world:entry0 + 1:0x000006a1]> e scr.p  [hello_world:entry0 + 1:0x000006a1]> e scr.pr [hello_world:entry0 + 1:0x000006a1]> e scr.pr  [hello_world:entry0 + 1:0x000006a1]> e scr.pro [hello_world:entry0 + 1:0x000006a1]> e scr.pro  [hello_world:entry0 + 1:0x000006a1]> e scr.prom [hello_world:entry0 + 1:0x000006a1]> e scr.prom  [hello_world:entry0 + 1:0x000006a1]> e scr.promp [hello_world:entry0 + 1:0x000006a1]> e scr.promp  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt [hello_world:entry0 + 1:0x000006a1]> e scr.prompt  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt. [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.f [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.f  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.fl [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.fl  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.fla [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.fla  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag. [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.o [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.o  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.on [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.on  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.onl [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.onl  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only= [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=t [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=t  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=tr [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=tr  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=tru [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=tru  [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=true [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=true [hello_world:entry0 + 1:0x000006a1]> e scr.prompt.flag.only=true  [hello_world:entry0 + 1]> [hello_world:entry0 + 1]>   [hello_world:entry0 + 1]> e [hello_world:entry0 + 1]> e  [hello_world:entry0 + 1]> e [hello_world:entry0 + 1]> e   [hello_world:entry0 + 1]> e s [hello_world:entry0 + 1]> e s  [hello_world:entry0 + 1]> e sc [hello_world:entry0 + 1]> e sc  [hello_world:entry0 + 1]> e scr [hello_world:entry0 + 1]> e scr  [hello_world:entry0 + 1]> e scr. [hello_world:entry0 + 1]> e scr.  [hello_world:entry0 + 1]> e scr.p [hello_world:entry0 + 1]> e scr.p  [hello_world:entry0 + 1]> e scr.pr [hello_world:entry0 + 1]> e scr.pr  [hello_world:entry0 + 1]> e scr.pro [hello_world:entry0 + 1]> e scr.pro  [hello_world:entry0 + 1]> e scr.prom [hello_world:entry0 + 1]> e scr.prom  [hello_world:entry0 + 1]> e scr.promp [hello_world:entry0 + 1]> e scr.promp  [hello_world:entry0 + 1]> e scr.prompt [hello_world:entry0 + 1]> e scr.prompt  [hello_world:entry0 + 1]> e scr.prompt. [hello_world:entry0 + 1]> e scr.prompt.  [hello_world:entry0 + 1]> e scr.prompt.s [hello_world:entry0 + 1]> e scr.prompt.s  [hello_world:entry0 + 1]> e scr.prompt.se [hello_world:entry0 + 1]> e scr.prompt.se  [hello_world:entry0 + 1]> e scr.prompt.sec [hello_world:entry0 + 1]> e scr.prompt.sec  [hello_world:entry0 + 1]> e scr.prompt.sect [hello_world:entry0 + 1]> e scr.prompt.sect  [hello_world:entry0 + 1]> e scr.prompt.sect= [hello_world:entry0 + 1]> e scr.prompt.sect=  [hello_world:entry0 + 1]> e scr.prompt.sect=t [hello_world:entry0 + 1]> e scr.prompt.sect=t  [hello_world:entry0 + 1]> e scr.prompt.sect=tr [hello_world:entry0 + 1]> e scr.prompt.sect=tr  [hello_world:entry0 + 1]> e scr.prompt.sect=tru [hello_world:entry0 + 1]> e scr.prompt.sect=tru  [hello_world:entry0 + 1]> e scr.prompt.sect=true [hello_world:entry0 + 1]> e scr.prompt.sect=true [hello_world:entry0 + 1]> e scr.prompt.sect=true  [hello_world:.text:entry0 + 1]> [hello_world:.text:entry0 + 1]>   [hello_world:.text:entry0 + 1]> q [hello_world:.text:entry0 + 1]> q [hello_world:.text:entry0 + 1]> q EOF RUN NAME=color prompt FILE== CMDS=!rizin -e cfg.fortunes=0 -e scr.color=1 -N -c "< \nq\n" = EXPECT=< [0x00000000]>  [0x00000000]>  [0x00000000]> [0x00000000]>   [0x00000000]> q [0x00000000]> q [0x00000000]> q EOF RUN NAME=read from stdin FILE=-- CMDS=echo \r\n | rizin -N -e scr.color=0 -qc "px 16" - EXPECT=< #include #include -#include #include #include #include