aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/archive.c44
-rw-r--r--bfd/bfd-in.h8
-rw-r--r--bfd/bfd-in2.h11
-rw-r--r--bfd/bfd.c3
-rw-r--r--bfd/coff-aarch64.c5
-rw-r--r--bfd/coff-ia64.c4
-rw-r--r--bfd/coff-loongarch64.c5
-rw-r--r--bfd/coff-mcore.c4
-rw-r--r--bfd/coff-riscv64.c4
-rw-r--r--bfd/coffcode.h6
-rw-r--r--bfd/coffswap.h14
-rw-r--r--bfd/config.bfd18
-rwxr-xr-xbfd/configure14
-rw-r--r--bfd/configure.ac13
-rw-r--r--bfd/elf-bfd.h6
-rw-r--r--bfd/elf-linker-x86.h17
-rw-r--r--bfd/elf-properties.c51
-rw-r--r--bfd/elf.c1083
-rw-r--r--bfd/elf32-arm.c35
-rw-r--r--bfd/elf32-i386.c70
-rw-r--r--bfd/elf64-ppc.c6
-rw-r--r--bfd/elf64-x86-64.c80
-rw-r--r--bfd/elflink.c145
-rw-r--r--bfd/elfnn-aarch64.c19
-rw-r--r--bfd/elfxx-loongarch.c4
-rw-r--r--bfd/elfxx-riscv.c30
-rw-r--r--bfd/elfxx-x86.c27
-rw-r--r--bfd/elfxx-x86.h27
-rw-r--r--bfd/format.c169
-rw-r--r--bfd/peXXigen.c10
-rw-r--r--bfd/pei-aarch64.c4
-rw-r--r--bfd/pei-loongarch64.c4
-rw-r--r--bfd/pei-riscv64.c4
-rw-r--r--bfd/pei-x86_64.c4
-rw-r--r--bfd/plugin.c22
-rw-r--r--bfd/plugin.h63
-rw-r--r--bfd/targets.c6
-rw-r--r--bfd/tekhex.c2
-rw-r--r--bfd/version.h2
-rw-r--r--bfd/xtensa-dynconfig.c62
40 files changed, 1034 insertions, 1071 deletions
diff --git a/bfd/archive.c b/bfd/archive.c
index 52d3119..d2a9fd1 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -141,9 +141,7 @@ SUBSECTION
#include "hashtab.h"
#include "filenames.h"
#include "bfdlink.h"
-#if BFD_SUPPORTS_PLUGINS
#include "plugin.h"
-#endif
#ifndef errno
extern int errno;
@@ -950,8 +948,8 @@ bfd_generic_archive_p (bfd *abfd)
if (first != NULL)
{
first->target_defaulted = false;
- if (bfd_check_format (first, bfd_object)
- && first->xvec != abfd->xvec)
+ if (!bfd_check_format (first, bfd_object)
+ || first->xvec != abfd->xvec)
bfd_set_error (bfd_error_wrong_object_format);
bfd_close (first);
}
@@ -1189,7 +1187,7 @@ do_slurp_coff_armap (bfd *abfd)
bool
bfd_slurp_armap (bfd *abfd)
{
- char nextname[17];
+ char nextname[16];
int i = bfd_read (nextname, 16, abfd);
if (i == 0)
@@ -1200,12 +1198,13 @@ bfd_slurp_armap (bfd *abfd)
if (bfd_seek (abfd, -16, SEEK_CUR) != 0)
return false;
- if (startswith (nextname, "__.SYMDEF ")
- || startswith (nextname, "__.SYMDEF/ ")) /* Old Linux archives. */
+ if (memcmp (nextname, "__.SYMDEF ", 16) == 0
+ /* Old Linux archives. */
+ || memcmp (nextname, "__.SYMDEF/ ", 16) == 0)
return do_slurp_bsd_armap (abfd);
- else if (startswith (nextname, "/ "))
+ else if (memcmp (nextname, "/ ", 16) == 0)
return do_slurp_coff_armap (abfd);
- else if (startswith (nextname, "/SYM64/ "))
+ else if (memcmp (nextname, "/SYM64/ ", 16) == 0)
{
/* 64bit (Irix 6) archive. */
#ifdef BFD64
@@ -1215,13 +1214,27 @@ bfd_slurp_armap (bfd *abfd)
return false;
#endif
}
- else if (startswith (nextname, "#1/20 "))
+ else if (memcmp (nextname, "________", 8) == 0
+ && ((nextname[8] == '_' && nextname[9] == '_')
+ || (nextname[8] == '6' && nextname[9] == '4'))
+ && nextname[10] == 'E'
+ && (nextname[11] == 'B' || nextname[11] == 'L')
+ && nextname[12] == 'E'
+ && (nextname[13] == 'B' || nextname[13] == 'L')
+ && nextname[14] == '_'
+ && (nextname[15] == ' ' || nextname[15] == 'X'))
+ {
+ /* ECOFF archive. */
+ bfd_set_error (bfd_error_wrong_format);
+ return false;
+ }
+ else if (memcmp (nextname, "#1/20 ", 16) == 0)
{
/* Mach-O has a special name for armap when the map is sorted by name.
However because this name has a space it is slightly more difficult
to check it. */
struct ar_hdr hdr;
- char extname[21];
+ char extname[20];
if (bfd_read (&hdr, sizeof (hdr), abfd) != sizeof (hdr))
return false;
@@ -1230,9 +1243,8 @@ bfd_slurp_armap (bfd *abfd)
return false;
if (bfd_seek (abfd, -(file_ptr) (sizeof (hdr) + 20), SEEK_CUR) != 0)
return false;
- extname[20] = 0;
- if (startswith (extname, "__.SYMDEF SORTED")
- || startswith (extname, "__.SYMDEF"))
+ if (memcmp (extname, "__.SYMDEF SORTED", 16) == 0
+ || memcmp (extname, "__.SYMDEF", 9) == 0)
return do_slurp_bsd_armap (abfd);
}
@@ -2346,9 +2358,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
long src_count;
if (bfd_get_lto_type (current) == lto_slim_ir_object
-#if BFD_SUPPORTS_PLUGINS
&& !bfd_plugin_target_p (current->xvec)
-#endif
&& report_plugin_err)
{
report_plugin_err = false;
@@ -2406,9 +2416,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
if (bfd_lto_slim_symbol_p (current,
syms[src_count]->name)
-#if BFD_SUPPORTS_PLUGINS
&& !bfd_plugin_target_p (current->xvec)
-#endif
&& report_plugin_err)
{
report_plugin_err = false;
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index df5568e..ea2d2cb 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -159,3 +159,11 @@ startswith (const char *str, const char *prefix)
return strncmp (str, prefix, strlen (prefix)) == 0;
}
+/* Return true if plugin is enabled. */
+
+static inline bool
+bfd_plugin_enabled (void)
+{
+ return BFD_SUPPORTS_PLUGINS != 0;
+}
+
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 12512a3..5e7c6dd 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -166,6 +166,14 @@ startswith (const char *str, const char *prefix)
return strncmp (str, prefix, strlen (prefix)) == 0;
}
+/* Return true if plugin is enabled. */
+
+static inline bool
+bfd_plugin_enabled (void)
+{
+ return BFD_SUPPORTS_PLUGINS != 0;
+}
+
/* Extracted from libbfd.c. */
void *bfd_alloc (bfd *abfd, bfd_size_type wanted);
@@ -2131,9 +2139,6 @@ struct bfd
/* Set if this is the linker input BFD. */
unsigned int is_linker_input : 1;
- /* Set if this is the strip input BFD. */
- unsigned int is_strip_input : 1;
-
/* If this is an input for a compiler plug-in library. */
ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2;
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 4aded68..858ab5c 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -296,9 +296,6 @@ CODE_FRAGMENT
. {* Set if this is the linker input BFD. *}
. unsigned int is_linker_input : 1;
.
-. {* Set if this is the strip input BFD. *}
-. unsigned int is_strip_input : 1;
-.
. {* If this is an input for a compiler plug-in library. *}
. ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2;
.
diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c
index af4a44d..48b8bfa 100644
--- a/bfd/coff-aarch64.c
+++ b/bfd/coff-aarch64.c
@@ -18,9 +18,8 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
-
-#ifndef COFF_WITH_peAArch64
-#define COFF_WITH_peAArch64
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
#endif
#include "sysdep.h"
diff --git a/bfd/coff-ia64.c b/bfd/coff-ia64.c
index 3a947ef..b2873ae 100644
--- a/bfd/coff-ia64.c
+++ b/bfd/coff-ia64.c
@@ -19,6 +19,10 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
+#endif
+
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
diff --git a/bfd/coff-loongarch64.c b/bfd/coff-loongarch64.c
index c1fe70b..a852108 100644
--- a/bfd/coff-loongarch64.c
+++ b/bfd/coff-loongarch64.c
@@ -18,9 +18,8 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
-
-#ifndef COFF_WITH_peLoongArch64
-#define COFF_WITH_peLoongArch64
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
#endif
#include "sysdep.h"
diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c
index e15c4b4..fab10a7 100644
--- a/bfd/coff-mcore.c
+++ b/bfd/coff-mcore.c
@@ -18,6 +18,10 @@
Foundation, 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA. */
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
+#endif
+
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
diff --git a/bfd/coff-riscv64.c b/bfd/coff-riscv64.c
index 870eef3..2356a6b 100644
--- a/bfd/coff-riscv64.c
+++ b/bfd/coff-riscv64.c
@@ -18,6 +18,10 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
+#ifndef COFF_WITH_PE
+#error non-PE COFF unsupported
+#endif
+
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index a2ee036..4a1f4be 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -6133,9 +6133,9 @@ const bfd_target VAR = \
TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols. */ \
\
/* Data conversion functions. */ \
- bfd_getb64, bfd_getb_signed_64, bfd_putb64, \
- bfd_getb32, bfd_getb_signed_32, bfd_putb32, \
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, \
+ bfd_getl64, bfd_getl_signed_64, bfd_putl64, \
+ bfd_getl32, bfd_getl_signed_32, bfd_putl32, \
+ bfd_getl16, bfd_getl_signed_16, bfd_putl16, \
\
/* Header conversion functions. */ \
bfd_getb64, bfd_getb_signed_64, bfd_putb64, \
diff --git a/bfd/coffswap.h b/bfd/coffswap.h
index 4d63824..823d3fd 100644
--- a/bfd/coffswap.h
+++ b/bfd/coffswap.h
@@ -422,13 +422,10 @@ coff_swap_aux_in (bfd *abfd,
in->x_file.x_n.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
}
else
- {
#if FILNMLEN != E_FILNMLEN
-#error we need to cope with truncating or extending FILNMLEN
-#else
- memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname, FILNMLEN);
+#error we need to cope with truncating or extending x_fname
#endif
- }
+ memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname, FILNMLEN);
goto end;
case C_STAT:
@@ -521,13 +518,10 @@ coff_swap_aux_out (bfd * abfd,
H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset, ext->x_file.x_n.x_offset);
}
else
- {
#if FILNMLEN != E_FILNMLEN
-#error we need to cope with truncating or extending FILNMLEN
-#else
- memcpy (ext->x_file.x_fname, in->x_file.x_n.x_fname, FILNMLEN);
+#error we need to cope with truncating or extending xfname
#endif
- }
+ memcpy (ext->x_file.x_fname, in->x_file.x_n.x_fname, E_FILNMLEN);
goto end;
case C_STAT:
diff --git a/bfd/config.bfd b/bfd/config.bfd
index eb20a01..a5c3953 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -77,17 +77,18 @@ case $targ in
mips*-*-irix5* | mips*-*-irix6*)
# Not obsolete
;;
- *-adobe-* | \
*-*-beos* | \
- *-go32-rtems* | \
- *-sony-* | \
- *-tandem-* | \
+ *-*-cloudabi* | \
*-*-ieee* | \
*-*-nacl* | \
*-*-netbsdpe* | \
*-*-netware* | \
*-*-rtemsaout* | \
*-*-rtemscoff* | \
+ *-adobe-* | \
+ *-go32-rtems* | \
+ *-sony-* | \
+ *-tandem-* | \
a29k-* | \
arm*-*-aout | \
arm-*-coff | \
@@ -275,11 +276,6 @@ case "${targ}" in
targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
want64=true
;;
- aarch64-*-cloudabi*)
- targ_defvec=aarch64_elf64_le_cloudabi_vec
- targ_selvecs=aarch64_elf64_be_cloudabi_vec
- want64=true
- ;;
aarch64-*-haiku*)
targ_defvec=aarch64_elf64_le_vec
targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec"
@@ -659,10 +655,6 @@ case "${targ}" in
targ64_selvecs=x86_64_elf64_vec
;;
#ifdef BFD64
- x86_64-*-cloudabi*)
- targ_defvec=x86_64_elf64_cloudabi_vec
- want64=true
- ;;
x86_64-*-darwin*)
targ_defvec=x86_64_mach_o_vec
targ_selvecs="i386_mach_o_vec mach_o_le_vec mach_o_be_vec mach_o_fat_vec pef_vec pef_xlib_vec sym_vec"
diff --git a/bfd/configure b/bfd/configure
index 28ac5cc..721a0e9 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -11867,7 +11867,6 @@ fi
case "${target}" in
- hppa*64*-*-*) ;;
*-*-*aout*| i[3-7]86-*-msdos* | ns32k-*-* | pdp11-*-*)
if test "$plugins" = "yes"; then
if test "${enable_plugins+set}" = set; then
@@ -11877,16 +11876,6 @@ $as_echo "$as_me: WARNING: Enabling plugins for AOUT is experimental" >&2;}
plugins=no
fi
fi ;;
- hppa*-*-hpux* | *-*-*vms* | \
- powerpc*-*-aix* | powerpc-*-beos* | powerpc-*-macos* | rs6000-*-*)
- if test "$plugins" = "yes"; then
- if test "${enable_plugins+set}" = set; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Enabling plugins may result in ar creating non-standard archives for ${target}" >&5
-$as_echo "$as_me: WARNING: Enabling plugins may result in ar creating non-standard archives for ${target}" >&2;}
- else
- plugins=no
- fi
- fi ;;
esac
if test "$plugins" = "yes"; then
@@ -15485,9 +15474,7 @@ do
aarch64_elf32_be_vec) tb="$tb elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo $elf"; target_size=64 ;;
aarch64_elf32_le_vec) tb="$tb elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo $elf"; target_size=64 ;;
aarch64_elf64_be_vec) tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
- aarch64_elf64_be_cloudabi_vec) tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
aarch64_elf64_le_vec) tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
- aarch64_elf64_le_cloudabi_vec) tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
aarch64_mach_o_vec) tb="$tb mach-o-aarch64.lo"; target_size=64 ;;
aarch64_pei_le_vec) tb="$tb pei-aarch64.lo pe-aarch64igen.lo $coff"; target_size=64 ;;
aarch64_pe_le_vec) tb="$tb pe-aarch64.lo pe-aarch64igen.lo $coff"; target_size=64 ;;
@@ -15739,7 +15726,6 @@ do
x86_64_coff_vec) tb="$tb coff-x86_64.lo $coff"; target_size=64 ;;
x86_64_elf32_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf32.lo $elf"; target_size=64 ;;
x86_64_elf64_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
- x86_64_elf64_cloudabi_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
x86_64_elf64_fbsd_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
x86_64_elf64_sol2_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
x86_64_mach_o_vec) tb="$tb mach-o-x86-64.lo" ;;
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 502c526..7059c8e 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -45,7 +45,6 @@ ACX_LARGEFILE
changequote(,)dnl
case "${target}" in
- hppa*64*-*-*) ;;
*-*-*aout*| i[3-7]86-*-msdos* | ns32k-*-* | pdp11-*-*)
changequote([,])dnl
if test "$plugins" = "yes"; then
@@ -55,15 +54,6 @@ changequote([,])dnl
plugins=no
fi
fi ;;
- hppa*-*-hpux* | *-*-*vms* | \
- powerpc*-*-aix* | powerpc-*-beos* | powerpc-*-macos* | rs6000-*-*)
- if test "$plugins" = "yes"; then
- if test "${enable_plugins+set}" = set; then
- AC_MSG_WARN(Enabling plugins may result in ar creating non-standard archives for ${target})
- else
- plugins=no
- fi
- fi ;;
esac
AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
@@ -409,9 +399,7 @@ do
aarch64_elf32_be_vec) tb="$tb elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo $elf"; target_size=64 ;;
aarch64_elf32_le_vec) tb="$tb elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo $elf"; target_size=64 ;;
aarch64_elf64_be_vec) tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
- aarch64_elf64_be_cloudabi_vec) tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
aarch64_elf64_le_vec) tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
- aarch64_elf64_le_cloudabi_vec) tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
aarch64_mach_o_vec) tb="$tb mach-o-aarch64.lo"; target_size=64 ;;
aarch64_pei_le_vec) tb="$tb pei-aarch64.lo pe-aarch64igen.lo $coff"; target_size=64 ;;
aarch64_pe_le_vec) tb="$tb pe-aarch64.lo pe-aarch64igen.lo $coff"; target_size=64 ;;
@@ -663,7 +651,6 @@ do
x86_64_coff_vec) tb="$tb coff-x86_64.lo $coff"; target_size=64 ;;
x86_64_elf32_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo elf32.lo $elf"; target_size=64 ;;
x86_64_elf64_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
- x86_64_elf64_cloudabi_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
x86_64_elf64_fbsd_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
x86_64_elf64_sol2_vec) tb="$tb elf64-x86-64.lo $elfxx_x86 elf64.lo $elf"; target_size=64 ;;
x86_64_mach_o_vec) tb="$tb mach-o-x86-64.lo" ;;
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index b791623..de7cc41 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2631,8 +2631,8 @@ extern bool _bfd_elf_link_output_relocs
(bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
struct elf_link_hash_entry **);
-extern void _bfd_elf_link_add_glibc_version_dependency
- (struct elf_find_verdep_info *, const char *[]);
+extern bool _bfd_elf_link_add_glibc_version_dependency
+ (struct elf_find_verdep_info *, const char *const [], bool *);
extern void _bfd_elf_link_add_dt_relr_dependency
(struct elf_find_verdep_info *);
@@ -2927,6 +2927,8 @@ extern char *elfcore_write_xstatereg
(bfd *, char *, int *, const void *, int);
extern char *elfcore_write_x86_segbases
(bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_i386_tls
+ (bfd *, char *, int *, const void *, int);
extern char *elfcore_write_ppc_vmx
(bfd *, char *, int *, const void *, int);
extern char *elfcore_write_ppc_vsx
diff --git a/bfd/elf-linker-x86.h b/bfd/elf-linker-x86.h
index 2c98257..cdd739e 100644
--- a/bfd/elf-linker-x86.h
+++ b/bfd/elf-linker-x86.h
@@ -72,6 +72,23 @@ struct elf_linker_x86_params
/* Mark PLT with dynamic tags. */
unsigned int mark_plt : 1;
+ /* Add the GLIBC_ABI_GNU2_TLS version dependency if input object files
+ have R_386_TLS_DESC_CALL or R_X86_64_TLSDESC_CALL relocation:
+ 0: Disable.
+ 1: Enable.
+ 2: Auto. Enable if libc.so has the GLIBC_ABI_GNU2_TLS version.
+ */
+ unsigned int gnu2_tls_version_tag : 2;
+
+ /* Add the GLIBC_ABI_GNU_TLS version dependency if input object files
+ call ___tls_get_addr:
+ 0: Disable.
+ 1: Enable.
+ 2: Auto. Enable if libc.so has the GLIBC_ABI_GNU_TLS version.
+ This is only used by i386.
+ */
+ unsigned int gnu_tls_version_tag : 2;
+
/* X86-64 ISA level needed. */
unsigned int isa_level;
diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c
index 07ab380..73eb231 100644
--- a/bfd/elf-properties.c
+++ b/bfd/elf-properties.c
@@ -697,6 +697,23 @@ _bfd_elf_link_create_gnu_property_sec (struct bfd_link_info *info, bfd *elf_bfd,
return sec;
}
+/* Prune empty generic properties. */
+
+static void
+elf_prune_empty_properties (elf_property_list **pp)
+{
+ elf_property_list *p;
+
+ while ((p = *pp) != NULL)
+ if ((p->property.pr_type < GNU_PROPERTY_LOPROC
+ || p->property.pr_type >= GNU_PROPERTY_LOUSER)
+ && p->property.pr_datasz != 0
+ && p->property.pr_kind == property_number
+ && p->property.u.number == 0)
+ *pp = p->next;
+ else
+ pp = &p->next;
+}
/* Set up GNU properties. Return the first relocatable ELF input with
GNU properties if found. Otherwise, return NULL. */
@@ -878,22 +895,6 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
if (bed->fixup_gnu_properties)
bed->fixup_gnu_properties (info, &elf_properties (first_pbfd));
- if (elf_properties (first_pbfd) == NULL)
- {
- /* Discard .note.gnu.property section if all properties have
- been removed. */
- sec->output_section = bfd_abs_section_ptr;
- return NULL;
- }
-
- /* Compute the section size. */
- list = elf_properties (first_pbfd);
- size = elf_get_gnu_property_section_size (list, align_size);
-
- /* Update .note.gnu.property section now. */
- sec->size = size;
- contents = (bfd_byte *) bfd_zalloc (first_pbfd, size);
-
if (info->indirect_extern_access <= 0)
{
/* Get GNU_PROPERTY_1_NEEDED properties. */
@@ -917,6 +918,24 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
}
}
+ elf_prune_empty_properties (&elf_properties (first_pbfd));
+
+ if (elf_properties (first_pbfd) == NULL)
+ {
+ /* Discard .note.gnu.property section if all properties have
+ been removed. */
+ sec->output_section = bfd_abs_section_ptr;
+ return NULL;
+ }
+
+ /* Compute the section size. */
+ list = elf_properties (first_pbfd);
+ size = elf_get_gnu_property_section_size (list, align_size);
+
+ /* Update .note.gnu.property section now. */
+ sec->size = size;
+ contents = (bfd_byte *) bfd_zalloc (first_pbfd, size);
+
elf_write_gnu_properties (info, first_pbfd, contents, list, size,
align_size);
diff --git a/bfd/elf.c b/bfd/elf.c
index dfa04c9..6ef6030 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -49,6 +49,72 @@ SECTION
#include CORE_HEADER
#endif
+/* Utility macro to make testing for string equality easier to read. */
+#ifndef streq
+#define streq(A,B) (strcmp ((A), (B)) == 0)
+#endif
+
+/* Core note names. */
+#define NOTE_NAME_CORE "CORE"
+#define NOTE_NAME_FREEBSD "FreeBSD"
+#define NOTE_NAME_GDB "GDB"
+#define NOTE_NAME_LINUX "LINUX"
+
+/* Names of a pseudo-section which represent core notes. */
+#define NOTE_PSEUDO_SECTION_AARCH_GCS ".reg-aarch-gcs"
+#define NOTE_PSEUDO_SECTION_AARCH_HW_BREAK ".reg-aarch-hw-break"
+#define NOTE_PSEUDO_SECTION_AARCH_HW_WATCH ".reg-aarch-hw-watch"
+#define NOTE_PSEUDO_SECTION_AARCH_MTE ".reg-aarch-mte"
+#define NOTE_PSEUDO_SECTION_AARCH_PAUTH ".reg-aarch-pauth"
+#define NOTE_PSEUDO_SECTION_AARCH_SSVE ".reg-aarch-ssve"
+#define NOTE_PSEUDO_SECTION_AARCH_SVE ".reg-aarch-sve"
+#define NOTE_PSEUDO_SECTION_AARCH_TLS ".reg-aarch-tls"
+#define NOTE_PSEUDO_SECTION_AARCH_ZA ".reg-aarch-za"
+#define NOTE_PSEUDO_SECTION_AARCH_ZT ".reg-aarch-zt"
+#define NOTE_PSEUDO_SECTION_ARC_V2 ".reg-arc-v2"
+#define NOTE_PSEUDO_SECTION_ARM_VFP ".reg-arm-vfp"
+#define NOTE_PSEUDO_SECTION_I386_TLS ".reg-i386-tls"
+#define NOTE_PSEUDO_SECTION_LOONGARCH_CPUCFG ".reg-loongarch-cpucfg"
+#define NOTE_PSEUDO_SECTION_LOONGARCH_LASX ".reg-loongarch-lasx"
+#define NOTE_PSEUDO_SECTION_LOONGARCH_LBT ".reg-loongarch-lbt"
+#define NOTE_PSEUDO_SECTION_LOONGARCH_LSX ".reg-loongarch-lsx"
+#define NOTE_PSEUDO_SECTION_PPC_DSCR ".reg-ppc-dscr"
+#define NOTE_PSEUDO_SECTION_PPC_EBB ".reg-ppc-ebb"
+#define NOTE_PSEUDO_SECTION_PPC_PMU ".reg-ppc-pmu"
+#define NOTE_PSEUDO_SECTION_PPC_PPR ".reg-ppc-ppr"
+#define NOTE_PSEUDO_SECTION_PPC_TAR ".reg-ppc-tar"
+#define NOTE_PSEUDO_SECTION_PPC_TM_CDSCR ".reg-ppc-tm-cdscr"
+#define NOTE_PSEUDO_SECTION_PPC_TM_CFPR ".reg-ppc-tm-cfpr"
+#define NOTE_PSEUDO_SECTION_PPC_TM_CGPR ".reg-ppc-tm-cgpr"
+#define NOTE_PSEUDO_SECTION_PPC_TM_CPPR ".reg-ppc-tm-cppr"
+#define NOTE_PSEUDO_SECTION_PPC_TM_CTAR ".reg-ppc-tm-ctar"
+#define NOTE_PSEUDO_SECTION_PPC_TM_CVMX ".reg-ppc-tm-cvmx"
+#define NOTE_PSEUDO_SECTION_PPC_TM_CVSX ".reg_ppc_tm_cvsx"
+#define NOTE_PSEUDO_SECTION_PPC_TM_SPR ".reg_ppc_tm_spr"
+#define NOTE_PSEUDO_SECTION_PPC_VSX ".reg_ppc_vsx"
+#define NOTE_PSEUDO_SECTION_PPC_VMX ".reg_ppc_vmx"
+#define NOTE_PSEUDO_SECTION_REG ".reg"
+#define NOTE_PSEUDO_SECTION_REG2 ".reg2"
+#define NOTE_PSEUDO_SECTION_RISCV_CSR ".reg_riscv_csr"
+#define NOTE_PSEUDO_SECTION_S390_CTRS ".reg_s390_ctrs"
+#define NOTE_PSEUDO_SECTION_S390_GS_BC ".reg-s390-gs-bc"
+#define NOTE_PSEUDO_SECTION_S390_GS_CB ".reg-s390-gs-cb"
+#define NOTE_PSEUDO_SECTION_S390_HIGH_GPRS ".reg-s390-high-gprs"
+#define NOTE_PSEUDO_SECTION_S390_LAST_BREAK ".reg-s390-last-break"
+#define NOTE_PSEUDO_SECTION_S390_PREFIX ".reg-s390-prefix"
+#define NOTE_PSEUDO_SECTION_S390_SYSTEM_CALL ".reg-s390-system-call"
+#define NOTE_PSEUDO_SECTION_S390_TDB ".reg-s390-tdb"
+#define NOTE_PSEUDO_SECTION_S390_TIMER ".reg-s390-timer"
+#define NOTE_PSEUDO_SECTION_S390_TODCMP ".reg-s390-todcmp"
+#define NOTE_PSEUDO_SECTION_S390_TODPREG ".reg-s390-todpreg"
+#define NOTE_PSEUDO_SECTION_S390_VXRS_HIGH ".reg-s390-vxrs-high"
+#define NOTE_PSEUDO_SECTION_S390_VXRS_LOW ".reg-s390-vxrs-low"
+#define NOTE_PSEUDO_SECTION_SSP ".reg-ssp"
+#define NOTE_PSEUDO_SECTION_TDESC ".gdb-tdesc"
+#define NOTE_PSEUDO_SECTION_X86_SEGBASES ".reg-x86-segbases"
+#define NOTE_PSEUDO_SECTION_XFP ".reg-xfp"
+#define NOTE_PSEUDO_SECTION_XSTATE ".reg-xstate"
+
static int elf_sort_sections (const void *, const void *);
static bool assign_file_positions_except_relocs (bfd *, struct bfd_link_info *);
static bool swap_out_syms (bfd *, struct elf_strtab_hash **, int,
@@ -865,20 +931,16 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
else if ((flags & SEC_LOAD) != 0)
flags |= SEC_DATA;
if ((hdr->sh_flags & SHF_MERGE) != 0)
- {
- flags |= SEC_MERGE;
- newsect->entsize = hdr->sh_entsize;
- }
+ flags |= SEC_MERGE;
if ((hdr->sh_flags & SHF_STRINGS) != 0)
- {
- flags |= SEC_STRINGS;
- newsect->entsize = hdr->sh_entsize;
- }
+ flags |= SEC_STRINGS;
if ((hdr->sh_flags & SHF_TLS) != 0)
flags |= SEC_THREAD_LOCAL;
if ((hdr->sh_flags & SHF_EXCLUDE) != 0)
flags |= SEC_EXCLUDE;
+ newsect->entsize = hdr->sh_entsize;
+
switch (elf_elfheader (abfd)->e_ident[EI_OSABI])
{
/* FIXME: We should not recognize SHF_GNU_MBIND for ELFOSABI_NONE,
@@ -895,7 +957,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
break;
}
- if ((flags & SEC_ALLOC) == 0)
+ if ((flags & (SEC_ALLOC | SEC_GROUP)) == 0)
{
/* The debugging sections appear to be recognized only by name,
not any sort of flag. Their SEC_ALLOC bits are cleared. */
@@ -914,7 +976,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
}
else if (startswith (name, ".line")
|| startswith (name, ".stab")
- || strcmp (name, ".gdb_index") == 0)
+ || streq (name, ".gdb_index"))
flags |= SEC_DEBUGGING;
}
}
@@ -1558,7 +1620,7 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
if (bed->elf_backend_get_target_dtag)
name = (*bed->elf_backend_get_target_dtag) (dyn.d_tag);
- if (!strcmp (name, ""))
+ if (streq (name, ""))
{
sprintf (ab, "%#" PRIx64, (uint64_t) dyn.d_tag);
name = ab;
@@ -2303,7 +2365,7 @@ _bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
if (base_p
|| nodename == NULL
|| symbol->name == NULL
- || strcmp (symbol->name, nodename) != 0)
+ || ! streq (symbol->name, nodename))
version_string = nodename;
}
else
@@ -3766,6 +3828,9 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
if ((asect->flags & (SEC_GROUP | SEC_EXCLUDE)) == SEC_EXCLUDE)
this_hdr->sh_flags |= SHF_EXCLUDE;
+ if (this_hdr->sh_entsize == 0)
+ this_hdr->sh_entsize = asect->entsize;
+
/* If the section has relocs, set up a section header for the
SHT_REL[A] section. If two relocation sections are required for
this section, it is up to the processor-specific back-end to
@@ -4000,7 +4065,7 @@ _bfd_elf_plt_get_reloc_section (bfd *abfd, const char *name)
/* If a target needs .got.plt section, relocations in rela.plt/rel.plt
section likely apply to .got.plt or .got section. */
if (get_elf_backend_data (abfd)->want_got_plt
- && strcmp (name, ".plt") == 0)
+ && streq (name, ".plt"))
{
asection *sec;
@@ -4306,7 +4371,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
but without the trailing ``str'', and set its sh_link
field to point to this section. */
if (startswith (sec->name, ".stab")
- && strcmp (sec->name + strlen (sec->name) - 3, "str") == 0)
+ && streq (sec->name + strlen (sec->name) - 3, "str"))
{
size_t len;
char *alc;
@@ -6099,7 +6164,7 @@ assign_file_positions_for_load_sections (bfd *abfd,
PT_DYNAMIC segment. */
else if (p->p_type == PT_DYNAMIC
&& m->count > 1
- && strcmp (m->sections[0]->name, ".dynamic") != 0)
+ && ! streq (m->sections[0]->name, ".dynamic"))
{
_bfd_error_handler
(_("%pB: The first section in the PT_DYNAMIC segment"
@@ -7464,7 +7529,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd, bfd_vma maxpagesize)
|| (segment->p_paddr \
? segment->p_paddr != section->lma * (opb) \
: segment->p_vaddr != section->vma * (opb)) \
- || (strcmp (bfd_section_name (section), ".dynamic") == 0)) \
+ || (streq (bfd_section_name (section), ".dynamic"))) \
&& (segment->p_type != PT_LOAD || !section->segment_mark))
/* If the output section of a section in the input segment is NULL,
@@ -8430,9 +8495,28 @@ _bfd_elf_copy_private_section_data (bfd *ibfd,
& ~(SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_RELOC)) == 0)))
elf_section_type (osec) = elf_section_type (isec);
- /* FIXME: Is this correct for all OS/PROC specific flags? */
- elf_section_flags (osec) = (elf_section_flags (isec)
- & (SHF_MASKOS | SHF_MASKPROC));
+ elf_section_flags (osec) = elf_section_flags (isec);
+ /* Like for type, retain flags for objcopy (yet unlike for type, don't do so
+ for relocatable link). Same heuristic as there: If the BFD section flags
+ are different, assume --set-section-flags is in use for the section.
+
+ FIXME: Is this correct for all OS/PROC specific flags? */
+ if (link_info != NULL || osec->flags != isec->flags)
+ elf_section_flags (osec) &= (SHF_MASKOS | SHF_MASKPROC);
+ else
+ {
+ /* Clear only flags which are set below or elsewhere. */
+ elf_section_flags (osec) &= ~(SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR
+ | SHF_MERGE | SHF_STRINGS | SHF_LINK_ORDER
+ | SHF_INFO_LINK | SHF_GROUP | SHF_TLS
+ | SHF_COMPRESSED);
+ if (elf_section_flags (osec) & ~(SHF_MASKOS | SHF_MASKPROC))
+ _bfd_error_handler
+ (_("%pB:%pA: warning: retaining unknown section flag(s) %#" PRIx64),
+ ibfd, isec,
+ (uint64_t) (elf_section_flags (osec)
+ & ~(SHF_MASKOS | SHF_MASKPROC)));
+ }
/* Copy sh_info from input for mbind section. */
if ((elf_tdata (ibfd)->has_gnu_osabi & elf_gnu_osabi_mbind) != 0
@@ -10357,7 +10441,7 @@ elfcore_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
}
/* Make a ".reg/999" section and a ".reg" section. */
- return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+ return _bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG,
size, note->descpos + offset);
}
#endif /* defined (HAVE_PRSTATUS_T) */
@@ -10379,7 +10463,7 @@ elfcore_make_note_pseudosection (bfd *abfd,
static bool
elfcore_grok_prfpreg (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg2", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note);
}
/* Linux dumps the Intel SSE regs in a note named "LINUX" with a note
@@ -10389,7 +10473,7 @@ elfcore_grok_prfpreg (bfd *abfd, Elf_Internal_Note *note)
static bool
elfcore_grok_prxfpreg (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_XFP, note);
}
/* Linux dumps the Intel XSAVE extended state in a note named "LINUX"
@@ -10399,236 +10483,235 @@ elfcore_grok_prxfpreg (bfd *abfd, Elf_Internal_Note *note)
static bool
elfcore_grok_xstatereg (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-xstate", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_XSTATE, note);
}
static bool
elfcore_grok_sspreg (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ssp", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_SSP, note);
}
static bool
elfcore_grok_ppc_vmx (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-vmx", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_VMX, note);
}
static bool
elfcore_grok_ppc_vsx (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-vsx", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_VSX, note);
}
static bool
elfcore_grok_ppc_tar (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tar", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TAR, note);
}
static bool
elfcore_grok_ppc_ppr (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-ppr", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_PPR, note);
}
static bool
elfcore_grok_ppc_dscr (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-dscr", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_DSCR, note);
}
static bool
elfcore_grok_ppc_ebb (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-ebb", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_EBB, note);
}
static bool
elfcore_grok_ppc_pmu (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-pmu", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_PMU, note);
}
static bool
elfcore_grok_ppc_tm_cgpr (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cgpr", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CGPR, note);
}
static bool
elfcore_grok_ppc_tm_cfpr (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cfpr", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CFPR, note);
}
static bool
elfcore_grok_ppc_tm_cvmx (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cvmx", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CVMX, note);
}
static bool
elfcore_grok_ppc_tm_cvsx (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cvsx", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CVSX, note);
}
static bool
elfcore_grok_ppc_tm_spr (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-spr", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_SPR, note);
}
static bool
elfcore_grok_ppc_tm_ctar (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-ctar", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CTAR, note);
}
static bool
elfcore_grok_ppc_tm_cppr (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cppr", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CPPR, note);
}
static bool
elfcore_grok_ppc_tm_cdscr (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cdscr", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CDSCR, note);
}
static bool
elfcore_grok_s390_high_gprs (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-high-gprs", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_HIGH_GPRS, note);
}
static bool
elfcore_grok_s390_timer (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-timer", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_TIMER, note);
}
static bool
elfcore_grok_s390_todcmp (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-todcmp", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_TODCMP, note);
}
static bool
elfcore_grok_s390_todpreg (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-todpreg", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_TODPREG, note);
}
static bool
elfcore_grok_s390_ctrs (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-ctrs", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_CTRS, note);
}
static bool
elfcore_grok_s390_prefix (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-prefix", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_PREFIX, note);
}
static bool
elfcore_grok_s390_last_break (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-last-break", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_LAST_BREAK, note);
}
static bool
elfcore_grok_s390_system_call (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-system-call", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_SYSTEM_CALL, note);
}
static bool
elfcore_grok_s390_tdb (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-tdb", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_TDB, note);
}
static bool
elfcore_grok_s390_vxrs_low (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-vxrs-low", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_VXRS_LOW, note);
}
static bool
elfcore_grok_s390_vxrs_high (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-vxrs-high", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_VXRS_HIGH, note);
}
static bool
elfcore_grok_s390_gs_cb (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-gs-cb", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_GS_CB, note);
}
static bool
elfcore_grok_s390_gs_bc (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-s390-gs-bc", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_GS_BC, note);
}
static bool
elfcore_grok_arm_vfp (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-arm-vfp", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_ARM_VFP, note);
}
static bool
elfcore_grok_aarch_tls (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-tls", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_TLS, note);
}
static bool
elfcore_grok_aarch_hw_break (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-break", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_HW_BREAK, note);
}
static bool
elfcore_grok_aarch_hw_watch (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-watch", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_HW_WATCH, note);
}
static bool
elfcore_grok_aarch_sve (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-sve", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_SVE, note);
}
static bool
elfcore_grok_aarch_pauth (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-pauth", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_PAUTH, note);
}
static bool
elfcore_grok_aarch_mte (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-mte",
- note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_MTE, note);
}
static bool
elfcore_grok_aarch_ssve (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-ssve", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_SSVE, note);
}
static bool
elfcore_grok_aarch_za (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-za", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_ZA, note);
}
/* Convert NOTE into a bfd_section called ".reg-aarch-zt". Return TRUE if
@@ -10637,7 +10720,7 @@ elfcore_grok_aarch_za (bfd *abfd, Elf_Internal_Note *note)
static bool
elfcore_grok_aarch_zt (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-zt", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_ZT, note);
}
/* Convert NOTE into a bfd_section called ".reg-aarch-gcs". Return TRUE if
@@ -10646,13 +10729,13 @@ elfcore_grok_aarch_zt (bfd *abfd, Elf_Internal_Note *note)
static bool
elfcore_grok_aarch_gcs (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-aarch-gcs", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_GCS, note);
}
static bool
elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-arc-v2", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_ARC_V2, note);
}
/* Convert NOTE into a bfd_section called ".reg-riscv-csr". Return TRUE if
@@ -10661,7 +10744,7 @@ elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note)
static bool
elfcore_grok_riscv_csr (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-riscv-csr", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_RISCV_CSR, note);
}
/* Convert NOTE into a bfd_section called ".gdb-tdesc". Return TRUE if
@@ -10674,27 +10757,34 @@ elfcore_grok_gdb_tdesc (bfd *abfd, Elf_Internal_Note *note)
}
static bool
+elfcore_grok_i386_tls (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_I386_TLS,
+ note);
+}
+
+static bool
elfcore_grok_loongarch_cpucfg (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-cpucfg", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_LOONGARCH_CPUCFG, note);
}
static bool
elfcore_grok_loongarch_lbt (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-lbt", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_LOONGARCH_LBT, note);
}
static bool
elfcore_grok_loongarch_lsx (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-lsx", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_LOONGARCH_LSX, note);
}
static bool
elfcore_grok_loongarch_lasx (bfd *abfd, Elf_Internal_Note *note)
{
- return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-lasx", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_LOONGARCH_LASX, note);
}
#if defined (HAVE_PRPSINFO_T)
@@ -10864,7 +10954,7 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
/* Make a ".reg/999" section. */
- sprintf (buf, ".reg/%d", elfcore_make_pid (abfd));
+ sprintf (buf, NOTE_PSEUDO_SECTION_REG "/%d", elfcore_make_pid (abfd));
len = strlen (buf) + 1;
name = bfd_alloc (abfd, len);
if (name == NULL)
@@ -10888,12 +10978,12 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
sect->alignment_power = 2;
- if (!elfcore_maybe_make_sect (abfd, ".reg", sect))
+ if (!elfcore_maybe_make_sect (abfd, NOTE_PSEUDO_SECTION_REG, sect))
return false;
/* Make a ".reg2/999" section */
- sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd));
+ sprintf (buf, NOTE_PSEUDO_SECTION_REG2 "/%d", elfcore_make_pid (abfd));
len = strlen (buf) + 1;
name = bfd_alloc (abfd, len);
if (name == NULL)
@@ -10917,7 +11007,7 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
sect->alignment_power = 2;
- return elfcore_maybe_make_sect (abfd, ".reg2", sect);
+ return elfcore_maybe_make_sect (abfd, NOTE_PSEUDO_SECTION_REG2, sect);
}
#endif /* defined (HAVE_LWPSTATUS_T) */
@@ -10948,7 +11038,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
type = bfd_get_32 (abfd, note->descdata);
- struct
+ static const struct
{
const char *type_name;
unsigned long min_size;
@@ -10983,7 +11073,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
/* Make a ".reg/<tid>" section containing the Win32 API thread CONTEXT
structure. */
/* thread_info.tid */
- sprintf (buf, ".reg/%ld", (long) bfd_get_32 (abfd, note->descdata + 4));
+ sprintf (buf, NOTE_PSEUDO_SECTION_REG "/%ld", (long) bfd_get_32 (abfd, note->descdata + 4));
len = strlen (buf) + 1;
name = (char *) bfd_alloc (abfd, len);
@@ -11006,7 +11096,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
is_active_thread = bfd_get_32 (abfd, note->descdata + 8);
if (is_active_thread)
- if (! elfcore_maybe_make_sect (abfd, ".reg", sect))
+ if (! elfcore_maybe_make_sect (abfd, NOTE_PSEUDO_SECTION_REG, sect))
return false;
break;
@@ -11067,6 +11157,64 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ /* Short cut for LINUX notes. */
+ if (note->namesz == 6 /* strlen (NOTE_NAME_LINUX) + 1 */
+ && streq (note->namedata, NOTE_NAME_LINUX))
+ {
+ switch (note->type)
+ {
+ case NT_386_TLS: return elfcore_grok_i386_tls (abfd, note);
+ case NT_ARC_V2: return elfcore_grok_arc_v2 (abfd, note);
+ case NT_ARM_GCS: return elfcore_grok_aarch_gcs (abfd, note);
+ case NT_ARM_HW_BREAK: return elfcore_grok_aarch_hw_break (abfd, note);
+ case NT_ARM_HW_WATCH: return elfcore_grok_aarch_hw_watch (abfd, note);
+ case NT_ARM_PAC_MASK: return elfcore_grok_aarch_pauth (abfd, note);
+ case NT_ARM_SSVE: return elfcore_grok_aarch_ssve (abfd, note);
+ case NT_ARM_SVE: return elfcore_grok_aarch_sve (abfd, note);
+ case NT_ARM_TAGGED_ADDR_CTRL: return elfcore_grok_aarch_mte (abfd, note);
+ case NT_ARM_TLS: return elfcore_grok_aarch_tls (abfd, note);
+ case NT_ARM_VFP: return elfcore_grok_arm_vfp (abfd, note);
+ case NT_ARM_ZA: return elfcore_grok_aarch_za (abfd, note);
+ case NT_ARM_ZT: return elfcore_grok_aarch_zt (abfd, note);
+ case NT_LARCH_CPUCFG: return elfcore_grok_loongarch_cpucfg (abfd, note);
+ case NT_LARCH_LASX: return elfcore_grok_loongarch_lasx (abfd, note);
+ case NT_LARCH_LBT: return elfcore_grok_loongarch_lbt (abfd, note);
+ case NT_LARCH_LSX: return elfcore_grok_loongarch_lsx (abfd, note);
+ case NT_PPC_DSCR: return elfcore_grok_ppc_dscr (abfd, note);
+ case NT_PPC_EBB: return elfcore_grok_ppc_ebb (abfd, note);
+ case NT_PPC_PMU: return elfcore_grok_ppc_pmu (abfd, note);
+ case NT_PPC_PPR: return elfcore_grok_ppc_ppr (abfd, note);
+ case NT_PPC_TAR: return elfcore_grok_ppc_tar (abfd, note);
+ case NT_PPC_TM_CDSCR: return elfcore_grok_ppc_tm_cdscr (abfd, note);
+ case NT_PPC_TM_CFPR: return elfcore_grok_ppc_tm_cfpr (abfd, note);
+ case NT_PPC_TM_CGPR: return elfcore_grok_ppc_tm_cgpr (abfd, note);
+ case NT_PPC_TM_CPPR: return elfcore_grok_ppc_tm_cppr (abfd, note);
+ case NT_PPC_TM_CTAR: return elfcore_grok_ppc_tm_ctar (abfd, note);
+ case NT_PPC_TM_CVMX: return elfcore_grok_ppc_tm_cvmx (abfd, note);
+ case NT_PPC_TM_CVSX: return elfcore_grok_ppc_tm_cvsx (abfd, note);
+ case NT_PPC_TM_SPR: return elfcore_grok_ppc_tm_spr (abfd, note);
+ case NT_PPC_VMX: return elfcore_grok_ppc_vmx (abfd, note);
+ case NT_PPC_VSX: return elfcore_grok_ppc_vsx (abfd, note);
+ case NT_PRXFPREG: return elfcore_grok_prxfpreg (abfd, note);
+ case NT_S390_CTRS: return elfcore_grok_s390_ctrs (abfd, note);
+ case NT_S390_GS_BC: return elfcore_grok_s390_gs_bc (abfd, note);
+ case NT_S390_GS_CB: return elfcore_grok_s390_gs_cb (abfd, note);
+ case NT_S390_HIGH_GPRS: return elfcore_grok_s390_high_gprs (abfd, note);
+ case NT_S390_LAST_BREAK: return elfcore_grok_s390_last_break (abfd, note);
+ case NT_S390_PREFIX: return elfcore_grok_s390_prefix (abfd, note);
+ case NT_S390_SYSTEM_CALL: return elfcore_grok_s390_system_call (abfd, note);
+ case NT_S390_TDB: return elfcore_grok_s390_tdb (abfd, note);
+ case NT_S390_TIMER: return elfcore_grok_s390_timer (abfd, note);
+ case NT_S390_TODCMP: return elfcore_grok_s390_todcmp (abfd, note);
+ case NT_S390_TODPREG: return elfcore_grok_s390_todpreg (abfd, note);
+ case NT_S390_VXRS_HIGH: return elfcore_grok_s390_vxrs_high (abfd, note);
+ case NT_S390_VXRS_LOW: return elfcore_grok_s390_vxrs_low (abfd, note);
+ case NT_X86_SHSTK: return elfcore_grok_sspreg (abfd, note);
+ case NT_X86_XSTATE: return elfcore_grok_xstatereg (abfd, note);
+ default: break;
+ }
+ }
+
switch (note->type)
{
default:
@@ -11092,354 +11240,24 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
return elfcore_grok_lwpstatus (abfd, note);
#endif
- case NT_FPREGSET: /* FIXME: rename to NT_PRFPREG */
+ case NT_FPREGSET: /* FIXME: rename to NT_PRFPREG. */
return elfcore_grok_prfpreg (abfd, note);
case NT_WIN32PSTATUS:
return elfcore_grok_win32pstatus (abfd, note);
- case NT_PRXFPREG: /* Linux SSE extension */
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_prxfpreg (abfd, note);
- else
- return true;
-
- case NT_X86_XSTATE: /* Linux XSAVE extension */
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_xstatereg (abfd, note);
- else
- return true;
-
- case NT_X86_SHSTK: /* Linux CET extension. */
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_sspreg (abfd, note);
- else
- return true;
-
- case NT_PPC_VMX:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_vmx (abfd, note);
- else
- return true;
-
- case NT_PPC_VSX:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_vsx (abfd, note);
- else
- return true;
-
- case NT_PPC_TAR:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_tar (abfd, note);
- else
- return true;
-
- case NT_PPC_PPR:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_ppr (abfd, note);
- else
- return true;
-
- case NT_PPC_DSCR:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_dscr (abfd, note);
- else
- return true;
-
- case NT_PPC_EBB:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_ebb (abfd, note);
- else
- return true;
-
- case NT_PPC_PMU:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_pmu (abfd, note);
- else
- return true;
-
- case NT_PPC_TM_CGPR:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_tm_cgpr (abfd, note);
- else
- return true;
-
- case NT_PPC_TM_CFPR:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_tm_cfpr (abfd, note);
- else
- return true;
-
- case NT_PPC_TM_CVMX:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_tm_cvmx (abfd, note);
- else
- return true;
-
- case NT_PPC_TM_CVSX:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_tm_cvsx (abfd, note);
- else
- return true;
-
- case NT_PPC_TM_SPR:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_tm_spr (abfd, note);
- else
- return true;
-
- case NT_PPC_TM_CTAR:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_tm_ctar (abfd, note);
- else
- return true;
-
- case NT_PPC_TM_CPPR:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_tm_cppr (abfd, note);
- else
- return true;
-
- case NT_PPC_TM_CDSCR:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_ppc_tm_cdscr (abfd, note);
- else
- return true;
-
- case NT_S390_HIGH_GPRS:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_high_gprs (abfd, note);
- else
- return true;
-
- case NT_S390_TIMER:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_timer (abfd, note);
- else
- return true;
-
- case NT_S390_TODCMP:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_todcmp (abfd, note);
- else
- return true;
-
- case NT_S390_TODPREG:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_todpreg (abfd, note);
- else
- return true;
-
- case NT_S390_CTRS:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_ctrs (abfd, note);
- else
- return true;
-
- case NT_S390_PREFIX:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_prefix (abfd, note);
- else
- return true;
-
- case NT_S390_LAST_BREAK:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_last_break (abfd, note);
- else
- return true;
-
- case NT_S390_SYSTEM_CALL:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_system_call (abfd, note);
- else
- return true;
-
- case NT_S390_TDB:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_tdb (abfd, note);
- else
- return true;
-
- case NT_S390_VXRS_LOW:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_vxrs_low (abfd, note);
- else
- return true;
-
- case NT_S390_VXRS_HIGH:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_vxrs_high (abfd, note);
- else
- return true;
-
- case NT_S390_GS_CB:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_gs_cb (abfd, note);
- else
- return true;
-
- case NT_S390_GS_BC:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_s390_gs_bc (abfd, note);
- else
- return true;
-
- case NT_ARC_V2:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_arc_v2 (abfd, note);
- else
- return true;
-
- case NT_ARM_VFP:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_arm_vfp (abfd, note);
- else
- return true;
-
- case NT_ARM_TLS:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_tls (abfd, note);
- else
- return true;
-
- case NT_ARM_HW_BREAK:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_hw_break (abfd, note);
- else
- return true;
-
- case NT_ARM_HW_WATCH:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_hw_watch (abfd, note);
- else
- return true;
-
- case NT_ARM_SVE:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_sve (abfd, note);
- else
- return true;
-
- case NT_ARM_PAC_MASK:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_pauth (abfd, note);
- else
- return true;
-
- case NT_ARM_TAGGED_ADDR_CTRL:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_mte (abfd, note);
- else
- return true;
-
- case NT_ARM_SSVE:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_ssve (abfd, note);
- else
- return true;
-
- case NT_ARM_ZA:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_za (abfd, note);
- else
- return true;
-
- case NT_ARM_ZT:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_zt (abfd, note);
- else
- return true;
-
- case NT_ARM_GCS:
- if (note->namesz == 6 && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_aarch_gcs (abfd, note);
- else
- return true;
-
case NT_GDB_TDESC:
- if (note->namesz == 4
- && strcmp (note->namedata, "GDB") == 0)
+ if (note->namesz == 4 && streq (note->namedata, NOTE_NAME_GDB))
return elfcore_grok_gdb_tdesc (abfd, note);
else
return true;
case NT_RISCV_CSR:
- if (note->namesz == 4
- && strcmp (note->namedata, "GDB") == 0)
+ if (note->namesz == 4 && streq (note->namedata, NOTE_NAME_GDB))
return elfcore_grok_riscv_csr (abfd, note);
else
return true;
- case NT_LARCH_CPUCFG:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_loongarch_cpucfg (abfd, note);
- else
- return true;
-
- case NT_LARCH_LBT:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_loongarch_lbt (abfd, note);
- else
- return true;
-
- case NT_LARCH_LSX:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_loongarch_lsx (abfd, note);
- else
- return true;
-
- case NT_LARCH_LASX:
- if (note->namesz == 6
- && strcmp (note->namedata, "LINUX") == 0)
- return elfcore_grok_loongarch_lasx (abfd, note);
- else
- return true;
-
case NT_PRPSINFO:
case NT_PSINFO:
if (bed->elf_backend_grok_psinfo)
@@ -11461,7 +11279,6 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
case NT_SIGINFO:
return elfcore_make_note_pseudosection (abfd, ".note.linuxcore.siginfo",
note);
-
}
}
@@ -11656,7 +11473,7 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note)
return false;
/* Make a ".reg/999" section and a ".reg" section. */
- return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+ return _bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG,
size, note->descpos + offset);
}
@@ -11698,7 +11515,7 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note)
return elfcore_make_auxv_note_section (abfd, note, 4);
case NT_FREEBSD_X86_SEGBASES:
- return elfcore_make_note_pseudosection (abfd, ".reg-x86-segbases", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_X86_SEGBASES, note);
case NT_X86_XSTATE:
return elfcore_grok_xstatereg (abfd, note);
@@ -11801,10 +11618,10 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
switch (note->type)
{
case NT_NETBSDCORE_FIRSTMACH+0:
- return elfcore_make_note_pseudosection (abfd, ".reg", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, note);
case NT_NETBSDCORE_FIRSTMACH+2:
- return elfcore_make_note_pseudosection (abfd, ".reg2", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note);
default:
return true;
@@ -11818,10 +11635,10 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
switch (note->type)
{
case NT_NETBSDCORE_FIRSTMACH+3:
- return elfcore_make_note_pseudosection (abfd, ".reg", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, note);
case NT_NETBSDCORE_FIRSTMACH+5:
- return elfcore_make_note_pseudosection (abfd, ".reg2", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note);
default:
return true;
@@ -11834,10 +11651,10 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note)
switch (note->type)
{
case NT_NETBSDCORE_FIRSTMACH+1:
- return elfcore_make_note_pseudosection (abfd, ".reg", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, note);
case NT_NETBSDCORE_FIRSTMACH+3:
- return elfcore_make_note_pseudosection (abfd, ".reg2", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note);
default:
return true;
@@ -11887,11 +11704,11 @@ elfcore_grok_solaris_prstatus (bfd *abfd, Elf_Internal_Note* note, int sig_off,
elf_tdata (abfd)->core->lwpid
= bfd_get_32 (abfd, note->descdata + lwpid_off);
- sect = bfd_get_section_by_name (abfd, ".reg");
+ sect = bfd_get_section_by_name (abfd, NOTE_PSEUDO_SECTION_REG);
if (sect != NULL)
sect->size = gregset_size;
- return _bfd_elfcore_make_pseudosection (abfd, ".reg", gregset_size,
+ return _bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, gregset_size,
note->descpos + gregset_offset);
}
@@ -11925,7 +11742,7 @@ elfcore_grok_solaris_lwpstatus (bfd *abfd, Elf_Internal_Note* note,
asection *sect = NULL;
char reg2_section_name[16] = { 0 };
- (void) snprintf (reg2_section_name, 16, "%s/%i", ".reg2",
+ (void) snprintf (reg2_section_name, 16, "%s/%i", NOTE_PSEUDO_SECTION_REG2,
elf_tdata (abfd)->core->lwpid);
/* offsetof(lwpstatus_t, pr_lwpid) */
@@ -11935,10 +11752,10 @@ elfcore_grok_solaris_lwpstatus (bfd *abfd, Elf_Internal_Note* note,
elf_tdata (abfd)->core->signal
= bfd_get_16 (abfd, note->descdata + 12);
- sect = bfd_get_section_by_name (abfd, ".reg");
+ sect = bfd_get_section_by_name (abfd, NOTE_PSEUDO_SECTION_REG);
if (sect != NULL)
sect->size = gregset_size;
- else if (!_bfd_elfcore_make_pseudosection (abfd, ".reg", gregset_size,
+ else if (!_bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, gregset_size,
note->descpos + gregset_off))
return false;
@@ -11949,7 +11766,7 @@ elfcore_grok_solaris_lwpstatus (bfd *abfd, Elf_Internal_Note* note,
sect->filepos = note->descpos + fpregset_off;
sect->alignment_power = 2;
}
- else if (!_bfd_elfcore_make_pseudosection (abfd, ".reg2", fpregset_size,
+ else if (!_bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, fpregset_size,
note->descpos + fpregset_off))
return false;
@@ -12063,13 +11880,13 @@ elfcore_grok_openbsd_note (bfd *abfd, Elf_Internal_Note *note)
return elfcore_grok_openbsd_procinfo (abfd, note);
if (note->type == NT_OPENBSD_REGS)
- return elfcore_make_note_pseudosection (abfd, ".reg", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, note);
if (note->type == NT_OPENBSD_FPREGS)
- return elfcore_make_note_pseudosection (abfd, ".reg2", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note);
if (note->type == NT_OPENBSD_XFPREGS)
- return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note);
+ return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_XFP, note);
if (note->type == NT_OPENBSD_AUXV)
return elfcore_make_auxv_note_section (abfd, note, 0);
@@ -12193,9 +12010,9 @@ elfcore_grok_nto_note (bfd *abfd, Elf_Internal_Note *note)
case QNT_CORE_STATUS:
return elfcore_grok_nto_status (abfd, note, &tid);
case QNT_CORE_GREG:
- return elfcore_grok_nto_regs (abfd, note, tid, ".reg");
+ return elfcore_grok_nto_regs (abfd, note, tid, NOTE_PSEUDO_SECTION_REG);
case QNT_CORE_FPREG:
- return elfcore_grok_nto_regs (abfd, note, tid, ".reg2");
+ return elfcore_grok_nto_regs (abfd, note, tid, NOTE_PSEUDO_SECTION_REG2);
default:
return true;
}
@@ -12345,7 +12162,7 @@ elfcore_write_prpsinfo (bfd *abfd,
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
return elfcore_write_note (abfd, buf, bufsiz,
- "CORE", note_type, &data, sizeof (data));
+ NOTE_NAME_CORE, note_type, &data, sizeof (data));
}
else
# endif
@@ -12362,7 +12179,7 @@ elfcore_write_prpsinfo (bfd *abfd,
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
return elfcore_write_note (abfd, buf, bufsiz,
- "CORE", note_type, &data, sizeof (data));
+ NOTE_NAME_CORE, note_type, &data, sizeof (data));
}
#endif /* PSINFO_T or PRPSINFO_T */
@@ -12383,7 +12200,7 @@ elfcore_write_linux_prpsinfo32
struct elf_external_linux_prpsinfo32_ugid16 data;
swap_linux_prpsinfo32_ugid16_out (abfd, prpsinfo, &data);
- return elfcore_write_note (abfd, buf, bufsiz, "CORE", NT_PRPSINFO,
+ return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE, NT_PRPSINFO,
&data, sizeof (data));
}
else
@@ -12391,7 +12208,7 @@ elfcore_write_linux_prpsinfo32
struct elf_external_linux_prpsinfo32_ugid32 data;
swap_linux_prpsinfo32_ugid32_out (abfd, prpsinfo, &data);
- return elfcore_write_note (abfd, buf, bufsiz, "CORE", NT_PRPSINFO,
+ return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE, NT_PRPSINFO,
&data, sizeof (data));
}
}
@@ -12407,7 +12224,7 @@ elfcore_write_linux_prpsinfo64
swap_linux_prpsinfo64_ugid16_out (abfd, prpsinfo, &data);
return elfcore_write_note (abfd, buf, bufsiz,
- "CORE", NT_PRPSINFO, &data, sizeof (data));
+ NOTE_NAME_CORE, NT_PRPSINFO, &data, sizeof (data));
}
else
{
@@ -12415,7 +12232,7 @@ elfcore_write_linux_prpsinfo64
swap_linux_prpsinfo64_ugid32_out (abfd, prpsinfo, &data);
return elfcore_write_note (abfd, buf, bufsiz,
- "CORE", NT_PRPSINFO, &data, sizeof (data));
+ NOTE_NAME_CORE, NT_PRPSINFO, &data, sizeof (data));
}
}
@@ -12449,7 +12266,7 @@ elfcore_write_prstatus (bfd *abfd,
prstat.pr_pid = pid;
prstat.pr_cursig = cursig;
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
- return elfcore_write_note (abfd, buf, bufsiz, "CORE",
+ return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE,
NT_PRSTATUS, &prstat, sizeof (prstat));
}
else
@@ -12461,7 +12278,7 @@ elfcore_write_prstatus (bfd *abfd,
prstat.pr_pid = pid;
prstat.pr_cursig = cursig;
memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
- return elfcore_write_note (abfd, buf, bufsiz, "CORE",
+ return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE,
NT_PRSTATUS, &prstat, sizeof (prstat));
}
#endif /* HAVE_PRSTATUS_T */
@@ -12480,7 +12297,6 @@ elfcore_write_lwpstatus (bfd *abfd,
const void *gregs)
{
lwpstatus_t lwpstat;
- const char *note_name = "CORE";
memset (&lwpstat, 0, sizeof (lwpstat));
lwpstat.pr_lwpid = pid >> 16;
@@ -12496,7 +12312,7 @@ elfcore_write_lwpstatus (bfd *abfd,
gregs, sizeof (lwpstat.pr_context.uc_mcontext.__gregs));
#endif
#endif
- return elfcore_write_note (abfd, buf, bufsiz, note_name,
+ return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE,
NT_LWPSTATUS, &lwpstat, sizeof (lwpstat));
}
#endif /* HAVE_LWPSTATUS_T */
@@ -12510,7 +12326,6 @@ elfcore_write_pstatus (bfd *abfd,
int cursig ATTRIBUTE_UNUSED,
const void *gregs ATTRIBUTE_UNUSED)
{
- const char *note_name = "CORE";
#if defined (HAVE_PSTATUS32_T)
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
@@ -12520,7 +12335,7 @@ elfcore_write_pstatus (bfd *abfd,
memset (&pstat, 0, sizeof (pstat));
pstat.pr_pid = pid & 0xffff;
- buf = elfcore_write_note (abfd, buf, bufsiz, note_name,
+ buf = elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE,
NT_PSTATUS, &pstat, sizeof (pstat));
return buf;
}
@@ -12531,7 +12346,7 @@ elfcore_write_pstatus (bfd *abfd,
memset (&pstat, 0, sizeof (pstat));
pstat.pr_pid = pid & 0xffff;
- buf = elfcore_write_note (abfd, buf, bufsiz, note_name,
+ buf = elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE,
NT_PSTATUS, &pstat, sizeof (pstat));
return buf;
}
@@ -12545,9 +12360,8 @@ elfcore_write_prfpreg (bfd *abfd,
const void *fpregs,
int size)
{
- const char *note_name = "CORE";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_FPREGSET, fpregs, size);
+ NOTE_NAME_CORE, NT_FPREGSET, fpregs, size);
}
char *
@@ -12557,9 +12371,8 @@ elfcore_write_prxfpreg (bfd *abfd,
const void *xfpregs,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PRXFPREG, xfpregs, size);
+ NOTE_NAME_LINUX, NT_PRXFPREG, xfpregs, size);
}
char *
@@ -12567,10 +12380,12 @@ elfcore_write_xstatereg (bfd *abfd, char *buf, int *bufsiz,
const void *xfpregs, int size)
{
char *note_name;
+
if (get_elf_backend_data (abfd)->elf_osabi == ELFOSABI_FREEBSD)
- note_name = "FreeBSD";
+ note_name = NOTE_NAME_FREEBSD;
else
- note_name = "LINUX";
+ note_name = NOTE_NAME_LINUX;
+
return elfcore_write_note (abfd, buf, bufsiz,
note_name, NT_X86_XSTATE, xfpregs, size);
}
@@ -12579,18 +12394,25 @@ static char *
elfcore_write_sspreg (bfd *abfd, char *buf, int *bufsiz,
const void *ssp, int size)
{
- const char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_X86_SHSTK, ssp, size);
+ NOTE_NAME_LINUX, NT_X86_SHSTK, ssp, size);
}
char *
elfcore_write_x86_segbases (bfd *abfd, char *buf, int *bufsiz,
const void *regs, int size)
{
- char *note_name = "FreeBSD";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_FREEBSD_X86_SEGBASES, regs, size);
+ NOTE_NAME_FREEBSD, NT_FREEBSD_X86_SEGBASES,
+ regs, size);
+}
+
+char *
+elfcore_write_i386_tls (bfd *abfd, char *buf, int *bufsiz,
+ const void *regs, int size)
+{
+ return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_LINUX, NT_386_TLS,
+ regs, size);
}
char *
@@ -12600,9 +12422,8 @@ elfcore_write_ppc_vmx (bfd *abfd,
const void *ppc_vmx,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_VMX, ppc_vmx, size);
+ NOTE_NAME_LINUX, NT_PPC_VMX, ppc_vmx, size);
}
char *
@@ -12612,9 +12433,8 @@ elfcore_write_ppc_vsx (bfd *abfd,
const void *ppc_vsx,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_VSX, ppc_vsx, size);
+ NOTE_NAME_LINUX, NT_PPC_VSX, ppc_vsx, size);
}
char *
@@ -12624,9 +12444,8 @@ elfcore_write_ppc_tar (bfd *abfd,
const void *ppc_tar,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_TAR, ppc_tar, size);
+ NOTE_NAME_LINUX, NT_PPC_TAR, ppc_tar, size);
}
char *
@@ -12636,9 +12455,8 @@ elfcore_write_ppc_ppr (bfd *abfd,
const void *ppc_ppr,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_PPR, ppc_ppr, size);
+ NOTE_NAME_LINUX, NT_PPC_PPR, ppc_ppr, size);
}
char *
@@ -12648,9 +12466,8 @@ elfcore_write_ppc_dscr (bfd *abfd,
const void *ppc_dscr,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_DSCR, ppc_dscr, size);
+ NOTE_NAME_LINUX, NT_PPC_DSCR, ppc_dscr, size);
}
char *
@@ -12660,9 +12477,8 @@ elfcore_write_ppc_ebb (bfd *abfd,
const void *ppc_ebb,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_EBB, ppc_ebb, size);
+ NOTE_NAME_LINUX, NT_PPC_EBB, ppc_ebb, size);
}
char *
@@ -12672,9 +12488,8 @@ elfcore_write_ppc_pmu (bfd *abfd,
const void *ppc_pmu,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_PMU, ppc_pmu, size);
+ NOTE_NAME_LINUX, NT_PPC_PMU, ppc_pmu, size);
}
char *
@@ -12684,9 +12499,9 @@ elfcore_write_ppc_tm_cgpr (bfd *abfd,
const void *ppc_tm_cgpr,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_TM_CGPR, ppc_tm_cgpr, size);
+ NOTE_NAME_LINUX, NT_PPC_TM_CGPR,
+ ppc_tm_cgpr, size);
}
char *
@@ -12696,9 +12511,9 @@ elfcore_write_ppc_tm_cfpr (bfd *abfd,
const void *ppc_tm_cfpr,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_TM_CFPR, ppc_tm_cfpr, size);
+ NOTE_NAME_LINUX, NT_PPC_TM_CFPR,
+ ppc_tm_cfpr, size);
}
char *
@@ -12708,9 +12523,9 @@ elfcore_write_ppc_tm_cvmx (bfd *abfd,
const void *ppc_tm_cvmx,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_TM_CVMX, ppc_tm_cvmx, size);
+ NOTE_NAME_LINUX, NT_PPC_TM_CVMX,
+ ppc_tm_cvmx, size);
}
char *
@@ -12720,9 +12535,9 @@ elfcore_write_ppc_tm_cvsx (bfd *abfd,
const void *ppc_tm_cvsx,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_TM_CVSX, ppc_tm_cvsx, size);
+ NOTE_NAME_LINUX, NT_PPC_TM_CVSX,
+ ppc_tm_cvsx, size);
}
char *
@@ -12732,9 +12547,9 @@ elfcore_write_ppc_tm_spr (bfd *abfd,
const void *ppc_tm_spr,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_TM_SPR, ppc_tm_spr, size);
+ NOTE_NAME_LINUX, NT_PPC_TM_SPR,
+ ppc_tm_spr, size);
}
char *
@@ -12744,9 +12559,9 @@ elfcore_write_ppc_tm_ctar (bfd *abfd,
const void *ppc_tm_ctar,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_TM_CTAR, ppc_tm_ctar, size);
+ NOTE_NAME_LINUX, NT_PPC_TM_CTAR,
+ ppc_tm_ctar, size);
}
char *
@@ -12756,9 +12571,9 @@ elfcore_write_ppc_tm_cppr (bfd *abfd,
const void *ppc_tm_cppr,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_TM_CPPR, ppc_tm_cppr, size);
+ NOTE_NAME_LINUX, NT_PPC_TM_CPPR,
+ ppc_tm_cppr, size);
}
char *
@@ -12768,9 +12583,9 @@ elfcore_write_ppc_tm_cdscr (bfd *abfd,
const void *ppc_tm_cdscr,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_PPC_TM_CDSCR, ppc_tm_cdscr, size);
+ NOTE_NAME_LINUX, NT_PPC_TM_CDSCR,
+ ppc_tm_cdscr, size);
}
static char *
@@ -12780,9 +12595,8 @@ elfcore_write_s390_high_gprs (bfd *abfd,
const void *s390_high_gprs,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_HIGH_GPRS,
+ NOTE_NAME_LINUX, NT_S390_HIGH_GPRS,
s390_high_gprs, size);
}
@@ -12793,9 +12607,9 @@ elfcore_write_s390_timer (bfd *abfd,
const void *s390_timer,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_TIMER, s390_timer, size);
+ NOTE_NAME_LINUX, NT_S390_TIMER,
+ s390_timer, size);
}
char *
@@ -12805,9 +12619,9 @@ elfcore_write_s390_todcmp (bfd *abfd,
const void *s390_todcmp,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_TODCMP, s390_todcmp, size);
+ NOTE_NAME_LINUX, NT_S390_TODCMP,
+ s390_todcmp, size);
}
char *
@@ -12817,9 +12631,9 @@ elfcore_write_s390_todpreg (bfd *abfd,
const void *s390_todpreg,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_TODPREG, s390_todpreg, size);
+ NOTE_NAME_LINUX, NT_S390_TODPREG,
+ s390_todpreg, size);
}
char *
@@ -12829,9 +12643,8 @@ elfcore_write_s390_ctrs (bfd *abfd,
const void *s390_ctrs,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_CTRS, s390_ctrs, size);
+ NOTE_NAME_LINUX, NT_S390_CTRS, s390_ctrs, size);
}
char *
@@ -12841,9 +12654,9 @@ elfcore_write_s390_prefix (bfd *abfd,
const void *s390_prefix,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_PREFIX, s390_prefix, size);
+ NOTE_NAME_LINUX, NT_S390_PREFIX,
+ s390_prefix, size);
}
char *
@@ -12853,9 +12666,8 @@ elfcore_write_s390_last_break (bfd *abfd,
const void *s390_last_break,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_LAST_BREAK,
+ NOTE_NAME_LINUX, NT_S390_LAST_BREAK,
s390_last_break, size);
}
@@ -12866,9 +12678,8 @@ elfcore_write_s390_system_call (bfd *abfd,
const void *s390_system_call,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_SYSTEM_CALL,
+ NOTE_NAME_LINUX, NT_S390_SYSTEM_CALL,
s390_system_call, size);
}
@@ -12879,9 +12690,8 @@ elfcore_write_s390_tdb (bfd *abfd,
const void *s390_tdb,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_TDB, s390_tdb, size);
+ NOTE_NAME_LINUX, NT_S390_TDB, s390_tdb, size);
}
char *
@@ -12891,9 +12701,9 @@ elfcore_write_s390_vxrs_low (bfd *abfd,
const void *s390_vxrs_low,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_VXRS_LOW, s390_vxrs_low, size);
+ NOTE_NAME_LINUX, NT_S390_VXRS_LOW,
+ s390_vxrs_low, size);
}
char *
@@ -12903,9 +12713,8 @@ elfcore_write_s390_vxrs_high (bfd *abfd,
const void *s390_vxrs_high,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_VXRS_HIGH,
+ NOTE_NAME_LINUX, NT_S390_VXRS_HIGH,
s390_vxrs_high, size);
}
@@ -12916,9 +12725,8 @@ elfcore_write_s390_gs_cb (bfd *abfd,
const void *s390_gs_cb,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_GS_CB,
+ NOTE_NAME_LINUX, NT_S390_GS_CB,
s390_gs_cb, size);
}
@@ -12929,9 +12737,8 @@ elfcore_write_s390_gs_bc (bfd *abfd,
const void *s390_gs_bc,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_S390_GS_BC,
+ NOTE_NAME_LINUX, NT_S390_GS_BC,
s390_gs_bc, size);
}
@@ -12942,9 +12749,9 @@ elfcore_write_arm_vfp (bfd *abfd,
const void *arm_vfp,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_VFP, arm_vfp, size);
+ NOTE_NAME_LINUX, NT_ARM_VFP,
+ arm_vfp, size);
}
char *
@@ -12954,9 +12761,8 @@ elfcore_write_aarch_tls (bfd *abfd,
const void *aarch_tls,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_TLS, aarch_tls, size);
+ NOTE_NAME_LINUX, NT_ARM_TLS, aarch_tls, size);
}
char *
@@ -12966,9 +12772,9 @@ elfcore_write_aarch_hw_break (bfd *abfd,
const void *aarch_hw_break,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_HW_BREAK, aarch_hw_break, size);
+ NOTE_NAME_LINUX, NT_ARM_HW_BREAK,
+ aarch_hw_break, size);
}
char *
@@ -12978,9 +12784,9 @@ elfcore_write_aarch_hw_watch (bfd *abfd,
const void *aarch_hw_watch,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_HW_WATCH, aarch_hw_watch, size);
+ NOTE_NAME_LINUX, NT_ARM_HW_WATCH,
+ aarch_hw_watch, size);
}
char *
@@ -12990,9 +12796,8 @@ elfcore_write_aarch_sve (bfd *abfd,
const void *aarch_sve,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_SVE, aarch_sve, size);
+ NOTE_NAME_LINUX, NT_ARM_SVE, aarch_sve, size);
}
char *
@@ -13002,23 +12807,21 @@ elfcore_write_aarch_pauth (bfd *abfd,
const void *aarch_pauth,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_PAC_MASK, aarch_pauth, size);
+ NOTE_NAME_LINUX, NT_ARM_PAC_MASK,
+ aarch_pauth, size);
}
char *
elfcore_write_aarch_mte (bfd *abfd,
- char *buf,
- int *bufsiz,
- const void *aarch_mte,
- int size)
+ char *buf,
+ int *bufsiz,
+ const void *aarch_mte,
+ int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_TAGGED_ADDR_CTRL,
- aarch_mte,
- size);
+ NOTE_NAME_LINUX, NT_ARM_TAGGED_ADDR_CTRL,
+ aarch_mte, size);
}
char *
@@ -13028,11 +12831,9 @@ elfcore_write_aarch_ssve (bfd *abfd,
const void *aarch_ssve,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_SSVE,
- aarch_ssve,
- size);
+ NOTE_NAME_LINUX, NT_ARM_SSVE,
+ aarch_ssve, size);
}
char *
@@ -13042,11 +12843,9 @@ elfcore_write_aarch_za (bfd *abfd,
const void *aarch_za,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_ZA,
- aarch_za,
- size);
+ NOTE_NAME_LINUX, NT_ARM_ZA,
+ aarch_za, size);
}
/* Write the buffer of zt register values in aarch_zt (length SIZE) into
@@ -13061,11 +12860,9 @@ elfcore_write_aarch_zt (bfd *abfd,
const void *aarch_zt,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARM_ZT,
- aarch_zt,
- size);
+ NOTE_NAME_LINUX, NT_ARM_ZT,
+ aarch_zt, size);
}
/* Write the buffer of GCS register values in AARCH_GCS (length SIZE) into
@@ -13077,8 +12874,7 @@ static char *
elfcore_write_aarch_gcs (bfd *abfd, char *buf, int *bufsiz,
const void *aarch_gcs, int size)
{
- const char *note_name = "LINUX";
- return elfcore_write_note (abfd, buf, bufsiz, note_name, NT_ARM_GCS,
+ return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_LINUX, NT_ARM_GCS,
aarch_gcs, size);
}
@@ -13089,9 +12885,8 @@ elfcore_write_arc_v2 (bfd *abfd,
const void *arc_v2,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_ARC_V2, arc_v2, size);
+ NOTE_NAME_LINUX, NT_ARC_V2, arc_v2, size);
}
char *
@@ -13101,9 +12896,8 @@ elfcore_write_loongarch_cpucfg (bfd *abfd,
const void *loongarch_cpucfg,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_LARCH_CPUCFG,
+ NOTE_NAME_LINUX, NT_LARCH_CPUCFG,
loongarch_cpucfg, size);
}
@@ -13114,9 +12908,9 @@ elfcore_write_loongarch_lbt (bfd *abfd,
const void *loongarch_lbt,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_LARCH_LBT, loongarch_lbt, size);
+ NOTE_NAME_LINUX, NT_LARCH_LBT,
+ loongarch_lbt, size);
}
char *
@@ -13126,9 +12920,9 @@ elfcore_write_loongarch_lsx (bfd *abfd,
const void *loongarch_lsx,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_LARCH_LSX, loongarch_lsx, size);
+ NOTE_NAME_LINUX, NT_LARCH_LSX,
+ loongarch_lsx, size);
}
char *
@@ -13138,9 +12932,9 @@ elfcore_write_loongarch_lasx (bfd *abfd,
const void *loongarch_lasx,
int size)
{
- char *note_name = "LINUX";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_LARCH_LASX, loongarch_lasx, size);
+ NOTE_NAME_LINUX, NT_LARCH_LASX,
+ loongarch_lasx, size);
}
/* Write the buffer of csr values in CSRS (length SIZE) into the note
@@ -13155,9 +12949,8 @@ elfcore_write_riscv_csr (bfd *abfd,
const void *csrs,
int size)
{
- const char *note_name = "GDB";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_RISCV_CSR, csrs, size);
+ NOTE_NAME_GDB, NT_RISCV_CSR, csrs, size);
}
/* Write the target description (a string) pointed to by TDESC, length
@@ -13172,9 +12965,8 @@ elfcore_write_gdb_tdesc (bfd *abfd,
const void *tdesc,
int size)
{
- const char *note_name = "GDB";
return elfcore_write_note (abfd, buf, bufsiz,
- note_name, NT_GDB_TDESC, tdesc, size);
+ NOTE_NAME_GDB, NT_GDB_TDESC, tdesc, size);
}
char *
@@ -13185,108 +12977,73 @@ elfcore_write_register_note (bfd *abfd,
const void *data,
int size)
{
- if (strcmp (section, ".reg2") == 0)
- return elfcore_write_prfpreg (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-xfp") == 0)
- return elfcore_write_prxfpreg (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-xstate") == 0)
- return elfcore_write_xstatereg (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-x86-segbases") == 0)
- return elfcore_write_x86_segbases (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ssp") == 0)
- return elfcore_write_sspreg (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-vmx") == 0)
- return elfcore_write_ppc_vmx (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-vsx") == 0)
- return elfcore_write_ppc_vsx (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-tar") == 0)
- return elfcore_write_ppc_tar (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-ppr") == 0)
- return elfcore_write_ppc_ppr (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-dscr") == 0)
- return elfcore_write_ppc_dscr (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-ebb") == 0)
- return elfcore_write_ppc_ebb (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-pmu") == 0)
- return elfcore_write_ppc_pmu (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-tm-cgpr") == 0)
- return elfcore_write_ppc_tm_cgpr (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-tm-cfpr") == 0)
- return elfcore_write_ppc_tm_cfpr (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-tm-cvmx") == 0)
- return elfcore_write_ppc_tm_cvmx (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-tm-cvsx") == 0)
- return elfcore_write_ppc_tm_cvsx (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-tm-spr") == 0)
- return elfcore_write_ppc_tm_spr (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-tm-ctar") == 0)
- return elfcore_write_ppc_tm_ctar (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-tm-cppr") == 0)
- return elfcore_write_ppc_tm_cppr (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-ppc-tm-cdscr") == 0)
- return elfcore_write_ppc_tm_cdscr (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-high-gprs") == 0)
- return elfcore_write_s390_high_gprs (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-timer") == 0)
- return elfcore_write_s390_timer (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-todcmp") == 0)
- return elfcore_write_s390_todcmp (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-todpreg") == 0)
- return elfcore_write_s390_todpreg (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-ctrs") == 0)
- return elfcore_write_s390_ctrs (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-prefix") == 0)
- return elfcore_write_s390_prefix (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-last-break") == 0)
- return elfcore_write_s390_last_break (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-system-call") == 0)
- return elfcore_write_s390_system_call (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-tdb") == 0)
- return elfcore_write_s390_tdb (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-vxrs-low") == 0)
- return elfcore_write_s390_vxrs_low (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-vxrs-high") == 0)
- return elfcore_write_s390_vxrs_high (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-gs-cb") == 0)
- return elfcore_write_s390_gs_cb (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-s390-gs-bc") == 0)
- return elfcore_write_s390_gs_bc (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-arm-vfp") == 0)
- return elfcore_write_arm_vfp (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-tls") == 0)
- return elfcore_write_aarch_tls (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-hw-break") == 0)
- return elfcore_write_aarch_hw_break (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-hw-watch") == 0)
- return elfcore_write_aarch_hw_watch (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-sve") == 0)
- return elfcore_write_aarch_sve (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-pauth") == 0)
- return elfcore_write_aarch_pauth (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-mte") == 0)
- return elfcore_write_aarch_mte (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-ssve") == 0)
- return elfcore_write_aarch_ssve (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-za") == 0)
- return elfcore_write_aarch_za (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-zt") == 0)
- return elfcore_write_aarch_zt (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-aarch-gcs") == 0)
- return elfcore_write_aarch_gcs (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-arc-v2") == 0)
- return elfcore_write_arc_v2 (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".gdb-tdesc") == 0)
- return elfcore_write_gdb_tdesc (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-riscv-csr") == 0)
- return elfcore_write_riscv_csr (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-loongarch-cpucfg") == 0)
- return elfcore_write_loongarch_cpucfg (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-loongarch-lbt") == 0)
- return elfcore_write_loongarch_lbt (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-loongarch-lsx") == 0)
- return elfcore_write_loongarch_lsx (abfd, buf, bufsiz, data, size);
- if (strcmp (section, ".reg-loongarch-lasx") == 0)
- return elfcore_write_loongarch_lasx (abfd, buf, bufsiz, data, size);
+ static const struct
+ {
+ const char * section_name;
+ char * (*writer) (bfd *, char *, int *, const void *, int);
+ }
+ note_writers [] =
+ {
+ { NOTE_PSEUDO_SECTION_AARCH_GCS, elfcore_write_aarch_gcs},
+ { NOTE_PSEUDO_SECTION_AARCH_HW_BREAK, elfcore_write_aarch_hw_break},
+ { NOTE_PSEUDO_SECTION_AARCH_HW_WATCH, elfcore_write_aarch_hw_watch},
+ { NOTE_PSEUDO_SECTION_AARCH_MTE, elfcore_write_aarch_mte},
+ { NOTE_PSEUDO_SECTION_AARCH_PAUTH, elfcore_write_aarch_pauth},
+ { NOTE_PSEUDO_SECTION_AARCH_SSVE, elfcore_write_aarch_ssve},
+ { NOTE_PSEUDO_SECTION_AARCH_SVE, elfcore_write_aarch_sve},
+ { NOTE_PSEUDO_SECTION_AARCH_TLS, elfcore_write_aarch_tls},
+ { NOTE_PSEUDO_SECTION_AARCH_ZA, elfcore_write_aarch_za},
+ { NOTE_PSEUDO_SECTION_AARCH_ZT, elfcore_write_aarch_zt},
+ { NOTE_PSEUDO_SECTION_ARC_V2, elfcore_write_arc_v2},
+ { NOTE_PSEUDO_SECTION_ARM_VFP, elfcore_write_arm_vfp},
+ { NOTE_PSEUDO_SECTION_I386_TLS, elfcore_write_i386_tls},
+ { NOTE_PSEUDO_SECTION_LOONGARCH_CPUCFG, elfcore_write_loongarch_cpucfg},
+ { NOTE_PSEUDO_SECTION_LOONGARCH_LASX, elfcore_write_loongarch_lasx},
+ { NOTE_PSEUDO_SECTION_LOONGARCH_LBT, elfcore_write_loongarch_lbt},
+ { NOTE_PSEUDO_SECTION_LOONGARCH_LSX, elfcore_write_loongarch_lsx},
+ { NOTE_PSEUDO_SECTION_PPC_DSCR, elfcore_write_ppc_dscr},
+ { NOTE_PSEUDO_SECTION_PPC_EBB, elfcore_write_ppc_ebb},
+ { NOTE_PSEUDO_SECTION_PPC_PMU, elfcore_write_ppc_pmu},
+ { NOTE_PSEUDO_SECTION_PPC_PPR, elfcore_write_ppc_ppr},
+ { NOTE_PSEUDO_SECTION_PPC_TAR, elfcore_write_ppc_tar},
+ { NOTE_PSEUDO_SECTION_PPC_TM_CDSCR, elfcore_write_ppc_tm_cdscr},
+ { NOTE_PSEUDO_SECTION_PPC_TM_CFPR, elfcore_write_ppc_tm_cfpr},
+ { NOTE_PSEUDO_SECTION_PPC_TM_CGPR, elfcore_write_ppc_tm_cgpr},
+ { NOTE_PSEUDO_SECTION_PPC_TM_CPPR, elfcore_write_ppc_tm_cppr},
+ { NOTE_PSEUDO_SECTION_PPC_TM_CTAR, elfcore_write_ppc_tm_ctar},
+ { NOTE_PSEUDO_SECTION_PPC_TM_CVMX, elfcore_write_ppc_tm_cvmx},
+ { NOTE_PSEUDO_SECTION_PPC_TM_CVSX, elfcore_write_ppc_tm_cvsx},
+ { NOTE_PSEUDO_SECTION_PPC_TM_SPR, elfcore_write_ppc_tm_spr},
+ { NOTE_PSEUDO_SECTION_PPC_VMX, elfcore_write_ppc_vmx},
+ { NOTE_PSEUDO_SECTION_PPC_VSX, elfcore_write_ppc_vsx},
+ { NOTE_PSEUDO_SECTION_REG2, elfcore_write_prfpreg},
+ { NOTE_PSEUDO_SECTION_RISCV_CSR, elfcore_write_riscv_csr},
+ { NOTE_PSEUDO_SECTION_S390_CTRS, elfcore_write_s390_ctrs},
+ { NOTE_PSEUDO_SECTION_S390_GS_BC, elfcore_write_s390_gs_bc},
+ { NOTE_PSEUDO_SECTION_S390_GS_CB, elfcore_write_s390_gs_cb},
+ { NOTE_PSEUDO_SECTION_S390_HIGH_GPRS, elfcore_write_s390_high_gprs},
+ { NOTE_PSEUDO_SECTION_S390_LAST_BREAK, elfcore_write_s390_last_break},
+ { NOTE_PSEUDO_SECTION_S390_PREFIX, elfcore_write_s390_prefix},
+ { NOTE_PSEUDO_SECTION_S390_SYSTEM_CALL, elfcore_write_s390_system_call},
+ { NOTE_PSEUDO_SECTION_S390_TDB, elfcore_write_s390_tdb},
+ { NOTE_PSEUDO_SECTION_S390_TIMER, elfcore_write_s390_timer},
+ { NOTE_PSEUDO_SECTION_S390_TODCMP, elfcore_write_s390_todcmp},
+ { NOTE_PSEUDO_SECTION_S390_TODPREG, elfcore_write_s390_todpreg},
+ { NOTE_PSEUDO_SECTION_S390_VXRS_HIGH, elfcore_write_s390_vxrs_high},
+ { NOTE_PSEUDO_SECTION_S390_VXRS_LOW, elfcore_write_s390_vxrs_low},
+ { NOTE_PSEUDO_SECTION_SSP, elfcore_write_sspreg},
+ { NOTE_PSEUDO_SECTION_TDESC, elfcore_write_gdb_tdesc},
+ { NOTE_PSEUDO_SECTION_X86_SEGBASES, elfcore_write_x86_segbases},
+ { NOTE_PSEUDO_SECTION_XFP, elfcore_write_prxfpreg},
+ { NOTE_PSEUDO_SECTION_XSTATE, elfcore_write_xstatereg} /* NB/ No comma. */
+ };
+
+ int i;
+
+ for (i = ARRAY_SIZE (note_writers); i--;)
+ if (streq (section, note_writers[i].section_name))
+ return note_writers[i].writer (abfd, buf, bufsiz, data, size);
+
return NULL;
}
@@ -13295,7 +13052,7 @@ elfcore_write_file_note (bfd *obfd, char *note_data, int *note_size,
const void *buf, int bufsiz)
{
return elfcore_write_note (obfd, note_data, note_size,
- "CORE", NT_FILE, buf, bufsiz);
+ NOTE_NAME_CORE, NT_FILE, buf, bufsiz);
}
static bool
@@ -13345,7 +13102,7 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset,
case bfd_core:
{
#define GROKER_ELEMENT(S,F) {S, sizeof (S) - 1, F}
- struct
+ static const struct
{
const char * string;
size_t len;
@@ -13354,13 +13111,13 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset,
grokers[] =
{
GROKER_ELEMENT ("", elfcore_grok_note),
- GROKER_ELEMENT ("FreeBSD", elfcore_grok_freebsd_note),
+ GROKER_ELEMENT (NOTE_NAME_FREEBSD, elfcore_grok_freebsd_note),
GROKER_ELEMENT ("NetBSD-CORE", elfcore_grok_netbsd_note),
GROKER_ELEMENT ("OpenBSD", elfcore_grok_openbsd_note),
GROKER_ELEMENT ("QNX", elfcore_grok_nto_note),
GROKER_ELEMENT ("SPU/", elfcore_grok_spu_note),
GROKER_ELEMENT ("GNU", elfobj_grok_gnu_note),
- GROKER_ELEMENT ("CORE", elfcore_grok_solaris_note)
+ GROKER_ELEMENT (NOTE_NAME_CORE, elfcore_grok_solaris_note)
};
#undef GROKER_ELEMENT
int i;
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index b5d1866..df60430 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -12542,7 +12542,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
case R_ARM_THM_ALU_ABS_G2_NC:
case R_ARM_THM_ALU_ABS_G3_NC:
{
- const int shift_array[4] = {0, 8, 16, 24};
+ static const int shift_array[4] = {0, 8, 16, 24};
bfd_vma insn = bfd_get_16 (input_bfd, hit_data);
bfd_vma addr = value;
int shift = shift_array[r_type - R_ARM_THM_ALU_ABS_G0_NC];
@@ -14061,11 +14061,12 @@ set_secondary_compatible_arch (bfd *abfd, int arch)
static int
tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
- int newtag, int secondary_compat, const char* name_table[])
+ int newtag, int secondary_compat,
+ const char *const name_table[])
{
#define T(X) TAG_CPU_ARCH_##X
int tagl, tagh, result;
- const int v6t2[] =
+ static const int v6t2[] =
{
T(V6T2), /* PRE_V4. */
T(V6T2), /* V4. */
@@ -14077,7 +14078,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7), /* V6KZ. */
T(V6T2) /* V6T2. */
};
- const int v6k[] =
+ static const int v6k[] =
{
T(V6K), /* PRE_V4. */
T(V6K), /* V4. */
@@ -14090,7 +14091,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7), /* V6T2. */
T(V6K) /* V6K. */
};
- const int v7[] =
+ static const int v7[] =
{
T(V7), /* PRE_V4. */
T(V7), /* V4. */
@@ -14104,7 +14105,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7), /* V6K. */
T(V7) /* V7. */
};
- const int v6_m[] =
+ static const int v6_m[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14119,7 +14120,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7), /* V7. */
T(V6_M) /* V6_M. */
};
- const int v6s_m[] =
+ static const int v6s_m[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14135,7 +14136,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V6S_M), /* V6_M. */
T(V6S_M) /* V6S_M. */
};
- const int v7e_m[] =
+ static const int v7e_m[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14152,7 +14153,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7E_M), /* V6S_M. */
T(V7E_M) /* V7E_M. */
};
- const int v8[] =
+ static const int v8[] =
{
T(V8), /* PRE_V4. */
T(V8), /* V4. */
@@ -14177,7 +14178,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V8), /* V8.3. */
T(V8), /* V8.1-M.MAIN. */
};
- const int v8r[] =
+ static const int v8r[] =
{
T(V8R), /* PRE_V4. */
T(V8R), /* V4. */
@@ -14196,7 +14197,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V8), /* V8. */
T(V8R), /* V8R. */
};
- const int v8m_baseline[] =
+ static const int v8m_baseline[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14216,7 +14217,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
-1, /* V8R. */
T(V8M_BASE) /* V8-M BASELINE. */
};
- const int v8m_mainline[] =
+ static const int v8m_mainline[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14237,7 +14238,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V8M_MAIN), /* V8-M BASELINE. */
T(V8M_MAIN) /* V8-M MAINLINE. */
};
- const int v8_1m_mainline[] =
+ static const int v8_1m_mainline[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14262,7 +14263,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
-1, /* Unused (20). */
T(V8_1M_MAIN) /* V8.1-M MAINLINE. */
};
- const int v9[] =
+ static const int v9[] =
{
T(V9), /* PRE_V4. */
T(V9), /* V4. */
@@ -14288,7 +14289,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V9), /* V8.1-M.MAIN. */
T(V9), /* V9. */
};
- const int v4t_plus_v6_m[] =
+ static const int v4t_plus_v6_m[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14315,7 +14316,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V9), /* V9. */
T(V4T_PLUS_V6_M) /* V4T plus V6_M. */
};
- const int *comb[] =
+ static const int *const comb[] =
{
v6t2,
v6k,
@@ -14539,7 +14540,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info)
int secondary_compat = -1, secondary_compat_out = -1;
unsigned int saved_out_attr = out_attr[i].i;
int arch_attr;
- static const char *name_table[] =
+ static const char *const name_table[] =
{
/* These aren't real CPU names, but we can't guess
that from the architecture version alone. */
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index abe26e4..4b99b8e 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1687,6 +1687,10 @@ elf_i386_scan_relocs (bfd *abfd,
size_reloc = true;
goto do_size;
+ case R_386_TLS_DESC_CALL:
+ htab->has_tls_desc_call = 1;
+ goto need_got;
+
case R_386_TLS_IE_32:
case R_386_TLS_IE:
case R_386_TLS_GOTIE:
@@ -1698,7 +1702,7 @@ elf_i386_scan_relocs (bfd *abfd,
case R_386_GOT32X:
case R_386_TLS_GD:
case R_386_TLS_GOTDESC:
- case R_386_TLS_DESC_CALL:
+ need_got:
/* This symbol requires a global offset table entry. */
{
int tls_type, old_tls_type;
@@ -3159,7 +3163,6 @@ elf_i386_relocate_section (bfd *output_bfd,
if (GOT_TLS_GDESC_P (tls_type))
{
- bfd_byte *loc;
outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_DESC);
BFD_ASSERT (htab->sgotplt_jump_table_size + offplt + 8
<= htab->elf.sgotplt->size);
@@ -3167,13 +3170,8 @@ elf_i386_relocate_section (bfd *output_bfd,
+ htab->elf.sgotplt->output_offset
+ offplt
+ htab->sgotplt_jump_table_size);
- sreloc = htab->elf.srelplt;
- loc = sreloc->contents;
- loc += (htab->next_tls_desc_index++
- * sizeof (Elf32_External_Rel));
- BFD_ASSERT (loc + sizeof (Elf32_External_Rel)
- <= sreloc->contents + sreloc->size);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+ sreloc = htab->rel_tls_desc;
+ elf_append_rel (output_bfd, sreloc, &outrel);
if (indx == 0)
{
BFD_ASSERT (! unresolved_reloc);
@@ -4492,6 +4490,50 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
return _bfd_x86_elf_link_setup_gnu_properties (info, &init_table);
}
+static void
+elf_i386_add_glibc_version_dependency
+ (struct elf_find_verdep_info *rinfo)
+{
+ int i = 0;
+ const char *version[4] = { NULL, NULL, NULL, NULL };
+ bool auto_version[4] = { false, false, false, false };
+ struct elf_x86_link_hash_table *htab;
+
+ if (rinfo->info->enable_dt_relr)
+ {
+ version[i] = "GLIBC_ABI_DT_RELR";
+ i++;
+ }
+
+ htab = elf_x86_hash_table (rinfo->info, I386_ELF_DATA);
+ if (htab != NULL)
+ {
+ if (htab->params->gnu2_tls_version_tag && htab->has_tls_desc_call)
+ {
+ version[i] = "GLIBC_ABI_GNU2_TLS";
+ /* 2 == auto, enable if libc.so defines the GLIBC_ABI_GNU2_TLS
+ version. */
+ if (htab->params->gnu2_tls_version_tag == 2)
+ auto_version[i] = true;
+ i++;
+ }
+ if (htab->params->gnu_tls_version_tag
+ && htab->has_tls_get_addr_call)
+ {
+ version[i] = "GLIBC_ABI_GNU_TLS";
+ /* 2 == auto, enable if libc.so defines the GLIBC_ABI_GNU_TLS
+ version. */
+ if (htab->params->gnu_tls_version_tag == 2)
+ auto_version[i] = true;
+ i++;
+ }
+ }
+
+ if (i != 0)
+ _bfd_elf_link_add_glibc_version_dependency (rinfo, version,
+ auto_version);
+}
+
#define TARGET_LITTLE_SYM i386_elf32_vec
#define TARGET_LITTLE_NAME "elf32-i386"
#define ELF_ARCH bfd_arch_i386
@@ -4532,6 +4574,8 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
#define elf_backend_relocate_section elf_i386_relocate_section
#define elf_backend_setup_gnu_properties elf_i386_link_setup_gnu_properties
#define elf_backend_hide_symbol _bfd_x86_elf_hide_symbol
+#define elf_backend_add_glibc_version_dependency \
+ elf_i386_add_glibc_version_dependency
#define elf_backend_linux_prpsinfo32_ugid16 true
@@ -4539,6 +4583,8 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
#include "elf32-target.h"
+#undef elf_backend_add_glibc_version_dependency
+
/* FreeBSD support. */
#undef TARGET_LITTLE_SYM
@@ -4586,6 +4632,9 @@ elf_i386_fbsd_init_file_header (bfd *abfd, struct bfd_link_info *info)
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf32-i386-sol2"
+#undef ELF_MAXPAGESIZE
+#define ELF_MAXPAGESIZE 0x10000
+
#undef ELF_TARGET_OS
#define ELF_TARGET_OS is_solaris
@@ -4713,6 +4762,9 @@ elf32_iamcu_elf_object_p (bfd *abfd)
#undef ELF_MACHINE_CODE
#define ELF_MACHINE_CODE EM_IAMCU
+#undef ELF_MAXPAGESIZE
+#define ELF_MAXPAGESIZE 0x1000
+
#undef ELF_TARGET_OS
#undef ELF_OSABI
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 7868063..2cacc9e 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -12226,9 +12226,9 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
struct elf_link_hash_entry *h;
size_t len1, len2;
char *name;
- const char *const stub_str[] = { "long_branch",
- "plt_branch",
- "plt_call" };
+ static const char stub_str[][16] = { "long_branch",
+ "plt_branch",
+ "plt_call" };
len1 = strlen (stub_str[stub_entry->type.main - 1]);
len2 = strlen (stub_entry->root.string);
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index b6f97b5..4f0e97c 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2694,6 +2694,10 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info,
eh->zero_undefweak &= 0x2;
break;
+ case R_X86_64_TLSDESC_CALL:
+ htab->has_tls_desc_call = 1;
+ goto need_got;
+
case R_X86_64_GOTTPOFF:
case R_X86_64_CODE_4_GOTTPOFF:
case R_X86_64_CODE_5_GOTTPOFF:
@@ -2715,7 +2719,7 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info,
case R_X86_64_GOTPLT64:
case R_X86_64_GOTPC32_TLSDESC:
case R_X86_64_CODE_4_GOTPC32_TLSDESC:
- case R_X86_64_TLSDESC_CALL:
+need_got:
/* This symbol requires a global offset table entry. */
{
int tls_type, old_tls_type;
@@ -4623,7 +4627,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
+ htab->elf.sgotplt->output_offset
+ offplt
+ htab->sgotplt_jump_table_size);
- sreloc = htab->elf.srelplt;
+ sreloc = htab->rel_tls_desc;
if (indx == 0)
outrel.r_addend = relocation - _bfd_x86_elf_dtpoff_base (info);
else
@@ -6242,8 +6246,9 @@ static void
elf_x86_64_add_glibc_version_dependency
(struct elf_find_verdep_info *rinfo)
{
- unsigned int i = 0;
- const char *version[3] = { NULL, NULL, NULL };
+ int i = 0, mark_plt = -1;
+ const char *version[4] = { NULL, NULL, NULL, NULL };
+ bool auto_version[4] = { false, false, false, false };
struct elf_x86_link_hash_table *htab;
if (rinfo->info->enable_dt_relr)
@@ -6253,14 +6258,41 @@ elf_x86_64_add_glibc_version_dependency
}
htab = elf_x86_hash_table (rinfo->info, X86_64_ELF_DATA);
- if (htab != NULL && htab->params->mark_plt)
+ if (htab != NULL)
{
- version[i] = "GLIBC_2.36";
- i++;
+ if (htab->params->gnu2_tls_version_tag && htab->has_tls_desc_call)
+ {
+ version[i] = "GLIBC_ABI_GNU2_TLS";
+ /* 2 == auto, enable if libc.so defines the GLIBC_ABI_GNU2_TLS
+ version. */
+ if (htab->params->gnu2_tls_version_tag == 2)
+ auto_version[i] = true;
+ i++;
+ }
+ if (htab->params->mark_plt)
+ {
+ mark_plt = i;
+ auto_version[i] = true;
+ version[i] = "GLIBC_ABI_DT_X86_64_PLT";
+ i++;
+ }
}
- if (i != 0)
- _bfd_elf_link_add_glibc_version_dependency (rinfo, version);
+ if (i == 0
+ || !_bfd_elf_link_add_glibc_version_dependency (rinfo, version,
+ auto_version))
+ return;
+
+ if (mark_plt < 0 || auto_version[mark_plt])
+ return;
+
+ /* Add the GLIBC_2.36 version dependency if libc.so doesn't have
+ GLIBC_ABI_DT_X86_64_PLT. */
+ version[0] = "GLIBC_2.36";
+ auto_version[0] = false;
+ version[1] = NULL;
+ _bfd_elf_link_add_glibc_version_dependency (rinfo, version,
+ auto_version);
}
static const struct bfd_elf_special_section
@@ -6281,7 +6313,7 @@ elf_x86_64_special_sections[]=
#define ELF_TARGET_ID X86_64_ELF_DATA
#define ELF_MACHINE_CODE EM_X86_64
#define ELF_MAXPAGESIZE 0x1000
-#define ELF_COMMONPAGESIZE 0x1000
+#define ELF_COMMONPAGESIZE ELF_MAXPAGESIZE
#define elf_backend_can_gc_sections 1
#define elf_backend_can_refcount 1
@@ -6355,20 +6387,7 @@ elf_x86_64_special_sections[]=
#include "elf64-target.h"
-/* CloudABI support. */
-
-#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM x86_64_elf64_cloudabi_vec
-#undef TARGET_LITTLE_NAME
-#define TARGET_LITTLE_NAME "elf64-x86-64-cloudabi"
-
-#undef ELF_OSABI
-#define ELF_OSABI ELFOSABI_CLOUDABI
-
-#undef elf64_bed
-#define elf64_bed elf64_x86_64_cloudabi_bed
-
-#include "elf64-target.h"
+#undef elf_backend_add_glibc_version_dependency
/* FreeBSD support. */
@@ -6392,7 +6411,10 @@ elf_x86_64_special_sections[]=
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf64-x86-64-sol2"
-#undef ELF_TARGET_OS
+#undef ELF_MAXPAGESIZE
+#define ELF_MAXPAGESIZE 0x100000
+
+#undef ELF_TARGET_OS
#define ELF_TARGET_OS is_solaris
/* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE
@@ -6453,8 +6475,8 @@ elf64_x86_64_copy_solaris_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUS
#undef ELF_ARCH
#define ELF_ARCH bfd_arch_i386
-#undef ELF_MACHINE_CODE
-#define ELF_MACHINE_CODE EM_X86_64
+#undef ELF_MAXPAGESIZE
+#define ELF_MAXPAGESIZE 0x1000
#undef ELF_TARGET_OS
#undef ELF_OSABI
@@ -6476,6 +6498,10 @@ elf64_x86_64_copy_solaris_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUS
#define elf_backend_bfd_from_remote_memory \
_bfd_elf32_bfd_from_remote_memory
+#undef elf_backend_add_glibc_version_dependency
+#define elf_backend_add_glibc_version_dependency \
+ elf_x86_64_add_glibc_version_dependency
+
#undef elf_backend_size_info
#define elf_backend_size_info \
_bfd_elf32_size_info
diff --git a/bfd/elflink.c b/bfd/elflink.c
index cdd58b2..53ec792 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -27,9 +27,7 @@
#include "safe-ctype.h"
#include "libiberty.h"
#include "objalloc.h"
-#if BFD_SUPPORTS_PLUGINS
#include "plugin.h"
-#endif
#include <limits.h>
#ifndef CHAR_BIT
@@ -2283,68 +2281,85 @@ _bfd_elf_export_symbol (struct elf_link_hash_entry *h, void *data)
return true;
}
-/* Return the glibc version reference if VERSION_DEP is added to the
- list of glibc version dependencies successfully. VERSION_DEP will
- be put into the .gnu.version_r section. GLIBC_MINOR_BASE is the
- pointer to the glibc minor base version. */
+/* Return true if linked against glibc. Otherwise return false. If
+ linked against glibc, add VERSION_DEP to the list of glibc version
+ dependencies and set *AUTO_VERSION to true. If *AUTO_VERSION is
+ true, add VERSION_DEP to the version dependency list only if libc.so
+ defines VERSION_DEP. GLIBC_MINOR_BASE is the pointer to the glibc
+ minor base version. */
-static Elf_Internal_Verneed *
+static bool
elf_link_add_glibc_verneed (struct elf_find_verdep_info *rinfo,
- Elf_Internal_Verneed *glibc_verref,
const char *version_dep,
- int *glibc_minor_base)
+ int *glibc_minor_base,
+ bool *auto_version)
{
Elf_Internal_Verneed *t;
Elf_Internal_Vernaux *a;
size_t amt;
int minor_version = -1;
+ bool added = false;
+ bool glibc = false;
- if (glibc_verref != NULL)
+ for (t = elf_tdata (rinfo->info->output_bfd)->verref;
+ t != NULL;
+ t = t->vn_nextref)
{
- t = glibc_verref;
+ const char *soname = bfd_elf_get_dt_soname (t->vn_bfd);
+ if (soname != NULL && startswith (soname, "libc.so."))
+ break;
+ }
- for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+ /* Skip the shared library if it isn't libc.so. */
+ if (t == NULL)
+ goto update_auto_version_and_return;
+
+ for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
+ {
+ /* Return if VERSION_DEP dependency has been added. */
+ if (a->vna_nodename == version_dep
+ || strcmp (a->vna_nodename, version_dep) == 0)
{
- /* Return if VERSION_DEP dependency has been added. */
- if (a->vna_nodename == version_dep
- || strcmp (a->vna_nodename, version_dep) == 0)
- return t;
+ glibc = true;
+ goto update_auto_version_and_return;
}
- }
- else
- {
- for (t = elf_tdata (rinfo->info->output_bfd)->verref;
- t != NULL;
- t = t->vn_nextref)
+
+ /* Check if libc.so provides GLIBC_2.XX version. */
+ if (startswith (a->vna_nodename, "GLIBC_2."))
{
- const char *soname = bfd_elf_get_dt_soname (t->vn_bfd);
- if (soname != NULL && startswith (soname, "libc.so."))
- break;
+ minor_version = strtol (a->vna_nodename + 8, NULL, 10);
+ if (minor_version < *glibc_minor_base)
+ *glibc_minor_base = minor_version;
}
+ }
- /* Skip the shared library if it isn't libc.so. */
- if (t == NULL)
- return t;
+ /* Skip if it isn't linked against glibc. */
+ if (minor_version < 0)
+ goto update_auto_version_and_return;
- for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
- {
- /* Return if VERSION_DEP dependency has been added. */
- if (a->vna_nodename == version_dep
- || strcmp (a->vna_nodename, version_dep) == 0)
- return t;
+ glibc = true;
- /* Check if libc.so provides GLIBC_2.XX version. */
- if (startswith (a->vna_nodename, "GLIBC_2."))
- {
- minor_version = strtol (a->vna_nodename + 8, NULL, 10);
- if (minor_version < *glibc_minor_base)
- *glibc_minor_base = minor_version;
- }
- }
+ if (auto_version && *auto_version)
+ {
+ /* Add VERSION_DEP to the version dependency list only if
+ libc.so defines VERSION_DEP. */
- /* Skip if it isn't linked against glibc. */
- if (minor_version < 0)
- return NULL;
+ bool defined = false;
+ Elf_Internal_Verdef *d;
+
+ for (d = elf_tdata (t->vn_bfd)->verdef;
+ d != NULL;
+ d = d->vd_nextdef)
+ if (strcmp (d->vd_nodename, version_dep) == 0)
+ {
+ defined = true;
+ break;
+ }
+
+ /* Set *AUTO_VERSION to false and return true to indicate that
+ libc.so doesn't define VERSION_DEP. */
+ if (!defined)
+ goto update_auto_version_and_return;
}
/* Skip if 2.GLIBC_MINOR_BASE includes VERSION_DEP. */
@@ -2352,7 +2367,7 @@ elf_link_add_glibc_verneed (struct elf_find_verdep_info *rinfo,
{
minor_version = strtol (version_dep + 8, NULL, 10);
if (minor_version <= *glibc_minor_base)
- return NULL;
+ goto update_auto_version_and_return;
}
amt = sizeof *a;
@@ -2360,7 +2375,8 @@ elf_link_add_glibc_verneed (struct elf_find_verdep_info *rinfo,
if (a == NULL)
{
rinfo->failed = true;
- return NULL;
+ glibc = false;
+ goto update_auto_version_and_return;
}
a->vna_nodename = version_dep;
@@ -2371,30 +2387,38 @@ elf_link_add_glibc_verneed (struct elf_find_verdep_info *rinfo,
t->vn_auxptr = a;
- return t;
+ added = true;
+
+ update_auto_version_and_return:
+ if (auto_version)
+ *auto_version = added;
+
+ return glibc;
}
/* Add VERSION_DEP to the list of version dependencies when linked
against glibc. */
-void
+bool
_bfd_elf_link_add_glibc_version_dependency
(struct elf_find_verdep_info *rinfo,
- const char *version_dep[])
+ const char *const version_dep[],
+ bool *auto_version)
{
- Elf_Internal_Verneed *t = NULL;
int glibc_minor_base = INT_MAX;
do
{
- t = elf_link_add_glibc_verneed (rinfo, t, *version_dep,
- &glibc_minor_base);
- /* Return if there is no glibc version reference. */
- if (t == NULL)
- return;
+ /* Return if not linked against glibc. */
+ if (!elf_link_add_glibc_verneed (rinfo, *version_dep,
+ &glibc_minor_base, auto_version))
+ return false;
version_dep++;
+ auto_version++;
}
while (*version_dep != NULL);
+
+ return true;
}
/* Add GLIBC_ABI_DT_RELR to the list of version dependencies when
@@ -2405,12 +2429,12 @@ _bfd_elf_link_add_dt_relr_dependency (struct elf_find_verdep_info *rinfo)
{
if (rinfo->info->enable_dt_relr)
{
- const char *version[] =
+ static const char *const version[] =
{
"GLIBC_ABI_DT_RELR",
NULL
};
- _bfd_elf_link_add_glibc_version_dependency (rinfo, version);
+ _bfd_elf_link_add_glibc_version_dependency (rinfo, version, NULL);
}
}
@@ -3678,11 +3702,8 @@ elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef)
get the correct symbol table. */
if (abfd->plugin_format == bfd_plugin_yes
|| abfd->plugin_format == bfd_plugin_yes_unused
-#if BFD_SUPPORTS_PLUGINS
|| (abfd->plugin_format == bfd_plugin_unknown
- && bfd_link_plugin_object_p (abfd))
-#endif
- )
+ && bfd_link_plugin_object_p (abfd)))
{
/* Use the IR symbol table if the object has been claimed by
plugin. */
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index cec579c..4517567 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -10785,22 +10785,3 @@ const struct elf_size_info elfNN_aarch64_size_info =
#define elf_backend_obj_attrs_section SEC_AARCH64_ATTRIBUTES
#include "elfNN-target.h"
-
-/* CloudABI support. */
-
-#undef TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM aarch64_elfNN_le_cloudabi_vec
-#undef TARGET_LITTLE_NAME
-#define TARGET_LITTLE_NAME "elfNN-littleaarch64-cloudabi"
-#undef TARGET_BIG_SYM
-#define TARGET_BIG_SYM aarch64_elfNN_be_cloudabi_vec
-#undef TARGET_BIG_NAME
-#define TARGET_BIG_NAME "elfNN-bigaarch64-cloudabi"
-
-#undef ELF_OSABI
-#define ELF_OSABI ELFOSABI_CLOUDABI
-
-#undef elfNN_bed
-#define elfNN_bed elfNN_aarch64_cloudabi_bed
-
-#include "elfNN-target.h"
diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c
index 6268c47..0b030d3 100644
--- a/bfd/elfxx-loongarch.c
+++ b/bfd/elfxx-loongarch.c
@@ -1388,7 +1388,7 @@ static loongarch_reloc_howto_type loongarch_howto_table[] =
false, /* partial_inplace. */
0, /* src_mask */
0xffffffff, /* dst_mask */
- false, /* pcrel_offset */
+ true, /* pcrel_offset */
BFD_RELOC_LARCH_32_PCREL, /* bfd_reloc_code_real_type */
reloc_sign_bits, /* adjust_reloc_bits */
NULL), /* larch_reloc_type_name */
@@ -1580,7 +1580,7 @@ static loongarch_reloc_howto_type loongarch_howto_table[] =
false, /* partial_inplace. */
0, /* src_mask */
0xffffffffffffffff, /* dst_mask */
- false, /* pcrel_offset */
+ true, /* pcrel_offset */
BFD_RELOC_LARCH_64_PCREL, /* bfd_reloc_code_real_type */
NULL, /* adjust_reloc_bits */
NULL), /* larch_reloc_type_name */
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 1200032..9163712 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -43,7 +43,7 @@ static bfd_reloc_status_type riscv_elf_ignore_reloc
/* The relocation table used for SHT_RELA sections. */
-static reloc_howto_type howto_table[] =
+static const reloc_howto_type howto_table[] =
{
/* No relocation. */
HOWTO (R_RISCV_NONE, /* type */
@@ -879,7 +879,7 @@ static reloc_howto_type howto_table[] =
false) /* pcrel_offset */
};
-static reloc_howto_type howto_table_internal[] =
+static const reloc_howto_type howto_table_internal[] =
{
/* R_RISCV_DELETE. */
EMPTY_HOWTO (0),
@@ -1204,7 +1204,7 @@ struct riscv_implicit_subset
const riscv_subset_t *);
};
/* Please added in order since this table is only run once time. */
-static struct riscv_implicit_subset riscv_implicit_subsets[] =
+static const struct riscv_implicit_subset riscv_implicit_subsets[] =
{
{"g", "+i,+m,+a,+f,+d,+zicsr,+zifencei", check_implicit_always},
{"e", "+i", check_implicit_always},
@@ -1336,7 +1336,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
};
/* This table records the mapping form RISC-V Profiles into march string. */
-static struct riscv_profiles riscv_profiles_table[] =
+static const struct riscv_profiles riscv_profiles_table[] =
{
/* RVI20U only contains the base extension 'i' as mandatory extension. */
{"rvi20u64", "rv64i"},
@@ -1408,7 +1408,7 @@ struct riscv_supported_ext
/* The standard extensions must be added in canonical order. */
-static struct riscv_supported_ext riscv_supported_std_ext[] =
+static const struct riscv_supported_ext riscv_supported_std_ext[] =
{
{"e", ISA_SPEC_CLASS_20191213, 1, 9, 0 },
{"e", ISA_SPEC_CLASS_20190608, 1, 9, 0 },
@@ -1443,7 +1443,7 @@ static struct riscv_supported_ext riscv_supported_std_ext[] =
{NULL, 0, 0, 0, 0}
};
-static struct riscv_supported_ext riscv_supported_std_z_ext[] =
+static const struct riscv_supported_ext riscv_supported_std_z_ext[] =
{
{"zic64b", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"ziccamoa", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -1550,7 +1550,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
{NULL, 0, 0, 0, 0}
};
-static struct riscv_supported_ext riscv_supported_std_s_ext[] =
+static const struct riscv_supported_ext riscv_supported_std_s_ext[] =
{
{"sha", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"shcounterenw", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -1597,12 +1597,12 @@ static struct riscv_supported_ext riscv_supported_std_s_ext[] =
{NULL, 0, 0, 0, 0}
};
-static struct riscv_supported_ext riscv_supported_std_zxm_ext[] =
+static const struct riscv_supported_ext riscv_supported_std_zxm_ext[] =
{
{NULL, 0, 0, 0, 0}
};
-static struct riscv_supported_ext riscv_supported_vendor_x_ext[] =
+static const struct riscv_supported_ext riscv_supported_vendor_x_ext[] =
{
{"xcvalu", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"xcvbi", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -1639,7 +1639,7 @@ static struct riscv_supported_ext riscv_supported_vendor_x_ext[] =
{NULL, 0, 0, 0, 0}
};
-const struct riscv_supported_ext *riscv_all_supported_ext[] =
+static const struct riscv_supported_ext *riscv_all_supported_ext[] =
{
riscv_supported_std_ext,
riscv_supported_std_z_ext,
@@ -1701,7 +1701,7 @@ riscv_get_prefix_class (const char *arch)
static bool
riscv_known_prefixed_ext (const char *ext,
- struct riscv_supported_ext *known_exts)
+ const struct riscv_supported_ext *known_exts)
{
size_t i;
for (i = 0; known_exts[i].name != NULL; ++i)
@@ -1894,7 +1894,7 @@ riscv_get_default_ext_version (enum riscv_spec_class *default_isa_spec,
|| *default_isa_spec == ISA_SPEC_CLASS_NONE)
return;
- struct riscv_supported_ext *table = NULL;
+ const struct riscv_supported_ext *table = NULL;
enum riscv_prefix_ext_class class = riscv_get_prefix_class (name);
switch (class)
{
@@ -2185,7 +2185,7 @@ riscv_update_subset1 (riscv_parse_subset_t *, riscv_subset_t *, const char *);
static void
riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps)
{
- struct riscv_implicit_subset *t = riscv_implicit_subsets;
+ const struct riscv_implicit_subset *t = riscv_implicit_subsets;
for (; t->ext; t++)
{
riscv_subset_t *subset = NULL;
@@ -3437,8 +3437,8 @@ _bfd_riscv_elf_link_setup_gnu_properties (struct bfd_link_info *info,
| SEC_READONLY | SEC_HAS_CONTENTS
| SEC_DATA));
if (sec == NULL)
- info->callbacks->einfo (
- _ ("%F%P: failed to create GNU property section\n"));
+ info->callbacks->fatal (
+ _("%P: failed to create GNU property section\n"));
elf_section_type (sec) = SHT_NOTE;
}
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 3dc0095..6dc1586 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -366,7 +366,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
htab->elf.srelgot->size += htab->sizeof_reloc;
if (GOT_TLS_GDESC_P (tls_type))
{
- htab->elf.srelplt->size += htab->sizeof_reloc;
+ htab->rel_tls_desc->size += htab->sizeof_reloc;
if (bed->target_id == X86_64_ELF_DATA)
htab->elf.tlsdesc_plt = (bfd_vma) -1;
}
@@ -882,6 +882,8 @@ _bfd_x86_elf_link_check_relocs (bfd *abfd, struct bfd_link_info *info)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
elf_x86_hash_entry (h)->tls_get_addr = 1;
}
+
+ htab->has_tls_get_addr_call = 1;
}
/* Pass NULL for __ehdr_start which will be defined by
@@ -2155,6 +2157,16 @@ _bfd_elf_x86_finish_relative_relocs (struct bfd_link_info *info)
return true;
}
+asection *
+_bfd_elf_x86_get_reloc_section (bfd *abfd, const char *name)
+{
+ /* Treat .rel.tls/.rela.tls section the same as .rel.plt/.rela.plt
+ section. */
+ if (strcmp (name, ".tls") == 0)
+ name = ".plt";
+ return _bfd_elf_plt_get_reloc_section (abfd, name);
+}
+
bool
_bfd_elf_x86_valid_reloc_p (asection *input_section,
struct bfd_link_info *info,
@@ -2374,7 +2386,7 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd,
srel->size += htab->sizeof_reloc;
if (GOT_TLS_GDESC_P (*local_tls_type))
{
- htab->elf.srelplt->size += htab->sizeof_reloc;
+ htab->rel_tls_desc->size += htab->sizeof_reloc;
if (bed->target_id == X86_64_ELF_DATA)
htab->elf.tlsdesc_plt = (bfd_vma) -1;
}
@@ -2415,7 +2427,6 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd,
so that R_{386,X86_64}_IRELATIVE entries come last. */
if (htab->elf.srelplt)
{
- htab->next_tls_desc_index = htab->elf.srelplt->reloc_count;
htab->sgotplt_jump_table_size
= elf_x86_compute_jump_table_size (htab);
htab->next_irelative_index = htab->elf.srelplt->reloc_count - 1;
@@ -4604,6 +4615,8 @@ _bfd_x86_elf_link_setup_gnu_properties
htab->sframe_plt = init_table->sframe_non_lazy_plt;
}
}
+ else if (lazy_plt)
+ htab->sframe_plt = init_table->sframe_lazy_plt;
else
htab->sframe_plt = NULL;
@@ -4738,6 +4751,14 @@ _bfd_x86_elf_link_setup_gnu_properties
}
}
+ sec = bfd_make_section_anyway_with_flags
+ (dynobj, bed->rela_plts_and_copies_p ? ".rela.tls" : ".rel.tls",
+ bed->dynamic_sec_flags | SEC_READONLY);
+ if (sec == NULL
+ || !bfd_set_section_alignment (sec, bed->s->log_file_align))
+ return false;
+ htab->rel_tls_desc = sec;
+
if (!info->no_ld_generated_unwind_info)
{
flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index 88bfa05..5593203 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -224,12 +224,15 @@
|| (EH)->elf.root.type == bfd_link_hash_undefined)))
/* TRUE if this input relocation should be copied to output. H->dynindx
- may be -1 if this symbol was marked to become local. */
+ may be -1 if this symbol was marked to become local. STV_PROTECTED
+ symbols are local. */
#define COPY_INPUT_RELOC_P(IS_X86_64, INFO, H, R_TYPE) \
((H) != NULL \
&& (H)->dynindx != -1 \
&& (X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \
- || !(bfd_link_executable (INFO) || SYMBOLIC_BIND ((INFO), (H))) \
+ || !(bfd_link_executable (INFO) \
+ || SYMBOLIC_BIND ((INFO), (H)) \
+ || ELF_ST_VISIBILITY ((H)->other) == STV_PROTECTED) \
|| !(H)->def_regular))
/* TRUE if this is actually a static link, or it is a -Bsymbolic link
@@ -647,14 +650,14 @@ struct elf_x86_link_hash_table
/* The index of the next R_X86_64_IRELATIVE entry in .rela.plt. */
bfd_vma next_irelative_index;
+ /* The .rela.tls/.rel.tls section for R_386_TLS_DESC or R_X86_64_TLSDESC
+ relocation. */
+ asection *rel_tls_desc;
+
/* The (unloaded but important) .rel.plt.unloaded section on VxWorks.
This is used for i386 only. */
asection *srelplt2;
- /* The index of the next unused R_386_TLS_DESC slot in .rel.plt. This
- is only used for i386. */
- bfd_vma next_tls_desc_index;
-
/* DT_RELR bitmap. */
struct elf_dt_relr_bitmap dt_relr_bitmap;
@@ -667,6 +670,13 @@ struct elf_x86_link_hash_table
/* Number of relative reloc generation pass. */
unsigned int generate_relative_reloc_pass;
+ /* TRUE if inputs have R_386_TLS_DESC_CALL or R_X86_64_TLSDESC_CALL
+ relocation. */
+ unsigned int has_tls_desc_call : 1;
+
+ /* TRUE if inputs call ___tls_get_addr. This is only used for i386. */
+ unsigned int has_tls_get_addr_call : 1;
+
/* Value used to fill the unused bytes of the first PLT entry. This
is only used for i386. */
bfd_byte plt0_pad_byte;
@@ -861,6 +871,9 @@ extern bool _bfd_elf_x86_size_relative_relocs
extern bool _bfd_elf_x86_finish_relative_relocs
(struct bfd_link_info *) ATTRIBUTE_HIDDEN;
+extern asection * _bfd_elf_x86_get_reloc_section
+ (bfd *, const char *) ATTRIBUTE_HIDDEN;
+
extern void _bfd_elf32_write_addend
(bfd *, uint64_t, void *) ATTRIBUTE_HIDDEN;
extern void _bfd_elf64_write_addend
@@ -984,6 +997,8 @@ extern void _bfd_x86_elf_link_report_tls_transition_error
_bfd_elf_x86_size_relative_relocs
#define elf_backend_finish_relative_relocs \
_bfd_elf_x86_finish_relative_relocs
+#define elf_backend_get_reloc_section \
+ _bfd_elf_x86_get_reloc_section
#define elf_backend_use_mmap true
#define ELF_P_ALIGN ELF_MINPAGESIZE
diff --git a/bfd/format.c b/bfd/format.c
index fba8d2a..81f29c5 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -46,9 +46,7 @@ SUBSECTION
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
-#if BFD_SUPPORTS_PLUGINS
#include "plugin.h"
-#endif
/* IMPORT from targets.c. */
extern const size_t _bfd_target_vector_entries;
@@ -366,9 +364,8 @@ struct lto_section
/* Set lto_type in ABFD. */
static void
-bfd_set_lto_type (bfd *abfd ATTRIBUTE_UNUSED)
+bfd_set_lto_type (bfd *abfd)
{
-#if BFD_SUPPORTS_PLUGINS
if (abfd->format == bfd_object
&& abfd->lto_type == lto_non_object
&& (abfd->flags
@@ -376,37 +373,52 @@ bfd_set_lto_type (bfd *abfd ATTRIBUTE_UNUSED)
| (bfd_get_flavour (abfd) == bfd_target_elf_flavour
? EXEC_P : 0))) == 0)
{
- asection *sec;
+ asection *sec = abfd->sections;
enum bfd_lto_object_type type = lto_non_ir_object;
- struct lto_section lsection = { 0, 0, 0, 0 };
- /* GCC uses .gnu.lto_.lto.<some_hash> as a LTO bytecode information
- section. */
- for (sec = abfd->sections; sec != NULL; sec = sec->next)
- if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0)
- {
- type = lto_mixed_object;
- abfd->object_only_section = sec;
- break;
- }
- else if (strcmp (sec->name, ".llvm.lto") == 0)
- {
- type = lto_fat_ir_object;
- break;
- }
- else if (lsection.major_version == 0
- && startswith (sec->name, ".gnu.lto_.lto.")
- && bfd_get_section_contents (abfd, sec, &lsection, 0,
- sizeof (struct lto_section)))
- {
- if (lsection.slim_object)
- type = lto_slim_ir_object;
- else
- type = lto_fat_ir_object;
+ if (sec == NULL)
+ {
+ /* If there are no sections, check for slim LLVM IR object whose
+ first 4 bytes are: 'B', 'C', 0xc0, 0xde. */
+ bfd_byte llvm_ir_magic[4];
+ if (bfd_seek (abfd, 0, SEEK_SET) == 0
+ && bfd_read (llvm_ir_magic, 4, abfd) == 4
+ && llvm_ir_magic[0] == 'B'
+ && llvm_ir_magic[1] == 'C'
+ && llvm_ir_magic[2] == 0xc0
+ && llvm_ir_magic[3] == 0xde)
+ type = lto_slim_ir_object;
+ }
+ else
+ {
+ struct lto_section lsection = { 0, 0, 0, 0 };
+ /* GCC uses .gnu.lto_.lto.<some_hash> as a LTO bytecode
+ information section. */
+ for (; sec != NULL; sec = sec->next)
+ if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0)
+ {
+ type = lto_mixed_object;
+ abfd->object_only_section = sec;
+ break;
+ }
+ else if (strcmp (sec->name, ".llvm.lto") == 0)
+ {
+ type = lto_fat_ir_object;
+ break;
+ }
+ else if (lsection.major_version == 0
+ && startswith (sec->name, ".gnu.lto_.lto.")
+ && bfd_get_section_contents (abfd, sec, &lsection, 0,
+ sizeof (struct lto_section)))
+ {
+ if (lsection.slim_object)
+ type = lto_slim_ir_object;
+ else
+ type = lto_fat_ir_object;
}
+ }
abfd->lto_type = type;
}
-#endif
}
/*
@@ -497,51 +509,66 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
if (!bfd_preserve_save (abfd, &preserve, NULL))
goto err_ret;
- /* If the target type was explicitly specified, just check that target. */
+ /* First try matching the plugin target if appropriate. Next try
+ the current target. The current target may have been set due to
+ a user option, or due to the linker trying optimistically to load
+ input files for the same target as the output. Either will
+ have target_defaulted false. Failing that, bfd_find_target will
+ have chosen a default target, and target_defaulted will be true. */
fail_targ = NULL;
- if (!abfd->target_defaulted
-#if BFD_SUPPORTS_PLUGINS
- && !(abfd->plugin_format == bfd_plugin_no
- && bfd_plugin_target_p (save_targ))
-#endif
- )
+ if (bfd_plugin_enabled ()
+ && abfd->format == bfd_object
+ && abfd->target_defaulted
+ && !abfd->is_linker_input
+ && abfd->plugin_format != bfd_plugin_no)
{
- if (bfd_seek (abfd, 0, SEEK_SET) != 0) /* rewind! */
+ if (bfd_seek (abfd, 0, SEEK_SET) != 0)
goto err_ret;
+ BFD_ASSERT (save_targ != bfd_plugin_vec ());
+ abfd->xvec = bfd_plugin_vec ();
+ bfd_set_error (bfd_error_no_error);
cleanup = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
-
- /* When called from strip, don't treat archive member nor
- standalone fat IR object as an IR object. For archive
- member, it will be copied as an unknown object if the
- plugin target is in use or it is a slim IR object. For
- standalone fat IR object, it will be copied as non-IR
- object. */
- if (cleanup
-#if BFD_SUPPORTS_PLUGINS
- && (!abfd->is_strip_input
- || !bfd_plugin_target_p (abfd->xvec)
- || (abfd->lto_type != lto_fat_ir_object
- && abfd->my_archive == NULL))
-#endif
- )
+ if (cleanup)
goto ok_ret;
- /* For a long time the code has dropped through to check all
- targets if the specified target was wrong. I don't know why,
- and I'm reluctant to change it. However, in the case of an
- archive, it can cause problems. If the specified target does
- not permit archives (e.g., the binary target), then we should
- not allow some other target to recognize it as an archive, but
- should instead allow the specified target to recognize it as an
- object. When I first made this change, it broke the PE target,
- because the specified pei-i386 target did not recognize the
- actual pe-i386 archive. Since there may be other problems of
- this sort, I changed this test to check only for the binary
- target. */
- if (format == bfd_archive && save_targ == &binary_vec)
- goto err_unrecog;
- fail_targ = save_targ;
+ bfd_reinit (abfd, initial_section_id, &preserve, cleanup);
+ bfd_release (abfd, preserve.marker);
+ preserve.marker = bfd_alloc (abfd, 1);
+ abfd->xvec = save_targ;
+ }
+
+ /* bfd_plugin_no excluding the plugin target is an optimisation.
+ The test can be removed if desired. */
+ if (!(abfd->plugin_format == bfd_plugin_no
+ && bfd_plugin_target_p (save_targ)))
+ {
+ if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ goto err_ret;
+
+ bfd_set_error (bfd_error_no_error);
+ cleanup = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
+ if (cleanup)
+ {
+ if (abfd->format != bfd_archive
+ /* An archive with object files matching the archive
+ target is OK. Other archives should be further
+ tested. */
+ || (bfd_has_map (abfd)
+ && bfd_get_error () != bfd_error_wrong_object_format)
+ /* Empty archives can match the current target.
+ Attempting to read the armap will result in a file
+ truncated error. */
+ || (!bfd_has_map (abfd)
+ && bfd_get_error () == bfd_error_file_truncated))
+ goto ok_ret;
+ }
+ else
+ {
+ if (!abfd->target_defaulted && !abfd->is_linker_input)
+ goto err_unrecog;
+ fail_targ = save_targ;
+ }
}
/* Check all targets in the hope that one will be recognized. */
@@ -570,12 +597,9 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
bfd_plugin_get_symbols_in_object_only.) */
if (*target == &binary_vec
|| *target == fail_targ
-#if BFD_SUPPORTS_PLUGINS
|| (((abfd->is_linker_input && match_count != 0)
|| abfd->plugin_format == bfd_plugin_no)
- && bfd_plugin_target_p (*target))
-#endif
- )
+ && bfd_plugin_target_p (*target)))
continue;
/* If we already tried a match, the bfd is modified and may
@@ -603,6 +627,7 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
if (bfd_seek (abfd, 0, SEEK_SET) != 0)
goto err_ret;
+ bfd_set_error (bfd_error_no_error);
cleanup = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
if (cleanup)
{
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index c337fc5..1a195d9 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -289,7 +289,7 @@ _bfd_XXi_swap_aux_in (bfd * abfd,
/* PR 17521: Make sure that all fields in the aux structure
are initialised. */
- memset (in, 0, sizeof * in);
+ memset (in, 0, sizeof (*in));
switch (in_class)
{
case C_FILE:
@@ -299,6 +299,9 @@ _bfd_XXi_swap_aux_in (bfd * abfd,
in->x_file.x_n.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
}
else
+#if FILNMLEN != E_FILNMLEN
+#error we need to cope with truncating or extending x_fname
+#endif
memcpy (in->x_file.x_n.x_fname, ext->x_file.x_fname, FILNMLEN);
return;
@@ -373,7 +376,10 @@ _bfd_XXi_swap_aux_out (bfd * abfd,
H_PUT_32 (abfd, in->x_file.x_n.x_n.x_offset, ext->x_file.x_n.x_offset);
}
else
- memcpy (ext->x_file.x_fname, in->x_file.x_n.x_fname, sizeof (ext->x_file.x_fname));
+#if FILNMLEN != E_FILNMLEN
+#error we need to cope with truncating or extending x_fname
+#endif
+ memcpy (ext->x_file.x_fname, in->x_file.x_n.x_fname, E_FILNMLEN);
return AUXESZ;
diff --git a/bfd/pei-aarch64.c b/bfd/pei-aarch64.c
index 00f38e0..835b547 100644
--- a/bfd/pei-aarch64.c
+++ b/bfd/pei-aarch64.c
@@ -20,6 +20,7 @@
#include "sysdep.h"
#include "bfd.h"
+#include "libbfd.h"
#define TARGET_SYM aarch64_pei_le_vec
#define TARGET_NAME "pei-aarch64-little"
@@ -58,9 +59,6 @@
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
#include "coff/aarch64.h"
#include "coff/internal.h"
#include "coff/pe.h"
diff --git a/bfd/pei-loongarch64.c b/bfd/pei-loongarch64.c
index f22498c..0b00cb2 100644
--- a/bfd/pei-loongarch64.c
+++ b/bfd/pei-loongarch64.c
@@ -20,6 +20,7 @@
#include "sysdep.h"
#include "bfd.h"
+#include "libbfd.h"
#define TARGET_SYM loongarch64_pei_vec
#define TARGET_NAME "pei-loongarch64"
@@ -58,9 +59,6 @@
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
#include "coff/loongarch64.h"
#include "coff/internal.h"
#include "coff/pe.h"
diff --git a/bfd/pei-riscv64.c b/bfd/pei-riscv64.c
index c4ae7bf..d8d4b5d 100644
--- a/bfd/pei-riscv64.c
+++ b/bfd/pei-riscv64.c
@@ -20,6 +20,7 @@
#include "sysdep.h"
#include "bfd.h"
+#include "libbfd.h"
#define TARGET_SYM riscv64_pei_vec
#define TARGET_NAME "pei-riscv64-little"
@@ -58,9 +59,6 @@
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
#include "coff/riscv64.h"
#include "coff/internal.h"
#include "coff/pe.h"
diff --git a/bfd/pei-x86_64.c b/bfd/pei-x86_64.c
index a5c2fd8..045fedb 100644
--- a/bfd/pei-x86_64.c
+++ b/bfd/pei-x86_64.c
@@ -22,6 +22,7 @@
#include "sysdep.h"
#include "bfd.h"
+#include "libbfd.h"
#define TARGET_SYM x86_64_pei_vec
#define TARGET_NAME "pei-x86-64"
@@ -60,9 +61,6 @@
{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
#include "coff/x86_64.h"
#include "coff/internal.h"
#include "coff/pe.h"
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 733e7f0..5e5a0b7 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -658,16 +658,6 @@ bfd_link_plugin_object_p (bfd *abfd)
return false;
}
-extern const bfd_target plugin_vec;
-
-/* Return TRUE if TARGET is a pointer to plugin_vec. */
-
-bool
-bfd_plugin_target_p (const bfd_target *target)
-{
- return target == &plugin_vec;
-}
-
/* Register OBJECT_P to be used by bfd_plugin_object_p. */
void
@@ -1002,30 +992,26 @@ const bfd_target plugin_vec =
{ /* bfd_check_format. */
_bfd_dummy_target,
bfd_plugin_object_p,
- bfd_generic_archive_p,
+ _bfd_dummy_target,
_bfd_dummy_target
},
{ /* bfd_set_format. */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
- _bfd_generic_mkarchive,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
- _bfd_write_archive_contents,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
BFD_JUMP_TABLE_GENERIC (bfd_plugin),
BFD_JUMP_TABLE_COPY (bfd_plugin),
BFD_JUMP_TABLE_CORE (bfd_plugin),
-#ifdef USE_64_BIT_ARCHIVE
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_64_bit),
-#else
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
-#endif
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
BFD_JUMP_TABLE_SYMBOLS (bfd_plugin),
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
BFD_JUMP_TABLE_WRITE (bfd_plugin),
diff --git a/bfd/plugin.h b/bfd/plugin.h
index d981c51..f16c45c 100644
--- a/bfd/plugin.h
+++ b/bfd/plugin.h
@@ -23,12 +23,73 @@
struct ld_plugin_input_file;
+#if BFD_SUPPORTS_PLUGINS
void bfd_plugin_set_program_name (const char *);
int bfd_plugin_open_input (bfd *, struct ld_plugin_input_file *);
void bfd_plugin_set_plugin (const char *);
-bool bfd_plugin_target_p (const bfd_target *);
bool bfd_link_plugin_object_p (bfd *);
void register_ld_plugin_object_p (bfd_cleanup (*object_p) (bfd *, bool));
void bfd_plugin_close_file_descriptor (bfd *, int);
+static inline const bfd_target *
+bfd_plugin_vec (void)
+{
+ extern const bfd_target plugin_vec;
+ return &plugin_vec;
+}
+
+static inline bool
+bfd_plugin_target_p (const bfd_target *target)
+{
+ return target == bfd_plugin_vec ();
+}
+#else
+static inline void
+bfd_plugin_set_program_name (const char *name ATTRIBUTE_UNUSED)
+{
+}
+
+static inline int
+bfd_plugin_open_input (bfd *ibfd ATTRIBUTE_UNUSED,
+ struct ld_plugin_input_file *file ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+
+static inline void
+bfd_plugin_set_plugin (const char *p ATTRIBUTE_UNUSED)
+{
+}
+
+static inline bool
+bfd_link_plugin_object_p (bfd *abfd ATTRIBUTE_UNUSED)
+{
+ return false;
+}
+
+static inline void
+register_ld_plugin_object_p
+ (bfd_cleanup (*object_p) (bfd *, bool) ATTRIBUTE_UNUSED)
+{
+}
+
+static inline void
+bfd_plugin_close_file_descriptor (bfd *abfd ATTRIBUTE_UNUSED,
+ int fd ATTRIBUTE_UNUSED)
+{
+}
+
+static inline const bfd_target *
+bfd_plugin_vec (void)
+{
+ return NULL;
+}
+
+static inline bool
+bfd_plugin_target_p (const bfd_target *target ATTRIBUTE_UNUSED)
+{
+ return false;
+}
+#endif
+
#endif
diff --git a/bfd/targets.c b/bfd/targets.c
index c2ee917..ee629bb 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -676,9 +676,7 @@ to find an alternative output format that is suitable.
extern const bfd_target aarch64_elf32_be_vec;
extern const bfd_target aarch64_elf32_le_vec;
extern const bfd_target aarch64_elf64_be_vec;
-extern const bfd_target aarch64_elf64_be_cloudabi_vec;
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;
@@ -929,7 +927,6 @@ 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_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_sol2_vec;
extern const bfd_target x86_64_mach_o_vec;
@@ -987,9 +984,7 @@ static const bfd_target * const _bfd_target_vector[] =
&aarch64_elf32_be_vec,
&aarch64_elf32_le_vec,
&aarch64_elf64_be_vec,
- &aarch64_elf64_be_cloudabi_vec,
&aarch64_elf64_le_vec,
- &aarch64_elf64_le_cloudabi_vec,
&aarch64_mach_o_vec,
&aarch64_pe_le_vec,
&aarch64_pei_le_vec,
@@ -1341,7 +1336,6 @@ static const bfd_target * const _bfd_target_vector[] =
&x86_64_coff_vec,
&x86_64_elf32_vec,
&x86_64_elf64_vec,
- &x86_64_elf64_cloudabi_vec,
&x86_64_elf64_fbsd_vec,
&x86_64_elf64_sol2_vec,
&x86_64_mach_o_vec,
diff --git a/bfd/tekhex.c b/bfd/tekhex.c
index 7e4e698..4ac6116 100644
--- a/bfd/tekhex.c
+++ b/bfd/tekhex.c
@@ -655,7 +655,7 @@ move_section_contents (bfd *abfd,
{
/* Different chunk, so move pointer. */
d = find_chunk (abfd, chunk_number, must_write);
- if (!d)
+ if (!d && must_write)
return false;
prev_number = chunk_number;
}
diff --git a/bfd/version.h b/bfd/version.h
index 89f11ee..286f2a2 100644
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -16,7 +16,7 @@
In releases, the date is not included in either version strings or
sonames. */
-#define BFD_VERSION_DATE 20250807
+#define BFD_VERSION_DATE 20250903
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@
#define REPORT_BUGS_TO @report_bugs_to@
diff --git a/bfd/xtensa-dynconfig.c b/bfd/xtensa-dynconfig.c
index 89053f7..eb04b9d 100644
--- a/bfd/xtensa-dynconfig.c
+++ b/bfd/xtensa-dynconfig.c
@@ -69,43 +69,44 @@ const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
const void *no_name_def ATTRIBUTE_UNUSED)
{
static int init;
-#if BFD_SUPPORTS_PLUGINS
- static void *handle;
- void *p;
-
- if (!init)
+ if (bfd_plugin_enabled ())
{
- const char *path = getenv (CONFIG_ENV_NAME);
+ static void *handle;
+ void *p;
- init = 1;
- if (!path)
- return no_plugin_def;
- handle = dlopen (path, RTLD_LAZY);
- if (!handle)
+ if (!init)
{
- _bfd_error_handler (_("%s is defined but could not be loaded: %s"),
- CONFIG_ENV_NAME, dlerror ());
- abort ();
+ const char *path = getenv (CONFIG_ENV_NAME);
+
+ init = 1;
+ if (!path)
+ return no_plugin_def;
+ handle = dlopen (path, RTLD_LAZY);
+ if (!handle)
+ {
+ _bfd_error_handler (_("%s is defined but could not be loaded: %s"),
+ CONFIG_ENV_NAME, dlerror ());
+ abort ();
+ }
+ }
+ else if (!handle)
+ {
+ return no_plugin_def;
}
- }
- else if (!handle)
- {
- return no_plugin_def;
- }
- p = dlsym (handle, name);
- if (!p)
- {
- if (no_name_def)
- return no_name_def;
+ p = dlsym (handle, name);
+ if (!p)
+ {
+ if (no_name_def)
+ return no_name_def;
- _bfd_error_handler (_("%s is loaded but symbol \"%s\" is not found: %s"),
- CONFIG_ENV_NAME, name, dlerror ());
- abort ();
+ _bfd_error_handler (_("%s is loaded but symbol \"%s\" is not found: %s"),
+ CONFIG_ENV_NAME, name, dlerror ());
+ abort ();
+ }
+ return p;
}
- return p;
-#else
- if (!init)
+ else if (!init)
{
const char *path = getenv (CONFIG_ENV_NAME);
@@ -118,7 +119,6 @@ const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
}
}
return no_plugin_def;
-#endif
}
XTENSA_CONFIG_INSTANCE_LIST;