Home | History | Annotate | Line # | Download | only in doc
      1 @section Targets
      2 
      3 
      4 Each port of BFD to a different machine requires the creation
      5 of a target back end. All the back end provides to the root
      6 part of BFD is a structure containing pointers to functions
      7 which perform certain low level operations on files. BFD
      8 translates the applications's requests through a pointer into
      9 calls to the back end routines.
     10 
     11 When a file is opened with @code{bfd_openr}, its format and
     12 target are unknown. BFD uses various mechanisms to determine
     13 how to interpret the file. The operations performed are:
     14 
     15 @itemize @bullet
     16 
     17 @item
     18 Create a BFD by calling the internal routine
     19 @code{_bfd_new_bfd}, then call @code{bfd_find_target} with the
     20 target string supplied to @code{bfd_openr} and the new BFD pointer.
     21 
     22 @item
     23 If a null target string was provided to @code{bfd_find_target},
     24 look up the environment variable @code{GNUTARGET} and use
     25 that as the target string.
     26 
     27 @item
     28 If the target string is still @code{NULL}, or the target string is
     29 @code{default}, then use the first item in the target vector
     30 as the target type, and set @code{target_defaulted} in the BFD to
     31 cause @code{bfd_check_format} to loop through all the targets.
     32 @xref{bfd_target}.  @xref{Formats}.
     33 
     34 @item
     35 Otherwise, inspect the elements in the target vector
     36 one by one, until a match on target name is found. When found,
     37 use it.
     38 
     39 @item
     40 Otherwise return the error @code{bfd_error_invalid_target} to
     41 @code{bfd_openr}.
     42 
     43 @item
     44 @code{bfd_openr} attempts to open the file using
     45 @code{bfd_open_file}, and returns the BFD.
     46 @end itemize
     47 Once the BFD has been opened and the target selected, the file
     48 format may be determined. This is done by calling
     49 @code{bfd_check_format} on the BFD with a suggested format.
     50 If @code{target_defaulted} has been set, each possible target
     51 type is tried to see if it recognizes the specified format.
     52 @code{bfd_check_format} returns @code{TRUE} when the caller guesses right.
     53 @menu
     54 * bfd_target::
     55 @end menu
     56 
     57 @node bfd_target,  , Targets, Targets
     58 
     59 @subsection bfd_target
     60 
     61 
     62 This structure contains everything that BFD knows about a
     63 target. It includes things like its byte order, name, and which
     64 routines to call to do various operations.
     65 
     66 Every BFD points to a target structure with its @code{xvec}
     67 member.
     68 
     69 The macros below are used to dispatch to functions through the
     70 @code{bfd_target} vector. They are used in a number of macros further
     71 down in @file{bfd.h}, and are also used when calling various
     72 routines by hand inside the BFD implementation.  The @var{arglist}
     73 argument must be parenthesized; it contains all the arguments
     74 to the called function.
     75 
     76 They make the documentation (more) unpleasant to read, so if
     77 someone wants to fix this and not break the above, please do.
     78 @example
     79 #define BFD_SEND(bfd, message, arglist) \
     80   ((*((bfd)->xvec->message)) arglist)
     81 
     82 #ifdef DEBUG_BFD_SEND
     83 #undef BFD_SEND
     84 #define BFD_SEND(bfd, message, arglist) \
     85   (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
     86     ((*((bfd)->xvec->message)) arglist) : \
     87     (bfd_assert (__FILE__,__LINE__), NULL))
     88 #endif
     89 @end example
     90 For operations which index on the BFD format:
     91 @example
     92 #define BFD_SEND_FMT(bfd, message, arglist) \
     93   (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist)
     94 
     95 #ifdef DEBUG_BFD_SEND
     96 #undef BFD_SEND_FMT
     97 #define BFD_SEND_FMT(bfd, message, arglist) \
     98   (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
     99    (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \
    100    (bfd_assert (__FILE__,__LINE__), NULL))
    101 #endif
    102 
    103 /* Defined to TRUE if unused section symbol should be kept.  */
    104 #ifndef TARGET_KEEP_UNUSED_SECTION_SYMBOLS
    105 #define TARGET_KEEP_UNUSED_SECTION_SYMBOLS true
    106 #endif
    107 
    108 /* Define to TRUE if section merging is supported by the backend.  */
    109 #ifndef TARGET_MERGE_SECTIONS
    110 #define TARGET_MERGE_SECTIONS false
    111 #endif
    112 
    113 @end example
    114 This is the structure which defines the type of BFD this is.  The
    115 @code{xvec} member of the struct @code{bfd} itself points here.  Each
    116 module that implements access to a different target under BFD,
    117 defines one of these.
    118 
    119 FIXME, these names should be rationalised with the names of
    120 the entry points which call them. Too bad we can't have one
    121 macro to define them both!
    122 
    123 
    124 @example
    125 typedef struct bfd_target
    126 @{
    127   /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc.  */
    128   const char *name;
    129 
    130  /* The "flavour" of a back end is a general indication about
    131     the contents of a file.  */
    132   enum bfd_flavour flavour;
    133 
    134   /* The order of bytes within the data area of a file.  */
    135   enum bfd_endian byteorder;
    136 
    137  /* The order of bytes within the header parts of a file.  */
    138   enum bfd_endian header_byteorder;
    139 
    140   /* A mask of all the flags which an executable may have set -
    141      from the set @code{BFD_NO_FLAGS}, @code{HAS_RELOC}, ...@code{D_PAGED}.  */
    142   flagword object_flags;
    143 
    144  /* A mask of all the flags which a section may have set - from
    145     the set @code{SEC_NO_FLAGS}, @code{SEC_ALLOC}, ...@code{SET_NEVER_LOAD}.  */
    146   flagword section_flags;
    147 
    148  /* The character normally found at the front of a symbol.
    149     (if any), perhaps `_'.  */
    150   char symbol_leading_char;
    151 
    152  /* The pad character for file names within an archive header.  */
    153   char ar_pad_char;
    154 
    155   /* The maximum number of characters in an archive header.  */
    156   unsigned char ar_max_namelen;
    157 
    158   /* How well this target matches, used to select between various
    159      possible targets when more than one target matches.  */
    160   unsigned char match_priority;
    161 
    162  /* TRUE if unused section symbols should be kept.  */
    163   bool keep_unused_section_symbols;
    164 
    165   /* TRUE if section merging is supported by the backend.  */
    166   bool merge_sections;
    167 
    168   /* Entries for byte swapping for data. These are different from the
    169      other entry points, since they don't take a BFD as the first argument.
    170      Certain other handlers could do the same.  */
    171   uint64_t       (*bfd_getx64) (const void *);
    172   int64_t        (*bfd_getx_signed_64) (const void *);
    173   void           (*bfd_putx64) (uint64_t, void *);
    174   bfd_vma        (*bfd_getx32) (const void *);
    175   bfd_signed_vma (*bfd_getx_signed_32) (const void *);
    176   void           (*bfd_putx32) (bfd_vma, void *);
    177   bfd_vma        (*bfd_getx16) (const void *);
    178   bfd_signed_vma (*bfd_getx_signed_16) (const void *);
    179   void           (*bfd_putx16) (bfd_vma, void *);
    180 
    181   /* Byte swapping for the headers.  */
    182   uint64_t       (*bfd_h_getx64) (const void *);
    183   int64_t        (*bfd_h_getx_signed_64) (const void *);
    184   void           (*bfd_h_putx64) (uint64_t, void *);
    185   bfd_vma        (*bfd_h_getx32) (const void *);
    186   bfd_signed_vma (*bfd_h_getx_signed_32) (const void *);
    187   void           (*bfd_h_putx32) (bfd_vma, void *);
    188   bfd_vma        (*bfd_h_getx16) (const void *);
    189   bfd_signed_vma (*bfd_h_getx_signed_16) (const void *);
    190   void           (*bfd_h_putx16) (bfd_vma, void *);
    191 
    192   /* Format dependent routines: these are vectors of entry points
    193      within the target vector structure, one for each format to check.  */
    194 
    195   /* Check the format of a file being read.  Return a @code{bfd_cleanup} on
    196      success or zero on failure.  */
    197   bfd_cleanup (*_bfd_check_format[bfd_type_end]) (bfd *);
    198 
    199   /* Set the format of a file being written.  */
    200   bool (*_bfd_set_format[bfd_type_end]) (bfd *);
    201 
    202   /* Write cached information into a file being written, at @code{bfd_close}.  */
    203   bool (*_bfd_write_contents[bfd_type_end]) (bfd *);
    204 
    205 @end example
    206 The general target vector.  These vectors are initialized using the
    207 BFD_JUMP_TABLE macros.
    208 @example
    209   /* Generic entry points.  */
    210 #define BFD_JUMP_TABLE_GENERIC(NAME) \
    211   NAME##_close_and_cleanup, \
    212   NAME##_bfd_free_cached_info, \
    213   NAME##_new_section_hook, \
    214   NAME##_get_section_contents
    215 
    216   /* Called when the BFD is being closed to do any necessary cleanup.  */
    217   bool (*_close_and_cleanup) (bfd *);
    218   /* Ask the BFD to free all cached information.  */
    219   bool (*_bfd_free_cached_info) (bfd *);
    220   /* Called when a new section is created.  */
    221   bool (*_new_section_hook) (bfd *, sec_ptr);
    222   /* Read the contents of a section.  */
    223   bool (*_bfd_get_section_contents) (bfd *, sec_ptr, void *, file_ptr,
    224                                      bfd_size_type);
    225 
    226   /* Entry points to copy private data.  */
    227 #define BFD_JUMP_TABLE_COPY(NAME) \
    228   NAME##_bfd_copy_private_bfd_data, \
    229   NAME##_bfd_merge_private_bfd_data, \
    230   NAME##_bfd_copy_private_section_data, \
    231   NAME##_bfd_copy_private_symbol_data, \
    232   NAME##_bfd_copy_private_header_data, \
    233   NAME##_bfd_set_private_flags, \
    234   NAME##_bfd_print_private_bfd_data
    235 
    236   /* Called to copy BFD general private data from one object file
    237      to another.  */
    238   bool (*_bfd_copy_private_bfd_data) (bfd *, bfd *);
    239   /* Called to merge BFD general private data from one object file
    240      to a common output file when linking.  */
    241   bool (*_bfd_merge_private_bfd_data) (bfd *, struct bfd_link_info *);
    242   /* Called to copy BFD private section data from one object file
    243      to another.  */
    244   bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr,
    245                                           struct bfd_link_info *);
    246   /* Called to copy BFD private symbol data from one symbol
    247      to another.  */
    248   bool (*_bfd_copy_private_symbol_data) (bfd *, asymbol **,
    249                                          bfd *, asymbol **);
    250   /* Called to copy BFD private header data from one object file
    251      to another.  */
    252   bool (*_bfd_copy_private_header_data) (bfd *, bfd *);
    253   /* Called to set private backend flags.  */
    254   bool (*_bfd_set_private_flags) (bfd *, flagword);
    255 
    256   /* Called to print private BFD data.  */
    257   bool (*_bfd_print_private_bfd_data) (bfd *, void *);
    258 
    259   /* Core file entry points.  */
    260 #define BFD_JUMP_TABLE_CORE(NAME) \
    261   NAME##_core_file_failing_command, \
    262   NAME##_core_file_failing_signal, \
    263   NAME##_core_file_matches_executable_p, \
    264   NAME##_core_file_pid
    265 
    266   char *(*_core_file_failing_command) (bfd *);
    267   int   (*_core_file_failing_signal) (bfd *);
    268   bool  (*_core_file_matches_executable_p) (bfd *, bfd *);
    269   int   (*_core_file_pid) (bfd *);
    270 
    271   /* Archive entry points.  */
    272 #define BFD_JUMP_TABLE_ARCHIVE(NAME) \
    273   NAME##_slurp_armap, \
    274   NAME##_slurp_extended_name_table, \
    275   NAME##_construct_extended_name_table, \
    276   NAME##_truncate_arname, \
    277   NAME##_write_armap, \
    278   NAME##_read_ar_hdr, \
    279   NAME##_write_ar_hdr, \
    280   NAME##_openr_next_archived_file, \
    281   NAME##_get_elt_at_index, \
    282   NAME##_generic_stat_arch_elt, \
    283   NAME##_update_armap_timestamp
    284 
    285   bool (*_bfd_slurp_armap) (bfd *);
    286   bool (*_bfd_slurp_extended_name_table) (bfd *);
    287   bool (*_bfd_construct_extended_name_table) (bfd *, char **,
    288                                               bfd_size_type *,
    289                                               const char **);
    290   void (*_bfd_truncate_arname) (bfd *, const char *, char *);
    291   bool (*write_armap) (bfd *, unsigned, struct orl *, unsigned, int);
    292   void *(*_bfd_read_ar_hdr_fn) (bfd *);
    293   bool (*_bfd_write_ar_hdr_fn) (bfd *, bfd *);
    294   bfd *(*openr_next_archived_file) (bfd *, bfd *);
    295 #define bfd_get_elt_at_index(b,i) \
    296        BFD_SEND (b, _bfd_get_elt_at_index, (b,i))
    297   bfd *(*_bfd_get_elt_at_index) (bfd *, symindex);
    298   int  (*_bfd_stat_arch_elt) (bfd *, struct stat *);
    299   bool (*_bfd_update_armap_timestamp) (bfd *);
    300 
    301   /* Entry points used for symbols.  */
    302 #define BFD_JUMP_TABLE_SYMBOLS(NAME) \
    303   NAME##_get_symtab_upper_bound, \
    304   NAME##_canonicalize_symtab, \
    305   NAME##_make_empty_symbol, \
    306   NAME##_print_symbol, \
    307   NAME##_get_symbol_info, \
    308   NAME##_get_symbol_version_string, \
    309   NAME##_bfd_is_local_label_name, \
    310   NAME##_bfd_is_target_special_symbol, \
    311   NAME##_get_lineno, \
    312   NAME##_find_nearest_line, \
    313   NAME##_find_nearest_line_with_alt, \
    314   NAME##_find_line, \
    315   NAME##_find_inliner_info, \
    316   NAME##_bfd_make_debug_symbol, \
    317   NAME##_read_minisymbols, \
    318   NAME##_minisymbol_to_symbol
    319 
    320   long (*_bfd_get_symtab_upper_bound) (bfd *);
    321   long (*_bfd_canonicalize_symtab) (bfd *, struct bfd_symbol **);
    322   struct bfd_symbol *
    323        (*_bfd_make_empty_symbol) (bfd *);
    324   void (*_bfd_print_symbol) (bfd *, void *, struct bfd_symbol *,
    325                              bfd_print_symbol_type);
    326 #define bfd_print_symbol(b,p,s,e) \
    327        BFD_SEND (b, _bfd_print_symbol, (b,p,s,e))
    328   void  (*_bfd_get_symbol_info) (bfd *, struct bfd_symbol *, symbol_info *);
    329 #define bfd_get_symbol_info(b,p,e) \
    330        BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
    331   const char *
    332        (*_bfd_get_symbol_version_string) (bfd *, struct bfd_symbol *,
    333                                           bool, bool *);
    334 #define bfd_get_symbol_version_string(b,s,p,h) \
    335        BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,p,h))
    336   bool (*_bfd_is_local_label_name) (bfd *, const char *);
    337   bool (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
    338   alent *
    339        (*_get_lineno) (bfd *, struct bfd_symbol *);
    340   bool (*_bfd_find_nearest_line) (bfd *, struct bfd_symbol **,
    341                                   struct bfd_section *, bfd_vma,
    342                                   const char **, const char **,
    343                                   unsigned int *, unsigned int *);
    344   bool (*_bfd_find_nearest_line_with_alt) (bfd *, const char *,
    345                                            struct bfd_symbol **,
    346                                            struct bfd_section *, bfd_vma,
    347                                            const char **, const char **,
    348                                            unsigned int *, unsigned int *);
    349   bool (*_bfd_find_line) (bfd *, struct bfd_symbol **,
    350                           struct bfd_symbol *, const char **,
    351                           unsigned int *);
    352   bool (*_bfd_find_inliner_info)
    353     (bfd *, const char **, const char **, unsigned int *);
    354  /* Back-door to allow format-aware applications to create debug symbols
    355     while using BFD for everything else.  Currently used by the assembler
    356     when creating COFF files.  */
    357   asymbol *
    358        (*_bfd_make_debug_symbol) (bfd *);
    359 #define bfd_read_minisymbols(b, d, m, s) \
    360        BFD_SEND (b, _read_minisymbols, (b, d, m, s))
    361   long (*_read_minisymbols) (bfd *, bool, void **, unsigned int *);
    362 #define bfd_minisymbol_to_symbol(b, d, m, f) \
    363        BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
    364   asymbol *
    365        (*_minisymbol_to_symbol) (bfd *, bool, const void *, asymbol *);
    366 
    367   /* Routines for relocs.  */
    368 #define BFD_JUMP_TABLE_RELOCS(NAME) \
    369   NAME##_get_reloc_upper_bound, \
    370   NAME##_canonicalize_reloc, \
    371   NAME##_finalize_section_relocs, \
    372   NAME##_bfd_reloc_type_lookup, \
    373   NAME##_bfd_reloc_name_lookup
    374 
    375   long (*_get_reloc_upper_bound) (bfd *, sec_ptr);
    376   long (*_bfd_canonicalize_reloc) (bfd *, sec_ptr, arelent **,
    377                                    struct bfd_symbol **);
    378   bool (*_bfd_finalize_section_relocs) (bfd *, sec_ptr, arelent **,
    379                                         unsigned int);
    380   /* See documentation on reloc types.  */
    381   reloc_howto_type *
    382        (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
    383   reloc_howto_type *
    384        (*reloc_name_lookup) (bfd *, const char *);
    385 
    386   /* Routines used when writing an object file.  */
    387 #define BFD_JUMP_TABLE_WRITE(NAME) \
    388   NAME##_set_arch_mach, \
    389   NAME##_set_section_contents
    390 
    391   bool (*_bfd_set_arch_mach) (bfd *, enum bfd_architecture,
    392                                      unsigned long);
    393   bool (*_bfd_set_section_contents) (bfd *, sec_ptr, const void *,
    394                                      file_ptr, bfd_size_type);
    395 
    396   /* Routines used by the linker.  */
    397 #define BFD_JUMP_TABLE_LINK(NAME) \
    398   NAME##_sizeof_headers, \
    399   NAME##_bfd_get_relocated_section_contents, \
    400   NAME##_bfd_relax_section, \
    401   NAME##_bfd_link_hash_table_create, \
    402   NAME##_bfd_link_add_symbols, \
    403   NAME##_bfd_link_just_syms, \
    404   NAME##_bfd_copy_link_hash_symbol_type, \
    405   NAME##_bfd_final_link, \
    406   NAME##_bfd_link_split_section, \
    407   NAME##_bfd_link_check_relocs, \
    408   NAME##_bfd_gc_sections, \
    409   NAME##_bfd_lookup_section_flags, \
    410   NAME##_bfd_is_group_section, \
    411   NAME##_bfd_group_name, \
    412   NAME##_bfd_discard_group, \
    413   NAME##_section_already_linked, \
    414   NAME##_bfd_define_common_symbol, \
    415   NAME##_bfd_link_hide_symbol, \
    416   NAME##_bfd_define_start_stop
    417 
    418   int  (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *);
    419   bfd_byte *
    420        (*_bfd_get_relocated_section_contents) (bfd *,
    421                                                struct bfd_link_info *,
    422                                                struct bfd_link_order *,
    423                                                bfd_byte *, bool,
    424                                                struct bfd_symbol **);
    425 
    426   bool (*_bfd_relax_section) (bfd *, struct bfd_section *,
    427                               struct bfd_link_info *, bool *);
    428 
    429   /* Create a hash table for the linker.  Different backends store
    430      different information in this table.  */
    431   struct bfd_link_hash_table *
    432        (*_bfd_link_hash_table_create) (bfd *);
    433 
    434   /* Add symbols from this object file into the hash table.  */
    435   bool (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *);
    436 
    437   /* Indicate that we are only retrieving symbol values from this section.  */
    438   void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *);
    439 
    440   /* Copy the symbol type and other attributes for a linker script
    441      assignment of one symbol to another.  */
    442 #define bfd_copy_link_hash_symbol_type(b, t, f) \
    443        BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f))
    444   void (*_bfd_copy_link_hash_symbol_type) (bfd *,
    445                                            struct bfd_link_hash_entry *,
    446                                            struct bfd_link_hash_entry *);
    447 
    448   /* Do a link based on the link_order structures attached to each
    449      section of the BFD.  */
    450   bool (*_bfd_final_link) (bfd *, struct bfd_link_info *);
    451 
    452   /* Should this section be split up into smaller pieces during linking.  */
    453   bool (*_bfd_link_split_section) (bfd *, struct bfd_section *);
    454 
    455   /* Check the relocations in the bfd for validity.  */
    456   bool (* _bfd_link_check_relocs)(bfd *, struct bfd_link_info *);
    457 
    458   /* Remove sections that are not referenced from the output.  */
    459   bool (*_bfd_gc_sections) (bfd *, struct bfd_link_info *);
    460 
    461   /* Sets the bitmask of allowed and disallowed section flags.  */
    462   bool (*_bfd_lookup_section_flags) (struct bfd_link_info *,
    463                                      struct flag_info *, asection *);
    464 
    465   /* Is this section a member of a group?  */
    466   bool (*_bfd_is_group_section) (bfd *, const struct bfd_section *);
    467 
    468   /* The group name, if section is a member of a group.  */
    469   const char *(*_bfd_group_name) (bfd *, const struct bfd_section *);
    470 
    471   /* Discard members of a group.  */
    472   bool (*_bfd_discard_group) (bfd *, struct bfd_section *);
    473 
    474   /* Check if SEC has been already linked during a reloceatable or
    475      final link.  */
    476   bool (*_section_already_linked) (bfd *, asection *,
    477                                    struct bfd_link_info *);
    478 
    479   /* Define a common symbol.  */
    480   bool (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *,
    481                                      struct bfd_link_hash_entry *);
    482 
    483   /* Hide a symbol.  */
    484   void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *,
    485                                  struct bfd_link_hash_entry *);
    486 
    487   /* Define a __start, __stop, .startof. or .sizeof. symbol.  */
    488   struct bfd_link_hash_entry *
    489        (*_bfd_define_start_stop) (struct bfd_link_info *, const char *,
    490                                   asection *);
    491 
    492   /* Routines to handle dynamic symbols and relocs.  */
    493 #define BFD_JUMP_TABLE_DYNAMIC(NAME) \
    494   NAME##_get_dynamic_symtab_upper_bound, \
    495   NAME##_canonicalize_dynamic_symtab, \
    496   NAME##_get_synthetic_symtab, \
    497   NAME##_get_dynamic_reloc_upper_bound, \
    498   NAME##_canonicalize_dynamic_reloc
    499 
    500   /* Get the amount of memory required to hold the dynamic symbols.  */
    501   long (*_bfd_get_dynamic_symtab_upper_bound) (bfd *);
    502   /* Read in the dynamic symbols.  */
    503   long (*_bfd_canonicalize_dynamic_symtab) (bfd *, struct bfd_symbol **);
    504   /* Create synthetized symbols.  */
    505   long (*_bfd_get_synthetic_symtab) (bfd *, long, struct bfd_symbol **,
    506                                      long, struct bfd_symbol **,
    507                                      struct bfd_symbol **);
    508   /* Get the amount of memory required to hold the dynamic relocs.  */
    509   long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *);
    510   /* Read in the dynamic relocs.  */
    511   long (*_bfd_canonicalize_dynamic_reloc) (bfd *, arelent **,
    512                                            struct bfd_symbol **);
    513 
    514 @end example
    515 A pointer to an alternative bfd_target in case the current one is not
    516 satisfactory.  This can happen when the target cpu supports both big
    517 and little endian code, and target chosen by the linker has the wrong
    518 endianness.  The function open_output() in ld/ldlang.c uses this field
    519 to find an alternative output format that is suitable.
    520 @example
    521   /* Opposite endian version of this target.  */
    522   const struct bfd_target *alternative_target;
    523 
    524   /* Data for use by back-end routines, which isn't
    525      generic enough to belong in this structure.  */
    526   const void *backend_data;
    527 
    528 @} bfd_target;
    529 
    530 static inline const char *
    531 bfd_get_target (const bfd *abfd)
    532 @{
    533   return abfd->xvec->name;
    534 @}
    535 
    536 static inline enum bfd_flavour
    537 bfd_get_flavour (const bfd *abfd)
    538 @{
    539   return abfd->xvec->flavour;
    540 @}
    541 
    542 static inline flagword
    543 bfd_applicable_file_flags (const bfd *abfd)
    544 @{
    545   return abfd->xvec->object_flags;
    546 @}
    547 
    548 static inline bool
    549 bfd_family_coff (const bfd *abfd)
    550 @{
    551   return (bfd_get_flavour (abfd) == bfd_target_coff_flavour
    552           || bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
    553 @}
    554 
    555 static inline bool
    556 bfd_big_endian (const bfd *abfd)
    557 @{
    558   return abfd->xvec->byteorder == BFD_ENDIAN_BIG;
    559 @}
    560 static inline bool
    561 bfd_little_endian (const bfd *abfd)
    562 @{
    563   return abfd->xvec->byteorder == BFD_ENDIAN_LITTLE;
    564 @}
    565 
    566 static inline bool
    567 bfd_header_big_endian (const bfd *abfd)
    568 @{
    569   return abfd->xvec->header_byteorder == BFD_ENDIAN_BIG;
    570 @}
    571 
    572 static inline bool
    573 bfd_header_little_endian (const bfd *abfd)
    574 @{
    575   return abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE;
    576 @}
    577 
    578 static inline flagword
    579 bfd_applicable_section_flags (const bfd *abfd)
    580 @{
    581   return abfd->xvec->section_flags;
    582 @}
    583 
    584 static inline char
    585 bfd_get_symbol_leading_char (const bfd *abfd)
    586 @{
    587   return abfd->xvec->symbol_leading_char;
    588 @}
    589 
    590 static inline enum bfd_flavour
    591 bfd_asymbol_flavour (const asymbol *sy)
    592 @{
    593   if ((sy->flags & BSF_SYNTHETIC) != 0)
    594     return bfd_target_unknown_flavour;
    595   return sy->the_bfd->xvec->flavour;
    596 @}
    597 
    598 static inline bool
    599 bfd_keep_unused_section_symbols (const bfd *abfd)
    600 @{
    601   return abfd->xvec->keep_unused_section_symbols;
    602 @}
    603 
    604 static inline bool
    605 bfd_target_supports_archives (const bfd *abfd)
    606 @{
    607   return (abfd->xvec->_bfd_check_format[bfd_archive]
    608           != abfd->xvec->_bfd_check_format[bfd_unknown]);
    609 @}
    610 
    611 @end example
    612 @findex bfd_set_default_target
    613 @subsubsection @code{bfd_set_default_target}
    614 @deftypefn {Function} bool bfd_set_default_target (const char *name); 
    615 Set the default target vector to use when recognizing a BFD.
    616 This takes the name of the target, which may be a BFD target
    617 name or a configuration triplet.
    618 
    619 @end deftypefn
    620 @findex bfd_find_target
    621 @subsubsection @code{bfd_find_target}
    622 @deftypefn {Function} const bfd_target *bfd_find_target (const char *target_name, bfd *abfd); 
    623 Return a pointer to the transfer vector for the object target
    624 named @var{target_name}.  If @var{target_name} is @code{NULL},
    625 choose the one in the environment variable @code{GNUTARGET}; if
    626 that is null or not defined, then choose the first entry in the
    627 target list.  Passing in the string "default" or setting the
    628 environment variable to "default" will cause the first entry in
    629 the target list to be returned, and "target_defaulted" will be
    630 set in the BFD if @var{abfd} isn't @code{NULL}.  This causes
    631 @code{bfd_check_format} to loop over all the targets to find the
    632 one that matches the file being read.
    633 
    634 @end deftypefn
    635 @findex bfd_get_target_info
    636 @subsubsection @code{bfd_get_target_info}
    637 @deftypefn {Function} const bfd_target *bfd_get_target_info (const char *target_name, bfd *abfd, bool *is_bigendian, int *underscoring, const char **def_target_arch); 
    638 Return a pointer to the transfer vector for the object target
    639 named @var{target_name}.  If @var{target_name} is @code{NULL},
    640 choose the one in the environment variable @code{GNUTARGET}; if
    641 that is null or not defined, then choose the first entry in the
    642 target list.  Passing in the string "default" or setting the
    643 environment variable to "default" will cause the first entry in
    644 the target list to be returned, and "target_defaulted" will be
    645 set in the BFD if @var{abfd} isn't @code{NULL}.  This causes
    646 @code{bfd_check_format} to loop over all the targets to find the
    647 one that matches the file being read.
    648 If @var{is_bigendian} is not @code{NULL}, then set this value to target's
    649 endian mode. True for big-endian, FALSE for little-endian or for
    650 invalid target.
    651 If @var{underscoring} is not @code{NULL}, then set this value to target's
    652 underscoring mode. Zero for none-underscoring, -1 for invalid target,
    653 else the value of target vector's symbol underscoring.
    654 If @var{def_target_arch} is not @code{NULL}, then set it to the architecture
    655 string specified by the target_name.
    656 
    657 @end deftypefn
    658 @findex bfd_target_list
    659 @subsubsection @code{bfd_target_list}
    660 @deftypefn {Function} const char ** bfd_target_list (void); 
    661 Return a freshly malloced NULL-terminated
    662 vector of the names of all the valid BFD targets. Do not
    663 modify the names.
    664 
    665 @end deftypefn
    666 @findex bfd_iterate_over_targets
    667 @subsubsection @code{bfd_iterate_over_targets}
    668 @deftypefn {Function} const bfd_target *bfd_iterate_over_targets (int (*func) (const bfd_target *, void *), void *data); 
    669 Call @var{func} for each target in the list of BFD target
    670 vectors, passing @var{data} to @var{func}.  Stop iterating if
    671 @var{func} returns a non-zero result, and return that target
    672 vector.  Return NULL if @var{func} always returns zero.
    673 
    674 @end deftypefn
    675 @findex bfd_flavour_name
    676 @subsubsection @code{bfd_flavour_name}
    677 @deftypefn {Function} const char *bfd_flavour_name (enum bfd_flavour flavour); 
    678 Return the string form of @var{flavour}.
    679 
    680 @end deftypefn
    681