Coverage Report

Created: 2026-07-25 10:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/opcodes/disassemble.c
Line
Count
Source
1
/* Select disassembly routine for specified architecture.
2
   Copyright (C) 1994-2026 Free Software Foundation, Inc.
3
4
   This file is part of the GNU opcodes library.
5
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.
10
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.
15
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.  */
20
21
#include "sysdep.h"
22
#include "disassemble.h"
23
#include "safe-ctype.h"
24
#include "opintl.h"
25
26
#ifdef ARCH_all
27
#ifdef BFD64
28
#define ARCH_aarch64
29
#define ARCH_alpha
30
#define ARCH_bpf
31
#define ARCH_ia64
32
#define ARCH_loongarch
33
#define ARCH_mips
34
#define ARCH_mmix
35
#define ARCH_nfp
36
#define ARCH_riscv
37
#define ARCH_score
38
#define ARCH_tilegx
39
#endif
40
#define ARCH_arc
41
#define ARCH_arm
42
#define ARCH_avr
43
#define ARCH_bfin
44
#define ARCH_cr16
45
#define ARCH_cris
46
#define ARCH_crx
47
#define ARCH_csky
48
#define ARCH_d10v
49
#define ARCH_d30v
50
#define ARCH_dlx
51
#define ARCH_epiphany
52
#define ARCH_fr30
53
#define ARCH_frv
54
#define ARCH_ft32
55
#define ARCH_h8300
56
#define ARCH_hppa
57
#define ARCH_i386
58
#define ARCH_ip2k
59
#define ARCH_iq2000
60
#define ARCH_kvx
61
#define ARCH_lm32
62
#define ARCH_m32c
63
#define ARCH_m32r
64
#define ARCH_m68hc11
65
#define ARCH_m68hc12
66
#define ARCH_m68k
67
#define ARCH_mcore
68
#define ARCH_mep
69
#define ARCH_metag
70
#define ARCH_microblaze
71
#define ARCH_mn10200
72
#define ARCH_mn10300
73
#define ARCH_moxie
74
#define ARCH_mt
75
#define ARCH_msp430
76
#define ARCH_nds32
77
#define ARCH_ns32k
78
#define ARCH_or1k
79
#define ARCH_pdp11
80
#define ARCH_pj
81
#define ARCH_powerpc
82
#define ARCH_pru
83
#define ARCH_rs6000
84
#define ARCH_rl78
85
#define ARCH_rx
86
#define ARCH_s12z
87
#define ARCH_s390
88
#define ARCH_sh
89
#define ARCH_sparc
90
#define ARCH_spu
91
#define ARCH_tic30
92
#define ARCH_tic4x
93
#define ARCH_tic54x
94
#define ARCH_tic6x
95
#define ARCH_tilepro
96
#define ARCH_v850
97
#define ARCH_vax
98
#define ARCH_visium
99
#define ARCH_wasm32
100
#define ARCH_xstormy16
101
#define ARCH_xgate
102
#define ARCH_xtensa
103
#define ARCH_z80
104
#define ARCH_z8k
105
#endif
106
107
#ifdef ARCH_m32c
108
#include "m32c-desc.h"
109
#endif
110
111
disassembler_ftype
112
disassembler (enum bfd_architecture a,
113
        bool big ATTRIBUTE_UNUSED,
114
        unsigned long mach ATTRIBUTE_UNUSED,
115
        bfd *abfd ATTRIBUTE_UNUSED)
116
128k
{
117
128k
  disassembler_ftype disassemble;
118
119
128k
  switch (a)
120
128k
    {
121
      /* If you add a case to this table, also add it to the
122
   ARCH_all definition right above this function.  */
123
0
#ifdef ARCH_aarch64
124
23.2k
    case bfd_arch_aarch64:
125
23.2k
      disassemble = print_insn_aarch64;
126
23.2k
      break;
127
0
#endif
128
0
#ifdef ARCH_alpha
129
468
    case bfd_arch_alpha:
130
468
      disassemble = print_insn_alpha;
131
468
      break;
132
0
#endif
133
0
#ifdef ARCH_arc
134
3.76k
    case bfd_arch_arc:
135
3.76k
      disassemble = arc_get_disassembler (abfd);
136
3.76k
      break;
137
0
#endif
138
0
#ifdef ARCH_arm
139
18.0k
    case bfd_arch_arm:
140
18.0k
      if (big)
141
7.56k
  disassemble = print_insn_big_arm;
142
10.5k
      else
143
10.5k
  disassemble = print_insn_little_arm;
144
18.0k
      break;
145
0
#endif
146
0
#ifdef ARCH_avr
147
376
    case bfd_arch_avr:
148
376
      disassemble = print_insn_avr;
149
376
      break;
150
0
#endif
151
0
#ifdef ARCH_bfin
152
3.21k
    case bfd_arch_bfin:
153
3.21k
      disassemble = print_insn_bfin;
154
3.21k
      break;
155
0
#endif
156
0
#ifdef ARCH_cr16
157
416
    case bfd_arch_cr16:
158
416
      disassemble = print_insn_cr16;
159
416
      break;
160
0
#endif
161
0
#ifdef ARCH_cris
162
730
    case bfd_arch_cris:
163
730
      disassemble = cris_get_disassembler (abfd);
164
730
      break;
165
0
#endif
166
0
#ifdef ARCH_crx
167
390
    case bfd_arch_crx:
168
390
      disassemble = print_insn_crx;
169
390
      break;
170
0
#endif
171
0
#ifdef ARCH_csky
172
1.08k
    case bfd_arch_csky:
173
1.08k
      disassemble = csky_get_disassembler (abfd);
174
1.08k
      break;
175
0
#endif
176
177
0
#ifdef ARCH_d10v
178
188
    case bfd_arch_d10v:
179
188
      disassemble = print_insn_d10v;
180
188
      break;
181
0
#endif
182
0
#ifdef ARCH_d30v
183
308
    case bfd_arch_d30v:
184
308
      disassemble = print_insn_d30v;
185
308
      break;
186
0
#endif
187
0
#ifdef ARCH_dlx
188
97
    case bfd_arch_dlx:
189
      /* As far as I know we only handle big-endian DLX objects.  */
190
97
      disassemble = print_insn_dlx;
191
97
      break;
192
0
#endif
193
0
#ifdef ARCH_h8300
194
494
    case bfd_arch_h8300:
195
494
      if (mach == bfd_mach_h8300h || mach == bfd_mach_h8300hn)
196
38
  disassemble = print_insn_h8300h;
197
456
      else if (mach == bfd_mach_h8300s
198
446
         || mach == bfd_mach_h8300sn
199
441
         || mach == bfd_mach_h8300sx
200
430
         || mach == bfd_mach_h8300sxn)
201
44
  disassemble = print_insn_h8300s;
202
412
      else
203
412
  disassemble = print_insn_h8300;
204
494
      break;
205
0
#endif
206
0
#ifdef ARCH_hppa
207
881
    case bfd_arch_hppa:
208
881
      disassemble = print_insn_hppa;
209
881
      break;
210
0
#endif
211
0
#ifdef ARCH_i386
212
15.6k
    case bfd_arch_i386:
213
15.9k
    case bfd_arch_iamcu:
214
15.9k
      disassemble = print_insn_i386;
215
15.9k
      break;
216
0
#endif
217
0
#ifdef ARCH_ia64
218
317
    case bfd_arch_ia64:
219
317
      disassemble = print_insn_ia64;
220
317
      break;
221
0
#endif
222
0
#ifdef ARCH_ip2k
223
107
    case bfd_arch_ip2k:
224
107
      disassemble = print_insn_ip2k;
225
107
      break;
226
0
#endif
227
0
#ifdef ARCH_bpf
228
63
    case bfd_arch_bpf:
229
63
      disassemble = print_insn_bpf;
230
63
      break;
231
0
#endif
232
0
#ifdef ARCH_epiphany
233
221
    case bfd_arch_epiphany:
234
221
      disassemble = print_insn_epiphany;
235
221
      break;
236
0
#endif
237
0
#ifdef ARCH_fr30
238
296
    case bfd_arch_fr30:
239
296
      disassemble = print_insn_fr30;
240
296
      break;
241
0
#endif
242
0
#ifdef ARCH_kvx
243
677
    case bfd_arch_kvx:
244
677
      disassemble = print_insn_kvx;
245
677
      break;
246
0
#endif
247
0
#ifdef ARCH_lm32
248
129
    case bfd_arch_lm32:
249
129
      disassemble = print_insn_lm32;
250
129
      break;
251
0
#endif
252
0
#ifdef ARCH_m32r
253
290
    case bfd_arch_m32r:
254
290
      disassemble = print_insn_m32r;
255
290
      break;
256
0
#endif
257
0
#if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) \
258
0
    || defined(ARCH_9s12x) || defined(ARCH_m9s12xg)
259
71
    case bfd_arch_m68hc11:
260
71
      disassemble = print_insn_m68hc11;
261
71
      break;
262
220
    case bfd_arch_m68hc12:
263
220
      disassemble = print_insn_m68hc12;
264
220
      break;
265
175
    case bfd_arch_m9s12x:
266
175
      disassemble = print_insn_m9s12x;
267
175
      break;
268
91
    case bfd_arch_m9s12xg:
269
91
      disassemble = print_insn_m9s12xg;
270
91
      break;
271
0
#endif
272
0
#if defined(ARCH_s12z)
273
872
    case bfd_arch_s12z:
274
872
      disassemble = print_insn_s12z;
275
872
      break;
276
0
#endif
277
0
#ifdef ARCH_m68k
278
1.10k
    case bfd_arch_m68k:
279
1.10k
      disassemble = print_insn_m68k;
280
1.10k
      break;
281
0
#endif
282
0
#ifdef ARCH_mt
283
279
    case bfd_arch_mt:
284
279
      disassemble = print_insn_mt;
285
279
      break;
286
0
#endif
287
0
#ifdef ARCH_microblaze
288
280
    case bfd_arch_microblaze:
289
280
      disassemble = print_insn_microblaze;
290
280
      break;
291
0
#endif
292
0
#ifdef ARCH_msp430
293
745
    case bfd_arch_msp430:
294
745
      disassemble = print_insn_msp430;
295
745
      break;
296
0
#endif
297
0
#ifdef ARCH_nds32
298
1.25k
    case bfd_arch_nds32:
299
1.25k
      disassemble = print_insn_nds32;
300
1.25k
      break;
301
0
#endif
302
0
#ifdef ARCH_nfp
303
1.02k
    case bfd_arch_nfp:
304
1.02k
      disassemble = print_insn_nfp;
305
1.02k
      break;
306
0
#endif
307
0
#ifdef ARCH_ns32k
308
676
    case bfd_arch_ns32k:
309
676
      disassemble = print_insn_ns32k;
310
676
      break;
311
0
#endif
312
0
#ifdef ARCH_mcore
313
365
    case bfd_arch_mcore:
314
365
      disassemble = print_insn_mcore;
315
365
      break;
316
0
#endif
317
0
#ifdef ARCH_mep
318
270
    case bfd_arch_mep:
319
270
      disassemble = print_insn_mep;
320
270
      break;
321
0
#endif
322
0
#ifdef ARCH_metag
323
3.08k
    case bfd_arch_metag:
324
3.08k
      disassemble = print_insn_metag;
325
3.08k
      break;
326
0
#endif
327
0
#ifdef ARCH_mips
328
8.02k
    case bfd_arch_mips:
329
8.02k
      if (big)
330
3.17k
  disassemble = print_insn_big_mips;
331
4.85k
      else
332
4.85k
  disassemble = print_insn_little_mips;
333
8.02k
      break;
334
0
#endif
335
0
#ifdef ARCH_mmix
336
351
    case bfd_arch_mmix:
337
351
      disassemble = print_insn_mmix;
338
351
      break;
339
0
#endif
340
0
#ifdef ARCH_mn10200
341
344
    case bfd_arch_mn10200:
342
344
      disassemble = print_insn_mn10200;
343
344
      break;
344
0
#endif
345
0
#ifdef ARCH_mn10300
346
556
    case bfd_arch_mn10300:
347
556
      disassemble = print_insn_mn10300;
348
556
      break;
349
0
#endif
350
0
#ifdef ARCH_or1k
351
180
    case bfd_arch_or1k:
352
180
      disassemble = print_insn_or1k;
353
180
      break;
354
0
#endif
355
0
#ifdef ARCH_pdp11
356
436
    case bfd_arch_pdp11:
357
436
      disassemble = print_insn_pdp11;
358
436
      break;
359
0
#endif
360
0
#ifdef ARCH_pj
361
0
    case bfd_arch_pj:
362
0
      disassemble = print_insn_pj;
363
0
      break;
364
0
#endif
365
0
#ifdef ARCH_powerpc
366
1.15k
    case bfd_arch_powerpc:
367
1.15k
#endif
368
1.15k
#ifdef ARCH_rs6000
369
1.31k
    case bfd_arch_rs6000:
370
1.31k
#endif
371
1.31k
#if defined ARCH_powerpc || defined ARCH_rs6000
372
1.31k
      if (big)
373
487
  disassemble = print_insn_big_powerpc;
374
825
      else
375
825
  disassemble = print_insn_little_powerpc;
376
1.31k
      break;
377
0
#endif
378
0
#ifdef ARCH_pru
379
170
    case bfd_arch_pru:
380
170
      disassemble = print_insn_pru;
381
170
      break;
382
0
#endif
383
0
#ifdef ARCH_riscv
384
1.57k
    case bfd_arch_riscv:
385
1.57k
      disassemble = print_insn_riscv;
386
1.57k
      break;
387
0
#endif
388
0
#ifdef ARCH_rl78
389
4.61k
    case bfd_arch_rl78:
390
4.61k
      disassemble = rl78_get_disassembler (abfd);
391
4.61k
      break;
392
0
#endif
393
0
#ifdef ARCH_rx
394
13.2k
    case bfd_arch_rx:
395
13.2k
      disassemble = print_insn_rx;
396
13.2k
      break;
397
0
#endif
398
0
#ifdef ARCH_s390
399
274
    case bfd_arch_s390:
400
274
      disassemble = print_insn_s390;
401
274
      break;
402
0
#endif
403
0
#ifdef ARCH_score
404
496
    case bfd_arch_score:
405
496
      if (big)
406
122
  disassemble = print_insn_big_score;
407
374
      else
408
374
  disassemble = print_insn_little_score;
409
496
     break;
410
0
#endif
411
0
#ifdef ARCH_sh
412
1.22k
    case bfd_arch_sh:
413
1.22k
      disassemble = print_insn_sh;
414
1.22k
      break;
415
0
#endif
416
0
#ifdef ARCH_sparc
417
612
    case bfd_arch_sparc:
418
612
      disassemble = print_insn_sparc;
419
612
      break;
420
0
#endif
421
0
#ifdef ARCH_spu
422
312
    case bfd_arch_spu:
423
312
      disassemble = print_insn_spu;
424
312
      break;
425
0
#endif
426
0
#ifdef ARCH_tic30
427
561
    case bfd_arch_tic30:
428
561
      disassemble = print_insn_tic30;
429
561
      break;
430
0
#endif
431
0
#ifdef ARCH_tic4x
432
420
    case bfd_arch_tic4x:
433
420
      disassemble = print_insn_tic4x;
434
420
      break;
435
0
#endif
436
0
#ifdef ARCH_tic54x
437
571
    case bfd_arch_tic54x:
438
571
      disassemble = print_insn_tic54x;
439
571
      break;
440
0
#endif
441
0
#ifdef ARCH_tic6x
442
273
    case bfd_arch_tic6x:
443
273
      disassemble = print_insn_tic6x;
444
273
      break;
445
0
#endif
446
0
#ifdef ARCH_ft32
447
219
    case bfd_arch_ft32:
448
219
      disassemble = print_insn_ft32;
449
219
      break;
450
0
#endif
451
0
#ifdef ARCH_v850
452
374
    case bfd_arch_v850:
453
592
    case bfd_arch_v850_rh850:
454
592
      disassemble = print_insn_v850;
455
592
      break;
456
0
#endif
457
0
#ifdef ARCH_wasm32
458
559
    case bfd_arch_wasm32:
459
559
      disassemble = print_insn_wasm32;
460
559
      break;
461
0
#endif
462
0
#ifdef ARCH_xgate
463
191
    case bfd_arch_xgate:
464
191
      disassemble = print_insn_xgate;
465
191
      break;
466
0
#endif
467
0
#ifdef ARCH_xstormy16
468
168
    case bfd_arch_xstormy16:
469
168
      disassemble = print_insn_xstormy16;
470
168
      break;
471
0
#endif
472
0
#ifdef ARCH_xtensa
473
4.38k
    case bfd_arch_xtensa:
474
4.38k
      disassemble = print_insn_xtensa;
475
4.38k
      break;
476
0
#endif
477
0
#ifdef ARCH_z80
478
578
    case bfd_arch_z80:
479
578
      disassemble = print_insn_z80;
480
578
      break;
481
0
#endif
482
0
#ifdef ARCH_z8k
483
409
    case bfd_arch_z8k:
484
409
      if (mach == bfd_mach_z8001)
485
119
  disassemble = print_insn_z8001;
486
290
      else
487
290
  disassemble = print_insn_z8002;
488
409
      break;
489
0
#endif
490
0
#ifdef ARCH_vax
491
333
    case bfd_arch_vax:
492
333
      disassemble = print_insn_vax;
493
333
      break;
494
0
#endif
495
0
#ifdef ARCH_visium
496
753
     case bfd_arch_visium:
497
753
       disassemble = print_insn_visium;
498
753
       break;
499
0
#endif
500
0
#ifdef ARCH_frv
501
377
    case bfd_arch_frv:
502
377
      disassemble = print_insn_frv;
503
377
      break;
504
0
#endif
505
0
#ifdef ARCH_moxie
506
126
    case bfd_arch_moxie:
507
126
      disassemble = print_insn_moxie;
508
126
      break;
509
0
#endif
510
0
#ifdef ARCH_iq2000
511
185
    case bfd_arch_iq2000:
512
185
      disassemble = print_insn_iq2000;
513
185
      break;
514
0
#endif
515
0
#ifdef ARCH_m32c
516
788
    case bfd_arch_m32c:
517
788
      disassemble = print_insn_m32c;
518
788
      break;
519
0
#endif
520
0
#ifdef ARCH_tilegx
521
249
    case bfd_arch_tilegx:
522
249
      disassemble = print_insn_tilegx;
523
249
      break;
524
0
#endif
525
0
#ifdef ARCH_tilepro
526
227
    case bfd_arch_tilepro:
527
227
      disassemble = print_insn_tilepro;
528
227
      break;
529
0
#endif
530
0
#ifdef ARCH_loongarch
531
290
    case bfd_arch_loongarch:
532
290
      disassemble = print_insn_loongarch;
533
290
      break;
534
0
#endif
535
370
    default:
536
370
      return 0;
537
128k
    }
538
128k
  return disassemble;
539
128k
}
540
541
void
542
disassembler_usage (FILE *stream ATTRIBUTE_UNUSED)
543
0
{
544
0
#ifdef ARCH_aarch64
545
0
  print_aarch64_disassembler_options (stream);
546
0
#endif
547
0
#ifdef ARCH_arc
548
0
  print_arc_disassembler_options (stream);
549
0
#endif
550
0
#ifdef ARCH_arm
551
0
  print_arm_disassembler_options (stream);
552
0
#endif
553
0
#ifdef ARCH_mips
554
0
  print_mips_disassembler_options (stream);
555
0
#endif
556
0
#ifdef ARCH_nfp
557
0
  print_nfp_disassembler_options (stream);
558
0
#endif
559
0
#ifdef ARCH_powerpc
560
0
  print_ppc_disassembler_options (stream);
561
0
#endif
562
0
#ifdef ARCH_riscv
563
0
  print_riscv_disassembler_options (stream);
564
0
#endif
565
0
#ifdef ARCH_i386
566
0
  print_i386_disassembler_options (stream);
567
0
#endif
568
0
#ifdef ARCH_kvx
569
0
  print_kvx_disassembler_options (stream);
570
0
#endif
571
0
#ifdef ARCH_s390
572
0
  print_s390_disassembler_options (stream);
573
0
#endif
574
0
#ifdef ARCH_wasm32
575
0
  print_wasm32_disassembler_options (stream);
576
0
#endif
577
0
#ifdef ARCH_loongarch
578
0
  print_loongarch_disassembler_options (stream);
579
0
#endif
580
0
#ifdef ARCH_bpf
581
0
  print_bpf_disassembler_options (stream);
582
0
#endif
583
0
  return;
584
0
}
585
586
void
587
disassemble_init_for_target (struct disassemble_info * info)
588
128k
{
589
128k
  if (info == NULL)
590
0
    return;
591
592
128k
  switch (info->arch)
593
128k
    {
594
0
#ifdef ARCH_aarch64
595
23.2k
    case bfd_arch_aarch64:
596
23.2k
      info->symbol_is_valid = aarch64_symbol_is_valid;
597
23.2k
      info->disassembler_needs_relocs = true;
598
23.2k
      info->created_styled_output = true;
599
23.2k
      break;
600
0
#endif
601
0
#ifdef ARCH_arc
602
3.76k
    case bfd_arch_arc:
603
3.76k
      info->created_styled_output = true;
604
3.76k
      break;
605
0
#endif
606
0
#ifdef ARCH_arm
607
18.0k
    case bfd_arch_arm:
608
18.0k
      info->symbol_is_valid = arm_symbol_is_valid;
609
18.0k
      info->disassembler_needs_relocs = true;
610
18.0k
      info->created_styled_output = true;
611
18.0k
      break;
612
0
#endif
613
0
#ifdef ARCH_avr
614
376
    case bfd_arch_avr:
615
376
      info->created_styled_output = true;
616
376
      break;
617
0
#endif
618
0
#ifdef ARCH_csky
619
1.08k
    case bfd_arch_csky:
620
1.08k
      info->symbol_is_valid = csky_symbol_is_valid;
621
1.08k
      info->disassembler_needs_relocs = true;
622
1.08k
      break;
623
0
#endif
624
0
#ifdef ARCH_i386
625
15.6k
    case bfd_arch_i386:
626
15.9k
    case bfd_arch_iamcu:
627
15.9k
      info->created_styled_output = true;
628
15.9k
      break;
629
0
#endif
630
0
#ifdef ARCH_ia64
631
317
    case bfd_arch_ia64:
632
317
      info->skip_zeroes = 16;
633
317
      break;
634
0
#endif
635
0
#ifdef ARCH_loongarch
636
290
    case bfd_arch_loongarch:
637
290
      info->created_styled_output = true;
638
290
      break;
639
0
#endif
640
0
#ifdef ARCH_tic4x
641
420
    case bfd_arch_tic4x:
642
420
      info->skip_zeroes = 32;
643
420
      break;
644
0
#endif
645
0
#ifdef ARCH_m68k
646
1.10k
    case bfd_arch_m68k:
647
1.10k
      info->created_styled_output = true;
648
1.10k
      break;
649
0
#endif
650
0
#ifdef ARCH_mep
651
270
    case bfd_arch_mep:
652
270
      info->skip_zeroes = 256;
653
270
      info->skip_zeroes_at_end = 0;
654
270
      break;
655
0
#endif
656
0
#ifdef ARCH_metag
657
3.08k
    case bfd_arch_metag:
658
3.08k
      info->disassembler_needs_relocs = true;
659
3.08k
      break;
660
0
#endif
661
0
#ifdef ARCH_mips
662
8.02k
    case bfd_arch_mips:
663
8.02k
      info->created_styled_output = true;
664
8.02k
      break;
665
0
#endif
666
0
#ifdef ARCH_m32c
667
788
    case bfd_arch_m32c:
668
      /* This processor in fact is little endian.  The value set here
669
   reflects the way opcodes are written in the cgen description.  */
670
788
      info->endian = BFD_ENDIAN_BIG;
671
788
      if (!info->private_data)
672
788
  {
673
788
    info->private_data = cgen_bitset_create (ISA_MAX);
674
788
    if (info->mach == bfd_mach_m16c)
675
271
      cgen_bitset_set (info->private_data, ISA_M16C);
676
517
    else
677
517
      cgen_bitset_set (info->private_data, ISA_M32C);
678
788
  }
679
788
      break;
680
0
#endif
681
0
#ifdef ARCH_bpf
682
63
    case bfd_arch_bpf:
683
63
      info->created_styled_output = true;
684
63
      break;
685
0
#endif
686
0
#ifdef ARCH_pru
687
170
    case bfd_arch_pru:
688
170
      info->disassembler_needs_relocs = true;
689
170
      break;
690
0
#endif
691
0
#ifdef ARCH_powerpc
692
1.15k
    case bfd_arch_powerpc:
693
1.15k
#endif
694
1.15k
#ifdef ARCH_rs6000
695
1.31k
    case bfd_arch_rs6000:
696
1.31k
#endif
697
1.31k
#if defined (ARCH_powerpc) || defined (ARCH_rs6000)
698
1.31k
      disassemble_init_powerpc (info);
699
1.31k
      info->created_styled_output = true;
700
1.31k
      break;
701
0
#endif
702
0
#ifdef ARCH_riscv
703
1.57k
    case bfd_arch_riscv:
704
1.57k
      info->symbol_is_valid = riscv_symbol_is_valid;
705
1.57k
      info->created_styled_output = true;
706
1.57k
      break;
707
0
#endif
708
0
#ifdef ARCH_wasm32
709
559
    case bfd_arch_wasm32:
710
559
      disassemble_init_wasm32 (info);
711
559
      break;
712
0
#endif
713
0
#ifdef ARCH_s390
714
274
    case bfd_arch_s390:
715
274
      disassemble_init_s390 (info);
716
274
      info->created_styled_output = true;
717
274
      break;
718
0
#endif
719
0
#ifdef ARCH_nds32
720
1.25k
    case bfd_arch_nds32:
721
1.25k
      disassemble_init_nds32 (info);
722
1.25k
      break;
723
0
 #endif
724
46.2k
    default:
725
46.2k
      break;
726
128k
    }
727
128k
}
728
729
void
730
disassemble_free_target (struct disassemble_info *info)
731
128k
{
732
128k
  if (info == NULL)
733
0
    return;
734
735
128k
  switch (info->arch)
736
128k
    {
737
118k
    default:
738
118k
      return;
739
740
118k
#ifdef ARCH_m32c
741
118k
    case bfd_arch_m32c:
742
788
#endif
743
788
#if defined ARCH_m32c
744
788
      if (info->private_data)
745
788
  {
746
788
    CGEN_BITSET *mask = info->private_data;
747
788
    free (mask->bits);
748
788
  }
749
788
      break;
750
0
#endif
751
752
0
#ifdef ARCH_arc
753
3.76k
    case bfd_arch_arc:
754
3.76k
      break;
755
0
#endif
756
0
#ifdef ARCH_cris
757
730
    case bfd_arch_cris:
758
730
      break;
759
0
#endif
760
0
#ifdef ARCH_mmix
761
351
    case bfd_arch_mmix:
762
351
      break;
763
0
#endif
764
0
#ifdef ARCH_nfp
765
1.02k
    case bfd_arch_nfp:
766
1.02k
      break;
767
0
#endif
768
0
#ifdef ARCH_powerpc
769
1.15k
    case bfd_arch_powerpc:
770
1.15k
      disassemble_free_powerpc (info);
771
1.15k
      break;
772
0
#endif
773
0
#ifdef ARCH_riscv
774
1.57k
    case bfd_arch_riscv:
775
1.57k
      disassemble_free_riscv (info);
776
1.57k
      break;
777
0
#endif
778
0
#ifdef ARCH_rs6000
779
162
    case bfd_arch_rs6000:
780
162
      break;
781
128k
#endif
782
128k
    }
783
784
9.54k
  free (info->private_data);
785
9.54k
}
786
787
/* Remove whitespace and consecutive commas from OPTIONS.  */
788
789
char *
790
remove_whitespace_and_extra_commas (char *options)
791
0
{
792
0
  char *str;
793
0
  size_t i, len;
794
795
0
  if (options == NULL)
796
0
    return NULL;
797
798
  /* Strip off all trailing whitespace and commas.  */
799
0
  for (len = strlen (options); len > 0; len--)
800
0
    {
801
0
      if (!ISSPACE (options[len - 1]) && options[len - 1] != ',')
802
0
  break;
803
0
      options[len - 1] = '\0';
804
0
    }
805
806
  /* Convert all remaining whitespace to commas.  */
807
0
  for (i = 0; options[i] != '\0'; i++)
808
0
    if (ISSPACE (options[i]))
809
0
      options[i] = ',';
810
811
  /* Remove consecutive commas.  */
812
0
  for (str = options; *str != '\0'; str++)
813
0
    if (*str == ',' && (*(str + 1) == ',' || str == options))
814
0
      {
815
0
  char *next = str + 1;
816
0
  while (*next == ',')
817
0
    next++;
818
0
  len = strlen (next);
819
0
  if (str != options)
820
0
    str++;
821
0
  memmove (str, next, len);
822
0
  next[len - (size_t)(next - str)] = '\0';
823
0
      }
824
0
  return (strlen (options) != 0) ? options : NULL;
825
0
}
826
827
/* Call FUNC for each comma separated option in INFO->disassembler_options,
828
   passing a zero terminated option and DATA.  The iteration terminates
829
   should FUNC return false.  */
830
831
bool
832
for_each_disassembler_option (struct disassemble_info *info,
833
            bool (*func) (const char *, void *),
834
            void *data)
835
557k
{
836
557k
  char *opt = (char *) info->disassembler_options;
837
557k
  bool ok = true;
838
557k
  if (opt != NULL)
839
39.3k
    while (ok)
840
39.3k
      {
841
39.3k
  char *opt_end = strchr (opt, ',');
842
39.3k
  if (opt_end != NULL)
843
21.8k
    *opt_end = 0;
844
39.3k
  ok = func (opt, data);
845
39.3k
  if (opt_end == NULL)
846
17.5k
    break;
847
21.8k
  *opt_end = ',';
848
21.8k
  opt = opt_end + 1;
849
21.8k
      }
850
557k
  return ok;
851
557k
}
852
853
void
854
opcodes_assert (const char *file, int line)
855
0
{
856
0
  opcodes_error_handler (_("assertion fail %s:%d"), file, line);
857
0
  opcodes_error_handler (_("Please report this bug"));
858
0
  abort ();
859
0
}
860
861
/* Set the stream, and the styled and unstyled printf functions within
862
   INFO.  */
863
864
void
865
disassemble_set_printf (struct disassemble_info *info, void *stream,
866
      fprintf_ftype unstyled_printf,
867
      fprintf_styled_ftype styled_printf)
868
114M
{
869
114M
  info->stream = stream;
870
114M
  info->fprintf_func = unstyled_printf;
871
114M
  info->fprintf_styled_func = styled_printf;
872
114M
}