Increase number of file descriptors available to plugins. (#1918924)

Remove uses of RPATH.
This commit is contained in:
Nick Clifton 2021-05-27 10:44:25 +01:00
parent 284ad2a04b
commit a4b106ec38
2 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,40 @@
diff -rup binutils.orig/bfd/plugin.c binutils-2.36.1/bfd/plugin.c
--- binutils.orig/bfd/plugin.c 2021-05-24 11:35:17.208423540 +0100
+++ binutils-2.36.1/bfd/plugin.c 2021-05-24 11:35:29.419349585 +0100
@@ -209,7 +209,35 @@ bfd_plugin_open_input (bfd *ibfd, struct
the same underlying file descriptor. */
file->fd = open (file->name, O_RDONLY | O_BINARY);
if (file->fd < 0)
- return 0;
+ {
+#ifndef EMFILE
+ return 0;
+#else
+ if (errno != EMFILE)
+ return 0;
+
+#ifdef HAVE_GETRLIMIT
+ struct rlimit lim;
+
+ /* Complicated links involving lots of files and/or large archives
+ can exhaust the number of file descriptors available to us.
+ If possible, try to allocate more descriptors. */
+ if (getrlimit (RLIMIT_NOFILE, & lim) == 0
+ && lim.rlim_cur < lim.rlim_max)
+ {
+ lim.rlim_cur = lim.rlim_max;
+ if (setrlimit (RLIMIT_NOFILE, &lim) == 0)
+ file->fd = open (file->name, O_RDONLY | O_BINARY);
+ }
+
+ if (file->fd < 0)
+#endif
+ {
+ _bfd_error_handler (_("plugin framework: out of file descriptors. Try using fewer objects/archives\n"));
+ return 0;
+ }
+#endif
+ }
if (iobfd == ibfd)
{

View File

@ -39,7 +39,7 @@
Summary: A GNU collection of binary utilities
Name: binutils%{?name_cross}%{?_with_debug:-debug}
Version: 2.36.1
Release: 12%{?dist}
Release: 13%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -281,6 +281,10 @@ Patch21: binutils-CVE-2021-3530.patch
# Lifetime: Fixed in 2.37
Patch22: binutils-ppc-weak-undefined-plt-relocs.patch
# Purpose: Increase the number of file descriptors available to plugins
# Lifetime: Fixed in 2.37
Patch23: binutils-plugin-file-descriptors.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -486,6 +490,12 @@ export CFLAGS="$CFLAGS -O0 -ggdb2 -Wno-error -D_FORTIFY_SOURCE=0"
%define _with_cc_clang 1
%endif
# BZ 1541027 - include the linker flags from redhat-rpm-config as well.
export LDFLAGS=$RPM_LD_FLAGS
%if %{enable_new_dtags}
export LDFLAGS="$LD_FLAGS -Wl,--enable-new-dtags"
%endif
CARGS=
%if %{with debuginfod}
@ -577,6 +587,7 @@ popd
%endif
%if %{enable_new_dtags}
--enable-new-dtags \
--disable-rpath \
%endif
%if %{default_compress_debug}
--enable-compressed-debug-sections=all \
@ -862,6 +873,10 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Tue May 18 2021 Nick Clifton <nickc@redhat.com> - 2.36.1-13
- Increase number of file descriptors available to plugins. (#1918924)
- Remove uses of RPATH.
* Tue May 18 2021 Nick Clifton <nickc@redhat.com> - 2.36.1-12
- Generate PLT relocs for weak undefined PPC function symbols. (#1960730)