PATCH: ld/3351: aborting at elflink.c line 6778 in elf_link_check_versioned_symbol

H. J. Lu hjl@lucon.org
Wed Oct 18 10:45:00 GMT 2006


When a shared library references a forced local symbol in executable,
linker tries to issue an error. But it doesn't check indirect symbols.
Also, when we update real symbol reference flags, we fail to update
indirect symbol reference flags. This patch fixes both.


H.J.
----
2006-10-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/3351
	* elflink.c (elf_link_add_object_symbols): Update indirect
	symbol reference flags.
	(elf_link_check_versioned_symbol): Check indirect symbol.
	(elf_link_output_extsym): Check indirect symbol when reporting
	error.

--- bfd/elflink.c.version	2006-10-17 07:11:12.000000000 -0700
+++ bfd/elflink.c	2006-10-17 16:28:51.000000000 -0700
@@ -3644,6 +3644,7 @@ elf_link_add_object_symbols (bfd *abfd, 
       flagword flags;
       const char *name;
       struct elf_link_hash_entry *h;
+      struct elf_link_hash_entry *hi;
       bfd_boolean definition;
       bfd_boolean size_change_ok;
       bfd_boolean type_change_ok;
@@ -3934,6 +3935,7 @@ elf_link_add_object_symbols (bfd *abfd, 
 	goto error_free_vers;
 
       h = *sym_hash;
+      hi = h;
       while (h->root.type == bfd_link_hash_indirect
 	     || h->root.type == bfd_link_hash_warning)
 	h = (struct elf_link_hash_entry *) h->root.u.i.link;
@@ -4163,6 +4165,14 @@ elf_link_add_object_symbols (bfd *abfd, 
 	      dynsym = FALSE;
 	    }
 
+	  if (hi->root.type == bfd_link_hash_indirect)
+	    {
+	      /* We need to make sure that indirect symbol reference
+		 flags are updated.  */
+	      hi->ref_dynamic |= h->ref_dynamic;
+	      hi->ref_regular |= h->ref_regular;
+	    }
+
 	  /* Check to see if we need to add an indirect symbol for
 	     the default name.  */
 	  if (definition || h->root.type == bfd_link_hash_common)
@@ -6729,6 +6739,10 @@ elf_link_check_versioned_symbol (struct 
   if (!is_elf_hash_table (info->hash))
     return FALSE;
 
+  /* Check indirect symbol.  */
+  while (h->root.type == bfd_link_hash_indirect)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   switch (h->root.type)
     {
     default:
@@ -6937,11 +6951,17 @@ elf_link_output_extsym (struct elf_link_
       && !h->dynamic_weak
       && ! elf_link_check_versioned_symbol (finfo->info, bed, h))
     {
+      struct elf_link_hash_entry *hi = h;
+
+      /* Check indirect symbol.  */
+      while (hi->root.type == bfd_link_hash_indirect)
+	hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
+
       (*_bfd_error_handler)
 	(_("%B: %s symbol `%s' in %B is referenced by DSO"),
 	 finfo->output_bfd,
-	 h->root.u.def.section == bfd_abs_section_ptr
-	 ? finfo->output_bfd : h->root.u.def.section->owner,
+	 hi->root.u.def.section == bfd_abs_section_ptr
+	 ? finfo->output_bfd : hi->root.u.def.section->owner,
 	 ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
 	 ? "internal"
 	 : ELF_ST_VISIBILITY (h->other) == STV_HIDDEN



More information about the Binutils mailing list