1 /* Select disassembly routine for specified architecture.
2 Copyright (C) 1994-2019 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. */
22 #include "disassemble.h"
23 #include "safe-ctype.h"
59 #define ARCH_microblaze
97 #define ARCH_xstormy16
106 #include "m32c-desc.h"
110 disassembler (enum bfd_architecture a,
111 bfd_boolean big ATTRIBUTE_UNUSED,
112 unsigned long mach ATTRIBUTE_UNUSED,
113 bfd *abfd ATTRIBUTE_UNUSED)
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);
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 = csky_get_disassembler (abfd);
177 disassemble = print_insn_d10v;
182 disassemble = print_insn_d30v;
187 /* As far as I know we only handle big-endian DLX objects. */
188 disassemble = print_insn_dlx;
193 if (mach == bfd_mach_h8300h || mach == bfd_mach_h8300hn)
194 disassemble = print_insn_h8300h;
195 else if (mach == bfd_mach_h8300s
196 || mach == bfd_mach_h8300sn
197 || mach == bfd_mach_h8300sx
198 || mach == bfd_mach_h8300sxn)
199 disassemble = print_insn_h8300s;
201 disassemble = print_insn_h8300;
206 disassemble = print_insn_hppa;
214 disassemble = print_insn_i386;
219 disassemble = print_insn_ia64;
224 disassemble = print_insn_ip2k;
228 case bfd_arch_epiphany:
229 disassemble = print_insn_epiphany;
234 disassemble = print_insn_fr30;
239 disassemble = print_insn_lm32;
244 disassemble = print_insn_m32r;
247 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) \
248 || defined(ARCH_9s12x) || defined(ARCH_m9s12xg)
249 case bfd_arch_m68hc11:
250 disassemble = print_insn_m68hc11;
252 case bfd_arch_m68hc12:
253 disassemble = print_insn_m68hc12;
255 case bfd_arch_m9s12x:
256 disassemble = print_insn_m9s12x;
258 case bfd_arch_m9s12xg:
259 disassemble = print_insn_m9s12xg;
262 #if defined(ARCH_s12z)
264 disassemble = print_insn_s12z;
269 disassemble = print_insn_m68k;
274 disassemble = print_insn_mt;
277 #ifdef ARCH_microblaze
278 case bfd_arch_microblaze:
279 disassemble = print_insn_microblaze;
283 case bfd_arch_msp430:
284 disassemble = print_insn_msp430;
289 disassemble = print_insn_nds32;
294 disassemble = print_insn_nfp;
299 disassemble = print_insn_ns32k;
304 disassemble = print_insn_mcore;
309 disassemble = print_insn_mep;
314 disassemble = print_insn_metag;
320 disassemble = print_insn_big_mips;
322 disassemble = print_insn_little_mips;
327 disassemble = print_insn_mmix;
331 case bfd_arch_mn10200:
332 disassemble = print_insn_mn10200;
336 case bfd_arch_mn10300:
337 disassemble = print_insn_mn10300;
343 disassemble = print_insn_big_nios2;
345 disassemble = print_insn_little_nios2;
350 disassemble = print_insn_or1k;
355 disassemble = print_insn_pdp11;
360 disassemble = print_insn_pj;
364 case bfd_arch_powerpc:
367 case bfd_arch_rs6000:
369 #if defined ARCH_powerpc || defined ARCH_rs6000
371 disassemble = print_insn_big_powerpc;
373 disassemble = print_insn_little_powerpc;
378 disassemble = print_insn_pru;
383 disassemble = print_insn_riscv;
388 disassemble = rl78_get_disassembler (abfd);
393 disassemble = print_insn_rx;
398 disassemble = print_insn_s390;
404 disassemble = print_insn_big_score;
406 disassemble = print_insn_little_score;
411 disassemble = print_insn_sh;
416 disassemble = print_insn_sparc;
421 disassemble = print_insn_spu;
426 disassemble = print_insn_tic30;
431 disassemble = print_insn_tic4x;
435 case bfd_arch_tic54x:
436 disassemble = print_insn_tic54x;
441 disassemble = print_insn_tic6x;
446 disassemble = print_insn_tic80;
451 disassemble = print_insn_ft32;
456 case bfd_arch_v850_rh850:
457 disassemble = print_insn_v850;
461 case bfd_arch_wasm32:
462 disassemble = print_insn_wasm32;
467 disassemble = print_insn_xgate;
470 #ifdef ARCH_xstormy16
471 case bfd_arch_xstormy16:
472 disassemble = print_insn_xstormy16;
477 disassemble = print_insn_xc16x;
481 case bfd_arch_xtensa:
482 disassemble = print_insn_xtensa;
487 disassemble = print_insn_z80;
492 if (mach == bfd_mach_z8001)
493 disassemble = print_insn_z8001;
495 disassemble = print_insn_z8002;
500 disassemble = print_insn_vax;
504 case bfd_arch_visium:
505 disassemble = print_insn_visium;
510 disassemble = print_insn_frv;
515 disassemble = print_insn_moxie;
519 case bfd_arch_iq2000:
520 disassemble = print_insn_iq2000;
525 disassemble = print_insn_m32c;
529 case bfd_arch_tilegx:
530 disassemble = print_insn_tilegx;
534 case bfd_arch_tilepro:
535 disassemble = print_insn_tilepro;
545 disassembler_usage (FILE *stream ATTRIBUTE_UNUSED)
548 print_aarch64_disassembler_options (stream);
551 print_arc_disassembler_options (stream);
554 print_arm_disassembler_options (stream);
557 print_mips_disassembler_options (stream);
560 print_nfp_disassembler_options (stream);
563 print_ppc_disassembler_options (stream);
566 print_riscv_disassembler_options (stream);
569 print_i386_disassembler_options (stream);
572 print_s390_disassembler_options (stream);
575 print_wasm32_disassembler_options (stream);
582 disassemble_init_for_target (struct disassemble_info * info)
590 case bfd_arch_aarch64:
591 info->symbol_is_valid = aarch64_symbol_is_valid;
592 info->disassembler_needs_relocs = TRUE;
597 info->symbol_is_valid = arm_symbol_is_valid;
598 info->disassembler_needs_relocs = TRUE;
603 info->symbol_is_valid = csky_symbol_is_valid;
604 info->disassembler_needs_relocs = TRUE;
610 info->skip_zeroes = 16;
615 info->skip_zeroes = 32;
620 info->skip_zeroes = 256;
621 info->skip_zeroes_at_end = 0;
626 info->disassembler_needs_relocs = TRUE;
631 /* This processor in fact is little endian. The value set here
632 reflects the way opcodes are written in the cgen description. */
633 info->endian = BFD_ENDIAN_BIG;
634 if (! info->insn_sets)
636 info->insn_sets = cgen_bitset_create (ISA_MAX);
637 if (info->mach == bfd_mach_m16c)
638 cgen_bitset_set (info->insn_sets, ISA_M16C);
640 cgen_bitset_set (info->insn_sets, ISA_M32C);
646 info->disassembler_needs_relocs = TRUE;
650 case bfd_arch_powerpc:
653 case bfd_arch_rs6000:
655 #if defined (ARCH_powerpc) || defined (ARCH_rs6000)
656 disassemble_init_powerpc (info);
661 info->symbol_is_valid = riscv_symbol_is_valid;
665 case bfd_arch_wasm32:
666 disassemble_init_wasm32 (info);
671 disassemble_init_s390 (info);
676 disassemble_init_nds32 (info);
684 /* Remove whitespace and consecutive commas from OPTIONS. */
687 remove_whitespace_and_extra_commas (char *options)
695 /* Strip off all trailing whitespace and commas. */
696 for (len = strlen (options); len > 0; len--)
698 if (!ISSPACE (options[len - 1]) && options[len - 1] != ',')
700 options[len - 1] = '\0';
703 /* Convert all remaining whitespace to commas. */
704 for (i = 0; options[i] != '\0'; i++)
705 if (ISSPACE (options[i]))
708 /* Remove consecutive commas. */
709 for (str = options; *str != '\0'; str++)
710 if (*str == ',' && (*(str + 1) == ',' || str == options))
712 char *next = str + 1;
718 memmove (str, next, len);
719 next[len - (size_t)(next - str)] = '\0';
721 return (strlen (options) != 0) ? options : NULL;
724 /* Like STRCMP, but treat ',' the same as '\0' so that we match
725 strings like "foobar" against "foobar,xxyyzz,...". */
728 disassembler_options_cmp (const char *s1, const char *s2)
730 unsigned char c1, c2;
734 c1 = (unsigned char) *s1++;
737 c2 = (unsigned char) *s2++;