1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-08 05:09:24 +00:00

binutils: Upgrade to 2.40 release

(From OE-Core rev: ae2b71ca2c73111a21845c2e1329ff973558991a)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Khem Raj
2023-01-18 20:27:22 -08:00
committed by Richard Purdie
parent 1afadc7e09
commit 918ba17f58
27 changed files with 5942 additions and 2904 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ PREFERRED_PROVIDER_virtual/gettext ??= "gettext"
GCCVERSION ?= "12.%"
SDKGCCVERSION ?= "${GCCVERSION}"
BINUVERSION ?= "2.39%"
BINUVERSION ?= "2.40%"
GDBVERSION ?= "12.%"
GLIBCVERSION ?= "2.36"
LINUXLIBCVERSION ?= "6.1%"
@@ -10,15 +10,15 @@ LIC_FILES_CHKSUM="\
file://bfd/COPYING;md5=d32239bcb673463ab874e80d47fae504\
"
# When upgrading to 2.39, please make sure there is no trailing .0, so
# When upgrading to 2.41, please make sure there is no trailing .0, so
# that upstream version check can work correctly.
PV = "2.39"
CVE_VERSION = "2.39"
SRCBRANCH ?= "binutils-2_39-branch"
PV = "2.40"
CVE_VERSION = "2.40"
SRCBRANCH ?= "binutils-2_40-branch"
UPSTREAM_CHECK_GITTAGREGEX = "binutils-(?P<pver>\d+_(\d_?)*)"
SRCREV ?= "f89058434f13382c85b8729464192bc7763d88a4"
SRCREV ?= "ffb83e32fc11f36b7b82b876c14888f82cd983b3"
BINUTILS_GIT_URI ?= "git://sourceware.org/git/binutils-gdb.git;branch=${SRCBRANCH};protocol=git"
SRC_URI = "\
${BINUTILS_GIT_URI} \
@@ -31,14 +31,8 @@ SRC_URI = "\
file://0010-sync-with-OE-libtool-changes.patch \
file://0011-Check-for-clang-before-checking-gcc-version.patch \
file://0012-Only-generate-an-RPATH-entry-if-LD_RUN_PATH-is-not-e.patch \
file://0013-CVE-2022-38533.patch \
file://0014-CVE-2022-38128-1.patch \
file://0014-CVE-2022-38128-2.patch \
file://0014-CVE-2022-38128-3.patch \
file://0015-CVE-2022-4285.patch \
file://0013-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \
file://0014-configure-remove-dependencies-on-gmp-and-mpfr-when-g.patch \
file://0015-Remove-duplicate-pe-dll.o-entry-deom-targ_extra_ofil.patch \
"
S = "${WORKDIR}/git"
# Already in 2.39 branch
# - https://sourceware.org/bugzilla/show_bug.cgi?id=29289
# - https://sourceware.org/bugzilla/show_bug.cgi?id=29290
CVE_CHECK_IGNORE += "CVE-2022-38126 CVE-2022-38127"
@@ -1,4 +1,4 @@
From a0ac147aec127c66c9e38292faa50bb56d3c2a19 Mon Sep 17 00:00:00 2001
From 25e715730ddcca37021fa4876aed4fa91d5dea25 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:58:54 +0000
Subject: [PATCH] binutils-crosssdk: Generate relocatable SDKs
@@ -21,10 +21,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/gold/layout.cc b/gold/layout.cc
index 3efe8d98ae9..9cc389664a6 100644
index 899d4af0707..7c31b1bef6e 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -5033,7 +5033,7 @@ Layout::create_interp(const Target* target)
@@ -5083,7 +5083,7 @@ Layout::create_interp(const Target* target)
gold_assert(interp != NULL);
}
@@ -34,7 +34,7 @@ index 3efe8d98ae9..9cc389664a6 100644
Output_section_data* odata = new Output_data_const(interp, len, 1);
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
index 278f212bdad..0c52ebee4d0 100755
index 382bd07ffe2..9fbd0c4cb8a 100755
--- a/ld/genscripts.sh
+++ b/ld/genscripts.sh
@@ -304,6 +304,7 @@ DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
@@ -59,7 +59,7 @@ index 278f212bdad..0c52ebee4d0 100755
DATA_ALIGNMENT=${DATA_ALIGNMENT_}
RELOCATING=" "
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index bf2268bb0ad..b1811ef130f 100644
index 5d3b0d31b1b..2163909cd56 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -148,8 +148,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then
@@ -1,4 +1,4 @@
From fd7065bfd20364679e3c3f329b19059bbc51ab02 Mon Sep 17 00:00:00 2001
From 080a8eafc5961f78222d84aaa816d0933441b7ab Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 6 Mar 2017 23:37:05 -0800
Subject: [PATCH] binutils-cross: Do not generate linker script directories
@@ -22,7 +22,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 file changed, 25 deletions(-)
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
index 0c52ebee4d0..1acbe66bd2e 100755
index 9fbd0c4cb8a..6be07038c9b 100755
--- a/ld/genscripts.sh
+++ b/ld/genscripts.sh
@@ -235,31 +235,6 @@ append_to_lib_path()
@@ -1,4 +1,4 @@
From 67735b3647f98ce0f010ff8b4f9b5c5da576cb17 Mon Sep 17 00:00:00 2001
From 90d1bb804033a74b54f64cd5d3127c004c266af8 Mon Sep 17 00:00:00 2001
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: Wed, 19 Feb 2020 09:51:16 -0800
Subject: [PATCH] binutils-nativesdk: Search for alternative ld.so.conf in SDK
@@ -29,7 +29,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
5 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/ld/Makefile.am b/ld/Makefile.am
index d31021c13e2..29782385ca4 100644
index 12b2c3c453f..0590b7055d0 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -42,7 +42,8 @@ ZLIBINC = @zlibinc@
@@ -41,12 +41,12 @@ index d31021c13e2..29782385ca4 100644
+ -DSYSCONFDIR="\"$(sysconfdir)\""
WARN_CFLAGS = @WARN_CFLAGS@
NO_WERROR = @NO_WERROR@
AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS)
AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
diff --git a/ld/Makefile.in b/ld/Makefile.in
index ee0c98f65b0..04ee68a2c67 100644
index 3d5685d6bae..70643b1ce46 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -562,7 +562,8 @@ ZLIB = @zlibdir@ -lz
@@ -566,7 +566,8 @@ ZLIB = @zlibdir@ -lz
ZLIBINC = @zlibinc@
ELF_CLFAGS = -DELF_LIST_OPTIONS=@elf_list_options@ \
-DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
@@ -54,10 +54,10 @@ index ee0c98f65b0..04ee68a2c67 100644
+ -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@ \
+ -DSYSCONFDIR="\"$(sysconfdir)\""
AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS)
AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
diff --git a/ld/ldelf.c b/ld/ldelf.c
index bfa0d54753a..0d61a3209ec 100644
index eff6693e052..95787012b89 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -936,7 +936,7 @@ ldelf_check_ld_so_conf (const struct bfd_link_needed_list *l, int force,
@@ -70,7 +70,7 @@ index bfa0d54753a..0d61a3209ec 100644
if (!ldelf_parse_ld_so_conf (&info, tmppath))
{
diff --git a/ld/ldmain.c b/ld/ldmain.c
index ea72b14a301..1ae90a77749 100644
index 9290a189b0d..ceaca2d85d0 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -70,6 +70,7 @@ char *program_name;
@@ -82,7 +82,7 @@ index ea72b14a301..1ae90a77749 100644
/* The canonical representation of ld_sysroot. */
char *ld_canon_sysroot;
diff --git a/ld/ldmain.h b/ld/ldmain.h
index f6d05a02f59..e60292cd522 100644
index dda124b96e8..ba06a7d7be2 100644
--- a/ld/ldmain.h
+++ b/ld/ldmain.h
@@ -23,6 +23,7 @@
@@ -1,4 +1,4 @@
From 2158e5bd4c6ea4db89e33d46ef25428e37bfc3a6 Mon Sep 17 00:00:00 2001
From a7c988d60f11c8279453c2d9edeede001cce7c9e Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:09:58 +0000
Subject: [PATCH] Point scripts location to libdir
@@ -12,10 +12,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 29782385ca4..062e6b6814b 100644
index 0590b7055d0..c30db94ee3c 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -51,7 +51,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS)
@@ -51,7 +51,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
# We put the scripts in the directory $(scriptdir)/ldscripts.
# We can't put the scripts in $(datadir) because the SEARCH_DIR
# directives need to be different for native and cross linkers.
@@ -25,10 +25,10 @@ index 29782385ca4..062e6b6814b 100644
EMUL = @EMUL@
EMULATION_OFILES = @EMULATION_OFILES@
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 04ee68a2c67..782d4017a60 100644
index 70643b1ce46..0405028e02f 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -570,7 +570,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS)
@@ -574,7 +574,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
# We put the scripts in the directory $(scriptdir)/ldscripts.
# We can't put the scripts in $(datadir) because the SEARCH_DIR
# directives need to be different for native and cross linkers.
@@ -1,4 +1,4 @@
From e74d765a1a95253c9247228bd7ccbcabecdd8f7e Mon Sep 17 00:00:00 2001
From fc39b9c332a346910695817274d55d0c20dc717a Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:39:01 +0000
Subject: [PATCH] don't let the distro compiler point to the wrong installation
@@ -17,7 +17,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index abef3c4601b..880c8826482 100644
index f9fbba23e2c..93495e45d6f 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -385,7 +385,8 @@ install-strip: install
@@ -1,4 +1,4 @@
From 2c43b1357db6b09d1645704afd3f45be6de0cf4d Mon Sep 17 00:00:00 2001
From b9af05e87ac8eb4fa18a75939edb661056246c30 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 15 Jan 2016 06:31:09 +0000
Subject: [PATCH] warn for uses of system directories when cross linking
@@ -63,10 +63,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
9 files changed, 88 insertions(+), 2 deletions(-)
diff --git a/ld/config.in b/ld/config.in
index d4c1fc420b5..1aece0b2c29 100644
index ad0dc6a106c..d21edaddce7 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -55,6 +55,9 @@
@@ -58,6 +58,9 @@
language is requested. */
#undef ENABLE_NLS
@@ -77,10 +77,10 @@ index d4c1fc420b5..1aece0b2c29 100644
#undef EXTRA_SHLIB_EXTENSION
diff --git a/ld/configure b/ld/configure
index e58fb7f3a35..d0a467ac101 100755
index 49936a0cb2a..5f5dad6d67c 100755
--- a/ld/configure
+++ b/ld/configure
@@ -836,6 +836,7 @@ with_lib_path
@@ -839,6 +839,7 @@ with_lib_path
enable_targets
enable_64_bit_bfd
with_sysroot
@@ -88,7 +88,7 @@ index e58fb7f3a35..d0a467ac101 100755
enable_gold
enable_got
enable_compressed_debug_sections
@@ -1514,6 +1515,8 @@ Optional Features:
@@ -1521,6 +1522,8 @@ Optional Features:
--enable-checking enable run-time checks
--enable-targets alternative target configurations
--enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)
@@ -97,7 +97,7 @@ index e58fb7f3a35..d0a467ac101 100755
--enable-gold[=ARG] build gold [ARG={default,yes,no}]
--enable-got=<type> GOT handling scheme (target, single, negative,
multigot)
@@ -15349,6 +15352,19 @@ fi
@@ -15483,6 +15486,19 @@ fi
@@ -118,10 +118,10 @@ index e58fb7f3a35..d0a467ac101 100755
if test "${enable_gold+set}" = set; then :
enableval=$enable_gold; case "${enableval}" in
diff --git a/ld/configure.ac b/ld/configure.ac
index 4331d6b1302..e2976bc2926 100644
index 77edac3258c..a74dac63038 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -102,6 +102,16 @@ AC_SUBST(use_sysroot)
@@ -103,6 +103,16 @@ AC_SUBST(use_sysroot)
AC_SUBST(TARGET_SYSTEM_ROOT)
AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
@@ -139,10 +139,10 @@ index 4331d6b1302..e2976bc2926 100644
dnl "install_as_default" is set to false if gold is the default linker.
dnl "installed_linker" is the installed BFD linker name.
diff --git a/ld/ld.h b/ld/ld.h
index f3086bf30de..db5064243c7 100644
index 05649ff61b8..1818c227473 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -162,6 +162,14 @@ typedef struct
@@ -163,6 +163,14 @@ typedef struct
in the linker script. */
bool force_group_allocation;
@@ -158,10 +158,10 @@ index f3086bf30de..db5064243c7 100644
enum endian_enum endian;
diff --git a/ld/ld.texi b/ld/ld.texi
index eabbec8faa9..c4680e4947e 100644
index db3a9f09b45..77037399cb9 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -2947,6 +2947,18 @@ creation of the metadata note, if one had been enabled by an earlier
@@ -2960,6 +2960,18 @@ creation of the metadata note, if one had been enabled by an earlier
occurrence of the --package-metdata option.
If the linker has been built with libjansson, then the JSON string
will be validated.
@@ -181,7 +181,7 @@ index eabbec8faa9..c4680e4947e 100644
@c man end
diff --git a/ld/ldfile.c b/ld/ldfile.c
index 731ae5f7aed..dd8f03fd960 100644
index b8fd4e5d8e0..1f1d8e23bc9 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -117,6 +117,23 @@ ldfile_add_library_path (const char *name, bool cmdline)
@@ -209,10 +209,10 @@ index 731ae5f7aed..dd8f03fd960 100644
/* Try to open a BFD for a lang_input_statement. */
diff --git a/ld/ldlex.h b/ld/ldlex.h
index 57ade1f754b..64007ff8684 100644
index 0538f0a06a1..f94a71875d8 100644
--- a/ld/ldlex.h
+++ b/ld/ldlex.h
@@ -168,6 +168,8 @@ enum option_values
@@ -170,6 +170,8 @@ enum option_values
OPTION_NO_WARN_EXECSTACK,
OPTION_WARN_RWX_SEGMENTS,
OPTION_NO_WARN_RWX_SEGMENTS,
@@ -222,7 +222,7 @@ index 57ade1f754b..64007ff8684 100644
/* The initial parser states. */
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 1ae90a77749..f40750fd816 100644
index ceaca2d85d0..62e7b4e5341 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -322,6 +322,8 @@ main (int argc, char **argv)
@@ -234,7 +234,7 @@ index 1ae90a77749..f40750fd816 100644
/* We initialize DEMANGLING based on the environment variable
COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
@@ -1447,7 +1449,7 @@ undefined_symbol (struct bfd_link_info *info,
@@ -1454,7 +1456,7 @@ undefined_symbol (struct bfd_link_info *info,
argv[1] = "undefined-symbol";
argv[2] = (char *) name;
argv[3] = NULL;
@@ -243,7 +243,7 @@ index 1ae90a77749..f40750fd816 100644
if (verbose)
einfo (_("%P: About to run error handling script '%s' with arguments: '%s' '%s'\n"),
argv[0], argv[1], argv[2]);
@@ -1468,7 +1470,7 @@ undefined_symbol (struct bfd_link_info *info,
@@ -1475,7 +1477,7 @@ undefined_symbol (struct bfd_link_info *info,
carry on to issue the normal error message. */
}
#endif /* SUPPORT_ERROR_HANDLING_SCRIPT */
@@ -253,10 +253,10 @@ index 1ae90a77749..f40750fd816 100644
{
if (error_count < MAX_ERRORS_IN_A_ROW)
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 9225f71b3ce..92fb66f1fa2 100644
index c5960385572..eb54627fb71 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -608,6 +608,14 @@ static const struct ld_option ld_options[] =
@@ -613,6 +613,14 @@ static const struct ld_option ld_options[] =
" <method> is: share-unconflicted (default),\n"
" share-duplicated"),
TWO_DASHES },
@@ -271,7 +271,7 @@ index 9225f71b3ce..92fb66f1fa2 100644
};
#define OPTION_COUNT ARRAY_SIZE (ld_options)
@@ -1722,6 +1730,14 @@ parse_args (unsigned argc, char **argv)
@@ -1735,6 +1743,14 @@ parse_args (unsigned argc, char **argv)
config.print_map_discarded = true;
break;
@@ -1,4 +1,4 @@
From 883b6c0930410f8553b3bce0dd98131bc1694fa6 Mon Sep 17 00:00:00 2001
From ef9aa69324a209e546956a2f674462717ec5af0f Mon Sep 17 00:00:00 2001
From: Zhenhua Luo <zhenhua.luo@nxp.com>
Date: Sat, 11 Jun 2016 22:08:29 -0500
Subject: [PATCH] fix the incorrect assembling for ppc wait mnemonic
@@ -14,10 +14,10 @@ Signed-off-by: Zhenhua Luo <zhenhua.luo@nxp.com>
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c
index 7637d3e349e..8e074e13208 100644
index 37f1aeb780c..45774c7cf79 100644
--- a/opcodes/ppc-opc.c
+++ b/opcodes/ppc-opc.c
@@ -6947,8 +6947,6 @@ const struct powerpc_opcode powerpc_opcodes[] = {
@@ -7138,8 +7138,6 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{"waitasec", X(31,30), XRTRARB_MASK, POWER8, POWER9, {0}},
{"waitrsv", XWCPL(31,30,1,0),0xffffffff, POWER10, EXT, {0}},
{"pause_short", XWCPL(31,30,2,0),0xffffffff, POWER10, EXT, {0}},
@@ -26,7 +26,7 @@ index 7637d3e349e..8e074e13208 100644
{"lwepx", X(31,31), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
@@ -7002,7 +7000,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
@@ -7193,7 +7191,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{"waitrsv", X(31,62)|(1<<21), 0xffffffff, E500MC|PPCA2, EXT, {0}},
{"waitimpl", X(31,62)|(2<<21), 0xffffffff, E500MC|PPCA2, EXT, {0}},
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
From 98410efc334e31ccfbdc0080fb293b0e06885454 Mon Sep 17 00:00:00 2001
From d6f4f62fda4fde10b805b06d5e61792ee821449c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:42:38 +0000
Subject: [PATCH] Fix rpath in libtool when sysroot is enabled
@@ -1,4 +1,4 @@
From 84fc4ceafcbfad4c6ddc9d65f6a425bd62dd062e Mon Sep 17 00:00:00 2001
From 654b4ea9e28aad037e788672ca0d9ba450b3285e Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@intel.com>
Date: Mon, 6 Mar 2017 23:33:27 -0800
Subject: [PATCH] sync with OE libtool changes
@@ -1,4 +1,4 @@
From 628c10087e6e11a7bc748437c5b695835b704aaf Mon Sep 17 00:00:00 2001
From 9d35ab04de550f1db5d2e74d37fdeab4ca436148 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 15 Apr 2020 14:17:20 -0700
Subject: [PATCH] Check for clang before checking gcc version
@@ -18,10 +18,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index be433ef6d5d..7494fbd2f06 100755
index 417fc5a970c..bdc3583215f 100755
--- a/configure
+++ b/configure
@@ -5294,7 +5294,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
@@ -5460,7 +5460,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -31,10 +31,10 @@ index be433ef6d5d..7494fbd2f06 100755
#endif
int main() {}
diff --git a/configure.ac b/configure.ac
index 1651cbf3b02..2e2ecc47542 100644
index 3a1eb0357e5..1c00b9aec42 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1323,7 +1323,7 @@ if test "$GCC" = yes; then
@@ -1444,7 +1444,7 @@ if test "$GCC" = yes; then
AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc])
AC_LANG_PUSH(C++)
AC_LINK_IFELSE([AC_LANG_SOURCE([
@@ -1,4 +1,4 @@
From 63157cb403b6aa13147840c036a8555c4ea9c166 Mon Sep 17 00:00:00 2001
From 9a296e537708296d32c07c1dc681f59de3d1acf9 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 10 Mar 2022 21:21:33 -0800
Subject: [PATCH] Only generate an RPATH entry if LD_RUN_PATH is not empty
@@ -14,7 +14,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 file changed, 5 insertions(+)
diff --git a/ld/ldelf.c b/ld/ldelf.c
index 0d61a3209ec..cd0da2013e2 100644
index 95787012b89..bc29909386f 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1127,6 +1127,9 @@ ldelf_handle_dt_needed (struct elf_link_hash_table *htab,
@@ -1,36 +0,0 @@
From ef186fe54aa6d281a3ff8a9528417e5cc614c797 Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Sat, 13 Aug 2022 15:32:47 +0930
Subject: [PATCH] PR29482 - strip: heap-buffer-overflow
PR 29482
* coffcode.h (coff_set_section_contents): Sanity check _LIB.
Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ef186fe54aa6d281a3ff8a9528417e5cc614c797]
Signed-off-by: Pgowda <pgowda.cve@gmail.com>
---
bfd/coffcode.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 67aaf158ca1..52027981c3f 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -4302,10 +4302,13 @@ coff_set_section_contents (bfd * abfd,
rec = (bfd_byte *) location;
recend = rec + count;
- while (rec < recend)
+ while (recend - rec >= 4)
{
+ size_t len = bfd_get_32 (abfd, rec);
+ if (len == 0 || len > (size_t) (recend - rec) / 4)
+ break;
+ rec += len * 4;
++section->lma;
- rec += bfd_get_32 (abfd, rec) * 4;
}
BFD_ASSERT (rec == recend);
@@ -0,0 +1,48 @@
From 5fb47367d885a4a32625f09138b306d36ec3769f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 15 Jan 2023 00:16:25 -0800
Subject: [PATCH] Define alignof using _Alignof when using C11 or newer
WG14 N2350 made very clear that it is an UB having type definitions
within "offsetof" [1]. This patch enhances the implementation of macro
alignof to use builtin "_Alignof" to avoid undefined behavior on
when using std=c11 or newer
clang 16+ has started to flag this [2]
Fixes build when using -std >= gnu11 and using clang16+
Older compilers gcc < 4.9 or clang < 8 has buggy _Alignof even though it
may support C11, exclude those compilers too
[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm
[2] https://reviews.llvm.org/D133574
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
libiberty/sha1.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libiberty/sha1.c b/libiberty/sha1.c
index 6c71e3ebb41..a2caf947d31 100644
--- a/libiberty/sha1.c
+++ b/libiberty/sha1.c
@@ -229,7 +229,17 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
if (len >= 64)
{
#if !_STRING_ARCH_unaligned
+/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
+ <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.
+ clang versions < 8.0.0 have the same bug. */
+#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
+ || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
+ && !defined __clang__) \
+ || (defined __clang__ && __clang_major__ < 8))
# define alignof(type) offsetof (struct { char c; type x; }, x)
+#else
+# define alignof(type) _Alignof(type)
+#endif
# define UNALIGNED_P(p) (((size_t) p) % alignof (sha1_uint32) != 0)
if (UNALIGNED_P (buffer))
while (len > 64)
@@ -1,350 +0,0 @@
From f07c08e115e27cddf5a0030dc6332bbee1bd9c6a Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Thu, 21 Jul 2022 08:38:14 +0930
Subject: [PATCH] binutils/dwarf.c: abbrev caching
I'm inclined to think that abbrev caching is counter-productive. The
time taken to search the list of abbrevs converted to internal form is
non-zero, and it's easy to decode the raw abbrevs. It's especially
silly to cache empty lists of decoded abbrevs (happens with zero
padding in .debug_abbrev), or abbrevs as they are displayed when there
is no further use of those abbrevs. This patch stops caching in those
cases.
* dwarf.c (record_abbrev_list_for_cu): Add free_list param.
Put abbrevs on abbrev_lists here.
(new_abbrev_list): Delete function.
(process_abbrev_set): Return newly allocated list. Move
abbrev base, offset and size checking to..
(find_and_process_abbrev_set): ..here, new function. Handle
lookup of cached abbrevs here, and calculate start and end
for process_abbrev_set. Return free_list if newly alloc'd.
(process_debug_info): Consolidate cached list lookup, new list
alloc and processing into find_and_process_abbrev_set call.
Free list when not cached.
(display_debug_abbrev): Similarly.
Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=f07c08e115e27cddf5a0030dc6332bbee1bd9c6a]
Signed-off-by: Pgowda <pgowda.cve@gmail.com>
---
binutils/dwarf.c | 208 +++++++++++++++++++++++++----------------------
1 file changed, 110 insertions(+), 98 deletions(-)
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 267ed3bb382..2fc352f74c5 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -882,8 +882,15 @@ static unsigned long next_free_abbrev_m
#define ABBREV_MAP_ENTRIES_INCREMENT 8
static void
-record_abbrev_list_for_cu (dwarf_vma start, dwarf_vma end, abbrev_list * list)
+record_abbrev_list_for_cu (dwarf_vma start, dwarf_vma end,
+ abbrev_list *list, abbrev_list *free_list)
{
+ if (free_list != NULL)
+ {
+ list->next = abbrev_lists;
+ abbrev_lists = list;
+ }
+
if (cu_abbrev_map == NULL)
{
num_abbrev_map_entries = INITIAL_NUM_ABBREV_MAP_ENTRIES;
@@ -936,20 +943,6 @@ free_all_abbrevs (void)
}
static abbrev_list *
-new_abbrev_list (dwarf_vma abbrev_base, dwarf_vma abbrev_offset)
-{
- abbrev_list * list = (abbrev_list *) xcalloc (sizeof * list, 1);
-
- list->abbrev_base = abbrev_base;
- list->abbrev_offset = abbrev_offset;
-
- list->next = abbrev_lists;
- abbrev_lists = list;
-
- return list;
-}
-
-static abbrev_list *
find_abbrev_list_by_abbrev_offset (dwarf_vma abbrev_base,
dwarf_vma abbrev_offset)
{
@@ -966,7 +959,7 @@ find_abbrev_list_by_abbrev_offset (dwarf
/* Find the abbreviation map for the CU that includes OFFSET.
OFFSET is an absolute offset from the start of the .debug_info section. */
/* FIXME: This function is going to slow down readelf & objdump.
- Consider using a better algorithm to mitigate this effect. */
+ Not caching abbrevs is likely the answer. */
static abbrev_map *
find_abbrev_map_by_offset (dwarf_vma offset)
@@ -1033,40 +1026,18 @@ add_abbrev_attr (unsigned long attrib
list->last_abbrev->last_attr = attr;
}
-/* Processes the (partial) contents of a .debug_abbrev section.
- Returns NULL if the end of the section was encountered.
- Returns the address after the last byte read if the end of
- an abbreviation set was found. */
+/* Return processed (partial) contents of a .debug_abbrev section.
+ Returns NULL on errors. */
-static unsigned char *
+static abbrev_list *
process_abbrev_set (struct dwarf_section *section,
- dwarf_vma abbrev_base,
- dwarf_vma abbrev_size,
- dwarf_vma abbrev_offset,
- abbrev_list *list)
+ unsigned char *start,
+ unsigned char *end)
{
- if (abbrev_base >= section->size
- || abbrev_size > section->size - abbrev_base)
- {
- /* PR 17531: file:4bcd9ce9. */
- warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
- "abbrev section size (%lx)\n"),
- (unsigned long) (abbrev_base + abbrev_size),
- (unsigned long) section->size);
- return NULL;
- }
- if (abbrev_offset >= abbrev_size)
- {
- warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than "
- "abbrev section size (%lx)\n"),
- (unsigned long) abbrev_offset,
- (unsigned long) abbrev_size);
- return NULL;
- }
+ abbrev_list *list = xmalloc (sizeof (*list));
+ list->first_abbrev = NULL;
+ list->last_abbrev = NULL;
- unsigned char *start = section->start + abbrev_base;
- unsigned char *end = start + abbrev_size;
- start += abbrev_offset;
while (start < end)
{
unsigned long entry;
@@ -1079,14 +1050,18 @@ process_abbrev_set (struct dwarf_section
/* A single zero is supposed to end the set according
to the standard. If there's more, then signal that to
the caller. */
- if (start == end)
- return NULL;
- if (entry == 0)
- return start;
+ if (start == end || entry == 0)
+ {
+ list->start_of_next_abbrevs = start != end ? start : NULL;
+ return list;
+ }
READ_ULEB (tag, start, end);
if (start == end)
- return NULL;
+ {
+ free (list);
+ return NULL;
+ }
children = *start++;
@@ -1121,9 +1096,67 @@ process_abbrev_set (struct dwarf_section
/* Report the missing single zero which ends the section. */
error (_(".debug_abbrev section not zero terminated\n"));
+ free (list);
return NULL;
}
+/* Return a sequence of abbrevs in SECTION starting at ABBREV_BASE
+ plus ABBREV_OFFSET and finishing at ABBREV_BASE + ABBREV_SIZE.
+ If FREE_LIST is non-NULL search the already decoded abbrevs on
+ abbrev_lists first and if found set *FREE_LIST to NULL. If
+ searching doesn't find a matching abbrev, set *FREE_LIST to the
+ newly allocated list. If FREE_LIST is NULL, no search is done and
+ the returned abbrev_list is always newly allocated. */
+
+static abbrev_list *
+find_and_process_abbrev_set (struct dwarf_section *section,
+ dwarf_vma abbrev_base,
+ dwarf_vma abbrev_size,
+ dwarf_vma abbrev_offset,
+ abbrev_list **free_list)
+{
+ if (free_list)
+ *free_list = NULL;
+
+ if (abbrev_base >= section->size
+ || abbrev_size > section->size - abbrev_base)
+ {
+ /* PR 17531: file:4bcd9ce9. */
+ warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
+ "abbrev section size (%lx)\n"),
+ (unsigned long) (abbrev_base + abbrev_size),
+ (unsigned long) section->size);
+ return NULL;
+ }
+ if (abbrev_offset >= abbrev_size)
+ {
+ warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than "
+ "abbrev section size (%lx)\n"),
+ (unsigned long) abbrev_offset,
+ (unsigned long) abbrev_size);
+ return NULL;
+ }
+
+ unsigned char *start = section->start + abbrev_base + abbrev_offset;
+ unsigned char *end = section->start + abbrev_base + abbrev_size;
+ abbrev_list *list = NULL;
+ if (free_list)
+ list = find_abbrev_list_by_abbrev_offset (abbrev_base, abbrev_offset);
+ if (list == NULL)
+ {
+ list = process_abbrev_set (section, start, end);
+ if (list)
+ {
+ list->abbrev_base = abbrev_base;
+ list->abbrev_offset = abbrev_offset;
+ list->next = NULL;
+ }
+ if (free_list)
+ *free_list = list;
+ }
+ return list;
+}
+
static const char *
get_TAG_name (unsigned long tag)
{
@@ -3670,7 +3703,6 @@ process_debug_info (struct dwarf_section
dwarf_vma cu_offset;
unsigned int offset_size;
struct cu_tu_set * this_set;
- abbrev_list * list;
unsigned char *end_cu;
hdrptr = start;
@@ -3726,22 +3758,18 @@ process_debug_info (struct dwarf_section
abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];
}
- list = find_abbrev_list_by_abbrev_offset (abbrev_base,
- compunit.cu_abbrev_offset);
- if (list == NULL)
- {
- unsigned char * next;
-
- list = new_abbrev_list (abbrev_base,
- compunit.cu_abbrev_offset);
- next = process_abbrev_set (&debug_displays[abbrev_sec].section,
- abbrev_base, abbrev_size,
- compunit.cu_abbrev_offset, list);
- list->start_of_next_abbrevs = next;
- }
-
+ abbrev_list *list;
+ abbrev_list *free_list;
+ list = find_and_process_abbrev_set (&debug_displays[abbrev_sec].section,
+ abbrev_base, abbrev_size,
+ compunit.cu_abbrev_offset,
+ &free_list);
start = end_cu;
- record_abbrev_list_for_cu (cu_offset, start - section_begin, list);
+ if (list != NULL && list->first_abbrev != NULL)
+ record_abbrev_list_for_cu (cu_offset, start - section_begin,
+ list, free_list);
+ else if (free_list != NULL)
+ free_abbrev_list (free_list);
}
for (start = section_begin, unit = 0; start < end; unit++)
@@ -3757,7 +3785,6 @@ process_debug_info (struct dwarf_section
struct cu_tu_set *this_set;
dwarf_vma abbrev_base;
size_t abbrev_size;
- abbrev_list * list = NULL;
unsigned char *end_cu;
hdrptr = start;
@@ -3936,20 +3963,10 @@ process_debug_info (struct dwarf_section
}
/* Process the abbrevs used by this compilation unit. */
- list = find_abbrev_list_by_abbrev_offset (abbrev_base,
- compunit.cu_abbrev_offset);
- if (list == NULL)
- {
- unsigned char *next;
-
- list = new_abbrev_list (abbrev_base,
- compunit.cu_abbrev_offset);
- next = process_abbrev_set (&debug_displays[abbrev_sec].section,
- abbrev_base, abbrev_size,
- compunit.cu_abbrev_offset, list);
- list->start_of_next_abbrevs = next;
- }
-
+ abbrev_list *list;
+ list = find_and_process_abbrev_set (&debug_displays[abbrev_sec].section,
+ abbrev_base, abbrev_size,
+ compunit.cu_abbrev_offset, NULL);
level = 0;
last_level = level;
saved_level = -1;
@@ -4128,6 +4145,8 @@ process_debug_info (struct dwarf_section
if (entry->children)
++level;
}
+ if (list != NULL)
+ free_abbrev_list (list);
}
/* Set num_debug_info_entries here so that it can be used to check if
@@ -6353,24 +6372,15 @@ display_debug_abbrev (struct dwarf_secti
do
{
- abbrev_list * list;
- dwarf_vma offset;
-
- offset = start - section->start;
- list = find_abbrev_list_by_abbrev_offset (0, offset);
+ dwarf_vma offset = start - section->start;
+ abbrev_list *list = find_and_process_abbrev_set (section, 0,
+ section->size, offset,
+ NULL);
if (list == NULL)
- {
- list = new_abbrev_list (0, offset);
- start = process_abbrev_set (section, 0, section->size, offset, list);
- list->start_of_next_abbrevs = start;
- }
- else
- start = list->start_of_next_abbrevs;
-
- if (list->first_abbrev == NULL)
- continue;
+ break;
- printf (_(" Number TAG (0x%lx)\n"), (long) offset);
+ if (list->first_abbrev)
+ printf (_(" Number TAG (0x%lx)\n"), (long) offset);
for (entry = list->first_abbrev; entry; entry = entry->next)
{
@@ -6391,6 +6401,8 @@ display_debug_abbrev (struct dwarf_secti
putchar ('\n');
}
}
+ start = list->start_of_next_abbrevs;
+ free_abbrev_list (list);
}
while (start);
@@ -1,536 +0,0 @@
From 175b91507b83ad42607d2f6dadaf55b7b511bdbe Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Wed, 20 Jul 2022 18:28:50 +0930
Subject: [PATCH] miscellaneous dwarf.c tidies
* dwarf.c: Leading and trailing whitespace fixes.
(free_abbrev_list): New function.
(free_all_abbrevs): Use the above. Free cu_abbrev_map here too.
(process_abbrev_set): Print actual section name on error.
(get_type_abbrev_from_form): Add overflow check.
(free_debug_memory): Don't free cu_abbrev_map here..
(process_debug_info): ..or here. Warn on another case of not
finding a neeeded abbrev.
Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=175b91507b83ad42607d2f6dadaf55b7b511bdbe]
Signed-off-by: Pgowda <pgowda.cve@gmail.com>
---
binutils/dwarf.c | 216 +++++++++++++++++++++++------------------------
1 file changed, 106 insertions(+), 110 deletions(-)
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 2b1eec49422..267ed3bb382 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -806,7 +806,7 @@ fetch_indexed_value (dwarf_vma idx,
pointer_size = 4;
bias = 12;
}
-
+
dwarf_vma offset = idx * pointer_size;
/* Offsets are biased by the size of the section header
@@ -908,38 +908,41 @@ record_abbrev_list_for_cu (dwarf_vma sta
next_free_abbrev_map_entry ++;
}
-static void
-free_all_abbrevs (void)
+static abbrev_list *
+free_abbrev_list (abbrev_list *list)
{
- abbrev_list * list;
+ abbrev_entry *abbrv = list->first_abbrev;
- for (list = abbrev_lists; list != NULL;)
+ while (abbrv)
{
- abbrev_list * next = list->next;
- abbrev_entry * abbrv;
+ abbrev_attr *attr = abbrv->first_attr;
- for (abbrv = list->first_abbrev; abbrv != NULL;)
+ while (attr)
{
- abbrev_entry * next_abbrev = abbrv->next;
- abbrev_attr * attr;
-
- for (attr = abbrv->first_attr; attr;)
- {
- abbrev_attr *next_attr = attr->next;
-
- free (attr);
- attr = next_attr;
- }
-
- free (abbrv);
- abbrv = next_abbrev;
+ abbrev_attr *next_attr = attr->next;
+ free (attr);
+ attr = next_attr;
}
- free (list);
- list = next;
+ abbrev_entry *next_abbrev = abbrv->next;
+ free (abbrv);
+ abbrv = next_abbrev;
}
- abbrev_lists = NULL;
+ abbrev_list *next = list->next;
+ free (list);
+ return next;
+}
+
+static void
+free_all_abbrevs (void)
+{
+ while (abbrev_lists)
+ abbrev_lists = free_abbrev_list (abbrev_lists);
+
+ free (cu_abbrev_map);
+ cu_abbrev_map = NULL;
+ next_free_abbrev_map_entry = 0;
}
static abbrev_list *
@@ -971,7 +974,7 @@ find_abbrev_map_by_offset (dwarf_vma off
&& cu_abbrev_map[i].end > offset)
return cu_abbrev_map + i;
- return NULL;
+ return NULL;
}
static void
@@ -1094,7 +1097,7 @@ process_abbrev_set (struct dwarf_section
}
/* Report the missing single zero which ends the section. */
- error (_(".debug_abbrev section not zero terminated\n"));
+ error (_("%s section not zero terminated\n"), section->name);
free (list);
return NULL;
@@ -1875,7 +1878,7 @@ fetch_alt_indirect_string (dwarf_vma off
dwarf_vmatoa ("x", offset));
return _("<offset is too big>");
}
-
+
static const char *
get_AT_name (unsigned long attribute)
{
@@ -2157,7 +2160,8 @@ get_type_abbrev_from_form (unsigned long
case DW_FORM_ref4:
case DW_FORM_ref8:
case DW_FORM_ref_udata:
- if (uvalue + cu_offset > (size_t) (cu_end - section->start))
+ if (uvalue + cu_offset < uvalue
+ || uvalue + cu_offset > (size_t) (cu_end - section->start))
{
warn (_("Unable to resolve ref form: uvalue %lx + cu_offset %lx > CU size %lx\n"),
uvalue, (long) cu_offset, (long) (cu_end - section->start));
@@ -2194,7 +2198,7 @@ get_type_abbrev_from_form (unsigned long
else
*map_return = NULL;
}
-
+
READ_ULEB (abbrev_number, data, section->start + section->size);
for (entry = map->list->first_abbrev; entry != NULL; entry = entry->next)
@@ -2783,10 +2787,10 @@ read_and_display_attr_value (unsigned lo
if (form == DW_FORM_loclistx)
{
if (dwo)
- {
- index = fetch_indexed_value (uvalue, loclists_dwo, 0);
- index += (offset_size == 8) ? 20 : 12;
- }
+ {
+ index = fetch_indexed_value (uvalue, loclists_dwo, 0);
+ index += (offset_size == 8) ? 20 : 12;
+ }
else if (debug_info_p == NULL)
{
index = fetch_indexed_value (uvalue, loclists, 0);
@@ -2804,21 +2808,21 @@ read_and_display_attr_value (unsigned lo
else if (form == DW_FORM_rnglistx)
{
if (dwo)
- {
- index = fetch_indexed_value (uvalue, rnglists_dwo, 0);
- index += (offset_size == 8) ? 20 : 12;
- }
+ {
+ index = fetch_indexed_value (uvalue, rnglists_dwo, 0);
+ index += (offset_size == 8) ? 20 : 12;
+ }
else
- {
- if (debug_info_p == NULL)
- base = 0;
- else
- base = debug_info_p->rnglists_base;
- /* We do not have a cached value this time, so we perform the
- computation manually. */
- index = fetch_indexed_value (uvalue, rnglists, base);
- index += base;
- }
+ {
+ if (debug_info_p == NULL)
+ base = 0;
+ else
+ base = debug_info_p->rnglists_base;
+ /* We do not have a cached value this time, so we perform the
+ computation manually. */
+ index = fetch_indexed_value (uvalue, rnglists, base);
+ index += base;
+ }
}
else
{
@@ -2844,7 +2848,7 @@ read_and_display_attr_value (unsigned lo
if (!do_loc)
printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue + cu_offset));
break;
-
+
default:
warn (_("Unrecognized form: 0x%lx\n"), form);
/* What to do? Consume a byte maybe? */
@@ -2869,9 +2873,9 @@ read_and_display_attr_value (unsigned lo
case DW_AT_rnglists_base:
if (debug_info_p->rnglists_base)
warn (_("CU @ 0x%s has multiple rnglists_base values (0x%s and 0x%s)"),
- dwarf_vmatoa ("x", debug_info_p->cu_offset),
- dwarf_vmatoa ("x", debug_info_p->rnglists_base),
- dwarf_vmatoa ("x", uvalue));
+ dwarf_vmatoa ("x", debug_info_p->cu_offset),
+ dwarf_vmatoa ("x", debug_info_p->rnglists_base),
+ dwarf_vmatoa ("x", uvalue));
debug_info_p->rnglists_base = uvalue;
break;
case DW_AT_str_offsets_base:
@@ -3021,7 +3025,7 @@ read_and_display_attr_value (unsigned lo
case DW_FORM_strx3:
case DW_FORM_strx4:
add_dwo_name (fetch_indexed_string (uvalue, this_set, offset_size, false,
- debug_info_p->str_offsets_base),
+ debug_info_p->str_offsets_base),
cu_offset);
break;
case DW_FORM_string:
@@ -3055,7 +3059,7 @@ read_and_display_attr_value (unsigned lo
case DW_FORM_strx3:
case DW_FORM_strx4:
add_dwo_dir (fetch_indexed_string (uvalue, this_set, offset_size, false,
- debug_info_p->str_offsets_base),
+ debug_info_p->str_offsets_base),
cu_offset);
break;
case DW_FORM_string:
@@ -3686,11 +3690,8 @@ process_debug_info (struct dwarf_section
introduce (section, false);
free_all_abbrevs ();
- free (cu_abbrev_map);
- cu_abbrev_map = NULL;
- next_free_abbrev_map_entry = 0;
- /* In order to be able to resolve DW_FORM_ref_attr forms we need
+ /* In order to be able to resolve DW_FORM_ref_addr forms we need
to load *all* of the abbrevs for all CUs in this .debug_info
section. This does effectively mean that we (partially) read
every CU header twice. */
@@ -4045,12 +4046,11 @@ process_debug_info (struct dwarf_section
/* Scan through the abbreviation list until we reach the
correct entry. */
- if (list == NULL)
- continue;
-
- for (entry = list->first_abbrev; entry != NULL; entry = entry->next)
- if (entry->number == abbrev_number)
- break;
+ entry = NULL;
+ if (list != NULL)
+ for (entry = list->first_abbrev; entry != NULL; entry = entry->next)
+ if (entry->number == abbrev_number)
+ break;
if (entry == NULL)
{
@@ -4074,7 +4074,7 @@ process_debug_info (struct dwarf_section
break;
case DW_TAG_compile_unit:
case DW_TAG_skeleton_unit:
- need_base_address = 1;
+ need_base_address = 1;
need_dwo_info = do_loc;
break;
case DW_TAG_entry_point:
@@ -4459,7 +4459,7 @@ display_debug_sup (struct dwarf_section
SAFE_BYTE_GET_AND_INC (is_supplementary, start, 1, end);
if (is_supplementary != 0 && is_supplementary != 1)
- warn (_("corrupt .debug_sup section: is_supplementary not 0 or 1\n"));
+ warn (_("corrupt .debug_sup section: is_supplementary not 0 or 1\n"));
sup_filename = start;
if (is_supplementary && sup_filename[0] != 0)
@@ -5638,7 +5638,7 @@ display_debug_lines_decoded (struct dwar
printf ("%s %11d %#18" DWARF_VMA_FMT "x",
newFileName, state_machine_regs.line,
state_machine_regs.address);
- }
+ }
else
{
if (xop == -DW_LNE_end_sequence)
@@ -6092,7 +6092,7 @@ display_debug_macro (struct dwarf_sectio
load_debug_section_with_follow (str, file);
load_debug_section_with_follow (line, file);
load_debug_section_with_follow (str_index, file);
-
+
introduce (section, false);
while (curr < end)
@@ -6537,7 +6537,7 @@ display_loc_list (struct dwarf_section *
/* Check base address specifiers. */
if (is_max_address (begin, pointer_size)
- && !is_max_address (end, pointer_size))
+ && !is_max_address (end, pointer_size))
{
base_address = end;
print_dwarf_vma (begin, pointer_size);
@@ -6715,7 +6715,7 @@ display_loclists_list (struct dwarf_sect
case DW_LLE_default_location:
begin = end = 0;
break;
-
+
case DW_LLE_offset_pair:
READ_ULEB (begin, start, section_end);
begin += base_address;
@@ -7011,7 +7011,7 @@ display_offset_entry_loclists (struct dw
unsigned char * start = section->start;
unsigned char * const end = start + section->size;
- introduce (section, false);
+ introduce (section, false);
do
{
@@ -7060,14 +7060,14 @@ display_offset_entry_loclists (struct dw
section->name, segment_selector_size);
return 0;
}
-
+
if (offset_entry_count == 0)
{
warn (_("The %s section contains a table without offset\n"),
section->name);
return 0;
}
-
+
printf (_("\n Offset Entries starting at 0x%lx:\n"),
(long)(start - section->start));
@@ -8229,7 +8229,7 @@ display_debug_rnglists (struct dwarf_sec
start = display_debug_rnglists_list
(start, end, address_size, offset, 0, offset_size);
if (start >= end)
- break;
+ break;
}
start = end;
@@ -8347,12 +8347,12 @@ display_debug_ranges (struct dwarf_secti
next = section_begin + offset + debug_info_p->rnglists_base;
/* If multiple DWARF entities reference the same range then we will
- have multiple entries in the `range_entries' list for the same
- offset. Thanks to the sort above these will all be consecutive in
- the `range_entries' list, so we can easily ignore duplicates
- here. */
+ have multiple entries in the `range_entries' list for the same
+ offset. Thanks to the sort above these will all be consecutive in
+ the `range_entries' list, so we can easily ignore duplicates
+ here. */
if (i > 0 && last_offset == offset)
- continue;
+ continue;
last_offset = offset;
if (dwarf_check != 0 && i > 0)
@@ -10286,7 +10286,7 @@ display_debug_names (struct dwarf_sectio
printf (_("Out of %lu items there are %zu bucket clashes"
" (longest of %zu entries).\n"),
(unsigned long) name_count, hash_clash_count, longest_clash);
-
+
if (name_count != buckets_filled + hash_clash_count)
warn (_("The name_count (%lu) is not the same as the used bucket_count (%lu) + the hash clash count (%lu)"),
(unsigned long) name_count,
@@ -10390,7 +10390,7 @@ display_debug_names (struct dwarf_sectio
break;
if (tagno >= 0)
printf ("%s<%lu>",
- (tagno == 0 && second_abbrev_tag == 0 ? " " : "\n\t"),
+ (tagno == 0 && second_abbrev_tag == 0 ? " " : "\n\t"),
(unsigned long) abbrev_tag);
for (entry = abbrev_lookup;
@@ -10919,7 +10919,7 @@ process_cu_tu_index (struct dwarf_sectio
Check for integer overflow (can occur when size_t is 32-bit)
with overlarge ncols or nused values. */
if (nused == -1u
- || _mul_overflow ((size_t) ncols, 4, &temp)
+ || _mul_overflow ((size_t) ncols, 4, &temp)
|| _mul_overflow ((size_t) nused + 1, temp, &total)
|| total > (size_t) (limit - ppool))
{
@@ -10927,7 +10927,7 @@ process_cu_tu_index (struct dwarf_sectio
section->name);
return 0;
}
-
+
if (do_display)
{
printf (_(" Offset table\n"));
@@ -11431,8 +11431,8 @@ add_separate_debug_file (const char * fi
static bool
debuginfod_fetch_separate_debug_info (struct dwarf_section * section,
- char ** filename,
- void * file)
+ char ** filename,
+ void * file)
{
size_t build_id_len;
unsigned char * build_id;
@@ -11450,14 +11450,14 @@ debuginfod_fetch_separate_debug_info (st
filelen = strnlen ((const char *)section->start, section->size);
if (filelen == section->size)
- /* Corrupt debugaltlink. */
- return false;
+ /* Corrupt debugaltlink. */
+ return false;
build_id = section->start + filelen + 1;
build_id_len = section->size - (filelen + 1);
if (build_id_len == 0)
- return false;
+ return false;
}
else
return false;
@@ -11469,25 +11469,25 @@ debuginfod_fetch_separate_debug_info (st
client = debuginfod_begin ();
if (client == NULL)
- return false;
+ return false;
/* Query debuginfod servers for the target file. If found its path
- will be stored in filename. */
+ will be stored in filename. */
fd = debuginfod_find_debuginfo (client, build_id, build_id_len, filename);
debuginfod_end (client);
/* Only free build_id if we allocated space for a hex string
- in get_build_id (). */
+ in get_build_id (). */
if (build_id_len == 0)
- free (build_id);
+ free (build_id);
if (fd >= 0)
- {
- /* File successfully retrieved. Close fd since we want to
- use open_debug_file () on filename instead. */
- close (fd);
- return true;
- }
+ {
+ /* File successfully retrieved. Close fd since we want to
+ use open_debug_file () on filename instead. */
+ close (fd);
+ return true;
+ }
}
return false;
@@ -11500,7 +11500,7 @@ load_separate_debug_info (const char *
parse_func_type parse_func,
check_func_type check_func,
void * func_data,
- void * file ATTRIBUTE_UNUSED)
+ void * file ATTRIBUTE_UNUSED)
{
const char * separate_filename;
char * debug_filename;
@@ -11616,11 +11616,11 @@ load_separate_debug_info (const char *
& tmp_filename,
file))
{
- /* File successfully downloaded from server, replace
- debug_filename with the file's path. */
- free (debug_filename);
- debug_filename = tmp_filename;
- goto found;
+ /* File successfully downloaded from server, replace
+ debug_filename with the file's path. */
+ free (debug_filename);
+ debug_filename = tmp_filename;
+ goto found;
}
}
#endif
@@ -11787,12 +11787,12 @@ load_build_id_debug_file (const char * m
/* In theory we should extract the contents of the section into
a note structure and then check the fields. For now though
just use hard coded offsets instead:
-
+
Field Bytes Contents
NSize 0...3 4
DSize 4...7 8+
Type 8..11 3 (NT_GNU_BUILD_ID)
- Name 12.15 GNU\0
+ Name 12.15 GNU\0
Data 16.... */
/* FIXME: Check the name size, name and type fields. */
@@ -11804,7 +11804,7 @@ load_build_id_debug_file (const char * m
warn (_(".note.gnu.build-id data size is too small\n"));
return;
}
-
+
if (build_id_size > (section->size - 16))
{
warn (_(".note.gnu.build-id data size is too bug\n"));
@@ -12100,10 +12100,6 @@ free_debug_memory (void)
free_all_abbrevs ();
- free (cu_abbrev_map);
- cu_abbrev_map = NULL;
- next_free_abbrev_map_entry = 0;
-
free (shndx_pool);
shndx_pool = NULL;
shndx_pool_size = 0;
@@ -1,95 +0,0 @@
From 695c6dfe7e85006b98c8b746f3fd5f913c94ebff Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Thu, 21 Jul 2022 09:56:15 +0930
Subject: [PATCH] PR29370, infinite loop in display_debug_abbrev
The PR29370 testcase is a fuzzed object file with multiple
.trace_abbrev sections. Multiple .trace_abbrev or .debug_abbrev
sections are not a violation of the DWARF standard. The DWARF5
standard even gives an example of multiple .debug_abbrev sections
contained in groups. Caching and lookup of processed abbrevs thus
needs to be done by section and offset rather than base and offset.
(Why base anyway?) Or, since section contents are kept, by a pointer
into the contents.
PR 29370
* dwarf.c (struct abbrev_list): Replace abbrev_base and
abbrev_offset with raw field.
(find_abbrev_list_by_abbrev_offset): Delete.
(find_abbrev_list_by_raw_abbrev): New function.
(process_abbrev_set): Set list->raw and list->next.
(find_and_process_abbrev_set): Replace abbrev list lookup with
new function. Don't set list abbrev_base, abbrev_offset or next.
Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=695c6dfe7e85006b98c8b746f3fd5f913c94ebff]
Signed-off-by: Pgowda <pgowda.cve@gmail.com>
---
binutils/dwarf.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 2fc352f74c5..99fb3566994 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -856,8 +856,7 @@ typedef struct abbrev_list
{
abbrev_entry * first_abbrev;
abbrev_entry * last_abbrev;
- dwarf_vma abbrev_base;
- dwarf_vma abbrev_offset;
+ unsigned char * raw;
struct abbrev_list * next;
unsigned char * start_of_next_abbrevs;
}
@@ -946,14 +945,12 @@ free_all_abbrevs (void)
}
static abbrev_list *
-find_abbrev_list_by_abbrev_offset (dwarf_vma abbrev_base,
- dwarf_vma abbrev_offset)
+find_abbrev_list_by_raw_abbrev (unsigned char *raw)
{
abbrev_list * list;
for (list = abbrev_lists; list != NULL; list = list->next)
- if (list->abbrev_base == abbrev_base
- && list->abbrev_offset == abbrev_offset)
+ if (list->raw == raw)
return list;
return NULL;
@@ -1040,6 +1037,7 @@ process_abbrev_set (struct dwarf_section
abbrev_list *list = xmalloc (sizeof (*list));
list->first_abbrev = NULL;
list->last_abbrev = NULL;
+ list->raw = start;
while (start < end)
{
@@ -1055,6 +1053,7 @@ process_abbrev_set (struct dwarf_section
the caller. */
if (start == end || entry == 0)
{
+ list->next = NULL;
list->start_of_next_abbrevs = start != end ? start : NULL;
return list;
}
@@ -1144,16 +1143,10 @@ find_and_process_abbrev_set (struct dwar
unsigned char *end = section->start + abbrev_base + abbrev_size;
abbrev_list *list = NULL;
if (free_list)
- list = find_abbrev_list_by_abbrev_offset (abbrev_base, abbrev_offset);
+ list = find_abbrev_list_by_raw_abbrev (start);
if (list == NULL)
{
list = process_abbrev_set (section, start, end);
- if (list)
- {
- list->abbrev_base = abbrev_base;
- list->abbrev_offset = abbrev_offset;
- list->next = NULL;
- }
if (free_list)
*free_list = list;
}
@@ -0,0 +1,56 @@
From 518c167116ab7aa6bb84a97200aeda2c4289e064 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <chigot@adacore.com>
Date: Tue, 3 Jan 2023 14:24:43 +0100
Subject: [PATCH] configure: remove dependencies on gmp and mpfr when gdb is
disabled
Since 991180627851801f1999d1ebbc0e569a17e47c74, the configure checks
about GMP and MPFR for gdb builds have been moved to the toplevel
configure.
However, it doesn't take into account the --disable-gdb option. Meaning
that a build without gdb will require these libraries even if not
needed.
ChangeLog:
* configure.ac: Skip GMP and MPFR when --disable-gdb is
provided.
* configure: Regenerate.
Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=5fb0e308577143ceb313fde5538dc9ecb038f29f]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
configure | 4 +++-
configure.ac | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index bdc3583215f..b63b5cd3de0 100755
--- a/configure
+++ b/configure
@@ -8032,7 +8032,9 @@ if test -d ${srcdir}/gcc ; then
require_mpc=yes
fi
if test -d ${srcdir}/gdb ; then
- require_gmp=yes
+ if test "x$enable_gdb" != xno; then
+ require_gmp=yes
+ fi
fi
gmplibs="-lmpfr -lgmp"
diff --git a/configure.ac b/configure.ac
index 1c00b9aec42..2df870b86af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1585,7 +1585,9 @@ if test -d ${srcdir}/gcc ; then
require_mpc=yes
fi
if test -d ${srcdir}/gdb ; then
- require_gmp=yes
+ if test "x$enable_gdb" != xno; then
+ require_gmp=yes
+ fi
fi
gmplibs="-lmpfr -lgmp"
@@ -1,37 +0,0 @@
From 5c831a3c7f3ca98d6aba1200353311e1a1f84c70 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Wed, 19 Oct 2022 15:09:12 +0100
Subject: [PATCH] Fix an illegal memory access when parsing an ELF file
containing corrupt symbol version information.
PR 29699
* elf.c (_bfd_elf_slurp_version_tables): Fail if the sh_info field
of the section header is zero.
Upstream-Status: Backport
[https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5c831a3c7f3ca98d6aba1200353311e1a1f84c70]
Signed-off-by: Pgowda <pgowda.cve@gmail.com>
---
bfd/ChangeLog | 6 ++++++
bfd/elf.c | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index fe00e0f9189..7cd7febcf95 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8918,7 +8918,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
bfd_set_error (bfd_error_file_too_big);
goto error_return_verref;
}
- elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) bfd_alloc (abfd, amt);
+ if (amt == 0)
+ goto error_return_verref;
+ elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verref == NULL)
goto error_return_verref;
--
2.31.1
@@ -0,0 +1,32 @@
From 9599d7d48913fca4c2bf0d0012f9655353ca6f6c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 18 Jan 2023 19:35:07 -0800
Subject: [PATCH] Remove duplicate pe-dll.o entry deom targ_extra_ofiles
Commit c60b3806799abf1d7f6cf5108a1b0e733a950b13 added support for
aarch64-pe which introduced wrapper over pep-dll.c for x86_64 as well as
aarch64, on x86_64 it was added but the old object pe-dll.o needs to be
removed too, otherwise build fails with duplicate symbols from pe-dll.o
and pep-dll-x86_64.o
Upstream-Status: Submitted [https://sourceware.org/pipermail/binutils/2023-January/125739.html]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Jedidiah Thompson <wej22007@outlook.com>
Cc: Zac Walker <zac.walker@linaro.org>
---
ld/configure.tgt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ld/configure.tgt b/ld/configure.tgt
index de04a44b812..f80c84ab13c 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -1056,7 +1056,7 @@ x86_64-*-cygwin) targ_emul=i386pep ;
;;
x86_64-*-mingw*) targ_emul=i386pep ;
targ_extra_emuls=i386pe
- targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o"
+ targ_extra_ofiles="deffilep.o pdb.o pe-dll.o"
;;
x86_64-*-gnu*) targ_emul=elf_x86_64
targ_extra_emuls="elf32_x86_64 elf_iamcu elf_i386"