Fix ret op type for RISC-V (#16954)

This commit is contained in:
Paul I 2020-05-27 06:51:01 +03:00 committed by GitHub
parent 3bea2cf5ed
commit 91255a4ccc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -538,8 +538,10 @@ static int riscv_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le
op->type = R_ANAL_OP_TYPE_JMP;
} else if (is_any ("j", "jump")) {
op->type = R_ANAL_OP_TYPE_JMP;
} else if (is_any ("jalr", "ret")) { // ?
op->type = R_ANAL_OP_TYPE_UCALL;
} else if (is_any ("jalr")) {
// decide whether it's ret or call
int rd = (word >> OP_SH_RD) & OP_MASK_RD;
op->type = (rd == 0) ? R_ANAL_OP_TYPE_RET: R_ANAL_OP_TYPE_UCALL;
} else if (is_any ("ret")) {
op->type = R_ANAL_OP_TYPE_RET;
} else if (is_any ("beqz", "beq", "blez", "bgez", "ble",

10
test/db/anal/riscv Normal file
View File

@ -0,0 +1,10 @@
NAME=ret
FILE=bins/elf/analysis/guess-number-riscv64
CMDS=<<EOF
af @ sym._printf_r
afl~_printf_r
EOF
EXPECT=<<EOF
0x00010330 1 68 sym._printf_r
EOF
RUN