1@section Architectures 2BFD keeps one atom in a BFD describing the 3architecture of the data attached to the BFD: a pointer to a 4@code{bfd_arch_info_type}. 5 6Pointers to structures can be requested independently of a BFD 7so that an architecture's information can be interrogated 8without access to an open BFD. 9 10The architecture information is provided by each architecture package. 11The set of default architectures is selected by the macro 12@code{SELECT_ARCHITECTURES}. This is normally set up in the 13@file{config/@var{target}.mt} file of your choice. If the name is not 14defined, then all the architectures supported are included. 15 16When BFD starts up, all the architectures are called with an 17initialize method. It is up to the architecture back end to 18insert as many items into the list of architectures as it wants to; 19generally this would be one for each machine and one for the 20default case (an item with a machine field of 0). 21 22BFD's idea of an architecture is implemented in @file{archures.c}. 23 24@subsection bfd_architecture 25 26 27@strong{Description}@* 28This enum gives the object file's CPU architecture, in a 29global sense---i.e., what processor family does it belong to? 30Another field indicates which processor within 31the family is in use. The machine gives a number which 32distinguishes different versions of the architecture, 33containing, for example, 2 and 3 for Intel i960 KA and i960 KB, 34and 68020 and 68030 for Motorola 68020 and 68030. 35@example 36enum bfd_architecture 37@{ 38 bfd_arch_unknown, /* File arch not known. */ 39 bfd_arch_obscure, /* Arch known, not one of these. */ 40 bfd_arch_m68k, /* Motorola 68xxx */ 41#define bfd_mach_m68000 1 42#define bfd_mach_m68008 2 43#define bfd_mach_m68010 3 44#define bfd_mach_m68020 4 45#define bfd_mach_m68030 5 46#define bfd_mach_m68040 6 47#define bfd_mach_m68060 7 48#define bfd_mach_cpu32 8 49#define bfd_mach_mcf5200 9 50#define bfd_mach_mcf5206e 10 51#define bfd_mach_mcf5307 11 52#define bfd_mach_mcf5407 12 53#define bfd_mach_mcf528x 13 54#define bfd_mach_mcfv4e 14 55#define bfd_mach_mcf521x 15 56#define bfd_mach_mcf5249 16 57#define bfd_mach_mcf547x 17 58#define bfd_mach_mcf548x 18 59 bfd_arch_vax, /* DEC Vax */ 60 bfd_arch_i960, /* Intel 960 */ 61 /* The order of the following is important. 62 lower number indicates a machine type that 63 only accepts a subset of the instructions 64 available to machines with higher numbers. 65 The exception is the "ca", which is 66 incompatible with all other machines except 67 "core". */ 68 69#define bfd_mach_i960_core 1 70#define bfd_mach_i960_ka_sa 2 71#define bfd_mach_i960_kb_sb 3 72#define bfd_mach_i960_mc 4 73#define bfd_mach_i960_xa 5 74#define bfd_mach_i960_ca 6 75#define bfd_mach_i960_jx 7 76#define bfd_mach_i960_hx 8 77 78 bfd_arch_or32, /* OpenRISC 32 */ 79 80 bfd_arch_a29k, /* AMD 29000 */ 81 bfd_arch_sparc, /* SPARC */ 82#define bfd_mach_sparc 1 83/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */ 84#define bfd_mach_sparc_sparclet 2 85#define bfd_mach_sparc_sparclite 3 86#define bfd_mach_sparc_v8plus 4 87#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns. */ 88#define bfd_mach_sparc_sparclite_le 6 89#define bfd_mach_sparc_v9 7 90#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns. */ 91#define bfd_mach_sparc_v8plusb 9 /* with cheetah add'ns. */ 92#define bfd_mach_sparc_v9b 10 /* with cheetah add'ns. */ 93/* Nonzero if MACH has the v9 instruction set. */ 94#define bfd_mach_sparc_v9_p(mach) \ 95 ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \ 96 && (mach) != bfd_mach_sparc_sparclite_le) 97/* Nonzero if MACH is a 64 bit sparc architecture. */ 98#define bfd_mach_sparc_64bit_p(mach) \ 99 ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb) 100 bfd_arch_mips, /* MIPS Rxxxx */ 101#define bfd_mach_mips3000 3000 102#define bfd_mach_mips3900 3900 103#define bfd_mach_mips4000 4000 104#define bfd_mach_mips4010 4010 105#define bfd_mach_mips4100 4100 106#define bfd_mach_mips4111 4111 107#define bfd_mach_mips4120 4120 108#define bfd_mach_mips4300 4300 109#define bfd_mach_mips4400 4400 110#define bfd_mach_mips4600 4600 111#define bfd_mach_mips4650 4650 112#define bfd_mach_mips5000 5000 113#define bfd_mach_mips5400 5400 114#define bfd_mach_mips5500 5500 115#define bfd_mach_mips6000 6000 116#define bfd_mach_mips7000 7000 117#define bfd_mach_mips8000 8000 118#define bfd_mach_mips9000 9000 119#define bfd_mach_mips10000 10000 120#define bfd_mach_mips12000 12000 121#define bfd_mach_mips16 16 122#define bfd_mach_mips5 5 123#define bfd_mach_mips_sb1 12310201 /* octal 'SB', 01 */ 124#define bfd_mach_mipsisa32 32 125#define bfd_mach_mipsisa32r2 33 126#define bfd_mach_mipsisa64 64 127#define bfd_mach_mipsisa64r2 65 128 bfd_arch_i386, /* Intel 386 */ 129#define bfd_mach_i386_i386 1 130#define bfd_mach_i386_i8086 2 131#define bfd_mach_i386_i386_intel_syntax 3 132#define bfd_mach_x86_64 64 133#define bfd_mach_x86_64_intel_syntax 65 134 bfd_arch_we32k, /* AT&T WE32xxx */ 135 bfd_arch_tahoe, /* CCI/Harris Tahoe */ 136 bfd_arch_i860, /* Intel 860 */ 137 bfd_arch_i370, /* IBM 360/370 Mainframes */ 138 bfd_arch_romp, /* IBM ROMP PC/RT */ 139 bfd_arch_alliant, /* Alliant */ 140 bfd_arch_convex, /* Convex */ 141 bfd_arch_m88k, /* Motorola 88xxx */ 142 bfd_arch_m98k, /* Motorola 98xxx */ 143 bfd_arch_pyramid, /* Pyramid Technology */ 144 bfd_arch_h8300, /* Renesas H8/300 (formerly Hitachi H8/300) */ 145#define bfd_mach_h8300 1 146#define bfd_mach_h8300h 2 147#define bfd_mach_h8300s 3 148#define bfd_mach_h8300hn 4 149#define bfd_mach_h8300sn 5 150#define bfd_mach_h8300sx 6 151#define bfd_mach_h8300sxn 7 152 bfd_arch_pdp11, /* DEC PDP-11 */ 153 bfd_arch_powerpc, /* PowerPC */ 154#define bfd_mach_ppc 32 155#define bfd_mach_ppc64 64 156#define bfd_mach_ppc_403 403 157#define bfd_mach_ppc_403gc 4030 158#define bfd_mach_ppc_505 505 159#define bfd_mach_ppc_601 601 160#define bfd_mach_ppc_602 602 161#define bfd_mach_ppc_603 603 162#define bfd_mach_ppc_ec603e 6031 163#define bfd_mach_ppc_604 604 164#define bfd_mach_ppc_620 620 165#define bfd_mach_ppc_630 630 166#define bfd_mach_ppc_750 750 167#define bfd_mach_ppc_860 860 168#define bfd_mach_ppc_a35 35 169#define bfd_mach_ppc_rs64ii 642 170#define bfd_mach_ppc_rs64iii 643 171#define bfd_mach_ppc_7400 7400 172#define bfd_mach_ppc_e500 500 173 bfd_arch_rs6000, /* IBM RS/6000 */ 174#define bfd_mach_rs6k 6000 175#define bfd_mach_rs6k_rs1 6001 176#define bfd_mach_rs6k_rsc 6003 177#define bfd_mach_rs6k_rs2 6002 178 bfd_arch_hppa, /* HP PA RISC */ 179#define bfd_mach_hppa10 10 180#define bfd_mach_hppa11 11 181#define bfd_mach_hppa20 20 182#define bfd_mach_hppa20w 25 183 bfd_arch_d10v, /* Mitsubishi D10V */ 184#define bfd_mach_d10v 1 185#define bfd_mach_d10v_ts2 2 186#define bfd_mach_d10v_ts3 3 187 bfd_arch_d30v, /* Mitsubishi D30V */ 188 bfd_arch_dlx, /* DLX */ 189 bfd_arch_m68hc11, /* Motorola 68HC11 */ 190 bfd_arch_m68hc12, /* Motorola 68HC12 */ 191#define bfd_mach_m6812_default 0 192#define bfd_mach_m6812 1 193#define bfd_mach_m6812s 2 194 bfd_arch_z8k, /* Zilog Z8000 */ 195#define bfd_mach_z8001 1 196#define bfd_mach_z8002 2 197 bfd_arch_h8500, /* Renesas H8/500 (formerly Hitachi H8/500) */ 198 bfd_arch_sh, /* Renesas / SuperH SH (formerly Hitachi SH) */ 199#define bfd_mach_sh 1 200#define bfd_mach_sh2 0x20 201#define bfd_mach_sh_dsp 0x2d 202#define bfd_mach_sh2a 0x2a 203#define bfd_mach_sh2a_nofpu 0x2b 204#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1 205#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2 206#define bfd_mach_sh2a_or_sh4 0x2a3 207#define bfd_mach_sh2a_or_sh3e 0x2a4 208#define bfd_mach_sh2e 0x2e 209#define bfd_mach_sh3 0x30 210#define bfd_mach_sh3_nommu 0x31 211#define bfd_mach_sh3_dsp 0x3d 212#define bfd_mach_sh3e 0x3e 213#define bfd_mach_sh4 0x40 214#define bfd_mach_sh4_nofpu 0x41 215#define bfd_mach_sh4_nommu_nofpu 0x42 216#define bfd_mach_sh4a 0x4a 217#define bfd_mach_sh4a_nofpu 0x4b 218#define bfd_mach_sh4al_dsp 0x4d 219#define bfd_mach_sh5 0x50 220 bfd_arch_alpha, /* Dec Alpha */ 221#define bfd_mach_alpha_ev4 0x10 222#define bfd_mach_alpha_ev5 0x20 223#define bfd_mach_alpha_ev6 0x30 224 bfd_arch_arm, /* Advanced Risc Machines ARM. */ 225#define bfd_mach_arm_unknown 0 226#define bfd_mach_arm_2 1 227#define bfd_mach_arm_2a 2 228#define bfd_mach_arm_3 3 229#define bfd_mach_arm_3M 4 230#define bfd_mach_arm_4 5 231#define bfd_mach_arm_4T 6 232#define bfd_mach_arm_5 7 233#define bfd_mach_arm_5T 8 234#define bfd_mach_arm_5TE 9 235#define bfd_mach_arm_XScale 10 236#define bfd_mach_arm_ep9312 11 237#define bfd_mach_arm_iWMMXt 12 238 bfd_arch_ns32k, /* National Semiconductors ns32000 */ 239 bfd_arch_w65, /* WDC 65816 */ 240 bfd_arch_tic30, /* Texas Instruments TMS320C30 */ 241 bfd_arch_tic4x, /* Texas Instruments TMS320C3X/4X */ 242#define bfd_mach_tic3x 30 243#define bfd_mach_tic4x 40 244 bfd_arch_tic54x, /* Texas Instruments TMS320C54X */ 245 bfd_arch_tic80, /* TI TMS320c80 (MVP) */ 246 bfd_arch_v850, /* NEC V850 */ 247#define bfd_mach_v850 1 248#define bfd_mach_v850e 'E' 249#define bfd_mach_v850e1 '1' 250 bfd_arch_arc, /* ARC Cores */ 251#define bfd_mach_arc_5 5 252#define bfd_mach_arc_6 6 253#define bfd_mach_arc_7 7 254#define bfd_mach_arc_8 8 255 bfd_arch_m32r, /* Renesas M32R (formerly Mitsubishi M32R/D) */ 256#define bfd_mach_m32r 1 /* For backwards compatibility. */ 257#define bfd_mach_m32rx 'x' 258#define bfd_mach_m32r2 '2' 259 bfd_arch_mn10200, /* Matsushita MN10200 */ 260 bfd_arch_mn10300, /* Matsushita MN10300 */ 261#define bfd_mach_mn10300 300 262#define bfd_mach_am33 330 263#define bfd_mach_am33_2 332 264 bfd_arch_fr30, 265#define bfd_mach_fr30 0x46523330 266 bfd_arch_frv, 267#define bfd_mach_frv 1 268#define bfd_mach_frvsimple 2 269#define bfd_mach_fr300 300 270#define bfd_mach_fr400 400 271#define bfd_mach_fr450 450 272#define bfd_mach_frvtomcat 499 /* fr500 prototype */ 273#define bfd_mach_fr500 500 274#define bfd_mach_fr550 550 275 bfd_arch_mcore, 276 bfd_arch_ia64, /* HP/Intel ia64 */ 277#define bfd_mach_ia64_elf64 64 278#define bfd_mach_ia64_elf32 32 279 bfd_arch_ip2k, /* Ubicom IP2K microcontrollers. */ 280#define bfd_mach_ip2022 1 281#define bfd_mach_ip2022ext 2 282 bfd_arch_iq2000, /* Vitesse IQ2000. */ 283#define bfd_mach_iq2000 1 284#define bfd_mach_iq10 2 285 bfd_arch_ms1, 286#define bfd_mach_ms1 1 287#define bfd_mach_mrisc2 2 288 bfd_arch_pj, 289 bfd_arch_avr, /* Atmel AVR microcontrollers. */ 290#define bfd_mach_avr1 1 291#define bfd_mach_avr2 2 292#define bfd_mach_avr3 3 293#define bfd_mach_avr4 4 294#define bfd_mach_avr5 5 295 bfd_arch_cr16c, /* National Semiconductor CompactRISC. */ 296#define bfd_mach_cr16c 1 297 bfd_arch_crx, /* National Semiconductor CRX. */ 298#define bfd_mach_crx 1 299 bfd_arch_cris, /* Axis CRIS */ 300#define bfd_mach_cris_v0_v10 255 301#define bfd_mach_cris_v32 32 302#define bfd_mach_cris_v10_v32 1032 303 bfd_arch_s390, /* IBM s390 */ 304#define bfd_mach_s390_31 31 305#define bfd_mach_s390_64 64 306 bfd_arch_openrisc, /* OpenRISC */ 307 bfd_arch_mmix, /* Donald Knuth's educational processor. */ 308 bfd_arch_xstormy16, 309#define bfd_mach_xstormy16 1 310 bfd_arch_msp430, /* Texas Instruments MSP430 architecture. */ 311#define bfd_mach_msp11 11 312#define bfd_mach_msp110 110 313#define bfd_mach_msp12 12 314#define bfd_mach_msp13 13 315#define bfd_mach_msp14 14 316#define bfd_mach_msp15 15 317#define bfd_mach_msp16 16 318#define bfd_mach_msp31 31 319#define bfd_mach_msp32 32 320#define bfd_mach_msp33 33 321#define bfd_mach_msp41 41 322#define bfd_mach_msp42 42 323#define bfd_mach_msp43 43 324#define bfd_mach_msp44 44 325 bfd_arch_xtensa, /* Tensilica's Xtensa cores. */ 326#define bfd_mach_xtensa 1 327 bfd_arch_maxq, /* Dallas MAXQ 10/20 */ 328#define bfd_mach_maxq10 10 329#define bfd_mach_maxq20 20 330 bfd_arch_last 331 @}; 332@end example 333 334@subsection bfd_arch_info 335 336 337@strong{Description}@* 338This structure contains information on architectures for use 339within BFD. 340@example 341 342typedef struct bfd_arch_info 343@{ 344 int bits_per_word; 345 int bits_per_address; 346 int bits_per_byte; 347 enum bfd_architecture arch; 348 unsigned long mach; 349 const char *arch_name; 350 const char *printable_name; 351 unsigned int section_align_power; 352 /* TRUE if this is the default machine for the architecture. 353 The default arch should be the first entry for an arch so that 354 all the entries for that arch can be accessed via @code{next}. */ 355 bfd_boolean the_default; 356 const struct bfd_arch_info * (*compatible) 357 (const struct bfd_arch_info *a, const struct bfd_arch_info *b); 358 359 bfd_boolean (*scan) (const struct bfd_arch_info *, const char *); 360 361 const struct bfd_arch_info *next; 362@} 363bfd_arch_info_type; 364 365@end example 366 367@findex bfd_printable_name 368@subsubsection @code{bfd_printable_name} 369@strong{Synopsis} 370@example 371const char *bfd_printable_name (bfd *abfd); 372@end example 373@strong{Description}@* 374Return a printable string representing the architecture and machine 375from the pointer to the architecture info structure. 376 377@findex bfd_scan_arch 378@subsubsection @code{bfd_scan_arch} 379@strong{Synopsis} 380@example 381const bfd_arch_info_type *bfd_scan_arch (const char *string); 382@end example 383@strong{Description}@* 384Figure out if BFD supports any cpu which could be described with 385the name @var{string}. Return a pointer to an @code{arch_info} 386structure if a machine is found, otherwise NULL. 387 388@findex bfd_arch_list 389@subsubsection @code{bfd_arch_list} 390@strong{Synopsis} 391@example 392const char **bfd_arch_list (void); 393@end example 394@strong{Description}@* 395Return a freshly malloced NULL-terminated vector of the names 396of all the valid BFD architectures. Do not modify the names. 397 398@findex bfd_arch_get_compatible 399@subsubsection @code{bfd_arch_get_compatible} 400@strong{Synopsis} 401@example 402const bfd_arch_info_type *bfd_arch_get_compatible 403 (const bfd *abfd, const bfd *bbfd, bfd_boolean accept_unknowns); 404@end example 405@strong{Description}@* 406Determine whether two BFDs' architectures and machine types 407are compatible. Calculates the lowest common denominator 408between the two architectures and machine types implied by 409the BFDs and returns a pointer to an @code{arch_info} structure 410describing the compatible machine. 411 412@findex bfd_default_arch_struct 413@subsubsection @code{bfd_default_arch_struct} 414@strong{Description}@* 415The @code{bfd_default_arch_struct} is an item of 416@code{bfd_arch_info_type} which has been initialized to a fairly 417generic state. A BFD starts life by pointing to this 418structure, until the correct back end has determined the real 419architecture of the file. 420@example 421extern const bfd_arch_info_type bfd_default_arch_struct; 422@end example 423 424@findex bfd_set_arch_info 425@subsubsection @code{bfd_set_arch_info} 426@strong{Synopsis} 427@example 428void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg); 429@end example 430@strong{Description}@* 431Set the architecture info of @var{abfd} to @var{arg}. 432 433@findex bfd_default_set_arch_mach 434@subsubsection @code{bfd_default_set_arch_mach} 435@strong{Synopsis} 436@example 437bfd_boolean bfd_default_set_arch_mach 438 (bfd *abfd, enum bfd_architecture arch, unsigned long mach); 439@end example 440@strong{Description}@* 441Set the architecture and machine type in BFD @var{abfd} 442to @var{arch} and @var{mach}. Find the correct 443pointer to a structure and insert it into the @code{arch_info} 444pointer. 445 446@findex bfd_get_arch 447@subsubsection @code{bfd_get_arch} 448@strong{Synopsis} 449@example 450enum bfd_architecture bfd_get_arch (bfd *abfd); 451@end example 452@strong{Description}@* 453Return the enumerated type which describes the BFD @var{abfd}'s 454architecture. 455 456@findex bfd_get_mach 457@subsubsection @code{bfd_get_mach} 458@strong{Synopsis} 459@example 460unsigned long bfd_get_mach (bfd *abfd); 461@end example 462@strong{Description}@* 463Return the long type which describes the BFD @var{abfd}'s 464machine. 465 466@findex bfd_arch_bits_per_byte 467@subsubsection @code{bfd_arch_bits_per_byte} 468@strong{Synopsis} 469@example 470unsigned int bfd_arch_bits_per_byte (bfd *abfd); 471@end example 472@strong{Description}@* 473Return the number of bits in one of the BFD @var{abfd}'s 474architecture's bytes. 475 476@findex bfd_arch_bits_per_address 477@subsubsection @code{bfd_arch_bits_per_address} 478@strong{Synopsis} 479@example 480unsigned int bfd_arch_bits_per_address (bfd *abfd); 481@end example 482@strong{Description}@* 483Return the number of bits in one of the BFD @var{abfd}'s 484architecture's addresses. 485 486@findex bfd_default_compatible 487@subsubsection @code{bfd_default_compatible} 488@strong{Synopsis} 489@example 490const bfd_arch_info_type *bfd_default_compatible 491 (const bfd_arch_info_type *a, const bfd_arch_info_type *b); 492@end example 493@strong{Description}@* 494The default function for testing for compatibility. 495 496@findex bfd_default_scan 497@subsubsection @code{bfd_default_scan} 498@strong{Synopsis} 499@example 500bfd_boolean bfd_default_scan 501 (const struct bfd_arch_info *info, const char *string); 502@end example 503@strong{Description}@* 504The default function for working out whether this is an 505architecture hit and a machine hit. 506 507@findex bfd_get_arch_info 508@subsubsection @code{bfd_get_arch_info} 509@strong{Synopsis} 510@example 511const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd); 512@end example 513@strong{Description}@* 514Return the architecture info struct in @var{abfd}. 515 516@findex bfd_lookup_arch 517@subsubsection @code{bfd_lookup_arch} 518@strong{Synopsis} 519@example 520const bfd_arch_info_type *bfd_lookup_arch 521 (enum bfd_architecture arch, unsigned long machine); 522@end example 523@strong{Description}@* 524Look for the architecture info structure which matches the 525arguments @var{arch} and @var{machine}. A machine of 0 matches the 526machine/architecture structure which marks itself as the 527default. 528 529@findex bfd_printable_arch_mach 530@subsubsection @code{bfd_printable_arch_mach} 531@strong{Synopsis} 532@example 533const char *bfd_printable_arch_mach 534 (enum bfd_architecture arch, unsigned long machine); 535@end example 536@strong{Description}@* 537Return a printable string representing the architecture and 538machine type. 539 540This routine is depreciated. 541 542@findex bfd_octets_per_byte 543@subsubsection @code{bfd_octets_per_byte} 544@strong{Synopsis} 545@example 546unsigned int bfd_octets_per_byte (bfd *abfd); 547@end example 548@strong{Description}@* 549Return the number of octets (8-bit quantities) per target byte 550(minimum addressable unit). In most cases, this will be one, but some 551DSP targets have 16, 32, or even 48 bits per byte. 552 553@findex bfd_arch_mach_octets_per_byte 554@subsubsection @code{bfd_arch_mach_octets_per_byte} 555@strong{Synopsis} 556@example 557unsigned int bfd_arch_mach_octets_per_byte 558 (enum bfd_architecture arch, unsigned long machine); 559@end example 560@strong{Description}@* 561See bfd_octets_per_byte. 562 563This routine is provided for those cases where a bfd * is not 564available 565 566