aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog5
-rw-r--r--opcodes/riscv-dis.c8
2 files changed, 11 insertions, 2 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index df466ef..92d2516 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,10 @@
2016-12-20 Andrew Waterman <andrew@sifive.com>
+ * riscv-dis.c (riscv_disassemble_insn): Default to the ELF's
+ XLEN when none is provided.
+
+2016-12-20 Andrew Waterman <andrew@sifive.com>
+
* riscv-opc.c: Formatting fixes.
2016-12-20 Alan Modra <amodra@gmail.com>
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 3b4e1e0..cb26350 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -406,8 +406,12 @@ riscv_disassemble_insn (bfd_vma memaddr, insn_t word, disassemble_info *info)
{
int xlen = 0;
- /* The incoming section might not always be complete. */
- if (info->section != NULL)
+ /* If XLEN is not known, get its value from the ELF class. */
+ if (info->mach == bfd_mach_riscv64)
+ xlen = 64;
+ else if (info->mach == bfd_mach_riscv32)
+ xlen = 32;
+ else if (info->section != NULL)
{
Elf_Internal_Ehdr *ehdr = elf_elfheader (info->section->owner);
xlen = ehdr->e_ident[EI_CLASS] == ELFCLASS64 ? 64 : 32;