* elf-hppa.h (elf_hppa_final_link): Use elf_hppa_final_link.
[deliverable/binutils-gdb.git] / bfd / xcofflink.c
index 47c330b6c15f1fd21f378d76fddb3698879a5049..21d9a2d944630f4af8c5046b79b6228a8af2d552 100644 (file)
@@ -1,13 +1,13 @@
 /* POWER/PowerPC XCOFF linker support.
    Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "coff/internal.h"
@@ -559,7 +560,7 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info)
 
   /* We can only handle a dynamic object if we are generating an XCOFF
      output file.  */
-   if (info->hash->creator != abfd->xvec)
+   if (info->output_bfd->xvec != abfd->xvec)
     {
       (*_bfd_error_handler)
        (_("%s: XCOFF shared object when not producing XCOFF output"),
@@ -785,7 +786,7 @@ xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
 {
   bfd_boolean return_value = FALSE;
 
-  if (info->hash->creator == abfd->xvec)
+  if (info->output_bfd->xvec == abfd->xvec)
     {
       /* We need to build a .loader section, so we do it here.  This
         won't work if we're producing an XCOFF output file with no
@@ -794,27 +795,27 @@ xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
       if (xcoff_hash_table (info)->loader_section == NULL)
        {
          asection *lsec;
+         flagword flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
 
-         lsec = bfd_make_section_anyway (abfd, ".loader");
+         lsec = bfd_make_section_anyway_with_flags (abfd, ".loader", flags);
          if (lsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->loader_section = lsec;
-         lsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
        }
 
       /* Likewise for the linkage section.  */
       if (xcoff_hash_table (info)->linkage_section == NULL)
        {
          asection *lsec;
+         flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                           | SEC_IN_MEMORY);
 
-         lsec = bfd_make_section_anyway (abfd, ".gl");
+         lsec = bfd_make_section_anyway_with_flags (abfd, ".gl", flags);
          if (lsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->linkage_section = lsec;
-         lsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                         | SEC_IN_MEMORY);
          lsec->alignment_power = 2;
        }
 
@@ -822,14 +823,14 @@ xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
       if (xcoff_hash_table (info)->toc_section == NULL)
        {
          asection *tsec;
+         flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                           | SEC_IN_MEMORY);
 
-         tsec = bfd_make_section_anyway (abfd, ".tc");
+         tsec = bfd_make_section_anyway_with_flags (abfd, ".tc", flags);
          if (tsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->toc_section = tsec;
-         tsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                         | SEC_IN_MEMORY);
          tsec->alignment_power = 2;
        }
 
@@ -837,14 +838,14 @@ xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
       if (xcoff_hash_table (info)->descriptor_section == NULL)
        {
          asection *dsec;
+         flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                           | SEC_IN_MEMORY);
 
-         dsec = bfd_make_section_anyway (abfd, ".ds");
+         dsec = bfd_make_section_anyway_with_flags (abfd, ".ds", flags);
          if (dsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->descriptor_section = dsec;
-         dsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                         | SEC_IN_MEMORY);
          dsec->alignment_power = 2;
        }
 
@@ -853,13 +854,13 @@ xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
          && info->strip != strip_all)
        {
          asection *dsec;
+         flagword flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
 
-         dsec = bfd_make_section_anyway (abfd, ".debug");
+         dsec = bfd_make_section_anyway_with_flags (abfd, ".debug", flags);
          if (dsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->debug_section = dsec;
-         dsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
        }
     }
 
@@ -1293,7 +1294,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
             place.  */
          if (aux.x_csect.x_smclas == XMC_TC
              && sym.n_sclass == C_HIDEXT
-             && info->hash->creator == abfd->xvec
+             && info->output_bfd->xvec == abfd->xvec
              && ((bfd_xcoff_is_xcoff32 (abfd)
                   && aux.x_csect.x_scnlen.l == 4)
                  || (bfd_xcoff_is_xcoff64 (abfd)
@@ -1552,16 +1553,17 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
            {
              /* The linker script puts the .td section in the data
                 section after the .tc section.  */
-             csect = bfd_make_section_anyway (abfd, ".td");
+             csect = bfd_make_section_anyway_with_flags (abfd, ".td",
+                                                         SEC_ALLOC);
            }
          else
-           csect = bfd_make_section_anyway (abfd, ".bss");
+           csect = bfd_make_section_anyway_with_flags (abfd, ".bss",
+                                                       SEC_ALLOC);
 
          if (csect == NULL)
            goto error_return;
          csect->vma = sym.n_value;
          csect->size = aux.x_csect.x_scnlen.l;
-         csect->flags |= SEC_ALLOC;
          csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
          /* There are a number of other fields and section flags
             which we do not bother to set.  */
@@ -1662,7 +1664,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
             shared object, which will cause symbol redefinitions,
             although this is an easier case to detect.  */
 
-         if (info->hash->creator == abfd->xvec)
+         if (info->output_bfd->xvec == abfd->xvec)
            {
              if (! bfd_is_und_section (section))
                *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
@@ -1787,7 +1789,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
                  = csect->alignment_power;
            }
 
-         if (info->hash->creator == abfd->xvec)
+         if (info->output_bfd->xvec == abfd->xvec)
            {
              int flag;
 
@@ -1846,7 +1848,7 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
              /* We identify all symbols which are called, so that we
                 can create glue code for calls to functions imported
                 from dynamic objects.  */
-             if (info->hash->creator == abfd->xvec
+             if (info->output_bfd->xvec == abfd->xvec
                  && *rel_csect != bfd_und_section_ptr
                  && (rel->r_type == R_BR
                      || rel->r_type == R_RBR)
@@ -2064,7 +2066,7 @@ xcoff_link_check_ar_symbols (bfd *abfd,
 
   if ((abfd->flags & DYNAMIC) != 0
       && ! info->static_link
-      && info->hash->creator == abfd->xvec)
+      && info->output_bfd->xvec == abfd->xvec)
     return xcoff_link_check_dynamic_ar_symbols (abfd, info, pneeded);
 
   symesz = bfd_coff_symesz (abfd);
@@ -2097,7 +2099,7 @@ xcoff_link_check_ar_symbols (bfd *abfd,
             undefined references in shared objects.  */
          if (h != NULL
              && h->type == bfd_link_hash_undefined
-             && (info->hash->creator != abfd->xvec
+             && (info->output_bfd->xvec != abfd->xvec
                  || (((struct xcoff_link_hash_entry *) h)->flags
                      & XCOFF_DEF_DYNAMIC) == 0))
            {
@@ -2178,7 +2180,7 @@ _bfd_xcoff_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
        while (member != NULL)
          {
            if (bfd_check_format (member, bfd_object)
-               && (info->hash->creator == member->xvec)
+               && (info->output_bfd->xvec == member->xvec)
                && (! bfd_has_map (abfd) || (member->flags & DYNAMIC) != 0))
              {
                bfd_boolean needed;
@@ -2250,7 +2252,7 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
 
   sec->flags |= SEC_MARK;
 
-  if (sec->owner->xvec == info->hash->creator
+  if (sec->owner->xvec == info->output_bfd->xvec
       && coff_section_data (sec->owner, sec) != NULL
       && xcoff_section_data (sec->owner, sec) != NULL)
     {
@@ -2384,7 +2386,7 @@ xcoff_sweep (struct bfd_link_info *info)
              /* Keep all sections from non-XCOFF input files.  Keep
                 special sections.  Keep .debug sections for the
                 moment.  */
-             if (sub->xvec != info->hash->creator
+             if (sub->xvec != info->output_bfd->xvec
                  || o == xcoff_hash_table (info)->debug_section
                  || o == xcoff_hash_table (info)->loader_section
                  || o == xcoff_hash_table (info)->linkage_section
@@ -2757,7 +2759,7 @@ xcoff_build_ldsyms (struct xcoff_link_hash_entry *h, void * p)
          || h->root.type == bfd_link_hash_defweak)
       && (h->root.u.def.section->owner == NULL
          || (h->root.u.def.section->owner->xvec
-             != ldinfo->info->hash->creator)))
+             != ldinfo->info->output_bfd->xvec)))
     h->flags |= XCOFF_MARK;
 
   /* If this symbol is called and defined in a dynamic object, or it
@@ -3255,7 +3257,7 @@ bfd_xcoff_size_dynamic_sections (bfd *output_bfd,
       bfd_byte *esym, *esymend;
       bfd_size_type symesz;
 
-      if (sub->xvec != info->hash->creator)
+      if (sub->xvec != info->output_bfd->xvec)
        continue;
       subdeb = bfd_get_section_by_name (sub, ".debug");
       if (subdeb == NULL || subdeb->size == 0)
@@ -5460,8 +5462,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
                         that needs padding.  This requires unlinking and
                         relinking the bfd's section list.  */
 
-                     n = bfd_make_section_anyway (abfd, ".pad");
-                     n->flags = SEC_HAS_CONTENTS;
+                     n = bfd_make_section_anyway_with_flags (abfd, ".pad",
+                                                             SEC_HAS_CONTENTS);
                      n->alignment_power = 0;
 
                      bfd_section_list_remove (abfd, n);
This page took 0.032613 seconds and 4 git commands to generate.