archures.c 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480
  1. /* BFD library support routines for architectures.
  2. Copyright (C) 1990-2022 Free Software Foundation, Inc.
  3. Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
  4. This file is part of BFD, the Binary File Descriptor library.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. #include "sysdep.h"
  18. #include "bfd.h"
  19. #include "libbfd.h"
  20. #include "safe-ctype.h"
  21. /*
  22. SECTION
  23. Architectures
  24. BFD keeps one atom in a BFD describing the
  25. architecture of the data attached to the BFD: a pointer to a
  26. <<bfd_arch_info_type>>.
  27. Pointers to structures can be requested independently of a BFD
  28. so that an architecture's information can be interrogated
  29. without access to an open BFD.
  30. The architecture information is provided by each architecture package.
  31. The set of default architectures is selected by the macro
  32. <<SELECT_ARCHITECTURES>>. This is normally set up in the
  33. @file{config/@var{target}.mt} file of your choice. If the name is not
  34. defined, then all the architectures supported are included.
  35. When BFD starts up, all the architectures are called with an
  36. initialize method. It is up to the architecture back end to
  37. insert as many items into the list of architectures as it wants to;
  38. generally this would be one for each machine and one for the
  39. default case (an item with a machine field of 0).
  40. BFD's idea of an architecture is implemented in @file{archures.c}.
  41. */
  42. /*
  43. SUBSECTION
  44. bfd_architecture
  45. DESCRIPTION
  46. This enum gives the object file's CPU architecture, in a
  47. global sense---i.e., what processor family does it belong to?
  48. Another field indicates which processor within
  49. the family is in use. The machine gives a number which
  50. distinguishes different versions of the architecture,
  51. containing, for example, 68020 for Motorola 68020.
  52. .enum bfd_architecture
  53. .{
  54. . bfd_arch_unknown, {* File arch not known. *}
  55. . bfd_arch_obscure, {* Arch known, not one of these. *}
  56. . bfd_arch_m68k, {* Motorola 68xxx. *}
  57. .#define bfd_mach_m68000 1
  58. .#define bfd_mach_m68008 2
  59. .#define bfd_mach_m68010 3
  60. .#define bfd_mach_m68020 4
  61. .#define bfd_mach_m68030 5
  62. .#define bfd_mach_m68040 6
  63. .#define bfd_mach_m68060 7
  64. .#define bfd_mach_cpu32 8
  65. .#define bfd_mach_fido 9
  66. .#define bfd_mach_mcf_isa_a_nodiv 10
  67. .#define bfd_mach_mcf_isa_a 11
  68. .#define bfd_mach_mcf_isa_a_mac 12
  69. .#define bfd_mach_mcf_isa_a_emac 13
  70. .#define bfd_mach_mcf_isa_aplus 14
  71. .#define bfd_mach_mcf_isa_aplus_mac 15
  72. .#define bfd_mach_mcf_isa_aplus_emac 16
  73. .#define bfd_mach_mcf_isa_b_nousp 17
  74. .#define bfd_mach_mcf_isa_b_nousp_mac 18
  75. .#define bfd_mach_mcf_isa_b_nousp_emac 19
  76. .#define bfd_mach_mcf_isa_b 20
  77. .#define bfd_mach_mcf_isa_b_mac 21
  78. .#define bfd_mach_mcf_isa_b_emac 22
  79. .#define bfd_mach_mcf_isa_b_float 23
  80. .#define bfd_mach_mcf_isa_b_float_mac 24
  81. .#define bfd_mach_mcf_isa_b_float_emac 25
  82. .#define bfd_mach_mcf_isa_c 26
  83. .#define bfd_mach_mcf_isa_c_mac 27
  84. .#define bfd_mach_mcf_isa_c_emac 28
  85. .#define bfd_mach_mcf_isa_c_nodiv 29
  86. .#define bfd_mach_mcf_isa_c_nodiv_mac 30
  87. .#define bfd_mach_mcf_isa_c_nodiv_emac 31
  88. . bfd_arch_vax, {* DEC Vax. *}
  89. .
  90. . bfd_arch_or1k, {* OpenRISC 1000. *}
  91. .#define bfd_mach_or1k 1
  92. .#define bfd_mach_or1knd 2
  93. .
  94. . bfd_arch_sparc, {* SPARC. *}
  95. .#define bfd_mach_sparc 1
  96. .{* The difference between v8plus and v9 is that v9 is a true 64 bit env. *}
  97. .#define bfd_mach_sparc_sparclet 2
  98. .#define bfd_mach_sparc_sparclite 3
  99. .#define bfd_mach_sparc_v8plus 4
  100. .#define bfd_mach_sparc_v8plusa 5 {* with ultrasparc add'ns. *}
  101. .#define bfd_mach_sparc_sparclite_le 6
  102. .#define bfd_mach_sparc_v9 7
  103. .#define bfd_mach_sparc_v9a 8 {* with ultrasparc add'ns. *}
  104. .#define bfd_mach_sparc_v8plusb 9 {* with cheetah add'ns. *}
  105. .#define bfd_mach_sparc_v9b 10 {* with cheetah add'ns. *}
  106. .#define bfd_mach_sparc_v8plusc 11 {* with UA2005 and T1 add'ns. *}
  107. .#define bfd_mach_sparc_v9c 12 {* with UA2005 and T1 add'ns. *}
  108. .#define bfd_mach_sparc_v8plusd 13 {* with UA2007 and T3 add'ns. *}
  109. .#define bfd_mach_sparc_v9d 14 {* with UA2007 and T3 add'ns. *}
  110. .#define bfd_mach_sparc_v8pluse 15 {* with OSA2001 and T4 add'ns (no IMA). *}
  111. .#define bfd_mach_sparc_v9e 16 {* with OSA2001 and T4 add'ns (no IMA). *}
  112. .#define bfd_mach_sparc_v8plusv 17 {* with OSA2011 and T4 and IMA and FJMAU add'ns. *}
  113. .#define bfd_mach_sparc_v9v 18 {* with OSA2011 and T4 and IMA and FJMAU add'ns. *}
  114. .#define bfd_mach_sparc_v8plusm 19 {* with OSA2015 and M7 add'ns. *}
  115. .#define bfd_mach_sparc_v9m 20 {* with OSA2015 and M7 add'ns. *}
  116. .#define bfd_mach_sparc_v8plusm8 21 {* with OSA2017 and M8 add'ns. *}
  117. .#define bfd_mach_sparc_v9m8 22 {* with OSA2017 and M8 add'ns. *}
  118. .{* Nonzero if MACH has the v9 instruction set. *}
  119. .#define bfd_mach_sparc_v9_p(mach) \
  120. . ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9m8 \
  121. . && (mach) != bfd_mach_sparc_sparclite_le)
  122. .{* Nonzero if MACH is a 64 bit sparc architecture. *}
  123. .#define bfd_mach_sparc_64bit_p(mach) \
  124. . ((mach) >= bfd_mach_sparc_v9 \
  125. . && (mach) != bfd_mach_sparc_v8plusb \
  126. . && (mach) != bfd_mach_sparc_v8plusc \
  127. . && (mach) != bfd_mach_sparc_v8plusd \
  128. . && (mach) != bfd_mach_sparc_v8pluse \
  129. . && (mach) != bfd_mach_sparc_v8plusv \
  130. . && (mach) != bfd_mach_sparc_v8plusm \
  131. . && (mach) != bfd_mach_sparc_v8plusm8)
  132. . bfd_arch_spu, {* PowerPC SPU. *}
  133. .#define bfd_mach_spu 256
  134. . bfd_arch_mips, {* MIPS Rxxxx. *}
  135. .#define bfd_mach_mips3000 3000
  136. .#define bfd_mach_mips3900 3900
  137. .#define bfd_mach_mips4000 4000
  138. .#define bfd_mach_mips4010 4010
  139. .#define bfd_mach_mips4100 4100
  140. .#define bfd_mach_mips4111 4111
  141. .#define bfd_mach_mips4120 4120
  142. .#define bfd_mach_mips4300 4300
  143. .#define bfd_mach_mips4400 4400
  144. .#define bfd_mach_mips4600 4600
  145. .#define bfd_mach_mips4650 4650
  146. .#define bfd_mach_mips5000 5000
  147. .#define bfd_mach_mips5400 5400
  148. .#define bfd_mach_mips5500 5500
  149. .#define bfd_mach_mips5900 5900
  150. .#define bfd_mach_mips6000 6000
  151. .#define bfd_mach_mips7000 7000
  152. .#define bfd_mach_mips8000 8000
  153. .#define bfd_mach_mips9000 9000
  154. .#define bfd_mach_mips10000 10000
  155. .#define bfd_mach_mips12000 12000
  156. .#define bfd_mach_mips14000 14000
  157. .#define bfd_mach_mips16000 16000
  158. .#define bfd_mach_mips16 16
  159. .#define bfd_mach_mips5 5
  160. .#define bfd_mach_mips_loongson_2e 3001
  161. .#define bfd_mach_mips_loongson_2f 3002
  162. .#define bfd_mach_mips_gs464 3003
  163. .#define bfd_mach_mips_gs464e 3004
  164. .#define bfd_mach_mips_gs264e 3005
  165. .#define bfd_mach_mips_sb1 12310201 {* octal 'SB', 01. *}
  166. .#define bfd_mach_mips_octeon 6501
  167. .#define bfd_mach_mips_octeonp 6601
  168. .#define bfd_mach_mips_octeon2 6502
  169. .#define bfd_mach_mips_octeon3 6503
  170. .#define bfd_mach_mips_xlr 887682 {* decimal 'XLR'. *}
  171. .#define bfd_mach_mips_interaptiv_mr2 736550 {* decimal 'IA2'. *}
  172. .#define bfd_mach_mipsisa32 32
  173. .#define bfd_mach_mipsisa32r2 33
  174. .#define bfd_mach_mipsisa32r3 34
  175. .#define bfd_mach_mipsisa32r5 36
  176. .#define bfd_mach_mipsisa32r6 37
  177. .#define bfd_mach_mipsisa64 64
  178. .#define bfd_mach_mipsisa64r2 65
  179. .#define bfd_mach_mipsisa64r3 66
  180. .#define bfd_mach_mipsisa64r5 68
  181. .#define bfd_mach_mipsisa64r6 69
  182. .#define bfd_mach_mips_micromips 96
  183. . bfd_arch_i386, {* Intel 386. *}
  184. .#define bfd_mach_i386_intel_syntax (1 << 0)
  185. .#define bfd_mach_i386_i8086 (1 << 1)
  186. .#define bfd_mach_i386_i386 (1 << 2)
  187. .#define bfd_mach_x86_64 (1 << 3)
  188. .#define bfd_mach_x64_32 (1 << 4)
  189. .#define bfd_mach_i386_i386_intel_syntax (bfd_mach_i386_i386 | bfd_mach_i386_intel_syntax)
  190. .#define bfd_mach_x86_64_intel_syntax (bfd_mach_x86_64 | bfd_mach_i386_intel_syntax)
  191. .#define bfd_mach_x64_32_intel_syntax (bfd_mach_x64_32 | bfd_mach_i386_intel_syntax)
  192. . bfd_arch_iamcu, {* Intel MCU. *}
  193. .#define bfd_mach_iamcu (1 << 8)
  194. .#define bfd_mach_i386_iamcu (bfd_mach_i386_i386 | bfd_mach_iamcu)
  195. .#define bfd_mach_i386_iamcu_intel_syntax (bfd_mach_i386_iamcu | bfd_mach_i386_intel_syntax)
  196. . bfd_arch_romp, {* IBM ROMP PC/RT. *}
  197. . bfd_arch_convex, {* Convex. *}
  198. . bfd_arch_m98k, {* Motorola 98xxx. *}
  199. . bfd_arch_pyramid, {* Pyramid Technology. *}
  200. . bfd_arch_h8300, {* Renesas H8/300 (formerly Hitachi H8/300). *}
  201. .#define bfd_mach_h8300 1
  202. .#define bfd_mach_h8300h 2
  203. .#define bfd_mach_h8300s 3
  204. .#define bfd_mach_h8300hn 4
  205. .#define bfd_mach_h8300sn 5
  206. .#define bfd_mach_h8300sx 6
  207. .#define bfd_mach_h8300sxn 7
  208. . bfd_arch_pdp11, {* DEC PDP-11. *}
  209. . bfd_arch_powerpc, {* PowerPC. *}
  210. .#define bfd_mach_ppc 32
  211. .#define bfd_mach_ppc64 64
  212. .#define bfd_mach_ppc_403 403
  213. .#define bfd_mach_ppc_403gc 4030
  214. .#define bfd_mach_ppc_405 405
  215. .#define bfd_mach_ppc_505 505
  216. .#define bfd_mach_ppc_601 601
  217. .#define bfd_mach_ppc_602 602
  218. .#define bfd_mach_ppc_603 603
  219. .#define bfd_mach_ppc_ec603e 6031
  220. .#define bfd_mach_ppc_604 604
  221. .#define bfd_mach_ppc_620 620
  222. .#define bfd_mach_ppc_630 630
  223. .#define bfd_mach_ppc_750 750
  224. .#define bfd_mach_ppc_860 860
  225. .#define bfd_mach_ppc_a35 35
  226. .#define bfd_mach_ppc_rs64ii 642
  227. .#define bfd_mach_ppc_rs64iii 643
  228. .#define bfd_mach_ppc_7400 7400
  229. .#define bfd_mach_ppc_e500 500
  230. .#define bfd_mach_ppc_e500mc 5001
  231. .#define bfd_mach_ppc_e500mc64 5005
  232. .#define bfd_mach_ppc_e5500 5006
  233. .#define bfd_mach_ppc_e6500 5007
  234. .#define bfd_mach_ppc_titan 83
  235. .#define bfd_mach_ppc_vle 84
  236. . bfd_arch_rs6000, {* IBM RS/6000. *}
  237. .#define bfd_mach_rs6k 6000
  238. .#define bfd_mach_rs6k_rs1 6001
  239. .#define bfd_mach_rs6k_rsc 6003
  240. .#define bfd_mach_rs6k_rs2 6002
  241. . bfd_arch_hppa, {* HP PA RISC. *}
  242. .#define bfd_mach_hppa10 10
  243. .#define bfd_mach_hppa11 11
  244. .#define bfd_mach_hppa20 20
  245. .#define bfd_mach_hppa20w 25
  246. . bfd_arch_d10v, {* Mitsubishi D10V. *}
  247. .#define bfd_mach_d10v 1
  248. .#define bfd_mach_d10v_ts2 2
  249. .#define bfd_mach_d10v_ts3 3
  250. . bfd_arch_d30v, {* Mitsubishi D30V. *}
  251. . bfd_arch_dlx, {* DLX. *}
  252. . bfd_arch_m68hc11, {* Motorola 68HC11. *}
  253. . bfd_arch_m68hc12, {* Motorola 68HC12. *}
  254. .#define bfd_mach_m6812_default 0
  255. .#define bfd_mach_m6812 1
  256. .#define bfd_mach_m6812s 2
  257. . bfd_arch_m9s12x, {* Freescale S12X. *}
  258. . bfd_arch_m9s12xg, {* Freescale XGATE. *}
  259. . bfd_arch_s12z, {* Freescale S12Z. *}
  260. .#define bfd_mach_s12z_default 0
  261. . bfd_arch_z8k, {* Zilog Z8000. *}
  262. .#define bfd_mach_z8001 1
  263. .#define bfd_mach_z8002 2
  264. . bfd_arch_sh, {* Renesas / SuperH SH (formerly Hitachi SH). *}
  265. .#define bfd_mach_sh 1
  266. .#define bfd_mach_sh2 0x20
  267. .#define bfd_mach_sh_dsp 0x2d
  268. .#define bfd_mach_sh2a 0x2a
  269. .#define bfd_mach_sh2a_nofpu 0x2b
  270. .#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1
  271. .#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2
  272. .#define bfd_mach_sh2a_or_sh4 0x2a3
  273. .#define bfd_mach_sh2a_or_sh3e 0x2a4
  274. .#define bfd_mach_sh2e 0x2e
  275. .#define bfd_mach_sh3 0x30
  276. .#define bfd_mach_sh3_nommu 0x31
  277. .#define bfd_mach_sh3_dsp 0x3d
  278. .#define bfd_mach_sh3e 0x3e
  279. .#define bfd_mach_sh4 0x40
  280. .#define bfd_mach_sh4_nofpu 0x41
  281. .#define bfd_mach_sh4_nommu_nofpu 0x42
  282. .#define bfd_mach_sh4a 0x4a
  283. .#define bfd_mach_sh4a_nofpu 0x4b
  284. .#define bfd_mach_sh4al_dsp 0x4d
  285. . bfd_arch_alpha, {* Dec Alpha. *}
  286. .#define bfd_mach_alpha_ev4 0x10
  287. .#define bfd_mach_alpha_ev5 0x20
  288. .#define bfd_mach_alpha_ev6 0x30
  289. . bfd_arch_arm, {* Advanced Risc Machines ARM. *}
  290. .#define bfd_mach_arm_unknown 0
  291. .#define bfd_mach_arm_2 1
  292. .#define bfd_mach_arm_2a 2
  293. .#define bfd_mach_arm_3 3
  294. .#define bfd_mach_arm_3M 4
  295. .#define bfd_mach_arm_4 5
  296. .#define bfd_mach_arm_4T 6
  297. .#define bfd_mach_arm_5 7
  298. .#define bfd_mach_arm_5T 8
  299. .#define bfd_mach_arm_5TE 9
  300. .#define bfd_mach_arm_XScale 10
  301. .#define bfd_mach_arm_ep9312 11
  302. .#define bfd_mach_arm_iWMMXt 12
  303. .#define bfd_mach_arm_iWMMXt2 13
  304. .#define bfd_mach_arm_5TEJ 14
  305. .#define bfd_mach_arm_6 15
  306. .#define bfd_mach_arm_6KZ 16
  307. .#define bfd_mach_arm_6T2 17
  308. .#define bfd_mach_arm_6K 18
  309. .#define bfd_mach_arm_7 19
  310. .#define bfd_mach_arm_6M 20
  311. .#define bfd_mach_arm_6SM 21
  312. .#define bfd_mach_arm_7EM 22
  313. .#define bfd_mach_arm_8 23
  314. .#define bfd_mach_arm_8R 24
  315. .#define bfd_mach_arm_8M_BASE 25
  316. .#define bfd_mach_arm_8M_MAIN 26
  317. .#define bfd_mach_arm_8_1M_MAIN 27
  318. .#define bfd_mach_arm_9 28
  319. . bfd_arch_nds32, {* Andes NDS32. *}
  320. .#define bfd_mach_n1 1
  321. .#define bfd_mach_n1h 2
  322. .#define bfd_mach_n1h_v2 3
  323. .#define bfd_mach_n1h_v3 4
  324. .#define bfd_mach_n1h_v3m 5
  325. . bfd_arch_ns32k, {* National Semiconductors ns32000. *}
  326. . bfd_arch_tic30, {* Texas Instruments TMS320C30. *}
  327. . bfd_arch_tic4x, {* Texas Instruments TMS320C3X/4X. *}
  328. .#define bfd_mach_tic3x 30
  329. .#define bfd_mach_tic4x 40
  330. . bfd_arch_tic54x, {* Texas Instruments TMS320C54X. *}
  331. . bfd_arch_tic6x, {* Texas Instruments TMS320C6X. *}
  332. . bfd_arch_v850, {* NEC V850. *}
  333. . bfd_arch_v850_rh850,{* NEC V850 (using RH850 ABI). *}
  334. .#define bfd_mach_v850 1
  335. .#define bfd_mach_v850e 'E'
  336. .#define bfd_mach_v850e1 '1'
  337. .#define bfd_mach_v850e2 0x4532
  338. .#define bfd_mach_v850e2v3 0x45325633
  339. .#define bfd_mach_v850e3v5 0x45335635 {* ('E'|'3'|'V'|'5'). *}
  340. . bfd_arch_arc, {* ARC Cores. *}
  341. .#define bfd_mach_arc_a4 0
  342. .#define bfd_mach_arc_a5 1
  343. .#define bfd_mach_arc_arc600 2
  344. .#define bfd_mach_arc_arc601 4
  345. .#define bfd_mach_arc_arc700 3
  346. .#define bfd_mach_arc_arcv2 5
  347. . bfd_arch_m32c, {* Renesas M16C/M32C. *}
  348. .#define bfd_mach_m16c 0x75
  349. .#define bfd_mach_m32c 0x78
  350. . bfd_arch_m32r, {* Renesas M32R (formerly Mitsubishi M32R/D). *}
  351. .#define bfd_mach_m32r 1 {* For backwards compatibility. *}
  352. .#define bfd_mach_m32rx 'x'
  353. .#define bfd_mach_m32r2 '2'
  354. . bfd_arch_mn10200, {* Matsushita MN10200. *}
  355. . bfd_arch_mn10300, {* Matsushita MN10300. *}
  356. .#define bfd_mach_mn10300 300
  357. .#define bfd_mach_am33 330
  358. .#define bfd_mach_am33_2 332
  359. . bfd_arch_fr30,
  360. .#define bfd_mach_fr30 0x46523330
  361. . bfd_arch_frv,
  362. .#define bfd_mach_frv 1
  363. .#define bfd_mach_frvsimple 2
  364. .#define bfd_mach_fr300 300
  365. .#define bfd_mach_fr400 400
  366. .#define bfd_mach_fr450 450
  367. .#define bfd_mach_frvtomcat 499 {* fr500 prototype. *}
  368. .#define bfd_mach_fr500 500
  369. .#define bfd_mach_fr550 550
  370. . bfd_arch_moxie, {* The moxie processor. *}
  371. .#define bfd_mach_moxie 1
  372. . bfd_arch_ft32, {* The ft32 processor. *}
  373. .#define bfd_mach_ft32 1
  374. .#define bfd_mach_ft32b 2
  375. . bfd_arch_mcore,
  376. . bfd_arch_mep,
  377. .#define bfd_mach_mep 1
  378. .#define bfd_mach_mep_h1 0x6831
  379. .#define bfd_mach_mep_c5 0x6335
  380. . bfd_arch_metag,
  381. .#define bfd_mach_metag 1
  382. . bfd_arch_ia64, {* HP/Intel ia64. *}
  383. .#define bfd_mach_ia64_elf64 64
  384. .#define bfd_mach_ia64_elf32 32
  385. . bfd_arch_ip2k, {* Ubicom IP2K microcontrollers. *}
  386. .#define bfd_mach_ip2022 1
  387. .#define bfd_mach_ip2022ext 2
  388. . bfd_arch_iq2000, {* Vitesse IQ2000. *}
  389. .#define bfd_mach_iq2000 1
  390. .#define bfd_mach_iq10 2
  391. . bfd_arch_bpf, {* Linux eBPF. *}
  392. .#define bfd_mach_bpf 1
  393. .#define bfd_mach_xbpf 2
  394. . bfd_arch_epiphany, {* Adapteva EPIPHANY. *}
  395. .#define bfd_mach_epiphany16 1
  396. .#define bfd_mach_epiphany32 2
  397. . bfd_arch_mt,
  398. .#define bfd_mach_ms1 1
  399. .#define bfd_mach_mrisc2 2
  400. .#define bfd_mach_ms2 3
  401. . bfd_arch_pj,
  402. . bfd_arch_avr, {* Atmel AVR microcontrollers. *}
  403. .#define bfd_mach_avr1 1
  404. .#define bfd_mach_avr2 2
  405. .#define bfd_mach_avr25 25
  406. .#define bfd_mach_avr3 3
  407. .#define bfd_mach_avr31 31
  408. .#define bfd_mach_avr35 35
  409. .#define bfd_mach_avr4 4
  410. .#define bfd_mach_avr5 5
  411. .#define bfd_mach_avr51 51
  412. .#define bfd_mach_avr6 6
  413. .#define bfd_mach_avrtiny 100
  414. .#define bfd_mach_avrxmega1 101
  415. .#define bfd_mach_avrxmega2 102
  416. .#define bfd_mach_avrxmega3 103
  417. .#define bfd_mach_avrxmega4 104
  418. .#define bfd_mach_avrxmega5 105
  419. .#define bfd_mach_avrxmega6 106
  420. .#define bfd_mach_avrxmega7 107
  421. . bfd_arch_bfin, {* ADI Blackfin. *}
  422. .#define bfd_mach_bfin 1
  423. . bfd_arch_cr16, {* National Semiconductor CompactRISC (ie CR16). *}
  424. .#define bfd_mach_cr16 1
  425. . bfd_arch_crx, {* National Semiconductor CRX. *}
  426. .#define bfd_mach_crx 1
  427. . bfd_arch_cris, {* Axis CRIS. *}
  428. .#define bfd_mach_cris_v0_v10 255
  429. .#define bfd_mach_cris_v32 32
  430. .#define bfd_mach_cris_v10_v32 1032
  431. . bfd_arch_riscv,
  432. .#define bfd_mach_riscv32 132
  433. .#define bfd_mach_riscv64 164
  434. . bfd_arch_rl78,
  435. .#define bfd_mach_rl78 0x75
  436. . bfd_arch_rx, {* Renesas RX. *}
  437. .#define bfd_mach_rx 0x75
  438. .#define bfd_mach_rx_v2 0x76
  439. .#define bfd_mach_rx_v3 0x77
  440. . bfd_arch_s390, {* IBM s390. *}
  441. .#define bfd_mach_s390_31 31
  442. .#define bfd_mach_s390_64 64
  443. . bfd_arch_score, {* Sunplus score. *}
  444. .#define bfd_mach_score3 3
  445. .#define bfd_mach_score7 7
  446. . bfd_arch_mmix, {* Donald Knuth's educational processor. *}
  447. . bfd_arch_xstormy16,
  448. .#define bfd_mach_xstormy16 1
  449. . bfd_arch_msp430, {* Texas Instruments MSP430 architecture. *}
  450. .#define bfd_mach_msp11 11
  451. .#define bfd_mach_msp110 110
  452. .#define bfd_mach_msp12 12
  453. .#define bfd_mach_msp13 13
  454. .#define bfd_mach_msp14 14
  455. .#define bfd_mach_msp15 15
  456. .#define bfd_mach_msp16 16
  457. .#define bfd_mach_msp20 20
  458. .#define bfd_mach_msp21 21
  459. .#define bfd_mach_msp22 22
  460. .#define bfd_mach_msp23 23
  461. .#define bfd_mach_msp24 24
  462. .#define bfd_mach_msp26 26
  463. .#define bfd_mach_msp31 31
  464. .#define bfd_mach_msp32 32
  465. .#define bfd_mach_msp33 33
  466. .#define bfd_mach_msp41 41
  467. .#define bfd_mach_msp42 42
  468. .#define bfd_mach_msp43 43
  469. .#define bfd_mach_msp44 44
  470. .#define bfd_mach_msp430x 45
  471. .#define bfd_mach_msp46 46
  472. .#define bfd_mach_msp47 47
  473. .#define bfd_mach_msp54 54
  474. . bfd_arch_xc16x, {* Infineon's XC16X Series. *}
  475. .#define bfd_mach_xc16x 1
  476. .#define bfd_mach_xc16xl 2
  477. .#define bfd_mach_xc16xs 3
  478. . bfd_arch_xgate, {* Freescale XGATE. *}
  479. .#define bfd_mach_xgate 1
  480. . bfd_arch_xtensa, {* Tensilica's Xtensa cores. *}
  481. .#define bfd_mach_xtensa 1
  482. . bfd_arch_z80,
  483. .{* Zilog Z80 without undocumented opcodes. *}
  484. .#define bfd_mach_z80strict 1
  485. .{* Zilog Z180: successor with additional instructions, but without
  486. . halves of ix and iy. *}
  487. .#define bfd_mach_z180 2
  488. .{* Zilog Z80 with ixl, ixh, iyl, and iyh. *}
  489. .#define bfd_mach_z80 3
  490. .{* Zilog eZ80 (successor of Z80 & Z180) in Z80 (16-bit address) mode. *}
  491. .#define bfd_mach_ez80_z80 4
  492. .{* Zilog eZ80 (successor of Z80 & Z180) in ADL (24-bit address) mode. *}
  493. .#define bfd_mach_ez80_adl 5
  494. .{* Z80N *}
  495. .#define bfd_mach_z80n 6
  496. .{* Zilog Z80 with all undocumented instructions. *}
  497. .#define bfd_mach_z80full 7
  498. .{* GameBoy Z80 (reduced instruction set). *}
  499. .#define bfd_mach_gbz80 8
  500. .{* ASCII R800: successor with multiplication. *}
  501. .#define bfd_mach_r800 11
  502. . bfd_arch_lm32, {* Lattice Mico32. *}
  503. .#define bfd_mach_lm32 1
  504. . bfd_arch_microblaze,{* Xilinx MicroBlaze. *}
  505. . bfd_arch_tilepro, {* Tilera TILEPro. *}
  506. . bfd_arch_tilegx, {* Tilera TILE-Gx. *}
  507. .#define bfd_mach_tilepro 1
  508. .#define bfd_mach_tilegx 1
  509. .#define bfd_mach_tilegx32 2
  510. . bfd_arch_aarch64, {* AArch64. *}
  511. .#define bfd_mach_aarch64 0
  512. .#define bfd_mach_aarch64_8R 1
  513. .#define bfd_mach_aarch64_ilp32 32
  514. . bfd_arch_nios2, {* Nios II. *}
  515. .#define bfd_mach_nios2 0
  516. .#define bfd_mach_nios2r1 1
  517. .#define bfd_mach_nios2r2 2
  518. . bfd_arch_visium, {* Visium. *}
  519. .#define bfd_mach_visium 1
  520. . bfd_arch_wasm32, {* WebAssembly. *}
  521. .#define bfd_mach_wasm32 1
  522. . bfd_arch_pru, {* PRU. *}
  523. .#define bfd_mach_pru 0
  524. . bfd_arch_nfp, {* Netronome Flow Processor *}
  525. .#define bfd_mach_nfp3200 0x3200
  526. .#define bfd_mach_nfp6000 0x6000
  527. . bfd_arch_csky, {* C-SKY. *}
  528. .#define bfd_mach_ck_unknown 0
  529. .#define bfd_mach_ck510 1
  530. .#define bfd_mach_ck610 2
  531. .#define bfd_mach_ck801 3
  532. .#define bfd_mach_ck802 4
  533. .#define bfd_mach_ck803 5
  534. .#define bfd_mach_ck807 6
  535. .#define bfd_mach_ck810 7
  536. .#define bfd_mach_ck860 8
  537. . bfd_arch_loongarch, {* LoongArch *}
  538. .#define bfd_mach_loongarch32 1
  539. .#define bfd_mach_loongarch64 2
  540. . bfd_arch_amdgcn, {* AMDGCN *}
  541. .#define bfd_mach_amdgcn_unknown 0x000
  542. .#define bfd_mach_amdgcn_gfx900 0x02c
  543. .#define bfd_mach_amdgcn_gfx904 0x02e
  544. .#define bfd_mach_amdgcn_gfx906 0x02f
  545. .#define bfd_mach_amdgcn_gfx908 0x030
  546. .#define bfd_mach_amdgcn_gfx90a 0x03f
  547. .#define bfd_mach_amdgcn_gfx1010 0x033
  548. .#define bfd_mach_amdgcn_gfx1011 0x034
  549. .#define bfd_mach_amdgcn_gfx1012 0x035
  550. .#define bfd_mach_amdgcn_gfx1030 0x036
  551. .#define bfd_mach_amdgcn_gfx1031 0x037
  552. .#define bfd_mach_amdgcn_gfx1032 0x038
  553. . bfd_arch_last
  554. . };
  555. */
  556. /*
  557. SUBSECTION
  558. bfd_arch_info
  559. DESCRIPTION
  560. This structure contains information on architectures for use
  561. within BFD.
  562. .
  563. .typedef struct bfd_arch_info
  564. .{
  565. . int bits_per_word;
  566. . int bits_per_address;
  567. . int bits_per_byte;
  568. . enum bfd_architecture arch;
  569. . unsigned long mach;
  570. . const char *arch_name;
  571. . const char *printable_name;
  572. . unsigned int section_align_power;
  573. . {* TRUE if this is the default machine for the architecture.
  574. . The default arch should be the first entry for an arch so that
  575. . all the entries for that arch can be accessed via <<next>>. *}
  576. . bool the_default;
  577. . const struct bfd_arch_info * (*compatible) (const struct bfd_arch_info *,
  578. . const struct bfd_arch_info *);
  579. .
  580. . bool (*scan) (const struct bfd_arch_info *, const char *);
  581. .
  582. . {* Allocate via bfd_malloc and return a fill buffer of size COUNT. If
  583. . IS_BIGENDIAN is TRUE, the order of bytes is big endian. If CODE is
  584. . TRUE, the buffer contains code. *}
  585. . void *(*fill) (bfd_size_type count, bool is_bigendian, bool code);
  586. .
  587. . const struct bfd_arch_info *next;
  588. .
  589. . {* On some architectures the offset for a relocation can point into
  590. . the middle of an instruction. This field specifies the maximum
  591. . offset such a relocation can have (in octets). This affects the
  592. . behaviour of the disassembler, since a value greater than zero
  593. . means that it may need to disassemble an instruction twice, once
  594. . to get its length and then a second time to display it. If the
  595. . value is negative then this has to be done for every single
  596. . instruction, regardless of the offset of the reloc. *}
  597. . signed int max_reloc_offset_into_insn;
  598. .}
  599. .bfd_arch_info_type;
  600. .
  601. */
  602. extern const bfd_arch_info_type bfd_aarch64_arch;
  603. extern const bfd_arch_info_type bfd_alpha_arch;
  604. extern const bfd_arch_info_type bfd_amdgcn_arch;
  605. extern const bfd_arch_info_type bfd_arc_arch;
  606. extern const bfd_arch_info_type bfd_arm_arch;
  607. extern const bfd_arch_info_type bfd_avr_arch;
  608. extern const bfd_arch_info_type bfd_bfin_arch;
  609. extern const bfd_arch_info_type bfd_cr16_arch;
  610. extern const bfd_arch_info_type bfd_cris_arch;
  611. extern const bfd_arch_info_type bfd_crx_arch;
  612. extern const bfd_arch_info_type bfd_csky_arch;
  613. extern const bfd_arch_info_type bfd_d10v_arch;
  614. extern const bfd_arch_info_type bfd_d30v_arch;
  615. extern const bfd_arch_info_type bfd_dlx_arch;
  616. extern const bfd_arch_info_type bfd_bpf_arch;
  617. extern const bfd_arch_info_type bfd_epiphany_arch;
  618. extern const bfd_arch_info_type bfd_fr30_arch;
  619. extern const bfd_arch_info_type bfd_frv_arch;
  620. extern const bfd_arch_info_type bfd_h8300_arch;
  621. extern const bfd_arch_info_type bfd_hppa_arch;
  622. extern const bfd_arch_info_type bfd_i386_arch;
  623. extern const bfd_arch_info_type bfd_iamcu_arch;
  624. extern const bfd_arch_info_type bfd_ia64_arch;
  625. extern const bfd_arch_info_type bfd_ip2k_arch;
  626. extern const bfd_arch_info_type bfd_iq2000_arch;
  627. extern const bfd_arch_info_type bfd_lm32_arch;
  628. extern const bfd_arch_info_type bfd_loongarch_arch;
  629. extern const bfd_arch_info_type bfd_m32c_arch;
  630. extern const bfd_arch_info_type bfd_m32r_arch;
  631. extern const bfd_arch_info_type bfd_m68hc11_arch;
  632. extern const bfd_arch_info_type bfd_m68hc12_arch;
  633. extern const bfd_arch_info_type bfd_m9s12x_arch;
  634. extern const bfd_arch_info_type bfd_m9s12xg_arch;
  635. extern const bfd_arch_info_type bfd_s12z_arch;
  636. extern const bfd_arch_info_type bfd_m68k_arch;
  637. extern const bfd_arch_info_type bfd_mcore_arch;
  638. extern const bfd_arch_info_type bfd_mep_arch;
  639. extern const bfd_arch_info_type bfd_metag_arch;
  640. extern const bfd_arch_info_type bfd_mips_arch;
  641. extern const bfd_arch_info_type bfd_microblaze_arch;
  642. extern const bfd_arch_info_type bfd_mmix_arch;
  643. extern const bfd_arch_info_type bfd_mn10200_arch;
  644. extern const bfd_arch_info_type bfd_mn10300_arch;
  645. extern const bfd_arch_info_type bfd_moxie_arch;
  646. extern const bfd_arch_info_type bfd_ft32_arch;
  647. extern const bfd_arch_info_type bfd_msp430_arch;
  648. extern const bfd_arch_info_type bfd_mt_arch;
  649. extern const bfd_arch_info_type bfd_nds32_arch;
  650. extern const bfd_arch_info_type bfd_nfp_arch;
  651. extern const bfd_arch_info_type bfd_nios2_arch;
  652. extern const bfd_arch_info_type bfd_ns32k_arch;
  653. extern const bfd_arch_info_type bfd_or1k_arch;
  654. extern const bfd_arch_info_type bfd_pdp11_arch;
  655. extern const bfd_arch_info_type bfd_pj_arch;
  656. extern const bfd_arch_info_type bfd_powerpc_archs[];
  657. #define bfd_powerpc_arch bfd_powerpc_archs[0]
  658. extern const bfd_arch_info_type bfd_pru_arch;
  659. extern const bfd_arch_info_type bfd_riscv_arch;
  660. extern const bfd_arch_info_type bfd_rs6000_arch;
  661. extern const bfd_arch_info_type bfd_rl78_arch;
  662. extern const bfd_arch_info_type bfd_rx_arch;
  663. extern const bfd_arch_info_type bfd_s390_arch;
  664. extern const bfd_arch_info_type bfd_score_arch;
  665. extern const bfd_arch_info_type bfd_sh_arch;
  666. extern const bfd_arch_info_type bfd_sparc_arch;
  667. extern const bfd_arch_info_type bfd_spu_arch;
  668. extern const bfd_arch_info_type bfd_tic30_arch;
  669. extern const bfd_arch_info_type bfd_tic4x_arch;
  670. extern const bfd_arch_info_type bfd_tic54x_arch;
  671. extern const bfd_arch_info_type bfd_tic6x_arch;
  672. extern const bfd_arch_info_type bfd_tilegx_arch;
  673. extern const bfd_arch_info_type bfd_tilepro_arch;
  674. extern const bfd_arch_info_type bfd_v850_arch;
  675. extern const bfd_arch_info_type bfd_v850_rh850_arch;
  676. extern const bfd_arch_info_type bfd_vax_arch;
  677. extern const bfd_arch_info_type bfd_visium_arch;
  678. extern const bfd_arch_info_type bfd_wasm32_arch;
  679. extern const bfd_arch_info_type bfd_xstormy16_arch;
  680. extern const bfd_arch_info_type bfd_xtensa_arch;
  681. extern const bfd_arch_info_type bfd_xc16x_arch;
  682. extern const bfd_arch_info_type bfd_xgate_arch;
  683. extern const bfd_arch_info_type bfd_z80_arch;
  684. extern const bfd_arch_info_type bfd_z8k_arch;
  685. static const bfd_arch_info_type * const bfd_archures_list[] =
  686. {
  687. #ifdef SELECT_ARCHITECTURES
  688. SELECT_ARCHITECTURES,
  689. #else
  690. &bfd_aarch64_arch,
  691. &bfd_alpha_arch,
  692. &bfd_amdgcn_arch,
  693. &bfd_arc_arch,
  694. &bfd_arm_arch,
  695. &bfd_avr_arch,
  696. &bfd_bfin_arch,
  697. &bfd_cr16_arch,
  698. &bfd_cris_arch,
  699. &bfd_crx_arch,
  700. &bfd_csky_arch,
  701. &bfd_d10v_arch,
  702. &bfd_d30v_arch,
  703. &bfd_dlx_arch,
  704. &bfd_bpf_arch,
  705. &bfd_epiphany_arch,
  706. &bfd_fr30_arch,
  707. &bfd_frv_arch,
  708. &bfd_h8300_arch,
  709. &bfd_hppa_arch,
  710. &bfd_i386_arch,
  711. &bfd_iamcu_arch,
  712. &bfd_ia64_arch,
  713. &bfd_ip2k_arch,
  714. &bfd_iq2000_arch,
  715. &bfd_lm32_arch,
  716. &bfd_loongarch_arch,
  717. &bfd_m32c_arch,
  718. &bfd_m32r_arch,
  719. &bfd_m68hc11_arch,
  720. &bfd_m68hc12_arch,
  721. &bfd_m9s12x_arch,
  722. &bfd_m9s12xg_arch,
  723. &bfd_s12z_arch,
  724. &bfd_m68k_arch,
  725. &bfd_mcore_arch,
  726. &bfd_mep_arch,
  727. &bfd_metag_arch,
  728. &bfd_microblaze_arch,
  729. &bfd_mips_arch,
  730. &bfd_mmix_arch,
  731. &bfd_mn10200_arch,
  732. &bfd_mn10300_arch,
  733. &bfd_moxie_arch,
  734. &bfd_ft32_arch,
  735. &bfd_msp430_arch,
  736. &bfd_mt_arch,
  737. &bfd_nds32_arch,
  738. &bfd_nfp_arch,
  739. &bfd_nios2_arch,
  740. &bfd_ns32k_arch,
  741. &bfd_or1k_arch,
  742. &bfd_pdp11_arch,
  743. &bfd_powerpc_arch,
  744. &bfd_pru_arch,
  745. &bfd_riscv_arch,
  746. &bfd_rl78_arch,
  747. &bfd_rs6000_arch,
  748. &bfd_rx_arch,
  749. &bfd_s390_arch,
  750. &bfd_score_arch,
  751. &bfd_sh_arch,
  752. &bfd_sparc_arch,
  753. &bfd_spu_arch,
  754. &bfd_tic30_arch,
  755. &bfd_tic4x_arch,
  756. &bfd_tic54x_arch,
  757. &bfd_tic6x_arch,
  758. &bfd_tilegx_arch,
  759. &bfd_tilepro_arch,
  760. &bfd_v850_arch,
  761. &bfd_v850_rh850_arch,
  762. &bfd_vax_arch,
  763. &bfd_visium_arch,
  764. &bfd_wasm32_arch,
  765. &bfd_xstormy16_arch,
  766. &bfd_xtensa_arch,
  767. &bfd_xc16x_arch,
  768. &bfd_xgate_arch,
  769. &bfd_z80_arch,
  770. &bfd_z8k_arch,
  771. #endif
  772. 0
  773. };
  774. /*
  775. FUNCTION
  776. bfd_printable_name
  777. SYNOPSIS
  778. const char *bfd_printable_name (bfd *abfd);
  779. DESCRIPTION
  780. Return a printable string representing the architecture and machine
  781. from the pointer to the architecture info structure.
  782. */
  783. const char *
  784. bfd_printable_name (bfd *abfd)
  785. {
  786. return abfd->arch_info->printable_name;
  787. }
  788. /*
  789. FUNCTION
  790. bfd_scan_arch
  791. SYNOPSIS
  792. const bfd_arch_info_type *bfd_scan_arch (const char *string);
  793. DESCRIPTION
  794. Figure out if BFD supports any cpu which could be described with
  795. the name @var{string}. Return a pointer to an <<arch_info>>
  796. structure if a machine is found, otherwise NULL.
  797. */
  798. const bfd_arch_info_type *
  799. bfd_scan_arch (const char *string)
  800. {
  801. const bfd_arch_info_type * const *app, *ap;
  802. /* Look through all the installed architectures. */
  803. for (app = bfd_archures_list; *app != NULL; app++)
  804. {
  805. for (ap = *app; ap != NULL; ap = ap->next)
  806. {
  807. if (ap->scan (ap, string))
  808. return ap;
  809. }
  810. }
  811. return NULL;
  812. }
  813. /*
  814. FUNCTION
  815. bfd_arch_list
  816. SYNOPSIS
  817. const char **bfd_arch_list (void);
  818. DESCRIPTION
  819. Return a freshly malloced NULL-terminated vector of the names
  820. of all the valid BFD architectures. Do not modify the names.
  821. */
  822. const char **
  823. bfd_arch_list (void)
  824. {
  825. int vec_length = 0;
  826. const char **name_ptr;
  827. const char **name_list;
  828. const bfd_arch_info_type * const *app;
  829. size_t amt;
  830. /* Determine the number of architectures. */
  831. vec_length = 0;
  832. for (app = bfd_archures_list; *app != NULL; app++)
  833. {
  834. const bfd_arch_info_type *ap;
  835. for (ap = *app; ap != NULL; ap = ap->next)
  836. {
  837. vec_length++;
  838. }
  839. }
  840. amt = (vec_length + 1) * sizeof (char *);
  841. name_list = (const char **) bfd_malloc (amt);
  842. if (name_list == NULL)
  843. return NULL;
  844. /* Point the list at each of the names. */
  845. name_ptr = name_list;
  846. for (app = bfd_archures_list; *app != NULL; app++)
  847. {
  848. const bfd_arch_info_type *ap;
  849. for (ap = *app; ap != NULL; ap = ap->next)
  850. {
  851. *name_ptr = ap->printable_name;
  852. name_ptr++;
  853. }
  854. }
  855. *name_ptr = NULL;
  856. return name_list;
  857. }
  858. /*
  859. FUNCTION
  860. bfd_arch_get_compatible
  861. SYNOPSIS
  862. const bfd_arch_info_type *bfd_arch_get_compatible
  863. (const bfd *abfd, const bfd *bbfd, bool accept_unknowns);
  864. DESCRIPTION
  865. Determine whether two BFDs' architectures and machine types
  866. are compatible. Calculates the lowest common denominator
  867. between the two architectures and machine types implied by
  868. the BFDs and returns a pointer to an <<arch_info>> structure
  869. describing the compatible machine.
  870. */
  871. const bfd_arch_info_type *
  872. bfd_arch_get_compatible (const bfd *abfd,
  873. const bfd *bbfd,
  874. bool accept_unknowns)
  875. {
  876. const bfd *ubfd, *kbfd;
  877. /* Look for an unknown architecture. */
  878. if (abfd->arch_info->arch == bfd_arch_unknown)
  879. ubfd = abfd, kbfd = bbfd;
  880. else if (bbfd->arch_info->arch == bfd_arch_unknown)
  881. ubfd = bbfd, kbfd = abfd;
  882. else
  883. /* Otherwise architecture-specific code has to decide. */
  884. return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info);
  885. /* We can allow an unknown architecture if accept_unknowns is true,
  886. if UBFD is an IR object, or if the target is the "binary" format,
  887. which has an unknown architecture. Since the binary format can
  888. only be set by explicit request from the user, it is safe
  889. to assume that they know what they are doing. */
  890. if (accept_unknowns
  891. || ubfd->plugin_format == bfd_plugin_yes
  892. || strcmp (bfd_get_target (ubfd), "binary") == 0)
  893. return kbfd->arch_info;
  894. return NULL;
  895. }
  896. /*
  897. INTERNAL_DEFINITION
  898. bfd_default_arch_struct
  899. DESCRIPTION
  900. The <<bfd_default_arch_struct>> is an item of
  901. <<bfd_arch_info_type>> which has been initialized to a fairly
  902. generic state. A BFD starts life by pointing to this
  903. structure, until the correct back end has determined the real
  904. architecture of the file.
  905. .extern const bfd_arch_info_type bfd_default_arch_struct;
  906. */
  907. const bfd_arch_info_type bfd_default_arch_struct =
  908. {
  909. 32, 32, 8, bfd_arch_unknown, 0, "unknown", "unknown", 2, true,
  910. bfd_default_compatible,
  911. bfd_default_scan,
  912. bfd_arch_default_fill,
  913. 0, 0
  914. };
  915. /*
  916. FUNCTION
  917. bfd_set_arch_info
  918. SYNOPSIS
  919. void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg);
  920. DESCRIPTION
  921. Set the architecture info of @var{abfd} to @var{arg}.
  922. */
  923. void
  924. bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg)
  925. {
  926. abfd->arch_info = arg;
  927. }
  928. /*
  929. FUNCTION
  930. bfd_default_set_arch_mach
  931. SYNOPSIS
  932. bool bfd_default_set_arch_mach
  933. (bfd *abfd, enum bfd_architecture arch, unsigned long mach);
  934. DESCRIPTION
  935. Set the architecture and machine type in BFD @var{abfd}
  936. to @var{arch} and @var{mach}. Find the correct
  937. pointer to a structure and insert it into the <<arch_info>>
  938. pointer.
  939. */
  940. bool
  941. bfd_default_set_arch_mach (bfd *abfd,
  942. enum bfd_architecture arch,
  943. unsigned long mach)
  944. {
  945. abfd->arch_info = bfd_lookup_arch (arch, mach);
  946. if (abfd->arch_info != NULL)
  947. return true;
  948. abfd->arch_info = &bfd_default_arch_struct;
  949. bfd_set_error (bfd_error_bad_value);
  950. return false;
  951. }
  952. /*
  953. FUNCTION
  954. bfd_get_arch
  955. SYNOPSIS
  956. enum bfd_architecture bfd_get_arch (const bfd *abfd);
  957. DESCRIPTION
  958. Return the enumerated type which describes the BFD @var{abfd}'s
  959. architecture.
  960. */
  961. enum bfd_architecture
  962. bfd_get_arch (const bfd *abfd)
  963. {
  964. return abfd->arch_info->arch;
  965. }
  966. /*
  967. FUNCTION
  968. bfd_get_mach
  969. SYNOPSIS
  970. unsigned long bfd_get_mach (const bfd *abfd);
  971. DESCRIPTION
  972. Return the long type which describes the BFD @var{abfd}'s
  973. machine.
  974. */
  975. unsigned long
  976. bfd_get_mach (const bfd *abfd)
  977. {
  978. return abfd->arch_info->mach;
  979. }
  980. /*
  981. FUNCTION
  982. bfd_arch_bits_per_byte
  983. SYNOPSIS
  984. unsigned int bfd_arch_bits_per_byte (const bfd *abfd);
  985. DESCRIPTION
  986. Return the number of bits in one of the BFD @var{abfd}'s
  987. architecture's bytes.
  988. */
  989. unsigned int
  990. bfd_arch_bits_per_byte (const bfd *abfd)
  991. {
  992. return abfd->arch_info->bits_per_byte;
  993. }
  994. /*
  995. FUNCTION
  996. bfd_arch_bits_per_address
  997. SYNOPSIS
  998. unsigned int bfd_arch_bits_per_address (const bfd *abfd);
  999. DESCRIPTION
  1000. Return the number of bits in one of the BFD @var{abfd}'s
  1001. architecture's addresses.
  1002. */
  1003. unsigned int
  1004. bfd_arch_bits_per_address (const bfd *abfd)
  1005. {
  1006. return abfd->arch_info->bits_per_address;
  1007. }
  1008. /*
  1009. INTERNAL_FUNCTION
  1010. bfd_default_compatible
  1011. SYNOPSIS
  1012. const bfd_arch_info_type *bfd_default_compatible
  1013. (const bfd_arch_info_type *a, const bfd_arch_info_type *b);
  1014. DESCRIPTION
  1015. The default function for testing for compatibility.
  1016. */
  1017. const bfd_arch_info_type *
  1018. bfd_default_compatible (const bfd_arch_info_type *a,
  1019. const bfd_arch_info_type *b)
  1020. {
  1021. if (a->arch != b->arch)
  1022. return NULL;
  1023. if (a->bits_per_word != b->bits_per_word)
  1024. return NULL;
  1025. if (a->mach > b->mach)
  1026. return a;
  1027. if (b->mach > a->mach)
  1028. return b;
  1029. return a;
  1030. }
  1031. /*
  1032. INTERNAL_FUNCTION
  1033. bfd_default_scan
  1034. SYNOPSIS
  1035. bool bfd_default_scan
  1036. (const struct bfd_arch_info *info, const char *string);
  1037. DESCRIPTION
  1038. The default function for working out whether this is an
  1039. architecture hit and a machine hit.
  1040. */
  1041. bool
  1042. bfd_default_scan (const bfd_arch_info_type *info, const char *string)
  1043. {
  1044. const char *ptr_src;
  1045. const char *ptr_tst;
  1046. unsigned long number;
  1047. enum bfd_architecture arch;
  1048. const char *printable_name_colon;
  1049. /* Exact match of the architecture name (ARCH_NAME) and also the
  1050. default architecture? */
  1051. if (strcasecmp (string, info->arch_name) == 0
  1052. && info->the_default)
  1053. return true;
  1054. /* Exact match of the machine name (PRINTABLE_NAME)? */
  1055. if (strcasecmp (string, info->printable_name) == 0)
  1056. return true;
  1057. /* Given that printable_name contains no colon, attempt to match:
  1058. ARCH_NAME [ ":" ] PRINTABLE_NAME? */
  1059. printable_name_colon = strchr (info->printable_name, ':');
  1060. if (printable_name_colon == NULL)
  1061. {
  1062. size_t strlen_arch_name = strlen (info->arch_name);
  1063. if (strncasecmp (string, info->arch_name, strlen_arch_name) == 0)
  1064. {
  1065. if (string[strlen_arch_name] == ':')
  1066. {
  1067. if (strcasecmp (string + strlen_arch_name + 1,
  1068. info->printable_name) == 0)
  1069. return true;
  1070. }
  1071. else
  1072. {
  1073. if (strcasecmp (string + strlen_arch_name,
  1074. info->printable_name) == 0)
  1075. return true;
  1076. }
  1077. }
  1078. }
  1079. /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>;
  1080. Attempt to match: <arch> <mach>? */
  1081. if (printable_name_colon != NULL)
  1082. {
  1083. size_t colon_index = printable_name_colon - info->printable_name;
  1084. if (strncasecmp (string, info->printable_name, colon_index) == 0
  1085. && strcasecmp (string + colon_index,
  1086. info->printable_name + colon_index + 1) == 0)
  1087. return true;
  1088. }
  1089. /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>; Do not
  1090. attempt to match just <mach>, it could be ambiguous. This test
  1091. is left until later. */
  1092. /* NOTE: The below is retained for compatibility only. Please do
  1093. not add to this code. */
  1094. /* See how much of the supplied string matches with the
  1095. architecture, eg the string m68k:68020 would match the 68k entry
  1096. up to the :, then we get left with the machine number. */
  1097. for (ptr_src = string, ptr_tst = info->arch_name;
  1098. *ptr_src && *ptr_tst;
  1099. ptr_src++, ptr_tst++)
  1100. {
  1101. if (*ptr_src != *ptr_tst)
  1102. break;
  1103. }
  1104. /* Chewed up as much of the architecture as will match, skip any
  1105. colons. */
  1106. if (*ptr_src == ':')
  1107. ptr_src++;
  1108. if (*ptr_src == 0)
  1109. {
  1110. /* Nothing more, then only keep this one if it is the default
  1111. machine for this architecture. */
  1112. return info->the_default;
  1113. }
  1114. number = 0;
  1115. while (ISDIGIT (*ptr_src))
  1116. {
  1117. number = number * 10 + *ptr_src - '0';
  1118. ptr_src++;
  1119. }
  1120. /* NOTE: The below is retained for compatibility only.
  1121. PLEASE DO NOT ADD TO THIS CODE. */
  1122. switch (number)
  1123. {
  1124. case 68000:
  1125. arch = bfd_arch_m68k;
  1126. number = bfd_mach_m68000;
  1127. break;
  1128. case 68010:
  1129. arch = bfd_arch_m68k;
  1130. number = bfd_mach_m68010;
  1131. break;
  1132. case 68020:
  1133. arch = bfd_arch_m68k;
  1134. number = bfd_mach_m68020;
  1135. break;
  1136. case 68030:
  1137. arch = bfd_arch_m68k;
  1138. number = bfd_mach_m68030;
  1139. break;
  1140. case 68040:
  1141. arch = bfd_arch_m68k;
  1142. number = bfd_mach_m68040;
  1143. break;
  1144. case 68060:
  1145. arch = bfd_arch_m68k;
  1146. number = bfd_mach_m68060;
  1147. break;
  1148. case 68332:
  1149. arch = bfd_arch_m68k;
  1150. number = bfd_mach_cpu32;
  1151. break;
  1152. case 5200:
  1153. arch = bfd_arch_m68k;
  1154. number = bfd_mach_mcf_isa_a_nodiv;
  1155. break;
  1156. case 5206:
  1157. arch = bfd_arch_m68k;
  1158. number = bfd_mach_mcf_isa_a_mac;
  1159. break;
  1160. case 5307:
  1161. arch = bfd_arch_m68k;
  1162. number = bfd_mach_mcf_isa_a_mac;
  1163. break;
  1164. case 5407:
  1165. arch = bfd_arch_m68k;
  1166. number = bfd_mach_mcf_isa_b_nousp_mac;
  1167. break;
  1168. case 5282:
  1169. arch = bfd_arch_m68k;
  1170. number = bfd_mach_mcf_isa_aplus_emac;
  1171. break;
  1172. case 3000:
  1173. arch = bfd_arch_mips;
  1174. number = bfd_mach_mips3000;
  1175. break;
  1176. case 4000:
  1177. arch = bfd_arch_mips;
  1178. number = bfd_mach_mips4000;
  1179. break;
  1180. case 6000:
  1181. arch = bfd_arch_rs6000;
  1182. break;
  1183. case 7410:
  1184. arch = bfd_arch_sh;
  1185. number = bfd_mach_sh_dsp;
  1186. break;
  1187. case 7708:
  1188. arch = bfd_arch_sh;
  1189. number = bfd_mach_sh3;
  1190. break;
  1191. case 7729:
  1192. arch = bfd_arch_sh;
  1193. number = bfd_mach_sh3_dsp;
  1194. break;
  1195. case 7750:
  1196. arch = bfd_arch_sh;
  1197. number = bfd_mach_sh4;
  1198. break;
  1199. default:
  1200. return false;
  1201. }
  1202. if (arch != info->arch)
  1203. return false;
  1204. if (number != info->mach)
  1205. return false;
  1206. return true;
  1207. }
  1208. /*
  1209. FUNCTION
  1210. bfd_get_arch_info
  1211. SYNOPSIS
  1212. const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd);
  1213. DESCRIPTION
  1214. Return the architecture info struct in @var{abfd}.
  1215. */
  1216. const bfd_arch_info_type *
  1217. bfd_get_arch_info (bfd *abfd)
  1218. {
  1219. return abfd->arch_info;
  1220. }
  1221. /*
  1222. FUNCTION
  1223. bfd_lookup_arch
  1224. SYNOPSIS
  1225. const bfd_arch_info_type *bfd_lookup_arch
  1226. (enum bfd_architecture arch, unsigned long machine);
  1227. DESCRIPTION
  1228. Look for the architecture info structure which matches the
  1229. arguments @var{arch} and @var{machine}. A machine of 0 matches the
  1230. machine/architecture structure which marks itself as the
  1231. default.
  1232. */
  1233. const bfd_arch_info_type *
  1234. bfd_lookup_arch (enum bfd_architecture arch, unsigned long machine)
  1235. {
  1236. const bfd_arch_info_type * const *app, *ap;
  1237. for (app = bfd_archures_list; *app != NULL; app++)
  1238. {
  1239. for (ap = *app; ap != NULL; ap = ap->next)
  1240. {
  1241. if (ap->arch == arch
  1242. && (ap->mach == machine
  1243. || (machine == 0 && ap->the_default)))
  1244. return ap;
  1245. }
  1246. }
  1247. return NULL;
  1248. }
  1249. /*
  1250. FUNCTION
  1251. bfd_printable_arch_mach
  1252. SYNOPSIS
  1253. const char *bfd_printable_arch_mach
  1254. (enum bfd_architecture arch, unsigned long machine);
  1255. DESCRIPTION
  1256. Return a printable string representing the architecture and
  1257. machine type.
  1258. This routine is depreciated.
  1259. */
  1260. const char *
  1261. bfd_printable_arch_mach (enum bfd_architecture arch, unsigned long machine)
  1262. {
  1263. const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine);
  1264. if (ap)
  1265. return ap->printable_name;
  1266. return "UNKNOWN!";
  1267. }
  1268. /*
  1269. FUNCTION
  1270. bfd_octets_per_byte
  1271. SYNOPSIS
  1272. unsigned int bfd_octets_per_byte (const bfd *abfd,
  1273. const asection *sec);
  1274. DESCRIPTION
  1275. Return the number of octets (8-bit quantities) per target byte
  1276. (minimum addressable unit). In most cases, this will be one, but some
  1277. DSP targets have 16, 32, or even 48 bits per byte.
  1278. */
  1279. unsigned int
  1280. bfd_octets_per_byte (const bfd *abfd, const asection *sec)
  1281. {
  1282. if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
  1283. && sec != NULL
  1284. && (sec->flags & SEC_ELF_OCTETS) != 0)
  1285. return 1;
  1286. return bfd_arch_mach_octets_per_byte (bfd_get_arch (abfd),
  1287. bfd_get_mach (abfd));
  1288. }
  1289. /*
  1290. FUNCTION
  1291. bfd_arch_mach_octets_per_byte
  1292. SYNOPSIS
  1293. unsigned int bfd_arch_mach_octets_per_byte
  1294. (enum bfd_architecture arch, unsigned long machine);
  1295. DESCRIPTION
  1296. See bfd_octets_per_byte.
  1297. This routine is provided for those cases where a bfd * is not
  1298. available
  1299. */
  1300. unsigned int
  1301. bfd_arch_mach_octets_per_byte (enum bfd_architecture arch,
  1302. unsigned long mach)
  1303. {
  1304. const bfd_arch_info_type *ap = bfd_lookup_arch (arch, mach);
  1305. if (ap)
  1306. return ap->bits_per_byte / 8;
  1307. return 1;
  1308. }
  1309. /*
  1310. INTERNAL_FUNCTION
  1311. bfd_arch_default_fill
  1312. SYNOPSIS
  1313. void *bfd_arch_default_fill (bfd_size_type count,
  1314. bool is_bigendian,
  1315. bool code);
  1316. DESCRIPTION
  1317. Allocate via bfd_malloc and return a fill buffer of size COUNT.
  1318. If IS_BIGENDIAN is TRUE, the order of bytes is big endian. If
  1319. CODE is TRUE, the buffer contains code.
  1320. */
  1321. void *
  1322. bfd_arch_default_fill (bfd_size_type count,
  1323. bool is_bigendian ATTRIBUTE_UNUSED,
  1324. bool code ATTRIBUTE_UNUSED)
  1325. {
  1326. void *fill = bfd_malloc (count);
  1327. if (fill != NULL)
  1328. memset (fill, 0, count);
  1329. return fill;
  1330. }
  1331. bool
  1332. _bfd_nowrite_set_arch_mach (bfd *abfd,
  1333. enum bfd_architecture arch ATTRIBUTE_UNUSED,
  1334. unsigned long mach ATTRIBUTE_UNUSED)
  1335. {
  1336. return _bfd_bool_bfd_false_error (abfd);
  1337. }