From 7fba55fcc07acc9b06fae5c167b5aa8e17773713 Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Wed, 3 Aug 2022 13:55:28 +0900 Subject: [PATCH] RISC-V: Print using ".dword" on RV64 riscv_disassemble_data has an ability to print 8-byte data with ".dword" but this is not utilized. This is possibly because, XLEN was not set before disassembling an instruction. Since prerequisite commits now set XLEN in riscv_get_disassembler, it's now safe to use ".dword" on RV64. gas/ChangeLog: * testsuite/gas/riscv/mapping-04b.d: Change to use RV64I. Check that ".dword" is actually used. * testsuite/gas/riscv/mapping-norelax-04b.d: Likewise. * testsuite/gas/riscv/mapping-04b-32.d: New test, the same as mapping-04b except it uses RV32I and ".dword" should not be used. opcodes/ChangeLog: * riscv-dis.c (riscv_data_length): Print using ".dword" on RV64. --- opcodes/riscv-dis.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index 81bb712a8c7..31a1c3c2172 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -1230,7 +1230,7 @@ riscv_data_length (bfd_vma memaddr, bfd_vma length; bool found = false; - length = 4; + length = xlen > 32 ? 8 : 4; if (info->symtab_size != 0 && bfd_asymbol_flavour (*info->symtab) == bfd_target_elf_flavour && last_map_symbol >= 0) @@ -1257,7 +1257,14 @@ riscv_data_length (bfd_vma memaddr, offset -= memaddr; length = (offset < length) ? offset : length; } - length = length == 3 ? 2 : length; + static const bfd_vma aligned_length[] = { + /* [0..0] */ 0, + /* [1..1] */ 1, + /* [2..3] */ 2, 2, + /* [4..7] */ 4, 4, 4, 4, + /* [8..8] */ 8, + }; + length = aligned_length[length]; return length; }