public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/binutils] rawhide: Yet another attempt to remove global static variables from libbfd.so.  (#2564442)
@ 2026-11-09 12:22 Nick Clifton
  0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2026-11-09 12:22 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/binutils
Branch : rawhide
Commit : e6cc0a7cc39c4251c54299b7414a99691a83c44e
Author : Nick Clifton <nickc@redhat.com>
Date   : 2026-11-09T12:22:23+00:00
Stats  : +21/-268 in 3 file(s)
URL    : https://src.fedoraproject.org/rpms/binutils/c/e6cc0a7cc39c4251c54299b7414a99691a83c44e?branch=rawhide

Log:
Yet another attempt to remove global static variables from libbfd.so.  (#2564442)

---
diff --git a/binutils-hide-global-symbols.patch b/binutils-hide-global-symbols.patch
new file mode 100644
index 0000000..ccd704e
--- /dev/null
+++ b/binutils-hide-global-symbols.patch
@@ -0,0 +1,14 @@
+diff -rup orig/bfd/bfd.c binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c
+--- orig/bfd/bfd.c	2026-11-09 10:11:35.396075783 +0000
++++ binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c	2026-11-09 10:25:51.698227198 +0000
+@@ -852,8 +852,8 @@ const char *const bfd_errmsgs[] =
+   N_("#<invalid error code>")
+ };
+ 
+-static THREAD_LOCAL bfd_error_type bfd_error;
+-static THREAD_LOCAL char *_bfd_error_buf;
++static THREAD_LOCAL bfd_error_type  bfd_error ATTRIBUTE_HIDDEN;
++static THREAD_LOCAL char *          _bfd_error_buf ATTRIBUTE_HIDDEN;
+ 
+ /* Free any data associated with the BFD error.  */
+ 

diff --git a/binutils-no-static-globals-in-libbfd.so.patch b/binutils-no-static-globals-in-libbfd.so.patch
deleted file mode 100644
index 424f3d7..0000000
--- a/binutils-no-static-globals-in-libbfd.so.patch
+++ /dev/null
@@ -1,265 +0,0 @@
-diff -rup orig/bfd/bfd.c binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c
---- orig/bfd/bfd.c	2026-11-02 13:48:46.966876451 +0000
-+++ binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c	2026-11-02 13:54:44.043119048 +0000
-@@ -852,7 +852,16 @@ const char *const bfd_errmsgs[] =
-   N_("#<invalid error code>")
- };
- 
--static THREAD_LOCAL bfd_error_type bfd_error;
-+static inline bfd_error_type
-+get_set_bfd_error (bfd_error_type e)
-+{
-+  static THREAD_LOCAL bfd_error_type bfd_error;
-+
-+  if (e != bfd_error_invalid_error_code)
-+    bfd_error = e;
-+  return bfd_error;
-+}
-+
- static THREAD_LOCAL char *_bfd_error_buf;
- 
- /* Free any data associated with the BFD error.  */
-@@ -860,7 +869,7 @@ static THREAD_LOCAL char *_bfd_error_buf
- static void
- _bfd_clear_error_data (void)
- {
--  bfd_error = bfd_error_no_error;
-+  (void) get_set_bfd_error (bfd_error_no_error);
-   free (_bfd_error_buf);
-   _bfd_error_buf = NULL;
- }
-@@ -899,8 +908,7 @@ DESCRIPTION
- void
- bfd_set_error (bfd_error_type error_tag)
- {
--  bfd_error = error_tag;
--  if (bfd_error >= bfd_error_on_input)
-+  if (get_set_bfd_error (error_tag) >= bfd_error_on_input)
-     abort ();
- }
- 
-@@ -928,7 +936,7 @@ bfd_set_input_error (bfd *input, bfd_err
-     abort ();
-   if (bfd_asprintf (_(bfd_errmsgs[bfd_error_on_input]),
- 		    bfd_get_filename (input), bfd_errmsg (error_tag)))
--    bfd_error = bfd_error_on_input;
-+    (void) get_set_bfd_error (bfd_error_on_input);
- }
- 
- /*
---- orig/bfd/bfd.c	2026-11-02 14:47:59.337099974 +0000
-+++ binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c	2026-11-02 14:48:46.814280770 +0000
-@@ -888,7 +888,7 @@ DESCRIPTION
- bfd_error_type
- bfd_get_error (void)
- {
--  return bfd_error;
-+  return get_set_bfd_error (bfd_error_invalid_error_code);
- }
- 
- /*
---- orig/bfd/bfd.c	2026-11-02 15:06:50.572575618 +0000
-+++ binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c	2026-11-02 15:07:51.815784835 +0000
-@@ -852,14 +852,14 @@ const char *const bfd_errmsgs[] =
-   N_("#<invalid error code>")
- };
- 
-+static THREAD_LOCAL bfd_error_type local_bfd_error;
-+
- static inline bfd_error_type
- get_set_bfd_error (bfd_error_type e)
- {
--  static THREAD_LOCAL bfd_error_type bfd_error;
--
-   if (e != bfd_error_invalid_error_code)
--    bfd_error = e;
--  return bfd_error;
-+    local_bfd_error = e;
-+  return local_bfd_error;
- }
- 
- static THREAD_LOCAL char *_bfd_error_buf;
-diff -rup orig/bfd/bfd.c binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c
---- orig/bfd/bfd.c	2026-11-05 09:50:11.390674033 +0000
-+++ binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c	2026-11-05 09:51:22.915859845 +0000
-@@ -852,11 +852,11 @@ const char *const bfd_errmsgs[] =
-   N_("#<invalid error code>")
- };
- 
--static THREAD_LOCAL bfd_error_type local_bfd_error;
--
- static inline bfd_error_type
- get_set_bfd_error (bfd_error_type e)
- {
-+  static THREAD_LOCAL bfd_error_type local_bfd_error;
-+
-   if (e != bfd_error_invalid_error_code)
-     local_bfd_error = e;
-   return local_bfd_error;
-diff -rup orig/bfd/bfd.c binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c
---- orig/bfd/bfd.c	2026-11-05 10:28:02.895308077 +0000
-+++ binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c	2026-11-05 10:30:30.643100505 +0000
-@@ -855,11 +855,11 @@ const char *const bfd_errmsgs[] =
- static inline bfd_error_type
- get_set_bfd_error (bfd_error_type e)
- {
--  static THREAD_LOCAL bfd_error_type local_bfd_error;
-+  static bfd_error_type _local_bfd_error;
- 
-   if (e != bfd_error_invalid_error_code)
--    local_bfd_error = e;
--  return local_bfd_error;
-+    _local_bfd_error = e;
-+  return _local_bfd_error;
- }
- 
- static THREAD_LOCAL char *_bfd_error_buf;
-diff -rup orig/bfd/bfd.c binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c
---- orig/bfd/bfd.c	2026-11-06 09:33:24.708778732 +0000
-+++ binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c	2026-11-06 09:46:04.391800265 +0000
-@@ -756,12 +756,6 @@ EXTERNAL
- #define EXIT_FAILURE 1
- #endif
- 
--#ifdef TLS
--#define THREAD_LOCAL TLS
--#else
--#define THREAD_LOCAL
--#endif
--
- \f
- /* provide storage for subsystem, stack and heap data which may have been
-    passed in on the command line.  Ld puts this data into a bfd_link_info
-@@ -862,7 +856,15 @@ get_set_bfd_error (bfd_error_type e)
-   return _local_bfd_error;
- }
- 
--static THREAD_LOCAL char *_bfd_error_buf;
-+static inline char *
-+get_set_bfd_error_buf (char * ptr, bool set)
-+{
-+  static char *_local_bfd_error_buf;
-+  if (set)
-+    _local_bfd_error_buf = ptr;
-+  return _local_bfd_error_buf;
-+}
-+    
- 
- /* Free any data associated with the BFD error.  */
- 
-@@ -870,8 +872,11 @@ static void
- _bfd_clear_error_data (void)
- {
-   (void) get_set_bfd_error (bfd_error_no_error);
--  free (_bfd_error_buf);
--  _bfd_error_buf = NULL;
-+
-+  char * buf = get_set_bfd_error_buf (NULL, false);
-+  if (buf != NULL)
-+    free (buf);
-+  (void) get_set_bfd_error_buf (NULL, true);
- }
- 
- /*
-@@ -958,7 +963,7 @@ bfd_errmsg (bfd_error_type error_tag)
-   extern int errno;
- #endif
-   if (error_tag == bfd_error_on_input)
--    return _bfd_error_buf;
-+    return get_set_bfd_error_buf (NULL, false);
- 
-   if (error_tag == bfd_error_system_call)
-     return xstrerror (errno);
-@@ -1015,18 +1020,20 @@ DESCRIPTION
- char *
- bfd_asprintf (const char *fmt, ...)
- {
--  free (_bfd_error_buf);
--  _bfd_error_buf = NULL;
-+  char * buf = get_set_bfd_error_buf (NULL, false);
-+  if (buf != NULL)
-+    free (buf);
-+
-   va_list ap;
-   va_start (ap, fmt);
--  int count = vasprintf (&_bfd_error_buf, fmt, ap);
-+  int count = vasprintf (&buf, fmt, ap);
-   va_end (ap);
-   if (count == -1)
-     {
-       bfd_set_error (bfd_error_no_memory);
--      _bfd_error_buf = NULL;
-+      buf = NULL;
-     }
--  return _bfd_error_buf;
-+  return get_set_bfd_error_buf (buf, true);
- }
- 
- /*
-@@ -1740,7 +1747,14 @@ _bfd_per_xvec_warn (struct per_xvec_mess
-    error_handler_sprintf; when NULL, _bfd_error_internal will be used
-    instead.  */
- 
--static THREAD_LOCAL struct per_xvec_messages *error_handler_messages;
-+static inline struct per_xvec_messages *
-+get_set_error_handler_messages (struct per_xvec_messages * messages, bool set)
-+{
-+  static struct per_xvec_messages * _error_handler_messages;
-+  if (set)
-+    _error_handler_messages = messages;
-+  return _error_handler_messages;
-+}
- 
- /* A special value for error_handler_messages that indicates that the
-    error should simply be ignored.  */
-@@ -1761,8 +1775,8 @@ error_handler_sprintf (const char *fmt,
-   _bfd_print (err_sprintf, &error_stream, fmt, ap);
- 
-   size_t len = error_stream.ptr - error_buf;
--  struct per_xvec_message *warn
--    = _bfd_per_xvec_warn (error_handler_messages, len + 1);
-+  struct per_xvec_message * warn
-+    = _bfd_per_xvec_warn (get_set_error_handler_messages (NULL, false), len + 1);
-   if (warn)
-     {
-       memcpy (warn->message, error_buf, len);
-@@ -1804,11 +1818,12 @@ _bfd_error_handler (const char *fmt, ...
-   va_list ap;
- 
-   va_start (ap, fmt);
--  if (error_handler_messages == IGNORE_ERROR_MESSAGES)
-+  struct per_xvec_messages * vec = get_set_error_handler_messages (NULL, false);
-+  if (vec == IGNORE_ERROR_MESSAGES)
-     {
-       /* Nothing.  */
-     }
--  else if (error_handler_messages != NULL)
-+  else if (vec != NULL)
-     error_handler_sprintf (fmt, ap);
-   else
-     _bfd_error_internal (fmt, ap);
-@@ -1855,11 +1870,12 @@ DESCRIPTION
- struct per_xvec_messages *
- _bfd_set_error_handler_caching (struct per_xvec_messages *messages)
- {
--  struct per_xvec_messages *old = error_handler_messages;
-+  struct per_xvec_messages *old = get_set_error_handler_messages (NULL, false);
-+
-   if (old == NULL)
--    error_handler_messages = messages;
-+    get_set_error_handler_messages (messages, true);
-   else
--    error_handler_messages = IGNORE_ERROR_MESSAGES;
-+    get_set_error_handler_messages (IGNORE_ERROR_MESSAGES, true);
-   return old;
- }
- 
-@@ -1877,7 +1893,7 @@ DESCRIPTION
- void
- _bfd_restore_error_handler_caching (struct per_xvec_messages *old)
- {
--  error_handler_messages = old;
-+  get_set_error_handler_messages (old, true);
- }
- 
- /*

diff --git a/binutils.spec b/binutils.spec
index 3cb8b4c..339329f 100644
--- a/binutils.spec
+++ b/binutils.spec
@@ -7,7 +7,7 @@ Name: binutils%{?_with_debug:-debug}
 # The variable %%{source} (see below) should be set to indicate which of these
 # origins is being used.
 Version: 2.47.50
-Release: 25%{?dist}
+Release: 26%{?dist}
 License: GPL-3.0-or-later AND (GPL-3.0-or-later WITH Bison-exception-2.2) AND (LGPL-2.0-or-later WITH GCC-exception-2.0) AND BSD-3-Clause AND GFDL-1.3-or-later AND GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-or-later
 URL: https://sourceware.org/binutils
 
@@ -405,8 +405,9 @@ Patch21: binutils-ld-default-z-text.patch
 # Purpose:  The x86_64 architecture does not allow a shared library to access
 # static variables inside a static library.  This is a problem for the
 # libbfd.so library, since it is really a static library in disguise.
+# Solution: hide the global symbols.
 # Lifetime: Permanent.
-Patch22: binutils-no-static-globals-in-libbfd.so.patch
+Patch22: binutils-hide-global-symbols.patch
 # %%endif
 
 #----------------------------------------------------------------------------
@@ -1841,7 +1842,10 @@ exit 0
 
 #----------------------------------------------------------------------------
 %changelog
-* Fri  Nov 05 2026 Nick Clifton <nickc@redhat.com> - 2.47.50-25
+* Mon Nov 09 2026 Nick Clifton <nickc@redhat.com> - 2.47.50-26
+- Yet another attempt to remove global static variables from libbfd.so.  (#2564442)
+
+* Fri Nov 06 2026 Nick Clifton <nickc@redhat.com> - 2.47.50-25
 - And another attempt to remove global static variables from libbfd.so.  (#2564442)
 
 * Thu  Nov 05 2026 Nick Clifton <nickc@redhat.com> - 2.47.50-24

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-09 12:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 12:22 [rpms/binutils] rawhide: Yet another attempt to remove global static variables from libbfd.so. (#2564442) Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox