/* Generic target-file-type support for the BFD library.
- Copyright (C) 1990-2021 Free Software Foundation, Inc.
+ Copyright (C) 1990-2023 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
MA 02110-1301, USA. */
#include "sysdep.h"
+#include "libiberty.h"
#include "bfd.h"
#include "libbfd.h"
#include "fnmatch.h"
. bfd_target_verilog_flavour,
. bfd_target_ihex_flavour,
. bfd_target_som_flavour,
-. bfd_target_os9k_flavour,
-. bfd_target_versados_flavour,
. bfd_target_msdos_flavour,
-. bfd_target_ovax_flavour,
. bfd_target_evax_flavour,
. bfd_target_mmo_flavour,
. bfd_target_mach_o_flavour,
. {* 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. *}
-. bfd_uint64_t (*bfd_getx64) (const void *);
-. bfd_int64_t (*bfd_getx_signed_64) (const void *);
-. void (*bfd_putx64) (bfd_uint64_t, void *);
+. uint64_t (*bfd_getx64) (const void *);
+. int64_t (*bfd_getx_signed_64) (const void *);
+. void (*bfd_putx64) (uint64_t, void *);
. bfd_vma (*bfd_getx32) (const void *);
. bfd_signed_vma (*bfd_getx_signed_32) (const void *);
. void (*bfd_putx32) (bfd_vma, void *);
. void (*bfd_putx16) (bfd_vma, void *);
.
. {* Byte swapping for the headers. *}
-. bfd_uint64_t (*bfd_h_getx64) (const void *);
-. bfd_int64_t (*bfd_h_getx_signed_64) (const void *);
-. void (*bfd_h_putx64) (bfd_uint64_t, void *);
+. uint64_t (*bfd_h_getx64) (const void *);
+. int64_t (*bfd_h_getx_signed_64) (const void *);
+. void (*bfd_h_putx64) (uint64_t, void *);
. bfd_vma (*bfd_h_getx32) (const void *);
. bfd_signed_vma (*bfd_h_getx_signed_32) (const void *);
. void (*bfd_h_putx32) (bfd_vma, void *);
. NAME##_bfd_is_target_special_symbol, \
. NAME##_get_lineno, \
. NAME##_find_nearest_line, \
+. NAME##_find_nearest_line_with_alt, \
. NAME##_find_line, \
. NAME##_find_inliner_info, \
. NAME##_bfd_make_debug_symbol, \
. struct bfd_section *, bfd_vma,
. const char **, const char **,
. unsigned int *, unsigned int *);
+. bool (*_bfd_find_nearest_line_with_alt) (bfd *, const char *,
+. struct bfd_symbol **,
+. struct bfd_section *, bfd_vma,
+. const char **, const char **,
+. unsigned int *, unsigned int *);
. bool (*_bfd_find_line) (bfd *, struct bfd_symbol **,
. struct bfd_symbol *, const char **,
. unsigned int *);
extern const bfd_target aarch64_elf64_le_vec;
extern const bfd_target aarch64_elf64_le_cloudabi_vec;
extern const bfd_target aarch64_mach_o_vec;
+extern const bfd_target aarch64_pei_le_vec;
+extern const bfd_target aarch64_pe_le_vec;
extern const bfd_target alpha_ecoff_le_vec;
extern const bfd_target alpha_elf64_vec;
extern const bfd_target alpha_elf64_fbsd_vec;
extern const bfd_target alpha_vms_vec;
extern const bfd_target alpha_vms_lib_txt_vec;
extern const bfd_target am33_elf32_linux_vec;
+extern const bfd_target amdgcn_elf64_le_vec;
extern const bfd_target aout_vec;
extern const bfd_target arc_elf32_be_vec;
extern const bfd_target arc_elf32_le_vec;
extern const bfd_target ia64_pei_vec;
extern const bfd_target ip2k_elf32_vec;
extern const bfd_target iq2000_elf32_vec;
-extern const bfd_target k1om_elf64_vec;
-extern const bfd_target k1om_elf64_fbsd_vec;
-extern const bfd_target l1om_elf64_vec;
-extern const bfd_target l1om_elf64_fbsd_vec;
extern const bfd_target lm32_elf32_vec;
extern const bfd_target lm32_elf32_fdpic_vec;
extern const bfd_target loongarch_elf64_vec;
extern const bfd_target loongarch_elf32_vec;
+extern const bfd_target loongarch64_pei_vec;
extern const bfd_target m32c_elf32_vec;
extern const bfd_target m32r_elf32_vec;
extern const bfd_target m32r_elf32_le_vec;
extern const bfd_target ns32k_aout_pc532mach_vec;
extern const bfd_target ns32k_aout_pc532nbsd_vec;
extern const bfd_target or1k_elf32_vec;
+extern const bfd_target pdb_vec;
extern const bfd_target pdp11_aout_vec;
extern const bfd_target pef_vec;
extern const bfd_target pef_xlib_vec;
extern const bfd_target x86_64_pe_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;
extern const bfd_target xstormy16_elf32_vec;
extern const bfd_target xtensa_elf32_be_vec;
extern const bfd_target ihex_vec;
/* All of the xvecs for core files. */
-extern const bfd_target core_aix386_vec;
extern const bfd_target core_cisco_be_vec;
extern const bfd_target core_cisco_le_vec;
extern const bfd_target core_hppabsd_vec;
extern const bfd_target core_netbsd_vec;
extern const bfd_target core_osf_vec;
extern const bfd_target core_ptrace_vec;
-extern const bfd_target core_sco5_vec;
extern const bfd_target core_trad_vec;
static const bfd_target * const _bfd_target_vector[] =
&aarch64_elf64_le_vec,
&aarch64_elf64_le_cloudabi_vec,
&aarch64_mach_o_vec,
+ &aarch64_pe_le_vec,
+ &aarch64_pei_le_vec,
+#endif
+
+#ifdef BFD64
+ &amdgcn_elf64_le_vec,
#endif
#ifdef BFD64
&ip2k_elf32_vec,
&iq2000_elf32_vec,
-#ifdef BFD64
- &k1om_elf64_vec,
- &k1om_elf64_fbsd_vec,
- &l1om_elf64_vec,
- &l1om_elf64_fbsd_vec,
-#endif
-
&lm32_elf32_vec,
&m32c_elf32_vec,
&or1k_elf32_vec,
+ &pdb_vec,
+
&pdp11_aout_vec,
&pef_vec,
&x86_64_pei_vec,
#endif
- &xc16x_elf32_vec,
-
&xgate_elf32_vec,
&xstormy16_elf32_vec,
#ifdef BFD64
&loongarch_elf32_vec,
&loongarch_elf64_vec,
+ &loongarch64_pei_vec,
#endif
#endif /* not SELECT_VECS */
/* Add any required traditional-core-file-handler. */
-#ifdef AIX386_CORE
- &core_aix386_vec,
-#endif
#if 0
/* We don't include cisco_core_*_vec. Although it has a magic number,
the magic number isn't at the beginning of the file, and thus
#ifdef PTRACE_CORE
&core_ptrace_vec,
#endif
-#ifdef SCO5_CORE
- &core_sco5_vec,
-#endif
#ifdef TRAD_CORE
&core_trad_vec,
#endif
/* 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
number of entries that the array could possibly need. */
-const size_t _bfd_target_vector_entries = sizeof (_bfd_target_vector)/sizeof (*_bfd_target_vector);
+const size_t _bfd_target_vector_entries = ARRAY_SIZE (_bfd_target_vector);
+
+/* A place to stash a warning from _bfd_check_format. */
+static struct per_xvec_message *per_xvec_warn[ARRAY_SIZE (_bfd_target_vector)
+ + 1];
\f
/* This array maps configuration triplets onto BFD vectors. */
{ NULL, NULL }
};
+/*
+CODE_FRAGMENT
+.{* Cached _bfd_check_format messages are put in this. *}
+.struct per_xvec_message
+.{
+. struct per_xvec_message *next;
+. char message[];
+.};
+.
+INTERNAL_FUNCTION
+ _bfd_per_xvec_warn
+
+SYNOPSIS
+ struct per_xvec_message **_bfd_per_xvec_warn (const bfd_target *, size_t);
+
+DESCRIPTION
+ Return a location for the given target xvec to use for
+ warnings specific to that target. If TARG is NULL, returns
+ the array of per_xvec_message pointers, otherwise if ALLOC is
+ zero, returns a pointer to a pointer to the list of messages
+ for TARG, otherwise (both TARG and ALLOC non-zero), allocates
+ a new per_xvec_message with space for a string of ALLOC
+ bytes and returns a pointer to a pointer to it. May return a
+ pointer to a NULL pointer on allocation failure.
+*/
+
+struct per_xvec_message **
+_bfd_per_xvec_warn (const bfd_target *targ, size_t alloc)
+{
+ size_t idx;
+
+ if (!targ)
+ return per_xvec_warn;
+ for (idx = 0; idx < ARRAY_SIZE (_bfd_target_vector); idx++)
+ if (_bfd_target_vector[idx] == targ)
+ break;
+ struct per_xvec_message **m = per_xvec_warn + idx;
+ if (!alloc)
+ return m;
+ int count = 0;
+ while (*m)
+ {
+ m = &(*m)->next;
+ count++;
+ }
+ /* Anti-fuzzer measure. Don't cache more than 5 messages. */
+ if (count < 5)
+ {
+ *m = bfd_malloc (sizeof (**m) + alloc);
+ if (*m != NULL)
+ (*m)->next = NULL;
+ }
+ return m;
+}
+
/* Find a target vector, given a name or configuration triplet. */
static const bfd_target *
case bfd_target_verilog_flavour: return "Verilog";
case bfd_target_ihex_flavour: return "Ihex";
case bfd_target_som_flavour: return "SOM";
- case bfd_target_os9k_flavour: return "OS9K";
- case bfd_target_versados_flavour: return "Versados";
case bfd_target_msdos_flavour: return "MSDOS";
- case bfd_target_ovax_flavour: return "Ovax";
case bfd_target_evax_flavour: return "Evax";
case bfd_target_mmo_flavour: return "mmo";
case bfd_target_mach_o_flavour: return "MACH_O";