1 /* Select disassembly routine for specified architecture.
2 Copyright (C) 1994-2017 Free Software Foundation, Inc.
4 This file is part of the GNU opcodes library.
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
23 #include "safe-ctype.h"
62 #define ARCH_microblaze
98 #define ARCH_xstormy16
104 #define INCLUDE_SHMEDIA
108 #include "m32c-desc.h"
112 disassembler (bfd *abfd)
114 enum bfd_architecture a = bfd_get_arch (abfd);
115 disassembler_ftype disassemble;
119 /* If you add a case to this table, also add it to the
120 ARCH_all definition right above this function. */
122 case bfd_arch_aarch64:
123 disassemble = print_insn_aarch64;
128 disassemble = print_insn_alpha;
133 disassemble = arc_get_disassembler (abfd);
138 if (bfd_big_endian (abfd))
139 disassemble = print_insn_big_arm;
141 disassemble = print_insn_little_arm;
146 disassemble = print_insn_avr;
151 disassemble = print_insn_bfin;
156 disassemble = print_insn_cr16;
161 disassemble = cris_get_disassembler (abfd);
166 disassemble = print_insn_crx;
171 disassemble = print_insn_d10v;
176 disassemble = print_insn_d30v;
181 /* As far as I know we only handle big-endian DLX objects. */
182 disassemble = print_insn_dlx;
187 if (bfd_get_mach (abfd) == bfd_mach_h8300h
188 || bfd_get_mach (abfd) == bfd_mach_h8300hn)
189 disassemble = print_insn_h8300h;
190 else if (bfd_get_mach (abfd) == bfd_mach_h8300s
191 || bfd_get_mach (abfd) == bfd_mach_h8300sn
192 || bfd_get_mach (abfd) == bfd_mach_h8300sx
193 || bfd_get_mach (abfd) == bfd_mach_h8300sxn)
194 disassemble = print_insn_h8300s;
196 disassemble = print_insn_h8300;
201 disassemble = print_insn_h8500;
206 disassemble = print_insn_hppa;
211 disassemble = print_insn_i370;
219 disassemble = print_insn_i386;
224 disassemble = print_insn_i860;
229 disassemble = print_insn_i960;
234 disassemble = print_insn_ia64;
239 disassemble = print_insn_ip2k;
243 case bfd_arch_epiphany:
244 disassemble = print_insn_epiphany;
249 disassemble = print_insn_fr30;
254 disassemble = print_insn_lm32;
259 disassemble = print_insn_m32r;
262 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) \
263 || defined(ARCH_9s12x) || defined(ARCH_m9s12xg)
264 case bfd_arch_m68hc11:
265 disassemble = print_insn_m68hc11;
267 case bfd_arch_m68hc12:
268 disassemble = print_insn_m68hc12;
270 case bfd_arch_m9s12x:
271 disassemble = print_insn_m9s12x;
273 case bfd_arch_m9s12xg:
274 disassemble = print_insn_m9s12xg;
279 disassemble = print_insn_m68k;
284 disassemble = print_insn_m88k;
289 disassemble = print_insn_mt;
292 #ifdef ARCH_microblaze
293 case bfd_arch_microblaze:
294 disassemble = print_insn_microblaze;
298 case bfd_arch_msp430:
299 disassemble = print_insn_msp430;
304 disassemble = print_insn_nds32;
309 disassemble = print_insn_ns32k;
314 disassemble = print_insn_mcore;
319 disassemble = print_insn_mep;
324 disassemble = print_insn_metag;
329 if (bfd_big_endian (abfd))
330 disassemble = print_insn_big_mips;
332 disassemble = print_insn_little_mips;
337 disassemble = print_insn_mmix;
341 case bfd_arch_mn10200:
342 disassemble = print_insn_mn10200;
346 case bfd_arch_mn10300:
347 disassemble = print_insn_mn10300;
352 if (bfd_big_endian (abfd))
353 disassemble = print_insn_big_nios2;
355 disassemble = print_insn_little_nios2;
360 disassemble = print_insn_or1k;
365 disassemble = print_insn_pdp11;
370 disassemble = print_insn_pj;
374 case bfd_arch_powerpc:
375 if (bfd_big_endian (abfd))
376 disassemble = print_insn_big_powerpc;
378 disassemble = print_insn_little_powerpc;
383 disassemble = print_insn_pru;
388 disassemble = print_insn_riscv;
392 case bfd_arch_rs6000:
393 if (bfd_get_mach (abfd) == bfd_mach_ppc_620)
394 disassemble = print_insn_big_powerpc;
396 disassemble = print_insn_rs6000;
401 disassemble = rl78_get_disassembler (abfd);
406 disassemble = print_insn_rx;
411 disassemble = print_insn_s390;
416 if (bfd_big_endian (abfd))
417 disassemble = print_insn_big_score;
419 disassemble = print_insn_little_score;
424 disassemble = print_insn_sh;
429 disassemble = print_insn_sparc;
434 disassemble = print_insn_spu;
439 disassemble = print_insn_tic30;
444 disassemble = print_insn_tic4x;
448 case bfd_arch_tic54x:
449 disassemble = print_insn_tic54x;
454 disassemble = print_insn_tic6x;
459 disassemble = print_insn_tic80;
464 disassemble = print_insn_ft32;
469 case bfd_arch_v850_rh850:
470 disassemble = print_insn_v850;
475 disassemble = print_insn_w65;
479 case bfd_arch_wasm32:
480 disassemble = print_insn_wasm32;
485 disassemble = print_insn_xgate;
488 #ifdef ARCH_xstormy16
489 case bfd_arch_xstormy16:
490 disassemble = print_insn_xstormy16;
495 disassemble = print_insn_xc16x;
499 case bfd_arch_xtensa:
500 disassemble = print_insn_xtensa;
505 disassemble = print_insn_z80;
510 if (bfd_get_mach(abfd) == bfd_mach_z8001)
511 disassemble = print_insn_z8001;
513 disassemble = print_insn_z8002;
518 disassemble = print_insn_vax;
522 case bfd_arch_visium:
523 disassemble = print_insn_visium;
528 disassemble = print_insn_frv;
533 disassemble = print_insn_moxie;
537 case bfd_arch_iq2000:
538 disassemble = print_insn_iq2000;
543 disassemble = print_insn_m32c;
547 case bfd_arch_tilegx:
548 disassemble = print_insn_tilegx;
552 case bfd_arch_tilepro:
553 disassemble = print_insn_tilepro;
563 disassembler_usage (FILE *stream ATTRIBUTE_UNUSED)
566 print_aarch64_disassembler_options (stream);
569 print_arc_disassembler_options (stream);
572 print_arm_disassembler_options (stream);
575 print_mips_disassembler_options (stream);
578 print_ppc_disassembler_options (stream);
581 print_riscv_disassembler_options (stream);
584 print_i386_disassembler_options (stream);
587 print_s390_disassembler_options (stream);
590 print_wasm32_disassembler_options (stream);
597 disassemble_init_for_target (struct disassemble_info * info)
605 case bfd_arch_aarch64:
606 info->symbol_is_valid = aarch64_symbol_is_valid;
607 info->disassembler_needs_relocs = TRUE;
612 info->symbol_is_valid = arm_symbol_is_valid;
613 info->disassembler_needs_relocs = TRUE;
618 info->skip_zeroes = 16;
623 info->skip_zeroes = 32;
628 info->skip_zeroes = 256;
629 info->skip_zeroes_at_end = 0;
634 info->disassembler_needs_relocs = TRUE;
639 /* This processor in fact is little endian. The value set here
640 reflects the way opcodes are written in the cgen description. */
641 info->endian = BFD_ENDIAN_BIG;
642 if (! info->insn_sets)
644 info->insn_sets = cgen_bitset_create (ISA_MAX);
645 if (info->mach == bfd_mach_m16c)
646 cgen_bitset_set (info->insn_sets, ISA_M16C);
648 cgen_bitset_set (info->insn_sets, ISA_M32C);
653 case bfd_arch_powerpc:
656 case bfd_arch_rs6000:
658 #if defined (ARCH_powerpc) || defined (ARCH_rs6000)
659 disassemble_init_powerpc (info);
663 case bfd_arch_wasm32:
664 disassemble_init_wasm32 (info);
669 disassemble_init_s390 (info);
677 /* Remove whitespace and consecutive commas from OPTIONS. */
680 remove_whitespace_and_extra_commas (char *options)
688 /* Strip off all trailing whitespace and commas. */
689 for (len = strlen (options); len > 0; len--)
691 if (!ISSPACE (options[len - 1]) && options[len - 1] != ',')
693 options[len - 1] = '\0';
696 /* Convert all remaining whitespace to commas. */
697 for (i = 0; options[i] != '\0'; i++)
698 if (ISSPACE (options[i]))
701 /* Remove consecutive commas. */
702 for (str = options; *str != '\0'; str++)
703 if (*str == ',' && (*(str + 1) == ',' || str == options))
705 char *next = str + 1;
711 memmove (str, next, len);
712 next[len - (size_t)(next - str)] = '\0';
714 return (strlen (options) != 0) ? options : NULL;
717 /* Like STRCMP, but treat ',' the same as '\0' so that we match
718 strings like "foobar" against "foobar,xxyyzz,...". */
721 disassembler_options_cmp (const char *s1, const char *s2)
723 unsigned char c1, c2;
727 c1 = (unsigned char) *s1++;
730 c2 = (unsigned char) *s2++;