tweak last patch
authorIan Lance Taylor <ian@airs.com>
Thu, 3 Apr 1997 16:27:28 +0000 (16:27 +0000)
committerIan Lance Taylor <ian@airs.com>
Thu, 3 Apr 1997 16:27:28 +0000 (16:27 +0000)
bfd/elflink.h

index 62d0c5a730b5ff61f9daf32094b884c91fc4a4ff..877f166ff86f433b50f1171cf79f995abbda5935 100644 (file)
@@ -887,20 +887,14 @@ elf_link_add_object_symbols (abfd, info)
             library is a function, since common symbols always
             represent variables; this can cause confusion in
             principle, but any such confusion would seem to indicate
-            an erroneous program or shared library.  We also treat a
-            common symbol as a definition if the symbol in the shared
-            library is in an uninitialized section, and it has a
-            smaller size.  */
+            an erroneous program or shared library.  */
          if (dynamic && definition)
            {
              if (h->root.type == bfd_link_hash_defined
                  || h->root.type == bfd_link_hash_defweak
                  || (h->root.type == bfd_link_hash_common
-                     && ((bind == STB_WEAK
-                          || ELF_ST_TYPE (sym.st_info) == STT_FUNC)
-                         || ((sec->flags & SEC_ALLOC) != 0
-                             && (sec->flags & SEC_LOAD) == 0
-                             && sym.st_size < h->size))))
+                     && (bind == STB_WEAK
+                         || ELF_ST_TYPE (sym.st_info) == STT_FUNC)))
                {
                  override = true;
                  sec = bfd_und_section_ptr;
@@ -911,6 +905,36 @@ elf_link_add_object_symbols (abfd, info)
                }
            }
 
+         /* If we already have a common symbol, and the symbol in the
+             shared library is in an uninitialized section, then treat
+             the shared library symbol as a common symbol.  This will
+             not always be correct, but it should do little harm.  */
+         if (dynamic
+             && definition
+             && h->root.type == bfd_link_hash_common
+             && (sec->flags & SEC_ALLOC) != 0
+             && (sec->flags & SEC_LOAD) == 0)
+           {
+             if (! ((*info->callbacks->multiple_common)
+                    (info, h->root.root.string,
+                     h->root.u.c.p->section->owner, bfd_link_hash_common,
+                     h->root.u.c.size, abfd, bfd_link_hash_common,
+                     sym.st_size)))
+               goto error_return;
+
+             /* If the symbol in the shared library is smaller than
+                 the one we already have, then override it to stick
+                 with the larger symbol.  Set SIZE_CHANGE_OK because
+                 we only want to warn if requested with --warn-common.  */
+             if (sym.st_size < h->size)
+               {
+                 override = true;
+                 sec = bfd_und_section_ptr;
+                 definition = false;
+                 size_change_ok = true;
+               }
+           }
+
          /* Similarly, if we are not looking at a dynamic object, and
             we have a definition, we want to override any definition
             we may have from a dynamic object.  Symbols from regular