00001 /* 00002 * Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* BFD library support routines for architectures. 00006 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 00007 2000, 2001, 2002, 2003, 2004, 2005 00008 Free Software Foundation, Inc. 00009 Hacked by John Gilmore and Steve Chamberlain of Cygnus Support. 00010 00011 This file is part of BFD, the Binary File Descriptor library. 00012 00013 This program is free software; you can redistribute it and/or modify 00014 it under the terms of the GNU General Public License as published by 00015 the Free Software Foundation; either version 2 of the License, or 00016 (at your option) any later version. 00017 00018 This program is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with this program; if not, write to the Free Software 00025 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 00026 00027 #include "bfd.h" 00028 #include "sysdep.h" 00029 #include "libbfd.h" 00030 #include "safe-ctype.h" 00031 00032 /* 00033 00034 SECTION 00035 Architectures 00036 00037 BFD keeps one atom in a BFD describing the 00038 architecture of the data attached to the BFD: a pointer to a 00039 <<bfd_arch_info_type>>. 00040 00041 Pointers to structures can be requested independently of a BFD 00042 so that an architecture's information can be interrogated 00043 without access to an open BFD. 00044 00045 The architecture information is provided by each architecture package. 00046 The set of default architectures is selected by the macro 00047 <<SELECT_ARCHITECTURES>>. This is normally set up in the 00048 @file{config/@var{target}.mt} file of your choice. If the name is not 00049 defined, then all the architectures supported are included. 00050 00051 When BFD starts up, all the architectures are called with an 00052 initialize method. It is up to the architecture back end to 00053 insert as many items into the list of architectures as it wants to; 00054 generally this would be one for each machine and one for the 00055 default case (an item with a machine field of 0). 00056 00057 BFD's idea of an architecture is implemented in @file{archures.c}. 00058 */ 00059 00060 /* 00061 00062 SUBSECTION 00063 bfd_architecture 00064 00065 DESCRIPTION 00066 This enum gives the object file's CPU architecture, in a 00067 global sense---i.e., what processor family does it belong to? 00068 Another field indicates which processor within 00069 the family is in use. The machine gives a number which 00070 distinguishes different versions of the architecture, 00071 containing, for example, 2 and 3 for Intel i960 KA and i960 KB, 00072 and 68020 and 68030 for Motorola 68020 and 68030. 00073 00074 .enum bfd_architecture 00075 .{ 00076 . bfd_arch_unknown, {* File arch not known. *} 00077 . bfd_arch_obscure, {* Arch known, not one of these. *} 00078 . bfd_arch_m68k, {* Motorola 68xxx *} 00079 .#define bfd_mach_m68000 1 00080 .#define bfd_mach_m68008 2 00081 .#define bfd_mach_m68010 3 00082 .#define bfd_mach_m68020 4 00083 .#define bfd_mach_m68030 5 00084 .#define bfd_mach_m68040 6 00085 .#define bfd_mach_m68060 7 00086 .#define bfd_mach_cpu32 8 00087 .#define bfd_mach_mcf5200 9 00088 .#define bfd_mach_mcf5206e 10 00089 .#define bfd_mach_mcf5307 11 00090 .#define bfd_mach_mcf5407 12 00091 .#define bfd_mach_mcf528x 13 00092 .#define bfd_mach_mcfv4e 14 00093 .#define bfd_mach_mcf521x 15 00094 .#define bfd_mach_mcf5249 16 00095 .#define bfd_mach_mcf547x 17 00096 .#define bfd_mach_mcf548x 18 00097 . bfd_arch_vax, {* DEC Vax *} 00098 . bfd_arch_i960, {* Intel 960 *} 00099 . {* The order of the following is important. 00100 . lower number indicates a machine type that 00101 . only accepts a subset of the instructions 00102 . available to machines with higher numbers. 00103 . The exception is the "ca", which is 00104 . incompatible with all other machines except 00105 . "core". *} 00106 . 00107 .#define bfd_mach_i960_core 1 00108 .#define bfd_mach_i960_ka_sa 2 00109 .#define bfd_mach_i960_kb_sb 3 00110 .#define bfd_mach_i960_mc 4 00111 .#define bfd_mach_i960_xa 5 00112 .#define bfd_mach_i960_ca 6 00113 .#define bfd_mach_i960_jx 7 00114 .#define bfd_mach_i960_hx 8 00115 . 00116 . bfd_arch_or32, {* OpenRISC 32 *} 00117 . 00118 . bfd_arch_a29k, {* AMD 29000 *} 00119 . bfd_arch_sparc, {* SPARC *} 00120 .#define bfd_mach_sparc 1 00121 .{* The difference between v8plus and v9 is that v9 is a true 64 bit env. *} 00122 .#define bfd_mach_sparc_sparclet 2 00123 .#define bfd_mach_sparc_sparclite 3 00124 .#define bfd_mach_sparc_v8plus 4 00125 .#define bfd_mach_sparc_v8plusa 5 {* with ultrasparc add'ns. *} 00126 .#define bfd_mach_sparc_sparclite_le 6 00127 .#define bfd_mach_sparc_v9 7 00128 .#define bfd_mach_sparc_v9a 8 {* with ultrasparc add'ns. *} 00129 .#define bfd_mach_sparc_v8plusb 9 {* with cheetah add'ns. *} 00130 .#define bfd_mach_sparc_v9b 10 {* with cheetah add'ns. *} 00131 .{* Nonzero if MACH has the v9 instruction set. *} 00132 .#define bfd_mach_sparc_v9_p(mach) \ 00133 . ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \ 00134 . && (mach) != bfd_mach_sparc_sparclite_le) 00135 .{* Nonzero if MACH is a 64 bit sparc architecture. *} 00136 .#define bfd_mach_sparc_64bit_p(mach) \ 00137 . ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb) 00138 . bfd_arch_mips, {* MIPS Rxxxx *} 00139 .#define bfd_mach_mips3000 3000 00140 .#define bfd_mach_mips3900 3900 00141 .#define bfd_mach_mips4000 4000 00142 .#define bfd_mach_mips4010 4010 00143 .#define bfd_mach_mips4100 4100 00144 .#define bfd_mach_mips4111 4111 00145 .#define bfd_mach_mips4120 4120 00146 .#define bfd_mach_mips4300 4300 00147 .#define bfd_mach_mips4400 4400 00148 .#define bfd_mach_mips4600 4600 00149 .#define bfd_mach_mips4650 4650 00150 .#define bfd_mach_mips5000 5000 00151 .#define bfd_mach_mips5400 5400 00152 .#define bfd_mach_mips5500 5500 00153 .#define bfd_mach_mips6000 6000 00154 .#define bfd_mach_mips7000 7000 00155 .#define bfd_mach_mips8000 8000 00156 .#define bfd_mach_mips9000 9000 00157 .#define bfd_mach_mips10000 10000 00158 .#define bfd_mach_mips12000 12000 00159 .#define bfd_mach_mips16 16 00160 .#define bfd_mach_mips5 5 00161 .#define bfd_mach_mips_sb1 12310201 {* octal 'SB', 01 *} 00162 .#define bfd_mach_mipsisa32 32 00163 .#define bfd_mach_mipsisa32r2 33 00164 .#define bfd_mach_mipsisa64 64 00165 .#define bfd_mach_mipsisa64r2 65 00166 . bfd_arch_i386, {* Intel 386 *} 00167 .#define bfd_mach_i386_i386 1 00168 .#define bfd_mach_i386_i8086 2 00169 .#define bfd_mach_i386_i386_intel_syntax 3 00170 .#define bfd_mach_x86_64 64 00171 .#define bfd_mach_x86_64_intel_syntax 65 00172 . bfd_arch_we32k, {* AT&T WE32xxx *} 00173 . bfd_arch_tahoe, {* CCI/Harris Tahoe *} 00174 . bfd_arch_i860, {* Intel 860 *} 00175 . bfd_arch_i370, {* IBM 360/370 Mainframes *} 00176 . bfd_arch_romp, {* IBM ROMP PC/RT *} 00177 . bfd_arch_alliant, {* Alliant *} 00178 . bfd_arch_convex, {* Convex *} 00179 . bfd_arch_m88k, {* Motorola 88xxx *} 00180 . bfd_arch_m98k, {* Motorola 98xxx *} 00181 . bfd_arch_pyramid, {* Pyramid Technology *} 00182 . bfd_arch_h8300, {* Renesas H8/300 (formerly Hitachi H8/300) *} 00183 .#define bfd_mach_h8300 1 00184 .#define bfd_mach_h8300h 2 00185 .#define bfd_mach_h8300s 3 00186 .#define bfd_mach_h8300hn 4 00187 .#define bfd_mach_h8300sn 5 00188 .#define bfd_mach_h8300sx 6 00189 .#define bfd_mach_h8300sxn 7 00190 . bfd_arch_pdp11, {* DEC PDP-11 *} 00191 . bfd_arch_powerpc, {* PowerPC *} 00192 .#define bfd_mach_ppc 32 00193 .#define bfd_mach_ppc64 64 00194 .#define bfd_mach_ppc_403 403 00195 .#define bfd_mach_ppc_403gc 4030 00196 .#define bfd_mach_ppc_505 505 00197 .#define bfd_mach_ppc_601 601 00198 .#define bfd_mach_ppc_602 602 00199 .#define bfd_mach_ppc_603 603 00200 .#define bfd_mach_ppc_ec603e 6031 00201 .#define bfd_mach_ppc_604 604 00202 .#define bfd_mach_ppc_620 620 00203 .#define bfd_mach_ppc_630 630 00204 .#define bfd_mach_ppc_750 750 00205 .#define bfd_mach_ppc_860 860 00206 .#define bfd_mach_ppc_a35 35 00207 .#define bfd_mach_ppc_rs64ii 642 00208 .#define bfd_mach_ppc_rs64iii 643 00209 .#define bfd_mach_ppc_7400 7400 00210 .#define bfd_mach_ppc_e500 500 00211 . bfd_arch_rs6000, {* IBM RS/6000 *} 00212 .#define bfd_mach_rs6k 6000 00213 .#define bfd_mach_rs6k_rs1 6001 00214 .#define bfd_mach_rs6k_rsc 6003 00215 .#define bfd_mach_rs6k_rs2 6002 00216 . bfd_arch_hppa, {* HP PA RISC *} 00217 .#define bfd_mach_hppa10 10 00218 .#define bfd_mach_hppa11 11 00219 .#define bfd_mach_hppa20 20 00220 .#define bfd_mach_hppa20w 25 00221 . bfd_arch_d10v, {* Mitsubishi D10V *} 00222 .#define bfd_mach_d10v 1 00223 .#define bfd_mach_d10v_ts2 2 00224 .#define bfd_mach_d10v_ts3 3 00225 . bfd_arch_d30v, {* Mitsubishi D30V *} 00226 . bfd_arch_dlx, {* DLX *} 00227 . bfd_arch_m68hc11, {* Motorola 68HC11 *} 00228 . bfd_arch_m68hc12, {* Motorola 68HC12 *} 00229 .#define bfd_mach_m6812_default 0 00230 .#define bfd_mach_m6812 1 00231 .#define bfd_mach_m6812s 2 00232 . bfd_arch_z8k, {* Zilog Z8000 *} 00233 .#define bfd_mach_z8001 1 00234 .#define bfd_mach_z8002 2 00235 . bfd_arch_h8500, {* Renesas H8/500 (formerly Hitachi H8/500) *} 00236 . bfd_arch_sh, {* Renesas / SuperH SH (formerly Hitachi SH) *} 00237 .#define bfd_mach_sh 1 00238 .#define bfd_mach_sh2 0x20 00239 .#define bfd_mach_sh_dsp 0x2d 00240 .#define bfd_mach_sh2a 0x2a 00241 .#define bfd_mach_sh2a_nofpu 0x2b 00242 .#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1 00243 .#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2 00244 .#define bfd_mach_sh2a_or_sh4 0x2a3 00245 .#define bfd_mach_sh2a_or_sh3e 0x2a4 00246 .#define bfd_mach_sh2e 0x2e 00247 .#define bfd_mach_sh3 0x30 00248 .#define bfd_mach_sh3_nommu 0x31 00249 .#define bfd_mach_sh3_dsp 0x3d 00250 .#define bfd_mach_sh3e 0x3e 00251 .#define bfd_mach_sh4 0x40 00252 .#define bfd_mach_sh4_nofpu 0x41 00253 .#define bfd_mach_sh4_nommu_nofpu 0x42 00254 .#define bfd_mach_sh4a 0x4a 00255 .#define bfd_mach_sh4a_nofpu 0x4b 00256 .#define bfd_mach_sh4al_dsp 0x4d 00257 .#define bfd_mach_sh5 0x50 00258 . bfd_arch_alpha, {* Dec Alpha *} 00259 .#define bfd_mach_alpha_ev4 0x10 00260 .#define bfd_mach_alpha_ev5 0x20 00261 .#define bfd_mach_alpha_ev6 0x30 00262 . bfd_arch_arm, {* Advanced Risc Machines ARM. *} 00263 .#define bfd_mach_arm_unknown 0 00264 .#define bfd_mach_arm_2 1 00265 .#define bfd_mach_arm_2a 2 00266 .#define bfd_mach_arm_3 3 00267 .#define bfd_mach_arm_3M 4 00268 .#define bfd_mach_arm_4 5 00269 .#define bfd_mach_arm_4T 6 00270 .#define bfd_mach_arm_5 7 00271 .#define bfd_mach_arm_5T 8 00272 .#define bfd_mach_arm_5TE 9 00273 .#define bfd_mach_arm_XScale 10 00274 .#define bfd_mach_arm_ep9312 11 00275 .#define bfd_mach_arm_iWMMXt 12 00276 . bfd_arch_ns32k, {* National Semiconductors ns32000 *} 00277 . bfd_arch_w65, {* WDC 65816 *} 00278 . bfd_arch_tic30, {* Texas Instruments TMS320C30 *} 00279 . bfd_arch_tic4x, {* Texas Instruments TMS320C3X/4X *} 00280 .#define bfd_mach_tic3x 30 00281 .#define bfd_mach_tic4x 40 00282 . bfd_arch_tic54x, {* Texas Instruments TMS320C54X *} 00283 . bfd_arch_tic80, {* TI TMS320c80 (MVP) *} 00284 . bfd_arch_v850, {* NEC V850 *} 00285 .#define bfd_mach_v850 1 00286 .#define bfd_mach_v850e 'E' 00287 .#define bfd_mach_v850e1 '1' 00288 . bfd_arch_arc, {* ARC Cores *} 00289 .#define bfd_mach_arc_5 5 00290 .#define bfd_mach_arc_6 6 00291 .#define bfd_mach_arc_7 7 00292 .#define bfd_mach_arc_8 8 00293 . bfd_arch_m32r, {* Renesas M32R (formerly Mitsubishi M32R/D) *} 00294 .#define bfd_mach_m32r 1 {* For backwards compatibility. *} 00295 .#define bfd_mach_m32rx 'x' 00296 .#define bfd_mach_m32r2 '2' 00297 . bfd_arch_mn10200, {* Matsushita MN10200 *} 00298 . bfd_arch_mn10300, {* Matsushita MN10300 *} 00299 .#define bfd_mach_mn10300 300 00300 .#define bfd_mach_am33 330 00301 .#define bfd_mach_am33_2 332 00302 . bfd_arch_fr30, 00303 .#define bfd_mach_fr30 0x46523330 00304 . bfd_arch_frv, 00305 .#define bfd_mach_frv 1 00306 .#define bfd_mach_frvsimple 2 00307 .#define bfd_mach_fr300 300 00308 .#define bfd_mach_fr400 400 00309 .#define bfd_mach_fr450 450 00310 .#define bfd_mach_frvtomcat 499 {* fr500 prototype *} 00311 .#define bfd_mach_fr500 500 00312 .#define bfd_mach_fr550 550 00313 . bfd_arch_mcore, 00314 . bfd_arch_ia64, {* HP/Intel ia64 *} 00315 .#define bfd_mach_ia64_elf64 64 00316 .#define bfd_mach_ia64_elf32 32 00317 . bfd_arch_ip2k, {* Ubicom IP2K microcontrollers. *} 00318 .#define bfd_mach_ip2022 1 00319 .#define bfd_mach_ip2022ext 2 00320 . bfd_arch_iq2000, {* Vitesse IQ2000. *} 00321 .#define bfd_mach_iq2000 1 00322 .#define bfd_mach_iq10 2 00323 . bfd_arch_pj, 00324 . bfd_arch_avr, {* Atmel AVR microcontrollers. *} 00325 .#define bfd_mach_avr1 1 00326 .#define bfd_mach_avr2 2 00327 .#define bfd_mach_avr3 3 00328 .#define bfd_mach_avr4 4 00329 .#define bfd_mach_avr5 5 00330 . bfd_arch_cr16c, {* National Semiconductor CompactRISC. *} 00331 .#define bfd_mach_cr16c 1 00332 . bfd_arch_crx, {* National Semiconductor CRX. *} 00333 .#define bfd_mach_crx 1 00334 . bfd_arch_cris, {* Axis CRIS *} 00335 .#define bfd_mach_cris_v0_v10 255 00336 .#define bfd_mach_cris_v32 32 00337 .#define bfd_mach_cris_v10_v32 1032 00338 . bfd_arch_s390, {* IBM s390 *} 00339 .#define bfd_mach_s390_31 31 00340 .#define bfd_mach_s390_64 64 00341 . bfd_arch_openrisc, {* OpenRISC *} 00342 . bfd_arch_mmix, {* Donald Knuth's educational processor. *} 00343 . bfd_arch_xstormy16, 00344 .#define bfd_mach_xstormy16 1 00345 . bfd_arch_msp430, {* Texas Instruments MSP430 architecture. *} 00346 .#define bfd_mach_msp11 11 00347 .#define bfd_mach_msp110 110 00348 .#define bfd_mach_msp12 12 00349 .#define bfd_mach_msp13 13 00350 .#define bfd_mach_msp14 14 00351 .#define bfd_mach_msp15 15 00352 .#define bfd_mach_msp16 16 00353 .#define bfd_mach_msp31 31 00354 .#define bfd_mach_msp32 32 00355 .#define bfd_mach_msp33 33 00356 .#define bfd_mach_msp41 41 00357 .#define bfd_mach_msp42 42 00358 .#define bfd_mach_msp43 43 00359 .#define bfd_mach_msp44 44 00360 . bfd_arch_xtensa, {* Tensilica's Xtensa cores. *} 00361 .#define bfd_mach_xtensa 1 00362 . bfd_arch_maxq, {* Dallas MAXQ 10/20 *} 00363 .#define bfd_mach_maxq10 10 00364 .#define bfd_mach_maxq20 20 00365 . bfd_arch_last 00366 . }; 00367 */ 00368 00369 /* 00370 SUBSECTION 00371 bfd_arch_info 00372 00373 DESCRIPTION 00374 This structure contains information on architectures for use 00375 within BFD. 00376 00377 . 00378 .typedef struct bfd_arch_info 00379 .{ 00380 . int bits_per_word; 00381 . int bits_per_address; 00382 . int bits_per_byte; 00383 . enum bfd_architecture arch; 00384 . unsigned long mach; 00385 . const char *arch_name; 00386 . const char *printable_name; 00387 . unsigned int section_align_power; 00388 . {* TRUE if this is the default machine for the architecture. 00389 . The default arch should be the first entry for an arch so that 00390 . all the entries for that arch can be accessed via <<next>>. *} 00391 . bfd_boolean the_default; 00392 . const struct bfd_arch_info * (*compatible) 00393 . (const struct bfd_arch_info *a, const struct bfd_arch_info *b); 00394 . 00395 . bfd_boolean (*scan) (const struct bfd_arch_info *, const char *); 00396 . 00397 . const struct bfd_arch_info *next; 00398 .} 00399 .bfd_arch_info_type; 00400 . 00401 */ 00402 00403 extern const bfd_arch_info_type bfd_a29k_arch; 00404 extern const bfd_arch_info_type bfd_alpha_arch; 00405 extern const bfd_arch_info_type bfd_arc_arch; 00406 extern const bfd_arch_info_type bfd_arm_arch; 00407 extern const bfd_arch_info_type bfd_avr_arch; 00408 extern const bfd_arch_info_type bfd_cr16c_arch; 00409 extern const bfd_arch_info_type bfd_cris_arch; 00410 extern const bfd_arch_info_type bfd_crx_arch; 00411 extern const bfd_arch_info_type bfd_d10v_arch; 00412 extern const bfd_arch_info_type bfd_d30v_arch; 00413 extern const bfd_arch_info_type bfd_dlx_arch; 00414 extern const bfd_arch_info_type bfd_fr30_arch; 00415 extern const bfd_arch_info_type bfd_frv_arch; 00416 extern const bfd_arch_info_type bfd_h8300_arch; 00417 extern const bfd_arch_info_type bfd_h8500_arch; 00418 extern const bfd_arch_info_type bfd_hppa_arch; 00419 extern const bfd_arch_info_type bfd_i370_arch; 00420 extern const bfd_arch_info_type bfd_i386_arch; 00421 extern const bfd_arch_info_type bfd_i860_arch; 00422 extern const bfd_arch_info_type bfd_i960_arch; 00423 extern const bfd_arch_info_type bfd_ia64_arch; 00424 extern const bfd_arch_info_type bfd_ip2k_arch; 00425 extern const bfd_arch_info_type bfd_iq2000_arch; 00426 extern const bfd_arch_info_type bfd_m32r_arch; 00427 extern const bfd_arch_info_type bfd_m68hc11_arch; 00428 extern const bfd_arch_info_type bfd_m68hc12_arch; 00429 extern const bfd_arch_info_type bfd_m68k_arch; 00430 extern const bfd_arch_info_type bfd_m88k_arch; 00431 extern const bfd_arch_info_type bfd_maxq_arch; 00432 extern const bfd_arch_info_type bfd_mcore_arch; 00433 extern const bfd_arch_info_type bfd_mips_arch; 00434 extern const bfd_arch_info_type bfd_mmix_arch; 00435 extern const bfd_arch_info_type bfd_mn10200_arch; 00436 extern const bfd_arch_info_type bfd_mn10300_arch; 00437 extern const bfd_arch_info_type bfd_msp430_arch; 00438 extern const bfd_arch_info_type bfd_ns32k_arch; 00439 extern const bfd_arch_info_type bfd_openrisc_arch; 00440 extern const bfd_arch_info_type bfd_or32_arch; 00441 extern const bfd_arch_info_type bfd_pdp11_arch; 00442 extern const bfd_arch_info_type bfd_pj_arch; 00443 extern const bfd_arch_info_type bfd_powerpc_archs[]; 00444 #define bfd_powerpc_arch bfd_powerpc_archs[0] 00445 extern const bfd_arch_info_type bfd_rs6000_arch; 00446 extern const bfd_arch_info_type bfd_s390_arch; 00447 extern const bfd_arch_info_type bfd_sh_arch; 00448 extern const bfd_arch_info_type bfd_sparc_arch; 00449 extern const bfd_arch_info_type bfd_tic30_arch; 00450 extern const bfd_arch_info_type bfd_tic4x_arch; 00451 extern const bfd_arch_info_type bfd_tic54x_arch; 00452 extern const bfd_arch_info_type bfd_tic80_arch; 00453 extern const bfd_arch_info_type bfd_v850_arch; 00454 extern const bfd_arch_info_type bfd_vax_arch; 00455 extern const bfd_arch_info_type bfd_we32k_arch; 00456 extern const bfd_arch_info_type bfd_w65_arch; 00457 extern const bfd_arch_info_type bfd_xstormy16_arch; 00458 extern const bfd_arch_info_type bfd_xtensa_arch; 00459 extern const bfd_arch_info_type bfd_z8k_arch; 00460 00461 static const bfd_arch_info_type * const bfd_archures_list[] = 00462 { 00463 #ifdef SELECT_ARCHITECTURES 00464 SELECT_ARCHITECTURES, 00465 #else 00466 &bfd_a29k_arch, 00467 &bfd_alpha_arch, 00468 &bfd_arc_arch, 00469 &bfd_arm_arch, 00470 &bfd_avr_arch, 00471 &bfd_cr16c_arch, 00472 &bfd_cris_arch, 00473 &bfd_crx_arch, 00474 &bfd_d10v_arch, 00475 &bfd_d30v_arch, 00476 &bfd_dlx_arch, 00477 &bfd_fr30_arch, 00478 &bfd_frv_arch, 00479 &bfd_h8300_arch, 00480 &bfd_h8500_arch, 00481 &bfd_hppa_arch, 00482 &bfd_i370_arch, 00483 &bfd_i386_arch, 00484 &bfd_i860_arch, 00485 &bfd_i960_arch, 00486 &bfd_ia64_arch, 00487 &bfd_ip2k_arch, 00488 &bfd_iq2000_arch, 00489 &bfd_m32r_arch, 00490 &bfd_m68hc11_arch, 00491 &bfd_m68hc12_arch, 00492 &bfd_m68k_arch, 00493 &bfd_m88k_arch, 00494 &bfd_maxq_arch, 00495 &bfd_mcore_arch, 00496 &bfd_mips_arch, 00497 &bfd_mmix_arch, 00498 &bfd_mn10200_arch, 00499 &bfd_mn10300_arch, 00500 &bfd_msp430_arch, 00501 &bfd_ns32k_arch, 00502 &bfd_openrisc_arch, 00503 &bfd_or32_arch, 00504 &bfd_pdp11_arch, 00505 &bfd_powerpc_arch, 00506 &bfd_rs6000_arch, 00507 &bfd_s390_arch, 00508 &bfd_sh_arch, 00509 &bfd_sparc_arch, 00510 &bfd_tic30_arch, 00511 &bfd_tic4x_arch, 00512 &bfd_tic54x_arch, 00513 &bfd_tic80_arch, 00514 &bfd_v850_arch, 00515 &bfd_vax_arch, 00516 &bfd_w65_arch, 00517 &bfd_we32k_arch, 00518 &bfd_xstormy16_arch, 00519 &bfd_xtensa_arch, 00520 &bfd_z8k_arch, 00521 #endif 00522 0 00523 }; 00524 00525 /* 00526 FUNCTION 00527 bfd_printable_name 00528 00529 SYNOPSIS 00530 const char *bfd_printable_name (bfd *abfd); 00531 00532 DESCRIPTION 00533 Return a printable string representing the architecture and machine 00534 from the pointer to the architecture info structure. 00535 00536 */ 00537 00538 const char * 00539 bfd_printable_name (bfd *abfd) 00540 { 00541 return abfd->arch_info->printable_name; 00542 } 00543 00544 /* 00545 FUNCTION 00546 bfd_scan_arch 00547 00548 SYNOPSIS 00549 const bfd_arch_info_type *bfd_scan_arch (const char *string); 00550 00551 DESCRIPTION 00552 Figure out if BFD supports any cpu which could be described with 00553 the name @var{string}. Return a pointer to an <<arch_info>> 00554 structure if a machine is found, otherwise NULL. 00555 */ 00556 00557 const bfd_arch_info_type * 00558 bfd_scan_arch (const char *string) 00559 { 00560 const bfd_arch_info_type * const *app, *ap; 00561 00562 /* Look through all the installed architectures. */ 00563 for (app = bfd_archures_list; *app != NULL; app++) 00564 { 00565 for (ap = *app; ap != NULL; ap = ap->next) 00566 { 00567 if (ap->scan (ap, string)) 00568 return ap; 00569 } 00570 } 00571 00572 return NULL; 00573 } 00574 00575 /* 00576 FUNCTION 00577 bfd_arch_list 00578 00579 SYNOPSIS 00580 const char **bfd_arch_list (void); 00581 00582 DESCRIPTION 00583 Return a freshly malloced NULL-terminated vector of the names 00584 of all the valid BFD architectures. Do not modify the names. 00585 */ 00586 00587 const char ** 00588 bfd_arch_list (void) 00589 { 00590 int vec_length = 0; 00591 const char **name_ptr; 00592 const char **name_list; 00593 const bfd_arch_info_type * const *app; 00594 bfd_size_type amt; 00595 00596 /* Determine the number of architectures. */ 00597 vec_length = 0; 00598 for (app = bfd_archures_list; *app != NULL; app++) 00599 { 00600 const bfd_arch_info_type *ap; 00601 for (ap = *app; ap != NULL; ap = ap->next) 00602 { 00603 vec_length++; 00604 } 00605 } 00606 00607 amt = (vec_length + 1) * sizeof (char **); 00608 name_list = bfd_malloc (amt); 00609 if (name_list == NULL) 00610 return NULL; 00611 00612 /* Point the list at each of the names. */ 00613 name_ptr = name_list; 00614 for (app = bfd_archures_list; *app != NULL; app++) 00615 { 00616 const bfd_arch_info_type *ap; 00617 for (ap = *app; ap != NULL; ap = ap->next) 00618 { 00619 *name_ptr = ap->printable_name; 00620 name_ptr++; 00621 } 00622 } 00623 *name_ptr = NULL; 00624 00625 return name_list; 00626 } 00627 00628 /* 00629 FUNCTION 00630 bfd_arch_get_compatible 00631 00632 SYNOPSIS 00633 const bfd_arch_info_type *bfd_arch_get_compatible 00634 (const bfd *abfd, const bfd *bbfd, bfd_boolean accept_unknowns); 00635 00636 DESCRIPTION 00637 Determine whether two BFDs' architectures and machine types 00638 are compatible. Calculates the lowest common denominator 00639 between the two architectures and machine types implied by 00640 the BFDs and returns a pointer to an <<arch_info>> structure 00641 describing the compatible machine. 00642 */ 00643 00644 const bfd_arch_info_type * 00645 bfd_arch_get_compatible (const bfd *abfd, 00646 const bfd *bbfd, 00647 bfd_boolean accept_unknowns) 00648 { 00649 const bfd * ubfd = NULL; 00650 00651 /* Look for an unknown architecture. */ 00652 if (((ubfd = abfd) && ubfd->arch_info->arch == bfd_arch_unknown) 00653 || ((ubfd = bbfd) && ubfd->arch_info->arch == bfd_arch_unknown)) 00654 { 00655 /* We can allow an unknown architecture if accept_unknowns 00656 is true, or if the target is the "binary" format, which 00657 has an unknown architecture. Since the binary format can 00658 only be set by explicit request from the user, it is safe 00659 to assume that they know what they are doing. */ 00660 if (accept_unknowns 00661 || strcmp (bfd_get_target (ubfd), "binary") == 0) 00662 return ubfd->arch_info; 00663 return NULL; 00664 } 00665 00666 /* Otherwise architecture-specific code has to decide. */ 00667 return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info); 00668 } 00669 00670 /* 00671 INTERNAL_DEFINITION 00672 bfd_default_arch_struct 00673 00674 DESCRIPTION 00675 The <<bfd_default_arch_struct>> is an item of 00676 <<bfd_arch_info_type>> which has been initialized to a fairly 00677 generic state. A BFD starts life by pointing to this 00678 structure, until the correct back end has determined the real 00679 architecture of the file. 00680 00681 .extern const bfd_arch_info_type bfd_default_arch_struct; 00682 */ 00683 00684 const bfd_arch_info_type bfd_default_arch_struct = { 00685 32, 32, 8, bfd_arch_unknown, 0, "unknown", "unknown", 2, TRUE, 00686 bfd_default_compatible, 00687 bfd_default_scan, 00688 0, 00689 }; 00690 00691 /* 00692 FUNCTION 00693 bfd_set_arch_info 00694 00695 SYNOPSIS 00696 void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg); 00697 00698 DESCRIPTION 00699 Set the architecture info of @var{abfd} to @var{arg}. 00700 */ 00701 00702 void 00703 bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg) 00704 { 00705 abfd->arch_info = arg; 00706 } 00707 00708 /* 00709 INTERNAL_FUNCTION 00710 bfd_default_set_arch_mach 00711 00712 SYNOPSIS 00713 bfd_boolean bfd_default_set_arch_mach 00714 (bfd *abfd, enum bfd_architecture arch, unsigned long mach); 00715 00716 DESCRIPTION 00717 Set the architecture and machine type in BFD @var{abfd} 00718 to @var{arch} and @var{mach}. Find the correct 00719 pointer to a structure and insert it into the <<arch_info>> 00720 pointer. 00721 */ 00722 00723 bfd_boolean 00724 bfd_default_set_arch_mach (bfd *abfd, 00725 enum bfd_architecture arch, 00726 unsigned long mach) 00727 { 00728 abfd->arch_info = bfd_lookup_arch (arch, mach); 00729 if (abfd->arch_info != NULL) 00730 return TRUE; 00731 00732 abfd->arch_info = &bfd_default_arch_struct; 00733 bfd_set_error (bfd_error_bad_value); 00734 return FALSE; 00735 } 00736 00737 /* 00738 FUNCTION 00739 bfd_get_arch 00740 00741 SYNOPSIS 00742 enum bfd_architecture bfd_get_arch (bfd *abfd); 00743 00744 DESCRIPTION 00745 Return the enumerated type which describes the BFD @var{abfd}'s 00746 architecture. 00747 */ 00748 00749 enum bfd_architecture 00750 bfd_get_arch (bfd *abfd) 00751 { 00752 return abfd->arch_info->arch; 00753 } 00754 00755 /* 00756 FUNCTION 00757 bfd_get_mach 00758 00759 SYNOPSIS 00760 unsigned long bfd_get_mach (bfd *abfd); 00761 00762 DESCRIPTION 00763 Return the long type which describes the BFD @var{abfd}'s 00764 machine. 00765 */ 00766 00767 unsigned long 00768 bfd_get_mach (bfd *abfd) 00769 { 00770 return abfd->arch_info->mach; 00771 } 00772 00773 /* 00774 FUNCTION 00775 bfd_arch_bits_per_byte 00776 00777 SYNOPSIS 00778 unsigned int bfd_arch_bits_per_byte (bfd *abfd); 00779 00780 DESCRIPTION 00781 Return the number of bits in one of the BFD @var{abfd}'s 00782 architecture's bytes. 00783 */ 00784 00785 unsigned int 00786 bfd_arch_bits_per_byte (bfd *abfd) 00787 { 00788 return abfd->arch_info->bits_per_byte; 00789 } 00790 00791 /* 00792 FUNCTION 00793 bfd_arch_bits_per_address 00794 00795 SYNOPSIS 00796 unsigned int bfd_arch_bits_per_address (bfd *abfd); 00797 00798 DESCRIPTION 00799 Return the number of bits in one of the BFD @var{abfd}'s 00800 architecture's addresses. 00801 */ 00802 00803 unsigned int 00804 bfd_arch_bits_per_address (bfd *abfd) 00805 { 00806 return abfd->arch_info->bits_per_address; 00807 } 00808 00809 /* 00810 INTERNAL_FUNCTION 00811 bfd_default_compatible 00812 00813 SYNOPSIS 00814 const bfd_arch_info_type *bfd_default_compatible 00815 (const bfd_arch_info_type *a, const bfd_arch_info_type *b); 00816 00817 DESCRIPTION 00818 The default function for testing for compatibility. 00819 */ 00820 00821 const bfd_arch_info_type * 00822 bfd_default_compatible (const bfd_arch_info_type *a, 00823 const bfd_arch_info_type *b) 00824 { 00825 if (a->arch != b->arch) 00826 return NULL; 00827 00828 if (a->bits_per_word != b->bits_per_word) 00829 return NULL; 00830 00831 if (a->mach > b->mach) 00832 return a; 00833 00834 if (b->mach > a->mach) 00835 return b; 00836 00837 return a; 00838 } 00839 00840 /* 00841 INTERNAL_FUNCTION 00842 bfd_default_scan 00843 00844 SYNOPSIS 00845 bfd_boolean bfd_default_scan 00846 (const struct bfd_arch_info *info, const char *string); 00847 00848 DESCRIPTION 00849 The default function for working out whether this is an 00850 architecture hit and a machine hit. 00851 */ 00852 00853 bfd_boolean 00854 bfd_default_scan (const bfd_arch_info_type *info, const char *string) 00855 { 00856 const char *ptr_src; 00857 const char *ptr_tst; 00858 unsigned long number; 00859 enum bfd_architecture arch; 00860 const char *printable_name_colon; 00861 00862 /* Exact match of the architecture name (ARCH_NAME) and also the 00863 default architecture? */ 00864 if (strcasecmp (string, info->arch_name) == 0 00865 && info->the_default) 00866 return TRUE; 00867 00868 /* Exact match of the machine name (PRINTABLE_NAME)? */ 00869 if (strcasecmp (string, info->printable_name) == 0) 00870 return TRUE; 00871 00872 /* Given that printable_name contains no colon, attempt to match: 00873 ARCH_NAME [ ":" ] PRINTABLE_NAME? */ 00874 printable_name_colon = strchr (info->printable_name, ':'); 00875 if (printable_name_colon == NULL) 00876 { 00877 size_t strlen_arch_name = strlen (info->arch_name); 00878 if (strncasecmp (string, info->arch_name, strlen_arch_name) == 0) 00879 { 00880 if (string[strlen_arch_name] == ':') 00881 { 00882 if (strcasecmp (string + strlen_arch_name + 1, 00883 info->printable_name) == 0) 00884 return TRUE; 00885 } 00886 else 00887 { 00888 if (strcasecmp (string + strlen_arch_name, 00889 info->printable_name) == 0) 00890 return TRUE; 00891 } 00892 } 00893 } 00894 00895 /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>; 00896 Attempt to match: <arch> <mach>? */ 00897 if (printable_name_colon != NULL) 00898 { 00899 size_t colon_index = printable_name_colon - info->printable_name; 00900 if (strncasecmp (string, info->printable_name, colon_index) == 0 00901 && strcasecmp (string + colon_index, 00902 info->printable_name + colon_index + 1) == 0) 00903 return TRUE; 00904 } 00905 00906 /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>; Do not 00907 attempt to match just <mach>, it could be ambiguous. This test 00908 is left until later. */ 00909 00910 /* NOTE: The below is retained for compatibility only. Please do 00911 not add to this code. */ 00912 00913 /* See how much of the supplied string matches with the 00914 architecture, eg the string m68k:68020 would match the 68k entry 00915 up to the :, then we get left with the machine number. */ 00916 00917 for (ptr_src = string, ptr_tst = info->arch_name; 00918 *ptr_src && *ptr_tst; 00919 ptr_src++, ptr_tst++) 00920 { 00921 if (*ptr_src != *ptr_tst) 00922 break; 00923 } 00924 00925 /* Chewed up as much of the architecture as will match, skip any 00926 colons. */ 00927 if (*ptr_src == ':') 00928 ptr_src++; 00929 00930 if (*ptr_src == 0) 00931 { 00932 /* Nothing more, then only keep this one if it is the default 00933 machine for this architecture. */ 00934 return info->the_default; 00935 } 00936 00937 number = 0; 00938 while (ISDIGIT (*ptr_src)) 00939 { 00940 number = number * 10 + *ptr_src - '0'; 00941 ptr_src++; 00942 } 00943 00944 /* NOTE: The below is retained for compatibility only. 00945 PLEASE DO NOT ADD TO THIS CODE. */ 00946 00947 switch (number) 00948 { 00949 /* FIXME: These are needed to parse IEEE objects. */ 00950 /* The following seven case's are here only for compatibility with 00951 older binutils (at least IEEE objects from binutils 2.9.1 require 00952 them). */ 00953 case bfd_mach_m68000: 00954 case bfd_mach_m68010: 00955 case bfd_mach_m68020: 00956 case bfd_mach_m68030: 00957 case bfd_mach_m68040: 00958 case bfd_mach_m68060: 00959 case bfd_mach_cpu32: 00960 arch = bfd_arch_m68k; 00961 break; 00962 case 68000: 00963 arch = bfd_arch_m68k; 00964 number = bfd_mach_m68000; 00965 break; 00966 case 68010: 00967 arch = bfd_arch_m68k; 00968 number = bfd_mach_m68010; 00969 break; 00970 case 68020: 00971 arch = bfd_arch_m68k; 00972 number = bfd_mach_m68020; 00973 break; 00974 case 68030: 00975 arch = bfd_arch_m68k; 00976 number = bfd_mach_m68030; 00977 break; 00978 case 68040: 00979 arch = bfd_arch_m68k; 00980 number = bfd_mach_m68040; 00981 break; 00982 case 68060: 00983 arch = bfd_arch_m68k; 00984 number = bfd_mach_m68060; 00985 break; 00986 case 68332: 00987 arch = bfd_arch_m68k; 00988 number = bfd_mach_cpu32; 00989 break; 00990 case 5200: 00991 arch = bfd_arch_m68k; 00992 number = bfd_mach_mcf5200; 00993 break; 00994 case 5206: 00995 arch = bfd_arch_m68k; 00996 number = bfd_mach_mcf5206e; 00997 break; 00998 case 5307: 00999 arch = bfd_arch_m68k; 01000 number = bfd_mach_mcf5307; 01001 break; 01002 case 5407: 01003 arch = bfd_arch_m68k; 01004 number = bfd_mach_mcf5407; 01005 break; 01006 case 5282: 01007 arch = bfd_arch_m68k; 01008 number = bfd_mach_mcf528x; 01009 break; 01010 01011 case 32000: 01012 arch = bfd_arch_we32k; 01013 break; 01014 01015 case 3000: 01016 arch = bfd_arch_mips; 01017 number = bfd_mach_mips3000; 01018 break; 01019 01020 case 4000: 01021 arch = bfd_arch_mips; 01022 number = bfd_mach_mips4000; 01023 break; 01024 01025 case 6000: 01026 arch = bfd_arch_rs6000; 01027 break; 01028 01029 case 7410: 01030 arch = bfd_arch_sh; 01031 number = bfd_mach_sh_dsp; 01032 break; 01033 01034 case 7708: 01035 arch = bfd_arch_sh; 01036 number = bfd_mach_sh3; 01037 break; 01038 01039 case 7729: 01040 arch = bfd_arch_sh; 01041 number = bfd_mach_sh3_dsp; 01042 break; 01043 01044 case 7750: 01045 arch = bfd_arch_sh; 01046 number = bfd_mach_sh4; 01047 break; 01048 01049 default: 01050 return FALSE; 01051 } 01052 01053 if (arch != info->arch) 01054 return FALSE; 01055 01056 if (number != info->mach) 01057 return FALSE; 01058 01059 return TRUE; 01060 } 01061 01062 /* 01063 FUNCTION 01064 bfd_get_arch_info 01065 01066 SYNOPSIS 01067 const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd); 01068 01069 DESCRIPTION 01070 Return the architecture info struct in @var{abfd}. 01071 */ 01072 01073 const bfd_arch_info_type * 01074 bfd_get_arch_info (bfd *abfd) 01075 { 01076 return abfd->arch_info; 01077 } 01078 01079 /* 01080 FUNCTION 01081 bfd_lookup_arch 01082 01083 SYNOPSIS 01084 const bfd_arch_info_type *bfd_lookup_arch 01085 (enum bfd_architecture arch, unsigned long machine); 01086 01087 DESCRIPTION 01088 Look for the architecture info structure which matches the 01089 arguments @var{arch} and @var{machine}. A machine of 0 matches the 01090 machine/architecture structure which marks itself as the 01091 default. 01092 */ 01093 01094 const bfd_arch_info_type * 01095 bfd_lookup_arch (enum bfd_architecture arch, unsigned long machine) 01096 { 01097 const bfd_arch_info_type * const *app, *ap; 01098 01099 for (app = bfd_archures_list; *app != NULL; app++) 01100 { 01101 for (ap = *app; ap != NULL; ap = ap->next) 01102 { 01103 if (ap->arch == arch 01104 && (ap->mach == machine 01105 || (machine == 0 && ap->the_default))) 01106 return ap; 01107 } 01108 } 01109 01110 return NULL; 01111 } 01112 01113 /* 01114 FUNCTION 01115 bfd_printable_arch_mach 01116 01117 SYNOPSIS 01118 const char *bfd_printable_arch_mach 01119 (enum bfd_architecture arch, unsigned long machine); 01120 01121 DESCRIPTION 01122 Return a printable string representing the architecture and 01123 machine type. 01124 01125 This routine is depreciated. 01126 */ 01127 01128 const char * 01129 bfd_printable_arch_mach (enum bfd_architecture arch, unsigned long machine) 01130 { 01131 const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine); 01132 01133 if (ap) 01134 return ap->printable_name; 01135 return "UNKNOWN!"; 01136 } 01137 01138 /* 01139 FUNCTION 01140 bfd_octets_per_byte 01141 01142 SYNOPSIS 01143 unsigned int bfd_octets_per_byte (bfd *abfd); 01144 01145 DESCRIPTION 01146 Return the number of octets (8-bit quantities) per target byte 01147 (minimum addressable unit). In most cases, this will be one, but some 01148 DSP targets have 16, 32, or even 48 bits per byte. 01149 */ 01150 01151 unsigned int 01152 bfd_octets_per_byte (bfd *abfd) 01153 { 01154 return bfd_arch_mach_octets_per_byte (bfd_get_arch (abfd), 01155 bfd_get_mach (abfd)); 01156 } 01157 01158 /* 01159 FUNCTION 01160 bfd_arch_mach_octets_per_byte 01161 01162 SYNOPSIS 01163 unsigned int bfd_arch_mach_octets_per_byte 01164 (enum bfd_architecture arch, unsigned long machine); 01165 01166 DESCRIPTION 01167 See bfd_octets_per_byte. 01168 01169 This routine is provided for those cases where a bfd * is not 01170 available 01171 */ 01172 01173 unsigned int 01174 bfd_arch_mach_octets_per_byte (enum bfd_architecture arch, 01175 unsigned long mach) 01176 { 01177 const bfd_arch_info_type *ap = bfd_lookup_arch (arch, mach); 01178 01179 if (ap) 01180 return ap->bits_per_byte / 8; 01181 return 1; 01182 }
1.5.6