Back to index

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