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