* m16.igen (break): Call SignalException not sim_engine_halt.
[deliverable/binutils-gdb.git] / bfd / elf64-alpha.c
index dc9c6ccfa7a15d3f95616bede2894abfb302164e..84f3075e4c82a265f03a13f2c8a975e1b31c9b8e 100644 (file)
@@ -1,5 +1,5 @@
 /* Alpha specific support for 64-bit ELF
-   Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright 1996, 97, 98, 1999 Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@tamu.edu>.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -72,8 +72,6 @@ static boolean elf64_alpha_section_from_shdr
   PARAMS((bfd *, Elf64_Internal_Shdr *, char *));
 static boolean elf64_alpha_fake_sections
   PARAMS((bfd *, Elf64_Internal_Shdr *, asection *));
-static int elf64_alpha_additional_program_headers
-  PARAMS((bfd *));
 static boolean elf64_alpha_create_got_section
   PARAMS((bfd *, struct bfd_link_info *));
 static boolean elf64_alpha_create_dynamic_sections
@@ -101,7 +99,6 @@ static void elf64_alpha_merge_gots
 static boolean elf64_alpha_calc_got_offsets_for_symbol
   PARAMS ((struct alpha_elf_link_hash_entry *, PTR));
 static void elf64_alpha_calc_got_offsets PARAMS ((struct bfd_link_info *));
-static void elf64_alpha_strip_section_from_output PARAMS ((asection *));
 static boolean elf64_alpha_size_got_sections
   PARAMS ((bfd *, struct bfd_link_info *));
 static boolean elf64_alpha_always_size_sections
@@ -118,8 +115,6 @@ static boolean elf64_alpha_adjust_dynamic_symbol
   PARAMS((struct bfd_link_info *, struct elf_link_hash_entry *));
 static boolean elf64_alpha_size_dynamic_sections
   PARAMS((bfd *, struct bfd_link_info *));
-static boolean elf64_alpha_adjust_dynindx
-  PARAMS((struct elf_link_hash_entry *, PTR));
 static boolean elf64_alpha_relocate_section
   PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
          Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
@@ -130,6 +125,10 @@ static boolean elf64_alpha_finish_dynamic_sections
   PARAMS((bfd *, struct bfd_link_info *));
 static boolean elf64_alpha_final_link
   PARAMS((bfd *, struct bfd_link_info *));
+static boolean elf64_alpha_merge_ind_symbols
+  PARAMS((struct alpha_elf_link_hash_entry *, PTR));
+static Elf_Internal_Rela * elf64_alpha_find_reloc_at_ofs
+  PARAMS ((Elf_Internal_Rela *, Elf_Internal_Rela *, bfd_vma, int));
 
 \f
 struct alpha_elf_link_hash_entry
@@ -226,11 +225,13 @@ struct alpha_elf_link_hash_table
 /* Should we do dynamic things to this symbol?  */
 
 #define alpha_elf_dynamic_symbol_p(h, info)                            \
-  (((info)->shared && !(info)->symbolic && (h)->dynindx != -1)         \
-   || (((h)->elf_link_hash_flags                                       \
-       & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))      \
-       == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))     \
-   || (h)->root.type == bfd_link_hash_undefweak)
+  ((((info)->shared && !(info)->symbolic)                              \
+    || (((h)->elf_link_hash_flags                                      \
+        & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))     \
+        == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))    \
+    || (h)->root.type == bfd_link_hash_undefweak                       \
+    || (h)->root.type == bfd_link_hash_defweak)                                \
+   && (h)->dynindx != -1)
 
 /* Create an entry in a Alpha ELF linker hash table.  */
 
@@ -975,6 +976,17 @@ static const struct elf_reloc_map elf64_alpha_reloc_map[] =
   {BFD_RELOC_16_PCREL,         R_ALPHA_SREL16},
   {BFD_RELOC_32_PCREL,         R_ALPHA_SREL32},
   {BFD_RELOC_64_PCREL,         R_ALPHA_SREL64},
+
+/* The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to process
+   the explicit !<reloc>!sequence relocations, and are mapped into the normal
+   relocations at the end of processing. */
+  {BFD_RELOC_ALPHA_USER_LITERAL,       R_ALPHA_LITERAL},
+  {BFD_RELOC_ALPHA_USER_LITUSE_BASE,   R_ALPHA_LITUSE},
+  {BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF, R_ALPHA_LITUSE},
+  {BFD_RELOC_ALPHA_USER_LITUSE_JSR,    R_ALPHA_LITUSE},
+  {BFD_RELOC_ALPHA_USER_GPDISP,                R_ALPHA_GPDISP},
+  {BFD_RELOC_ALPHA_USER_GPRELHIGH,     R_ALPHA_GPRELHIGH},
+  {BFD_RELOC_ALPHA_USER_GPRELLOW,      R_ALPHA_GPRELLOW},
 };
 
 /* Given a BFD reloc type, return a HOWTO structure.  */
@@ -1473,8 +1485,8 @@ elf64_alpha_relax_section (abfd, sec, link_info, again)
   for (irel = internal_relocs; irel < irelend; irel++)
     {
       bfd_vma symval;
-      unsigned int insn;
       Elf_Internal_Sym isym;
+      struct alpha_elf_got_entry *gotent;
 
       if (ELF64_R_TYPE (irel->r_info) != (int) R_ALPHA_LITERAL)
        continue;
@@ -1519,7 +1531,6 @@ elf64_alpha_relax_section (abfd, sec, link_info, again)
       /* Get the value of the symbol referred to by the reloc.  */
       if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
        {
-
          /* A local symbol.  */
          bfd_elf64_swap_symbol_in (abfd,
                                    extsyms + ELF64_R_SYM (irel->r_info),
@@ -1536,38 +1547,42 @@ elf64_alpha_relax_section (abfd, sec, link_info, again)
            continue;   /* who knows. */
 
          info.h = NULL;
-         info.gotent = local_got_entries[ELF64_R_SYM(irel->r_info)];
          info.other = isym.st_other;
+         gotent = local_got_entries[ELF64_R_SYM(irel->r_info)];
          symval = isym.st_value;
        }
       else
        {
          unsigned long indx;
          struct alpha_elf_link_hash_entry *h;
-         struct alpha_elf_got_entry *gotent;
 
          indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
          h = alpha_elf_sym_hashes (abfd)[indx];
          BFD_ASSERT (h != NULL);
 
+         while (h->root.root.type == bfd_link_hash_indirect
+                || h->root.root.type == bfd_link_hash_warning)
+           h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
+
          /* We can't do anthing with undefined or dynamic symbols.  */
          if (h->root.root.type == bfd_link_hash_undefined
              || h->root.root.type == bfd_link_hash_undefweak
              || alpha_elf_dynamic_symbol_p (&h->root, link_info))
            continue;
 
-         /* Search for the got entry to be used by this relocation.  */
-         for (gotent = h->got_entries; gotent ; gotent = gotent->next)
-           if (gotent->gotobj == info.gotobj
-               && gotent->addend == irel->r_addend)
-             break;
-
          info.h = h;
          info.gotent = gotent;
          info.tsec = h->root.root.u.def.section;
          info.other = h->root.other;
+         gotent = h->got_entries;
          symval = h->root.root.u.def.value;
        }
+
+      /* Search for the got entry to be used by this relocation.  */
+      while (gotent->gotobj != info.gotobj || gotent->addend != irel->r_addend)
+       gotent = gotent->next;
+      info.gotent = gotent;
+
       symval += info.tsec->output_section->vma + info.tsec->output_offset;
       symval += irel->r_addend;
 
@@ -1820,34 +1835,6 @@ elf64_alpha_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
   return true;
 }
 
-/* Return the number of additional phdrs we will need.  */
-
-static int
-elf64_alpha_additional_program_headers (abfd)
-     bfd *abfd;
-{
-  asection *s;
-  int ret;
-
-  ret = 0;
-
-  s = bfd_get_section_by_name (abfd, ".reginfo");
-  if (s != NULL && (s->flags & SEC_LOAD) != 0)
-    {
-      /* We need a PT_ALPHA_REGINFO segment.  */
-      ++ret;
-    }
-
-  if (bfd_get_section_by_name (abfd, ".dynamic") != NULL
-      && bfd_get_section_by_name (abfd, ".mdebug") != NULL)
-    {
-      /* We need a PT_ALPHA_RTPROC segment.  */
-      ++ret;
-    }
-
-  return ret;
-}
-
 /* Create the .got section.  */
 
 static boolean
@@ -1975,6 +1962,7 @@ elf64_alpha_read_ecoff_info (abfd, section, debug)
   char *ext_hdr = NULL;
 
   swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
+  memset (debug, 0, sizeof(*debug));
 
   ext_hdr = (char *) bfd_malloc ((size_t) swap->external_hdr_size);
   if (ext_hdr == NULL && swap->external_hdr_size != 0)
@@ -2593,9 +2581,10 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs)
              else
                rent->count++;
            }
-         else if (info->shared)
+         else if (info->shared && (sec->flags & SEC_ALLOC))
            {
-             /* If this is a shared library, we need a RELATIVE reloc.  */
+             /* If this is a shared library, and the section is to be
+                loaded into memory, we need a RELATIVE reloc.  */
              sreloc->_raw_size += sizeof (Elf64_External_Rela);
            }
          break;
@@ -2655,7 +2644,8 @@ elf64_alpha_adjust_dynamic_symbol (info, h)
         generating a shared library, then set the symbol to the location
         in the .plt.  This is required to make function pointers compare
         equal between the normal executable and the shared library.  */
-      if (!info->shared)
+      if (! info->shared
+         && h->root.type != bfd_link_hash_defweak)
        {
          h->root.u.def.section = s;
          h->root.u.def.value = h->plt.offset;
@@ -2982,22 +2972,6 @@ elf64_alpha_calc_got_offsets (info)
     }
 }
 
-/* Remove a section from the output BFD.  */
-
-static void
-elf64_alpha_strip_section_from_output (s)
-     asection *s;
-{
-  asection **spp;
-
-  for (spp = &s->output_section->owner->sections;
-       *spp != s->output_section;
-       spp = &(*spp)->next)
-    continue;
-  *spp = s->output_section->next;
-  --s->output_section->owner->section_count;
-}
-
 /* Constructs the gots.  */
 
 static boolean
@@ -3137,21 +3111,36 @@ elf64_alpha_calc_dynrel_sizes (h, info)
     }
 
   /* If the symbol is dynamic, we'll need all the relocations in their
-     natural form.  If it has been forced local, we'll need the same 
-     number of RELATIVE relocations. 
-     Except, don't add a .got reloc if we're not using a .plt entry.  */
+     natural form.  If this is a shared object, and it has been forced
+     local, we'll need the same number of RELATIVE relocations.  */
 
-  if ((alpha_elf_dynamic_symbol_p (&h->root, info)
-       || info->shared)
-      && h->root.plt.offset == MINUS_ONE)
+  if (alpha_elf_dynamic_symbol_p (&h->root, info) || info->shared)
     {
-      bfd *dynobj = elf_hash_table(info)->dynobj;
+      struct alpha_elf_reloc_entry *relent;
+      bfd *dynobj;
       struct alpha_elf_got_entry *gotent;
-      bfd_size_type count = 0;
+      bfd_size_type count;
       asection *srel;
 
+      for (relent = h->reloc_entries; relent; relent = relent->next)
+       if (relent->rtype == R_ALPHA_REFLONG
+           || relent->rtype == R_ALPHA_REFQUAD)
+         {
+           relent->srel->_raw_size +=
+             sizeof(Elf64_External_Rela) * relent->count;
+         }
+
+      dynobj = elf_hash_table(info)->dynobj;
+      count = 0;
+
       for (gotent = h->got_entries; gotent ; gotent = gotent->next)
        count++;
+
+      /* If we are using a .plt entry, subtract one, as the first
+        reference uses a .rela.plt entry instead.  */
+      if (h->root.plt.offset != MINUS_ONE)
+       count--;
+
       if (count > 0)
        {
          srel = bfd_get_section_by_name (dynobj, ".rela.got");
@@ -3160,21 +3149,6 @@ elf64_alpha_calc_dynrel_sizes (h, info)
        }
     }
 
-  /* Shared objects require at least RELATIVE relocs for all REFQUAD
-     and REFLONG relocations.  */
-  if (info->shared)
-    {
-      struct alpha_elf_reloc_entry *relent;
-
-      for (relent = h->reloc_entries; relent; relent = relent->next)
-       if (relent->rtype == R_ALPHA_REFLONG
-           || relent->rtype == R_ALPHA_REFQUAD)
-         {
-           relent->srel->_raw_size +=
-             sizeof(Elf64_External_Rela) * relent->count;
-         }
-    }
-
   return true;
 }
 
@@ -3294,7 +3268,7 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
        }
 
       if (strip)
-       elf64_alpha_strip_section_from_output (s);
+       _bfd_strip_section_from_output (info, s);
       else
        {
          /* Allocate memory for the section contents.  */
@@ -3304,34 +3278,6 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
        }
     }
 
-  /* If we are generating a shared library, we generate a section
-     symbol for each output section.  These are local symbols, which
-     means that they must come first in the dynamic symbol table.
-     That means we must increment the dynamic symbol index of every
-     other dynamic symbol.  */
-  if (info->shared)
-    {
-      long c[2], i;
-      asection *p;
-
-      c[0] = 0;
-      c[1] = bfd_count_sections (output_bfd);
-
-      elf_hash_table (info)->dynsymcount += c[1];
-      elf_link_hash_traverse (elf_hash_table(info),
-                             elf64_alpha_adjust_dynindx,
-                             (PTR) c);
-
-      for (i = 1, p = output_bfd->sections;
-          p != NULL;
-          p = p->next, i++)
-       {
-         elf_section_data (p)->dynindx = i;
-         /* These symbols will have no names, so we don't need to
-            fiddle with dynstr_index.  */
-       }
-    }
-
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Add some entries to the .dynamic section.  We fill in the
@@ -3372,22 +3318,6 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
   return true;
 }
 
-/* Increment the index of a dynamic symbol by a given amount.  Called
-   via elf_link_hash_traverse.  */
-
-static boolean
-elf64_alpha_adjust_dynindx (h, cparg)
-     struct elf_link_hash_entry *h;
-     PTR cparg;
-{
-  long *cp = (long *)cparg;
-
-  if (h->dynindx >= cp[0])
-    h->dynindx += cp[1];
-
-  return true;
-}
-
 /* Relocate an Alpha ELF section.  */
 
 static boolean
@@ -3463,6 +3393,12 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
             anything, unless the reloc is against a section symbol,
             in which case we have to adjust according to where the
             section symbol winds up in the output section.  */
+
+         /* The symbol associated with GPDISP and LITUSE is 
+            immaterial.  Only the addend is significant.  */
+         if (r_type == R_ALPHA_GPDISP || r_type == R_ALPHA_LITUSE)
+           continue;
+
          if (r_symndx < symtab_hdr->sh_info)
            {
              sym = local_syms + r_symndx;
@@ -3539,13 +3475,17 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
            }
          else if (h->root.root.type == bfd_link_hash_undefweak)
            relocation = 0;
-         else if (info->shared && !info->symbolic)
+         else if (info->shared && !info->symbolic
+                  && !info->no_undefined
+                  && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
            relocation = 0;
          else
            {
              if (!((*info->callbacks->undefined_symbol)
                    (info, h->root.root.root.string, input_bfd,
-                    input_section, rel->r_offset)))
+                    input_section, rel->r_offset,
+                    (!info->shared || info->no_undefined
+                     || ELF_ST_VISIBILITY (h->root.other)))))
                return false;
              relocation = 0;
            }
@@ -3582,6 +3522,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
        case R_ALPHA_LITERAL:
          {
            struct alpha_elf_got_entry *gotent;
+           boolean dynamic_symbol;
 
            BFD_ASSERT(sgot != NULL);
            BFD_ASSERT(gp != 0);
@@ -3589,76 +3530,53 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
            if (h != NULL)
              {
                gotent = h->got_entries;
-               BFD_ASSERT(gotent != NULL);
-
-               while (gotent->gotobj != gotobj || gotent->addend != addend)
-                 gotent = gotent->next;
-
-               /* Initialize the .got entry's value.  */
-               if (!(gotent->flags & ALPHA_ELF_GOT_ENTRY_RELOCS_DONE))
-                 {
-                   bfd_put_64 (output_bfd, relocation+addend,
-                               sgot->contents + gotent->got_offset);
-
-                   /* If the symbol has been forced local, output a
-                      RELATIVE reloc, otherwise it will be handled in
-                      finish_dynamic_symbol.  */
-                   if (info->shared
-                       && !alpha_elf_dynamic_symbol_p (&h->root, info))
-                     {
-                       Elf_Internal_Rela outrel;
-
-                       BFD_ASSERT(srelgot != NULL);
-
-                       outrel.r_offset = (sgot->output_section->vma
-                                          + sgot->output_offset
-                                          + gotent->got_offset);
-                       outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
-                       outrel.r_addend = 0;
-
-                       bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-                                                  ((Elf64_External_Rela *)
-                                                   srelgot->contents)
-                                                  + srelgot->reloc_count++);
-                     }
-
-                   gotent->flags |= ALPHA_ELF_GOT_ENTRY_RELOCS_DONE;
-                 }
+               dynamic_symbol = alpha_elf_dynamic_symbol_p (&h->root, info);
              }
            else
              {
                gotent = (alpha_elf_tdata(input_bfd)->
                          local_got_entries[r_symndx]);
-               while (gotent->addend != addend)
-                 gotent = gotent->next;
+               dynamic_symbol = false;
+             }
+
+           BFD_ASSERT(gotent != NULL);
 
-               if (!(gotent->flags & ALPHA_ELF_GOT_ENTRY_RELOCS_DONE))
+           while (gotent->gotobj != gotobj || gotent->addend != addend)
+             gotent = gotent->next;
+
+           BFD_ASSERT(gotent->use_count >= 1);
+
+           /* Initialize the .got entry's value.  */
+           if (!(gotent->flags & ALPHA_ELF_GOT_ENTRY_RELOCS_DONE))
+             {
+               bfd_put_64 (output_bfd, relocation+addend,
+                           sgot->contents + gotent->got_offset);
+
+               /* If the symbol has been forced local, output a
+                  RELATIVE reloc, otherwise it will be handled in
+                  finish_dynamic_symbol.  */
+               if (info->shared && !dynamic_symbol)
                  {
-                   bfd_put_64 (output_bfd, relocation+addend,
-                               sgot->contents + gotent->got_offset);
-
-                   /* Local got entries need RELATIVE relocs in shared
-                      libraries.  */
-                   if (info->shared)
-                     {
-                       Elf_Internal_Rela outrel;
-
-                       BFD_ASSERT(srelgot != NULL);
-
-                       outrel.r_offset = (sgot->output_section->vma
-                                          + sgot->output_offset
-                                          + gotent->got_offset);
-                       outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
-                       outrel.r_addend = 0;
-
-                       bfd_elf64_swap_reloca_out (output_bfd, &outrel,
-                                                  ((Elf64_External_Rela *)
-                                                   srelgot->contents)
-                                                  + srelgot->reloc_count++);
-                     }
-
-                   gotent->flags |= ALPHA_ELF_GOT_ENTRY_RELOCS_DONE;
+                   Elf_Internal_Rela outrel;
+
+                   BFD_ASSERT(srelgot != NULL);
+
+                   outrel.r_offset = (sgot->output_section->vma
+                                      + sgot->output_offset
+                                      + gotent->got_offset);
+                   outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
+                   outrel.r_addend = 0;
+
+                   bfd_elf64_swap_reloca_out (output_bfd, &outrel,
+                                              ((Elf64_External_Rela *)
+                                               srelgot->contents)
+                                              + srelgot->reloc_count++);
+                   BFD_ASSERT (sizeof(Elf64_External_Rela)
+                               * srelgot->reloc_count
+                               <= srelgot->_cooked_size);
                  }
+
+               gotent->flags |= ALPHA_ELF_GOT_ENTRY_RELOCS_DONE;
              }
 
            /* Figure the gprel relocation.  */
@@ -3709,7 +3627,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
                outrel.r_addend = addend;
                addend = 0, relocation = 0;
              }
-           else if (info->shared)
+           else if (info->shared && (input_section->flags & SEC_ALLOC))
              {
                outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
                outrel.r_addend = 0;
@@ -3758,6 +3676,8 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
                                       ((Elf64_External_Rela *)
                                        srel->contents)
                                       + srel->reloc_count++);
+           BFD_ASSERT (sizeof(Elf64_External_Rela) * srel->reloc_count
+                       <= srel->_cooked_size);
          }
          goto default_reloc;
 
@@ -3882,14 +3802,40 @@ elf64_alpha_finish_dynamic_symbol (output_bfd, info, h, sym)
       bfd_put_64 (output_bfd, plt_addr, sgot->contents + gotent->got_offset);
 
       /* Subsequent .got entries will continue to bounce through the .plt.  */
-      while ((gotent = gotent->next) != NULL)
+      if (gotent->next)
        {
-         sgot = alpha_elf_tdata(gotent->gotobj)->got;
-         BFD_ASSERT(sgot != NULL);
-         BFD_ASSERT(gotent->addend == 0);
+         srel = bfd_get_section_by_name (dynobj, ".rela.got");
+         BFD_ASSERT (! info->shared || srel != NULL);
+
+         gotent = gotent->next;
+         do
+           {
+             sgot = alpha_elf_tdata(gotent->gotobj)->got;
+             BFD_ASSERT(sgot != NULL);
+             BFD_ASSERT(gotent->addend == 0);
+
+             bfd_put_64 (output_bfd, plt_addr,
+                         sgot->contents + gotent->got_offset);
 
-         bfd_put_64 (output_bfd, plt_addr,
-                     sgot->contents + gotent->got_offset);
+             if (info->shared)
+               {
+                 outrel.r_offset = (sgot->output_section->vma
+                                    + sgot->output_offset
+                                    + gotent->got_offset);
+                 outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
+                 outrel.r_addend = 0;
+
+                 bfd_elf64_swap_reloca_out (output_bfd, &outrel,
+                                            ((Elf64_External_Rela *)
+                                             srel->contents)
+                                            + srel->reloc_count++);
+                 BFD_ASSERT (sizeof(Elf64_External_Rela) * srel->reloc_count
+                             <= srel->_cooked_size);
+               }
+
+             gotent = gotent->next;
+           }
+          while (gotent != NULL);
        }
     }
   else if (alpha_elf_dynamic_symbol_p (h, info))
@@ -3916,6 +3862,8 @@ elf64_alpha_finish_dynamic_symbol (output_bfd, info, h, sym)
          bfd_elf64_swap_reloca_out (output_bfd, &outrel,
                                     ((Elf64_External_Rela *)srel->contents
                                      + srel->reloc_count++));
+         BFD_ASSERT (sizeof(Elf64_External_Rela) * srel->reloc_count
+                     <= srel->_cooked_size);
        }
     }
 
@@ -4017,44 +3965,6 @@ elf64_alpha_finish_dynamic_sections (output_bfd, info)
        }
     }
 
-  if (info->shared)
-    {
-      asection *sdynsym;
-      asection *s;
-      Elf_Internal_Sym sym;
-
-      /* Set up the section symbols for the output sections.  */
-
-      sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
-      BFD_ASSERT (sdynsym != NULL);
-
-      sym.st_size = 0;
-      sym.st_name = 0;
-      sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
-      sym.st_other = 0;
-
-      for (s = output_bfd->sections; s != NULL; s = s->next)
-       {
-         int indx;
-
-         sym.st_value = s->vma;
-
-         indx = elf_section_data (s)->this_idx;
-         BFD_ASSERT (indx > 0);
-         sym.st_shndx = indx;
-
-         bfd_elf64_swap_symbol_out (output_bfd, &sym,
-                                    (PTR) (((Elf64_External_Sym *)
-                                            sdynsym->contents)
-                                           + elf_section_data (s)->dynindx));
-       }
-
-      /* Set the sh_info field of the output .dynsym section to the
-         index of the first global symbol.  */
-      elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
-       bfd_count_sections (output_bfd) + 1;
-    }
-
   return true;
 }
 
@@ -4733,6 +4643,36 @@ elf64_alpha_ecoff_debug_swap =
   elf64_alpha_read_ecoff_info
 };
 \f
+/* Use a non-standard hash bucket size of 8.  */
+
+const struct elf_size_info alpha_elf_size_info =
+{
+  sizeof (Elf64_External_Ehdr),
+  sizeof (Elf64_External_Phdr),
+  sizeof (Elf64_External_Shdr),
+  sizeof (Elf64_External_Rel),
+  sizeof (Elf64_External_Rela),
+  sizeof (Elf64_External_Sym),
+  sizeof (Elf64_External_Dyn),
+  sizeof (Elf_External_Note),
+  8,
+  1,
+  64, 8,
+  ELFCLASS64, EV_CURRENT,
+  bfd_elf64_write_out_phdrs,
+  bfd_elf64_write_shdrs_and_ehdr,
+  bfd_elf64_write_relocs,
+  bfd_elf64_swap_symbol_out,
+  bfd_elf64_slurp_reloc_table,
+  bfd_elf64_slurp_symbol_table,
+  bfd_elf64_swap_dyn_in,
+  bfd_elf64_swap_dyn_out,
+  NULL,
+  NULL,
+  NULL,
+  NULL
+};
+
 #define TARGET_LITTLE_SYM      bfd_elf64_alpha_vec
 #define TARGET_LITTLE_NAME     "elf64-alpha"
 #define ELF_ARCH               bfd_arch_alpha
@@ -4756,8 +4696,6 @@ elf64_alpha_ecoff_debug_swap =
   elf64_alpha_section_from_shdr
 #define elf_backend_fake_sections \
   elf64_alpha_fake_sections
-#define elf_backend_additional_program_headers \
-  elf64_alpha_additional_program_headers
 
 #define bfd_elf64_bfd_is_local_label_name \
   elf64_alpha_is_local_label_name
@@ -4790,6 +4728,9 @@ elf64_alpha_ecoff_debug_swap =
 #define elf_backend_ecoff_debug_swap \
   &elf64_alpha_ecoff_debug_swap
 
+#define elf_backend_size_info \
+  alpha_elf_size_info
+
 /*
  * A few constants that determine how the .plt section is set up.
  */
This page took 0.051896 seconds and 4 git commands to generate.