Rename r16 files to rce, and fix some more .Sanitize typos.
[deliverable/binutils-gdb.git] / bfd / archures.c
CommitLineData
c618de01 1/* BFD library support routines for architectures.
d94aca1a 2 Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
4e6f9223
SC
3 Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
4
c618de01 5This file is part of BFD, the Binary File Descriptor library.
4a81b561 6
c618de01 7This program is free software; you can redistribute it and/or modify
4a81b561 8it under the terms of the GNU General Public License as published by
c618de01
SC
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
4a81b561 11
c618de01 12This program is distributed in the hope that it will be useful,
4a81b561
DHW
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
c618de01
SC
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
9fda1a39 21/*
4e6f9223 22
9fda1a39
SC
23SECTION
24 Architectures
25
c188b0be
DM
26 BFD keeps one atom in a BFD describing the
27 architecture of the data attached to the BFD: a pointer to a
9fda1a39
SC
28 <<bfd_arch_info_type>>.
29
c188b0be 30 Pointers to structures can be requested independently of a BFD
9fda1a39 31 so that an architecture's information can be interrogated
c188b0be 32 without access to an open BFD.
9fda1a39 33
c188b0be
DM
34 The architecture information is provided by each architecture package.
35 The set of default architectures is selected by the macro
9fda1a39 36 <<SELECT_ARCHITECTURES>>. This is normally set up in the
d94aca1a 37 @file{config/@var{target}.mt} file of your choice. If the name is not
9fda1a39
SC
38 defined, then all the architectures supported are included.
39
40 When BFD starts up, all the architectures are called with an
41 initialize method. It is up to the architecture back end to
71c0bae0 42 insert as many items into the list of architectures as it wants to;
9fda1a39
SC
43 generally this would be one for each machine and one for the
44 default case (an item with a machine field of 0).
c188b0be 45
d94aca1a 46 BFD's idea of an architecture is implemented in @file{archures.c}.
c618de01
SC
47*/
48
9fda1a39
SC
49/*
50
51SUBSECTION
52 bfd_architecture
53
54DESCRIPTION
55 This enum gives the object file's CPU architecture, in a
c188b0be
DM
56 global sense---i.e., what processor family does it belong to?
57 Another field indicates which processor within
9fda1a39 58 the family is in use. The machine gives a number which
c188b0be
DM
59 distinguishes different versions of the architecture,
60 containing, for example, 2 and 3 for Intel i960 KA and i960 KB,
9fda1a39
SC
61 and 68020 and 68030 for Motorola 68020 and 68030.
62
63.enum bfd_architecture
64.{
65. bfd_arch_unknown, {* File arch not known *}
66. bfd_arch_obscure, {* Arch known, not one of these *}
67. bfd_arch_m68k, {* Motorola 68xxx *}
68. bfd_arch_vax, {* DEC Vax *}
69. bfd_arch_i960, {* Intel 960 *}
70. {* The order of the following is important.
71. lower number indicates a machine type that
72. only accepts a subset of the instructions
73. available to machines with higher numbers.
74. The exception is the "ca", which is
75. incompatible with all other machines except
76. "core". *}
77.
78.#define bfd_mach_i960_core 1
79.#define bfd_mach_i960_ka_sa 2
80.#define bfd_mach_i960_kb_sb 3
81.#define bfd_mach_i960_mc 4
82.#define bfd_mach_i960_xa 5
83.#define bfd_mach_i960_ca 6
d94aca1a
MT
84. {* start-sanitize-i960xl *}
85.#define bfd_mach_i960_xl 7
86. {* end-sanitize-i960xl *}
9fda1a39
SC
87.
88. bfd_arch_a29k, {* AMD 29000 *}
89. bfd_arch_sparc, {* SPARC *}
90. bfd_arch_mips, {* MIPS Rxxxx *}
91. bfd_arch_i386, {* Intel 386 *}
71c0bae0 92. bfd_arch_we32k, {* AT&T WE32xxx *}
9fda1a39
SC
93. bfd_arch_tahoe, {* CCI/Harris Tahoe *}
94. bfd_arch_i860, {* Intel 860 *}
95. bfd_arch_romp, {* IBM ROMP PC/RT *}
96. bfd_arch_alliant, {* Alliant *}
97. bfd_arch_convex, {* Convex *}
98. bfd_arch_m88k, {* Motorola 88xxx *}
99. bfd_arch_pyramid, {* Pyramid Technology *}
100. bfd_arch_h8300, {* Hitachi H8/300 *}
2e235c93
ILT
101.#define bfd_mach_h8300 1
102.#define bfd_mach_h8300h 2
d94aca1a 103. bfd_arch_powerpc, {* PowerPC *}
9fda1a39 104. bfd_arch_rs6000, {* IBM RS/6000 *}
e3c01e92 105. bfd_arch_hppa, {* HP PA RISC *}
71c0bae0
KR
106. bfd_arch_z8k, {* Zilog Z8000 *}
107.#define bfd_mach_z8001 1
108.#define bfd_mach_z8002 2
2e235c93
ILT
109. bfd_arch_h8500, {* Hitachi H8/500 *}
110. bfd_arch_sh, {* Hitachi SH *}
111. bfd_arch_alpha, {* Dec Alpha *}
d94aca1a
MT
112. bfd_arch_arm, {* Advanced Risc Machines ARM *}
113. bfd_arch_ns32k, {* National Semiconductors ns32000 *}
9fda1a39
SC
114. bfd_arch_last
115. };
c618de01 116
c618de01
SC
117
118*/
119
4a81b561 120#include "bfd.h"
cbdc7909 121#include "sysdep.h"
4e6f9223
SC
122#include "libbfd.h"
123
9fda1a39
SC
124/*
125
126SUBSECTION
127 bfd_arch_info
128
129DESCRIPTION
130 This structure contains information on architectures for use
131 within BFD.
132
9fda1a39
SC
133.
134.typedef struct bfd_arch_info
135.{
136. int bits_per_word;
137. int bits_per_address;
138. int bits_per_byte;
139. enum bfd_architecture arch;
140. long mach;
141. char *arch_name;
142. CONST char *printable_name;
ce07dd7c
KR
143. unsigned int section_align_power;
144. {* true if this is the default machine for the architecture *}
9fda1a39 145. boolean the_default;
71c0bae0
KR
146. CONST struct bfd_arch_info * (*compatible)
147. PARAMS ((CONST struct bfd_arch_info *a,
148. CONST struct bfd_arch_info *b));
9fda1a39 149.
71c0bae0
KR
150. boolean (*scan) PARAMS ((CONST struct bfd_arch_info *, CONST char *));
151. {* How to disassemble an instruction, producing a printable
152. representation on a specified stdio stream. This isn't
153. defined for most processors at present, because of the size
154. of the additional tables it would drag in, and because gdb
155. wants to use a different interface. *}
156. unsigned int (*disassemble) PARAMS ((bfd_vma addr, CONST char *data,
157. PTR stream));
9fda1a39 158.
ce07dd7c 159. struct bfd_arch_info *next;
9fda1a39 160.} bfd_arch_info_type;
4e6f9223
SC
161*/
162
cbdc7909 163bfd_arch_info_type *bfd_arch_info_list;
4a81b561 164
4a81b561 165
9fda1a39 166/*
9fda1a39
SC
167FUNCTION
168 bfd_printable_name
4e6f9223 169
ce07dd7c
KR
170SYNOPSIS
171 CONST char *bfd_printable_name(bfd *abfd);
172
9fda1a39
SC
173DESCRIPTION
174 Return a printable string representing the architecture and machine
c188b0be 175 from the pointer to the architecture info structure.
4e6f9223 176
4e6f9223
SC
177*/
178
179CONST char *
d94aca1a
MT
180bfd_printable_name (abfd)
181 bfd *abfd;
4e6f9223
SC
182{
183 return abfd->arch_info->printable_name;
4a81b561
DHW
184}
185
4e6f9223
SC
186
187
9fda1a39
SC
188/*
189FUNCTION
190 bfd_scan_arch
4e6f9223 191
ce07dd7c 192SYNOPSIS
c188b0be 193 bfd_arch_info_type *bfd_scan_arch(CONST char *string);
ce07dd7c 194
9fda1a39 195DESCRIPTION
c188b0be
DM
196 Figure out if BFD supports any cpu which could be described with
197 the name @var{string}. Return a pointer to an <<arch_info>>
9fda1a39
SC
198 structure if a machine is found, otherwise NULL.
199
c618de01 200*/
4a81b561 201
cbdc7909 202bfd_arch_info_type *
d94aca1a
MT
203bfd_scan_arch (string)
204 CONST char *string;
4a81b561 205{
cbdc7909 206 struct bfd_arch_info *ap;
4e6f9223
SC
207
208 /* Look through all the installed architectures */
209 for (ap = bfd_arch_info_list;
cbdc7909 210 ap != (bfd_arch_info_type *)NULL;
4e6f9223 211 ap = ap->next) {
cbdc7909 212
4e6f9223
SC
213 if (ap->scan(ap, string))
214 return ap;
4a81b561 215 }
cbdc7909 216 return (bfd_arch_info_type *)NULL;
4e6f9223
SC
217}
218
4a81b561 219
4a81b561 220
9fda1a39
SC
221/*
222FUNCTION
223 bfd_arch_get_compatible
224
ce07dd7c
KR
225SYNOPSIS
226 CONST bfd_arch_info_type *bfd_arch_get_compatible(
227 CONST bfd *abfd,
228 CONST bfd *bbfd);
4e6f9223 229
ce07dd7c 230DESCRIPTION
c188b0be
DM
231 Determine whether two BFDs'
232 architectures and machine types are compatible. Calculates
9fda1a39
SC
233 the lowest common denominator between the two architectures
234 and machine types implied by the BFDs and returns a pointer to
c188b0be 235 an <<arch_info>> structure describing the compatible machine.
4e6f9223
SC
236*/
237
cbdc7909 238CONST bfd_arch_info_type *
d94aca1a
MT
239bfd_arch_get_compatible (abfd, bbfd)
240 CONST bfd *abfd;
241 CONST bfd *bbfd;
4e6f9223
SC
242{
243 return abfd->arch_info->compatible(abfd->arch_info,bbfd->arch_info);
4a81b561
DHW
244}
245
4e6f9223 246
9fda1a39 247/*
ce07dd7c 248INTERNAL_DEFINITION
9fda1a39 249 bfd_default_arch_struct
4e6f9223 250
9fda1a39 251DESCRIPTION
ce07dd7c
KR
252 The <<bfd_default_arch_struct>> is an item of
253 <<bfd_arch_info_type>> which has been initialized to a fairly
254 generic state. A BFD starts life by pointing to this
255 structure, until the correct back end has determined the real
256 architecture of the file.
9fda1a39
SC
257
258.extern bfd_arch_info_type bfd_default_arch_struct;
4e6f9223 259
4e6f9223
SC
260*/
261
cbdc7909 262bfd_arch_info_type bfd_default_arch_struct =
9fda1a39 263{
2e235c93 264 32,32,8,bfd_arch_unknown,0,"unknown","unknown",2,true,
9fda1a39
SC
265 bfd_default_compatible,
266 bfd_default_scan,
267 0,
9fda1a39 268};
4e6f9223 269
9fda1a39
SC
270/*
271FUNCTION
272 bfd_set_arch_info
4e6f9223 273
9fda1a39 274SYNOPSIS
c188b0be 275 void bfd_set_arch_info(bfd *abfd, bfd_arch_info_type *arg);
4e6f9223 276
c188b0be
DM
277DESCRIPTION
278 Set the architecture info of @var{abfd} to @var{arg}.
4e6f9223
SC
279*/
280
d94aca1a
MT
281void
282bfd_set_arch_info (abfd, arg)
283 bfd *abfd;
284 bfd_arch_info_type *arg;
4a81b561 285{
4e6f9223
SC
286 abfd->arch_info = arg;
287}
288
9fda1a39 289/*
ce07dd7c 290INTERNAL_FUNCTION
9fda1a39
SC
291 bfd_default_set_arch_mach
292
9fda1a39
SC
293SYNOPSIS
294 boolean bfd_default_set_arch_mach(bfd *abfd,
295 enum bfd_architecture arch,
296 unsigned long mach);
4e6f9223 297
ce07dd7c 298DESCRIPTION
c188b0be
DM
299 Set the architecture and machine type in BFD @var{abfd}
300 to @var{arch} and @var{mach}. Find the correct
301 pointer to a structure and insert it into the <<arch_info>>
ce07dd7c 302 pointer.
4e6f9223
SC
303*/
304
d94aca1a
MT
305boolean
306bfd_default_set_arch_mach (abfd, arch, mach)
307 bfd *abfd;
308 enum bfd_architecture arch;
309 unsigned long mach;
4e6f9223 310{
cbdc7909 311 static struct bfd_arch_info *old_ptr = &bfd_default_arch_struct;
4e6f9223
SC
312 boolean found = false;
313 /* run through the table to find the one we want, we keep a little
314 cache to speed things up */
315 if (old_ptr == 0 || arch != old_ptr->arch || mach != old_ptr->mach) {
cbdc7909
JG
316 bfd_arch_info_type *ptr;
317 old_ptr = (bfd_arch_info_type *)NULL;
4e6f9223 318 for (ptr = bfd_arch_info_list;
cbdc7909 319 ptr != (bfd_arch_info_type *)NULL;
4e6f9223
SC
320 ptr= ptr->next) {
321 if (ptr->arch == arch &&
322 ((ptr->mach == mach) || (ptr->the_default && mach == 0))) {
323 old_ptr = ptr;
324 found = true;
325 break;
326 }
4a81b561 327 }
4e6f9223
SC
328 if (found==false) {
329 /*looked for it and it wasn't there, so put in the default */
330 old_ptr = &bfd_default_arch_struct;
d94aca1a 331 bfd_set_error (bfd_error_bad_value);
4e6f9223
SC
332 }
333 }
334 else {
335 /* it was in the cache */
336 found = true;
4a81b561
DHW
337 }
338
4e6f9223
SC
339 abfd->arch_info = old_ptr;
340
341 return found;
4a81b561 342}
4a81b561 343
4e6f9223 344
9fda1a39
SC
345/*
346FUNCTION
347 bfd_get_arch
4e6f9223 348
ce07dd7c
KR
349SYNOPSIS
350 enum bfd_architecture bfd_get_arch(bfd *abfd);
351
9fda1a39 352DESCRIPTION
c188b0be
DM
353 Return the enumerated type which describes the BFD @var{abfd}'s
354 architecture.
4e6f9223 355
4e6f9223
SC
356*/
357
d94aca1a
MT
358enum bfd_architecture
359bfd_get_arch (abfd)
360 bfd *abfd;
9fda1a39 361{
4e6f9223 362 return abfd->arch_info->arch;
9fda1a39 363}
4e6f9223 364
9fda1a39
SC
365/*
366FUNCTION
367 bfd_get_mach
4e6f9223 368
ce07dd7c
KR
369SYNOPSIS
370 unsigned long bfd_get_mach(bfd *abfd);
371
9fda1a39 372DESCRIPTION
c188b0be
DM
373 Return the long type which describes the BFD @var{abfd}'s
374 machine.
4e6f9223
SC
375*/
376
9fda1a39 377unsigned long
d94aca1a
MT
378bfd_get_mach (abfd)
379 bfd *abfd;
4a81b561 380{
4e6f9223 381 return abfd->arch_info->mach;
9fda1a39 382}
4e6f9223 383
9fda1a39
SC
384/*
385FUNCTION
386 bfd_arch_bits_per_byte
4e6f9223 387
ce07dd7c
KR
388SYNOPSIS
389 unsigned int bfd_arch_bits_per_byte(bfd *abfd);
390
9fda1a39 391DESCRIPTION
c188b0be
DM
392 Return the number of bits in one of the BFD @var{abfd}'s
393 architecture's bytes.
4e6f9223 394
4e6f9223
SC
395*/
396
d94aca1a
MT
397unsigned int
398bfd_arch_bits_per_byte (abfd)
399 bfd *abfd;
c188b0be
DM
400{
401 return abfd->arch_info->bits_per_byte;
402}
4e6f9223 403
9fda1a39
SC
404/*
405FUNCTION
406 bfd_arch_bits_per_address
4e6f9223 407
9fda1a39
SC
408SYNOPSIS
409 unsigned int bfd_arch_bits_per_address(bfd *abfd);
ce07dd7c
KR
410
411DESCRIPTION
c188b0be
DM
412 Return the number of bits in one of the BFD @var{abfd}'s
413 architecture's addresses.
4e6f9223
SC
414*/
415
d94aca1a
MT
416unsigned int
417bfd_arch_bits_per_address (abfd)
418 bfd *abfd;
c188b0be
DM
419{
420 return abfd->arch_info->bits_per_address;
421}
4e6f9223
SC
422
423
c188b0be
DM
424extern void bfd_a29k_arch PARAMS ((void));
425extern void bfd_alpha_arch PARAMS ((void));
d94aca1a 426extern void bfd_arm_arch PARAMS ((void));
71c0bae0 427extern void bfd_h8300_arch PARAMS ((void));
2e235c93 428extern void bfd_h8500_arch PARAMS ((void));
c188b0be
DM
429extern void bfd_hppa_arch PARAMS ((void));
430extern void bfd_i386_arch PARAMS ((void));
71c0bae0 431extern void bfd_i960_arch PARAMS ((void));
71c0bae0 432extern void bfd_m68k_arch PARAMS ((void));
c188b0be 433extern void bfd_m88k_arch PARAMS ((void));
71c0bae0 434extern void bfd_mips_arch PARAMS ((void));
d94aca1a 435extern void bfd_powerpc_arch PARAMS ((void));
71c0bae0 436extern void bfd_rs6000_arch PARAMS ((void));
c188b0be 437extern void bfd_sh_arch PARAMS ((void));
03c4ce2f
MT
438/* start-sanitize-rce */
439extern void bfd_rce_arch PARAMS ((void));
440/* end-sanitize-rce */
c188b0be
DM
441extern void bfd_sparc_arch PARAMS ((void));
442extern void bfd_vax_arch PARAMS ((void));
71c0bae0 443extern void bfd_we32k_arch PARAMS ((void));
c188b0be 444extern void bfd_z8k_arch PARAMS ((void));
d94aca1a 445extern void bfd_ns32k_arch PARAMS ((void));
4e6f9223 446
71c0bae0 447static void (*archures_init_table[]) PARAMS ((void)) =
4e6f9223
SC
448{
449#ifdef SELECT_ARCHITECTURES
450 SELECT_ARCHITECTURES,
451#else
4e6f9223 452 bfd_a29k_arch,
2e235c93 453 bfd_alpha_arch,
d94aca1a 454 bfd_arm_arch,
4e6f9223 455 bfd_h8300_arch,
2e235c93
ILT
456 bfd_h8500_arch,
457 bfd_hppa_arch,
4e6f9223 458 bfd_i386_arch,
4e6f9223
SC
459 bfd_i960_arch,
460 bfd_m68k_arch,
2e235c93
ILT
461 bfd_m88k_arch,
462 bfd_mips_arch,
d94aca1a 463 bfd_powerpc_arch,
cbdc7909 464 bfd_rs6000_arch,
2e235c93 465 bfd_sh_arch,
03c4ce2f
MT
466/* start-sanitize-rce */
467 bfd_rce_arch,
468/* end-sanitize-rce */
2e235c93
ILT
469 bfd_sparc_arch,
470 bfd_vax_arch,
71c0bae0 471 bfd_we32k_arch,
2e235c93 472 bfd_z8k_arch,
d94aca1a 473 bfd_ns32k_arch,
4e6f9223
SC
474#endif
475 0
476 };
477
478
479
9fda1a39 480/*
ce07dd7c 481INTERNAL_FUNCTION
9fda1a39 482 bfd_arch_init
4e6f9223 483
ce07dd7c 484SYNOPSIS
c188b0be 485 void bfd_arch_init(void);
ce07dd7c 486
9fda1a39 487DESCRIPTION
c188b0be 488 Initialize the architecture dispatch table by
9fda1a39
SC
489 calling all installed architecture packages and getting them
490 to poke around.
4e6f9223
SC
491*/
492
493void
d94aca1a 494bfd_arch_init ()
4e6f9223 495{
71c0bae0 496 void (**ptable) PARAMS ((void));
9fda1a39
SC
497 for (ptable = archures_init_table;
498 *ptable ;
499 ptable++)
500 {
4e6f9223 501 (*ptable)();
9fda1a39 502 }
4a81b561
DHW
503}
504
4e6f9223 505
9fda1a39 506/*
ce07dd7c 507INTERNAL_FUNCTION
9fda1a39 508 bfd_arch_linkin
4e6f9223 509
9fda1a39 510SYNOPSIS
c188b0be 511 void bfd_arch_linkin(bfd_arch_info_type *ptr);
4e6f9223 512
ce07dd7c 513DESCRIPTION
c188b0be 514 Link the architecture info structure @var{ptr} into the list.
4e6f9223
SC
515*/
516
d94aca1a
MT
517void
518bfd_arch_linkin (ptr)
519 bfd_arch_info_type *ptr;
4a81b561 520{
4e6f9223
SC
521 ptr->next = bfd_arch_info_list;
522 bfd_arch_info_list = ptr;
523}
4a81b561 524
4a81b561 525
9fda1a39 526/*
ce07dd7c 527INTERNAL_FUNCTION
9fda1a39 528 bfd_default_compatible
4e6f9223 529
9fda1a39
SC
530SYNOPSIS
531 CONST bfd_arch_info_type *bfd_default_compatible
532 (CONST bfd_arch_info_type *a,
533 CONST bfd_arch_info_type *b);
ce07dd7c
KR
534
535DESCRIPTION
536 The default function for testing for compatibility.
4e6f9223
SC
537*/
538
cbdc7909 539CONST bfd_arch_info_type *
d94aca1a
MT
540bfd_default_compatible (a,b)
541 CONST bfd_arch_info_type *a;
542 CONST bfd_arch_info_type *b;
4e6f9223 543{
cbdc7909 544 if(a->arch != b->arch) return NULL;
4e6f9223
SC
545
546 if (a->mach > b->mach) {
547 return a;
548 }
549 if (b->mach > a->mach) {
550 return b;
551 }
552 return a;
4a81b561
DHW
553}
554
555
9fda1a39 556/*
ce07dd7c 557INTERNAL_FUNCTION
9fda1a39
SC
558 bfd_default_scan
559
9fda1a39 560SYNOPSIS
c188b0be 561 boolean bfd_default_scan(CONST struct bfd_arch_info *info, CONST char *string);
4e6f9223 562
ce07dd7c
KR
563DESCRIPTION
564 The default function for working out whether this is an
565 architecture hit and a machine hit.
4e6f9223
SC
566*/
567
568boolean
d94aca1a
MT
569bfd_default_scan (info, string)
570 CONST struct bfd_arch_info *info;
571 CONST char *string;
4a81b561 572{
9fda1a39
SC
573 CONST char *ptr_src;
574 CONST char *ptr_tst;
575 unsigned long number;
576 enum bfd_architecture arch;
577 /* First test for an exact match */
578 if (strcmp(string, info->printable_name) == 0) return true;
579
580 /* See how much of the supplied string matches with the
581 architecture, eg the string m68k:68020 would match the 68k entry
582 up to the :, then we get left with the machine number */
583
584 for (ptr_src = string,
585 ptr_tst = info->arch_name;
586 *ptr_src && *ptr_tst;
587 ptr_src++,
588 ptr_tst++)
589 {
4e6f9223 590 if (*ptr_src != *ptr_tst) break;
9fda1a39 591 }
4e6f9223 592
9fda1a39
SC
593 /* Chewed up as much of the architecture as will match, skip any
594 colons */
595 if (*ptr_src == ':') ptr_src++;
4e6f9223 596
9fda1a39
SC
597 if (*ptr_src == 0) {
598 /* nothing more, then only keep this one if it is the default
599 machine for this architecture */
600 return info->the_default;
601 }
602 number = 0;
603 while (isdigit(*ptr_src)) {
604 number = number * 10 + *ptr_src - '0';
605 ptr_src++;
606 }
607
608 switch (number)
609 {
2e235c93
ILT
610 case 300:
611 arch = bfd_arch_h8300;
612 break;
613
614 case 500:
615 arch = bfd_arch_h8500;
616 break;
617
9fda1a39
SC
618 case 68010:
619 case 68020:
620 case 68030:
621 case 68040:
622 case 68332:
623 case 68050:
624 case 68000:
625 arch = bfd_arch_m68k;
626 break;
627 case 386:
628 case 80386:
629 case 486:
71c0bae0 630 case 80486:
9fda1a39
SC
631 arch = bfd_arch_i386;
632 break;
633 case 29000:
634 arch = bfd_arch_a29k;
635 break;
4a81b561 636
71c0bae0
KR
637 case 8000:
638 arch = bfd_arch_z8k;
639 break;
640
641 case 32000:
642 arch = bfd_arch_we32k;
9fda1a39 643 break;
4e6f9223 644
9fda1a39
SC
645 case 860:
646 case 80860:
647 arch = bfd_arch_i860;
648 break;
71c0bae0
KR
649 case 960:
650 case 80960:
651 arch = bfd_arch_i960;
652 break;
653
654 case 2000:
655 case 3000:
656 case 4000:
657 case 4400:
658 arch = bfd_arch_mips;
659 break;
4a81b561 660
9fda1a39
SC
661 case 6000:
662 arch = bfd_arch_rs6000;
663 break;
664
665 default:
666 return false;
667 }
668 if (arch != info->arch)
669 return false;
670
671 if (number != info->mach)
672 return false;
673
674 return true;
4a81b561 675}
c618de01
SC
676
677
9fda1a39
SC
678/*
679FUNCTION
680 bfd_get_arch_info
c618de01 681
9fda1a39 682SYNOPSIS
c188b0be 683 bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
c618de01 684
c188b0be
DM
685DESCRIPTION
686 Return the architecture info struct in @var{abfd}.
4e6f9223 687*/
c618de01 688
cbdc7909 689bfd_arch_info_type *
d94aca1a
MT
690bfd_get_arch_info (abfd)
691 bfd *abfd;
4e6f9223
SC
692{
693 return abfd->arch_info;
694}
cbdc7909
JG
695
696
9fda1a39
SC
697/*
698FUNCTION
699 bfd_lookup_arch
700
9fda1a39
SC
701SYNOPSIS
702 bfd_arch_info_type *bfd_lookup_arch
703 (enum bfd_architecture
704 arch,
705 long machine);
cbdc7909 706
ce07dd7c 707DESCRIPTION
c188b0be
DM
708 Look for the architecure info structure which matches the
709 arguments @var{arch} and @var{machine}. A machine of 0 matches the
ce07dd7c
KR
710 machine/architecture structure which marks itself as the
711 default.
cbdc7909
JG
712*/
713
714bfd_arch_info_type *
d94aca1a
MT
715bfd_lookup_arch (arch, machine)
716 enum bfd_architecture arch;
717 long machine;
cbdc7909 718{
9fda1a39
SC
719 bfd_arch_info_type *ap;
720 bfd_check_init();
721 for (ap = bfd_arch_info_list;
722 ap != (bfd_arch_info_type *)NULL;
723 ap = ap->next) {
724 if (ap->arch == arch &&
725 ((ap->mach == machine)
726 || (ap->the_default && machine == 0))) {
727 return ap;
728 }
729 }
730 return (bfd_arch_info_type *)NULL;
cbdc7909
JG
731}
732
733
9fda1a39
SC
734/*
735FUNCTION
736 bfd_printable_arch_mach
737
ce07dd7c 738SYNOPSIS
c188b0be 739 CONST char *bfd_printable_arch_mach
ce07dd7c
KR
740 (enum bfd_architecture arch, unsigned long machine);
741
9fda1a39
SC
742DESCRIPTION
743 Return a printable string representing the architecture and
744 machine type.
cbdc7909 745
c188b0be 746 This routine is depreciated.
cbdc7909
JG
747*/
748
749CONST char *
d94aca1a
MT
750bfd_printable_arch_mach (arch, machine)
751 enum bfd_architecture arch;
752 unsigned long machine;
cbdc7909 753{
9fda1a39
SC
754 bfd_arch_info_type *ap = bfd_lookup_arch(arch, machine);
755 if(ap) return ap->printable_name;
756 return "UNKNOWN!";
cbdc7909 757}
This page took 0.190625 seconds and 4 git commands to generate.