1 /* Select disassembly routine for specified architecture.
2 Copyright (C) 1994-2018 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"
58 #define ARCH_microblaze
95 #define ARCH_xstormy16
104 #include "m32c-desc.h"
108 disassembler (enum bfd_architecture a
,
109 bfd_boolean big ATTRIBUTE_UNUSED
,
110 unsigned long mach ATTRIBUTE_UNUSED
,
111 bfd
*abfd ATTRIBUTE_UNUSED
)
113 disassembler_ftype disassemble
;
117 /* If you add a case to this table, also add it to the
118 ARCH_all definition right above this function. */
120 case bfd_arch_aarch64
:
121 disassemble
= print_insn_aarch64
;
126 disassemble
= print_insn_alpha
;
131 disassemble
= arc_get_disassembler (abfd
);
137 disassemble
= print_insn_big_arm
;
139 disassemble
= print_insn_little_arm
;
144 disassemble
= print_insn_avr
;
149 disassemble
= print_insn_bfin
;
154 disassemble
= print_insn_cr16
;
159 disassemble
= cris_get_disassembler (abfd
);
164 disassemble
= print_insn_crx
;
169 disassemble
= print_insn_d10v
;
174 disassemble
= print_insn_d30v
;
179 /* As far as I know we only handle big-endian DLX objects. */
180 disassemble
= print_insn_dlx
;
185 if (mach
== bfd_mach_h8300h
|| mach
== bfd_mach_h8300hn
)
186 disassemble
= print_insn_h8300h
;
187 else if (mach
== bfd_mach_h8300s
188 || mach
== bfd_mach_h8300sn
189 || mach
== bfd_mach_h8300sx
190 || mach
== bfd_mach_h8300sxn
)
191 disassemble
= print_insn_h8300s
;
193 disassemble
= print_insn_h8300
;
198 disassemble
= print_insn_hppa
;
206 disassemble
= print_insn_i386
;
211 disassemble
= print_insn_ia64
;
216 disassemble
= print_insn_ip2k
;
220 case bfd_arch_epiphany
:
221 disassemble
= print_insn_epiphany
;
226 disassemble
= print_insn_fr30
;
231 disassemble
= print_insn_lm32
;
236 disassemble
= print_insn_m32r
;
239 #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) \
240 || defined(ARCH_9s12x) || defined(ARCH_m9s12xg)
241 case bfd_arch_m68hc11
:
242 disassemble
= print_insn_m68hc11
;
244 case bfd_arch_m68hc12
:
245 disassemble
= print_insn_m68hc12
;
247 case bfd_arch_m9s12x
:
248 disassemble
= print_insn_m9s12x
;
250 case bfd_arch_m9s12xg
:
251 disassemble
= print_insn_m9s12xg
;
254 #if defined(ARCH_s12z)
256 disassemble
= print_insn_s12z
;
261 disassemble
= print_insn_m68k
;
266 disassemble
= print_insn_mt
;
269 #ifdef ARCH_microblaze
270 case bfd_arch_microblaze
:
271 disassemble
= print_insn_microblaze
;
275 case bfd_arch_msp430
:
276 disassemble
= print_insn_msp430
;
281 disassemble
= print_insn_nds32
;
286 disassemble
= print_insn_nfp
;
291 disassemble
= print_insn_ns32k
;
296 disassemble
= print_insn_mcore
;
301 disassemble
= print_insn_mep
;
306 disassemble
= print_insn_metag
;
312 disassemble
= print_insn_big_mips
;
314 disassemble
= print_insn_little_mips
;
319 disassemble
= print_insn_mmix
;
323 case bfd_arch_mn10200
:
324 disassemble
= print_insn_mn10200
;
328 case bfd_arch_mn10300
:
329 disassemble
= print_insn_mn10300
;
335 disassemble
= print_insn_big_nios2
;
337 disassemble
= print_insn_little_nios2
;
342 disassemble
= print_insn_or1k
;
347 disassemble
= print_insn_pdp11
;
352 disassemble
= print_insn_pj
;
356 case bfd_arch_powerpc
:
359 case bfd_arch_rs6000
:
361 #if defined ARCH_powerpc || defined ARCH_rs6000
363 disassemble
= print_insn_big_powerpc
;
365 disassemble
= print_insn_little_powerpc
;
370 disassemble
= print_insn_pru
;
375 disassemble
= print_insn_riscv
;
380 disassemble
= rl78_get_disassembler (abfd
);
385 disassemble
= print_insn_rx
;
390 disassemble
= print_insn_s390
;
396 disassemble
= print_insn_big_score
;
398 disassemble
= print_insn_little_score
;
403 disassemble
= print_insn_sh
;
408 disassemble
= print_insn_sparc
;
413 disassemble
= print_insn_spu
;
418 disassemble
= print_insn_tic30
;
423 disassemble
= print_insn_tic4x
;
427 case bfd_arch_tic54x
:
428 disassemble
= print_insn_tic54x
;
433 disassemble
= print_insn_tic6x
;
438 disassemble
= print_insn_tic80
;
443 disassemble
= print_insn_ft32
;
448 case bfd_arch_v850_rh850
:
449 disassemble
= print_insn_v850
;
453 case bfd_arch_wasm32
:
454 disassemble
= print_insn_wasm32
;
459 disassemble
= print_insn_xgate
;
462 #ifdef ARCH_xstormy16
463 case bfd_arch_xstormy16
:
464 disassemble
= print_insn_xstormy16
;
469 disassemble
= print_insn_xc16x
;
473 case bfd_arch_xtensa
:
474 disassemble
= print_insn_xtensa
;
479 disassemble
= print_insn_z80
;
484 if (mach
== bfd_mach_z8001
)
485 disassemble
= print_insn_z8001
;
487 disassemble
= print_insn_z8002
;
492 disassemble
= print_insn_vax
;
496 case bfd_arch_visium
:
497 disassemble
= print_insn_visium
;
502 disassemble
= print_insn_frv
;
507 disassemble
= print_insn_moxie
;
511 case bfd_arch_iq2000
:
512 disassemble
= print_insn_iq2000
;
517 disassemble
= print_insn_m32c
;
521 case bfd_arch_tilegx
:
522 disassemble
= print_insn_tilegx
;
526 case bfd_arch_tilepro
:
527 disassemble
= print_insn_tilepro
;
537 disassembler_usage (FILE *stream ATTRIBUTE_UNUSED
)
540 print_aarch64_disassembler_options (stream
);
543 print_arc_disassembler_options (stream
);
546 print_arm_disassembler_options (stream
);
549 print_mips_disassembler_options (stream
);
552 print_nfp_disassembler_options (stream
);
555 print_ppc_disassembler_options (stream
);
558 print_riscv_disassembler_options (stream
);
561 print_i386_disassembler_options (stream
);
564 print_s390_disassembler_options (stream
);
567 print_wasm32_disassembler_options (stream
);
574 disassemble_init_for_target (struct disassemble_info
* info
)
582 case bfd_arch_aarch64
:
583 info
->symbol_is_valid
= aarch64_symbol_is_valid
;
584 info
->disassembler_needs_relocs
= TRUE
;
589 info
->symbol_is_valid
= arm_symbol_is_valid
;
590 info
->disassembler_needs_relocs
= TRUE
;
595 info
->skip_zeroes
= 16;
600 info
->skip_zeroes
= 32;
605 info
->skip_zeroes
= 256;
606 info
->skip_zeroes_at_end
= 0;
611 info
->disassembler_needs_relocs
= TRUE
;
616 /* This processor in fact is little endian. The value set here
617 reflects the way opcodes are written in the cgen description. */
618 info
->endian
= BFD_ENDIAN_BIG
;
619 if (! info
->insn_sets
)
621 info
->insn_sets
= cgen_bitset_create (ISA_MAX
);
622 if (info
->mach
== bfd_mach_m16c
)
623 cgen_bitset_set (info
->insn_sets
, ISA_M16C
);
625 cgen_bitset_set (info
->insn_sets
, ISA_M32C
);
631 info
->disassembler_needs_relocs
= TRUE
;
635 case bfd_arch_powerpc
:
638 case bfd_arch_rs6000
:
640 #if defined (ARCH_powerpc) || defined (ARCH_rs6000)
641 disassemble_init_powerpc (info
);
645 case bfd_arch_wasm32
:
646 disassemble_init_wasm32 (info
);
651 disassemble_init_s390 (info
);
659 /* Remove whitespace and consecutive commas from OPTIONS. */
662 remove_whitespace_and_extra_commas (char *options
)
670 /* Strip off all trailing whitespace and commas. */
671 for (len
= strlen (options
); len
> 0; len
--)
673 if (!ISSPACE (options
[len
- 1]) && options
[len
- 1] != ',')
675 options
[len
- 1] = '\0';
678 /* Convert all remaining whitespace to commas. */
679 for (i
= 0; options
[i
] != '\0'; i
++)
680 if (ISSPACE (options
[i
]))
683 /* Remove consecutive commas. */
684 for (str
= options
; *str
!= '\0'; str
++)
685 if (*str
== ',' && (*(str
+ 1) == ',' || str
== options
))
687 char *next
= str
+ 1;
693 memmove (str
, next
, len
);
694 next
[len
- (size_t)(next
- str
)] = '\0';
696 return (strlen (options
) != 0) ? options
: NULL
;
699 /* Like STRCMP, but treat ',' the same as '\0' so that we match
700 strings like "foobar" against "foobar,xxyyzz,...". */
703 disassembler_options_cmp (const char *s1
, const char *s2
)
705 unsigned char c1
, c2
;
709 c1
= (unsigned char) *s1
++;
712 c2
= (unsigned char) *s2
++;