Add new port: crx-elf
[deliverable/binutils-gdb.git] / bfd / elf64-alpha.c
index 029c1d479068ddb8be2cce61c1b83742d290906c..7b17db54333cb3a9278e31372048121f2159be4f 100644 (file)
@@ -1,5 +1,5 @@
 /* Alpha specific support for 64-bit ELF
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@tamu.edu>.
 
@@ -47,7 +47,7 @@
 #define ECOFF_64
 #include "ecoffswap.h"
 
-static int alpha_elf_dynamic_symbol_p
+static bfd_boolean alpha_elf_dynamic_symbol_p
   PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *));
 static struct bfd_hash_entry * elf64_alpha_link_hash_newfunc
   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
@@ -75,7 +75,7 @@ static bfd_boolean elf64_alpha_object_p
 static bfd_boolean elf64_alpha_section_from_shdr
   PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean elf64_alpha_section_flags
-  PARAMS ((flagword *, Elf_Internal_Shdr *));
+  PARAMS ((flagword *, const Elf_Internal_Shdr *));
 static bfd_boolean elf64_alpha_fake_sections
   PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
 static bfd_boolean elf64_alpha_create_got_section
@@ -123,7 +123,7 @@ static bfd_boolean elf64_alpha_size_rela_got_section
 static bfd_boolean elf64_alpha_size_rela_got_1
   PARAMS ((struct alpha_elf_link_hash_entry *, struct bfd_link_info *));
 static bfd_boolean elf64_alpha_add_symbol_hook
-  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
+  PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
           const char **, flagword *, asection **, bfd_vma *));
 static struct alpha_elf_got_entry *get_got_entry
   PARAMS ((bfd *, struct alpha_elf_link_hash_entry *, unsigned long,
@@ -177,6 +177,11 @@ struct alpha_elf_link_hash_entry
 #define ALPHA_ELF_LINK_HASH_LU_TLSLDM  0x20
 #define ALPHA_ELF_LINK_HASH_LU_FUNC    0x38
 #define ALPHA_ELF_LINK_HASH_TLS_IE     0x40
+#define ALPHA_ELF_LINK_HASH_PLT_LOC    0x80
+
+  /* Used to undo the localization of a plt symbol.  */
+  asection *plt_old_section;
+  bfd_vma plt_old_value;
 
   /* Used to implement multiple .got subsections.  */
   struct alpha_elf_got_entry
@@ -264,47 +269,17 @@ struct alpha_elf_link_hash_table
 #define alpha_elf_sym_hashes(abfd) \
   ((struct alpha_elf_link_hash_entry **)elf_sym_hashes(abfd))
 
-/* Should we do dynamic things to this symbol?  */
+/* Should we do dynamic things to this symbol?  This differs from the 
+   generic version in that we never need to consider function pointer
+   equality wrt PLT entries -- we don't create a PLT entry if a symbol's
+   address is ever taken.  */
 
-static int
+static inline bfd_boolean
 alpha_elf_dynamic_symbol_p (h, info)
      struct elf_link_hash_entry *h;
      struct bfd_link_info *info;
 {
-  if (h == NULL)
-    return FALSE;
-
-  while (h->root.type == bfd_link_hash_indirect
-        || h->root.type == bfd_link_hash_warning)
-    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-  if (h->dynindx == -1)
-    return FALSE;
-
-  if (h->root.type == bfd_link_hash_undefweak
-      || h->root.type == bfd_link_hash_defweak)
-    return TRUE;
-
-  switch (ELF_ST_VISIBILITY (h->other))
-    {
-    case STV_DEFAULT:
-      break;
-    case STV_HIDDEN:
-    case STV_INTERNAL:
-      return FALSE;
-    case STV_PROTECTED:
-      if (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
-        return FALSE;
-      break;
-    }
-
-  if ((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)))
-    return TRUE;
-
-  return FALSE;
+  return _bfd_elf_dynamic_symbol_p (h, info, 0);
 }
 
 /* Create an entry in a Alpha ELF linker hash table.  */
@@ -418,15 +393,6 @@ static bfd_boolean
 elf64_alpha_object_p (abfd)
      bfd *abfd;
 {
-  /* Allocate our special target data.  */
-  struct alpha_elf_obj_tdata *new_tdata;
-  bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata);
-  new_tdata = bfd_zalloc (abfd, amt);
-  if (new_tdata == NULL)
-    return FALSE;
-  new_tdata->root = *abfd->tdata.elf_obj_data;
-  abfd->tdata.any = new_tdata;
-
   /* Set the right machine number for an Alpha ELF file.  */
   return bfd_default_set_arch_mach (abfd, bfd_arch_alpha, 0);
 }
@@ -1070,6 +1036,7 @@ elf64_alpha_reloc_gpdisp (abfd, reloc_entry, sym, data, input_section,
 {
   bfd_reloc_status_type ret;
   bfd_vma gp, relocation;
+  bfd_vma high_address;
   bfd_byte *p_ldah, *p_lda;
 
   /* Don't do anything if we're not doing a final link.  */
@@ -1079,8 +1046,9 @@ elf64_alpha_reloc_gpdisp (abfd, reloc_entry, sym, data, input_section,
       return bfd_reloc_ok;
     }
 
-  if (reloc_entry->address > input_section->_cooked_size ||
-      reloc_entry->address + reloc_entry->addend > input_section->_cooked_size)
+  high_address = bfd_get_section_limit (abfd, input_section);
+  if (reloc_entry->address > high_address
+      || reloc_entry->address + reloc_entry->addend > high_address)
     return bfd_reloc_outofrange;
 
   /* The gp used in the portion of the output object to which this
@@ -1183,13 +1151,15 @@ elf64_alpha_info_to_howto (abfd, cache_ptr, dst)
   (r_type == R_ALPHA_TLSGD || r_type == R_ALPHA_TLSLDM ? 16 : 8)
 
 /* This is PT_TLS segment p_vaddr.  */
-#define alpha_get_dtprel_base(tlss) \
-  ((tlss)->start)
+#define alpha_get_dtprel_base(info) \
+  (elf_hash_table (info)->tls_sec->vma)
 
 /* Main program TLS (whose template starts at PT_TLS p_vaddr)
    is assigned offset round(16, PT_TLS p_align).  */
-#define alpha_get_tprel_base(tlss) \
-  ((tlss)->start - align_power ((bfd_vma) 16, (tlss)->align))
+#define alpha_get_tprel_base(info) \
+  (elf_hash_table (info)->tls_sec->vma                                 \
+   - align_power ((bfd_vma) 16,                                                \
+                 elf_hash_table (info)->tls_sec->alignment_power))
 \f
 /* These functions do relaxation for Alpha ELF.
 
@@ -1223,7 +1193,6 @@ struct alpha_relax_info
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Rela *relocs, *relend;
   struct bfd_link_info *link_info;
-  struct elf_link_tls_segment *tls_segment;
   bfd_vma gp;
   bfd *gotobj;
   asection *tsec;
@@ -1249,8 +1218,6 @@ static bfd_boolean elf64_alpha_relax_gprelhilo
 static bfd_boolean elf64_alpha_relax_tls_get_addr
   PARAMS((struct alpha_relax_info *info, bfd_vma symval,
           Elf_Internal_Rela *irel, bfd_boolean));
-static struct elf_link_tls_segment *elf64_alpha_relax_find_tls_segment
-  PARAMS((struct alpha_relax_info *, struct elf_link_tls_segment *));
 static bfd_boolean elf64_alpha_relax_section
   PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
          bfd_boolean *again));
@@ -1549,7 +1516,7 @@ elf64_alpha_relax_opt_call (info, symval)
        }
       else
        {
-         tsec_relocs = (_bfd_elf64_link_read_relocs
+         tsec_relocs = (_bfd_elf_link_read_relocs
                         (info->abfd, info->tsec, (PTR) NULL,
                         (Elf_Internal_Rela *) NULL,
                         info->link_info->keep_memory));
@@ -1623,9 +1590,9 @@ elf64_alpha_relax_got_load (info, symval, irel, r_type)
     {
       bfd_vma dtp_base, tp_base;
 
-      BFD_ASSERT (info->tls_segment != NULL);
-      dtp_base = alpha_get_dtprel_base (info->tls_segment);
-      tp_base = alpha_get_tprel_base (info->tls_segment);
+      BFD_ASSERT (elf_hash_table (info->link_info)->tls_sec != NULL);
+      dtp_base = alpha_get_dtprel_base (info->link_info);
+      tp_base = alpha_get_tprel_base (info->link_info);
       disp = symval - (r_type == R_ALPHA_GOTDTPREL ? dtp_base : tp_base);
     }
 
@@ -1753,16 +1720,10 @@ elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd)
   unsigned int insn;
   Elf_Internal_Rela *gpdisp, *hint;
   bfd_boolean dynamic, use_gottprel, pos1_unusable;
+  unsigned long new_symndx;
 
   dynamic = alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info);
 
-  /* ??? For LD relaxation, we need a symbol referencing the beginning
-     of the TLS segment.  */
-  /* ??? The STN_UNDEF symbol (dynindex 0) works fine for this.  Adjust
-     the code below to expect that.  */
-  if (!is_gd)
-    return TRUE;
-
   /* If a TLS symbol is accessed using IE at least once, there is no point
      to use dynamic model for it.  */
   if (is_gd && info->h && (info->h->flags & ALPHA_ELF_LINK_HASH_TLS_IE))
@@ -1868,6 +1829,7 @@ elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd)
      as appropriate.  */
 
   use_gottprel = FALSE;
+  new_symndx = is_gd ? ELF64_R_SYM (irel->r_info) : 0;
   switch (!dynamic && !info->link_info->shared)
     {
     case 1:
@@ -1875,8 +1837,8 @@ elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd)
        bfd_vma tp_base;
        bfd_signed_vma disp;
 
-       BFD_ASSERT (info->tls_segment != NULL);
-       tp_base = alpha_get_tprel_base (info->tls_segment);
+       BFD_ASSERT (elf_hash_table (info->link_info)->tls_sec != NULL);
+       tp_base = alpha_get_tprel_base (info->link_info);
        disp = symval - tp_base;
 
        if (disp >= -0x8000 && disp < 0x8000)
@@ -1886,8 +1848,7 @@ elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd)
            bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]);
 
            irel[0].r_offset = pos[0] - info->contents;
-           irel[0].r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
-                                          R_ALPHA_TPREL16);
+           irel[0].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_TPREL16);
            irel[1].r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
            break;
          }
@@ -1901,11 +1862,9 @@ elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd)
            bfd_put_32 (info->abfd, (bfd_vma) insn, pos[1]);
 
            irel[0].r_offset = pos[0] - info->contents;
-           irel[0].r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
-                                          R_ALPHA_TPRELHI);
+           irel[0].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_TPRELHI);
            irel[1].r_offset = pos[1] - info->contents;
-           irel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
-                                          R_ALPHA_TPRELLO);
+           irel[1].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_TPRELLO);
            break;
          }
       }
@@ -1919,8 +1878,7 @@ elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd)
       bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]);
 
       irel[0].r_offset = pos[0] - info->contents;
-      irel[0].r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
-                                    R_ALPHA_GOTTPREL);
+      irel[0].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_GOTTPREL);
       irel[1].r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
       break;
     }
@@ -1995,53 +1953,6 @@ elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd)
   return TRUE;
 }
 
-static struct elf_link_tls_segment *
-elf64_alpha_relax_find_tls_segment (info, seg)
-     struct alpha_relax_info *info;
-     struct elf_link_tls_segment *seg;
-{
-  bfd *output_bfd = info->sec->output_section->owner;
-  asection *o;
-  unsigned int align;
-  bfd_vma base, end;
-
-  for (o = output_bfd->sections; o ; o = o->next)
-    if ((o->flags & SEC_THREAD_LOCAL) != 0
-        && (o->flags & SEC_LOAD) != 0)
-      break;
-  if (!o)
-    return NULL;
-
-  base = o->vma;
-  align = 0;
-
-  do
-    {
-      bfd_vma size;
-
-      if (bfd_get_section_alignment (output_bfd, o) > align)
-       align = bfd_get_section_alignment (output_bfd, o);
-
-      size = o->_raw_size;
-      if (size == 0 && (o->flags & SEC_HAS_CONTENTS) == 0)
-       {
-         struct bfd_link_order *lo;
-         for (lo = o->link_order_head; lo ; lo = lo->next)
-           if (size < lo->offset + lo->size)
-             size = lo->offset + lo->size;
-       }
-      end = o->vma + size;
-      o = o->next;
-    }
-  while (o && (o->flags & SEC_THREAD_LOCAL));
-
-  seg->start = base;
-  seg->size = end - base;
-  seg->align = align;
-
-  return seg;
-}
-
 static bfd_boolean
 elf64_alpha_relax_section (abfd, sec, link_info, again)
      bfd *abfd;
@@ -2055,26 +1966,20 @@ elf64_alpha_relax_section (abfd, sec, link_info, again)
   Elf_Internal_Sym *isymbuf = NULL;
   struct alpha_elf_got_entry **local_got_entries;
   struct alpha_relax_info info;
-  struct elf_link_tls_segment tls_segment;
 
   /* We are not currently changing any sizes, so only one pass.  */
   *again = FALSE;
 
-  if (link_info->relocateable
+  if (link_info->relocatable
       || (sec->flags & SEC_RELOC) == 0
       || sec->reloc_count == 0)
     return TRUE;
 
-  /* If this is the first time we have been called for this section,
-     initialize the cooked size.  */
-  if (sec->_cooked_size == 0)
-    sec->_cooked_size = sec->_raw_size;
-
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   local_got_entries = alpha_elf_tdata(abfd)->local_got_entries;
 
   /* Load the relocations for this section.  */
-  internal_relocs = (_bfd_elf64_link_read_relocs
+  internal_relocs = (_bfd_elf_link_read_relocs
                     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
                      link_info->keep_memory));
   if (internal_relocs == NULL)
@@ -2104,25 +2009,16 @@ elf64_alpha_relax_section (abfd, sec, link_info, again)
     info.contents = elf_section_data (sec)->this_hdr.contents;
   else
     {
-      info.contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
-      if (info.contents == NULL)
-       goto error_return;
-
-      if (! bfd_get_section_contents (abfd, sec, info.contents,
-                                     (file_ptr) 0, sec->_raw_size))
+      if (!bfd_malloc_and_get_section (abfd, sec, &info.contents))
        goto error_return;
     }
 
-  /* Compute the TLS segment information.  The version normally found in
-     elf_hash_table (link_info)->tls_segment isn't built until final_link.
-     ??? Probably should look into extracting this into a common function.  */
-  info.tls_segment = elf64_alpha_relax_find_tls_segment (&info, &tls_segment);
-
   for (irel = internal_relocs; irel < irelend; irel++)
     {
       bfd_vma symval;
       struct alpha_elf_got_entry *gotent;
       unsigned long r_type = ELF64_R_TYPE (irel->r_info);
+      unsigned long r_symndx = ELF64_R_SYM (irel->r_info);
 
       /* Early exit for unhandled or unrelaxable relocations.  */
       switch (r_type)
@@ -2133,14 +2029,20 @@ elf64_alpha_relax_section (abfd, sec, link_info, again)
        case R_ALPHA_GOTDTPREL:
        case R_ALPHA_GOTTPREL:
        case R_ALPHA_TLSGD:
+         break;
+
        case R_ALPHA_TLSLDM:
+         /* The symbol for a TLSLDM reloc is ignored.  Collapse the
+             reloc to the 0 symbol so that they all match.  */
+         r_symndx = 0;
          break;
+
        default:
          continue;
        }
 
       /* Get the value of the symbol referred to by the reloc.  */
-      if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
+      if (r_symndx < symtab_hdr->sh_info)
        {
          /* A local symbol.  */
          Elf_Internal_Sym *isym;
@@ -2157,27 +2059,44 @@ elf64_alpha_relax_section (abfd, sec, link_info, again)
                goto error_return;
            }
 
-         isym = isymbuf + ELF64_R_SYM (irel->r_info);
-         if (isym->st_shndx == SHN_UNDEF)
-           continue;
-         else if (isym->st_shndx == SHN_ABS)
-           info.tsec = bfd_abs_section_ptr;
-         else if (isym->st_shndx == SHN_COMMON)
-           info.tsec = bfd_com_section_ptr;
+         isym = isymbuf + r_symndx;
+
+         /* Given the symbol for a TLSLDM reloc is ignored, this also
+            means forcing the symbol value to the tp base.  */
+         if (r_type == R_ALPHA_TLSLDM)
+           {
+             info.tsec = bfd_abs_section_ptr;
+             symval = alpha_get_tprel_base (info.link_info);
+           }
          else
-           info.tsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
+           {
+             symval = isym->st_value;
+             if (isym->st_shndx == SHN_UNDEF)
+               continue;
+             else if (isym->st_shndx == SHN_ABS)
+               info.tsec = bfd_abs_section_ptr;
+             else if (isym->st_shndx == SHN_COMMON)
+               info.tsec = bfd_com_section_ptr;
+             else
+               info.tsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
+           }
 
          info.h = NULL;
          info.other = isym->st_other;
-         info.first_gotent = &local_got_entries[ELF64_R_SYM(irel->r_info)];
-         symval = isym->st_value;
+         if (local_got_entries)
+           info.first_gotent = &local_got_entries[r_symndx];
+         else
+           {
+             info.first_gotent = &info.gotent;
+             info.gotent = NULL;
+           }
        }
       else
        {
          unsigned long indx;
          struct alpha_elf_link_hash_entry *h;
 
-         indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
+         indx = r_symndx - symtab_hdr->sh_info;
          h = alpha_elf_sym_hashes (abfd)[indx];
          BFD_ASSERT (h != NULL);
 
@@ -2193,13 +2112,23 @@ elf64_alpha_relax_section (abfd, sec, link_info, again)
          /* If the symbol isn't defined in the current module, again
             we can't do anything.  */
          if (!(h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
-           continue;
+           {
+             /* Except for TLSGD relocs, which can sometimes be
+                relaxed to GOTTPREL relocs.  */
+             if (r_type != R_ALPHA_TLSGD)
+               continue;
+             info.tsec = bfd_abs_section_ptr;
+             symval = 0;
+           }
+         else
+           {
+             info.tsec = h->root.root.u.def.section;
+             symval = h->root.root.u.def.value;
+           }
 
          info.h = h;
-         info.tsec = h->root.root.u.def.section;
          info.other = h->root.other;
          info.first_gotent = &h->got_entries;
-         symval = h->root.root.u.def.value;
        }
 
       /* Search for the got entry to be used by this relocation.  */
@@ -2378,7 +2307,7 @@ elf64_alpha_section_from_shdr (abfd, hdr, name)
 static bfd_boolean
 elf64_alpha_section_flags (flags, hdr)
      flagword *flags;
-     Elf_Internal_Shdr *hdr;
+     const Elf_Internal_Shdr *hdr;
 {
   if (hdr->sh_flags & SHF_ALPHA_GPREL)
     *flags |= SEC_SMALL_DATA;
@@ -2426,14 +2355,14 @@ static bfd_boolean
 elf64_alpha_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
      bfd *abfd;
      struct bfd_link_info *info;
-     const Elf_Internal_Sym *sym;
+     Elf_Internal_Sym *sym;
      const char **namep ATTRIBUTE_UNUSED;
      flagword *flagsp ATTRIBUTE_UNUSED;
      asection **secp;
      bfd_vma *valp;
 {
   if (sym->st_shndx == SHN_COMMON
-      && !info->relocateable
+      && !info->relocatable
       && sym->st_size <= elf_gp_size (abfd))
     {
       /* Common symbols less than or equal to -G nn bytes are
@@ -2467,8 +2396,13 @@ elf64_alpha_create_got_section(abfd, info)
 {
   asection *s;
 
-  if (bfd_get_section_by_name (abfd, ".got"))
-    return TRUE;
+  if ((s = bfd_get_section_by_name (abfd, ".got")))
+    {
+      /* Check for a non-linker created .got?  */
+      if (alpha_elf_tdata (abfd)->got == NULL)
+       alpha_elf_tdata (abfd)->got = s;
+      return TRUE;
+    }
 
   s = bfd_make_section (abfd, ".got");
   if (s == NULL
@@ -2520,7 +2454,7 @@ elf64_alpha_create_dynamic_sections (abfd, info)
   h->type = STT_OBJECT;
 
   if (info->shared
-      && ! _bfd_elf_link_record_dynamic_symbol (info, h))
+      && ! bfd_elf_link_record_dynamic_symbol (info, h))
     return FALSE;
 
   s = bfd_make_section (abfd, ".rela.plt");
@@ -2564,7 +2498,7 @@ elf64_alpha_create_dynamic_sections (abfd, info)
   h->type = STT_OBJECT;
 
   if (info->shared
-      && ! _bfd_elf_link_record_dynamic_symbol (info, h))
+      && ! bfd_elf_link_record_dynamic_symbol (info, h))
     return FALSE;
 
   elf_hash_table (info)->hgot = h;
@@ -2630,7 +2564,6 @@ elf64_alpha_read_ecoff_info (abfd, section, debug)
 #undef READ
 
   debug->fdr = NULL;
-  debug->adjust = NULL;
 
   return TRUE;
 
@@ -3025,7 +2958,7 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs)
   bfd_boolean got_created;
   bfd_size_type amt;
 
-  if (info->relocateable)
+  if (info->relocatable)
     return TRUE;
 
   dynobj = elf_hash_table(info)->dynobj;
@@ -3074,7 +3007,7 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs)
          this may help reduce memory usage and processing time later.  */
       maybe_dynamic = FALSE;
       if (h && ((info->shared
-                && (!info->symbolic || info->allow_shlib_undefined))
+                && (!info->symbolic || info->unresolved_syms_in_shared_libs == RM_IGNORE))
                || ! (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
                || h->root.root.type == bfd_link_hash_defweak))
         maybe_dynamic = TRUE;
@@ -3117,8 +3050,15 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs)
            need = NEED_DYNREL;
          break;
 
-       case R_ALPHA_TLSGD:
        case R_ALPHA_TLSLDM:
+         /* The symbol for a TLSLDM reloc is ignored.  Collapse the
+            reloc to the 0 symbol so that they all match.  */
+         r_symndx = 0;
+         h = 0;
+         maybe_dynamic = FALSE;
+         /* FALLTHRU */
+
+       case R_ALPHA_TLSGD:
        case R_ALPHA_GOTDTPREL:
          need = NEED_GOT | NEED_GOT_ENTRY;
          break;
@@ -3256,7 +3196,7 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs)
            {
              /* 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);
+             sreloc->size += sizeof (Elf64_External_Rela);
              if ((sec->flags & (SEC_READONLY | SEC_ALLOC))
                  == (SEC_READONLY | SEC_ALLOC))
                info->flags |= DF_TEXTREL;
@@ -3307,11 +3247,11 @@ elf64_alpha_adjust_dynamic_symbol (info, h)
        return FALSE;
 
       /* The first bit of the .plt is reserved.  */
-      if (s->_raw_size == 0)
-       s->_raw_size = PLT_HEADER_SIZE;
+      if (s->size == 0)
+       s->size = PLT_HEADER_SIZE;
 
-      h->plt.offset = s->_raw_size;
-      s->_raw_size += PLT_ENTRY_SIZE;
+      h->plt.offset = s->size;
+      s->size += PLT_ENTRY_SIZE;
 
       /* If this symbol is not defined in a regular file, and we are not
         generating a shared library, then set the symbol to the location
@@ -3320,6 +3260,9 @@ elf64_alpha_adjust_dynamic_symbol (info, h)
       if (! info->shared
          && h->root.type != bfd_link_hash_defweak)
        {
+         ah->plt_old_section = h->root.u.def.section;
+         ah->plt_old_value = h->root.u.def.value;
+         ah->flags |= ALPHA_ELF_LINK_HASH_PLT_LOC;
          h->root.u.def.section = s;
          h->root.u.def.value = h->plt.offset;
        }
@@ -3327,7 +3270,7 @@ elf64_alpha_adjust_dynamic_symbol (info, h)
       /* We also need a JMP_SLOT entry in the .rela.plt section.  */
       s = bfd_get_section_by_name (dynobj, ".rela.plt");
       BFD_ASSERT (s != NULL);
-      s->_raw_size += sizeof (Elf64_External_Rela);
+      s->size += sizeof (Elf64_External_Rela);
 
       return TRUE;
     }
@@ -3595,6 +3538,7 @@ elf64_alpha_calc_got_offsets_for_symbol (h, arg)
      struct alpha_elf_link_hash_entry *h;
      PTR arg ATTRIBUTE_UNUSED;
 {
+  bfd_boolean result = TRUE;
   struct alpha_elf_got_entry *gotent;
 
   if (h->root.root.type == bfd_link_hash_warning)
@@ -3603,14 +3547,23 @@ elf64_alpha_calc_got_offsets_for_symbol (h, arg)
   for (gotent = h->got_entries; gotent; gotent = gotent->next)
     if (gotent->use_count > 0)
       {
-       bfd_size_type *plge
-         = &alpha_elf_tdata (gotent->gotobj)->got->_raw_size;
+       struct alpha_elf_obj_tdata *td;
+       bfd_size_type *plge;
 
+       td = alpha_elf_tdata (gotent->gotobj);
+       if (td == NULL)
+         {
+           _bfd_error_handler (_("Symbol %s has no GOT subsection for offset 0x%x"),
+                               h->root.root.root.string, gotent->got_offset);
+           result = FALSE;
+           continue;
+         }
+       plge = &td->got->size;
        gotent->got_offset = *plge;
        *plge += alpha_got_entry_size (gotent->reloc_type);
       }
 
-  return TRUE;
+  return result;
 }
 
 static void
@@ -3622,7 +3575,7 @@ elf64_alpha_calc_got_offsets (info)
   /* First, zero out the .got sizes, as we may be recalculating the
      .got after optimizing it.  */
   for (i = got_list; i ; i = alpha_elf_tdata(i)->got_link_next)
-    alpha_elf_tdata(i)->got->_raw_size = 0;
+    alpha_elf_tdata(i)->got->size = 0;
 
   /* Next, fill in the offsets for all the global entries.  */
   alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
@@ -3632,7 +3585,7 @@ elf64_alpha_calc_got_offsets (info)
   /* Finally, fill in the offsets for the local entries.  */
   for (i = got_list; i ; i = alpha_elf_tdata(i)->got_link_next)
     {
-      bfd_size_type got_offset = alpha_elf_tdata(i)->got->_raw_size;
+      bfd_size_type got_offset = alpha_elf_tdata(i)->got->size;
       bfd *j;
 
       for (j = i; j ; j = alpha_elf_tdata(j)->in_got_link_next)
@@ -3653,8 +3606,7 @@ elf64_alpha_calc_got_offsets (info)
                }
        }
 
-      alpha_elf_tdata(i)->got->_raw_size = got_offset;
-      alpha_elf_tdata(i)->got->_cooked_size = got_offset;
+      alpha_elf_tdata(i)->got->size = got_offset;
     }
 }
 
@@ -3679,7 +3631,7 @@ elf64_alpha_size_got_sections (info)
          if (this_got == NULL)
            continue;
 
-         /* We are assuming no merging has yet ocurred.  */
+         /* We are assuming no merging has yet occurred.  */
          BFD_ASSERT (this_got == i);
 
           if (alpha_elf_tdata (this_got)->total_got_size > MAX_GOT_SIZE)
@@ -3751,21 +3703,18 @@ elf64_alpha_size_plt_section (info)
   if (splt == NULL)
     return TRUE;
 
-  splt->_raw_size = 0;
+  splt->size = 0;
 
   alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
                                elf64_alpha_size_plt_section_1, splt);
 
-  splt->_cooked_size = splt->_raw_size;
-
   /* Every plt entry requires a JMP_SLOT relocation.  */
   spltrel = bfd_get_section_by_name (dynobj, ".rela.plt");
-  if (splt->_raw_size)
-    entries = (splt->_raw_size - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE;
+  if (splt->size)
+    entries = (splt->size - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE;
   else
     entries = 0;
-  spltrel->_raw_size = entries * sizeof (Elf64_External_Rela);
-  spltrel->_cooked_size = spltrel->_raw_size;
+  spltrel->size = entries * sizeof (Elf64_External_Rela);
 
   return TRUE;
 }
@@ -3792,15 +3741,23 @@ elf64_alpha_size_plt_section_1 (h, data)
      a need for the PLT entry.  */
   if (gotent)
     {
-      if (splt->_raw_size == 0)
-       splt->_raw_size = PLT_HEADER_SIZE;
-      h->root.plt.offset = splt->_raw_size;
-      splt->_raw_size += PLT_ENTRY_SIZE;
+      if (splt->size == 0)
+       splt->size = PLT_HEADER_SIZE;
+      h->root.plt.offset = splt->size;
+      splt->size += PLT_ENTRY_SIZE;
     }
   else
     {
       h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
       h->root.plt.offset = -1;
+
+      /* Undo the definition frobbing begun in adjust_dynamic_symbol.  */
+      if (h->flags & ALPHA_ELF_LINK_HASH_PLT_LOC)
+       {
+         h->root.root.u.def.section = h->plt_old_section;
+         h->root.root.u.def.value = h->plt_old_value;
+         h->flags &= ~ALPHA_ELF_LINK_HASH_PLT_LOC;
+       }
     }
 
   return TRUE;
@@ -3813,7 +3770,7 @@ elf64_alpha_always_size_sections (output_bfd, info)
 {
   bfd *i;
 
-  if (info->relocateable)
+  if (info->relocatable)
     return TRUE;
 
   /* First, take care of the indirect symbols created by versioning.  */
@@ -3829,9 +3786,9 @@ elf64_alpha_always_size_sections (output_bfd, info)
   for ( ; i ; i = alpha_elf_tdata(i)->got_link_next)
     {
       asection *s = alpha_elf_tdata(i)->got;
-      if (s->_raw_size > 0)
+      if (s->size > 0)
        {
-         s->contents = (bfd_byte *) bfd_zalloc (i, s->_raw_size);
+         s->contents = (bfd_byte *) bfd_zalloc (i, s->size);
          if (s->contents == NULL)
            return FALSE;
        }
@@ -3915,7 +3872,7 @@ elf64_alpha_calc_dynrel_sizes (h, info)
                                                 info->shared);
       if (entries)
        {
-         relent->srel->_raw_size +=
+         relent->srel->size +=
            entries * sizeof (Elf64_External_Rela) * relent->count;
          if (relent->reltext)
            info->flags |= DT_TEXTREL;
@@ -3969,14 +3926,12 @@ elf64_alpha_size_rela_got_section (info)
       BFD_ASSERT (entries == 0);
       return TRUE;
     }
-  srel->_raw_size = sizeof (Elf64_External_Rela) * entries;
+  srel->size = sizeof (Elf64_External_Rela) * entries;
 
   /* Now do the non-local symbols.  */
   alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
                                elf64_alpha_size_rela_got_1, info);
 
-  srel->_cooked_size = srel->_raw_size;
-
   return TRUE;
 }
 
@@ -4017,7 +3972,7 @@ elf64_alpha_size_rela_got_1 (h, info)
       bfd *dynobj = elf_hash_table(info)->dynobj;
       asection *srel = bfd_get_section_by_name (dynobj, ".rela.got");
       BFD_ASSERT (srel != NULL);
-      srel->_raw_size += sizeof (Elf64_External_Rela) * entries;
+      srel->size += sizeof (Elf64_External_Rela) * entries;
     }
 
   return TRUE;
@@ -4040,11 +3995,11 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (!info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
-         s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+         s->size = sizeof ELF_DYNAMIC_INTERPRETER;
          s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
        }
 
@@ -4087,7 +4042,7 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
 
       if (strncmp (name, ".rela", 5) == 0)
        {
-         strip = (s->_raw_size == 0);
+         strip = (s->size == 0);
 
          if (!strip)
            {
@@ -4110,8 +4065,8 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
       else
        {
          /* Allocate memory for the section contents.  */
-         s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
-         if (s->contents == NULL && s->_raw_size != 0)
+         s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
+         if (s->contents == NULL && s->size != 0)
            return FALSE;
        }
     }
@@ -4124,9 +4079,9 @@ elf64_alpha_size_dynamic_sections (output_bfd, info)
         the .dynamic section.  The DT_DEBUG entry is filled in by the
         dynamic linker and used by the debugger.  */
 #define add_dynamic_entry(TAG, VAL) \
-  bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+  _bfd_elf_add_dynamic_entry (info, TAG, VAL)
 
-      if (!info->shared)
+      if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
@@ -4185,8 +4140,7 @@ elf64_alpha_emit_dynrel (abfd, info, sec, srel, offset, dynindx, rtype, addend)
   loc = srel->contents;
   loc += srel->reloc_count++ * sizeof (Elf64_External_Rela);
   bfd_elf64_swap_reloca_out (abfd, &outrel, loc);
-  BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
-             <= srel->_cooked_size);
+  BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count <= srel->size);
 }
 
 /* Relocate an Alpha ELF section for a relocatable link.
@@ -4271,7 +4225,6 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Rela *rel;
   Elf_Internal_Rela *relend;
-  struct elf_link_tls_segment *tls_segment;
   asection *sgot, *srel, *srelgot;
   bfd *dynobj, *gotobj;
   bfd_vma gp, tp_base, dtp_base;
@@ -4280,7 +4233,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
   const char *section_name;
 
   /* Handle relocatable links with a smaller loop.  */
-  if (info->relocateable)
+  if (info->relocatable)
     return elf64_alpha_relocate_section_r (output_bfd, info, input_bfd,
                                           input_section, contents, relocs,
                                           local_syms, local_sections);
@@ -4325,11 +4278,10 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
 
   local_got_entries = alpha_elf_tdata(input_bfd)->local_got_entries;
 
-  tls_segment = elf_hash_table (info)->tls_segment;
-  if (tls_segment)
+  if (elf_hash_table (info)->tls_sec != NULL)
     {
-      dtp_base = alpha_get_dtprel_base (tls_segment);
-      tp_base = alpha_get_tprel_base (tls_segment);
+      dtp_base = alpha_get_dtprel_base (info);
+      tp_base = alpha_get_tprel_base (info);
     }
   else
     dtp_base = tp_base = 0;
@@ -4364,11 +4316,30 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
       howto = elf64_alpha_howto_table + r_type;
       r_symndx = ELF64_R_SYM(rel->r_info);
 
+      /* The symbol for a TLSLDM reloc is ignored.  Collapse the
+        reloc to the 0 symbol so that they all match.  */
+      if (r_type == R_ALPHA_TLSLDM)
+       r_symndx = 0;
+
       if (r_symndx < symtab_hdr->sh_info)
        {
+         asection *msec;
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         value = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         msec = sec;
+         value = _bfd_elf_rela_local_sym (output_bfd, sym, &msec, rel);
+
+         /* If this is a tp-relative relocation against sym 0,
+            this is hackery from relax_section.  Force the value to
+            be the tls base.  */
+         if (r_symndx == 0
+             && (r_type == R_ALPHA_TLSLDM
+                 || r_type == R_ALPHA_GOTTPREL
+                 || r_type == R_ALPHA_TPREL64
+                 || r_type == R_ALPHA_TPRELHI
+                 || r_type == R_ALPHA_TPRELLO
+                 || r_type == R_ALPHA_TPREL16))
+           value = tp_base;
 
          if (local_got_entries)
            gotent = local_got_entries[r_symndx];
@@ -4379,13 +4350,11 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
             unless it has been done already.  */
          if ((sec->flags & SEC_MERGE)
              && ELF_ST_TYPE (sym->st_info) == STT_SECTION
-             && (elf_section_data (sec)->sec_info_type
-                 == ELF_INFO_TYPE_MERGE)
+             && sec->sec_info_type == ELF_INFO_TYPE_MERGE
              && gotent
              && !gotent->reloc_xlated)
            {
              struct alpha_elf_got_entry *ent;
-             asection *msec;
 
              for (ent = gotent; ent; ent = ent->next)
                {
@@ -4397,8 +4366,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
                    _bfd_merged_section_offset (output_bfd, &msec,
                                                elf_section_data (sec)->
                                                  sec_info,
-                                               sym->st_value + ent->addend,
-                                               (bfd_vma) 0);
+                                               sym->st_value + ent->addend);
                  ent->addend -= sym->st_value;
                  ent->addend += msec->output_section->vma
                                 + msec->output_offset
@@ -4411,50 +4379,25 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = alpha_elf_sym_hashes (input_bfd)[r_symndx - symtab_hdr->sh_info];
+         bfd_boolean warned;
+         bfd_boolean unresolved_reloc;
+         struct elf_link_hash_entry *hh;
+         struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
 
-         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;
+         RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+                                  r_symndx, symtab_hdr, sym_hashes,
+                                  hh, sec, value,
+                                  unresolved_reloc, warned);
 
-         value = 0;
-         if (h->root.root.type == bfd_link_hash_defined
-             || h->root.root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.root.u.def.section;
-
-             /* Detect the cases that sym_sec->output_section is
-                expected to be NULL -- all cases in which the symbol
-                is defined in another shared module.  This includes
-                PLT relocs for which we've created a PLT entry and
-                other relocs for which we're prepared to create
-                dynamic relocations.  */
-             /* ??? Just accept it NULL and continue.  */
-
-             if (sec->output_section != NULL)
-               value = (h->root.root.u.def.value
-                        + sec->output_section->vma
-                             + sec->output_offset);
-           }
-         else if (h->root.root.type == bfd_link_hash_undefweak)
+         if (warned)
+           continue;
+
+         if (value == 0
+             && ! unresolved_reloc
+             && hh->root.type == bfd_link_hash_undefweak)
            undef_weak_ref = TRUE;
-         else if (info->shared
-                  && (!info->symbolic || info->allow_shlib_undefined)
-                  && !info->no_undefined
-                  && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
-           ;
-         else
-           {
-             if (!((*info->callbacks->undefined_symbol)
-                   (info, h->root.root.root.string, input_bfd,
-                    input_section, rel->r_offset,
-                    (!info->shared || info->no_undefined
-                     || ELF_ST_VISIBILITY (h->root.other)))))
-               return FALSE;
-             ret_val = FALSE;
-             continue;
-           }
 
+         h = (struct alpha_elf_link_hash_entry *) hh;
           dynamic_symbol_p = alpha_elf_dynamic_symbol_p (&h->root, info);
          gotent = h->got_entries;
        }
@@ -4517,8 +4460,20 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
          value -= gp;
          goto default_reloc;
 
-       case R_ALPHA_GPREL16:
        case R_ALPHA_GPREL32:
+         /* If the target section was a removed linkonce section,
+            r_symndx will be zero.  In this case, assume that the
+            switch will not be used, so don't fill it in.  If we
+            do nothing here, we'll get relocation truncated messages,
+            due to the placement of the application above 4GB.  */
+         if (r_symndx == 0)
+           {
+             r = bfd_reloc_ok;
+             break;
+           }
+         /* FALLTHRU */
+
+       case R_ALPHA_GPREL16:
        case R_ALPHA_GPRELLOW:
          if (dynamic_symbol_p)
             {
@@ -4648,13 +4603,13 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
              }
            else if (r_type == R_ALPHA_DTPREL64)
              {
-               BFD_ASSERT(tls_segment != NULL);
+               BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
                value -= dtp_base;
                goto default_reloc;
              }
            else if (r_type == R_ALPHA_TPREL64)
              {
-               BFD_ASSERT(tls_segment != NULL);
+               BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
                if (!info->shared)
                  {
                    value -= tp_base;
@@ -4734,7 +4689,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
                value = 0;
              else
                {
-                 BFD_ASSERT(tls_segment != NULL);
+                 BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
                  value -= dtp_base;
                }
              bfd_put_64 (output_bfd, value,
@@ -4757,7 +4712,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
                  bfd_archive_filename (input_bfd), h->root.root.root.string);
               ret_val = FALSE;
             }
-         BFD_ASSERT(tls_segment != NULL);
+         BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
          value -= dtp_base;
          if (r_type == R_ALPHA_DTPRELHI)
            value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1);
@@ -4780,7 +4735,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
                  bfd_archive_filename (input_bfd), h->root.root.root.string);
               ret_val = FALSE;
             }
-         BFD_ASSERT(tls_segment != NULL);
+         BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
          value -= tp_base;
          if (r_type == R_ALPHA_TPRELHI)
            value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1);
@@ -4801,7 +4756,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
                value = 0;
              else
                {
-                 BFD_ASSERT(tls_segment != NULL);
+                 BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
                  if (r_type == R_ALPHA_GOTDTPREL)
                    value -= dtp_base;
                  else if (!info->shared)
@@ -5062,7 +5017,7 @@ elf64_alpha_finish_dynamic_sections (output_bfd, info)
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf64_External_Dyn *) sdyn->contents;
-      dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+      dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
@@ -5091,10 +5046,7 @@ elf64_alpha_finish_dynamic_sections (output_bfd, info)
                 out who is right.  */
              s = bfd_get_section_by_name (output_bfd, ".rela.plt");
              if (s)
-               {
-                 dyn.d_un.d_val -=
-                   (s->_cooked_size ? s->_cooked_size : s->_raw_size);
-               }
+               dyn.d_un.d_val -= s->size;
              break;
 
            get_vma:
@@ -5104,16 +5056,15 @@ elf64_alpha_finish_dynamic_sections (output_bfd, info)
 
            get_size:
              s = bfd_get_section_by_name (output_bfd, name);
-             dyn.d_un.d_val =
-               (s->_cooked_size ? s->_cooked_size : s->_raw_size);
+             dyn.d_un.d_val = s->size;
              break;
            }
 
          bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
        }
 
-      /* Initialize the PLT0 entry */
-      if (splt->_raw_size > 0)
+      /* Initialize the PLT0 entry */
+      if (splt->size > 0)
        {
          bfd_put_32 (output_bfd, PLT_HEADER_WORD1, splt->contents);
          bfd_put_32 (output_bfd, PLT_HEADER_WORD2, splt->contents + 4);
@@ -5224,7 +5175,7 @@ elf64_alpha_final_link (abfd, info)
                  if (s != NULL)
                    {
                      esym.asym.value = s->vma;
-                     last = s->vma + s->_raw_size;
+                     last = s->vma + s->size;
                    }
                  else
                    esym.asym.value = last;
@@ -5269,7 +5220,7 @@ elf64_alpha_final_link (abfd, info)
              input_swap = (get_elf_backend_data (input_bfd)
                            ->elf_backend_ecoff_debug_swap);
 
-             BFD_ASSERT (p->size == input_section->_raw_size);
+             BFD_ASSERT (p->size == input_section->size);
 
              /* The ECOFF linking code expects that we have already
                 read in the debugging information and set up an
@@ -5352,7 +5303,7 @@ elf64_alpha_final_link (abfd, info)
            return FALSE;
 
          /* Set the size of the .mdebug section.  */
-         o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap);
+         o->size = bfd_ecoff_debug_size (abfd, &debug, swap);
 
          /* Skip this section later on (I don't think this currently
             matters, but someday it might).  */
@@ -5363,7 +5314,7 @@ elf64_alpha_final_link (abfd, info)
     }
 
   /* Invoke the regular ELF backend linker to do all the work.  */
-  if (! bfd_elf64_bfd_final_link (abfd, info))
+  if (! bfd_elf_final_link (abfd, info))
     return FALSE;
 
   /* Now write out the computed sections.  */
@@ -5385,7 +5336,7 @@ elf64_alpha_final_link (abfd, info)
        if (! bfd_set_section_contents (abfd, sgot->output_section,
                                        sgot->contents,
                                        (file_ptr) sgot->output_offset,
-                                       sgot->_raw_size))
+                                       sgot->size))
          return FALSE;
       }
   }
@@ -5421,6 +5372,13 @@ elf64_alpha_reloc_type_class (rela)
     }
 }
 \f
+static struct bfd_elf_special_section const elf64_alpha_special_sections[]=
+{
+  { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL },
+  { ".sbss",  5, -2, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL },
+  { NULL,     0,  0, 0,            0 }
+};
+
 /* ECOFF swapping routines.  These are used when dealing with the
    .mdebug section, which is in the ECOFF debugging format.  Copied
    from elf32-mips.c.  */
@@ -5480,7 +5438,7 @@ static const struct elf_size_info alpha_elf_size_info =
   sizeof (Elf_External_Note),
   8,
   1,
-  64, 8,
+  64, 3,
   ELFCLASS64, EV_CURRENT,
   bfd_elf64_write_out_phdrs,
   bfd_elf64_write_shdrs_and_ehdr,
@@ -5559,12 +5517,14 @@ static const struct elf_size_info alpha_elf_size_info =
 #define elf_backend_size_info \
   alpha_elf_size_info
 
+#define elf_backend_special_sections \
+  elf64_alpha_special_sections
+
 /* A few constants that determine how the .plt section is set up.  */
 #define elf_backend_want_got_plt 0
 #define elf_backend_plt_readonly 0
 #define elf_backend_want_plt_sym 1
 #define elf_backend_got_header_size 0
-#define elf_backend_plt_header_size PLT_HEADER_SIZE
 
 #include "elf64-target.h"
 \f
This page took 0.058667 seconds and 4 git commands to generate.