* Makefile.in: Rebuild dependencies.
[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 *}
37648010
KR
114. {* start-sanitize-rce *}
115. bfd_arch_rce, {* Motorola RCE *}
116. {* end-sanitize-rce *}
117. {* start-sanitize-arc *}
118. bfd_arch_arc, {* Argonaut RISC Core *}
119. {* end-sanitize-arc *}
9fda1a39
SC
120. bfd_arch_last
121. };
c618de01 122
c618de01
SC
123
124*/
125
4a81b561 126#include "bfd.h"
cbdc7909 127#include "sysdep.h"
4e6f9223
SC
128#include "libbfd.h"
129
9fda1a39
SC
130/*
131
132SUBSECTION
133 bfd_arch_info
134
135DESCRIPTION
136 This structure contains information on architectures for use
137 within BFD.
138
9fda1a39
SC
139.
140.typedef struct bfd_arch_info
141.{
142. int bits_per_word;
143. int bits_per_address;
144. int bits_per_byte;
145. enum bfd_architecture arch;
146. long mach;
147. char *arch_name;
148. CONST char *printable_name;
ce07dd7c
KR
149. unsigned int section_align_power;
150. {* true if this is the default machine for the architecture *}
9fda1a39 151. boolean the_default;
71c0bae0
KR
152. CONST struct bfd_arch_info * (*compatible)
153. PARAMS ((CONST struct bfd_arch_info *a,
154. CONST struct bfd_arch_info *b));
9fda1a39 155.
71c0bae0
KR
156. boolean (*scan) PARAMS ((CONST struct bfd_arch_info *, CONST char *));
157. {* How to disassemble an instruction, producing a printable
158. representation on a specified stdio stream. This isn't
159. defined for most processors at present, because of the size
160. of the additional tables it would drag in, and because gdb
161. wants to use a different interface. *}
162. unsigned int (*disassemble) PARAMS ((bfd_vma addr, CONST char *data,
163. PTR stream));
9fda1a39 164.
ce07dd7c 165. struct bfd_arch_info *next;
9fda1a39 166.} bfd_arch_info_type;
4e6f9223
SC
167*/
168
cbdc7909 169bfd_arch_info_type *bfd_arch_info_list;
4a81b561 170
4a81b561 171
9fda1a39 172/*
9fda1a39
SC
173FUNCTION
174 bfd_printable_name
4e6f9223 175
ce07dd7c
KR
176SYNOPSIS
177 CONST char *bfd_printable_name(bfd *abfd);
178
9fda1a39
SC
179DESCRIPTION
180 Return a printable string representing the architecture and machine
c188b0be 181 from the pointer to the architecture info structure.
4e6f9223 182
4e6f9223
SC
183*/
184
185CONST char *
d94aca1a
MT
186bfd_printable_name (abfd)
187 bfd *abfd;
4e6f9223
SC
188{
189 return abfd->arch_info->printable_name;
4a81b561
DHW
190}
191
4e6f9223
SC
192
193
9fda1a39
SC
194/*
195FUNCTION
196 bfd_scan_arch
4e6f9223 197
ce07dd7c 198SYNOPSIS
c188b0be 199 bfd_arch_info_type *bfd_scan_arch(CONST char *string);
ce07dd7c 200
9fda1a39 201DESCRIPTION
c188b0be
DM
202 Figure out if BFD supports any cpu which could be described with
203 the name @var{string}. Return a pointer to an <<arch_info>>
9fda1a39
SC
204 structure if a machine is found, otherwise NULL.
205
c618de01 206*/
4a81b561 207
cbdc7909 208bfd_arch_info_type *
d94aca1a
MT
209bfd_scan_arch (string)
210 CONST char *string;
4a81b561 211{
cbdc7909 212 struct bfd_arch_info *ap;
4e6f9223
SC
213
214 /* Look through all the installed architectures */
215 for (ap = bfd_arch_info_list;
cbdc7909 216 ap != (bfd_arch_info_type *)NULL;
4e6f9223 217 ap = ap->next) {
cbdc7909 218
4e6f9223
SC
219 if (ap->scan(ap, string))
220 return ap;
4a81b561 221 }
cbdc7909 222 return (bfd_arch_info_type *)NULL;
4e6f9223
SC
223}
224
4a81b561 225
4a81b561 226
9fda1a39
SC
227/*
228FUNCTION
229 bfd_arch_get_compatible
230
ce07dd7c
KR
231SYNOPSIS
232 CONST bfd_arch_info_type *bfd_arch_get_compatible(
233 CONST bfd *abfd,
234 CONST bfd *bbfd);
4e6f9223 235
ce07dd7c 236DESCRIPTION
c188b0be
DM
237 Determine whether two BFDs'
238 architectures and machine types are compatible. Calculates
9fda1a39
SC
239 the lowest common denominator between the two architectures
240 and machine types implied by the BFDs and returns a pointer to
c188b0be 241 an <<arch_info>> structure describing the compatible machine.
4e6f9223
SC
242*/
243
cbdc7909 244CONST bfd_arch_info_type *
d94aca1a
MT
245bfd_arch_get_compatible (abfd, bbfd)
246 CONST bfd *abfd;
247 CONST bfd *bbfd;
4e6f9223
SC
248{
249 return abfd->arch_info->compatible(abfd->arch_info,bbfd->arch_info);
4a81b561
DHW
250}
251
4e6f9223 252
9fda1a39 253/*
ce07dd7c 254INTERNAL_DEFINITION
9fda1a39 255 bfd_default_arch_struct
4e6f9223 256
9fda1a39 257DESCRIPTION
ce07dd7c
KR
258 The <<bfd_default_arch_struct>> is an item of
259 <<bfd_arch_info_type>> which has been initialized to a fairly
260 generic state. A BFD starts life by pointing to this
261 structure, until the correct back end has determined the real
262 architecture of the file.
9fda1a39
SC
263
264.extern bfd_arch_info_type bfd_default_arch_struct;
4e6f9223 265
4e6f9223
SC
266*/
267
cbdc7909 268bfd_arch_info_type bfd_default_arch_struct =
9fda1a39 269{
2e235c93 270 32,32,8,bfd_arch_unknown,0,"unknown","unknown",2,true,
9fda1a39
SC
271 bfd_default_compatible,
272 bfd_default_scan,
273 0,
9fda1a39 274};
4e6f9223 275
9fda1a39
SC
276/*
277FUNCTION
278 bfd_set_arch_info
4e6f9223 279
9fda1a39 280SYNOPSIS
c188b0be 281 void bfd_set_arch_info(bfd *abfd, bfd_arch_info_type *arg);
4e6f9223 282
c188b0be
DM
283DESCRIPTION
284 Set the architecture info of @var{abfd} to @var{arg}.
4e6f9223
SC
285*/
286
d94aca1a
MT
287void
288bfd_set_arch_info (abfd, arg)
289 bfd *abfd;
290 bfd_arch_info_type *arg;
4a81b561 291{
4e6f9223
SC
292 abfd->arch_info = arg;
293}
294
9fda1a39 295/*
ce07dd7c 296INTERNAL_FUNCTION
9fda1a39
SC
297 bfd_default_set_arch_mach
298
9fda1a39
SC
299SYNOPSIS
300 boolean bfd_default_set_arch_mach(bfd *abfd,
301 enum bfd_architecture arch,
302 unsigned long mach);
4e6f9223 303
ce07dd7c 304DESCRIPTION
c188b0be
DM
305 Set the architecture and machine type in BFD @var{abfd}
306 to @var{arch} and @var{mach}. Find the correct
307 pointer to a structure and insert it into the <<arch_info>>
ce07dd7c 308 pointer.
4e6f9223
SC
309*/
310
d94aca1a
MT
311boolean
312bfd_default_set_arch_mach (abfd, arch, mach)
313 bfd *abfd;
314 enum bfd_architecture arch;
315 unsigned long mach;
4e6f9223 316{
cbdc7909 317 static struct bfd_arch_info *old_ptr = &bfd_default_arch_struct;
4e6f9223
SC
318 boolean found = false;
319 /* run through the table to find the one we want, we keep a little
320 cache to speed things up */
321 if (old_ptr == 0 || arch != old_ptr->arch || mach != old_ptr->mach) {
cbdc7909
JG
322 bfd_arch_info_type *ptr;
323 old_ptr = (bfd_arch_info_type *)NULL;
4e6f9223 324 for (ptr = bfd_arch_info_list;
cbdc7909 325 ptr != (bfd_arch_info_type *)NULL;
4e6f9223
SC
326 ptr= ptr->next) {
327 if (ptr->arch == arch &&
328 ((ptr->mach == mach) || (ptr->the_default && mach == 0))) {
329 old_ptr = ptr;
330 found = true;
331 break;
332 }
4a81b561 333 }
4e6f9223
SC
334 if (found==false) {
335 /*looked for it and it wasn't there, so put in the default */
336 old_ptr = &bfd_default_arch_struct;
d94aca1a 337 bfd_set_error (bfd_error_bad_value);
4e6f9223
SC
338 }
339 }
340 else {
341 /* it was in the cache */
342 found = true;
4a81b561
DHW
343 }
344
4e6f9223
SC
345 abfd->arch_info = old_ptr;
346
347 return found;
4a81b561 348}
4a81b561 349
4e6f9223 350
9fda1a39
SC
351/*
352FUNCTION
353 bfd_get_arch
4e6f9223 354
ce07dd7c
KR
355SYNOPSIS
356 enum bfd_architecture bfd_get_arch(bfd *abfd);
357
9fda1a39 358DESCRIPTION
c188b0be
DM
359 Return the enumerated type which describes the BFD @var{abfd}'s
360 architecture.
4e6f9223 361
4e6f9223
SC
362*/
363
d94aca1a
MT
364enum bfd_architecture
365bfd_get_arch (abfd)
366 bfd *abfd;
9fda1a39 367{
4e6f9223 368 return abfd->arch_info->arch;
9fda1a39 369}
4e6f9223 370
9fda1a39
SC
371/*
372FUNCTION
373 bfd_get_mach
4e6f9223 374
ce07dd7c
KR
375SYNOPSIS
376 unsigned long bfd_get_mach(bfd *abfd);
377
9fda1a39 378DESCRIPTION
c188b0be
DM
379 Return the long type which describes the BFD @var{abfd}'s
380 machine.
4e6f9223
SC
381*/
382
9fda1a39 383unsigned long
d94aca1a
MT
384bfd_get_mach (abfd)
385 bfd *abfd;
4a81b561 386{
4e6f9223 387 return abfd->arch_info->mach;
9fda1a39 388}
4e6f9223 389
9fda1a39
SC
390/*
391FUNCTION
392 bfd_arch_bits_per_byte
4e6f9223 393
ce07dd7c
KR
394SYNOPSIS
395 unsigned int bfd_arch_bits_per_byte(bfd *abfd);
396
9fda1a39 397DESCRIPTION
c188b0be
DM
398 Return the number of bits in one of the BFD @var{abfd}'s
399 architecture's bytes.
4e6f9223 400
4e6f9223
SC
401*/
402
d94aca1a
MT
403unsigned int
404bfd_arch_bits_per_byte (abfd)
405 bfd *abfd;
c188b0be
DM
406{
407 return abfd->arch_info->bits_per_byte;
408}
4e6f9223 409
9fda1a39
SC
410/*
411FUNCTION
412 bfd_arch_bits_per_address
4e6f9223 413
9fda1a39
SC
414SYNOPSIS
415 unsigned int bfd_arch_bits_per_address(bfd *abfd);
ce07dd7c
KR
416
417DESCRIPTION
c188b0be
DM
418 Return the number of bits in one of the BFD @var{abfd}'s
419 architecture's addresses.
4e6f9223
SC
420*/
421
d94aca1a
MT
422unsigned int
423bfd_arch_bits_per_address (abfd)
424 bfd *abfd;
c188b0be
DM
425{
426 return abfd->arch_info->bits_per_address;
427}
4e6f9223
SC
428
429
c188b0be
DM
430extern void bfd_a29k_arch PARAMS ((void));
431extern void bfd_alpha_arch PARAMS ((void));
37648010
KR
432/* start-sanitize-arc */
433extern void bfd_arc_arch PARAMS ((void));
434/* end-sanitize-arc */
d94aca1a 435extern void bfd_arm_arch PARAMS ((void));
71c0bae0 436extern void bfd_h8300_arch PARAMS ((void));
2e235c93 437extern void bfd_h8500_arch PARAMS ((void));
c188b0be
DM
438extern void bfd_hppa_arch PARAMS ((void));
439extern void bfd_i386_arch PARAMS ((void));
71c0bae0 440extern void bfd_i960_arch PARAMS ((void));
71c0bae0 441extern void bfd_m68k_arch PARAMS ((void));
c188b0be 442extern void bfd_m88k_arch PARAMS ((void));
71c0bae0 443extern void bfd_mips_arch PARAMS ((void));
d94aca1a 444extern void bfd_powerpc_arch PARAMS ((void));
71c0bae0 445extern void bfd_rs6000_arch PARAMS ((void));
c188b0be 446extern void bfd_sh_arch PARAMS ((void));
03c4ce2f
MT
447/* start-sanitize-rce */
448extern void bfd_rce_arch PARAMS ((void));
449/* end-sanitize-rce */
c188b0be
DM
450extern void bfd_sparc_arch PARAMS ((void));
451extern void bfd_vax_arch PARAMS ((void));
71c0bae0 452extern void bfd_we32k_arch PARAMS ((void));
c188b0be 453extern void bfd_z8k_arch PARAMS ((void));
d94aca1a 454extern void bfd_ns32k_arch PARAMS ((void));
4e6f9223 455
37648010 456static void (*const archures_init_table[]) PARAMS ((void)) =
4e6f9223
SC
457{
458#ifdef SELECT_ARCHITECTURES
459 SELECT_ARCHITECTURES,
460#else
4e6f9223 461 bfd_a29k_arch,
2e235c93 462 bfd_alpha_arch,
37648010
KR
463/* start-sanitize-arc */
464 bfd_arc_arch,
465/* end-sanitize-arc */
d94aca1a 466 bfd_arm_arch,
4e6f9223 467 bfd_h8300_arch,
2e235c93
ILT
468 bfd_h8500_arch,
469 bfd_hppa_arch,
4e6f9223 470 bfd_i386_arch,
4e6f9223
SC
471 bfd_i960_arch,
472 bfd_m68k_arch,
2e235c93
ILT
473 bfd_m88k_arch,
474 bfd_mips_arch,
d94aca1a 475 bfd_powerpc_arch,
cbdc7909 476 bfd_rs6000_arch,
2e235c93 477 bfd_sh_arch,
03c4ce2f
MT
478/* start-sanitize-rce */
479 bfd_rce_arch,
480/* end-sanitize-rce */
2e235c93
ILT
481 bfd_sparc_arch,
482 bfd_vax_arch,
71c0bae0 483 bfd_we32k_arch,
2e235c93 484 bfd_z8k_arch,
d94aca1a 485 bfd_ns32k_arch,
4e6f9223
SC
486#endif
487 0
488 };
489
490
491
9fda1a39 492/*
ce07dd7c 493INTERNAL_FUNCTION
9fda1a39 494 bfd_arch_init
4e6f9223 495
ce07dd7c 496SYNOPSIS
c188b0be 497 void bfd_arch_init(void);
ce07dd7c 498
9fda1a39 499DESCRIPTION
c188b0be 500 Initialize the architecture dispatch table by
9fda1a39
SC
501 calling all installed architecture packages and getting them
502 to poke around.
4e6f9223
SC
503*/
504
505void
d94aca1a 506bfd_arch_init ()
4e6f9223 507{
37648010
KR
508 void (*const *ptable) PARAMS ((void));
509 for (ptable = archures_init_table; *ptable ; ptable++)
510 (*ptable)();
4a81b561
DHW
511}
512
4e6f9223 513
9fda1a39 514/*
ce07dd7c 515INTERNAL_FUNCTION
9fda1a39 516 bfd_arch_linkin
4e6f9223 517
9fda1a39 518SYNOPSIS
c188b0be 519 void bfd_arch_linkin(bfd_arch_info_type *ptr);
4e6f9223 520
ce07dd7c 521DESCRIPTION
c188b0be 522 Link the architecture info structure @var{ptr} into the list.
4e6f9223
SC
523*/
524
d94aca1a
MT
525void
526bfd_arch_linkin (ptr)
527 bfd_arch_info_type *ptr;
4a81b561 528{
4e6f9223
SC
529 ptr->next = bfd_arch_info_list;
530 bfd_arch_info_list = ptr;
531}
4a81b561 532
4a81b561 533
9fda1a39 534/*
ce07dd7c 535INTERNAL_FUNCTION
9fda1a39 536 bfd_default_compatible
4e6f9223 537
9fda1a39
SC
538SYNOPSIS
539 CONST bfd_arch_info_type *bfd_default_compatible
540 (CONST bfd_arch_info_type *a,
541 CONST bfd_arch_info_type *b);
ce07dd7c
KR
542
543DESCRIPTION
544 The default function for testing for compatibility.
4e6f9223
SC
545*/
546
cbdc7909 547CONST bfd_arch_info_type *
d94aca1a
MT
548bfd_default_compatible (a,b)
549 CONST bfd_arch_info_type *a;
550 CONST bfd_arch_info_type *b;
4e6f9223 551{
cbdc7909 552 if(a->arch != b->arch) return NULL;
4e6f9223
SC
553
554 if (a->mach > b->mach) {
555 return a;
556 }
557 if (b->mach > a->mach) {
558 return b;
559 }
560 return a;
4a81b561
DHW
561}
562
563
9fda1a39 564/*
ce07dd7c 565INTERNAL_FUNCTION
9fda1a39
SC
566 bfd_default_scan
567
9fda1a39 568SYNOPSIS
c188b0be 569 boolean bfd_default_scan(CONST struct bfd_arch_info *info, CONST char *string);
4e6f9223 570
ce07dd7c
KR
571DESCRIPTION
572 The default function for working out whether this is an
573 architecture hit and a machine hit.
4e6f9223
SC
574*/
575
576boolean
d94aca1a
MT
577bfd_default_scan (info, string)
578 CONST struct bfd_arch_info *info;
579 CONST char *string;
4a81b561 580{
9fda1a39
SC
581 CONST char *ptr_src;
582 CONST char *ptr_tst;
583 unsigned long number;
584 enum bfd_architecture arch;
585 /* First test for an exact match */
586 if (strcmp(string, info->printable_name) == 0) return true;
587
588 /* See how much of the supplied string matches with the
589 architecture, eg the string m68k:68020 would match the 68k entry
590 up to the :, then we get left with the machine number */
591
592 for (ptr_src = string,
593 ptr_tst = info->arch_name;
594 *ptr_src && *ptr_tst;
595 ptr_src++,
596 ptr_tst++)
597 {
4e6f9223 598 if (*ptr_src != *ptr_tst) break;
9fda1a39 599 }
4e6f9223 600
9fda1a39
SC
601 /* Chewed up as much of the architecture as will match, skip any
602 colons */
603 if (*ptr_src == ':') ptr_src++;
4e6f9223 604
9fda1a39
SC
605 if (*ptr_src == 0) {
606 /* nothing more, then only keep this one if it is the default
607 machine for this architecture */
608 return info->the_default;
609 }
610 number = 0;
611 while (isdigit(*ptr_src)) {
612 number = number * 10 + *ptr_src - '0';
613 ptr_src++;
614 }
615
616 switch (number)
617 {
2e235c93
ILT
618 case 300:
619 arch = bfd_arch_h8300;
620 break;
621
622 case 500:
623 arch = bfd_arch_h8500;
624 break;
625
9fda1a39
SC
626 case 68010:
627 case 68020:
628 case 68030:
629 case 68040:
630 case 68332:
631 case 68050:
632 case 68000:
633 arch = bfd_arch_m68k;
634 break;
635 case 386:
636 case 80386:
637 case 486:
71c0bae0 638 case 80486:
9fda1a39
SC
639 arch = bfd_arch_i386;
640 break;
641 case 29000:
642 arch = bfd_arch_a29k;
643 break;
4a81b561 644
71c0bae0
KR
645 case 8000:
646 arch = bfd_arch_z8k;
647 break;
648
649 case 32000:
650 arch = bfd_arch_we32k;
9fda1a39 651 break;
4e6f9223 652
9fda1a39
SC
653 case 860:
654 case 80860:
655 arch = bfd_arch_i860;
656 break;
71c0bae0
KR
657 case 960:
658 case 80960:
659 arch = bfd_arch_i960;
660 break;
661
662 case 2000:
663 case 3000:
664 case 4000:
665 case 4400:
666 arch = bfd_arch_mips;
667 break;
4a81b561 668
9fda1a39
SC
669 case 6000:
670 arch = bfd_arch_rs6000;
671 break;
672
673 default:
674 return false;
675 }
676 if (arch != info->arch)
677 return false;
678
679 if (number != info->mach)
680 return false;
681
682 return true;
4a81b561 683}
c618de01
SC
684
685
9fda1a39
SC
686/*
687FUNCTION
688 bfd_get_arch_info
c618de01 689
9fda1a39 690SYNOPSIS
c188b0be 691 bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
c618de01 692
c188b0be
DM
693DESCRIPTION
694 Return the architecture info struct in @var{abfd}.
4e6f9223 695*/
c618de01 696
cbdc7909 697bfd_arch_info_type *
d94aca1a
MT
698bfd_get_arch_info (abfd)
699 bfd *abfd;
4e6f9223
SC
700{
701 return abfd->arch_info;
702}
cbdc7909
JG
703
704
9fda1a39
SC
705/*
706FUNCTION
707 bfd_lookup_arch
708
9fda1a39
SC
709SYNOPSIS
710 bfd_arch_info_type *bfd_lookup_arch
711 (enum bfd_architecture
712 arch,
713 long machine);
cbdc7909 714
ce07dd7c 715DESCRIPTION
c188b0be
DM
716 Look for the architecure info structure which matches the
717 arguments @var{arch} and @var{machine}. A machine of 0 matches the
ce07dd7c
KR
718 machine/architecture structure which marks itself as the
719 default.
cbdc7909
JG
720*/
721
722bfd_arch_info_type *
d94aca1a
MT
723bfd_lookup_arch (arch, machine)
724 enum bfd_architecture arch;
725 long machine;
cbdc7909 726{
9fda1a39
SC
727 bfd_arch_info_type *ap;
728 bfd_check_init();
729 for (ap = bfd_arch_info_list;
730 ap != (bfd_arch_info_type *)NULL;
731 ap = ap->next) {
732 if (ap->arch == arch &&
733 ((ap->mach == machine)
734 || (ap->the_default && machine == 0))) {
735 return ap;
736 }
737 }
738 return (bfd_arch_info_type *)NULL;
cbdc7909
JG
739}
740
741
9fda1a39
SC
742/*
743FUNCTION
744 bfd_printable_arch_mach
745
ce07dd7c 746SYNOPSIS
c188b0be 747 CONST char *bfd_printable_arch_mach
ce07dd7c
KR
748 (enum bfd_architecture arch, unsigned long machine);
749
9fda1a39
SC
750DESCRIPTION
751 Return a printable string representing the architecture and
752 machine type.
cbdc7909 753
c188b0be 754 This routine is depreciated.
cbdc7909
JG
755*/
756
757CONST char *
d94aca1a
MT
758bfd_printable_arch_mach (arch, machine)
759 enum bfd_architecture arch;
760 unsigned long machine;
cbdc7909 761{
9fda1a39
SC
762 bfd_arch_info_type *ap = bfd_lookup_arch(arch, machine);
763 if(ap) return ap->printable_name;
764 return "UNKNOWN!";
cbdc7909 765}
This page took 0.192717 seconds and 4 git commands to generate.