alpha: Properly handle local weak undefined symbols

Alan Modra amodra@gmail.com
Wed May 27 12:52:37 GMT 2026


asan complains "runtime error: member access within null pointer"
for &h->root with NULL h, which is annoying since &h->root is the
same address as h, causing
alpha-linux-gnu  +FAIL: TLS -fpic -shared
alpha-linux-gnu  +FAIL: TLS -fpic and -fno-pic exec
alpha-linux-gnu  +FAIL: TLS -fpic and -fno-pic exec -relax

	* elf64-alpha.c (elf64_alpha_relocate_section): Fix asan
	complaint.

diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 594bfe9a80e..8cc70610c59 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -4648,7 +4648,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 		 input_bfd, h->root.root.root.string);
 	      ret_val = false;
 	    }
-	  else if (elf_link_local_undefweak_p (&h->root, info))
+	  else if (elf_link_local_undefweak_p (h ? &h->root : NULL, info))
 	    /* NB: The local undefined TLS symbol address isn't usable
 	       since it isn't mapped to any TLS storage.  Set it to 0
 	       to avoid relocation overflow.  */
@@ -4676,7 +4676,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 		value = 0;
 	      else
 		{
-		  if (elf_link_local_undefweak_p (&h->root, info))
+		  if (elf_link_local_undefweak_p (h ? &h->root : NULL, info))
 		    /* NB: The local undefined TLS symbol address isn't
 		       usable since it isn't mapped to any TLS storage.
 		       Set it to 0 to avoid relocation overflow.  */

-- 
Alan Modra


More information about the Binutils mailing list