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.
This commit is contained in:
Job Noorman
2021-05-18 08:41:11 +08:00
committed by Nelson Chu
parent 549f123c68
commit 113bb7618a
2 changed files with 20 additions and 10 deletions
+6
View File
@@ -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
+14 -10
View File
@@ -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;