forked from Imagelibrary/binutils-gdb
opcodes: don't assume ELF in riscv, csky, rl78, mep disassemblers
Currently, the get_disassembler() implementations for riscv, csky, and rl78--and mep_print_insn() for mep--access ELF variants of union fields without first checking that the bfd actually represents an ELF. This causes undefined behavior and crashes when disassembling non-ELF files (the "binary" BFD, for example). Fix that.
This commit is contained in:
@@ -408,7 +408,7 @@ rl78_get_disassembler (bfd *abfd)
|
||||
{
|
||||
int cpu = E_FLAG_RL78_ANY_CPU;
|
||||
|
||||
if (abfd != NULL)
|
||||
if (abfd != NULL && bfd_get_flavour (abfd) == bfd_target_elf_flavour)
|
||||
cpu = abfd->tdata.elf_obj_data->elf_header->e_flags & E_FLAG_RL78_CPU_MASK;
|
||||
|
||||
switch (cpu)
|
||||
|
||||
Reference in New Issue
Block a user