Skip to content

Commit 293d535

Browse files
kolerovShahab Vahedi
authored andcommitted
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 87f69af commit 293d535

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
@@ -420,6 +420,16 @@ arc_insn_get_branch_target (const struct arc_instruction &insn)
420420
instruction, hence last two bits should be truncated. */
421421
return pcrel_addr + align_down (insn.address, 4);
422422
}
423+
/* DBNZ is the only branch instruction that keeps a branch address in
424+
the second operand. It must be intercepted and treated differently. */
425+
else if (insn.insn_class == DBNZ)
426+
{
427+
CORE_ADDR pcrel_addr = arc_insn_get_operand_value_signed (insn, 1);
428+
429+
/* Offset is relative to the 4-byte aligned address of the current
430+
instruction, hence last two bits should be truncated. */
431+
return pcrel_addr + align_down (insn.address, 4);
432+
}
423433
/* B, Bcc, BL, BLcc, LP, LPcc: PC = currentPC + operand. */
424434
else if (insn.insn_class == BRANCH || insn.insn_class == LOOP)
425435
{

0 commit comments

Comments
 (0)