Wed Oct 18 15:53:56 1995 steve chamberlain <sac@slash.cygnus.com>
[deliverable/binutils-gdb.git] / bfd / elflink.h
index dc2da5ef3dce369cb243b1851c761f0eb016ac5c..f324ebb1cdbaa9a1a260aa8bd1c2657e59b5cdb8 100644 (file)
@@ -442,12 +442,11 @@ elf_link_add_object_symbols (abfd, info)
                }
              if (dyn.d_tag == DT_NEEDED)
                {
-                 struct bfd_elf_link_needed_list *n, **pn;
+                 struct bfd_link_needed_list *n, **pn;
                  char *fnm, *anm;
 
-                 n = (struct bfd_elf_link_needed_list *)
-                   bfd_alloc (abfd,
-                              sizeof (struct bfd_elf_link_needed_list));
+                 n = ((struct bfd_link_needed_list *)
+                      bfd_alloc (abfd, sizeof (struct bfd_link_needed_list)));
                  fnm = bfd_elf_string_from_elf_section (abfd, link,
                                                         dyn.d_un.d_val);
                  if (n == NULL || fnm == NULL)
@@ -555,7 +554,7 @@ elf_link_add_object_symbols (abfd, info)
       const char *name;
       struct elf_link_hash_entry *h;
       boolean definition;
-      boolean wasweak;
+      boolean size_change_ok, type_change_ok;
       boolean new_weakdef;
 
       elf_swap_symbol_in (abfd, esym, &sym);
@@ -642,7 +641,8 @@ elf_link_add_object_symbols (abfd, info)
       else
        definition = true;
 
-      wasweak = false;
+      size_change_ok = false;
+      type_change_ok = false;
       if (info->hash->creator->flavour == bfd_target_elf_flavour)
        {
          /* We need to look up the symbol now in order to get some of
@@ -659,9 +659,17 @@ elf_link_add_object_symbols (abfd, info)
                 || h->root.type == bfd_link_hash_warning)
            h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
-         /* Remember whether this used to be a weak definition.  */
-         wasweak = (h->root.type == bfd_link_hash_defweak
-                    || h->root.type == bfd_link_hash_undefweak);
+         /* It's OK to change the type if it used to be a weak
+             definition.  */
+         type_change_ok = (h->root.type == bfd_link_hash_defweak
+                           || h->root.type == bfd_link_hash_undefweak);
+
+         /* It's OK to change the size if it used to be a weak
+            definition, or if it used to be undefined, or if we will
+            be overriding an old definition.
+            */
+         size_change_ok = (type_change_ok
+                           || h->root.type == bfd_link_hash_undefined);
 
          /* If we are looking at a dynamic object, and this is a
             definition, we need to see if it has already been defined
@@ -678,6 +686,7 @@ elf_link_add_object_symbols (abfd, info)
                {
                  sec = bfd_und_section_ptr;
                  definition = false;
+                 size_change_ok = true;
                }
            }
 
@@ -702,6 +711,7 @@ elf_link_add_object_symbols (abfd, info)
                 with the new definition.  */
              h->root.type = bfd_link_hash_undefined;
              h->root.u.undef.abfd = h->root.u.def.section->owner;
+             size_change_ok = true;
            }
        }
 
@@ -756,7 +766,7 @@ elf_link_add_object_symbols (abfd, info)
          if (sym.st_size != 0
              && (definition || h->size == 0))
            {
-             if (h->size != 0 && h->size != sym.st_size && ! wasweak)
+             if (h->size != 0 && h->size != sym.st_size && ! size_change_ok)
                (*_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,
@@ -769,7 +779,7 @@ elf_link_add_object_symbols (abfd, info)
            {
              if (h->type != STT_NOTYPE
                  && h->type != ELF_ST_TYPE (sym.st_info)
-                 && ! wasweak)
+                 && ! type_change_ok)
                (*_bfd_error_handler)
                  ("Warning: type of symbol `%s' changed from %d to %d in %s",
                   name, h->type, ELF_ST_TYPE (sym.st_info),
This page took 0.026175 seconds and 4 git commands to generate.