From 91172e86d8f4275fdbba57c1ff8b090ca2b29b4a Mon Sep 17 00:00:00 2001 From: "Dr. Christian Giessen" Date: Mon, 27 Apr 2026 12:01:49 +0000 Subject: [PATCH] Fix analysis: remove early return, add eob for branches The decoder had an early return when mask lacked DISASM, causing op->type/jump/eob to never be set during analysis passes. Removed the early return so all decode paths execute regardless of requested mask. Added op->eob = true for: - Unconditional JUMP (Type 10a, 36) - Unconditional indirect JUMP (Type 19) - RTS/RTI (Type 20) Added op->fail for: - Conditional JUMP (Type 10) - Conditional indirect jump (Type 19) This fixes function analysis (af), basic block detection (afb), and control flow graphing (agf/VV). Tested: isa_test.bin now shows 5 basic blocks with correct control flow edges. --- r2plugin/asm_adsp219x.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/r2plugin/asm_adsp219x.c b/r2plugin/asm_adsp219x.c index 55ffd61..146a04e 100644 --- a/r2plugin/asm_adsp219x.c +++ b/r2plugin/asm_adsp219x.c @@ -74,7 +74,7 @@ decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) ins2 = ((ut32) b[3] << 16) | ((ut32) b[4] << 8) | (ut32) b[5]; op->size = 3; op->type = R_ANAL_OP_TYPE_UNK; - if (!(mask & R_ARCH_OP_MASK_DISASM)) return true; + (void) mask; /* decode always runs full; r2 frees mnemonic */ /* Priority check: High bits */ ut32 b23_22 = (ins >> 22) & 0x3; @@ -352,6 +352,8 @@ decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) op->type = s_bit ? R_ANAL_OP_TYPE_CALL : R_ANAL_OP_TYPE_JMP; op->jump = addr; + if (!s_bit) + op->eob = true; return true; } @@ -416,6 +418,8 @@ decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) op->type = s_bit ? R_ANAL_OP_TYPE_CALL : R_ANAL_OP_TYPE_JMP; op->jump = target; + if (!s_bit) + op->eob = true; return true; } /* Type 10: bits 23-19 = 00011, bit18 = 0 (conditional 13-bit rel) */ @@ -466,6 +470,7 @@ decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) cond_str[cond], ret, b_bit ? " (DB)" : ""); op->type = R_ANAL_OP_TYPE_RET; + op->eob = true; return true; } @@ -629,6 +634,10 @@ decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) b_bit ? " (DB)" : ""); op->type = s_bit ? R_ANAL_OP_TYPE_CALL : R_ANAL_OP_TYPE_JMP; + if (!s_bit && cond == 15) + op->eob = true; + if (cond != 15) + op->fail = op->addr + 3; return true; }