Skip to content

Commit

Permalink
Revert 722e5c0
Browse files Browse the repository at this point in the history
It is dictated by BAP theory that the jumps come last.
  • Loading branch information
Rot127 committed Mar 16, 2024
1 parent 66c08ea commit c59a465
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions librz/il/il_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,11 @@ VALIDATOR_EFFECT(seq) {
VALIDATOR_DESCEND_EFFECT(args->x, &tx, ctx, {});
RzILTypeEffect ty;
VALIDATOR_DESCEND_EFFECT(args->y, &ty, ctx, {});
// Code after a jmp/goto makes no sense because the jmp naturally jumps somewhere else already.
// Intuitively, this could be considered just dead code and valid, but because it is not practically useful,
// we reject such code completely for now, which gives us more freedom if in the future we do want to define
// semantics for code after ctrl in some way.
VALIDATOR_ASSERT(!(tx & RZ_IL_TYPE_EFFECT_CTRL) || !ty, "Encountered further effects after a ctrl effect in seq op.");
*type_out = tx | ty;
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit/test_il_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,12 @@ static bool test_il_validate_effect_seq() {
mu_assert_null(report, "no report");
rz_il_op_effect_free(op);

op = rz_il_op_new_seq(rz_il_op_new_jmp(rz_il_op_new_bitv_from_ut64(24, 0x100)), rz_il_op_new_set("x", true, rz_il_op_new_b0()));
val = rz_il_validate_effect(op, ctx, NULL, &t, &report);
mu_assert_false(val, "invalid");
mu_assert_streq_free(report, "Encountered further effects after a ctrl effect in seq op.", "report");
rz_il_op_effect_free(op);

op = rz_il_op_new_seq(rz_il_op_new_jmp(rz_il_op_new_bitv_from_ut64(24, 0x100)), rz_il_op_new_nop());
val = rz_il_validate_effect(op, ctx, NULL, &t, &report);
mu_assert_true(val, "valid");
Expand Down

0 comments on commit c59a465

Please sign in to comment.