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
97 #define ARCH_xstormy16
103 #define INCLUDE_SHMEDIA
107 #include "m32c-desc.h"
111 disassembler (bfd
*abfd
)
113 enum bfd_architecture a
= bfd_get_arch (abfd
);
114 disassembler_ftype disassemble
;
118 /* If you add a case to this table, also add it to the
119 ARCH_all definition right above this function. */
121 case bfd_arch_aarch64
:
122 disassemble
= print_insn_aarch64
;
127 disassemble
= print_insn_alpha
;
132 disassemble
= arc_get_disassembler (abfd
);
137 if (bfd_big_endian (abfd
))
138 disassemble
= print_insn_big_arm
;
140 disassemble
= print_insn_little_arm
;
145 disassemble
= print_insn_avr
;
150 disassemble
= print_insn_bfin
;
155 disassemble
= print_insn_cr16
;
160 disassemble
= cris_get_disassembler (abfd
);
165 disassemble
= print_insn_crx
;
170 disassemble
= print_insn_d10v
;
175 disassemble
= print_insn_d30v
;
180 /* As far as I know we only handle big-endian DLX objects. */
181 disassemble
= print_insn_dlx
;
186 if (bfd_get_mach (abfd
) == bfd_mach_h8300h
187 || bfd_get_mach (abfd
) == bfd_mach_h8300hn
)
188 disassemble
= print_insn_h8300h
;
189 else if (bfd_get_mach (abfd
) == bfd_mach_h8300s
190 || bfd_get_mach (abfd
) == bfd_mach_h8300sn
191 || bfd_get_mach (abfd
) == bfd_mach_h8300sx
192 || bfd_get_mach (abfd
) == bfd_mach_h8300sxn
)
193 disassemble
= print_insn_h8300s
;
195 disassemble
= print_insn_h8300
;
200 disassemble
= print_insn_h8500
;
205 disassemble
= print_insn_hppa
;
210 disassemble
= print_insn_i370
;
218 disassemble
= print_insn_i386
;
223 disassemble
= print_insn_i860
;
228 disassemble
= print_insn_i960
;
233 disassemble
= print_insn_ia64
;
238 disassemble
= print_insn_ip2k
;
242 case bfd_arch_epiphany
:
243 disassemble
= print_insn_epiphany
;
248 disassemble
= print_insn_fr30
;
253 disassemble
= print_insn_lm32
;
258 disassemble
= print_insn_m32r
;
261 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) \
262 || defined(ARCH_9s12x) || defined(ARCH_m9s12xg)
263 case bfd_arch_m68hc11
:
264 disassemble
= print_insn_m68hc11
;
266 case bfd_arch_m68hc12
:
267 disassemble
= print_insn_m68hc12
;
269 case bfd_arch_m9s12x
:
270 disassemble
= print_insn_m9s12x
;
272 case bfd_arch_m9s12xg
:
273 disassemble
= print_insn_m9s12xg
;
278 disassemble
= print_insn_m68k
;
283 disassemble
= print_insn_m88k
;
288 disassemble
= print_insn_mt
;
291 #ifdef ARCH_microblaze
292 case bfd_arch_microblaze
:
293 disassemble
= print_insn_microblaze
;
297 case bfd_arch_msp430
:
298 disassemble
= print_insn_msp430
;
303 disassemble
= print_insn_nds32
;
308 disassemble
= print_insn_ns32k
;
313 disassemble
= print_insn_mcore
;
318 disassemble
= print_insn_mep
;
323 disassemble
= print_insn_metag
;
328 if (bfd_big_endian (abfd
))
329 disassemble
= print_insn_big_mips
;
331 disassemble
= print_insn_little_mips
;
336 disassemble
= print_insn_mmix
;
340 case bfd_arch_mn10200
:
341 disassemble
= print_insn_mn10200
;
345 case bfd_arch_mn10300
:
346 disassemble
= print_insn_mn10300
;
351 if (bfd_big_endian (abfd
))
352 disassemble
= print_insn_big_nios2
;
354 disassemble
= print_insn_little_nios2
;
359 disassemble
= print_insn_or1k
;
364 disassemble
= print_insn_pdp11
;
369 disassemble
= print_insn_pj
;
373 case bfd_arch_powerpc
:
374 if (bfd_big_endian (abfd
))
375 disassemble
= print_insn_big_powerpc
;
377 disassemble
= print_insn_little_powerpc
;
382 disassemble
= print_insn_pru
;
387 disassemble
= print_insn_riscv
;
391 case bfd_arch_rs6000
:
392 if (bfd_get_mach (abfd
) == bfd_mach_ppc_620
)
393 disassemble
= print_insn_big_powerpc
;
395 disassemble
= print_insn_rs6000
;
400 disassemble
= rl78_get_disassembler (abfd
);
405 disassemble
= print_insn_rx
;
410 disassemble
= print_insn_s390
;
415 if (bfd_big_endian (abfd
))
416 disassemble
= print_insn_big_score
;
418 disassemble
= print_insn_little_score
;
423 disassemble
= print_insn_sh
;
428 disassemble
= print_insn_sparc
;
433 disassemble
= print_insn_spu
;
438 disassemble
= print_insn_tic30
;
443 disassemble
= print_insn_tic4x
;
447 case bfd_arch_tic54x
:
448 disassemble
= print_insn_tic54x
;
453 disassemble
= print_insn_tic6x
;
458 disassemble
= print_insn_tic80
;
463 disassemble
= print_insn_ft32
;
468 case bfd_arch_v850_rh850
:
469 disassemble
= print_insn_v850
;
474 disassemble
= print_insn_w65
;
479 disassemble
= print_insn_xgate
;
482 #ifdef ARCH_xstormy16
483 case bfd_arch_xstormy16
:
484 disassemble
= print_insn_xstormy16
;
489 disassemble
= print_insn_xc16x
;
493 case bfd_arch_xtensa
:
494 disassemble
= print_insn_xtensa
;
499 disassemble
= print_insn_z80
;
504 if (bfd_get_mach(abfd
) == bfd_mach_z8001
)
505 disassemble
= print_insn_z8001
;
507 disassemble
= print_insn_z8002
;
512 disassemble
= print_insn_vax
;
516 case bfd_arch_visium
:
517 disassemble
= print_insn_visium
;
522 disassemble
= print_insn_frv
;
527 disassemble
= print_insn_moxie
;
531 case bfd_arch_iq2000
:
532 disassemble
= print_insn_iq2000
;
537 disassemble
= print_insn_m32c
;
541 case bfd_arch_tilegx
:
542 disassemble
= print_insn_tilegx
;
546 case bfd_arch_tilepro
:
547 disassemble
= print_insn_tilepro
;
557 disassembler_usage (FILE *stream ATTRIBUTE_UNUSED
)
560 print_aarch64_disassembler_options (stream
);
563 print_arc_disassembler_options (stream
);
566 print_arm_disassembler_options (stream
);
569 print_mips_disassembler_options (stream
);
572 print_ppc_disassembler_options (stream
);
575 print_riscv_disassembler_options (stream
);
578 print_i386_disassembler_options (stream
);
581 print_s390_disassembler_options (stream
);
588 disassemble_init_for_target (struct disassemble_info
* info
)
596 case bfd_arch_aarch64
:
597 info
->symbol_is_valid
= aarch64_symbol_is_valid
;
598 info
->disassembler_needs_relocs
= TRUE
;
603 info
->symbol_is_valid
= arm_symbol_is_valid
;
604 info
->disassembler_needs_relocs
= TRUE
;
609 info
->skip_zeroes
= 16;
614 info
->skip_zeroes
= 32;
619 info
->skip_zeroes
= 256;
620 info
->skip_zeroes_at_end
= 0;
625 info
->disassembler_needs_relocs
= TRUE
;
630 /* This processor in fact is little endian. The value set here
631 reflects the way opcodes are written in the cgen description. */
632 info
->endian
= BFD_ENDIAN_BIG
;
633 if (! info
->insn_sets
)
635 info
->insn_sets
= cgen_bitset_create (ISA_MAX
);
636 if (info
->mach
== bfd_mach_m16c
)
637 cgen_bitset_set (info
->insn_sets
, ISA_M16C
);
639 cgen_bitset_set (info
->insn_sets
, ISA_M32C
);
644 case bfd_arch_powerpc
:
647 case bfd_arch_rs6000
:
649 #if defined (ARCH_powerpc) || defined (ARCH_rs6000)
650 disassemble_init_powerpc (info
);
655 disassemble_init_s390 (info
);
663 /* Remove whitespace and consecutive commas from OPTIONS. */
666 remove_whitespace_and_extra_commas (char *options
)
674 /* Strip off all trailing whitespace and commas. */
675 for (len
= strlen (options
); len
> 0; len
--)
677 if (!ISSPACE (options
[len
- 1]) && options
[len
- 1] != ',')
679 options
[len
- 1] = '\0';
682 /* Convert all remaining whitespace to commas. */
683 for (i
= 0; options
[i
] != '\0'; i
++)
684 if (ISSPACE (options
[i
]))
687 /* Remove consecutive commas. */
688 for (str
= options
; *str
!= '\0'; str
++)
689 if (*str
== ',' && (*(str
+ 1) == ',' || str
== options
))
691 char *next
= str
+ 1;
697 memmove (str
, next
, len
);
698 next
[len
- (size_t)(next
- str
)] = '\0';
700 return (strlen (options
) != 0) ? options
: NULL
;
703 /* Like STRCMP, but treat ',' the same as '\0' so that we match
704 strings like "foobar" against "foobar,xxyyzz,...". */
707 disassembler_options_cmp (const char *s1
, const char *s2
)
709 unsigned char c1
, c2
;
713 c1
= (unsigned char) *s1
++;
716 c2
= (unsigned char) *s2
++;