11592Srgrimes/* Generic target-file-type support for the BFD library.
21592Srgrimes   Copyright (C) 1990-2017 Free Software Foundation, Inc.
31592Srgrimes   Written by Cygnus Support.
41592Srgrimes
51592Srgrimes   This file is part of BFD, the Binary File Descriptor library.
61592Srgrimes
71592Srgrimes   This program is free software; you can redistribute it and/or modify
81592Srgrimes   it under the terms of the GNU General Public License as published by
91592Srgrimes   the Free Software Foundation; either version 3 of the License, or
101592Srgrimes   (at your option) any later version.
111592Srgrimes
121592Srgrimes   This program is distributed in the hope that it will be useful,
131592Srgrimes   but WITHOUT ANY WARRANTY; without even the implied warranty of
141592Srgrimes   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
151592Srgrimes   GNU General Public License for more details.
161592Srgrimes
171592Srgrimes   You should have received a copy of the GNU General Public License
181592Srgrimes   along with this program; if not, write to the Free Software
191592Srgrimes   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
201592Srgrimes   MA 02110-1301, USA.  */
211592Srgrimes
221592Srgrimes#include "sysdep.h"
231592Srgrimes#include "bfd.h"
241592Srgrimes#include "libbfd.h"
251592Srgrimes#include "fnmatch.h"
261592Srgrimes
271592Srgrimes/*
281592Srgrimes   It's okay to see some:
291592Srgrimes#if 0
301592Srgrimes   directives in this source file, as targets.c uses them to exclude
311592Srgrimes   certain BFD vectors.  This comment is specially formatted to catch
321592Srgrimes   users who grep for ^#if 0, so please keep it this way!
331592Srgrimes*/
341592Srgrimes
351592Srgrimes/*
361592SrgrimesSECTION
371592Srgrimes	Targets
381592Srgrimes
391592SrgrimesDESCRIPTION
401592Srgrimes	Each port of BFD to a different machine requires the creation
411592Srgrimes	of a target back end. All the back end provides to the root
421592Srgrimes	part of BFD is a structure containing pointers to functions
431592Srgrimes	which perform certain low level operations on files. BFD
441592Srgrimes	translates the applications's requests through a pointer into
451592Srgrimes	calls to the back end routines.
461592Srgrimes
471592Srgrimes	When a file is opened with <<bfd_openr>>, its format and
481592Srgrimes	target are unknown. BFD uses various mechanisms to determine
491592Srgrimes	how to interpret the file. The operations performed are:
501592Srgrimes
511592Srgrimes	o Create a BFD by calling the internal routine
521592Srgrimes	<<_bfd_new_bfd>>, then call <<bfd_find_target>> with the
531592Srgrimes	target string supplied to <<bfd_openr>> and the new BFD pointer.
541592Srgrimes
551592Srgrimes	o If a null target string was provided to <<bfd_find_target>>,
561592Srgrimes	look up the environment variable <<GNUTARGET>> and use
571592Srgrimes	that as the target string.
581592Srgrimes
591592Srgrimes	o If the target string is still <<NULL>>, or the target string is
601592Srgrimes	<<default>>, then use the first item in the target vector
611592Srgrimes	as the target type, and set <<target_defaulted>> in the BFD to
621592Srgrimes	cause <<bfd_check_format>> to loop through all the targets.
631592Srgrimes	@xref{bfd_target}.  @xref{Formats}.
641592Srgrimes
651592Srgrimes	o Otherwise, inspect the elements in the target vector
661592Srgrimes	one by one, until a match on target name is found. When found,
671592Srgrimes	use it.
681592Srgrimes
691592Srgrimes	o Otherwise return the error <<bfd_error_invalid_target>> to
701592Srgrimes	<<bfd_openr>>.
711592Srgrimes
721592Srgrimes	o <<bfd_openr>> attempts to open the file using
731592Srgrimes	<<bfd_open_file>>, and returns the BFD.
741592Srgrimes
751592Srgrimes	Once the BFD has been opened and the target selected, the file
761592Srgrimes	format may be determined. This is done by calling
771592Srgrimes	<<bfd_check_format>> on the BFD with a suggested format.
781592Srgrimes	If <<target_defaulted>> has been set, each possible target
791592Srgrimes	type is tried to see if it recognizes the specified format.
803938Spst	<<bfd_check_format>> returns <<TRUE>> when the caller guesses right.
813938Spst@menu
823938Spst@* bfd_target::
833938Spst@end menu
841592Srgrimes*/
851592Srgrimes
861592Srgrimes/*
871592Srgrimes
881592SrgrimesINODE
891592Srgrimes	bfd_target,  , Targets, Targets
901592SrgrimesDOCDD
911592SrgrimesSUBSECTION
921592Srgrimes	bfd_target
931592Srgrimes
941592SrgrimesDESCRIPTION
951592Srgrimes	This structure contains everything that BFD knows about a
961592Srgrimes	target. It includes things like its byte order, name, and which
971592Srgrimes	routines to call to do various operations.
981592Srgrimes
991592Srgrimes	Every BFD points to a target structure with its <<xvec>>
1001592Srgrimes	member.
1011592Srgrimes
1021592Srgrimes	The macros below are used to dispatch to functions through the
1031592Srgrimes	<<bfd_target>> vector. They are used in a number of macros further
1041592Srgrimes	down in @file{bfd.h}, and are also used when calling various
1051592Srgrimes	routines by hand inside the BFD implementation.  The @var{arglist}
1061592Srgrimes	argument must be parenthesized; it contains all the arguments
1071592Srgrimes	to the called function.
1081592Srgrimes
1091592Srgrimes	They make the documentation (more) unpleasant to read, so if
1101592Srgrimes	someone wants to fix this and not break the above, please do.
1111592Srgrimes
1121592Srgrimes.#define BFD_SEND(bfd, message, arglist) \
1136740Sguido.  ((*((bfd)->xvec->message)) arglist)
1146740Sguido.
1156740Sguido.#ifdef DEBUG_BFD_SEND
1166740Sguido.#undef BFD_SEND
1171592Srgrimes.#define BFD_SEND(bfd, message, arglist) \
1181592Srgrimes.  (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
1191592Srgrimes.    ((*((bfd)->xvec->message)) arglist) : \
1201592Srgrimes.    (bfd_assert (__FILE__,__LINE__), NULL))
1211592Srgrimes.#endif
1221592Srgrimes
1231592Srgrimes	For operations which index on the BFD format:
1241592Srgrimes
1251592Srgrimes.#define BFD_SEND_FMT(bfd, message, arglist) \
1261592Srgrimes.  (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist)
1271592Srgrimes.
1281592Srgrimes.#ifdef DEBUG_BFD_SEND
1291592Srgrimes.#undef BFD_SEND_FMT
1301592Srgrimes.#define BFD_SEND_FMT(bfd, message, arglist) \
1311592Srgrimes.  (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
1321592Srgrimes.   (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \
1331592Srgrimes.   (bfd_assert (__FILE__,__LINE__), NULL))
1346740Sguido.#endif
1356740Sguido.
1366740Sguido	This is the structure which defines the type of BFD this is.  The
1371592Srgrimes	<<xvec>> member of the struct <<bfd>> itself points here.  Each
1381592Srgrimes	module that implements access to a different target under BFD,
1391592Srgrimes	defines one of these.
1401592Srgrimes
1411592Srgrimes	FIXME, these names should be rationalised with the names of
1421592Srgrimes	the entry points which call them. Too bad we can't have one
1431592Srgrimes	macro to define them both!
1441592Srgrimes
1451592Srgrimes.enum bfd_flavour
1461592Srgrimes.{
1471592Srgrimes.  {* N.B. Update bfd_flavour_name if you change this.  *}
1481592Srgrimes.  bfd_target_unknown_flavour,
1491592Srgrimes.  bfd_target_aout_flavour,
1501592Srgrimes.  bfd_target_coff_flavour,
1511592Srgrimes.  bfd_target_ecoff_flavour,
1521592Srgrimes.  bfd_target_xcoff_flavour,
1531592Srgrimes.  bfd_target_elf_flavour,
1541592Srgrimes.  bfd_target_ieee_flavour,
1552193Sguido.  bfd_target_nlm_flavour,
1562193Sguido.  bfd_target_oasys_flavour,
1573938Spst.  bfd_target_tekhex_flavour,
1582193Sguido.  bfd_target_srec_flavour,
1592193Sguido.  bfd_target_verilog_flavour,
1601592Srgrimes.  bfd_target_ihex_flavour,
1611592Srgrimes.  bfd_target_som_flavour,
1621592Srgrimes.  bfd_target_os9k_flavour,
1631592Srgrimes.  bfd_target_versados_flavour,
1641592Srgrimes.  bfd_target_msdos_flavour,
1651592Srgrimes.  bfd_target_ovax_flavour,
1661592Srgrimes.  bfd_target_evax_flavour,
1671592Srgrimes.  bfd_target_mmo_flavour,
1681592Srgrimes.  bfd_target_mach_o_flavour,
1691592Srgrimes.  bfd_target_pef_flavour,
1701592Srgrimes.  bfd_target_pef_xlib_flavour,
1711592Srgrimes.  bfd_target_sym_flavour
1721592Srgrimes.};
1731592Srgrimes.
1741592Srgrimes.enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
1751592Srgrimes.
1761592Srgrimes.{* Forward declaration.  *}
1771592Srgrimes.typedef struct bfd_link_info _bfd_link_info;
1781592Srgrimes.
1791592Srgrimes.{* Forward declaration.  *}
1801592Srgrimes.typedef struct flag_info flag_info;
1811592Srgrimes.
1821592Srgrimes.typedef struct bfd_target
1831592Srgrimes.{
1841592Srgrimes.  {* Identifies the kind of target, e.g., SunOS4, Ultrix, etc.  *}
1851592Srgrimes.  char *name;
1861592Srgrimes.
1871592Srgrimes. {* The "flavour" of a back end is a general indication about
1881592Srgrimes.    the contents of a file.  *}
1891592Srgrimes.  enum bfd_flavour flavour;
1901592Srgrimes.
1911592Srgrimes.  {* The order of bytes within the data area of a file.  *}
1921592Srgrimes.  enum bfd_endian byteorder;
1931592Srgrimes.
1941592Srgrimes. {* The order of bytes within the header parts of a file.  *}
1951592Srgrimes.  enum bfd_endian header_byteorder;
1961592Srgrimes.
1971592Srgrimes.  {* A mask of all the flags which an executable may have set -
1981592Srgrimes.     from the set <<BFD_NO_FLAGS>>, <<HAS_RELOC>>, ...<<D_PAGED>>.  *}
1991592Srgrimes.  flagword object_flags;
2001592Srgrimes.
2011592Srgrimes. {* A mask of all the flags which a section may have set - from
2021592Srgrimes.    the set <<SEC_NO_FLAGS>>, <<SEC_ALLOC>>, ...<<SET_NEVER_LOAD>>.  *}
2031592Srgrimes.  flagword section_flags;
2041592Srgrimes.
2051592Srgrimes. {* The character normally found at the front of a symbol.
2061592Srgrimes.    (if any), perhaps `_'.  *}
2071592Srgrimes.  char symbol_leading_char;
2081592Srgrimes.
2091592Srgrimes. {* The pad character for file names within an archive header.  *}
2101592Srgrimes.  char ar_pad_char;
2111592Srgrimes.
2121592Srgrimes.  {* The maximum number of characters in an archive header.  *}
2131592Srgrimes.  unsigned char ar_max_namelen;
2141592Srgrimes.
2151592Srgrimes.  {* How well this target matches, used to select between various
2161592Srgrimes.     possible targets when more than one target matches.  *}
2171592Srgrimes.  unsigned char match_priority;
2183938Spst.
2193938Spst.  {* Entries for byte swapping for data. These are different from the
2201592Srgrimes.     other entry points, since they don't take a BFD as the first argument.
2211592Srgrimes.     Certain other handlers could do the same.  *}
2221592Srgrimes.  bfd_uint64_t   (*bfd_getx64) (const void *);
2231592Srgrimes.  bfd_int64_t    (*bfd_getx_signed_64) (const void *);
2241592Srgrimes.  void           (*bfd_putx64) (bfd_uint64_t, void *);
2251592Srgrimes.  bfd_vma        (*bfd_getx32) (const void *);
2261592Srgrimes.  bfd_signed_vma (*bfd_getx_signed_32) (const void *);
2271592Srgrimes.  void           (*bfd_putx32) (bfd_vma, void *);
2281592Srgrimes.  bfd_vma        (*bfd_getx16) (const void *);
2291592Srgrimes.  bfd_signed_vma (*bfd_getx_signed_16) (const void *);
2303938Spst.  void           (*bfd_putx16) (bfd_vma, void *);
2313938Spst.
2323938Spst.  {* Byte swapping for the headers.  *}
2331592Srgrimes.  bfd_uint64_t   (*bfd_h_getx64) (const void *);
2341592Srgrimes.  bfd_int64_t    (*bfd_h_getx_signed_64) (const void *);
2351592Srgrimes.  void           (*bfd_h_putx64) (bfd_uint64_t, void *);
2361592Srgrimes.  bfd_vma        (*bfd_h_getx32) (const void *);
2371592Srgrimes.  bfd_signed_vma (*bfd_h_getx_signed_32) (const void *);
2381592Srgrimes.  void           (*bfd_h_putx32) (bfd_vma, void *);
2391592Srgrimes.  bfd_vma        (*bfd_h_getx16) (const void *);
2401592Srgrimes.  bfd_signed_vma (*bfd_h_getx_signed_16) (const void *);
2411592Srgrimes.  void           (*bfd_h_putx16) (bfd_vma, void *);
2421592Srgrimes.
2431592Srgrimes.  {* Format dependent routines: these are vectors of entry points
2441592Srgrimes.     within the target vector structure, one for each format to check.  *}
2451592Srgrimes.
2461592Srgrimes.  {* Check the format of a file being read.  Return a <<bfd_target *>> or zero.  *}
2471592Srgrimes.  const struct bfd_target *(*_bfd_check_format[bfd_type_end]) (bfd *);
2481592Srgrimes.
2491592Srgrimes.  {* Set the format of a file being written.  *}
2501592Srgrimes.  bfd_boolean (*_bfd_set_format[bfd_type_end]) (bfd *);
2511592Srgrimes.
2521592Srgrimes.  {* Write cached information into a file being written, at <<bfd_close>>.  *}
2531592Srgrimes.  bfd_boolean (*_bfd_write_contents[bfd_type_end]) (bfd *);
2541592Srgrimes.
2556740SguidoThe general target vector.  These vectors are initialized using the
2566740SguidoBFD_JUMP_TABLE macros.
2576740Sguido.
2586740Sguido.  {* Generic entry points.  *}
2591592Srgrimes.#define BFD_JUMP_TABLE_GENERIC(NAME) \
2606740Sguido.  NAME##_close_and_cleanup, \
2611592Srgrimes.  NAME##_bfd_free_cached_info, \
2621592Srgrimes.  NAME##_new_section_hook, \
2631592Srgrimes.  NAME##_get_section_contents, \
2641592Srgrimes.  NAME##_get_section_contents_in_window
2651592Srgrimes.
2661592Srgrimes.  {* Called when the BFD is being closed to do any necessary cleanup.  *}
2671592Srgrimes.  bfd_boolean (*_close_and_cleanup) (bfd *);
2681592Srgrimes.  {* Ask the BFD to free all cached information.  *}
2691592Srgrimes.  bfd_boolean (*_bfd_free_cached_info) (bfd *);
2701592Srgrimes.  {* Called when a new section is created.  *}
2711592Srgrimes.  bfd_boolean (*_new_section_hook) (bfd *, sec_ptr);
2721592Srgrimes.  {* Read the contents of a section.  *}
2731592Srgrimes.  bfd_boolean (*_bfd_get_section_contents)
2741592Srgrimes.    (bfd *, sec_ptr, void *, file_ptr, bfd_size_type);
2756740Sguido.  bfd_boolean (*_bfd_get_section_contents_in_window)
2766740Sguido.    (bfd *, sec_ptr, bfd_window *, file_ptr, bfd_size_type);
2776740Sguido.
2786740Sguido.  {* Entry points to copy private data.  *}
2796740Sguido.#define BFD_JUMP_TABLE_COPY(NAME) \
2801592Srgrimes.  NAME##_bfd_copy_private_bfd_data, \
2811592Srgrimes.  NAME##_bfd_merge_private_bfd_data, \
2821592Srgrimes.  _bfd_generic_init_private_section_data, \
2831592Srgrimes.  NAME##_bfd_copy_private_section_data, \
2841592Srgrimes.  NAME##_bfd_copy_private_symbol_data, \
2851592Srgrimes.  NAME##_bfd_copy_private_header_data, \
2861592Srgrimes.  NAME##_bfd_set_private_flags, \
2871592Srgrimes.  NAME##_bfd_print_private_bfd_data
2881592Srgrimes.
2891592Srgrimes.  {* Called to copy BFD general private data from one object file
2901592Srgrimes.     to another.  *}
2911592Srgrimes.  bfd_boolean (*_bfd_copy_private_bfd_data) (bfd *, bfd *);
2921592Srgrimes.  {* Called to merge BFD general private data from one object file
2931592Srgrimes.     to a common output file when linking.  *}
2941592Srgrimes.  bfd_boolean (*_bfd_merge_private_bfd_data) (bfd *, struct bfd_link_info *);
2951592Srgrimes.  {* Called to initialize BFD private section data from one object file
2961592Srgrimes.     to another.  *}
2971592Srgrimes.#define bfd_init_private_section_data(ibfd, isec, obfd, osec, link_info) \
2981592Srgrimes.  BFD_SEND (obfd, _bfd_init_private_section_data, (ibfd, isec, obfd, osec, link_info))
2991592Srgrimes.  bfd_boolean (*_bfd_init_private_section_data)
3001592Srgrimes.    (bfd *, sec_ptr, bfd *, sec_ptr, struct bfd_link_info *);
3011592Srgrimes.  {* Called to copy BFD private section data from one object file
3021592Srgrimes.     to another.  *}
3031592Srgrimes.  bfd_boolean (*_bfd_copy_private_section_data)
3041592Srgrimes.    (bfd *, sec_ptr, bfd *, sec_ptr);
3051592Srgrimes.  {* Called to copy BFD private symbol data from one symbol
3061592Srgrimes.     to another.  *}
3071592Srgrimes.  bfd_boolean (*_bfd_copy_private_symbol_data)
3081592Srgrimes.    (bfd *, asymbol *, bfd *, asymbol *);
3091592Srgrimes.  {* Called to copy BFD private header data from one object file
3101592Srgrimes.     to another.  *}
3111592Srgrimes.  bfd_boolean (*_bfd_copy_private_header_data)
3121592Srgrimes.    (bfd *, bfd *);
3131592Srgrimes.  {* Called to set private backend flags.  *}
3141592Srgrimes.  bfd_boolean (*_bfd_set_private_flags) (bfd *, flagword);
3151592Srgrimes.
3161592Srgrimes.  {* Called to print private BFD data.  *}
3171592Srgrimes.  bfd_boolean (*_bfd_print_private_bfd_data) (bfd *, void *);
3181592Srgrimes.
3191592Srgrimes.  {* Core file entry points.  *}
3201592Srgrimes.#define BFD_JUMP_TABLE_CORE(NAME) \
3211592Srgrimes.  NAME##_core_file_failing_command, \
3221592Srgrimes.  NAME##_core_file_failing_signal, \
3231592Srgrimes.  NAME##_core_file_matches_executable_p, \
3241592Srgrimes.  NAME##_core_file_pid
3251592Srgrimes.
3261592Srgrimes.  char *      (*_core_file_failing_command) (bfd *);
3271592Srgrimes.  int         (*_core_file_failing_signal) (bfd *);
3281592Srgrimes.  bfd_boolean (*_core_file_matches_executable_p) (bfd *, bfd *);
3291592Srgrimes.  int         (*_core_file_pid) (bfd *);
3301592Srgrimes.
3311592Srgrimes.  {* Archive entry points.  *}
3321592Srgrimes.#define BFD_JUMP_TABLE_ARCHIVE(NAME) \
3331592Srgrimes.  NAME##_slurp_armap, \
3341592Srgrimes.  NAME##_slurp_extended_name_table, \
3351592Srgrimes.  NAME##_construct_extended_name_table, \
3361592Srgrimes.  NAME##_truncate_arname, \
3371592Srgrimes.  NAME##_write_armap, \
3381592Srgrimes.  NAME##_read_ar_hdr, \
3391592Srgrimes.  NAME##_write_ar_hdr, \
3401592Srgrimes.  NAME##_openr_next_archived_file, \
3411592Srgrimes.  NAME##_get_elt_at_index, \
3421592Srgrimes.  NAME##_generic_stat_arch_elt, \
3431592Srgrimes.  NAME##_update_armap_timestamp
3441592Srgrimes.
3451592Srgrimes.  bfd_boolean (*_bfd_slurp_armap) (bfd *);
3461592Srgrimes.  bfd_boolean (*_bfd_slurp_extended_name_table) (bfd *);
3471592Srgrimes.  bfd_boolean (*_bfd_construct_extended_name_table)
3481592Srgrimes.    (bfd *, char **, bfd_size_type *, const char **);
3491592Srgrimes.  void        (*_bfd_truncate_arname) (bfd *, const char *, char *);
3501592Srgrimes.  bfd_boolean (*write_armap)
3511592Srgrimes.    (bfd *, unsigned int, struct orl *, unsigned int, int);
3521592Srgrimes.  void *      (*_bfd_read_ar_hdr_fn) (bfd *);
3531592Srgrimes.  bfd_boolean (*_bfd_write_ar_hdr_fn) (bfd *, bfd *);
3541592Srgrimes.  bfd *       (*openr_next_archived_file) (bfd *, bfd *);
3551592Srgrimes.#define bfd_get_elt_at_index(b,i) BFD_SEND (b, _bfd_get_elt_at_index, (b,i))
3561592Srgrimes.  bfd *       (*_bfd_get_elt_at_index) (bfd *, symindex);
3571592Srgrimes.  int         (*_bfd_stat_arch_elt) (bfd *, struct stat *);
3581592Srgrimes.  bfd_boolean (*_bfd_update_armap_timestamp) (bfd *);
3591592Srgrimes.
3601592Srgrimes.  {* Entry points used for symbols.  *}
3611592Srgrimes.#define BFD_JUMP_TABLE_SYMBOLS(NAME) \
3621592Srgrimes.  NAME##_get_symtab_upper_bound, \
3631592Srgrimes.  NAME##_canonicalize_symtab, \
3641592Srgrimes.  NAME##_make_empty_symbol, \
3651592Srgrimes.  NAME##_print_symbol, \
3661592Srgrimes.  NAME##_get_symbol_info, \
3671592Srgrimes.  NAME##_get_symbol_version_string, \
3681592Srgrimes.  NAME##_bfd_is_local_label_name, \
3691592Srgrimes.  NAME##_bfd_is_target_special_symbol, \
3701592Srgrimes.  NAME##_get_lineno, \
3711592Srgrimes.  NAME##_find_nearest_line, \
3721592Srgrimes.  NAME##_find_line, \
3731592Srgrimes.  NAME##_find_inliner_info, \
3741592Srgrimes.  NAME##_bfd_make_debug_symbol, \
3751592Srgrimes.  NAME##_read_minisymbols, \
3761592Srgrimes.  NAME##_minisymbol_to_symbol
3771592Srgrimes.
3781592Srgrimes.  long        (*_bfd_get_symtab_upper_bound) (bfd *);
3791592Srgrimes.  long        (*_bfd_canonicalize_symtab)
3801592Srgrimes.    (bfd *, struct bfd_symbol **);
3811592Srgrimes.  struct bfd_symbol *
3821592Srgrimes.              (*_bfd_make_empty_symbol) (bfd *);
3831592Srgrimes.  void        (*_bfd_print_symbol)
3841592Srgrimes.    (bfd *, void *, struct bfd_symbol *, bfd_print_symbol_type);
3851592Srgrimes.#define bfd_print_symbol(b,p,s,e) BFD_SEND (b, _bfd_print_symbol, (b,p,s,e))
3861592Srgrimes.  void        (*_bfd_get_symbol_info)
3871592Srgrimes.    (bfd *, struct bfd_symbol *, symbol_info *);
3881592Srgrimes.#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
3891592Srgrimes.  const char *(*_bfd_get_symbol_version_string)
3901592Srgrimes.    (bfd *, struct bfd_symbol *, bfd_boolean *);
3911592Srgrimes.#define bfd_get_symbol_version_string(b,s,h) BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h))
3921592Srgrimes.  bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *);
3931592Srgrimes.  bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
3941592Srgrimes.  alent *     (*_get_lineno) (bfd *, struct bfd_symbol *);
3951592Srgrimes.  bfd_boolean (*_bfd_find_nearest_line)
3961592Srgrimes.    (bfd *, struct bfd_symbol **, struct bfd_section *, bfd_vma,
3971592Srgrimes.     const char **, const char **, unsigned int *, unsigned int *);
3981592Srgrimes.  bfd_boolean (*_bfd_find_line)
3991592Srgrimes.    (bfd *, struct bfd_symbol **, struct bfd_symbol *,
4001592Srgrimes.     const char **, unsigned int *);
4011592Srgrimes.  bfd_boolean (*_bfd_find_inliner_info)
4021592Srgrimes.    (bfd *, const char **, const char **, unsigned int *);
4031592Srgrimes. {* Back-door to allow format-aware applications to create debug symbols
4041592Srgrimes.    while using BFD for everything else.  Currently used by the assembler
4051592Srgrimes.    when creating COFF files.  *}
4061592Srgrimes.  asymbol *   (*_bfd_make_debug_symbol)
4071592Srgrimes.    (bfd *, void *, unsigned long size);
4081592Srgrimes.#define bfd_read_minisymbols(b, d, m, s) \
4091592Srgrimes.  BFD_SEND (b, _read_minisymbols, (b, d, m, s))
4101592Srgrimes.  long        (*_read_minisymbols)
4111592Srgrimes.    (bfd *, bfd_boolean, void **, unsigned int *);
4121592Srgrimes.#define bfd_minisymbol_to_symbol(b, d, m, f) \
4131592Srgrimes.  BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
4141592Srgrimes.  asymbol *   (*_minisymbol_to_symbol)
4151592Srgrimes.    (bfd *, bfd_boolean, const void *, asymbol *);
4161592Srgrimes.
4171592Srgrimes.  {* Routines for relocs.  *}
4181592Srgrimes.#define BFD_JUMP_TABLE_RELOCS(NAME) \
4191592Srgrimes.  NAME##_get_reloc_upper_bound, \
4201592Srgrimes.  NAME##_canonicalize_reloc, \
4211592Srgrimes.  NAME##_bfd_reloc_type_lookup, \
4221592Srgrimes.  NAME##_bfd_reloc_name_lookup
4231592Srgrimes.
4241592Srgrimes.  long        (*_get_reloc_upper_bound) (bfd *, sec_ptr);
4251592Srgrimes.  long        (*_bfd_canonicalize_reloc)
4261592Srgrimes.    (bfd *, sec_ptr, arelent **, struct bfd_symbol **);
4271592Srgrimes.  {* See documentation on reloc types.  *}
4281592Srgrimes.  reloc_howto_type *
4291592Srgrimes.              (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
4301592Srgrimes.  reloc_howto_type *
4311592Srgrimes.              (*reloc_name_lookup) (bfd *, const char *);
4321592Srgrimes.
4331592Srgrimes.
4341592Srgrimes.  {* Routines used when writing an object file.  *}
4351592Srgrimes.#define BFD_JUMP_TABLE_WRITE(NAME) \
4361592Srgrimes.  NAME##_set_arch_mach, \
4371592Srgrimes.  NAME##_set_section_contents
4381592Srgrimes.
4391592Srgrimes.  bfd_boolean (*_bfd_set_arch_mach)
4401592Srgrimes.    (bfd *, enum bfd_architecture, unsigned long);
4411592Srgrimes.  bfd_boolean (*_bfd_set_section_contents)
4421592Srgrimes.    (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
4431592Srgrimes.
4441592Srgrimes.  {* Routines used by the linker.  *}
4451592Srgrimes.#define BFD_JUMP_TABLE_LINK(NAME) \
4461592Srgrimes.  NAME##_sizeof_headers, \
4471592Srgrimes.  NAME##_bfd_get_relocated_section_contents, \
4481592Srgrimes.  NAME##_bfd_relax_section, \
4491592Srgrimes.  NAME##_bfd_link_hash_table_create, \
4501592Srgrimes.  NAME##_bfd_link_add_symbols, \
4511592Srgrimes.  NAME##_bfd_link_just_syms, \
4521592Srgrimes.  NAME##_bfd_copy_link_hash_symbol_type, \
4531592Srgrimes.  NAME##_bfd_final_link, \
4541592Srgrimes.  NAME##_bfd_link_split_section, \
4551592Srgrimes.  NAME##_bfd_link_check_relocs, \
4561592Srgrimes.  NAME##_bfd_gc_sections, \
4571592Srgrimes.  NAME##_bfd_lookup_section_flags, \
4581592Srgrimes.  NAME##_bfd_merge_sections, \
4591592Srgrimes.  NAME##_bfd_is_group_section, \
4601592Srgrimes.  NAME##_bfd_discard_group, \
4613938Spst.  NAME##_section_already_linked, \
4621592Srgrimes.  NAME##_bfd_define_common_symbol
4631592Srgrimes.
4641592Srgrimes.  int         (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
4651592Srgrimes.  bfd_byte *  (*_bfd_get_relocated_section_contents)
4661592Srgrimes.    (bfd *, struct bfd_link_info *, struct bfd_link_order *,
4671592Srgrimes.     bfd_byte *, bfd_boolean, struct bfd_symbol **);
4681592Srgrimes.
4691592Srgrimes.  bfd_boolean (*_bfd_relax_section)
4701592Srgrimes.    (bfd *, struct bfd_section *, struct bfd_link_info *, bfd_boolean *);
4711592Srgrimes.
4721592Srgrimes.  {* Create a hash table for the linker.  Different backends store
4731592Srgrimes.     different information in this table.  *}
4741592Srgrimes.  struct bfd_link_hash_table *
4751592Srgrimes.              (*_bfd_link_hash_table_create) (bfd *);
4761592Srgrimes.
4771592Srgrimes.  {* Add symbols from this object file into the hash table.  *}
4781592Srgrimes.  bfd_boolean (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *);
4791592Srgrimes.
4801592Srgrimes.  {* Indicate that we are only retrieving symbol values from this section.  *}
4811592Srgrimes.  void        (*_bfd_link_just_syms) (asection *, struct bfd_link_info *);
4821592Srgrimes.
4831592Srgrimes.  {* Copy the symbol type and other attributes for a linker script
4841592Srgrimes.     assignment of one symbol to another.  *}
4851592Srgrimes.#define bfd_copy_link_hash_symbol_type(b, t, f) \
4861592Srgrimes.  BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f))
4871592Srgrimes.  void (*_bfd_copy_link_hash_symbol_type)
4881592Srgrimes.    (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *);
4892193Sguido.
4903938Spst.  {* Do a link based on the link_order structures attached to each
4912193Sguido.     section of the BFD.  *}
4922193Sguido.  bfd_boolean (*_bfd_final_link) (bfd *, struct bfd_link_info *);
4931592Srgrimes.
4942193Sguido.  {* Should this section be split up into smaller pieces during linking.  *}
4951592Srgrimes.  bfd_boolean (*_bfd_link_split_section) (bfd *, struct bfd_section *);
4961592Srgrimes.
4971592Srgrimes.  {* Check the relocations in the bfd for validity.  *}
4981592Srgrimes.  bfd_boolean (* _bfd_link_check_relocs)(bfd *, struct bfd_link_info *);
4991592Srgrimes.
5001592Srgrimes.  {* Remove sections that are not referenced from the output.  *}
5011592Srgrimes.  bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *);
5021592Srgrimes.
5031592Srgrimes.  {* Sets the bitmask of allowed and disallowed section flags.  *}
5041592Srgrimes.  bfd_boolean (*_bfd_lookup_section_flags) (struct bfd_link_info *,
5051592Srgrimes.					     struct flag_info *,
5061592Srgrimes.					     asection *);
5071592Srgrimes.
5081592Srgrimes.  {* Attempt to merge SEC_MERGE sections.  *}
5091592Srgrimes.  bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
5101592Srgrimes.
5111592Srgrimes.  {* Is this section a member of a group?  *}
5121592Srgrimes.  bfd_boolean (*_bfd_is_group_section) (bfd *, const struct bfd_section *);
5131592Srgrimes.
5141592Srgrimes.  {* Discard members of a group.  *}
5151592Srgrimes.  bfd_boolean (*_bfd_discard_group) (bfd *, struct bfd_section *);
5161592Srgrimes.
5171592Srgrimes.  {* Check if SEC has been already linked during a reloceatable or
5181592Srgrimes.     final link.  *}
5191592Srgrimes.  bfd_boolean (*_section_already_linked) (bfd *, asection *,
5201592Srgrimes.					   struct bfd_link_info *);
5212930Sdg.
5221592Srgrimes.  {* Define a common symbol.  *}
5231592Srgrimes.  bfd_boolean (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
5241592Srgrimes.					     struct bfd_link_hash_entry *);
5251592Srgrimes.
5261592Srgrimes.  {* Routines to handle dynamic symbols and relocs.  *}
5271592Srgrimes.#define BFD_JUMP_TABLE_DYNAMIC(NAME) \
5281592Srgrimes.  NAME##_get_dynamic_symtab_upper_bound, \
5291592Srgrimes.  NAME##_canonicalize_dynamic_symtab, \
5301592Srgrimes.  NAME##_get_synthetic_symtab, \
5311592Srgrimes.  NAME##_get_dynamic_reloc_upper_bound, \
5321592Srgrimes.  NAME##_canonicalize_dynamic_reloc
5331592Srgrimes.
5341592Srgrimes.  {* Get the amount of memory required to hold the dynamic symbols.  *}
5351592Srgrimes.  long        (*_bfd_get_dynamic_symtab_upper_bound) (bfd *);
5361592Srgrimes.  {* Read in the dynamic symbols.  *}
5371592Srgrimes.  long        (*_bfd_canonicalize_dynamic_symtab)
5381592Srgrimes.    (bfd *, struct bfd_symbol **);
5391592Srgrimes.  {* Create synthetized symbols.  *}
5401592Srgrimes.  long        (*_bfd_get_synthetic_symtab)
5411592Srgrimes.    (bfd *, long, struct bfd_symbol **, long, struct bfd_symbol **,
5421592Srgrimes.     struct bfd_symbol **);
5431592Srgrimes.  {* Get the amount of memory required to hold the dynamic relocs.  *}
5441592Srgrimes.  long        (*_bfd_get_dynamic_reloc_upper_bound) (bfd *);
5451592Srgrimes.  {* Read in the dynamic relocs.  *}
5461592Srgrimes.  long        (*_bfd_canonicalize_dynamic_reloc)
5471592Srgrimes.    (bfd *, arelent **, struct bfd_symbol **);
5481592Srgrimes.
5491592Srgrimes
5501592SrgrimesA pointer to an alternative bfd_target in case the current one is not
5511592Srgrimessatisfactory.  This can happen when the target cpu supports both big
5521592Srgrimesand little endian code, and target chosen by the linker has the wrong
5531592Srgrimesendianness.  The function open_output() in ld/ldlang.c uses this field
5541592Srgrimesto find an alternative output format that is suitable.
5551592Srgrimes
5561592Srgrimes.  {* Opposite endian version of this target.  *}
5571592Srgrimes.  const struct bfd_target * alternative_target;
5581592Srgrimes.
5591592Srgrimes
5601592Srgrimes.  {* Data for use by back-end routines, which isn't
5611592Srgrimes.     generic enough to belong in this structure.  *}
5621592Srgrimes.  const void *backend_data;
5631592Srgrimes.
5642193Sguido.} bfd_target;
5652193Sguido.
5663206Spst*/
5672193Sguido
5681592Srgrimes/* All known xvecs (even those that don't compile on all systems).
5692193Sguido   Alphabetized for easy reference.
5701592Srgrimes   They are listed a second time below, since
5711592Srgrimes   we can't intermix extern's and initializers.  */
5721592Srgrimesextern const bfd_target aarch64_elf32_be_vec;
5731592Srgrimesextern const bfd_target aarch64_elf32_le_vec;
5741592Srgrimesextern const bfd_target aarch64_elf64_be_vec;
5751592Srgrimesextern const bfd_target aarch64_elf64_be_cloudabi_vec;
5761592Srgrimesextern const bfd_target aarch64_elf64_le_vec;
5771592Srgrimesextern const bfd_target aarch64_elf64_le_cloudabi_vec;
5781592Srgrimesextern const bfd_target aarch64_mach_o_vec;
5791592Srgrimesextern const bfd_target alpha_ecoff_le_vec;
5801592Srgrimesextern const bfd_target alpha_elf64_vec;
5811592Srgrimesextern const bfd_target alpha_elf64_fbsd_vec;
5821592Srgrimesextern const bfd_target alpha_nlm32_vec;
5831592Srgrimesextern const bfd_target alpha_vms_vec;
5841592Srgrimesextern const bfd_target alpha_vms_lib_txt_vec;
5851592Srgrimesextern const bfd_target am33_elf32_linux_vec;
5861592Srgrimesextern const bfd_target aout0_be_vec;
5871592Srgrimesextern const bfd_target aout64_vec;
5881592Srgrimesextern const bfd_target aout_vec;
5891592Srgrimesextern const bfd_target aout_adobe_vec;
5901592Srgrimesextern const bfd_target arc_elf32_be_vec;
5911592Srgrimesextern const bfd_target arc_elf32_le_vec;
5921592Srgrimesextern const bfd_target arm_aout_be_vec;
5931592Srgrimesextern const bfd_target arm_aout_le_vec;
5941592Srgrimesextern const bfd_target arm_aout_nbsd_vec;
5951592Srgrimesextern const bfd_target arm_aout_riscix_vec;
5961592Srgrimesextern const bfd_target arm_coff_be_vec;
5971592Srgrimesextern const bfd_target arm_coff_le_vec;
5981592Srgrimesextern const bfd_target arm_elf32_be_vec;
5991592Srgrimesextern const bfd_target arm_elf32_le_vec;
6006740Sguidoextern const bfd_target arm_elf32_nacl_be_vec;
6016740Sguidoextern const bfd_target arm_elf32_nacl_le_vec;
6026740Sguidoextern const bfd_target arm_elf32_symbian_be_vec;
6036740Sguidoextern const bfd_target arm_elf32_symbian_le_vec;
6046740Sguidoextern const bfd_target arm_elf32_vxworks_be_vec;
6056740Sguidoextern const bfd_target arm_elf32_vxworks_le_vec;
6061592Srgrimesextern const bfd_target arm_mach_o_vec;
6071592Srgrimesextern const bfd_target arm_pe_be_vec;
6081592Srgrimesextern const bfd_target arm_pe_le_vec;
6091592Srgrimesextern const bfd_target arm_pe_epoc_be_vec;
6101592Srgrimesextern const bfd_target arm_pe_epoc_le_vec;
6111592Srgrimesextern const bfd_target arm_pe_wince_be_vec;
6121592Srgrimesextern const bfd_target arm_pe_wince_le_vec;
6131592Srgrimesextern const bfd_target arm_pei_be_vec;
6141592Srgrimesextern const bfd_target arm_pei_le_vec;
6151592Srgrimesextern const bfd_target arm_pei_epoc_be_vec;
6161592Srgrimesextern const bfd_target arm_pei_epoc_le_vec;
6171592Srgrimesextern const bfd_target arm_pei_wince_be_vec;
6181592Srgrimesextern const bfd_target arm_pei_wince_le_vec;
6191592Srgrimesextern const bfd_target avr_elf32_vec;
6201592Srgrimesextern const bfd_target bfin_elf32_vec;
6211592Srgrimesextern const bfd_target bfin_elf32_fdpic_vec;
6221592Srgrimesextern const bfd_target bout_be_vec;
6231592Srgrimesextern const bfd_target bout_le_vec;
6241592Srgrimesextern const bfd_target cr16_elf32_vec;
6251592Srgrimesextern const bfd_target cr16c_elf32_vec;
6261592Srgrimesextern const bfd_target cris_aout_vec;
6271592Srgrimesextern const bfd_target cris_elf32_vec;
6281592Srgrimesextern const bfd_target cris_elf32_us_vec;
6291592Srgrimesextern const bfd_target crx_elf32_vec;
6301592Srgrimesextern const bfd_target d10v_elf32_vec;
6311592Srgrimesextern const bfd_target d30v_elf32_vec;
6321592Srgrimesextern const bfd_target dlx_elf32_be_vec;
6331592Srgrimesextern const bfd_target elf32_be_vec;
6341592Srgrimesextern const bfd_target elf32_le_vec;
6351592Srgrimesextern const bfd_target elf64_be_vec;
6361592Srgrimesextern const bfd_target elf64_le_vec;
6371592Srgrimesextern const bfd_target epiphany_elf32_vec;
6381592Srgrimesextern const bfd_target fr30_elf32_vec;
6391592Srgrimesextern const bfd_target frv_elf32_vec;
6401592Srgrimesextern const bfd_target frv_elf32_fdpic_vec;
6411592Srgrimesextern const bfd_target h8300_coff_vec;
6421592Srgrimesextern const bfd_target h8300_elf32_vec;
6431592Srgrimesextern const bfd_target h8300_elf32_linux_vec;
6446740Sguidoextern const bfd_target h8500_coff_vec;
6456740Sguidoextern const bfd_target hppa_elf32_vec;
6466740Sguidoextern const bfd_target hppa_elf32_linux_vec;
6476740Sguidoextern const bfd_target hppa_elf32_nbsd_vec;
6486740Sguidoextern const bfd_target hppa_elf64_vec;
6496740Sguidoextern const bfd_target hppa_elf64_linux_vec;
6506740Sguidoextern const bfd_target hppa_som_vec;
6511592Srgrimesextern const bfd_target i370_elf32_vec;
6521592Srgrimesextern const bfd_target i386_aout_vec;
6531592Srgrimesextern const bfd_target i386_aout_bsd_vec;
6541592Srgrimesextern const bfd_target i386_aout_dynix_vec;
6551592Srgrimesextern const bfd_target i386_aout_fbsd_vec;
6561592Srgrimesextern const bfd_target i386_aout_linux_vec;
6571592Srgrimesextern const bfd_target i386_aout_lynx_vec;
6581592Srgrimesextern const bfd_target i386_aout_mach3_vec;
6591592Srgrimesextern const bfd_target i386_aout_nbsd_vec;
6601592Srgrimesextern const bfd_target i386_aout_os9k_vec;
6611592Srgrimesextern const bfd_target i386_coff_vec;
6621592Srgrimesextern const bfd_target i386_coff_go32_vec;
6631592Srgrimesextern const bfd_target i386_coff_go32stubbed_vec;
6641592Srgrimesextern const bfd_target i386_coff_lynx_vec;
6651592Srgrimesextern const bfd_target i386_elf32_vec;
6661592Srgrimesextern const bfd_target i386_elf32_fbsd_vec;
6671592Srgrimesextern const bfd_target i386_elf32_nacl_vec;
6681592Srgrimesextern const bfd_target i386_elf32_sol2_vec;
6691592Srgrimesextern const bfd_target i386_elf32_vxworks_vec;
6701592Srgrimesextern const bfd_target i386_mach_o_vec;
6711592Srgrimesextern const bfd_target i386_msdos_vec;
6721592Srgrimesextern const bfd_target i386_nlm32_vec;
6731592Srgrimesextern const bfd_target i386_pe_vec;
6741592Srgrimesextern const bfd_target i386_pei_vec;
6751592Srgrimesextern const bfd_target iamcu_elf32_vec;
6761592Srgrimesextern const bfd_target i860_coff_vec;
6771592Srgrimesextern const bfd_target i860_elf32_vec;
6781592Srgrimesextern const bfd_target i860_elf32_le_vec;
6791592Srgrimesextern const bfd_target i960_elf32_vec;
6801592Srgrimesextern const bfd_target ia64_elf32_be_vec;
6811592Srgrimesextern const bfd_target ia64_elf32_hpux_be_vec;
6821592Srgrimesextern const bfd_target ia64_elf64_be_vec;
6831592Srgrimesextern const bfd_target ia64_elf64_le_vec;
6841592Srgrimesextern const bfd_target ia64_elf64_hpux_be_vec;
6851592Srgrimesextern const bfd_target ia64_elf64_vms_vec;
6861592Srgrimesextern const bfd_target ia64_pei_vec;
6876740Sguidoextern const bfd_target icoff_be_vec;
6886740Sguidoextern const bfd_target icoff_le_vec;
6896740Sguidoextern const bfd_target ieee_vec;
6901592Srgrimesextern const bfd_target ip2k_elf32_vec;
6911592Srgrimesextern const bfd_target iq2000_elf32_vec;
6921592Srgrimesextern const bfd_target k1om_elf64_vec;
6931592Srgrimesextern const bfd_target k1om_elf64_fbsd_vec;
6941592Srgrimesextern const bfd_target l1om_elf64_vec;
6951592Srgrimesextern const bfd_target l1om_elf64_fbsd_vec;
6961592Srgrimesextern const bfd_target lm32_elf32_vec;
6971592Srgrimesextern const bfd_target lm32_elf32_fdpic_vec;
6981592Srgrimesextern const bfd_target m32c_elf32_vec;
6991592Srgrimesextern const bfd_target m32r_elf32_vec;
7001592Srgrimesextern const bfd_target m32r_elf32_le_vec;
7011592Srgrimesextern const bfd_target m32r_elf32_linux_vec;
7021592Srgrimesextern const bfd_target m32r_elf32_linux_le_vec;
7031592Srgrimesextern const bfd_target m68hc11_elf32_vec;
7041592Srgrimesextern const bfd_target m68hc12_elf32_vec;
7051592Srgrimesextern const bfd_target m68k_aout_4knbsd_vec;
7061592Srgrimesextern const bfd_target m68k_aout_hp300bsd_vec;
7071592Srgrimesextern const bfd_target m68k_aout_hp300hpux_vec;
7081592Srgrimesextern const bfd_target m68k_aout_linux_vec;
7091592Srgrimesextern const bfd_target m68k_aout_nbsd_vec;
7101592Srgrimesextern const bfd_target m68k_aout_newsos3_vec;
7111592Srgrimesextern const bfd_target m68k_coff_vec;
7121592Srgrimesextern const bfd_target m68k_coff_apollo_vec;
7131592Srgrimesextern const bfd_target m68k_coff_aux_vec;
7141592Srgrimesextern const bfd_target m68k_coff_sysv_vec;
7151592Srgrimesextern const bfd_target m68k_coff_un_vec;
7161592Srgrimesextern const bfd_target m68k_elf32_vec;
7171592Srgrimesextern const bfd_target m68k_versados_vec;
7181592Srgrimesextern const bfd_target m88k_aout_mach3_vec;
7191592Srgrimesextern const bfd_target m88k_aout_obsd_vec;
7201592Srgrimesextern const bfd_target m88k_coff_bcs_vec;
7211592Srgrimesextern const bfd_target m88k_elf32_vec;
7221592Srgrimesextern const bfd_target mach_o_be_vec;
7231592Srgrimesextern const bfd_target mach_o_le_vec;
7241592Srgrimesextern const bfd_target mach_o_fat_vec;
7251592Srgrimesextern const bfd_target mcore_elf32_be_vec;
7261592Srgrimesextern const bfd_target mcore_elf32_le_vec;
7271592Srgrimesextern const bfd_target mcore_pe_be_vec;
7281592Srgrimesextern const bfd_target mcore_pe_le_vec;
7291592Srgrimesextern const bfd_target mcore_pei_be_vec;
7301592Srgrimesextern const bfd_target mcore_pei_le_vec;
7311592Srgrimesextern const bfd_target mep_elf32_vec;
7321592Srgrimesextern const bfd_target mep_elf32_le_vec;
7331592Srgrimesextern const bfd_target metag_elf32_vec;
7341592Srgrimesextern const bfd_target microblaze_elf32_vec;
7351592Srgrimesextern const bfd_target microblaze_elf32_le_vec;
7361592Srgrimesextern const bfd_target mips_aout_be_vec;
7371592Srgrimesextern const bfd_target mips_aout_le_vec;
7381592Srgrimesextern const bfd_target mips_ecoff_be_vec;
7396740Sguidoextern const bfd_target mips_ecoff_le_vec;
7406740Sguidoextern const bfd_target mips_ecoff_bele_vec;
7416740Sguidoextern const bfd_target mips_elf32_be_vec;
7421592Srgrimesextern const bfd_target mips_elf32_le_vec;
7436740Sguidoextern const bfd_target mips_elf32_n_be_vec;
7446740Sguidoextern const bfd_target mips_elf32_n_le_vec;
7456740Sguidoextern const bfd_target mips_elf32_ntrad_be_vec;
7466740Sguidoextern const bfd_target mips_elf32_ntrad_le_vec;
7471592Srgrimesextern const bfd_target mips_elf32_ntradfbsd_be_vec;
7481592Srgrimesextern const bfd_target mips_elf32_ntradfbsd_le_vec;
7491592Srgrimesextern const bfd_target mips_elf32_trad_be_vec;
7501592Srgrimesextern const bfd_target mips_elf32_trad_le_vec;
7511592Srgrimesextern const bfd_target mips_elf32_tradfbsd_be_vec;
7521592Srgrimesextern const bfd_target mips_elf32_tradfbsd_le_vec;
7531592Srgrimesextern const bfd_target mips_elf32_vxworks_be_vec;
7541592Srgrimesextern const bfd_target mips_elf32_vxworks_le_vec;
7551592Srgrimesextern const bfd_target mips_elf64_be_vec;
7561592Srgrimesextern const bfd_target mips_elf64_le_vec;
7571592Srgrimesextern const bfd_target mips_elf64_trad_be_vec;
7581592Srgrimesextern const bfd_target mips_elf64_trad_le_vec;
7591592Srgrimesextern const bfd_target mips_elf64_tradfbsd_be_vec;
7601592Srgrimesextern const bfd_target mips_elf64_tradfbsd_le_vec;
7611592Srgrimesextern const bfd_target mips_pe_le_vec;
7621592Srgrimesextern const bfd_target mips_pei_le_vec;
7631592Srgrimesextern const bfd_target mmix_elf64_vec;
7641592Srgrimesextern const bfd_target mmix_mmo_vec;
7651592Srgrimesextern const bfd_target mn10200_elf32_vec;
7661592Srgrimesextern const bfd_target mn10300_elf32_vec;
7671592Srgrimesextern const bfd_target moxie_elf32_be_vec;
7681592Srgrimesextern const bfd_target moxie_elf32_le_vec;
7691592Srgrimesextern const bfd_target msp430_elf32_vec;
7701592Srgrimesextern const bfd_target msp430_elf32_ti_vec;
7711592Srgrimesextern const bfd_target mt_elf32_vec;
7721592Srgrimesextern const bfd_target nds32_elf32_be_vec;
7731592Srgrimesextern const bfd_target nds32_elf32_le_vec;
7741592Srgrimesextern const bfd_target nds32_elf32_linux_be_vec;
7751592Srgrimesextern const bfd_target nds32_elf32_linux_le_vec;
7761592Srgrimesextern const bfd_target nios2_elf32_be_vec;
7771592Srgrimesextern const bfd_target nios2_elf32_le_vec;
7781592Srgrimesextern const bfd_target ns32k_aout_pc532mach_vec;
7791592Srgrimesextern const bfd_target ns32k_aout_pc532nbsd_vec;
7801592Srgrimesextern const bfd_target oasys_vec;
7811592Srgrimesextern const bfd_target or1k_elf32_vec;
7821592Srgrimesextern const bfd_target pdp11_aout_vec;
7831592Srgrimesextern const bfd_target pef_vec;
7841592Srgrimesextern const bfd_target pef_xlib_vec;
7851592Srgrimesextern const bfd_target pj_elf32_vec;
7861592Srgrimesextern const bfd_target pj_elf32_le_vec;
7871592Srgrimesextern const bfd_target plugin_vec;
7881592Srgrimesextern const bfd_target powerpc_boot_vec;
7891592Srgrimesextern const bfd_target powerpc_elf32_vec;
7901592Srgrimesextern const bfd_target powerpc_elf32_le_vec;
7911592Srgrimesextern const bfd_target powerpc_elf32_fbsd_vec;
7921592Srgrimesextern const bfd_target powerpc_elf32_vxworks_vec;
7931592Srgrimesextern const bfd_target powerpc_elf64_vec;
7941592Srgrimesextern const bfd_target powerpc_elf64_le_vec;
7951592Srgrimesextern const bfd_target powerpc_elf64_fbsd_vec;
7961592Srgrimesextern const bfd_target powerpc_nlm32_vec;
7971592Srgrimesextern const bfd_target powerpc_pe_vec;
7981592Srgrimesextern const bfd_target powerpc_pe_le_vec;
7991592Srgrimesextern const bfd_target powerpc_pei_vec;
8001592Srgrimesextern const bfd_target powerpc_pei_le_vec;
8011592Srgrimesextern const bfd_target powerpc_xcoff_vec;
8021592Srgrimesextern const bfd_target riscv_elf32_vec;
8031592Srgrimesextern const bfd_target riscv_elf64_vec;
8041592Srgrimesextern const bfd_target rl78_elf32_vec;
8051592Srgrimesextern const bfd_target rs6000_xcoff64_vec;
8061592Srgrimesextern const bfd_target rs6000_xcoff64_aix_vec;
8071592Srgrimesextern const bfd_target rs6000_xcoff_vec;
8081592Srgrimesextern const bfd_target rx_elf32_be_vec;
8091592Srgrimesextern const bfd_target rx_elf32_be_ns_vec;
8101592Srgrimesextern const bfd_target rx_elf32_le_vec;
8111592Srgrimesextern const bfd_target s390_elf32_vec;
8121592Srgrimesextern const bfd_target s390_elf64_vec;
8131592Srgrimesextern const bfd_target score_elf32_be_vec;
8141592Srgrimesextern const bfd_target score_elf32_le_vec;
8151592Srgrimesextern const bfd_target sh64_elf32_vec;
8161592Srgrimesextern const bfd_target sh64_elf32_le_vec;
8171592Srgrimesextern const bfd_target sh64_elf32_linux_vec;
8181592Srgrimesextern const bfd_target sh64_elf32_linux_be_vec;
8191592Srgrimesextern const bfd_target sh64_elf32_nbsd_vec;
8201592Srgrimesextern const bfd_target sh64_elf32_nbsd_le_vec;
8211592Srgrimesextern const bfd_target sh64_elf64_vec;
8221592Srgrimesextern const bfd_target sh64_elf64_le_vec;
8231592Srgrimesextern const bfd_target sh64_elf64_linux_vec;
8241592Srgrimesextern const bfd_target sh64_elf64_linux_be_vec;
8251592Srgrimesextern const bfd_target sh64_elf64_nbsd_vec;
8261592Srgrimesextern const bfd_target sh64_elf64_nbsd_le_vec;
8271592Srgrimesextern const bfd_target sh_coff_vec;
8281592Srgrimesextern const bfd_target sh_coff_le_vec;
8291592Srgrimesextern const bfd_target sh_coff_small_vec;
8301592Srgrimesextern const bfd_target sh_coff_small_le_vec;
8311592Srgrimesextern const bfd_target sh_elf32_vec;
8321592Srgrimesextern const bfd_target sh_elf32_le_vec;
8331592Srgrimesextern const bfd_target sh_elf32_fdpic_be_vec;
8341592Srgrimesextern const bfd_target sh_elf32_fdpic_le_vec;
8351592Srgrimesextern const bfd_target sh_elf32_linux_vec;
8361592Srgrimesextern const bfd_target sh_elf32_linux_be_vec;
8371592Srgrimesextern const bfd_target sh_elf32_nbsd_vec;
8381592Srgrimesextern const bfd_target sh_elf32_nbsd_le_vec;
8391592Srgrimesextern const bfd_target sh_elf32_symbian_le_vec;
8401592Srgrimesextern const bfd_target sh_elf32_vxworks_vec;
8411592Srgrimesextern const bfd_target sh_elf32_vxworks_le_vec;
8421592Srgrimesextern const bfd_target sh_pe_le_vec;
8431592Srgrimesextern const bfd_target sh_pei_le_vec;
8441592Srgrimesextern const bfd_target sparc_aout_le_vec;
8451592Srgrimesextern const bfd_target sparc_aout_linux_vec;
8461592Srgrimesextern const bfd_target sparc_aout_lynx_vec;
8471592Srgrimesextern const bfd_target sparc_aout_nbsd_vec;
8481592Srgrimesextern const bfd_target sparc_aout_sunos_be_vec;
8491592Srgrimesextern const bfd_target sparc_coff_vec;
8501592Srgrimesextern const bfd_target sparc_coff_lynx_vec;
8511592Srgrimesextern const bfd_target sparc_elf32_vec;
8521592Srgrimesextern const bfd_target sparc_elf32_sol2_vec;
8531592Srgrimesextern const bfd_target sparc_elf32_vxworks_vec;
8541592Srgrimesextern const bfd_target sparc_elf64_vec;
8551592Srgrimesextern const bfd_target sparc_elf64_fbsd_vec;
8561592Srgrimesextern const bfd_target sparc_elf64_sol2_vec;
8571592Srgrimesextern const bfd_target sparc_nlm32_vec;
8581592Srgrimesextern const bfd_target spu_elf32_vec;
8591592Srgrimesextern const bfd_target sym_vec;
8601592Srgrimesextern const bfd_target tic30_aout_vec;
8611592Srgrimesextern const bfd_target tic30_coff_vec;
8621592Srgrimesextern const bfd_target tic4x_coff0_vec;
8631592Srgrimesextern const bfd_target tic4x_coff0_beh_vec;
8641592Srgrimesextern const bfd_target tic4x_coff1_vec;
8651592Srgrimesextern const bfd_target tic4x_coff1_beh_vec;
8661592Srgrimesextern const bfd_target tic4x_coff2_vec;
8671592Srgrimesextern const bfd_target tic4x_coff2_beh_vec;
8681592Srgrimesextern const bfd_target tic54x_coff0_vec;
8691592Srgrimesextern const bfd_target tic54x_coff0_beh_vec;
8701592Srgrimesextern const bfd_target tic54x_coff1_vec;
8711592Srgrimesextern const bfd_target tic54x_coff1_beh_vec;
8721592Srgrimesextern const bfd_target tic54x_coff2_vec;
8731592Srgrimesextern const bfd_target tic54x_coff2_beh_vec;
8741592Srgrimesextern const bfd_target tic6x_elf32_be_vec;
8751592Srgrimesextern const bfd_target tic6x_elf32_le_vec;
8761592Srgrimesextern const bfd_target tic6x_elf32_c6000_be_vec;
8771592Srgrimesextern const bfd_target tic6x_elf32_c6000_le_vec;
8781592Srgrimesextern const bfd_target tic6x_elf32_linux_be_vec;
8791592Srgrimesextern const bfd_target tic6x_elf32_linux_le_vec;
8801592Srgrimesextern const bfd_target tic80_coff_vec;
8811592Srgrimesextern const bfd_target tilegx_elf32_be_vec;
8821592Srgrimesextern const bfd_target tilegx_elf32_le_vec;
8831592Srgrimesextern const bfd_target tilegx_elf64_be_vec;
8841592Srgrimesextern const bfd_target tilegx_elf64_le_vec;
8851592Srgrimesextern const bfd_target tilepro_elf32_vec;
8861592Srgrimesextern const bfd_target v800_elf32_vec;
8871592Srgrimesextern const bfd_target v850_elf32_vec;
8881592Srgrimesextern const bfd_target ft32_elf32_vec;
8891592Srgrimesextern const bfd_target vax_aout_1knbsd_vec;
8901592Srgrimesextern const bfd_target vax_aout_bsd_vec;
8911592Srgrimesextern const bfd_target vax_aout_nbsd_vec;
8921592Srgrimesextern const bfd_target vax_elf32_vec;
8931592Srgrimesextern const bfd_target visium_elf32_vec;
8941592Srgrimesextern const bfd_target w65_coff_vec;
8951592Srgrimesextern const bfd_target we32k_coff_vec;
8961592Srgrimesextern const bfd_target x86_64_coff_vec;
8971592Srgrimesextern const bfd_target x86_64_elf32_vec;
8981592Srgrimesextern const bfd_target x86_64_elf32_nacl_vec;
8991592Srgrimesextern const bfd_target x86_64_elf64_vec;
9001592Srgrimesextern const bfd_target x86_64_elf64_cloudabi_vec;
9011592Srgrimesextern const bfd_target x86_64_elf64_fbsd_vec;
9021592Srgrimesextern const bfd_target x86_64_elf64_nacl_vec;
9031592Srgrimesextern const bfd_target x86_64_elf64_sol2_vec;
9041592Srgrimesextern const bfd_target x86_64_mach_o_vec;
9051592Srgrimesextern const bfd_target x86_64_pe_vec;
9061592Srgrimesextern const bfd_target x86_64_pe_be_vec;
9071592Srgrimesextern const bfd_target x86_64_pei_vec;
9081592Srgrimesextern const bfd_target xc16x_elf32_vec;
9091592Srgrimesextern const bfd_target xgate_elf32_vec;
9101592Srgrimesextern const bfd_target xstormy16_elf32_vec;
9111592Srgrimesextern const bfd_target xtensa_elf32_be_vec;
9121592Srgrimesextern const bfd_target xtensa_elf32_le_vec;
9131592Srgrimesextern const bfd_target z80_coff_vec;
9141592Srgrimesextern const bfd_target z8k_coff_vec;
9151592Srgrimes
9161592Srgrimes/* These are always included.  */
9171592Srgrimesextern const bfd_target srec_vec;
9181592Srgrimesextern const bfd_target symbolsrec_vec;
9191592Srgrimesextern const bfd_target verilog_vec;
9201592Srgrimesextern const bfd_target tekhex_vec;
9211592Srgrimesextern const bfd_target binary_vec;
9221592Srgrimesextern const bfd_target ihex_vec;
9231592Srgrimes
9241592Srgrimes/* All of the xvecs for core files.  */
9251592Srgrimesextern const bfd_target core_aix386_vec;
9261592Srgrimesextern const bfd_target core_cisco_be_vec;
9271592Srgrimesextern const bfd_target core_cisco_le_vec;
9281592Srgrimesextern const bfd_target core_hppabsd_vec;
9291592Srgrimesextern const bfd_target core_hpux_vec;
9301592Srgrimesextern const bfd_target core_irix_vec;
9311592Srgrimesextern const bfd_target core_netbsd_vec;
9321592Srgrimesextern const bfd_target core_osf_vec;
9331592Srgrimesextern const bfd_target core_ptrace_vec;
9341592Srgrimesextern const bfd_target core_sco5_vec;
9351592Srgrimesextern const bfd_target core_trad_vec;
9361592Srgrimes
9371592Srgrimesstatic const bfd_target * const _bfd_target_vector[] =
9381592Srgrimes{
9391592Srgrimes#ifdef SELECT_VECS
9401592Srgrimes
9411592Srgrimes	SELECT_VECS,
9421592Srgrimes
9431592Srgrimes#else /* not SELECT_VECS */
9441592Srgrimes
9451592Srgrimes#ifdef DEFAULT_VECTOR
9461592Srgrimes	&DEFAULT_VECTOR,
9471592Srgrimes#endif
9481592Srgrimes	/* This list is alphabetized to make it easy to compare
9491592Srgrimes	   with other vector lists -- the decls above and
9501592Srgrimes	   the case statement in configure.ac.
9511592Srgrimes	   Try to keep it in order when adding new targets, and
9521592Srgrimes	   use a name of the form <cpu>_<format>_<other>_<endian>_vec.
9531592Srgrimes	   Note that sorting is done as if _<endian>_vec wasn't present.
9541592Srgrimes	   Vectors that don't compile on all systems, or aren't finished,
9551592Srgrimes	   should have an entry here with #if 0 around it, to show that
9561592Srgrimes	   it wasn't omitted by mistake.  */
9571592Srgrimes#ifdef BFD64
9581592Srgrimes	&aarch64_elf32_be_vec,
9591592Srgrimes	&aarch64_elf32_le_vec,
9601592Srgrimes	&aarch64_elf64_be_vec,
9611592Srgrimes	&aarch64_elf64_be_cloudabi_vec,
9621592Srgrimes	&aarch64_elf64_le_vec,
9631592Srgrimes	&aarch64_elf64_le_cloudabi_vec,
9641592Srgrimes	&aarch64_mach_o_vec,
9651592Srgrimes#endif
9661592Srgrimes
9671592Srgrimes#ifdef BFD64
9681592Srgrimes	&alpha_ecoff_le_vec,
9691592Srgrimes	&alpha_elf64_vec,
9701592Srgrimes	&alpha_elf64_fbsd_vec,
9711592Srgrimes	&alpha_nlm32_vec,
9721592Srgrimes	&alpha_vms_vec,
9731592Srgrimes#endif
9741592Srgrimes	&alpha_vms_lib_txt_vec,
9751592Srgrimes
9761592Srgrimes	&am33_elf32_linux_vec,
9771592Srgrimes
9781592Srgrimes	&aout0_be_vec,
9791592Srgrimes#ifdef BFD64
9801592Srgrimes	&aout64_vec,	/* Only compiled if host has long-long support.  */
9811592Srgrimes#endif
9821592Srgrimes#if 0
9831592Srgrimes	/* Since a.out files lack decent magic numbers, no way to recognize
9841592Srgrimes	   which kind of a.out file it is.  */
9851592Srgrimes	&aout_vec,
9861592Srgrimes#endif
9871592Srgrimes	&aout_adobe_vec,
9881592Srgrimes
9891592Srgrimes	&arc_elf32_be_vec,
9901592Srgrimes	&arc_elf32_le_vec,
9911592Srgrimes
9921592Srgrimes#if 0
9931592Srgrimes	/* We have no way of distinguishing these from other a.out variants.  */
9941592Srgrimes	&arm_aout_be_vec,
9951592Srgrimes	&arm_aout_le_vec,
9961592Srgrimes#endif
9971592Srgrimes	&arm_aout_nbsd_vec,
9981592Srgrimes#if 0
9991592Srgrimes	/* We have no way of distinguishing these from other a.out variants.  */
10001592Srgrimes	&arm_aout_riscix_vec,
10011592Srgrimes#endif
10021592Srgrimes	&arm_coff_be_vec,
10031592Srgrimes	&arm_coff_le_vec,
10041592Srgrimes	&arm_elf32_be_vec,
10051592Srgrimes	&arm_elf32_le_vec,
10061592Srgrimes	&arm_elf32_symbian_be_vec,
10071592Srgrimes	&arm_elf32_symbian_le_vec,
10081592Srgrimes	&arm_elf32_vxworks_be_vec,
10091592Srgrimes	&arm_elf32_vxworks_le_vec,
10101592Srgrimes	&arm_mach_o_vec,
10111592Srgrimes	&arm_pe_be_vec,
10121592Srgrimes	&arm_pe_le_vec,
10131592Srgrimes	&arm_pe_epoc_be_vec,
10141592Srgrimes	&arm_pe_epoc_le_vec,
10151592Srgrimes	&arm_pe_wince_be_vec,
10161592Srgrimes	&arm_pe_wince_le_vec,
10171592Srgrimes	&arm_pei_be_vec,
10181592Srgrimes	&arm_pei_le_vec,
10191592Srgrimes	&arm_pei_epoc_be_vec,
10201592Srgrimes	&arm_pei_epoc_le_vec,
10211592Srgrimes	&arm_pei_wince_be_vec,
10221592Srgrimes	&arm_pei_wince_le_vec,
10231592Srgrimes
10241592Srgrimes	&avr_elf32_vec,
10251592Srgrimes
10261592Srgrimes	&bfin_elf32_vec,
10271592Srgrimes	&bfin_elf32_fdpic_vec,
10281592Srgrimes
10291592Srgrimes	&bout_be_vec,
10301592Srgrimes	&bout_le_vec,
10311592Srgrimes
10321592Srgrimes	&cr16_elf32_vec,
10331592Srgrimes	&cr16c_elf32_vec,
10341592Srgrimes
10351592Srgrimes	&cris_aout_vec,
10361592Srgrimes	&cris_elf32_vec,
10371592Srgrimes	&cris_elf32_us_vec,
10381592Srgrimes
10391592Srgrimes	&crx_elf32_vec,
10401592Srgrimes
10411592Srgrimes	&d10v_elf32_vec,
10421592Srgrimes	&d30v_elf32_vec,
10431592Srgrimes
10441592Srgrimes	&dlx_elf32_be_vec,
10451592Srgrimes
10461592Srgrimes	/* This, and other vectors, may not be used in any *.mt configuration.
10471592Srgrimes	   But that does not mean they are unnecessary.  If configured with
10481592Srgrimes	   --enable-targets=all, objdump or gdb should be able to examine
10491592Srgrimes	   the file even if we don't recognize the machine type.  */
10501592Srgrimes	&elf32_be_vec,
10511592Srgrimes	&elf32_le_vec,
10521592Srgrimes#ifdef BFD64
10531592Srgrimes	&elf64_be_vec,
10541592Srgrimes	&elf64_le_vec,
10551592Srgrimes#endif
10561592Srgrimes
10571592Srgrimes	&epiphany_elf32_vec,
10581592Srgrimes
10591592Srgrimes	&fr30_elf32_vec,
10601592Srgrimes
10611592Srgrimes	&frv_elf32_vec,
10621592Srgrimes	&frv_elf32_fdpic_vec,
10631592Srgrimes
10641592Srgrimes	&h8300_coff_vec,
10651592Srgrimes	&h8300_elf32_vec,
10661592Srgrimes	&h8300_elf32_linux_vec,
10671592Srgrimes	&h8500_coff_vec,
10681592Srgrimes
10691592Srgrimes	&hppa_elf32_vec,
10701592Srgrimes	&hppa_elf32_linux_vec,
10711592Srgrimes	&hppa_elf32_nbsd_vec,
10721592Srgrimes#ifdef BFD64
10731592Srgrimes	&hppa_elf64_vec,
10741592Srgrimes	&hppa_elf64_linux_vec,
10751592Srgrimes#endif
10761592Srgrimes	&hppa_som_vec,
10771592Srgrimes
10781592Srgrimes	&i370_elf32_vec,
10791592Srgrimes
10801592Srgrimes	&i386_aout_vec,
10811592Srgrimes	&i386_aout_bsd_vec,
10821592Srgrimes#if 0
10831592Srgrimes	&i386_aout_dynix_vec,
10841592Srgrimes#endif
10851592Srgrimes	&i386_aout_fbsd_vec,
10861592Srgrimes#if 0
10871592Srgrimes	/* Since a.out files lack decent magic numbers, no way to recognize
10881592Srgrimes	   which kind of a.out file it is.  */
10891592Srgrimes	&i386_aout_linux_vec,
10901592Srgrimes#endif
10911592Srgrimes	&i386_aout_lynx_vec,
10921592Srgrimes#if 0
10931592Srgrimes	/* No distinguishing features for Mach 3 executables.  */
10941592Srgrimes	&i386_aout_mach3_vec,
10951592Srgrimes#endif
10961592Srgrimes	&i386_aout_nbsd_vec,
10971592Srgrimes	&i386_aout_os9k_vec,
10981592Srgrimes	&i386_coff_vec,
10991592Srgrimes	&i386_coff_go32_vec,
11001592Srgrimes	&i386_coff_go32stubbed_vec,
11011592Srgrimes	&i386_coff_lynx_vec,
11021592Srgrimes	&i386_elf32_vec,
11031592Srgrimes	&i386_elf32_fbsd_vec,
11041592Srgrimes	&i386_elf32_nacl_vec,
11051592Srgrimes	&i386_elf32_sol2_vec,
11061592Srgrimes	&i386_elf32_vxworks_vec,
11071592Srgrimes	&i386_mach_o_vec,
11081592Srgrimes	&i386_msdos_vec,
11091592Srgrimes	&i386_nlm32_vec,
11101592Srgrimes	&i386_pe_vec,
11111592Srgrimes	&i386_pei_vec,
11121592Srgrimes
11131592Srgrimes	&iamcu_elf32_vec,
11141592Srgrimes
11151592Srgrimes	&i860_coff_vec,
11161592Srgrimes	&i860_elf32_vec,
11171592Srgrimes	&i860_elf32_le_vec,
11181592Srgrimes
11191592Srgrimes	&i960_elf32_vec,
11201592Srgrimes
11211592Srgrimes#ifdef BFD64
11221592Srgrimes#if 0
11231592Srgrimes	&ia64_elf32_be_vec,
11241592Srgrimes#endif
11251592Srgrimes	&ia64_elf32_hpux_be_vec,
11261592Srgrimes	&ia64_elf64_be_vec,
11271592Srgrimes	&ia64_elf64_le_vec,
11281592Srgrimes	&ia64_elf64_hpux_be_vec,
11291592Srgrimes	&ia64_elf64_vms_vec,
11301592Srgrimes	&ia64_pei_vec,
11311592Srgrimes#endif
11321592Srgrimes
11331592Srgrimes	&icoff_be_vec,
11341592Srgrimes	&icoff_le_vec,
11351592Srgrimes
11361592Srgrimes	&ieee_vec,
11371592Srgrimes
11381592Srgrimes	&ip2k_elf32_vec,
11391592Srgrimes	&iq2000_elf32_vec,
11401592Srgrimes
11411592Srgrimes#ifdef BFD64
11421592Srgrimes	&k1om_elf64_vec,
11431592Srgrimes	&k1om_elf64_fbsd_vec,
11441592Srgrimes	&l1om_elf64_vec,
11451592Srgrimes	&l1om_elf64_fbsd_vec,
11461592Srgrimes#endif
11471592Srgrimes
11481592Srgrimes	&lm32_elf32_vec,
11491592Srgrimes
11501592Srgrimes	&m32c_elf32_vec,
11511592Srgrimes
11521592Srgrimes	&m32r_elf32_vec,
11531592Srgrimes	&m32r_elf32_le_vec,
11541592Srgrimes	&m32r_elf32_linux_vec,
11551592Srgrimes	&m32r_elf32_linux_le_vec,
11561592Srgrimes
11571592Srgrimes	&m68hc11_elf32_vec,
11581592Srgrimes	&m68hc12_elf32_vec,
11591592Srgrimes
11601592Srgrimes#if 0
11611592Srgrimes	&m68k_aout_4knbsd_vec,
11621592Srgrimes	/* Clashes with sparc_aout_sunos_be_vec magic no.  */
11631592Srgrimes	&m68k_aout_hp300bsd_vec,
11641592Srgrimes#endif
11651592Srgrimes	&m68k_aout_hp300hpux_vec,
11661592Srgrimes#if 0
11671592Srgrimes	/* Since a.out files lack decent magic numbers, no way to recognize
11681592Srgrimes	   which kind of a.out file it is.  */
11691592Srgrimes	&m68k_aout_linux_vec,
11701592Srgrimes#endif
11711592Srgrimes	&m68k_aout_nbsd_vec,
11721592Srgrimes	&m68k_aout_newsos3_vec,
11731592Srgrimes	&m68k_coff_vec,
11741592Srgrimes#if 0
11751592Srgrimes	&m68k_coff_apollo_vec,
11761592Srgrimes	&m68k_coff_aux_vec,
11771592Srgrimes#endif
11781592Srgrimes	&m68k_coff_sysv_vec,
11791592Srgrimes	&m68k_coff_un_vec,
11801592Srgrimes	&m68k_elf32_vec,
11811592Srgrimes	&m68k_versados_vec,
11821592Srgrimes
11831592Srgrimes	&m88k_aout_mach3_vec,
11841592Srgrimes	&m88k_aout_obsd_vec,
11851592Srgrimes	&m88k_coff_bcs_vec,
11861592Srgrimes	&m88k_elf32_vec,
11871592Srgrimes
11881592Srgrimes	&mach_o_be_vec,
11891592Srgrimes	&mach_o_le_vec,
11901592Srgrimes	&mach_o_fat_vec,
11911592Srgrimes
11921592Srgrimes	&mcore_elf32_be_vec,
11931592Srgrimes	&mcore_elf32_le_vec,
11941592Srgrimes	&mcore_pe_be_vec,
11951592Srgrimes	&mcore_pe_le_vec,
11961592Srgrimes	&mcore_pei_be_vec,
11971592Srgrimes	&mcore_pei_le_vec,
11981592Srgrimes
11991592Srgrimes	&mep_elf32_vec,
12001592Srgrimes
12011592Srgrimes	&metag_elf32_vec,
12021592Srgrimes
12031592Srgrimes	&microblaze_elf32_vec,
12041592Srgrimes
12051592Srgrimes#if 0
12061592Srgrimes	/* No one seems to use this.  */
12071592Srgrimes	&mips_aout_be_vec,
12081592Srgrimes#endif
12091592Srgrimes	&mips_aout_le_vec,
12101592Srgrimes	&mips_ecoff_be_vec,
12111592Srgrimes	&mips_ecoff_le_vec,
12121592Srgrimes	&mips_ecoff_bele_vec,
12131592Srgrimes#ifdef BFD64
12141592Srgrimes	&mips_elf32_be_vec,
12151592Srgrimes	&mips_elf32_le_vec,
12161592Srgrimes	&mips_elf32_n_be_vec,
12171592Srgrimes	&mips_elf32_n_le_vec,
12181592Srgrimes	&mips_elf32_ntrad_be_vec,
12191592Srgrimes	&mips_elf32_ntrad_le_vec,
12201592Srgrimes	&mips_elf32_ntradfbsd_be_vec,
12211592Srgrimes	&mips_elf32_ntradfbsd_le_vec,
12221592Srgrimes	&mips_elf32_trad_be_vec,
12231592Srgrimes	&mips_elf32_trad_le_vec,
12241592Srgrimes	&mips_elf32_tradfbsd_be_vec,
12251592Srgrimes	&mips_elf32_tradfbsd_le_vec,
12261592Srgrimes	&mips_elf32_vxworks_be_vec,
12271592Srgrimes	&mips_elf32_vxworks_le_vec,
12281592Srgrimes	&mips_elf64_be_vec,
12291592Srgrimes	&mips_elf64_le_vec,
12301592Srgrimes	&mips_elf64_trad_be_vec,
12311592Srgrimes	&mips_elf64_trad_le_vec,
12321592Srgrimes	&mips_elf64_tradfbsd_be_vec,
12331592Srgrimes	&mips_elf64_tradfbsd_le_vec,
12341592Srgrimes#endif
12351592Srgrimes	&mips_pe_le_vec,
12361592Srgrimes	&mips_pei_le_vec,
12371592Srgrimes
12381592Srgrimes#ifdef BFD64
12391592Srgrimes	&mmix_elf64_vec,
12401592Srgrimes	&mmix_mmo_vec,
12411592Srgrimes#endif
12421592Srgrimes
12431592Srgrimes	&mn10200_elf32_vec,
12441592Srgrimes	&mn10300_elf32_vec,
12451592Srgrimes
12461592Srgrimes	&moxie_elf32_be_vec,
12471592Srgrimes	&moxie_elf32_le_vec,
12481592Srgrimes
12491592Srgrimes	&msp430_elf32_vec,
12501592Srgrimes	&msp430_elf32_ti_vec,
12511592Srgrimes
12521592Srgrimes	&mt_elf32_vec,
12531592Srgrimes
12541592Srgrimes	&nds32_elf32_be_vec,
12551592Srgrimes	&nds32_elf32_le_vec,
12561592Srgrimes	&nds32_elf32_linux_be_vec,
12571592Srgrimes	&nds32_elf32_linux_le_vec,
12581592Srgrimes
12591592Srgrimes	&nios2_elf32_be_vec,
12601592Srgrimes	&nios2_elf32_le_vec,
12611592Srgrimes
12621592Srgrimes	&ns32k_aout_pc532mach_vec,
12631592Srgrimes	&ns32k_aout_pc532nbsd_vec,
12641592Srgrimes
12651592Srgrimes#if 0
12661592Srgrimes	/* We have no oasys tools anymore, so we can't test any of this
12671592Srgrimes	   anymore. If you want to test the stuff yourself, go ahead...
12681592Srgrimes	   steve@cygnus.com
12691592Srgrimes	   Worse, since there is no magic number for archives, there
12701592Srgrimes	   can be annoying target mis-matches.  */
12711592Srgrimes	&oasys_vec,
12721592Srgrimes#endif
12731592Srgrimes
12741592Srgrimes	&or1k_elf32_vec,
12751592Srgrimes
12761592Srgrimes	&pdp11_aout_vec,
12771592Srgrimes
12781592Srgrimes	&pef_vec,
12791592Srgrimes	&pef_xlib_vec,
12801592Srgrimes
12811592Srgrimes	&pj_elf32_vec,
12821592Srgrimes	&pj_elf32_le_vec,
12831592Srgrimes
12841592Srgrimes#if BFD_SUPPORTS_PLUGINS
12851592Srgrimes	&plugin_vec,
12861592Srgrimes#endif
12871592Srgrimes
12881592Srgrimes	&powerpc_boot_vec,
12891592Srgrimes	&powerpc_elf32_vec,
12901592Srgrimes	&powerpc_elf32_le_vec,
12911592Srgrimes	&powerpc_elf32_fbsd_vec,
12921592Srgrimes	&powerpc_elf32_vxworks_vec,
12931592Srgrimes#ifdef BFD64
12941592Srgrimes	&powerpc_elf64_vec,
12951592Srgrimes	&powerpc_elf64_le_vec,
12961592Srgrimes	&powerpc_elf64_fbsd_vec,
12971592Srgrimes#endif
12981592Srgrimes	&powerpc_nlm32_vec,
12991592Srgrimes	&powerpc_pe_vec,
13001592Srgrimes	&powerpc_pe_le_vec,
13011592Srgrimes	&powerpc_pei_vec,
13021592Srgrimes	&powerpc_pei_le_vec,
13031592Srgrimes#if 0
13041592Srgrimes	/* This has the same magic number as RS/6000.  */
13051592Srgrimes	&powerpc_xcoff_vec,
13061592Srgrimes#endif
13071592Srgrimes
13081592Srgrimes#ifdef BFD64
13091592Srgrimes	&riscv_elf32_vec,
13101592Srgrimes	&riscv_elf64_vec,
13111592Srgrimes#endif
13121592Srgrimes	&rl78_elf32_vec,
13131592Srgrimes
13141592Srgrimes#ifdef BFD64
13151592Srgrimes	&rs6000_xcoff64_vec,
13161592Srgrimes	&rs6000_xcoff64_aix_vec,
13171592Srgrimes#endif
13181592Srgrimes	&rs6000_xcoff_vec,
13191592Srgrimes
13201592Srgrimes	&rx_elf32_be_vec,
13211592Srgrimes	&rx_elf32_be_ns_vec,
13221592Srgrimes	&rx_elf32_le_vec,
13231592Srgrimes
13241592Srgrimes	&s390_elf32_vec,
13251592Srgrimes#ifdef BFD64
13261592Srgrimes	&s390_elf64_vec,
13271592Srgrimes#endif
13281592Srgrimes
13291592Srgrimes#ifdef BFD64
13301592Srgrimes	&score_elf32_be_vec,
13311592Srgrimes	&score_elf32_le_vec,
13321592Srgrimes#endif
13331592Srgrimes
13341592Srgrimes#ifdef BFD64
13351592Srgrimes	&sh64_elf32_vec,
13361592Srgrimes	&sh64_elf32_le_vec,
13371592Srgrimes	&sh64_elf32_linux_vec,
13381592Srgrimes	&sh64_elf32_linux_be_vec,
13391592Srgrimes	&sh64_elf32_nbsd_vec,
13401592Srgrimes	&sh64_elf32_nbsd_le_vec,
13411592Srgrimes	&sh64_elf64_vec,
13421592Srgrimes	&sh64_elf64_le_vec,
13431592Srgrimes	&sh64_elf64_linux_vec,
13441592Srgrimes	&sh64_elf64_linux_be_vec,
13451592Srgrimes	&sh64_elf64_nbsd_vec,
13461592Srgrimes	&sh64_elf64_nbsd_le_vec,
13471592Srgrimes#endif
13481592Srgrimes	&sh_coff_vec,
13491592Srgrimes	&sh_coff_le_vec,
13501592Srgrimes	&sh_coff_small_vec,
13511592Srgrimes	&sh_coff_small_le_vec,
13521592Srgrimes	&sh_elf32_vec,
13531592Srgrimes	&sh_elf32_le_vec,
13541592Srgrimes	&sh_elf32_fdpic_be_vec,
13551592Srgrimes	&sh_elf32_fdpic_le_vec,
13561592Srgrimes	&sh_elf32_linux_vec,
13571592Srgrimes	&sh_elf32_linux_be_vec,
13581592Srgrimes	&sh_elf32_nbsd_vec,
13591592Srgrimes	&sh_elf32_nbsd_le_vec,
13601592Srgrimes	&sh_elf32_symbian_le_vec,
13611592Srgrimes	&sh_elf32_vxworks_vec,
13621592Srgrimes	&sh_elf32_vxworks_le_vec,
13631592Srgrimes	&sh_pe_le_vec,
13641592Srgrimes	&sh_pei_le_vec,
13651592Srgrimes
13661592Srgrimes	&sparc_aout_le_vec,
13671592Srgrimes	&sparc_aout_linux_vec,
13681592Srgrimes	&sparc_aout_lynx_vec,
13691592Srgrimes	&sparc_aout_nbsd_vec,
13701592Srgrimes	&sparc_aout_sunos_be_vec,
13711592Srgrimes	&sparc_coff_vec,
13721592Srgrimes	&sparc_coff_lynx_vec,
13731592Srgrimes	&sparc_elf32_vec,
13741592Srgrimes	&sparc_elf32_sol2_vec,
13751592Srgrimes	&sparc_elf32_vxworks_vec,
13761592Srgrimes#ifdef BFD64
13771592Srgrimes	&sparc_elf64_vec,
13781592Srgrimes	&sparc_elf64_fbsd_vec,
13791592Srgrimes	&sparc_elf64_sol2_vec,
13801592Srgrimes#endif
13811592Srgrimes	&sparc_nlm32_vec,
13821592Srgrimes
13831592Srgrimes	&spu_elf32_vec,
13841592Srgrimes
13851592Srgrimes	&sym_vec,
13861592Srgrimes
13871592Srgrimes	&tic30_aout_vec,
13881592Srgrimes	&tic30_coff_vec,
13891592Srgrimes	&tic54x_coff0_beh_vec,
13901592Srgrimes	&tic54x_coff0_vec,
13911592Srgrimes	&tic54x_coff1_beh_vec,
13921592Srgrimes	&tic54x_coff1_vec,
13931592Srgrimes	&tic54x_coff2_beh_vec,
13941592Srgrimes	&tic54x_coff2_vec,
13951592Srgrimes	&tic6x_elf32_be_vec,
13961592Srgrimes	&tic6x_elf32_le_vec,
13971592Srgrimes	&tic80_coff_vec,
13981592Srgrimes
13991592Srgrimes	&tilegx_elf32_be_vec,
14001592Srgrimes	&tilegx_elf32_le_vec,
14011592Srgrimes#ifdef BFD64
14021592Srgrimes	&tilegx_elf64_be_vec,
14031592Srgrimes	&tilegx_elf64_le_vec,
14041592Srgrimes#endif
14051592Srgrimes	&tilepro_elf32_vec,
14061592Srgrimes
14071592Srgrimes	&ft32_elf32_vec,
14081592Srgrimes
14091592Srgrimes	&v800_elf32_vec,
14101592Srgrimes	&v850_elf32_vec,
14111592Srgrimes
14121592Srgrimes	&vax_aout_1knbsd_vec,
14131592Srgrimes	&vax_aout_bsd_vec,
14141592Srgrimes	&vax_aout_nbsd_vec,
14151592Srgrimes	&vax_elf32_vec,
14161592Srgrimes
14171592Srgrimes	&visium_elf32_vec,
14181592Srgrimes
14191592Srgrimes	&w65_coff_vec,
14201592Srgrimes
14211592Srgrimes	&we32k_coff_vec,
14221592Srgrimes
14231592Srgrimes#ifdef BFD64
14241592Srgrimes	&x86_64_coff_vec,
14251592Srgrimes	&x86_64_elf32_vec,
14261592Srgrimes	&x86_64_elf32_nacl_vec,
14271592Srgrimes	&x86_64_elf64_vec,
14281592Srgrimes	&x86_64_elf64_cloudabi_vec,
14291592Srgrimes	&x86_64_elf64_fbsd_vec,
14301592Srgrimes	&x86_64_elf64_nacl_vec,
14311592Srgrimes	&x86_64_elf64_sol2_vec,
14321592Srgrimes	&x86_64_mach_o_vec,
14331592Srgrimes	&x86_64_pe_vec,
14341592Srgrimes	&x86_64_pe_be_vec,
14351592Srgrimes	&x86_64_pei_vec,
14361592Srgrimes#endif
14371592Srgrimes
14381592Srgrimes	&xc16x_elf32_vec,
14391592Srgrimes
14401592Srgrimes	&xgate_elf32_vec,
14411592Srgrimes
14421592Srgrimes	&xstormy16_elf32_vec,
14431592Srgrimes
14441592Srgrimes	&xtensa_elf32_be_vec,
14451592Srgrimes	&xtensa_elf32_le_vec,
14461592Srgrimes
14471592Srgrimes	&z80_coff_vec,
14481592Srgrimes
14491592Srgrimes	&z8k_coff_vec,
14501592Srgrimes#endif /* not SELECT_VECS */
14511592Srgrimes
14521592Srgrimes/* Always support S-records, for convenience.  */
14531592Srgrimes	&srec_vec,
14541592Srgrimes	&symbolsrec_vec,
14551592Srgrimes/* And verilog.  */
14561592Srgrimes	&verilog_vec,
14571592Srgrimes/* And tekhex */
14581592Srgrimes	&tekhex_vec,
14591592Srgrimes/* Likewise for binary output.  */
14601592Srgrimes	&binary_vec,
14611592Srgrimes/* Likewise for ihex.  */
14621592Srgrimes	&ihex_vec,
14631592Srgrimes
14641592Srgrimes/* Add any required traditional-core-file-handler.  */
14651592Srgrimes
14661592Srgrimes#ifdef AIX386_CORE
14671592Srgrimes	&core_aix386_vec,
14681592Srgrimes#endif
14691592Srgrimes#if 0
14701592Srgrimes	/* We don't include cisco_core_*_vec.  Although it has a magic number,
14711592Srgrimes	   the magic number isn't at the beginning of the file, and thus
14721592Srgrimes	   might spuriously match other kinds of files.  */
14731592Srgrimes	&core_cisco_be_vec,
14741592Srgrimes	&core_cisco_le_vec,
14751592Srgrimes#endif
14761592Srgrimes#ifdef HPPABSD_CORE
14771592Srgrimes	&core_hppabsd_vec,
14781592Srgrimes#endif
14791592Srgrimes#ifdef HPUX_CORE
14801592Srgrimes	&core_hpux_vec,
14811592Srgrimes#endif
14821592Srgrimes#ifdef IRIX_CORE
14831592Srgrimes	&core_irix_vec,
14841592Srgrimes#endif
14851592Srgrimes#ifdef NETBSD_CORE
14861592Srgrimes	&core_netbsd_vec,
14871592Srgrimes#endif
14881592Srgrimes#ifdef OSF_CORE
14891592Srgrimes	&core_osf_vec,
14901592Srgrimes#endif
14911592Srgrimes#ifdef PTRACE_CORE
14921592Srgrimes	&core_ptrace_vec,
14931592Srgrimes#endif
14941592Srgrimes#ifdef SCO5_CORE
14951592Srgrimes	&core_sco5_vec,
14961592Srgrimes#endif
14971592Srgrimes#ifdef TRAD_CORE
14981592Srgrimes	&core_trad_vec,
14991592Srgrimes#endif
15001592Srgrimes
15011592Srgrimes	NULL /* end of list marker */
15021592Srgrimes};
15031592Srgrimesconst bfd_target * const *bfd_target_vector = _bfd_target_vector;
15041592Srgrimes
15051592Srgrimes/* bfd_default_vector[0] contains either the address of the default vector,
15061592Srgrimes   if there is one, or zero if there isn't.  */
15071592Srgrimes
15081592Srgrimesconst bfd_target *bfd_default_vector[] = {
15091592Srgrimes#ifdef DEFAULT_VECTOR
15101592Srgrimes	&DEFAULT_VECTOR,
15111592Srgrimes#endif
15121592Srgrimes	NULL
15131592Srgrimes};
15141592Srgrimes
15151592Srgrimes/* bfd_associated_vector[] contains the associated target vectors used
15161592Srgrimes   to reduce the ambiguity in bfd_check_format_matches.  */
15171592Srgrimes
15181592Srgrimesstatic const bfd_target *_bfd_associated_vector[] = {
15191592Srgrimes#ifdef ASSOCIATED_VECS
15201592Srgrimes	ASSOCIATED_VECS,
15211592Srgrimes#endif
15221592Srgrimes	NULL
15231592Srgrimes};
15241592Srgrimesconst bfd_target * const *bfd_associated_vector = _bfd_associated_vector;
15251592Srgrimes
15261592Srgrimes/* When there is an ambiguous match, bfd_check_format_matches puts the
15271592Srgrimes   names of the matching targets in an array.  This variable is the maximum
15281592Srgrimes   number of entries that the array could possibly need.  */
15291592Srgrimesconst size_t _bfd_target_vector_entries = sizeof (_bfd_target_vector)/sizeof (*_bfd_target_vector);
15301592Srgrimes
15311592Srgrimes/* This array maps configuration triplets onto BFD vectors.  */
15321592Srgrimes
15331592Srgrimesstruct targmatch
15341592Srgrimes{
15351592Srgrimes  /* The configuration triplet.  */
15361592Srgrimes  const char *triplet;
15371592Srgrimes  /* The BFD vector.  If this is NULL, then the vector is found by
15381592Srgrimes     searching forward for the next structure with a non NULL vector
15391592Srgrimes     field.  */
15401592Srgrimes  const bfd_target *vector;
15411592Srgrimes};
15421592Srgrimes
15431592Srgrimes/* targmatch.h is built by Makefile out of config.bfd.  */
15441592Srgrimesstatic const struct targmatch bfd_target_match[] = {
15451592Srgrimes#include "targmatch.h"
15461592Srgrimes  { NULL, NULL }
15471592Srgrimes};
15481592Srgrimes
15491592Srgrimes/* Find a target vector, given a name or configuration triplet.  */
15501592Srgrimes
15511592Srgrimesstatic const bfd_target *
15521592Srgrimesfind_target (const char *name)
15531592Srgrimes{
15541592Srgrimes  const bfd_target * const *target;
15551592Srgrimes  const struct targmatch *match;
15561592Srgrimes
15571592Srgrimes  for (target = &bfd_target_vector[0]; *target != NULL; target++)
15581592Srgrimes    if (strcmp (name, (*target)->name) == 0)
15591592Srgrimes      return *target;
15601592Srgrimes
15611592Srgrimes  /* If we couldn't match on the exact name, try matching on the
15621592Srgrimes     configuration triplet.  FIXME: We should run the triplet through
15631592Srgrimes     config.sub first, but that is hard.  */
15641592Srgrimes  for (match = &bfd_target_match[0]; match->triplet != NULL; match++)
15651592Srgrimes    {
15661592Srgrimes      if (fnmatch (match->triplet, name, 0) == 0)
15671592Srgrimes	{
15681592Srgrimes	  while (match->vector == NULL)
15691592Srgrimes	    ++match;
15701592Srgrimes	  return match->vector;
15711592Srgrimes	}
15721592Srgrimes    }
15731592Srgrimes
15741592Srgrimes  bfd_set_error (bfd_error_invalid_target);
15751592Srgrimes  return NULL;
15761592Srgrimes}
15771592Srgrimes
15781592Srgrimes/*
15791592SrgrimesFUNCTION
15801592Srgrimes	bfd_set_default_target
15811592Srgrimes
15821592SrgrimesSYNOPSIS
15831592Srgrimes	bfd_boolean bfd_set_default_target (const char *name);
15841592Srgrimes
15851592SrgrimesDESCRIPTION
15861592Srgrimes	Set the default target vector to use when recognizing a BFD.
15871592Srgrimes	This takes the name of the target, which may be a BFD target
15881592Srgrimes	name or a configuration triplet.
15891592Srgrimes*/
15901592Srgrimes
15911592Srgrimesbfd_boolean
15921592Srgrimesbfd_set_default_target (const char *name)
15931592Srgrimes{
15941592Srgrimes  const bfd_target *target;
15951592Srgrimes
15961592Srgrimes  if (bfd_default_vector[0] != NULL
15971592Srgrimes      && strcmp (name, bfd_default_vector[0]->name) == 0)
15981592Srgrimes    return TRUE;
15991592Srgrimes
16001592Srgrimes  target = find_target (name);
16011592Srgrimes  if (target == NULL)
16021592Srgrimes    return FALSE;
16031592Srgrimes
16041592Srgrimes  bfd_default_vector[0] = target;
16051592Srgrimes  return TRUE;
16061592Srgrimes}
16071592Srgrimes
16081592Srgrimes/*
16091592SrgrimesFUNCTION
16101592Srgrimes	bfd_find_target
16111592Srgrimes
16121592SrgrimesSYNOPSIS
16131592Srgrimes	const bfd_target *bfd_find_target (const char *target_name, bfd *abfd);
16141592Srgrimes
16151592SrgrimesDESCRIPTION
16161592Srgrimes	Return a pointer to the transfer vector for the object target
16171592Srgrimes	named @var{target_name}.  If @var{target_name} is <<NULL>>,
16181592Srgrimes	choose the one in the environment variable <<GNUTARGET>>; if
16191592Srgrimes	that is null or not defined, then choose the first entry in the
16201592Srgrimes	target list.  Passing in the string "default" or setting the
16211592Srgrimes	environment variable to "default" will cause the first entry in
16221592Srgrimes	the target list to be returned, and "target_defaulted" will be
16231592Srgrimes	set in the BFD if @var{abfd} isn't <<NULL>>.  This causes
16241592Srgrimes	<<bfd_check_format>> to loop over all the targets to find the
16251592Srgrimes	one that matches the file being read.
16261592Srgrimes*/
16271592Srgrimes
16281592Srgrimesconst bfd_target *
16291592Srgrimesbfd_find_target (const char *target_name, bfd *abfd)
16301592Srgrimes{
16311592Srgrimes  const char *targname;
16321592Srgrimes  const bfd_target *target;
16331592Srgrimes
16341592Srgrimes  if (target_name != NULL)
16351592Srgrimes    targname = target_name;
16361592Srgrimes  else
16371592Srgrimes    targname = getenv ("GNUTARGET");
16381592Srgrimes
16391592Srgrimes  /* This is safe; the vector cannot be null.  */
16401592Srgrimes  if (targname == NULL || strcmp (targname, "default") == 0)
16411592Srgrimes    {
16421592Srgrimes      if (bfd_default_vector[0] != NULL)
16431592Srgrimes	target = bfd_default_vector[0];
16441592Srgrimes      else
16451592Srgrimes	target = bfd_target_vector[0];
16461592Srgrimes      if (abfd)
16471592Srgrimes	{
16481592Srgrimes	  abfd->xvec = target;
16491592Srgrimes	  abfd->target_defaulted = TRUE;
16501592Srgrimes	}
16511592Srgrimes      return target;
16521592Srgrimes    }
16531592Srgrimes
16541592Srgrimes  if (abfd)
16551592Srgrimes    abfd->target_defaulted = FALSE;
16561592Srgrimes
16571592Srgrimes  target = find_target (targname);
16581592Srgrimes  if (target == NULL)
16591592Srgrimes    return NULL;
16601592Srgrimes
16611592Srgrimes  if (abfd)
16621592Srgrimes    abfd->xvec = target;
16631592Srgrimes  return target;
16641592Srgrimes}
16651592Srgrimes
16661592Srgrimes/* Helper function for bfd_get_target_info to determine the target's
16671592Srgrimes   architecture.  This method handles bfd internal target names as
16681592Srgrimes   tuples and triplets.  */
16691592Srgrimesstatic bfd_boolean
16701592Srgrimes_bfd_find_arch_match (const char *tname, const char **arch,
16711592Srgrimes		      const char **def_target_arch)
16721592Srgrimes{
16731592Srgrimes  if (!arch)
16741592Srgrimes    return FALSE;
16751592Srgrimes
16761592Srgrimes  while (*arch != NULL)
16771592Srgrimes    {
16781592Srgrimes      const char *in_a = strstr (*arch, tname);
16791592Srgrimes      char end_ch = (in_a ? in_a[strlen (tname)] : 0);
16801592Srgrimes
16811592Srgrimes      if (in_a && (in_a == *arch || in_a[-1] == ':')
16821592Srgrimes          && end_ch == 0)
16831592Srgrimes        {
16841592Srgrimes          *def_target_arch = *arch;
16851592Srgrimes          return TRUE;
16861592Srgrimes        }
16871592Srgrimes      arch++;
16881592Srgrimes    }
16891592Srgrimes  return FALSE;
16901592Srgrimes}
16911592Srgrimes
16921592Srgrimes/*
16931592SrgrimesFUNCTION
16941592Srgrimes	bfd_get_target_info
16951592SrgrimesSYNOPSIS
16961592Srgrimes	const bfd_target *bfd_get_target_info (const char *target_name,
16971592Srgrimes					       bfd *abfd,
16981592Srgrimes					       bfd_boolean *is_bigendian,
16991592Srgrimes					       int *underscoring,
17001592Srgrimes					       const char **def_target_arch);
17011592SrgrimesDESCRIPTION
17021592Srgrimes        Return a pointer to the transfer vector for the object target
17031592Srgrimes        named @var{target_name}.  If @var{target_name} is <<NULL>>,
17041592Srgrimes        choose the one in the environment variable <<GNUTARGET>>; if
17051592Srgrimes        that is null or not defined, then choose the first entry in the
17061592Srgrimes        target list.  Passing in the string "default" or setting the
17071592Srgrimes        environment variable to "default" will cause the first entry in
17081592Srgrimes        the target list to be returned, and "target_defaulted" will be
17091592Srgrimes        set in the BFD if @var{abfd} isn't <<NULL>>.  This causes
17101592Srgrimes        <<bfd_check_format>> to loop over all the targets to find the
17111592Srgrimes        one that matches the file being read.
17121592Srgrimes	If @var{is_bigendian} is not <<NULL>>, then set this value to target's
17131592Srgrimes	endian mode. True for big-endian, FALSE for little-endian or for
17141592Srgrimes	invalid target.
17151592Srgrimes	If @var{underscoring} is not <<NULL>>, then set this value to target's
17161592Srgrimes	underscoring mode. Zero for none-underscoring, -1 for invalid target,
17171592Srgrimes	else the value of target vector's symbol underscoring.
17186740Sguido	If @var{def_target_arch} is not <<NULL>>, then set it to the architecture
17196740Sguido	string specified by the target_name.
17206740Sguido*/
17216740Sguidoconst bfd_target *
17226740Sguidobfd_get_target_info (const char *target_name, bfd *abfd,
17236740Sguido		     bfd_boolean *is_bigendian,
17246740Sguido		     int *underscoring, const char **def_target_arch)
17256740Sguido{
17266740Sguido  const bfd_target *target_vec;
17276740Sguido
17286740Sguido  if (is_bigendian)
17296740Sguido    *is_bigendian = FALSE;
17306740Sguido  if (underscoring)
17316740Sguido    *underscoring = -1;
17326740Sguido  if (def_target_arch)
17336740Sguido    *def_target_arch = NULL;
17346740Sguido  target_vec = bfd_find_target (target_name, abfd);
17356740Sguido  if (! target_vec)
17366740Sguido    return NULL;
17376740Sguido  if (is_bigendian)
17386740Sguido    *is_bigendian = ((target_vec->byteorder == BFD_ENDIAN_BIG) ? TRUE
17396740Sguido							       : FALSE);
17406740Sguido  if (underscoring)
17416740Sguido    *underscoring = ((int) target_vec->symbol_leading_char) & 0xff;
17426740Sguido
17436740Sguido  if (def_target_arch)
17446740Sguido    {
17456740Sguido      const char *tname = target_vec->name;
17466740Sguido      const char **arches = bfd_arch_list ();
17476740Sguido
17486740Sguido      if (arches && tname)
17496740Sguido        {
17506740Sguido          char *hyp = strchr (tname, '-');
1751
1752          if (hyp != NULL)
1753            {
1754              tname = ++hyp;
1755
1756	      /* Make sure we detect architecture names
1757		 for triplets like "pe-arm-wince-little".  */
1758	      if (!_bfd_find_arch_match (tname, arches, def_target_arch))
1759		{
1760		  char new_tname[50];
1761
1762		  strcpy (new_tname, hyp);
1763		  while ((hyp = strrchr (new_tname, '-')) != NULL)
1764		    {
1765		      *hyp = 0;
1766		      if (_bfd_find_arch_match (new_tname, arches,
1767						def_target_arch))
1768			break;
1769		    }
1770		}
1771	    }
1772	  else
1773	    _bfd_find_arch_match (tname, arches, def_target_arch);
1774	}
1775
1776      if (arches)
1777        free (arches);
1778    }
1779  return target_vec;
1780}
1781
1782/*
1783FUNCTION
1784	bfd_target_list
1785
1786SYNOPSIS
1787	const char ** bfd_target_list (void);
1788
1789DESCRIPTION
1790	Return a freshly malloced NULL-terminated
1791	vector of the names of all the valid BFD targets. Do not
1792	modify the names.
1793
1794*/
1795
1796const char **
1797bfd_target_list (void)
1798{
1799  int vec_length = 0;
1800  bfd_size_type amt;
1801  const bfd_target * const *target;
1802  const  char **name_list, **name_ptr;
1803
1804  for (target = &bfd_target_vector[0]; *target != NULL; target++)
1805    vec_length++;
1806
1807  amt = (vec_length + 1) * sizeof (char **);
1808  name_ptr = name_list = (const  char **) bfd_malloc (amt);
1809
1810  if (name_list == NULL)
1811    return NULL;
1812
1813  for (target = &bfd_target_vector[0]; *target != NULL; target++)
1814    if (target == &bfd_target_vector[0]
1815	|| *target != bfd_target_vector[0])
1816      *name_ptr++ = (*target)->name;
1817
1818  *name_ptr = NULL;
1819  return name_list;
1820}
1821
1822/*
1823FUNCTION
1824	bfd_iterate_over_targets
1825
1826SYNOPSIS
1827	const bfd_target *bfd_iterate_over_targets
1828	  (int (*func) (const bfd_target *, void *),
1829	   void *data);
1830
1831DESCRIPTION
1832	Call @var{func} for each target in the list of BFD target
1833	vectors, passing @var{data} to @var{func}.  Stop iterating if
1834	@var{func} returns a non-zero result, and return that target
1835	vector.  Return NULL if @var{func} always returns zero.
1836*/
1837
1838const bfd_target *
1839bfd_iterate_over_targets (int (*func) (const bfd_target *, void *),
1840			  void *data)
1841{
1842  const bfd_target *const *target;
1843
1844  for (target = bfd_target_vector; *target != NULL; ++target)
1845    if (func (*target, data))
1846      return *target;
1847
1848  return NULL;
1849}
1850
1851/*
1852FUNCTION
1853	bfd_flavour_name
1854
1855SYNOPSIS
1856	const char *bfd_flavour_name (enum bfd_flavour flavour);
1857
1858DESCRIPTION
1859	Return the string form of @var{flavour}.
1860*/
1861
1862const char *
1863bfd_flavour_name (enum bfd_flavour flavour)
1864{
1865  switch (flavour)
1866    {
1867    case bfd_target_unknown_flavour: return "unknown file format";
1868    case bfd_target_aout_flavour: return "a.out";
1869    case bfd_target_coff_flavour: return "COFF";
1870    case bfd_target_ecoff_flavour: return "ECOFF";
1871    case bfd_target_xcoff_flavour: return "XCOFF";
1872    case bfd_target_elf_flavour: return "ELF";
1873    case bfd_target_ieee_flavour: return "IEEE";
1874    case bfd_target_nlm_flavour: return "NLM";
1875    case bfd_target_oasys_flavour: return "Oasys";
1876    case bfd_target_tekhex_flavour: return "Tekhex";
1877    case bfd_target_srec_flavour: return "Srec";
1878    case bfd_target_verilog_flavour: return "Verilog";
1879    case bfd_target_ihex_flavour: return "Ihex";
1880    case bfd_target_som_flavour: return "SOM";
1881    case bfd_target_os9k_flavour: return "OS9K";
1882    case bfd_target_versados_flavour: return "Versados";
1883    case bfd_target_msdos_flavour: return "MSDOS";
1884    case bfd_target_ovax_flavour: return "Ovax";
1885    case bfd_target_evax_flavour: return "Evax";
1886    case bfd_target_mmo_flavour: return "mmo";
1887    case bfd_target_mach_o_flavour: return "MACH_O";
1888    case bfd_target_pef_flavour: return "PEF";
1889    case bfd_target_pef_xlib_flavour: return "PEF_XLIB";
1890    case bfd_target_sym_flavour: return "SYM";
1891    /* There is no "default" case here so that -Wswitch (part of -Wall)
1892       catches missing entries.  */
1893    }
1894
1895  abort ();
1896}
1897