Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / targets.c
index 158168cb3ba275df2efaefed2e33543bbf709c40..dcd42636df0432135a9501ced33d4ee22cca56f6 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic target-file-type support for the BFD library.
-   Copyright (C) 1990-2019 Free Software Foundation, Inc.
+   Copyright (C) 1990-2021 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -132,6 +132,11 @@ DESCRIPTION
 .   (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \
 .   (bfd_assert (__FILE__,__LINE__), NULL))
 .#endif
+.
+.{* Defined to TRUE if unused section symbol should be kept.  *}
+.#ifndef TARGET_KEEP_UNUSED_SECTION_SYMBOLS
+.#define TARGET_KEEP_UNUSED_SECTION_SYMBOLS TRUE
+.#endif
 .
        This is the structure which defines the type of BFD this is.  The
        <<xvec>> member of the struct <<bfd>> itself points here.  Each
@@ -176,10 +181,12 @@ DESCRIPTION
 .{* Forward declaration.  *}
 .typedef struct flag_info flag_info;
 .
+.typedef void (*bfd_cleanup) (bfd *);
+.
 .typedef struct bfd_target
 .{
 .  {* Identifies the kind of target, e.g., SunOS4, Ultrix, etc.  *}
-.  char *name;
+.  const char *name;
 .
 . {* The "flavour" of a back end is a general indication about
 .    the contents of a file.  *}
@@ -213,6 +220,9 @@ DESCRIPTION
 .     possible targets when more than one target matches.  *}
 .  unsigned char match_priority;
 .
+. {* TRUE if unused section symbols should be kept.  *}
+.  bfd_boolean keep_unused_section_symbols;
+.
 .  {* Entries for byte swapping for data. These are different from the
 .     other entry points, since they don't take a BFD as the first argument.
 .     Certain other handlers could do the same.  *}
@@ -240,9 +250,9 @@ DESCRIPTION
 .  {* Format dependent routines: these are vectors of entry points
 .     within the target vector structure, one for each format to check.  *}
 .
-.  {* Check the format of a file being read.  Return a <<bfd_target *>> or zero.  *}
-.  const struct bfd_target *
-.             (*_bfd_check_format[bfd_type_end]) (bfd *);
+.  {* Check the format of a file being read.  Return a <<bfd_cleanup>> on
+.     success or zero on failure.  *}
+.  bfd_cleanup (*_bfd_check_format[bfd_type_end]) (bfd *);
 .
 .  {* Set the format of a file being written.  *}
 .  bfd_boolean (*_bfd_set_format[bfd_type_end]) (bfd *);
@@ -390,9 +400,10 @@ BFD_JUMP_TABLE macros.
 .#define bfd_get_symbol_info(b,p,e) \
 .      BFD_SEND (b, _bfd_get_symbol_info, (b,p,e))
 .  const char *(*_bfd_get_symbol_version_string) (bfd *, struct bfd_symbol *,
+.                                                bfd_boolean,
 .                                                bfd_boolean *);
-.#define bfd_get_symbol_version_string(b,s,h) \
-.      BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h))
+.#define bfd_get_symbol_version_string(b,s,p,h) \
+.      BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,p,h))
 .  bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *);
 .  bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *);
 .  alent *     (*_get_lineno) (bfd *, struct bfd_symbol *);
@@ -462,6 +473,7 @@ BFD_JUMP_TABLE macros.
 .  NAME##_bfd_lookup_section_flags, \
 .  NAME##_bfd_merge_sections, \
 .  NAME##_bfd_is_group_section, \
+.  NAME##_bfd_group_name, \
 .  NAME##_bfd_discard_group, \
 .  NAME##_section_already_linked, \
 .  NAME##_bfd_define_common_symbol, \
@@ -520,6 +532,9 @@ BFD_JUMP_TABLE macros.
 .  {* Is this section a member of a group?  *}
 .  bfd_boolean (*_bfd_is_group_section) (bfd *, const struct bfd_section *);
 .
+.  {* The group name, if section is a member of a group.  *}
+.  const char *(*_bfd_group_name) (bfd *, const struct bfd_section *);
+.
 .  {* Discard members of a group.  *}
 .  bfd_boolean (*_bfd_discard_group) (bfd *, struct bfd_section *);
 .
@@ -580,6 +595,80 @@ to find an alternative output format that is suitable.
 .
 .} bfd_target;
 .
+.static inline const char *
+.bfd_get_target (const bfd *abfd)
+.{
+.  return abfd->xvec->name;
+.}
+.
+.static inline enum bfd_flavour
+.bfd_get_flavour (const bfd *abfd)
+.{
+.  return abfd->xvec->flavour;
+.}
+.
+.static inline flagword
+.bfd_applicable_file_flags (const bfd *abfd)
+.{
+.  return abfd->xvec->object_flags;
+.}
+.
+.static inline bfd_boolean
+.bfd_family_coff (const bfd *abfd)
+.{
+.  return (bfd_get_flavour (abfd) == bfd_target_coff_flavour
+.          || bfd_get_flavour (abfd) == bfd_target_xcoff_flavour);
+.}
+.
+.static inline bfd_boolean
+.bfd_big_endian (const bfd *abfd)
+.{
+.  return abfd->xvec->byteorder == BFD_ENDIAN_BIG;
+.}
+.static inline bfd_boolean
+.bfd_little_endian (const bfd *abfd)
+.{
+.  return abfd->xvec->byteorder == BFD_ENDIAN_LITTLE;
+.}
+.
+.static inline bfd_boolean
+.bfd_header_big_endian (const bfd *abfd)
+.{
+.  return abfd->xvec->header_byteorder == BFD_ENDIAN_BIG;
+.}
+.
+.static inline bfd_boolean
+.bfd_header_little_endian (const bfd *abfd)
+.{
+.  return abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE;
+.}
+.
+.static inline flagword
+.bfd_applicable_section_flags (const bfd *abfd)
+.{
+.  return abfd->xvec->section_flags;
+.}
+.
+.static inline char
+.bfd_get_symbol_leading_char (const bfd *abfd)
+.{
+.  return abfd->xvec->symbol_leading_char;
+.}
+.
+.static inline enum bfd_flavour
+.bfd_asymbol_flavour (const asymbol *sy)
+.{
+.  if ((sy->flags & BSF_SYNTHETIC) != 0)
+.    return bfd_target_unknown_flavour;
+.  return sy->the_bfd->xvec->flavour;
+.}
+.
+.static inline bfd_boolean
+.bfd_keep_unused_section_symbols (const bfd *abfd)
+.{
+.  return abfd->xvec->keep_unused_section_symbols;
+.}
+.
 */
 
 /* All known xvecs (even those that don't compile on all systems).
@@ -608,8 +697,6 @@ extern const bfd_target arm_elf32_fdpic_be_vec;
 extern const bfd_target arm_elf32_fdpic_le_vec;
 extern const bfd_target arm_elf32_nacl_be_vec;
 extern const bfd_target arm_elf32_nacl_le_vec;
-extern const bfd_target arm_elf32_symbian_be_vec;
-extern const bfd_target arm_elf32_symbian_le_vec;
 extern const bfd_target arm_elf32_vxworks_be_vec;
 extern const bfd_target arm_elf32_vxworks_le_vec;
 extern const bfd_target arm_mach_o_vec;
@@ -625,7 +712,6 @@ extern const bfd_target avr_elf32_vec;
 extern const bfd_target bfin_elf32_vec;
 extern const bfd_target bfin_elf32_fdpic_vec;
 extern const bfd_target cr16_elf32_vec;
-extern const bfd_target cr16c_elf32_vec;
 extern const bfd_target cris_aout_vec;
 extern const bfd_target cris_elf32_vec;
 extern const bfd_target cris_elf32_us_vec;
@@ -639,6 +725,8 @@ extern const bfd_target elf32_be_vec;
 extern const bfd_target elf32_le_vec;
 extern const bfd_target elf64_be_vec;
 extern const bfd_target elf64_le_vec;
+extern const bfd_target bpf_elf64_le_vec;
+extern const bfd_target bpf_elf64_be_vec;
 extern const bfd_target epiphany_elf32_vec;
 extern const bfd_target fr30_elf32_vec;
 extern const bfd_target frv_elf32_vec;
@@ -660,12 +748,12 @@ extern const bfd_target i386_coff_go32stubbed_vec;
 extern const bfd_target i386_coff_lynx_vec;
 extern const bfd_target i386_elf32_vec;
 extern const bfd_target i386_elf32_fbsd_vec;
-extern const bfd_target i386_elf32_nacl_vec;
 extern const bfd_target i386_elf32_sol2_vec;
 extern const bfd_target i386_elf32_vxworks_vec;
 extern const bfd_target i386_mach_o_vec;
 extern const bfd_target i386_msdos_vec;
 extern const bfd_target i386_pe_vec;
+extern const bfd_target i386_pe_big_vec;
 extern const bfd_target i386_pei_vec;
 extern const bfd_target iamcu_elf32_vec;
 extern const bfd_target ia64_elf32_be_vec;
@@ -762,14 +850,13 @@ extern const bfd_target powerpc_elf32_vxworks_vec;
 extern const bfd_target powerpc_elf64_vec;
 extern const bfd_target powerpc_elf64_le_vec;
 extern const bfd_target powerpc_elf64_fbsd_vec;
-extern const bfd_target powerpc_pe_vec;
-extern const bfd_target powerpc_pe_le_vec;
-extern const bfd_target powerpc_pei_vec;
-extern const bfd_target powerpc_pei_le_vec;
+extern const bfd_target powerpc_elf64_fbsd_le_vec;
 extern const bfd_target powerpc_xcoff_vec;
 extern const bfd_target pru_elf32_vec;
 extern const bfd_target riscv_elf32_vec;
 extern const bfd_target riscv_elf64_vec;
+extern const bfd_target riscv_elf32_be_vec;
+extern const bfd_target riscv_elf64_be_vec;
 extern const bfd_target rl78_elf32_vec;
 extern const bfd_target rs6000_xcoff64_vec;
 extern const bfd_target rs6000_xcoff64_aix_vec;
@@ -806,7 +893,6 @@ extern const bfd_target sparc_elf64_fbsd_vec;
 extern const bfd_target sparc_elf64_sol2_vec;
 extern const bfd_target spu_elf32_vec;
 extern const bfd_target sym_vec;
-extern const bfd_target tic30_aout_vec;
 extern const bfd_target tic30_coff_vec;
 extern const bfd_target tic4x_coff0_vec;
 extern const bfd_target tic4x_coff0_beh_vec;
@@ -826,7 +912,6 @@ extern const bfd_target tic6x_elf32_c6000_be_vec;
 extern const bfd_target tic6x_elf32_c6000_le_vec;
 extern const bfd_target tic6x_elf32_linux_be_vec;
 extern const bfd_target tic6x_elf32_linux_le_vec;
-extern const bfd_target tic80_coff_vec;
 extern const bfd_target tilegx_elf32_be_vec;
 extern const bfd_target tilegx_elf32_le_vec;
 extern const bfd_target tilegx_elf64_be_vec;
@@ -843,15 +928,13 @@ extern const bfd_target wasm_vec;
 extern const bfd_target wasm32_elf32_vec;
 extern const bfd_target x86_64_coff_vec;
 extern const bfd_target x86_64_elf32_vec;
-extern const bfd_target x86_64_elf32_nacl_vec;
 extern const bfd_target x86_64_elf64_vec;
 extern const bfd_target x86_64_elf64_cloudabi_vec;
 extern const bfd_target x86_64_elf64_fbsd_vec;
-extern const bfd_target x86_64_elf64_nacl_vec;
 extern const bfd_target x86_64_elf64_sol2_vec;
 extern const bfd_target x86_64_mach_o_vec;
 extern const bfd_target x86_64_pe_vec;
-extern const bfd_target x86_64_pe_be_vec;
+extern const bfd_target x86_64_pe_big_vec;
 extern const bfd_target x86_64_pei_vec;
 extern const bfd_target xc16x_elf32_vec;
 extern const bfd_target xgate_elf32_vec;
@@ -859,6 +942,7 @@ extern const bfd_target xstormy16_elf32_vec;
 extern const bfd_target xtensa_elf32_be_vec;
 extern const bfd_target xtensa_elf32_le_vec;
 extern const bfd_target z80_coff_vec;
+extern const bfd_target z80_elf32_vec;
 extern const bfd_target z8k_coff_vec;
 
 /* These are always included.  */
@@ -935,8 +1019,6 @@ static const bfd_target * const _bfd_target_vector[] =
        &arm_elf32_le_vec,
        &arm_elf32_fdpic_be_vec,
        &arm_elf32_fdpic_le_vec,
-       &arm_elf32_symbian_be_vec,
-       &arm_elf32_symbian_le_vec,
        &arm_elf32_vxworks_be_vec,
        &arm_elf32_vxworks_le_vec,
        &arm_mach_o_vec,
@@ -955,7 +1037,6 @@ static const bfd_target * const _bfd_target_vector[] =
        &bfin_elf32_fdpic_vec,
 
        &cr16_elf32_vec,
-       &cr16c_elf32_vec,
 
        &cris_aout_vec,
        &cris_elf32_vec,
@@ -1010,16 +1091,21 @@ static const bfd_target * const _bfd_target_vector[] =
        &i386_coff_lynx_vec,
        &i386_elf32_vec,
        &i386_elf32_fbsd_vec,
-       &i386_elf32_nacl_vec,
        &i386_elf32_sol2_vec,
        &i386_elf32_vxworks_vec,
        &i386_mach_o_vec,
        &i386_msdos_vec,
        &i386_pe_vec,
+       &i386_pe_big_vec,
        &i386_pei_vec,
 
        &iamcu_elf32_vec,
 
+#ifdef BFD64
+       &bpf_elf64_be_vec,
+       &bpf_elf64_le_vec,
+#endif
+
 #ifdef BFD64
 #if 0
        &ia64_elf32_be_vec,
@@ -1142,10 +1228,6 @@ static const bfd_target * const _bfd_target_vector[] =
        &pj_elf32_vec,
        &pj_elf32_le_vec,
 
-#if BFD_SUPPORTS_PLUGINS
-       &plugin_vec,
-#endif
-
        &powerpc_boot_vec,
        &powerpc_elf32_vec,
        &powerpc_elf32_le_vec,
@@ -1155,11 +1237,8 @@ static const bfd_target * const _bfd_target_vector[] =
        &powerpc_elf64_vec,
        &powerpc_elf64_le_vec,
        &powerpc_elf64_fbsd_vec,
+       &powerpc_elf64_fbsd_le_vec,
 #endif
-       &powerpc_pe_vec,
-       &powerpc_pe_le_vec,
-       &powerpc_pei_vec,
-       &powerpc_pei_le_vec,
 #if 0
        /* This has the same magic number as RS/6000.  */
        &powerpc_xcoff_vec,
@@ -1170,6 +1249,8 @@ static const bfd_target * const _bfd_target_vector[] =
 #ifdef BFD64
        &riscv_elf32_vec,
        &riscv_elf64_vec,
+       &riscv_elf32_be_vec,
+       &riscv_elf64_be_vec,
 #endif
        &rl78_elf32_vec,
 
@@ -1223,7 +1304,6 @@ static const bfd_target * const _bfd_target_vector[] =
 
        &sym_vec,
 
-       &tic30_aout_vec,
        &tic30_coff_vec,
        &tic54x_coff0_beh_vec,
        &tic54x_coff0_vec,
@@ -1233,7 +1313,6 @@ static const bfd_target * const _bfd_target_vector[] =
        &tic54x_coff2_vec,
        &tic6x_elf32_be_vec,
        &tic6x_elf32_le_vec,
-       &tic80_coff_vec,
 
        &tilegx_elf32_be_vec,
        &tilegx_elf32_le_vec,
@@ -1260,15 +1339,13 @@ static const bfd_target * const _bfd_target_vector[] =
 #ifdef BFD64
        &x86_64_coff_vec,
        &x86_64_elf32_vec,
-       &x86_64_elf32_nacl_vec,
        &x86_64_elf64_vec,
        &x86_64_elf64_cloudabi_vec,
        &x86_64_elf64_fbsd_vec,
-       &x86_64_elf64_nacl_vec,
        &x86_64_elf64_sol2_vec,
        &x86_64_mach_o_vec,
        &x86_64_pe_vec,
-       &x86_64_pe_be_vec,
+       &x86_64_pe_big_vec,
        &x86_64_pei_vec,
 #endif
 
@@ -1282,6 +1359,7 @@ static const bfd_target * const _bfd_target_vector[] =
        &xtensa_elf32_le_vec,
 
        &z80_coff_vec,
+       &z80_elf32_vec,
 
        &z8k_coff_vec,
 #endif /* not SELECT_VECS */
@@ -1298,6 +1376,10 @@ static const bfd_target * const _bfd_target_vector[] =
 /* Likewise for ihex.  */
        &ihex_vec,
 
+#if BFD_SUPPORTS_PLUGINS
+       &plugin_vec,
+#endif
+
 /* Add any required traditional-core-file-handler.  */
 
 #ifdef AIX386_CORE
@@ -1337,7 +1419,7 @@ static const bfd_target * const _bfd_target_vector[] =
 
        NULL /* end of list marker */
 };
-const bfd_target * const *bfd_target_vector = _bfd_target_vector;
+const bfd_target *const *const bfd_target_vector = _bfd_target_vector;
 
 /* bfd_default_vector[0] contains either the address of the default vector,
    if there is one, or zero if there isn't.  */
@@ -1352,13 +1434,13 @@ const bfd_target *bfd_default_vector[] = {
 /* bfd_associated_vector[] contains the associated target vectors used
    to reduce the ambiguity in bfd_check_format_matches.  */
 
-static const bfd_target *_bfd_associated_vector[] = {
+static const bfd_target *const _bfd_associated_vector[] = {
 #ifdef ASSOCIATED_VECS
        ASSOCIATED_VECS,
 #endif
        NULL
 };
-const bfd_target * const *bfd_associated_vector = _bfd_associated_vector;
+const bfd_target *const *const bfd_associated_vector = _bfd_associated_vector;
 
 /* When there is an ambiguous match, bfd_check_format_matches puts the
    names of the matching targets in an array.  This variable is the maximum
@@ -1610,8 +1692,7 @@ bfd_get_target_info (const char *target_name, bfd *abfd,
            _bfd_find_arch_match (tname, arches, def_target_arch);
        }
 
-      if (arches)
-       free (arches);
+      free (arches);
     }
   return target_vec;
 }
@@ -1634,7 +1715,7 @@ const char **
 bfd_target_list (void)
 {
   int vec_length = 0;
-  bfd_size_type amt;
+  size_t amt;
   const bfd_target * const *target;
   const  char **name_list, **name_ptr;
 
This page took 0.031027 seconds and 4 git commands to generate.