diff --git a/librz/analysis/op.c b/librz/analysis/op.c index 35122dee4f4..d08074a710c 100644 --- a/librz/analysis/op.c +++ b/librz/analysis/op.c @@ -290,7 +290,7 @@ static struct optype { /** * Return the op type corresponding the given name * \param name string, name of the optype - * \return type int, id of the op type (one of \link _RzAnalysisOpType \endlink) + * \return type int, id of the op type (one of \link RzAnalysisOpType \endlink) */ RZ_API int rz_analysis_optype_from_string(RZ_NONNULL const char *name) { rz_return_val_if_fail(name, -1); @@ -305,7 +305,7 @@ RZ_API int rz_analysis_optype_from_string(RZ_NONNULL const char *name) { /** * Return the name of the given op type - * \param type int, id of the op type (one of \link _RzAnalysisOpType \endlink) + * \param type int, id of the op type (one of \link RzAnalysisOpType \endlink) * \return name string, string, name of the optype */ RZ_API const char *rz_analysis_optype_to_string(int type) { diff --git a/librz/asm/arch/8051/8051_ops.h b/librz/asm/arch/8051/8051_ops.h index 619af082a03..ec61f571d05 100644 --- a/librz/asm/arch/8051/8051_ops.h +++ b/librz/asm/arch/8051/8051_ops.h @@ -101,7 +101,7 @@ typedef struct { ut8 op; int cycles; op8051 instr; // instruction - _RzAnalysisOpType type; + RzAnalysisOpType type; char *string; // disassembly output size_t len; argmask8051 mask; // bits masked to determine opcode diff --git a/librz/asm/arch/hexagon/hexagon_disas.c b/librz/asm/arch/hexagon/hexagon_disas.c index d72062f7000..69915dfd7e6 100644 --- a/librz/asm/arch/hexagon/hexagon_disas.c +++ b/librz/asm/arch/hexagon/hexagon_disas.c @@ -91,7 +91,7 @@ typedef struct { ut8 cond; // RzTypeCond ut8 flags; // HexInsnTemplateFlag const char *syntax; - _RzAnalysisOpType type; + RzAnalysisOpType type; } HexInsnTemplate; static const HexInsnTemplate templates_sub_A[] = { diff --git a/librz/asm/arch/or1k/or1k_disas.h b/librz/asm/arch/or1k/or1k_disas.h index 35e2b701281..53677693964 100644 --- a/librz/asm/arch/or1k/or1k_disas.h +++ b/librz/asm/arch/or1k/or1k_disas.h @@ -107,14 +107,14 @@ typedef struct { char *name; int type; int opcode_mask; - int insn_type; /**< One of \link _RzAnalysisOpType \endlink */ + int insn_type; /**< One of \link RzAnalysisOpType \endlink */ } insn_extra_t; typedef struct { ut32 opcode; char *name; int type; - int insn_type; /**< One of \link _RzAnalysisOpType \endlink */ + int insn_type; /**< One of \link RzAnalysisOpType \endlink */ insn_extra_t *extra; } insn_t; diff --git a/librz/include/rz_analysis.h b/librz/include/rz_analysis.h index 3a71b62c55a..1a869e07328 100644 --- a/librz/include/rz_analysis.h +++ b/librz/include/rz_analysis.h @@ -25,6 +25,7 @@ #include #include #include +#include #define esilprintf(op, fmt, ...) rz_strbuf_setf(&op->esil, fmt, ##__VA_ARGS__) @@ -254,89 +255,6 @@ typedef enum { /* TODO: add segment override typemods? */ } RzAnalysisOpPrefix; -// XXX: this definition is plain wrong. use enum or empower bits -#define RZ_ANALYSIS_OP_TYPE_MASK 0x8000ffff -#define RZ_ANALYSIS_OP_HINT_MASK 0xf0000000 -typedef enum { - RZ_ANALYSIS_OP_TYPE_COND = 0x80000000, // TODO must be moved to prefix? - // TODO: MOVE TO PREFIX .. it is used by analysis_java.. must be updated - RZ_ANALYSIS_OP_TYPE_REP = 0x40000000, /* repeats next instruction N times */ - RZ_ANALYSIS_OP_TYPE_MEM = 0x20000000, // TODO must be moved to prefix? - RZ_ANALYSIS_OP_TYPE_REG = 0x10000000, // operand is a register - RZ_ANALYSIS_OP_TYPE_IND = 0x08000000, // operand is indirect - RZ_ANALYSIS_OP_TYPE_SIMD = 0x04000000, // SIMD - RZ_ANALYSIS_OP_TYPE_NULL = 0, - RZ_ANALYSIS_OP_TYPE_JMP = 1, /* mandatory jump */ - RZ_ANALYSIS_OP_TYPE_UJMP = 2, /* unknown jump (register or so) */ - RZ_ANALYSIS_OP_TYPE_RJMP = RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UJMP, - RZ_ANALYSIS_OP_TYPE_IJMP = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_UJMP, - RZ_ANALYSIS_OP_TYPE_IRJMP = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UJMP, - RZ_ANALYSIS_OP_TYPE_CJMP = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_JMP, /* conditional jump */ - RZ_ANALYSIS_OP_TYPE_RCJMP = RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_CJMP, /* conditional jump register */ - RZ_ANALYSIS_OP_TYPE_MJMP = RZ_ANALYSIS_OP_TYPE_MEM | RZ_ANALYSIS_OP_TYPE_JMP, /* memory jump */ - RZ_ANALYSIS_OP_TYPE_MCJMP = RZ_ANALYSIS_OP_TYPE_MEM | RZ_ANALYSIS_OP_TYPE_CJMP, /* memory conditional jump */ - RZ_ANALYSIS_OP_TYPE_UCJMP = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_UJMP, /* conditional unknown jump */ - RZ_ANALYSIS_OP_TYPE_CALL = 3, /* call to subroutine (branch+link) */ - RZ_ANALYSIS_OP_TYPE_UCALL = 4, /* unknown call (register or so) */ - RZ_ANALYSIS_OP_TYPE_RCALL = RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UCALL, - RZ_ANALYSIS_OP_TYPE_ICALL = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_UCALL, - RZ_ANALYSIS_OP_TYPE_IRCALL = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UCALL, - RZ_ANALYSIS_OP_TYPE_CCALL = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_CALL, /* conditional call to subroutine */ - RZ_ANALYSIS_OP_TYPE_UCCALL = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_UCALL, /* conditional unknown call */ - RZ_ANALYSIS_OP_TYPE_RET = 5, /* returns from subroutine */ - RZ_ANALYSIS_OP_TYPE_CRET = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_RET, /* conditional return from subroutine */ - RZ_ANALYSIS_OP_TYPE_ILL = 6, /* illegal instruction // trap */ - RZ_ANALYSIS_OP_TYPE_UNK = 7, /* unknown opcode type */ - RZ_ANALYSIS_OP_TYPE_NOP = 8, /* does nothing */ - RZ_ANALYSIS_OP_TYPE_MOV = 9, /* register move */ - RZ_ANALYSIS_OP_TYPE_CMOV = 9 | RZ_ANALYSIS_OP_TYPE_COND, /* conditional move */ - RZ_ANALYSIS_OP_TYPE_TRAP = 10, /* it's a trap! */ - RZ_ANALYSIS_OP_TYPE_SWI = 11, /* syscall, software interrupt */ - RZ_ANALYSIS_OP_TYPE_CSWI = 11 | RZ_ANALYSIS_OP_TYPE_COND, /* syscall, software interrupt */ - RZ_ANALYSIS_OP_TYPE_UPUSH = 12, /* unknown push of data into stack */ - RZ_ANALYSIS_OP_TYPE_RPUSH = RZ_ANALYSIS_OP_TYPE_UPUSH | RZ_ANALYSIS_OP_TYPE_REG, /* push register */ - RZ_ANALYSIS_OP_TYPE_PUSH = 13, /* push value into stack */ - RZ_ANALYSIS_OP_TYPE_POP = 14, /* pop value from stack to register */ - RZ_ANALYSIS_OP_TYPE_CMP = 15, /* compare something */ - RZ_ANALYSIS_OP_TYPE_ACMP = 16, /* compare via and */ - RZ_ANALYSIS_OP_TYPE_ADD = 17, - RZ_ANALYSIS_OP_TYPE_SUB = 18, - RZ_ANALYSIS_OP_TYPE_IO = 19, - RZ_ANALYSIS_OP_TYPE_MUL = 20, - RZ_ANALYSIS_OP_TYPE_DIV = 21, - RZ_ANALYSIS_OP_TYPE_SHR = 22, - RZ_ANALYSIS_OP_TYPE_SHL = 23, - RZ_ANALYSIS_OP_TYPE_SAL = 24, - RZ_ANALYSIS_OP_TYPE_SAR = 25, - RZ_ANALYSIS_OP_TYPE_OR = 26, - RZ_ANALYSIS_OP_TYPE_AND = 27, - RZ_ANALYSIS_OP_TYPE_XOR = 28, - RZ_ANALYSIS_OP_TYPE_NOR = 29, - RZ_ANALYSIS_OP_TYPE_NOT = 30, - RZ_ANALYSIS_OP_TYPE_STORE = 31, /* store from register to memory */ - RZ_ANALYSIS_OP_TYPE_LOAD = 32, /* load from memory to register */ - RZ_ANALYSIS_OP_TYPE_LEA = 33, /* TODO add ulea */ - RZ_ANALYSIS_OP_TYPE_LEAVE = 34, - RZ_ANALYSIS_OP_TYPE_ROR = 35, - RZ_ANALYSIS_OP_TYPE_ROL = 36, - RZ_ANALYSIS_OP_TYPE_XCHG = 37, - RZ_ANALYSIS_OP_TYPE_MOD = 38, - RZ_ANALYSIS_OP_TYPE_SWITCH = 39, - RZ_ANALYSIS_OP_TYPE_CASE = 40, - RZ_ANALYSIS_OP_TYPE_LENGTH = 41, - RZ_ANALYSIS_OP_TYPE_CAST = 42, - RZ_ANALYSIS_OP_TYPE_NEW = 43, - RZ_ANALYSIS_OP_TYPE_ABS = 44, - RZ_ANALYSIS_OP_TYPE_CPL = 45, /* complement */ - RZ_ANALYSIS_OP_TYPE_CRYPTO = 46, - RZ_ANALYSIS_OP_TYPE_SYNC = 47, -// RZ_ANALYSIS_OP_TYPE_DEBUG = 43, // monitor/trace/breakpoint -#if 0 - RZ_ANALYSIS_OP_TYPE_PRIV = 40, /* privileged instruction */ - RZ_ANALYSIS_OP_TYPE_FPU = 41, /* floating point stuff */ -#endif -} _RzAnalysisOpType; - typedef enum { RZ_ANALYSIS_OP_MASK_BASIC = 0, // Just fills basic op info , it's fast RZ_ANALYSIS_OP_MASK_ESIL = (1 << 0), // It fills RzAnalysisop->esil info diff --git a/librz/include/rz_analysis_optype.h b/librz/include/rz_analysis_optype.h new file mode 100644 index 00000000000..d87eb1eddc2 --- /dev/null +++ b/librz/include/rz_analysis_optype.h @@ -0,0 +1,88 @@ +#ifndef RZ_ANALYSIS_OPTYPE_H +#define RZ_ANALYSIS_OPTYPE_H + +// XXX: this definition is plain wrong. use enum or empower bits +#define RZ_ANALYSIS_OP_TYPE_MASK 0x8000ffff +#define RZ_ANALYSIS_OP_HINT_MASK 0xf0000000 + +typedef enum { + RZ_ANALYSIS_OP_TYPE_COND = 0x80000000, // TODO must be moved to prefix? + // TODO: MOVE TO PREFIX .. it is used by analysis_java.. must be updated + RZ_ANALYSIS_OP_TYPE_REP = 0x40000000, /* repeats next instruction N times */ + RZ_ANALYSIS_OP_TYPE_MEM = 0x20000000, // TODO must be moved to prefix? + RZ_ANALYSIS_OP_TYPE_REG = 0x10000000, // operand is a register + RZ_ANALYSIS_OP_TYPE_IND = 0x08000000, // operand is indirect + RZ_ANALYSIS_OP_TYPE_SIMD = 0x04000000, // SIMD + RZ_ANALYSIS_OP_TYPE_NULL = 0, + RZ_ANALYSIS_OP_TYPE_JMP = 1, /* mandatory jump */ + RZ_ANALYSIS_OP_TYPE_UJMP = 2, /* unknown jump (register or so) */ + RZ_ANALYSIS_OP_TYPE_RJMP = RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UJMP, + RZ_ANALYSIS_OP_TYPE_IJMP = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_UJMP, + RZ_ANALYSIS_OP_TYPE_IRJMP = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UJMP, + RZ_ANALYSIS_OP_TYPE_CJMP = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_JMP, /* conditional jump */ + RZ_ANALYSIS_OP_TYPE_RCJMP = RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_CJMP, /* conditional jump register */ + RZ_ANALYSIS_OP_TYPE_MJMP = RZ_ANALYSIS_OP_TYPE_MEM | RZ_ANALYSIS_OP_TYPE_JMP, /* memory jump */ + RZ_ANALYSIS_OP_TYPE_MCJMP = RZ_ANALYSIS_OP_TYPE_MEM | RZ_ANALYSIS_OP_TYPE_CJMP, /* memory conditional jump */ + RZ_ANALYSIS_OP_TYPE_UCJMP = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_UJMP, /* conditional unknown jump */ + RZ_ANALYSIS_OP_TYPE_CALL = 3, /* call to subroutine (branch+link) */ + RZ_ANALYSIS_OP_TYPE_UCALL = 4, /* unknown call (register or so) */ + RZ_ANALYSIS_OP_TYPE_RCALL = RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UCALL, + RZ_ANALYSIS_OP_TYPE_ICALL = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_UCALL, + RZ_ANALYSIS_OP_TYPE_IRCALL = RZ_ANALYSIS_OP_TYPE_IND | RZ_ANALYSIS_OP_TYPE_REG | RZ_ANALYSIS_OP_TYPE_UCALL, + RZ_ANALYSIS_OP_TYPE_CCALL = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_CALL, /* conditional call to subroutine */ + RZ_ANALYSIS_OP_TYPE_UCCALL = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_UCALL, /* conditional unknown call */ + RZ_ANALYSIS_OP_TYPE_RET = 5, /* returns from subroutine */ + RZ_ANALYSIS_OP_TYPE_CRET = RZ_ANALYSIS_OP_TYPE_COND | RZ_ANALYSIS_OP_TYPE_RET, /* conditional return from subroutine */ + RZ_ANALYSIS_OP_TYPE_ILL = 6, /* illegal instruction // trap */ + RZ_ANALYSIS_OP_TYPE_UNK = 7, /* unknown opcode type */ + RZ_ANALYSIS_OP_TYPE_NOP = 8, /* does nothing */ + RZ_ANALYSIS_OP_TYPE_MOV = 9, /* register move */ + RZ_ANALYSIS_OP_TYPE_CMOV = 9 | RZ_ANALYSIS_OP_TYPE_COND, /* conditional move */ + RZ_ANALYSIS_OP_TYPE_TRAP = 10, /* it's a trap! */ + RZ_ANALYSIS_OP_TYPE_SWI = 11, /* syscall, software interrupt */ + RZ_ANALYSIS_OP_TYPE_CSWI = 11 | RZ_ANALYSIS_OP_TYPE_COND, /* syscall, software interrupt */ + RZ_ANALYSIS_OP_TYPE_UPUSH = 12, /* unknown push of data into stack */ + RZ_ANALYSIS_OP_TYPE_RPUSH = RZ_ANALYSIS_OP_TYPE_UPUSH | RZ_ANALYSIS_OP_TYPE_REG, /* push register */ + RZ_ANALYSIS_OP_TYPE_PUSH = 13, /* push value into stack */ + RZ_ANALYSIS_OP_TYPE_POP = 14, /* pop value from stack to register */ + RZ_ANALYSIS_OP_TYPE_CMP = 15, /* compare something */ + RZ_ANALYSIS_OP_TYPE_ACMP = 16, /* compare via and */ + RZ_ANALYSIS_OP_TYPE_ADD = 17, + RZ_ANALYSIS_OP_TYPE_SUB = 18, + RZ_ANALYSIS_OP_TYPE_IO = 19, + RZ_ANALYSIS_OP_TYPE_MUL = 20, + RZ_ANALYSIS_OP_TYPE_DIV = 21, + RZ_ANALYSIS_OP_TYPE_SHR = 22, + RZ_ANALYSIS_OP_TYPE_SHL = 23, + RZ_ANALYSIS_OP_TYPE_SAL = 24, + RZ_ANALYSIS_OP_TYPE_SAR = 25, + RZ_ANALYSIS_OP_TYPE_OR = 26, + RZ_ANALYSIS_OP_TYPE_AND = 27, + RZ_ANALYSIS_OP_TYPE_XOR = 28, + RZ_ANALYSIS_OP_TYPE_NOR = 29, + RZ_ANALYSIS_OP_TYPE_NOT = 30, + RZ_ANALYSIS_OP_TYPE_STORE = 31, /* store from register to memory */ + RZ_ANALYSIS_OP_TYPE_LOAD = 32, /* load from memory to register */ + RZ_ANALYSIS_OP_TYPE_LEA = 33, /* TODO add ulea */ + RZ_ANALYSIS_OP_TYPE_LEAVE = 34, + RZ_ANALYSIS_OP_TYPE_ROR = 35, + RZ_ANALYSIS_OP_TYPE_ROL = 36, + RZ_ANALYSIS_OP_TYPE_XCHG = 37, + RZ_ANALYSIS_OP_TYPE_MOD = 38, + RZ_ANALYSIS_OP_TYPE_SWITCH = 39, + RZ_ANALYSIS_OP_TYPE_CASE = 40, + RZ_ANALYSIS_OP_TYPE_LENGTH = 41, + RZ_ANALYSIS_OP_TYPE_CAST = 42, + RZ_ANALYSIS_OP_TYPE_NEW = 43, + RZ_ANALYSIS_OP_TYPE_ABS = 44, + RZ_ANALYSIS_OP_TYPE_CPL = 45, /* complement */ + RZ_ANALYSIS_OP_TYPE_CRYPTO = 46, + RZ_ANALYSIS_OP_TYPE_SYNC = 47, +// RZ_ANALYSIS_OP_TYPE_DEBUG = 43, // monitor/trace/breakpoint +#if 0 + RZ_ANALYSIS_OP_TYPE_PRIV = 40, /* privileged instruction */ + RZ_ANALYSIS_OP_TYPE_FPU = 41, /* floating point stuff */ +#endif +} RzAnalysisOpType; + +#endif // RZ_ANALYSIS_OPTYPE_H diff --git a/librz/include/rz_util/rz_print.h b/librz/include/rz_util/rz_print.h index fbc8e6fcaa5..28c4346f944 100644 --- a/librz/include/rz_util/rz_print.h +++ b/librz/include/rz_util/rz_print.h @@ -77,7 +77,7 @@ typedef struct { typedef struct { const RzRegSet *reg_sets; ///< Array of reg sets used to lookup register names during parsing. - ut32 ana_op_type; ///< Analysis op type (see: _RzAnalysisOpType) of the token string to parse. + ut32 ana_op_type; ///< Analysis op type (see: RzAnalysisOpType) of the token string to parse. } RzAsmParseParam; /** diff --git a/librz/util/print.c b/librz/util/print.c index fdd622352ff..40d7e3aacc3 100644 --- a/librz/util/print.c +++ b/librz/util/print.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include