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

A new commit has been pushed.

Repo   : rpms/binutils
Branch : rawhide
Commit : a9943d2a70e9bd99e14704c1b69f81fe5aef4d31
Author : Nick Clifton <nickc@redhat.com>
Date   : 2026-11-06T15:02:40+00:00
Stats  : +153/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/binutils/c/a9943d2a70e9bd99e14704c1b69f81fe5aef4d31?branch=rawhide

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

---
diff --git a/binutils-no-static-globals-in-libbfd.so.patch b/binutils-no-static-globals-in-libbfd.so.patch
index 5d439b8..424f3d7 100644
--- a/binutils-no-static-globals-in-libbfd.so.patch
+++ b/binutils-no-static-globals-in-libbfd.so.patch
@@ -114,3 +114,152 @@ diff -rup orig/bfd/bfd.c binutils-with-gold-2.47.50-86187fd72fd/bfd/bfd.c
  }
  
  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 ce750be..3cb8b4c 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: 24%{?dist}
+Release: 25%{?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
 
@@ -1841,6 +1841,9 @@ exit 0
 
 #----------------------------------------------------------------------------
 %changelog
+* Fri  Nov 05 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
 - Another attempt to remove global static variables from libbfd.so.  (#2564442)
 

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

only message in thread, other threads:[~2026-11-06 15:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 15:03 [rpms/binutils] rawhide: And 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