targets.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880
  1. /* Generic target-file-type support for the BFD library.
  2. Copyright (C) 1990-2015 Free Software Foundation, Inc.
  3. Written by 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 "fnmatch.h"
  21. /*
  22. It's okay to see some:
  23. #if 0
  24. directives in this source file, as targets.c uses them to exclude
  25. certain BFD vectors. This comment is specially formatted to catch
  26. users who grep for ^#if 0, so please keep it this way!
  27. */
  28. /*
  29. SECTION
  30. Targets
  31. DESCRIPTION
  32. Each port of BFD to a different machine requires the creation
  33. of a target back end. All the back end provides to the root
  34. part of BFD is a structure containing pointers to functions
  35. which perform certain low level operations on files. BFD
  36. translates the applications's requests through a pointer into
  37. calls to the back end routines.
  38. When a file is opened with <<bfd_openr>>, its format and
  39. target are unknown. BFD uses various mechanisms to determine
  40. how to interpret the file. The operations performed are:
  41. o Create a BFD by calling the internal routine
  42. <<_bfd_new_bfd>>, then call <<bfd_find_target>> with the
  43. target string supplied to <<bfd_openr>> and the new BFD pointer.
  44. o If a null target string was provided to <<bfd_find_target>>,
  45. look up the environment variable <<GNUTARGET>> and use
  46. that as the target string.
  47. o If the target string is still <<NULL>>, or the target string is
  48. <<default>>, then use the first item in the target vector
  49. as the target type, and set <<target_defaulted>> in the BFD to
  50. cause <<bfd_check_format>> to loop through all the targets.
  51. @xref{bfd_target}. @xref{Formats}.
  52. o Otherwise, inspect the elements in the target vector
  53. one by one, until a match on target name is found. When found,
  54. use it.
  55. o Otherwise return the error <<bfd_error_invalid_target>> to
  56. <<bfd_openr>>.
  57. o <<bfd_openr>> attempts to open the file using
  58. <<bfd_open_file>>, and returns the BFD.
  59. Once the BFD has been opened and the target selected, the file
  60. format may be determined. This is done by calling
  61. <<bfd_check_format>> on the BFD with a suggested format.
  62. If <<target_defaulted>> has been set, each possible target
  63. type is tried to see if it recognizes the specified format.
  64. <<bfd_check_format>> returns <<TRUE>> when the caller guesses right.
  65. @menu
  66. @* bfd_target::
  67. @end menu
  68. */
  69. /*
  70. INODE
  71. bfd_target, , Targets, Targets
  72. DOCDD
  73. SUBSECTION
  74. bfd_target
  75. DESCRIPTION
  76. This structure contains everything that BFD knows about a
  77. target. It includes things like its byte order, name, and which
  78. routines to call to do various operations.
  79. Every BFD points to a target structure with its <<xvec>>
  80. member.
  81. The macros below are used to dispatch to functions through the
  82. <<bfd_target>> vector. They are used in a number of macros further
  83. down in @file{bfd.h}, and are also used when calling various
  84. routines by hand inside the BFD implementation. The @var{arglist}
  85. argument must be parenthesized; it contains all the arguments
  86. to the called function.
  87. They make the documentation (more) unpleasant to read, so if
  88. someone wants to fix this and not break the above, please do.
  89. .#define BFD_SEND(bfd, message, arglist) \
  90. . ((*((bfd)->xvec->message)) arglist)
  91. .
  92. .#ifdef DEBUG_BFD_SEND
  93. .#undef BFD_SEND
  94. .#define BFD_SEND(bfd, message, arglist) \
  95. . (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
  96. . ((*((bfd)->xvec->message)) arglist) : \
  97. . (bfd_assert (__FILE__,__LINE__), NULL))
  98. .#endif
  99. For operations which index on the BFD format:
  100. .#define BFD_SEND_FMT(bfd, message, arglist) \
  101. . (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist)
  102. .
  103. .#ifdef DEBUG_BFD_SEND
  104. .#undef BFD_SEND_FMT
  105. .#define BFD_SEND_FMT(bfd, message, arglist) \
  106. . (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
  107. . (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \
  108. . (bfd_assert (__FILE__,__LINE__), NULL))
  109. .#endif
  110. .
  111. This is the structure which defines the type of BFD this is. The
  112. <<xvec>> member of the struct <<bfd>> itself points here. Each
  113. module that implements access to a different target under BFD,
  114. defines one of these.
  115. FIXME, these names should be rationalised with the names of
  116. the entry points which call them. Too bad we can't have one
  117. macro to define them both!
  118. .enum bfd_flavour
  119. .{
  120. . {* N.B. Update bfd_flavour_name if you change this. *}
  121. . bfd_target_unknown_flavour,
  122. . bfd_target_aout_flavour,
  123. . bfd_target_coff_flavour,
  124. . bfd_target_ecoff_flavour,
  125. . bfd_target_xcoff_flavour,
  126. . bfd_target_elf_flavour,
  127. . bfd_target_ieee_flavour,
  128. . bfd_target_nlm_flavour,
  129. . bfd_target_oasys_flavour,
  130. . bfd_target_tekhex_flavour,
  131. . bfd_target_srec_flavour,
  132. . bfd_target_verilog_flavour,
  133. . bfd_target_ihex_flavour,
  134. . bfd_target_som_flavour,
  135. . bfd_target_os9k_flavour,
  136. . bfd_target_versados_flavour,
  137. . bfd_target_msdos_flavour,
  138. . bfd_target_ovax_flavour,
  139. . bfd_target_evax_flavour,
  140. . bfd_target_mmo_flavour,
  141. . bfd_target_mach_o_flavour,
  142. . bfd_target_pef_flavour,
  143. . bfd_target_pef_xlib_flavour,
  144. . bfd_target_sym_flavour
  145. .};
  146. .
  147. .enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
  148. .
  149. .{* Forward declaration. *}
  150. .typedef struct bfd_link_info _bfd_link_info;
  151. .
  152. .{* Forward declaration. *}
  153. .typedef struct flag_info flag_info;
  154. .
  155. .typedef struct bfd_target
  156. .{
  157. . {* Identifies the kind of target, e.g., SunOS4, Ultrix, etc. *}
  158. . char *name;
  159. .
  160. . {* The "flavour" of a back end is a general indication about
  161. . the contents of a file. *}
  162. . enum bfd_flavour flavour;
  163. .
  164. . {* The order of bytes within the data area of a file. *}
  165. . enum bfd_endian byteorder;
  166. .
  167. . {* The order of bytes within the header parts of a file. *}
  168. . enum bfd_endian header_byteorder;
  169. .
  170. . {* A mask of all the flags which an executable may have set -
  171. . from the set <<BFD_NO_FLAGS>>, <<HAS_RELOC>>, ...<<D_PAGED>>. *}
  172. . flagword object_flags;
  173. .
  174. . {* A mask of all the flags which a section may have set - from
  175. . the set <<SEC_NO_FLAGS>>, <<SEC_ALLOC>>, ...<<SET_NEVER_LOAD>>. *}
  176. . flagword section_flags;
  177. .
  178. . {* The character normally found at the front of a symbol.
  179. . (if any), perhaps `_'. *}
  180. . char symbol_leading_char;
  181. .
  182. . {* The pad character for file names within an archive header. *}
  183. . char ar_pad_char;
  184. .
  185. . {* The maximum number of characters in an archive header. *}
  186. . unsigned char ar_max_namelen;
  187. .
  188. . {* How well this target matches, used to select between various
  189. . possible targets when more than one target matches. *}
  190. . unsigned char match_priority;
  191. .
  192. . {* Entries for byte swapping for data. These are different from the
  193. . other entry points, since they don't take a BFD as the first argument.
  194. . Certain other handlers could do the same. *}
  195. . bfd_uint64_t (*bfd_getx64) (const void *);
  196. . bfd_int64_t (*bfd_getx_signed_64) (const void *);
  197. . void (*bfd_putx64) (bfd_uint64_t, void *);
  198. . bfd_vma (*bfd_getx32) (const void *);
  199. . bfd_signed_vma (*bfd_getx_signed_32) (const void *);
  200. . void (*bfd_putx32) (bfd_vma, void *);
  201. . bfd_vma (*bfd_getx16) (const void *);
  202. . bfd_signed_vma (*bfd_getx_signed_16) (const void *);
  203. . void (*bfd_putx16) (bfd_vma, void *);
  204. .
  205. . {* Byte swapping for the headers. *}
  206. . bfd_uint64_t (*bfd_h_getx64) (const void *);
  207. . bfd_int64_t (*bfd_h_getx_signed_64) (const void *);
  208. . void (*bfd_h_putx64) (bfd_uint64_t, void *);
  209. . bfd_vma (*bfd_h_getx32) (const void *);
  210. . bfd_signed_vma (*bfd_h_getx_signed_32) (const void *);
  211. . void (*bfd_h_putx32) (bfd_vma, void *);
  212. . bfd_vma (*bfd_h_getx16) (const void *);
  213. . bfd_signed_vma (*bfd_h_getx_signed_16) (const void *);
  214. . void (*bfd_h_putx16) (bfd_vma, void *);
  215. .
  216. . {* Format dependent routines: these are vectors of entry points
  217. . within the target vector structure, one for each format to check. *}
  218. .
  219. . {* Check the format of a file being read. Return a <<bfd_target *>> or zero. *}
  220. . const struct bfd_target *(*_bfd_check_format[bfd_type_end]) (bfd *);
  221. .
  222. . {* Set the format of a file being written. *}
  223. . bfd_boolean (*_bfd_set_format[bfd_type_end]) (bfd *);
  224. .
  225. . {* Write cached information into a file being written, at <<bfd_close>>. *}
  226. . bfd_boolean (*_bfd_write_contents[bfd_type_end]) (bfd *);
  227. .
  228. The general target vector. These vectors are initialized using the
  229. BFD_JUMP_TABLE macros.
  230. .
  231. . {* Generic entry points. *}
  232. .#define BFD_JUMP_TABLE_GENERIC(NAME) \
  233. . NAME##_close_and_cleanup, \
  234. . NAME##_bfd_free_cached_info, \
  235. . NAME##_new_section_hook, \
  236. . NAME##_get_section_contents, \
  237. . NAME##_get_section_contents_in_window
  238. .
  239. . {* Called when the BFD is being closed to do any necessary cleanup. *}
  240. . bfd_boolean (*_close_and_cleanup) (bfd *);
  241. . {* Ask the BFD to free all cached information. *}
  242. . bfd_boolean (*_bfd_free_cached_info) (bfd *);
  243. . {* Called when a new section is created. *}
  244. . bfd_boolean (*_new_section_hook) (bfd *, sec_ptr);
  245. . {* Read the contents of a section. *}
  246. . bfd_boolean (*_bfd_get_section_contents)
  247. . (bfd *, sec_ptr, void *, file_ptr, bfd_size_type);
  248. . bfd_boolean (*_bfd_get_section_contents_in_window)
  249. . (bfd *, sec_ptr, bfd_window *, file_ptr, bfd_size_type);
  250. .
  251. . {* Entry points to copy private data. *}
  252. .#define BFD_JUMP_TABLE_COPY(NAME) \
  253. . NAME##_bfd_copy_private_bfd_data, \
  254. . NAME##_bfd_merge_private_bfd_data, \
  255. . _bfd_generic_init_private_section_data, \
  256. . NAME##_bfd_copy_private_section_data, \
  257. . NAME##_bfd_copy_private_symbol_data, \
  258. . NAME##_bfd_copy_private_header_data, \
  259. . NAME##_bfd_set_private_flags, \
  260. . NAME##_bfd_print_private_bfd_data
  261. .
  262. . {* Called to copy BFD general private data from one object file
  263. . to another. *}
  264. . bfd_boolean (*_bfd_copy_private_bfd_data) (bfd *, bfd *);
  265. . {* Called to merge BFD general private data from one object file
  266. . to a common output file when linking. *}
  267. . bfd_boolean (*_bfd_merge_private_bfd_data) (bfd *, bfd *);
  268. . {* Called to initialize BFD private section data from one object file
  269. . to another. *}
  270. .#define bfd_init_private_section_data(ibfd, isec, obfd, osec, link_info) \
  271. . BFD_SEND (obfd, _bfd_init_private_section_data, (ibfd, isec, obfd, osec, link_info))
  272. . bfd_boolean (*_bfd_init_private_section_data)
  273. . (bfd *, sec_ptr, bfd *, sec_ptr, struct bfd_link_info *);
  274. . {* Called to copy BFD private section data from one object file
  275. . to another. *}
  276. . bfd_boolean (*_bfd_copy_private_section_data)
  277. . (bfd *, sec_ptr, bfd *, sec_ptr);
  278. . {* Called to copy BFD private symbol data from one symbol
  279. . to another. *}
  280. . bfd_boolean (*_bfd_copy_private_symbol_data)
  281. . (bfd *, asymbol *, bfd *, asymbol *);
  282. . {* Called to copy BFD private header data from one object file
  283. . to another. *}
  284. . bfd_boolean (*_bfd_copy_private_header_data)
  285. . (bfd *, bfd *);
  286. . {* Called to set private backend flags. *}
  287. . bfd_boolean (*_bfd_set_private_flags) (bfd *, flagword);
  288. .
  289. . {* Called to print private BFD data. *}
  290. . bfd_boolean (*_bfd_print_private_bfd_data) (bfd *, void *);
  291. .
  292. . {* Core file entry points. *}
  293. .#define BFD_JUMP_TABLE_CORE(NAME) \
  294. . NAME##_core_file_failing_command, \
  295. . NAME##_core_file_failing_signal, \
  296. . NAME##_core_file_matches_executable_p, \
  297. . NAME##_core_file_pid
  298. .
  299. . char * (*_core_file_failing_command) (bfd *);
  300. . int (*_core_file_failing_signal) (bfd *);
  301. . bfd_boolean (*_core_file_matches_executable_p) (bfd *, bfd *);
  302. . int (*_core_file_pid) (bfd *);
  303. .
  304. . {* Archive entry points. *}
  305. .#define BFD_JUMP_TABLE_ARCHIVE(NAME) \
  306. . NAME##_slurp_armap, \
  307. . NAME##_slurp_extended_name_table, \
  308. . NAME##_construct_extended_name_table, \
  309. . NAME##_truncate_arname, \
  310. . NAME##_write_armap, \
  311. . NAME##_read_ar_hdr, \
  312. . NAME##_write_ar_hdr, \
  313. . NAME##_openr_next_archived_file, \
  314. . NAME##_get_elt_at_index, \
  315. . NAME##_generic_stat_arch_elt, \
  316. . NAME##_update_armap_timestamp
  317. .
  318. . bfd_boolean (*_bfd_slurp_armap) (bfd *);
  319. . bfd_boolean (*_bfd_slurp_extended_name_table) (bfd *);
  320. . bfd_boolean (*_bfd_construct_extended_name_table)
  321. . (bfd *, char **, bfd_size_type *, const char **);
  322. . void (*_bfd_truncate_arname) (bfd *, const char *, char *);
  323. . bfd_boolean (*write_armap)
  324. . (bfd *, unsigned int, struct orl *, unsigned int, int);
  325. . void * (*_bfd_read_ar_hdr_fn) (bfd *);
  326. . bfd_boolean (*_bfd_write_ar_hdr_fn) (bfd *, bfd *);
  327. . bfd * (*openr_next_archived_file) (bfd *, bfd *);
  328. .#define bfd_get_elt_at_index(b,i) BFD_SEND (b, _bfd_get_elt_at_index, (b,i))
  329. . bfd * (*_bfd_get_elt_at_index) (bfd *, symindex);
  330. . int (*_bfd_stat_arch_elt) (bfd *, struct stat *);
  331. . bfd_boolean (*_bfd_update_armap_timestamp) (bfd *);
  332. .
  333. . {* Entry points used for symbols. *}
  334. .#define BFD_JUMP_TABLE_SYMBOLS(NAME) \
  335. . NAME##_get_symtab_upper_bound, \
  336. . NAME##_canonicalize_symtab, \
  337. . NAME##_make_empty_symbol, \
  338. . NAME##_print_symbol, \
  339. . NAME##_get_symbol_info, \
  340. . NAME##_get_symbol_version_string, \
  341. . NAME##_bfd_is_local_label_name, \
  342. . NAME##_bfd_is_target_special_symbol, \
  343. . NAME##_get_lineno, \
  344. . NAME##_find_nearest_line, \
  345. . NAME##_find_line, \
  346. . NAME##_find_inliner_info, \
  347. . NAME##_bfd_make_debug_symbol, \
  348. . NAME##_read_minisymbols, \
  349. . NAME##_minisymbol_to_symbol
  350. .
  351. . long (*_bfd_get_symtab_upper_bound) (bfd *);
  352. . long (*_bfd_canonicalize_symtab)
  353. . (bfd *, struct bfd_symbol **);
  354. . struct bfd_symbol *
  355. . (*_bfd_make_empty_symbol) (bfd *);
  356. . void (*_bfd_print_symbol)
  357. . (bfd *, void *, struct bfd_symbol *, bfd_print_symbol_type);
  358. .#define bfd_print_symbol(b,p,s,e) BFD_SEND (b, _bfd_print_symbol, (b,p,s,e))
  359. . void (*_bfd_get_symbol_info)
  360. . (bfd *, struct bfd_symbol *, symbol_info *);
  361. .#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
  362. . const char *(*_bfd_get_symbol_version_string)
  363. . (bfd *, struct bfd_symbol *, bfd_boolean *);
  364. .#define bfd_get_symbol_version_string(b,s,h) BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h))
  365. . bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *);
  366. . bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
  367. . alent * (*_get_lineno) (bfd *, struct bfd_symbol *);
  368. . bfd_boolean (*_bfd_find_nearest_line)
  369. . (bfd *, struct bfd_symbol **, struct bfd_section *, bfd_vma,
  370. . const char **, const char **, unsigned int *, unsigned int *);
  371. . bfd_boolean (*_bfd_find_line)
  372. . (bfd *, struct bfd_symbol **, struct bfd_symbol *,
  373. . const char **, unsigned int *);
  374. . bfd_boolean (*_bfd_find_inliner_info)
  375. . (bfd *, const char **, const char **, unsigned int *);
  376. . {* Back-door to allow format-aware applications to create debug symbols
  377. . while using BFD for everything else. Currently used by the assembler
  378. . when creating COFF files. *}
  379. . asymbol * (*_bfd_make_debug_symbol)
  380. . (bfd *, void *, unsigned long size);
  381. .#define bfd_read_minisymbols(b, d, m, s) \
  382. . BFD_SEND (b, _read_minisymbols, (b, d, m, s))
  383. . long (*_read_minisymbols)
  384. . (bfd *, bfd_boolean, void **, unsigned int *);
  385. .#define bfd_minisymbol_to_symbol(b, d, m, f) \
  386. . BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
  387. . asymbol * (*_minisymbol_to_symbol)
  388. . (bfd *, bfd_boolean, const void *, asymbol *);
  389. .
  390. . {* Routines for relocs. *}
  391. .#define BFD_JUMP_TABLE_RELOCS(NAME) \
  392. . NAME##_get_reloc_upper_bound, \
  393. . NAME##_canonicalize_reloc, \
  394. . NAME##_bfd_reloc_type_lookup, \
  395. . NAME##_bfd_reloc_name_lookup
  396. .
  397. . long (*_get_reloc_upper_bound) (bfd *, sec_ptr);
  398. . long (*_bfd_canonicalize_reloc)
  399. . (bfd *, sec_ptr, arelent **, struct bfd_symbol **);
  400. . {* See documentation on reloc types. *}
  401. . reloc_howto_type *
  402. . (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
  403. . reloc_howto_type *
  404. . (*reloc_name_lookup) (bfd *, const char *);
  405. .
  406. .
  407. . {* Routines used when writing an object file. *}
  408. .#define BFD_JUMP_TABLE_WRITE(NAME) \
  409. . NAME##_set_arch_mach, \
  410. . NAME##_set_section_contents
  411. .
  412. . bfd_boolean (*_bfd_set_arch_mach)
  413. . (bfd *, enum bfd_architecture, unsigned long);
  414. . bfd_boolean (*_bfd_set_section_contents)
  415. . (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
  416. .
  417. . {* Routines used by the linker. *}
  418. .#define BFD_JUMP_TABLE_LINK(NAME) \
  419. . NAME##_sizeof_headers, \
  420. . NAME##_bfd_get_relocated_section_contents, \
  421. . NAME##_bfd_relax_section, \
  422. . NAME##_bfd_link_hash_table_create, \
  423. . NAME##_bfd_link_add_symbols, \
  424. . NAME##_bfd_link_just_syms, \
  425. . NAME##_bfd_copy_link_hash_symbol_type, \
  426. . NAME##_bfd_final_link, \
  427. . NAME##_bfd_link_split_section, \
  428. . NAME##_bfd_gc_sections, \
  429. . NAME##_bfd_lookup_section_flags, \
  430. . NAME##_bfd_merge_sections, \
  431. . NAME##_bfd_is_group_section, \
  432. . NAME##_bfd_discard_group, \
  433. . NAME##_section_already_linked, \
  434. . NAME##_bfd_define_common_symbol
  435. .
  436. . int (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
  437. . bfd_byte * (*_bfd_get_relocated_section_contents)
  438. . (bfd *, struct bfd_link_info *, struct bfd_link_order *,
  439. . bfd_byte *, bfd_boolean, struct bfd_symbol **);
  440. .
  441. . bfd_boolean (*_bfd_relax_section)
  442. . (bfd *, struct bfd_section *, struct bfd_link_info *, bfd_boolean *);
  443. .
  444. . {* Create a hash table for the linker. Different backends store
  445. . different information in this table. *}
  446. . struct bfd_link_hash_table *
  447. . (*_bfd_link_hash_table_create) (bfd *);
  448. .
  449. . {* Add symbols from this object file into the hash table. *}
  450. . bfd_boolean (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *);
  451. .
  452. . {* Indicate that we are only retrieving symbol values from this section. *}
  453. . void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *);
  454. .
  455. . {* Copy the symbol type and other attributes for a linker script
  456. . assignment of one symbol to another. *}
  457. .#define bfd_copy_link_hash_symbol_type(b, t, f) \
  458. . BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f))
  459. . void (*_bfd_copy_link_hash_symbol_type)
  460. . (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *);
  461. .
  462. . {* Do a link based on the link_order structures attached to each
  463. . section of the BFD. *}
  464. . bfd_boolean (*_bfd_final_link) (bfd *, struct bfd_link_info *);
  465. .
  466. . {* Should this section be split up into smaller pieces during linking. *}
  467. . bfd_boolean (*_bfd_link_split_section) (bfd *, struct bfd_section *);
  468. .
  469. . {* Remove sections that are not referenced from the output. *}
  470. . bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *);
  471. .
  472. . {* Sets the bitmask of allowed and disallowed section flags. *}
  473. . bfd_boolean (*_bfd_lookup_section_flags) (struct bfd_link_info *,
  474. . struct flag_info *,
  475. . asection *);
  476. .
  477. . {* Attempt to merge SEC_MERGE sections. *}
  478. . bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
  479. .
  480. . {* Is this section a member of a group? *}
  481. . bfd_boolean (*_bfd_is_group_section) (bfd *, const struct bfd_section *);
  482. .
  483. . {* Discard members of a group. *}
  484. . bfd_boolean (*_bfd_discard_group) (bfd *, struct bfd_section *);
  485. .
  486. . {* Check if SEC has been already linked during a reloceatable or
  487. . final link. *}
  488. . bfd_boolean (*_section_already_linked) (bfd *, asection *,
  489. . struct bfd_link_info *);
  490. .
  491. . {* Define a common symbol. *}
  492. . bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
  493. . struct bfd_link_hash_entry *);
  494. .
  495. . {* Routines to handle dynamic symbols and relocs. *}
  496. .#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
  497. . NAME##_get_dynamic_symtab_upper_bound, \
  498. . NAME##_canonicalize_dynamic_symtab, \
  499. . NAME##_get_synthetic_symtab, \
  500. . NAME##_get_dynamic_reloc_upper_bound, \
  501. . NAME##_canonicalize_dynamic_reloc
  502. .
  503. . {* Get the amount of memory required to hold the dynamic symbols. *}
  504. . long (*_bfd_get_dynamic_symtab_upper_bound) (bfd *);
  505. . {* Read in the dynamic symbols. *}
  506. . long (*_bfd_canonicalize_dynamic_symtab)
  507. . (bfd *, struct bfd_symbol **);
  508. . {* Create synthetized symbols. *}
  509. . long (*_bfd_get_synthetic_symtab)
  510. . (bfd *, long, struct bfd_symbol **, long, struct bfd_symbol **,
  511. . struct bfd_symbol **);
  512. . {* Get the amount of memory required to hold the dynamic relocs. *}
  513. . long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *);
  514. . {* Read in the dynamic relocs. *}
  515. . long (*_bfd_canonicalize_dynamic_reloc)
  516. . (bfd *, arelent **, struct bfd_symbol **);
  517. .
  518. A pointer to an alternative bfd_target in case the current one is not
  519. satisfactory. This can happen when the target cpu supports both big
  520. and little endian code, and target chosen by the linker has the wrong
  521. endianness. The function open_output() in ld/ldlang.c uses this field
  522. to find an alternative output format that is suitable.
  523. . {* Opposite endian version of this target. *}
  524. . const struct bfd_target * alternative_target;
  525. .
  526. . {* Data for use by back-end routines, which isn't
  527. . generic enough to belong in this structure. *}
  528. . const void *backend_data;
  529. .
  530. .} bfd_target;
  531. .
  532. */
  533. /* All known xvecs (even those that don't compile on all systems).
  534. Alphabetized for easy reference.
  535. They are listed a second time below, since
  536. we can't intermix extern's and initializers. */
  537. extern const bfd_target aarch64_elf32_be_vec;
  538. extern const bfd_target aarch64_elf32_le_vec;
  539. extern const bfd_target aarch64_elf64_be_vec;
  540. extern const bfd_target aarch64_elf64_le_vec;
  541. extern const bfd_target alpha_ecoff_le_vec;
  542. extern const bfd_target alpha_elf64_vec;
  543. extern const bfd_target alpha_elf64_fbsd_vec;
  544. extern const bfd_target alpha_nlm32_vec;
  545. extern const bfd_target alpha_vms_vec;
  546. extern const bfd_target alpha_vms_lib_txt_vec;
  547. extern const bfd_target am33_elf32_linux_vec;
  548. extern const bfd_target aout0_be_vec;
  549. extern const bfd_target aout64_vec;
  550. extern const bfd_target aout_vec;
  551. extern const bfd_target aout_adobe_vec;
  552. extern const bfd_target arc_elf32_be_vec;
  553. extern const bfd_target arc_elf32_le_vec;
  554. extern const bfd_target arm_aout_be_vec;
  555. extern const bfd_target arm_aout_le_vec;
  556. extern const bfd_target arm_aout_nbsd_vec;
  557. extern const bfd_target arm_aout_riscix_vec;
  558. extern const bfd_target arm_coff_be_vec;
  559. extern const bfd_target arm_coff_le_vec;
  560. extern const bfd_target arm_elf32_be_vec;
  561. extern const bfd_target arm_elf32_le_vec;
  562. extern const bfd_target arm_elf32_nacl_be_vec;
  563. extern const bfd_target arm_elf32_nacl_le_vec;
  564. extern const bfd_target arm_elf32_symbian_be_vec;
  565. extern const bfd_target arm_elf32_symbian_le_vec;
  566. extern const bfd_target arm_elf32_vxworks_be_vec;
  567. extern const bfd_target arm_elf32_vxworks_le_vec;
  568. extern const bfd_target arm_pe_be_vec;
  569. extern const bfd_target arm_pe_le_vec;
  570. extern const bfd_target arm_pe_epoc_be_vec;
  571. extern const bfd_target arm_pe_epoc_le_vec;
  572. extern const bfd_target arm_pe_wince_be_vec;
  573. extern const bfd_target arm_pe_wince_le_vec;
  574. extern const bfd_target arm_pei_be_vec;
  575. extern const bfd_target arm_pei_le_vec;
  576. extern const bfd_target arm_pei_epoc_be_vec;
  577. extern const bfd_target arm_pei_epoc_le_vec;
  578. extern const bfd_target arm_pei_wince_be_vec;
  579. extern const bfd_target arm_pei_wince_le_vec;
  580. extern const bfd_target avr_elf32_vec;
  581. extern const bfd_target bfin_elf32_vec;
  582. extern const bfd_target bfin_elf32_fdpic_vec;
  583. extern const bfd_target bout_be_vec;
  584. extern const bfd_target bout_le_vec;
  585. extern const bfd_target cr16_elf32_vec;
  586. extern const bfd_target cr16c_elf32_vec;
  587. extern const bfd_target cris_aout_vec;
  588. extern const bfd_target cris_elf32_vec;
  589. extern const bfd_target cris_elf32_us_vec;
  590. extern const bfd_target crx_elf32_vec;
  591. extern const bfd_target d10v_elf32_vec;
  592. extern const bfd_target d30v_elf32_vec;
  593. extern const bfd_target dlx_elf32_be_vec;
  594. extern const bfd_target elf32_be_vec;
  595. extern const bfd_target elf32_le_vec;
  596. extern const bfd_target elf64_be_vec;
  597. extern const bfd_target elf64_le_vec;
  598. extern const bfd_target epiphany_elf32_vec;
  599. extern const bfd_target fr30_elf32_vec;
  600. extern const bfd_target frv_elf32_vec;
  601. extern const bfd_target frv_elf32_fdpic_vec;
  602. extern const bfd_target h8300_coff_vec;
  603. extern const bfd_target h8300_elf32_vec;
  604. extern const bfd_target h8300_elf32_linux_vec;
  605. extern const bfd_target h8500_coff_vec;
  606. extern const bfd_target hppa_elf32_vec;
  607. extern const bfd_target hppa_elf32_linux_vec;
  608. extern const bfd_target hppa_elf32_nbsd_vec;
  609. extern const bfd_target hppa_elf64_vec;
  610. extern const bfd_target hppa_elf64_linux_vec;
  611. extern const bfd_target hppa_som_vec;
  612. extern const bfd_target i370_elf32_vec;
  613. extern const bfd_target i386_aout_vec;
  614. extern const bfd_target i386_aout_bsd_vec;
  615. extern const bfd_target i386_aout_dynix_vec;
  616. extern const bfd_target i386_aout_fbsd_vec;
  617. extern const bfd_target i386_aout_linux_vec;
  618. extern const bfd_target i386_aout_lynx_vec;
  619. extern const bfd_target i386_aout_mach3_vec;
  620. extern const bfd_target i386_aout_nbsd_vec;
  621. extern const bfd_target i386_aout_os9k_vec;
  622. extern const bfd_target i386_coff_vec;
  623. extern const bfd_target i386_coff_go32_vec;
  624. extern const bfd_target i386_coff_go32stubbed_vec;
  625. extern const bfd_target i386_coff_lynx_vec;
  626. extern const bfd_target i386_elf32_vec;
  627. extern const bfd_target i386_elf32_fbsd_vec;
  628. extern const bfd_target i386_elf32_nacl_vec;
  629. extern const bfd_target i386_elf32_sol2_vec;
  630. extern const bfd_target i386_elf32_vxworks_vec;
  631. extern const bfd_target i386_mach_o_vec;
  632. extern const bfd_target i386_msdos_vec;
  633. extern const bfd_target i386_nlm32_vec;
  634. extern const bfd_target i386_pe_vec;
  635. extern const bfd_target i386_pei_vec;
  636. extern const bfd_target iamcu_elf32_vec;
  637. extern const bfd_target i860_coff_vec;
  638. extern const bfd_target i860_elf32_vec;
  639. extern const bfd_target i860_elf32_le_vec;
  640. extern const bfd_target i960_elf32_vec;
  641. extern const bfd_target ia64_elf32_be_vec;
  642. extern const bfd_target ia64_elf32_hpux_be_vec;
  643. extern const bfd_target ia64_elf64_be_vec;
  644. extern const bfd_target ia64_elf64_le_vec;
  645. extern const bfd_target ia64_elf64_hpux_be_vec;
  646. extern const bfd_target ia64_elf64_vms_vec;
  647. extern const bfd_target ia64_pei_vec;
  648. extern const bfd_target icoff_be_vec;
  649. extern const bfd_target icoff_le_vec;
  650. extern const bfd_target ieee_vec;
  651. extern const bfd_target ip2k_elf32_vec;
  652. extern const bfd_target iq2000_elf32_vec;
  653. extern const bfd_target k1om_elf64_vec;
  654. extern const bfd_target k1om_elf64_fbsd_vec;
  655. extern const bfd_target l1om_elf64_vec;
  656. extern const bfd_target l1om_elf64_fbsd_vec;
  657. extern const bfd_target lm32_elf32_vec;
  658. extern const bfd_target lm32_elf32_fdpic_vec;
  659. extern const bfd_target m32c_elf32_vec;
  660. extern const bfd_target m32r_elf32_vec;
  661. extern const bfd_target m32r_elf32_le_vec;
  662. extern const bfd_target m32r_elf32_linux_vec;
  663. extern const bfd_target m32r_elf32_linux_le_vec;
  664. extern const bfd_target m68hc11_elf32_vec;
  665. extern const bfd_target m68hc12_elf32_vec;
  666. extern const bfd_target m68k_aout_4knbsd_vec;
  667. extern const bfd_target m68k_aout_hp300bsd_vec;
  668. extern const bfd_target m68k_aout_hp300hpux_vec;
  669. extern const bfd_target m68k_aout_linux_vec;
  670. extern const bfd_target m68k_aout_nbsd_vec;
  671. extern const bfd_target m68k_aout_newsos3_vec;
  672. extern const bfd_target m68k_coff_vec;
  673. extern const bfd_target m68k_coff_apollo_vec;
  674. extern const bfd_target m68k_coff_aux_vec;
  675. extern const bfd_target m68k_coff_sysv_vec;
  676. extern const bfd_target m68k_coff_un_vec;
  677. extern const bfd_target m68k_elf32_vec;
  678. extern const bfd_target m68k_versados_vec;
  679. extern const bfd_target m88k_aout_mach3_vec;
  680. extern const bfd_target m88k_aout_obsd_vec;
  681. extern const bfd_target m88k_coff_bcs_vec;
  682. extern const bfd_target m88k_elf32_vec;
  683. extern const bfd_target mach_o_be_vec;
  684. extern const bfd_target mach_o_le_vec;
  685. extern const bfd_target mach_o_fat_vec;
  686. extern const bfd_target mcore_elf32_be_vec;
  687. extern const bfd_target mcore_elf32_le_vec;
  688. extern const bfd_target mcore_pe_be_vec;
  689. extern const bfd_target mcore_pe_le_vec;
  690. extern const bfd_target mcore_pei_be_vec;
  691. extern const bfd_target mcore_pei_le_vec;
  692. extern const bfd_target mep_elf32_vec;
  693. extern const bfd_target mep_elf32_le_vec;
  694. extern const bfd_target metag_elf32_vec;
  695. extern const bfd_target microblaze_elf32_vec;
  696. extern const bfd_target microblaze_elf32_le_vec;
  697. extern const bfd_target mips_aout_be_vec;
  698. extern const bfd_target mips_aout_le_vec;
  699. extern const bfd_target mips_ecoff_be_vec;
  700. extern const bfd_target mips_ecoff_le_vec;
  701. extern const bfd_target mips_ecoff_bele_vec;
  702. extern const bfd_target mips_elf32_be_vec;
  703. extern const bfd_target mips_elf32_le_vec;
  704. extern const bfd_target mips_elf32_n_be_vec;
  705. extern const bfd_target mips_elf32_n_le_vec;
  706. extern const bfd_target mips_elf32_ntrad_be_vec;
  707. extern const bfd_target mips_elf32_ntrad_le_vec;
  708. extern const bfd_target mips_elf32_ntradfbsd_be_vec;
  709. extern const bfd_target mips_elf32_ntradfbsd_le_vec;
  710. extern const bfd_target mips_elf32_trad_be_vec;
  711. extern const bfd_target mips_elf32_trad_le_vec;
  712. extern const bfd_target mips_elf32_tradfbsd_be_vec;
  713. extern const bfd_target mips_elf32_tradfbsd_le_vec;
  714. extern const bfd_target mips_elf32_vxworks_be_vec;
  715. extern const bfd_target mips_elf32_vxworks_le_vec;
  716. extern const bfd_target mips_elf64_be_vec;
  717. extern const bfd_target mips_elf64_le_vec;
  718. extern const bfd_target mips_elf64_trad_be_vec;
  719. extern const bfd_target mips_elf64_trad_le_vec;
  720. extern const bfd_target mips_elf64_tradfbsd_be_vec;
  721. extern const bfd_target mips_elf64_tradfbsd_le_vec;
  722. extern const bfd_target mips_pe_le_vec;
  723. extern const bfd_target mips_pei_le_vec;
  724. extern const bfd_target mmix_elf64_vec;
  725. extern const bfd_target mmix_mmo_vec;
  726. extern const bfd_target mn10200_elf32_vec;
  727. extern const bfd_target mn10300_elf32_vec;
  728. extern const bfd_target moxie_elf32_be_vec;
  729. extern const bfd_target moxie_elf32_le_vec;
  730. extern const bfd_target msp430_elf32_vec;
  731. extern const bfd_target msp430_elf32_ti_vec;
  732. extern const bfd_target mt_elf32_vec;
  733. extern const bfd_target nds32_elf32_be_vec;
  734. extern const bfd_target nds32_elf32_le_vec;
  735. extern const bfd_target nds32_elf32_linux_be_vec;
  736. extern const bfd_target nds32_elf32_linux_le_vec;
  737. extern const bfd_target nios2_elf32_be_vec;
  738. extern const bfd_target nios2_elf32_le_vec;
  739. extern const bfd_target ns32k_aout_pc532mach_vec;
  740. extern const bfd_target ns32k_aout_pc532nbsd_vec;
  741. extern const bfd_target oasys_vec;
  742. extern const bfd_target or1k_elf32_vec;
  743. extern const bfd_target pdp11_aout_vec;
  744. extern const bfd_target pef_vec;
  745. extern const bfd_target pef_xlib_vec;
  746. extern const bfd_target pj_elf32_vec;
  747. extern const bfd_target pj_elf32_le_vec;
  748. extern const bfd_target plugin_vec;
  749. extern const bfd_target powerpc_boot_vec;
  750. extern const bfd_target powerpc_elf32_vec;
  751. extern const bfd_target powerpc_elf32_le_vec;
  752. extern const bfd_target powerpc_elf32_fbsd_vec;
  753. extern const bfd_target powerpc_elf32_vxworks_vec;
  754. extern const bfd_target powerpc_elf64_vec;
  755. extern const bfd_target powerpc_elf64_le_vec;
  756. extern const bfd_target powerpc_elf64_fbsd_vec;
  757. extern const bfd_target powerpc_nlm32_vec;
  758. extern const bfd_target powerpc_pe_vec;
  759. extern const bfd_target powerpc_pe_le_vec;
  760. extern const bfd_target powerpc_pei_vec;
  761. extern const bfd_target powerpc_pei_le_vec;
  762. extern const bfd_target powerpc_xcoff_vec;
  763. extern const bfd_target rl78_elf32_vec;
  764. extern const bfd_target rs6000_xcoff64_vec;
  765. extern const bfd_target rs6000_xcoff64_aix_vec;
  766. extern const bfd_target rs6000_xcoff_vec;
  767. extern const bfd_target rx_elf32_be_vec;
  768. extern const bfd_target rx_elf32_be_ns_vec;
  769. extern const bfd_target rx_elf32_le_vec;
  770. extern const bfd_target s390_elf32_vec;
  771. extern const bfd_target s390_elf64_vec;
  772. extern const bfd_target score_elf32_be_vec;
  773. extern const bfd_target score_elf32_le_vec;
  774. extern const bfd_target sh64_elf32_vec;
  775. extern const bfd_target sh64_elf32_le_vec;
  776. extern const bfd_target sh64_elf32_linux_vec;
  777. extern const bfd_target sh64_elf32_linux_be_vec;
  778. extern const bfd_target sh64_elf32_nbsd_vec;
  779. extern const bfd_target sh64_elf32_nbsd_le_vec;
  780. extern const bfd_target sh64_elf64_vec;
  781. extern const bfd_target sh64_elf64_le_vec;
  782. extern const bfd_target sh64_elf64_linux_vec;
  783. extern const bfd_target sh64_elf64_linux_be_vec;
  784. extern const bfd_target sh64_elf64_nbsd_vec;
  785. extern const bfd_target sh64_elf64_nbsd_le_vec;
  786. extern const bfd_target sh_coff_vec;
  787. extern const bfd_target sh_coff_le_vec;
  788. extern const bfd_target sh_coff_small_vec;
  789. extern const bfd_target sh_coff_small_le_vec;
  790. extern const bfd_target sh_elf32_vec;
  791. extern const bfd_target sh_elf32_le_vec;
  792. extern const bfd_target sh_elf32_fdpic_be_vec;
  793. extern const bfd_target sh_elf32_fdpic_le_vec;
  794. extern const bfd_target sh_elf32_linux_vec;
  795. extern const bfd_target sh_elf32_linux_be_vec;
  796. extern const bfd_target sh_elf32_nbsd_vec;
  797. extern const bfd_target sh_elf32_nbsd_le_vec;
  798. extern const bfd_target sh_elf32_symbian_le_vec;
  799. extern const bfd_target sh_elf32_vxworks_vec;
  800. extern const bfd_target sh_elf32_vxworks_le_vec;
  801. extern const bfd_target sh_pe_le_vec;
  802. extern const bfd_target sh_pei_le_vec;
  803. extern const bfd_target sparc_aout_le_vec;
  804. extern const bfd_target sparc_aout_linux_vec;
  805. extern const bfd_target sparc_aout_lynx_vec;
  806. extern const bfd_target sparc_aout_nbsd_vec;
  807. extern const bfd_target sparc_aout_sunos_be_vec;
  808. extern const bfd_target sparc_coff_vec;
  809. extern const bfd_target sparc_coff_lynx_vec;
  810. extern const bfd_target sparc_elf32_vec;
  811. extern const bfd_target sparc_elf32_sol2_vec;
  812. extern const bfd_target sparc_elf32_vxworks_vec;
  813. extern const bfd_target sparc_elf64_vec;
  814. extern const bfd_target sparc_elf64_fbsd_vec;
  815. extern const bfd_target sparc_elf64_sol2_vec;
  816. extern const bfd_target sparc_nlm32_vec;
  817. extern const bfd_target spu_elf32_vec;
  818. extern const bfd_target sym_vec;
  819. extern const bfd_target tic30_aout_vec;
  820. extern const bfd_target tic30_coff_vec;
  821. extern const bfd_target tic4x_coff0_vec;
  822. extern const bfd_target tic4x_coff0_beh_vec;
  823. extern const bfd_target tic4x_coff1_vec;
  824. extern const bfd_target tic4x_coff1_beh_vec;
  825. extern const bfd_target tic4x_coff2_vec;
  826. extern const bfd_target tic4x_coff2_beh_vec;
  827. extern const bfd_target tic54x_coff0_vec;
  828. extern const bfd_target tic54x_coff0_beh_vec;
  829. extern const bfd_target tic54x_coff1_vec;
  830. extern const bfd_target tic54x_coff1_beh_vec;
  831. extern const bfd_target tic54x_coff2_vec;
  832. extern const bfd_target tic54x_coff2_beh_vec;
  833. extern const bfd_target tic6x_elf32_be_vec;
  834. extern const bfd_target tic6x_elf32_le_vec;
  835. extern const bfd_target tic6x_elf32_c6000_be_vec;
  836. extern const bfd_target tic6x_elf32_c6000_le_vec;
  837. extern const bfd_target tic6x_elf32_linux_be_vec;
  838. extern const bfd_target tic6x_elf32_linux_le_vec;
  839. extern const bfd_target tic80_coff_vec;
  840. extern const bfd_target tilegx_elf32_be_vec;
  841. extern const bfd_target tilegx_elf32_le_vec;
  842. extern const bfd_target tilegx_elf64_be_vec;
  843. extern const bfd_target tilegx_elf64_le_vec;
  844. extern const bfd_target tilepro_elf32_vec;
  845. extern const bfd_target v800_elf32_vec;
  846. extern const bfd_target v850_elf32_vec;
  847. extern const bfd_target ft32_elf32_vec;
  848. extern const bfd_target vax_aout_1knbsd_vec;
  849. extern const bfd_target vax_aout_bsd_vec;
  850. extern const bfd_target vax_aout_nbsd_vec;
  851. extern const bfd_target vax_elf32_vec;
  852. extern const bfd_target visium_elf32_vec;
  853. extern const bfd_target w65_coff_vec;
  854. extern const bfd_target we32k_coff_vec;
  855. extern const bfd_target x86_64_coff_vec;
  856. extern const bfd_target x86_64_elf32_vec;
  857. extern const bfd_target x86_64_elf32_nacl_vec;
  858. extern const bfd_target x86_64_elf64_vec;
  859. extern const bfd_target x86_64_elf64_cloudabi_vec;
  860. extern const bfd_target x86_64_elf64_fbsd_vec;
  861. extern const bfd_target x86_64_elf64_nacl_vec;
  862. extern const bfd_target x86_64_elf64_sol2_vec;
  863. extern const bfd_target x86_64_mach_o_vec;
  864. extern const bfd_target x86_64_pe_vec;
  865. extern const bfd_target x86_64_pe_be_vec;
  866. extern const bfd_target x86_64_pei_vec;
  867. extern const bfd_target xc16x_elf32_vec;
  868. extern const bfd_target xgate_elf32_vec;
  869. extern const bfd_target xstormy16_elf32_vec;
  870. extern const bfd_target xtensa_elf32_be_vec;
  871. extern const bfd_target xtensa_elf32_le_vec;
  872. extern const bfd_target z80_coff_vec;
  873. extern const bfd_target z8k_coff_vec;
  874. /* These are always included. */
  875. extern const bfd_target srec_vec;
  876. extern const bfd_target symbolsrec_vec;
  877. extern const bfd_target verilog_vec;
  878. extern const bfd_target tekhex_vec;
  879. extern const bfd_target binary_vec;
  880. extern const bfd_target ihex_vec;
  881. /* All of the xvecs for core files. */
  882. extern const bfd_target core_aix386_vec;
  883. extern const bfd_target core_cisco_be_vec;
  884. extern const bfd_target core_cisco_le_vec;
  885. extern const bfd_target core_hppabsd_vec;
  886. extern const bfd_target core_hpux_vec;
  887. extern const bfd_target core_irix_vec;
  888. extern const bfd_target core_netbsd_vec;
  889. extern const bfd_target core_osf_vec;
  890. extern const bfd_target core_ptrace_vec;
  891. extern const bfd_target core_sco5_vec;
  892. extern const bfd_target core_trad_vec;
  893. static const bfd_target * const _bfd_target_vector[] =
  894. {
  895. #ifdef SELECT_VECS
  896. SELECT_VECS,
  897. #else /* not SELECT_VECS */
  898. #ifdef DEFAULT_VECTOR
  899. &DEFAULT_VECTOR,
  900. #endif
  901. /* This list is alphabetized to make it easy to compare
  902. with other vector lists -- the decls above and
  903. the case statement in configure.ac.
  904. Try to keep it in order when adding new targets, and
  905. use a name of the form <cpu>_<format>_<other>_<endian>_vec.
  906. Note that sorting is done as if _<endian>_vec wasn't present.
  907. Vectors that don't compile on all systems, or aren't finished,
  908. should have an entry here with #if 0 around it, to show that
  909. it wasn't omitted by mistake. */
  910. #ifdef BFD64
  911. &aarch64_elf32_be_vec,
  912. &aarch64_elf32_le_vec,
  913. &aarch64_elf64_be_vec,
  914. &aarch64_elf64_le_vec,
  915. #endif
  916. #ifdef BFD64
  917. &alpha_ecoff_le_vec,
  918. &alpha_elf64_vec,
  919. &alpha_elf64_fbsd_vec,
  920. &alpha_nlm32_vec,
  921. &alpha_vms_vec,
  922. #endif
  923. &alpha_vms_lib_txt_vec,
  924. &am33_elf32_linux_vec,
  925. &aout0_be_vec,
  926. #ifdef BFD64
  927. &aout64_vec, /* Only compiled if host has long-long support. */
  928. #endif
  929. #if 0
  930. /* Since a.out files lack decent magic numbers, no way to recognize
  931. which kind of a.out file it is. */
  932. &aout_vec,
  933. #endif
  934. &aout_adobe_vec,
  935. &arc_elf32_be_vec,
  936. &arc_elf32_le_vec,
  937. #if 0
  938. /* We have no way of distinguishing these from other a.out variants. */
  939. &arm_aout_be_vec,
  940. &arm_aout_le_vec,
  941. #endif
  942. &arm_aout_nbsd_vec,
  943. #if 0
  944. /* We have no way of distinguishing these from other a.out variants. */
  945. &arm_aout_riscix_vec,
  946. #endif
  947. &arm_coff_be_vec,
  948. &arm_coff_le_vec,
  949. &arm_elf32_be_vec,
  950. &arm_elf32_le_vec,
  951. &arm_elf32_symbian_be_vec,
  952. &arm_elf32_symbian_le_vec,
  953. &arm_elf32_vxworks_be_vec,
  954. &arm_elf32_vxworks_le_vec,
  955. &arm_pe_be_vec,
  956. &arm_pe_le_vec,
  957. &arm_pe_epoc_be_vec,
  958. &arm_pe_epoc_le_vec,
  959. &arm_pe_wince_be_vec,
  960. &arm_pe_wince_le_vec,
  961. &arm_pei_be_vec,
  962. &arm_pei_le_vec,
  963. &arm_pei_epoc_be_vec,
  964. &arm_pei_epoc_le_vec,
  965. &arm_pei_wince_be_vec,
  966. &arm_pei_wince_le_vec,
  967. &avr_elf32_vec,
  968. &bfin_elf32_vec,
  969. &bfin_elf32_fdpic_vec,
  970. &bout_be_vec,
  971. &bout_le_vec,
  972. &cr16_elf32_vec,
  973. &cr16c_elf32_vec,
  974. &cris_aout_vec,
  975. &cris_elf32_vec,
  976. &cris_elf32_us_vec,
  977. &crx_elf32_vec,
  978. &d10v_elf32_vec,
  979. &d30v_elf32_vec,
  980. &dlx_elf32_be_vec,
  981. /* This, and other vectors, may not be used in any *.mt configuration.
  982. But that does not mean they are unnecessary. If configured with
  983. --enable-targets=all, objdump or gdb should be able to examine
  984. the file even if we don't recognize the machine type. */
  985. &elf32_be_vec,
  986. &elf32_le_vec,
  987. #ifdef BFD64
  988. &elf64_be_vec,
  989. &elf64_le_vec,
  990. #endif
  991. &epiphany_elf32_vec,
  992. &fr30_elf32_vec,
  993. &frv_elf32_vec,
  994. &frv_elf32_fdpic_vec,
  995. &h8300_coff_vec,
  996. &h8300_elf32_vec,
  997. &h8300_elf32_linux_vec,
  998. &h8500_coff_vec,
  999. &hppa_elf32_vec,
  1000. &hppa_elf32_linux_vec,
  1001. &hppa_elf32_nbsd_vec,
  1002. #ifdef BFD64
  1003. &hppa_elf64_vec,
  1004. &hppa_elf64_linux_vec,
  1005. #endif
  1006. &hppa_som_vec,
  1007. &i370_elf32_vec,
  1008. &i386_aout_vec,
  1009. &i386_aout_bsd_vec,
  1010. #if 0
  1011. &i386_aout_dynix_vec,
  1012. #endif
  1013. &i386_aout_fbsd_vec,
  1014. #if 0
  1015. /* Since a.out files lack decent magic numbers, no way to recognize
  1016. which kind of a.out file it is. */
  1017. &i386_aout_linux_vec,
  1018. #endif
  1019. &i386_aout_lynx_vec,
  1020. #if 0
  1021. /* No distinguishing features for Mach 3 executables. */
  1022. &i386_aout_mach3_vec,
  1023. #endif
  1024. &i386_aout_nbsd_vec,
  1025. &i386_aout_os9k_vec,
  1026. &i386_coff_vec,
  1027. &i386_coff_go32_vec,
  1028. &i386_coff_go32stubbed_vec,
  1029. &i386_coff_lynx_vec,
  1030. &i386_elf32_vec,
  1031. &i386_elf32_fbsd_vec,
  1032. &i386_elf32_nacl_vec,
  1033. &i386_elf32_sol2_vec,
  1034. &i386_elf32_vxworks_vec,
  1035. &i386_mach_o_vec,
  1036. &i386_msdos_vec,
  1037. &i386_nlm32_vec,
  1038. &i386_pe_vec,
  1039. &i386_pei_vec,
  1040. &iamcu_elf32_vec,
  1041. &i860_coff_vec,
  1042. &i860_elf32_vec,
  1043. &i860_elf32_le_vec,
  1044. &i960_elf32_vec,
  1045. #ifdef BFD64
  1046. #if 0
  1047. &ia64_elf32_be_vec,
  1048. #endif
  1049. &ia64_elf32_hpux_be_vec,
  1050. &ia64_elf64_be_vec,
  1051. &ia64_elf64_le_vec,
  1052. &ia64_elf64_hpux_be_vec,
  1053. &ia64_elf64_vms_vec,
  1054. &ia64_pei_vec,
  1055. #endif
  1056. &icoff_be_vec,
  1057. &icoff_le_vec,
  1058. &ieee_vec,
  1059. &ip2k_elf32_vec,
  1060. &iq2000_elf32_vec,
  1061. #ifdef BFD64
  1062. &k1om_elf64_vec,
  1063. &k1om_elf64_fbsd_vec,
  1064. &l1om_elf64_vec,
  1065. &l1om_elf64_fbsd_vec,
  1066. #endif
  1067. &lm32_elf32_vec,
  1068. &m32c_elf32_vec,
  1069. &m32r_elf32_vec,
  1070. &m32r_elf32_le_vec,
  1071. &m32r_elf32_linux_vec,
  1072. &m32r_elf32_linux_le_vec,
  1073. &m68hc11_elf32_vec,
  1074. &m68hc12_elf32_vec,
  1075. #if 0
  1076. &m68k_aout_4knbsd_vec,
  1077. /* Clashes with sparc_aout_sunos_be_vec magic no. */
  1078. &m68k_aout_hp300bsd_vec,
  1079. #endif
  1080. &m68k_aout_hp300hpux_vec,
  1081. #if 0
  1082. /* Since a.out files lack decent magic numbers, no way to recognize
  1083. which kind of a.out file it is. */
  1084. &m68k_aout_linux_vec,
  1085. #endif
  1086. &m68k_aout_nbsd_vec,
  1087. &m68k_aout_newsos3_vec,
  1088. &m68k_coff_vec,
  1089. #if 0
  1090. &m68k_coff_apollo_vec,
  1091. &m68k_coff_aux_vec,
  1092. #endif
  1093. &m68k_coff_sysv_vec,
  1094. &m68k_coff_un_vec,
  1095. &m68k_elf32_vec,
  1096. &m68k_versados_vec,
  1097. &m88k_aout_mach3_vec,
  1098. &m88k_aout_obsd_vec,
  1099. &m88k_coff_bcs_vec,
  1100. &m88k_elf32_vec,
  1101. &mach_o_be_vec,
  1102. &mach_o_le_vec,
  1103. &mach_o_fat_vec,
  1104. &mcore_elf32_be_vec,
  1105. &mcore_elf32_le_vec,
  1106. &mcore_pe_be_vec,
  1107. &mcore_pe_le_vec,
  1108. &mcore_pei_be_vec,
  1109. &mcore_pei_le_vec,
  1110. &mep_elf32_vec,
  1111. &metag_elf32_vec,
  1112. &microblaze_elf32_vec,
  1113. #if 0
  1114. /* No one seems to use this. */
  1115. &mips_aout_be_vec,
  1116. #endif
  1117. &mips_aout_le_vec,
  1118. &mips_ecoff_be_vec,
  1119. &mips_ecoff_le_vec,
  1120. &mips_ecoff_bele_vec,
  1121. #ifdef BFD64
  1122. &mips_elf32_be_vec,
  1123. &mips_elf32_le_vec,
  1124. &mips_elf32_n_be_vec,
  1125. &mips_elf32_n_le_vec,
  1126. &mips_elf32_ntrad_be_vec,
  1127. &mips_elf32_ntrad_le_vec,
  1128. &mips_elf32_ntradfbsd_be_vec,
  1129. &mips_elf32_ntradfbsd_le_vec,
  1130. &mips_elf32_trad_be_vec,
  1131. &mips_elf32_trad_le_vec,
  1132. &mips_elf32_tradfbsd_be_vec,
  1133. &mips_elf32_tradfbsd_le_vec,
  1134. &mips_elf32_vxworks_be_vec,
  1135. &mips_elf32_vxworks_le_vec,
  1136. &mips_elf64_be_vec,
  1137. &mips_elf64_le_vec,
  1138. &mips_elf64_trad_be_vec,
  1139. &mips_elf64_trad_le_vec,
  1140. &mips_elf64_tradfbsd_be_vec,
  1141. &mips_elf64_tradfbsd_le_vec,
  1142. #endif
  1143. &mips_pe_le_vec,
  1144. &mips_pei_le_vec,
  1145. #ifdef BFD64
  1146. &mmix_elf64_vec,
  1147. &mmix_mmo_vec,
  1148. #endif
  1149. &mn10200_elf32_vec,
  1150. &mn10300_elf32_vec,
  1151. &moxie_elf32_be_vec,
  1152. &moxie_elf32_le_vec,
  1153. &msp430_elf32_vec,
  1154. &msp430_elf32_ti_vec,
  1155. &mt_elf32_vec,
  1156. &nds32_elf32_be_vec,
  1157. &nds32_elf32_le_vec,
  1158. &nds32_elf32_linux_be_vec,
  1159. &nds32_elf32_linux_le_vec,
  1160. &nios2_elf32_be_vec,
  1161. &nios2_elf32_le_vec,
  1162. &ns32k_aout_pc532mach_vec,
  1163. &ns32k_aout_pc532nbsd_vec,
  1164. #if 0
  1165. /* We have no oasys tools anymore, so we can't test any of this
  1166. anymore. If you want to test the stuff yourself, go ahead...
  1167. steve@cygnus.com
  1168. Worse, since there is no magic number for archives, there
  1169. can be annoying target mis-matches. */
  1170. &oasys_vec,
  1171. #endif
  1172. &or1k_elf32_vec,
  1173. &pdp11_aout_vec,
  1174. &pef_vec,
  1175. &pef_xlib_vec,
  1176. &pj_elf32_vec,
  1177. &pj_elf32_le_vec,
  1178. #if BFD_SUPPORTS_PLUGINS
  1179. &plugin_vec,
  1180. #endif
  1181. &powerpc_boot_vec,
  1182. &powerpc_elf32_vec,
  1183. &powerpc_elf32_le_vec,
  1184. &powerpc_elf32_fbsd_vec,
  1185. &powerpc_elf32_vxworks_vec,
  1186. #ifdef BFD64
  1187. &powerpc_elf64_vec,
  1188. &powerpc_elf64_le_vec,
  1189. &powerpc_elf64_fbsd_vec,
  1190. #endif
  1191. &powerpc_nlm32_vec,
  1192. &powerpc_pe_vec,
  1193. &powerpc_pe_le_vec,
  1194. &powerpc_pei_vec,
  1195. &powerpc_pei_le_vec,
  1196. #if 0
  1197. /* This has the same magic number as RS/6000. */
  1198. &powerpc_xcoff_vec,
  1199. #endif
  1200. &rl78_elf32_vec,
  1201. #ifdef BFD64
  1202. &rs6000_xcoff64_vec,
  1203. &rs6000_xcoff64_aix_vec,
  1204. #endif
  1205. &rs6000_xcoff_vec,
  1206. &rx_elf32_be_vec,
  1207. &rx_elf32_be_ns_vec,
  1208. &rx_elf32_le_vec,
  1209. &s390_elf32_vec,
  1210. #ifdef BFD64
  1211. &s390_elf64_vec,
  1212. #endif
  1213. #ifdef BFD64
  1214. &score_elf32_be_vec,
  1215. &score_elf32_le_vec,
  1216. #endif
  1217. #ifdef BFD64
  1218. &sh64_elf32_vec,
  1219. &sh64_elf32_le_vec,
  1220. &sh64_elf32_linux_vec,
  1221. &sh64_elf32_linux_be_vec,
  1222. &sh64_elf32_nbsd_vec,
  1223. &sh64_elf32_nbsd_le_vec,
  1224. &sh64_elf64_vec,
  1225. &sh64_elf64_le_vec,
  1226. &sh64_elf64_linux_vec,
  1227. &sh64_elf64_linux_be_vec,
  1228. &sh64_elf64_nbsd_vec,
  1229. &sh64_elf64_nbsd_le_vec,
  1230. #endif
  1231. &sh_coff_vec,
  1232. &sh_coff_le_vec,
  1233. &sh_coff_small_vec,
  1234. &sh_coff_small_le_vec,
  1235. &sh_elf32_vec,
  1236. &sh_elf32_le_vec,
  1237. &sh_elf32_fdpic_be_vec,
  1238. &sh_elf32_fdpic_le_vec,
  1239. &sh_elf32_linux_vec,
  1240. &sh_elf32_linux_be_vec,
  1241. &sh_elf32_nbsd_vec,
  1242. &sh_elf32_nbsd_le_vec,
  1243. &sh_elf32_symbian_le_vec,
  1244. &sh_elf32_vxworks_vec,
  1245. &sh_elf32_vxworks_le_vec,
  1246. &sh_pe_le_vec,
  1247. &sh_pei_le_vec,
  1248. &sparc_aout_le_vec,
  1249. &sparc_aout_linux_vec,
  1250. &sparc_aout_lynx_vec,
  1251. &sparc_aout_nbsd_vec,
  1252. &sparc_aout_sunos_be_vec,
  1253. &sparc_coff_vec,
  1254. &sparc_coff_lynx_vec,
  1255. &sparc_elf32_vec,
  1256. &sparc_elf32_sol2_vec,
  1257. &sparc_elf32_vxworks_vec,
  1258. #ifdef BFD64
  1259. &sparc_elf64_vec,
  1260. &sparc_elf64_fbsd_vec,
  1261. &sparc_elf64_sol2_vec,
  1262. #endif
  1263. &sparc_nlm32_vec,
  1264. &spu_elf32_vec,
  1265. &sym_vec,
  1266. &tic30_aout_vec,
  1267. &tic30_coff_vec,
  1268. &tic54x_coff0_beh_vec,
  1269. &tic54x_coff0_vec,
  1270. &tic54x_coff1_beh_vec,
  1271. &tic54x_coff1_vec,
  1272. &tic54x_coff2_beh_vec,
  1273. &tic54x_coff2_vec,
  1274. &tic6x_elf32_be_vec,
  1275. &tic6x_elf32_le_vec,
  1276. &tic80_coff_vec,
  1277. &tilegx_elf32_be_vec,
  1278. &tilegx_elf32_le_vec,
  1279. #ifdef BFD64
  1280. &tilegx_elf64_be_vec,
  1281. &tilegx_elf64_le_vec,
  1282. #endif
  1283. &tilepro_elf32_vec,
  1284. &ft32_elf32_vec,
  1285. &v800_elf32_vec,
  1286. &v850_elf32_vec,
  1287. &vax_aout_1knbsd_vec,
  1288. &vax_aout_bsd_vec,
  1289. &vax_aout_nbsd_vec,
  1290. &vax_elf32_vec,
  1291. &visium_elf32_vec,
  1292. &w65_coff_vec,
  1293. &we32k_coff_vec,
  1294. #ifdef BFD64
  1295. &x86_64_coff_vec,
  1296. &x86_64_elf32_vec,
  1297. &x86_64_elf32_nacl_vec,
  1298. &x86_64_elf64_vec,
  1299. &x86_64_elf64_cloudabi_vec,
  1300. &x86_64_elf64_fbsd_vec,
  1301. &x86_64_elf64_nacl_vec,
  1302. &x86_64_elf64_sol2_vec,
  1303. &x86_64_mach_o_vec,
  1304. &x86_64_pe_vec,
  1305. &x86_64_pe_be_vec,
  1306. &x86_64_pei_vec,
  1307. #endif
  1308. &xc16x_elf32_vec,
  1309. &xgate_elf32_vec,
  1310. &xstormy16_elf32_vec,
  1311. &xtensa_elf32_be_vec,
  1312. &xtensa_elf32_le_vec,
  1313. &z80_coff_vec,
  1314. &z8k_coff_vec,
  1315. #endif /* not SELECT_VECS */
  1316. /* Always support S-records, for convenience. */
  1317. &srec_vec,
  1318. &symbolsrec_vec,
  1319. /* And verilog. */
  1320. &verilog_vec,
  1321. /* And tekhex */
  1322. &tekhex_vec,
  1323. /* Likewise for binary output. */
  1324. &binary_vec,
  1325. /* Likewise for ihex. */
  1326. &ihex_vec,
  1327. /* Add any required traditional-core-file-handler. */
  1328. #ifdef AIX386_CORE
  1329. &core_aix386_vec,
  1330. #endif
  1331. #if 0
  1332. /* We don't include cisco_core_*_vec. Although it has a magic number,
  1333. the magic number isn't at the beginning of the file, and thus
  1334. might spuriously match other kinds of files. */
  1335. &core_cisco_be_vec,
  1336. &core_cisco_le_vec,
  1337. #endif
  1338. #ifdef HPPABSD_CORE
  1339. &core_hppabsd_vec,
  1340. #endif
  1341. #ifdef HPUX_CORE
  1342. &core_hpux_vec,
  1343. #endif
  1344. #ifdef IRIX_CORE
  1345. &core_irix_vec,
  1346. #endif
  1347. #ifdef NETBSD_CORE
  1348. &core_netbsd_vec,
  1349. #endif
  1350. #ifdef OSF_CORE
  1351. &core_osf_vec,
  1352. #endif
  1353. #ifdef PTRACE_CORE
  1354. &core_ptrace_vec,
  1355. #endif
  1356. #ifdef SCO5_CORE
  1357. &core_sco5_vec,
  1358. #endif
  1359. #ifdef TRAD_CORE
  1360. &core_trad_vec,
  1361. #endif
  1362. NULL /* end of list marker */
  1363. };
  1364. const bfd_target * const *bfd_target_vector = _bfd_target_vector;
  1365. /* bfd_default_vector[0] contains either the address of the default vector,
  1366. if there is one, or zero if there isn't. */
  1367. const bfd_target *bfd_default_vector[] = {
  1368. #ifdef DEFAULT_VECTOR
  1369. &DEFAULT_VECTOR,
  1370. #endif
  1371. NULL
  1372. };
  1373. /* bfd_associated_vector[] contains the associated target vectors used
  1374. to reduce the ambiguity in bfd_check_format_matches. */
  1375. static const bfd_target *_bfd_associated_vector[] = {
  1376. #ifdef ASSOCIATED_VECS
  1377. ASSOCIATED_VECS,
  1378. #endif
  1379. NULL
  1380. };
  1381. const bfd_target * const *bfd_associated_vector = _bfd_associated_vector;
  1382. /* When there is an ambiguous match, bfd_check_format_matches puts the
  1383. names of the matching targets in an array. This variable is the maximum
  1384. number of entries that the array could possibly need. */
  1385. const size_t _bfd_target_vector_entries = sizeof (_bfd_target_vector)/sizeof (*_bfd_target_vector);
  1386. /* This array maps configuration triplets onto BFD vectors. */
  1387. struct targmatch
  1388. {
  1389. /* The configuration triplet. */
  1390. const char *triplet;
  1391. /* The BFD vector. If this is NULL, then the vector is found by
  1392. searching forward for the next structure with a non NULL vector
  1393. field. */
  1394. const bfd_target *vector;
  1395. };
  1396. /* targmatch.h is built by Makefile out of config.bfd. */
  1397. static const struct targmatch bfd_target_match[] = {
  1398. #include "targmatch.h"
  1399. { NULL, NULL }
  1400. };
  1401. /* Find a target vector, given a name or configuration triplet. */
  1402. static const bfd_target *
  1403. find_target (const char *name)
  1404. {
  1405. const bfd_target * const *target;
  1406. const struct targmatch *match;
  1407. for (target = &bfd_target_vector[0]; *target != NULL; target++)
  1408. if (strcmp (name, (*target)->name) == 0)
  1409. return *target;
  1410. /* If we couldn't match on the exact name, try matching on the
  1411. configuration triplet. FIXME: We should run the triplet through
  1412. config.sub first, but that is hard. */
  1413. for (match = &bfd_target_match[0]; match->triplet != NULL; match++)
  1414. {
  1415. if (fnmatch (match->triplet, name, 0) == 0)
  1416. {
  1417. while (match->vector == NULL)
  1418. ++match;
  1419. return match->vector;
  1420. }
  1421. }
  1422. bfd_set_error (bfd_error_invalid_target);
  1423. return NULL;
  1424. }
  1425. /*
  1426. FUNCTION
  1427. bfd_set_default_target
  1428. SYNOPSIS
  1429. bfd_boolean bfd_set_default_target (const char *name);
  1430. DESCRIPTION
  1431. Set the default target vector to use when recognizing a BFD.
  1432. This takes the name of the target, which may be a BFD target
  1433. name or a configuration triplet.
  1434. */
  1435. bfd_boolean
  1436. bfd_set_default_target (const char *name)
  1437. {
  1438. const bfd_target *target;
  1439. if (bfd_default_vector[0] != NULL
  1440. && strcmp (name, bfd_default_vector[0]->name) == 0)
  1441. return TRUE;
  1442. target = find_target (name);
  1443. if (target == NULL)
  1444. return FALSE;
  1445. bfd_default_vector[0] = target;
  1446. return TRUE;
  1447. }
  1448. /*
  1449. FUNCTION
  1450. bfd_find_target
  1451. SYNOPSIS
  1452. const bfd_target *bfd_find_target (const char *target_name, bfd *abfd);
  1453. DESCRIPTION
  1454. Return a pointer to the transfer vector for the object target
  1455. named @var{target_name}. If @var{target_name} is <<NULL>>,
  1456. choose the one in the environment variable <<GNUTARGET>>; if
  1457. that is null or not defined, then choose the first entry in the
  1458. target list. Passing in the string "default" or setting the
  1459. environment variable to "default" will cause the first entry in
  1460. the target list to be returned, and "target_defaulted" will be
  1461. set in the BFD if @var{abfd} isn't <<NULL>>. This causes
  1462. <<bfd_check_format>> to loop over all the targets to find the
  1463. one that matches the file being read.
  1464. */
  1465. const bfd_target *
  1466. bfd_find_target (const char *target_name, bfd *abfd)
  1467. {
  1468. const char *targname;
  1469. const bfd_target *target;
  1470. if (target_name != NULL)
  1471. targname = target_name;
  1472. else
  1473. targname = getenv ("GNUTARGET");
  1474. /* This is safe; the vector cannot be null. */
  1475. if (targname == NULL || strcmp (targname, "default") == 0)
  1476. {
  1477. if (bfd_default_vector[0] != NULL)
  1478. target = bfd_default_vector[0];
  1479. else
  1480. target = bfd_target_vector[0];
  1481. if (abfd)
  1482. {
  1483. abfd->xvec = target;
  1484. abfd->target_defaulted = TRUE;
  1485. }
  1486. return target;
  1487. }
  1488. if (abfd)
  1489. abfd->target_defaulted = FALSE;
  1490. target = find_target (targname);
  1491. if (target == NULL)
  1492. return NULL;
  1493. if (abfd)
  1494. abfd->xvec = target;
  1495. return target;
  1496. }
  1497. /* Helper function for bfd_get_target_info to determine the target's
  1498. architecture. This method handles bfd internal target names as
  1499. tuples and triplets. */
  1500. static bfd_boolean
  1501. _bfd_find_arch_match (const char *tname, const char **arch,
  1502. const char **def_target_arch)
  1503. {
  1504. if (!arch)
  1505. return FALSE;
  1506. while (*arch != NULL)
  1507. {
  1508. const char *in_a = strstr (*arch, tname);
  1509. char end_ch = (in_a ? in_a[strlen (tname)] : 0);
  1510. if (in_a && (in_a == *arch || in_a[-1] == ':')
  1511. && end_ch == 0)
  1512. {
  1513. *def_target_arch = *arch;
  1514. return TRUE;
  1515. }
  1516. arch++;
  1517. }
  1518. return FALSE;
  1519. }
  1520. /*
  1521. FUNCTION
  1522. bfd_get_target_info
  1523. SYNOPSIS
  1524. const bfd_target *bfd_get_target_info (const char *target_name,
  1525. bfd *abfd,
  1526. bfd_boolean *is_bigendian,
  1527. int *underscoring,
  1528. const char **def_target_arch);
  1529. DESCRIPTION
  1530. Return a pointer to the transfer vector for the object target
  1531. named @var{target_name}. If @var{target_name} is <<NULL>>,
  1532. choose the one in the environment variable <<GNUTARGET>>; if
  1533. that is null or not defined, then choose the first entry in the
  1534. target list. Passing in the string "default" or setting the
  1535. environment variable to "default" will cause the first entry in
  1536. the target list to be returned, and "target_defaulted" will be
  1537. set in the BFD if @var{abfd} isn't <<NULL>>. This causes
  1538. <<bfd_check_format>> to loop over all the targets to find the
  1539. one that matches the file being read.
  1540. If @var{is_bigendian} is not <<NULL>>, then set this value to target's
  1541. endian mode. True for big-endian, FALSE for little-endian or for
  1542. invalid target.
  1543. If @var{underscoring} is not <<NULL>>, then set this value to target's
  1544. underscoring mode. Zero for none-underscoring, -1 for invalid target,
  1545. else the value of target vector's symbol underscoring.
  1546. If @var{def_target_arch} is not <<NULL>>, then set it to the architecture
  1547. string specified by the target_name.
  1548. */
  1549. const bfd_target *
  1550. bfd_get_target_info (const char *target_name, bfd *abfd,
  1551. bfd_boolean *is_bigendian,
  1552. int *underscoring, const char **def_target_arch)
  1553. {
  1554. const bfd_target *target_vec;
  1555. if (is_bigendian)
  1556. *is_bigendian = FALSE;
  1557. if (underscoring)
  1558. *underscoring = -1;
  1559. if (def_target_arch)
  1560. *def_target_arch = NULL;
  1561. target_vec = bfd_find_target (target_name, abfd);
  1562. if (! target_vec)
  1563. return NULL;
  1564. if (is_bigendian)
  1565. *is_bigendian = ((target_vec->byteorder == BFD_ENDIAN_BIG) ? TRUE
  1566. : FALSE);
  1567. if (underscoring)
  1568. *underscoring = ((int) target_vec->symbol_leading_char) & 0xff;
  1569. if (def_target_arch)
  1570. {
  1571. const char *tname = target_vec->name;
  1572. const char **arches = bfd_arch_list ();
  1573. if (arches && tname)
  1574. {
  1575. char *hyp = strchr (tname, '-');
  1576. if (hyp != NULL)
  1577. {
  1578. tname = ++hyp;
  1579. /* Make sure we detect architecture names
  1580. for triplets like "pe-arm-wince-little". */
  1581. if (!_bfd_find_arch_match (tname, arches, def_target_arch))
  1582. {
  1583. char new_tname[50];
  1584. strcpy (new_tname, hyp);
  1585. while ((hyp = strrchr (new_tname, '-')) != NULL)
  1586. {
  1587. *hyp = 0;
  1588. if (_bfd_find_arch_match (new_tname, arches,
  1589. def_target_arch))
  1590. break;
  1591. }
  1592. }
  1593. }
  1594. else
  1595. _bfd_find_arch_match (tname, arches, def_target_arch);
  1596. }
  1597. if (arches)
  1598. free (arches);
  1599. }
  1600. return target_vec;
  1601. }
  1602. /*
  1603. FUNCTION
  1604. bfd_target_list
  1605. SYNOPSIS
  1606. const char ** bfd_target_list (void);
  1607. DESCRIPTION
  1608. Return a freshly malloced NULL-terminated
  1609. vector of the names of all the valid BFD targets. Do not
  1610. modify the names.
  1611. */
  1612. const char **
  1613. bfd_target_list (void)
  1614. {
  1615. int vec_length = 0;
  1616. bfd_size_type amt;
  1617. const bfd_target * const *target;
  1618. const char **name_list, **name_ptr;
  1619. for (target = &bfd_target_vector[0]; *target != NULL; target++)
  1620. vec_length++;
  1621. amt = (vec_length + 1) * sizeof (char **);
  1622. name_ptr = name_list = (const char **) bfd_malloc (amt);
  1623. if (name_list == NULL)
  1624. return NULL;
  1625. for (target = &bfd_target_vector[0]; *target != NULL; target++)
  1626. if (target == &bfd_target_vector[0]
  1627. || *target != bfd_target_vector[0])
  1628. *name_ptr++ = (*target)->name;
  1629. *name_ptr = NULL;
  1630. return name_list;
  1631. }
  1632. /*
  1633. FUNCTION
  1634. bfd_seach_for_target
  1635. SYNOPSIS
  1636. const bfd_target *bfd_search_for_target
  1637. (int (*search_func) (const bfd_target *, void *),
  1638. void *);
  1639. DESCRIPTION
  1640. Return a pointer to the first transfer vector in the list of
  1641. transfer vectors maintained by BFD that produces a non-zero
  1642. result when passed to the function @var{search_func}. The
  1643. parameter @var{data} is passed, unexamined, to the search
  1644. function.
  1645. */
  1646. const bfd_target *
  1647. bfd_search_for_target (int (*search_func) (const bfd_target *, void *),
  1648. void *data)
  1649. {
  1650. const bfd_target * const *target;
  1651. for (target = bfd_target_vector; *target != NULL; target ++)
  1652. if (search_func (*target, data))
  1653. return *target;
  1654. return NULL;
  1655. }
  1656. /*
  1657. FUNCTION
  1658. bfd_flavour_name
  1659. SYNOPSIS
  1660. const char *bfd_flavour_name (enum bfd_flavour flavour);
  1661. DESCRIPTION
  1662. Return the string form of @var{flavour}.
  1663. */
  1664. const char *
  1665. bfd_flavour_name (enum bfd_flavour flavour)
  1666. {
  1667. switch (flavour)
  1668. {
  1669. case bfd_target_unknown_flavour: return "unknown file format";
  1670. case bfd_target_aout_flavour: return "a.out";
  1671. case bfd_target_coff_flavour: return "COFF";
  1672. case bfd_target_ecoff_flavour: return "ECOFF";
  1673. case bfd_target_xcoff_flavour: return "XCOFF";
  1674. case bfd_target_elf_flavour: return "ELF";
  1675. case bfd_target_ieee_flavour: return "IEEE";
  1676. case bfd_target_nlm_flavour: return "NLM";
  1677. case bfd_target_oasys_flavour: return "Oasys";
  1678. case bfd_target_tekhex_flavour: return "Tekhex";
  1679. case bfd_target_srec_flavour: return "Srec";
  1680. case bfd_target_verilog_flavour: return "Verilog";
  1681. case bfd_target_ihex_flavour: return "Ihex";
  1682. case bfd_target_som_flavour: return "SOM";
  1683. case bfd_target_os9k_flavour: return "OS9K";
  1684. case bfd_target_versados_flavour: return "Versados";
  1685. case bfd_target_msdos_flavour: return "MSDOS";
  1686. case bfd_target_ovax_flavour: return "Ovax";
  1687. case bfd_target_evax_flavour: return "Evax";
  1688. case bfd_target_mmo_flavour: return "mmo";
  1689. case bfd_target_mach_o_flavour: return "MACH_O";
  1690. case bfd_target_pef_flavour: return "PEF";
  1691. case bfd_target_pef_xlib_flavour: return "PEF_XLIB";
  1692. case bfd_target_sym_flavour: return "SYM";
  1693. /* There is no "default" case here so that -Wswitch (part of -Wall)
  1694. catches missing entries. */
  1695. }
  1696. abort ();
  1697. }