*** empty log message ***
[deliverable/binutils-gdb.git] / bfd / archures.c
CommitLineData
252b5132 1/* BFD library support routines for architectures.
7898deda 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
0dc93057 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
d4845d57 4 Free Software Foundation, Inc.
252b5132
RH
5 Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
6
3af9a47b 7 This file is part of BFD, the Binary File Descriptor library.
252b5132 8
3af9a47b
NC
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
cd123cb7 11 the Free Software Foundation; either version 3 of the License, or
3af9a47b 12 (at your option) any later version.
252b5132 13
3af9a47b
NC
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
252b5132 18
3af9a47b
NC
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
cd123cb7
NC
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
252b5132 23
252b5132 24#include "sysdep.h"
3db64b00 25#include "bfd.h"
252b5132 26#include "libbfd.h"
3882b010 27#include "safe-ctype.h"
252b5132
RH
28
29/*
30
31SECTION
32 Architectures
33
34 BFD keeps one atom in a BFD describing the
35 architecture of the data attached to the BFD: a pointer to a
0ef5a5bd 36 <<bfd_arch_info_type>>.
252b5132
RH
37
38 Pointers to structures can be requested independently of a BFD
39 so that an architecture's information can be interrogated
40 without access to an open BFD.
41
42 The architecture information is provided by each architecture package.
43 The set of default architectures is selected by the macro
44 <<SELECT_ARCHITECTURES>>. This is normally set up in the
45 @file{config/@var{target}.mt} file of your choice. If the name is not
0ef5a5bd 46 defined, then all the architectures supported are included.
252b5132
RH
47
48 When BFD starts up, all the architectures are called with an
49 initialize method. It is up to the architecture back end to
50 insert as many items into the list of architectures as it wants to;
51 generally this would be one for each machine and one for the
0ef5a5bd 52 default case (an item with a machine field of 0).
252b5132
RH
53
54 BFD's idea of an architecture is implemented in @file{archures.c}.
55*/
56
57/*
58
59SUBSECTION
60 bfd_architecture
61
62DESCRIPTION
63 This enum gives the object file's CPU architecture, in a
64 global sense---i.e., what processor family does it belong to?
65 Another field indicates which processor within
66 the family is in use. The machine gives a number which
67 distinguishes different versions of the architecture,
68 containing, for example, 2 and 3 for Intel i960 KA and i960 KB,
0ef5a5bd 69 and 68020 and 68030 for Motorola 68020 and 68030.
252b5132 70
0ef5a5bd 71.enum bfd_architecture
252b5132 72.{
c312a6a4
NC
73. bfd_arch_unknown, {* File arch not known. *}
74. bfd_arch_obscure, {* Arch known, not one of these. *}
252b5132
RH
75. bfd_arch_m68k, {* Motorola 68xxx *}
76.#define bfd_mach_m68000 1
77.#define bfd_mach_m68008 2
78.#define bfd_mach_m68010 3
79.#define bfd_mach_m68020 4
80.#define bfd_mach_m68030 5
81.#define bfd_mach_m68040 6
82.#define bfd_mach_m68060 7
83.#define bfd_mach_cpu32 8
3bdcfdf4 84.#define bfd_mach_fido 9
9840d27e
KH
85.#define bfd_mach_mcf_isa_a_nodiv 10
86.#define bfd_mach_mcf_isa_a 11
87.#define bfd_mach_mcf_isa_a_mac 12
88.#define bfd_mach_mcf_isa_a_emac 13
89.#define bfd_mach_mcf_isa_aplus 14
90.#define bfd_mach_mcf_isa_aplus_mac 15
91.#define bfd_mach_mcf_isa_aplus_emac 16
92.#define bfd_mach_mcf_isa_b_nousp 17
93.#define bfd_mach_mcf_isa_b_nousp_mac 18
94.#define bfd_mach_mcf_isa_b_nousp_emac 19
95.#define bfd_mach_mcf_isa_b 20
96.#define bfd_mach_mcf_isa_b_mac 21
97.#define bfd_mach_mcf_isa_b_emac 22
98.#define bfd_mach_mcf_isa_b_float 23
99.#define bfd_mach_mcf_isa_b_float_mac 24
100.#define bfd_mach_mcf_isa_b_float_emac 25
9a2e615a
NS
101.#define bfd_mach_mcf_isa_c 26
102.#define bfd_mach_mcf_isa_c_mac 27
103.#define bfd_mach_mcf_isa_c_emac 28
8d100c32
KH
104.#define bfd_mach_mcf_isa_c_nodiv 29
105.#define bfd_mach_mcf_isa_c_nodiv_mac 30
106.#define bfd_mach_mcf_isa_c_nodiv_emac 31
0ef5a5bd 107. bfd_arch_vax, {* DEC Vax *}
252b5132
RH
108. bfd_arch_i960, {* Intel 960 *}
109. {* The order of the following is important.
0ef5a5bd 110. lower number indicates a machine type that
252b5132
RH
111. only accepts a subset of the instructions
112. available to machines with higher numbers.
113. The exception is the "ca", which is
0ef5a5bd 114. incompatible with all other machines except
c312a6a4 115. "core". *}
252b5132
RH
116.
117.#define bfd_mach_i960_core 1
118.#define bfd_mach_i960_ka_sa 2
119.#define bfd_mach_i960_kb_sb 3
120.#define bfd_mach_i960_mc 4
121.#define bfd_mach_i960_xa 5
122.#define bfd_mach_i960_ca 6
123.#define bfd_mach_i960_jx 7
124.#define bfd_mach_i960_hx 8
125.
3b16e843
NC
126. bfd_arch_or32, {* OpenRISC 32 *}
127.
252b5132
RH
128. bfd_arch_sparc, {* SPARC *}
129.#define bfd_mach_sparc 1
130.{* The difference between v8plus and v9 is that v9 is a true 64 bit env. *}
131.#define bfd_mach_sparc_sparclet 2
132.#define bfd_mach_sparc_sparclite 3
133.#define bfd_mach_sparc_v8plus 4
c312a6a4 134.#define bfd_mach_sparc_v8plusa 5 {* with ultrasparc add'ns. *}
252b5132
RH
135.#define bfd_mach_sparc_sparclite_le 6
136.#define bfd_mach_sparc_v9 7
c312a6a4
NC
137.#define bfd_mach_sparc_v9a 8 {* with ultrasparc add'ns. *}
138.#define bfd_mach_sparc_v8plusb 9 {* with cheetah add'ns. *}
139.#define bfd_mach_sparc_v9b 10 {* with cheetah add'ns. *}
252b5132
RH
140.{* Nonzero if MACH has the v9 instruction set. *}
141.#define bfd_mach_sparc_v9_p(mach) \
19f7b010
JJ
142. ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \
143. && (mach) != bfd_mach_sparc_sparclite_le)
7946e94a
JJ
144.{* Nonzero if MACH is a 64 bit sparc architecture. *}
145.#define bfd_mach_sparc_64bit_p(mach) \
146. ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb)
e9f53129
AM
147. bfd_arch_spu, {* PowerPC SPU *}
148.#define bfd_mach_spu 256
252b5132
RH
149. bfd_arch_mips, {* MIPS Rxxxx *}
150.#define bfd_mach_mips3000 3000
151.#define bfd_mach_mips3900 3900
152.#define bfd_mach_mips4000 4000
153.#define bfd_mach_mips4010 4010
154.#define bfd_mach_mips4100 4100
155.#define bfd_mach_mips4111 4111
00707a0e 156.#define bfd_mach_mips4120 4120
252b5132
RH
157.#define bfd_mach_mips4300 4300
158.#define bfd_mach_mips4400 4400
159.#define bfd_mach_mips4600 4600
160.#define bfd_mach_mips4650 4650
161.#define bfd_mach_mips5000 5000
00707a0e
RS
162.#define bfd_mach_mips5400 5400
163.#define bfd_mach_mips5500 5500
252b5132 164.#define bfd_mach_mips6000 6000
5a7ea749 165.#define bfd_mach_mips7000 7000
252b5132 166.#define bfd_mach_mips8000 8000
0d2e43ed 167.#define bfd_mach_mips9000 9000
252b5132 168.#define bfd_mach_mips10000 10000
d1cf510e 169.#define bfd_mach_mips12000 12000
3aa3176b
TS
170.#define bfd_mach_mips14000 14000
171.#define bfd_mach_mips16000 16000
252b5132 172.#define bfd_mach_mips16 16
84ea6cf2 173.#define bfd_mach_mips5 5
350cc38d
MS
174.#define bfd_mach_mips_loongson_2e 3001
175.#define bfd_mach_mips_loongson_2f 3002
c6c98b38 176.#define bfd_mach_mips_sb1 12310201 {* octal 'SB', 01 *}
6f179bd0 177.#define bfd_mach_mips_octeon 6501
52b6b6b9 178.#define bfd_mach_mips_xlr 887682 {* decimal 'XLR' *}
a1cd6a8f 179.#define bfd_mach_mipsisa32 32
af7ee8bf 180.#define bfd_mach_mipsisa32r2 33
a1cd6a8f 181.#define bfd_mach_mipsisa64 64
5f74bc13 182.#define bfd_mach_mipsisa64r2 65
252b5132 183. bfd_arch_i386, {* Intel 386 *}
686e4055
AM
184.#define bfd_mach_i386_i386 1
185.#define bfd_mach_i386_i8086 2
186.#define bfd_mach_i386_i386_intel_syntax 3
187.#define bfd_mach_x86_64 64
188.#define bfd_mach_x86_64_intel_syntax 65
8a9036a4
L
189. bfd_arch_l1om, {* Intel L1OM *}
190.#define bfd_mach_l1om 66
191.#define bfd_mach_l1om_intel_syntax 67
252b5132
RH
192. bfd_arch_we32k, {* AT&T WE32xxx *}
193. bfd_arch_tahoe, {* CCI/Harris Tahoe *}
194. bfd_arch_i860, {* Intel 860 *}
5b93d8bb 195. bfd_arch_i370, {* IBM 360/370 Mainframes *}
252b5132 196. bfd_arch_romp, {* IBM ROMP PC/RT *}
252b5132
RH
197. bfd_arch_convex, {* Convex *}
198. bfd_arch_m88k, {* Motorola 88xxx *}
3af9a47b 199. bfd_arch_m98k, {* Motorola 98xxx *}
252b5132 200. bfd_arch_pyramid, {* Pyramid Technology *}
c2dcd04e 201. bfd_arch_h8300, {* Renesas H8/300 (formerly Hitachi H8/300) *}
8d9cd6b1
NC
202.#define bfd_mach_h8300 1
203.#define bfd_mach_h8300h 2
204.#define bfd_mach_h8300s 3
205.#define bfd_mach_h8300hn 4
206.#define bfd_mach_h8300sn 5
5d1db417 207.#define bfd_mach_h8300sx 6
f4984206 208.#define bfd_mach_h8300sxn 7
e135f41b 209. bfd_arch_pdp11, {* DEC PDP-11 *}
ce3c775b 210. bfd_arch_plugin,
252b5132 211. bfd_arch_powerpc, {* PowerPC *}
686e4055
AM
212.#define bfd_mach_ppc 32
213.#define bfd_mach_ppc64 64
87f33987
ND
214.#define bfd_mach_ppc_403 403
215.#define bfd_mach_ppc_403gc 4030
305f7588 216.#define bfd_mach_ppc_405 405
87f33987
ND
217.#define bfd_mach_ppc_505 505
218.#define bfd_mach_ppc_601 601
219.#define bfd_mach_ppc_602 602
220.#define bfd_mach_ppc_603 603
221.#define bfd_mach_ppc_ec603e 6031
222.#define bfd_mach_ppc_604 604
223.#define bfd_mach_ppc_620 620
224.#define bfd_mach_ppc_630 630
225.#define bfd_mach_ppc_750 750
226.#define bfd_mach_ppc_860 860
227.#define bfd_mach_ppc_a35 35
228.#define bfd_mach_ppc_rs64ii 642
229.#define bfd_mach_ppc_rs64iii 643
230.#define bfd_mach_ppc_7400 7400
d62b1198 231.#define bfd_mach_ppc_e500 500
19a6653c 232.#define bfd_mach_ppc_e500mc 5001
ce3d2015
AM
233.#define bfd_mach_ppc_e500mc64 5005
234.#define bfd_mach_ppc_titan 83
252b5132 235. bfd_arch_rs6000, {* IBM RS/6000 *}
686e4055 236.#define bfd_mach_rs6k 6000
87f33987
ND
237.#define bfd_mach_rs6k_rs1 6001
238.#define bfd_mach_rs6k_rsc 6003
239.#define bfd_mach_rs6k_rs2 6002
252b5132 240. bfd_arch_hppa, {* HP PA RISC *}
42acdc7c
JB
241.#define bfd_mach_hppa10 10
242.#define bfd_mach_hppa11 11
243.#define bfd_mach_hppa20 20
244.#define bfd_mach_hppa20w 25
252b5132 245. bfd_arch_d10v, {* Mitsubishi D10V *}
686e4055 246.#define bfd_mach_d10v 1
7af8cca9
MM
247.#define bfd_mach_d10v_ts2 2
248.#define bfd_mach_d10v_ts3 3
252b5132 249. bfd_arch_d30v, {* Mitsubishi D30V *}
d172d4ba 250. bfd_arch_dlx, {* DLX *}
60bcf0fa
NC
251. bfd_arch_m68hc11, {* Motorola 68HC11 *}
252. bfd_arch_m68hc12, {* Motorola 68HC12 *}
bc7c6a90
SC
253.#define bfd_mach_m6812_default 0
254.#define bfd_mach_m6812 1
255.#define bfd_mach_m6812s 2
252b5132
RH
256. bfd_arch_z8k, {* Zilog Z8000 *}
257.#define bfd_mach_z8001 1
258.#define bfd_mach_z8002 2
c2dcd04e 259. bfd_arch_h8500, {* Renesas H8/500 (formerly Hitachi H8/500) *}
ef230218 260. bfd_arch_sh, {* Renesas / SuperH SH (formerly Hitachi SH) *}
686e4055 261.#define bfd_mach_sh 1
d4845d57
JR
262.#define bfd_mach_sh2 0x20
263.#define bfd_mach_sh_dsp 0x2d
1d70c7fb
AO
264.#define bfd_mach_sh2a 0x2a
265.#define bfd_mach_sh2a_nofpu 0x2b
e38bc3b5
NC
266.#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1
267.#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2
268.#define bfd_mach_sh2a_or_sh4 0x2a3
269.#define bfd_mach_sh2a_or_sh3e 0x2a4
5177500f 270.#define bfd_mach_sh2e 0x2e
252b5132 271.#define bfd_mach_sh3 0x30
f6f9408f 272.#define bfd_mach_sh3_nommu 0x31
d4845d57 273.#define bfd_mach_sh3_dsp 0x3d
252b5132 274.#define bfd_mach_sh3e 0x3e
d4845d57 275.#define bfd_mach_sh4 0x40
af9ba621 276.#define bfd_mach_sh4_nofpu 0x41
ae51a426 277.#define bfd_mach_sh4_nommu_nofpu 0x42
af9ba621
CV
278.#define bfd_mach_sh4a 0x4a
279.#define bfd_mach_sh4a_nofpu 0x4b
280.#define bfd_mach_sh4al_dsp 0x4d
fbca6ad9 281.#define bfd_mach_sh5 0x50
252b5132
RH
282. bfd_arch_alpha, {* Dec Alpha *}
283.#define bfd_mach_alpha_ev4 0x10
284.#define bfd_mach_alpha_ev5 0x20
285.#define bfd_mach_alpha_ev6 0x30
c312a6a4 286. bfd_arch_arm, {* Advanced Risc Machines ARM. *}
5a6c6817 287.#define bfd_mach_arm_unknown 0
252b5132 288.#define bfd_mach_arm_2 1
478d07d6 289.#define bfd_mach_arm_2a 2
252b5132
RH
290.#define bfd_mach_arm_3 3
291.#define bfd_mach_arm_3M 4
478d07d6 292.#define bfd_mach_arm_4 5
252b5132 293.#define bfd_mach_arm_4T 6
478d07d6
NC
294.#define bfd_mach_arm_5 7
295.#define bfd_mach_arm_5T 8
077b8428
NC
296.#define bfd_mach_arm_5TE 9
297.#define bfd_mach_arm_XScale 10
fde78edd 298.#define bfd_mach_arm_ep9312 11
e16bb312 299.#define bfd_mach_arm_iWMMXt 12
2d447fca 300.#define bfd_mach_arm_iWMMXt2 13
252b5132
RH
301. bfd_arch_ns32k, {* National Semiconductors ns32000 *}
302. bfd_arch_w65, {* WDC 65816 *}
303. bfd_arch_tic30, {* Texas Instruments TMS320C30 *}
026df7c5 304. bfd_arch_tic4x, {* Texas Instruments TMS320C3X/4X *}
be33c5dd
SS
305.#define bfd_mach_tic3x 30
306.#define bfd_mach_tic4x 40
81635ce4 307. bfd_arch_tic54x, {* Texas Instruments TMS320C54X *}
40b36596 308. bfd_arch_tic6x, {* Texas Instruments TMS320C6X *}
252b5132
RH
309. bfd_arch_tic80, {* TI TMS320c80 (MVP) *}
310. bfd_arch_v850, {* NEC V850 *}
686e4055 311.#define bfd_mach_v850 1
252b5132 312.#define bfd_mach_v850e 'E'
1cd986c5
NC
313.#define bfd_mach_v850e1 '1'
314.#define bfd_mach_v850e2 0x4532
315.#define bfd_mach_v850e2v3 0x45325633
0d2bcfaf 316. bfd_arch_arc, {* ARC Cores *}
686e4055
AM
317.#define bfd_mach_arc_5 5
318.#define bfd_mach_arc_6 6
319.#define bfd_mach_arc_7 7
320.#define bfd_mach_arc_8 8
49f58d10
JB
321. bfd_arch_m32c, {* Renesas M16C/M32C. *}
322.#define bfd_mach_m16c 0x75
323.#define bfd_mach_m32c 0x78
26597c86 324. bfd_arch_m32r, {* Renesas M32R (formerly Mitsubishi M32R/D) *}
686e4055 325.#define bfd_mach_m32r 1 {* For backwards compatibility. *}
a23ef39f 326.#define bfd_mach_m32rx 'x'
88845958 327.#define bfd_mach_m32r2 '2'
252b5132
RH
328. bfd_arch_mn10200, {* Matsushita MN10200 *}
329. bfd_arch_mn10300, {* Matsushita MN10300 *}
330.#define bfd_mach_mn10300 300
31f8dc8f 331.#define bfd_mach_am33 330
b08fa4d3 332.#define bfd_mach_am33_2 332
252b5132
RH
333. bfd_arch_fr30,
334.#define bfd_mach_fr30 0x46523330
4e5ba5b7 335. bfd_arch_frv,
686e4055
AM
336.#define bfd_mach_frv 1
337.#define bfd_mach_frvsimple 2
4e5ba5b7
DB
338.#define bfd_mach_fr300 300
339.#define bfd_mach_fr400 400
676a64f4 340.#define bfd_mach_fr450 450
4e5ba5b7
DB
341.#define bfd_mach_frvtomcat 499 {* fr500 prototype *}
342.#define bfd_mach_fr500 500
9c8ee639 343.#define bfd_mach_fr550 550
20135e4c
NC
344. bfd_arch_moxie, {* The moxie processor *}
345.#define bfd_mach_moxie 1
252b5132 346. bfd_arch_mcore,
d9352518
DB
347. bfd_arch_mep,
348.#define bfd_mach_mep 1
349.#define bfd_mach_mep_h1 0x6831
4d28413b 350.#define bfd_mach_mep_c5 0x6335
800eeca4 351. bfd_arch_ia64, {* HP/Intel ia64 *}
686e4055
AM
352.#define bfd_mach_ia64_elf64 64
353.#define bfd_mach_ia64_elf32 32
cf88bb9f 354. bfd_arch_ip2k, {* Ubicom IP2K microcontrollers. *}
686e4055
AM
355.#define bfd_mach_ip2022 1
356.#define bfd_mach_ip2022ext 2
a75473eb
SC
357. bfd_arch_iq2000, {* Vitesse IQ2000. *}
358.#define bfd_mach_iq2000 1
359.#define bfd_mach_iq10 2
d031aafb 360. bfd_arch_mt,
de33e640
AH
361.#define bfd_mach_ms1 1
362.#define bfd_mach_mrisc2 2
6f84a2a6 363.#define bfd_mach_ms2 3
0bcb993b 364. bfd_arch_pj,
c312a6a4 365. bfd_arch_avr, {* Atmel AVR microcontrollers. *}
adde6300
AM
366.#define bfd_mach_avr1 1
367.#define bfd_mach_avr2 2
7b21ac3f 368.#define bfd_mach_avr25 25
adde6300 369.#define bfd_mach_avr3 3
7b21ac3f
EW
370.#define bfd_mach_avr31 31
371.#define bfd_mach_avr35 35
adde6300 372.#define bfd_mach_avr4 4
65aa24b6 373.#define bfd_mach_avr5 5
7b21ac3f 374.#define bfd_mach_avr51 51
28c9d252 375.#define bfd_mach_avr6 6
0f64bb02
CM
376. bfd_arch_bfin, {* ADI Blackfin *}
377.#define bfd_mach_bfin 1
3d3d428f
NC
378. bfd_arch_cr16, {* National Semiconductor CompactRISC (ie CR16). *}
379.#define bfd_mach_cr16 1
0949843d
NC
380. bfd_arch_cr16c, {* National Semiconductor CompactRISC. *}
381.#define bfd_mach_cr16c 1
1fe1f39c
NC
382. bfd_arch_crx, {* National Semiconductor CRX. *}
383.#define bfd_mach_crx 1
06c15ad7 384. bfd_arch_cris, {* Axis CRIS *}
bac23f82
HPN
385.#define bfd_mach_cris_v0_v10 255
386.#define bfd_mach_cris_v32 32
387.#define bfd_mach_cris_v10_v32 1032
c7927a3c
NC
388. bfd_arch_rx, {* Renesas RX. *}
389.#define bfd_mach_rx 0x75
a85d7ed0 390. bfd_arch_s390, {* IBM s390 *}
686e4055
AM
391.#define bfd_mach_s390_31 31
392.#define bfd_mach_s390_64 64
1c0d3aa6 393. bfd_arch_score, {* Sunplus score *}
c3b7224a
NC
394.#define bfd_mach_score3 3
395.#define bfd_mach_score7 7
b3baf5d0 396. bfd_arch_openrisc, {* OpenRISC *}
c312a6a4 397. bfd_arch_mmix, {* Donald Knuth's educational processor. *}
93fbbb04 398. bfd_arch_xstormy16,
686e4055 399.#define bfd_mach_xstormy16 1
2469cfa2 400. bfd_arch_msp430, {* Texas Instruments MSP430 architecture. *}
2469cfa2 401.#define bfd_mach_msp11 11
3b260895 402.#define bfd_mach_msp110 110
2469cfa2
NC
403.#define bfd_mach_msp12 12
404.#define bfd_mach_msp13 13
405.#define bfd_mach_msp14 14
3b260895 406.#define bfd_mach_msp15 15
d70c5fc7 407.#define bfd_mach_msp16 16
44c86e8c 408.#define bfd_mach_msp21 21
2469cfa2
NC
409.#define bfd_mach_msp31 31
410.#define bfd_mach_msp32 32
411.#define bfd_mach_msp33 33
3b260895
NC
412.#define bfd_mach_msp41 41
413.#define bfd_mach_msp42 42
2469cfa2
NC
414.#define bfd_mach_msp43 43
415.#define bfd_mach_msp44 44
d70c5fc7
NC
416. bfd_arch_xc16x, {* Infineon's XC16X Series. *}
417.#define bfd_mach_xc16x 1
418.#define bfd_mach_xc16xl 2
419.#define bfd_mach_xc16xs 3
e0001a05
NC
420. bfd_arch_xtensa, {* Tensilica's Xtensa cores. *}
421.#define bfd_mach_xtensa 1
3c9b82ba
NC
422. bfd_arch_z80,
423.#define bfd_mach_z80strict 1 {* No undocumented opcodes. *}
424.#define bfd_mach_z80 3 {* With ixl, ixh, iyl, and iyh. *}
425.#define bfd_mach_z80full 7 {* All undocumented instructions. *}
426.#define bfd_mach_r800 11 {* R800: successor with multiplication. *}
84e94c90
NC
427. bfd_arch_lm32, {* Lattice Mico32 *}
428.#define bfd_mach_lm32 1
7ba29e2a 429. bfd_arch_microblaze,{* Xilinx MicroBlaze. *}
252b5132
RH
430. bfd_arch_last
431. };
252b5132
RH
432*/
433
434/*
252b5132
RH
435SUBSECTION
436 bfd_arch_info
437
438DESCRIPTION
439 This structure contains information on architectures for use
440 within BFD.
441
442.
0ef5a5bd 443.typedef struct bfd_arch_info
252b5132
RH
444.{
445. int bits_per_word;
446. int bits_per_address;
447. int bits_per_byte;
448. enum bfd_architecture arch;
449. unsigned long mach;
450. const char *arch_name;
451. const char *printable_name;
452. unsigned int section_align_power;
b34976b6 453. {* TRUE if this is the default machine for the architecture.
aa3d5824
AM
454. The default arch should be the first entry for an arch so that
455. all the entries for that arch can be accessed via <<next>>. *}
b34976b6 456. bfd_boolean the_default;
252b5132 457. const struct bfd_arch_info * (*compatible)
c58b9523 458. (const struct bfd_arch_info *a, const struct bfd_arch_info *b);
252b5132 459.
c58b9523 460. bfd_boolean (*scan) (const struct bfd_arch_info *, const char *);
252b5132
RH
461.
462. const struct bfd_arch_info *next;
3b16e843
NC
463.}
464.bfd_arch_info_type;
465.
252b5132
RH
466*/
467
252b5132
RH
468extern const bfd_arch_info_type bfd_alpha_arch;
469extern const bfd_arch_info_type bfd_arc_arch;
470extern const bfd_arch_info_type bfd_arm_arch;
3b16e843 471extern const bfd_arch_info_type bfd_avr_arch;
0f64bb02 472extern const bfd_arch_info_type bfd_bfin_arch;
3d3d428f 473extern const bfd_arch_info_type bfd_cr16_arch;
0949843d 474extern const bfd_arch_info_type bfd_cr16c_arch;
06c15ad7 475extern const bfd_arch_info_type bfd_cris_arch;
1fe1f39c 476extern const bfd_arch_info_type bfd_crx_arch;
252b5132
RH
477extern const bfd_arch_info_type bfd_d10v_arch;
478extern const bfd_arch_info_type bfd_d30v_arch;
d172d4ba 479extern const bfd_arch_info_type bfd_dlx_arch;
3b16e843 480extern const bfd_arch_info_type bfd_fr30_arch;
4e5ba5b7 481extern const bfd_arch_info_type bfd_frv_arch;
252b5132
RH
482extern const bfd_arch_info_type bfd_h8300_arch;
483extern const bfd_arch_info_type bfd_h8500_arch;
484extern const bfd_arch_info_type bfd_hppa_arch;
5b93d8bb 485extern const bfd_arch_info_type bfd_i370_arch;
252b5132
RH
486extern const bfd_arch_info_type bfd_i386_arch;
487extern const bfd_arch_info_type bfd_i860_arch;
488extern const bfd_arch_info_type bfd_i960_arch;
3b16e843 489extern const bfd_arch_info_type bfd_ia64_arch;
cf88bb9f 490extern const bfd_arch_info_type bfd_ip2k_arch;
a75473eb 491extern const bfd_arch_info_type bfd_iq2000_arch;
9e675548 492extern const bfd_arch_info_type bfd_l1om_arch;
84e94c90 493extern const bfd_arch_info_type bfd_lm32_arch;
49f58d10 494extern const bfd_arch_info_type bfd_m32c_arch;
252b5132 495extern const bfd_arch_info_type bfd_m32r_arch;
60bcf0fa
NC
496extern const bfd_arch_info_type bfd_m68hc11_arch;
497extern const bfd_arch_info_type bfd_m68hc12_arch;
252b5132
RH
498extern const bfd_arch_info_type bfd_m68k_arch;
499extern const bfd_arch_info_type bfd_m88k_arch;
3b16e843 500extern const bfd_arch_info_type bfd_mcore_arch;
d9352518 501extern const bfd_arch_info_type bfd_mep_arch;
252b5132 502extern const bfd_arch_info_type bfd_mips_arch;
7ba29e2a 503extern const bfd_arch_info_type bfd_microblaze_arch;
3b16e843 504extern const bfd_arch_info_type bfd_mmix_arch;
252b5132
RH
505extern const bfd_arch_info_type bfd_mn10200_arch;
506extern const bfd_arch_info_type bfd_mn10300_arch;
9e675548 507extern const bfd_arch_info_type bfd_moxie_arch;
2469cfa2 508extern const bfd_arch_info_type bfd_msp430_arch;
d031aafb 509extern const bfd_arch_info_type bfd_mt_arch;
3b16e843
NC
510extern const bfd_arch_info_type bfd_ns32k_arch;
511extern const bfd_arch_info_type bfd_openrisc_arch;
512extern const bfd_arch_info_type bfd_or32_arch;
e135f41b 513extern const bfd_arch_info_type bfd_pdp11_arch;
3b16e843 514extern const bfd_arch_info_type bfd_pj_arch;
ce3c775b 515extern const bfd_arch_info_type bfd_plugin_arch;
899f54f5
AM
516extern const bfd_arch_info_type bfd_powerpc_archs[];
517#define bfd_powerpc_arch bfd_powerpc_archs[0]
252b5132 518extern const bfd_arch_info_type bfd_rs6000_arch;
c7927a3c 519extern const bfd_arch_info_type bfd_rx_arch;
3b16e843 520extern const bfd_arch_info_type bfd_s390_arch;
1c0d3aa6 521extern const bfd_arch_info_type bfd_score_arch;
252b5132
RH
522extern const bfd_arch_info_type bfd_sh_arch;
523extern const bfd_arch_info_type bfd_sparc_arch;
e9f53129 524extern const bfd_arch_info_type bfd_spu_arch;
252b5132 525extern const bfd_arch_info_type bfd_tic30_arch;
026df7c5 526extern const bfd_arch_info_type bfd_tic4x_arch;
81635ce4 527extern const bfd_arch_info_type bfd_tic54x_arch;
40b36596 528extern const bfd_arch_info_type bfd_tic6x_arch;
252b5132 529extern const bfd_arch_info_type bfd_tic80_arch;
3b16e843 530extern const bfd_arch_info_type bfd_v850_arch;
252b5132 531extern const bfd_arch_info_type bfd_vax_arch;
252b5132 532extern const bfd_arch_info_type bfd_w65_arch;
9e675548 533extern const bfd_arch_info_type bfd_we32k_arch;
93fbbb04 534extern const bfd_arch_info_type bfd_xstormy16_arch;
e0001a05 535extern const bfd_arch_info_type bfd_xtensa_arch;
d70c5fc7 536extern const bfd_arch_info_type bfd_xc16x_arch;
3c9b82ba 537extern const bfd_arch_info_type bfd_z80_arch;
3b16e843 538extern const bfd_arch_info_type bfd_z8k_arch;
252b5132 539
3b16e843
NC
540static const bfd_arch_info_type * const bfd_archures_list[] =
541 {
252b5132 542#ifdef SELECT_ARCHITECTURES
3b16e843 543 SELECT_ARCHITECTURES,
252b5132 544#else
3b16e843
NC
545 &bfd_alpha_arch,
546 &bfd_arc_arch,
547 &bfd_arm_arch,
548 &bfd_avr_arch,
0f64bb02 549 &bfd_bfin_arch,
3d3d428f 550 &bfd_cr16_arch,
0949843d 551 &bfd_cr16c_arch,
3b16e843 552 &bfd_cris_arch,
1fe1f39c 553 &bfd_crx_arch,
3b16e843
NC
554 &bfd_d10v_arch,
555 &bfd_d30v_arch,
d172d4ba 556 &bfd_dlx_arch,
3b16e843 557 &bfd_fr30_arch,
4e5ba5b7 558 &bfd_frv_arch,
3b16e843
NC
559 &bfd_h8300_arch,
560 &bfd_h8500_arch,
561 &bfd_hppa_arch,
562 &bfd_i370_arch,
563 &bfd_i386_arch,
564 &bfd_i860_arch,
565 &bfd_i960_arch,
566 &bfd_ia64_arch,
cf88bb9f 567 &bfd_ip2k_arch,
a75473eb 568 &bfd_iq2000_arch,
9e675548 569 &bfd_l1om_arch,
84e94c90 570 &bfd_lm32_arch,
e729279b 571 &bfd_m32c_arch,
3b16e843
NC
572 &bfd_m32r_arch,
573 &bfd_m68hc11_arch,
574 &bfd_m68hc12_arch,
575 &bfd_m68k_arch,
576 &bfd_m88k_arch,
577 &bfd_mcore_arch,
d9352518 578 &bfd_mep_arch,
7ba29e2a 579 &bfd_microblaze_arch,
3b16e843
NC
580 &bfd_mips_arch,
581 &bfd_mmix_arch,
582 &bfd_mn10200_arch,
583 &bfd_mn10300_arch,
9e675548 584 &bfd_moxie_arch,
2469cfa2 585 &bfd_msp430_arch,
9e675548 586 &bfd_mt_arch,
3b16e843
NC
587 &bfd_ns32k_arch,
588 &bfd_openrisc_arch,
589 &bfd_or32_arch,
590 &bfd_pdp11_arch,
591 &bfd_powerpc_arch,
592 &bfd_rs6000_arch,
c7927a3c 593 &bfd_rx_arch,
3b16e843 594 &bfd_s390_arch,
1c0d3aa6 595 &bfd_score_arch,
3b16e843
NC
596 &bfd_sh_arch,
597 &bfd_sparc_arch,
e9f53129 598 &bfd_spu_arch,
3b16e843 599 &bfd_tic30_arch,
026df7c5 600 &bfd_tic4x_arch,
3b16e843 601 &bfd_tic54x_arch,
40b36596 602 &bfd_tic6x_arch,
3b16e843
NC
603 &bfd_tic80_arch,
604 &bfd_v850_arch,
605 &bfd_vax_arch,
606 &bfd_w65_arch,
607 &bfd_we32k_arch,
608 &bfd_xstormy16_arch,
e0001a05 609 &bfd_xtensa_arch,
d70c5fc7 610 &bfd_xc16x_arch,
3c9b82ba 611 &bfd_z80_arch,
3b16e843 612 &bfd_z8k_arch,
252b5132
RH
613#endif
614 0
615};
616
617/*
618FUNCTION
619 bfd_printable_name
620
621SYNOPSIS
c58b9523 622 const char *bfd_printable_name (bfd *abfd);
252b5132
RH
623
624DESCRIPTION
625 Return a printable string representing the architecture and machine
626 from the pointer to the architecture info structure.
627
628*/
629
630const char *
c58b9523 631bfd_printable_name (bfd *abfd)
252b5132
RH
632{
633 return abfd->arch_info->printable_name;
634}
635
252b5132
RH
636/*
637FUNCTION
638 bfd_scan_arch
639
640SYNOPSIS
c58b9523 641 const bfd_arch_info_type *bfd_scan_arch (const char *string);
252b5132
RH
642
643DESCRIPTION
644 Figure out if BFD supports any cpu which could be described with
645 the name @var{string}. Return a pointer to an <<arch_info>>
646 structure if a machine is found, otherwise NULL.
252b5132
RH
647*/
648
649const bfd_arch_info_type *
c58b9523 650bfd_scan_arch (const char *string)
252b5132
RH
651{
652 const bfd_arch_info_type * const *app, *ap;
653
047066e1 654 /* Look through all the installed architectures. */
252b5132
RH
655 for (app = bfd_archures_list; *app != NULL; app++)
656 {
657 for (ap = *app; ap != NULL; ap = ap->next)
658 {
659 if (ap->scan (ap, string))
660 return ap;
661 }
662 }
663
664 return NULL;
665}
666
252b5132
RH
667/*
668FUNCTION
669 bfd_arch_list
670
671SYNOPSIS
c58b9523 672 const char **bfd_arch_list (void);
252b5132
RH
673
674DESCRIPTION
675 Return a freshly malloced NULL-terminated vector of the names
676 of all the valid BFD architectures. Do not modify the names.
252b5132
RH
677*/
678
679const char **
c58b9523 680bfd_arch_list (void)
252b5132
RH
681{
682 int vec_length = 0;
683 const char **name_ptr;
684 const char **name_list;
685 const bfd_arch_info_type * const *app;
dc810e39 686 bfd_size_type amt;
252b5132 687
047066e1 688 /* Determine the number of architectures. */
252b5132
RH
689 vec_length = 0;
690 for (app = bfd_archures_list; *app != NULL; app++)
691 {
692 const bfd_arch_info_type *ap;
693 for (ap = *app; ap != NULL; ap = ap->next)
694 {
695 vec_length++;
696 }
697 }
698
dc810e39 699 amt = (vec_length + 1) * sizeof (char **);
a50b1753 700 name_list = (const char **) bfd_malloc (amt);
252b5132
RH
701 if (name_list == NULL)
702 return NULL;
703
047066e1 704 /* Point the list at each of the names. */
252b5132
RH
705 name_ptr = name_list;
706 for (app = bfd_archures_list; *app != NULL; app++)
707 {
708 const bfd_arch_info_type *ap;
709 for (ap = *app; ap != NULL; ap = ap->next)
710 {
711 *name_ptr = ap->printable_name;
712 name_ptr++;
713 }
714 }
715 *name_ptr = NULL;
716
717 return name_list;
718}
719
252b5132
RH
720/*
721FUNCTION
722 bfd_arch_get_compatible
723
724SYNOPSIS
c58b9523
AM
725 const bfd_arch_info_type *bfd_arch_get_compatible
726 (const bfd *abfd, const bfd *bbfd, bfd_boolean accept_unknowns);
252b5132
RH
727
728DESCRIPTION
312b768e
NC
729 Determine whether two BFDs' architectures and machine types
730 are compatible. Calculates the lowest common denominator
731 between the two architectures and machine types implied by
732 the BFDs and returns a pointer to an <<arch_info>> structure
733 describing the compatible machine.
252b5132
RH
734*/
735
736const bfd_arch_info_type *
c58b9523
AM
737bfd_arch_get_compatible (const bfd *abfd,
738 const bfd *bbfd,
739 bfd_boolean accept_unknowns)
252b5132 740{
312b768e
NC
741 const bfd * ubfd = NULL;
742
743 /* Look for an unknown architecture. */
744 if (((ubfd = abfd) && ubfd->arch_info->arch == bfd_arch_unknown)
745 || ((ubfd = bbfd) && ubfd->arch_info->arch == bfd_arch_unknown))
746 {
747 /* We can allow an unknown architecture if accept_unknowns
748 is true, or if the target is the "binary" format, which
749 has an unknown architecture. Since the binary format can
750 only be set by explicit request from the user, it is safe
751 to assume that they know what they are doing. */
752 if (accept_unknowns
753 || strcmp (bfd_get_target (ubfd), "binary") == 0)
754 return ubfd->arch_info;
755 return NULL;
756 }
252b5132
RH
757
758 /* Otherwise architecture-specific code has to decide. */
759 return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info);
760}
761
252b5132
RH
762/*
763INTERNAL_DEFINITION
764 bfd_default_arch_struct
765
766DESCRIPTION
767 The <<bfd_default_arch_struct>> is an item of
768 <<bfd_arch_info_type>> which has been initialized to a fairly
769 generic state. A BFD starts life by pointing to this
770 structure, until the correct back end has determined the real
771 architecture of the file.
772
773.extern const bfd_arch_info_type bfd_default_arch_struct;
252b5132
RH
774*/
775
047066e1 776const bfd_arch_info_type bfd_default_arch_struct = {
b34976b6 777 32, 32, 8, bfd_arch_unknown, 0, "unknown", "unknown", 2, TRUE,
047066e1
KH
778 bfd_default_compatible,
779 bfd_default_scan,
780 0,
252b5132
RH
781};
782
783/*
784FUNCTION
785 bfd_set_arch_info
786
787SYNOPSIS
c58b9523 788 void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg);
252b5132
RH
789
790DESCRIPTION
791 Set the architecture info of @var{abfd} to @var{arg}.
792*/
793
794void
c58b9523 795bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg)
252b5132
RH
796{
797 abfd->arch_info = arg;
798}
799
800/*
801INTERNAL_FUNCTION
802 bfd_default_set_arch_mach
803
804SYNOPSIS
c58b9523
AM
805 bfd_boolean bfd_default_set_arch_mach
806 (bfd *abfd, enum bfd_architecture arch, unsigned long mach);
252b5132
RH
807
808DESCRIPTION
809 Set the architecture and machine type in BFD @var{abfd}
810 to @var{arch} and @var{mach}. Find the correct
811 pointer to a structure and insert it into the <<arch_info>>
0ef5a5bd 812 pointer.
252b5132
RH
813*/
814
b34976b6 815bfd_boolean
c58b9523
AM
816bfd_default_set_arch_mach (bfd *abfd,
817 enum bfd_architecture arch,
818 unsigned long mach)
252b5132 819{
99dc0092
AM
820 abfd->arch_info = bfd_lookup_arch (arch, mach);
821 if (abfd->arch_info != NULL)
b34976b6 822 return TRUE;
252b5132
RH
823
824 abfd->arch_info = &bfd_default_arch_struct;
825 bfd_set_error (bfd_error_bad_value);
b34976b6 826 return FALSE;
252b5132
RH
827}
828
252b5132
RH
829/*
830FUNCTION
831 bfd_get_arch
832
833SYNOPSIS
c58b9523 834 enum bfd_architecture bfd_get_arch (bfd *abfd);
252b5132
RH
835
836DESCRIPTION
837 Return the enumerated type which describes the BFD @var{abfd}'s
838 architecture.
252b5132
RH
839*/
840
841enum bfd_architecture
c58b9523 842bfd_get_arch (bfd *abfd)
252b5132 843{
047066e1 844 return abfd->arch_info->arch;
252b5132
RH
845}
846
847/*
848FUNCTION
849 bfd_get_mach
850
851SYNOPSIS
c58b9523 852 unsigned long bfd_get_mach (bfd *abfd);
252b5132
RH
853
854DESCRIPTION
855 Return the long type which describes the BFD @var{abfd}'s
856 machine.
857*/
858
0ef5a5bd 859unsigned long
c58b9523 860bfd_get_mach (bfd *abfd)
252b5132 861{
047066e1 862 return abfd->arch_info->mach;
252b5132
RH
863}
864
865/*
866FUNCTION
867 bfd_arch_bits_per_byte
868
869SYNOPSIS
c58b9523 870 unsigned int bfd_arch_bits_per_byte (bfd *abfd);
252b5132
RH
871
872DESCRIPTION
873 Return the number of bits in one of the BFD @var{abfd}'s
874 architecture's bytes.
252b5132
RH
875*/
876
877unsigned int
c58b9523 878bfd_arch_bits_per_byte (bfd *abfd)
252b5132
RH
879{
880 return abfd->arch_info->bits_per_byte;
881}
882
883/*
884FUNCTION
885 bfd_arch_bits_per_address
886
887SYNOPSIS
c58b9523 888 unsigned int bfd_arch_bits_per_address (bfd *abfd);
252b5132
RH
889
890DESCRIPTION
891 Return the number of bits in one of the BFD @var{abfd}'s
892 architecture's addresses.
893*/
894
895unsigned int
c58b9523 896bfd_arch_bits_per_address (bfd *abfd)
252b5132
RH
897{
898 return abfd->arch_info->bits_per_address;
899}
900
252b5132 901/*
0ef5a5bd 902INTERNAL_FUNCTION
252b5132
RH
903 bfd_default_compatible
904
905SYNOPSIS
906 const bfd_arch_info_type *bfd_default_compatible
c58b9523 907 (const bfd_arch_info_type *a, const bfd_arch_info_type *b);
252b5132
RH
908
909DESCRIPTION
910 The default function for testing for compatibility.
911*/
912
913const bfd_arch_info_type *
c58b9523
AM
914bfd_default_compatible (const bfd_arch_info_type *a,
915 const bfd_arch_info_type *b)
252b5132
RH
916{
917 if (a->arch != b->arch)
918 return NULL;
919
b74fa2cd
AM
920 if (a->bits_per_word != b->bits_per_word)
921 return NULL;
922
252b5132
RH
923 if (a->mach > b->mach)
924 return a;
925
926 if (b->mach > a->mach)
927 return b;
928
929 return a;
930}
931
252b5132
RH
932/*
933INTERNAL_FUNCTION
934 bfd_default_scan
935
936SYNOPSIS
c58b9523
AM
937 bfd_boolean bfd_default_scan
938 (const struct bfd_arch_info *info, const char *string);
252b5132
RH
939
940DESCRIPTION
941 The default function for working out whether this is an
942 architecture hit and a machine hit.
943*/
944
b34976b6 945bfd_boolean
c58b9523 946bfd_default_scan (const bfd_arch_info_type *info, const char *string)
252b5132
RH
947{
948 const char *ptr_src;
949 const char *ptr_tst;
950 unsigned long number;
951 enum bfd_architecture arch;
952 const char *printable_name_colon;
953
954 /* Exact match of the architecture name (ARCH_NAME) and also the
047066e1 955 default architecture? */
252b5132
RH
956 if (strcasecmp (string, info->arch_name) == 0
957 && info->the_default)
b34976b6 958 return TRUE;
252b5132 959
047066e1 960 /* Exact match of the machine name (PRINTABLE_NAME)? */
252b5132 961 if (strcasecmp (string, info->printable_name) == 0)
b34976b6 962 return TRUE;
0ef5a5bd 963
252b5132 964 /* Given that printable_name contains no colon, attempt to match:
047066e1 965 ARCH_NAME [ ":" ] PRINTABLE_NAME? */
252b5132
RH
966 printable_name_colon = strchr (info->printable_name, ':');
967 if (printable_name_colon == NULL)
968 {
dc810e39 969 size_t strlen_arch_name = strlen (info->arch_name);
252b5132
RH
970 if (strncasecmp (string, info->arch_name, strlen_arch_name) == 0)
971 {
972 if (string[strlen_arch_name] == ':')
973 {
974 if (strcasecmp (string + strlen_arch_name + 1,
975 info->printable_name) == 0)
b34976b6 976 return TRUE;
252b5132
RH
977 }
978 else
979 {
980 if (strcasecmp (string + strlen_arch_name,
981 info->printable_name) == 0)
b34976b6 982 return TRUE;
252b5132
RH
983 }
984 }
985 }
986
987 /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>;
047066e1 988 Attempt to match: <arch> <mach>? */
252b5132
RH
989 if (printable_name_colon != NULL)
990 {
dc810e39 991 size_t colon_index = printable_name_colon - info->printable_name;
252b5132
RH
992 if (strncasecmp (string, info->printable_name, colon_index) == 0
993 && strcasecmp (string + colon_index,
994 info->printable_name + colon_index + 1) == 0)
b34976b6 995 return TRUE;
252b5132
RH
996 }
997
998 /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>; Do not
5c4491d3 999 attempt to match just <mach>, it could be ambiguous. This test
0ef5a5bd 1000 is left until later. */
252b5132 1001
047066e1
KH
1002 /* NOTE: The below is retained for compatibility only. Please do
1003 not add to this code. */
252b5132
RH
1004
1005 /* See how much of the supplied string matches with the
1006 architecture, eg the string m68k:68020 would match the 68k entry
047066e1 1007 up to the :, then we get left with the machine number. */
252b5132 1008
0ef5a5bd 1009 for (ptr_src = string, ptr_tst = info->arch_name;
252b5132 1010 *ptr_src && *ptr_tst;
0ef5a5bd 1011 ptr_src++, ptr_tst++)
252b5132 1012 {
047066e1
KH
1013 if (*ptr_src != *ptr_tst)
1014 break;
252b5132
RH
1015 }
1016
1017 /* Chewed up as much of the architecture as will match, skip any
047066e1 1018 colons. */
252b5132
RH
1019 if (*ptr_src == ':')
1020 ptr_src++;
0ef5a5bd 1021
252b5132
RH
1022 if (*ptr_src == 0)
1023 {
047066e1
KH
1024 /* Nothing more, then only keep this one if it is the default
1025 machine for this architecture. */
252b5132
RH
1026 return info->the_default;
1027 }
1028
1029 number = 0;
3882b010 1030 while (ISDIGIT (*ptr_src))
252b5132 1031 {
047066e1 1032 number = number * 10 + *ptr_src - '0';
252b5132
RH
1033 ptr_src++;
1034 }
1035
1036 /* NOTE: The below is retained for compatibility only.
0ef5a5bd 1037 PLEASE DO NOT ADD TO THIS CODE. */
252b5132 1038
0ef5a5bd 1039 switch (number)
252b5132
RH
1040 {
1041 /* FIXME: These are needed to parse IEEE objects. */
83ea41ad
NC
1042 /* The following seven case's are here only for compatibility with
1043 older binutils (at least IEEE objects from binutils 2.9.1 require
1044 them). */
1045 case bfd_mach_m68000:
1046 case bfd_mach_m68010:
1047 case bfd_mach_m68020:
1048 case bfd_mach_m68030:
1049 case bfd_mach_m68040:
1050 case bfd_mach_m68060:
1051 case bfd_mach_cpu32:
1052 arch = bfd_arch_m68k;
1053 break;
0ef5a5bd 1054 case 68000:
252b5132
RH
1055 arch = bfd_arch_m68k;
1056 number = bfd_mach_m68000;
1057 break;
1058 case 68010:
1059 arch = bfd_arch_m68k;
1060 number = bfd_mach_m68010;
1061 break;
1062 case 68020:
1063 arch = bfd_arch_m68k;
1064 number = bfd_mach_m68020;
1065 break;
1066 case 68030:
1067 arch = bfd_arch_m68k;
1068 number = bfd_mach_m68030;
1069 break;
1070 case 68040:
1071 arch = bfd_arch_m68k;
1072 number = bfd_mach_m68040;
1073 break;
1074 case 68060:
1075 arch = bfd_arch_m68k;
1076 number = bfd_mach_m68060;
1077 break;
1078 case 68332:
1079 arch = bfd_arch_m68k;
1080 number = bfd_mach_cpu32;
1081 break;
3cac17ae
NC
1082 case 5200:
1083 arch = bfd_arch_m68k;
0b2e31dc 1084 number = bfd_mach_mcf_isa_a_nodiv;
3cac17ae
NC
1085 break;
1086 case 5206:
1087 arch = bfd_arch_m68k;
0b2e31dc 1088 number = bfd_mach_mcf_isa_a_mac;
3cac17ae
NC
1089 break;
1090 case 5307:
1091 arch = bfd_arch_m68k;
0b2e31dc 1092 number = bfd_mach_mcf_isa_a_mac;
3cac17ae
NC
1093 break;
1094 case 5407:
1095 arch = bfd_arch_m68k;
0b2e31dc 1096 number = bfd_mach_mcf_isa_b_nousp_mac;
3cac17ae 1097 break;
3e602632
NC
1098 case 5282:
1099 arch = bfd_arch_m68k;
0b2e31dc 1100 number = bfd_mach_mcf_isa_aplus_emac;
3e602632 1101 break;
252b5132
RH
1102
1103 case 32000:
1104 arch = bfd_arch_we32k;
1105 break;
1106
1107 case 3000:
1108 arch = bfd_arch_mips;
1109 number = bfd_mach_mips3000;
1110 break;
1111
1112 case 4000:
1113 arch = bfd_arch_mips;
1114 number = bfd_mach_mips4000;
1115 break;
1116
1117 case 6000:
1118 arch = bfd_arch_rs6000;
1119 break;
1120
d4845d57
JR
1121 case 7410:
1122 arch = bfd_arch_sh;
1123 number = bfd_mach_sh_dsp;
1124 break;
1125
1126 case 7708:
1127 arch = bfd_arch_sh;
1128 number = bfd_mach_sh3;
1129 break;
1130
1131 case 7729:
1132 arch = bfd_arch_sh;
1133 number = bfd_mach_sh3_dsp;
1134 break;
1135
1136 case 7750:
1137 arch = bfd_arch_sh;
1138 number = bfd_mach_sh4;
1139 break;
1140
0ef5a5bd 1141 default:
b34976b6 1142 return FALSE;
252b5132
RH
1143 }
1144
0ef5a5bd 1145 if (arch != info->arch)
b34976b6 1146 return FALSE;
252b5132
RH
1147
1148 if (number != info->mach)
b34976b6 1149 return FALSE;
252b5132 1150
b34976b6 1151 return TRUE;
252b5132
RH
1152}
1153
252b5132
RH
1154/*
1155FUNCTION
1156 bfd_get_arch_info
1157
1158SYNOPSIS
c58b9523 1159 const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd);
252b5132
RH
1160
1161DESCRIPTION
1162 Return the architecture info struct in @var{abfd}.
1163*/
1164
1165const bfd_arch_info_type *
c58b9523 1166bfd_get_arch_info (bfd *abfd)
252b5132
RH
1167{
1168 return abfd->arch_info;
1169}
1170
252b5132
RH
1171/*
1172FUNCTION
1173 bfd_lookup_arch
1174
1175SYNOPSIS
1176 const bfd_arch_info_type *bfd_lookup_arch
c58b9523 1177 (enum bfd_architecture arch, unsigned long machine);
252b5132
RH
1178
1179DESCRIPTION
5c4491d3 1180 Look for the architecture info structure which matches the
252b5132
RH
1181 arguments @var{arch} and @var{machine}. A machine of 0 matches the
1182 machine/architecture structure which marks itself as the
aa3d5824 1183 default.
252b5132
RH
1184*/
1185
0ef5a5bd 1186const bfd_arch_info_type *
c58b9523 1187bfd_lookup_arch (enum bfd_architecture arch, unsigned long machine)
252b5132
RH
1188{
1189 const bfd_arch_info_type * const *app, *ap;
1190
1191 for (app = bfd_archures_list; *app != NULL; app++)
1192 {
1193 for (ap = *app; ap != NULL; ap = ap->next)
1194 {
1195 if (ap->arch == arch
1196 && (ap->mach == machine
1197 || (machine == 0 && ap->the_default)))
1198 return ap;
1199 }
1200 }
1201
1202 return NULL;
1203}
1204
252b5132
RH
1205/*
1206FUNCTION
1207 bfd_printable_arch_mach
1208
1209SYNOPSIS
1210 const char *bfd_printable_arch_mach
c58b9523 1211 (enum bfd_architecture arch, unsigned long machine);
252b5132
RH
1212
1213DESCRIPTION
1214 Return a printable string representing the architecture and
0ef5a5bd 1215 machine type.
252b5132
RH
1216
1217 This routine is depreciated.
1218*/
1219
1220const char *
c58b9523 1221bfd_printable_arch_mach (enum bfd_architecture arch, unsigned long machine)
252b5132 1222{
047066e1 1223 const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine);
252b5132 1224
047066e1
KH
1225 if (ap)
1226 return ap->printable_name;
1227 return "UNKNOWN!";
252b5132 1228}
9a968f43
NC
1229
1230/*
1231FUNCTION
1232 bfd_octets_per_byte
1233
1234SYNOPSIS
c58b9523 1235 unsigned int bfd_octets_per_byte (bfd *abfd);
9a968f43
NC
1236
1237DESCRIPTION
1238 Return the number of octets (8-bit quantities) per target byte
1239 (minimum addressable unit). In most cases, this will be one, but some
1240 DSP targets have 16, 32, or even 48 bits per byte.
9a968f43
NC
1241*/
1242
f6af82bd 1243unsigned int
c58b9523 1244bfd_octets_per_byte (bfd *abfd)
9a968f43 1245{
047066e1
KH
1246 return bfd_arch_mach_octets_per_byte (bfd_get_arch (abfd),
1247 bfd_get_mach (abfd));
9a968f43
NC
1248}
1249
1250/*
1251FUNCTION
1252 bfd_arch_mach_octets_per_byte
1253
1254SYNOPSIS
c58b9523
AM
1255 unsigned int bfd_arch_mach_octets_per_byte
1256 (enum bfd_architecture arch, unsigned long machine);
9a968f43
NC
1257
1258DESCRIPTION
1259 See bfd_octets_per_byte.
0ef5a5bd 1260
9a968f43
NC
1261 This routine is provided for those cases where a bfd * is not
1262 available
1263*/
1264
f6af82bd 1265unsigned int
c58b9523
AM
1266bfd_arch_mach_octets_per_byte (enum bfd_architecture arch,
1267 unsigned long mach)
9a968f43 1268{
047066e1 1269 const bfd_arch_info_type *ap = bfd_lookup_arch (arch, mach);
0ef5a5bd 1270
047066e1
KH
1271 if (ap)
1272 return ap->bits_per_byte / 8;
1273 return 1;
9a968f43 1274}
This page took 0.551168 seconds and 4 git commands to generate.