2004-02-21 H.J. Lu <hongjiu.lu@intel.com>
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 21 Feb 2004 23:05:13 +0000 (23:05 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 21 Feb 2004 23:05:13 +0000 (23:05 +0000)
* elflink.c (_bfd_elf_merge_symbol): Properly handle undefined
symbols with non-default visibility.

bfd/ChangeLog
bfd/elflink.c

index 4c97561..94d1876 100644 (file)
@@ -1,3 +1,8 @@
+2004-02-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elflink.c (_bfd_elf_merge_symbol): Properly handle undefined
+       symbols with non-default visibility.
+
 2004-02-21  Danny Smith  <daanysmith@users.sourceforge.net>
 
        * peXXigen.c (_bfd_XXi_swap_scnhdr_out): Clear
index f58a67a..e605a8d 100644 (file)
@@ -843,8 +843,26 @@ _bfd_elf_merge_symbol (bfd *abfd,
         object, we remove the old definition.  */
       if ((*sym_hash)->root.type == bfd_link_hash_indirect)
        h = *sym_hash;
-      h->root.type = bfd_link_hash_new;
-      h->root.u.undef.abfd = NULL;
+
+      if ((h->root.und_next || info->hash->undefs_tail == &h->root)
+         && bfd_is_und_section (sec))
+       {
+         /* If the new symbol is undefined and the old symbol was
+            also undefined before, we need to make sure
+            _bfd_generic_link_add_one_symbol doesn't mess
+            up the linker hash table undefs list. Since the old
+            definition came from a dynamic object, it is still on the
+            undefs list.  */
+         h->root.type = bfd_link_hash_undefined;
+         /* FIXME: What if the new symbol is weak undefined?  */
+         h->root.u.undef.abfd = abfd;
+       }
+      else
+       {
+         h->root.type = bfd_link_hash_new;
+         h->root.u.undef.abfd = NULL;
+       }
+
       if (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC)
        {
          h->elf_link_hash_flags &= ~ELF_LINK_HASH_DEF_DYNAMIC;