Skip to content

Commit 3fd9b50

Browse files
committed
arc64: Determine a branch target of DBNZ correctly
DBNZ instruction was moved from BRANCH class to a separate one - DBNZ. Thus, it must be processed separately in arc_insn_get_branch_target to correctly determine an offset for a possible branch. Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
1 parent 590062d commit 3fd9b50

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

gdb/arc64-tdep.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,16 @@ arc_insn_get_branch_target (const struct arc_instruction &insn)
419419
instruction, hence last two bits should be truncated. */
420420
return pcrel_addr + align_down (insn.address, 4);
421421
}
422+
/* DBNZ is the only branch instruction that keeps a branch address in
423+
the second operand. It must be intercepted and treated differently. */
424+
else if (insn.insn_class == DBNZ)
425+
{
426+
CORE_ADDR pcrel_addr = arc_insn_get_operand_value_signed (insn, 1);
427+
428+
/* Offset is relative to the 4-byte aligned address of the current
429+
instruction, hence last two bits should be truncated. */
430+
return pcrel_addr + align_down (insn.address, 4);
431+
}
422432
/* B, Bcc, BL, BLcc, LP, LPcc: PC = currentPC + operand. */
423433
else if (insn.insn_class == BRANCH || insn.insn_class == LOOP)
424434
{

0 commit comments

Comments
 (0)