* elflink.h (elf_link_add_object_symbols): Don't let a weak
authorIan Lance Taylor <ian@airs.com>
Mon, 2 Oct 1995 18:11:12 +0000 (18:11 +0000)
committerIan Lance Taylor <ian@airs.com>
Mon, 2 Oct 1995 18:11:12 +0000 (18:11 +0000)
dynamic symbol override a common symbol.  Don't change the size or
type if they have been set and the new symbol is not a definition.
Warn if the size or type changes.

bfd/ChangeLog
bfd/elflink.h

index a9177f367c5af202b1d121f4aa82123a3d17e1d7..114a99a1be9c80ec82c52a8fa812cb9e4d9c0ad8 100644 (file)
@@ -1,3 +1,10 @@
+Mon Oct  2 14:08:55 1995  Ian Lance Taylor  <ian@cygnus.com>
+
+       * elflink.h (elf_link_add_object_symbols): Don't let a weak
+       dynamic symbol override a common symbol.  Don't change the size or
+       type if they have been set and the new symbol is not a definition.
+       Warn if the size or type changes.
+
 Sun Oct  1 01:34:41 1995  Jeff Law  (law@hurl.cygnus.com
 
         * som.c (som_begin_writing): Don't write the symbol table or
index f4674f4ffd360734bf08f3969e92feec0e35dbff..1aaa17ed08e29b146d19cbc38a0940e42619f3ef 100644 (file)
@@ -666,8 +666,13 @@ elf_link_add_object_symbols (abfd, info)
          if (dynamic && definition)
            {
              if (h->root.type == bfd_link_hash_defined
-                 || h->root.type == bfd_link_hash_defweak)
-               sec = bfd_und_section_ptr;
+                 || h->root.type == bfd_link_hash_defweak
+                 || (h->root.type == bfd_link_hash_common
+                     && bind == STB_WEAK))
+               {
+                 sec = bfd_und_section_ptr;
+                 definition = false;
+               }
            }
 
          /* Similarly, if we are not looking at a dynamic object, and
@@ -742,16 +747,27 @@ elf_link_add_object_symbols (abfd, info)
          int new_flag;
 
          /* Remember the symbol size and type.  */
-         if (sym.st_size != 0)
+         if (sym.st_size != 0
+             && (definition || h->size == 0))
            {
-             /* FIXME: We should probably somehow give a warning if
-                the symbol size changes.  */
+             if (h->size != 0 && h->size != sym.st_size)
+               (*_bfd_error_handler)
+                 ("Warning: size of symbol `%s' changed from %lu to %lu in %s",
+                  name, (unsigned long) h->size, (unsigned long) sym.st_size,
+                  bfd_get_filename (abfd));
+
              h->size = sym.st_size;
            }
-         if (ELF_ST_TYPE (sym.st_info) != STT_NOTYPE)
+         if (ELF_ST_TYPE (sym.st_info) != STT_NOTYPE
+             && (definition || h->type == STT_NOTYPE))
            {
-             /* FIXME: We should probably somehow give a warning if
-                the symbol type changes.  */
+             if (h->type != STT_NOTYPE
+                 && h->type != ELF_ST_TYPE (sym.st_info))
+               (*_bfd_error_handler)
+                 ("Warning: type of symbol `%s' changed from %d to %d in %s",
+                  name, h->type, ELF_ST_TYPE (sym.st_info),
+                  bfd_get_filename (abfd));
+
              h->type = ELF_ST_TYPE (sym.st_info);
            }