public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Aaron Merey <amerey@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/elfutils] rawhide: 0.197-2 - Enable thread safety and backport upstream thread-safety fixes
Date: Sat, 31 Oct 2026 01:34:46 GMT	[thread overview]
Message-ID: <179341048628.1.8829142360042446458.rpms-elfutils-2e77d38798f7@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/elfutils
            Branch : rawhide
            Commit : 2e77d38798f7bde83e02adc904b3c6caf5e980e0
            Author : Aaron Merey <amerey@redhat.com>
            Date   : 2026-10-30T21:19:29-04:00
            Stats  : +2086/-1 in 19 file(s)
            URL    : https://src.fedoraproject.org/rpms/elfutils/c/2e77d38798f7bde83e02adc904b3c6caf5e980e0?branch=rawhide

            Log:
            0.197-2 - Enable thread safety and backport upstream thread-safety fixes

Configure with --enable-thread-safety on Fedora 46 and later (currently
rawhide only).  Thread safety stays off for stable Fedora, RHEL and ELN
builds of this spec.

Backport the 18 upstream thread safety commits following 0.197
(elfutils-0.197..eef98f2a) as elfutils-0.197-thread-safety-*.patch, one
patch per upstream commit.

Assisted-By: Claude Fable 5.1 <noreply@anthropic.com>

---
diff --git a/elfutils-0.197-thread-safety-01-elf_rand-unlock.patch b/elfutils-0.197-thread-safety-01-elf_rand-unlock.patch
new file mode 100644
index 0000000..74345bf
--- /dev/null
+++ b/elfutils-0.197-thread-safety-01-elf_rand-unlock.patch
@@ -0,0 +1,25 @@
+From 75adf5145ae14b2c7ef6abf59df9c6711ade0eee Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 11:15:47 -0400
+Subject: [PATCH] elf_rand.c: Add missing rwlock_unlock for early return
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libelf/elf_rand.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libelf/elf_rand.c b/libelf/elf_rand.c
+index c08eadc6..be5a39c2 100644
+--- a/libelf/elf_rand.c
++++ b/libelf/elf_rand.c
+@@ -54,6 +54,7 @@ elf_rand (Elf *elf, size_t offset)
+     {
+       /* Mark the archive header as unusable.  */
+       elf->elf_ar_hdr.ar_name = NULL;
++      rwlock_unlock (elf->lock);
+       return 0;
+     }
+ 
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-02-asm_align-edeadlk.patch b/elfutils-0.197-thread-safety-02-asm_align-edeadlk.patch
new file mode 100644
index 0000000..ca250e8
--- /dev/null
+++ b/elfutils-0.197-thread-safety-02-asm_align-edeadlk.patch
@@ -0,0 +1,38 @@
+From defa4f7e8e0afbe9859e8e1e289c769c44694fae Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 11:21:37 -0400
+Subject: [PATCH] asm_align.c: Avoid EDEADLK in asm_align
+
+asm_align acquires asmscn->ctx->lock wrlock before updating a parent
+asmscn's alignment.  While doing this asm_align also attempts to acquire
+the parent asmscn's wrlock.  The parent and child share the same ctx,
+causing an EDEADLK error.
+
+Fix this by removing the inner acquisition of the wrlock.  Since the ctx
+is shared, this inner acquisition is redundant.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libasm/asm_align.c | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/libasm/asm_align.c b/libasm/asm_align.c
+index 19ec9a13..65d3198f 100644
+--- a/libasm/asm_align.c
++++ b/libasm/asm_align.c
+@@ -112,12 +112,8 @@ asm_align (AsmScn_t *asmscn, GElf_Word value)
+       /* Update the parent as well (if it exists).  */
+       if (asmscn->subsection_id != 0)
+ 	{
+-	  rwlock_wrlock (asmscn->data.up->ctx->lock);
+-
+ 	  if (asmscn->data.up->max_align < value)
+ 	    asmscn->data.up->max_align = value;
+-
+-	  rwlock_unlock (asmscn->data.up->ctx->lock);
+ 	}
+     }
+ 
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-03-libasm-unlock.patch b/elfutils-0.197-thread-safety-03-libasm-unlock.patch
new file mode 100644
index 0000000..8d2cf86
--- /dev/null
+++ b/elfutils-0.197-thread-safety-03-libasm-unlock.patch
@@ -0,0 +1,46 @@
+From 50e0475db16506294d0c5767a415f0be9eb30334 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 11:30:59 -0400
+Subject: [PATCH] libasm: Add missing rwlock_unlock for early returns
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libasm/asm_newabssym.c | 5 ++++-
+ libasm/asm_newcomsym.c | 5 ++++-
+ 2 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/libasm/asm_newabssym.c b/libasm/asm_newabssym.c
+index 728d6043..38628f5f 100644
+--- a/libasm/asm_newabssym.c
++++ b/libasm/asm_newabssym.c
+@@ -73,7 +73,10 @@ asm_newabssym (AsmCtx_t *ctx, const char *name, GElf_Xword size,
+ 
+   result = malloc (sizeof (AsmSym_t));
+   if (result == NULL)
+-    return NULL;
++    {
++      rwlock_unlock (ctx->lock);
++      return NULL;
++    }
+ 
+   result->scn = (AsmScn_t *) &__libasm_abs_scn;
+   result->size = size;
+diff --git a/libasm/asm_newcomsym.c b/libasm/asm_newcomsym.c
+index 750a1380..b4c6e82b 100644
+--- a/libasm/asm_newcomsym.c
++++ b/libasm/asm_newcomsym.c
+@@ -73,7 +73,10 @@ asm_newcomsym (AsmCtx_t *ctx, const char *name, GElf_Xword size,
+ 
+   result = malloc (sizeof (AsmSym_t));
+   if (result == NULL)
+-    return NULL;
++    {
++      rwlock_unlock (ctx->lock);
++      return NULL;
++    }
+ 
+   result->scn = (AsmScn_t *) &__libasm_com_scn;
+   result->size = size;
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-04-readelf-job-output.patch b/elfutils-0.197-thread-safety-04-readelf-job-output.patch
new file mode 100644
index 0000000..44f0e0e
--- /dev/null
+++ b/elfutils-0.197-thread-safety-04-readelf-job-output.patch
@@ -0,0 +1,80 @@
+From f3ae1c4647591e5d86078f40078cbcc531123824 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 11:35:54 -0400
+Subject: [PATCH] readelf.c: Print to job output stream instead of stdout
+
+When built with --enable-thread-safety, DWARF sections should be printed
+to per-job output stream.
+
+Fix skip_listptr_hole and print_debug_exception_table printing to stdout
+and bypassing job output streams.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ src/readelf.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/src/readelf.c b/src/readelf.c
+index 57b0dd2c..9ca2d278 100644
+--- a/src/readelf.c
++++ b/src/readelf.c
+@@ -5864,7 +5864,7 @@ skip_listptr_hole (struct listptr_table *table, size_t *idxp,
+ 		   uint_fast8_t *address_sizep, uint_fast8_t *offset_sizep,
+ 		   Dwarf_Addr *base, struct Dwarf_CU **cu, ptrdiff_t offset,
+ 		   unsigned char **readp, unsigned char *endp,
+-		   unsigned int *attr)
++		   unsigned int *attr, FILE *out)
+ {
+   if (table->n == 0)
+     return false;
+@@ -5878,16 +5878,16 @@ skip_listptr_hole (struct listptr_table *table, size_t *idxp,
+       || p->offset >= (Dwarf_Off) (endp - *readp + offset))
+     {
+       *readp = endp;
+-      printf (_(" [%6tx]  <UNUSED GARBAGE IN REST OF SECTION>\n"),
+-	      offset);
++      fprintf (out, _(" [%6tx]  <UNUSED GARBAGE IN REST OF SECTION>\n"),
++	       offset);
+       return true;
+     }
+ 
+   if (p->offset != (Dwarf_Off) offset)
+     {
+       *readp += p->offset - offset;
+-      printf (_(" [%6tx]  <UNUSED GARBAGE> ... %" PRIu64 " bytes ...\n"),
+-	      offset, (Dwarf_Off) p->offset - offset);
++      fprintf (out, _(" [%6tx]  <UNUSED GARBAGE> ... %" PRIu64 " bytes ...\n"),
++	       offset, (Dwarf_Off) p->offset - offset);
+       return true;
+     }
+ 
+@@ -6934,7 +6934,7 @@ print_debug_ranges_section (Dwfl_Module *dwflmod,
+ 
+       if (first && skip_listptr_hole (&known_rangelistptr, &listptr_idx,
+ 				      &address_size, NULL, &base, &cu,
+-				      offset, &readp, endp, NULL))
++				      offset, &readp, endp, NULL, out))
+ 	continue;
+ 
+       if (last_cu != cu)
+@@ -10586,7 +10586,7 @@ print_debug_loc_section (Dwfl_Module *dwflmod,
+ 
+       if (first && skip_listptr_hole (&known_locsptr, &listptr_idx,
+ 				      &address_size, &offset_size, &base,
+-				      &cu, offset, &readp, endp, &attr))
++				      &cu, offset, &readp, endp, &attr, out))
+ 	continue;
+ 
+       if (last_cu != cu)
+@@ -11826,7 +11826,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
+       if (max_action > maxdata || maxdata - max_action < 1)
+ 	{
+ 	invalid_action_table:
+-	  fputs (_("   <INVALID DATA>\n"), stdout);
++	  fputs (_("   <INVALID DATA>\n"), out);
+ 	  return;
+ 	}
+ 
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-05-locks-atomic-macros.patch b/elfutils-0.197-thread-safety-05-locks-atomic-macros.patch
new file mode 100644
index 0000000..f7f18ac
--- /dev/null
+++ b/elfutils-0.197-thread-safety-05-locks-atomic-macros.patch
@@ -0,0 +1,110 @@
+From 85130670e49813225fb0000ae2af17c108d441a2 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Wed, 30 Sep 2026 15:05:33 -0400
+Subject: [PATCH] lib/locks.h: Add atomic load/store macros
+
+Use __atomic_{load, store, compare_exchange}_n when USE_LOCKS is defined
+using new macros atomic_load_acquire, atomic_store_release,
+atomic_compare_exchange.  The new macros fall back to non-atomic operations
+when USE_LOCKS is not defined.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ lib/locks.h    | 22 ++++++++++++++++++++++
+ libdw/libdwP.h | 16 ++++------------
+ 2 files changed, 26 insertions(+), 12 deletions(-)
+
+diff --git a/lib/locks.h b/lib/locks.h
+index 3cd0914e..89ed3409 100644
+--- a/lib/locks.h
++++ b/lib/locks.h
+@@ -29,6 +29,8 @@
+ #ifndef LOCKS_H
+ #define LOCKS_H     1
+ 
++#include <stdbool.h>
++
+ #ifdef USE_VG_ANNOTATIONS
+ # include <valgrind/helgrind.h>
+ #else
+@@ -64,6 +66,17 @@
+ # define mutex_fini(lock)		MUTEX_CALL (destroy (&lock))
+ # define once(once_control, init_routine)  \
+   ONCE_CALL (once (&once_control, init_routine))
++/* __atomic_* compiler builtin functions are used instead of <stdatomic.h>
++   because the builtins can operate on non-_Atomic types.
++   Dwarf_Die.abbrev cannot be made _Atomic without possibly breaking ABI
++   compatibility.  */
++# define atomic_load_acquire(ptr) \
++  __atomic_load_n ((ptr), __ATOMIC_ACQUIRE)
++# define atomic_store_release(ptr, val) \
++  __atomic_store_n ((ptr), (val), __ATOMIC_RELEASE)
++# define atomic_compare_exchange(ptr, expected, val) \
++  __atomic_compare_exchange_n ((ptr), (expected), (val), false, \
++                               __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)
+ #else
+ /* Eventually we will allow multi-threaded applications to use the
+    libraries.  Therefore we will add the necessary locking although
+@@ -81,6 +94,15 @@
+ # define mutex_fini(lock) ((void) (lock))
+ # define once_define(class,name)
+ # define once(once_control, init_routine)       init_routine()
++# define atomic_load_acquire(ptr) (*(ptr))
++# define atomic_store_release(ptr, val) ((void) (*(ptr) = (val)))
++# define atomic_compare_exchange(ptr, expected, val) \
++  ({ bool _match = *(ptr) == *(expected);  \
++     if (_match)			   \
++       *(ptr) = (val);			   \
++     else				   \
++       *(expected) = *(ptr);		   \
++     _match; })
+ #endif  /* USE_LOCKS */
+ 
+ #endif  /* locks.h */
+diff --git a/libdw/libdwP.h b/libdw/libdwP.h
+index 7d0b09a0..e1034c83 100644
+--- a/libdw/libdwP.h
++++ b/libdw/libdwP.h
+@@ -831,16 +831,11 @@ __libdw_dieabbrev (Dwarf_Die *die, const unsigned char **readp)
+ 
+   if (unlikely (die->cu == NULL))
+     {
+-      /* __atomic_* compiler builtin functions are used instead of <stdatomic.h>
+-	 because the builtins can operate on non-_Atomic types.
+-	 Dwarf_Die.abbrev cannot be made _Atomic without possibly breaking ABI
+-	 compatibility.  */
+-      __atomic_compare_exchange_n (&die->abbrev, &expected, end_abbrev, false,
+-				   __ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
++      atomic_compare_exchange (&die->abbrev, &expected, end_abbrev);
+       return end_abbrev;
+     }
+ 
+-  Dwarf_Abbrev *abbrev = __atomic_load_n (&die->abbrev, __ATOMIC_ACQUIRE);
++  Dwarf_Abbrev *abbrev = atomic_load_acquire (&die->abbrev);
+   if (abbrev == NULL || readp != NULL)
+     {
+       /* We need to get the abbreviation or need to read after the code.  */
+@@ -848,9 +843,7 @@ __libdw_dieabbrev (Dwarf_Die *die, const unsigned char **readp)
+       const unsigned char *addr = die->addr;
+       if (addr >= (const unsigned char *) die->cu->endp)
+ 	{
+-	  __atomic_compare_exchange_n (&die->abbrev, &expected,
+-				       end_abbrev, false,
+-				       __ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
++	  atomic_compare_exchange (&die->abbrev, &expected, end_abbrev);
+ 	  return end_abbrev;
+ 	}
+ 
+@@ -863,8 +856,7 @@ __libdw_dieabbrev (Dwarf_Die *die, const unsigned char **readp)
+       if (abbrev == NULL)
+ 	{
+ 	  abbrev = __libdw_findabbrev (die->cu, code);
+-	  __atomic_compare_exchange_n (&die->abbrev, &expected, abbrev, false,
+-				       __ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
++	  atomic_compare_exchange (&die->abbrev, &expected, abbrev);
+ 	}
+     }
+ 
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-06-elf_getscn-hotpath.patch b/elfutils-0.197-thread-safety-06-elf_getscn-hotpath.patch
new file mode 100644
index 0000000..5c625b7
--- /dev/null
+++ b/elfutils-0.197-thread-safety-06-elf_getscn-hotpath.patch
@@ -0,0 +1,117 @@
+From 97af06b35692836898a6aab13b9a471116ca193b Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Wed, 30 Sep 2026 15:05:34 -0400
+Subject: [PATCH] elf_getscn.c: Remove locking from hotpath
+
+Remove the rdlock held throughout elf_getscn and replace it with a wrlock
+that covers only the one-time initialization of section zero.  This
+reduces rwlock overhead when on the hotpath and also fixes a race
+condition where a flag (runp->cnt) could be updated while the rdlock was
+being held, causing leaks and racing stores.
+
+Atomic store/acquire is now used when accessing section zero outside
+of when a lock is being held.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libelf/elf_getscn.c | 57 +++++++++++++++++++++++++--------------------
+ 1 file changed, 32 insertions(+), 25 deletions(-)
+
+diff --git a/libelf/elf_getscn.c b/libelf/elf_getscn.c
+index be9c76f0..8b268f7b 100644
+--- a/libelf/elf_getscn.c
++++ b/libelf/elf_getscn.c
+@@ -50,8 +50,6 @@ elf_getscn (Elf *elf, size_t idx)
+       return NULL;
+     }
+ 
+-  rwlock_rdlock (elf->lock);
+-
+   Elf_Scn *result = NULL;
+ 
+   /* Find the section in the list.  */
+@@ -63,39 +61,51 @@ elf_getscn (Elf *elf, size_t idx)
+   /* Section zero is special.  It always exists even if there is no
+      "first" section.  And it is needed to store "overflow" values
+      from the Elf header.  */
+-  if (idx == 0 && runp->cnt == 0 && runp->max > 0)
++  if (idx == 0 && atomic_load_acquire (&runp->cnt) == 0 && runp->max > 0)
+     {
+-      Elf_Scn *scn0 = &runp->data[0];
+-      if (elf->class == ELFCLASS32)
++      rwlock_wrlock (elf->lock);
++
++      /* Check whether section zero was set up before this thread acquired
++	 the wrlock.  */
++      if (runp->cnt == 0)
+ 	{
+-	  scn0->shdr.e32 = calloc (1, sizeof (Elf32_Shdr));
+-	  if (scn0->shdr.e32 == NULL)
++	  Elf_Scn *scn0 = &runp->data[0];
++	  if (elf->class == ELFCLASS32)
+ 	    {
+-	      __libelf_seterrno (ELF_E_NOMEM);
+-	      goto out;
++	      scn0->shdr.e32 = calloc (1, sizeof (Elf32_Shdr));
++	      if (scn0->shdr.e32 == NULL)
++		{
++		  __libelf_seterrno (ELF_E_NOMEM);
++		  rwlock_unlock (elf->lock);
++		  return NULL;
++		}
+ 	    }
+-	}
+-      else
+-	{
+-	  scn0->shdr.e64 = calloc (1, sizeof (Elf64_Shdr));
+-	  if (scn0->shdr.e64 == NULL)
++	  else
+ 	    {
+-	      __libelf_seterrno (ELF_E_NOMEM);
+-	      goto out;
++	      scn0->shdr.e64 = calloc (1, sizeof (Elf64_Shdr));
++	      if (scn0->shdr.e64 == NULL)
++		{
++		  __libelf_seterrno (ELF_E_NOMEM);
++		  rwlock_unlock (elf->lock);
++		  return NULL;
++		}
+ 	    }
++
++	  scn0->elf = elf;
++	  scn0->shdr_flags = ELF_F_DIRTY | ELF_F_MALLOCED;
++	  scn0->list = elf->state.elf.scns_last;
++	  scn0->data_read = 1;
++	  atomic_store_release (&runp->cnt, 1);
+ 	}
+-      scn0->elf = elf;
+-      scn0->shdr_flags = ELF_F_DIRTY | ELF_F_MALLOCED;
+-      scn0->list = elf->state.elf.scns_last;
+-      scn0->data_read = 1;
+-      runp->cnt = 1;
++
++      rwlock_unlock (elf->lock);
+     }
+ 
+   while (1)
+     {
+       if (idx < runp->max)
+ 	{
+-	  if (idx < runp->cnt)
++	  if (idx < atomic_load_acquire (&runp->cnt))
+ 	    result = &runp->data[idx];
+ 	  else
+ 	    __libelf_seterrno (ELF_E_INVALID_INDEX);
+@@ -112,9 +122,6 @@ elf_getscn (Elf *elf, size_t idx)
+ 	}
+     }
+ 
+- out:
+-  rwlock_unlock (elf->lock);
+-
+   return result;
+ }
+ INTDEF(elf_getscn)
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-07-getshdr-hotpath.patch b/elfutils-0.197-thread-safety-07-getshdr-hotpath.patch
new file mode 100644
index 0000000..912de32
--- /dev/null
+++ b/elfutils-0.197-thread-safety-07-getshdr-hotpath.patch
@@ -0,0 +1,123 @@
+From 3f791bd50a5c3c7bf467fe874206fde180b4e9d2 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Wed, 30 Sep 2026 15:05:35 -0400
+Subject: [PATCH] gelf_getshdr.c, elfNN_getshdr.c: Remove hotpath locks
+
+Check whether the target shdr has already been loaded without using
+scn->elf->lock.  Otherwise use this lock only for the one-time lazy
+loading of the shdr.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libelf/elf32_getshdr.c | 21 ++++++++++++++-------
+ libelf/gelf_getshdr.c  | 33 ++++++++++++++++++++-------------
+ 2 files changed, 34 insertions(+), 20 deletions(-)
+
+diff --git a/libelf/elf32_getshdr.c b/libelf/elf32_getshdr.c
+index e4bebe18..02f8d2a3 100644
+--- a/libelf/elf32_getshdr.c
++++ b/libelf/elf32_getshdr.c
+@@ -196,10 +196,13 @@ load_shdr_wrlock (Elf_Scn *scn)
+       goto out;
+     }
+ 
+-  /* Set the pointers in the `scn's.  */
+-  for (size_t cnt = 0; cnt < shnum; ++cnt)
+-    elf->state.ELFW(elf,LIBELFBITS).scns.data[cnt].shdr.ELFW(e,LIBELFBITS)
+-      = &elf->state.ELFW(elf,LIBELFBITS).shdr[cnt];
++  Elf_Scn *scns = elf->state.ELFW(elf,LIBELFBITS).scns.data;
++
++  /* Set the pointers in the `scn's.  Set section 0 last to indicate that
++     all sections have been set.  */
++  for (size_t cnt = shnum; cnt > 0; --cnt)
++    atomic_store_release (&scns[cnt - 1].shdr.ELFW(e,LIBELFBITS),
++			  &elf->state.ELFW(elf,LIBELFBITS).shdr[cnt - 1]);
+ 
+   result = scn->shdr.ELFW(e,LIBELFBITS);
+   assert (result != NULL);
+@@ -275,9 +278,13 @@ elfw2(LIBELFBITS,getshdr) (Elf_Scn *scn)
+   if (!scn_valid (scn))
+     return NULL;
+ 
+-  rwlock_rdlock (scn->elf->lock);
+-  result = __elfw2(LIBELFBITS,getshdr_rdlock) (scn);
+-  rwlock_unlock (scn->elf->lock);
++  result = atomic_load_acquire (&scn->shdr.ELFW(e,LIBELFBITS));
++  if (result == NULL)
++    {
++      rwlock_wrlock (scn->elf->lock);
++      result = __elfw2(LIBELFBITS,getshdr_wrlock) (scn);
++      rwlock_unlock (scn->elf->lock);
++    }
+ 
+   return result;
+ }
+diff --git a/libelf/gelf_getshdr.c b/libelf/gelf_getshdr.c
+index 3858c8e1..2b16e502 100644
+--- a/libelf/gelf_getshdr.c
++++ b/libelf/gelf_getshdr.c
+@@ -51,18 +51,22 @@ gelf_getshdr (Elf_Scn *scn, GElf_Shdr *dst)
+       return NULL;
+     }
+ 
+-  rwlock_rdlock (scn->elf->lock);
+-
+   if (scn->elf->class == ELFCLASS32)
+     {
+       /* Copy the elements one-by-one.  */
+-      Elf32_Shdr *shdr
+-	= scn->shdr.e32 ?: __elf32_getshdr_rdlock (scn);
++      Elf32_Shdr *shdr = atomic_load_acquire (&scn->shdr.e32);
+ 
+       if (shdr == NULL)
+ 	{
+-	  __libelf_seterrno (ELF_E_INVALID_OPERAND);
+-	  goto out;
++	  rwlock_wrlock (scn->elf->lock);
++	  shdr = __elf32_getshdr_wrlock (scn);
++	  rwlock_unlock (scn->elf->lock);
++
++	  if (shdr == NULL)
++	    {
++	      __libelf_seterrno (ELF_E_INVALID_OPERAND);
++	      return NULL;
++	    }
+ 	}
+ 
+ #define COPY(name) \
+@@ -82,22 +86,25 @@ gelf_getshdr (Elf_Scn *scn, GElf_Shdr *dst)
+     }
+   else
+     {
+-      Elf64_Shdr *shdr
+-	= scn->shdr.e64 ?: __elf64_getshdr_rdlock (scn);
++      Elf64_Shdr *shdr = atomic_load_acquire (&scn->shdr.e64);
+ 
+       if (shdr == NULL)
+ 	{
+-	  __libelf_seterrno (ELF_E_INVALID_OPERAND);
+-	  goto out;
++	  rwlock_wrlock (scn->elf->lock);
++	  shdr = __elf64_getshdr_wrlock (scn);
++	  rwlock_unlock (scn->elf->lock);
++
++	  if (shdr == NULL)
++	    {
++	      __libelf_seterrno (ELF_E_INVALID_OPERAND);
++	      return NULL;
++	    }
+ 	}
+ 
+       /* We only have to copy the data.  */
+       result = memcpy (dst, shdr, sizeof (GElf_Shdr));
+     }
+ 
+- out:
+-  rwlock_unlock (scn->elf->lock);
+-
+   return result;
+ }
+ INTDEF(gelf_getshdr)
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-08-offscn-atomic-load.patch b/elfutils-0.197-thread-safety-08-offscn-atomic-load.patch
new file mode 100644
index 0000000..023623d
--- /dev/null
+++ b/elfutils-0.197-thread-safety-08-offscn-atomic-load.patch
@@ -0,0 +1,39 @@
+From 0e2e8dd178fcb1bc53dbc1c612b3aeef79ffe865 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Wed, 30 Sep 2026 15:05:36 -0400
+Subject: [PATCH] elf32_offscn.c: Use atomic_load_acquire for Elf_ScnList
+ fields
+
+elfNN_offscn reads Elf_ScnList fields cnt and data[0].shdr while not
+holding any lock.  These fields may be written to concurrently by
+elf_getscn and load_shdr_wrlock.
+
+Replace elfNN_offscn's plain loads of these fields with
+atomic_load_acquire to avoid data races.  Atomic ops are used instead
+of locking in order to avoid holding elf->lock when calling
+elfNN_getshdr, which may also need elf->lock's wrlock.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libelf/elf32_offscn.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/libelf/elf32_offscn.c b/libelf/elf32_offscn.c
+index 1a9a3b0a..5ddb3b58 100644
+--- a/libelf/elf32_offscn.c
++++ b/libelf/elf32_offscn.c
+@@ -58,8 +58,9 @@ elfw2(LIBELFBITS,offscn) (Elf *elf, ElfW2(LIBELFBITS,Off) offset)
+ 
+   /* If we have not looked at section headers before,
+      we might need to read them in first.  */
+-  if (runp->cnt > 0
+-      && unlikely (runp->data[0].shdr.ELFW(e,LIBELFBITS) == NULL)
++  if (atomic_load_acquire (&runp->cnt) > 0
++      && unlikely (atomic_load_acquire (&runp->data[0].shdr.ELFW(e,LIBELFBITS))
++		   == NULL)
+       && unlikely (elfw2(LIBELFBITS,getshdr) (&runp->data[0]) == NULL))
+     return NULL;
+ 
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-09-gelf_getsymshndx-locking.patch b/elfutils-0.197-thread-safety-09-gelf_getsymshndx-locking.patch
new file mode 100644
index 0000000..4ffb11c
--- /dev/null
+++ b/elfutils-0.197-thread-safety-09-gelf_getsymshndx-locking.patch
@@ -0,0 +1,67 @@
+From 16e9cbdee8d27694e8405cde142b7fb45e26723c Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Wed, 30 Sep 2026 15:05:37 -0400
+Subject: [PATCH] gelf_getsymshndx.c: Remove locking
+
+Remove all locking from gelf_getsymshndx.  Any functions that change
+any state associated with gelf_getsymshndx are not to be called
+concurrently with gelf_getsymshndx (see THREAD-SAFETY) so no locking is
+needed.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libelf/gelf_getsymshndx.c | 11 +++--------
+ 1 file changed, 3 insertions(+), 8 deletions(-)
+
+diff --git a/libelf/gelf_getsymshndx.c b/libelf/gelf_getsymshndx.c
+index 534502e3..1be35360 100644
+--- a/libelf/gelf_getsymshndx.c
++++ b/libelf/gelf_getsymshndx.c
+@@ -58,8 +58,6 @@ gelf_getsymshndx (Elf_Data *symdata, Elf_Data *shndxdata, int ndx,
+       return NULL;
+     }
+ 
+-  rwlock_rdlock (symdata_scn->s->elf->lock);
+-
+   /* The user is not required to pass a data descriptor for an extended
+      section index table.  */
+   if (likely (shndxdata_scn != NULL))
+@@ -67,7 +65,7 @@ gelf_getsymshndx (Elf_Data *symdata, Elf_Data *shndxdata, int ndx,
+       if (INVALID_NDX (ndx, Elf32_Word, &shndxdata_scn->d))
+ 	{
+ 	  __libelf_seterrno (ELF_E_INVALID_INDEX);
+-	  goto out;
++	  return NULL;
+ 	}
+ 
+       shndx = ((Elf32_Word *) shndxdata_scn->d.d_buf)[ndx];
+@@ -87,7 +85,7 @@ gelf_getsymshndx (Elf_Data *symdata, Elf_Data *shndxdata, int ndx,
+       if (INVALID_NDX (ndx, Elf32_Sym, symdata))
+ 	{
+ 	  __libelf_seterrno (ELF_E_INVALID_INDEX);
+-	  goto out;
++	  return NULL;
+ 	}
+ 
+       src = &((Elf32_Sym *) symdata->d_buf)[ndx];
+@@ -116,7 +114,7 @@ gelf_getsymshndx (Elf_Data *symdata, Elf_Data *shndxdata, int ndx,
+       if (INVALID_NDX (ndx, GElf_Sym, symdata))
+ 	{
+ 	  __libelf_seterrno (ELF_E_INVALID_INDEX);
+-	  goto out;
++	  return NULL;
+ 	}
+ 
+       *dst = ((GElf_Sym *) symdata->d_buf)[ndx];
+@@ -128,8 +126,5 @@ gelf_getsymshndx (Elf_Data *symdata, Elf_Data *shndxdata, int ndx,
+ 
+   result = dst;
+ 
+- out:
+-  rwlock_unlock (symdata_scn->s->elf->lock);
+-
+   return result;
+ }
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-10-dwarf_getmacros-macro_lock.patch b/elfutils-0.197-thread-safety-10-dwarf_getmacros-macro_lock.patch
new file mode 100644
index 0000000..f3dac41
--- /dev/null
+++ b/elfutils-0.197-thread-safety-10-dwarf_getmacros-macro_lock.patch
@@ -0,0 +1,44 @@
+From ec7371b89bb6dca00cf758b6870553c7e507ef14 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Wed, 30 Sep 2026 15:06:48 -0400
+Subject: [PATCH] dwarf_getmacros.c: Acquire macro_lock before macro_ops_tree
+ find
+
+cache_op_table calls eu_tsearch_nolock on macro_ops_tree while holding
+a macro_lock mutex.  cache_op_table's fast path also contains a call to
+eu_tfind on macro_ops_tree when macro_lock is not held.  This creates a
+data race where one thread may attempt to read macro_ops_tree with eu_tfind
+while it's being modified by eu_tsearch_nolock in another thread.
+
+Fix this by acquiring macro_lock first and replacing eu_tfind with
+eu_tfind_nolock.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libdw/dwarf_getmacros.c | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
+index e3efd083..183e885f 100644
+--- a/libdw/dwarf_getmacros.c
++++ b/libdw/dwarf_getmacros.c
+@@ -330,14 +330,11 @@ cache_op_table (Dwarf *dbg, int sec_index, Dwarf_Off macoff,
+ 		Dwarf_Die *cudie)
+ {
+   Dwarf_Macro_Op_Table fake = { .offset = macoff, .sec_index = sec_index };
+-  Dwarf_Macro_Op_Table **found = eu_tfind (&fake, &dbg->macro_ops_tree,
+-					macro_op_compare);
+-  if (found != NULL)
+-    return *found;
+ 
+   mutex_lock (dbg->macro_lock);
+ 
+-  found = eu_tfind_nolock (&fake, &dbg->macro_ops_tree, macro_op_compare);
++  Dwarf_Macro_Op_Table **found = eu_tfind_nolock (&fake, &dbg->macro_ops_tree,
++						  macro_op_compare);
+   if (found != NULL)
+     {
+       mutex_unlock (dbg->macro_lock);
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-11-getshdr-archive-assert.patch b/elfutils-0.197-thread-safety-11-getshdr-archive-assert.patch
new file mode 100644
index 0000000..05fddf4
--- /dev/null
+++ b/elfutils-0.197-thread-safety-11-getshdr-archive-assert.patch
@@ -0,0 +1,94 @@
+From c8bbaed0921505ba0ce57951333a09004f7e53ba Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Wed, 30 Sep 2026 15:06:50 -0400
+Subject: [PATCH] elf32_getshdr.c: Avoid failed assert for archive member
+
+__libelf_readall reads an entire image into memory and sets
+ELF_F_MALLOCED for the associated elf descriptor.  For ELF_K_AR
+descriptors, member/child descriptors do not have ELF_F_MALLOCED
+set even though their image is in a malloced buffer.
+
+This causes an assert failure in elf32_getshdr.c:load_shdr_wrlock
+when attempting to read an shdr from an archive member.  The function
+asserts that ELF_F_MALLOCED is set because the member descriptor's
+map_address is non-NULL.
+
+Fix this by introducing a new internal flag ELF_F_PARENT_MALLOCED
+to indicate that this descriptor's image has been allocated but the
+memory is owned by a parent descriptor.  Also remove a redundant assert
+that is a repeat of the failing assert.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libelf/elf32_getshdr.c | 12 ++++--------
+ libelf/elf_readall.c   |  4 ++++
+ libelf/libelfP.h       |  3 ++-
+ 3 files changed, 10 insertions(+), 9 deletions(-)
+
+diff --git a/libelf/elf32_getshdr.c b/libelf/elf32_getshdr.c
+index 02f8d2a3..cb4bad11 100644
+--- a/libelf/elf32_getshdr.c
++++ b/libelf/elf32_getshdr.c
+@@ -91,11 +91,12 @@ load_shdr_wrlock (Elf_Scn *scn)
+       /* All the data is already mapped.  If we could use it
+ 	 directly this would already have happened.  Unless
+ 	 we allocated the memory ourselves and the ELF_F_MALLOCED
+-	 flag is set.  */
++	 flag is set, or a parent archive allocated the memory
++	 and ELF_F_PARENT_MALLOCED is set.  */
+       void *file_shdr = ((char *) elf->map_address
+ 			 + elf->start_offset + ehdr->e_shoff);
+ 
+-      assert ((elf->flags & ELF_F_MALLOCED)
++      assert ((elf->flags & (ELF_F_MALLOCED | ELF_F_PARENT_MALLOCED))
+ 	      || ehdr->e_ident[EI_DATA] != MY_ELFDATA
+ 	      || elf->cmd == ELF_C_READ_MMAP
+ 	      || (! ALLOW_UNALIGNED
+@@ -104,12 +105,7 @@ load_shdr_wrlock (Elf_Scn *scn)
+ 
+       /* Now copy the data and at the same time convert the byte order.  */
+       if (ehdr->e_ident[EI_DATA] == MY_ELFDATA)
+-	{
+-	  assert ((elf->flags & ELF_F_MALLOCED)
+-		  || elf->cmd == ELF_C_READ_MMAP
+-		  || ! ALLOW_UNALIGNED);
+-	  memcpy (shdr, file_shdr, size);
+-	}
++	memcpy (shdr, file_shdr, size);
+       else
+ 	{
+ 	  bool copy = ! (ALLOW_UNALIGNED
+diff --git a/libelf/elf_readall.c b/libelf/elf_readall.c
+index 4ef8fe97..135e41f9 100644
+--- a/libelf/elf_readall.c
++++ b/libelf/elf_readall.c
+@@ -49,8 +49,12 @@ set_address (Elf *elf, size_t offset)
+ 	{
+ 	  if (child->map_address == NULL)
+ 	    {
++	      /* Record that child's archive image is backed by a parent
++		 archive's malloced buffer.  */
++	      child->flags |= ELF_F_PARENT_MALLOCED;
+ 	      child->map_address = elf->map_address;
+ 	      child->start_offset -= offset;
++
+ 	      if (child->kind == ELF_K_AR)
+ 		child->state.ar.offset -= offset;
+ 
+diff --git a/libelf/libelfP.h b/libelf/libelfP.h
+index 52767aa5..dae775c6 100644
+--- a/libelf/libelfP.h
++++ b/libelf/libelfP.h
+@@ -83,7 +83,8 @@ enum
+ {
+   ELF_F_MMAPPED = 0x40,
+   ELF_F_MALLOCED = 0x80,
+-  ELF_F_FILEDATA = 0x100
++  ELF_F_FILEDATA = 0x100,
++  ELF_F_PARENT_MALLOCED = 0x200
+ };
+ 
+ 
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-12-cfi-cie-init-race.patch b/elfutils-0.197-thread-safety-12-cfi-cie-init-race.patch
new file mode 100644
index 0000000..41c22b9
--- /dev/null
+++ b/elfutils-0.197-thread-safety-12-cfi-cie-init-race.patch
@@ -0,0 +1,90 @@
+From 377447e9f704be430b4e0abc05cb56e6ebea8f38 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 01:16:13 -0400
+Subject: [PATCH] libdw/cfi.c: Prevent CIE init data race
+
+Concurrent calls to dwarf_cfi_addrframe are unsynchronized and can
+result in a CIE's initial state being initialized multiple times across
+threads or a thread reading a partially initialized initial state.
+
+Fix this by checking cie->initial_state atomically and if it isn't
+initialized, acquire cache->lock before performing the initialization.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libdw/cfi.c | 21 +++++++++++++++++----
+ libdw/cfi.h |  5 +++++
+ 2 files changed, 22 insertions(+), 4 deletions(-)
+
+diff --git a/libdw/cfi.c b/libdw/cfi.c
+index a9607246..4710b474 100644
+--- a/libdw/cfi.c
++++ b/libdw/cfi.c
+@@ -456,9 +456,14 @@ cie_cache_initial_state (Dwarf_CFI *cache, struct dwarf_cie *cie)
+ {
+   int result = DWARF_E_NOERROR;
+ 
+-  if (likely (cie->initial_state != NULL))
++  if (likely (atomic_load_acquire (&cie->initial_state) != NULL))
+     return result;
+ 
++  mutex_lock (cache->lock);
++
++  if (cie->initial_state != NULL)
++    goto out;
++
+   /* This CIE has not been used before.  Play out its initial
+      instructions and cache the initial state that results.
+      First we'll let the backend fill in the default initial
+@@ -477,11 +482,17 @@ cie_cache_initial_state (Dwarf_CFI *cache, struct dwarf_cie *cie)
+   /* Fetch the ABI's default CFI program.  */
+   if (likely (cache->ebl != (void *) -1l)
+       && unlikely (ebl_abi_cfi (cache->ebl, &abi_info) < 0))
+-    return DWARF_E_UNKNOWN_ERROR;
++    {
++      result = DWARF_E_UNKNOWN_ERROR;
++      goto out;
++    }
+ 
+   Dwarf_Frame *cie_fs = calloc (1, sizeof (Dwarf_Frame));
+   if (unlikely (cie_fs == NULL))
+-    return DWARF_E_NOMEM;
++    {
++      result = DWARF_E_NOMEM;
++      goto out;
++    }
+ 
+   /* If the default state of any register is not "undefined"
+      (i.e. call-clobbered), then the backend supplies instructions
+@@ -513,9 +524,11 @@ cie_cache_initial_state (Dwarf_CFI *cache, struct dwarf_cie *cie)
+       /* Now we have the initial state of things that all
+ 	 FDEs using this CIE will start from.  */
+       cie_fs->cache = cache;
+-      cie->initial_state = cie_fs;
++      atomic_store_release (&cie->initial_state, cie_fs);
+     }
+ 
++out:
++  mutex_unlock (cache->lock);
+   return result;
+ }
+ 
+diff --git a/libdw/cfi.h b/libdw/cfi.h
+index eb765205..fe8fbb69 100644
+--- a/libdw/cfi.h
++++ b/libdw/cfi.h
+@@ -48,6 +48,11 @@ struct dwarf_cie
+   const uint8_t *initial_instructions;
+   const uint8_t *initial_instructions_end;
+ 
++  /* Initial frame state holding instructions for unwinding frames associated
++     with FDEs using this CIE.  Set in cie_cache_initial_state while holding
++     the corresponding cfi->lock.  Destroyed by __libdw_destroy_frame_cache
++     called from either dwarf_end (for Dwarf_CFI acquired from dwarf_getcfi)
++     or dwarf_cfi_end (for Dwarf_CFI acquired from dwarf_getcfi_elf).  */
+   const Dwarf_Frame *initial_state;
+ 
+   uint8_t fde_encoding;		/* DW_EH_PE_* for addresses in FDEs.  */
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-13-dwfl-lazy-loading.patch b/elfutils-0.197-thread-safety-13-dwfl-lazy-loading.patch
new file mode 100644
index 0000000..c259b78
--- /dev/null
+++ b/elfutils-0.197-thread-safety-13-dwfl-lazy-loading.patch
@@ -0,0 +1,357 @@
+From 0f8ae537506a24f220e2cbc876916c9260eeaa7a Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 01:16:14 -0400
+Subject: [PATCH] libdwfl: Serialize module lazy loading entry points
+
+Add load_lock to Dwfl for serializing module loading, including loading
+of module's elf, dwarf, symbols as well as performing relocations.
+
+load_lock is used only for lazy loading of these components.  Hot paths
+are kept lock-free using atomics.  New Dwfl_Module fields elf_loaded,
+dwarf_loaded and symbols_loaded have been added.  These are set to
+true when lazy loading of elf, dwarf and symbols is completed.  They are
+also set to true when initialization has been attempted and failed.
+
+This commit serializes only the lazy loading entry points.
+
+libdwfl/
+
+	* dwfl_begin.c (dwfl_begin): Initialize load_lock.  Also move
+	  the debuginfod_lock init to avoid NULL dereference.
+	* dwfl_end.c (dwfl_end): Tear down load_lock.
+	* dwfl_module_build_id.c (found_build_id): Store build_id_len
+	  atomically.
+	  (dwfl_module_build_id): Attempt to read build_id_len
+	  atomically.  If it hasn't been loaded, acquire load_lock
+	  first.
+	* dwfl_module_getdwarf.c (find_symtab_locked): Renamed from
+	  find_symtab.
+	  (find_symtab): Wrapper for find_symtab_locked that handles
+	  locking and checking symbols_loaded.
+	  (get_dwarf_locked): Renamed from dwfl_module_getdwarf.
+	  (dwfl_module_getdwarf): Wrapper for get_dwarf_locked that
+	  handles locking and checking dwarf_loaded.
+	  (__libdwfl_getelf): Add a comment stating why build_id_len
+	  does not need an atomic store.
+	* dwfl_module_getelf.c (get_elf_locked): Renamed from
+	  dwfl_module_getelf.
+	  (dwfl_module_getelf): Wrapper for get_elf_locked that handles
+	  locking and checking elf_loaded.
+	* dwfl_module_getsym.c (__libdwfl_getsym): Check symbols_loaded
+	  before calling dwfl_module_getsymtab.
+	* libdwflP.h (struct Dwfl): Add load_lock.
+	  (struct Dwfl_Module): Add bools symbols_loaded, dwarf_loaded
+	  and elf_loaded.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libdwfl/dwfl_begin.c           |  4 +-
+ libdwfl/dwfl_end.c             |  1 +
+ libdwfl/dwfl_module_build_id.c | 31 ++++++++++-----
+ libdwfl/dwfl_module_getdwarf.c | 70 +++++++++++++++++++++++++---------
+ libdwfl/dwfl_module_getelf.c   | 33 +++++++++++++---
+ libdwfl/dwfl_module_getsym.c   |  3 +-
+ libdwfl/libdwflP.h             |  8 ++++
+ 7 files changed, 114 insertions(+), 36 deletions(-)
+
+diff --git a/libdwfl/dwfl_begin.c b/libdwfl/dwfl_begin.c
+index 835de8e3..2b029426 100644
+--- a/libdwfl/dwfl_begin.c
++++ b/libdwfl/dwfl_begin.c
+@@ -48,10 +48,10 @@ dwfl_begin (const Dwfl_Callbacks *callbacks)
+     {
+       dwfl->callbacks = callbacks;
+       dwfl->offline_next_address = OFFLINE_REDZONE;
++      mutex_init (dwfl->debuginfod_lock);
++      mutex_init (dwfl->load_lock);
+     }
+ 
+-  mutex_init (dwfl->debuginfod_lock);
+-
+   return dwfl;
+ }
+ INTDEF (dwfl_begin)
+diff --git a/libdwfl/dwfl_end.c b/libdwfl/dwfl_end.c
+index c82d83fb..97516a01 100644
+--- a/libdwfl/dwfl_end.c
++++ b/libdwfl/dwfl_end.c
+@@ -54,6 +54,7 @@ dwfl_end (Dwfl *dwfl)
+   free (dwfl->lookup_segndx);
+   free (dwfl->sysroot);
+   mutex_fini (dwfl->debuginfod_lock);
++  mutex_fini (dwfl->load_lock);
+ 
+   Dwfl_Module *next = dwfl->modulelist;
+   while (next != NULL)
+diff --git a/libdwfl/dwfl_module_build_id.c b/libdwfl/dwfl_module_build_id.c
+index 0c198f23..c3ff08f8 100644
+--- a/libdwfl/dwfl_module_build_id.c
++++ b/libdwfl/dwfl_module_build_id.c
+@@ -52,7 +52,9 @@ found_build_id (Dwfl_Module *mod, bool set,
+ 
+   mod->build_id_bits = memcpy (copy, bits, len);
+   mod->build_id_vaddr = vaddr;
+-  mod->build_id_len = len;
++
++  /* Build id readers check len to tell if bits and vaddr are also loaded.  */
++  atomic_store_release (&mod->build_id_len, len);
+   return len;
+ }
+ 
+@@ -85,23 +87,34 @@ dwfl_module_build_id (Dwfl_Module *mod,
+   if (mod == NULL)
+     return -1;
+ 
+-  if (mod->build_id_len == 0 && mod->main.elf != NULL)
++  int len = atomic_load_acquire (&mod->build_id_len);
++  if (len == 0)
+     {
+-      /* We have the file, but have not examined it yet.  */
+-      int result = __libdwfl_find_build_id (mod, true, mod->main.elf);
+-      if (result <= 0)
++      mutex_lock (mod->dwfl->load_lock);
++      len = mod->build_id_len;
++      if (len == 0 && mod->main.elf != NULL)
+ 	{
+-	  mod->build_id_len = -1;	/* Cache negative result.  */
+-	  return result;
++	  /* We have the file, but have not examined it yet.  */
++	  len = __libdwfl_find_build_id (mod, true, mod->main.elf);
++	  if (len <= 0)
++	    {
++	      /* Cache negative result.  */
++	      atomic_store_release (&mod->build_id_len, -1);
++	      mutex_unlock (mod->dwfl->load_lock);
++	      return len;
++	    }
+ 	}
++
++      mutex_unlock (mod->dwfl->load_lock);
+     }
+ 
+-  if (mod->build_id_len <= 0)
++  if (len <= 0)
+     return 0;
+ 
+   *bits = mod->build_id_bits;
+   *vaddr = mod->build_id_vaddr;
+-  return mod->build_id_len;
++
++  return len;
+ }
+ NEW_INTDEF (dwfl_module_build_id)
+ 
+diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
+index 430c3236..6c62ee1d 100644
+--- a/libdwfl/dwfl_module_getdwarf.c
++++ b/libdwfl/dwfl_module_getdwarf.c
+@@ -234,7 +234,9 @@ __libdwfl_getelf (Dwfl_Module *mod)
+   if (!mod->main.valid)
+     {
+       /* Clear any explicitly reported build ID, just in case it was wrong.
+-	 We'll fetch it from the file when asked.  */
++	 We'll fetch it from the file when asked.  The main ELF must be set
++	 during a caller-serialized phase before MOD is shared across threads,
++	 so no atomic store is needed here.  */
+       free (mod->build_id_bits);
+       mod->build_id_bits = NULL;
+       mod->build_id_len = 0;
+@@ -1075,12 +1077,8 @@ find_aux_sym (Dwfl_Module *mod __attribute__ ((unused)),
+ 
+ /* Try to find a symbol table in either MOD->main.elf or MOD->debug.elf.  */
+ static void
+-find_symtab (Dwfl_Module *mod)
++find_symtab_locked (Dwfl_Module *mod)
+ {
+-  if (mod->symdata != NULL || mod->aux_symdata != NULL	/* Already done.  */
+-      || mod->symerr != DWFL_E_NOERROR) /* Cached previous failure.  */
+-    return;
+-
+   __libdwfl_getelf (mod);
+   mod->symerr = mod->elferr;
+   if (mod->symerr != DWFL_E_NOERROR)
+@@ -1325,6 +1323,24 @@ find_symtab (Dwfl_Module *mod)
+     }
+ }
+ 
++/* Load the symtab if it isn't already loaded.  */
++static void
++find_symtab (Dwfl_Module *mod)
++{
++  if (likely (atomic_load_acquire (&mod->symbols_loaded)))
++    return;
++
++  mutex_lock (mod->dwfl->load_lock);
++  if (!mod->symbols_loaded && mod->symdata == NULL
++      && mod->aux_symdata == NULL && mod->symerr == DWFL_E_NOERROR)
++    {
++      find_symtab_locked (mod);
++      mod->symerr = __libdwfl_canon_error (mod->symerr);
++      atomic_store_release (&mod->symbols_loaded, true);
++    }
++
++  mutex_unlock (mod->dwfl->load_lock);
++}
+ 
+ /* Try to open a libebl backend for MOD.  */
+ Dwfl_Error
+@@ -1411,10 +1427,6 @@ load_dw (Dwfl_Module *mod, struct dwfl_file *debugfile)
+ static void
+ find_dw (Dwfl_Module *mod)
+ {
+-  if (mod->dw != NULL		/* Already done.  */
+-      || mod->dwerr != DWFL_E_NOERROR) /* Cached previous failure.  */
+-    return;
+-
+   __libdwfl_getelf (mod);
+   mod->dwerr = mod->elferr;
+   if (mod->dwerr != DWFL_E_NOERROR)
+@@ -1471,12 +1483,9 @@ find_dw (Dwfl_Module *mod)
+   mod->dwerr = __libdwfl_canon_error (mod->dwerr);
+ }
+ 
+-Dwarf *
+-dwfl_module_getdwarf (Dwfl_Module *mod, Dwarf_Addr *bias)
++static void
++get_dwarf_locked (Dwfl_Module *mod)
+ {
+-  if (mod == NULL)
+-    return NULL;
+-
+   find_dw (mod);
+   if (mod->dwerr == DWFL_E_NOERROR)
+     {
+@@ -1489,13 +1498,36 @@ dwfl_module_getdwarf (Dwfl_Module *mod, Dwarf_Addr *bias)
+ 	  if (mod->debug.elf != mod->main.elf)
+ 	    (void) __libdwfl_relocate (mod, mod->debug.elf, false);
+ 	}
++    }
++
++}
++
++Dwarf *
++dwfl_module_getdwarf (Dwfl_Module *mod, Dwarf_Addr *bias)
++{
++  if (mod == NULL)
++    return NULL;
++
++  if (unlikely (!atomic_load_acquire (&mod->dwarf_loaded)))
++    {
++      mutex_lock (mod->dwfl->load_lock);
++      if (!mod->dwarf_loaded && mod->dw == NULL && mod->dwerr == DWFL_E_NOERROR)
++	{
++	  get_dwarf_locked (mod);
++	  atomic_store_release (&mod->dwarf_loaded, true);
++	}
+ 
+-      *bias = dwfl_adjusted_dwarf_addr (mod, 0);
+-      return mod->dw;
++      mutex_unlock (mod->dwfl->load_lock);
++    }
++
++  if (mod->dwerr != DWFL_E_NOERROR)
++    {
++      __libdwfl_seterrno (mod->dwerr);
++      return NULL;
+     }
+ 
+-  __libdwfl_seterrno (mod->dwerr);
+-  return NULL;
++  *bias = dwfl_adjusted_dwarf_addr (mod, 0);
++  return mod->dw;
+ }
+ INTDEF (dwfl_module_getdwarf)
+ 
+diff --git a/libdwfl/dwfl_module_getelf.c b/libdwfl/dwfl_module_getelf.c
+index 6358de4c..e3a0197b 100644
+--- a/libdwfl/dwfl_module_getelf.c
++++ b/libdwfl/dwfl_module_getelf.c
+@@ -32,12 +32,9 @@
+ 
+ #include "libdwflP.h"
+ 
+-Elf *
+-dwfl_module_getelf (Dwfl_Module *mod, GElf_Addr *loadbase)
++static Elf *
++get_elf_locked (Dwfl_Module *mod, GElf_Addr *loadbase)
+ {
+-  if (mod == NULL)
+-    return NULL;
+-
+   __libdwfl_getelf (mod);
+   if (mod->elferr == DWFL_E_NOERROR)
+     {
+@@ -68,4 +65,30 @@ dwfl_module_getelf (Dwfl_Module *mod, GElf_Addr *loadbase)
+   __libdwfl_seterrno (mod->elferr);
+   return NULL;
+ }
++
++Elf *
++dwfl_module_getelf (Dwfl_Module *mod, GElf_Addr *loadbase)
++{
++  if (mod == NULL)
++    return NULL;
++
++  if (likely (atomic_load_acquire (&mod->elf_loaded)))
++    {
++      if (mod->elferr != DWFL_E_NOERROR)
++	{
++	  __libdwfl_seterrno (mod->elferr);
++	  return NULL;
++	}
++
++      *loadbase = dwfl_adjusted_address (mod, 0);
++      return mod->main.elf;
++    }
++
++  mutex_lock (mod->dwfl->load_lock);
++  Elf *elf = get_elf_locked (mod, loadbase);
++  atomic_store_release (&mod->elf_loaded, true);
++  mutex_unlock (mod->dwfl->load_lock);
++
++  return elf;
++}
+ INTDEF (dwfl_module_getelf)
+diff --git a/libdwfl/dwfl_module_getsym.c b/libdwfl/dwfl_module_getsym.c
+index 8de9a3eb..2bb07fd8 100644
+--- a/libdwfl/dwfl_module_getsym.c
++++ b/libdwfl/dwfl_module_getsym.c
+@@ -41,7 +41,8 @@ __libdwfl_getsym (Dwfl_Module *mod, int ndx, GElf_Sym *sym, GElf_Addr *addr,
+   if (unlikely (mod == NULL))
+     return NULL;
+ 
+-  if (unlikely (mod->symdata == NULL))
++  if (unlikely (!atomic_load_acquire (&mod->symbols_loaded)
++		|| mod->symdata == NULL))
+     {
+       int result = INTUSE(dwfl_module_getsymtab) (mod);
+       if (result < 0)
+diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
+index 7a181029..6e2c2f8b 100644
+--- a/libdwfl/libdwflP.h
++++ b/libdwfl/libdwflP.h
+@@ -144,6 +144,10 @@ struct Dwfl
+ 
+   /* Serialize debuginfod_client usage.  */
+   mutex_define (, debuginfod_lock);
++
++  /* Serialize loading of ELF/DWARF, relocations, symbols as well as
++     Dwfl_Callbacks.*/
++  mutex_define (, load_lock);
+ };
+ 
+ #define OFFLINE_REDZONE		0x10000
+@@ -206,6 +210,10 @@ struct Dwfl_Module
+   Dwfl_Error symerr;		/* Previous failure to load symbols.  */
+   Dwfl_Error dwerr;		/* Previous failure to load DWARF.  */
+ 
++  bool symbols_loaded;		/* True if symbols loaded or failed to load.  */
++  bool dwarf_loaded;		/* True if dwarf loaded or failed to load.  */
++  bool elf_loaded;		/* True if elf loaded or failed to load.  */
++
+   /* Known CU's in this module.  */
+   struct dwfl_cu *first_cu, **cu;
+ 
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-14-dwfl-cfi-cache.patch b/elfutils-0.197-thread-safety-14-dwfl-cfi-cache.patch
new file mode 100644
index 0000000..5387b1a
--- /dev/null
+++ b/elfutils-0.197-thread-safety-14-dwfl-cfi-cache.patch
@@ -0,0 +1,170 @@
+From 6c6cf6cd33352a5166ef8a0f62560ec267d8b467 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 01:16:15 -0400
+Subject: [PATCH] libdwfl: Serialize CFI cache initialization
+
+Use a CFI cache's corresponding dwfl load_lock to serialize its
+initialization.  Rename __libdwfl_set_cfi to __libdwfl_set_cfi_locked
+to indicate that the caller must hold the load_lock.   Atomics are used
+to acquire an initialized CFI cache without needing to obtain the
+load_lock.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libdwfl/dwfl_module.c           |  2 +-
+ libdwfl/dwfl_module_dwarf_cfi.c | 38 ++++++++++++++++++++++++++-------
+ libdwfl/dwfl_module_eh_cfi.c    | 26 +++++++++++++++-------
+ libdwfl/libdwflP.h              |  7 +++---
+ 4 files changed, 53 insertions(+), 20 deletions(-)
+
+diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c
+index b4ddf806..27e6c064 100644
+--- a/libdwfl/dwfl_module.c
++++ b/libdwfl/dwfl_module.c
+@@ -74,7 +74,7 @@ __libdwfl_module_free (Dwfl_Module *mod)
+     }
+ 
+   /* We might have primed the Dwarf_CFI ebl cache with our own ebl
+-     in __libdwfl_set_cfi. Make sure we don't free it twice.  */
++     in __libdwfl_set_cfi_locked. Make sure we don't free it twice.  */
+   if (mod->eh_cfi != NULL)
+     {
+       if (mod->eh_cfi->ebl != NULL && mod->eh_cfi->ebl == mod->ebl)
+diff --git a/libdwfl/dwfl_module_dwarf_cfi.c b/libdwfl/dwfl_module_dwarf_cfi.c
+index 05a14f7c..a8b2d9a5 100644
+--- a/libdwfl/dwfl_module_dwarf_cfi.c
++++ b/libdwfl/dwfl_module_dwarf_cfi.c
+@@ -35,15 +35,26 @@
+ 
+ Dwarf_CFI *
+ internal_function
+-__libdwfl_set_cfi (Dwfl_Module *mod, Dwarf_CFI **slot, Dwarf_CFI *cfi)
++__libdwfl_set_cfi_locked (Dwfl_Module *mod, Dwarf_CFI **slot, Dwarf_CFI *cfi)
+ {
+-  if (cfi != NULL && cfi->ebl == NULL)
++  if (slot != &mod->eh_cfi && slot != &mod->dwarf_cfi)
++    {
++      __libdwfl_seterrno (DWFL_E_INVALID_ARGUMENT);
++      return NULL;
++    }
++
++  if (cfi == NULL)
++    return NULL;
++
++  mutex_lock (cfi->lock);
++  if (cfi->ebl == NULL)
+     {
+       Dwfl_Error error = __libdwfl_module_getebl (mod);
+       if (error == DWFL_E_NOERROR)
+ 	cfi->ebl = mod->ebl;
+       else
+ 	{
++	  mutex_unlock (cfi->lock);
+ 	  if (slot == &mod->eh_cfi)
+ 	    INTUSE(dwarf_cfi_end) (cfi);
+ 	  __libdwfl_seterrno (error);
+@@ -51,7 +62,9 @@ __libdwfl_set_cfi (Dwfl_Module *mod, Dwarf_CFI **slot, Dwarf_CFI *cfi)
+ 	}
+     }
+ 
+-  return *slot = cfi;
++  atomic_store_release (slot, cfi);
++  mutex_unlock (cfi->lock);
++  return cfi;
+ }
+ 
+ Dwarf_CFI *
+@@ -60,14 +73,23 @@ dwfl_module_dwarf_cfi (Dwfl_Module *mod, Dwarf_Addr *bias)
+   if (mod == NULL)
+     return NULL;
+ 
+-  if (mod->dwarf_cfi != NULL)
++  Dwarf_CFI *cfi = atomic_load_acquire (&mod->dwarf_cfi);
++  if (cfi != NULL)
+     {
+       *bias = dwfl_adjusted_dwarf_addr (mod, 0);
+-      return mod->dwarf_cfi;
++      return cfi;
+     }
+ 
+-  return __libdwfl_set_cfi (mod, &mod->dwarf_cfi,
+-			    INTUSE(dwarf_getcfi)
+-			    (INTUSE(dwfl_module_getdwarf) (mod, bias)));
++  mutex_lock (mod->dwfl->load_lock);
++  cfi = mod->dwarf_cfi;
++  if (cfi == NULL)
++    cfi = __libdwfl_set_cfi_locked (mod, &mod->dwarf_cfi,
++				    INTUSE(dwarf_getcfi)
++				    (INTUSE(dwfl_module_getdwarf) (mod, bias)));
++  else
++    *bias = dwfl_adjusted_dwarf_addr (mod, 0);
++
++  mutex_unlock (mod->dwfl->load_lock);
++  return cfi;
+ }
+ INTDEF (dwfl_module_dwarf_cfi)
+diff --git a/libdwfl/dwfl_module_eh_cfi.c b/libdwfl/dwfl_module_eh_cfi.c
+index aac6657d..cc28ad60 100644
+--- a/libdwfl/dwfl_module_eh_cfi.c
++++ b/libdwfl/dwfl_module_eh_cfi.c
+@@ -39,21 +39,31 @@ dwfl_module_eh_cfi (Dwfl_Module *mod, Dwarf_Addr *bias)
+   if (mod == NULL)
+     return NULL;
+ 
+-  if (mod->eh_cfi != NULL)
++  Dwarf_CFI *cfi = atomic_load_acquire (&mod->eh_cfi);
++  if (cfi != NULL)
+     {
+       *bias = dwfl_adjusted_address (mod, 0);
+-      return mod->eh_cfi;
++      return cfi;
+     }
+ 
+-  __libdwfl_getelf (mod);
+-  if (mod->elferr != DWFL_E_NOERROR)
++  mutex_lock (mod->dwfl->load_lock);
++  cfi = mod->eh_cfi;
++  if (cfi == NULL)
+     {
+-      __libdwfl_seterrno (mod->elferr);
+-      return NULL;
++      __libdwfl_getelf (mod);
++      if (mod->elferr != DWFL_E_NOERROR)
++	{
++	  __libdwfl_seterrno (mod->elferr);
++	  mutex_unlock (mod->dwfl->load_lock);
++	  return NULL;
++	}
++
++      cfi = __libdwfl_set_cfi_locked (mod, &mod->eh_cfi,
++				      INTUSE(dwarf_getcfi_elf) (mod->main.elf));
+     }
+ 
++  mutex_unlock (mod->dwfl->load_lock);
+   *bias = dwfl_adjusted_address (mod, 0);
+-  return __libdwfl_set_cfi (mod, &mod->eh_cfi,
+-			    INTUSE(dwarf_getcfi_elf) (mod->main.elf));
++  return cfi;
+ }
+ INTDEF (dwfl_module_eh_cfi)
+diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
+index 6e2c2f8b..3b4df7e8 100644
+--- a/libdwfl/libdwflP.h
++++ b/libdwfl/libdwflP.h
+@@ -529,9 +529,10 @@ extern Dwfl_Error __libdwfl_relocate_value (Dwfl_Module *mod, Elf *elf,
+ /* Ensure that MOD->ebl is set up.  */
+ extern Dwfl_Error __libdwfl_module_getebl (Dwfl_Module *mod) internal_function;
+ 
+-/* Install a new Dwarf_CFI in *SLOT (MOD->eh_cfi or MOD->dwarf_cfi).  */
+-extern Dwarf_CFI *__libdwfl_set_cfi (Dwfl_Module *mod, Dwarf_CFI **slot,
+-				     Dwarf_CFI *cfi)
++/* Install a new Dwarf_CFI in *SLOT (MOD->eh_cfi or MOD->dwarf_cfi).
++   MOD->dwfl->load_lock must be held by the caller.  */
++extern Dwarf_CFI *__libdwfl_set_cfi_locked (Dwfl_Module *mod, Dwarf_CFI **slot,
++					    Dwarf_CFI *cfi)
+   internal_function;
+ 
+ /* Iterate through all the CU's in the module.  Start by passing a null
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-15-dwfl-backend.patch b/elfutils-0.197-thread-safety-15-dwfl-backend.patch
new file mode 100644
index 0000000..dbe29ad
--- /dev/null
+++ b/elfutils-0.197-thread-safety-15-dwfl-backend.patch
@@ -0,0 +1,159 @@
+From 5accf0ec8251992fbe137cbe554e9c76f68a40c7 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 01:16:16 -0400
+Subject: [PATCH] libdwfl: Synchronize access to backend
+
+Store a Dwfl_Module's ebl field atomically in __libdwfl_module_getebl
+while holding the associated Dwfl load_lock.
+
+Change usage of the ebl field so that before using it's either been
+atomically read or else it's used after __libdwfl_module_getebl returns
+DWFL_E_NOERROR.
+
+In __libdwfl_getsym also initialize the backend before calling
+ebl_func_addr_mask and return early if it fails.
+
+Also fix a bug where ebl wasn't initialized before calling
+ebl_func_addr_mask.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libdwfl/dwfl_module_getdwarf.c              | 24 +++++++++++++++------
+ libdwfl/dwfl_module_getsym.c                | 24 ++++++++++++---------
+ libdwfl/dwfl_module_register_names.c        | 11 ++++------
+ libdwfl/dwfl_module_return_value_location.c | 11 ++++------
+ 4 files changed, 40 insertions(+), 30 deletions(-)
+
+diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
+index 6c62ee1d..eb7b3f8c 100644
+--- a/libdwfl/dwfl_module_getdwarf.c
++++ b/libdwfl/dwfl_module_getdwarf.c
+@@ -1347,17 +1347,29 @@ Dwfl_Error
+ internal_function
+ __libdwfl_module_getebl (Dwfl_Module *mod)
+ {
++  if (likely (atomic_load_acquire (&mod->ebl) != NULL))
++    return DWFL_E_NOERROR;
++
++  Dwfl_Error ret = DWFL_E_NOERROR;
++  mutex_lock (mod->dwfl->load_lock);
++
+   if (mod->ebl == NULL)
+     {
+       __libdwfl_getelf (mod);
+-      if (mod->elferr != DWFL_E_NOERROR)
+-	return mod->elferr;
++      ret = mod->elferr;
+ 
+-      mod->ebl = ebl_openbackend (mod->main.elf);
+-      if (mod->ebl == NULL)
+-	return DWFL_E_LIBEBL;
++      if (ret == DWFL_E_NOERROR)
++	{
++	  Ebl *ebl = ebl_openbackend (mod->main.elf);
++	  if (ebl == NULL)
++	    ret = DWFL_E_LIBEBL;
++	  else
++	    atomic_store_release (&mod->ebl, ebl);
++	}
+     }
+-  return DWFL_E_NOERROR;
++
++  mutex_unlock (mod->dwfl->load_lock);
++  return ret;
+ }
+ 
+ /* Try to start up libdw on DEBUGFILE.  */
+diff --git a/libdwfl/dwfl_module_getsym.c b/libdwfl/dwfl_module_getsym.c
+index 2bb07fd8..3a364a76 100644
+--- a/libdwfl/dwfl_module_getsym.c
++++ b/libdwfl/dwfl_module_getsym.c
+@@ -123,6 +123,13 @@ __libdwfl_getsym (Dwfl_Module *mod, int ndx, GElf_Sym *sym, GElf_Addr *addr,
+      might know where the real value is (e.g. for function
+      descriptors).  */
+ 
++  Dwfl_Error error = __libdwfl_module_getebl (mod);
++  if (unlikely (error != DWFL_E_NOERROR))
++    {
++      __libdwfl_seterrno (error);
++      return NULL;
++    }
++
+   char *ident;
+   GElf_Addr st_value = sym->st_value & ebl_func_addr_mask (mod->ebl);
+   *resolved = false;
+@@ -132,18 +139,15 @@ __libdwfl_getsym (Dwfl_Module *mod, int ndx, GElf_Sym *sym, GElf_Addr *addr,
+ 	      && (ident = elf_getident (elf, NULL)) != NULL
+ 	      && ident[EI_OSABI] == ELFOSABI_LINUX)))
+     {
+-      if (likely (__libdwfl_module_getebl (mod) == DWFL_E_NOERROR))
++      if (elf != mod->main.elf)
+ 	{
+-	  if (elf != mod->main.elf)
+-	    {
+-	      st_value = dwfl_adjusted_st_value (mod, elf, st_value);
+-	      st_value = dwfl_deadjust_st_value (mod, mod->main.elf, st_value);
+-	    }
+-
+-	  *resolved = ebl_resolve_sym_value (mod->ebl, &st_value);
+-	  if (! *resolved)
+-	    st_value = sym->st_value;
++	  st_value = dwfl_adjusted_st_value (mod, elf, st_value);
++	  st_value = dwfl_deadjust_st_value (mod, mod->main.elf, st_value);
+ 	}
++
++      *resolved = ebl_resolve_sym_value (mod->ebl, &st_value);
++      if (! *resolved)
++	st_value = sym->st_value;
+     }
+ 
+   if (shndxp != NULL)
+diff --git a/libdwfl/dwfl_module_register_names.c b/libdwfl/dwfl_module_register_names.c
+index 9ea09371..a8aa8a65 100644
+--- a/libdwfl/dwfl_module_register_names.c
++++ b/libdwfl/dwfl_module_register_names.c
+@@ -43,14 +43,11 @@ dwfl_module_register_names (Dwfl_Module *mod,
+   if (unlikely (mod == NULL))
+     return -1;
+ 
+-  if (unlikely (mod->ebl == NULL))
++  Dwfl_Error error = __libdwfl_module_getebl (mod);
++  if (unlikely (error != DWFL_E_NOERROR))
+     {
+-      Dwfl_Error error = __libdwfl_module_getebl (mod);
+-      if (error != DWFL_E_NOERROR)
+-	{
+-	  __libdwfl_seterrno (error);
+-	  return -1;
+-	}
++      __libdwfl_seterrno (error);
++      return -1;
+     }
+ 
+   int nregs = ebl_register_info (mod->ebl, -1, NULL, 0,
+diff --git a/libdwfl/dwfl_module_return_value_location.c b/libdwfl/dwfl_module_return_value_location.c
+index ff6f56f8..8a3e63a9 100644
+--- a/libdwfl/dwfl_module_return_value_location.c
++++ b/libdwfl/dwfl_module_return_value_location.c
+@@ -40,14 +40,11 @@ dwfl_module_return_value_location (Dwfl_Module *mod, Dwarf_Die *functypedie,
+   if (mod == NULL)
+     return -1;
+ 
+-  if (mod->ebl == NULL)
++  Dwfl_Error error = __libdwfl_module_getebl (mod);
++  if (error != DWFL_E_NOERROR)
+     {
+-      Dwfl_Error error = __libdwfl_module_getebl (mod);
+-      if (error != DWFL_E_NOERROR)
+-	{
+-	  __libdwfl_seterrno (error);
+-	  return -1;
+-	}
++      __libdwfl_seterrno (error);
++      return -1;
+     }
+ 
+   int nops = ebl_return_value_location (mod->ebl, functypedie, locops);
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-16-dwfl-aranges.patch b/elfutils-0.197-thread-safety-16-dwfl-aranges.patch
new file mode 100644
index 0000000..5ba57d8
--- /dev/null
+++ b/elfutils-0.197-thread-safety-16-dwfl-aranges.patch
@@ -0,0 +1,185 @@
+From 1f70973b0e8f7b013b9669b93d7edefd31aa85b9 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 01:16:17 -0400
+Subject: [PATCH] libdwfl: Serialize aranges initialization
+
+Move addrarange's initialization code into new function
+addrarange_locked, which addrarange calls while holding
+dwfl->load_lock.
+
+Also move arangecu's CU initialization code into new function
+arangecu_locked, which arangecu calls while holding dwfl->load_lock.
+
+Atomics are used to acquire initialized aranges and their CUs without
+needing to obtain the load_lock.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libdwfl/cu.c | 128 +++++++++++++++++++++++++++++++++------------------
+ 1 file changed, 84 insertions(+), 44 deletions(-)
+
+diff --git a/libdwfl/cu.c b/libdwfl/cu.c
+index 416773b3..2087ca46 100644
+--- a/libdwfl/cu.c
++++ b/libdwfl/cu.c
+@@ -43,52 +43,72 @@ dwar (Dwfl_Module *mod, unsigned int idx)
+ }
+ 
+ 
++static Dwfl_Error
++addrarange_locked (Dwfl_Module *mod, struct dwfl_arange **result)
++{
++  struct dwfl_arange *aranges = NULL;
++  Dwarf_Aranges *dwaranges = NULL;
++  size_t naranges;
++  if (__libdw_getdieranges (mod->dw, &dwaranges, &naranges) != 0)
++    return DWFL_E_LIBDW;
++
++  /* If the module has no aranges (when no code is included) we
++     allocate nothing.  */
++  if (naranges != 0)
++    {
++      aranges = malloc (naranges * sizeof *aranges);
++      if (unlikely (aranges == NULL))
++	return DWFL_E_NOMEM;
++
++      /* libdw has sorted its list by address, which is how we want it.
++	 But the sorted list is full of not-quite-contiguous runs pointing
++	 to the same CU.  We don't care about the little gaps inside the
++	 module, we'll consider them part of the surrounding CU anyway.
++	 Collect our own array with just one record for each run of ranges
++	 pointing to one CU.  */
++
++      naranges = 0;
++      Dwarf_Off lastcu = 0;
++      for (size_t i = 0; i < dwaranges->naranges; ++i)
++	if (i == 0 || dwaranges->info[i].offset != lastcu)
++	  {
++	    aranges[naranges].arange = i;
++	    aranges[naranges].cu = NULL;
++	    ++naranges;
++	    lastcu = dwaranges->info[i].offset;
++	  }
++    }
++
++  /* Store the final array, which is probably much smaller than before.  */
++  mod->naranges = naranges;
++  if (naranges > 0)
++    *result = (realloc (aranges, naranges * sizeof aranges[0]) ?: aranges);
++  else if (aranges != NULL)
++    free (aranges);
++  mod->lazycu += naranges;
++
++  return DWFL_E_NOERROR;
++}
++
+ static Dwfl_Error
+ addrarange (Dwfl_Module *mod, Dwarf_Addr addr, struct dwfl_arange **arange)
+ {
+-  if (mod->aranges == NULL)
++  if (unlikely (atomic_load_acquire (&mod->aranges) == NULL))
+     {
+       struct dwfl_arange *aranges = NULL;
+-      Dwarf_Aranges *dwaranges = NULL;
+-      size_t naranges;
+-      if (__libdw_getdieranges (mod->dw, &dwaranges, &naranges) != 0)
+-	return DWFL_E_LIBDW;
++      Dwfl_Error error = DWFL_E_NOERROR;
+ 
+-      /* If the module has no aranges (when no code is included) we
+-	 allocate nothing.  */
+-      if (naranges != 0)
++      mutex_lock (mod->dwfl->load_lock);
++      if (mod->aranges == NULL)
+ 	{
+-	  aranges = malloc (naranges * sizeof *aranges);
+-	  if (unlikely (aranges == NULL))
+-	    return DWFL_E_NOMEM;
+-
+-	  /* libdw has sorted its list by address, which is how we want it.
+-	     But the sorted list is full of not-quite-contiguous runs pointing
+-	     to the same CU.  We don't care about the little gaps inside the
+-	     module, we'll consider them part of the surrounding CU anyway.
+-	     Collect our own array with just one record for each run of ranges
+-	     pointing to one CU.  */
+-
+-	  naranges = 0;
+-	  Dwarf_Off lastcu = 0;
+-	  for (size_t i = 0; i < dwaranges->naranges; ++i)
+-	    if (i == 0 || dwaranges->info[i].offset != lastcu)
+-	      {
+-		aranges[naranges].arange = i;
+-		aranges[naranges].cu = NULL;
+-		++naranges;
+-		lastcu = dwaranges->info[i].offset;
+-	      }
++	  error = addrarange_locked (mod, &aranges);
++	  if (error == DWFL_E_NOERROR)
++	    atomic_store_release (&mod->aranges, aranges);
+ 	}
+ 
+-      /* Store the final array, which is probably much smaller than before.  */
+-      mod->naranges = naranges;
+-      if (naranges > 0)
+-        mod->aranges = (realloc (aranges, naranges * sizeof aranges[0])
+-			?: aranges);
+-      else if (aranges != NULL)
+-	free (aranges);
+-      mod->lazycu += naranges;
++      mutex_unlock (mod->dwfl->load_lock);
++      if (error != DWFL_E_NOERROR)
++	return error;
+     }
+ 
+   /* The address must be inside the module to begin with.  */
+@@ -288,20 +308,40 @@ __libdwfl_nextcu (Dwfl_Module *mod, struct dwfl_cu *lastcu,
+   return DWFL_E_NOERROR;
+ }
+ 
++static Dwfl_Error
++arangecu_locked (Dwfl_Module *mod, struct dwfl_arange *arange,
++		 struct dwfl_cu **cu)
++{
++  const Dwarf_Arange *dwarange = &mod->dw->dieranges->info[arange->arange];
++  Dwfl_Error result = intern_cu (mod, dwarange->offset, cu);
++  if (result != DWFL_E_NOERROR)
++    return result;
++  assert (*cu != NULL && *cu != (void *) -1l);
++  less_lazy (mod);		/* Each arange with null ->cu counts once.  */
++
++  return DWFL_E_NOERROR;
++}
+ 
+ /* Intern the CU arange points to, if necessary.  */
+ 
+ static Dwfl_Error
+ arangecu (Dwfl_Module *mod, struct dwfl_arange *arange, struct dwfl_cu **cu)
+ {
+-  if (arange->cu == NULL)
++  if (unlikely (atomic_load_acquire (&arange->cu) == NULL))
+     {
+-      const Dwarf_Arange *dwarange = &mod->dw->dieranges->info[arange->arange];
+-      Dwfl_Error result = intern_cu (mod, dwarange->offset, &arange->cu);
+-      if (result != DWFL_E_NOERROR)
+-	return result;
+-      assert (arange->cu != NULL && arange->cu != (void *) -1l);
+-      less_lazy (mod);		/* Each arange with null ->cu counts once.  */
++      Dwfl_Error error = DWFL_E_NOERROR;
++      mutex_lock (mod->dwfl->load_lock);
++      if (arange->cu == NULL)
++	{
++	  struct dwfl_cu *newcu = NULL;
++	  error = arangecu_locked (mod, arange, &newcu);
++	  if (error == DWFL_E_NOERROR)
++	    atomic_store_release (&arange->cu, newcu);
++	}
++
++      mutex_unlock (mod->dwfl->load_lock);
++      if (error != DWFL_E_NOERROR)
++	return error;
+     }
+ 
+   *cu = arange->cu;
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-17-dwarf_formref_die-toctou.patch b/elfutils-0.197-thread-safety-17-dwarf_formref_die-toctou.patch
new file mode 100644
index 0000000..6c94902
--- /dev/null
+++ b/elfutils-0.197-thread-safety-17-dwarf_formref_die-toctou.patch
@@ -0,0 +1,33 @@
+From 89d5fa985bb074a25d635431f0e914b7e84d8125 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Fri, 30 Oct 2026 12:08:06 -0400
+Subject: [PATCH] dwarf_formref_die.c: Avoid TOCTOU race in dwarf_formref_die
+
+dwarf_formref_die acquires attr->cu->dbg->dwarf_lock before interning a
+CU.  After acquiring there is a missing check for whether another thread
+interned the CU while the current thread was waiting for the lock.  Add
+this check.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ libdw/dwarf_formref_die.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/libdw/dwarf_formref_die.c b/libdw/dwarf_formref_die.c
+index 1bedf5e9..15aea2f6 100644
+--- a/libdw/dwarf_formref_die.c
++++ b/libdw/dwarf_formref_die.c
+@@ -95,7 +95,9 @@ dwarf_formref_die (Dwarf_Attribute *attr, Dwarf_Die *result)
+ 	  do
+ 	    {
+ 	      mutex_lock (attr->cu->dbg->dwarf_lock);
+-	      cu = __libdw_intern_next_unit (attr->cu->dbg, scan_debug_types);
++	      cu = Dwarf_Sig8_Hash_find (&attr->cu->dbg->sig8_hash, sig);
++	      if (cu == NULL)
++		cu = __libdw_intern_next_unit (attr->cu->dbg, scan_debug_types);
+ 	      mutex_unlock (attr->cu->dbg->dwarf_lock);
+ 
+ 	      if (cu == NULL)
+-- 
+2.56.0
+

diff --git a/elfutils-0.197-thread-safety-18-dynamicsizehash-lockfree-find.patch b/elfutils-0.197-thread-safety-18-dynamicsizehash-lockfree-find.patch
new file mode 100644
index 0000000..5fd381c
--- /dev/null
+++ b/elfutils-0.197-thread-safety-18-dynamicsizehash-lockfree-find.patch
@@ -0,0 +1,252 @@
+From eef98f2a160f6a6725b48ebe1f561c0b97eeefe7 Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Wed, 30 Sep 2026 15:05:38 -0400
+Subject: [PATCH] lib/dynamicsizehash_concurrent.c: Implement lock-free lookups
+
+libdw's concurrent hash tables currently take an rwlock for every
+FIND operation, adding significant overhead for FIND-heavy workloads.
+
+Modify FIND to avoid taking a lock when the hash table isn't being
+resized.  To ensure that table pointers always remain valid for all
+threads, do not free the prior table when allocating a new one during
+resize.  All tables are freed during the hash table FREE operation.
+Excess memory consumed by old tables is always less than the size
+of the current table.
+
+dwflst_tracker_end now calls hash table FREE to ensure that all
+tables are freed.  Previously it manually freed the hash table.
+
+To facilitate this lock-free design, entry 0 of a hash table now
+stores its size and a pointer to the hash table used before the
+last resize (if any).
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ lib/dynamicsizehash_concurrent.c            | 89 +++++++++++++++------
+ lib/dynamicsizehash_concurrent.h            |  5 +-
+ libdwfl_stacktrace/dwflst_process_tracker.c |  6 +-
+ 3 files changed, 71 insertions(+), 29 deletions(-)
+
+diff --git a/lib/dynamicsizehash_concurrent.c b/lib/dynamicsizehash_concurrent.c
+index 2ea545e0..e5222bb3 100644
+--- a/lib/dynamicsizehash_concurrent.c
++++ b/lib/dynamicsizehash_concurrent.c
+@@ -38,35 +38,37 @@
+    TYPE      data type of the hash table entries
+  */
+ 
++/* Name of the table entry type.  */
++#define ENTRY(name) _ENTRY (name)
++#define _ENTRY(name) \
++  name##_ent
+ 
+ static size_t
+-lookup (NAME *htab, HASHTYPE hval)
++lookup (ENTRY(NAME) *table, size_t size, HASHTYPE hval)
+ {
+   /* First hash function: simply take the modulus but prevent zero.  Small values
+       can skip the division, which helps performance when this is common.  */
+-  size_t idx = 1 + (hval < htab->size ? hval : hval % htab->size);
++  size_t idx = 1 + (hval < size ? hval : hval % size);
+ 
+   HASHTYPE hash;
+ 
+-  hash = atomic_load_explicit(&htab->table[idx].hashval,
+-                              memory_order_acquire);
++  hash = atomic_load_explicit(&table[idx].hashval, memory_order_acquire);
+   if (hash == hval)
+     return idx;
+   else if (hash == 0)
+     return 0;
+ 
+   /* Second hash function as suggested in [Knuth].  */
+-  HASHTYPE second_hash = 1 + hval % (htab->size - 2);
++  HASHTYPE second_hash = 1 + hval % (size - 2);
+ 
+   for(;;)
+     {
+       if (idx <= second_hash)
+-          idx = htab->size + idx - second_hash;
++          idx = size + idx - second_hash;
+       else
+           idx -= second_hash;
+ 
+-      hash = atomic_load_explicit(&htab->table[idx].hashval,
+-                                  memory_order_acquire);
++      hash = atomic_load_explicit(&table[idx].hashval, memory_order_acquire);
+       if (hash == hval)
+ 	return idx;
+       else if (hash == 0)
+@@ -254,7 +256,7 @@ static void resize_helper(NAME *htab, int blocking)
+ 
+ /* Called by the main thread holding the htab->resize_rwl lock to
+    coordinate the moving of hash table data. Allocates the new hash
+-   table and frees the old one when moving all data is done.  */
++   table.  */
+ static void
+ resize_coordinator(NAME *htab)
+ {
+@@ -262,8 +264,17 @@ resize_coordinator(NAME *htab)
+   htab->old_table = htab->table;
+ 
+   htab->size = next_prime(htab->size * 2);
+-  htab->table = malloc((1 + htab->size) * sizeof(htab->table[0]));
+-  assert(htab->table);
++
++  ENTRY(NAME) *table = malloc((1 + htab->size) * sizeof(htab->table[0]));
++  assert(table);
++
++  /* Store this table's size with the table itself.  */
++  atomic_init (&table[0].hashval, htab->size);
++
++  /* Preserve old_table in case other threads are reading it.  */
++  atomic_init (&table[0].val_ptr, (uintptr_t) htab->old_table);
++
++  __atomic_store_n(&htab->table, table, __ATOMIC_RELEASE);
+ 
+   /* Change state from ALLOCATING_MEMORY to MOVING_DATA */
+   atomic_fetch_xor_explicit(&htab->resizing_state,
+@@ -288,12 +299,9 @@ resize_coordinator(NAME *htab)
+   atomic_store_explicit(&htab->next_move_block, 0, memory_order_relaxed);
+   atomic_store_explicit(&htab->num_moved_blocks, 0, memory_order_relaxed);
+ 
+-  free(htab->old_table);
+-
+   /* Change state to NO_RESIZING */
+   atomic_fetch_xor_explicit(&htab->resizing_state, CLEANING ^ NO_RESIZING,
+-                            memory_order_relaxed);
+-
++                            memory_order_release);
+ }
+ 
+ /* Called by any thread that wants to do an insert or find operation
+@@ -369,7 +377,12 @@ INIT(NAME) (NAME *htab, size_t init_size)
+   if (htab->table == NULL)
+       return -1;
+ 
+-  for (size_t i = 0; i <= init_size; i++)
++  /* Entry zero stores the size of this table as well as the previous table
++     used prior to the last resize (NULL in this case).  */
++  atomic_init(&htab->table[0].hashval, (uintptr_t) init_size);
++  atomic_init(&htab->table[0].val_ptr, (uintptr_t) NULL);
++
++  for (size_t i = 1; i <= init_size; i++)
+     {
+       atomic_init(&htab->table[i].hashval, (uintptr_t) NULL);
+       atomic_init(&htab->table[i].val_ptr, (uintptr_t) NULL);
+@@ -386,7 +399,16 @@ name##_free
+ FREE(NAME) (NAME *htab)
+ {
+   pthread_rwlock_destroy(&htab->resize_rwl);
+-  free (htab->table);
++
++  ENTRY(NAME) *cur = htab->table;
++  while (cur != NULL)
++    {
++      ENTRY(NAME) *t = cur;
++      cur = (ENTRY(NAME) *) atomic_load_explicit(&cur[0].val_ptr,
++                                                  memory_order_relaxed);
++      free (t);
++    }
++
+   return 0;
+ }
+ 
+@@ -470,17 +492,38 @@ TYPE
+   name##_find
+ FIND(NAME) (NAME *htab, HASHTYPE hval)
+ {
+-  /* If we cannot get the resize_rwl lock someone is resizing
+-     the hash table, try to help out by moving table data.  */
+-  while (pthread_rwlock_tryrdlock(&htab->resize_rwl) != 0)
+-    resize_worker(htab);
++  size_t idx = 0;
+ 
+-  size_t idx;
++  /* Snapshot of the current table.  This pointer stays valid even if a
++     new table is allocated during resize.  */
++  ENTRY(NAME) *table = __atomic_load_n(&htab->table, __ATOMIC_ACQUIRE);
+ 
+   /* Make the hash data nonzero.  */
+   hval = hval ?: 1;
+-  idx = lookup(htab, hval);
+ 
++  /* Make sure the current table isn't in the middle of a resize with
++     uninitialized entries present.  */
++  if (atomic_load_explicit(&htab->resizing_state, memory_order_acquire)
++      == NO_RESIZING)
++    {
++      size_t size = atomic_load_explicit(&table[0].hashval,
++                                         memory_order_acquire);
++
++      /* Lock-free check for whether the entry is present.  */
++      idx = lookup(table, size, hval);
++
++      if (idx == 0)
++        return NULL;
++      return (TYPE) atomic_load_explicit(&table[idx].val_ptr,
++                                         memory_order_acquire);
++    }
++
++  /* If we cannot get the resize_rwl lock someone is resizing
++     the hash table, try to help out by moving table data.  */
++  while (pthread_rwlock_tryrdlock(&htab->resize_rwl) != 0)
++    resize_worker(htab);
++
++  idx = lookup(htab->table, htab->size, hval);
+   if (idx == 0)
+     {
+       pthread_rwlock_unlock(&htab->resize_rwl);
+diff --git a/lib/dynamicsizehash_concurrent.h b/lib/dynamicsizehash_concurrent.h
+index be7e98f0..7dba72b9 100644
+--- a/lib/dynamicsizehash_concurrent.h
++++ b/lib/dynamicsizehash_concurrent.h
+@@ -54,8 +54,9 @@
+ /* Defined separately.  */
+ extern size_t next_prime (size_t seed);
+ 
+-
+-/* Table entry type.  */
++/* Table entry type.  Entry 0 does not hold data and is instead used
++   to store the table size and a pointer to the previous table (if a
++   resize has occurred).  */
+ #define _DYNHASHCONENTTYPE(name)       \
+   typedef struct name##_ent         \
+   {                                 \
+diff --git a/libdwfl_stacktrace/dwflst_process_tracker.c b/libdwfl_stacktrace/dwflst_process_tracker.c
+index 967c51ec..0e359e86 100644
+--- a/libdwfl_stacktrace/dwflst_process_tracker.c
++++ b/libdwfl_stacktrace/dwflst_process_tracker.c
+@@ -168,7 +168,6 @@ void dwflst_tracker_end (Dwflst_Process_Tracker *tracker)
+   /* HACK to allow iteration of dynamicsizehash_concurrent.  */
+   /* XXX Based on lib/dynamicsizehash_concurrent.c free().  */
+   rwlock_fini (tracker->elftab_lock);
+-  pthread_rwlock_destroy(&tracker->elftab.resize_rwl);
+   for (idx = 1; idx <= tracker->elftab.size; idx++)
+     {
+       dwflst_tracker_elftab_ent *ent = &tracker->elftab.table[idx];
+@@ -184,11 +183,10 @@ void dwflst_tracker_end (Dwflst_Process_Tracker *tracker)
+ 	elf_end(t->elf);
+       free(t); /* TODO: Check necessity. */
+     }
+-  free (tracker->elftab.table);
++  dwflst_tracker_elftab_free (&tracker->elftab);
+ 
+   /* XXX Based on lib/dynamicsizehash_concurrent.c free().  */
+   rwlock_fini (tracker->dwfltab_lock);
+-  pthread_rwlock_destroy(&tracker->dwfltab.resize_rwl);
+   for (idx = 1; idx <= tracker->dwfltab.size; idx++)
+     {
+       dwflst_tracker_dwfltab_ent *ent = &tracker->dwfltab.table[idx];
+@@ -201,7 +199,7 @@ void dwflst_tracker_end (Dwflst_Process_Tracker *tracker)
+ 	INTUSE(dwfl_end) (t->dwfl);
+       free(t);
+     }
+-  free (tracker->dwfltab.table);
++  dwflst_tracker_dwfltab_free (&tracker->dwfltab);
+ 
+   free (tracker);
+ }
+-- 
+2.56.0
+

diff --git a/elfutils.spec b/elfutils.spec
index 0b4c958..ec7172b 100644
--- a/elfutils.spec
+++ b/elfutils.spec
@@ -4,7 +4,7 @@
 
 Name: elfutils
 Version: 0.197
-%global baserelease 1
+%global baserelease 2
 Release: %{baserelease}%{?dist}
 URL: http://elfutils.org/
 %global source_url ftp://sourceware.org/pub/elfutils/%{version}/
@@ -23,6 +23,14 @@ Summary: A collection of utilities and DSOs to handle ELF files and DWARF data
 %global enable_stackprof 0
 %endif
 
+# Experimental thread safety for the elfutils libraries.  Enabled on
+# Fedora 46 and later (currently rawhide only).
+%if 0%{?fedora} >= 46
+%global enable_thread_safety 1
+%else
+%global enable_thread_safety 0
+%endif
+
 %global provide_yama_scope      0
 
 %if 0%{?fedora} >= 22 || 0%{?rhel} >= 7
@@ -101,6 +109,45 @@ BuildRequires: gettext-devel
 # For s390x... FDO package notes are bogus.
 Patch1: elfutils-0.186-fdo-swap.patch
 
+# Thread safety fixes backported from upstream commits following 0.197
+# (elfutils-0.197..eef98f2a).
+# elf_rand.c: Add missing rwlock_unlock for early return
+Patch2: elfutils-0.197-thread-safety-01-elf_rand-unlock.patch
+# asm_align.c: Avoid EDEADLK in asm_align
+Patch3: elfutils-0.197-thread-safety-02-asm_align-edeadlk.patch
+# libasm: Add missing rwlock_unlock for early returns
+Patch4: elfutils-0.197-thread-safety-03-libasm-unlock.patch
+# readelf.c: Print to job output stream instead of stdout
+Patch5: elfutils-0.197-thread-safety-04-readelf-job-output.patch
+# lib/locks.h: Add atomic load/store macros
+Patch6: elfutils-0.197-thread-safety-05-locks-atomic-macros.patch
+# elf_getscn.c: Remove locking from hotpath
+Patch7: elfutils-0.197-thread-safety-06-elf_getscn-hotpath.patch
+# gelf_getshdr.c, elfNN_getshdr.c: Remove hotpath locks
+Patch8: elfutils-0.197-thread-safety-07-getshdr-hotpath.patch
+# elf32_offscn.c: Use atomic_load_acquire for Elf_ScnList fields
+Patch9: elfutils-0.197-thread-safety-08-offscn-atomic-load.patch
+# gelf_getsymshndx.c: Remove locking
+Patch10: elfutils-0.197-thread-safety-09-gelf_getsymshndx-locking.patch
+# dwarf_getmacros.c: Acquire macro_lock before macro_ops_tree find
+Patch11: elfutils-0.197-thread-safety-10-dwarf_getmacros-macro_lock.patch
+# elf32_getshdr.c: Avoid failed assert for archive member
+Patch12: elfutils-0.197-thread-safety-11-getshdr-archive-assert.patch
+# libdw/cfi.c: Prevent CIE init data race
+Patch13: elfutils-0.197-thread-safety-12-cfi-cie-init-race.patch
+# libdwfl: Serialize module lazy loading entry points
+Patch14: elfutils-0.197-thread-safety-13-dwfl-lazy-loading.patch
+# libdwfl: Serialize CFI cache initialization
+Patch15: elfutils-0.197-thread-safety-14-dwfl-cfi-cache.patch
+# libdwfl: Synchronize access to backend
+Patch16: elfutils-0.197-thread-safety-15-dwfl-backend.patch
+# libdwfl: Serialize aranges initialization
+Patch17: elfutils-0.197-thread-safety-16-dwfl-aranges.patch
+# dwarf_formref_die.c: Avoid TOCTOU race in dwarf_formref_die
+Patch18: elfutils-0.197-thread-safety-17-dwarf_formref_die-toctou.patch
+# lib/dynamicsizehash_concurrent.c: Implement lock-free lookups
+Patch19: elfutils-0.197-thread-safety-18-dynamicsizehash-lockfree-find.patch
+
 %description
 Elfutils is a collection of utilities, including stack (to show
 backtraces), nm (for listing symbols from object files), size
@@ -339,6 +386,9 @@ trap 'cat config.log' EXIT
 %else
 	--disable-stackprof \
 %endif
+%if %{enable_thread_safety}
+	--enable-thread-safety \
+%endif
 	--enable-debuginfod-ima-verification \
 	--enable-debuginfod-ima-cert-path=%{_sysconfdir}/keys/ima
 trap '' EXIT
@@ -532,6 +582,12 @@ exit 0
 %systemd_postun_with_restart debuginfod.service
 
 %changelog
+* Fri Oct 30 2026 Aaron Merey <amerey@redhat.com> - 0.197-2
+- Enable experimental thread safety (--enable-thread-safety) in the
+  elfutils libraries on Fedora rawhide (46+) only
+- Backport upstream thread safety fixes following 0.197 as
+  elfutils-0.197-thread-safety-*.patch
+
 * Tue Oct 20 2026 Aaron Merey <amerey@redhat.com> - 0.197-1
 - Upgrade to upstream elfutils 0.197
 - Include the upstream thread-safety documentation in elfutils

                 reply	other threads:[~2026-10-31  1:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179341048628.1.8829142360042446458.rpms-elfutils-2e77d38798f7@fedoraproject.org \
    --to=amerey@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox