diff options
-rw-r--r-- | lib/arm/dis-thumb.inc.h | 3 | ||||
-rw-r--r-- | lib/arm/transform-dis-arm-multi.inc.h | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/arm/dis-thumb.inc.h b/lib/arm/dis-thumb.inc.h index 8be137e..72865cf 100644 --- a/lib/arm/dis-thumb.inc.h +++ b/lib/arm/dis-thumb.inc.h @@ -61,7 +61,8 @@ static INLINE void P(t_cbtarget_target_B_2_tCBNZ)(tdis_ctx ctx, struct bitslice P(branch)(ctx, ctx->pc + 4 + 2 * bs_get(target, ctx->op), CC_CBXZ); if (TDIS_CTX_MODIFY(ctx)) { /* change target, and flip z/nz if necessary (i.e. always) */ - unsigned new = bs_set(target, TDIS_CTX_NEWVAL(ctx, 0), ctx->op); + int new_target = (TDIS_CTX_NEWVAL(ctx, 0) - (ctx->pc + 4)) / 2; + unsigned new = bs_set(target, new_target, ctx->op); if (TDIS_CTX_NEWVAL(ctx, 1)) new ^= 1 << 11; TDIS_CTX_SET_NEWOP(ctx, new); diff --git a/lib/arm/transform-dis-arm-multi.inc.h b/lib/arm/transform-dis-arm-multi.inc.h index 1025ae0..e080866 100644 --- a/lib/arm/transform-dis-arm-multi.inc.h +++ b/lib/arm/transform-dis-arm-multi.inc.h @@ -159,10 +159,10 @@ static NOINLINE UNUSED void transform_dis_branch(struct transform_dis_ctx *ctx, ctx->write_newop_here = NULL; if ((cc & CC_ARMCC) == CC_ARMCC) { actx.cond = invert_arm_cond(cc & 0xf); - Bccrel(actx, 8); + Bccrel(actx, 2+8); } else if ((cc & CC_CBXZ) == CC_CBXZ) { ctx->modify = true; - ctx->newval[0] = 2+8; + ctx->newval[0] = ctx->pc + 2+8; ctx->newval[1] = 1; /* do invert */ void **codep = ctx->rewritten_ptr_ptr; ctx->write_newop_here = *codep; *codep += 2; |