Add support for configuring for the ARM Phoenix target.
[deliverable/binutils-gdb.git] / bfd / linker.c
index 92238101010c0ae00adcd4d3d23231a0275a7c43..082eea0715b0bd62820140bda518f690a6f9f63e 100644 (file)
@@ -1,5 +1,5 @@
 /* linker.c -- BFD linker routines
 /* linker.c -- BFD linker routines
-   Copyright (C) 1993-2014 Free Software Foundation, Inc.
+   Copyright (C) 1993-2016 Free Software Foundation, Inc.
    Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
 
    This file is part of BFD, the Binary File Descriptor library.
    Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -1475,7 +1475,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
   else if (bfd_is_com_section (section))
     {
       row = COMMON_ROW;
   else if (bfd_is_com_section (section))
     {
       row = COMMON_ROW;
-      if (strcmp (name, "__gnu_lto_slim") == 0)
+      if (!bfd_link_relocatable (info)
+         && strcmp (name, "__gnu_lto_slim") == 0)
        (*_bfd_error_handler)
          (_("%s: plugin needed to handle lto object"),
           bfd_get_filename (abfd));
        (*_bfd_error_handler)
          (_("%s: plugin needed to handle lto object"),
           bfd_get_filename (abfd));
@@ -1906,7 +1907,7 @@ _bfd_generic_final_link (bfd *abfd, struct bfd_link_info *info)
   if (! generic_add_output_symbol (abfd, &outsymalloc, NULL))
     return FALSE;
 
   if (! generic_add_output_symbol (abfd, &outsymalloc, NULL))
     return FALSE;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     {
       /* Allocate space for the output relocs for each section.  */
       for (o = abfd->sections; o != NULL; o = o->next)
     {
       /* Allocate space for the output relocs for each section.  */
       for (o = abfd->sections; o != NULL; o = o->next)
@@ -2136,7 +2137,7 @@ _bfd_generic_link_output_symbols (bfd *output_bfd,
                  /* fall through */
                case bfd_link_hash_defined:
                  sym->flags |= BSF_GLOBAL;
                  /* fall through */
                case bfd_link_hash_defined:
                  sym->flags |= BSF_GLOBAL;
-                 sym->flags &=~ BSF_CONSTRUCTOR;
+                 sym->flags &=~ (BSF_WEAK | BSF_CONSTRUCTOR);
                  sym->value = h->root.u.def.value;
                  sym->section = h->root.u.def.section;
                  break;
                  sym->value = h->root.u.def.value;
                  sym->section = h->root.u.def.section;
                  break;
@@ -2210,7 +2211,7 @@ _bfd_generic_link_output_symbols (bfd *output_bfd,
                  break;
                case discard_sec_merge:
                  output = TRUE;
                  break;
                case discard_sec_merge:
                  output = TRUE;
-                 if (info->relocatable
+                 if (bfd_link_relocatable (info)
                      || ! (sym->section->flags & SEC_MERGE))
                    break;
                  /* FALLTHROUGH */
                      || ! (sym->section->flags & SEC_MERGE))
                    break;
                  /* FALLTHROUGH */
@@ -2380,7 +2381,7 @@ _bfd_generic_reloc_link_order (bfd *abfd,
 {
   arelent *r;
 
 {
   arelent *r;
 
-  if (! info->relocatable)
+  if (! bfd_link_relocatable (info))
     abort ();
   if (sec->orelocation == NULL)
     abort ();
     abort ();
   if (sec->orelocation == NULL)
     abort ();
@@ -2434,7 +2435,7 @@ _bfd_generic_reloc_link_order (bfd *abfd,
 
       size = bfd_get_reloc_size (r->howto);
       buf = (bfd_byte *) bfd_zmalloc (size);
 
       size = bfd_get_reloc_size (r->howto);
       buf = (bfd_byte *) bfd_zmalloc (size);
-      if (buf == NULL)
+      if (buf == NULL && size != 0)
        return FALSE;
       rstat = _bfd_relocate_contents (r->howto, abfd,
                                      (bfd_vma) link_order->u.reloc.p->addend,
        return FALSE;
       rstat = _bfd_relocate_contents (r->howto, abfd,
                                      (bfd_vma) link_order->u.reloc.p->addend,
@@ -2611,7 +2612,7 @@ default_indirect_link_order (bfd *output_bfd,
   BFD_ASSERT (input_section->output_offset == link_order->offset);
   BFD_ASSERT (input_section->size == link_order->size);
 
   BFD_ASSERT (input_section->output_offset == link_order->offset);
   BFD_ASSERT (input_section->size == link_order->size);
 
-  if (info->relocatable
+  if (bfd_link_relocatable (info)
       && input_section->reloc_count > 0
       && output_section->orelocation == NULL)
     {
       && input_section->reloc_count > 0
       && output_section->orelocation == NULL)
     {
@@ -2705,7 +2706,7 @@ default_indirect_link_order (bfd *output_bfd,
        goto error_return;
       new_contents = (bfd_get_relocated_section_contents
                      (output_bfd, info, link_order, contents,
        goto error_return;
       new_contents = (bfd_get_relocated_section_contents
                      (output_bfd, info, link_order, contents,
-                      info->relocatable,
+                      bfd_link_relocatable (info),
                       _bfd_generic_link_get_symbols (input_bfd)));
       if (!new_contents)
        goto error_return;
                       _bfd_generic_link_get_symbols (input_bfd)));
       if (!new_contents)
        goto error_return;
@@ -2896,7 +2897,7 @@ _bfd_handle_already_linked (asection *sec,
         files over IR because the first pass may contain a
         mix of LTO and normal objects and we must keep the
         first match, be it IR or real.  */
         files over IR because the first pass may contain a
         mix of LTO and normal objects and we must keep the
         first match, be it IR or real.  */
-      if (info->loading_lto_outputs
+      if (sec->owner->lto_output
          && (l->sec->owner->flags & BFD_PLUGIN) != 0)
        {
          l->sec = sec;
          && (l->sec->owner->flags & BFD_PLUGIN) != 0)
        {
          l->sec = sec;
@@ -3303,3 +3304,46 @@ bfd_hide_sym_by_version (struct bfd_elf_version_tree *verdefs,
   bfd_find_version_for_sym (verdefs, sym_name, &hidden);
   return hidden;
 }
   bfd_find_version_for_sym (verdefs, sym_name, &hidden);
   return hidden;
 }
+
+/*
+FUNCTION
+       bfd_link_check_relocs
+
+SYNOPSIS
+       bfd_boolean bfd_link_check_relocs
+         (bfd *abfd, struct bfd_link_info *info);
+
+DESCRIPTION
+       Checks the relocs in ABFD for validity.
+       Does not execute the relocs.
+       Return TRUE if everything is OK, FALSE otherwise.
+       This is the external entry point to this code.
+*/
+
+bfd_boolean
+bfd_link_check_relocs (bfd *abfd, struct bfd_link_info *info)
+{
+  return BFD_SEND (abfd, _bfd_link_check_relocs, (abfd, info));
+}
+
+/*
+FUNCTION
+       _bfd_generic_link_check_relocs
+
+SYNOPSIS
+       bfd_boolean _bfd_generic_link_check_relocs
+         (bfd *abfd, struct bfd_link_info *info);
+
+DESCRIPTION
+        Stub function for targets that do not implement reloc checking.
+       Return TRUE.
+       This is an internal function.  It should not be called from
+       outside the BFD library.
+*/
+
+bfd_boolean
+_bfd_generic_link_check_relocs (bfd *abfd ATTRIBUTE_UNUSED,
+                               struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
This page took 0.026243 seconds and 4 git commands to generate.