Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/elf64-alpha.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Alpha specific support for 64-bit ELF
    2    Copyright 1996, 1997, 1998, 1999, 2000, 2001
     2   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
    33   Free Software Foundation, Inc.
    44   Contributed by Richard Henderson <rth@tamu.edu>.
    55
    6 This file is part of BFD, the Binary File Descriptor library.
    7 
    8 This program is free software; you can redistribute it and/or modify
    9 it under the terms of the GNU General Public License as published by
    10 the Free Software Foundation; either version 2 of the License, or
    11 (at your option) any later version.
    12 
    13 This program is distributed in the hope that it will be useful,
    14 but WITHOUT ANY WARRANTY; without even the implied warranty of
    15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 GNU General Public License for more details.
    17 
    18 You should have received a copy of the GNU General Public License
    19 along with this program; if not, write to the Free Software
    20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     6   This file is part of BFD, the Binary File Descriptor library.
     7
     8   This program is free software; you can redistribute it and/or modify
     9   it under the terms of the GNU General Public License as published by
     10   the Free Software Foundation; either version 2 of the License, or
     11   (at your option) any later version.
     12
     13   This program is distributed in the hope that it will be useful,
     14   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16   GNU General Public License for more details.
     17
     18   You should have received a copy of the GNU General Public License
     19   along with this program; if not, write to the Free Software
     20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    2121
    2222/* We need a published ABI spec for this.  Until one comes out, don't
     
    4949
    5050static int alpha_elf_dynamic_symbol_p
    51   PARAMS((struct elf_link_hash_entry *, struct bfd_link_info *));
     51  PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *));
    5252static struct bfd_hash_entry * elf64_alpha_link_hash_newfunc
    53   PARAMS((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
     53  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
    5454static struct bfd_link_hash_table * elf64_alpha_bfd_link_hash_table_create
    55   PARAMS((bfd *));
     55  PARAMS ((bfd *));
    5656
    5757static bfd_reloc_status_type elf64_alpha_reloc_nil
    58   PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
     58  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
    5959static bfd_reloc_status_type elf64_alpha_reloc_bad
    60   PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
     60  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
    6161static bfd_reloc_status_type elf64_alpha_do_reloc_gpdisp
    62   PARAMS((bfd *, bfd_vma, bfd_byte *, bfd_byte *));
     62  PARAMS ((bfd *, bfd_vma, bfd_byte *, bfd_byte *));
    6363static bfd_reloc_status_type elf64_alpha_reloc_gpdisp
    64   PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
     64  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
    6565
    6666static reloc_howto_type * elf64_alpha_bfd_reloc_type_lookup
    67   PARAMS((bfd *, bfd_reloc_code_real_type));
     67  PARAMS ((bfd *, bfd_reloc_code_real_type));
    6868static void elf64_alpha_info_to_howto
    69   PARAMS((bfd *, arelent *, Elf64_Internal_Rela *));
    70 
    71 static boolean elf64_alpha_mkobject
    72   PARAMS((bfd *));
    73 static boolean elf64_alpha_object_p
    74   PARAMS((bfd *));
    75 static boolean elf64_alpha_section_from_shdr
    76   PARAMS((bfd *, Elf64_Internal_Shdr *, char *));
    77 static boolean elf64_alpha_fake_sections
    78   PARAMS((bfd *, Elf64_Internal_Shdr *, asection *));
    79 static boolean elf64_alpha_create_got_section
    80   PARAMS((bfd *, struct bfd_link_info *));
    81 static boolean elf64_alpha_create_dynamic_sections
    82   PARAMS((bfd *, struct bfd_link_info *));
    83 
    84 static boolean elf64_alpha_read_ecoff_info
    85   PARAMS((bfd *, asection *, struct ecoff_debug_info *));
    86 static boolean elf64_alpha_is_local_label_name
    87   PARAMS((bfd *, const char *));
    88 static boolean elf64_alpha_find_nearest_line
    89   PARAMS((bfd *, asection *, asymbol **, bfd_vma, const char **,
    90           const char **, unsigned int *));
     69  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
     70
     71static bfd_boolean elf64_alpha_mkobject
     72  PARAMS ((bfd *));
     73static bfd_boolean elf64_alpha_object_p
     74  PARAMS ((bfd *));
     75static bfd_boolean elf64_alpha_section_from_shdr
     76  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
     77static bfd_boolean elf64_alpha_section_flags
     78  PARAMS ((flagword *, Elf_Internal_Shdr *));
     79static bfd_boolean elf64_alpha_fake_sections
     80  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
     81static bfd_boolean elf64_alpha_create_got_section
     82  PARAMS ((bfd *, struct bfd_link_info *));
     83static bfd_boolean elf64_alpha_create_dynamic_sections
     84  PARAMS ((bfd *, struct bfd_link_info *));
     85
     86static bfd_boolean elf64_alpha_read_ecoff_info
     87  PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
     88static bfd_boolean elf64_alpha_is_local_label_name
     89  PARAMS ((bfd *, const char *));
     90static bfd_boolean elf64_alpha_find_nearest_line
     91  PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
     92           const char **, unsigned int *));
    9193
    9294#if defined(__STDC__) || defined(ALMOST_STDC)
     
    9496#endif
    9597
    96 static boolean elf64_alpha_output_extsym
    97   PARAMS((struct alpha_elf_link_hash_entry *, PTR));
    98 
    99 static boolean elf64_alpha_can_merge_gots
    100   PARAMS((bfd *, bfd *));
     98static bfd_boolean elf64_alpha_output_extsym
     99  PARAMS ((struct alpha_elf_link_hash_entry *, PTR));
     100
     101static bfd_boolean elf64_alpha_can_merge_gots
     102  PARAMS ((bfd *, bfd *));
    101103static void elf64_alpha_merge_gots
    102   PARAMS((bfd *, bfd *));
    103 static boolean elf64_alpha_calc_got_offsets_for_symbol
     104  PARAMS ((bfd *, bfd *));
     105static bfd_boolean elf64_alpha_calc_got_offsets_for_symbol
    104106  PARAMS ((struct alpha_elf_link_hash_entry *, PTR));
    105 static void elf64_alpha_calc_got_offsets PARAMS ((struct bfd_link_info *));
    106 static boolean elf64_alpha_size_got_sections
     107static void elf64_alpha_calc_got_offsets
     108  PARAMS ((struct bfd_link_info *));
     109static bfd_boolean elf64_alpha_size_got_sections
     110  PARAMS ((struct bfd_link_info *));
     111static bfd_boolean elf64_alpha_size_plt_section
     112  PARAMS ((struct bfd_link_info *));
     113static bfd_boolean elf64_alpha_size_plt_section_1
     114  PARAMS ((struct alpha_elf_link_hash_entry *, PTR));
     115static bfd_boolean elf64_alpha_always_size_sections
    107116  PARAMS ((bfd *, struct bfd_link_info *));
    108 static boolean elf64_alpha_always_size_sections
    109   PARAMS ((bfd *, struct bfd_link_info *));
    110 static boolean elf64_alpha_calc_dynrel_sizes
     117static int alpha_dynamic_entries_for_reloc
     118  PARAMS ((int, int, int));
     119static bfd_boolean elf64_alpha_calc_dynrel_sizes
    111120  PARAMS ((struct alpha_elf_link_hash_entry *, struct bfd_link_info *));
    112 static boolean elf64_alpha_add_symbol_hook
     121static bfd_boolean elf64_alpha_size_rela_got_section
     122  PARAMS ((struct bfd_link_info *));
     123static bfd_boolean elf64_alpha_size_rela_got_1
     124  PARAMS ((struct alpha_elf_link_hash_entry *, struct bfd_link_info *));
     125static bfd_boolean elf64_alpha_add_symbol_hook
    113126  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
    114127           const char **, flagword *, asection **, bfd_vma *));
    115 static boolean elf64_alpha_check_relocs
    116   PARAMS((bfd *, struct bfd_link_info *, asection *sec,
     128static struct alpha_elf_got_entry *get_got_entry
     129  PARAMS ((bfd *, struct alpha_elf_link_hash_entry *, unsigned long,
     130           unsigned long, bfd_vma));
     131static bfd_boolean elf64_alpha_check_relocs
     132  PARAMS ((bfd *, struct bfd_link_info *, asection *sec,
    117133          const Elf_Internal_Rela *));
    118 static boolean elf64_alpha_adjust_dynamic_symbol
    119   PARAMS((struct bfd_link_info *, struct elf_link_hash_entry *));
    120 static boolean elf64_alpha_size_dynamic_sections
    121   PARAMS((bfd *, struct bfd_link_info *));
    122 static boolean elf64_alpha_relocate_section
    123   PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
     134static bfd_boolean elf64_alpha_adjust_dynamic_symbol
     135  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
     136static bfd_boolean elf64_alpha_size_dynamic_sections
     137  PARAMS ((bfd *, struct bfd_link_info *));
     138static void elf64_alpha_emit_dynrel
     139  PARAMS ((bfd *, struct bfd_link_info *, asection *, asection *,
     140           bfd_vma, long, long, bfd_vma));
     141static bfd_boolean elf64_alpha_relocate_section_r
     142  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
     143           Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
     144static bfd_boolean elf64_alpha_relocate_section
     145  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    124146          Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
    125 static boolean elf64_alpha_finish_dynamic_symbol
    126   PARAMS((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
    127           Elf_Internal_Sym *));
    128 static boolean elf64_alpha_finish_dynamic_sections
    129   PARAMS((bfd *, struct bfd_link_info *));
    130 static boolean elf64_alpha_final_link
    131   PARAMS((bfd *, struct bfd_link_info *));
    132 static boolean elf64_alpha_merge_ind_symbols
    133   PARAMS((struct alpha_elf_link_hash_entry *, PTR));
     147static bfd_boolean elf64_alpha_finish_dynamic_symbol
     148  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
     149           Elf_Internal_Sym *));
     150static bfd_boolean elf64_alpha_finish_dynamic_sections
     151  PARAMS ((bfd *, struct bfd_link_info *));
     152static bfd_boolean elf64_alpha_final_link
     153  PARAMS ((bfd *, struct bfd_link_info *));
     154static bfd_boolean elf64_alpha_merge_ind_symbols
     155  PARAMS ((struct alpha_elf_link_hash_entry *, PTR));
    134156static Elf_Internal_Rela * elf64_alpha_find_reloc_at_ofs
    135157  PARAMS ((Elf_Internal_Rela *, Elf_Internal_Rela *, bfd_vma, int));
     158static enum elf_reloc_type_class elf64_alpha_reloc_type_class
     159  PARAMS ((const Elf_Internal_Rela *));
    136160
    137161
     
    146170  int flags;
    147171
    148   /* Contexts (LITUSE) in which a literal was referenced.  */
    149 #define ALPHA_ELF_LINK_HASH_LU_ADDR 0x01
    150 #define ALPHA_ELF_LINK_HASH_LU_MEM  0x02
    151 #define ALPHA_ELF_LINK_HASH_LU_BYTE 0x04
    152 #define ALPHA_ELF_LINK_HASH_LU_FUNC 0x08
     172  /* Contexts in which a literal was referenced.  */
     173#define ALPHA_ELF_LINK_HASH_LU_ADDR     0x01
     174#define ALPHA_ELF_LINK_HASH_LU_MEM      0x02
     175#define ALPHA_ELF_LINK_HASH_LU_BYTE     0x04
     176#define ALPHA_ELF_LINK_HASH_LU_JSR      0x08
     177#define ALPHA_ELF_LINK_HASH_LU_TLSGD    0x10
     178#define ALPHA_ELF_LINK_HASH_LU_TLSLDM   0x20
     179#define ALPHA_ELF_LINK_HASH_LU_FUNC     0x38
     180#define ALPHA_ELF_LINK_HASH_TLS_IE      0x40
     181#define ALPHA_ELF_LINK_HASH_PLT_LOC     0x80
     182
     183  /* Used to undo the localization of a plt symbol.  */
     184  asection *plt_old_section;
     185  bfd_vma plt_old_value;
    153186
    154187  /* Used to implement multiple .got subsections.  */
     
    157190    struct alpha_elf_got_entry *next;
    158191
    159     /* which .got subsection?  */
     192    /* Which .got subsection?  */
    160193    bfd *gotobj;
    161194
    162     /* the addend in effect for this entry.  */
     195    /* The addend in effect for this entry.  */
    163196    bfd_vma addend;
    164197
    165     /* the .got offset for this entry.  */
     198    /* The .got offset for this entry.  */
    166199    int got_offset;
    167200
    168     int flags;
    169 
    170     /* An additional flag.  */
    171 #define ALPHA_ELF_GOT_ENTRY_RELOCS_DONE 0x10
    172 
     201    /* How many references to this entry?  */
    173202    int use_count;
     203
     204    /* The relocation type of this entry.  */
     205    unsigned char reloc_type;
     206
     207    /* How a LITERAL is used.  */
     208    unsigned char flags;
     209
     210    /* Have we initialized the dynamic relocation for this entry?  */
     211    unsigned char reloc_done;
     212
     213    /* Have we adjusted this entry for SEC_MERGE?  */
     214    unsigned char reloc_xlated;
    174215  } *got_entries;
    175216
    176   /* used to count non-got, non-plt relocations for delayed sizing
     217  /* Used to count non-got, non-plt relocations for delayed sizing
    177218     of relocation sections.  */
    178219  struct alpha_elf_reloc_entry
     
    180221    struct alpha_elf_reloc_entry *next;
    181222
    182     /* which .reloc section? */
     223    /* Which .reloc section? */
    183224    asection *srel;
    184225
    185     /* what kind of relocation? */
    186     unsigned long rtype;
    187 
    188     /* how many did we find?  */
     226    /* What kind of relocation? */
     227    unsigned int rtype;
     228
     229    /* Is this against read-only section? */
     230    unsigned int reltext : 1;
     231
     232    /* How many did we find?  */
    189233    unsigned long count;
    190234  } *reloc_entries;
     
    214258  (elf_link_hash_traverse                                               \
    215259   (&(table)->root,                                                     \
    216     (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func),  \
     260    (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
    217261    (info)))
    218262
     
    235279{
    236280  if (h == NULL)
    237     return false;
     281    return FALSE;
    238282
    239283  while (h->root.type == bfd_link_hash_indirect
     
    242286
    243287  if (h->dynindx == -1)
    244     return false;
     288    return FALSE;
    245289
    246290  if (h->root.type == bfd_link_hash_undefweak
    247291      || h->root.type == bfd_link_hash_defweak)
    248     return true;
     292    return TRUE;
    249293
    250294  switch (ELF_ST_VISIBILITY (h->other))
     
    254298    case STV_HIDDEN:
    255299    case STV_INTERNAL:
    256       return false;
     300      return FALSE;
    257301    case STV_PROTECTED:
    258302      if (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
    259         return false;
     303        return FALSE;
    260304      break;
    261305    }
     
    263307  if ((info->shared && !info->symbolic)
    264308      || ((h->elf_link_hash_flags
    265            & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))
     309           & (ELF_LINK_HASH_DEF_DYNAMIC
     310              | ELF_LINK_HASH_DEF_REGULAR
     311              | ELF_LINK_HASH_REF_REGULAR))
    266312          == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)))
    267     return true;
    268 
    269   return false;
     313    return TRUE;
     314
     315  return FALSE;
    270316}
    271317
     
    316362{
    317363  struct alpha_elf_link_hash_table *ret;
    318 
    319   ret = ((struct alpha_elf_link_hash_table *)
    320          bfd_zalloc (abfd, sizeof (struct alpha_elf_link_hash_table)));
     364  bfd_size_type amt = sizeof (struct alpha_elf_link_hash_table);
     365
     366  ret = (struct alpha_elf_link_hash_table *) bfd_zmalloc (amt);
    321367  if (ret == (struct alpha_elf_link_hash_table *) NULL)
    322368    return NULL;
     
    325371                                       elf64_alpha_link_hash_newfunc))
    326372    {
    327       bfd_release (abfd, ret);
     373      free (ret);
    328374      return NULL;
    329375    }
     
    356402  asection *got;
    357403
    358   /* For every got, this is it's total number of *entries*.  */
    359   int total_got_entries;
    360 
    361   /* For every got, this is the sum of the number of *entries* required
     404  /* For every got, this is it's total number of words.  */
     405  int total_got_size;
     406
     407  /* For every got, this is the sum of the number of words required
    362408     to hold all of the member object's local got.  */
    363   int n_local_got_entries;
     409  int local_got_size;
    364410};
    365411
     
    367413  ((struct alpha_elf_obj_tdata *) (abfd)->tdata.any)
    368414
    369 static boolean
     415static bfd_boolean
    370416elf64_alpha_mkobject (abfd)
    371417     bfd *abfd;
    372418{
    373   abfd->tdata.any = bfd_zalloc (abfd, sizeof (struct alpha_elf_obj_tdata));
     419  bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata);
     420  abfd->tdata.any = bfd_zalloc (abfd, amt);
    374421  if (abfd->tdata.any == NULL)
    375     return false;
    376   return true;
     422    return FALSE;
     423  return TRUE;
    377424}
    378425
    379 static boolean
     426static bfd_boolean
    380427elf64_alpha_object_p (abfd)
    381428     bfd *abfd;
     
    383430  /* Allocate our special target data.  */
    384431  struct alpha_elf_obj_tdata *new_tdata;
    385   new_tdata = bfd_zalloc (abfd, sizeof (struct alpha_elf_obj_tdata));
     432  bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata);
     433  new_tdata = bfd_zalloc (abfd, amt);
    386434  if (new_tdata == NULL)
    387     return false;
     435    return FALSE;
    388436  new_tdata->root = *abfd->tdata.elf_obj_data;
    389437  abfd->tdata.any = new_tdata;
     
    397445   from smaller values.  Start with zero, widen, *then* decrement.  */
    398446#define MINUS_ONE       (((bfd_vma)0) - 1)
     447
     448#define SKIP_HOWTO(N) \
     449  HOWTO(N, 0, 0, 0, 0, 0, 0, elf64_alpha_reloc_bad, 0, 0, 0, 0, 0)
    399450
    400451static reloc_howto_type elf64_alpha_howto_table[] =
     
    404455         0,                     /* size (0 = byte, 1 = short, 2 = long) */
    405456         8,                     /* bitsize */
    406          true,                  /* pc_relative */
     457         TRUE,                  /* pc_relative */
    407458         0,                     /* bitpos */
    408459         complain_overflow_dont, /* complain_on_overflow */
    409460         elf64_alpha_reloc_nil, /* special_function */
    410461         "NONE",                /* name */
    411          false,                 /* partial_inplace */
     462         FALSE,                 /* partial_inplace */
    412463         0,                     /* src_mask */
    413464         0,                     /* dst_mask */
    414          true),                 /* pcrel_offset */
     465         TRUE),                 /* pcrel_offset */
    415466
    416467  /* A 32 bit reference to a symbol.  */
     
    419470         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    420471         32,                    /* bitsize */
    421          false,                 /* pc_relative */
     472         FALSE,                 /* pc_relative */
    422473         0,                     /* bitpos */
    423474         complain_overflow_bitfield, /* complain_on_overflow */
    424475         0,                     /* special_function */
    425476         "REFLONG",             /* name */
    426          false,                 /* partial_inplace */
     477         FALSE,                 /* partial_inplace */
    427478         0xffffffff,            /* src_mask */
    428479         0xffffffff,            /* dst_mask */
    429          false),                /* pcrel_offset */
     480         FALSE),                /* pcrel_offset */
    430481
    431482  /* A 64 bit reference to a symbol.  */
     
    434485         4,                     /* size (0 = byte, 1 = short, 2 = long) */
    435486         64,                    /* bitsize */
    436          false,                 /* pc_relative */
     487         FALSE,                 /* pc_relative */
    437488         0,                     /* bitpos */
    438489         complain_overflow_bitfield, /* complain_on_overflow */
    439490         0,                     /* special_function */
    440491         "REFQUAD",             /* name */
    441          false,                 /* partial_inplace */
     492         FALSE,                 /* partial_inplace */
    442493         MINUS_ONE,             /* src_mask */
    443494         MINUS_ONE,             /* dst_mask */
    444          false),                /* pcrel_offset */
     495         FALSE),                /* pcrel_offset */
    445496
    446497  /* A 32 bit GP relative offset.  This is just like REFLONG except
     
    451502         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    452503         32,                    /* bitsize */
    453          false,                 /* pc_relative */
     504         FALSE,                 /* pc_relative */
    454505         0,                     /* bitpos */
    455506         complain_overflow_bitfield, /* complain_on_overflow */
    456507         0,                     /* special_function */
    457508         "GPREL32",             /* name */
    458          false,                 /* partial_inplace */
     509         FALSE,                 /* partial_inplace */
    459510         0xffffffff,            /* src_mask */
    460511         0xffffffff,            /* dst_mask */
    461          false),                /* pcrel_offset */
     512         FALSE),                /* pcrel_offset */
    462513
    463514  /* Used for an instruction that refers to memory off the GP register.  */
    464515  HOWTO (R_ALPHA_LITERAL,       /* type */
    465516         0,                     /* rightshift */
    466          2,                     /* size (0 = byte, 1 = short, 2 = long) */
     517         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    467518         16,                    /* bitsize */
    468          false,                 /* pc_relative */
     519         FALSE,                 /* pc_relative */
    469520         0,                     /* bitpos */
    470521         complain_overflow_signed, /* complain_on_overflow */
    471522         0,                     /* special_function */
    472523         "ELF_LITERAL",         /* name */
    473          false,                 /* partial_inplace */
     524         FALSE,                 /* partial_inplace */
    474525         0xffff,                /* src_mask */
    475526         0xffff,                /* dst_mask */
    476          false),                /* pcrel_offset */
     527         FALSE),                /* pcrel_offset */
    477528
    478529  /* This reloc only appears immediately following an ELF_LITERAL reloc.
     
    485536  HOWTO (R_ALPHA_LITUSE,        /* type */
    486537         0,                     /* rightshift */
    487          2,                     /* size (0 = byte, 1 = short, 2 = long) */
     538         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    488539         32,                    /* bitsize */
    489          false,                 /* pc_relative */
     540         FALSE,                 /* pc_relative */
    490541         0,                     /* bitpos */
    491542         complain_overflow_dont, /* complain_on_overflow */
    492543         elf64_alpha_reloc_nil, /* special_function */
    493544         "LITUSE",              /* name */
    494          false,                 /* partial_inplace */
     545         FALSE,                 /* partial_inplace */
    495546         0,                     /* src_mask */
    496547         0,                     /* dst_mask */
    497          false),                /* pcrel_offset */
     548         FALSE),                /* pcrel_offset */
    498549
    499550  /* Load the gp register.  This is always used for a ldah instruction
     
    517568         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    518569         16,                    /* bitsize */
    519          false,                 /* pc_relative */
     570         FALSE,                 /* pc_relative */
    520571         0,                     /* bitpos */
    521572         complain_overflow_dont, /* complain_on_overflow */
    522573         elf64_alpha_reloc_gpdisp, /* special_function */
    523574         "GPDISP",              /* name */
    524          false,                 /* partial_inplace */
     575         FALSE,                 /* partial_inplace */
    525576         0xffff,                /* src_mask */
    526577         0xffff,                /* dst_mask */
    527          true),                 /* pcrel_offset */
     578         TRUE),                 /* pcrel_offset */
    528579
    529580  /* A 21 bit branch.  */
     
    532583         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    533584         21,                    /* bitsize */
    534          true,                  /* pc_relative */
     585         TRUE,                  /* pc_relative */
    535586         0,                     /* bitpos */
    536587         complain_overflow_signed, /* complain_on_overflow */
    537588         0,                     /* special_function */
    538589         "BRADDR",              /* name */
    539          false,                 /* partial_inplace */
     590         FALSE,                 /* partial_inplace */
    540591         0x1fffff,              /* src_mask */
    541592         0x1fffff,              /* dst_mask */
    542          true),                 /* pcrel_offset */
     593         TRUE),                 /* pcrel_offset */
    543594
    544595  /* A hint for a jump to a register.  */
    545596  HOWTO (R_ALPHA_HINT,          /* type */
    546597         2,                     /* rightshift */
    547          2,                     /* size (0 = byte, 1 = short, 2 = long) */
     598         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    548599         14,                    /* bitsize */
    549          true,                  /* pc_relative */
     600         TRUE,                  /* pc_relative */
    550601         0,                     /* bitpos */
    551602         complain_overflow_dont, /* complain_on_overflow */
    552603         0,                     /* special_function */
    553604         "HINT",                /* name */
    554          false,                 /* partial_inplace */
     605         FALSE,                 /* partial_inplace */
    555606         0x3fff,                /* src_mask */
    556607         0x3fff,                /* dst_mask */
    557          true),                 /* pcrel_offset */
     608         TRUE),                 /* pcrel_offset */
    558609
    559610  /* 16 bit PC relative offset.  */
     
    562613         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    563614         16,                    /* bitsize */
    564          true,                  /* pc_relative */
     615         TRUE,                  /* pc_relative */
    565616         0,                     /* bitpos */
    566617         complain_overflow_signed, /* complain_on_overflow */
    567618         0,                     /* special_function */
    568619         "SREL16",              /* name */
    569          false,                 /* partial_inplace */
     620         FALSE,                 /* partial_inplace */
    570621         0xffff,                /* src_mask */
    571622         0xffff,                /* dst_mask */
    572          true),                 /* pcrel_offset */
     623         TRUE),                 /* pcrel_offset */
    573624
    574625  /* 32 bit PC relative offset.  */
     
    577628         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    578629         32,                    /* bitsize */
    579          true,                  /* pc_relative */
     630         TRUE,                  /* pc_relative */
    580631         0,                     /* bitpos */
    581632         complain_overflow_signed, /* complain_on_overflow */
    582633         0,                     /* special_function */
    583634         "SREL32",              /* name */
    584          false,                 /* partial_inplace */
     635         FALSE,                 /* partial_inplace */
    585636         0xffffffff,            /* src_mask */
    586637         0xffffffff,            /* dst_mask */
    587          true),                 /* pcrel_offset */
     638         TRUE),                 /* pcrel_offset */
    588639
    589640  /* A 64 bit PC relative offset.  */
     
    592643         4,                     /* size (0 = byte, 1 = short, 2 = long) */
    593644         64,                    /* bitsize */
    594          true,                  /* pc_relative */
     645         TRUE,                  /* pc_relative */
    595646         0,                     /* bitpos */
    596647         complain_overflow_signed, /* complain_on_overflow */
    597648         0,                     /* special_function */
    598649         "SREL64",              /* name */
    599          false,                 /* partial_inplace */
     650         FALSE,                 /* partial_inplace */
    600651         MINUS_ONE,             /* src_mask */
    601652         MINUS_ONE,             /* dst_mask */
    602          true),                 /* pcrel_offset */
    603 
    604   /* Push a value on the reloc evaluation stack.  */
    605   /* Not implemented -- it's dumb.  */
    606   HOWTO (R_ALPHA_OP_PUSH,       /* type */
    607          0,                     /* rightshift */
    608          0,                     /* size (0 = byte, 1 = short, 2 = long) */
    609          0,                     /* bitsize */
    610          false,                 /* pc_relative */
    611          0,                     /* bitpos */
    612          complain_overflow_dont, /* complain_on_overflow */
    613          elf64_alpha_reloc_bad, /* special_function */
    614          "OP_PUSH",             /* name */
    615          false,                 /* partial_inplace */
    616          0,                     /* src_mask */
    617          0,                     /* dst_mask */
    618          false),                /* pcrel_offset */
    619 
    620   /* Store the value from the stack at the given address.  Store it in
    621      a bitfield of size r_size starting at bit position r_offset.  */
    622   /* Not implemented -- it's dumb.  */
    623   HOWTO (R_ALPHA_OP_STORE,      /* type */
    624          0,                     /* rightshift */
    625          4,                     /* size (0 = byte, 1 = short, 2 = long) */
    626          64,                    /* bitsize */
    627          false,                 /* pc_relative */
    628          0,                     /* bitpos */
    629          complain_overflow_dont, /* complain_on_overflow */
    630          elf64_alpha_reloc_bad, /* special_function */
    631          "OP_STORE",            /* name */
    632          false,                 /* partial_inplace */
    633          0,                     /* src_mask */
    634          MINUS_ONE,             /* dst_mask */
    635          false),                /* pcrel_offset */
    636 
    637   /* Subtract the reloc address from the value on the top of the
    638      relocation stack.  */
    639   /* Not implemented -- it's dumb.  */
    640   HOWTO (R_ALPHA_OP_PSUB,       /* type */
    641          0,                     /* rightshift */
    642          0,                     /* size (0 = byte, 1 = short, 2 = long) */
    643          0,                     /* bitsize */
    644          false,                 /* pc_relative */
    645          0,                     /* bitpos */
    646          complain_overflow_dont, /* complain_on_overflow */
    647          elf64_alpha_reloc_bad, /* special_function */
    648          "OP_PSUB",             /* name */
    649          false,                 /* partial_inplace */
    650          0,                     /* src_mask */
    651          0,                     /* dst_mask */
    652          false),                /* pcrel_offset */
    653 
    654   /* Shift the value on the top of the relocation stack right by the
    655      given value.  */
    656   /* Not implemented -- it's dumb.  */
    657   HOWTO (R_ALPHA_OP_PRSHIFT,    /* type */
    658          0,                     /* rightshift */
    659          0,                     /* size (0 = byte, 1 = short, 2 = long) */
    660          0,                     /* bitsize */
    661          false,                 /* pc_relative */
    662          0,                     /* bitpos */
    663          complain_overflow_dont, /* complain_on_overflow */
    664          elf64_alpha_reloc_bad, /* special_function */
    665          "OP_PRSHIFT",          /* name */
    666          false,                 /* partial_inplace */
    667          0,                     /* src_mask */
    668          0,                     /* dst_mask */
    669          false),                /* pcrel_offset */
    670 
    671   /* Change the value of GP used by +r_addend until the next GPVALUE or the
    672      end of the input bfd.  */
    673   /* Not implemented -- it's dumb.  */
    674   HOWTO (R_ALPHA_GPVALUE,
    675          0,                     /* rightshift */
    676          0,                     /* size (0 = byte, 1 = short, 2 = long) */
    677          0,                     /* bitsize */
    678          false,                 /* pc_relative */
    679          0,                     /* bitpos */
    680          complain_overflow_dont, /* complain_on_overflow */
    681          elf64_alpha_reloc_bad, /* special_function */
    682          "GPVALUE",             /* name */
    683          false,                 /* partial_inplace */
    684          0,                     /* src_mask */
    685          0,                     /* dst_mask */
    686          false),                /* pcrel_offset */
     653         TRUE),                 /* pcrel_offset */
     654
     655  /* Skip 12 - 16; deprecated ECOFF relocs.  */
     656  SKIP_HOWTO (12),
     657  SKIP_HOWTO (13),
     658  SKIP_HOWTO (14),
     659  SKIP_HOWTO (15),
     660  SKIP_HOWTO (16),
    687661
    688662  /* The high 16 bits of the displacement from GP to the target.  */
    689663  HOWTO (R_ALPHA_GPRELHIGH,
    690664         0,                     /* rightshift */
    691          2,                     /* size (0 = byte, 1 = short, 2 = long) */
     665         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    692666         16,                    /* bitsize */
    693          false,                 /* pc_relative */
     667         FALSE,                 /* pc_relative */
    694668         0,                     /* bitpos */
    695669         complain_overflow_signed, /* complain_on_overflow */
    696          elf64_alpha_reloc_bad, /* special_function */
     670         0,                     /* special_function */
    697671         "GPRELHIGH",           /* name */
    698          false,                 /* partial_inplace */
     672         FALSE,                 /* partial_inplace */
    699673         0xffff,                /* src_mask */
    700674         0xffff,                /* dst_mask */
    701          false),                /* pcrel_offset */
     675         FALSE),                /* pcrel_offset */
    702676
    703677  /* The low 16 bits of the displacement from GP to the target.  */
    704678  HOWTO (R_ALPHA_GPRELLOW,
    705679         0,                     /* rightshift */
    706          2,                     /* size (0 = byte, 1 = short, 2 = long) */
     680         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    707681         16,                    /* bitsize */
    708          false,                 /* pc_relative */
     682         FALSE,                 /* pc_relative */
    709683         0,                     /* bitpos */
    710684         complain_overflow_dont, /* complain_on_overflow */
    711          elf64_alpha_reloc_bad, /* special_function */
     685         0,                     /* special_function */
    712686         "GPRELLOW",            /* name */
    713          false,                 /* partial_inplace */
     687         FALSE,                 /* partial_inplace */
    714688         0xffff,                /* src_mask */
    715689         0xffff,                /* dst_mask */
    716          false),                /* pcrel_offset */
     690         FALSE),                /* pcrel_offset */
    717691
    718692  /* A 16-bit displacement from the GP to the target.  */
    719   /* XXX: Not implemented.  */
    720   HOWTO (R_ALPHA_IMMED_GP_16,
     693  HOWTO (R_ALPHA_GPREL16,
    721694         0,                     /* rightshift */
    722          2,                     /* size (0 = byte, 1 = short, 2 = long) */
     695         1,                     /* size (0 = byte, 1 = short, 2 = long) */
    723696         16,                    /* bitsize */
    724          false,                 /* pc_relative */
     697         FALSE,                 /* pc_relative */
    725698         0,                     /* bitpos */
    726699         complain_overflow_signed, /* complain_on_overflow */
    727700         0,                     /* special_function */
    728          "IMMED_GP_16",         /* name */
    729          false,                 /* partial_inplace */
     701         "GPREL16",             /* name */
     702         FALSE,                 /* partial_inplace */
    730703         0xffff,                /* src_mask */
    731704         0xffff,                /* dst_mask */
    732          false),                /* pcrel_offset */
    733 
    734   /* The high bits of a 32-bit displacement from the GP to the target; the
    735      low bits are supplied in the subsequent R_ALPHA_IMMED_LO32 relocs.  */
    736   /* XXX: Not implemented.  */
    737   HOWTO (R_ALPHA_IMMED_GP_HI32,
    738          0,                     /* rightshift */
    739          0,                     /* size (0 = byte, 1 = short, 2 = long) */
    740          0,                     /* bitsize */
    741          false,                 /* pc_relative */
    742          0,                     /* bitpos */
    743          complain_overflow_dont, /* complain_on_overflow */
    744          elf64_alpha_reloc_bad, /* special_function */
    745          "IMMED_GP_HI32",               /* name */
    746          false,                 /* partial_inplace */
    747          0,                     /* src_mask */
    748          0,                     /* dst_mask */
    749          false),                /* pcrel_offset */
    750 
    751   /* The high bits of a 32-bit displacement to the starting address of the
    752      current section (the relocation target is ignored); the low bits are
    753      supplied in the subsequent R_ALPHA_IMMED_LO32 relocs.  */
    754   /* XXX: Not implemented.  */
    755   HOWTO (R_ALPHA_IMMED_SCN_HI32,
    756          0,                     /* rightshift */
    757          0,                     /* size (0 = byte, 1 = short, 2 = long) */
    758          0,                     /* bitsize */
    759          false,                 /* pc_relative */
    760          0,                     /* bitpos */
    761          complain_overflow_dont, /* complain_on_overflow */
    762          elf64_alpha_reloc_bad, /* special_function */
    763          "IMMED_SCN_HI32",              /* name */
    764          false,                 /* partial_inplace */
    765          0,                     /* src_mask */
    766          0,                     /* dst_mask */
    767          false),                /* pcrel_offset */
    768 
    769   /* The high bits of a 32-bit displacement from the previous br, bsr, jsr
    770      or jmp insn (as tagged by a BRADDR or HINT reloc) to the target; the
    771      low bits are supplied by subsequent R_ALPHA_IMMED_LO32 relocs.  */
    772   /* XXX: Not implemented.  */
    773   HOWTO (R_ALPHA_IMMED_BR_HI32,
    774          0,                     /* rightshift */
    775          0,                     /* size (0 = byte, 1 = short, 2 = long) */
    776          0,                     /* bitsize */
    777          false,                 /* pc_relative */
    778          0,                     /* bitpos */
    779          complain_overflow_dont, /* complain_on_overflow */
    780          elf64_alpha_reloc_bad, /* special_function */
    781          "IMMED_BR_HI32",               /* name */
    782          false,                 /* partial_inplace */
    783          0,                     /* src_mask */
    784          0,                     /* dst_mask */
    785          false),                /* pcrel_offset */
    786 
    787   /* The low 16 bits of a displacement calculated in a previous HI32 reloc.  */
    788   /* XXX: Not implemented.  */
    789   HOWTO (R_ALPHA_IMMED_LO32,
    790          0,                     /* rightshift */
    791          0,                     /* size (0 = byte, 1 = short, 2 = long) */
    792          0,                     /* bitsize */
    793          false,                 /* pc_relative */
    794          0,                     /* bitpos */
    795          complain_overflow_dont, /* complain_on_overflow */
    796          elf64_alpha_reloc_bad, /* special_function */
    797          "IMMED_LO32",          /* name */
    798          false,                 /* partial_inplace */
    799          0,                     /* src_mask */
    800          0,                     /* dst_mask */
    801          false),                /* pcrel_offset */
     705         FALSE),                /* pcrel_offset */
     706
     707  /* Skip 20 - 23; deprecated ECOFF relocs.  */
     708  SKIP_HOWTO (20),
     709  SKIP_HOWTO (21),
     710  SKIP_HOWTO (22),
     711  SKIP_HOWTO (23),
    802712
    803713  /* Misc ELF relocations.  */
     
    811721         0,
    812722         0,
    813          false,
     723         FALSE,
    814724         0,
    815725         complain_overflow_dont,
    816726         bfd_elf_generic_reloc,
    817727         "COPY",
    818          false,
     728         FALSE,
    819729         0,
    820730         0,
    821          true),
     731         TRUE),
    822732
    823733  /* A dynamic relocation for a .got entry.  */
     
    826736         0,
    827737         0,
    828          false,
     738         FALSE,
    829739         0,
    830740         complain_overflow_dont,
    831741         bfd_elf_generic_reloc,
    832742         "GLOB_DAT",
    833          false,
     743         FALSE,
    834744         0,
    835745         0,
    836          true),
     746         TRUE),
    837747
    838748  /* A dynamic relocation for a .plt entry.  */
     
    841751         0,
    842752         0,
    843          false,
     753         FALSE,
    844754         0,
    845755         complain_overflow_dont,
    846756         bfd_elf_generic_reloc,
    847757         "JMP_SLOT",
    848          false,
     758         FALSE,
    849759         0,
    850760         0,
    851          true),
     761         TRUE),
    852762
    853763  /* A dynamic relocation to add the base of the DSO to a 64-bit field.  */
     
    856766         0,
    857767         0,
    858          false,
     768         FALSE,
    859769         0,
    860770         complain_overflow_dont,
    861771         bfd_elf_generic_reloc,
    862772         "RELATIVE",
    863          false,
     773         FALSE,
    864774         0,
    865775         0,
    866          true)
     776         TRUE),
     777
     778  /* A 21 bit branch that adjusts for gp loads.  */
     779  HOWTO (R_ALPHA_BRSGP,         /* type */
     780         2,                     /* rightshift */
     781         2,                     /* size (0 = byte, 1 = short, 2 = long) */
     782         21,                    /* bitsize */
     783         TRUE,                  /* pc_relative */
     784         0,                     /* bitpos */
     785         complain_overflow_signed, /* complain_on_overflow */
     786         0,                     /* special_function */
     787         "BRSGP",               /* name */
     788         FALSE,                 /* partial_inplace */
     789         0x1fffff,              /* src_mask */
     790         0x1fffff,              /* dst_mask */
     791         TRUE),                 /* pcrel_offset */
     792
     793  /* Creates a tls_index for the symbol in the got.  */
     794  HOWTO (R_ALPHA_TLSGD,         /* type */
     795         0,                     /* rightshift */
     796         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     797         16,                    /* bitsize */
     798         FALSE,                 /* pc_relative */
     799         0,                     /* bitpos */
     800         complain_overflow_signed, /* complain_on_overflow */
     801         0,                     /* special_function */
     802         "TLSGD",               /* name */
     803         FALSE,                 /* partial_inplace */
     804         0xffff,                /* src_mask */
     805         0xffff,                /* dst_mask */
     806         FALSE),                /* pcrel_offset */
     807
     808  /* Creates a tls_index for the (current) module in the got.  */
     809  HOWTO (R_ALPHA_TLSLDM,        /* type */
     810         0,                     /* rightshift */
     811         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     812         16,                    /* bitsize */
     813         FALSE,                 /* pc_relative */
     814         0,                     /* bitpos */
     815         complain_overflow_signed, /* complain_on_overflow */
     816         0,                     /* special_function */
     817         "TLSLDM",              /* name */
     818         FALSE,                 /* partial_inplace */
     819         0xffff,                /* src_mask */
     820         0xffff,                /* dst_mask */
     821         FALSE),                /* pcrel_offset */
     822
     823  /* A dynamic relocation for a DTP module entry.  */
     824  HOWTO (R_ALPHA_DTPMOD64,      /* type */
     825         0,                     /* rightshift */
     826         4,                     /* size (0 = byte, 1 = short, 2 = long) */
     827         64,                    /* bitsize */
     828         FALSE,                 /* pc_relative */
     829         0,                     /* bitpos */
     830         complain_overflow_bitfield, /* complain_on_overflow */
     831         0,                     /* special_function */
     832         "DTPMOD64",            /* name */
     833         FALSE,                 /* partial_inplace */
     834         MINUS_ONE,             /* src_mask */
     835         MINUS_ONE,             /* dst_mask */
     836         FALSE),                /* pcrel_offset */
     837
     838  /* Creates a 64-bit offset in the got for the displacement
     839     from DTP to the target.  */
     840  HOWTO (R_ALPHA_GOTDTPREL,     /* type */
     841         0,                     /* rightshift */
     842         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     843         16,                    /* bitsize */
     844         FALSE,                 /* pc_relative */
     845         0,                     /* bitpos */
     846         complain_overflow_signed, /* complain_on_overflow */
     847         0,                     /* special_function */
     848         "GOTDTPREL",           /* name */
     849         FALSE,                 /* partial_inplace */
     850         0xffff,                /* src_mask */
     851         0xffff,                /* dst_mask */
     852         FALSE),                /* pcrel_offset */
     853
     854  /* A dynamic relocation for a displacement from DTP to the target.  */
     855  HOWTO (R_ALPHA_DTPREL64,      /* type */
     856         0,                     /* rightshift */
     857         4,                     /* size (0 = byte, 1 = short, 2 = long) */
     858         64,                    /* bitsize */
     859         FALSE,                 /* pc_relative */
     860         0,                     /* bitpos */
     861         complain_overflow_bitfield, /* complain_on_overflow */
     862         0,                     /* special_function */
     863         "DTPREL64",            /* name */
     864         FALSE,                 /* partial_inplace */
     865         MINUS_ONE,             /* src_mask */
     866         MINUS_ONE,             /* dst_mask */
     867         FALSE),                /* pcrel_offset */
     868
     869  /* The high 16 bits of the displacement from DTP to the target.  */
     870  HOWTO (R_ALPHA_DTPRELHI,      /* type */
     871         0,                     /* rightshift */
     872         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     873         16,                    /* bitsize */
     874         FALSE,                 /* pc_relative */
     875         0,                     /* bitpos */
     876         complain_overflow_signed, /* complain_on_overflow */
     877         0,                     /* special_function */
     878         "DTPRELHI",            /* name */
     879         FALSE,                 /* partial_inplace */
     880         0xffff,                /* src_mask */
     881         0xffff,                /* dst_mask */
     882         FALSE),                /* pcrel_offset */
     883
     884  /* The low 16 bits of the displacement from DTP to the target.  */
     885  HOWTO (R_ALPHA_DTPRELLO,      /* type */
     886         0,                     /* rightshift */
     887         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     888         16,                    /* bitsize */
     889         FALSE,                 /* pc_relative */
     890         0,                     /* bitpos */
     891         complain_overflow_dont, /* complain_on_overflow */
     892         0,                     /* special_function */
     893         "DTPRELLO",            /* name */
     894         FALSE,                 /* partial_inplace */
     895         0xffff,                /* src_mask */
     896         0xffff,                /* dst_mask */
     897         FALSE),                /* pcrel_offset */
     898
     899  /* A 16-bit displacement from DTP to the target.  */
     900  HOWTO (R_ALPHA_DTPREL16,      /* type */
     901         0,                     /* rightshift */
     902         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     903         16,                    /* bitsize */
     904         FALSE,                 /* pc_relative */
     905         0,                     /* bitpos */
     906         complain_overflow_signed, /* complain_on_overflow */
     907         0,                     /* special_function */
     908         "DTPREL16",            /* name */
     909         FALSE,                 /* partial_inplace */
     910         0xffff,                /* src_mask */
     911         0xffff,                /* dst_mask */
     912         FALSE),                /* pcrel_offset */
     913
     914  /* Creates a 64-bit offset in the got for the displacement
     915     from TP to the target.  */
     916  HOWTO (R_ALPHA_GOTTPREL,      /* type */
     917         0,                     /* rightshift */
     918         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     919         16,                    /* bitsize */
     920         FALSE,                 /* pc_relative */
     921         0,                     /* bitpos */
     922         complain_overflow_signed, /* complain_on_overflow */
     923         0,                     /* special_function */
     924         "GOTTPREL",            /* name */
     925         FALSE,                 /* partial_inplace */
     926         0xffff,                /* src_mask */
     927         0xffff,                /* dst_mask */
     928         FALSE),                /* pcrel_offset */
     929
     930  /* A dynamic relocation for a displacement from TP to the target.  */
     931  HOWTO (R_ALPHA_TPREL64,       /* type */
     932         0,                     /* rightshift */
     933         4,                     /* size (0 = byte, 1 = short, 2 = long) */
     934         64,                    /* bitsize */
     935         FALSE,                 /* pc_relative */
     936         0,                     /* bitpos */
     937         complain_overflow_bitfield, /* complain_on_overflow */
     938         0,                     /* special_function */
     939         "TPREL64",             /* name */
     940         FALSE,                 /* partial_inplace */
     941         MINUS_ONE,             /* src_mask */
     942         MINUS_ONE,             /* dst_mask */
     943         FALSE),                /* pcrel_offset */
     944
     945  /* The high 16 bits of the displacement from TP to the target.  */
     946  HOWTO (R_ALPHA_TPRELHI,       /* type */
     947         0,                     /* rightshift */
     948         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     949         16,                    /* bitsize */
     950         FALSE,                 /* pc_relative */
     951         0,                     /* bitpos */
     952         complain_overflow_signed, /* complain_on_overflow */
     953         0,                     /* special_function */
     954         "TPRELHI",             /* name */
     955         FALSE,                 /* partial_inplace */
     956         0xffff,                /* src_mask */
     957         0xffff,                /* dst_mask */
     958         FALSE),                /* pcrel_offset */
     959
     960  /* The low 16 bits of the displacement from TP to the target.  */
     961  HOWTO (R_ALPHA_TPRELLO,       /* type */
     962         0,                     /* rightshift */
     963         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     964         16,                    /* bitsize */
     965         FALSE,                 /* pc_relative */
     966         0,                     /* bitpos */
     967         complain_overflow_dont, /* complain_on_overflow */
     968         0,                     /* special_function */
     969         "TPRELLO",             /* name */
     970         FALSE,                 /* partial_inplace */
     971         0xffff,                /* src_mask */
     972         0xffff,                /* dst_mask */
     973         FALSE),                /* pcrel_offset */
     974
     975  /* A 16-bit displacement from TP to the target.  */
     976  HOWTO (R_ALPHA_TPREL16,       /* type */
     977         0,                     /* rightshift */
     978         1,                     /* size (0 = byte, 1 = short, 2 = long) */
     979         16,                    /* bitsize */
     980         FALSE,                 /* pc_relative */
     981         0,                     /* bitpos */
     982         complain_overflow_signed, /* complain_on_overflow */
     983         0,                     /* special_function */
     984         "TPREL16",             /* name */
     985         FALSE,                 /* partial_inplace */
     986         0xffff,                /* src_mask */
     987         0xffff,                /* dst_mask */
     988         FALSE),                /* pcrel_offset */
    867989};
    868990
     
    9381060  i_lda = (i_lda & 0xffff0000) | (gpdisp & 0xffff);
    9391061
    940   bfd_put_32 (abfd, i_ldah, p_ldah);
    941   bfd_put_32 (abfd, i_lda, p_lda);
     1062  bfd_put_32 (abfd, (bfd_vma) i_ldah, p_ldah);
     1063  bfd_put_32 (abfd, (bfd_vma) i_lda, p_lda);
    9421064
    9431065  return ret;
     
    10021124static const struct elf_reloc_map elf64_alpha_reloc_map[] =
    10031125{
    1004   {BFD_RELOC_NONE,              R_ALPHA_NONE},
    1005   {BFD_RELOC_32,                R_ALPHA_REFLONG},
    1006   {BFD_RELOC_64,                R_ALPHA_REFQUAD},
    1007   {BFD_RELOC_CTOR,              R_ALPHA_REFQUAD},
    1008   {BFD_RELOC_GPREL32,           R_ALPHA_GPREL32},
    1009   {BFD_RELOC_ALPHA_ELF_LITERAL, R_ALPHA_LITERAL},
    1010   {BFD_RELOC_ALPHA_LITUSE,      R_ALPHA_LITUSE},
    1011   {BFD_RELOC_ALPHA_GPDISP,      R_ALPHA_GPDISP},
    1012   {BFD_RELOC_23_PCREL_S2,       R_ALPHA_BRADDR},
    1013   {BFD_RELOC_ALPHA_HINT,        R_ALPHA_HINT},
    1014   {BFD_RELOC_16_PCREL,          R_ALPHA_SREL16},
    1015   {BFD_RELOC_32_PCREL,          R_ALPHA_SREL32},
    1016   {BFD_RELOC_64_PCREL,          R_ALPHA_SREL64},
    1017 
    1018 /* The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to process
    1019    the explicit !<reloc>!sequence relocations, and are mapped into the normal
    1020    relocations at the end of processing.  */
    1021   {BFD_RELOC_ALPHA_USER_LITERAL,        R_ALPHA_LITERAL},
    1022   {BFD_RELOC_ALPHA_USER_LITUSE_BASE,    R_ALPHA_LITUSE},
    1023   {BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF,  R_ALPHA_LITUSE},
    1024   {BFD_RELOC_ALPHA_USER_LITUSE_JSR,     R_ALPHA_LITUSE},
    1025   {BFD_RELOC_ALPHA_USER_GPDISP,         R_ALPHA_GPDISP},
    1026   {BFD_RELOC_ALPHA_USER_GPRELHIGH,      R_ALPHA_GPRELHIGH},
    1027   {BFD_RELOC_ALPHA_USER_GPRELLOW,       R_ALPHA_GPRELLOW},
     1126  {BFD_RELOC_NONE,                      R_ALPHA_NONE},
     1127  {BFD_RELOC_32,                        R_ALPHA_REFLONG},
     1128  {BFD_RELOC_64,                        R_ALPHA_REFQUAD},
     1129  {BFD_RELOC_CTOR,                      R_ALPHA_REFQUAD},
     1130  {BFD_RELOC_GPREL32,                   R_ALPHA_GPREL32},
     1131  {BFD_RELOC_ALPHA_ELF_LITERAL,         R_ALPHA_LITERAL},
     1132  {BFD_RELOC_ALPHA_LITUSE,              R_ALPHA_LITUSE},
     1133  {BFD_RELOC_ALPHA_GPDISP,              R_ALPHA_GPDISP},
     1134  {BFD_RELOC_23_PCREL_S2,               R_ALPHA_BRADDR},
     1135  {BFD_RELOC_ALPHA_HINT,                R_ALPHA_HINT},
     1136  {BFD_RELOC_16_PCREL,                  R_ALPHA_SREL16},
     1137  {BFD_RELOC_32_PCREL,                  R_ALPHA_SREL32},
     1138  {BFD_RELOC_64_PCREL,                  R_ALPHA_SREL64},
     1139  {BFD_RELOC_ALPHA_GPREL_HI16,          R_ALPHA_GPRELHIGH},
     1140  {BFD_RELOC_ALPHA_GPREL_LO16,          R_ALPHA_GPRELLOW},
     1141  {BFD_RELOC_GPREL16,                   R_ALPHA_GPREL16},
     1142  {BFD_RELOC_ALPHA_BRSGP,               R_ALPHA_BRSGP},
     1143  {BFD_RELOC_ALPHA_TLSGD,               R_ALPHA_TLSGD},
     1144  {BFD_RELOC_ALPHA_TLSLDM,              R_ALPHA_TLSLDM},
     1145  {BFD_RELOC_ALPHA_DTPMOD64,            R_ALPHA_DTPMOD64},
     1146  {BFD_RELOC_ALPHA_GOTDTPREL16,         R_ALPHA_GOTDTPREL},
     1147  {BFD_RELOC_ALPHA_DTPREL64,            R_ALPHA_DTPREL64},
     1148  {BFD_RELOC_ALPHA_DTPREL_HI16,         R_ALPHA_DTPRELHI},
     1149  {BFD_RELOC_ALPHA_DTPREL_LO16,         R_ALPHA_DTPRELLO},
     1150  {BFD_RELOC_ALPHA_DTPREL16,            R_ALPHA_DTPREL16},
     1151  {BFD_RELOC_ALPHA_GOTTPREL16,          R_ALPHA_GOTTPREL},
     1152  {BFD_RELOC_ALPHA_TPREL64,             R_ALPHA_TPREL64},
     1153  {BFD_RELOC_ALPHA_TPREL_HI16,          R_ALPHA_TPRELHI},
     1154  {BFD_RELOC_ALPHA_TPREL_LO16,          R_ALPHA_TPRELLO},
     1155  {BFD_RELOC_ALPHA_TPREL16,             R_ALPHA_TPREL16},
    10281156};
    10291157
     
    10521180     bfd *abfd ATTRIBUTE_UNUSED;
    10531181     arelent *cache_ptr;
    1054      Elf64_Internal_Rela *dst;
     1182     Elf_Internal_Rela *dst;
    10551183{
    10561184  unsigned r_type;
     
    10601188  cache_ptr->howto = &elf64_alpha_howto_table[r_type];
    10611189}
     1190
     1191/* These two relocations create a two-word entry in the got.  */
     1192#define alpha_got_entry_size(r_type) \
     1193  (r_type == R_ALPHA_TLSGD || r_type == R_ALPHA_TLSLDM ? 16 : 8)
     1194
     1195/* This is PT_TLS segment p_vaddr.  */
     1196#define alpha_get_dtprel_base(tlss) \
     1197  ((tlss)->start)
     1198
     1199/* Main program TLS (whose template starts at PT_TLS p_vaddr)
     1200   is assigned offset round(16, PT_TLS p_align).  */
     1201#define alpha_get_tprel_base(tlss) \
     1202  ((tlss)->start - align_power ((bfd_vma) 16, (tlss)->align))
    10621203
    10631204
     
    10821223#define OP_BR           0x30
    10831224#define OP_BSR          0x34
    1084 #define INSN_UNOP       0x2fe00000
     1225#define INSN_UNOP       0x2ffe0000
     1226#define INSN_ADDQ       0x40000400
     1227#define INSN_RDUNIQ     0x0000009e
    10851228
    10861229struct alpha_relax_info
     
    10891232  asection *sec;
    10901233  bfd_byte *contents;
     1234  Elf_Internal_Shdr *symtab_hdr;
    10911235  Elf_Internal_Rela *relocs, *relend;
    10921236  struct bfd_link_info *link_info;
    1093   boolean changed_contents;
    1094   boolean changed_relocs;
     1237  struct elf_link_tls_segment *tls_segment;
    10951238  bfd_vma gp;
    10961239  bfd *gotobj;
    10971240  asection *tsec;
    10981241  struct alpha_elf_link_hash_entry *h;
     1242  struct alpha_elf_got_entry **first_gotent;
    10991243  struct alpha_elf_got_entry *gotent;
     1244  bfd_boolean changed_contents;
     1245  bfd_boolean changed_relocs;
    11001246  unsigned char other;
    11011247};
    11021248
    1103 static Elf_Internal_Rela * elf64_alpha_relax_with_lituse
    1104   PARAMS((struct alpha_relax_info *info, bfd_vma symval,
    1105           Elf_Internal_Rela *irel, Elf_Internal_Rela *irelend));
    1106 
    1107 static boolean elf64_alpha_relax_without_lituse
     1249static bfd_boolean elf64_alpha_relax_with_lituse
    11081250  PARAMS((struct alpha_relax_info *info, bfd_vma symval,
    11091251          Elf_Internal_Rela *irel));
    1110 
    11111252static bfd_vma elf64_alpha_relax_opt_call
    11121253  PARAMS((struct alpha_relax_info *info, bfd_vma symval));
    1113 
    1114 static boolean elf64_alpha_relax_section
     1254static bfd_boolean elf64_alpha_relax_got_load
     1255  PARAMS((struct alpha_relax_info *info, bfd_vma symval,
     1256          Elf_Internal_Rela *irel, unsigned long));
     1257static bfd_boolean elf64_alpha_relax_gprelhilo
     1258  PARAMS((struct alpha_relax_info *info, bfd_vma symval,
     1259          Elf_Internal_Rela *irel, bfd_boolean));
     1260static bfd_boolean elf64_alpha_relax_tls_get_addr
     1261  PARAMS((struct alpha_relax_info *info, bfd_vma symval,
     1262          Elf_Internal_Rela *irel, bfd_boolean));
     1263static struct elf_link_tls_segment *elf64_alpha_relax_find_tls_segment
     1264  PARAMS((struct alpha_relax_info *, struct elf_link_tls_segment *));
     1265static bfd_boolean elf64_alpha_relax_section
    11151266  PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
    1116           boolean *again));
     1267          bfd_boolean *again));
    11171268
    11181269static Elf_Internal_Rela *
     
    11241275  while (rel < relend)
    11251276    {
    1126       if (rel->r_offset == offset && ELF64_R_TYPE (rel->r_info) == type)
     1277      if (rel->r_offset == offset
     1278          && ELF64_R_TYPE (rel->r_info) == (unsigned int) type)
    11271279        return rel;
    11281280      ++rel;
     
    11311283}
    11321284
    1133 static Elf_Internal_Rela *
    1134 elf64_alpha_relax_with_lituse (info, symval, irel, irelend)
     1285static bfd_boolean
     1286elf64_alpha_relax_with_lituse (info, symval, irel)
    11351287     struct alpha_relax_info *info;
    11361288     bfd_vma symval;
    1137      Elf_Internal_Rela *irel, *irelend;
    1138 {
    1139   Elf_Internal_Rela *urel;
     1289     Elf_Internal_Rela *irel;
     1290{
     1291  Elf_Internal_Rela *urel, *irelend = info->relend;
    11401292  int flags, count, i;
    11411293  bfd_signed_vma disp;
    1142   boolean fits16;
    1143   boolean fits32;
    1144   boolean lit_reused = false;
    1145   boolean all_optimized = true;
     1294  bfd_boolean fits16;
     1295  bfd_boolean fits32;
     1296  bfd_boolean lit_reused = FALSE;
     1297  bfd_boolean all_optimized = TRUE;
    11461298  unsigned int lit_insn;
    11471299
     
    11511303      ((*_bfd_error_handler)
    11521304       ("%s: %s+0x%lx: warning: LITERAL relocation against unexpected insn",
    1153         bfd_get_filename (info->abfd), info->sec->name,
    1154         (unsigned long)irel->r_offset));
    1155       return irel;
    1156     }
     1305        bfd_archive_filename (info->abfd), info->sec->name,
     1306        (unsigned long) irel->r_offset));
     1307      return TRUE;
     1308    }
     1309
     1310  /* Can't relax dynamic symbols.  */
     1311  if (alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info))
     1312    return TRUE;
    11571313
    11581314  /* Summarize how this particular LITERAL is used.  */
     
    11611317      if (ELF64_R_TYPE (urel->r_info) != R_ALPHA_LITUSE)
    11621318        break;
    1163       if (urel->r_addend >= 0 && urel->r_addend <= 3)
     1319      if (urel->r_addend <= 3)
    11641320        flags |= 1 << urel->r_addend;
    11651321    }
     
    11781334      switch (urel->r_addend)
    11791335        {
    1180         default: /* 0 = ADDRESS FORMAT */
     1336        case LITUSE_ALPHA_ADDR:
     1337        default:
    11811338          /* This type is really just a placeholder to note that all
    11821339             uses cannot be optimized, but to still allow some.  */
    1183           all_optimized = false;
     1340          all_optimized = FALSE;
    11841341          break;
    11851342
    1186         case 1: /* MEM FORMAT */
     1343        case LITUSE_ALPHA_BASE:
    11871344          /* We can always optimize 16-bit displacements.  */
    11881345
     
    11911348             displacement from GP.  */
    11921349          insn_disp = insn & 0x0000ffff;
    1193           if (insn_disp & 0x00008000)
    1194             insn_disp |= 0xffff0000;  /* Negative: sign-extend.  */
     1350          if (insn_disp & 0x8000)
     1351            insn_disp |= ~0xffff;  /* Negative: sign-extend.  */
    11951352
    11961353          xdisp = disp + insn_disp;
    1197           fits16 = (xdisp >= - (bfd_signed_vma) 0x00008000 && xdisp < 0x00008000);
    1198           fits32 = (xdisp >= - (bfd_signed_vma) 0x80000000 && xdisp < 0x7fff8000);
     1354          fits16 = (xdisp >= - (bfd_signed_vma) 0x8000 && xdisp < 0x8000);
     1355          fits32 = (xdisp >= - (bfd_signed_vma) 0x80000000
     1356                    && xdisp < 0x7fff8000);
    11991357
    12001358          if (fits16)
     
    12041362              insn = (insn & 0xffe0ffff) | (lit_insn & 0x001f0000);
    12051363              urel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
    1206                                            R_ALPHA_GPRELLOW);
     1364                                           R_ALPHA_GPREL16);
    12071365              urel->r_addend = irel->r_addend;
    1208               info->changed_relocs = true;
    1209 
    1210               bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset);
    1211               info->changed_contents = true;
     1366              info->changed_relocs = TRUE;
     1367
     1368              bfd_put_32 (info->abfd, (bfd_vma) insn,
     1369                          info->contents + urel->r_offset);
     1370              info->changed_contents = TRUE;
    12121371            }
    12131372
     
    12201379                                           R_ALPHA_GPRELHIGH);
    12211380              lit_insn = (OP_LDAH << 26) | (lit_insn & 0x03ff0000);
    1222               bfd_put_32 (info->abfd, lit_insn,
     1381              bfd_put_32 (info->abfd, (bfd_vma) lit_insn,
    12231382                          info->contents + irel->r_offset);
    1224               lit_reused = true;
    1225               info->changed_contents = true;
     1383              lit_reused = TRUE;
     1384              info->changed_contents = TRUE;
    12261385
    12271386              urel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
    12281387                                           R_ALPHA_GPRELLOW);
    12291388              urel->r_addend = irel->r_addend;
    1230               info->changed_relocs = true;
     1389              info->changed_relocs = TRUE;
    12311390            }
    12321391          else
    1233             all_optimized = false;
     1392            all_optimized = FALSE;
    12341393          break;
    12351394
    1236         case 2: /* BYTE OFFSET FORMAT */
     1395        case LITUSE_ALPHA_BYTOFF:
    12371396          /* We can always optimize byte instructions.  */
    12381397
     
    12401399             literal dest reg is indeed Rb in the byte insn.  */
    12411400
    1242           insn = (insn & ~0x001ff000) | ((symval & 7) << 13) | 0x1000;
     1401          insn &= ~ (unsigned) 0x001ff000;
     1402          insn |= ((symval & 7) << 13) | 0x1000;
    12431403
    12441404          urel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
    12451405          urel->r_addend = 0;
    1246           info->changed_relocs = true;
    1247 
    1248           bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset);
    1249           info->changed_contents = true;
     1406          info->changed_relocs = TRUE;
     1407
     1408          bfd_put_32 (info->abfd, (bfd_vma) insn,
     1409                      info->contents + urel->r_offset);
     1410          info->changed_contents = TRUE;
    12501411          break;
    12511412
    1252         case 3: /* CALL FORMAT */
     1413        case LITUSE_ALPHA_JSR:
     1414        case LITUSE_ALPHA_TLSGD:
     1415        case LITUSE_ALPHA_TLSLDM:
    12531416          {
     1417            bfd_vma optdest, org;
     1418            bfd_signed_vma odisp;
     1419
    12541420            /* If not zero, place to jump without needing pv.  */
    1255             bfd_vma optdest = elf64_alpha_relax_opt_call (info, symval);
    1256             bfd_vma org = (info->sec->output_section->vma
    1257                            + info->sec->output_offset
    1258                            + urel->r_offset + 4);
    1259             bfd_signed_vma odisp;
    1260 
     1421            optdest = elf64_alpha_relax_opt_call (info, symval);
     1422            org = (info->sec->output_section->vma
     1423                   + info->sec->output_offset
     1424                   + urel->r_offset + 4);
    12611425            odisp = (optdest ? optdest : symval) - org;
     1426
    12621427            if (odisp >= -0x400000 && odisp < 0x400000)
    12631428              {
     
    12771442                  urel->r_addend += optdest - symval;
    12781443                else
    1279                   all_optimized = false;
    1280 
    1281                 bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset);
     1444                  all_optimized = FALSE;
     1445
     1446                bfd_put_32 (info->abfd, (bfd_vma) insn,
     1447                            info->contents + urel->r_offset);
    12821448
    12831449                /* Kill any HINT reloc that might exist for this insn.  */
     
    12881454                  xrel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
    12891455
    1290                 info->changed_contents = true;
    1291                 info->changed_relocs = true;
     1456                info->changed_contents = TRUE;
     1457                info->changed_relocs = TRUE;
    12921458              }
    12931459            else
    1294               all_optimized = false;
    1295 
    1296             /* ??? If target gp == current gp we can eliminate the gp reload.
    1297                This does depend on every place a gp could be reloaded will
    1298                be, which currently happens for all code produced by gcc, but
    1299                not necessarily by hand-coded assembly, or if sibling calls
    1300                are enabled in gcc.
    1301 
    1302                Perhaps conditionalize this on a flag being set in the target
    1303                object file's header, and have gcc set it?  */
     1460              all_optimized = FALSE;
     1461
     1462            /* Even if the target is not in range for a direct branch,
     1463               if we share a GP, we can eliminate the gp reload.  */
     1464            if (optdest)
     1465              {
     1466                Elf_Internal_Rela *gpdisp
     1467                  = (elf64_alpha_find_reloc_at_ofs
     1468                     (info->relocs, irelend, urel->r_offset + 4,
     1469                      R_ALPHA_GPDISP));
     1470                if (gpdisp)
     1471                  {
     1472                    bfd_byte *p_ldah = info->contents + gpdisp->r_offset;
     1473                    bfd_byte *p_lda = p_ldah + gpdisp->r_addend;
     1474                    unsigned int ldah = bfd_get_32 (info->abfd, p_ldah);
     1475                    unsigned int lda = bfd_get_32 (info->abfd, p_lda);
     1476
     1477                    /* Verify that the instruction is "ldah $29,0($26)".
     1478                       Consider a function that ends in a noreturn call,
     1479                       and that the next function begins with an ldgp,
     1480                       and that by accident there is no padding between.
     1481                       In that case the insn would use $27 as the base.  */
     1482                    if (ldah == 0x27ba0000 && lda == 0x23bd0000)
     1483                      {
     1484                        bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, p_ldah);
     1485                        bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, p_lda);
     1486
     1487                        gpdisp->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
     1488                        info->changed_contents = TRUE;
     1489                        info->changed_relocs = TRUE;
     1490                      }
     1491                  }
     1492              }
    13041493          }
    13051494          break;
     
    13111500  if (all_optimized)
    13121501    {
    1313       info->gotent->use_count -= 1;
    1314       alpha_elf_tdata (info->gotent->gotobj)->total_got_entries -= 1;
    1315       if (!info->h)
    1316         alpha_elf_tdata (info->gotent->gotobj)->n_local_got_entries -= 1;
     1502      if (--info->gotent->use_count == 0)
     1503        {
     1504          int sz = alpha_got_entry_size (R_ALPHA_LITERAL);
     1505          alpha_elf_tdata (info->gotobj)->total_got_size -= sz;
     1506          if (!info->h)
     1507            alpha_elf_tdata (info->gotobj)->local_got_size -= sz;
     1508        }
    13171509
    13181510      /* If the literal instruction is no longer needed (it may have been
    1319          reused.  We can eliminate it.
    1320         ??? For now, I don't want to deal with compacting the section,
     1511         reused.  We can eliminate it.  */
     1512      /* ??? For now, I don't want to deal with compacting the section,
    13211513         so just nop it out.  */
    13221514      if (!lit_reused)
    13231515        {
    13241516          irel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
    1325           info->changed_relocs = true;
    1326 
    1327           bfd_put_32 (info->abfd, INSN_UNOP, info->contents + irel->r_offset);
    1328           info->changed_contents = true;
    1329         }
    1330     }
    1331 
    1332   return irel + count;
     1517          info->changed_relocs = TRUE;
     1518
     1519          bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP,
     1520                      info->contents + irel->r_offset);
     1521          info->changed_contents = TRUE;
     1522        }
     1523    }
     1524
     1525  return TRUE;
    13331526}
    13341527
     
    14051598}
    14061599
    1407 static boolean
    1408 elf64_alpha_relax_without_lituse (info, symval, irel)
     1600static bfd_boolean
     1601elf64_alpha_relax_got_load (info, symval, irel, r_type)
    14091602     struct alpha_relax_info *info;
    14101603     bfd_vma symval;
    14111604     Elf_Internal_Rela *irel;
     1605     unsigned long r_type;
    14121606{
    14131607  unsigned int insn;
     
    14191613  if (insn >> 26 != OP_LDQ)
    14201614    {
     1615      reloc_howto_type *howto = elf64_alpha_howto_table + r_type;
    14211616      ((*_bfd_error_handler)
    1422        ("%s: %s+0x%lx: warning: LITERAL relocation against unexpected insn",
    1423         bfd_get_filename (info->abfd), info->sec->name,
    1424         (unsigned long) irel->r_offset));
    1425       return true;
    1426     }
    1427 
    1428   /* So we aren't told much.  Do what we can with the address load and
    1429      fake the rest.  All of the optimizations here require that the
    1430      offset from the GP fit in 16 bits.  */
    1431 
    1432   disp = symval - info->gp;
     1617       ("%s: %s+0x%lx: warning: %s relocation against unexpected insn",
     1618        bfd_archive_filename (info->abfd), info->sec->name,
     1619        (unsigned long) irel->r_offset, howto->name));
     1620      return TRUE;
     1621    }
     1622
     1623  /* Can't relax dynamic symbols.  */
     1624  if (alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info))
     1625    return TRUE;
     1626
     1627  /* Can't use local-exec relocations in shared libraries.  */
     1628  if (r_type == R_ALPHA_GOTTPREL && info->link_info->shared)
     1629    return TRUE;
     1630
     1631  if (r_type == R_ALPHA_LITERAL)
     1632    disp = symval - info->gp;
     1633  else
     1634    {
     1635      bfd_vma dtp_base, tp_base;
     1636
     1637      BFD_ASSERT (info->tls_segment != NULL);
     1638      dtp_base = alpha_get_dtprel_base (info->tls_segment);
     1639      tp_base = alpha_get_tprel_base (info->tls_segment);
     1640      disp = symval - (r_type == R_ALPHA_GOTDTPREL ? dtp_base : tp_base);
     1641    }
     1642
    14331643  if (disp < -0x8000 || disp >= 0x8000)
    1434     return true;
    1435 
    1436   /* On the LITERAL instruction itself, consider exchanging
    1437      `ldq R,X(gp)' for `lda R,Y(gp)'.  */
    1438 
    1439   insn = (OP_LDA << 26) | (insn & 0x03ff0000);
    1440   bfd_put_32 (info->abfd, insn, info->contents + irel->r_offset);
    1441   info->changed_contents = true;
    1442 
    1443   irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), R_ALPHA_GPRELLOW);
    1444   info->changed_relocs = true;
     1644    return TRUE;
     1645
     1646  /* Exchange LDQ for LDA.  In the case of the TLS relocs, we're loading
     1647     a constant, so force the base register to be $31.  */
     1648  if (r_type == R_ALPHA_LITERAL)
     1649    insn = (OP_LDA << 26) | (insn & 0x03ff0000);
     1650  else
     1651    insn = (OP_LDA << 26) | (insn & (31 << 21)) | (31 << 16);
     1652  bfd_put_32 (info->abfd, (bfd_vma) insn, info->contents + irel->r_offset);
     1653  info->changed_contents = TRUE;
    14451654
    14461655  /* Reduce the use count on this got entry by one, possibly
    14471656     eliminating it.  */
    1448   info->gotent->use_count -= 1;
    1449   alpha_elf_tdata (info->gotent->gotobj)->total_got_entries -= 1;
    1450   if (!info->h)
    1451     alpha_elf_tdata (info->gotent->gotobj)->n_local_got_entries -= 1;
     1657  if (--info->gotent->use_count == 0)
     1658    {
     1659      int sz = alpha_got_entry_size (r_type);
     1660      alpha_elf_tdata (info->gotobj)->total_got_size -= sz;
     1661      if (!info->h)
     1662        alpha_elf_tdata (info->gotobj)->local_got_size -= sz;
     1663    }
     1664
     1665  /* Smash the existing GOT relocation for its 16-bit immediate pair.  */
     1666  switch (r_type)
     1667    {
     1668    case R_ALPHA_LITERAL:
     1669      r_type = R_ALPHA_GPREL16;
     1670      break;
     1671    case R_ALPHA_GOTDTPREL:
     1672      r_type = R_ALPHA_DTPREL16;
     1673      break;
     1674    case R_ALPHA_GOTTPREL:
     1675      r_type = R_ALPHA_TPREL16;
     1676      break;
     1677    default:
     1678      BFD_ASSERT (0);
     1679      return FALSE;
     1680    }
     1681
     1682  irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), r_type);
     1683  info->changed_relocs = TRUE;
    14521684
    14531685  /* ??? Search forward through this basic block looking for insns
     
    14641696     which gives one pause.  */
    14651697
    1466   return true;
     1698  return TRUE;
    14671699}
    14681700
    1469 static boolean
     1701static bfd_boolean
     1702elf64_alpha_relax_gprelhilo (info, symval, irel, hi)
     1703     struct alpha_relax_info *info;
     1704     bfd_vma symval;
     1705     Elf_Internal_Rela *irel;
     1706     bfd_boolean hi;
     1707{
     1708  unsigned int insn;
     1709  bfd_signed_vma disp;
     1710  bfd_byte *pos = info->contents + irel->r_offset;
     1711
     1712  /* ??? This assumes that the compiler doesn't render
     1713
     1714        array[i]
     1715     as
     1716        ldah    t, array(gp)    !gprelhigh
     1717        s8addl  i, t, t
     1718        ldq     r, array(t)     !gprellow
     1719
     1720     which would indeed be the most efficient way to implement this.  */
     1721
     1722  return TRUE;
     1723
     1724  disp = symval - info->gp;
     1725  if (disp < -0x8000 || disp >= 0x8000)
     1726    return TRUE;
     1727
     1728  if (hi)
     1729    {
     1730      /* Nop out the high instruction.  */
     1731
     1732      bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos);
     1733      info->changed_contents = TRUE;
     1734
     1735      irel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
     1736      irel->r_addend = 0;
     1737      info->changed_relocs = TRUE;
     1738    }
     1739  else
     1740    {
     1741      /* Adjust the low instruction to reference GP directly.  */
     1742
     1743      insn = bfd_get_32 (info->abfd, pos);
     1744      insn = (insn & 0xffe00000) | (29 << 16);
     1745      bfd_put_32 (info->abfd, (bfd_vma) insn, pos);
     1746      info->changed_contents = TRUE;
     1747
     1748      irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
     1749                                   R_ALPHA_GPREL16);
     1750      info->changed_relocs = TRUE;
     1751    }
     1752
     1753  return TRUE;
     1754}
     1755
     1756static bfd_boolean
     1757elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd)
     1758     struct alpha_relax_info *info;
     1759     bfd_vma symval;
     1760     Elf_Internal_Rela *irel;
     1761     bfd_boolean is_gd;
     1762{
     1763  bfd_byte *pos[5];
     1764  unsigned int insn;
     1765  Elf_Internal_Rela *gpdisp, *hint;
     1766  bfd_boolean dynamic, use_gottprel, pos1_unusable;
     1767  unsigned long new_symndx;
     1768
     1769  dynamic = alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info);
     1770
     1771  /* If a TLS symbol is accessed using IE at least once, there is no point
     1772     to use dynamic model for it.  */
     1773  if (is_gd && info->h && (info->h->flags & ALPHA_ELF_LINK_HASH_TLS_IE))
     1774    ;
     1775
     1776  /* If the symbol is local, and we've already committed to DF_STATIC_TLS,
     1777     then we might as well relax to IE.  */
     1778  else if (info->link_info->shared && !dynamic
     1779           && (info->link_info->flags & DF_STATIC_TLS))
     1780    ;
     1781
     1782  /* Otherwise we must be building an executable to do anything.  */
     1783  else if (info->link_info->shared)
     1784    return TRUE;
     1785
     1786  /* The TLSGD/TLSLDM relocation must be followed by a LITERAL and
     1787     the matching LITUSE_TLS relocations.  */
     1788  if (irel + 2 >= info->relend)
     1789    return TRUE;
     1790  if (ELF64_R_TYPE (irel[1].r_info) != R_ALPHA_LITERAL
     1791      || ELF64_R_TYPE (irel[2].r_info) != R_ALPHA_LITUSE
     1792      || irel[2].r_addend != (is_gd ? LITUSE_ALPHA_TLSGD : LITUSE_ALPHA_TLSLDM))
     1793    return TRUE;
     1794
     1795  /* There must be a GPDISP relocation positioned immediately after the
     1796     LITUSE relocation.  */
     1797  gpdisp = elf64_alpha_find_reloc_at_ofs (info->relocs, info->relend,
     1798                                          irel[2].r_offset + 4, R_ALPHA_GPDISP);
     1799  if (!gpdisp)
     1800    return TRUE;
     1801
     1802  pos[0] = info->contents + irel[0].r_offset;
     1803  pos[1] = info->contents + irel[1].r_offset;
     1804  pos[2] = info->contents + irel[2].r_offset;
     1805  pos[3] = info->contents + gpdisp->r_offset;
     1806  pos[4] = pos[3] + gpdisp->r_addend;
     1807  pos1_unusable = FALSE;
     1808
     1809  /* Generally, the positions are not allowed to be out of order, lest the
     1810     modified insn sequence have different register lifetimes.  We can make
     1811     an exception when pos 1 is adjacent to pos 0.  */
     1812  if (pos[1] + 4 == pos[0])
     1813    {
     1814      bfd_byte *tmp = pos[0];
     1815      pos[0] = pos[1];
     1816      pos[1] = tmp;
     1817    }
     1818  else if (pos[1] < pos[0])
     1819    pos1_unusable = TRUE;
     1820  if (pos[1] >= pos[2] || pos[2] >= pos[3])
     1821    return TRUE;
     1822
     1823  /* Reduce the use count on the LITERAL relocation.  Do this before we
     1824     smash the symndx when we adjust the relocations below.  */
     1825  {
     1826    struct alpha_elf_got_entry *lit_gotent;
     1827    struct alpha_elf_link_hash_entry *lit_h;
     1828    unsigned long indx;
     1829
     1830    BFD_ASSERT (ELF64_R_SYM (irel[1].r_info) >= info->symtab_hdr->sh_info);
     1831    indx = ELF64_R_SYM (irel[1].r_info) - info->symtab_hdr->sh_info;
     1832    lit_h = alpha_elf_sym_hashes (info->abfd)[indx];
     1833
     1834    while (lit_h->root.root.type == bfd_link_hash_indirect
     1835           || lit_h->root.root.type == bfd_link_hash_warning)
     1836      lit_h = (struct alpha_elf_link_hash_entry *) lit_h->root.root.u.i.link;
     1837
     1838    for (lit_gotent = lit_h->got_entries; lit_gotent ;
     1839         lit_gotent = lit_gotent->next)
     1840      if (lit_gotent->gotobj == info->gotobj
     1841          && lit_gotent->reloc_type == R_ALPHA_LITERAL
     1842          && lit_gotent->addend == irel[1].r_addend)
     1843        break;
     1844    BFD_ASSERT (lit_gotent);
     1845
     1846    if (--lit_gotent->use_count == 0)
     1847      {
     1848        int sz = alpha_got_entry_size (R_ALPHA_LITERAL);
     1849        alpha_elf_tdata (info->gotobj)->total_got_size -= sz;
     1850      }
     1851  }
     1852
     1853  /* Change
     1854
     1855        lda     $16,x($gp)              !tlsgd!1
     1856        ldq     $27,__tls_get_addr($gp) !literal!1
     1857        jsr     $26,($27)__tls_get_addr !lituse_tlsgd!1
     1858        ldah    $29,0($26)              !gpdisp!2
     1859        lda     $29,0($29)              !gpdisp!2
     1860     to
     1861        ldq     $16,x($gp)              !gottprel
     1862        unop
     1863        call_pal rduniq
     1864        addq    $16,$0,$0
     1865        unop
     1866     or the first pair to
     1867        lda     $16,x($gp)              !tprel
     1868        unop
     1869     or
     1870        ldah    $16,x($gp)              !tprelhi
     1871        lda     $16,x($16)              !tprello
     1872
     1873     as appropriate.  */
     1874
     1875  use_gottprel = FALSE;
     1876  new_symndx = is_gd ? ELF64_R_SYM (irel->r_info) : 0;
     1877  switch (!dynamic && !info->link_info->shared)
     1878    {
     1879    case 1:
     1880      {
     1881        bfd_vma tp_base;
     1882        bfd_signed_vma disp;
     1883
     1884        BFD_ASSERT (info->tls_segment != NULL);
     1885        tp_base = alpha_get_tprel_base (info->tls_segment);
     1886        disp = symval - tp_base;
     1887
     1888        if (disp >= -0x8000 && disp < 0x8000)
     1889          {
     1890            insn = (OP_LDA << 26) | (16 << 21) | (31 << 16);
     1891            bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]);
     1892            bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]);
     1893
     1894            irel[0].r_offset = pos[0] - info->contents;
     1895            irel[0].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_TPREL16);
     1896            irel[1].r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
     1897            break;
     1898          }
     1899        else if (disp >= -(bfd_signed_vma) 0x80000000
     1900                 && disp < (bfd_signed_vma) 0x7fff8000
     1901                 && !pos1_unusable)
     1902          {
     1903            insn = (OP_LDAH << 26) | (16 << 21) | (31 << 16);
     1904            bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]);
     1905            insn = (OP_LDA << 26) | (16 << 21) | (16 << 16);
     1906            bfd_put_32 (info->abfd, (bfd_vma) insn, pos[1]);
     1907
     1908            irel[0].r_offset = pos[0] - info->contents;
     1909            irel[0].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_TPRELHI);
     1910            irel[1].r_offset = pos[1] - info->contents;
     1911            irel[1].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_TPRELLO);
     1912            break;
     1913          }
     1914      }
     1915      /* FALLTHRU */
     1916
     1917    default:
     1918      use_gottprel = TRUE;
     1919
     1920      insn = (OP_LDQ << 26) | (16 << 21) | (29 << 16);
     1921      bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]);
     1922      bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]);
     1923
     1924      irel[0].r_offset = pos[0] - info->contents;
     1925      irel[0].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_GOTTPREL);
     1926      irel[1].r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
     1927      break;
     1928    }
     1929
     1930  bfd_put_32 (info->abfd, (bfd_vma) INSN_RDUNIQ, pos[2]);
     1931
     1932  insn = INSN_ADDQ | (16 << 21) | (0 << 16) | (0 << 0);
     1933  bfd_put_32 (info->abfd, (bfd_vma) insn, pos[3]);
     1934
     1935  bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[4]);
     1936
     1937  irel[2].r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
     1938  gpdisp->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
     1939
     1940  hint = elf64_alpha_find_reloc_at_ofs (info->relocs, info->relend,
     1941                                        irel[2].r_offset, R_ALPHA_HINT);
     1942  if (hint)
     1943    hint->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
     1944
     1945  info->changed_contents = TRUE;
     1946  info->changed_relocs = TRUE;
     1947
     1948  /* Reduce the use count on the TLSGD/TLSLDM relocation.  */
     1949  if (--info->gotent->use_count == 0)
     1950    {
     1951      int sz = alpha_got_entry_size (info->gotent->reloc_type);
     1952      alpha_elf_tdata (info->gotobj)->total_got_size -= sz;
     1953      if (!info->h)
     1954        alpha_elf_tdata (info->gotobj)->local_got_size -= sz;
     1955    }
     1956
     1957  /* If we've switched to a GOTTPREL relocation, increment the reference
     1958     count on that got entry.  */
     1959  if (use_gottprel)
     1960    {
     1961      struct alpha_elf_got_entry *tprel_gotent;
     1962
     1963      for (tprel_gotent = *info->first_gotent; tprel_gotent ;
     1964           tprel_gotent = tprel_gotent->next)
     1965        if (tprel_gotent->gotobj == info->gotobj
     1966            && tprel_gotent->reloc_type == R_ALPHA_GOTTPREL
     1967            && tprel_gotent->addend == irel->r_addend)
     1968          break;
     1969      if (tprel_gotent)
     1970        tprel_gotent->use_count++;
     1971      else
     1972        {
     1973          if (info->gotent->use_count == 0)
     1974            tprel_gotent = info->gotent;
     1975          else
     1976            {
     1977              tprel_gotent = (struct alpha_elf_got_entry *)
     1978                bfd_alloc (info->abfd, sizeof (struct alpha_elf_got_entry));
     1979              if (!tprel_gotent)
     1980                return FALSE;
     1981
     1982              tprel_gotent->next = *info->first_gotent;
     1983              *info->first_gotent = tprel_gotent;
     1984
     1985              tprel_gotent->gotobj = info->gotobj;
     1986              tprel_gotent->addend = irel->r_addend;
     1987              tprel_gotent->got_offset = -1;
     1988              tprel_gotent->reloc_done = 0;
     1989              tprel_gotent->reloc_xlated = 0;
     1990            }
     1991
     1992          tprel_gotent->use_count = 1;
     1993          tprel_gotent->reloc_type = R_ALPHA_GOTTPREL;
     1994        }
     1995    }
     1996
     1997  return TRUE;
     1998}
     1999
     2000static struct elf_link_tls_segment *
     2001elf64_alpha_relax_find_tls_segment (info, seg)
     2002     struct alpha_relax_info *info;
     2003     struct elf_link_tls_segment *seg;
     2004{
     2005  bfd *output_bfd = info->sec->output_section->owner;
     2006  asection *o;
     2007  unsigned int align;
     2008  bfd_vma base, end;
     2009
     2010  for (o = output_bfd->sections; o ; o = o->next)
     2011    if ((o->flags & SEC_THREAD_LOCAL) != 0
     2012        && (o->flags & SEC_LOAD) != 0)
     2013      break;
     2014  if (!o)
     2015    return NULL;
     2016
     2017  base = o->vma;
     2018  align = 0;
     2019
     2020  do
     2021    {
     2022      bfd_vma size;
     2023
     2024      if (bfd_get_section_alignment (output_bfd, o) > align)
     2025        align = bfd_get_section_alignment (output_bfd, o);
     2026
     2027      size = o->_raw_size;
     2028      if (size == 0 && (o->flags & SEC_HAS_CONTENTS) == 0)
     2029        {
     2030          struct bfd_link_order *lo;
     2031          for (lo = o->link_order_head; lo ; lo = lo->next)
     2032            if (size < lo->offset + lo->size)
     2033              size = lo->offset + lo->size;
     2034        }
     2035      end = o->vma + size;
     2036      o = o->next;
     2037    }
     2038  while (o && (o->flags & SEC_THREAD_LOCAL));
     2039
     2040  seg->start = base;
     2041  seg->size = end - base;
     2042  seg->align = align;
     2043
     2044  return seg;
     2045}
     2046
     2047static bfd_boolean
    14702048elf64_alpha_relax_section (abfd, sec, link_info, again)
    14712049     bfd *abfd;
    14722050     asection *sec;
    14732051     struct bfd_link_info *link_info;
    1474      boolean *again;
     2052     bfd_boolean *again;
    14752053{
    14762054  Elf_Internal_Shdr *symtab_hdr;
    14772055  Elf_Internal_Rela *internal_relocs;
    1478   Elf_Internal_Rela *free_relocs = NULL;
    14792056  Elf_Internal_Rela *irel, *irelend;
    1480   bfd_byte *free_contents = NULL;
    1481   Elf64_External_Sym *extsyms = NULL;
    1482   Elf64_External_Sym *free_extsyms = NULL;
     2057  Elf_Internal_Sym *isymbuf = NULL;
    14832058  struct alpha_elf_got_entry **local_got_entries;
    14842059  struct alpha_relax_info info;
     2060  struct elf_link_tls_segment tls_segment;
    14852061
    14862062  /* We are not currently changing any sizes, so only one pass.  */
    1487   *again = false;
     2063  *again = FALSE;
    14882064
    14892065  if (link_info->relocateable
    14902066      || (sec->flags & SEC_RELOC) == 0
    14912067      || sec->reloc_count == 0)
    1492     return true;
     2068    return TRUE;
    14932069
    14942070  /* If this is the first time we have been called for this section,
     
    15052081                      link_info->keep_memory));
    15062082  if (internal_relocs == NULL)
    1507     goto error_return;
    1508   if (! link_info->keep_memory)
    1509     free_relocs = internal_relocs;
     2083    return FALSE;
    15102084
    15112085  memset(&info, 0, sizeof (info));
     
    15132087  info.sec = sec;
    15142088  info.link_info = link_info;
     2089  info.symtab_hdr = symtab_hdr;
    15152090  info.relocs = internal_relocs;
    15162091  info.relend = irelend = internal_relocs + sec->reloc_count;
    15172092
    1518   /* Find the GP for this object.  */
     2093  /* Find the GP for this object.  Do not store the result back via
     2094     _bfd_set_gp_value, since this could change again before final.  */
    15192095  info.gotobj = alpha_elf_tdata (abfd)->gotobj;
    15202096  if (info.gotobj)
    15212097    {
    15222098      asection *sgot = alpha_elf_tdata (info.gotobj)->got;
    1523       info.gp = _bfd_get_gp_value (info.gotobj);
    1524       if (info.gp == 0)
    1525         {
    1526           info.gp = (sgot->output_section->vma
    1527                      + sgot->output_offset
    1528                      + 0x8000);
    1529           _bfd_set_gp_value (info.gotobj, info.gp);
    1530         }
    1531     }
     2099      info.gp = (sgot->output_section->vma
     2100                 + sgot->output_offset
     2101                 + 0x8000);
     2102    }
     2103
     2104  /* Get the section contents.  */
     2105  if (elf_section_data (sec)->this_hdr.contents != NULL)
     2106    info.contents = elf_section_data (sec)->this_hdr.contents;
     2107  else
     2108    {
     2109      info.contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
     2110      if (info.contents == NULL)
     2111        goto error_return;
     2112
     2113      if (! bfd_get_section_contents (abfd, sec, info.contents,
     2114                                      (file_ptr) 0, sec->_raw_size))
     2115        goto error_return;
     2116    }
     2117
     2118  /* Compute the TLS segment information.  The version normally found in
     2119     elf_hash_table (link_info)->tls_segment isn't built until final_link.
     2120     ??? Probably should look into extracting this into a common function.  */
     2121  info.tls_segment = elf64_alpha_relax_find_tls_segment (&info, &tls_segment);
    15322122
    15332123  for (irel = internal_relocs; irel < irelend; irel++)
    15342124    {
    15352125      bfd_vma symval;
    1536       Elf_Internal_Sym isym;
    15372126      struct alpha_elf_got_entry *gotent;
    1538 
    1539       if (ELF64_R_TYPE (irel->r_info) != (int) R_ALPHA_LITERAL)
    1540         continue;
    1541 
    1542       /* Get the section contents.  */
    1543       if (info.contents == NULL)
    1544         {
    1545           if (elf_section_data (sec)->this_hdr.contents != NULL)
    1546             info.contents = elf_section_data (sec)->this_hdr.contents;
     2127      unsigned long r_type = ELF64_R_TYPE (irel->r_info);
     2128      unsigned long r_symndx = ELF64_R_SYM (irel->r_info);
     2129
     2130      /* Early exit for unhandled or unrelaxable relocations.  */
     2131      switch (r_type)
     2132        {
     2133        case R_ALPHA_LITERAL:
     2134        case R_ALPHA_GPRELHIGH:
     2135        case R_ALPHA_GPRELLOW:
     2136        case R_ALPHA_GOTDTPREL:
     2137        case R_ALPHA_GOTTPREL:
     2138        case R_ALPHA_TLSGD:
     2139          break;
     2140
     2141        case R_ALPHA_TLSLDM:
     2142          /* The symbol for a TLSLDM reloc is ignored.  Collapse the
     2143             reloc to the 0 symbol so that they all match.  */
     2144          r_symndx = 0;
     2145          break;
     2146
     2147        default:
     2148          continue;
     2149        }
     2150
     2151      /* Get the value of the symbol referred to by the reloc.  */
     2152      if (r_symndx < symtab_hdr->sh_info)
     2153        {
     2154          /* A local symbol.  */
     2155          Elf_Internal_Sym *isym;
     2156
     2157          /* Read this BFD's local symbols.  */
     2158          if (isymbuf == NULL)
     2159            {
     2160              isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
     2161              if (isymbuf == NULL)
     2162                isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
     2163                                                symtab_hdr->sh_info, 0,
     2164                                                NULL, NULL, NULL);
     2165              if (isymbuf == NULL)
     2166                goto error_return;
     2167            }
     2168
     2169          isym = isymbuf + r_symndx;
     2170
     2171          /* Given the symbol for a TLSLDM reloc is ignored, this also
     2172             means forcing the symbol value to the tp base.  */
     2173          if (r_type == R_ALPHA_TLSLDM)
     2174            {
     2175              info.tsec = bfd_abs_section_ptr;
     2176              symval = alpha_get_tprel_base (info.tls_segment);
     2177            }
    15472178          else
    15482179            {
    1549               info.contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
    1550               if (info.contents == NULL)
    1551                 goto error_return;
    1552               free_contents = info.contents;
    1553 
    1554               if (! bfd_get_section_contents (abfd, sec, info.contents,
    1555                                               (file_ptr) 0, sec->_raw_size))
    1556                 goto error_return;
     2180              symval = isym->st_value;
     2181              if (isym->st_shndx == SHN_UNDEF)
     2182                continue;
     2183              else if (isym->st_shndx == SHN_ABS)
     2184                info.tsec = bfd_abs_section_ptr;
     2185              else if (isym->st_shndx == SHN_COMMON)
     2186                info.tsec = bfd_com_section_ptr;
     2187              else
     2188                info.tsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
    15572189            }
    1558         }
    1559 
    1560       /* Read this BFD's symbols if we haven't done so already.  */
    1561       if (extsyms == NULL)
    1562         {
    1563           if (symtab_hdr->contents != NULL)
    1564             extsyms = (Elf64_External_Sym *) symtab_hdr->contents;
     2190
     2191          info.h = NULL;
     2192          info.other = isym->st_other;
     2193          if (local_got_entries)
     2194            info.first_gotent = &local_got_entries[r_symndx];
    15652195          else
    15662196            {
    1567               extsyms = ((Elf64_External_Sym *)
    1568                          bfd_malloc (symtab_hdr->sh_size));
    1569               if (extsyms == NULL)
    1570                 goto error_return;
    1571               free_extsyms = extsyms;
    1572               if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
    1573                   || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
    1574                       != symtab_hdr->sh_size))
    1575                 goto error_return;
     2197              info.first_gotent = &info.gotent;
     2198              info.gotent = NULL;
    15762199            }
    1577         }
    1578 
    1579       /* Get the value of the symbol referred to by the reloc.  */
    1580       if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
    1581         {
    1582           /* A local symbol.  */
    1583           bfd_elf64_swap_symbol_in (abfd,
    1584                                     extsyms + ELF64_R_SYM (irel->r_info),
    1585                                     &isym);
    1586           if (isym.st_shndx == SHN_UNDEF)
    1587             info.tsec = bfd_und_section_ptr;
    1588           else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)
    1589             info.tsec = bfd_section_from_elf_index (abfd, isym.st_shndx);
    1590           else if (isym.st_shndx == SHN_ABS)
    1591             info.tsec = bfd_abs_section_ptr;
    1592           else if (isym.st_shndx == SHN_COMMON)
    1593             info.tsec = bfd_com_section_ptr;
    1594           else
    1595             continue;   /* who knows.  */
    1596 
    1597           info.h = NULL;
    1598           info.other = isym.st_other;
    1599           gotent = local_got_entries[ELF64_R_SYM(irel->r_info)];
    1600           symval = isym.st_value;
    16012200        }
    16022201      else
     
    16052204          struct alpha_elf_link_hash_entry *h;
    16062205
    1607           indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
     2206          indx = r_symndx - symtab_hdr->sh_info;
    16082207          h = alpha_elf_sym_hashes (abfd)[indx];
    16092208          BFD_ASSERT (h != NULL);
     
    16132212            h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
    16142213
    1615           /* We can't do anthing with undefined or dynamic symbols.  */
    1616           if (h->root.root.type == bfd_link_hash_undefined
    1617               || h->root.root.type == bfd_link_hash_undefweak
    1618               || alpha_elf_dynamic_symbol_p (&h->root, link_info))
     2214          /* If the symbol is undefined, we can't do anything with it.  */
     2215          if (h->root.root.type == bfd_link_hash_undefweak
     2216              || h->root.root.type == bfd_link_hash_undefined)
    16192217            continue;
    16202218
     2219          /* If the symbol isn't defined in the current module, again
     2220             we can't do anything.  */
     2221          if (!(h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
     2222            {
     2223              /* Except for TLSGD relocs, which can sometimes be
     2224                 relaxed to GOTTPREL relocs.  */
     2225              if (r_type != R_ALPHA_TLSGD)
     2226                continue;
     2227              info.tsec = bfd_abs_section_ptr;
     2228              symval = 0;
     2229            }
     2230          else
     2231            {
     2232              info.tsec = h->root.root.u.def.section;
     2233              symval = h->root.root.u.def.value;
     2234            }
     2235
    16212236          info.h = h;
    1622           info.gotent = gotent;
    1623           info.tsec = h->root.root.u.def.section;
    16242237          info.other = h->root.other;
    1625           gotent = h->got_entries;
    1626           symval = h->root.root.u.def.value;
     2238          info.first_gotent = &h->got_entries;
    16272239        }
    16282240
    16292241      /* Search for the got entry to be used by this relocation.  */
    1630       while (gotent->gotobj != info.gotobj || gotent->addend != irel->r_addend)
    1631         gotent = gotent->next;
     2242      for (gotent = *info.first_gotent; gotent ; gotent = gotent->next)
     2243        if (gotent->gotobj == info.gotobj
     2244            && gotent->reloc_type == r_type
     2245            && gotent->addend == irel->r_addend)
     2246          break;
    16322247      info.gotent = gotent;
    16332248
     
    16352250      symval += irel->r_addend;
    16362251
    1637       BFD_ASSERT(info.gotent != NULL);
    1638 
    1639       /* If there exist LITUSE relocations immediately following, this
    1640          opens up all sorts of interesting optimizations, because we
    1641          now know every location that this address load is used.  */
    1642 
    1643       if (irel+1 < irelend && ELF64_R_TYPE (irel[1].r_info) == R_ALPHA_LITUSE)
    1644         {
    1645           irel = elf64_alpha_relax_with_lituse (&info, symval, irel, irelend);
    1646           if (irel == NULL)
     2252      switch (r_type)
     2253        {
     2254        case R_ALPHA_LITERAL:
     2255          BFD_ASSERT(info.gotent != NULL);
     2256
     2257          /* If there exist LITUSE relocations immediately following, this
     2258             opens up all sorts of interesting optimizations, because we
     2259             now know every location that this address load is used.  */
     2260          if (irel+1 < irelend
     2261              && ELF64_R_TYPE (irel[1].r_info) == R_ALPHA_LITUSE)
     2262            {
     2263              if (!elf64_alpha_relax_with_lituse (&info, symval, irel))
     2264                goto error_return;
     2265            }
     2266          else
     2267            {
     2268              if (!elf64_alpha_relax_got_load (&info, symval, irel, r_type))
     2269                goto error_return;
     2270            }
     2271          break;
     2272
     2273        case R_ALPHA_GPRELHIGH:
     2274        case R_ALPHA_GPRELLOW:
     2275          if (!elf64_alpha_relax_gprelhilo (&info, symval, irel,
     2276                                            r_type == R_ALPHA_GPRELHIGH))
    16472277            goto error_return;
    1648         }
     2278          break;
     2279
     2280        case R_ALPHA_GOTDTPREL:
     2281        case R_ALPHA_GOTTPREL:
     2282          BFD_ASSERT(info.gotent != NULL);
     2283          if (!elf64_alpha_relax_got_load (&info, symval, irel, r_type))
     2284            goto error_return;
     2285          break;
     2286
     2287        case R_ALPHA_TLSGD:
     2288        case R_ALPHA_TLSLDM:
     2289          BFD_ASSERT(info.gotent != NULL);
     2290          if (!elf64_alpha_relax_tls_get_addr (&info, symval, irel,
     2291                                               r_type == R_ALPHA_TLSGD))
     2292            goto error_return;
     2293          break;
     2294        }
     2295    }
     2296
     2297  if (!elf64_alpha_size_plt_section (link_info))
     2298    return FALSE;
     2299  if (!elf64_alpha_size_got_sections (link_info))
     2300    return FALSE;
     2301  if (!elf64_alpha_size_rela_got_section (link_info))
     2302    return FALSE;
     2303
     2304  if (isymbuf != NULL
     2305      && symtab_hdr->contents != (unsigned char *) isymbuf)
     2306    {
     2307      if (!link_info->keep_memory)
     2308        free (isymbuf);
    16492309      else
    16502310        {
    1651           if (!elf64_alpha_relax_without_lituse (&info, symval, irel))
    1652             goto error_return;
    1653         }
    1654     }
    1655 
    1656   if (!elf64_alpha_size_got_sections (abfd, link_info))
    1657     return false;
    1658 
    1659   if (info.changed_relocs)
    1660     {
    1661       elf_section_data (sec)->relocs = internal_relocs;
    1662     }
    1663   else if (free_relocs != NULL)
    1664     {
    1665       free (free_relocs);
    1666     }
    1667 
    1668   if (info.changed_contents)
    1669     {
    1670       elf_section_data (sec)->this_hdr.contents = info.contents;
    1671     }
    1672   else if (free_contents != NULL)
    1673     {
    1674       if (! link_info->keep_memory)
    1675         free (free_contents);
     2311          /* Cache the symbols for elf_link_input_bfd.  */
     2312          symtab_hdr->contents = (unsigned char *) isymbuf;
     2313        }
     2314    }
     2315
     2316  if (info.contents != NULL
     2317      && elf_section_data (sec)->this_hdr.contents != info.contents)
     2318    {
     2319      if (!info.changed_contents && !link_info->keep_memory)
     2320        free (info.contents);
    16762321      else
    16772322        {
     
    16812326    }
    16822327
    1683   if (free_extsyms != NULL)
    1684     {
    1685       if (! link_info->keep_memory)
    1686         free (free_extsyms);
     2328  if (elf_section_data (sec)->relocs != internal_relocs)
     2329    {
     2330      if (!info.changed_relocs)
     2331        free (internal_relocs);
    16872332      else
    1688         {
    1689           /* Cache the symbols for elf_link_input_bfd.  */
    1690           symtab_hdr->contents = extsyms;
    1691         }
     2333        elf_section_data (sec)->relocs = internal_relocs;
    16922334    }
    16932335
    16942336  *again = info.changed_contents || info.changed_relocs;
    16952337
    1696   return true;
     2338  return TRUE;
    16972339
    16982340 error_return:
    1699   if (free_relocs != NULL)
    1700     free (free_relocs);
    1701   if (free_contents != NULL)
    1702     free (free_contents);
    1703   if (free_extsyms != NULL)
    1704     free (free_extsyms);
    1705   return false;
     2341  if (isymbuf != NULL
     2342      && symtab_hdr->contents != (unsigned char *) isymbuf)
     2343    free (isymbuf);
     2344  if (info.contents != NULL
     2345      && elf_section_data (sec)->this_hdr.contents != info.contents)
     2346    free (info.contents);
     2347  if (internal_relocs != NULL
     2348      && elf_section_data (sec)->relocs != internal_relocs)
     2349    free (internal_relocs);
     2350  return FALSE;
    17062351}
    17072352
     
    17092354/* PLT/GOT Stuff */
    17102355#define PLT_HEADER_SIZE 32
    1711 #define PLT_HEADER_WORD1        0xc3600000      /* br   $27,.+4     */
    1712 #define PLT_HEADER_WORD2        0xa77b000c      /* ldq  $27,12($27) */
    1713 #define PLT_HEADER_WORD3        0x47ff041f      /* nop              */
    1714 #define PLT_HEADER_WORD4        0x6b7b0000      /* jmp  $27,($27)   */
     2356#define PLT_HEADER_WORD1        (bfd_vma) 0xc3600000    /* br   $27,.+4     */
     2357#define PLT_HEADER_WORD2        (bfd_vma) 0xa77b000c    /* ldq  $27,12($27) */
     2358#define PLT_HEADER_WORD3        (bfd_vma) 0x47ff041f    /* nop              */
     2359#define PLT_HEADER_WORD4        (bfd_vma) 0x6b7b0000    /* jmp  $27,($27)   */
    17152360
    17162361#define PLT_ENTRY_SIZE 12
     
    17192364#define PLT_ENTRY_WORD3         0
    17202365
    1721 #define MAX_GOT_ENTRIES         (64*1024 / 8)
     2366#define MAX_GOT_SIZE            (64*1024)
    17222367
    17232368#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so"
     
    17292374   how to.  */
    17302375
    1731 static boolean
     2376static bfd_boolean
    17322377elf64_alpha_section_from_shdr (abfd, hdr, name)
    17332378     bfd *abfd;
    1734      Elf64_Internal_Shdr *hdr;
    1735      char *name;
     2379     Elf_Internal_Shdr *hdr;
     2380     const char *name;
    17362381{
    17372382  asection *newsect;
     
    17462391    case SHT_ALPHA_DEBUG:
    17472392      if (strcmp (name, ".mdebug") != 0)
    1748         return false;
     2393        return FALSE;
    17492394      break;
    1750 #ifdef ERIC_neverdef
    1751     case SHT_ALPHA_REGINFO:
    1752       if (strcmp (name, ".reginfo") != 0
    1753           || hdr->sh_size != sizeof (Elf64_External_RegInfo))
    1754         return false;
    1755       break;
    1756 #endif
    17572395    default:
    1758       return false;
     2396      return FALSE;
    17592397    }
    17602398
    17612399  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
    1762     return false;
     2400    return FALSE;
    17632401  newsect = hdr->bfd_section;
    17642402
     
    17682406                                   (bfd_get_section_flags (abfd, newsect)
    17692407                                    | SEC_DEBUGGING)))
    1770         return false;
    1771     }
    1772 
    1773 #ifdef ERIC_neverdef
    1774   /* For a .reginfo section, set the gp value in the tdata information
    1775      from the contents of this section.  We need the gp value while
    1776      processing relocs, so we just get it now.  */
    1777   if (hdr->sh_type == SHT_ALPHA_REGINFO)
    1778     {
    1779       Elf64_External_RegInfo ext;
    1780       Elf64_RegInfo s;
    1781 
    1782       if (! bfd_get_section_contents (abfd, newsect, (PTR) &ext,
    1783                                       (file_ptr) 0, sizeof ext))
    1784         return false;
    1785       bfd_alpha_elf64_swap_reginfo_in (abfd, &ext, &s);
    1786       elf_gp (abfd) = s.ri_gp_value;
    1787     }
    1788 #endif
    1789 
    1790   return true;
     2408        return FALSE;
     2409    }
     2410
     2411  return TRUE;
     2412}
     2413
     2414/* Convert Alpha specific section flags to bfd internal section flags.  */
     2415
     2416static bfd_boolean
     2417elf64_alpha_section_flags (flags, hdr)
     2418     flagword *flags;
     2419     Elf_Internal_Shdr *hdr;
     2420{
     2421  if (hdr->sh_flags & SHF_ALPHA_GPREL)
     2422    *flags |= SEC_SMALL_DATA;
     2423
     2424  return TRUE;
    17912425}
    17922426
     
    17942428   section name, which is a hack, but ought to work.  */
    17952429
    1796 static boolean
     2430static bfd_boolean
    17972431elf64_alpha_fake_sections (abfd, hdr, sec)
    17982432     bfd *abfd;
    1799      Elf64_Internal_Shdr *hdr;
     2433     Elf_Internal_Shdr *hdr;
    18002434     asection *sec;
    18012435{
     
    18142448        hdr->sh_entsize = 1;
    18152449    }
    1816 #ifdef ERIC_neverdef
    1817   else if (strcmp (name, ".reginfo") == 0)
    1818     {
    1819       hdr->sh_type = SHT_ALPHA_REGINFO;
    1820       /* In a shared object on Irix 5.3, the .reginfo section has an
    1821          entsize of 0x18.  FIXME: Does this matter?  */
    1822       if ((abfd->flags & DYNAMIC) != 0)
    1823         hdr->sh_entsize = sizeof (Elf64_External_RegInfo);
    1824       else
    1825         hdr->sh_entsize = 1;
    1826 
    1827       /* Force the section size to the correct value, even if the
    1828          linker thinks it is larger.  The link routine below will only
    1829          write out this much data for .reginfo.  */
    1830       hdr->sh_size = sec->_raw_size = sizeof (Elf64_External_RegInfo);
    1831     }
    1832   else if (strcmp (name, ".hash") == 0
    1833            || strcmp (name, ".dynamic") == 0
    1834            || strcmp (name, ".dynstr") == 0)
    1835     {
    1836       hdr->sh_entsize = 0;
    1837       hdr->sh_info = SIZEOF_ALPHA_DYNSYM_SECNAMES;
    1838     }
    1839 #endif
    1840   else if (strcmp (name, ".sdata") == 0
     2450  else if ((sec->flags & SEC_SMALL_DATA)
     2451           || strcmp (name, ".sdata") == 0
    18412452           || strcmp (name, ".sbss") == 0
    18422453           || strcmp (name, ".lit4") == 0
     
    18442455    hdr->sh_flags |= SHF_ALPHA_GPREL;
    18452456
    1846   return true;
     2457  return TRUE;
    18472458}
    18482459
     
    18502461   file.  We use it to put .comm items in .sbss, and not .bss.  */
    18512462
    1852 static boolean
     2463static bfd_boolean
    18532464elf64_alpha_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
    18542465     bfd *abfd;
     
    18622473  if (sym->st_shndx == SHN_COMMON
    18632474      && !info->relocateable
    1864       && sym->st_size <= bfd_get_gp_size (abfd))
     2475      && sym->st_size <= elf_gp_size (abfd))
    18652476    {
    18662477      /* Common symbols less than or equal to -G nn bytes are
     
    18762487                                                       | SEC_IS_COMMON
    18772488                                                       | SEC_LINKER_CREATED)))
    1878             return false;
     2489            return FALSE;
    18792490        }
    18802491
     
    18832494    }
    18842495
    1885   return true;
     2496  return TRUE;
    18862497}
    18872498
    18882499/* Create the .got section.  */
    18892500
    1890 static boolean
     2501static bfd_boolean
    18912502elf64_alpha_create_got_section(abfd, info)
    18922503     bfd *abfd;
     
    18962507
    18972508  if (bfd_get_section_by_name (abfd, ".got"))
    1898     return true;
     2509    return TRUE;
    18992510
    19002511  s = bfd_make_section (abfd, ".got");
     
    19052516                                           | SEC_LINKER_CREATED))
    19062517      || !bfd_set_section_alignment (abfd, s, 3))
    1907     return false;
     2518    return FALSE;
    19082519
    19092520  alpha_elf_tdata (abfd)->got = s;
    19102521
    1911   return true;
     2522  return TRUE;
    19122523}
    19132524
    19142525/* Create all the dynamic sections.  */
    19152526
    1916 static boolean
     2527static bfd_boolean
    19172528elf64_alpha_create_dynamic_sections (abfd, info)
    19182529     bfd *abfd;
     
    19212532  asection *s;
    19222533  struct elf_link_hash_entry *h;
     2534  struct bfd_link_hash_entry *bh;
    19232535
    19242536  /* We need to create .plt, .rela.plt, .got, and .rela.got sections.  */
     
    19322544                                            | SEC_CODE))
    19332545      || ! bfd_set_section_alignment (abfd, s, 3))
    1934     return false;
     2546    return FALSE;
    19352547
    19362548  /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
    19372549     .plt section.  */
    1938   h = NULL;
     2550  bh = NULL;
    19392551  if (! (_bfd_generic_link_add_one_symbol
    19402552         (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
    1941           (bfd_vma) 0, (const char *) NULL, false,
    1942           get_elf_backend_data (abfd)->collect,
    1943           (struct bfd_link_hash_entry **) &h)))
    1944     return false;
     2553          (bfd_vma) 0, (const char *) NULL, FALSE,
     2554          get_elf_backend_data (abfd)->collect, &bh)))
     2555    return FALSE;
     2556  h = (struct elf_link_hash_entry *) bh;
    19452557  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
    19462558  h->type = STT_OBJECT;
     
    19482560  if (info->shared
    19492561      && ! _bfd_elf_link_record_dynamic_symbol (info, h))
    1950     return false;
     2562    return FALSE;
    19512563
    19522564  s = bfd_make_section (abfd, ".rela.plt");
     
    19582570                                           | SEC_READONLY))
    19592571      || ! bfd_set_section_alignment (abfd, s, 3))
    1960     return false;
     2572    return FALSE;
    19612573
    19622574  /* We may or may not have created a .got section for this object, but
     
    19642576
    19652577  if (!elf64_alpha_create_got_section (abfd, info))
    1966     return false;
     2578    return FALSE;
    19672579
    19682580  s = bfd_make_section(abfd, ".rela.got");
     
    19742586                                           | SEC_READONLY))
    19752587      || !bfd_set_section_alignment (abfd, s, 3))
    1976     return false;
     2588    return FALSE;
    19772589
    19782590  /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the
     
    19802592     because we don't want to define the symbol if we are not creating
    19812593     a global offset table.  */
    1982   h = NULL;
     2594  bh = NULL;
    19832595  if (!(_bfd_generic_link_add_one_symbol
    19842596        (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL,
    19852597         alpha_elf_tdata(abfd)->got, (bfd_vma) 0, (const char *) NULL,
    1986          false, get_elf_backend_data (abfd)->collect,
    1987          (struct bfd_link_hash_entry **) &h)))
    1988     return false;
     2598         FALSE, get_elf_backend_data (abfd)->collect, &bh)))
     2599    return FALSE;
     2600  h = (struct elf_link_hash_entry *) bh;
    19892601  h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
    19902602  h->type = STT_OBJECT;
     
    19922604  if (info->shared
    19932605      && ! _bfd_elf_link_record_dynamic_symbol (info, h))
    1994     return false;
     2606    return FALSE;
    19952607
    19962608  elf_hash_table (info)->hgot = h;
    19972609
    1998   return true;
     2610  return TRUE;
    19992611}
    20002612
     
    20032615   ecoff_debug_info structure.  */
    20042616
    2005 static boolean
     2617static bfd_boolean
    20062618elf64_alpha_read_ecoff_info (abfd, section, debug)
    20072619     bfd *abfd;
     
    20162628  memset (debug, 0, sizeof (*debug));
    20172629
    2018   ext_hdr = (char *) bfd_malloc ((size_t) swap->external_hdr_size);
     2630  ext_hdr = (char *) bfd_malloc (swap->external_hdr_size);
    20192631  if (ext_hdr == NULL && swap->external_hdr_size != 0)
    20202632    goto error_return;
    20212633
    2022   if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0,
    2023                                 swap->external_hdr_size)
    2024       == false)
     2634  if (! bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0,
     2635                                  swap->external_hdr_size))
    20252636    goto error_return;
    20262637
     
    20352646  else                                                                  \
    20362647    {                                                                   \
    2037       debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
     2648      bfd_size_type amt = (bfd_size_type) size * symhdr->count;         \
     2649      debug->ptr = (type) bfd_malloc (amt);                             \
    20382650      if (debug->ptr == NULL)                                           \
    20392651        goto error_return;                                              \
    20402652      if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0     \
    2041           || (bfd_read (debug->ptr, size, symhdr->count,                \
    2042                         abfd) != size * symhdr->count))                 \
     2653          || bfd_bread (debug->ptr, amt, abfd) != amt)                  \
    20432654        goto error_return;                                              \
    20442655    }
     
    20612672  debug->adjust = NULL;
    20622673
    2063   return true;
     2674  return TRUE;
    20642675
    20652676 error_return:
     
    20882699  if (debug->external_ext != NULL)
    20892700    free (debug->external_ext);
    2090   return false;
     2701  return FALSE;
    20912702}
    20922703
    20932704/* Alpha ELF local labels start with '$'.  */
    20942705
    2095 static boolean
     2706static bfd_boolean
    20962707elf64_alpha_is_local_label_name (abfd, name)
    20972708     bfd *abfd ATTRIBUTE_UNUSED;
     
    21122723};
    21132724
    2114 static boolean
     2725static bfd_boolean
    21152726elf64_alpha_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
    21162727                               functionname_ptr, line_ptr)
     
    21292740                                     line_ptr, 0,
    21302741                                     &elf_tdata (abfd)->dwarf2_find_line_info))
    2131     return true;
     2742    return TRUE;
    21322743
    21332744  msec = bfd_get_section_by_name (abfd, ".mdebug");
     
    21532764          char *fraw_end;
    21542765          struct fdr *fdr_ptr;
    2155 
    2156           fi = ((struct mips_elf_find_line *)
    2157                 bfd_zalloc (abfd, sizeof (struct mips_elf_find_line)));
     2766          bfd_size_type amt = sizeof (struct mips_elf_find_line);
     2767
     2768          fi = (struct mips_elf_find_line *) bfd_zalloc (abfd, amt);
    21582769          if (fi == NULL)
    21592770            {
    21602771              msec->flags = origflags;
    2161               return false;
     2772              return FALSE;
    21622773            }
    21632774
     
    21652776            {
    21662777              msec->flags = origflags;
    2167               return false;
     2778              return FALSE;
    21682779            }
    21692780
    21702781          /* Swap in the FDR information.  */
    2171           fi->d.fdr = ((struct fdr *)
    2172                        bfd_alloc (abfd,
    2173                                   (fi->d.symbolic_header.ifdMax *
    2174                                    sizeof (struct fdr))));
     2782          amt = fi->d.symbolic_header.ifdMax * sizeof (struct fdr);
     2783          fi->d.fdr = (struct fdr *) bfd_alloc (abfd, amt);
    21752784          if (fi->d.fdr == NULL)
    21762785            {
    21772786              msec->flags = origflags;
    2178               return false;
     2787              return FALSE;
    21792788            }
    21802789          external_fdr_size = swap->external_fdr_size;
     
    22012810        {
    22022811          msec->flags = origflags;
    2203           return true;
     2812          return TRUE;
    22042813        }
    22052814
     
    22232832  struct ecoff_debug_info *debug;
    22242833  const struct ecoff_debug_swap *swap;
    2225   boolean failed;
     2834  bfd_boolean failed;
    22262835};
    22272836
    2228 static boolean
     2837static bfd_boolean
    22292838elf64_alpha_output_extsym (h, data)
    22302839     struct alpha_elf_link_hash_entry *h;
     
    22322841{
    22332842  struct extsym_info *einfo = (struct extsym_info *) data;
    2234   boolean strip;
     2843  bfd_boolean strip;
    22352844  asection *sec, *output_section;
    22362845
     2846  if (h->root.root.type == bfd_link_hash_warning)
     2847    h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link;
     2848
    22372849  if (h->root.indx == -2)
    2238     strip = false;
     2850    strip = FALSE;
    22392851  else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
    2240            || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
    2241           && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
    2242           && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
    2243     strip = true;
     2852            || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
     2853           && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
     2854           && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
     2855    strip = TRUE;
    22442856  else if (einfo->info->strip == strip_all
    2245           || (einfo->info->strip == strip_some
    2246               && bfd_hash_lookup (einfo->info->keep_hash,
    2247                                   h->root.root.root.string,
    2248                                   false, false) == NULL))
    2249     strip = true;
     2857           || (einfo->info->strip == strip_some
     2858               && bfd_hash_lookup (einfo->info->keep_hash,
     2859                                   h->root.root.root.string,
     2860                                   FALSE, FALSE) == NULL))
     2861    strip = TRUE;
    22502862  else
    2251     strip = false;
     2863    strip = FALSE;
    22522864
    22532865  if (strip)
    2254     return true;
     2866    return TRUE;
    22552867
    22562868  if (h->esym.ifd == -2)
     
    22652877
    22662878      if (h->root.root.type != bfd_link_hash_defined
    2267          && h->root.root.type != bfd_link_hash_defweak)
    2268        h->esym.asym.sc = scAbs;
     2879          && h->root.root.type != bfd_link_hash_defweak)
     2880        h->esym.asym.sc = scAbs;
    22692881      else
    2270        {
    2271          const char *name;
    2272 
    2273          sec = h->root.root.u.def.section;
    2274          output_section = sec->output_section;
    2275 
    2276          /* When making a shared library and symbol h is the one from
    2277             the another shared library, OUTPUT_SECTION may be null.  */
    2278          if (output_section == NULL)
    2279            h->esym.asym.sc = scUndefined;
    2280          else
    2281            {
    2282              name = bfd_section_name (output_section->owner, output_section);
    2283 
    2284              if (strcmp (name, ".text") == 0)
    2285                h->esym.asym.sc = scText;
    2286              else if (strcmp (name, ".data") == 0)
    2287                h->esym.asym.sc = scData;
    2288              else if (strcmp (name, ".sdata") == 0)
    2289                h->esym.asym.sc = scSData;
    2290              else if (strcmp (name, ".rodata") == 0
    2291                       || strcmp (name, ".rdata") == 0)
    2292                h->esym.asym.sc = scRData;
    2293              else if (strcmp (name, ".bss") == 0)
    2294                h->esym.asym.sc = scBss;
    2295              else if (strcmp (name, ".sbss") == 0)
    2296                h->esym.asym.sc = scSBss;
    2297              else if (strcmp (name, ".init") == 0)
    2298                h->esym.asym.sc = scInit;
    2299              else if (strcmp (name, ".fini") == 0)
    2300                h->esym.asym.sc = scFini;
    2301              else
    2302                h->esym.asym.sc = scAbs;
    2303            }
    2304        }
     2882        {
     2883          const char *name;
     2884
     2885          sec = h->root.root.u.def.section;
     2886          output_section = sec->output_section;
     2887
     2888          /* When making a shared library and symbol h is the one from
     2889             the another shared library, OUTPUT_SECTION may be null.  */
     2890          if (output_section == NULL)
     2891            h->esym.asym.sc = scUndefined;
     2892          else
     2893            {
     2894              name = bfd_section_name (output_section->owner, output_section);
     2895
     2896              if (strcmp (name, ".text") == 0)
     2897                h->esym.asym.sc = scText;
     2898              else if (strcmp (name, ".data") == 0)
     2899                h->esym.asym.sc = scData;
     2900              else if (strcmp (name, ".sdata") == 0)
     2901                h->esym.asym.sc = scSData;
     2902              else if (strcmp (name, ".rodata") == 0
     2903                       || strcmp (name, ".rdata") == 0)
     2904                h->esym.asym.sc = scRData;
     2905              else if (strcmp (name, ".bss") == 0)
     2906                h->esym.asym.sc = scBss;
     2907              else if (strcmp (name, ".sbss") == 0)
     2908                h->esym.asym.sc = scSBss;
     2909              else if (strcmp (name, ".init") == 0)
     2910                h->esym.asym.sc = scInit;
     2911              else if (strcmp (name, ".fini") == 0)
     2912                h->esym.asym.sc = scFini;
     2913              else
     2914                h->esym.asym.sc = scAbs;
     2915            }
     2916        }
    23052917
    23062918      h->esym.asym.reserved = 0;
     
    23142926    {
    23152927      if (h->esym.asym.sc == scCommon)
    2316        h->esym.asym.sc = scBss;
     2928        h->esym.asym.sc = scBss;
    23172929      else if (h->esym.asym.sc == scSCommon)
    2318        h->esym.asym.sc = scSBss;
     2930        h->esym.asym.sc = scSBss;
    23192931
    23202932      sec = h->root.root.u.def.section;
    23212933      output_section = sec->output_section;
    23222934      if (output_section != NULL)
    2323        h->esym.asym.value = (h->root.root.u.def.value
    2324                              + sec->output_offset
    2325                              + output_section->vma);
     2935        h->esym.asym.value = (h->root.root.u.def.value
     2936                              + sec->output_offset
     2937                              + output_section->vma);
    23262938      else
    2327        h->esym.asym.value = 0;
     2939        h->esym.asym.value = 0;
    23282940    }
    23292941  else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
     
    23442956            h->esym.asym.value = 0;
    23452957        }
    2346 #if 0 /* FIXME?  */
    2347       h->esym.ifd = 0;
    2348 #endif
    23492958    }
    23502959
    23512960  if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap,
    2352                                      h->root.root.root.string,
    2353                                      &h->esym))
    2354     {
    2355       einfo->failed = true;
    2356       return false;
    2357     }
    2358 
    2359   return true;
     2961                                      h->root.root.root.string,
     2962                                      &h->esym))
     2963    {
     2964      einfo->failed = TRUE;
     2965      return FALSE;
     2966    }
     2967
     2968  return TRUE;
    23602969}
    23612970
    2362 /* FIXME:  Create a runtime procedure table from the .mdebug section.
    2363 
    2364 static boolean
    2365 mips_elf_create_procedure_table (handle, abfd, info, s, debug)
    2366      PTR handle;
     2971
     2972/* Search for and possibly create a got entry.  */
     2973
     2974static struct alpha_elf_got_entry *
     2975get_got_entry (abfd, h, r_type, r_symndx, r_addend)
    23672976     bfd *abfd;
    2368      struct bfd_link_info *info;
    2369      asection *s;
    2370      struct ecoff_debug_info *debug;
    2371 */
    2372 
     2977     struct alpha_elf_link_hash_entry *h;
     2978     unsigned long r_type, r_symndx;
     2979     bfd_vma r_addend;
     2980{
     2981  struct alpha_elf_got_entry *gotent;
     2982  struct alpha_elf_got_entry **slot;
     2983
     2984  if (h)
     2985    slot = &h->got_entries;
     2986  else
     2987    {
     2988      /* This is a local .got entry -- record for merge.  */
     2989
     2990      struct alpha_elf_got_entry **local_got_entries;
     2991
     2992      local_got_entries = alpha_elf_tdata(abfd)->local_got_entries;
     2993      if (!local_got_entries)
     2994        {
     2995          bfd_size_type size;
     2996          Elf_Internal_Shdr *symtab_hdr;
     2997
     2998          symtab_hdr = &elf_tdata(abfd)->symtab_hdr;
     2999          size = symtab_hdr->sh_info;
     3000          size *= sizeof (struct alpha_elf_got_entry *);
     3001
     3002          local_got_entries
     3003            = (struct alpha_elf_got_entry **) bfd_zalloc (abfd, size);
     3004          if (!local_got_entries)
     3005            return NULL;
     3006
     3007          alpha_elf_tdata (abfd)->local_got_entries = local_got_entries;
     3008        }
     3009
     3010      slot = &local_got_entries[r_symndx];
     3011    }
     3012
     3013  for (gotent = *slot; gotent ; gotent = gotent->next)
     3014    if (gotent->gotobj == abfd
     3015        && gotent->reloc_type == r_type
     3016        && gotent->addend == r_addend)
     3017      break;
     3018
     3019  if (!gotent)
     3020    {
     3021      int entry_size;
     3022      bfd_size_type amt;
     3023
     3024      amt = sizeof (struct alpha_elf_got_entry);
     3025      gotent = (struct alpha_elf_got_entry *) bfd_alloc (abfd, amt);
     3026      if (!gotent)
     3027        return NULL;
     3028
     3029      gotent->gotobj = abfd;
     3030      gotent->addend = r_addend;
     3031      gotent->got_offset = -1;
     3032      gotent->use_count = 1;
     3033      gotent->reloc_type = r_type;
     3034      gotent->reloc_done = 0;
     3035      gotent->reloc_xlated = 0;
     3036
     3037      gotent->next = *slot;
     3038      *slot = gotent;
     3039
     3040      entry_size = alpha_got_entry_size (r_type);
     3041      alpha_elf_tdata (abfd)->total_got_size += entry_size;
     3042      if (!h)
     3043        alpha_elf_tdata(abfd)->local_got_size += entry_size;
     3044    }
     3045  else
     3046    gotent->use_count += 1;
     3047
     3048  return gotent;
     3049}
    23733050
    23743051/* Handle dynamic relocations when doing an Alpha ELF link.  */
    23753052
    2376 static boolean
     3053static bfd_boolean
    23773054elf64_alpha_check_relocs (abfd, info, sec, relocs)
    23783055     bfd *abfd;
     
    23863063  Elf_Internal_Shdr *symtab_hdr;
    23873064  struct alpha_elf_link_hash_entry **sym_hashes;
    2388   struct alpha_elf_got_entry **local_got_entries;
    23893065  const Elf_Internal_Rela *rel, *relend;
    2390   int got_created;
     3066  bfd_boolean got_created;
     3067  bfd_size_type amt;
    23913068
    23923069  if (info->relocateable)
    2393     return true;
     3070    return TRUE;
    23943071
    23953072  dynobj = elf_hash_table(info)->dynobj;
     
    24013078  symtab_hdr = &elf_tdata(abfd)->symtab_hdr;
    24023079  sym_hashes = alpha_elf_sym_hashes(abfd);
    2403   local_got_entries = alpha_elf_tdata(abfd)->local_got_entries;
    2404   got_created = 0;
     3080  got_created = FALSE;
    24053081
    24063082  relend = relocs + sec->reloc_count;
    24073083  for (rel = relocs; rel < relend; ++rel)
    24083084    {
     3085      enum {
     3086        NEED_GOT = 1,
     3087        NEED_GOT_ENTRY = 2,
     3088        NEED_DYNREL = 4
     3089      };
     3090
    24093091      unsigned long r_symndx, r_type;
    24103092      struct alpha_elf_link_hash_entry *h;
     3093      unsigned int gotent_flags;
     3094      bfd_boolean maybe_dynamic;
     3095      unsigned int need;
     3096      bfd_vma addend;
    24113097
    24123098      r_symndx = ELF64_R_SYM (rel->r_info);
     
    24233109          h->root.elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
    24243110        }
     3111
     3112      /* We can only get preliminary data on whether a symbol is
     3113         locally or externally defined, as not all of the input files
     3114         have yet been processed.  Do something with what we know, as
     3115         this may help reduce memory usage and processing time later.  */
     3116      maybe_dynamic = FALSE;
     3117      if (h && ((info->shared
     3118                 && (!info->symbolic || info->allow_shlib_undefined))
     3119                || ! (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
     3120                || h->root.root.type == bfd_link_hash_defweak))
     3121        maybe_dynamic = TRUE;
     3122
     3123      need = 0;
     3124      gotent_flags = 0;
    24253125      r_type = ELF64_R_TYPE (rel->r_info);
     3126      addend = rel->r_addend;
    24263127
    24273128      switch (r_type)
    24283129        {
    24293130        case R_ALPHA_LITERAL:
    2430           {
    2431             struct alpha_elf_got_entry *gotent;
    2432             int flags = 0;
    2433 
    2434             if (h)
    2435               {
    2436                 /* Search for and possibly create a got entry.  */
    2437                 for (gotent = h->got_entries; gotent ; gotent = gotent->next)
    2438                   if (gotent->gotobj == abfd &&
    2439                       gotent->addend == rel->r_addend)
    2440                     break;
    2441 
    2442                 if (!gotent)
    2443                   {
    2444                     gotent = ((struct alpha_elf_got_entry *)
    2445                               bfd_alloc (abfd,
    2446                                          sizeof (struct alpha_elf_got_entry)));
    2447                     if (!gotent)
    2448                       return false;
    2449 
    2450                     gotent->gotobj = abfd;
    2451                     gotent->addend = rel->r_addend;
    2452                     gotent->got_offset = -1;
    2453                     gotent->flags = 0;
    2454                     gotent->use_count = 1;
    2455 
    2456                     gotent->next = h->got_entries;
    2457                     h->got_entries = gotent;
    2458 
    2459                     alpha_elf_tdata (abfd)->total_got_entries++;
    2460                   }
    2461                 else
    2462                   gotent->use_count += 1;
    2463               }
    2464             else
    2465               {
    2466                 /* This is a local .got entry -- record for merge.  */
    2467                 if (!local_got_entries)
    2468                   {
    2469                     size_t size;
    2470                     size = (symtab_hdr->sh_info
    2471                             * sizeof (struct alpha_elf_got_entry *));
    2472 
    2473                     local_got_entries = ((struct alpha_elf_got_entry **)
    2474                                          bfd_alloc (abfd, size));
    2475                     if (!local_got_entries)
    2476                       return false;
    2477 
    2478                     memset (local_got_entries, 0, size);
    2479                     alpha_elf_tdata (abfd)->local_got_entries =
    2480                       local_got_entries;
    2481                   }
    2482 
    2483                 for (gotent = local_got_entries[ELF64_R_SYM(rel->r_info)];
    2484                      gotent != NULL && gotent->addend != rel->r_addend;
    2485                      gotent = gotent->next)
    2486                   continue;
    2487                 if (!gotent)
    2488                   {
    2489                     gotent = ((struct alpha_elf_got_entry *)
    2490                               bfd_alloc (abfd,
    2491                                          sizeof (struct alpha_elf_got_entry)));
    2492                     if (!gotent)
    2493                       return false;
    2494 
    2495                     gotent->gotobj = abfd;
    2496                     gotent->addend = rel->r_addend;
    2497                     gotent->got_offset = -1;
    2498                     gotent->flags = 0;
    2499                     gotent->use_count = 1;
    2500 
    2501                     gotent->next = local_got_entries[ELF64_R_SYM(rel->r_info)];
    2502                     local_got_entries[ELF64_R_SYM(rel->r_info)] = gotent;
    2503 
    2504                     alpha_elf_tdata(abfd)->total_got_entries++;
    2505                     alpha_elf_tdata(abfd)->n_local_got_entries++;
    2506                   }
    2507                 else
    2508                   gotent->use_count += 1;
    2509               }
    2510 
    2511             /* Remember how this literal is used from its LITUSEs.
    2512                This will be important when it comes to decide if we can
    2513                create a .plt entry for a function symbol.  */
    2514             if (rel+1 < relend
    2515                 && ELF64_R_TYPE (rel[1].r_info) == R_ALPHA_LITUSE)
    2516               {
    2517                 do
    2518                   {
    2519                     ++rel;
    2520                     if (rel->r_addend >= 1 && rel->r_addend <= 3)
    2521                       flags |= 1 << rel->r_addend;
    2522                   }
    2523                 while (rel+1 < relend &&
    2524                        ELF64_R_TYPE (rel[1].r_info) == R_ALPHA_LITUSE);
    2525               }
    2526             else
    2527               {
    2528                 /* No LITUSEs -- presumably the address is not being
    2529                    loaded for nothing.  */
    2530                 flags = ALPHA_ELF_LINK_HASH_LU_ADDR;
    2531               }
    2532 
    2533             gotent->flags |= flags;
    2534             if (h)
    2535               {
    2536                 /* Make a guess as to whether a .plt entry will be needed.  */
    2537                 if ((h->flags |= flags) == ALPHA_ELF_LINK_HASH_LU_FUNC)
    2538                   h->root.elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
    2539                 else
    2540                   h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
    2541               }
    2542           }
    2543           /* FALLTHRU */
     3131          need = NEED_GOT | NEED_GOT_ENTRY;
     3132
     3133          /* Remember how this literal is used from its LITUSEs.
     3134             This will be important when it comes to decide if we can
     3135             create a .plt entry for a function symbol.  */
     3136          while (++rel < relend && ELF64_R_TYPE (rel->r_info) == R_ALPHA_LITUSE)
     3137            if (rel->r_addend >= 1 && rel->r_addend <= 5)
     3138              gotent_flags |= 1 << rel->r_addend;
     3139          --rel;
     3140
     3141          /* No LITUSEs -- presumably the address is used somehow.  */
     3142          if (gotent_flags == 0)
     3143            gotent_flags = ALPHA_ELF_LINK_HASH_LU_ADDR;
     3144          break;
    25443145
    25453146        case R_ALPHA_GPDISP:
     3147        case R_ALPHA_GPREL16:
    25463148        case R_ALPHA_GPREL32:
    25473149        case R_ALPHA_GPRELHIGH:
    25483150        case R_ALPHA_GPRELLOW:
    2549           /* We don't actually use the .got here, but the sections must
    2550              be created before the linker maps input sections to output
    2551              sections.  */
     3151        case R_ALPHA_BRSGP:
     3152          need = NEED_GOT;
     3153          break;
     3154
     3155        case R_ALPHA_REFLONG:
     3156        case R_ALPHA_REFQUAD:
     3157          if ((info->shared && (sec->flags & SEC_ALLOC)) || maybe_dynamic)
     3158            need = NEED_DYNREL;
     3159          break;
     3160
     3161        case R_ALPHA_TLSLDM:
     3162          /* The symbol for a TLSLDM reloc is ignored.  Collapse the
     3163             reloc to the 0 symbol so that they all match.  */
     3164          r_symndx = 0;
     3165          h = 0;
     3166          maybe_dynamic = FALSE;
     3167          /* FALLTHRU */
     3168
     3169        case R_ALPHA_TLSGD:
     3170        case R_ALPHA_GOTDTPREL:
     3171          need = NEED_GOT | NEED_GOT_ENTRY;
     3172          break;
     3173
     3174        case R_ALPHA_GOTTPREL:
     3175          need = NEED_GOT | NEED_GOT_ENTRY;
     3176          gotent_flags = ALPHA_ELF_LINK_HASH_TLS_IE;
     3177          if (info->shared)
     3178            info->flags |= DF_STATIC_TLS;
     3179          break;
     3180
     3181        case R_ALPHA_TPREL64:
     3182          if (info->shared || maybe_dynamic)
     3183            need = NEED_DYNREL;
     3184          if (info->shared)
     3185            info->flags |= DF_STATIC_TLS;
     3186          break;
     3187        }
     3188
     3189      if (need & NEED_GOT)
     3190        {
    25523191          if (!got_created)
    25533192            {
    25543193              if (!elf64_alpha_create_got_section (abfd, info))
    2555                 return false;
     3194                return FALSE;
    25563195
    25573196              /* Make sure the object's gotobj is set to itself so
     
    25633202              got_created = 1;
    25643203            }
    2565           break;
    2566 
    2567         case R_ALPHA_SREL16:
    2568         case R_ALPHA_SREL32:
    2569         case R_ALPHA_SREL64:
    2570           if (h == NULL)
    2571             break;
    2572           /* FALLTHRU */
    2573 
    2574         case R_ALPHA_REFLONG:
    2575         case R_ALPHA_REFQUAD:
     3204        }
     3205
     3206      if (need & NEED_GOT_ENTRY)
     3207        {
     3208          struct alpha_elf_got_entry *gotent;
     3209
     3210          gotent = get_got_entry (abfd, h, r_type, r_symndx, addend);
     3211          if (!gotent)
     3212            return FALSE;
     3213
     3214          if (gotent_flags)
     3215            {
     3216              gotent->flags |= gotent_flags;
     3217              if (h)
     3218                {
     3219                  gotent_flags |= h->flags;
     3220                  h->flags = gotent_flags;
     3221
     3222                  /* Make a guess as to whether a .plt entry is needed.  */
     3223                  if ((gotent_flags & ALPHA_ELF_LINK_HASH_LU_FUNC)
     3224                      && !(gotent_flags & ~ALPHA_ELF_LINK_HASH_LU_FUNC))
     3225                    h->root.elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
     3226                  else
     3227                    h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
     3228                }
     3229            }
     3230        }
     3231
     3232      if (need & NEED_DYNREL)
     3233        {
    25763234          if (rel_sec_name == NULL)
    25773235            {
     
    25803238                               elf_section_data(sec)->rel_hdr.sh_name));
    25813239              if (rel_sec_name == NULL)
    2582                 return false;
     3240                return FALSE;
    25833241
    25843242              BFD_ASSERT (strncmp (rel_sec_name, ".rela", 5) == 0
     
    25963254              if (sreloc == NULL)
    25973255                {
     3256                  flagword flags;
     3257
    25983258                  sreloc = bfd_make_section (dynobj, rel_sec_name);
     3259                  flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY
     3260                           | SEC_LINKER_CREATED | SEC_READONLY);
     3261                  if (sec->flags & SEC_ALLOC)
     3262                    flags |= SEC_ALLOC | SEC_LOAD;
    25993263                  if (sreloc == NULL
    2600                       || !bfd_set_section_flags (dynobj, sreloc,
    2601                                                  ((sec->flags & (SEC_ALLOC
    2602                                                                  | SEC_LOAD))
    2603                                                   | SEC_HAS_CONTENTS
    2604                                                   | SEC_IN_MEMORY
    2605                                                   | SEC_LINKER_CREATED
    2606                                                   | SEC_READONLY))
     3264                      || !bfd_set_section_flags (dynobj, sreloc, flags)
    26073265                      || !bfd_set_section_alignment (dynobj, sreloc, 3))
    2608                     return false;
     3266                    return FALSE;
    26093267                }
    26103268            }
     
    26263284              if (!rent)
    26273285                {
    2628                   rent = ((struct alpha_elf_reloc_entry *)
    2629                           bfd_alloc (abfd,
    2630                                      sizeof (struct alpha_elf_reloc_entry)));
     3286                  amt = sizeof (struct alpha_elf_reloc_entry);
     3287                  rent = (struct alpha_elf_reloc_entry *) bfd_alloc (abfd, amt);
    26313288                  if (!rent)
    2632                     return false;
     3289                    return FALSE;
    26333290
    26343291                  rent->srel = sreloc;
    26353292                  rent->rtype = r_type;
    26363293                  rent->count = 1;
     3294                  rent->reltext = ((sec->flags & (SEC_READONLY | SEC_ALLOC))
     3295                                   == (SEC_READONLY | SEC_ALLOC));
    26373296
    26383297                  rent->next = h->reloc_entries;
     
    26423301                rent->count++;
    26433302            }
    2644           else if (info->shared && (sec->flags & SEC_ALLOC))
     3303          else if (info->shared)
    26453304            {
    26463305              /* If this is a shared library, and the section is to be
    26473306                 loaded into memory, we need a RELATIVE reloc.  */
    26483307              sreloc->_raw_size += sizeof (Elf64_External_Rela);
     3308              if ((sec->flags & (SEC_READONLY | SEC_ALLOC))
     3309                  == (SEC_READONLY | SEC_ALLOC))
     3310                info->flags |= DF_TEXTREL;
    26493311            }
    2650           break;
    2651         }
    2652     }
    2653 
    2654   return true;
     3312        }
     3313    }
     3314
     3315  return TRUE;
    26553316}
    26563317
     
    26613322   understand.  */
    26623323
    2663 static boolean
     3324static bfd_boolean
    26643325elf64_alpha_adjust_dynamic_symbol (info, h)
    26653326     struct bfd_link_info *info;
     
    26763337     about whether this symbol should get a .plt entry.  */
    26773338
    2678   if (h->root.type != bfd_link_hash_undefweak
    2679       && alpha_elf_dynamic_symbol_p (h, info)
     3339  if (alpha_elf_dynamic_symbol_p (h, info)
    26803340      && ((h->type == STT_FUNC
    26813341           && !(ah->flags & ALPHA_ELF_LINK_HASH_LU_ADDR))
    26823342          || (h->type == STT_NOTYPE
    2683               && ah->flags == ALPHA_ELF_LINK_HASH_LU_FUNC))
     3343              && (ah->flags & ALPHA_ELF_LINK_HASH_LU_FUNC)
     3344              && !(ah->flags & ~ALPHA_ELF_LINK_HASH_LU_FUNC)))
    26843345      /* Don't prevent otherwise valid programs from linking by attempting
    26853346         to create a new .got entry somewhere.  A Correct Solution would be
     
    26923353      s = bfd_get_section_by_name(dynobj, ".plt");
    26933354      if (!s && !elf64_alpha_create_dynamic_sections (dynobj, info))
    2694         return false;
     3355        return FALSE;
    26953356
    26963357      /* The first bit of the .plt is reserved.  */
     
    27083369          && h->root.type != bfd_link_hash_defweak)
    27093370        {
     3371          ah->plt_old_section = h->root.u.def.section;
     3372          ah->plt_old_value = h->root.u.def.value;
     3373          ah->flags |= ALPHA_ELF_LINK_HASH_PLT_LOC;
    27103374          h->root.u.def.section = s;
    27113375          h->root.u.def.value = h->plt.offset;
     
    27173381      s->_raw_size += sizeof (Elf64_External_Rela);
    27183382
    2719       return true;
     3383      return TRUE;
    27203384    }
    27213385  else
     
    27313395      h->root.u.def.section = h->weakdef->root.u.def.section;
    27323396      h->root.u.def.value = h->weakdef->root.u.def.value;
    2733       return true;
     3397      return TRUE;
    27343398    }
    27353399
     
    27393403     .dynbss section and COPY dynamic relocations.  */
    27403404
    2741   return true;
     3405  return TRUE;
    27423406}
    27433407
     
    27463410   in these situations.  */
    27473411
    2748 static boolean
     3412static bfd_boolean
    27493413elf64_alpha_merge_ind_symbols (hi, dummy)
    27503414     struct alpha_elf_link_hash_entry *hi;
     
    27543418
    27553419  if (hi->root.root.type != bfd_link_hash_indirect)
    2756     return true;
     3420    return TRUE;
    27573421  hs = hi;
    27583422  do {
     
    27783442          gin = gi->next;
    27793443          for (gs = gsh; gs ; gs = gs->next)
    2780             if (gi->gotobj == gs->gotobj && gi->addend == gs->addend)
    2781               goto got_found;
     3444            if (gi->gotobj == gs->gotobj
     3445                && gi->reloc_type == gs->reloc_type
     3446                && gi->addend == gs->addend)
     3447              {
     3448                gi->use_count += gs->use_count;
     3449                goto got_found;
     3450              }
    27823451          gi->next = hs->got_entries;
    27833452          hs->got_entries = gi;
     
    28003469          rin = ri->next;
    28013470          for (rs = rsh; rs ; rs = rs->next)
    2802             if (ri->rtype == rs->rtype)
     3471            if (ri->rtype == rs->rtype && ri->srel == rs->srel)
    28033472              {
    28043473                rs->count += ri->count;
     
    28123481  hi->reloc_entries = NULL;
    28133482
    2814   return true;
     3483  return TRUE;
    28153484}
    28163485
    28173486/* Is it possible to merge two object file's .got tables?  */
    28183487
    2819 static boolean
     3488static bfd_boolean
    28203489elf64_alpha_can_merge_gots (a, b)
    28213490     bfd *a, *b;
    28223491{
    2823   int total = alpha_elf_tdata (a)->total_got_entries;
     3492  int total = alpha_elf_tdata (a)->total_got_size;
    28243493  bfd *bsub;
    28253494
    28263495  /* Trivial quick fallout test.  */
    2827   if (total + alpha_elf_tdata (b)->total_got_entries <= MAX_GOT_ENTRIES)
    2828     return true;
     3496  if (total + alpha_elf_tdata (b)->total_got_size <= MAX_GOT_SIZE)
     3497    return TRUE;
    28293498
    28303499  /* By their nature, local .got entries cannot be merged.  */
    2831   if ((total += alpha_elf_tdata (b)->n_local_got_entries) > MAX_GOT_ENTRIES)
    2832     return false;
     3500  if ((total += alpha_elf_tdata (b)->local_got_size) > MAX_GOT_SIZE)
     3501    return FALSE;
    28333502
    28343503  /* Failing the common trivial comparison, we must effectively
     
    28603529
    28613530              for (ae = h->got_entries; ae ; ae = ae->next)
    2862                 if (ae->gotobj == a && ae->addend == be->addend)
     3531                if (ae->gotobj == a
     3532                    && ae->reloc_type == be->reloc_type
     3533                    && ae->addend == be->addend)
    28633534                  goto global_found;
    28643535
    2865               if (++total > MAX_GOT_ENTRIES)
    2866                 return false;
     3536              total += alpha_got_entry_size (be->reloc_type);
     3537              if (total > MAX_GOT_SIZE)
     3538                return FALSE;
    28673539            global_found:;
    28683540            }
     
    28703542    }
    28713543
    2872   return true;
     3544  return TRUE;
    28733545}
    28743546
     
    28793551     bfd *a, *b;
    28803552{
    2881   int total = alpha_elf_tdata (a)->total_got_entries;
     3553  int total = alpha_elf_tdata (a)->total_got_size;
    28823554  bfd *bsub;
    28833555
    28843556  /* Remember local expansion.  */
    28853557  {
    2886     int e = alpha_elf_tdata (b)->n_local_got_entries;
     3558    int e = alpha_elf_tdata (b)->local_got_size;
    28873559    total += e;
    2888     alpha_elf_tdata (a)->n_local_got_entries += e;
     3560    alpha_elf_tdata (a)->local_got_size += e;
    28893561  }
    28903562
     
    29363608
    29373609              for (ae = *start; ae ; ae = ae->next)
    2938                 if (ae->gotobj == a && ae->addend == be->addend)
     3610                if (ae->gotobj == a
     3611                    && ae->reloc_type == be->reloc_type
     3612                    && ae->addend == be->addend)
    29393613                  {
    29403614                    ae->flags |= be->flags;
     
    29443618                  }
    29453619              be->gotobj = a;
    2946               total += 1;
     3620              total += alpha_got_entry_size (be->reloc_type);
    29473621
    29483622            global_found:;
     
    29523626      alpha_elf_tdata (bsub)->gotobj = a;
    29533627    }
    2954   alpha_elf_tdata (a)->total_got_entries = total;
     3628  alpha_elf_tdata (a)->total_got_size = total;
    29553629
    29563630  /* Merge the two in_got chains.  */
     
    29683642/* Calculate the offsets for the got entries.  */
    29693643
    2970 static boolean
     3644static bfd_boolean
    29713645elf64_alpha_calc_got_offsets_for_symbol (h, arg)
    29723646     struct alpha_elf_link_hash_entry *h;
    2973      PTR arg;
     3647     PTR arg ATTRIBUTE_UNUSED;
    29743648{
    29753649  struct alpha_elf_got_entry *gotent;
     3650
     3651  if (h->root.root.type == bfd_link_hash_warning)
     3652    h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link;
    29763653
    29773654  for (gotent = h->got_entries; gotent; gotent = gotent->next)
     
    29823659
    29833660        gotent->got_offset = *plge;
    2984         *plge += 8;
     3661        *plge += alpha_got_entry_size (gotent->reloc_type);
    29853662      }
    29863663
    2987   return true;
     3664  return TRUE;
    29883665}
    29893666
     
    30243701                {
    30253702                  gotent->got_offset = got_offset;
    3026                   got_offset += 8;
     3703                  got_offset += alpha_got_entry_size (gotent->reloc_type);
    30273704                }
    30283705        }
     
    30353712/* Constructs the gots.  */
    30363713
    3037 static boolean
    3038 elf64_alpha_size_got_sections (output_bfd, info)
    3039      bfd *output_bfd;
     3714static bfd_boolean
     3715elf64_alpha_size_got_sections (info)
    30403716     struct bfd_link_info *info;
    30413717{
    3042   bfd *i, *got_list, *cur_got_obj;
     3718  bfd *i, *got_list, *cur_got_obj = NULL;
    30433719  int something_changed = 0;
    30443720
     
    30583734          BFD_ASSERT (this_got == i);
    30593735
    3060           if (alpha_elf_tdata (this_got)->total_got_entries > MAX_GOT_ENTRIES)
     3736          if (alpha_elf_tdata (this_got)->total_got_size > MAX_GOT_SIZE)
    30613737            {
    30623738              /* Yikes! A single object file has too many entries.  */
    30633739              (*_bfd_error_handler)
    30643740                (_("%s: .got subsegment exceeds 64K (size %d)"),
    3065                  bfd_get_filename (i),
    3066                  alpha_elf_tdata (this_got)->total_got_entries * 8);
    3067               return false;
     3741                 bfd_archive_filename (i),
     3742                 alpha_elf_tdata (this_got)->total_got_size);
     3743              return FALSE;
    30683744            }
    30693745
     
    30773753      /* Strange degenerate case of no got references.  */
    30783754      if (got_list == NULL)
    3079         return true;
     3755        return TRUE;
    30803756
    30813757      alpha_elf_hash_table (info)->got_list = got_list;
     
    31083784    elf64_alpha_calc_got_offsets (info);
    31093785
    3110   return true;
     3786  return TRUE;
    31113787}
    31123788
    3113 static boolean
     3789/* Called from relax_section to rebuild the PLT in light of
     3790   potential changes in the function's status.  */
     3791
     3792static bfd_boolean
     3793elf64_alpha_size_plt_section (info)
     3794     struct bfd_link_info *info;
     3795{
     3796  asection *splt, *spltrel;
     3797  unsigned long entries;
     3798  bfd *dynobj;
     3799
     3800  dynobj = elf_hash_table(info)->dynobj;
     3801  splt = bfd_get_section_by_name(dynobj, ".plt");
     3802  if (splt == NULL)
     3803    return TRUE;
     3804
     3805  splt->_raw_size = 0;
     3806
     3807  alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
     3808                                elf64_alpha_size_plt_section_1, splt);
     3809
     3810  splt->_cooked_size = splt->_raw_size;
     3811
     3812  /* Every plt entry requires a JMP_SLOT relocation.  */
     3813  spltrel = bfd_get_section_by_name (dynobj, ".rela.plt");
     3814  if (splt->_raw_size)
     3815    entries = (splt->_raw_size - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE;
     3816  else
     3817    entries = 0;
     3818  spltrel->_raw_size = entries * sizeof (Elf64_External_Rela);
     3819  spltrel->_cooked_size = spltrel->_raw_size;
     3820
     3821  return TRUE;
     3822}
     3823
     3824static bfd_boolean
     3825elf64_alpha_size_plt_section_1 (h, data)
     3826     struct alpha_elf_link_hash_entry *h;
     3827     PTR data;
     3828{
     3829  asection *splt = (asection *) data;
     3830  struct alpha_elf_got_entry *gotent;
     3831
     3832  /* If we didn't need an entry before, we still don't.  */
     3833  if (!(h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT))
     3834    return TRUE;
     3835
     3836  /* There must still be a LITERAL got entry for the function.  */
     3837  for (gotent = h->got_entries; gotent ; gotent = gotent->next)
     3838    if (gotent->reloc_type == R_ALPHA_LITERAL
     3839        && gotent->use_count > 0)
     3840      break;
     3841
     3842  /* If there is, reset the PLT offset.  If not, there's no longer
     3843     a need for the PLT entry.  */
     3844  if (gotent)
     3845    {
     3846      if (splt->_raw_size == 0)
     3847        splt->_raw_size = PLT_HEADER_SIZE;
     3848      h->root.plt.offset = splt->_raw_size;
     3849      splt->_raw_size += PLT_ENTRY_SIZE;
     3850    }
     3851  else
     3852    {
     3853      h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
     3854      h->root.plt.offset = -1;
     3855
     3856      /* Undo the definition frobbing begun in adjust_dynamic_symbol.  */
     3857      if (h->flags & ALPHA_ELF_LINK_HASH_PLT_LOC)
     3858        {
     3859          h->root.root.u.def.section = h->plt_old_section;
     3860          h->root.root.u.def.value = h->plt_old_value;
     3861          h->flags &= ~ALPHA_ELF_LINK_HASH_PLT_LOC;
     3862        }
     3863    }
     3864
     3865  return TRUE;
     3866}
     3867
     3868static bfd_boolean
    31143869elf64_alpha_always_size_sections (output_bfd, info)
    3115      bfd *output_bfd;
     3870     bfd *output_bfd ATTRIBUTE_UNUSED;
    31163871     struct bfd_link_info *info;
    31173872{
     
    31193874
    31203875  if (info->relocateable)
    3121     return true;
     3876    return TRUE;
    31223877
    31233878  /* First, take care of the indirect symbols created by versioning.  */
     
    31263881                                NULL);
    31273882
    3128   if (!elf64_alpha_size_got_sections (output_bfd, info))
    3129     return false;
     3883  if (!elf64_alpha_size_got_sections (info))
     3884    return FALSE;
    31303885
    31313886  /* Allocate space for all of the .got subsections.  */
     
    31383893          s->contents = (bfd_byte *) bfd_zalloc (i, s->_raw_size);
    31393894          if (s->contents == NULL)
    3140             return false;
    3141         }
    3142     }
    3143 
    3144   return true;
     3895            return FALSE;
     3896        }
     3897    }
     3898
     3899  return TRUE;
    31453900}
    31463901
     3902/* The number of dynamic relocations required by a static relocation.  */
     3903
     3904static int
     3905alpha_dynamic_entries_for_reloc (r_type, dynamic, shared)
     3906     int r_type, dynamic, shared;
     3907{
     3908  switch (r_type)
     3909    {
     3910    /* May appear in GOT entries.  */
     3911    case R_ALPHA_TLSGD:
     3912      return (dynamic ? 2 : shared ? 1 : 0);
     3913    case R_ALPHA_TLSLDM:
     3914      return shared;
     3915    case R_ALPHA_LITERAL:
     3916    case R_ALPHA_GOTTPREL:
     3917      return dynamic || shared;
     3918    case R_ALPHA_GOTDTPREL:
     3919      return dynamic;
     3920
     3921    /* May appear in data sections.  */
     3922    case R_ALPHA_REFLONG:
     3923    case R_ALPHA_REFQUAD:
     3924    case R_ALPHA_TPREL64:
     3925      return dynamic || shared;
     3926
     3927    /* Everything else is illegal.  We'll issue an error during
     3928       relocate_section.  */
     3929    default:
     3930      return 0;
     3931    }
     3932}
     3933
    31473934/* Work out the sizes of the dynamic relocation entries.  */
    31483935
    3149 static boolean
     3936static bfd_boolean
    31503937elf64_alpha_calc_dynrel_sizes (h, info)
    31513938     struct alpha_elf_link_hash_entry *h;
    31523939     struct bfd_link_info *info;
    31533940{
     3941  bfd_boolean dynamic;
     3942  struct alpha_elf_reloc_entry *relent;
     3943  unsigned long entries;
     3944
     3945  if (h->root.root.type == bfd_link_hash_warning)
     3946    h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link;
     3947
    31543948  /* If the symbol was defined as a common symbol in a regular object
    31553949     file, and there was no definition in any dynamic object, then the
     
    31673961          || h->root.root.type == bfd_link_hash_defweak)
    31683962      && !(h->root.root.u.def.section->owner->flags & DYNAMIC))
    3169     {
    3170       h->root.elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
    3171     }
     3963    h->root.elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
    31723964
    31733965  /* If the symbol is dynamic, we'll need all the relocations in their
     
    31753967     local, we'll need the same number of RELATIVE relocations.  */
    31763968
    3177   if (alpha_elf_dynamic_symbol_p (&h->root, info) || info->shared)
    3178     {
    3179       struct alpha_elf_reloc_entry *relent;
    3180       bfd *dynobj;
    3181       struct alpha_elf_got_entry *gotent;
    3182       bfd_size_type count;
    3183       asection *srel;
    3184 
    3185       for (relent = h->reloc_entries; relent; relent = relent->next)
    3186         if (relent->rtype == R_ALPHA_REFLONG
    3187             || relent->rtype == R_ALPHA_REFQUAD)
    3188           {
    3189             relent->srel->_raw_size +=
    3190               sizeof (Elf64_External_Rela) * relent->count;
    3191           }
    3192 
    3193       dynobj = elf_hash_table(info)->dynobj;
    3194       count = 0;
    3195 
    3196       for (gotent = h->got_entries; gotent ; gotent = gotent->next)
    3197         count++;
    3198 
    3199       /* If we are using a .plt entry, subtract one, as the first
    3200          reference uses a .rela.plt entry instead.  */
    3201       if (h->root.plt.offset != MINUS_ONE)
    3202         count--;
    3203 
    3204       if (count > 0)
    3205         {
    3206           srel = bfd_get_section_by_name (dynobj, ".rela.got");
    3207           BFD_ASSERT (srel != NULL);
    3208           srel->_raw_size += sizeof (Elf64_External_Rela) * count;
    3209         }
    3210     }
    3211 
    3212   return true;
     3969  dynamic = alpha_elf_dynamic_symbol_p (&h->root, info);
     3970
     3971  for (relent = h->reloc_entries; relent; relent = relent->next)
     3972    {
     3973      entries = alpha_dynamic_entries_for_reloc (relent->rtype, dynamic,
     3974                                                 info->shared);
     3975      if (entries)
     3976        {
     3977          relent->srel->_raw_size +=
     3978            entries * sizeof (Elf64_External_Rela) * relent->count;
     3979          if (relent->reltext)
     3980            info->flags |= DT_TEXTREL;
     3981        }
     3982    }
     3983
     3984  return TRUE;
    32133985}
    32143986
     3987/* Set the sizes of the dynamic relocation sections.  */
     3988
     3989static bfd_boolean
     3990elf64_alpha_size_rela_got_section (info)
     3991     struct bfd_link_info *info;
     3992{
     3993  unsigned long entries;
     3994  bfd *i, *dynobj;
     3995  asection *srel;
     3996
     3997  /* Shared libraries often require RELATIVE relocs, and some relocs
     3998     require attention for the main application as well.  */
     3999
     4000  entries = 0;
     4001  for (i = alpha_elf_hash_table(info)->got_list;
     4002       i ; i = alpha_elf_tdata(i)->got_link_next)
     4003    {
     4004      bfd *j;
     4005
     4006      for (j = i; j ; j = alpha_elf_tdata(j)->in_got_link_next)
     4007        {
     4008          struct alpha_elf_got_entry **local_got_entries, *gotent;
     4009          int k, n;
     4010
     4011          local_got_entries = alpha_elf_tdata(j)->local_got_entries;
     4012          if (!local_got_entries)
     4013            continue;
     4014
     4015          for (k = 0, n = elf_tdata(j)->symtab_hdr.sh_info; k < n; ++k)
     4016            for (gotent = local_got_entries[k];
     4017                 gotent ; gotent = gotent->next)
     4018              if (gotent->use_count > 0)
     4019                entries += (alpha_dynamic_entries_for_reloc
     4020                            (gotent->reloc_type, 0, info->shared));
     4021        }
     4022    }
     4023
     4024  dynobj = elf_hash_table(info)->dynobj;
     4025  srel = bfd_get_section_by_name (dynobj, ".rela.got");
     4026  if (!srel)
     4027    {
     4028      BFD_ASSERT (entries == 0);
     4029      return TRUE;
     4030    }
     4031  srel->_raw_size = sizeof (Elf64_External_Rela) * entries;
     4032
     4033  /* Now do the non-local symbols.  */
     4034  alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
     4035                                elf64_alpha_size_rela_got_1, info);
     4036
     4037  srel->_cooked_size = srel->_raw_size;
     4038
     4039  return TRUE;
     4040}
     4041
     4042/* Subroutine of elf64_alpha_size_rela_got_section for doing the
     4043   global symbols.  */
     4044
     4045static bfd_boolean
     4046elf64_alpha_size_rela_got_1 (h, info)
     4047     struct alpha_elf_link_hash_entry *h;
     4048     struct bfd_link_info *info;
     4049{
     4050  bfd_boolean dynamic;
     4051  struct alpha_elf_got_entry *gotent;
     4052  unsigned long entries;
     4053
     4054  if (h->root.root.type == bfd_link_hash_warning)
     4055    h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link;
     4056
     4057  /* If the symbol is dynamic, we'll need all the relocations in their
     4058     natural form.  If this is a shared object, and it has been forced
     4059     local, we'll need the same number of RELATIVE relocations.  */
     4060
     4061  dynamic = alpha_elf_dynamic_symbol_p (&h->root, info);
     4062
     4063  entries = 0;
     4064  for (gotent = h->got_entries; gotent ; gotent = gotent->next)
     4065    if (gotent->use_count > 0)
     4066      entries += alpha_dynamic_entries_for_reloc (gotent->reloc_type,
     4067                                                  dynamic, info->shared);
     4068
     4069  /* If we are using a .plt entry, subtract one, as the first
     4070     reference uses a .rela.plt entry instead.  */
     4071  if (h->root.plt.offset != MINUS_ONE)
     4072    entries--;
     4073
     4074  if (entries > 0)
     4075    {
     4076      bfd *dynobj = elf_hash_table(info)->dynobj;
     4077      asection *srel = bfd_get_section_by_name (dynobj, ".rela.got");
     4078      BFD_ASSERT (srel != NULL);
     4079      srel->_raw_size += sizeof (Elf64_External_Rela) * entries;
     4080    }
     4081
     4082  return TRUE;
     4083}
     4084
    32154085/* Set the sizes of the dynamic sections.  */
    32164086
    3217 static boolean
     4087static bfd_boolean
    32184088elf64_alpha_size_dynamic_sections (output_bfd, info)
    3219      bfd *output_bfd;
     4089     bfd *output_bfd ATTRIBUTE_UNUSED;
    32204090     struct bfd_link_info *info;
    32214091{
    32224092  bfd *dynobj;
    32234093  asection *s;
    3224   boolean reltext;
    3225   boolean relplt;
     4094  bfd_boolean relplt;
    32264095
    32274096  dynobj = elf_hash_table(info)->dynobj;
     
    32444113         size the dynamic relocation sections.  */
    32454114      alpha_elf_link_hash_traverse (alpha_elf_hash_table (info),
    3246                                     elf64_alpha_calc_dynrel_sizes,
    3247                                     info);
    3248 
    3249       /* When building shared libraries, each local .got entry needs a
    3250          RELATIVE reloc.  */
    3251       if (info->shared)
    3252         {
    3253           bfd *i;
    3254           asection *srel;
    3255           bfd_size_type count;
    3256 
    3257           srel = bfd_get_section_by_name (dynobj, ".rela.got");
    3258           BFD_ASSERT (srel != NULL);
    3259 
    3260           for (i = alpha_elf_hash_table(info)->got_list, count = 0;
    3261                i != NULL;
    3262                i = alpha_elf_tdata(i)->got_link_next)
    3263             count += alpha_elf_tdata(i)->n_local_got_entries;
    3264 
    3265           srel->_raw_size += count * sizeof (Elf64_External_Rela);
    3266         }
     4115                                    elf64_alpha_calc_dynrel_sizes, info);
     4116
     4117      elf64_alpha_size_rela_got_section (info);
    32674118    }
    32684119  /* else we're not dynamic and by definition we don't need such things.  */
     
    32714122     determined the sizes of the various dynamic sections.  Allocate
    32724123     memory for them.  */
    3273   reltext = false;
    3274   relplt = false;
     4124  relplt = FALSE;
    32754125  for (s = dynobj->sections; s != NULL; s = s->next)
    32764126    {
    32774127      const char *name;
    3278       boolean strip;
     4128      bfd_boolean strip;
    32794129
    32804130      if (!(s->flags & SEC_LINKER_CREATED))
     
    32934143         go into these sections.  */
    32944144
    3295       strip = false;
     4145      strip = FALSE;
    32964146
    32974147      if (strncmp (name, ".rela", 5) == 0)
     
    33014151          if (!strip)
    33024152            {
    3303               const char *outname;
    3304               asection *target;
    3305 
    3306               /* If this relocation section applies to a read only
    3307                  section, then we probably need a DT_TEXTREL entry.  */
    3308               outname = bfd_get_section_name (output_bfd,
    3309                                               s->output_section);
    3310               target = bfd_get_section_by_name (output_bfd, outname + 5);
    3311               if (target != NULL
    3312                   && (target->flags & SEC_READONLY) != 0
    3313                   && (target->flags & SEC_ALLOC) != 0)
    3314                 reltext = true;
    3315 
    33164153              if (strcmp(name, ".rela.plt") == 0)
    3317                 relplt = true;
     4154                relplt = TRUE;
    33184155
    33194156              /* We use the reloc_count field as a counter if we need
     
    33334170        {
    33344171          /* Allocate memory for the section contents.  */
    3335           s->contents = (bfd_byte *) bfd_zalloc(dynobj, s->_raw_size);
     4172          s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
    33364173          if (s->contents == NULL && s->_raw_size != 0)
    3337             return false;
     4174            return FALSE;
    33384175        }
    33394176    }
     
    33464183         the .dynamic section.  The DT_DEBUG entry is filled in by the
    33474184         dynamic linker and used by the debugger.  */
     4185#define add_dynamic_entry(TAG, VAL) \
     4186  bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
     4187
    33484188      if (!info->shared)
    33494189        {
    3350           if (!bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
    3351             return false;
    3352         }
    3353 
    3354       if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0))
    3355         return false;
     4190          if (!add_dynamic_entry (DT_DEBUG, 0))
     4191            return FALSE;
     4192        }
    33564193
    33574194      if (relplt)
    33584195        {
    3359           if (! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
    3360               || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
    3361               || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
    3362             return false;
    3363         }
    3364 
    3365       if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
    3366           || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
    3367           || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
    3368                                             sizeof (Elf64_External_Rela)))
    3369         return false;
    3370 
    3371       if (reltext)
    3372         {
    3373           if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
    3374             return false;
    3375           info->flags |= DF_TEXTREL;
    3376         }
    3377     }
    3378 
    3379   return true;
     4196          if (!add_dynamic_entry (DT_PLTGOT, 0)
     4197              || !add_dynamic_entry (DT_PLTRELSZ, 0)
     4198              || !add_dynamic_entry (DT_PLTREL, DT_RELA)
     4199              || !add_dynamic_entry (DT_JMPREL, 0))
     4200            return FALSE;
     4201        }
     4202
     4203      if (!add_dynamic_entry (DT_RELA, 0)
     4204          || !add_dynamic_entry (DT_RELASZ, 0)
     4205          || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
     4206        return FALSE;
     4207
     4208      if (info->flags & DF_TEXTREL)
     4209        {
     4210          if (!add_dynamic_entry (DT_TEXTREL, 0))
     4211            return FALSE;
     4212        }
     4213    }
     4214#undef add_dynamic_entry
     4215
     4216  return TRUE;
    33804217}
    33814218
     4219/* Emit a dynamic relocation for (DYNINDX, RTYPE, ADDEND) at (SEC, OFFSET)
     4220   into the next available slot in SREL.  */
     4221
     4222static void
     4223elf64_alpha_emit_dynrel (abfd, info, sec, srel, offset, dynindx, rtype, addend)
     4224     bfd *abfd;
     4225     struct bfd_link_info *info;
     4226     asection *sec, *srel;
     4227     bfd_vma offset, addend;
     4228     long dynindx, rtype;
     4229{
     4230  Elf_Internal_Rela outrel;
     4231  bfd_byte *loc;
     4232
     4233  BFD_ASSERT (srel != NULL);
     4234
     4235  outrel.r_info = ELF64_R_INFO (dynindx, rtype);
     4236  outrel.r_addend = addend;
     4237
     4238  offset = _bfd_elf_section_offset (abfd, info, sec, offset);
     4239  if ((offset | 1) != (bfd_vma) -1)
     4240    outrel.r_offset = sec->output_section->vma + sec->output_offset + offset;
     4241  else
     4242    memset (&outrel, 0, sizeof (outrel));
     4243
     4244  loc = srel->contents;
     4245  loc += srel->reloc_count++ * sizeof (Elf64_External_Rela);
     4246  bfd_elf64_swap_reloca_out (abfd, &outrel, loc);
     4247  BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
     4248              <= srel->_cooked_size);
     4249}
     4250
     4251/* Relocate an Alpha ELF section for a relocatable link.
     4252
     4253   We don't have to change anything unless the reloc is against a section
     4254   symbol, in which case we have to adjust according to where the section
     4255   symbol winds up in the output section.  */
     4256
     4257static bfd_boolean
     4258elf64_alpha_relocate_section_r (output_bfd, info, input_bfd, input_section,
     4259                                contents, relocs, local_syms, local_sections)
     4260     bfd *output_bfd ATTRIBUTE_UNUSED;
     4261     struct bfd_link_info *info ATTRIBUTE_UNUSED;
     4262     bfd *input_bfd;
     4263     asection *input_section;
     4264     bfd_byte *contents ATTRIBUTE_UNUSED;
     4265     Elf_Internal_Rela *relocs;
     4266     Elf_Internal_Sym *local_syms;
     4267     asection **local_sections;
     4268{
     4269  unsigned long symtab_hdr_sh_info;
     4270  Elf_Internal_Rela *rel;
     4271  Elf_Internal_Rela *relend;
     4272  bfd_boolean ret_val = TRUE;
     4273
     4274  symtab_hdr_sh_info = elf_tdata (input_bfd)->symtab_hdr.sh_info;
     4275
     4276  relend = relocs + input_section->reloc_count;
     4277  for (rel = relocs; rel < relend; rel++)
     4278    {
     4279      unsigned long r_symndx;
     4280      Elf_Internal_Sym *sym;
     4281      asection *sec;
     4282      unsigned long r_type;
     4283
     4284      r_type = ELF64_R_TYPE(rel->r_info);
     4285      if (r_type >= R_ALPHA_max)
     4286        {
     4287          (*_bfd_error_handler)
     4288            (_("%s: unknown relocation type %d"),
     4289             bfd_archive_filename (input_bfd), (int)r_type);
     4290          bfd_set_error (bfd_error_bad_value);
     4291          ret_val = FALSE;
     4292          continue;
     4293        }
     4294
     4295      r_symndx = ELF64_R_SYM(rel->r_info);
     4296
     4297      /* The symbol associated with GPDISP and LITUSE is
     4298         immaterial.  Only the addend is significant.  */
     4299      if (r_type == R_ALPHA_GPDISP || r_type == R_ALPHA_LITUSE)
     4300        continue;
     4301
     4302      if (r_symndx < symtab_hdr_sh_info)
     4303        {
     4304          sym = local_syms + r_symndx;
     4305          if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
     4306            {
     4307              sec = local_sections[r_symndx];
     4308              rel->r_addend += sec->output_offset + sym->st_value;
     4309            }
     4310        }
     4311    }
     4312
     4313  return ret_val;
     4314}
     4315
    33824316/* Relocate an Alpha ELF section.  */
    33834317
    3384 static boolean
     4318static bfd_boolean
    33854319elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
    33864320                              contents, relocs, local_syms, local_sections)
     
    33974331  Elf_Internal_Rela *rel;
    33984332  Elf_Internal_Rela *relend;
    3399   asection *sec, *sgot, *srel, *srelgot;
     4333  struct elf_link_tls_segment *tls_segment;
     4334  asection *sgot, *srel, *srelgot;
    34004335  bfd *dynobj, *gotobj;
    3401   bfd_vma gp;
    3402 
    3403   srelgot = srel = NULL;
     4336  bfd_vma gp, tp_base, dtp_base;
     4337  struct alpha_elf_got_entry **local_got_entries;
     4338  bfd_boolean ret_val;
     4339  const char *section_name;
     4340
     4341  /* Handle relocatable links with a smaller loop.  */
     4342  if (info->relocateable)
     4343    return elf64_alpha_relocate_section_r (output_bfd, info, input_bfd,
     4344                                           input_section, contents, relocs,
     4345                                           local_syms, local_sections);
     4346
     4347  /* This is a final link.  */
     4348
     4349  ret_val = TRUE;
     4350
    34044351  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
     4352
    34054353  dynobj = elf_hash_table (info)->dynobj;
    34064354  if (dynobj)
    3407     {
    3408       srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
    3409     }
     4355    srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
     4356  else
     4357    srelgot = NULL;
     4358
     4359  section_name = (bfd_elf_string_from_elf_section
     4360                  (input_bfd, elf_elfheader(input_bfd)->e_shstrndx,
     4361                   elf_section_data(input_section)->rel_hdr.sh_name));
     4362  BFD_ASSERT(section_name != NULL);
     4363  srel = bfd_get_section_by_name (dynobj, section_name);
    34104364
    34114365  /* Find the gp value for this input bfd.  */
    3412   sgot = NULL;
    3413   gp = 0;
    34144366  gotobj = alpha_elf_tdata (input_bfd)->gotobj;
    34154367  if (gotobj)
     
    34254377        }
    34264378    }
    3427 
    3428   rel = relocs;
     4379  else
     4380    {
     4381      sgot = NULL;
     4382      gp = 0;
     4383    }
     4384
     4385  local_got_entries = alpha_elf_tdata(input_bfd)->local_got_entries;
     4386
     4387  tls_segment = elf_hash_table (info)->tls_segment;
     4388  if (tls_segment)
     4389    {
     4390      dtp_base = alpha_get_dtprel_base (tls_segment);
     4391      tp_base = alpha_get_tprel_base (tls_segment);
     4392    }
     4393  else
     4394    dtp_base = tp_base = 0;
     4395
    34294396  relend = relocs + input_section->reloc_count;
    3430   for (; rel < relend; rel++)
    3431     {
    3432       int r_type;
     4397  for (rel = relocs; rel < relend; rel++)
     4398    {
     4399      struct alpha_elf_link_hash_entry *h = NULL;
     4400      struct alpha_elf_got_entry *gotent;
     4401      bfd_reloc_status_type r;
    34334402      reloc_howto_type *howto;
    34344403      unsigned long r_symndx;
    3435       struct alpha_elf_link_hash_entry *h;
    3436       Elf_Internal_Sym *sym;
    3437       bfd_vma relocation;
     4404      Elf_Internal_Sym *sym = NULL;
     4405      asection *sec = NULL;
     4406      bfd_vma value;
    34384407      bfd_vma addend;
    3439       bfd_reloc_status_type r;
     4408      bfd_boolean dynamic_symbol_p;
     4409      bfd_boolean undef_weak_ref = FALSE;
     4410      unsigned long r_type;
    34404411
    34414412      r_type = ELF64_R_TYPE(rel->r_info);
    3442       if (r_type < 0 || r_type >= (int) R_ALPHA_max)
    3443         {
     4413      if (r_type >= R_ALPHA_max)
     4414        {
     4415          (*_bfd_error_handler)
     4416            (_("%s: unknown relocation type %d"),
     4417             bfd_archive_filename (input_bfd), (int)r_type);
    34444418          bfd_set_error (bfd_error_bad_value);
    3445           return false;
    3446         }
     4419          ret_val = FALSE;
     4420          continue;
     4421        }
     4422
    34474423      howto = elf64_alpha_howto_table + r_type;
    3448 
    34494424      r_symndx = ELF64_R_SYM(rel->r_info);
    34504425
    3451       if (info->relocateable)
    3452         {
    3453           /* This is a relocateable link.  We don't have to change
    3454              anything, unless the reloc is against a section symbol,
    3455              in which case we have to adjust according to where the
    3456              section symbol winds up in the output section.  */
    3457 
    3458           /* The symbol associated with GPDISP and LITUSE is
    3459              immaterial.  Only the addend is significant.  */
    3460           if (r_type == R_ALPHA_GPDISP || r_type == R_ALPHA_LITUSE)
    3461             continue;
    3462 
    3463           if (r_symndx < symtab_hdr->sh_info)
     4426      /* The symbol for a TLSLDM reloc is ignored.  Collapse the
     4427         reloc to the 0 symbol so that they all match.  */
     4428      if (r_type == R_ALPHA_TLSLDM)
     4429        r_symndx = 0;
     4430
     4431      if (r_symndx < symtab_hdr->sh_info)
     4432        {
     4433          sym = local_syms + r_symndx;
     4434          sec = local_sections[r_symndx];
     4435          value = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
     4436
     4437          /* If this is a tp-relative relocation against sym 0,
     4438             this is hackery from relax_section.  Force the value to
     4439             be the tls base.  */
     4440          if (r_symndx == 0
     4441              && (r_type == R_ALPHA_TLSLDM
     4442                  || r_type == R_ALPHA_GOTTPREL
     4443                  || r_type == R_ALPHA_TPREL64
     4444                  || r_type == R_ALPHA_TPRELHI
     4445                  || r_type == R_ALPHA_TPRELLO
     4446                  || r_type == R_ALPHA_TPREL16))
     4447            value = tp_base;
     4448
     4449          if (local_got_entries)
     4450            gotent = local_got_entries[r_symndx];
     4451          else
     4452            gotent = NULL;
     4453
     4454          /* Need to adjust local GOT entries' addends for SEC_MERGE
     4455             unless it has been done already.  */
     4456          if ((sec->flags & SEC_MERGE)
     4457              && ELF_ST_TYPE (sym->st_info) == STT_SECTION
     4458              && sec->sec_info_type == ELF_INFO_TYPE_MERGE
     4459              && gotent
     4460              && !gotent->reloc_xlated)
    34644461            {
    3465               sym = local_syms + r_symndx;
    3466               if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
     4462              struct alpha_elf_got_entry *ent;
     4463              asection *msec;
     4464
     4465              for (ent = gotent; ent; ent = ent->next)
    34674466                {
    3468                   sec = local_sections[r_symndx];
    3469                   rel->r_addend += sec->output_offset + sym->st_value;
     4467                  ent->reloc_xlated = 1;
     4468                  if (ent->use_count == 0)
     4469                    continue;
     4470                  msec = sec;
     4471                  ent->addend =
     4472                    _bfd_merged_section_offset (output_bfd, &msec,
     4473                                                elf_section_data (sec)->
     4474                                                  sec_info,
     4475                                                sym->st_value + ent->addend,
     4476                                                (bfd_vma) 0);
     4477                  ent->addend -= sym->st_value;
     4478                  ent->addend += msec->output_section->vma
     4479                                 + msec->output_offset
     4480                                 - sec->output_section->vma
     4481                                 - sec->output_offset;
    34704482                }
    34714483            }
    34724484
    3473           continue;
    3474         }
    3475 
    3476       /* This is a final link.  */
    3477 
    3478       h = NULL;
    3479       sym = NULL;
    3480       sec = NULL;
    3481 
    3482       if (r_symndx < symtab_hdr->sh_info)
    3483         {
    3484           sym = local_syms + r_symndx;
    3485           sec = local_sections[r_symndx];
    3486           relocation = (sec->output_section->vma
    3487                         + sec->output_offset
    3488                         + sym->st_value);
     4485          dynamic_symbol_p = FALSE;
    34894486        }
    34904487      else
     
    34964493            h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
    34974494
     4495          value = 0;
    34984496          if (h->root.root.type == bfd_link_hash_defined
    34994497              || h->root.root.type == bfd_link_hash_defweak)
     
    35014499              sec = h->root.root.u.def.section;
    35024500
    3503 #if rth_notdef
    3504               if ((r_type == R_ALPHA_LITERAL
    3505                    && elf_hash_table(info)->dynamic_sections_created
    3506                    && (!info->shared
    3507                        || !info->symbolic
    3508                        || !(h->root.elf_link_hash_flags
    3509                             & ELF_LINK_HASH_DEF_REGULAR)))
    3510                   || (info->shared
    3511                       && (!info->symbolic
    3512                           || !(h->root.elf_link_hash_flags
    3513                                & ELF_LINK_HASH_DEF_REGULAR))
    3514                       && (input_section->flags & SEC_ALLOC)
    3515                       && (r_type == R_ALPHA_REFLONG
    3516                           || r_type == R_ALPHA_REFQUAD
    3517                           || r_type == R_ALPHA_LITERAL)))
    3518                 {
    3519                   /* In these cases, we don't need the relocation value.
    3520                      We check specially because in some obscure cases
    3521                      sec->output_section will be NULL.  */
    3522                   relocation = 0;
    3523                 }
    3524 #else
    3525               /* FIXME: Are not these obscure cases simply bugs?  Let's
    3526                  get something working and come back to this.  */
    3527               if (sec->output_section == NULL)
    3528                 relocation = 0;
    3529 #endif /* rth_notdef */
    3530               else
    3531                 {
    3532                   relocation = (h->root.root.u.def.value
    3533                                 + sec->output_section->vma
    3534                                 + sec->output_offset);
    3535                 }
     4501              /* Detect the cases that sym_sec->output_section is
     4502                 expected to be NULL -- all cases in which the symbol
     4503                 is defined in another shared module.  This includes
     4504                 PLT relocs for which we've created a PLT entry and
     4505                 other relocs for which we're prepared to create
     4506                 dynamic relocations.  */
     4507              /* ??? Just accept it NULL and continue.  */
     4508
     4509              if (sec->output_section != NULL)
     4510                value = (h->root.root.u.def.value
     4511                         + sec->output_section->vma
     4512                              + sec->output_offset);
    35364513            }
    35374514          else if (h->root.root.type == bfd_link_hash_undefweak)
    3538             relocation = 0;
    3539           else if (info->shared && !info->symbolic
     4515            undef_weak_ref = TRUE;
     4516          else if (info->shared
    35404517                   && !info->no_undefined
    35414518                   && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
    3542             relocation = 0;
     4519            ;
    35434520          else
    35444521            {
     
    35484525                     (!info->shared || info->no_undefined
    35494526                      || ELF_ST_VISIBILITY (h->root.other)))))
    3550                 return false;
    3551               relocation = 0;
     4527                return FALSE;
     4528              continue;
    35524529            }
    3553         }
     4530
     4531          dynamic_symbol_p = alpha_elf_dynamic_symbol_p (&h->root, info);
     4532          gotent = h->got_entries;
     4533        }
     4534
    35544535      addend = rel->r_addend;
     4536      value += addend;
     4537
     4538      /* Search for the proper got entry.  */
     4539      for (; gotent ; gotent = gotent->next)
     4540        if (gotent->gotobj == gotobj
     4541            && gotent->reloc_type == r_type
     4542            && gotent->addend == addend)
     4543          break;
    35554544
    35564545      switch (r_type)
     
    35624551            BFD_ASSERT(gp != 0);
    35634552
    3564             relocation = (input_section->output_section->vma
    3565                           + input_section->output_offset
    3566                           + rel->r_offset);
    3567 
    3568             p_ldah = contents + rel->r_offset - input_section->vma;
     4553            value = (input_section->output_section->vma
     4554                     + input_section->output_offset
     4555                     + rel->r_offset);
     4556
     4557            p_ldah = contents + rel->r_offset;
    35694558            p_lda = p_ldah + rel->r_addend;
    35704559
    3571             r = elf64_alpha_do_reloc_gpdisp (input_bfd, gp - relocation,
     4560            r = elf64_alpha_do_reloc_gpdisp (input_bfd, gp - value,
    35724561                                             p_ldah, p_lda);
    35734562          }
    35744563          break;
    35754564
    3576         case R_ALPHA_OP_PUSH:
    3577         case R_ALPHA_OP_STORE:
    3578         case R_ALPHA_OP_PSUB:
    3579         case R_ALPHA_OP_PRSHIFT:
    3580           /* We hate these silly beasts.  */
    3581           abort ();
    3582 
    35834565        case R_ALPHA_LITERAL:
    3584           {
    3585             struct alpha_elf_got_entry *gotent;
    3586             boolean dynamic_symbol;
    3587 
    3588             BFD_ASSERT(sgot != NULL);
    3589             BFD_ASSERT(gp != 0);
    3590 
    3591             if (h != NULL)
    3592               {
    3593                 gotent = h->got_entries;
    3594                 dynamic_symbol = alpha_elf_dynamic_symbol_p (&h->root, info);
    3595               }
    3596             else
    3597               {
    3598                 gotent = (alpha_elf_tdata(input_bfd)->
    3599                           local_got_entries[r_symndx]);
    3600                 dynamic_symbol = false;
    3601               }
    3602 
    3603             BFD_ASSERT(gotent != NULL);
    3604 
    3605             while (gotent->gotobj != gotobj || gotent->addend != addend)
    3606               gotent = gotent->next;
    3607 
    3608             BFD_ASSERT(gotent->use_count >= 1);
    3609 
    3610             /* Initialize the .got entry's value.  */
    3611             if (!(gotent->flags & ALPHA_ELF_GOT_ENTRY_RELOCS_DONE))
    3612               {
    3613                 bfd_put_64 (output_bfd, relocation+addend,
    3614                             sgot->contents + gotent->got_offset);
    3615 
    3616                 /* If the symbol has been forced local, output a
    3617                    RELATIVE reloc, otherwise it will be handled in
    3618                    finish_dynamic_symbol.  */
    3619                 if (info->shared && !dynamic_symbol)
    3620                   {
    3621                     Elf_Internal_Rela outrel;
    3622 
    3623                     BFD_ASSERT(srelgot != NULL);
    3624 
    3625                     outrel.r_offset = (sgot->output_section->vma
    3626                                        + sgot->output_offset
    3627                                        + gotent->got_offset);
    3628                     outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
    3629                     outrel.r_addend = 0;
    3630 
    3631                     bfd_elf64_swap_reloca_out (output_bfd, &outrel,
    3632                                                ((Elf64_External_Rela *)
    3633                                                 srelgot->contents)
    3634                                                + srelgot->reloc_count++);
    3635                     BFD_ASSERT (sizeof (Elf64_External_Rela)
    3636                                 * srelgot->reloc_count
    3637                                 <= srelgot->_cooked_size);
    3638                   }
    3639 
    3640                 gotent->flags |= ALPHA_ELF_GOT_ENTRY_RELOCS_DONE;
    3641               }
    3642 
    3643             /* Figure the gprel relocation.  */
    3644             addend = 0;
    3645             relocation = (sgot->output_section->vma
    3646                           + sgot->output_offset
    3647                           + gotent->got_offset);
    3648             relocation -= gp;
    3649           }
    3650           /* overflow handled by _bfd_final_link_relocate */
     4566          BFD_ASSERT(sgot != NULL);
     4567          BFD_ASSERT(gp != 0);
     4568          BFD_ASSERT(gotent != NULL);
     4569          BFD_ASSERT(gotent->use_count >= 1);
     4570
     4571          if (!gotent->reloc_done)
     4572            {
     4573              gotent->reloc_done = 1;
     4574
     4575              bfd_put_64 (output_bfd, value,
     4576                          sgot->contents + gotent->got_offset);
     4577
     4578              /* If the symbol has been forced local, output a
     4579                 RELATIVE reloc, otherwise it will be handled in
     4580                 finish_dynamic_symbol.  */
     4581              if (info->shared && !dynamic_symbol_p)
     4582                elf64_alpha_emit_dynrel (output_bfd, info, sgot, srelgot,
     4583                                         gotent->got_offset, 0,
     4584                                         R_ALPHA_RELATIVE, value);
     4585            }
     4586
     4587          value = (sgot->output_section->vma
     4588                   + sgot->output_offset
     4589                   + gotent->got_offset);
     4590          value -= gp;
    36514591          goto default_reloc;
    36524592
    36534593        case R_ALPHA_GPREL32:
     4594          /* If the target section was a removed linkonce section,
     4595             r_symndx will be zero.  In this case, assume that the
     4596             switch will not be used, so don't fill it in.  If we
     4597             do nothing here, we'll get relocation truncated messages,
     4598             due to the placement of the application above 4GB.  */
     4599          if (r_symndx == 0)
     4600            {
     4601              r = bfd_reloc_ok;
     4602              break;
     4603            }
     4604          /* FALLTHRU */
     4605
     4606        case R_ALPHA_GPREL16:
    36544607        case R_ALPHA_GPRELLOW:
     4608          if (dynamic_symbol_p)
     4609            {
     4610              (*_bfd_error_handler)
     4611                (_("%s: gp-relative relocation against dynamic symbol %s"),
     4612                 bfd_archive_filename (input_bfd), h->root.root.root.string);
     4613              ret_val = FALSE;
     4614            }
    36554615          BFD_ASSERT(gp != 0);
    3656           relocation -= gp;
     4616          value -= gp;
    36574617          goto default_reloc;
    36584618
    36594619        case R_ALPHA_GPRELHIGH:
     4620          if (dynamic_symbol_p)
     4621            {
     4622              (*_bfd_error_handler)
     4623                (_("%s: gp-relative relocation against dynamic symbol %s"),
     4624                 bfd_archive_filename (input_bfd), h->root.root.root.string);
     4625              ret_val = FALSE;
     4626            }
    36604627          BFD_ASSERT(gp != 0);
    3661           relocation -= gp;
    3662           relocation += addend;
    3663           addend = 0;
    3664           relocation = (((bfd_signed_vma) relocation >> 16)
    3665                         + ((relocation >> 15) & 1));
     4628          value -= gp;
     4629          value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1);
    36664630          goto default_reloc;
    36674631
    3668         case R_ALPHA_BRADDR:
    36694632        case R_ALPHA_HINT:
     4633          /* A call to a dynamic symbol is definitely out of range of
     4634             the 16-bit displacement.  Don't bother writing anything.  */
     4635          if (dynamic_symbol_p)
     4636            {
     4637              r = bfd_reloc_ok;
     4638              break;
     4639            }
    36704640          /* The regular PC-relative stuff measures from the start of
    36714641             the instruction rather than the end.  */
    3672           addend -= 4;
     4642          value -= 4;
    36734643          goto default_reloc;
     4644
     4645        case R_ALPHA_BRADDR:
     4646          if (dynamic_symbol_p)
     4647            {
     4648              (*_bfd_error_handler)
     4649                (_("%s: pc-relative relocation against dynamic symbol %s"),
     4650                 bfd_archive_filename (input_bfd), h->root.root.root.string);
     4651              ret_val = FALSE;
     4652            }
     4653          /* The regular PC-relative stuff measures from the start of
     4654             the instruction rather than the end.  */
     4655          value -= 4;
     4656          goto default_reloc;
     4657
     4658        case R_ALPHA_BRSGP:
     4659          {
     4660            int other;
     4661            const char *name;
     4662
     4663            /* The regular PC-relative stuff measures from the start of
     4664               the instruction rather than the end.  */
     4665            value -= 4;
     4666
     4667            /* The source and destination gp must be the same.  Note that
     4668               the source will always have an assigned gp, since we forced
     4669               one in check_relocs, but that the destination may not, as
     4670               it might not have had any relocations at all.  Also take
     4671               care not to crash if H is an undefined symbol.  */
     4672            if (h != NULL && sec != NULL
     4673                && alpha_elf_tdata (sec->owner)->gotobj
     4674                && gotobj != alpha_elf_tdata (sec->owner)->gotobj)
     4675              {
     4676                (*_bfd_error_handler)
     4677                  (_("%s: change in gp: BRSGP %s"),
     4678                   bfd_archive_filename (input_bfd), h->root.root.root.string);
     4679                ret_val = FALSE;
     4680              }
     4681
     4682            /* The symbol should be marked either NOPV or STD_GPLOAD.  */
     4683            if (h != NULL)
     4684              other = h->root.other;
     4685            else
     4686              other = sym->st_other;
     4687            switch (other & STO_ALPHA_STD_GPLOAD)
     4688              {
     4689              case STO_ALPHA_NOPV:
     4690                break;
     4691              case STO_ALPHA_STD_GPLOAD:
     4692                value += 8;
     4693                break;
     4694              default:
     4695                if (h != NULL)
     4696                  name = h->root.root.root.string;
     4697                else
     4698                  {
     4699                    name = (bfd_elf_string_from_elf_section
     4700                            (input_bfd, symtab_hdr->sh_link, sym->st_name));
     4701                    if (name == NULL)
     4702                      name = _("<unknown>");
     4703                    else if (name[0] == 0)
     4704                      name = bfd_section_name (input_bfd, sec);
     4705                  }
     4706                (*_bfd_error_handler)
     4707                  (_("%s: !samegp reloc against symbol without .prologue: %s"),
     4708                   bfd_archive_filename (input_bfd), name);
     4709                ret_val = FALSE;
     4710                break;
     4711              }
     4712
     4713            goto default_reloc;
     4714          }
    36744715
    36754716        case R_ALPHA_REFLONG:
    36764717        case R_ALPHA_REFQUAD:
     4718        case R_ALPHA_DTPREL64:
     4719        case R_ALPHA_TPREL64:
    36774720          {
    3678             Elf_Internal_Rela outrel;
    3679             boolean skip;
     4721            long dynindx, dyntype = r_type;
     4722            bfd_vma dynaddend;
    36804723
    36814724            /* Careful here to remember RELATIVE relocations for global
    36824725               variables for symbolic shared objects.  */
    36834726
    3684             if (h && alpha_elf_dynamic_symbol_p (&h->root, info))
     4727            if (dynamic_symbol_p)
    36854728              {
    36864729                BFD_ASSERT(h->root.dynindx != -1);
    3687                 outrel.r_info = ELF64_R_INFO(h->root.dynindx, r_type);
    3688                 outrel.r_addend = addend;
    3689                 addend = 0, relocation = 0;
     4730                dynindx = h->root.dynindx;
     4731                dynaddend = addend;
     4732                addend = 0, value = 0;
    36904733              }
    3691             else if (info->shared && (input_section->flags & SEC_ALLOC))
     4734            else if (r_type == R_ALPHA_DTPREL64)
    36924735              {
    3693                 outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
    3694                 outrel.r_addend = 0;
     4736                BFD_ASSERT(tls_segment != NULL);
     4737                value -= dtp_base;
     4738                goto default_reloc;
     4739              }
     4740            else if (r_type == R_ALPHA_TPREL64)
     4741              {
     4742                BFD_ASSERT(tls_segment != NULL);
     4743                if (!info->shared)
     4744                  {
     4745                    value -= tp_base;
     4746                    goto default_reloc;
     4747                  }
     4748                dynindx = 0;
     4749                dynaddend = value - dtp_base;
     4750              }
     4751            else if (info->shared
     4752                     && r_symndx != 0
     4753                     && (input_section->flags & SEC_ALLOC))
     4754              {
     4755                if (r_type == R_ALPHA_REFLONG)
     4756                  {
     4757                    (*_bfd_error_handler)
     4758                      (_("%s: unhandled dynamic relocation against %s"),
     4759                       bfd_archive_filename (input_bfd),
     4760                       h->root.root.root.string);
     4761                    ret_val = FALSE;
     4762                  }
     4763                dynindx = 0;
     4764                dyntype = R_ALPHA_RELATIVE;
     4765                dynaddend = value;
    36954766              }
    36964767            else
    36974768              goto default_reloc;
    36984769
    3699             if (!srel)
    3700               {
    3701                 const char *name;
    3702 
    3703                 name = (bfd_elf_string_from_elf_section
    3704                         (input_bfd, elf_elfheader(input_bfd)->e_shstrndx,
    3705                          elf_section_data(input_section)->rel_hdr.sh_name));
    3706                 BFD_ASSERT(name != NULL);
    3707 
    3708                 srel = bfd_get_section_by_name (dynobj, name);
    3709                 BFD_ASSERT(srel != NULL);
    3710               }
    3711 
    3712             skip = false;
    3713 
    3714             if (elf_section_data (input_section)->stab_info == NULL)
    3715               outrel.r_offset = rel->r_offset;
    3716             else
    3717               {
    3718                 bfd_vma off;
    3719 
    3720                 off = (_bfd_stab_section_offset
    3721                        (output_bfd, &elf_hash_table (info)->stab_info,
    3722                         input_section,
    3723                         &elf_section_data (input_section)->stab_info,
    3724                         rel->r_offset));
    3725                 if (off == (bfd_vma) -1)
    3726                   skip = true;
    3727                 outrel.r_offset = off;
    3728               }
    3729 
    3730             if (! skip)
    3731               outrel.r_offset += (input_section->output_section->vma
    3732                                   + input_section->output_offset);
    3733             else
    3734               memset (&outrel, 0, sizeof outrel);
    3735 
    3736             bfd_elf64_swap_reloca_out (output_bfd, &outrel,
    3737                                        ((Elf64_External_Rela *)
    3738                                         srel->contents)
    3739                                        + srel->reloc_count++);
    3740             BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
    3741                         <= srel->_cooked_size);
     4770            elf64_alpha_emit_dynrel (output_bfd, info, input_section,
     4771                                     srel, rel->r_offset, dynindx,
     4772                                     dyntype, dynaddend);
    37424773          }
     4774          goto default_reloc;
     4775
     4776        case R_ALPHA_SREL16:
     4777        case R_ALPHA_SREL32:
     4778        case R_ALPHA_SREL64:
     4779          if (dynamic_symbol_p)
     4780            {
     4781              (*_bfd_error_handler)
     4782                (_("%s: pc-relative relocation against dynamic symbol %s"),
     4783                 bfd_archive_filename (input_bfd), h->root.root.root.string);
     4784              ret_val = FALSE;
     4785            }
     4786
     4787          /* ??? .eh_frame references to discarded sections will be smashed
     4788             to relocations against SHN_UNDEF.  The .eh_frame format allows
     4789             NULL to be encoded as 0 in any format, so this works here.  */
     4790          if (r_symndx == 0)
     4791            howto = (elf64_alpha_howto_table
     4792                     + (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG));
     4793          goto default_reloc;
     4794
     4795        case R_ALPHA_TLSLDM:
     4796          /* Ignore the symbol for the relocation.  The result is always
     4797             the current module.  */
     4798          dynamic_symbol_p = 0;
     4799          /* FALLTHRU */
     4800
     4801        case R_ALPHA_TLSGD:
     4802          if (!gotent->reloc_done)
     4803            {
     4804              gotent->reloc_done = 1;
     4805
     4806              /* Note that the module index for the main program is 1.  */
     4807              bfd_put_64 (output_bfd, !info->shared && !dynamic_symbol_p,
     4808                          sgot->contents + gotent->got_offset);
     4809
     4810              /* If the symbol has been forced local, output a
     4811                 DTPMOD64 reloc, otherwise it will be handled in
     4812                 finish_dynamic_symbol.  */
     4813              if (info->shared && !dynamic_symbol_p)
     4814                elf64_alpha_emit_dynrel (output_bfd, info, sgot, srelgot,
     4815                                         gotent->got_offset, 0,
     4816                                         R_ALPHA_DTPMOD64, 0);
     4817
     4818              if (dynamic_symbol_p || r_type == R_ALPHA_TLSLDM)
     4819                value = 0;
     4820              else
     4821                {
     4822                  BFD_ASSERT(tls_segment != NULL);
     4823                  value -= dtp_base;
     4824                }
     4825              bfd_put_64 (output_bfd, value,
     4826                          sgot->contents + gotent->got_offset + 8);
     4827            }
     4828
     4829          value = (sgot->output_section->vma
     4830                   + sgot->output_offset
     4831                   + gotent->got_offset);
     4832          value -= gp;
     4833          goto default_reloc;
     4834
     4835        case R_ALPHA_DTPRELHI:
     4836        case R_ALPHA_DTPRELLO:
     4837        case R_ALPHA_DTPREL16:
     4838          if (dynamic_symbol_p)
     4839            {
     4840              (*_bfd_error_handler)
     4841                (_("%s: dtp-relative relocation against dynamic symbol %s"),
     4842                 bfd_archive_filename (input_bfd), h->root.root.root.string);
     4843              ret_val = FALSE;
     4844            }
     4845          BFD_ASSERT(tls_segment != NULL);
     4846          value -= dtp_base;
     4847          if (r_type == R_ALPHA_DTPRELHI)
     4848            value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1);
     4849          goto default_reloc;
     4850
     4851        case R_ALPHA_TPRELHI:
     4852        case R_ALPHA_TPRELLO:
     4853        case R_ALPHA_TPREL16:
     4854          if (info->shared)
     4855            {
     4856              (*_bfd_error_handler)
     4857                (_("%s: TLS local exec code cannot be linked into shared objects"),
     4858                bfd_archive_filename (input_bfd));
     4859              ret_val = FALSE;
     4860            }
     4861          else if (dynamic_symbol_p)
     4862            {
     4863              (*_bfd_error_handler)
     4864                (_("%s: tp-relative relocation against dynamic symbol %s"),
     4865                 bfd_archive_filename (input_bfd), h->root.root.root.string);
     4866              ret_val = FALSE;
     4867            }
     4868          BFD_ASSERT(tls_segment != NULL);
     4869          value -= tp_base;
     4870          if (r_type == R_ALPHA_TPRELHI)
     4871            value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1);
     4872          goto default_reloc;
     4873
     4874        case R_ALPHA_GOTDTPREL:
     4875        case R_ALPHA_GOTTPREL:
     4876          BFD_ASSERT(sgot != NULL);
     4877          BFD_ASSERT(gp != 0);
     4878          BFD_ASSERT(gotent != NULL);
     4879          BFD_ASSERT(gotent->use_count >= 1);
     4880
     4881          if (!gotent->reloc_done)
     4882            {
     4883              gotent->reloc_done = 1;
     4884
     4885              if (dynamic_symbol_p)
     4886                value = 0;
     4887              else
     4888                {
     4889                  BFD_ASSERT(tls_segment != NULL);
     4890                  if (r_type == R_ALPHA_GOTDTPREL)
     4891                    value -= dtp_base;
     4892                  else if (!info->shared)
     4893                    value -= tp_base;
     4894                  else
     4895                    {
     4896                      elf64_alpha_emit_dynrel (output_bfd, info, sgot, srelgot,
     4897                                               gotent->got_offset, 0,
     4898                                               R_ALPHA_TPREL64,
     4899                                               value - dtp_base);
     4900                      value = 0;
     4901                    }
     4902                }
     4903              bfd_put_64 (output_bfd, value,
     4904                          sgot->contents + gotent->got_offset);
     4905            }
     4906
     4907          value = (sgot->output_section->vma
     4908                   + sgot->output_offset
     4909                   + gotent->got_offset);
     4910          value -= gp;
    37434911          goto default_reloc;
    37444912
     
    37464914        default_reloc:
    37474915          r = _bfd_final_link_relocate (howto, input_bfd, input_section,
    3748                                         contents, rel->r_offset, relocation,
    3749                                         addend);
     4916                                        contents, rel->r_offset, value, 0);
    37504917          break;
    37514918        }
     
    37594926          {
    37604927            const char *name;
     4928
     4929            /* Don't warn if the overflow is due to pc relative reloc
     4930               against discarded section.  Section optimization code should
     4931               handle it.  */
     4932
     4933            if (r_symndx < symtab_hdr->sh_info
     4934                && sec != NULL && howto->pc_relative
     4935                && elf_discarded_section (sec))
     4936              break;
    37614937
    37624938            if (h != NULL)
     
    37674943                        (input_bfd, symtab_hdr->sh_link, sym->st_name));
    37684944                if (name == NULL)
    3769                   return false;
     4945                  return FALSE;
    37704946                if (*name == '\0')
    37714947                  name = bfd_section_name (input_bfd, sec);
     
    37744950                   (info, name, howto->name, (bfd_vma) 0,
    37754951                    input_bfd, input_section, rel->r_offset)))
    3776               return false;
     4952              ret_val = FALSE;
    37774953          }
    37784954          break;
     
    37844960    }
    37854961
    3786   return true;
     4962  return ret_val;
    37874963}
    37884964
     
    37904966   dynamic sections here.  */
    37914967
    3792 static boolean
     4968static bfd_boolean
    37934969elf64_alpha_finish_dynamic_symbol (output_bfd, info, h, sym)
    37944970     bfd *output_bfd;
     
    38044980      asection *splt, *sgot, *srel;
    38054981      Elf_Internal_Rela outrel;
     4982      bfd_byte *loc;
    38064983      bfd_vma got_addr, plt_addr;
    38074984      bfd_vma plt_index;
     
    38335010      /* Fill in the entry in the procedure linkage table.  */
    38345011      {
    3835         unsigned insn1, insn2, insn3;
     5012        bfd_vma insn1, insn2, insn3;
    38365013
    38375014        insn1 = PLT_ENTRY_WORD1 | ((-(h->plt.offset + 4) >> 2) & 0x1fffff);
     
    38495026      outrel.r_addend = 0;
    38505027
    3851       bfd_elf64_swap_reloca_out (output_bfd, &outrel,
    3852                                  ((Elf64_External_Rela *)srel->contents
    3853                                   + plt_index));
     5028      loc = srel->contents + plt_index * sizeof (Elf64_External_Rela);
     5029      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
    38545030
    38555031      if (!(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
     
    38805056
    38815057              if (info->shared)
    3882                 {
    3883                   outrel.r_offset = (sgot->output_section->vma
    3884                                      + sgot->output_offset
    3885                                      + gotent->got_offset);
    3886                   outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
    3887                   outrel.r_addend = 0;
    3888 
    3889                   bfd_elf64_swap_reloca_out (output_bfd, &outrel,
    3890                                              ((Elf64_External_Rela *)
    3891                                               srel->contents)
    3892                                              + srel->reloc_count++);
    3893                   BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
    3894                               <= srel->_cooked_size);
    3895                 }
     5058                elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel,
     5059                                         gotent->got_offset, 0,
     5060                                         R_ALPHA_RELATIVE, plt_addr);
    38965061
    38975062              gotent = gotent->next;
     
    39045069      /* Fill in the dynamic relocations for this symbol's .got entries.  */
    39055070      asection *srel;
    3906       Elf_Internal_Rela outrel;
    39075071      struct alpha_elf_got_entry *gotent;
    39085072
     
    39105074      BFD_ASSERT (srel != NULL);
    39115075
    3912       outrel.r_info = ELF64_R_INFO (h->dynindx, R_ALPHA_GLOB_DAT);
    39135076      for (gotent = ((struct alpha_elf_link_hash_entry *) h)->got_entries;
    39145077           gotent != NULL;
    39155078           gotent = gotent->next)
    39165079        {
    3917           asection *sgot = alpha_elf_tdata (gotent->gotobj)->got;
    3918           outrel.r_offset = (sgot->output_section->vma
    3919                              + sgot->output_offset
    3920                              + gotent->got_offset);
    3921           outrel.r_addend = gotent->addend;
    3922 
    3923           bfd_elf64_swap_reloca_out (output_bfd, &outrel,
    3924                                      ((Elf64_External_Rela *)srel->contents
    3925                                       + srel->reloc_count++));
    3926           BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count
    3927                       <= srel->_cooked_size);
     5080          asection *sgot;
     5081          long r_type;
     5082
     5083          if (gotent->use_count == 0)
     5084            continue;
     5085
     5086          sgot = alpha_elf_tdata (gotent->gotobj)->got;
     5087
     5088          r_type = gotent->reloc_type;
     5089          switch (r_type)
     5090            {
     5091            case R_ALPHA_LITERAL:
     5092              r_type = R_ALPHA_GLOB_DAT;
     5093              break;
     5094            case R_ALPHA_TLSGD:
     5095              r_type = R_ALPHA_DTPMOD64;
     5096              break;
     5097            case R_ALPHA_GOTDTPREL:
     5098              r_type = R_ALPHA_DTPREL64;
     5099              break;
     5100            case R_ALPHA_GOTTPREL:
     5101              r_type = R_ALPHA_TPREL64;
     5102              break;
     5103            case R_ALPHA_TLSLDM:
     5104            default:
     5105              abort ();
     5106            }
     5107
     5108          elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel,
     5109                                   gotent->got_offset, h->dynindx,
     5110                                   r_type, gotent->addend);
     5111
     5112          if (gotent->reloc_type == R_ALPHA_TLSGD)
     5113            elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel,
     5114                                     gotent->got_offset + 8, h->dynindx,
     5115                                     R_ALPHA_DTPREL64, gotent->addend);
    39285116        }
    39295117    }
     
    39355123    sym->st_shndx = SHN_ABS;
    39365124
    3937   return true;
     5125  return TRUE;
    39385126}
    39395127
    39405128/* Finish up the dynamic sections.  */
    39415129
    3942 static boolean
     5130static bfd_boolean
    39435131elf64_alpha_finish_dynamic_sections (output_bfd, info)
    39445132     bfd *output_bfd;
     
    40105198        }
    40115199
    4012       /* Initialize the PLT0 entry */
     5200      /* Initialize the PLT0 entry. */
    40135201      if (splt->_raw_size > 0)
    40145202        {
     
    40195207
    40205208          /* The next two words will be filled in by ld.so */
    4021           bfd_put_64 (output_bfd, 0, splt->contents + 16);
    4022           bfd_put_64 (output_bfd, 0, splt->contents + 24);
    4023 
    4024           elf_section_data (splt->output_section)->this_hdr.sh_entsize =
    4025             PLT_HEADER_SIZE;
    4026         }
    4027     }
    4028 
    4029   return true;
     5209          bfd_put_64 (output_bfd, (bfd_vma) 0, splt->contents + 16);
     5210          bfd_put_64 (output_bfd, (bfd_vma) 0, splt->contents + 24);
     5211
     5212          elf_section_data (splt->output_section)->this_hdr.sh_entsize = 0;
     5213        }
     5214    }
     5215
     5216  return TRUE;
    40305217}
    40315218
    4032 /* We need to use a special link routine to handle the .reginfo and
    4033    the .mdebug sections.  We need to merge all instances of these
    4034    sections together, not write them all out sequentially.  */
    4035 
    4036 static boolean
     5219/* We need to use a special link routine to handle the .mdebug section.
     5220   We need to merge all instances of these sections together, not write
     5221   them all out sequentially.  */
     5222
     5223static bfd_boolean
    40375224elf64_alpha_final_link (abfd, info)
    40385225     bfd *abfd;
     
    40415228  asection *o;
    40425229  struct bfd_link_order *p;
    4043   asection *reginfo_sec, *mdebug_sec, *gptab_data_sec, *gptab_bss_sec;
     5230  asection *mdebug_sec;
    40445231  struct ecoff_debug_info debug;
    40455232  const struct ecoff_debug_swap *swap
     
    40485235  PTR mdebug_handle = NULL;
    40495236
    4050 #if 0
    4051               if (++ngots == 2)
    4052                 {
    4053                   (*info->callbacks->warning)
    4054                     (info, _("using multiple gp values"), (char *) NULL,
    4055                      output_bfd, (asection *) NULL, (bfd_vma) 0);
    4056                 }
    4057 #endif
    4058 
    4059   /* Go through the sections and collect the .reginfo and .mdebug
    4060      information.  */
    4061   reginfo_sec = NULL;
     5237  /* Go through the sections and collect the mdebug information.  */
    40625238  mdebug_sec = NULL;
    4063   gptab_data_sec = NULL;
    4064   gptab_bss_sec = NULL;
    40655239  for (o = abfd->sections; o != (asection *) NULL; o = o->next)
    40665240    {
    4067 #ifdef ERIC_neverdef
    4068       if (strcmp (o->name, ".reginfo") == 0)
    4069         {
    4070           memset (&reginfo, 0, sizeof reginfo);
    4071 
    4072           /* We have found the .reginfo section in the output file.
    4073              Look through all the link_orders comprising it and merge
    4074              the information together.  */
    4075           for (p = o->link_order_head;
    4076                p != (struct bfd_link_order *) NULL;
    4077                p = p->next)
    4078             {
    4079               asection *input_section;
    4080               bfd *input_bfd;
    4081               Elf64_External_RegInfo ext;
    4082               Elf64_RegInfo sub;
    4083 
    4084               if (p->type != bfd_indirect_link_order)
    4085                 {
    4086                   if (p->type == bfd_fill_link_order)
    4087                     continue;
    4088                   abort ();
    4089                 }
    4090 
    4091               input_section = p->u.indirect.section;
    4092               input_bfd = input_section->owner;
    4093 
    4094               /* The linker emulation code has probably clobbered the
    4095                  size to be zero bytes.  */
    4096               if (input_section->_raw_size == 0)
    4097                 input_section->_raw_size = sizeof (Elf64_External_RegInfo);
    4098 
    4099               if (! bfd_get_section_contents (input_bfd, input_section,
    4100                                               (PTR) &ext,
    4101                                               (file_ptr) 0,
    4102                                               sizeof ext))
    4103                 return false;
    4104 
    4105               bfd_alpha_elf64_swap_reginfo_in (input_bfd, &ext, &sub);
    4106 
    4107               reginfo.ri_gprmask |= sub.ri_gprmask;
    4108               reginfo.ri_cprmask[0] |= sub.ri_cprmask[0];
    4109               reginfo.ri_cprmask[1] |= sub.ri_cprmask[1];
    4110               reginfo.ri_cprmask[2] |= sub.ri_cprmask[2];
    4111               reginfo.ri_cprmask[3] |= sub.ri_cprmask[3];
    4112 
    4113               /* ri_gp_value is set by the function
    4114                  alpha_elf_section_processing when the section is
    4115                  finally written out.  */
    4116 
    4117               /* Hack: reset the SEC_HAS_CONTENTS flag so that
    4118                  elf_link_input_bfd ignores this section.  */
    4119               input_section->flags &=~ SEC_HAS_CONTENTS;
    4120             }
    4121 
    4122           /* Force the section size to the value we want.  */
    4123           o->_raw_size = sizeof (Elf64_External_RegInfo);
    4124 
    4125           /* Skip this section later on (I don't think this currently
    4126              matters, but someday it might).  */
    4127           o->link_order_head = (struct bfd_link_order *) NULL;
    4128 
    4129           reginfo_sec = o;
    4130         }
    4131 #endif
    4132 
    41335241      if (strcmp (o->name, ".mdebug") == 0)
    41345242        {
     
    41705278          mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
    41715279          if (mdebug_handle == (PTR) NULL)
    4172             return false;
     5280            return FALSE;
    41735281
    41745282          if (1)
     
    41765284              asection *s;
    41775285              EXTR esym;
    4178               bfd_vma last;
     5286              bfd_vma last = 0;
    41795287              unsigned int i;
    41805288              static const char * const name[] =
     
    42095317                  if (! bfd_ecoff_debug_one_external (abfd, &debug, swap,
    42105318                                                      name[i], &esym))
    4211                     return false;
     5319                    return FALSE;
    42125320                }
    42135321            }
     
    42265334              if (p->type != bfd_indirect_link_order)
    42275335                {
    4228                   if (p->type == bfd_fill_link_order)
     5336                  if (p->type == bfd_data_link_order)
    42295337                    continue;
    42305338                  abort ();
     
    42545362              if (!elf64_alpha_read_ecoff_info (input_bfd, input_section,
    42555363                                                &input_debug))
    4256                 return false;
     5364                return FALSE;
    42575365
    42585366              if (! (bfd_ecoff_debug_accumulate
    42595367                     (mdebug_handle, abfd, &debug, swap, input_bfd,
    42605368                      &input_debug, input_swap, info)))
    4261                 return false;
     5369                return FALSE;
    42625370
    42635371              /* Loop through the external symbols.  For each one with
     
    42855393                  name = input_debug.ssext + ext.asym.iss;
    42865394                  h = alpha_elf_link_hash_lookup (alpha_elf_hash_table (info),
    4287                                                   name, false, false, true);
     5395                                                  name, FALSE, FALSE, TRUE);
    42885396                  if (h == NULL || h->esym.ifd != -2)
    42895397                    continue;
     
    43175425            }
    43185426
    4319 #ifdef ERIC_neverdef
    4320           if (info->shared)
    4321             {
    4322               /* Create .rtproc section.  */
    4323               rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
    4324               if (rtproc_sec == NULL)
    4325                 {
    4326                   flagword flags = (SEC_HAS_CONTENTS
    4327                                     | SEC_IN_MEMORY
    4328                                     | SEC_LINKER_CREATED
    4329                                     | SEC_READONLY);
    4330 
    4331                   rtproc_sec = bfd_make_section (abfd, ".rtproc");
    4332                   if (rtproc_sec == NULL
    4333                       || ! bfd_set_section_flags (abfd, rtproc_sec, flags)
    4334                       || ! bfd_set_section_alignment (abfd, rtproc_sec, 12))
    4335                     return false;
    4336                 }
    4337 
    4338               if (! alpha_elf_create_procedure_table (mdebug_handle, abfd,
    4339                                                      info, rtproc_sec, &debug))
    4340                 return false;
    4341             }
    4342 #endif
    4343 
    43445427          /* Build the external symbol information.  */
    43455428          einfo.abfd = abfd;
     
    43475430          einfo.debug = &debug;
    43485431          einfo.swap = swap;
    4349           einfo.failed = false;
     5432          einfo.failed = FALSE;
    43505433          elf_link_hash_traverse (elf_hash_table (info),
    43515434                                  elf64_alpha_output_extsym,
    43525435                                  (PTR) &einfo);
    43535436          if (einfo.failed)
    4354             return false;
     5437            return FALSE;
    43555438
    43565439          /* Set the size of the .mdebug section.  */
     
    43635446          mdebug_sec = o;
    43645447        }
    4365 
    4366 #ifdef ERIC_neverdef
    4367       if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0)
    4368         {
    4369           const char *subname;
    4370           unsigned int c;
    4371           Elf64_gptab *tab;
    4372           Elf64_External_gptab *ext_tab;
    4373           unsigned int i;
    4374 
    4375           /* The .gptab.sdata and .gptab.sbss sections hold
    4376              information describing how the small data area would
    4377              change depending upon the -G switch.  These sections
    4378              not used in executables files.  */
    4379           if (! info->relocateable)
    4380             {
    4381               asection **secpp;
    4382 
    4383               for (p = o->link_order_head;
    4384                    p != (struct bfd_link_order *) NULL;
    4385                    p = p->next)
    4386                 {
    4387                   asection *input_section;
    4388 
    4389                   if (p->type != bfd_indirect_link_order)
    4390                     {
    4391                       if (p->type == bfd_fill_link_order)
    4392                         continue;
    4393                       abort ();
    4394                     }
    4395 
    4396                   input_section = p->u.indirect.section;
    4397 
    4398                   /* Hack: reset the SEC_HAS_CONTENTS flag so that
    4399                      elf_link_input_bfd ignores this section.  */
    4400                   input_section->flags &=~ SEC_HAS_CONTENTS;
    4401                 }
    4402 
    4403               /* Skip this section later on (I don't think this
    4404                  currently matters, but someday it might).  */
    4405               o->link_order_head = (struct bfd_link_order *) NULL;
    4406 
    4407               /* Really remove the section.  */
    4408               for (secpp = &abfd->sections;
    4409                    *secpp != o;
    4410                    secpp = &(*secpp)->next)
    4411                 ;
    4412               *secpp = (*secpp)->next;
    4413               --abfd->section_count;
    4414 
    4415               continue;
    4416             }
    4417 
    4418           /* There is one gptab for initialized data, and one for
    4419              uninitialized data.  */
    4420           if (strcmp (o->name, ".gptab.sdata") == 0)
    4421             gptab_data_sec = o;
    4422           else if (strcmp (o->name, ".gptab.sbss") == 0)
    4423             gptab_bss_sec = o;
    4424           else
    4425             {
    4426               (*_bfd_error_handler)
    4427                 (_("%s: illegal section name `%s'"),
    4428                  bfd_get_filename (abfd), o->name);
    4429               bfd_set_error (bfd_error_nonrepresentable_section);
    4430               return false;
    4431             }
    4432 
    4433           /* The linker script always combines .gptab.data and
    4434              .gptab.sdata into .gptab.sdata, and likewise for
    4435              .gptab.bss and .gptab.sbss.  It is possible that there is
    4436              no .sdata or .sbss section in the output file, in which
    4437              case we must change the name of the output section.  */
    4438           subname = o->name + sizeof ".gptab" - 1;
    4439           if (bfd_get_section_by_name (abfd, subname) == NULL)
    4440             {
    4441               if (o == gptab_data_sec)
    4442                 o->name = ".gptab.data";
    4443               else
    4444                 o->name = ".gptab.bss";
    4445               subname = o->name + sizeof ".gptab" - 1;
    4446               BFD_ASSERT (bfd_get_section_by_name (abfd, subname) != NULL);
    4447             }
    4448 
    4449           /* Set up the first entry.  */
    4450           c = 1;
    4451           tab = (Elf64_gptab *) bfd_malloc (c * sizeof (Elf64_gptab));
    4452           if (tab == NULL)
    4453             return false;
    4454           tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd);
    4455           tab[0].gt_header.gt_unused = 0;
    4456 
    4457           /* Combine the input sections.  */
    4458           for (p = o->link_order_head;
    4459                p != (struct bfd_link_order *) NULL;
    4460                p = p->next)
    4461             {
    4462               asection *input_section;
    4463               bfd *input_bfd;
    4464               bfd_size_type size;
    4465               unsigned long last;
    4466               bfd_size_type gpentry;
    4467 
    4468               if (p->type != bfd_indirect_link_order)
    4469                 {
    4470                   if (p->type == bfd_fill_link_order)
    4471                     continue;
    4472                   abort ();
    4473                 }
    4474 
    4475               input_section = p->u.indirect.section;
    4476               input_bfd = input_section->owner;
    4477 
    4478               /* Combine the gptab entries for this input section one
    4479                  by one.  We know that the input gptab entries are
    4480                  sorted by ascending -G value.  */
    4481               size = bfd_section_size (input_bfd, input_section);
    4482               last = 0;
    4483               for (gpentry = sizeof (Elf64_External_gptab);
    4484                    gpentry < size;
    4485                    gpentry += sizeof (Elf64_External_gptab))
    4486                 {
    4487                   Elf64_External_gptab ext_gptab;
    4488                   Elf64_gptab int_gptab;
    4489                   unsigned long val;
    4490                   unsigned long add;
    4491                   boolean exact;
    4492                   unsigned int look;
    4493 
    4494                   if (! (bfd_get_section_contents
    4495                          (input_bfd, input_section, (PTR) &ext_gptab,
    4496                           gpentry, sizeof (Elf64_External_gptab))))
    4497                     {
    4498                       free (tab);
    4499                       return false;
    4500                     }
    4501 
    4502                   bfd_alpha_elf64_swap_gptab_in (input_bfd, &ext_gptab,
    4503                                                 &int_gptab);
    4504                   val = int_gptab.gt_entry.gt_g_value;
    4505                   add = int_gptab.gt_entry.gt_bytes - last;
    4506 
    4507                   exact = false;
    4508                   for (look = 1; look < c; look++)
    4509                     {
    4510                       if (tab[look].gt_entry.gt_g_value >= val)
    4511                         tab[look].gt_entry.gt_bytes += add;
    4512 
    4513                       if (tab[look].gt_entry.gt_g_value == val)
    4514                         exact = true;
    4515                     }
    4516 
    4517                   if (! exact)
    4518                     {
    4519                       Elf64_gptab *new_tab;
    4520                       unsigned int max;
    4521 
    4522                       /* We need a new table entry.  */
    4523                       new_tab = ((Elf64_gptab *)
    4524                                  bfd_realloc ((PTR) tab,
    4525                                               (c + 1) * sizeof (Elf64_gptab)));
    4526                       if (new_tab == NULL)
    4527                         {
    4528                           free (tab);
    4529                           return false;
    4530                         }
    4531                       tab = new_tab;
    4532                       tab[c].gt_entry.gt_g_value = val;
    4533                       tab[c].gt_entry.gt_bytes = add;
    4534 
    4535                       /* Merge in the size for the next smallest -G
    4536                          value, since that will be implied by this new
    4537                          value.  */
    4538                       max = 0;
    4539                       for (look = 1; look < c; look++)
    4540                         {
    4541                           if (tab[look].gt_entry.gt_g_value < val
    4542                               && (max == 0
    4543                                   || (tab[look].gt_entry.gt_g_value
    4544                                       > tab[max].gt_entry.gt_g_value)))
    4545                             max = look;
    4546                         }
    4547                       if (max != 0)
    4548                         tab[c].gt_entry.gt_bytes +=
    4549                           tab[max].gt_entry.gt_bytes;
    4550 
    4551                       ++c;
    4552                     }
    4553 
    4554                   last = int_gptab.gt_entry.gt_bytes;
    4555                 }
    4556 
    4557               /* Hack: reset the SEC_HAS_CONTENTS flag so that
    4558                  elf_link_input_bfd ignores this section.  */
    4559               input_section->flags &=~ SEC_HAS_CONTENTS;
    4560             }
    4561 
    4562           /* The table must be sorted by -G value.  */
    4563           if (c > 2)
    4564             qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare);
    4565 
    4566           /* Swap out the table.  */
    4567           ext_tab = ((Elf64_External_gptab *)
    4568                      bfd_alloc (abfd, c * sizeof (Elf64_External_gptab)));
    4569           if (ext_tab == NULL)
    4570             {
    4571               free (tab);
    4572               return false;
    4573             }
    4574 
    4575           for (i = 0; i < c; i++)
    4576             bfd_alpha_elf64_swap_gptab_out (abfd, tab + i, ext_tab + i);
    4577           free (tab);
    4578 
    4579           o->_raw_size = c * sizeof (Elf64_External_gptab);
    4580           o->contents = (bfd_byte *) ext_tab;
    4581 
    4582           /* Skip this section later on (I don't think this currently
    4583              matters, but someday it might).  */
    4584           o->link_order_head = (struct bfd_link_order *) NULL;
    4585         }
    4586 #endif
    4587 
    45885448    }
    45895449
    45905450  /* Invoke the regular ELF backend linker to do all the work.  */
    45915451  if (! bfd_elf64_bfd_final_link (abfd, info))
    4592     return false;
     5452    return FALSE;
    45935453
    45945454  /* Now write out the computed sections.  */
     
    46095469        sgot = alpha_elf_tdata(i)->got;
    46105470        if (! bfd_set_section_contents (abfd, sgot->output_section,
    4611                                         sgot->contents, sgot->output_offset,
     5471                                        sgot->contents,
     5472                                        (file_ptr) sgot->output_offset,
    46125473                                        sgot->_raw_size))
    4613           return false;
     5474          return FALSE;
    46145475      }
    46155476  }
    4616 
    4617 #ifdef ERIC_neverdef
    4618   if (reginfo_sec != (asection *) NULL)
    4619     {
    4620       Elf64_External_RegInfo ext;
    4621 
    4622       bfd_alpha_elf64_swap_reginfo_out (abfd, &reginfo, &ext);
    4623       if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext,
    4624                                       (file_ptr) 0, sizeof ext))
    4625         return false;
    4626     }
    4627 #endif
    46285477
    46295478  if (mdebug_sec != (asection *) NULL)
     
    46335482                                               swap, info,
    46345483                                               mdebug_sec->filepos))
    4635         return false;
     5484        return FALSE;
    46365485
    46375486      bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info);
    46385487    }
    46395488
    4640   if (gptab_data_sec != (asection *) NULL)
    4641     {
    4642       if (! bfd_set_section_contents (abfd, gptab_data_sec,
    4643                                       gptab_data_sec->contents,
    4644                                       (file_ptr) 0,
    4645                                       gptab_data_sec->_raw_size))
    4646         return false;
    4647     }
    4648 
    4649   if (gptab_bss_sec != (asection *) NULL)
    4650     {
    4651       if (! bfd_set_section_contents (abfd, gptab_bss_sec,
    4652                                       gptab_bss_sec->contents,
    4653                                       (file_ptr) 0,
    4654                                       gptab_bss_sec->_raw_size))
    4655         return false;
    4656     }
    4657 
    4658   return true;
     5489  return TRUE;
     5490}
     5491
     5492static enum elf_reloc_type_class
     5493elf64_alpha_reloc_type_class (rela)
     5494     const Elf_Internal_Rela *rela;
     5495{
     5496  switch ((int) ELF64_R_TYPE (rela->r_info))
     5497    {
     5498    case R_ALPHA_RELATIVE:
     5499      return reloc_class_relative;
     5500    case R_ALPHA_JMP_SLOT:
     5501      return reloc_class_plt;
     5502    case R_ALPHA_COPY:
     5503      return reloc_class_copy;
     5504    default:
     5505      return reloc_class_normal;
     5506    }
    46595507}
    46605508
     
    47085556/* Use a non-standard hash bucket size of 8.  */
    47095557
    4710 const struct elf_size_info alpha_elf_size_info =
     5558static const struct elf_size_info alpha_elf_size_info =
    47115559{
    47125560  sizeof (Elf64_External_Ehdr),
     
    47255573  bfd_elf64_write_shdrs_and_ehdr,
    47265574  bfd_elf64_write_relocs,
     5575  bfd_elf64_swap_symbol_in,
    47275576  bfd_elf64_swap_symbol_out,
    47285577  bfd_elf64_slurp_reloc_table,
     
    47305579  bfd_elf64_swap_dyn_in,
    47315580  bfd_elf64_swap_dyn_out,
    4732   NULL,
    4733   NULL,
    4734   NULL,
    4735   NULL
     5581  bfd_elf64_swap_reloc_in,
     5582  bfd_elf64_swap_reloc_out,
     5583  bfd_elf64_swap_reloca_in,
     5584  bfd_elf64_swap_reloca_out
    47365585};
    47375586
     
    47575606#define elf_backend_section_from_shdr \
    47585607  elf64_alpha_section_from_shdr
     5608#define elf_backend_section_flags \
     5609  elf64_alpha_section_flags
    47595610#define elf_backend_fake_sections \
    47605611  elf64_alpha_fake_sections
     
    47875638#define bfd_elf64_bfd_final_link \
    47885639  elf64_alpha_final_link
     5640#define elf_backend_reloc_type_class \
     5641  elf64_alpha_reloc_type_class
    47895642
    47905643#define elf_backend_ecoff_debug_swap \
     
    48025655
    48035656#include "elf64-target.h"
     5657
     5658
     5659/* FreeBSD support.  */
     5660
     5661#undef TARGET_LITTLE_SYM
     5662#define TARGET_LITTLE_SYM       bfd_elf64_alpha_freebsd_vec
     5663#undef TARGET_LITTLE_NAME
     5664#define TARGET_LITTLE_NAME      "elf64-alpha-freebsd"
     5665
     5666/* The kernel recognizes executables as valid only if they carry a
     5667   "FreeBSD" label in the ELF header.  So we put this label on all
     5668   executables and (for simplicity) also all other object files.  */
     5669
     5670static void elf64_alpha_fbsd_post_process_headers
     5671  PARAMS ((bfd *, struct bfd_link_info *));
     5672
     5673static void
     5674elf64_alpha_fbsd_post_process_headers (abfd, link_info)
     5675     bfd * abfd;
     5676     struct bfd_link_info * link_info ATTRIBUTE_UNUSED;
     5677{
     5678  Elf_Internal_Ehdr * i_ehdrp;  /* ELF file header, internal form.  */
     5679
     5680  i_ehdrp = elf_elfheader (abfd);
     5681
     5682  /* Put an ABI label supported by FreeBSD >= 4.1.  */
     5683  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
     5684#ifdef OLD_FREEBSD_ABI_LABEL
     5685  /* The ABI label supported by FreeBSD <= 4.0 is quite nonstandard.  */
     5686  memcpy (&i_ehdrp->e_ident[EI_ABIVERSION], "FreeBSD", 8);
     5687#endif
     5688}
     5689
     5690#undef elf_backend_post_process_headers
     5691#define elf_backend_post_process_headers \
     5692  elf64_alpha_fbsd_post_process_headers
     5693
     5694#undef  elf64_bed
     5695#define elf64_bed elf64_alpha_fbsd_bed
     5696
     5697#include "elf64-target.h"
Note: See TracChangeset for help on using the changeset viewer.