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. */
22 #include "disassemble.h"
23 #include "safe-ctype.h"
63 #define ARCH_microblaze
99 #define ARCH_xstormy16
105 #define INCLUDE_SHMEDIA
109 #include "m32c-desc.h"
113 disassembler (enum bfd_architecture a,
114 bfd_boolean big ATTRIBUTE_UNUSED,
115 unsigned long mach ATTRIBUTE_UNUSED,
116 bfd *abfd ATTRIBUTE_UNUSED)
118 disassembler_ftype disassemble;
122 /* If you add a case to this table, also add it to the
123 ARCH_all definition right above this function. */
125 case bfd_arch_aarch64:
126 disassemble = print_insn_aarch64;
131 disassemble = print_insn_alpha;
136 disassemble = arc_get_disassembler (abfd);
142 disassemble = print_insn_big_arm;
144 disassemble = print_insn_little_arm;
149 disassemble = print_insn_avr;
154 disassemble = print_insn_bfin;
159 disassemble = print_insn_cr16;
164 disassemble = cris_get_disassembler (abfd);
169 disassemble = print_insn_crx;
174 disassemble = print_insn_d10v;
179 disassemble = print_insn_d30v;
184 /* As far as I know we only handle big-endian DLX objects. */
185 disassemble = print_insn_dlx;
190 if (mach == bfd_mach_h8300h || mach == bfd_mach_h8300hn)
191 disassemble = print_insn_h8300h;
192 else if (mach == bfd_mach_h8300s
193 || mach == bfd_mach_h8300sn
194 || mach == bfd_mach_h8300sx
195 || mach == bfd_mach_h8300sxn)
196 disassemble = print_insn_h8300s;
198 disassemble = print_insn_h8300;
203 disassemble = print_insn_h8500;
208 disassemble = print_insn_hppa;
213 disassemble = print_insn_i370;
221 disassemble = print_insn_i386;
226 disassemble = print_insn_i860;
231 disassemble = print_insn_i960;
236 disassemble = print_insn_ia64;
241 disassemble = print_insn_ip2k;
245 case bfd_arch_epiphany:
246 disassemble = print_insn_epiphany;
251 disassemble = print_insn_fr30;
256 disassemble = print_insn_lm32;
261 disassemble = print_insn_m32r;
264 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) \
265 || defined(ARCH_9s12x) || defined(ARCH_m9s12xg)
266 case bfd_arch_m68hc11:
267 disassemble = print_insn_m68hc11;
269 case bfd_arch_m68hc12:
270 disassemble = print_insn_m68hc12;
272 case bfd_arch_m9s12x:
273 disassemble = print_insn_m9s12x;
275 case bfd_arch_m9s12xg:
276 disassemble = print_insn_m9s12xg;
281 disassemble = print_insn_m68k;
286 disassemble = print_insn_m88k;
291 disassemble = print_insn_mt;
294 #ifdef ARCH_microblaze
295 case bfd_arch_microblaze:
296 disassemble = print_insn_microblaze;
300 case bfd_arch_msp430:
301 disassemble = print_insn_msp430;
306 disassemble = print_insn_nds32;
311 disassemble = print_insn_ns32k;
316 disassemble = print_insn_mcore;
321 disassemble = print_insn_mep;
326 disassemble = print_insn_metag;
332 disassemble = print_insn_big_mips;
334 disassemble = print_insn_little_mips;
339 disassemble = print_insn_mmix;
343 case bfd_arch_mn10200:
344 disassemble = print_insn_mn10200;
348 case bfd_arch_mn10300:
349 disassemble = print_insn_mn10300;
355 disassemble = print_insn_big_nios2;
357 disassemble = print_insn_little_nios2;
362 disassemble = print_insn_or1k;
367 disassemble = print_insn_pdp11;
372 disassemble = print_insn_pj;
376 case bfd_arch_powerpc:
378 disassemble = print_insn_big_powerpc;
380 disassemble = print_insn_little_powerpc;
385 disassemble = print_insn_pru;
390 disassemble = print_insn_riscv;
394 case bfd_arch_rs6000:
395 if (mach == bfd_mach_ppc_620)
396 disassemble = print_insn_big_powerpc;
398 disassemble = print_insn_rs6000;
403 disassemble = rl78_get_disassembler (abfd);
408 disassemble = print_insn_rx;
413 disassemble = print_insn_s390;
419 disassemble = print_insn_big_score;
421 disassemble = print_insn_little_score;
426 disassemble = print_insn_sh;
431 disassemble = print_insn_sparc;
436 disassemble = print_insn_spu;
441 disassemble = print_insn_tic30;
446 disassemble = print_insn_tic4x;
450 case bfd_arch_tic54x:
451 disassemble = print_insn_tic54x;
456 disassemble = print_insn_tic6x;
461 disassemble = print_insn_tic80;
466 disassemble = print_insn_ft32;
471 case bfd_arch_v850_rh850:
472 disassemble = print_insn_v850;
477 disassemble = print_insn_w65;
481 case bfd_arch_wasm32:
482 disassemble = print_insn_wasm32;
487 disassemble = print_insn_xgate;
490 #ifdef ARCH_xstormy16
491 case bfd_arch_xstormy16:
492 disassemble = print_insn_xstormy16;
497 disassemble = print_insn_xc16x;
501 case bfd_arch_xtensa:
502 disassemble = print_insn_xtensa;
507 disassemble = print_insn_z80;
512 if (mach == bfd_mach_z8001)
513 disassemble = print_insn_z8001;
515 disassemble = print_insn_z8002;
520 disassemble = print_insn_vax;
524 case bfd_arch_visium:
525 disassemble = print_insn_visium;
530 disassemble = print_insn_frv;
535 disassemble = print_insn_moxie;
539 case bfd_arch_iq2000:
540 disassemble = print_insn_iq2000;
545 disassemble = print_insn_m32c;
549 case bfd_arch_tilegx:
550 disassemble = print_insn_tilegx;
554 case bfd_arch_tilepro:
555 disassemble = print_insn_tilepro;
565 disassembler_usage (FILE *stream ATTRIBUTE_UNUSED)
568 print_aarch64_disassembler_options (stream);
571 print_arc_disassembler_options (stream);
574 print_arm_disassembler_options (stream);
577 print_mips_disassembler_options (stream);
580 print_ppc_disassembler_options (stream);
583 print_riscv_disassembler_options (stream);
586 print_i386_disassembler_options (stream);
589 print_s390_disassembler_options (stream);
592 print_wasm32_disassembler_options (stream);
599 disassemble_init_for_target (struct disassemble_info * info)
607 case bfd_arch_aarch64:
608 info->symbol_is_valid = aarch64_symbol_is_valid;
609 info->disassembler_needs_relocs = TRUE;
614 info->symbol_is_valid = arm_symbol_is_valid;
615 info->disassembler_needs_relocs = TRUE;
620 info->skip_zeroes = 16;
625 info->skip_zeroes = 32;
630 info->skip_zeroes = 256;
631 info->skip_zeroes_at_end = 0;
636 info->disassembler_needs_relocs = TRUE;
641 /* This processor in fact is little endian. The value set here
642 reflects the way opcodes are written in the cgen description. */
643 info->endian = BFD_ENDIAN_BIG;
644 if (! info->insn_sets)
646 info->insn_sets = cgen_bitset_create (ISA_MAX);
647 if (info->mach == bfd_mach_m16c)
648 cgen_bitset_set (info->insn_sets, ISA_M16C);
650 cgen_bitset_set (info->insn_sets, ISA_M32C);
655 case bfd_arch_powerpc:
658 case bfd_arch_rs6000:
660 #if defined (ARCH_powerpc) || defined (ARCH_rs6000)
661 disassemble_init_powerpc (info);
665 case bfd_arch_wasm32:
666 disassemble_init_wasm32 (info);
671 disassemble_init_s390 (info);
679 /* Remove whitespace and consecutive commas from OPTIONS. */
682 remove_whitespace_and_extra_commas (char *options)
690 /* Strip off all trailing whitespace and commas. */
691 for (len = strlen (options); len > 0; len--)
693 if (!ISSPACE (options[len - 1]) && options[len - 1] != ',')
695 options[len - 1] = '\0';
698 /* Convert all remaining whitespace to commas. */
699 for (i = 0; options[i] != '\0'; i++)
700 if (ISSPACE (options[i]))
703 /* Remove consecutive commas. */
704 for (str = options; *str != '\0'; str++)
705 if (*str == ',' && (*(str + 1) == ',' || str == options))
707 char *next = str + 1;
713 memmove (str, next, len);
714 next[len - (size_t)(next - str)] = '\0';
716 return (strlen (options) != 0) ? options : NULL;
719 /* Like STRCMP, but treat ',' the same as '\0' so that we match
720 strings like "foobar" against "foobar,xxyyzz,...". */
723 disassembler_options_cmp (const char *s1, const char *s2)
725 unsigned char c1, c2;
729 c1 = (unsigned char) *s1++;
732 c2 = (unsigned char) *s2++;