/* Generic target-file-type support for the BFD library.
- Copyright (C) 1990-2022 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.
. 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,
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_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 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_pei_vec,
+ &aarch64_pe_le_vec,
+ &aarch64_pei_le_vec,
#endif
#ifdef BFD64
/* 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
const size_t _bfd_target_vector_entries = ARRAY_SIZE (_bfd_target_vector);
/* A place to stash a warning from _bfd_check_format. */
-static const char *per_xvec_warn[ARRAY_SIZE (_bfd_target_vector) + 1];
+static struct per_xvec_message *per_xvec_warn[ARRAY_SIZE (_bfd_target_vector)
+ + 1];
\f
/* This array maps configuration triplets onto BFD vectors. */
};
/*
+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
- const char **_bfd_per_xvec_warn (const bfd_target *);
+ 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.
+ 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.
*/
-const char **
-_bfd_per_xvec_warn (const bfd_target *targ)
+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;
- return per_xvec_warn + idx;
+ 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. */
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";