aboutsummaryrefslogtreecommitdiff
path: root/opcodes/rl78-dis.c
diff options
context:
space:
mode:
authorThomas Hebb <tommyhebb@gmail.com>2022-04-29 21:17:58 -0700
committerAlan Modra <amodra@gmail.com>2022-04-30 19:21:11 +0930
commit16089f320a9226e7cdb73e9fb4266d9e450085b2 (patch)
treebb6e791e1b2862d6204e645bf27ca312423c23da /opcodes/rl78-dis.c
parent2e920d702b43c6d21ebd1e8a49c9e976a0d2cde6 (diff)
downloadgdb-16089f320a9226e7cdb73e9fb4266d9e450085b2.zip
gdb-16089f320a9226e7cdb73e9fb4266d9e450085b2.tar.gz
gdb-16089f320a9226e7cdb73e9fb4266d9e450085b2.tar.bz2
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.
Diffstat (limited to 'opcodes/rl78-dis.c')
-rw-r--r--opcodes/rl78-dis.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/opcodes/rl78-dis.c b/opcodes/rl78-dis.c
index cc08a29..2d7ffb2 100644
--- a/opcodes/rl78-dis.c
+++ b/opcodes/rl78-dis.c
@@ -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)