13 #define XTENSA_MAX_LENGTH 8
16 static int length_table[16] = { 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 8, 8 };
37 ut8 imm6 = (
buf[1] >> 4) | (
buf[0] & 0x30);
38 return (
addr + 4 + imm6);
43 return (
addr + 4 + imm8 - 0x100);
45 return (
addr + 4 + imm8);
51 return (
addr + 4 + imm12 - 0x1000);
53 return (
addr + 4 + imm12);
120 op->ptr = ((
addr + 3) & ~3) + ((
buf[2] << 8 |
buf[1]) << 2) - 0x40000;
124 switch ((
buf[0] >> 4) & 0xf) {
151 switch ((
buf[0] >> 4) & 0xf) {
169 switch ((
buf[0] >> 4) & 0xf) {
171 switch (
buf[1] & 0xf) {
195 switch ((
buf[1] >> 4) & 0xf) {
229 switch ((
buf[1] >> 4) & 0xf) {
258 switch (
buf[1] & 0xf) {
273 switch ((
buf[2] >> 4) & 0xf) {
293 switch ((
buf[2] >> 4) & 0xf) {
306 switch ((
buf[1] >> 4) & 0xf) {
316 if (((
buf[0] >> 4) & 0xf) <= 1) {
397 switch ((
buf[2] >> 4) & 0xf) {
412 switch ((
buf[2] >> 4) & 0xf) {
429 switch ((
buf[2] >> 4) & 0xf) {
451 switch ((
buf[0] >> 4) & 0xf) {
476 switch ((
buf[2] >> 4) & 0xf) {
594 switch (
buf[1] >> 4) {
637 switch ((
buf[1] >> 4) & 0xf) {
642 switch ((
buf[0] >> 4) & 0xf) {
694 if (((*
value >> bit1) & 1) && ((*
value >> bit2) & 1)) {
715 if (
dst == 1 &&
src == 1) {
739 ut32 extend_mask = 0xFFFFFFFF <<
bit;
776 ut8 data_size = opcode == 82 ? 2
790 sign_extend_bit = 15;
812 if (sign_extend_bit != 0) {
1120 (is_add ?
"+" :
"-"),
1314 char compare_val[4] =
"0";
1339 sizeof(compare_val),
1444 bit_clear = opcode == 56;
1445 cmp_op = bit_clear ?
"==,$z" :
"==,$z,!";
1446 mask = 1 << imm_bit;
1449 imm_offset += 4 - 3;
1502 bit_clear = opcode == 70;
1503 cmp_op = bit_clear ?
"==,$z" :
"==,$z,!";
1506 imm_offset += 4 - 3;
1607 bool call = opcode == 76;
1611 (
ut32 *)&imm_offset);
1627 imm_offset += 4 - 3;
1636 bool callx = opcode == 77;
1696 const char *shift_op =
"";
1707 if (opcode == 113) {
1733 const char *shift_op =
"";
1742 if (opcode == 109) {
1777 ut32 and_mask = (1 << (imm_mask + 1)) - 1;
1948 if (
op->size > len_original) {
1990 for (
i = 0;
i < nslots;
i++) {
2009 "# a0 return address\n"
2010 "# a1 stack pointer\n"
2011 "# a2-a7 arguments\n"
2012 "# a2-a5 return value (call0 ABI)\n"
2013 "# a12-a15 callee-saved (call0 ABI)\n"
2033 "gpr a10 .32 44 0\n"
2034 "gpr a11 .32 48 0\n"
2035 "gpr a12 .32 52 0\n"
2036 "gpr a13 .32 56 0\n"
2037 "gpr a14 .32 60 0\n"
2038 "gpr a15 .32 64 0\n"
2044 "gpr sar .32 72 0\n");
2049 .desc =
"Xtensa disassembler",
2058 #ifndef RZ_PLUGIN_INCORE
static void esil_branch_compare_single(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_mul_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_si_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_unk_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_null_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_bitwise_op(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void esil_move(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static char * get_reg_profile(RzAnalysis *analysis)
static void xtensa_div_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_rt0_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_shr_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void sign_extend2(st32 *value, ut8 bit1, ut8 bit2, ut8 shift)
static XtensaOpFn xtensa_op0_fns[]
static void xtensa_shl_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_call(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_lscx_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_fp0_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_add_sub(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
RzAnalysisPlugin rz_analysis_plugin_xtensa
static void esil_move_imm(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void esil_set_shift_amount(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void analop_esil(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_store_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_rst1_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_fp1_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_branch_compare_imm(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_l32r_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_rst2_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_load_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static int xtensa_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf_original, int len_original, RzAnalysisOpMask mask)
static void sign_extend(st32 *value, ut8 bit)
#define XTENSA_MAX_LENGTH
static ut64 xtensa_imm8s(ut64 addr, ut8 imm8)
static void xtensa_and_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_st3n_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_store_imm(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_rfei_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_branch_check_bit_imm(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static XtensaOpFn xtensa_lsai_fns[]
static void xtensa_mov_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_check_stack_op(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_b_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
RZ_API RzLibStruct rizin_plugin
static void esil_sign_extend(RzStrBuf *esil, ut8 bit)
static void esil_shift_logic_imm(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_rst0_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static XtensaOpFn xtensa_rst1_fns[]
static void esil_abs_neg(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_qrst_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_branch_check_bit(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_lsai_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static XtensaOpFn xtensa_qrst_fns[]
static ut64 xtensa_offset(ut64 addr, const ut8 *buf)
static void esil_callx(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_calln_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static XtensaOpFn xtensa_rst0_fns[]
static void esil_extract_unsigned(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void esil_load_relative(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void esil_branch_compare(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void esil_set_shift_amount_imm(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_tlb_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_shift_logic_sar(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_sub_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
void(* XtensaOpFn)(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_load_imm(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_or_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_sync_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_xor_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static XtensaOpFn xtensa_rst2_fns[]
static void esil_branch_check_mask(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static ut64 xtensa_imm12s(ut64 addr, const ut8 *buf)
static void xtensa_st2n_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_st1_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static int xtensa_length(const ut8 *insn)
static void esil_push_signed_imm(RzStrBuf *esil, st32 imm)
static void xtensa_mod_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_st0_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static ut64 xtensa_imm18s(ut64 addr, const ut8 *buf)
static void xtensa_accer_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_lsci_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_snm0_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void xtensa_add_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_add_imm(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static void xtensa_imp_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static void esil_move_conditional(xtensa_isa isa, xtensa_opcode opcode, xtensa_format format, size_t i, xtensa_insnbuf slot_buffer, RzAnalysisOp *op)
static ut64 xtensa_imm6s(ut64 addr, const ut8 *buf)
static void xtensa_lsc4_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf)
static RZ_NULLABLE RzILOpBitVector * shift(RzILOpBitVector *val, RZ_NULLABLE RzILOpBool **carry_out, arm_shifter type, RZ_OWN RzILOpBitVector *dist)
static ut32 neg(ArmOp *op)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static const char * cmp_op[]
@ RZ_ANALYSIS_OP_FAMILY_FPU
@ RZ_ANALYSIS_OP_MASK_ESIL
@ RZ_ANALYSIS_OP_TYPE_CMP
@ RZ_ANALYSIS_OP_TYPE_SUB
@ RZ_ANALYSIS_OP_TYPE_LOAD
@ RZ_ANALYSIS_OP_TYPE_UNK
@ RZ_ANALYSIS_OP_TYPE_MUL
@ RZ_ANALYSIS_OP_TYPE_JMP
@ RZ_ANALYSIS_OP_TYPE_AND
@ RZ_ANALYSIS_OP_TYPE_MOD
@ RZ_ANALYSIS_OP_TYPE_UPUSH
@ RZ_ANALYSIS_OP_TYPE_UJMP
@ RZ_ANALYSIS_OP_TYPE_SWI
@ RZ_ANALYSIS_OP_TYPE_ABS
@ RZ_ANALYSIS_OP_TYPE_NULL
@ RZ_ANALYSIS_OP_TYPE_CMOV
@ RZ_ANALYSIS_OP_TYPE_TRAP
@ RZ_ANALYSIS_OP_TYPE_CALL
@ RZ_ANALYSIS_OP_TYPE_ADD
@ RZ_ANALYSIS_OP_TYPE_STORE
@ RZ_ANALYSIS_OP_TYPE_SHR
@ RZ_ANALYSIS_OP_TYPE_CJMP
@ RZ_ANALYSIS_OP_TYPE_DIV
@ RZ_ANALYSIS_OP_TYPE_MOV
@ RZ_ANALYSIS_OP_TYPE_SHL
@ RZ_ANALYSIS_OP_TYPE_ILL
@ RZ_ANALYSIS_OP_TYPE_UCALL
@ RZ_ANALYSIS_OP_TYPE_NOT
@ RZ_ANALYSIS_OP_TYPE_RET
@ RZ_ANALYSIS_OP_TYPE_NOP
@ RZ_ANALYSIS_OP_TYPE_XOR
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
RZ_API const char * rz_strbuf_setf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API bool rz_strbuf_appendf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
#define cond(bop, top, mask, flags)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
const char * xtensa_regfile_shortname(xtensa_isa isa, xtensa_regfile rf)
int xtensa_format_get_slot(xtensa_isa isa, xtensa_format fmt, int slot, const xtensa_insnbuf insn, xtensa_insnbuf slotbuf)
int xtensa_format_num_slots(xtensa_isa isa, xtensa_format fmt)
uint32 xtensa_insnbuf_word
xtensa_opcode xtensa_opcode_decode(xtensa_isa isa, xtensa_format fmt, int slot, const xtensa_insnbuf slotbuf)
xtensa_insnbuf_word * xtensa_insnbuf
int xtensa_insnbuf_size(xtensa_isa isa)
xtensa_regfile xtensa_operand_regfile(xtensa_isa isa, xtensa_opcode opc, int opnd)
int xtensa_operand_get_field(xtensa_isa isa, xtensa_opcode opc, int opnd, xtensa_format fmt, int slot, const xtensa_insnbuf slotbuf, uint32 *valp)
int xtensa_operand_decode(xtensa_isa isa, xtensa_opcode opc, int opnd, uint32 *valp)
xtensa_format xtensa_format_decode(xtensa_isa isa, const xtensa_insnbuf insn)
void xtensa_insnbuf_from_chars(xtensa_isa isa, xtensa_insnbuf insn, const unsigned char *cp, int num_chars)
xtensa_isa xtensa_isa_init(xtensa_isa_status *errno_p, char **error_msg_p)
xtensa_isa xtensa_default_isa
xtensa_insnbuf xtensa_insnbuf_alloc(xtensa_isa isa)
static int length_table[16]