public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* sparc64 segfault in finish_dynamic_symbol
@ 2022-05-31 11:49 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-05-31 11:49 UTC (permalink / raw)
  To: binutils

SYMBOL_REFERENCES_LOCAL can return true for undefined symbols.  This
can result in a segfault when running sparc64 ld/testsuite/ld-vsb
tests that expect a failure.

	* elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Don't
	access u.def.section on non-default visibility undefined symbol.

diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 618b88589c7..514db1e4c76 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -4416,7 +4416,10 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd,
 	  return true;
 	}
 
-      if (bfd_link_pic (info) && SYMBOL_REFERENCES_LOCAL (info, h))
+      if (bfd_link_pic (info)
+	  && (h->root.type == bfd_link_hash_defined
+	      || h->root.type == bfd_link_hash_defweak)
+	  && SYMBOL_REFERENCES_LOCAL (info, h))
 	{
 	  asection *sec = h->root.u.def.section;
 	  if (h->type == STT_GNU_IFUNC)

-- 
Alan Modra
Australia Development Lab, IBM

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

only message in thread, other threads:[~2022-05-31 11:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-31 11:49 sparc64 segfault in finish_dynamic_symbol Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).