cross/binutils: upgrade to 2.37.3-r3

This commit is contained in:
Alexey Minnekhanov 2021-09-27 17:41:54 +03:00
parent b7b51e45f5
commit e722328906
No known key found for this signature in database
GPG key ID: 6FE3B029D9D9FAFF
15 changed files with 891 additions and 378 deletions

View file

@ -1,39 +1,24 @@
From b1faf99f3e546df2cd302bb1ad36a2078224fe8b Mon Sep 17 00:00:00 2001
From bbf05b742fde518fb97c789b043fe0d3aaf549f0 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 30 Oct 2020 16:59:48 -0600
Date: Tue, 21 Sep 2021 14:53:13 +0000
Subject: [PATCH] Revert "PR25882, .gnu.attributes are not checked for shared
libraries"
This revert is needed to avoid wrongly tagging objects with the incompatible
IBM long double ABI, which is not supported by musl and will result in
linking errors if used.
This reverts commit a8acd6eeb6dc2cc5460ece90f90ebe36b56b20ba.
---
bfd/ChangeLog | 6 ------
bfd/elf32-tic6x.c | 3 ---
ld/ChangeLog | 6 ------
ld/ldlang.c | 9 ++++-----
4 files changed, 4 insertions(+), 20 deletions(-)
bfd/elf32-tic6x.c | 3 ---
ld/ldlang.c | 10 ++++------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9fac12538a..b5461494e8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1422,12 +1422,6 @@
accessing root.u.def of symbols. Also check root.u.def.section
is non-NULL. Reverse tests so as to make the logic positive.
-2020-05-01 Alan Modra <amodra@gmail.com>
-
- PR 25882
- * elf32-tic6x.c (elf32_tic6x_merge_attributes): Don't transfer
- Tag_ABI_PIC or Tag_ABI_PID from dynamic objects to the output.
-
2020-05-01 Alan Modra <amodra@gmail.com>
PR 25882
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index b8b916bfd3..91bb6a10b1 100644
index 5754f3cb860..3ad1d612749 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -3748,9 +3748,6 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
@@ -3735,9 +3735,6 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
case Tag_ABI_PIC:
case Tag_ABI_PID:
@ -43,36 +28,20 @@ index b8b916bfd3..91bb6a10b1 100644
if (out_attr[i].i > in_attr[i].i)
out_attr[i].i = in_attr[i].i;
break;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 4eec7d2977..b93452f70c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1319,12 +1319,6 @@
* testsuite/ld-aarch64/farcall-group.d: New test driver.
* testsuite/ld-aarch64/aarch64-elf.exp: Run the new test.
-2020-05-01 Alan Modra <amodra@gmail.com>
-
- PR 25882
- * ldlang.c (lang_check): Call bfd_merge_private_bfd_data for
- shared libraries.
-
2020-05-01 Alan Modra <amodra@gmail.com>
* po/BLD-POTFILES.in: Regenerate.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 9977195074..173d8ec349 100644
index 37b64c89ee1..f13beaef9d9 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -6972,12 +6972,11 @@ lang_check (void)
@@ -7071,13 +7071,11 @@ lang_check (void)
bfd_printable_name (input_bfd), input_bfd,
bfd_printable_name (link_info.output_bfd));
}
-
- /* If the input bfd has no contents, it shouldn't set the
- private data of the output bfd. */
- else if ((input_bfd->flags & DYNAMIC) != 0
- || bfd_count_sections (input_bfd) != 0)
- else if (!file->flags.just_syms
- && ((input_bfd->flags & DYNAMIC) != 0
- || bfd_count_sections (input_bfd) != 0))
+ else if (bfd_count_sections (input_bfd))
{
+ /* If the input bfd has no contents, it shouldn't set the
@ -82,5 +51,5 @@ index 9977195074..173d8ec349 100644
/* If we aren't supposed to warn about mismatched input
--
2.29.2
2.33.0

View file

@ -3,8 +3,8 @@
# Based on: main/binutils
pkgname=binutils-aarch64
pkgver=2.35.2
pkgrel=2
pkgver=2.37
pkgrel=3
pkgdesc="Tools necessary to build programs for aarch64 targets"
url="https://www.gnu.org/software/binutils/"
makedepends="gettext libtool autoconf automake bison texinfo"
@ -15,8 +15,9 @@ source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
gold-mips.patch
ld-bfd-mips.patch
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
CVE-2021-3487.patch
binutils-mips-disable-assert.patch
bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
defang-no-split.patch
"
builddir="$srcdir/binutils-$pkgver"
@ -69,11 +70,12 @@ package() {
sha512sums="
9974ede5978d32e0d68fef23da48fa00bd06b0bff7ec45b00ca075c126d6bbe0cf2defc03ecc3f17bc6cc85b64271a13009c4049d7ba17de26e84e3a6e2c0348 binutils-2.35.2.tar.xz
5c11aeef6935860a6819ed3a3c93371f052e52b4bdc5033da36037c1544d013b7f12cb8d561ec954fe7469a68f1b66f1a3cd53d5a3af7293635a90d69edd15e7 binutils-2.37.tar.xz
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch
314d2ef9071c89940aa6c8118e8a1e2f191a5d0a4bf596da1ad9cc84f884d8bc7dea8bd7b9fc3f8f1bddd3fd41c6eb017e1e804044b3bf084df1ed9e6e095e2d ld-bfd-mips.patch
642c617db6c6e491f78f053d60f3aa369bad7bf8c1bc7ce267de6cf8fddf6c0d4cf63ce8c8f6e2f225dedbce7cb930d8e87e168fd8f72ca0837c77266ee2b5f8 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
b08384ed124a74ad3a424db370c107230f09a54378502ca4385deb738f7cf799857f2af0db52709c7eeab8fa6c0a3d972f891396cce1e2834a21f67682fc4355 CVE-2021-3487.patch
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch
10a0074583d2cc4598710c7e434ba7088da074b105f4f5e951fc61af7150ad62adf60a7c98f6fd13b1771f169e45a5a1ef618240c6893d3f0f3d93fd768a03c6 bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
4652f092c9376f0cb7fd6c72cb37ff7c15c1c6e3408fac79329b7f41a7925c98eb35989a9a040682130988a36401901d6d95afa44f0ce50caa85ee478db6bf03 defang-no-split.patch
"

View file

@ -1,72 +0,0 @@
From 647cebce12a6b0a26960220caff96ff38978cf24 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Thu, 26 Nov 2020 17:08:33 +0000
Subject: [PATCH] Prevent a memory allocation failure when parsing corrupt
DWARF debug sections.
PR 26946
* dwarf2.c (read_section): Check for debug sections with excessive
sizes.
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 977bf43a6a1..8bbfc81d3e7 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -531,22 +531,24 @@ read_section (bfd * abfd,
bfd_byte ** section_buffer,
bfd_size_type * section_size)
{
- asection *msec;
const char *section_name = sec->uncompressed_name;
bfd_byte *contents = *section_buffer;
- bfd_size_type amt;
/* The section may have already been read. */
if (contents == NULL)
{
+ bfd_size_type amt;
+ asection *msec;
+ ufile_ptr filesize;
+
msec = bfd_get_section_by_name (abfd, section_name);
- if (! msec)
+ if (msec == NULL)
{
section_name = sec->compressed_name;
if (section_name != NULL)
msec = bfd_get_section_by_name (abfd, section_name);
}
- if (! msec)
+ if (msec == NULL)
{
_bfd_error_handler (_("DWARF error: can't find %s section."),
sec->uncompressed_name);
@@ -554,12 +556,23 @@ read_section (bfd * abfd,
return FALSE;
}
- *section_size = msec->rawsize ? msec->rawsize : msec->size;
+ amt = bfd_get_section_limit_octets (abfd, msec);
+ filesize = bfd_get_file_size (abfd);
+ if (amt >= filesize)
+ {
+ /* PR 26946 */
+ _bfd_error_handler (_("DWARF error: section %s is larger than its filesize! (0x%lx vs 0x%lx)"),
+ section_name, (long) amt, (long) filesize);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ *section_size = amt;
/* Paranoia - alloc one extra so that we can make sure a string
section is NUL terminated. */
- amt = *section_size + 1;
+ amt += 1;
if (amt == 0)
{
+ /* Paranoia - this should never happen. */
bfd_set_error (bfd_error_no_memory);
return FALSE;
}
--
2.27.0

View file

@ -0,0 +1,234 @@
Upstream: yes
URL: https://sourceware.org/bugzilla/show_bug.cgi?id=28138
From 1c611b40e6bfc8029bff7696814330b5bc0ee5c0 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 26 Jul 2021 05:59:55 -0700
Subject: [PATCH] bfd: Close the file descriptor if there is no archive fd
Close the file descriptor if there is no archive plugin file descriptor
to avoid running out of file descriptors on thin archives with many
archive members.
bfd/
PR ld/28138
* plugin.c (bfd_plugin_close_file_descriptor): Close the file
descriptor there is no archive plugin file descriptor.
ld/
PR ld/28138
* testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for
native build.
PR ld/28138
* testsuite/ld-plugin/lto.exp: Run ld/28138 tests.
* testsuite/ld-plugin/pr28138.c: New file.
* testsuite/ld-plugin/pr28138-1.c: Likewise.
* testsuite/ld-plugin/pr28138-2.c: Likewise.
* testsuite/ld-plugin/pr28138-3.c: Likewise.
* testsuite/ld-plugin/pr28138-4.c: Likewise.
* testsuite/ld-plugin/pr28138-5.c: Likewise.
* testsuite/ld-plugin/pr28138-6.c: Likewise.
* testsuite/ld-plugin/pr28138-7.c: Likewise.
(cherry picked from commit 5a98fb7513b559e20dfebdbaa2a471afda3b4742)
(cherry picked from commit 7dc37e1e1209c80e0bab784df6b6bac335e836f2)
---
bfd/plugin.c | 8 +++++++
ld/testsuite/ld-plugin/lto.exp | 34 ++++++++++++++++++++++++++++++
ld/testsuite/ld-plugin/pr28138-1.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-2.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-3.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-4.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-5.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-6.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-7.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138.c | 20 ++++++++++++++++++
10 files changed, 104 insertions(+)
create mode 100644 ld/testsuite/ld-plugin/pr28138-1.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-2.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-3.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-4.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-5.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-6.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-7.c
create mode 100644 ld/testsuite/ld-plugin/pr28138.c
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 6cfa2b66470..3bab8febe88 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *abfd, int fd)
&& !bfd_is_thin_archive (abfd->my_archive))
abfd = abfd->my_archive;
+ /* Close the file descriptor if there is no archive plugin file
+ descriptor. */
+ if (abfd->archive_plugin_fd == -1)
+ {
+ close (fd);
+ return;
+ }
+
abfd->archive_plugin_fd_open_count--;
/* Dup the archive plugin file descriptor for later use, which
will be closed by _bfd_archive_close_and_cleanup. */
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index def69e43ab3..999d911ce6a 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_shared_available] } {
}
}
+run_cc_link_tests [list \
+ [list \
+ "Build pr28138.a" \
+ "-T" "" \
+ {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \
+ pr28138-6.c pr28138-7.c} {} "pr28138.a" \
+ ] \
+ [list \
+ "Build pr28138.o" \
+ "" "" \
+ {pr28138.c} {} \
+ ] \
+]
+
+set exec_output [run_host_cmd "sh" \
+ "-c \"ulimit -n 20; \
+ $CC -Btmpdir/ld -o tmpdir/pr28138 \
+ tmpdir/pr28138.o tmpdir/pr28138.a\""]
+set exec_output [prune_warnings $exec_output]
+if [string match "" $exec_output] then {
+ if { [isnative] } {
+ set exec_output [run_host_cmd "tmpdir/pr28138" ""]
+ if [string match "PASS" $exec_output] then {
+ pass "PR ld/28138"
+ } else {
+ fail "PR ld/28138"
+ }
+ } else {
+ pass "PR ld/28138"
+ }
+} else {
+ fail "PR ld/28138"
+}
+
set testname "Build liblto-11.a"
remote_file host delete "tmpdir/liblto-11.a"
set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
diff --git a/ld/testsuite/ld-plugin/pr28138-1.c b/ld/testsuite/ld-plugin/pr28138-1.c
new file mode 100644
index 00000000000..51d119e1642
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-1.c
@@ -0,0 +1,6 @@
+extern int a0(void);
+int
+a1(void)
+{
+ return 1 + a0();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-2.c b/ld/testsuite/ld-plugin/pr28138-2.c
new file mode 100644
index 00000000000..1120cd797e9
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-2.c
@@ -0,0 +1,6 @@
+extern int a1(void);
+int
+a2(void)
+{
+ return 1 + a1();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-3.c b/ld/testsuite/ld-plugin/pr28138-3.c
new file mode 100644
index 00000000000..ec464947ee6
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-3.c
@@ -0,0 +1,6 @@
+extern int a2(void);
+int
+a3(void)
+{
+ return 1 + a2();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-4.c b/ld/testsuite/ld-plugin/pr28138-4.c
new file mode 100644
index 00000000000..475701b2c5c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-4.c
@@ -0,0 +1,6 @@
+extern int a3(void);
+int
+a4(void)
+{
+ return 1 + a3();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-5.c b/ld/testsuite/ld-plugin/pr28138-5.c
new file mode 100644
index 00000000000..e24f86c363e
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-5.c
@@ -0,0 +1,6 @@
+extern int a4(void);
+int
+a5(void)
+{
+ return 1 + a4();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-6.c b/ld/testsuite/ld-plugin/pr28138-6.c
new file mode 100644
index 00000000000..b5b938bdb21
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-6.c
@@ -0,0 +1,6 @@
+extern int a5(void);
+int
+a6(void)
+{
+ return 1 + a5();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-7.c b/ld/testsuite/ld-plugin/pr28138-7.c
new file mode 100644
index 00000000000..4ef75bf0f0c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-7.c
@@ -0,0 +1,6 @@
+extern int a6(void);
+int
+a7(void)
+{
+ return 1 + a6();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138.c b/ld/testsuite/ld-plugin/pr28138.c
new file mode 100644
index 00000000000..68252c9f382
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+extern int a7(void);
+
+int
+a0(void)
+{
+ return 0;
+}
+
+int
+main()
+{
+ if (a7() == 7)
+ {
+ printf ("PASS\n");
+ return 0;
+ }
+ return 1;
+}
--
2.27.0

View file

@ -0,0 +1,38 @@
From 2dad02b6d46eef438cbd14d8511487b056628a38 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <siarheit@google.com>
Date: Mon, 26 Jul 2021 22:51:18 +0100
Subject: [PATCH 1/1] texi2pod.pl: add no-op --no-split option support
[PR28144]
Change 2faf902da ("generate single html manual page by default")
added use of --no-split option to makeinfo. binutils reuses
makeinfo options for texi2pod.pl wrapper. Unsupported option
led to silent manpage truncation.
The change adds no-op option support.
etc/
PR 28144
* texi2pod.pl: Handle no-op --no-split option.
(cherry picked from commit 96a7037cd8573cf065aa6b12baca68696f96d9ca)
---
etc/texi2pod.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/etc/texi2pod.pl b/etc/texi2pod.pl
index 11f70d156be..dcf2b437640 100644
--- a/etc/texi2pod.pl
+++ b/etc/texi2pod.pl
@@ -59,6 +59,8 @@ while ($_ = shift) {
$flag = shift;
}
push (@ipath, $flag);
+ } elsif (/^--no-split$/) {
+ # ignore option for makeinfo compatibility
} elsif (/^-/) {
usage();
} else {
--
2.27.0

View file

@ -1,39 +1,24 @@
From b1faf99f3e546df2cd302bb1ad36a2078224fe8b Mon Sep 17 00:00:00 2001
From bbf05b742fde518fb97c789b043fe0d3aaf549f0 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 30 Oct 2020 16:59:48 -0600
Date: Tue, 21 Sep 2021 14:53:13 +0000
Subject: [PATCH] Revert "PR25882, .gnu.attributes are not checked for shared
libraries"
This revert is needed to avoid wrongly tagging objects with the incompatible
IBM long double ABI, which is not supported by musl and will result in
linking errors if used.
This reverts commit a8acd6eeb6dc2cc5460ece90f90ebe36b56b20ba.
---
bfd/ChangeLog | 6 ------
bfd/elf32-tic6x.c | 3 ---
ld/ChangeLog | 6 ------
ld/ldlang.c | 9 ++++-----
4 files changed, 4 insertions(+), 20 deletions(-)
bfd/elf32-tic6x.c | 3 ---
ld/ldlang.c | 10 ++++------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9fac12538a..b5461494e8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1422,12 +1422,6 @@
accessing root.u.def of symbols. Also check root.u.def.section
is non-NULL. Reverse tests so as to make the logic positive.
-2020-05-01 Alan Modra <amodra@gmail.com>
-
- PR 25882
- * elf32-tic6x.c (elf32_tic6x_merge_attributes): Don't transfer
- Tag_ABI_PIC or Tag_ABI_PID from dynamic objects to the output.
-
2020-05-01 Alan Modra <amodra@gmail.com>
PR 25882
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index b8b916bfd3..91bb6a10b1 100644
index 5754f3cb860..3ad1d612749 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -3748,9 +3748,6 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
@@ -3735,9 +3735,6 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
case Tag_ABI_PIC:
case Tag_ABI_PID:
@ -43,36 +28,20 @@ index b8b916bfd3..91bb6a10b1 100644
if (out_attr[i].i > in_attr[i].i)
out_attr[i].i = in_attr[i].i;
break;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 4eec7d2977..b93452f70c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1319,12 +1319,6 @@
* testsuite/ld-aarch64/farcall-group.d: New test driver.
* testsuite/ld-aarch64/aarch64-elf.exp: Run the new test.
-2020-05-01 Alan Modra <amodra@gmail.com>
-
- PR 25882
- * ldlang.c (lang_check): Call bfd_merge_private_bfd_data for
- shared libraries.
-
2020-05-01 Alan Modra <amodra@gmail.com>
* po/BLD-POTFILES.in: Regenerate.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 9977195074..173d8ec349 100644
index 37b64c89ee1..f13beaef9d9 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -6972,12 +6972,11 @@ lang_check (void)
@@ -7071,13 +7071,11 @@ lang_check (void)
bfd_printable_name (input_bfd), input_bfd,
bfd_printable_name (link_info.output_bfd));
}
-
- /* If the input bfd has no contents, it shouldn't set the
- private data of the output bfd. */
- else if ((input_bfd->flags & DYNAMIC) != 0
- || bfd_count_sections (input_bfd) != 0)
- else if (!file->flags.just_syms
- && ((input_bfd->flags & DYNAMIC) != 0
- || bfd_count_sections (input_bfd) != 0))
+ else if (bfd_count_sections (input_bfd))
{
+ /* If the input bfd has no contents, it shouldn't set the
@ -82,5 +51,5 @@ index 9977195074..173d8ec349 100644
/* If we aren't supposed to warn about mismatched input
--
2.29.2
2.33.0

View file

@ -3,8 +3,8 @@
# Based on: main/binutils
pkgname=binutils-armhf
pkgver=2.35.2
pkgrel=2
pkgver=2.37
pkgrel=3
pkgdesc="Tools necessary to build programs for armhf targets"
url="https://www.gnu.org/software/binutils/"
makedepends="gettext libtool autoconf automake bison texinfo"
@ -15,8 +15,9 @@ source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
gold-mips.patch
ld-bfd-mips.patch
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
CVE-2021-3487.patch
binutils-mips-disable-assert.patch
bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
defang-no-split.patch
"
builddir="$srcdir/binutils-$pkgver"
@ -69,11 +70,12 @@ package() {
sha512sums="
9974ede5978d32e0d68fef23da48fa00bd06b0bff7ec45b00ca075c126d6bbe0cf2defc03ecc3f17bc6cc85b64271a13009c4049d7ba17de26e84e3a6e2c0348 binutils-2.35.2.tar.xz
5c11aeef6935860a6819ed3a3c93371f052e52b4bdc5033da36037c1544d013b7f12cb8d561ec954fe7469a68f1b66f1a3cd53d5a3af7293635a90d69edd15e7 binutils-2.37.tar.xz
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch
314d2ef9071c89940aa6c8118e8a1e2f191a5d0a4bf596da1ad9cc84f884d8bc7dea8bd7b9fc3f8f1bddd3fd41c6eb017e1e804044b3bf084df1ed9e6e095e2d ld-bfd-mips.patch
642c617db6c6e491f78f053d60f3aa369bad7bf8c1bc7ce267de6cf8fddf6c0d4cf63ce8c8f6e2f225dedbce7cb930d8e87e168fd8f72ca0837c77266ee2b5f8 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
b08384ed124a74ad3a424db370c107230f09a54378502ca4385deb738f7cf799857f2af0db52709c7eeab8fa6c0a3d972f891396cce1e2834a21f67682fc4355 CVE-2021-3487.patch
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch
10a0074583d2cc4598710c7e434ba7088da074b105f4f5e951fc61af7150ad62adf60a7c98f6fd13b1771f169e45a5a1ef618240c6893d3f0f3d93fd768a03c6 bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
4652f092c9376f0cb7fd6c72cb37ff7c15c1c6e3408fac79329b7f41a7925c98eb35989a9a040682130988a36401901d6d95afa44f0ce50caa85ee478db6bf03 defang-no-split.patch
"

View file

@ -1,72 +0,0 @@
From 647cebce12a6b0a26960220caff96ff38978cf24 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Thu, 26 Nov 2020 17:08:33 +0000
Subject: [PATCH] Prevent a memory allocation failure when parsing corrupt
DWARF debug sections.
PR 26946
* dwarf2.c (read_section): Check for debug sections with excessive
sizes.
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 977bf43a6a1..8bbfc81d3e7 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -531,22 +531,24 @@ read_section (bfd * abfd,
bfd_byte ** section_buffer,
bfd_size_type * section_size)
{
- asection *msec;
const char *section_name = sec->uncompressed_name;
bfd_byte *contents = *section_buffer;
- bfd_size_type amt;
/* The section may have already been read. */
if (contents == NULL)
{
+ bfd_size_type amt;
+ asection *msec;
+ ufile_ptr filesize;
+
msec = bfd_get_section_by_name (abfd, section_name);
- if (! msec)
+ if (msec == NULL)
{
section_name = sec->compressed_name;
if (section_name != NULL)
msec = bfd_get_section_by_name (abfd, section_name);
}
- if (! msec)
+ if (msec == NULL)
{
_bfd_error_handler (_("DWARF error: can't find %s section."),
sec->uncompressed_name);
@@ -554,12 +556,23 @@ read_section (bfd * abfd,
return FALSE;
}
- *section_size = msec->rawsize ? msec->rawsize : msec->size;
+ amt = bfd_get_section_limit_octets (abfd, msec);
+ filesize = bfd_get_file_size (abfd);
+ if (amt >= filesize)
+ {
+ /* PR 26946 */
+ _bfd_error_handler (_("DWARF error: section %s is larger than its filesize! (0x%lx vs 0x%lx)"),
+ section_name, (long) amt, (long) filesize);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ *section_size = amt;
/* Paranoia - alloc one extra so that we can make sure a string
section is NUL terminated. */
- amt = *section_size + 1;
+ amt += 1;
if (amt == 0)
{
+ /* Paranoia - this should never happen. */
bfd_set_error (bfd_error_no_memory);
return FALSE;
}
--
2.27.0

View file

@ -0,0 +1,234 @@
Upstream: yes
URL: https://sourceware.org/bugzilla/show_bug.cgi?id=28138
From 1c611b40e6bfc8029bff7696814330b5bc0ee5c0 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 26 Jul 2021 05:59:55 -0700
Subject: [PATCH] bfd: Close the file descriptor if there is no archive fd
Close the file descriptor if there is no archive plugin file descriptor
to avoid running out of file descriptors on thin archives with many
archive members.
bfd/
PR ld/28138
* plugin.c (bfd_plugin_close_file_descriptor): Close the file
descriptor there is no archive plugin file descriptor.
ld/
PR ld/28138
* testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for
native build.
PR ld/28138
* testsuite/ld-plugin/lto.exp: Run ld/28138 tests.
* testsuite/ld-plugin/pr28138.c: New file.
* testsuite/ld-plugin/pr28138-1.c: Likewise.
* testsuite/ld-plugin/pr28138-2.c: Likewise.
* testsuite/ld-plugin/pr28138-3.c: Likewise.
* testsuite/ld-plugin/pr28138-4.c: Likewise.
* testsuite/ld-plugin/pr28138-5.c: Likewise.
* testsuite/ld-plugin/pr28138-6.c: Likewise.
* testsuite/ld-plugin/pr28138-7.c: Likewise.
(cherry picked from commit 5a98fb7513b559e20dfebdbaa2a471afda3b4742)
(cherry picked from commit 7dc37e1e1209c80e0bab784df6b6bac335e836f2)
---
bfd/plugin.c | 8 +++++++
ld/testsuite/ld-plugin/lto.exp | 34 ++++++++++++++++++++++++++++++
ld/testsuite/ld-plugin/pr28138-1.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-2.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-3.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-4.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-5.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-6.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-7.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138.c | 20 ++++++++++++++++++
10 files changed, 104 insertions(+)
create mode 100644 ld/testsuite/ld-plugin/pr28138-1.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-2.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-3.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-4.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-5.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-6.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-7.c
create mode 100644 ld/testsuite/ld-plugin/pr28138.c
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 6cfa2b66470..3bab8febe88 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *abfd, int fd)
&& !bfd_is_thin_archive (abfd->my_archive))
abfd = abfd->my_archive;
+ /* Close the file descriptor if there is no archive plugin file
+ descriptor. */
+ if (abfd->archive_plugin_fd == -1)
+ {
+ close (fd);
+ return;
+ }
+
abfd->archive_plugin_fd_open_count--;
/* Dup the archive plugin file descriptor for later use, which
will be closed by _bfd_archive_close_and_cleanup. */
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index def69e43ab3..999d911ce6a 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_shared_available] } {
}
}
+run_cc_link_tests [list \
+ [list \
+ "Build pr28138.a" \
+ "-T" "" \
+ {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \
+ pr28138-6.c pr28138-7.c} {} "pr28138.a" \
+ ] \
+ [list \
+ "Build pr28138.o" \
+ "" "" \
+ {pr28138.c} {} \
+ ] \
+]
+
+set exec_output [run_host_cmd "sh" \
+ "-c \"ulimit -n 20; \
+ $CC -Btmpdir/ld -o tmpdir/pr28138 \
+ tmpdir/pr28138.o tmpdir/pr28138.a\""]
+set exec_output [prune_warnings $exec_output]
+if [string match "" $exec_output] then {
+ if { [isnative] } {
+ set exec_output [run_host_cmd "tmpdir/pr28138" ""]
+ if [string match "PASS" $exec_output] then {
+ pass "PR ld/28138"
+ } else {
+ fail "PR ld/28138"
+ }
+ } else {
+ pass "PR ld/28138"
+ }
+} else {
+ fail "PR ld/28138"
+}
+
set testname "Build liblto-11.a"
remote_file host delete "tmpdir/liblto-11.a"
set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
diff --git a/ld/testsuite/ld-plugin/pr28138-1.c b/ld/testsuite/ld-plugin/pr28138-1.c
new file mode 100644
index 00000000000..51d119e1642
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-1.c
@@ -0,0 +1,6 @@
+extern int a0(void);
+int
+a1(void)
+{
+ return 1 + a0();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-2.c b/ld/testsuite/ld-plugin/pr28138-2.c
new file mode 100644
index 00000000000..1120cd797e9
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-2.c
@@ -0,0 +1,6 @@
+extern int a1(void);
+int
+a2(void)
+{
+ return 1 + a1();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-3.c b/ld/testsuite/ld-plugin/pr28138-3.c
new file mode 100644
index 00000000000..ec464947ee6
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-3.c
@@ -0,0 +1,6 @@
+extern int a2(void);
+int
+a3(void)
+{
+ return 1 + a2();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-4.c b/ld/testsuite/ld-plugin/pr28138-4.c
new file mode 100644
index 00000000000..475701b2c5c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-4.c
@@ -0,0 +1,6 @@
+extern int a3(void);
+int
+a4(void)
+{
+ return 1 + a3();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-5.c b/ld/testsuite/ld-plugin/pr28138-5.c
new file mode 100644
index 00000000000..e24f86c363e
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-5.c
@@ -0,0 +1,6 @@
+extern int a4(void);
+int
+a5(void)
+{
+ return 1 + a4();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-6.c b/ld/testsuite/ld-plugin/pr28138-6.c
new file mode 100644
index 00000000000..b5b938bdb21
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-6.c
@@ -0,0 +1,6 @@
+extern int a5(void);
+int
+a6(void)
+{
+ return 1 + a5();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-7.c b/ld/testsuite/ld-plugin/pr28138-7.c
new file mode 100644
index 00000000000..4ef75bf0f0c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-7.c
@@ -0,0 +1,6 @@
+extern int a6(void);
+int
+a7(void)
+{
+ return 1 + a6();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138.c b/ld/testsuite/ld-plugin/pr28138.c
new file mode 100644
index 00000000000..68252c9f382
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+extern int a7(void);
+
+int
+a0(void)
+{
+ return 0;
+}
+
+int
+main()
+{
+ if (a7() == 7)
+ {
+ printf ("PASS\n");
+ return 0;
+ }
+ return 1;
+}
--
2.27.0

View file

@ -0,0 +1,38 @@
From 2dad02b6d46eef438cbd14d8511487b056628a38 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <siarheit@google.com>
Date: Mon, 26 Jul 2021 22:51:18 +0100
Subject: [PATCH 1/1] texi2pod.pl: add no-op --no-split option support
[PR28144]
Change 2faf902da ("generate single html manual page by default")
added use of --no-split option to makeinfo. binutils reuses
makeinfo options for texi2pod.pl wrapper. Unsupported option
led to silent manpage truncation.
The change adds no-op option support.
etc/
PR 28144
* texi2pod.pl: Handle no-op --no-split option.
(cherry picked from commit 96a7037cd8573cf065aa6b12baca68696f96d9ca)
---
etc/texi2pod.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/etc/texi2pod.pl b/etc/texi2pod.pl
index 11f70d156be..dcf2b437640 100644
--- a/etc/texi2pod.pl
+++ b/etc/texi2pod.pl
@@ -59,6 +59,8 @@ while ($_ = shift) {
$flag = shift;
}
push (@ipath, $flag);
+ } elsif (/^--no-split$/) {
+ # ignore option for makeinfo compatibility
} elsif (/^-/) {
usage();
} else {
--
2.27.0

View file

@ -1,39 +1,24 @@
From b1faf99f3e546df2cd302bb1ad36a2078224fe8b Mon Sep 17 00:00:00 2001
From bbf05b742fde518fb97c789b043fe0d3aaf549f0 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 30 Oct 2020 16:59:48 -0600
Date: Tue, 21 Sep 2021 14:53:13 +0000
Subject: [PATCH] Revert "PR25882, .gnu.attributes are not checked for shared
libraries"
This revert is needed to avoid wrongly tagging objects with the incompatible
IBM long double ABI, which is not supported by musl and will result in
linking errors if used.
This reverts commit a8acd6eeb6dc2cc5460ece90f90ebe36b56b20ba.
---
bfd/ChangeLog | 6 ------
bfd/elf32-tic6x.c | 3 ---
ld/ChangeLog | 6 ------
ld/ldlang.c | 9 ++++-----
4 files changed, 4 insertions(+), 20 deletions(-)
bfd/elf32-tic6x.c | 3 ---
ld/ldlang.c | 10 ++++------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9fac12538a..b5461494e8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1422,12 +1422,6 @@
accessing root.u.def of symbols. Also check root.u.def.section
is non-NULL. Reverse tests so as to make the logic positive.
-2020-05-01 Alan Modra <amodra@gmail.com>
-
- PR 25882
- * elf32-tic6x.c (elf32_tic6x_merge_attributes): Don't transfer
- Tag_ABI_PIC or Tag_ABI_PID from dynamic objects to the output.
-
2020-05-01 Alan Modra <amodra@gmail.com>
PR 25882
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index b8b916bfd3..91bb6a10b1 100644
index 5754f3cb860..3ad1d612749 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -3748,9 +3748,6 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
@@ -3735,9 +3735,6 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
case Tag_ABI_PIC:
case Tag_ABI_PID:
@ -43,36 +28,20 @@ index b8b916bfd3..91bb6a10b1 100644
if (out_attr[i].i > in_attr[i].i)
out_attr[i].i = in_attr[i].i;
break;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 4eec7d2977..b93452f70c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1319,12 +1319,6 @@
* testsuite/ld-aarch64/farcall-group.d: New test driver.
* testsuite/ld-aarch64/aarch64-elf.exp: Run the new test.
-2020-05-01 Alan Modra <amodra@gmail.com>
-
- PR 25882
- * ldlang.c (lang_check): Call bfd_merge_private_bfd_data for
- shared libraries.
-
2020-05-01 Alan Modra <amodra@gmail.com>
* po/BLD-POTFILES.in: Regenerate.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 9977195074..173d8ec349 100644
index 37b64c89ee1..f13beaef9d9 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -6972,12 +6972,11 @@ lang_check (void)
@@ -7071,13 +7071,11 @@ lang_check (void)
bfd_printable_name (input_bfd), input_bfd,
bfd_printable_name (link_info.output_bfd));
}
-
- /* If the input bfd has no contents, it shouldn't set the
- private data of the output bfd. */
- else if ((input_bfd->flags & DYNAMIC) != 0
- || bfd_count_sections (input_bfd) != 0)
- else if (!file->flags.just_syms
- && ((input_bfd->flags & DYNAMIC) != 0
- || bfd_count_sections (input_bfd) != 0))
+ else if (bfd_count_sections (input_bfd))
{
+ /* If the input bfd has no contents, it shouldn't set the
@ -82,5 +51,5 @@ index 9977195074..173d8ec349 100644
/* If we aren't supposed to warn about mismatched input
--
2.29.2
2.33.0

View file

@ -3,8 +3,8 @@
# Based on: main/binutils
pkgname=binutils-armv7
pkgver=2.35.2
pkgrel=2
pkgver=2.37
pkgrel=3
pkgdesc="Tools necessary to build programs for armv7 targets"
url="https://www.gnu.org/software/binutils/"
makedepends="gettext libtool autoconf automake bison texinfo"
@ -15,8 +15,9 @@ source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz
gold-mips.patch
ld-bfd-mips.patch
0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
CVE-2021-3487.patch
binutils-mips-disable-assert.patch
bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
defang-no-split.patch
"
builddir="$srcdir/binutils-$pkgver"
@ -69,11 +70,12 @@ package() {
sha512sums="
9974ede5978d32e0d68fef23da48fa00bd06b0bff7ec45b00ca075c126d6bbe0cf2defc03ecc3f17bc6cc85b64271a13009c4049d7ba17de26e84e3a6e2c0348 binutils-2.35.2.tar.xz
5c11aeef6935860a6819ed3a3c93371f052e52b4bdc5033da36037c1544d013b7f12cb8d561ec954fe7469a68f1b66f1a3cd53d5a3af7293635a90d69edd15e7 binutils-2.37.tar.xz
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch
314d2ef9071c89940aa6c8118e8a1e2f191a5d0a4bf596da1ad9cc84f884d8bc7dea8bd7b9fc3f8f1bddd3fd41c6eb017e1e804044b3bf084df1ed9e6e095e2d ld-bfd-mips.patch
642c617db6c6e491f78f053d60f3aa369bad7bf8c1bc7ce267de6cf8fddf6c0d4cf63ce8c8f6e2f225dedbce7cb930d8e87e168fd8f72ca0837c77266ee2b5f8 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
b08384ed124a74ad3a424db370c107230f09a54378502ca4385deb738f7cf799857f2af0db52709c7eeab8fa6c0a3d972f891396cce1e2834a21f67682fc4355 CVE-2021-3487.patch
70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch
609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch
10a0074583d2cc4598710c7e434ba7088da074b105f4f5e951fc61af7150ad62adf60a7c98f6fd13b1771f169e45a5a1ef618240c6893d3f0f3d93fd768a03c6 bfd-close-file-desriptor-if-there-is-no-archive-fd.patch
4652f092c9376f0cb7fd6c72cb37ff7c15c1c6e3408fac79329b7f41a7925c98eb35989a9a040682130988a36401901d6d95afa44f0ce50caa85ee478db6bf03 defang-no-split.patch
"

View file

@ -1,72 +0,0 @@
From 647cebce12a6b0a26960220caff96ff38978cf24 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Thu, 26 Nov 2020 17:08:33 +0000
Subject: [PATCH] Prevent a memory allocation failure when parsing corrupt
DWARF debug sections.
PR 26946
* dwarf2.c (read_section): Check for debug sections with excessive
sizes.
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 977bf43a6a1..8bbfc81d3e7 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -531,22 +531,24 @@ read_section (bfd * abfd,
bfd_byte ** section_buffer,
bfd_size_type * section_size)
{
- asection *msec;
const char *section_name = sec->uncompressed_name;
bfd_byte *contents = *section_buffer;
- bfd_size_type amt;
/* The section may have already been read. */
if (contents == NULL)
{
+ bfd_size_type amt;
+ asection *msec;
+ ufile_ptr filesize;
+
msec = bfd_get_section_by_name (abfd, section_name);
- if (! msec)
+ if (msec == NULL)
{
section_name = sec->compressed_name;
if (section_name != NULL)
msec = bfd_get_section_by_name (abfd, section_name);
}
- if (! msec)
+ if (msec == NULL)
{
_bfd_error_handler (_("DWARF error: can't find %s section."),
sec->uncompressed_name);
@@ -554,12 +556,23 @@ read_section (bfd * abfd,
return FALSE;
}
- *section_size = msec->rawsize ? msec->rawsize : msec->size;
+ amt = bfd_get_section_limit_octets (abfd, msec);
+ filesize = bfd_get_file_size (abfd);
+ if (amt >= filesize)
+ {
+ /* PR 26946 */
+ _bfd_error_handler (_("DWARF error: section %s is larger than its filesize! (0x%lx vs 0x%lx)"),
+ section_name, (long) amt, (long) filesize);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ *section_size = amt;
/* Paranoia - alloc one extra so that we can make sure a string
section is NUL terminated. */
- amt = *section_size + 1;
+ amt += 1;
if (amt == 0)
{
+ /* Paranoia - this should never happen. */
bfd_set_error (bfd_error_no_memory);
return FALSE;
}
--
2.27.0

View file

@ -0,0 +1,234 @@
Upstream: yes
URL: https://sourceware.org/bugzilla/show_bug.cgi?id=28138
From 1c611b40e6bfc8029bff7696814330b5bc0ee5c0 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 26 Jul 2021 05:59:55 -0700
Subject: [PATCH] bfd: Close the file descriptor if there is no archive fd
Close the file descriptor if there is no archive plugin file descriptor
to avoid running out of file descriptors on thin archives with many
archive members.
bfd/
PR ld/28138
* plugin.c (bfd_plugin_close_file_descriptor): Close the file
descriptor there is no archive plugin file descriptor.
ld/
PR ld/28138
* testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for
native build.
PR ld/28138
* testsuite/ld-plugin/lto.exp: Run ld/28138 tests.
* testsuite/ld-plugin/pr28138.c: New file.
* testsuite/ld-plugin/pr28138-1.c: Likewise.
* testsuite/ld-plugin/pr28138-2.c: Likewise.
* testsuite/ld-plugin/pr28138-3.c: Likewise.
* testsuite/ld-plugin/pr28138-4.c: Likewise.
* testsuite/ld-plugin/pr28138-5.c: Likewise.
* testsuite/ld-plugin/pr28138-6.c: Likewise.
* testsuite/ld-plugin/pr28138-7.c: Likewise.
(cherry picked from commit 5a98fb7513b559e20dfebdbaa2a471afda3b4742)
(cherry picked from commit 7dc37e1e1209c80e0bab784df6b6bac335e836f2)
---
bfd/plugin.c | 8 +++++++
ld/testsuite/ld-plugin/lto.exp | 34 ++++++++++++++++++++++++++++++
ld/testsuite/ld-plugin/pr28138-1.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-2.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-3.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-4.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-5.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-6.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138-7.c | 6 ++++++
ld/testsuite/ld-plugin/pr28138.c | 20 ++++++++++++++++++
10 files changed, 104 insertions(+)
create mode 100644 ld/testsuite/ld-plugin/pr28138-1.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-2.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-3.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-4.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-5.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-6.c
create mode 100644 ld/testsuite/ld-plugin/pr28138-7.c
create mode 100644 ld/testsuite/ld-plugin/pr28138.c
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 6cfa2b66470..3bab8febe88 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *abfd, int fd)
&& !bfd_is_thin_archive (abfd->my_archive))
abfd = abfd->my_archive;
+ /* Close the file descriptor if there is no archive plugin file
+ descriptor. */
+ if (abfd->archive_plugin_fd == -1)
+ {
+ close (fd);
+ return;
+ }
+
abfd->archive_plugin_fd_open_count--;
/* Dup the archive plugin file descriptor for later use, which
will be closed by _bfd_archive_close_and_cleanup. */
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index def69e43ab3..999d911ce6a 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_shared_available] } {
}
}
+run_cc_link_tests [list \
+ [list \
+ "Build pr28138.a" \
+ "-T" "" \
+ {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \
+ pr28138-6.c pr28138-7.c} {} "pr28138.a" \
+ ] \
+ [list \
+ "Build pr28138.o" \
+ "" "" \
+ {pr28138.c} {} \
+ ] \
+]
+
+set exec_output [run_host_cmd "sh" \
+ "-c \"ulimit -n 20; \
+ $CC -Btmpdir/ld -o tmpdir/pr28138 \
+ tmpdir/pr28138.o tmpdir/pr28138.a\""]
+set exec_output [prune_warnings $exec_output]
+if [string match "" $exec_output] then {
+ if { [isnative] } {
+ set exec_output [run_host_cmd "tmpdir/pr28138" ""]
+ if [string match "PASS" $exec_output] then {
+ pass "PR ld/28138"
+ } else {
+ fail "PR ld/28138"
+ }
+ } else {
+ pass "PR ld/28138"
+ }
+} else {
+ fail "PR ld/28138"
+}
+
set testname "Build liblto-11.a"
remote_file host delete "tmpdir/liblto-11.a"
set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
diff --git a/ld/testsuite/ld-plugin/pr28138-1.c b/ld/testsuite/ld-plugin/pr28138-1.c
new file mode 100644
index 00000000000..51d119e1642
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-1.c
@@ -0,0 +1,6 @@
+extern int a0(void);
+int
+a1(void)
+{
+ return 1 + a0();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-2.c b/ld/testsuite/ld-plugin/pr28138-2.c
new file mode 100644
index 00000000000..1120cd797e9
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-2.c
@@ -0,0 +1,6 @@
+extern int a1(void);
+int
+a2(void)
+{
+ return 1 + a1();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-3.c b/ld/testsuite/ld-plugin/pr28138-3.c
new file mode 100644
index 00000000000..ec464947ee6
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-3.c
@@ -0,0 +1,6 @@
+extern int a2(void);
+int
+a3(void)
+{
+ return 1 + a2();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-4.c b/ld/testsuite/ld-plugin/pr28138-4.c
new file mode 100644
index 00000000000..475701b2c5c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-4.c
@@ -0,0 +1,6 @@
+extern int a3(void);
+int
+a4(void)
+{
+ return 1 + a3();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-5.c b/ld/testsuite/ld-plugin/pr28138-5.c
new file mode 100644
index 00000000000..e24f86c363e
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-5.c
@@ -0,0 +1,6 @@
+extern int a4(void);
+int
+a5(void)
+{
+ return 1 + a4();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-6.c b/ld/testsuite/ld-plugin/pr28138-6.c
new file mode 100644
index 00000000000..b5b938bdb21
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-6.c
@@ -0,0 +1,6 @@
+extern int a5(void);
+int
+a6(void)
+{
+ return 1 + a5();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-7.c b/ld/testsuite/ld-plugin/pr28138-7.c
new file mode 100644
index 00000000000..4ef75bf0f0c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-7.c
@@ -0,0 +1,6 @@
+extern int a6(void);
+int
+a7(void)
+{
+ return 1 + a6();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138.c b/ld/testsuite/ld-plugin/pr28138.c
new file mode 100644
index 00000000000..68252c9f382
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+extern int a7(void);
+
+int
+a0(void)
+{
+ return 0;
+}
+
+int
+main()
+{
+ if (a7() == 7)
+ {
+ printf ("PASS\n");
+ return 0;
+ }
+ return 1;
+}
--
2.27.0

View file

@ -0,0 +1,38 @@
From 2dad02b6d46eef438cbd14d8511487b056628a38 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <siarheit@google.com>
Date: Mon, 26 Jul 2021 22:51:18 +0100
Subject: [PATCH 1/1] texi2pod.pl: add no-op --no-split option support
[PR28144]
Change 2faf902da ("generate single html manual page by default")
added use of --no-split option to makeinfo. binutils reuses
makeinfo options for texi2pod.pl wrapper. Unsupported option
led to silent manpage truncation.
The change adds no-op option support.
etc/
PR 28144
* texi2pod.pl: Handle no-op --no-split option.
(cherry picked from commit 96a7037cd8573cf065aa6b12baca68696f96d9ca)
---
etc/texi2pod.pl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/etc/texi2pod.pl b/etc/texi2pod.pl
index 11f70d156be..dcf2b437640 100644
--- a/etc/texi2pod.pl
+++ b/etc/texi2pod.pl
@@ -59,6 +59,8 @@ while ($_ = shift) {
$flag = shift;
}
push (@ipath, $flag);
+ } elsif (/^--no-split$/) {
+ # ignore option for makeinfo compatibility
} elsif (/^-/) {
usage();
} else {
--
2.27.0