aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorJob Noorman <mtvec@pm.me>2021-05-18 08:41:11 +0800
committerNelson Chu <nelson.chu@sifive.com>2021-05-18 09:26:39 +0800
commit113bb7618a4b52c5fc8fdc0e82b2cd9f72471f72 (patch)
treef1df2713e905248346f2e64a711feb8635f58877 /opcodes
parent549f123c687def1194243cd8ff3bebd14ba67635 (diff)
downloadgdb-113bb7618a4b52c5fc8fdc0e82b2cd9f72471f72.zip
gdb-113bb7618a4b52c5fc8fdc0e82b2cd9f72471f72.tar.gz
gdb-113bb7618a4b52c5fc8fdc0e82b2cd9f72471f72.tar.bz2
RISC-V: PR27814, Objdump crashes when disassembling a non-ELF RISC-V binary.
2021-05-18 Job Noorman <mtvec@pm.me> opcodes/ PR 27814 * riscv-dis.c (riscv_get_disassembler): Get elf attributes only for the elf objects.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog6
-rw-r--r--opcodes/riscv-dis.c24
2 files changed, 20 insertions, 10 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index d506b71..11896df 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,9 @@
+2021-05-18 Job Noorman <mtvec@pm.me>
+
+ PR 27814
+ * riscv-dis.c (riscv_get_disassembler): Get elf attributes only for
+ the elf objects.
+
2021-05-17 Alex Coplan <alex.coplan@arm.com>
* arm-dis.c (mve_opcodes): Fix disassembly of
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 025d134..fe8dfb8 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -597,17 +597,21 @@ riscv_get_disassembler (bfd *abfd)
{
if (abfd)
{
- const char *sec_name = get_elf_backend_data (abfd)->obj_attrs_section;
- if (bfd_get_section_by_name (abfd, sec_name) != NULL)
+ const struct elf_backend_data *ebd = get_elf_backend_data (abfd);
+ if (ebd)
{
- obj_attribute *attr = elf_known_obj_attributes_proc (abfd);
- unsigned int Tag_a = Tag_RISCV_priv_spec;
- unsigned int Tag_b = Tag_RISCV_priv_spec_minor;
- unsigned int Tag_c = Tag_RISCV_priv_spec_revision;
- riscv_get_priv_spec_class_from_numbers (attr[Tag_a].i,
- attr[Tag_b].i,
- attr[Tag_c].i,
- &default_priv_spec);
+ const char *sec_name = ebd->obj_attrs_section;
+ if (bfd_get_section_by_name (abfd, sec_name) != NULL)
+ {
+ obj_attribute *attr = elf_known_obj_attributes_proc (abfd);
+ unsigned int Tag_a = Tag_RISCV_priv_spec;
+ unsigned int Tag_b = Tag_RISCV_priv_spec_minor;
+ unsigned int Tag_c = Tag_RISCV_priv_spec_revision;
+ riscv_get_priv_spec_class_from_numbers (attr[Tag_a].i,
+ attr[Tag_b].i,
+ attr[Tag_c].i,
+ &default_priv_spec);
+ }
}
}
return print_insn_riscv;