From a38d139645fe557563c3c513b9175e07ceb5f5f8 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 3 Jun 2021 12:03:09 +0930 Subject: [PATCH] PR1202, mcore disassembler: wrong address loopt Fixes a 16 year old bug report, which even came with a patch. opcodes/ PR 1202 * mcore-dis.c (print_insn_mcore): Correct loopt disassembly. Use unsigned int for inst. gas/ PR 1202 * testsuite/gas/mcore/allinsn.d: Correct loopt expected output. --- gas/ChangeLog | 5 +++++ gas/testsuite/gas/mcore/allinsn.d | 2 +- opcodes/ChangeLog | 6 ++++++ opcodes/mcore-dis.c | 8 ++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 3e2e3c5d0b5..67b4583f212 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2021-06-03 Alan Modra + + PR 1202 + * testsuite/gas/mcore/allinsn.d: Correct loopt expected output. + 2021-05-29 Alan Modra * testsuite/gas/ppc/raw.s, diff --git a/gas/testsuite/gas/mcore/allinsn.d b/gas/testsuite/gas/mcore/allinsn.d index a53805bae2f..cf3b0ff6339 100644 --- a/gas/testsuite/gas/mcore/allinsn.d +++ b/gas/testsuite/gas/mcore/allinsn.d @@ -199,7 +199,7 @@ Disassembly of section \.text: 7e: 0041 ldq r4-r7, \(r1\) 0+080 : - 80: 048e loopt r8, 0x64 + 80: 048e loopt r8, 0x7e 0+082 : 82: 7901 lrw r9, 0x3C0C1BBA diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index fc3dd0818dc..6419ee83cc4 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,9 @@ +2021-06-03 Alan Modra + + PR 1202 + * mcore-dis.c (print_insn_mcore): Correct loopt disassembly. + Use unsigned int for inst. + 2021-06-02 Shahab Vahedi * arc-dis.c (arc_option_arg_t): New enumeration. diff --git a/opcodes/mcore-dis.c b/opcodes/mcore-dis.c index 0ee2e60eeda..c359ee0ec6e 100644 --- a/opcodes/mcore-dis.c +++ b/opcodes/mcore-dis.c @@ -95,7 +95,7 @@ print_insn_mcore (bfd_vma memaddr, unsigned char ibytes[4]; fprintf_ftype print_func = info->fprintf_func; void *stream = info->stream; - unsigned short inst; + unsigned int inst; unsigned int i; int status; @@ -215,10 +215,10 @@ print_insn_mcore (bfd_vma memaddr, case BL: { - uint32_t val = inst & 0x000F; + uint32_t val = memaddr + 2 + ((inst | ~0xF) << 1); + (*print_func) (stream, "\t%s, 0x%x", - grname[(inst >> 4) & 0xF], - (uint32_t) (memaddr - (val << 1))); + grname[(inst >> 4) & 0xF], val); } break; -- 2.30.2