Fix compile time warnings about using possibly uninitialised variables in rs6000...
[deliverable/binutils-gdb.git] / bfd / sunos.c
index 03d386a2f8f20b6acd4e261758e6e64e38d2331b..10f43549c920ba23afaab5139dd007e2db831774 100644 (file)
@@ -1,13 +1,12 @@
 /* BFD backend for SunOS binaries.
 /* BFD backend for SunOS binaries.
-   Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1990-2017 Free Software Foundation, Inc.
    Written by 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
    Written by 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,
    (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
 
    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.  */
 
 #define TARGETNAME "a.out-sunos-big"
 
 /* Do not "beautify" the CONCAT* macro args.  Traditional C will not
    remove whitespace added here, and thus will fail to concatenate
    the tokens.  */
 
 #define TARGETNAME "a.out-sunos-big"
 
 /* Do not "beautify" the CONCAT* macro args.  Traditional C will not
    remove whitespace added here, and thus will fail to concatenate
    the tokens.  */
-#define MY(OP) CONCAT2 (sunos_big_,OP)
+#define MY(OP) CONCAT2 (sparc_aout_sunos_be_,OP)
 
 
+#include "sysdep.h"
 #include "bfd.h"
 #include "bfdlink.h"
 #include "libaout.h"
 #include "bfd.h"
 #include "bfdlink.h"
 #include "libaout.h"
@@ -676,25 +677,17 @@ sunos_link_hash_table_create (bfd *abfd)
   struct sunos_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct sunos_link_hash_table);
 
   struct sunos_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct sunos_link_hash_table);
 
-  ret = bfd_malloc (amt);
+  ret = bfd_zmalloc (amt);
   if (ret ==  NULL)
     return NULL;
   if (ret ==  NULL)
     return NULL;
-  if (! NAME (aout, link_hash_table_init) (&ret->root, abfd,
-                                          sunos_link_hash_newfunc))
+  if (!NAME (aout, link_hash_table_init) (&ret->root, abfd,
+                                         sunos_link_hash_newfunc,
+                                         sizeof (struct sunos_link_hash_entry)))
     {
       free (ret);
       return NULL;
     }
 
     {
       free (ret);
       return NULL;
     }
 
-  ret->dynobj = NULL;
-  ret->dynamic_sections_created = FALSE;
-  ret->dynamic_sections_needed = FALSE;
-  ret->got_needed = FALSE;
-  ret->dynsymcount = 0;
-  ret->bucketcount = 0;
-  ret->needed = NULL;
-  ret->got_base = 0;
-
   return &ret->root.root;
 }
 
   return &ret->root.root;
 }
 
@@ -744,57 +737,54 @@ sunos_create_dynamic_sections (bfd *abfd,
       /* The .dynamic section holds the basic dynamic information: the
         sun4_dynamic structure, the dynamic debugger information, and
         the sun4_dynamic_link structure.  */
       /* The .dynamic section holds the basic dynamic information: the
         sun4_dynamic structure, the dynamic debugger information, and
         the sun4_dynamic_link structure.  */
-      s = bfd_make_section (abfd, ".dynamic");
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynamic", flags);
       if (s == NULL
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .got section holds the global offset table.  The address
         is put in the ld_got field.  */
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .got section holds the global offset table.  The address
         is put in the ld_got field.  */
-      s = bfd_make_section (abfd, ".got");
+      s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
       if (s == NULL
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .plt section holds the procedure linkage table.  The
         address is put in the ld_plt field.  */
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .plt section holds the procedure linkage table.  The
         address is put in the ld_plt field.  */
-      s = bfd_make_section (abfd, ".plt");
+      s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags | SEC_CODE);
       if (s == NULL
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .dynrel section holds the dynamic relocs.  The address is
         put in the ld_rel field.  */
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .dynrel section holds the dynamic relocs.  The address is
         put in the ld_rel field.  */
-      s = bfd_make_section (abfd, ".dynrel");
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynrel",
+                                             flags | SEC_READONLY);
       if (s == NULL
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .hash section holds the dynamic hash table.  The address
         is put in the ld_hash field.  */
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .hash section holds the dynamic hash table.  The address
         is put in the ld_hash field.  */
-      s = bfd_make_section (abfd, ".hash");
+      s = bfd_make_section_anyway_with_flags (abfd, ".hash",
+                                             flags | SEC_READONLY);
       if (s == NULL
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .dynsym section holds the dynamic symbols.  The address
         is put in the ld_stab field.  */
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .dynsym section holds the dynamic symbols.  The address
         is put in the ld_stab field.  */
-      s = bfd_make_section (abfd, ".dynsym");
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynsym",
+                                             flags | SEC_READONLY);
       if (s == NULL
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .dynstr section holds the dynamic symbol string table.
         The address is put in the ld_symbols field.  */
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .dynstr section holds the dynamic symbol string table.
         The address is put in the ld_symbols field.  */
-      s = bfd_make_section (abfd, ".dynstr");
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynstr",
+                                             flags | SEC_READONLY);
       if (s == NULL
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
@@ -802,13 +792,13 @@ sunos_create_dynamic_sections (bfd *abfd,
     }
 
   if ((needed && ! sunos_hash_table (info)->dynamic_sections_needed)
     }
 
   if ((needed && ! sunos_hash_table (info)->dynamic_sections_needed)
-      || info->shared)
+      || bfd_link_pic (info))
     {
       bfd *dynobj;
 
       dynobj = sunos_hash_table (info)->dynobj;
 
     {
       bfd *dynobj;
 
       dynobj = sunos_hash_table (info)->dynobj;
 
-      s = bfd_get_section_by_name (dynobj, ".got");
+      s = bfd_get_linker_section (dynobj, ".got");
       if (s->size == 0)
        s->size = BYTES_IN_WORD;
 
       if (s->size == 0)
        s->size = BYTES_IN_WORD;
 
@@ -834,11 +824,11 @@ sunos_add_dynamic_symbols (bfd *abfd,
   unsigned long need;
 
   /* Make sure we have all the required sections.  */
   unsigned long need;
 
   /* Make sure we have all the required sections.  */
-  if (info->hash->creator == abfd->xvec)
+  if (info->output_bfd->xvec == abfd->xvec)
     {
       if (! sunos_create_dynamic_sections (abfd, info,
                                           ((abfd->flags & DYNAMIC) != 0
     {
       if (! sunos_create_dynamic_sections (abfd, info,
                                           ((abfd->flags & DYNAMIC) != 0
-                                           && !info->relocatable)))
+                                           && !bfd_link_relocatable (info))))
        return FALSE;
     }
 
        return FALSE;
     }
 
@@ -870,12 +860,12 @@ sunos_add_dynamic_symbols (bfd *abfd,
 
   /* The native linker seems to just ignore dynamic objects when -r is
      used.  */
 
   /* The native linker seems to just ignore dynamic objects when -r is
      used.  */
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   /* There's no hope of using a dynamic object which does not exactly
      match the format of the output file.  */
     return TRUE;
 
   /* There's no hope of using a dynamic object which does not exactly
      match the format of the output file.  */
-  if (info->hash->creator != abfd->xvec)
+  if (info->output_bfd->xvec != abfd->xvec)
     {
       bfd_set_error (bfd_error_invalid_operation);
       return FALSE;
     {
       bfd_set_error (bfd_error_invalid_operation);
       return FALSE;
@@ -889,14 +879,10 @@ sunos_add_dynamic_symbols (bfd *abfd,
       /* The .need section holds the list of names of shared objets
         which must be included at runtime.  The address of this
         section is put in the ld_need field.  */
       /* The .need section holds the list of names of shared objets
         which must be included at runtime.  The address of this
         section is put in the ld_need field.  */
-      asection *s = bfd_make_section (dynobj, ".need");
+      flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                       | SEC_IN_MEMORY | SEC_READONLY);
+      asection *s = bfd_make_section_with_flags (dynobj, ".need", flags);
       if (s == NULL
       if (s == NULL
-         || ! bfd_set_section_flags (dynobj, s,
-                                     (SEC_ALLOC
-                                      | SEC_LOAD
-                                      | SEC_HAS_CONTENTS
-                                      | SEC_IN_MEMORY
-                                      | SEC_READONLY))
          || ! bfd_set_section_alignment (dynobj, s, 2))
        return FALSE;
     }
          || ! bfd_set_section_alignment (dynobj, s, 2))
        return FALSE;
     }
@@ -906,14 +892,10 @@ sunos_add_dynamic_symbols (bfd *abfd,
       /* The .rules section holds the path to search for shared
         objects.  The address of this section is put in the ld_rules
         field.  */
       /* The .rules section holds the path to search for shared
         objects.  The address of this section is put in the ld_rules
         field.  */
-      asection *s = bfd_make_section (dynobj, ".rules");
+      flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                       | SEC_IN_MEMORY | SEC_READONLY);
+      asection *s = bfd_make_section_with_flags (dynobj, ".rules", flags);
       if (s == NULL
       if (s == NULL
-         || ! bfd_set_section_flags (dynobj, s,
-                                     (SEC_ALLOC
-                                      | SEC_LOAD
-                                      | SEC_HAS_CONTENTS
-                                      | SEC_IN_MEMORY
-                                      | SEC_READONLY))
          || ! bfd_set_section_alignment (dynobj, s, 2))
        return FALSE;
     }
          || ! bfd_set_section_alignment (dynobj, s, 2))
        return FALSE;
     }
@@ -1134,7 +1116,7 @@ sunos_add_one_symbol (struct bfd_link_info *info,
     }
 
   if ((abfd->flags & DYNAMIC) != 0
     }
 
   if ((abfd->flags & DYNAMIC) != 0
-      && abfd->xvec == info->hash->creator
+      && abfd->xvec == info->output_bfd->xvec
       && (h->flags & SUNOS_CONSTRUCTOR) != 0)
     /* The existing symbol is a constructor symbol, and this symbol
        is from a dynamic object.  A constructor symbol is actually a
       && (h->flags & SUNOS_CONSTRUCTOR) != 0)
     /* The existing symbol is a constructor symbol, and this symbol
        is from a dynamic object.  A constructor symbol is actually a
@@ -1158,7 +1140,7 @@ sunos_add_one_symbol (struct bfd_link_info *info,
                                          hashp))
     return FALSE;
 
                                          hashp))
     return FALSE;
 
-  if (abfd->xvec == info->hash->creator)
+  if (abfd->xvec == info->output_bfd->xvec)
     {
       /* Set a flag in the hash table entry indicating the type of
         reference or definition we just found.  Keep a count of the
     {
       /* Set a flag in the hash table entry indicating the type of
         reference or definition we just found.  Keep a count of the
@@ -1204,7 +1186,7 @@ struct bfd_link_needed_list *
 bfd_sunos_get_needed_list (bfd *abfd ATTRIBUTE_UNUSED,
                           struct bfd_link_info *info)
 {
 bfd_sunos_get_needed_list (bfd *abfd ATTRIBUTE_UNUSED,
                           struct bfd_link_info *info)
 {
-  if (info->hash->creator != &MY (vec))
+  if (info->output_bfd->xvec != &MY (vec))
     return NULL;
   return sunos_hash_table (info)->needed;
 }
     return NULL;
   return sunos_hash_table (info)->needed;
 }
@@ -1232,7 +1214,7 @@ bfd_sunos_record_link_assignment (bfd *output_bfd,
 
   /* In a shared library, the __DYNAMIC symbol does not appear in the
      dynamic symbol table.  */
 
   /* In a shared library, the __DYNAMIC symbol does not appear in the
      dynamic symbol table.  */
-  if (! info->shared || strcmp (name, "__DYNAMIC") != 0)
+  if (! bfd_link_pic (info) || strcmp (name, "__DYNAMIC") != 0)
     {
       h->flags |= SUNOS_DEF_REGULAR;
 
     {
       h->flags |= SUNOS_DEF_REGULAR;
 
@@ -1336,11 +1318,11 @@ sunos_scan_std_relocs (struct bfd_link_info *info,
          if (! sunos_create_dynamic_sections (abfd, info, FALSE))
            return FALSE;
          dynobj = sunos_hash_table (info)->dynobj;
          if (! sunos_create_dynamic_sections (abfd, info, FALSE))
            return FALSE;
          dynobj = sunos_hash_table (info)->dynobj;
-         splt = bfd_get_section_by_name (dynobj, ".plt");
-         srel = bfd_get_section_by_name (dynobj, ".dynrel");
+         splt = bfd_get_linker_section (dynobj, ".plt");
+         srel = bfd_get_linker_section (dynobj, ".dynrel");
          BFD_ASSERT (splt != NULL && srel != NULL);
 
          BFD_ASSERT (splt != NULL && srel != NULL);
 
-         sgot = bfd_get_section_by_name (dynobj, ".got");
+         sgot = bfd_get_linker_section (dynobj, ".got");
          BFD_ASSERT (sgot != NULL);
          if (sgot->size == 0)
            sgot->size = BYTES_IN_WORD;
          BFD_ASSERT (sgot != NULL);
          if (sgot->size == 0)
            sgot->size = BYTES_IN_WORD;
@@ -1486,9 +1468,9 @@ sunos_scan_ext_relocs (struct bfd_link_info *info,
              if (! sunos_create_dynamic_sections (abfd, info, FALSE))
                return FALSE;
              dynobj = sunos_hash_table (info)->dynobj;
              if (! sunos_create_dynamic_sections (abfd, info, FALSE))
                return FALSE;
              dynobj = sunos_hash_table (info)->dynobj;
-             splt = bfd_get_section_by_name (dynobj, ".plt");
-             sgot = bfd_get_section_by_name (dynobj, ".got");
-             srel = bfd_get_section_by_name (dynobj, ".dynrel");
+             splt = bfd_get_linker_section (dynobj, ".plt");
+             sgot = bfd_get_linker_section (dynobj, ".got");
+             srel = bfd_get_linker_section (dynobj, ".dynrel");
              BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
              /* Make sure we have an initial entry in the .got table.  */
              BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
              /* Make sure we have an initial entry in the .got table.  */
@@ -1531,7 +1513,7 @@ sunos_scan_ext_relocs (struct bfd_link_info *info,
          /* If we are making a shared library, or if the symbol is
             defined by a dynamic object, we will need a dynamic reloc
             entry.  */
          /* If we are making a shared library, or if the symbol is
             defined by a dynamic object, we will need a dynamic reloc
             entry.  */
-         if (info->shared
+         if (bfd_link_pic (info)
              || (h != NULL
                  && (h->flags & SUNOS_DEF_DYNAMIC) != 0
                  && (h->flags & SUNOS_DEF_REGULAR) == 0))
              || (h != NULL
                  && (h->flags & SUNOS_DEF_DYNAMIC) != 0
                  && (h->flags & SUNOS_DEF_REGULAR) == 0))
@@ -1547,16 +1529,16 @@ sunos_scan_ext_relocs (struct bfd_link_info *info,
        {
          /* But, if we are creating a shared library, we need to
             generate an absolute reloc.  */
        {
          /* But, if we are creating a shared library, we need to
             generate an absolute reloc.  */
-         if (info->shared)
+         if (bfd_link_pic (info))
            {
              if (dynobj == NULL)
                {
                  if (! sunos_create_dynamic_sections (abfd, info, TRUE))
                    return FALSE;
                  dynobj = sunos_hash_table (info)->dynobj;
            {
              if (dynobj == NULL)
                {
                  if (! sunos_create_dynamic_sections (abfd, info, TRUE))
                    return FALSE;
                  dynobj = sunos_hash_table (info)->dynobj;
-                 splt = bfd_get_section_by_name (dynobj, ".plt");
-                 sgot = bfd_get_section_by_name (dynobj, ".got");
-                 srel = bfd_get_section_by_name (dynobj, ".dynrel");
+                 splt = bfd_get_linker_section (dynobj, ".plt");
+                 sgot = bfd_get_linker_section (dynobj, ".got");
+                 srel = bfd_get_linker_section (dynobj, ".dynrel");
                  BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
                }
 
                  BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
                }
 
@@ -1577,13 +1559,13 @@ sunos_scan_ext_relocs (struct bfd_link_info *info,
        continue;
 
       if (r_type != RELOC_JMP_TBL
        continue;
 
       if (r_type != RELOC_JMP_TBL
-         && ! info->shared
+         && ! bfd_link_pic (info)
          && ((h->flags & SUNOS_DEF_DYNAMIC) == 0
              || (h->flags & SUNOS_DEF_REGULAR) != 0))
        continue;
 
       if (r_type == RELOC_JMP_TBL
          && ((h->flags & SUNOS_DEF_DYNAMIC) == 0
              || (h->flags & SUNOS_DEF_REGULAR) != 0))
        continue;
 
       if (r_type == RELOC_JMP_TBL
-         && ! info->shared
+         && ! bfd_link_pic (info)
          && (h->flags & SUNOS_DEF_DYNAMIC) == 0
          && (h->flags & SUNOS_DEF_REGULAR) == 0)
        {
          && (h->flags & SUNOS_DEF_DYNAMIC) == 0
          && (h->flags & SUNOS_DEF_REGULAR) == 0)
        {
@@ -1601,9 +1583,9 @@ sunos_scan_ext_relocs (struct bfd_link_info *info,
          if (! sunos_create_dynamic_sections (abfd, info, FALSE))
            return FALSE;
          dynobj = sunos_hash_table (info)->dynobj;
          if (! sunos_create_dynamic_sections (abfd, info, FALSE))
            return FALSE;
          dynobj = sunos_hash_table (info)->dynobj;
-         splt = bfd_get_section_by_name (dynobj, ".plt");
-         sgot = bfd_get_section_by_name (dynobj, ".got");
-         srel = bfd_get_section_by_name (dynobj, ".dynrel");
+         splt = bfd_get_linker_section (dynobj, ".plt");
+         sgot = bfd_get_linker_section (dynobj, ".got");
+         srel = bfd_get_linker_section (dynobj, ".dynrel");
          BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
          /* Make sure we have an initial entry in the .got table.  */
          BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
          /* Make sure we have an initial entry in the .got table.  */
@@ -1613,10 +1595,10 @@ sunos_scan_ext_relocs (struct bfd_link_info *info,
        }
 
       BFD_ASSERT (r_type == RELOC_JMP_TBL
        }
 
       BFD_ASSERT (r_type == RELOC_JMP_TBL
-                 || info->shared
+                 || bfd_link_pic (info)
                  || (h->flags & SUNOS_REF_REGULAR) != 0);
       BFD_ASSERT (r_type == RELOC_JMP_TBL
                  || (h->flags & SUNOS_REF_REGULAR) != 0);
       BFD_ASSERT (r_type == RELOC_JMP_TBL
-                 || info->shared
+                 || bfd_link_pic (info)
                  || h->plt_offset != 0
                  || ((h->root.root.type == bfd_link_hash_defined
                       || h->root.root.type == bfd_link_hash_defweak)
                  || h->plt_offset != 0
                  || ((h->root.root.type == bfd_link_hash_defined
                       || h->root.root.type == bfd_link_hash_defweak)
@@ -1675,13 +1657,13 @@ sunos_scan_ext_relocs (struct bfd_link_info *info,
              /* We will also need a dynamic reloc entry, unless this
                 is a JMP_TBL reloc produced by linking PIC compiled
                 code, and we are not making a shared library.  */
              /* We will also need a dynamic reloc entry, unless this
                 is a JMP_TBL reloc produced by linking PIC compiled
                 code, and we are not making a shared library.  */
-             if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0)
+             if (bfd_link_pic (info) || (h->flags & SUNOS_DEF_REGULAR) == 0)
                srel->size += RELOC_EXT_SIZE;
            }
 
          /* If we are creating a shared library, we need to copy over
             any reloc other than a jump table reloc.  */
                srel->size += RELOC_EXT_SIZE;
            }
 
          /* If we are creating a shared library, we need to copy over
             any reloc other than a jump table reloc.  */
-         if (info->shared && r_type != RELOC_JMP_TBL)
+         if (bfd_link_pic (info) && r_type != RELOC_JMP_TBL)
            srel->size += RELOC_EXT_SIZE;
        }
     }
            srel->size += RELOC_EXT_SIZE;
        }
     }
@@ -1761,9 +1743,6 @@ sunos_scan_dynamic_symbol (struct sunos_link_hash_entry *h, void * data)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) data;
 
 {
   struct bfd_link_info *info = (struct bfd_link_info *) data;
 
-  if (h->root.root.type == bfd_link_hash_warning)
-    h = (struct sunos_link_hash_entry *) h->root.root.u.i.link;
-
   /* Set the written flag for symbols we do not want to write out as
      part of the regular symbol table.  This is all symbols which are
      not defined in a regular object file.  For some reason symbols
   /* Set the written flag for symbols we do not want to write out as
      part of the regular symbol table.  This is all symbols which are
      not defined in a regular object file.  For some reason symbols
@@ -1829,7 +1808,7 @@ sunos_scan_dynamic_symbol (struct sunos_link_hash_entry *h, void * data)
         regular symbols includes the debugging symbols, which have
         long names and are often duplicated in several object files.
         There are no debugging symbols in the dynamic symbols.  */
         regular symbols includes the debugging symbols, which have
         long names and are often duplicated in several object files.
         There are no debugging symbols in the dynamic symbols.  */
-      s = bfd_get_section_by_name (dynobj, ".dynstr");
+      s = bfd_get_linker_section (dynobj, ".dynstr");
       BFD_ASSERT (s != NULL);
       contents = bfd_realloc (s->contents, s->size + len + 1);
       if (contents == NULL)
       BFD_ASSERT (s != NULL);
       contents = bfd_realloc (s->contents, s->size + len + 1);
       if (contents == NULL)
@@ -1848,7 +1827,7 @@ sunos_scan_dynamic_symbol (struct sunos_link_hash_entry *h, void * data)
       hash &= 0x7fffffff;
       hash %= sunos_hash_table (info)->bucketcount;
 
       hash &= 0x7fffffff;
       hash %= sunos_hash_table (info)->bucketcount;
 
-      s = bfd_get_section_by_name (dynobj, ".hash");
+      s = bfd_get_linker_section (dynobj, ".hash");
       BFD_ASSERT (s != NULL);
 
       if (GET_SWORD (dynobj, s->contents + hash * HASH_ENTRY_SIZE) == -1)
       BFD_ASSERT (s != NULL);
 
       if (GET_SWORD (dynobj, s->contents + hash * HASH_ENTRY_SIZE) == -1)
@@ -1901,7 +1880,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
   *sneedptr = NULL;
   *srulesptr = NULL;
 
   *sneedptr = NULL;
   *srulesptr = NULL;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   if (output_bfd->xvec != &MY(vec))
     return TRUE;
 
   if (output_bfd->xvec != &MY(vec))
@@ -1912,7 +1891,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
      to determine the number of dynamic relocs we need, and, more
      importantly, there is no other way to know which symbols should
      get an entry in the procedure linkage table.  */
      to determine the number of dynamic relocs we need, and, more
      importantly, there is no other way to know which symbols should
      get an entry in the procedure linkage table.  */
-  for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+  for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
     {
       if ((sub->flags & DYNAMIC) == 0
          && sub->xvec == output_bfd->xvec)
     {
       if ((sub->flags & DYNAMIC) == 0
          && sub->xvec == output_bfd->xvec)
@@ -1945,14 +1924,14 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
          ++sunos_hash_table (info)->dynsymcount;
          h->dynindx = -2;
        }
          ++sunos_hash_table (info)->dynsymcount;
          h->dynindx = -2;
        }
+      s = bfd_get_linker_section (dynobj, ".got");
+      BFD_ASSERT (s != NULL);
       h->root.root.type = bfd_link_hash_defined;
       h->root.root.type = bfd_link_hash_defined;
-      h->root.root.u.def.section = bfd_get_section_by_name (dynobj, ".got");
+      h->root.root.u.def.section = s;
 
       /* If the .got section is more than 0x1000 bytes, we set
         __GLOBAL_OFFSET_TABLE_ to be 0x1000 bytes into the section,
         so that 13 bit relocations have a greater chance of working.  */
 
       /* If the .got section is more than 0x1000 bytes, we set
         __GLOBAL_OFFSET_TABLE_ to be 0x1000 bytes into the section,
         so that 13 bit relocations have a greater chance of working.  */
-      s = bfd_get_section_by_name (dynobj, ".got");
-      BFD_ASSERT (s != NULL);
       if (s->size >= 0x1000)
        h->root.root.u.def.value = 0x1000;
       else
       if (s->size >= 0x1000)
        h->root.root.u.def.value = 0x1000;
       else
@@ -1965,7 +1944,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
      up the dynamic linking information.  */
   if (sunos_hash_table (info)->dynamic_sections_needed)
     {
      up the dynamic linking information.  */
   if (sunos_hash_table (info)->dynamic_sections_needed)
     {
-      *sdynptr = bfd_get_section_by_name (dynobj, ".dynamic");
+      *sdynptr = bfd_get_linker_section (dynobj, ".dynamic");
 
       /* The .dynamic section is always the same size.  */
       s = *sdynptr;
 
       /* The .dynamic section is always the same size.  */
       s = *sdynptr;
@@ -1982,7 +1961,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
         symbols.  We build the dynamic symbol string table (.dynstr)
         in a traversal of the symbol table using
         sunos_scan_dynamic_symbol.  */
         symbols.  We build the dynamic symbol string table (.dynstr)
         in a traversal of the symbol table using
         sunos_scan_dynamic_symbol.  */
-      s = bfd_get_section_by_name (dynobj, ".dynsym");
+      s = bfd_get_linker_section (dynobj, ".dynsym");
       BFD_ASSERT (s != NULL);
       s->size = dynsymcount * sizeof (struct external_nlist);
       s->contents = bfd_alloc (output_bfd, s->size);
       BFD_ASSERT (s != NULL);
       s->size = dynsymcount * sizeof (struct external_nlist);
       s->contents = bfd_alloc (output_bfd, s->size);
@@ -2003,7 +1982,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
        bucketcount = dynsymcount;
       else
        bucketcount = 1;
        bucketcount = dynsymcount;
       else
        bucketcount = 1;
-      s = bfd_get_section_by_name (dynobj, ".hash");
+      s = bfd_get_linker_section (dynobj, ".hash");
       BFD_ASSERT (s != NULL);
       hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
       s->contents = bfd_zalloc (dynobj, hashalloc);
       BFD_ASSERT (s != NULL);
       hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
       s->contents = bfd_zalloc (dynobj, hashalloc);
@@ -2027,7 +2006,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
       /* The SunOS native linker seems to align the total size of the
         symbol strings to a multiple of 8.  I don't know if this is
         important, but it can't hurt much.  */
       /* The SunOS native linker seems to align the total size of the
         symbol strings to a multiple of 8.  I don't know if this is
         important, but it can't hurt much.  */
-      s = bfd_get_section_by_name (dynobj, ".dynstr");
+      s = bfd_get_linker_section (dynobj, ".dynstr");
       BFD_ASSERT (s != NULL);
       if ((s->size & 7) != 0)
        {
       BFD_ASSERT (s != NULL);
       if ((s->size & 7) != 0)
        {
@@ -2046,7 +2025,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
 
   /* Now that we have worked out the sizes of the procedure linkage
      table and the dynamic relocs, allocate storage for them.  */
 
   /* Now that we have worked out the sizes of the procedure linkage
      table and the dynamic relocs, allocate storage for them.  */
-  s = bfd_get_section_by_name (dynobj, ".plt");
+  s = bfd_get_linker_section (dynobj, ".plt");
   BFD_ASSERT (s != NULL);
   if (s->size != 0)
     {
   BFD_ASSERT (s != NULL);
   if (s->size != 0)
     {
@@ -2070,7 +2049,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
        }
     }
 
        }
     }
 
-  s = bfd_get_section_by_name (dynobj, ".dynrel");
+  s = bfd_get_linker_section (dynobj, ".dynrel");
   if (s->size != 0)
     {
       s->contents = bfd_alloc (dynobj, s->size);
   if (s->size != 0)
     {
       s->contents = bfd_alloc (dynobj, s->size);
@@ -2082,7 +2061,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd,
   s->reloc_count = 0;
 
   /* Make space for the global offset table.  */
   s->reloc_count = 0;
 
   /* Make space for the global offset table.  */
-  s = bfd_get_section_by_name (dynobj, ".got");
+  s = bfd_get_linker_section (dynobj, ".got");
   s->contents = bfd_alloc (dynobj, s->size);
   if (s->contents == NULL)
     return FALSE;
   s->contents = bfd_alloc (dynobj, s->size);
   if (s->contents == NULL)
     return FALSE;
@@ -2128,10 +2107,10 @@ sunos_write_dynamic_symbol (bfd *output_bfd,
       bfd_vma r_address;
 
       dynobj = sunos_hash_table (info)->dynobj;
       bfd_vma r_address;
 
       dynobj = sunos_hash_table (info)->dynobj;
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       p = splt->contents + h->plt_offset;
 
       p = splt->contents + h->plt_offset;
 
-      s = bfd_get_section_by_name (dynobj, ".dynrel");
+      s = bfd_get_linker_section (dynobj, ".dynrel");
 
       r_address = (splt->output_section->vma
                   + splt->output_offset
 
       r_address = (splt->output_section->vma
                   + splt->output_offset
@@ -2140,7 +2119,7 @@ sunos_write_dynamic_symbol (bfd *output_bfd,
       switch (bfd_get_arch (output_bfd))
        {
        case bfd_arch_sparc:
       switch (bfd_get_arch (output_bfd))
        {
        case bfd_arch_sparc:
-         if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0)
+         if (bfd_link_pic (info) || (h->flags & SUNOS_DEF_REGULAR) == 0)
            {
              bfd_put_32 (output_bfd, SPARC_PLT_ENTRY_WORD0, p);
              bfd_put_32 (output_bfd,
            {
              bfd_put_32 (output_bfd, SPARC_PLT_ENTRY_WORD0, p);
              bfd_put_32 (output_bfd,
@@ -2167,7 +2146,7 @@ sunos_write_dynamic_symbol (bfd *output_bfd,
          break;
 
        case bfd_arch_m68k:
          break;
 
        case bfd_arch_m68k:
-         if (! info->shared && (h->flags & SUNOS_DEF_REGULAR) != 0)
+         if (! bfd_link_pic (info) && (h->flags & SUNOS_DEF_REGULAR) != 0)
            abort ();
          bfd_put_16 (output_bfd, M68K_PLT_ENTRY_WORD0, p);
          bfd_put_32 (output_bfd, (- (h->plt_offset + 2)), p + 2);
            abort ();
          bfd_put_16 (output_bfd, M68K_PLT_ENTRY_WORD0, p);
          bfd_put_32 (output_bfd, (- (h->plt_offset + 2)), p + 2);
@@ -2181,7 +2160,7 @@ sunos_write_dynamic_symbol (bfd *output_bfd,
 
       /* We also need to add a jump table reloc, unless this is the
         result of a JMP_TBL reloc from PIC compiled code.  */
 
       /* We also need to add a jump table reloc, unless this is the
         result of a JMP_TBL reloc from PIC compiled code.  */
-      if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0)
+      if (bfd_link_pic (info) || (h->flags & SUNOS_DEF_REGULAR) == 0)
        {
          BFD_ASSERT (h->dynindx >= 0);
          BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
        {
          BFD_ASSERT (h->dynindx >= 0);
          BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
@@ -2315,7 +2294,7 @@ sunos_write_dynamic_symbol (bfd *output_bfd,
       return TRUE;
     }
 
       return TRUE;
     }
 
-  s = bfd_get_section_by_name (sunos_hash_table (info)->dynobj, ".dynsym");
+  s = bfd_get_linker_section (sunos_hash_table (info)->dynobj, ".dynsym");
   BFD_ASSERT (s != NULL);
   outsym = ((struct external_nlist *)
            (s->contents + h->dynindx * EXTERNAL_NLIST_SIZE));
   BFD_ASSERT (s != NULL);
   outsym = ((struct external_nlist *)
            (s->contents + h->dynindx * EXTERNAL_NLIST_SIZE));
@@ -2364,13 +2343,13 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info,
 
   if (h != NULL
       && h->plt_offset != 0
 
   if (h != NULL
       && h->plt_offset != 0
-      && (info->shared
+      && (bfd_link_pic (info)
          || (h->flags & SUNOS_DEF_REGULAR) == 0))
     {
       asection *splt;
 
       /* Redirect the relocation to the PLT entry.  */
          || (h->flags & SUNOS_DEF_REGULAR) == 0))
     {
       asection *splt;
 
       /* Redirect the relocation to the PLT entry.  */
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       *relocationp = (splt->output_section->vma
                      + splt->output_offset
                      + h->plt_offset);
       *relocationp = (splt->output_section->vma
                      + splt->output_offset
                      + h->plt_offset);
@@ -2465,21 +2444,21 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info,
 
       BFD_ASSERT (got_offsetp != NULL && *got_offsetp != 0);
 
 
       BFD_ASSERT (got_offsetp != NULL && *got_offsetp != 0);
 
-      sgot = bfd_get_section_by_name (dynobj, ".got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
 
       /* We set the least significant bit to indicate whether we have
         already initialized the GOT entry.  */
       if ((*got_offsetp & 1) == 0)
        {
          if (h == NULL
 
       /* We set the least significant bit to indicate whether we have
         already initialized the GOT entry.  */
       if ((*got_offsetp & 1) == 0)
        {
          if (h == NULL
-             || (! info->shared
+             || (! bfd_link_pic (info)
                  && ((h->flags & SUNOS_DEF_DYNAMIC) == 0
                      || (h->flags & SUNOS_DEF_REGULAR) != 0)))
            PUT_WORD (dynobj, *relocationp, sgot->contents + *got_offsetp);
          else
            PUT_WORD (dynobj, 0, sgot->contents + *got_offsetp);
 
                  && ((h->flags & SUNOS_DEF_DYNAMIC) == 0
                      || (h->flags & SUNOS_DEF_REGULAR) != 0)))
            PUT_WORD (dynobj, *relocationp, sgot->contents + *got_offsetp);
          else
            PUT_WORD (dynobj, 0, sgot->contents + *got_offsetp);
 
-         if (info->shared
+         if (bfd_link_pic (info)
              || (h != NULL
                  && (h->flags & SUNOS_DEF_DYNAMIC) != 0
                  && (h->flags & SUNOS_DEF_REGULAR) == 0))
              || (h != NULL
                  && (h->flags & SUNOS_DEF_DYNAMIC) != 0
                  && (h->flags & SUNOS_DEF_REGULAR) == 0))
@@ -2487,7 +2466,7 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info,
              /* We need to create a GLOB_DAT or 32 reloc to tell the
                 dynamic linker to fill in this entry in the table.  */
 
              /* We need to create a GLOB_DAT or 32 reloc to tell the
                 dynamic linker to fill in this entry in the table.  */
 
-             s = bfd_get_section_by_name (dynobj, ".dynrel");
+             s = bfd_get_linker_section (dynobj, ".dynrel");
              BFD_ASSERT (s != NULL);
              BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
                          < s->size);
              BFD_ASSERT (s != NULL);
              BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
                          < s->size);
@@ -2595,7 +2574,7 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info,
 
   if (! sunos_hash_table (info)->dynamic_sections_needed)
     return TRUE;
 
   if (! sunos_hash_table (info)->dynamic_sections_needed)
     return TRUE;
-  if (! info->shared)
+  if (! bfd_link_pic (info))
     {
       if (h == NULL
          || h->dynindx == -1
     {
       if (h == NULL
          || h->dynindx == -1
@@ -2617,7 +2596,7 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info,
 
   /* It looks like this is a reloc we are supposed to copy.  */
 
 
   /* It looks like this is a reloc we are supposed to copy.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynrel");
+  s = bfd_get_linker_section (dynobj, ".dynrel");
   BFD_ASSERT (s != NULL);
   BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) < s->size);
 
   BFD_ASSERT (s != NULL);
   BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) < s->size);
 
@@ -2715,7 +2694,7 @@ sunos_finish_dynamic_link (bfd *abfd, struct bfd_link_info *info)
 
   dynobj = sunos_hash_table (info)->dynobj;
 
 
   dynobj = sunos_hash_table (info)->dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
   BFD_ASSERT (sdyn != NULL);
 
   /* Finish up the .need section.  The linker emulation code filled it
   BFD_ASSERT (sdyn != NULL);
 
   /* Finish up the .need section.  The linker emulation code filled it
@@ -2745,9 +2724,9 @@ sunos_finish_dynamic_link (bfd *abfd, struct bfd_link_info *info)
 
   /* The first entry in the .got section is the address of the
      dynamic information, unless this is a shared library.  */
 
   /* The first entry in the .got section is the address of the
      dynamic information, unless this is a shared library.  */
-  s = bfd_get_section_by_name (dynobj, ".got");
+  s = bfd_get_linker_section (dynobj, ".got");
   BFD_ASSERT (s != NULL);
   BFD_ASSERT (s != NULL);
-  if (info->shared || sdyn->size == 0)
+  if (bfd_link_pic (info) || sdyn->size == 0)
     PUT_WORD (dynobj, 0, s->contents);
   else
     PUT_WORD (dynobj, sdyn->output_section->vma + sdyn->output_offset,
     PUT_WORD (dynobj, 0, s->contents);
   else
     PUT_WORD (dynobj, sdyn->output_section->vma + sdyn->output_offset,
@@ -2807,30 +2786,30 @@ sunos_finish_dynamic_link (bfd *abfd, struct bfd_link_info *info)
        PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                  esdl.ld_rules);
 
        PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                  esdl.ld_rules);
 
-      s = bfd_get_section_by_name (dynobj, ".got");
+      s = bfd_get_linker_section (dynobj, ".got");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->vma + s->output_offset,
                esdl.ld_got);
 
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->vma + s->output_offset,
                esdl.ld_got);
 
-      s = bfd_get_section_by_name (dynobj, ".plt");
+      s = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->vma + s->output_offset,
                esdl.ld_plt);
       PUT_WORD (dynobj, s->size, esdl.ld_plt_sz);
 
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->vma + s->output_offset,
                esdl.ld_plt);
       PUT_WORD (dynobj, s->size, esdl.ld_plt_sz);
 
-      s = bfd_get_section_by_name (dynobj, ".dynrel");
+      s = bfd_get_linker_section (dynobj, ".dynrel");
       BFD_ASSERT (s != NULL);
       BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
                  == s->size);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                esdl.ld_rel);
 
       BFD_ASSERT (s != NULL);
       BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
                  == s->size);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                esdl.ld_rel);
 
-      s = bfd_get_section_by_name (dynobj, ".hash");
+      s = bfd_get_linker_section (dynobj, ".hash");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                esdl.ld_hash);
 
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                esdl.ld_hash);
 
-      s = bfd_get_section_by_name (dynobj, ".dynsym");
+      s = bfd_get_linker_section (dynobj, ".dynsym");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                esdl.ld_stab);
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                esdl.ld_stab);
@@ -2840,7 +2819,7 @@ sunos_finish_dynamic_link (bfd *abfd, struct bfd_link_info *info)
       PUT_WORD (dynobj, (bfd_vma) sunos_hash_table (info)->bucketcount,
                esdl.ld_buckets);
 
       PUT_WORD (dynobj, (bfd_vma) sunos_hash_table (info)->bucketcount,
                esdl.ld_buckets);
 
-      s = bfd_get_section_by_name (dynobj, ".dynstr");
+      s = bfd_get_linker_section (dynobj, ".dynstr");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                esdl.ld_symbols);
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
                esdl.ld_symbols);
This page took 0.033991 seconds and 4 git commands to generate.