[binutils-gdb] PR 34165 aarch64 assertion fail and segv

Alan Modra via Binutils-cvs <[email protected]> Thu, 2 Jul 2026 03:12:19 +0000 (GMT)
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=457c3b91dfc6bc0bf149229265ba1ddf5ac018a1

commit 457c3b91dfc6bc0bf149229265ba1ddf5ac018a1
Author: Alan Modra <[email protected]>
Date:   Wed Jul 1 10:58:53 2026 +0930

    PR 34165 aarch64 assertion fail and segv
    
            * elfnn-aarch64.c (dtpoff_base, tpoff_base): Don't assert that
            tls_sec is non-NULL, return zero instead.

Diff:
---
 bfd/elfnn-aarch64.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index ffca9048e65..cbd4abea122 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -5396,8 +5396,8 @@ aarch64_tls_transition (bfd *input_bfd,
 static bfd_vma
 dtpoff_base (struct bfd_link_info *info)
 {
-  /* If tls_sec is NULL, we should have signalled an error already.  */
-  BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
+  if (elf_hash_table (info)->tls_sec == NULL)
+    return 0;
   return elf_hash_table (info)->tls_sec->vma;
 }
 
@@ -5409,8 +5409,8 @@ tpoff_base (struct bfd_link_info *info)
 {
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
-  /* If tls_sec is NULL, we should have signalled an error already.  */
-  BFD_ASSERT (htab->tls_sec != NULL);
+  if (htab->tls_sec == NULL)
+    return 0;
 
   bfd_vma base = align_power ((bfd_vma) TCB_SIZE,
 			      htab->tls_sec->alignment_power);