From e2daa49642b0034b49c48bf32f19df1a45a2d4fc Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 30 Jul 2021 10:07:27 +0300 Subject: [PATCH] binutils: fix #303 --- core/binutils/build | 2 ++ core/binutils/checksums | 1 + core/binutils/patches/fix-fd-issue.patch | 39 ++++++++++++++++++++++++ core/binutils/sources | 1 + core/binutils/version | 2 +- 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 core/binutils/patches/fix-fd-issue.patch diff --git a/core/binutils/build b/core/binutils/build index 2cdb8b24..2c2c5e1f 100755 --- a/core/binutils/build +++ b/core/binutils/build @@ -1,5 +1,7 @@ #!/bin/sh -e +patch -p1 < fix-fd-issue.patch + cat > makeinfo < +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. + +(cherry picked from commit 5a98fb7513b559e20dfebdbaa2a471afda3b4742) +(cherry picked from commit 7dc37e1e1209c80e0bab784df6b6bac335e836f2) +--- + bfd/plugin.c | 8 +++++++ + +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/core/binutils/sources b/core/binutils/sources index bf13052d..e5befec0 100644 --- a/core/binutils/sources +++ b/core/binutils/sources @@ -1 +1,2 @@ https://ftp.gnu.org/gnu/binutils/binutils-VERSION.tar.xz +patches/fix-fd-issue.patch diff --git a/core/binutils/version b/core/binutils/version index c304d360..a3a0f409 100644 --- a/core/binutils/version +++ b/core/binutils/version @@ -1 +1 @@ -2.37 1 +2.37 2