Skip to content

Commit

Permalink
librz/analysis: add RZ_ANALYSIS_IL_STEP_UNIMPLEMENTED_IL (#4887)
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio authored Feb 9, 2025
1 parent fc6886b commit 6047120
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
9 changes: 6 additions & 3 deletions librz/arch/il/analysis_il.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,17 @@ static RzAnalysisILStepResult analysis_il_vm_step_while(
analysis->read_at(analysis, addr, code, sizeof(code));
int r = rz_analysis_op(analysis, &op, addr, code, sizeof(code), RZ_ANALYSIS_OP_MASK_IL | RZ_ANALYSIS_OP_MASK_HINT | RZ_ANALYSIS_OP_MASK_DISASM);

if (r < 0 || !op.il_op) {
if (r < 0) {
res = RZ_ANALYSIS_IL_STEP_INVALID_OP;
break;
}
if (!rz_il_vm_step(vm->vm, op.il_op, addr + (op.size > 0 ? op.size : 1))) {
} else if (!op.il_op) {
res = RZ_ANALYSIS_IL_STEP_UNIMPLEMENTED_IL;
break;
} else if (!rz_il_vm_step(vm->vm, op.il_op, addr + (op.size > 0 ? op.size : 1))) {
res = RZ_ANALYSIS_IL_STEP_IL_RUNTIME_ERROR;
break;
}

if (!with_events) {
rz_analysis_op_fini(&op);
continue;
Expand Down
16 changes: 10 additions & 6 deletions librz/core/cil.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,13 +679,17 @@ static bool step_handle_result(RzCore *core, RzAnalysisILStepResult r) {
case RZ_ANALYSIS_IL_STEP_RESULT_SUCCESS:
rz_core_reg_update_flags(core);
return true;
case RZ_ANALYSIS_IL_STEP_INVALID_OP:
RZ_LOG_ERROR("RzIL: invalid instruction or lifting not implemented at address 0x%08" PFMT64x "\n",
rz_reg_get_value_by_role(core->analysis->reg, RZ_REG_NAME_PC));
break;
case RZ_ANALYSIS_IL_STEP_UNIMPLEMENTED_IL: {
ut64 reg_pc = rz_reg_get_value_by_role(core->analysis->reg, RZ_REG_NAME_PC);
RZ_LOG_ERROR("RzIL: lifting not implemented at address 0x%08" PFMT64x "\n", reg_pc);
} break;
case RZ_ANALYSIS_IL_STEP_INVALID_OP: {
ut64 reg_pc = rz_reg_get_value_by_role(core->analysis->reg, RZ_REG_NAME_PC);
RZ_LOG_ERROR("RzIL: invalid instruction at address 0x%08" PFMT64x "\n", reg_pc);
} break;
default: {
ut64 addr = rz_bv_to_ut64(core->analysis->il_vm->vm->pc);
RZ_LOG_ERROR("RzIL: stepping failed with PC at 0x%" PFMT64x ".\n", addr);
ut64 vm_pc = rz_bv_to_ut64(core->analysis->il_vm->vm->pc);
RZ_LOG_ERROR("RzIL: stepping failed with PC at 0x%" PFMT64x ".\n", vm_pc);
} break;
}
return false;
Expand Down
1 change: 1 addition & 0 deletions librz/include/rz_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,7 @@ typedef enum {
RZ_ANALYSIS_IL_STEP_RESULT_SUCCESS,
RZ_ANALYSIS_IL_STEP_RESULT_NOT_SET_UP,
RZ_ANALYSIS_IL_STEP_IL_RUNTIME_ERROR,
RZ_ANALYSIS_IL_STEP_UNIMPLEMENTED_IL,
RZ_ANALYSIS_IL_STEP_INVALID_OP
} RzAnalysisILStepResult;

Expand Down
6 changes: 3 additions & 3 deletions test/db/cmd/cmd_aez
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ REGEXP_FILTER_ERR=<<EOF
ERROR:.+
EOF
EXPECT_ERR=<<EOF
ERROR: RzIL: invalid instruction or lifting not implemented at address 0x00000004
ERROR: RzIL: lifting not implemented at address 0x00000004
EOF
RUN

Expand All @@ -52,7 +52,7 @@ REGEXP_FILTER_ERR=<<EOF
ERROR:.+
EOF
EXPECT_ERR=<<EOF
ERROR: RzIL: invalid instruction or lifting not implemented at address 0x00000004
ERROR: RzIL: lifting not implemented at address 0x00000004
EOF
RUN

Expand Down Expand Up @@ -82,7 +82,7 @@ REGEXP_FILTER_ERR=<<EOF
ERROR:.+
EOF
EXPECT_ERR=<<EOF
ERROR: RzIL: invalid instruction or lifting not implemented at address 0x00000004
ERROR: RzIL: lifting not implemented at address 0x00000004
EOF
RUN

Expand Down

0 comments on commit 6047120

Please sign in to comment.