Skip to content

Commit

Permalink
callx0|callx4|callx8|callx12
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed Nov 12, 2024
1 parent 025a8e5 commit d0ee139
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
35 changes: 35 additions & 0 deletions librz/arch/isa/xtensa/xtensa_il.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,37 @@ static RzAnalysisLiftedILOp op_call12(XtensaContext *ctx) {
JMP(U32(PC + IMM(0))));
}

static RzAnalysisLiftedILOp op_callx0(XtensaContext *ctx) {
return SEQ3(
SETL("next", IREG(0)),
SETG("a0", U32(nextPC)),
JMP(VARL("next")));
}

// Fixme: WindowCheck
static RzAnalysisLiftedILOp op_callx4(XtensaContext *ctx) {
return SEQ3(
SETL("next", IREG(0)),
SETG("a4", U32(0x1 << 29 | (nextPC & 0x3fffffff))),
JMP(VARL("next")));
}

// Fixme: WindowCheck
static RzAnalysisLiftedILOp op_callx8(XtensaContext *ctx) {
return SEQ3(
SETL("next", IREG(0)),
SETG("a8", U32(0x2 << 29 | (nextPC & 0x3fffffff))),
JMP(VARL("next")));
}

// Fixme: WindowCheck
static RzAnalysisLiftedILOp op_callx12(XtensaContext *ctx) {
return SEQ3(
SETL("next", IREG(0)),
SETG("a12", U32(0x3 << 29 | (nextPC & 0x3fffffff))),
JMP(VARL("next")));
}

#include <rz_il/rz_il_opbuilder_end.h>

static const fn_analyze_op_il fn_tbl[] = {
Expand Down Expand Up @@ -402,6 +433,10 @@ static const fn_analyze_op_il fn_tbl[] = {
[XTENSA_INS_CALL4] = op_call4,
[XTENSA_INS_CALL8] = op_call8,
[XTENSA_INS_CALL12] = op_call12,
[XTENSA_INS_CALLX0] = op_callx0,
[XTENSA_INS_CALLX4] = op_callx4,
[XTENSA_INS_CALLX8] = op_callx8,
[XTENSA_INS_CALLX12] = op_callx12,
};

void xtensa_analyze_op_rzil(XtensaContext *ctx, RzAnalysisOp *op) {
Expand Down
8 changes: 8 additions & 0 deletions test/db/asm/xtensa
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ d "call0 . 0" c5ffff 0x40000 (seq (set a0 (bv 32 0x40003)) (jmp (bv 32 0x40000))
d "call4 . 0" d5ffff 0x40000 (seq (set a4 (bv 32 0x40040003)) (jmp (bv 32 0x40000)))
d "call8 . 0" e5ffff 0x40000 (seq (set a8 (bv 32 0x80040003)) (jmp (bv 32 0x40000)))
d "call12 . 0" f5ffff 0x40000 (seq (set a12 (bv 32 0xc0040003)) (jmp (bv 32 0x40000)))
d "callx12 a1" f00100 0x0 (seq (set next (var a1)) (set a12 (bv 32 0x60000003)) (jmp (var next)))
d "callx8 a1" e00100 0x0 (seq (set next (var a1)) (set a8 (bv 32 0x40000003)) (jmp (var next)))
d "callx4 a1" d00100 0x0 (seq (set next (var a1)) (set a4 (bv 32 0x20000003)) (jmp (var next)))
d "callx0 a1" c00100 0x0 (seq (set next (var a1)) (set a0 (bv 32 0x3)) (jmp (var next)))
d "callx12 a1" f00100 0x40000 (seq (set next (var a1)) (set a12 (bv 32 0x60040003)) (jmp (var next)))
d "callx8 a1" e00100 0x40000 (seq (set next (var a1)) (set a8 (bv 32 0x40040003)) (jmp (var next)))
d "callx4 a1" d00100 0x40000 (seq (set next (var a1)) (set a4 (bv 32 0x20040003)) (jmp (var next)))
d "callx0 a1" c00100 0x40000 (seq (set next (var a1)) (set a0 (bv 32 0x40003)) (jmp (var next)))

0 comments on commit d0ee139

Please sign in to comment.