* elf32-sh.c (sh_elf_relocate_section): Don't complain about
[deliverable/binutils-gdb.git] / bfd / linker.c
index b4b9f292b871dcda8e62b5d4f1190cc2b286f139..a5ded1f58836befe5af09bee5796db6b369aafc8 100644 (file)
@@ -449,7 +449,8 @@ _bfd_link_hash_newfunc (entry, table, string)
      subclass.  */
   if (entry == NULL)
     {
-      entry = bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry));
+      entry = (struct bfd_hash_entry *)
+       bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry));
       if (entry == NULL)
        return entry;
     }
@@ -645,8 +646,8 @@ _bfd_generic_link_hash_newfunc (entry, table, string)
      subclass.  */
   if (entry == NULL)
     {
-      entry = bfd_hash_allocate (table,
-                                sizeof (struct generic_link_hash_entry));
+      entry = (struct bfd_hash_entry *)
+       bfd_hash_allocate (table, sizeof (struct generic_link_hash_entry));
       if (entry == NULL)
        return entry;
     }
@@ -757,6 +758,19 @@ _bfd_generic_link_add_symbols_collect (abfd, info)
   return generic_link_add_symbols (abfd, info, true);
 }
 
+/* Indicate that we are only retrieving symbol values from this
+   section.  We want the symbols to act as though the values in the
+   file are absolute.  */
+
+void
+_bfd_generic_link_just_syms (sec, info)
+     asection *sec;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
+{
+  sec->output_section = bfd_abs_section_ptr;
+  sec->output_offset = sec->vma;
+}
+
 /* Add symbols from an object file to the global hash table.  */
 
 static boolean
@@ -1292,6 +1306,7 @@ generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
          const char *name;
          const char *string;
          struct generic_link_hash_entry *h;
+         struct bfd_link_hash_entry *bh;
 
          name = bfd_asymbol_name (p);
          if (((p->flags & BSF_INDIRECT) != 0
@@ -1313,12 +1328,12 @@ generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect)
          else
            string = NULL;
 
-         h = NULL;
+         bh = NULL;
          if (! (_bfd_generic_link_add_one_symbol
                 (info, abfd, name, p->flags, bfd_get_section (p),
-                 p->value, string, false, collect,
-                 (struct bfd_link_hash_entry **) &h)))
+                 p->value, string, false, collect, &bh)))
            return false;
+         h = (struct generic_link_hash_entry *) bh;
 
          /* If this is a constructor symbol, and the linker didn't do
              anything with it, then we want to just pass the symbol
@@ -1661,8 +1676,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
                          abort ();
 
                        if (! ((*info->callbacks->constructor)
-                              (info,
-                               c == 'I' ? true : false,
+                              (info, c == 'I',
                                h->root.string, abfd, section, value)))
                          return false;
                      }
@@ -1800,37 +1814,38 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
          /* Fall through.  */
        case MDEF:
          /* Handle a multiple definition.  */
-         {
-           asection *msec = NULL;
-           bfd_vma mval = 0;
+         if (!info->allow_multiple_definition)
+           {
+             asection *msec = NULL;
+             bfd_vma mval = 0;
 
-           switch (h->type)
-             {
-             case bfd_link_hash_defined:
-               msec = h->u.def.section;
-               mval = h->u.def.value;
-               break;
-             case bfd_link_hash_indirect:
-               msec = bfd_ind_section_ptr;
-               mval = 0;
-               break;
-             default:
-               abort ();
-             }
+             switch (h->type)
+               {
+               case bfd_link_hash_defined:
+                 msec = h->u.def.section;
+                 mval = h->u.def.value;
+                 break;
+               case bfd_link_hash_indirect:
+                 msec = bfd_ind_section_ptr;
+                 mval = 0;
+                 break;
+               default:
+                 abort ();
+               }
 
-           /* Ignore a redefinition of an absolute symbol to the same
-               value; it's harmless.  */
-           if (h->type == bfd_link_hash_defined
-               && bfd_is_abs_section (msec)
-               && bfd_is_abs_section (section)
-               && value == mval)
-             break;
+             /* Ignore a redefinition of an absolute symbol to the
+                same value; it's harmless.  */
+             if (h->type == bfd_link_hash_defined
+                 && bfd_is_abs_section (msec)
+                 && bfd_is_abs_section (section)
+                 && value == mval)
+               break;
 
-           if (! ((*info->callbacks->multiple_definition)
-                  (info, h->root.string, msec->owner, msec, mval, abfd,
-                   section, value)))
-             return false;
-         }
+             if (! ((*info->callbacks->multiple_definition)
+                    (info, h->root.string, msec->owner, msec, mval,
+                     abfd, section, value)))
+               return false;
+           }
          break;
 
        case CIND:
@@ -1961,12 +1976,12 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
            else
              {
                char *w;
+               size_t len = strlen (string) + 1;
 
-               w = bfd_hash_allocate (&info->hash->table,
-                                      strlen (string) + 1);
+               w = bfd_hash_allocate (&info->hash->table, len);
                if (w == NULL)
                  return false;
-               strcpy (w, string);
+               memcpy (w, string, len);
                sub->u.i.warning = w;
              }
 
@@ -2005,7 +2020,7 @@ _bfd_generic_final_link (abfd, info)
   for (o = abfd->sections; o != NULL; o = o->next)
     for (p = o->link_order_head; p != NULL; p = p->next)
       if (p->type == bfd_indirect_link_order)
-       p->u.indirect.section->linker_mark = true;
+       p->u.indirect.section->linker_mark = (unsigned int) true;
 
   /* Build the output symbol table.  */
   for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next)
@@ -2377,7 +2392,7 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
         Gross.  .bss and similar sections won't have the linker_mark
         field set.  */
       if ((sym->section->flags & SEC_HAS_CONTENTS) != 0
-         && sym->section->linker_mark == false)
+         && ! sym->section->linker_mark)
        output = false;
 
       if (output)
This page took 0.02737 seconds and 4 git commands to generate.