Skip to content

Commit

Permalink
RISC-V: Print using ".dword" on RV64
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
a4lg committed Aug 3, 2023
1 parent 6e9d1dd commit 4fe476a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions opcodes/riscv-dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,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)
Expand All @@ -1247,7 +1247,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;
}

Expand Down

0 comments on commit 4fe476a

Please sign in to comment.