Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XTENSA Always fallback on bad CPU and set illegal on bad decoding #4801

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions librz/arch/isa/xtensa/xtensa.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ bool xtensa_open(XtensaContext *ctx, const char *cpu, bool big_endian) {
return false;
}
cs_mode mode = big_endian ? CS_MODE_BIG_ENDIAN : CS_MODE_LITTLE_ENDIAN;
if (RZ_STR_ISEMPTY(cpu)) {
mode |= xtensa_cpu_modes[0].mode;
} else {
cs_mode mcpu = xtensa_cpu_modes[0].mode;
if (RZ_STR_ISNOTEMPTY(cpu)) {
for (int i = 0; i < RZ_ARRAY_SIZE(xtensa_cpu_modes); ++i) {
if (RZ_STR_EQ(cpu, xtensa_cpu_modes[i].cpu)) {
mode |= xtensa_cpu_modes[i].mode;
mcpu = xtensa_cpu_modes[i].mode;
break;
}
}
}
mode |= mcpu;
if (mode == ctx->mode) {
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions librz/arch/p/asm/asm_xtensa_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ static int asm_xtensa_disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len
op->size = ctx->insn->size;
xtensa_disassemble_fini(ctx);
return op->size;

beach:
rz_asm_op_set_asm(op, "illegal");
xtensa_disassemble_fini(ctx);
return -1;
}
Expand Down
Loading