archures.c revision 78828
133965Sjdp/* BFD library support routines for architectures. 278828Sobrien Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 378828Sobrien 2000, 2001 460484Sobrien Free Software Foundation, Inc. 533965Sjdp Hacked by John Gilmore and Steve Chamberlain of Cygnus Support. 633965Sjdp 733965SjdpThis file is part of BFD, the Binary File Descriptor library. 833965Sjdp 933965SjdpThis program is free software; you can redistribute it and/or modify 1033965Sjdpit under the terms of the GNU General Public License as published by 1133965Sjdpthe Free Software Foundation; either version 2 of the License, or 1233965Sjdp(at your option) any later version. 1333965Sjdp 1433965SjdpThis program is distributed in the hope that it will be useful, 1533965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of 1633965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1733965SjdpGNU General Public License for more details. 1833965Sjdp 1933965SjdpYou should have received a copy of the GNU General Public License 2033965Sjdpalong with this program; if not, write to the Free Software 2133965SjdpFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 2233965Sjdp 2333965Sjdp#include "bfd.h" 2433965Sjdp#include "sysdep.h" 2533965Sjdp#include "libbfd.h" 2633965Sjdp#include <ctype.h> 2733965Sjdp 2833965Sjdp/* 2933965Sjdp 3033965SjdpSECTION 3133965Sjdp Architectures 3233965Sjdp 3333965Sjdp BFD keeps one atom in a BFD describing the 3433965Sjdp architecture of the data attached to the BFD: a pointer to a 3577298Sobrien <<bfd_arch_info_type>>. 3633965Sjdp 3733965Sjdp Pointers to structures can be requested independently of a BFD 3833965Sjdp so that an architecture's information can be interrogated 3933965Sjdp without access to an open BFD. 4033965Sjdp 4133965Sjdp The architecture information is provided by each architecture package. 4233965Sjdp The set of default architectures is selected by the macro 4333965Sjdp <<SELECT_ARCHITECTURES>>. This is normally set up in the 4433965Sjdp @file{config/@var{target}.mt} file of your choice. If the name is not 4577298Sobrien defined, then all the architectures supported are included. 4633965Sjdp 4733965Sjdp When BFD starts up, all the architectures are called with an 4833965Sjdp initialize method. It is up to the architecture back end to 4933965Sjdp insert as many items into the list of architectures as it wants to; 5033965Sjdp generally this would be one for each machine and one for the 5177298Sobrien default case (an item with a machine field of 0). 5233965Sjdp 5333965Sjdp BFD's idea of an architecture is implemented in @file{archures.c}. 5433965Sjdp*/ 5533965Sjdp 5633965Sjdp/* 5733965Sjdp 5833965SjdpSUBSECTION 5933965Sjdp bfd_architecture 6033965Sjdp 6133965SjdpDESCRIPTION 6233965Sjdp This enum gives the object file's CPU architecture, in a 6333965Sjdp global sense---i.e., what processor family does it belong to? 6433965Sjdp Another field indicates which processor within 6533965Sjdp the family is in use. The machine gives a number which 6633965Sjdp distinguishes different versions of the architecture, 6733965Sjdp containing, for example, 2 and 3 for Intel i960 KA and i960 KB, 6877298Sobrien and 68020 and 68030 for Motorola 68020 and 68030. 6933965Sjdp 7077298Sobrien.enum bfd_architecture 7133965Sjdp.{ 7233965Sjdp. bfd_arch_unknown, {* File arch not known *} 7333965Sjdp. bfd_arch_obscure, {* Arch known, not one of these *} 7433965Sjdp. bfd_arch_m68k, {* Motorola 68xxx *} 7538889Sjdp.#define bfd_mach_m68000 1 7638889Sjdp.#define bfd_mach_m68008 2 7738889Sjdp.#define bfd_mach_m68010 3 7838889Sjdp.#define bfd_mach_m68020 4 7938889Sjdp.#define bfd_mach_m68030 5 8038889Sjdp.#define bfd_mach_m68040 6 8138889Sjdp.#define bfd_mach_m68060 7 8260484Sobrien.#define bfd_mach_cpu32 8 8378828Sobrien.#define bfd_mach_mcf5200 9 8478828Sobrien.#define bfd_mach_mcf5206e 10 8578828Sobrien.#define bfd_mach_mcf5307 11 8678828Sobrien.#define bfd_mach_mcf5407 12 8777298Sobrien. bfd_arch_vax, {* DEC Vax *} 8833965Sjdp. bfd_arch_i960, {* Intel 960 *} 8933965Sjdp. {* The order of the following is important. 9077298Sobrien. lower number indicates a machine type that 9133965Sjdp. only accepts a subset of the instructions 9233965Sjdp. available to machines with higher numbers. 9333965Sjdp. The exception is the "ca", which is 9477298Sobrien. incompatible with all other machines except 9533965Sjdp. "core". *} 9633965Sjdp. 9733965Sjdp.#define bfd_mach_i960_core 1 9833965Sjdp.#define bfd_mach_i960_ka_sa 2 9933965Sjdp.#define bfd_mach_i960_kb_sb 3 10033965Sjdp.#define bfd_mach_i960_mc 4 10133965Sjdp.#define bfd_mach_i960_xa 5 10233965Sjdp.#define bfd_mach_i960_ca 6 10333965Sjdp.#define bfd_mach_i960_jx 7 10433965Sjdp.#define bfd_mach_i960_hx 8 10533965Sjdp. 10633965Sjdp. bfd_arch_a29k, {* AMD 29000 *} 10733965Sjdp. bfd_arch_sparc, {* SPARC *} 10833965Sjdp.#define bfd_mach_sparc 1 10933965Sjdp.{* The difference between v8plus and v9 is that v9 is a true 64 bit env. *} 11033965Sjdp.#define bfd_mach_sparc_sparclet 2 11133965Sjdp.#define bfd_mach_sparc_sparclite 3 11233965Sjdp.#define bfd_mach_sparc_v8plus 4 11333965Sjdp.#define bfd_mach_sparc_v8plusa 5 {* with ultrasparc add'ns *} 11460484Sobrien.#define bfd_mach_sparc_sparclite_le 6 11560484Sobrien.#define bfd_mach_sparc_v9 7 11660484Sobrien.#define bfd_mach_sparc_v9a 8 {* with ultrasparc add'ns *} 11777298Sobrien.#define bfd_mach_sparc_v8plusb 9 {* with cheetah add'ns *} 11877298Sobrien.#define bfd_mach_sparc_v9b 10 {* with cheetah add'ns *} 11933965Sjdp.{* Nonzero if MACH has the v9 instruction set. *} 12033965Sjdp.#define bfd_mach_sparc_v9_p(mach) \ 12177298Sobrien. ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \ 12277298Sobrien. && (mach) != bfd_mach_sparc_sparclite_le) 12333965Sjdp. bfd_arch_mips, {* MIPS Rxxxx *} 12438889Sjdp.#define bfd_mach_mips3000 3000 12538889Sjdp.#define bfd_mach_mips3900 3900 12638889Sjdp.#define bfd_mach_mips4000 4000 12738889Sjdp.#define bfd_mach_mips4010 4010 12838889Sjdp.#define bfd_mach_mips4100 4100 12960484Sobrien.#define bfd_mach_mips4111 4111 13038889Sjdp.#define bfd_mach_mips4300 4300 13138889Sjdp.#define bfd_mach_mips4400 4400 13238889Sjdp.#define bfd_mach_mips4600 4600 13338889Sjdp.#define bfd_mach_mips4650 4650 13438889Sjdp.#define bfd_mach_mips5000 5000 13538889Sjdp.#define bfd_mach_mips6000 6000 13638889Sjdp.#define bfd_mach_mips8000 8000 13738889Sjdp.#define bfd_mach_mips10000 10000 13878828Sobrien.#define bfd_mach_mips12000 12000 13938889Sjdp.#define bfd_mach_mips16 16 14077298Sobrien.#define bfd_mach_mips32 32 14177298Sobrien.#define bfd_mach_mips32_4k 3204113 {* 32, 04, octal 'K' *} 14277298Sobrien.#define bfd_mach_mips5 5 14377298Sobrien.#define bfd_mach_mips64 64 14477298Sobrien.#define bfd_mach_mips_sb1 12310201 {* octal 'SB', 01 *} 14533965Sjdp. bfd_arch_i386, {* Intel 386 *} 14633965Sjdp.#define bfd_mach_i386_i386 0 14733965Sjdp.#define bfd_mach_i386_i8086 1 14860484Sobrien.#define bfd_mach_i386_i386_intel_syntax 2 14977298Sobrien.#define bfd_mach_x86_64 3 15077298Sobrien.#define bfd_mach_x86_64_intel_syntax 4 15133965Sjdp. bfd_arch_we32k, {* AT&T WE32xxx *} 15233965Sjdp. bfd_arch_tahoe, {* CCI/Harris Tahoe *} 15333965Sjdp. bfd_arch_i860, {* Intel 860 *} 15460484Sobrien. bfd_arch_i370, {* IBM 360/370 Mainframes *} 15533965Sjdp. bfd_arch_romp, {* IBM ROMP PC/RT *} 15633965Sjdp. bfd_arch_alliant, {* Alliant *} 15733965Sjdp. bfd_arch_convex, {* Convex *} 15833965Sjdp. bfd_arch_m88k, {* Motorola 88xxx *} 15933965Sjdp. bfd_arch_pyramid, {* Pyramid Technology *} 16033965Sjdp. bfd_arch_h8300, {* Hitachi H8/300 *} 16133965Sjdp.#define bfd_mach_h8300 1 16233965Sjdp.#define bfd_mach_h8300h 2 16333965Sjdp.#define bfd_mach_h8300s 3 16433965Sjdp. bfd_arch_powerpc, {* PowerPC *} 16577298Sobrien.#define bfd_mach_ppc 0 16677298Sobrien.#define bfd_mach_ppc_403 403 16777298Sobrien.#define bfd_mach_ppc_403gc 4030 16877298Sobrien.#define bfd_mach_ppc_505 505 16977298Sobrien.#define bfd_mach_ppc_601 601 17077298Sobrien.#define bfd_mach_ppc_602 602 17177298Sobrien.#define bfd_mach_ppc_603 603 17277298Sobrien.#define bfd_mach_ppc_ec603e 6031 17377298Sobrien.#define bfd_mach_ppc_604 604 17477298Sobrien.#define bfd_mach_ppc_620 620 17577298Sobrien.#define bfd_mach_ppc_630 630 17677298Sobrien.#define bfd_mach_ppc_750 750 17777298Sobrien.#define bfd_mach_ppc_860 860 17877298Sobrien.#define bfd_mach_ppc_a35 35 17977298Sobrien.#define bfd_mach_ppc_rs64ii 642 18077298Sobrien.#define bfd_mach_ppc_rs64iii 643 18177298Sobrien.#define bfd_mach_ppc_7400 7400 18233965Sjdp. bfd_arch_rs6000, {* IBM RS/6000 *} 18377298Sobrien.#define bfd_mach_rs6k 0 18477298Sobrien.#define bfd_mach_rs6k_rs1 6001 18577298Sobrien.#define bfd_mach_rs6k_rsc 6003 18677298Sobrien.#define bfd_mach_rs6k_rs2 6002 18733965Sjdp. bfd_arch_hppa, {* HP PA RISC *} 18833965Sjdp. bfd_arch_d10v, {* Mitsubishi D10V *} 18960484Sobrien.#define bfd_mach_d10v 0 19060484Sobrien.#define bfd_mach_d10v_ts2 2 19160484Sobrien.#define bfd_mach_d10v_ts3 3 19260484Sobrien. bfd_arch_d30v, {* Mitsubishi D30V *} 19377298Sobrien. bfd_arch_m68hc11, {* Motorola 68HC11 *} 19477298Sobrien. bfd_arch_m68hc12, {* Motorola 68HC12 *} 19533965Sjdp. bfd_arch_z8k, {* Zilog Z8000 *} 19633965Sjdp.#define bfd_mach_z8001 1 19733965Sjdp.#define bfd_mach_z8002 2 19833965Sjdp. bfd_arch_h8500, {* Hitachi H8/500 *} 19933965Sjdp. bfd_arch_sh, {* Hitachi SH *} 20038889Sjdp.#define bfd_mach_sh 0 20160484Sobrien.#define bfd_mach_sh2 0x20 20260484Sobrien.#define bfd_mach_sh_dsp 0x2d 20338889Sjdp.#define bfd_mach_sh3 0x30 20460484Sobrien.#define bfd_mach_sh3_dsp 0x3d 20538889Sjdp.#define bfd_mach_sh3e 0x3e 20638889Sjdp.#define bfd_mach_sh4 0x40 20733965Sjdp. bfd_arch_alpha, {* Dec Alpha *} 20860484Sobrien.#define bfd_mach_alpha_ev4 0x10 20960484Sobrien.#define bfd_mach_alpha_ev5 0x20 21060484Sobrien.#define bfd_mach_alpha_ev6 0x30 21133965Sjdp. bfd_arch_arm, {* Advanced Risc Machines ARM *} 21238889Sjdp.#define bfd_mach_arm_2 1 21360484Sobrien.#define bfd_mach_arm_2a 2 21438889Sjdp.#define bfd_mach_arm_3 3 21538889Sjdp.#define bfd_mach_arm_3M 4 21660484Sobrien.#define bfd_mach_arm_4 5 21738889Sjdp.#define bfd_mach_arm_4T 6 21860484Sobrien.#define bfd_mach_arm_5 7 21960484Sobrien.#define bfd_mach_arm_5T 8 22077298Sobrien.#define bfd_mach_arm_5TE 9 22177298Sobrien.#define bfd_mach_arm_XScale 10 22233965Sjdp. bfd_arch_ns32k, {* National Semiconductors ns32000 *} 22333965Sjdp. bfd_arch_w65, {* WDC 65816 *} 22438889Sjdp. bfd_arch_tic30, {* Texas Instruments TMS320C30 *} 22577298Sobrien. bfd_arch_tic54x, {* Texas Instruments TMS320C54X *} 22660484Sobrien. bfd_arch_tic80, {* TI TMS320c80 (MVP) *} 22738889Sjdp. bfd_arch_v850, {* NEC V850 *} 22838889Sjdp.#define bfd_mach_v850 0 22960484Sobrien.#define bfd_mach_v850e 'E' 23060484Sobrien.#define bfd_mach_v850ea 'A' 23177298Sobrien. bfd_arch_arc, {* ARC Cores *} 23277298Sobrien.#define bfd_mach_arc_5 0 23377298Sobrien.#define bfd_mach_arc_6 1 23477298Sobrien.#define bfd_mach_arc_7 2 23577298Sobrien.#define bfd_mach_arc_8 3 23633965Sjdp. bfd_arch_m32r, {* Mitsubishi M32R/D *} 23738889Sjdp.#define bfd_mach_m32r 0 {* backwards compatibility *} 23860484Sobrien.#define bfd_mach_m32rx 'x' 23933965Sjdp. bfd_arch_mn10200, {* Matsushita MN10200 *} 24033965Sjdp. bfd_arch_mn10300, {* Matsushita MN10300 *} 24160484Sobrien.#define bfd_mach_mn10300 300 24260484Sobrien.#define bfd_mach_am33 330 24360484Sobrien. bfd_arch_fr30, 24460484Sobrien.#define bfd_mach_fr30 0x46523330 24560484Sobrien. bfd_arch_mcore, 24677298Sobrien. bfd_arch_ia64, {* HP/Intel ia64 *} 24777298Sobrien.#define bfd_mach_ia64_elf64 0 24877298Sobrien.#define bfd_mach_ia64_elf32 1 24960484Sobrien. bfd_arch_pj, 25060484Sobrien. bfd_arch_avr, {* Atmel AVR microcontrollers *} 25160484Sobrien.#define bfd_mach_avr1 1 25260484Sobrien.#define bfd_mach_avr2 2 25360484Sobrien.#define bfd_mach_avr3 3 25460484Sobrien.#define bfd_mach_avr4 4 25577298Sobrien.#define bfd_mach_avr5 5 25677298Sobrien. bfd_arch_cris, {* Axis CRIS *} 25733965Sjdp. bfd_arch_last 25833965Sjdp. }; 25933965Sjdp*/ 26033965Sjdp 26133965Sjdp/* 26233965SjdpSUBSECTION 26333965Sjdp bfd_arch_info 26433965Sjdp 26533965SjdpDESCRIPTION 26633965Sjdp This structure contains information on architectures for use 26733965Sjdp within BFD. 26833965Sjdp 26933965Sjdp. 27077298Sobrien.typedef struct bfd_arch_info 27133965Sjdp.{ 27233965Sjdp. int bits_per_word; 27333965Sjdp. int bits_per_address; 27433965Sjdp. int bits_per_byte; 27533965Sjdp. enum bfd_architecture arch; 27633965Sjdp. unsigned long mach; 27733965Sjdp. const char *arch_name; 27833965Sjdp. const char *printable_name; 27933965Sjdp. unsigned int section_align_power; 28077298Sobrien. {* True if this is the default machine for the architecture. *} 28177298Sobrien. boolean the_default; 28233965Sjdp. const struct bfd_arch_info * (*compatible) 28333965Sjdp. PARAMS ((const struct bfd_arch_info *a, 28433965Sjdp. const struct bfd_arch_info *b)); 28533965Sjdp. 28633965Sjdp. boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *)); 28733965Sjdp. 28833965Sjdp. const struct bfd_arch_info *next; 28933965Sjdp.} bfd_arch_info_type; 29033965Sjdp*/ 29133965Sjdp 29233965Sjdpextern const bfd_arch_info_type bfd_a29k_arch; 29333965Sjdpextern const bfd_arch_info_type bfd_alpha_arch; 29438889Sjdpextern const bfd_arch_info_type bfd_arc_arch; 29533965Sjdpextern const bfd_arch_info_type bfd_arm_arch; 29677298Sobrienextern const bfd_arch_info_type bfd_cris_arch; 29733965Sjdpextern const bfd_arch_info_type bfd_d10v_arch; 29860484Sobrienextern const bfd_arch_info_type bfd_d30v_arch; 29933965Sjdpextern const bfd_arch_info_type bfd_h8300_arch; 30033965Sjdpextern const bfd_arch_info_type bfd_h8500_arch; 30133965Sjdpextern const bfd_arch_info_type bfd_hppa_arch; 30260484Sobrienextern const bfd_arch_info_type bfd_i370_arch; 30333965Sjdpextern const bfd_arch_info_type bfd_i386_arch; 30433965Sjdpextern const bfd_arch_info_type bfd_i860_arch; 30533965Sjdpextern const bfd_arch_info_type bfd_i960_arch; 30633965Sjdpextern const bfd_arch_info_type bfd_m32r_arch; 30777298Sobrienextern const bfd_arch_info_type bfd_m68hc11_arch; 30877298Sobrienextern const bfd_arch_info_type bfd_m68hc12_arch; 30933965Sjdpextern const bfd_arch_info_type bfd_m68k_arch; 31033965Sjdpextern const bfd_arch_info_type bfd_m88k_arch; 31133965Sjdpextern const bfd_arch_info_type bfd_mips_arch; 31233965Sjdpextern const bfd_arch_info_type bfd_mn10200_arch; 31333965Sjdpextern const bfd_arch_info_type bfd_mn10300_arch; 31433965Sjdpextern const bfd_arch_info_type bfd_powerpc_arch; 31533965Sjdpextern const bfd_arch_info_type bfd_rs6000_arch; 31660484Sobrienextern const bfd_arch_info_type bfd_pj_arch; 31733965Sjdpextern const bfd_arch_info_type bfd_sh_arch; 31833965Sjdpextern const bfd_arch_info_type bfd_sparc_arch; 31938889Sjdpextern const bfd_arch_info_type bfd_tic30_arch; 32077298Sobrienextern const bfd_arch_info_type bfd_tic54x_arch; 32160484Sobrienextern const bfd_arch_info_type bfd_tic80_arch; 32233965Sjdpextern const bfd_arch_info_type bfd_vax_arch; 32333965Sjdpextern const bfd_arch_info_type bfd_we32k_arch; 32433965Sjdpextern const bfd_arch_info_type bfd_z8k_arch; 32533965Sjdpextern const bfd_arch_info_type bfd_ns32k_arch; 32633965Sjdpextern const bfd_arch_info_type bfd_w65_arch; 32738889Sjdpextern const bfd_arch_info_type bfd_v850_arch; 32860484Sobrienextern const bfd_arch_info_type bfd_fr30_arch; 32960484Sobrienextern const bfd_arch_info_type bfd_mcore_arch; 33060484Sobrienextern const bfd_arch_info_type bfd_avr_arch; 33177298Sobrienextern const bfd_arch_info_type bfd_ia64_arch; 33233965Sjdp 33377298Sobrienstatic const bfd_arch_info_type * const bfd_archures_list[] = { 33433965Sjdp#ifdef SELECT_ARCHITECTURES 33533965Sjdp SELECT_ARCHITECTURES, 33633965Sjdp#else 33733965Sjdp &bfd_a29k_arch, 33833965Sjdp &bfd_alpha_arch, 33938889Sjdp &bfd_arc_arch, 34033965Sjdp &bfd_arm_arch, 34177298Sobrien &bfd_cris_arch, 34233965Sjdp &bfd_d10v_arch, 34360484Sobrien &bfd_d30v_arch, 34433965Sjdp &bfd_h8300_arch, 34533965Sjdp &bfd_h8500_arch, 34633965Sjdp &bfd_hppa_arch, 34760484Sobrien &bfd_i370_arch, 34833965Sjdp &bfd_i386_arch, 34933965Sjdp &bfd_i860_arch, 35033965Sjdp &bfd_i960_arch, 35133965Sjdp &bfd_m32r_arch, 35277298Sobrien &bfd_m68hc11_arch, 35377298Sobrien &bfd_m68hc12_arch, 35433965Sjdp &bfd_m68k_arch, 35533965Sjdp &bfd_m88k_arch, 35633965Sjdp &bfd_mips_arch, 35733965Sjdp &bfd_mn10200_arch, 35833965Sjdp &bfd_mn10300_arch, 35933965Sjdp &bfd_powerpc_arch, 36033965Sjdp &bfd_rs6000_arch, 36133965Sjdp &bfd_sh_arch, 36233965Sjdp &bfd_sparc_arch, 36338889Sjdp &bfd_tic30_arch, 36477298Sobrien &bfd_tic54x_arch, 36560484Sobrien &bfd_tic80_arch, 36633965Sjdp &bfd_vax_arch, 36733965Sjdp &bfd_we32k_arch, 36833965Sjdp &bfd_z8k_arch, 36933965Sjdp &bfd_ns32k_arch, 37033965Sjdp &bfd_w65_arch, 37138889Sjdp &bfd_v850_arch, 37260484Sobrien &bfd_fr30_arch, 37360484Sobrien &bfd_mcore_arch, 37460484Sobrien &bfd_avr_arch, 37577298Sobrien &bfd_ia64_arch, 37633965Sjdp#endif 37733965Sjdp 0 37833965Sjdp}; 37933965Sjdp 38033965Sjdp/* 38133965SjdpFUNCTION 38233965Sjdp bfd_printable_name 38333965Sjdp 38433965SjdpSYNOPSIS 38533965Sjdp const char *bfd_printable_name(bfd *abfd); 38633965Sjdp 38733965SjdpDESCRIPTION 38833965Sjdp Return a printable string representing the architecture and machine 38933965Sjdp from the pointer to the architecture info structure. 39033965Sjdp 39133965Sjdp*/ 39233965Sjdp 39333965Sjdpconst char * 39433965Sjdpbfd_printable_name (abfd) 39533965Sjdp bfd *abfd; 39633965Sjdp{ 39733965Sjdp return abfd->arch_info->printable_name; 39833965Sjdp} 39933965Sjdp 40033965Sjdp/* 40133965SjdpFUNCTION 40233965Sjdp bfd_scan_arch 40333965Sjdp 40433965SjdpSYNOPSIS 40533965Sjdp const bfd_arch_info_type *bfd_scan_arch(const char *string); 40633965Sjdp 40733965SjdpDESCRIPTION 40833965Sjdp Figure out if BFD supports any cpu which could be described with 40933965Sjdp the name @var{string}. Return a pointer to an <<arch_info>> 41033965Sjdp structure if a machine is found, otherwise NULL. 41133965Sjdp*/ 41233965Sjdp 41333965Sjdpconst bfd_arch_info_type * 41433965Sjdpbfd_scan_arch (string) 41533965Sjdp const char *string; 41633965Sjdp{ 41733965Sjdp const bfd_arch_info_type * const *app, *ap; 41833965Sjdp 41977298Sobrien /* Look through all the installed architectures. */ 42033965Sjdp for (app = bfd_archures_list; *app != NULL; app++) 42133965Sjdp { 42233965Sjdp for (ap = *app; ap != NULL; ap = ap->next) 42333965Sjdp { 42433965Sjdp if (ap->scan (ap, string)) 42533965Sjdp return ap; 42633965Sjdp } 42733965Sjdp } 42833965Sjdp 42933965Sjdp return NULL; 43033965Sjdp} 43133965Sjdp 43233965Sjdp/* 43333965SjdpFUNCTION 43438889Sjdp bfd_arch_list 43538889Sjdp 43638889SjdpSYNOPSIS 43738889Sjdp const char **bfd_arch_list(void); 43838889Sjdp 43938889SjdpDESCRIPTION 44038889Sjdp Return a freshly malloced NULL-terminated vector of the names 44138889Sjdp of all the valid BFD architectures. Do not modify the names. 44238889Sjdp*/ 44338889Sjdp 44438889Sjdpconst char ** 44538889Sjdpbfd_arch_list () 44638889Sjdp{ 44738889Sjdp int vec_length = 0; 44838889Sjdp const char **name_ptr; 44938889Sjdp const char **name_list; 45038889Sjdp const bfd_arch_info_type * const *app; 45138889Sjdp 45277298Sobrien /* Determine the number of architectures. */ 45338889Sjdp vec_length = 0; 45438889Sjdp for (app = bfd_archures_list; *app != NULL; app++) 45538889Sjdp { 45638889Sjdp const bfd_arch_info_type *ap; 45738889Sjdp for (ap = *app; ap != NULL; ap = ap->next) 45838889Sjdp { 45938889Sjdp vec_length++; 46038889Sjdp } 46138889Sjdp } 46238889Sjdp 46377298Sobrien name_list = (const char **) 46438889Sjdp bfd_malloc ((vec_length + 1) * sizeof (char **)); 46538889Sjdp if (name_list == NULL) 46638889Sjdp return NULL; 46738889Sjdp 46877298Sobrien /* Point the list at each of the names. */ 46938889Sjdp name_ptr = name_list; 47038889Sjdp for (app = bfd_archures_list; *app != NULL; app++) 47138889Sjdp { 47238889Sjdp const bfd_arch_info_type *ap; 47338889Sjdp for (ap = *app; ap != NULL; ap = ap->next) 47438889Sjdp { 47538889Sjdp *name_ptr = ap->printable_name; 47638889Sjdp name_ptr++; 47738889Sjdp } 47838889Sjdp } 47938889Sjdp *name_ptr = NULL; 48038889Sjdp 48138889Sjdp return name_list; 48238889Sjdp} 48338889Sjdp 48438889Sjdp/* 48538889SjdpFUNCTION 48633965Sjdp bfd_arch_get_compatible 48733965Sjdp 48833965SjdpSYNOPSIS 48933965Sjdp const bfd_arch_info_type *bfd_arch_get_compatible( 49033965Sjdp const bfd *abfd, 49133965Sjdp const bfd *bbfd); 49233965Sjdp 49333965SjdpDESCRIPTION 49433965Sjdp Determine whether two BFDs' 49533965Sjdp architectures and machine types are compatible. Calculates 49633965Sjdp the lowest common denominator between the two architectures 49733965Sjdp and machine types implied by the BFDs and returns a pointer to 49833965Sjdp an <<arch_info>> structure describing the compatible machine. 49933965Sjdp*/ 50033965Sjdp 50133965Sjdpconst bfd_arch_info_type * 50233965Sjdpbfd_arch_get_compatible (abfd, bbfd) 50333965Sjdp const bfd *abfd; 50433965Sjdp const bfd *bbfd; 50533965Sjdp{ 50633965Sjdp /* If either architecture is unknown, then all we can do is assume 50733965Sjdp the user knows what he's doing. */ 50833965Sjdp if (abfd->arch_info->arch == bfd_arch_unknown) 50977298Sobrien return bbfd->arch_info; 51033965Sjdp if (bbfd->arch_info->arch == bfd_arch_unknown) 51177298Sobrien return abfd->arch_info; 51233965Sjdp 51333965Sjdp /* Otherwise architecture-specific code has to decide. */ 51433965Sjdp return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info); 51533965Sjdp} 51633965Sjdp 51733965Sjdp/* 51833965SjdpINTERNAL_DEFINITION 51933965Sjdp bfd_default_arch_struct 52033965Sjdp 52133965SjdpDESCRIPTION 52233965Sjdp The <<bfd_default_arch_struct>> is an item of 52333965Sjdp <<bfd_arch_info_type>> which has been initialized to a fairly 52433965Sjdp generic state. A BFD starts life by pointing to this 52533965Sjdp structure, until the correct back end has determined the real 52633965Sjdp architecture of the file. 52733965Sjdp 52833965Sjdp.extern const bfd_arch_info_type bfd_default_arch_struct; 52933965Sjdp*/ 53033965Sjdp 53177298Sobrienconst bfd_arch_info_type bfd_default_arch_struct = { 53277298Sobrien 32, 32, 8, bfd_arch_unknown, 0, "unknown", "unknown", 2, true, 53377298Sobrien bfd_default_compatible, 53477298Sobrien bfd_default_scan, 53577298Sobrien 0, 53633965Sjdp}; 53733965Sjdp 53833965Sjdp/* 53933965SjdpFUNCTION 54033965Sjdp bfd_set_arch_info 54133965Sjdp 54233965SjdpSYNOPSIS 54333965Sjdp void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg); 54433965Sjdp 54533965SjdpDESCRIPTION 54633965Sjdp Set the architecture info of @var{abfd} to @var{arg}. 54733965Sjdp*/ 54833965Sjdp 54933965Sjdpvoid 55033965Sjdpbfd_set_arch_info (abfd, arg) 55133965Sjdp bfd *abfd; 55233965Sjdp const bfd_arch_info_type *arg; 55333965Sjdp{ 55433965Sjdp abfd->arch_info = arg; 55533965Sjdp} 55633965Sjdp 55733965Sjdp/* 55833965SjdpINTERNAL_FUNCTION 55933965Sjdp bfd_default_set_arch_mach 56033965Sjdp 56133965SjdpSYNOPSIS 56233965Sjdp boolean bfd_default_set_arch_mach(bfd *abfd, 56333965Sjdp enum bfd_architecture arch, 56433965Sjdp unsigned long mach); 56533965Sjdp 56633965SjdpDESCRIPTION 56733965Sjdp Set the architecture and machine type in BFD @var{abfd} 56833965Sjdp to @var{arch} and @var{mach}. Find the correct 56933965Sjdp pointer to a structure and insert it into the <<arch_info>> 57077298Sobrien pointer. 57133965Sjdp*/ 57233965Sjdp 57333965Sjdpboolean 57433965Sjdpbfd_default_set_arch_mach (abfd, arch, mach) 57533965Sjdp bfd *abfd; 57633965Sjdp enum bfd_architecture arch; 57733965Sjdp unsigned long mach; 57833965Sjdp{ 57933965Sjdp const bfd_arch_info_type * const *app, *ap; 58033965Sjdp 58133965Sjdp for (app = bfd_archures_list; *app != NULL; app++) 58233965Sjdp { 58333965Sjdp for (ap = *app; ap != NULL; ap = ap->next) 58433965Sjdp { 58533965Sjdp if (ap->arch == arch 58633965Sjdp && (ap->mach == mach 58733965Sjdp || (mach == 0 && ap->the_default))) 58833965Sjdp { 58933965Sjdp abfd->arch_info = ap; 59033965Sjdp return true; 59133965Sjdp } 59233965Sjdp } 59333965Sjdp } 59433965Sjdp 59533965Sjdp abfd->arch_info = &bfd_default_arch_struct; 59633965Sjdp bfd_set_error (bfd_error_bad_value); 59733965Sjdp return false; 59833965Sjdp} 59933965Sjdp 60033965Sjdp/* 60133965SjdpFUNCTION 60233965Sjdp bfd_get_arch 60333965Sjdp 60433965SjdpSYNOPSIS 60533965Sjdp enum bfd_architecture bfd_get_arch(bfd *abfd); 60633965Sjdp 60733965SjdpDESCRIPTION 60833965Sjdp Return the enumerated type which describes the BFD @var{abfd}'s 60933965Sjdp architecture. 61033965Sjdp*/ 61133965Sjdp 61233965Sjdpenum bfd_architecture 61333965Sjdpbfd_get_arch (abfd) 61433965Sjdp bfd *abfd; 61533965Sjdp{ 61677298Sobrien return abfd->arch_info->arch; 61733965Sjdp} 61833965Sjdp 61933965Sjdp/* 62033965SjdpFUNCTION 62133965Sjdp bfd_get_mach 62233965Sjdp 62333965SjdpSYNOPSIS 62433965Sjdp unsigned long bfd_get_mach(bfd *abfd); 62533965Sjdp 62633965SjdpDESCRIPTION 62733965Sjdp Return the long type which describes the BFD @var{abfd}'s 62833965Sjdp machine. 62933965Sjdp*/ 63033965Sjdp 63177298Sobrienunsigned long 63233965Sjdpbfd_get_mach (abfd) 63333965Sjdp bfd *abfd; 63433965Sjdp{ 63577298Sobrien return abfd->arch_info->mach; 63633965Sjdp} 63733965Sjdp 63833965Sjdp/* 63933965SjdpFUNCTION 64033965Sjdp bfd_arch_bits_per_byte 64133965Sjdp 64233965SjdpSYNOPSIS 64333965Sjdp unsigned int bfd_arch_bits_per_byte(bfd *abfd); 64433965Sjdp 64533965SjdpDESCRIPTION 64633965Sjdp Return the number of bits in one of the BFD @var{abfd}'s 64733965Sjdp architecture's bytes. 64833965Sjdp*/ 64933965Sjdp 65033965Sjdpunsigned int 65133965Sjdpbfd_arch_bits_per_byte (abfd) 65233965Sjdp bfd *abfd; 65333965Sjdp{ 65433965Sjdp return abfd->arch_info->bits_per_byte; 65533965Sjdp} 65633965Sjdp 65733965Sjdp/* 65833965SjdpFUNCTION 65933965Sjdp bfd_arch_bits_per_address 66033965Sjdp 66133965SjdpSYNOPSIS 66233965Sjdp unsigned int bfd_arch_bits_per_address(bfd *abfd); 66333965Sjdp 66433965SjdpDESCRIPTION 66533965Sjdp Return the number of bits in one of the BFD @var{abfd}'s 66633965Sjdp architecture's addresses. 66733965Sjdp*/ 66833965Sjdp 66933965Sjdpunsigned int 67033965Sjdpbfd_arch_bits_per_address (abfd) 67133965Sjdp bfd *abfd; 67233965Sjdp{ 67333965Sjdp return abfd->arch_info->bits_per_address; 67433965Sjdp} 67533965Sjdp 67633965Sjdp/* 67777298SobrienINTERNAL_FUNCTION 67833965Sjdp bfd_default_compatible 67933965Sjdp 68033965SjdpSYNOPSIS 68133965Sjdp const bfd_arch_info_type *bfd_default_compatible 68233965Sjdp (const bfd_arch_info_type *a, 68333965Sjdp const bfd_arch_info_type *b); 68433965Sjdp 68533965SjdpDESCRIPTION 68633965Sjdp The default function for testing for compatibility. 68733965Sjdp*/ 68833965Sjdp 68933965Sjdpconst bfd_arch_info_type * 69077298Sobrienbfd_default_compatible (a, b) 69133965Sjdp const bfd_arch_info_type *a; 69233965Sjdp const bfd_arch_info_type *b; 69333965Sjdp{ 69433965Sjdp if (a->arch != b->arch) 69533965Sjdp return NULL; 69633965Sjdp 69733965Sjdp if (a->mach > b->mach) 69833965Sjdp return a; 69933965Sjdp 70033965Sjdp if (b->mach > a->mach) 70133965Sjdp return b; 70233965Sjdp 70333965Sjdp return a; 70433965Sjdp} 70533965Sjdp 70633965Sjdp/* 70733965SjdpINTERNAL_FUNCTION 70833965Sjdp bfd_default_scan 70933965Sjdp 71033965SjdpSYNOPSIS 71133965Sjdp boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string); 71233965Sjdp 71333965SjdpDESCRIPTION 71433965Sjdp The default function for working out whether this is an 71533965Sjdp architecture hit and a machine hit. 71633965Sjdp*/ 71733965Sjdp 71877298Sobrienboolean 71933965Sjdpbfd_default_scan (info, string) 72033965Sjdp const struct bfd_arch_info *info; 72133965Sjdp const char *string; 72233965Sjdp{ 72333965Sjdp const char *ptr_src; 72433965Sjdp const char *ptr_tst; 72533965Sjdp unsigned long number; 72633965Sjdp enum bfd_architecture arch; 72738889Sjdp const char *printable_name_colon; 72833965Sjdp 72938889Sjdp /* Exact match of the architecture name (ARCH_NAME) and also the 73077298Sobrien default architecture? */ 73138889Sjdp if (strcasecmp (string, info->arch_name) == 0 73238889Sjdp && info->the_default) 73333965Sjdp return true; 73433965Sjdp 73577298Sobrien /* Exact match of the machine name (PRINTABLE_NAME)? */ 73638889Sjdp if (strcasecmp (string, info->printable_name) == 0) 73738889Sjdp return true; 73877298Sobrien 73938889Sjdp /* Given that printable_name contains no colon, attempt to match: 74077298Sobrien ARCH_NAME [ ":" ] PRINTABLE_NAME? */ 74138889Sjdp printable_name_colon = strchr (info->printable_name, ':'); 74238889Sjdp if (printable_name_colon == NULL) 74338889Sjdp { 74438889Sjdp int strlen_arch_name = strlen (info->arch_name); 74538889Sjdp if (strncasecmp (string, info->arch_name, strlen_arch_name) == 0) 74638889Sjdp { 74738889Sjdp if (string[strlen_arch_name] == ':') 74838889Sjdp { 74938889Sjdp if (strcasecmp (string + strlen_arch_name + 1, 75038889Sjdp info->printable_name) == 0) 75138889Sjdp return true; 75238889Sjdp } 75338889Sjdp else 75438889Sjdp { 75538889Sjdp if (strcasecmp (string + strlen_arch_name, 75638889Sjdp info->printable_name) == 0) 75738889Sjdp return true; 75838889Sjdp } 75938889Sjdp } 76038889Sjdp } 76138889Sjdp 76238889Sjdp /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>; 76377298Sobrien Attempt to match: <arch> <mach>? */ 76438889Sjdp if (printable_name_colon != NULL) 76538889Sjdp { 76638889Sjdp int colon_index = printable_name_colon - info->printable_name; 76738889Sjdp if (strncasecmp (string, info->printable_name, colon_index) == 0 76838889Sjdp && strcasecmp (string + colon_index, 76938889Sjdp info->printable_name + colon_index + 1) == 0) 77038889Sjdp return true; 77138889Sjdp } 77238889Sjdp 77338889Sjdp /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>; Do not 77438889Sjdp attempt to match just <mach>, it could be ambigious. This test 77577298Sobrien is left until later. */ 77638889Sjdp 77777298Sobrien /* NOTE: The below is retained for compatibility only. Please do 77877298Sobrien not add to this code. */ 77938889Sjdp 78033965Sjdp /* See how much of the supplied string matches with the 78133965Sjdp architecture, eg the string m68k:68020 would match the 68k entry 78277298Sobrien up to the :, then we get left with the machine number. */ 78333965Sjdp 78477298Sobrien for (ptr_src = string, ptr_tst = info->arch_name; 78533965Sjdp *ptr_src && *ptr_tst; 78677298Sobrien ptr_src++, ptr_tst++) 78733965Sjdp { 78877298Sobrien if (*ptr_src != *ptr_tst) 78977298Sobrien break; 79033965Sjdp } 79133965Sjdp 79233965Sjdp /* Chewed up as much of the architecture as will match, skip any 79377298Sobrien colons. */ 79433965Sjdp if (*ptr_src == ':') 79533965Sjdp ptr_src++; 79677298Sobrien 79733965Sjdp if (*ptr_src == 0) 79833965Sjdp { 79977298Sobrien /* Nothing more, then only keep this one if it is the default 80077298Sobrien machine for this architecture. */ 80133965Sjdp return info->the_default; 80233965Sjdp } 80333965Sjdp 80433965Sjdp number = 0; 80538889Sjdp while (isdigit ((unsigned char) *ptr_src)) 80633965Sjdp { 80777298Sobrien number = number * 10 + *ptr_src - '0'; 80833965Sjdp ptr_src++; 80933965Sjdp } 81033965Sjdp 81138889Sjdp /* NOTE: The below is retained for compatibility only. 81277298Sobrien PLEASE DO NOT ADD TO THIS CODE. */ 81338889Sjdp 81477298Sobrien switch (number) 81533965Sjdp { 81638889Sjdp /* FIXME: These are needed to parse IEEE objects. */ 81777298Sobrien /* The following seven case's are here only for compatibility with 81877298Sobrien older binutils (at least IEEE objects from binutils 2.9.1 require 81977298Sobrien them). */ 82077298Sobrien case bfd_mach_m68000: 82177298Sobrien case bfd_mach_m68010: 82277298Sobrien case bfd_mach_m68020: 82377298Sobrien case bfd_mach_m68030: 82477298Sobrien case bfd_mach_m68040: 82577298Sobrien case bfd_mach_m68060: 82677298Sobrien case bfd_mach_cpu32: 82738889Sjdp arch = bfd_arch_m68k; 82877298Sobrien break; 82977298Sobrien case 68000: 83077298Sobrien arch = bfd_arch_m68k; 83138889Sjdp number = bfd_mach_m68000; 83233965Sjdp break; 83338889Sjdp case 68010: 83438889Sjdp arch = bfd_arch_m68k; 83538889Sjdp number = bfd_mach_m68010; 83633965Sjdp break; 83738889Sjdp case 68020: 83838889Sjdp arch = bfd_arch_m68k; 83938889Sjdp number = bfd_mach_m68020; 84033965Sjdp break; 84133965Sjdp case 68030: 84238889Sjdp arch = bfd_arch_m68k; 84338889Sjdp number = bfd_mach_m68030; 84438889Sjdp break; 84533965Sjdp case 68040: 84638889Sjdp arch = bfd_arch_m68k; 84738889Sjdp number = bfd_mach_m68040; 84838889Sjdp break; 84960484Sobrien case 68060: 85060484Sobrien arch = bfd_arch_m68k; 85160484Sobrien number = bfd_mach_m68060; 85260484Sobrien break; 85333965Sjdp case 68332: 85438889Sjdp arch = bfd_arch_m68k; 85560484Sobrien number = bfd_mach_cpu32; 85633965Sjdp break; 85778828Sobrien case 5200: 85878828Sobrien arch = bfd_arch_m68k; 85978828Sobrien number = bfd_mach_mcf5200; 86078828Sobrien break; 86178828Sobrien case 5206: 86278828Sobrien arch = bfd_arch_m68k; 86378828Sobrien number = bfd_mach_mcf5206e; 86478828Sobrien break; 86578828Sobrien case 5307: 86678828Sobrien arch = bfd_arch_m68k; 86778828Sobrien number = bfd_mach_mcf5307; 86878828Sobrien break; 86978828Sobrien case 5407: 87078828Sobrien arch = bfd_arch_m68k; 87178828Sobrien number = bfd_mach_mcf5407; 87278828Sobrien break; 87333965Sjdp 87433965Sjdp case 32000: 87533965Sjdp arch = bfd_arch_we32k; 87633965Sjdp break; 87733965Sjdp 87838889Sjdp case 3000: 87938889Sjdp arch = bfd_arch_mips; 88038889Sjdp number = bfd_mach_mips3000; 88133965Sjdp break; 88233965Sjdp 88333965Sjdp case 4000: 88433965Sjdp arch = bfd_arch_mips; 88538889Sjdp number = bfd_mach_mips4000; 88633965Sjdp break; 88733965Sjdp 88833965Sjdp case 6000: 88933965Sjdp arch = bfd_arch_rs6000; 89033965Sjdp break; 89133965Sjdp 89260484Sobrien case 7410: 89360484Sobrien arch = bfd_arch_sh; 89460484Sobrien number = bfd_mach_sh_dsp; 89560484Sobrien break; 89660484Sobrien 89760484Sobrien case 7708: 89860484Sobrien arch = bfd_arch_sh; 89960484Sobrien number = bfd_mach_sh3; 90060484Sobrien break; 90160484Sobrien 90260484Sobrien case 7729: 90360484Sobrien arch = bfd_arch_sh; 90460484Sobrien number = bfd_mach_sh3_dsp; 90560484Sobrien break; 90660484Sobrien 90760484Sobrien case 7750: 90860484Sobrien arch = bfd_arch_sh; 90960484Sobrien number = bfd_mach_sh4; 91060484Sobrien break; 91160484Sobrien 91277298Sobrien default: 91333965Sjdp return false; 91433965Sjdp } 91533965Sjdp 91677298Sobrien if (arch != info->arch) 91733965Sjdp return false; 91833965Sjdp 91933965Sjdp if (number != info->mach) 92033965Sjdp return false; 92133965Sjdp 92233965Sjdp return true; 92333965Sjdp} 92433965Sjdp 92533965Sjdp/* 92633965SjdpFUNCTION 92733965Sjdp bfd_get_arch_info 92833965Sjdp 92933965SjdpSYNOPSIS 93033965Sjdp const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd); 93133965Sjdp 93233965SjdpDESCRIPTION 93333965Sjdp Return the architecture info struct in @var{abfd}. 93433965Sjdp*/ 93533965Sjdp 93633965Sjdpconst bfd_arch_info_type * 93733965Sjdpbfd_get_arch_info (abfd) 93833965Sjdp bfd *abfd; 93933965Sjdp{ 94033965Sjdp return abfd->arch_info; 94133965Sjdp} 94233965Sjdp 94333965Sjdp/* 94433965SjdpFUNCTION 94533965Sjdp bfd_lookup_arch 94633965Sjdp 94733965SjdpSYNOPSIS 94833965Sjdp const bfd_arch_info_type *bfd_lookup_arch 94933965Sjdp (enum bfd_architecture 95033965Sjdp arch, 95133965Sjdp unsigned long machine); 95233965Sjdp 95333965SjdpDESCRIPTION 95433965Sjdp Look for the architecure info structure which matches the 95533965Sjdp arguments @var{arch} and @var{machine}. A machine of 0 matches the 95633965Sjdp machine/architecture structure which marks itself as the 95733965Sjdp default. 95833965Sjdp*/ 95933965Sjdp 96077298Sobrienconst bfd_arch_info_type * 96133965Sjdpbfd_lookup_arch (arch, machine) 96233965Sjdp enum bfd_architecture arch; 96333965Sjdp unsigned long machine; 96433965Sjdp{ 96533965Sjdp const bfd_arch_info_type * const *app, *ap; 96633965Sjdp 96733965Sjdp for (app = bfd_archures_list; *app != NULL; app++) 96833965Sjdp { 96933965Sjdp for (ap = *app; ap != NULL; ap = ap->next) 97033965Sjdp { 97133965Sjdp if (ap->arch == arch 97233965Sjdp && (ap->mach == machine 97333965Sjdp || (machine == 0 && ap->the_default))) 97433965Sjdp return ap; 97533965Sjdp } 97633965Sjdp } 97733965Sjdp 97833965Sjdp return NULL; 97933965Sjdp} 98033965Sjdp 98133965Sjdp/* 98233965SjdpFUNCTION 98333965Sjdp bfd_printable_arch_mach 98433965Sjdp 98533965SjdpSYNOPSIS 98633965Sjdp const char *bfd_printable_arch_mach 98733965Sjdp (enum bfd_architecture arch, unsigned long machine); 98833965Sjdp 98933965SjdpDESCRIPTION 99033965Sjdp Return a printable string representing the architecture and 99177298Sobrien machine type. 99233965Sjdp 99333965Sjdp This routine is depreciated. 99433965Sjdp*/ 99533965Sjdp 99633965Sjdpconst char * 99733965Sjdpbfd_printable_arch_mach (arch, machine) 99833965Sjdp enum bfd_architecture arch; 99933965Sjdp unsigned long machine; 100033965Sjdp{ 100177298Sobrien const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine); 100233965Sjdp 100377298Sobrien if (ap) 100477298Sobrien return ap->printable_name; 100577298Sobrien return "UNKNOWN!"; 100633965Sjdp} 100760484Sobrien 100860484Sobrien/* 100960484SobrienFUNCTION 101060484Sobrien bfd_octets_per_byte 101160484Sobrien 101260484SobrienSYNOPSIS 101360484Sobrien unsigned int bfd_octets_per_byte(bfd *abfd); 101460484Sobrien 101560484SobrienDESCRIPTION 101660484Sobrien Return the number of octets (8-bit quantities) per target byte 101760484Sobrien (minimum addressable unit). In most cases, this will be one, but some 101860484Sobrien DSP targets have 16, 32, or even 48 bits per byte. 101960484Sobrien*/ 102060484Sobrien 102160484Sobrienunsigned int 102260484Sobrienbfd_octets_per_byte (abfd) 102377298Sobrien bfd *abfd; 102460484Sobrien{ 102577298Sobrien return bfd_arch_mach_octets_per_byte (bfd_get_arch (abfd), 102677298Sobrien bfd_get_mach (abfd)); 102760484Sobrien} 102860484Sobrien 102960484Sobrien/* 103060484SobrienFUNCTION 103160484Sobrien bfd_arch_mach_octets_per_byte 103260484Sobrien 103360484SobrienSYNOPSIS 103460484Sobrien unsigned int bfd_arch_mach_octets_per_byte(enum bfd_architecture arch, 103560484Sobrien unsigned long machine); 103660484Sobrien 103760484SobrienDESCRIPTION 103860484Sobrien See bfd_octets_per_byte. 103977298Sobrien 104060484Sobrien This routine is provided for those cases where a bfd * is not 104160484Sobrien available 104260484Sobrien*/ 104360484Sobrien 104460484Sobrienunsigned int 104560484Sobrienbfd_arch_mach_octets_per_byte (arch, mach) 104677298Sobrien enum bfd_architecture arch; 104777298Sobrien unsigned long mach; 104860484Sobrien{ 104977298Sobrien const bfd_arch_info_type *ap = bfd_lookup_arch (arch, mach); 105077298Sobrien 105177298Sobrien if (ap) 105277298Sobrien return ap->bits_per_byte / 8; 105377298Sobrien return 1; 105460484Sobrien} 1055