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/elfxx-ia64.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* IA-64 support for 64-bit ELF
    2    Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
     2   Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    33   Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
    44
    5 This file is part of BFD, the Binary File Descriptor library.
    6 
    7 This program is free software; you can redistribute it and/or modify
    8 it under the terms of the GNU General Public License as published by
    9 the Free Software Foundation; either version 2 of the License, or
    10 (at your option) any later version.
    11 
    12 This program is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with this program; if not, write to the Free Software
    19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     5   This file is part of BFD, the Binary File Descriptor library.
     6
     7   This program is free software; you can redistribute it and/or modify
     8   it under the terms of the GNU General Public License as published by
     9   the Free Software Foundation; either version 2 of the License, or
     10   (at your option) any later version.
     11
     12   This program is distributed in the hope that it will be useful,
     13   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15   GNU General Public License for more details.
     16
     17   You should have received a copy of the GNU General Public License
     18   along with this program; if not, write to the Free Software
     19   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    2020
    2121#include "bfd.h"
     
    2626#include "elf/ia64.h"
    2727
    28 /*
    29  * THE RULES for all the stuff the linker creates --
    30  *
    31  * GOT          Entries created in response to LTOFF or LTOFF_FPTR
    32  *              relocations.  Dynamic relocs created for dynamic
    33  *              symbols in an application; REL relocs for locals
    34  *              in a shared library.
    35  *
    36  * FPTR         The canonical function descriptor.  Created for local
    37  *              symbols in applications.  Descriptors for dynamic symbols
    38  *              and local symbols in shared libraries are created by
    39  *              ld.so.  Thus there are no dynamic relocs against these
    40  *              objects.  The FPTR relocs for such _are_ passed through
    41  *              to the dynamic relocation tables.
    42  *
    43  * FULL_PLT     Created for a PCREL21B relocation against a dynamic symbol.
    44  *              Requires the creation of a PLTOFF entry.  This does not
    45  *              require any dynamic relocations.
    46  *
    47  * PLTOFF       Created by PLTOFF relocations.  For local symbols, this
    48  *              is an alternate function descriptor, and in shared libraries
    49  *              requires two REL relocations.  Note that this cannot be
    50  *              transformed into an FPTR relocation, since it must be in
    51  *              range of the GP.  For dynamic symbols, this is a function
    52  *              descriptor for a MIN_PLT entry, and requires one IPLT reloc.
    53  *
    54  * MIN_PLT      Created by PLTOFF entries against dynamic symbols.  This
    55  *              does not reqire dynamic relocations.
    56  */
    57 
    58 #define USE_RELA                /* we want RELA relocs, not REL */
     28/* THE RULES for all the stuff the linker creates --
     29
     30  GOT           Entries created in response to LTOFF or LTOFF_FPTR
     31                relocations.  Dynamic relocs created for dynamic
     32                symbols in an application; REL relocs for locals
     33                in a shared library.
     34
     35  FPTR          The canonical function descriptor.  Created for local
     36                symbols in applications.  Descriptors for dynamic symbols
     37                and local symbols in shared libraries are created by
     38                ld.so.  Thus there are no dynamic relocs against these
     39                objects.  The FPTR relocs for such _are_ passed through
     40                to the dynamic relocation tables.
     41
     42  FULL_PLT      Created for a PCREL21B relocation against a dynamic symbol.
     43                Requires the creation of a PLTOFF entry.  This does not
     44                require any dynamic relocations.
     45
     46  PLTOFF        Created by PLTOFF relocations.  For local symbols, this
     47                is an alternate function descriptor, and in shared libraries
     48                requires two REL relocations.  Note that this cannot be
     49                transformed into an FPTR relocation, since it must be in
     50                range of the GP.  For dynamic symbols, this is a function
     51                descriptor for a MIN_PLT entry, and requires one IPLT reloc.
     52
     53  MIN_PLT       Created by PLTOFF entries against dynamic symbols.  This
     54                does not reqire dynamic relocations.  */
    5955
    6056#define NELEMS(a)       ((int) (sizeof (a) / sizeof ((a)[0])))
     
    8076  bfd_vma plt_offset;
    8177  bfd_vma plt2_offset;
     78  bfd_vma tprel_offset;
     79  bfd_vma dtpmod_offset;
     80  bfd_vma dtprel_offset;
    8281
    8382  /* The symbol table entry, if any, that this was derrived from.  */
     
    9493  } *reloc_entries;
    9594
    96   /* True when the section contents have been updated.  */
     95  /* TRUE when the section contents have been updated.  */
    9796  unsigned got_done : 1;
    9897  unsigned fptr_done : 1;
    9998  unsigned pltoff_done : 1;
    100 
    101   /* True for the different kinds of linker data we want created.  */
     99  unsigned tprel_done : 1;
     100  unsigned dtpmod_done : 1;
     101  unsigned dtprel_done : 1;
     102
     103  /* TRUE for the different kinds of linker data we want created.  */
    102104  unsigned want_got : 1;
     105  unsigned want_gotx : 1;
    103106  unsigned want_fptr : 1;
    104107  unsigned want_ltoff_fptr : 1;
     
    106109  unsigned want_plt2 : 1;
    107110  unsigned want_pltoff : 1;
     111  unsigned want_tprel : 1;
     112  unsigned want_dtpmod : 1;
     113  unsigned want_dtprel : 1;
    108114};
    109115
     
    112118  struct bfd_hash_entry root;
    113119  struct elfNN_ia64_dyn_sym_info *info;
     120
     121  /* TRUE if this hash entry's addends was translated for
     122     SHF_MERGE optimization.  */
     123  unsigned sec_merge_done : 1;
    114124};
    115125
     
    128138struct elfNN_ia64_link_hash_table
    129139{
    130   /* The main hash table */
     140  /* The main hash table. */
    131141  struct elf_link_hash_table root;
    132142
     
    139149
    140150  bfd_size_type minplt_entries; /* number of minplt entries */
     151  unsigned reltext : 1;         /* are there relocs against readonly sections? */
     152  unsigned self_dtpmod_done : 1;/* has self DTPMOD entry been finished? */
     153  bfd_vma self_dtpmod_offset;   /* .got offset to self DTPMOD entry */
    141154
    142155  struct elfNN_ia64_local_hash_table loc_hash_table;
     156};
     157
     158struct elfNN_ia64_allocate_data
     159{
     160  struct bfd_link_info *info;
     161  bfd_size_type ofs;
    143162};
    144163
     
    154173  PARAMS ((bfd *abfd, bfd_reloc_code_real_type bfd_code));
    155174static void elfNN_ia64_info_to_howto
    156   PARAMS ((bfd *abfd, arelent *bfd_reloc, ElfNN_Internal_Rela *elf_reloc));
    157 static boolean elfNN_ia64_relax_section
     175  PARAMS ((bfd *abfd, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc));
     176static bfd_boolean elfNN_ia64_relax_section
    158177  PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
    159           boolean *again));
    160 static boolean is_unwind_section_name
    161   PARAMS ((const char *));
    162 static boolean elfNN_ia64_section_from_shdr
    163   PARAMS ((bfd *, ElfNN_Internal_Shdr *, char *));
    164 static boolean elfNN_ia64_fake_sections
    165   PARAMS ((bfd *abfd, ElfNN_Internal_Shdr *hdr, asection *sec));
     178          bfd_boolean *again));
     179static void elfNN_ia64_relax_ldxmov
     180  PARAMS((bfd *abfd, bfd_byte *contents, bfd_vma off));
     181static bfd_boolean is_unwind_section_name
     182  PARAMS ((bfd *abfd, const char *));
     183static bfd_boolean elfNN_ia64_section_from_shdr
     184  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
     185static bfd_boolean elfNN_ia64_section_flags
     186  PARAMS ((flagword *, Elf_Internal_Shdr *));
     187static bfd_boolean elfNN_ia64_fake_sections
     188  PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec));
    166189static void elfNN_ia64_final_write_processing
    167   PARAMS ((bfd *abfd, boolean linker));
    168 static boolean elfNN_ia64_add_symbol_hook
     190  PARAMS ((bfd *abfd, bfd_boolean linker));
     191static bfd_boolean elfNN_ia64_add_symbol_hook
    169192  PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym,
    170193           const char **namep, flagword *flagsp, asection **secp,
    171194           bfd_vma *valp));
     195static bfd_boolean elfNN_ia64_aix_vec
     196  PARAMS ((const bfd_target *vec));
     197static bfd_boolean elfNN_ia64_aix_add_symbol_hook
     198  PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym,
     199           const char **namep, flagword *flagsp, asection **secp,
     200           bfd_vma *valp));
     201static bfd_boolean elfNN_ia64_aix_link_add_symbols
     202  PARAMS ((bfd *abfd, struct bfd_link_info *info));
    172203static int elfNN_ia64_additional_program_headers
    173204  PARAMS ((bfd *abfd));
    174 static boolean elfNN_ia64_is_local_label_name
     205static bfd_boolean elfNN_ia64_modify_segment_map
     206  PARAMS ((bfd *));
     207static bfd_boolean elfNN_ia64_is_local_label_name
    175208  PARAMS ((bfd *abfd, const char *name));
    176 static boolean elfNN_ia64_dynamic_symbol_p
     209static bfd_boolean elfNN_ia64_dynamic_symbol_p
    177210  PARAMS ((struct elf_link_hash_entry *h, struct bfd_link_info *info));
    178 static boolean elfNN_ia64_local_hash_table_init
     211static bfd_boolean elfNN_ia64_local_hash_table_init
    179212  PARAMS ((struct elfNN_ia64_local_hash_table *ht, bfd *abfd,
    180213           new_hash_entry_func new));
     
    185218  PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table,
    186219           const char *string));
     220static void elfNN_ia64_hash_copy_indirect
     221  PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *,
     222           struct elf_link_hash_entry *));
     223static void elfNN_ia64_hash_hide_symbol
     224  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean));
    187225static struct bfd_link_hash_table *elfNN_ia64_hash_table_create
    188226  PARAMS ((bfd *abfd));
    189227static struct elfNN_ia64_local_hash_entry *elfNN_ia64_local_hash_lookup
    190228  PARAMS ((struct elfNN_ia64_local_hash_table *table, const char *string,
    191            boolean create, boolean copy));
     229           bfd_boolean create, bfd_boolean copy));
     230static bfd_boolean elfNN_ia64_global_dyn_sym_thunk
     231  PARAMS ((struct bfd_hash_entry *, PTR));
     232static bfd_boolean elfNN_ia64_local_dyn_sym_thunk
     233  PARAMS ((struct bfd_hash_entry *, PTR));
    192234static void elfNN_ia64_dyn_sym_traverse
    193235  PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info,
    194            boolean (*func) (struct elfNN_ia64_dyn_sym_info *, PTR),
     236           bfd_boolean (*func) (struct elfNN_ia64_dyn_sym_info *, PTR),
    195237           PTR info));
    196 static boolean elfNN_ia64_create_dynamic_sections
     238static bfd_boolean elfNN_ia64_create_dynamic_sections
    197239  PARAMS ((bfd *abfd, struct bfd_link_info *info));
     240static struct elfNN_ia64_local_hash_entry * get_local_sym_hash
     241  PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info,
     242           bfd *abfd, const Elf_Internal_Rela *rel, bfd_boolean create));
    198243static struct elfNN_ia64_dyn_sym_info * get_dyn_sym_info
    199244  PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info,
    200245           struct elf_link_hash_entry *h,
    201            bfd *abfd, const Elf_Internal_Rela *rel, boolean create));
     246           bfd *abfd, const Elf_Internal_Rela *rel, bfd_boolean create));
    202247static asection *get_got
    203248  PARAMS ((bfd *abfd, struct bfd_link_info *info,
     
    211256static asection *get_reloc_section
    212257  PARAMS ((bfd *abfd, struct elfNN_ia64_link_hash_table *ia64_info,
    213            asection *sec, boolean create));
    214 static boolean count_dyn_reloc
     258           asection *sec, bfd_boolean create));
     259static bfd_boolean count_dyn_reloc
    215260  PARAMS ((bfd *abfd, struct elfNN_ia64_dyn_sym_info *dyn_i,
    216261           asection *srel, int type));
    217 static boolean elfNN_ia64_check_relocs
     262static bfd_boolean elfNN_ia64_check_relocs
    218263  PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec,
    219264           const Elf_Internal_Rela *relocs));
    220 static boolean elfNN_ia64_adjust_dynamic_symbol
     265static bfd_boolean elfNN_ia64_adjust_dynamic_symbol
    221266  PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
    222 static unsigned long global_sym_index
     267static long global_sym_index
    223268  PARAMS ((struct elf_link_hash_entry *h));
    224 static boolean allocate_fptr
     269static bfd_boolean allocate_fptr
    225270  PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data));
    226 static boolean allocate_global_data_got
     271static bfd_boolean allocate_global_data_got
    227272  PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data));
    228 static boolean allocate_global_fptr_got
     273static bfd_boolean allocate_global_fptr_got
    229274  PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data));
    230 static boolean allocate_local_got
     275static bfd_boolean allocate_local_got
    231276  PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data));
    232 static boolean allocate_pltoff_entries
     277static bfd_boolean allocate_pltoff_entries
    233278  PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data));
    234 static boolean allocate_plt_entries
     279static bfd_boolean allocate_plt_entries
    235280  PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data));
    236 static boolean allocate_plt2_entries
     281static bfd_boolean allocate_plt2_entries
    237282  PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data));
    238 static boolean allocate_dynrel_entries
     283static bfd_boolean allocate_dynrel_entries
    239284  PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data));
    240 static boolean elfNN_ia64_size_dynamic_sections
     285static bfd_boolean elfNN_ia64_size_dynamic_sections
    241286  PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
    242287static bfd_reloc_status_type elfNN_ia64_install_value
     
    257302  PARAMS ((bfd *abfd, struct bfd_link_info *info,
    258303           struct elfNN_ia64_dyn_sym_info *dyn_i,
    259            bfd_vma value, boolean));
    260 static boolean elfNN_ia64_final_link
     304           bfd_vma value, bfd_boolean));
     305static bfd_vma elfNN_ia64_tprel_base
     306  PARAMS ((struct bfd_link_info *info));
     307static bfd_vma elfNN_ia64_dtprel_base
     308  PARAMS ((struct bfd_link_info *info));
     309static int elfNN_ia64_unwind_entry_compare
     310  PARAMS ((const PTR, const PTR));
     311static bfd_boolean elfNN_ia64_choose_gp
    261312  PARAMS ((bfd *abfd, struct bfd_link_info *info));
    262 static boolean elfNN_ia64_relocate_section
     313static bfd_boolean elfNN_ia64_final_link
     314  PARAMS ((bfd *abfd, struct bfd_link_info *info));
     315static bfd_boolean elfNN_ia64_relocate_section
    263316  PARAMS ((bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd,
    264317           asection *input_section, bfd_byte *contents,
    265318           Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
    266319           asection **local_sections));
    267 static boolean elfNN_ia64_finish_dynamic_symbol
     320static bfd_boolean elfNN_ia64_finish_dynamic_symbol
    268321  PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
    269322           struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
    270 static boolean elfNN_ia64_finish_dynamic_sections
     323static bfd_boolean elfNN_ia64_finish_dynamic_sections
    271324  PARAMS ((bfd *abfd, struct bfd_link_info *info));
    272 static boolean elfNN_ia64_set_private_flags
     325static bfd_boolean elfNN_ia64_set_private_flags
    273326  PARAMS ((bfd *abfd, flagword flags));
    274 static boolean elfNN_ia64_copy_private_bfd_data
     327static bfd_boolean elfNN_ia64_merge_private_bfd_data
    275328  PARAMS ((bfd *ibfd, bfd *obfd));
    276 static boolean elfNN_ia64_merge_private_bfd_data
    277   PARAMS ((bfd *ibfd, bfd *obfd));
    278 static boolean elfNN_ia64_print_private_bfd_data
     329static bfd_boolean elfNN_ia64_print_private_bfd_data
    279330  PARAMS ((bfd *abfd, PTR ptr));
    280 
    281 
    282 /* ia64-specific relocation */
     331static enum elf_reloc_type_class elfNN_ia64_reloc_type_class
     332  PARAMS ((const Elf_Internal_Rela *));
     333static bfd_boolean elfNN_ia64_hpux_vec
     334  PARAMS ((const bfd_target *vec));
     335static void elfNN_hpux_post_process_headers
     336  PARAMS ((bfd *abfd, struct bfd_link_info *info));
     337bfd_boolean elfNN_hpux_backend_section_from_bfd_section
     338  PARAMS ((bfd *abfd, asection *sec, int *retval));
     339
     340
     341/* ia64-specific relocation.  */
    283342
    284343/* Perform a relocation.  Not much to do here as all the hard work is
     
    300359      return bfd_reloc_ok;
    301360    }
     361
     362  if (input_section->flags & SEC_DEBUGGING)
     363    return bfd_reloc_continue;
     364
    302365  *error_message = "Unsupported call to elfNN_ia64_reloc";
    303366  return bfd_reloc_notsupported;
     
    306369#define IA64_HOWTO(TYPE, NAME, SIZE, PCREL, IN)                 \
    307370  HOWTO (TYPE, 0, SIZE, 0, PCREL, 0, complain_overflow_signed,  \
    308          elfNN_ia64_reloc, NAME, false, 0, 0, IN)
     371         elfNN_ia64_reloc, NAME, FALSE, 0, 0, IN)
    309372
    310373/* This table has to be sorted according to increasing number of the
     
    312375static reloc_howto_type ia64_howto_table[] =
    313376  {
    314     IA64_HOWTO (R_IA64_NONE,        "NONE",        0, false, true),
    315 
    316     IA64_HOWTO (R_IA64_IMM14,       "IMM14",       0, false, true),
    317     IA64_HOWTO (R_IA64_IMM22,       "IMM22",       0, false, true),
    318     IA64_HOWTO (R_IA64_IMM64,       "IMM64",       0, false, true),
    319     IA64_HOWTO (R_IA64_DIR32MSB,    "DIR32MSB",    2, false, true),
    320     IA64_HOWTO (R_IA64_DIR32LSB,    "DIR32LSB",    2, false, true),
    321     IA64_HOWTO (R_IA64_DIR64MSB,    "DIR64MSB",    4, false, true),
    322     IA64_HOWTO (R_IA64_DIR64LSB,    "DIR64LSB",    4, false, true),
    323 
    324     IA64_HOWTO (R_IA64_GPREL22,     "GPREL22",     0, false, true),
    325     IA64_HOWTO (R_IA64_GPREL64I,    "GPREL64I",    0, false, true),
    326     IA64_HOWTO (R_IA64_GPREL32MSB,  "GPREL32MSB",  2, false, true),
    327     IA64_HOWTO (R_IA64_GPREL32LSB,  "GPREL32LSB",  2, false, true),
    328     IA64_HOWTO (R_IA64_GPREL64MSB,  "GPREL64MSB",  4, false, true),
    329     IA64_HOWTO (R_IA64_GPREL64LSB,  "GPREL64LSB",  4, false, true),
    330 
    331     IA64_HOWTO (R_IA64_LTOFF22,     "LTOFF22",     0, false, true),
    332     IA64_HOWTO (R_IA64_LTOFF64I,    "LTOFF64I",    0, false, true),
    333 
    334     IA64_HOWTO (R_IA64_PLTOFF22,    "PLTOFF22",    0, false, true),
    335     IA64_HOWTO (R_IA64_PLTOFF64I,   "PLTOFF64I",   0, false, true),
    336     IA64_HOWTO (R_IA64_PLTOFF64MSB, "PLTOFF64MSB", 4, false, true),
    337     IA64_HOWTO (R_IA64_PLTOFF64LSB, "PLTOFF64LSB", 4, false, true),
    338 
    339     IA64_HOWTO (R_IA64_FPTR64I,     "FPTR64I",     0, false, true),
    340     IA64_HOWTO (R_IA64_FPTR32MSB,   "FPTR32MSB",   2, false, true),
    341     IA64_HOWTO (R_IA64_FPTR32LSB,   "FPTR32LSB",   2, false, true),
    342     IA64_HOWTO (R_IA64_FPTR64MSB,   "FPTR64MSB",   4, false, true),
    343     IA64_HOWTO (R_IA64_FPTR64LSB,   "FPTR64LSB",   4, false, true),
    344 
    345     IA64_HOWTO (R_IA64_PCREL60B,    "PCREL60B",    0, true, true),
    346     IA64_HOWTO (R_IA64_PCREL21B,    "PCREL21B",    0, true, true),
    347     IA64_HOWTO (R_IA64_PCREL21M,    "PCREL21M",    0, true, true),
    348     IA64_HOWTO (R_IA64_PCREL21F,    "PCREL21F",    0, true, true),
    349     IA64_HOWTO (R_IA64_PCREL32MSB,  "PCREL32MSB",  2, true, true),
    350     IA64_HOWTO (R_IA64_PCREL32LSB,  "PCREL32LSB",  2, true, true),
    351     IA64_HOWTO (R_IA64_PCREL64MSB,  "PCREL64MSB",  4, true, true),
    352     IA64_HOWTO (R_IA64_PCREL64LSB,  "PCREL64LSB",  4, true, true),
    353 
    354     IA64_HOWTO (R_IA64_LTOFF_FPTR22, "LTOFF_FPTR22", 0, false, true),
    355     IA64_HOWTO (R_IA64_LTOFF_FPTR64I, "LTOFF_FPTR64I", 0, false, true),
    356     IA64_HOWTO (R_IA64_LTOFF_FPTR64MSB, "LTOFF_FPTR64MSB", 4, false, true),
    357     IA64_HOWTO (R_IA64_LTOFF_FPTR64LSB, "LTOFF_FPTR64LSB", 4, false, true),
    358 
    359     IA64_HOWTO (R_IA64_SEGREL32MSB, "SEGREL32MSB", 2, false, true),
    360     IA64_HOWTO (R_IA64_SEGREL32LSB, "SEGREL32LSB", 2, false, true),
    361     IA64_HOWTO (R_IA64_SEGREL64MSB, "SEGREL64MSB", 4, false, true),
    362     IA64_HOWTO (R_IA64_SEGREL64LSB, "SEGREL64LSB", 4, false, true),
    363 
    364     IA64_HOWTO (R_IA64_SECREL32MSB, "SECREL32MSB", 2, false, true),
    365     IA64_HOWTO (R_IA64_SECREL32LSB, "SECREL32LSB", 2, false, true),
    366     IA64_HOWTO (R_IA64_SECREL64MSB, "SECREL64MSB", 4, false, true),
    367     IA64_HOWTO (R_IA64_SECREL64LSB, "SECREL64LSB", 4, false, true),
    368 
    369     IA64_HOWTO (R_IA64_REL32MSB,    "REL32MSB",    2, false, true),
    370     IA64_HOWTO (R_IA64_REL32LSB,    "REL32LSB",    2, false, true),
    371     IA64_HOWTO (R_IA64_REL64MSB,    "REL64MSB",    4, false, true),
    372     IA64_HOWTO (R_IA64_REL64LSB,    "REL64LSB",    4, false, true),
    373 
    374     IA64_HOWTO (R_IA64_LTV32MSB,    "LTV32MSB",    2, false, true),
    375     IA64_HOWTO (R_IA64_LTV32LSB,    "LTV32LSB",    2, false, true),
    376     IA64_HOWTO (R_IA64_LTV64MSB,    "LTV64MSB",    4, false, true),
    377     IA64_HOWTO (R_IA64_LTV64LSB,    "LTV64LSB",    4, false, true),
    378 
    379     IA64_HOWTO (R_IA64_PCREL21BI,   "PCREL21BI",   0, true, true),
    380     IA64_HOWTO (R_IA64_PCREL22,     "PCREL22",     0, true, true),
    381     IA64_HOWTO (R_IA64_PCREL64I,    "PCREL64I",    0, true, true),
    382 
    383     IA64_HOWTO (R_IA64_IPLTMSB,     "IPLTMSB",     4, false, true),
    384     IA64_HOWTO (R_IA64_IPLTLSB,     "IPLTLSB",     4, false, true),
    385     IA64_HOWTO (R_IA64_COPY,        "COPY",        4, false, true),
    386     IA64_HOWTO (R_IA64_LTOFF22X,    "LTOFF22X",    0, false, true),
    387     IA64_HOWTO (R_IA64_LDXMOV,      "LDXMOV",      0, false, true),
    388 
    389     IA64_HOWTO (R_IA64_TPREL22,     "TPREL22",     0, false, false),
    390     IA64_HOWTO (R_IA64_TPREL64MSB,  "TPREL64MSB",  8, false, false),
    391     IA64_HOWTO (R_IA64_TPREL64LSB,  "TPREL64LSB",  8, false, false),
    392     IA64_HOWTO (R_IA64_LTOFF_TP22,  "LTOFF_TP22",  0, false, false),
     377    IA64_HOWTO (R_IA64_NONE,        "NONE",        0, FALSE, TRUE),
     378
     379    IA64_HOWTO (R_IA64_IMM14,       "IMM14",       0, FALSE, TRUE),
     380    IA64_HOWTO (R_IA64_IMM22,       "IMM22",       0, FALSE, TRUE),
     381    IA64_HOWTO (R_IA64_IMM64,       "IMM64",       0, FALSE, TRUE),
     382    IA64_HOWTO (R_IA64_DIR32MSB,    "DIR32MSB",    2, FALSE, TRUE),
     383    IA64_HOWTO (R_IA64_DIR32LSB,    "DIR32LSB",    2, FALSE, TRUE),
     384    IA64_HOWTO (R_IA64_DIR64MSB,    "DIR64MSB",    4, FALSE, TRUE),
     385    IA64_HOWTO (R_IA64_DIR64LSB,    "DIR64LSB",    4, FALSE, TRUE),
     386
     387    IA64_HOWTO (R_IA64_GPREL22,     "GPREL22",     0, FALSE, TRUE),
     388    IA64_HOWTO (R_IA64_GPREL64I,    "GPREL64I",    0, FALSE, TRUE),
     389    IA64_HOWTO (R_IA64_GPREL32MSB,  "GPREL32MSB",  2, FALSE, TRUE),
     390    IA64_HOWTO (R_IA64_GPREL32LSB,  "GPREL32LSB",  2, FALSE, TRUE),
     391    IA64_HOWTO (R_IA64_GPREL64MSB,  "GPREL64MSB",  4, FALSE, TRUE),
     392    IA64_HOWTO (R_IA64_GPREL64LSB,  "GPREL64LSB",  4, FALSE, TRUE),
     393
     394    IA64_HOWTO (R_IA64_LTOFF22,     "LTOFF22",     0, FALSE, TRUE),
     395    IA64_HOWTO (R_IA64_LTOFF64I,    "LTOFF64I",    0, FALSE, TRUE),
     396
     397    IA64_HOWTO (R_IA64_PLTOFF22,    "PLTOFF22",    0, FALSE, TRUE),
     398    IA64_HOWTO (R_IA64_PLTOFF64I,   "PLTOFF64I",   0, FALSE, TRUE),
     399    IA64_HOWTO (R_IA64_PLTOFF64MSB, "PLTOFF64MSB", 4, FALSE, TRUE),
     400    IA64_HOWTO (R_IA64_PLTOFF64LSB, "PLTOFF64LSB", 4, FALSE, TRUE),
     401
     402    IA64_HOWTO (R_IA64_FPTR64I,     "FPTR64I",     0, FALSE, TRUE),
     403    IA64_HOWTO (R_IA64_FPTR32MSB,   "FPTR32MSB",   2, FALSE, TRUE),
     404    IA64_HOWTO (R_IA64_FPTR32LSB,   "FPTR32LSB",   2, FALSE, TRUE),
     405    IA64_HOWTO (R_IA64_FPTR64MSB,   "FPTR64MSB",   4, FALSE, TRUE),
     406    IA64_HOWTO (R_IA64_FPTR64LSB,   "FPTR64LSB",   4, FALSE, TRUE),
     407
     408    IA64_HOWTO (R_IA64_PCREL60B,    "PCREL60B",    0, TRUE, TRUE),
     409    IA64_HOWTO (R_IA64_PCREL21B,    "PCREL21B",    0, TRUE, TRUE),
     410    IA64_HOWTO (R_IA64_PCREL21M,    "PCREL21M",    0, TRUE, TRUE),
     411    IA64_HOWTO (R_IA64_PCREL21F,    "PCREL21F",    0, TRUE, TRUE),
     412    IA64_HOWTO (R_IA64_PCREL32MSB,  "PCREL32MSB",  2, TRUE, TRUE),
     413    IA64_HOWTO (R_IA64_PCREL32LSB,  "PCREL32LSB",  2, TRUE, TRUE),
     414    IA64_HOWTO (R_IA64_PCREL64MSB,  "PCREL64MSB",  4, TRUE, TRUE),
     415    IA64_HOWTO (R_IA64_PCREL64LSB,  "PCREL64LSB",  4, TRUE, TRUE),
     416
     417    IA64_HOWTO (R_IA64_LTOFF_FPTR22, "LTOFF_FPTR22", 0, FALSE, TRUE),
     418    IA64_HOWTO (R_IA64_LTOFF_FPTR64I, "LTOFF_FPTR64I", 0, FALSE, TRUE),
     419    IA64_HOWTO (R_IA64_LTOFF_FPTR32MSB, "LTOFF_FPTR32MSB", 2, FALSE, TRUE),
     420    IA64_HOWTO (R_IA64_LTOFF_FPTR32LSB, "LTOFF_FPTR32LSB", 2, FALSE, TRUE),
     421    IA64_HOWTO (R_IA64_LTOFF_FPTR64MSB, "LTOFF_FPTR64MSB", 4, FALSE, TRUE),
     422    IA64_HOWTO (R_IA64_LTOFF_FPTR64LSB, "LTOFF_FPTR64LSB", 4, FALSE, TRUE),
     423
     424    IA64_HOWTO (R_IA64_SEGREL32MSB, "SEGREL32MSB", 2, FALSE, TRUE),
     425    IA64_HOWTO (R_IA64_SEGREL32LSB, "SEGREL32LSB", 2, FALSE, TRUE),
     426    IA64_HOWTO (R_IA64_SEGREL64MSB, "SEGREL64MSB", 4, FALSE, TRUE),
     427    IA64_HOWTO (R_IA64_SEGREL64LSB, "SEGREL64LSB", 4, FALSE, TRUE),
     428
     429    IA64_HOWTO (R_IA64_SECREL32MSB, "SECREL32MSB", 2, FALSE, TRUE),
     430    IA64_HOWTO (R_IA64_SECREL32LSB, "SECREL32LSB", 2, FALSE, TRUE),
     431    IA64_HOWTO (R_IA64_SECREL64MSB, "SECREL64MSB", 4, FALSE, TRUE),
     432    IA64_HOWTO (R_IA64_SECREL64LSB, "SECREL64LSB", 4, FALSE, TRUE),
     433
     434    IA64_HOWTO (R_IA64_REL32MSB,    "REL32MSB",    2, FALSE, TRUE),
     435    IA64_HOWTO (R_IA64_REL32LSB,    "REL32LSB",    2, FALSE, TRUE),
     436    IA64_HOWTO (R_IA64_REL64MSB,    "REL64MSB",    4, FALSE, TRUE),
     437    IA64_HOWTO (R_IA64_REL64LSB,    "REL64LSB",    4, FALSE, TRUE),
     438
     439    IA64_HOWTO (R_IA64_LTV32MSB,    "LTV32MSB",    2, FALSE, TRUE),
     440    IA64_HOWTO (R_IA64_LTV32LSB,    "LTV32LSB",    2, FALSE, TRUE),
     441    IA64_HOWTO (R_IA64_LTV64MSB,    "LTV64MSB",    4, FALSE, TRUE),
     442    IA64_HOWTO (R_IA64_LTV64LSB,    "LTV64LSB",    4, FALSE, TRUE),
     443
     444    IA64_HOWTO (R_IA64_PCREL21BI,   "PCREL21BI",   0, TRUE, TRUE),
     445    IA64_HOWTO (R_IA64_PCREL22,     "PCREL22",     0, TRUE, TRUE),
     446    IA64_HOWTO (R_IA64_PCREL64I,    "PCREL64I",    0, TRUE, TRUE),
     447
     448    IA64_HOWTO (R_IA64_IPLTMSB,     "IPLTMSB",     4, FALSE, TRUE),
     449    IA64_HOWTO (R_IA64_IPLTLSB,     "IPLTLSB",     4, FALSE, TRUE),
     450    IA64_HOWTO (R_IA64_COPY,        "COPY",        4, FALSE, TRUE),
     451    IA64_HOWTO (R_IA64_LTOFF22X,    "LTOFF22X",    0, FALSE, TRUE),
     452    IA64_HOWTO (R_IA64_LDXMOV,      "LDXMOV",      0, FALSE, TRUE),
     453
     454    IA64_HOWTO (R_IA64_TPREL14,     "TPREL14",     0, FALSE, FALSE),
     455    IA64_HOWTO (R_IA64_TPREL22,     "TPREL22",     0, FALSE, FALSE),
     456    IA64_HOWTO (R_IA64_TPREL64I,    "TPREL64I",    0, FALSE, FALSE),
     457    IA64_HOWTO (R_IA64_TPREL64MSB,  "TPREL64MSB",  8, FALSE, FALSE),
     458    IA64_HOWTO (R_IA64_TPREL64LSB,  "TPREL64LSB",  8, FALSE, FALSE),
     459    IA64_HOWTO (R_IA64_LTOFF_TPREL22, "LTOFF_TPREL22",  0, FALSE, FALSE),
     460
     461    IA64_HOWTO (R_IA64_DTPMOD64MSB, "TPREL64MSB",  8, FALSE, FALSE),
     462    IA64_HOWTO (R_IA64_DTPMOD64LSB, "TPREL64LSB",  8, FALSE, FALSE),
     463    IA64_HOWTO (R_IA64_LTOFF_DTPMOD22, "LTOFF_DTPMOD22", 0, FALSE, FALSE),
     464
     465    IA64_HOWTO (R_IA64_DTPREL14,    "DTPREL14",    0, FALSE, FALSE),
     466    IA64_HOWTO (R_IA64_DTPREL22,    "DTPREL22",    0, FALSE, FALSE),
     467    IA64_HOWTO (R_IA64_DTPREL64I,   "DTPREL64I",   0, FALSE, FALSE),
     468    IA64_HOWTO (R_IA64_DTPREL32MSB, "DTPREL32MSB", 4, FALSE, FALSE),
     469    IA64_HOWTO (R_IA64_DTPREL32LSB, "DTPREL32LSB", 4, FALSE, FALSE),
     470    IA64_HOWTO (R_IA64_DTPREL64MSB, "DTPREL64MSB", 8, FALSE, FALSE),
     471    IA64_HOWTO (R_IA64_DTPREL64LSB, "DTPREL64LSB", 8, FALSE, FALSE),
     472    IA64_HOWTO (R_IA64_LTOFF_DTPREL22, "LTOFF_DTPREL22", 0, FALSE, FALSE),
    393473  };
    394474
     
    397477/* Given a BFD reloc type, return the matching HOWTO structure.  */
    398478
    399 static reloc_howto_type*
     479static reloc_howto_type *
    400480lookup_howto (rtype)
    401481     unsigned int rtype;
     
    474554    case BFD_RELOC_IA64_LTOFF_FPTR22:   rtype = R_IA64_LTOFF_FPTR22; break;
    475555    case BFD_RELOC_IA64_LTOFF_FPTR64I:  rtype = R_IA64_LTOFF_FPTR64I; break;
     556    case BFD_RELOC_IA64_LTOFF_FPTR32MSB: rtype = R_IA64_LTOFF_FPTR32MSB; break;
     557    case BFD_RELOC_IA64_LTOFF_FPTR32LSB: rtype = R_IA64_LTOFF_FPTR32LSB; break;
    476558    case BFD_RELOC_IA64_LTOFF_FPTR64MSB: rtype = R_IA64_LTOFF_FPTR64MSB; break;
    477559    case BFD_RELOC_IA64_LTOFF_FPTR64LSB: rtype = R_IA64_LTOFF_FPTR64LSB; break;
     
    503585    case BFD_RELOC_IA64_LDXMOV:         rtype = R_IA64_LDXMOV; break;
    504586
     587    case BFD_RELOC_IA64_TPREL14:        rtype = R_IA64_TPREL14; break;
    505588    case BFD_RELOC_IA64_TPREL22:        rtype = R_IA64_TPREL22; break;
     589    case BFD_RELOC_IA64_TPREL64I:       rtype = R_IA64_TPREL64I; break;
    506590    case BFD_RELOC_IA64_TPREL64MSB:     rtype = R_IA64_TPREL64MSB; break;
    507591    case BFD_RELOC_IA64_TPREL64LSB:     rtype = R_IA64_TPREL64LSB; break;
    508     case BFD_RELOC_IA64_LTOFF_TP22:     rtype = R_IA64_LTOFF_TP22; break;
     592    case BFD_RELOC_IA64_LTOFF_TPREL22:  rtype = R_IA64_LTOFF_TPREL22; break;
     593
     594    case BFD_RELOC_IA64_DTPMOD64MSB:    rtype = R_IA64_DTPMOD64MSB; break;
     595    case BFD_RELOC_IA64_DTPMOD64LSB:    rtype = R_IA64_DTPMOD64LSB; break;
     596    case BFD_RELOC_IA64_LTOFF_DTPMOD22: rtype = R_IA64_LTOFF_DTPMOD22; break;
     597
     598    case BFD_RELOC_IA64_DTPREL14:       rtype = R_IA64_DTPREL14; break;
     599    case BFD_RELOC_IA64_DTPREL22:       rtype = R_IA64_DTPREL22; break;
     600    case BFD_RELOC_IA64_DTPREL64I:      rtype = R_IA64_DTPREL64I; break;
     601    case BFD_RELOC_IA64_DTPREL32MSB:    rtype = R_IA64_DTPREL32MSB; break;
     602    case BFD_RELOC_IA64_DTPREL32LSB:    rtype = R_IA64_DTPREL32LSB; break;
     603    case BFD_RELOC_IA64_DTPREL64MSB:    rtype = R_IA64_DTPREL64MSB; break;
     604    case BFD_RELOC_IA64_DTPREL64LSB:    rtype = R_IA64_DTPREL64LSB; break;
     605    case BFD_RELOC_IA64_LTOFF_DTPREL22: rtype = R_IA64_LTOFF_DTPREL22; break;
    509606
    510607    default: return 0;
     
    519616     bfd *abfd ATTRIBUTE_UNUSED;
    520617     arelent *bfd_reloc;
    521      ElfNN_Internal_Rela *elf_reloc;
    522 {
    523   bfd_reloc->howto = lookup_howto (ELFNN_R_TYPE (elf_reloc->r_info));
     618     Elf_Internal_Rela *elf_reloc;
     619{
     620  bfd_reloc->howto
     621    = lookup_howto ((unsigned int) ELFNN_R_TYPE (elf_reloc->r_info));
    524622}
    525623
     
    561659
    562660#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
    563 
    564 /* Select out of range branch fixup type.  Note that Itanium does
    565    not support brl, and so it gets emulated by the kernel.  */
    566 #undef USE_BRL
     661#define AIX_DYNAMIC_INTERPRETER "/usr/lib/ia64l64/libc.so.1"
     662#define DYNAMIC_INTERPRETER(abfd) \
     663  (elfNN_ia64_aix_vec (abfd->xvec) ? AIX_DYNAMIC_INTERPRETER : ELF_DYNAMIC_INTERPRETER)
    567664
    568665static const bfd_byte oor_brl[16] =
     
    573670};
    574671
    575 static const bfd_byte oor_ip[48] =
    576 {
    577   0x04, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MLX]        nop.m 0            */
    578   0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,  /*               movl r15=0         */
    579   0x01, 0x00, 0x00, 0x60,
    580   0x03, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MII]        nop.m 0            */
    581   0x00, 0x01, 0x00, 0x60, 0x00, 0x00,  /*               mov r16=ip;;       */
    582   0xf2, 0x80, 0x00, 0x80,              /*               add r16=r15,r16;;  */
    583   0x11, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MIB]        nop.m 0            */
    584   0x60, 0x80, 0x04, 0x80, 0x03, 0x00,  /*               mov b6=r16         */
    585   0x60, 0x00, 0x80, 0x00               /*               br b6;;            */
    586 };
    587 
    588 
    589 /* These functions do relaxation for IA-64 ELF.
    590 
    591    This is primarily to support branches to targets out of range;
    592    relaxation of R_IA64_LTOFF22X and R_IA64_LDXMOV not yet supported.  */
    593 
    594 static boolean
     672
     673/* These functions do relaxation for IA-64 ELF.  */
     674
     675static bfd_boolean
    595676elfNN_ia64_relax_section (abfd, sec, link_info, again)
    596677     bfd *abfd;
    597678     asection *sec;
    598679     struct bfd_link_info *link_info;
    599      boolean *again;
     680     bfd_boolean *again;
    600681{
    601682  struct one_fixup
     
    609690  Elf_Internal_Shdr *symtab_hdr;
    610691  Elf_Internal_Rela *internal_relocs;
    611   Elf_Internal_Rela *free_relocs = NULL;
    612692  Elf_Internal_Rela *irel, *irelend;
    613693  bfd_byte *contents;
    614   bfd_byte *free_contents = NULL;
    615   ElfNN_External_Sym *extsyms;
    616   ElfNN_External_Sym *free_extsyms = NULL;
     694  Elf_Internal_Sym *isymbuf = NULL;
    617695  struct elfNN_ia64_link_hash_table *ia64_info;
    618696  struct one_fixup *fixups = NULL;
    619   boolean changed_contents = false;
    620   boolean changed_relocs = false;
     697  bfd_boolean changed_contents = FALSE;
     698  bfd_boolean changed_relocs = FALSE;
     699  bfd_boolean changed_got = FALSE;
     700  bfd_vma gp = 0;
    621701
    622702  /* Assume we're not going to change any sizes, and we'll only need
    623703     one pass.  */
    624   *again = false;
    625 
    626   /* Nothing to do if there are no relocations.  */
     704  *again = FALSE;
     705
     706  /* Don't even try to relax for non-ELF outputs.  */
     707  if (link_info->hash->creator->flavour != bfd_target_elf_flavour)
     708    return FALSE;
     709
     710  /* Nothing to do if there are no relocations or there is no need for
     711     the relax finalize pass.  */
    627712  if ((sec->flags & SEC_RELOC) == 0
    628       || sec->reloc_count == 0)
    629     return true;
     713      || sec->reloc_count == 0
     714      || (link_info->relax_finalizing
     715          && sec->need_finalize_relax == 0))
     716    return TRUE;
    630717
    631718  /* If this is the first time we have been called for this section,
     
    641728                      link_info->keep_memory));
    642729  if (internal_relocs == NULL)
    643     goto error_return;
    644 
    645   if (! link_info->keep_memory)
    646     free_relocs = internal_relocs;
     730    return FALSE;
    647731
    648732  ia64_info = elfNN_ia64_hash_table (link_info);
    649733  irelend = internal_relocs + sec->reloc_count;
    650 
    651   for (irel = internal_relocs; irel < irelend; irel++)
    652     if (ELFNN_R_TYPE (irel->r_info) == (int) R_IA64_PCREL21B)
    653       break;
    654 
    655   /* No branch-type relocations.  */
    656   if (irel == irelend)
    657     {
    658       if (free_relocs != NULL)
    659         free (free_relocs);
    660       return true;
    661     }
    662734
    663735  /* Get the section contents.  */
     
    669741      if (contents == NULL)
    670742        goto error_return;
    671       free_contents = contents;
    672743
    673744      if (! bfd_get_section_contents (abfd, sec, contents,
     
    676747    }
    677748
    678   /* Read this BFD's symbols.  */
    679   if (symtab_hdr->contents != NULL)
    680     extsyms = (ElfNN_External_Sym *) symtab_hdr->contents;
    681   else
    682     {
    683       extsyms = (ElfNN_External_Sym *) bfd_malloc (symtab_hdr->sh_size);
    684       if (extsyms == NULL)
    685         goto error_return;
    686       free_extsyms = extsyms;
    687       if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
    688           || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
    689               != symtab_hdr->sh_size))
    690         goto error_return;
    691     }
    692 
    693   for (; irel < irelend; irel++)
    694     {
     749  for (irel = internal_relocs; irel < irelend; irel++)
     750    {
     751      unsigned long r_type = ELFNN_R_TYPE (irel->r_info);
    695752      bfd_vma symaddr, reladdr, trampoff, toff, roff;
    696       Elf_Internal_Sym isym;
    697753      asection *tsec;
    698754      struct one_fixup *f;
    699 
    700       if (ELFNN_R_TYPE (irel->r_info) != (int) R_IA64_PCREL21B)
    701         continue;
     755      bfd_size_type amt;
     756      bfd_boolean is_branch;
     757      struct elfNN_ia64_dyn_sym_info *dyn_i;
     758
     759      switch (r_type)
     760        {
     761        case R_IA64_PCREL21B:
     762        case R_IA64_PCREL21BI:
     763        case R_IA64_PCREL21M:
     764        case R_IA64_PCREL21F:
     765          if (link_info->relax_finalizing)
     766            continue;
     767          is_branch = TRUE;
     768          break;
     769
     770        case R_IA64_LTOFF22X:
     771        case R_IA64_LDXMOV:
     772          if (!link_info->relax_finalizing)
     773            {
     774              sec->need_finalize_relax = 1;
     775              continue;
     776            }
     777          is_branch = FALSE;
     778          break;
     779
     780        default:
     781          continue;
     782        }
    702783
    703784      /* Get the value of the symbol referred to by the reloc.  */
     
    705786        {
    706787          /* A local symbol.  */
    707           bfd_elfNN_swap_symbol_in (abfd,
    708                                     extsyms + ELFNN_R_SYM (irel->r_info),
    709                                     &isym);
    710           if (isym.st_shndx == SHN_UNDEF)
     788          Elf_Internal_Sym *isym;
     789
     790          /* Read this BFD's local symbols.  */
     791          if (isymbuf == NULL)
     792            {
     793              isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
     794              if (isymbuf == NULL)
     795                isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
     796                                                symtab_hdr->sh_info, 0,
     797                                                NULL, NULL, NULL);
     798              if (isymbuf == 0)
     799                goto error_return;
     800            }
     801
     802          isym = isymbuf + ELFNN_R_SYM (irel->r_info);
     803          if (isym->st_shndx == SHN_UNDEF)
    711804            continue;   /* We can't do anthing with undefined symbols.  */
    712           else if (isym.st_shndx == SHN_ABS)
     805          else if (isym->st_shndx == SHN_ABS)
    713806            tsec = bfd_abs_section_ptr;
    714           else if (isym.st_shndx == SHN_COMMON)
     807          else if (isym->st_shndx == SHN_COMMON)
    715808            tsec = bfd_com_section_ptr;
    716           else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)
    717             tsec = bfd_section_from_elf_index (abfd, isym.st_shndx);
     809          else if (isym->st_shndx == SHN_IA_64_ANSI_COMMON)
     810            tsec = bfd_com_section_ptr;
    718811          else
    719             continue;   /* who knows.  */
    720 
    721           toff = isym.st_value;
     812            tsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
     813
     814          toff = isym->st_value;
     815          dyn_i = get_dyn_sym_info (ia64_info, NULL, abfd, irel, FALSE);
    722816        }
    723817      else
     
    725819          unsigned long indx;
    726820          struct elf_link_hash_entry *h;
    727           struct elfNN_ia64_dyn_sym_info *dyn_i;
    728821
    729822          indx = ELFNN_R_SYM (irel->r_info) - symtab_hdr->sh_info;
     
    735828            h = (struct elf_link_hash_entry *) h->root.u.i.link;
    736829
    737           dyn_i = get_dyn_sym_info (ia64_info, h, abfd, irel, false);
     830          dyn_i = get_dyn_sym_info (ia64_info, h, abfd, irel, FALSE);
    738831
    739832          /* For branches to dynamic symbols, we're interested instead
    740833             in a branch to the PLT entry.  */
    741           if (dyn_i && dyn_i->want_plt2)
     834          if (is_branch && dyn_i && dyn_i->want_plt2)
    742835            {
     836              /* Internal branches shouldn't be sent to the PLT.
     837                 Leave this for now and we'll give an error later.  */
     838              if (r_type != R_IA64_PCREL21B)
     839                continue;
     840
    743841              tsec = ia64_info->plt_sec;
    744842              toff = dyn_i->plt2_offset;
     843              BFD_ASSERT (irel->r_addend == 0);
    745844            }
     845
     846          /* Can't do anything else with dynamic symbols.  */
     847          else if (elfNN_ia64_dynamic_symbol_p (h, link_info))
     848            continue;
     849
    746850          else
    747851            {
     
    756860        }
    757861
    758       symaddr = (tsec->output_section->vma
    759                  + tsec->output_offset
    760                  + toff
    761                  + irel->r_addend);
     862      if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
     863        toff = _bfd_merged_section_offset (abfd, &tsec,
     864                                           elf_section_data (tsec)->sec_info,
     865                                           toff + irel->r_addend,
     866                                           (bfd_vma) 0);
     867      else
     868        toff += irel->r_addend;
     869
     870      symaddr = tsec->output_section->vma + tsec->output_offset + toff;
    762871
    763872      roff = irel->r_offset;
    764       reladdr = (sec->output_section->vma
    765                  + sec->output_offset
    766                  + roff) & -4;
    767 
    768       /* If the branch is in range, no need to do anything.  */
    769       if ((bfd_signed_vma) (symaddr - reladdr) >= -0x1000000
    770           && (bfd_signed_vma) (symaddr - reladdr) <= 0x0FFFFF0)
    771         continue;
    772 
    773       /* If the branch and target are in the same section, you've
    774          got one honking big section and we can't help you.  You'll
    775          get an error message later.  */
    776       if (tsec == sec)
    777         continue;
    778 
    779       /* Look for an existing fixup to this address.  */
    780       for (f = fixups; f ; f = f->next)
    781         if (f->tsec == tsec && f->toff == toff)
    782           break;
    783 
    784       if (f == NULL)
    785         {
    786           /* Two alternatives: If it's a branch to a PLT entry, we can
    787              make a copy of the FULL_PLT entry.  Otherwise, we'll have
    788              to use a `brl' insn to get where we're going.  */
    789 
    790           int size;
    791 
    792           if (tsec == ia64_info->plt_sec)
    793             size = sizeof (plt_full_entry);
    794           else
     873
     874      if (is_branch)
     875        {
     876          reladdr = (sec->output_section->vma
     877                     + sec->output_offset
     878                     + roff) & (bfd_vma) -4;
     879
     880          /* If the branch is in range, no need to do anything.  */
     881          if ((bfd_signed_vma) (symaddr - reladdr) >= -0x1000000
     882              && (bfd_signed_vma) (symaddr - reladdr) <= 0x0FFFFF0)
     883            continue;
     884
     885          /* If the branch and target are in the same section, you've
     886             got one honking big section and we can't help you.  You'll
     887             get an error message later.  */
     888          if (tsec == sec)
     889            continue;
     890
     891          /* Look for an existing fixup to this address.  */
     892          for (f = fixups; f ; f = f->next)
     893            if (f->tsec == tsec && f->toff == toff)
     894              break;
     895
     896          if (f == NULL)
    795897            {
    796 #ifdef USE_BRL
    797               size = sizeof (oor_brl);
    798 #else
    799               size = sizeof (oor_ip);
    800 #endif
    801             }
    802 
    803           /* Resize the current section to make room for the new branch.  */
    804           trampoff = (sec->_cooked_size + 15) & -16;
    805           contents = (bfd_byte *) bfd_realloc (contents, trampoff + size);
    806           if (contents == NULL)
    807             goto error_return;
    808           sec->_cooked_size = trampoff + size;
    809 
    810           if (tsec == ia64_info->plt_sec)
    811             {
    812               memcpy (contents + trampoff, plt_full_entry, size);
    813 
    814               /* Hijack the old relocation for use as the PLTOFF reloc.  */
    815               irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
    816                                            R_IA64_PLTOFF22);
    817               irel->r_offset = trampoff;
     898              /* Two alternatives: If it's a branch to a PLT entry, we can
     899                 make a copy of the FULL_PLT entry.  Otherwise, we'll have
     900                 to use a `brl' insn to get where we're going.  */
     901
     902              size_t size;
     903
     904              if (tsec == ia64_info->plt_sec)
     905                size = sizeof (plt_full_entry);
     906              else
     907                {
     908                  size = sizeof (oor_brl);
     909                }
     910
     911              /* Resize the current section to make room for the new branch. */
     912              trampoff = (sec->_cooked_size + 15) & (bfd_vma) -16;
     913              amt = trampoff + size;
     914              contents = (bfd_byte *) bfd_realloc (contents, amt);
     915              if (contents == NULL)
     916                goto error_return;
     917              sec->_cooked_size = amt;
     918
     919              if (tsec == ia64_info->plt_sec)
     920                {
     921                  memcpy (contents + trampoff, plt_full_entry, size);
     922
     923                  /* Hijack the old relocation for use as the PLTOFF reloc.  */
     924                  irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
     925                                               R_IA64_PLTOFF22);
     926                  irel->r_offset = trampoff;
     927                }
     928              else
     929                {
     930                  memcpy (contents + trampoff, oor_brl, size);
     931                  irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
     932                                               R_IA64_PCREL60B);
     933                  irel->r_offset = trampoff + 2;
     934                }
     935
     936              /* Record the fixup so we don't do it again this section.  */
     937              f = (struct one_fixup *)
     938                bfd_malloc ((bfd_size_type) sizeof (*f));
     939              f->next = fixups;
     940              f->tsec = tsec;
     941              f->toff = toff;
     942              f->trampoff = trampoff;
     943              fixups = f;
    818944            }
    819945          else
    820946            {
    821 #ifdef USE_BRL
    822               memcpy (contents + trampoff, oor_brl, size);
     947              /* Nop out the reloc, since we're finalizing things here.  */
     948              irel->r_info = ELFNN_R_INFO (0, R_IA64_NONE);
     949            }
     950
     951          /* Fix up the existing branch to hit the trampoline.  Hope like
     952             hell this doesn't overflow too.  */
     953          if (elfNN_ia64_install_value (abfd, contents + roff,
     954                                        f->trampoff - (roff & (bfd_vma) -4),
     955                                        r_type) != bfd_reloc_ok)
     956            goto error_return;
     957
     958          changed_contents = TRUE;
     959          changed_relocs = TRUE;
     960        }
     961      else
     962        {
     963          /* Fetch the gp.  */
     964          if (gp == 0)
     965            {
     966              bfd *obfd = sec->output_section->owner;
     967              gp = _bfd_get_gp_value (obfd);
     968              if (gp == 0)
     969                {
     970                  if (!elfNN_ia64_choose_gp (obfd, link_info))
     971                    goto error_return;
     972                  gp = _bfd_get_gp_value (obfd);
     973                }
     974            }
     975
     976          /* If the data is out of range, do nothing.  */
     977          if ((bfd_signed_vma) (symaddr - gp) >= 0x200000
     978              ||(bfd_signed_vma) (symaddr - gp) < -0x200000)
     979            continue;
     980
     981          if (r_type == R_IA64_LTOFF22X)
     982            {
    823983              irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
    824                                            R_IA64_PCREL60B);
    825               irel->r_offset = trampoff + 2;
    826 #else
    827               memcpy (contents + trampoff, oor_ip, size);
    828               irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
    829                                            R_IA64_PCREL64I);
    830               irel->r_addend -= 16;
    831               irel->r_offset = trampoff + 2;
    832 #endif
     984                                           R_IA64_GPREL22);
     985              changed_relocs = TRUE;
     986              if (dyn_i->want_gotx)
     987                {
     988                  dyn_i->want_gotx = 0;
     989                  changed_got |= !dyn_i->want_got;
     990                }
    833991            }
    834 
    835           /* Record the fixup so we don't do it again this section.  */
    836           f = (struct one_fixup *) bfd_malloc (sizeof (*f));
    837           f->next = fixups;
    838           f->tsec = tsec;
    839           f->toff = toff;
    840           f->trampoff = trampoff;
    841           fixups = f;
    842         }
    843       else
    844         {
    845           /* Nop out the reloc, since we're finalizing things here.  */
    846           irel->r_info = ELFNN_R_INFO (0, R_IA64_NONE);
    847         }
    848 
    849       /* Fix up the existing branch to hit the trampoline.  Hope like
    850          hell this doesn't overflow too.  */
    851       if (elfNN_ia64_install_value (abfd, contents + roff,
    852                                     f->trampoff - (roff & -4),
    853                                     R_IA64_PCREL21B) != bfd_reloc_ok)
    854         goto error_return;
    855 
    856       changed_contents = true;
    857       changed_relocs = true;
    858     }
    859 
     992          else
     993            {
     994              elfNN_ia64_relax_ldxmov (abfd, contents, roff);
     995              irel->r_info = ELFNN_R_INFO (0, R_IA64_NONE);
     996              changed_contents = TRUE;
     997              changed_relocs = TRUE;
     998            }
     999        }
     1000    }
     1001
     1002  /* ??? If we created fixups, this may push the code segment large
     1003     enough that the data segment moves, which will change the GP.
     1004     Reset the GP so that we re-calculate next round.  We need to
     1005     do this at the _beginning_ of the next round; now will not do.  */
     1006     
    8601007  /* Clean up and go home.  */
    8611008  while (fixups)
     
    8661013    }
    8671014
    868   if (changed_relocs)
    869     elf_section_data (sec)->relocs = internal_relocs;
    870   else if (free_relocs != NULL)
    871     free (free_relocs);
    872 
    873   if (changed_contents)
    874     elf_section_data (sec)->this_hdr.contents = contents;
    875   else if (free_contents != NULL)
     1015  if (isymbuf != NULL
     1016      && symtab_hdr->contents != (unsigned char *) isymbuf)
    8761017    {
    8771018      if (! link_info->keep_memory)
    878         free (free_contents);
     1019        free (isymbuf);
     1020      else
     1021        {
     1022          /* Cache the symbols for elf_link_input_bfd.  */
     1023          symtab_hdr->contents = (unsigned char *) isymbuf;
     1024        }
     1025    }
     1026
     1027  if (contents != NULL
     1028      && elf_section_data (sec)->this_hdr.contents != contents)
     1029    {
     1030      if (!changed_contents && !link_info->keep_memory)
     1031        free (contents);
    8791032      else
    8801033        {
     
    8841037    }
    8851038
    886   if (free_extsyms != NULL)
    887     {
    888       if (! link_info->keep_memory)
    889         free (free_extsyms);
     1039  if (elf_section_data (sec)->relocs != internal_relocs)
     1040    {
     1041      if (!changed_relocs)
     1042        free (internal_relocs);
    8901043      else
    891         {
    892           /* Cache the symbols for elf_link_input_bfd.  */
    893           symtab_hdr->contents = extsyms;
    894         }
    895     }
     1044        elf_section_data (sec)->relocs = internal_relocs;
     1045    }
     1046
     1047  if (changed_got)
     1048    {
     1049      struct elfNN_ia64_allocate_data data;
     1050      data.info = link_info;
     1051      data.ofs = 0;
     1052      ia64_info->self_dtpmod_offset = (bfd_vma) -1;
     1053
     1054      elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_data_got, &data);
     1055      elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_fptr_got, &data);
     1056      elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_local_got, &data);
     1057      ia64_info->got_sec->_raw_size = data.ofs;
     1058      ia64_info->got_sec->_cooked_size = data.ofs;
     1059
     1060      /* ??? Resize .rela.got too.  */
     1061    }
     1062
     1063  if (link_info->relax_finalizing)
     1064    sec->need_finalize_relax = 0;
    8961065
    8971066  *again = changed_contents || changed_relocs;
    898   return true;
     1067  return TRUE;
    8991068
    9001069 error_return:
    901   if (free_relocs != NULL)
    902     free (free_relocs);
    903   if (free_contents != NULL)
    904     free (free_contents);
    905   if (free_extsyms != NULL)
    906     free (free_extsyms);
    907   return false;
    908 }
    909 
    910 
    911 /* Return true if NAME is an unwind table section name.  */
    912 
    913 static inline boolean
    914 is_unwind_section_name (name)
     1070  if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
     1071    free (isymbuf);
     1072  if (contents != NULL
     1073      && elf_section_data (sec)->this_hdr.contents != contents)
     1074    free (contents);
     1075  if (internal_relocs != NULL
     1076      && elf_section_data (sec)->relocs != internal_relocs)
     1077    free (internal_relocs);
     1078  return FALSE;
     1079}
     1080
     1081static void
     1082elfNN_ia64_relax_ldxmov (abfd, contents, off)
     1083     bfd *abfd;
     1084     bfd_byte *contents;
     1085     bfd_vma off;
     1086{
     1087  int shift, r1, r3;
     1088  bfd_vma dword, insn;
     1089
     1090  switch ((int)off & 0x3)
     1091    {
     1092    case 0: shift =  5; break;
     1093    case 1: shift = 14; off += 3; break;
     1094    case 2: shift = 23; off += 6; break;
     1095    default:
     1096      abort ();
     1097    }
     1098
     1099  dword = bfd_get_64 (abfd, contents + off);
     1100  insn = (dword >> shift) & 0x1ffffffffffLL;
     1101
     1102  r1 = (insn >> 6) & 127;
     1103  r3 = (insn >> 20) & 127;
     1104  if (r1 == r3)
     1105    insn = 0x8000000;                              /* nop */
     1106  else
     1107    insn = (insn & 0x7f01fff) | 0x10800000000LL;   /* (qp) mov r1 = r3 */
     1108
     1109  dword &= ~(0x1ffffffffffLL << shift);
     1110  dword |= (insn << shift);
     1111  bfd_put_64 (abfd, dword, contents + off);
     1112}
     1113
     1114
     1115/* Return TRUE if NAME is an unwind table section name.  */
     1116
     1117static inline bfd_boolean
     1118is_unwind_section_name (abfd, name)
     1119        bfd *abfd;
    9151120        const char *name;
    9161121{
    9171122  size_t len1, len2, len3;
     1123
     1124  if (elfNN_ia64_hpux_vec (abfd->xvec)
     1125      && !strcmp (name, ELF_STRING_ia64_unwind_hdr))
     1126    return FALSE;
    9181127
    9191128  len1 = sizeof (ELF_STRING_ia64_unwind) - 1;
     
    9281137   is called when elfcode.h finds a section with an unknown type.  */
    9291138
    930 static boolean
     1139static bfd_boolean
    9311140elfNN_ia64_section_from_shdr (abfd, hdr, name)
    9321141     bfd *abfd;
    933      ElfNN_Internal_Shdr *hdr;
    934      char *name;
     1142     Elf_Internal_Shdr *hdr;
     1143     const char *name;
    9351144{
    9361145  asection *newsect;
     
    9441153    {
    9451154    case SHT_IA_64_UNWIND:
     1155    case SHT_IA_64_HP_OPT_ANOT:
    9461156      break;
    9471157
    9481158    case SHT_IA_64_EXT:
    9491159      if (strcmp (name, ELF_STRING_ia64_archext) != 0)
    950         return false;
     1160        return FALSE;
    9511161      break;
    9521162
    9531163    default:
    954       return false;
     1164      return FALSE;
    9551165    }
    9561166
    9571167  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
    958     return false;
     1168    return FALSE;
    9591169  newsect = hdr->bfd_section;
    9601170
    961   return true;
     1171  return TRUE;
    9621172}
    9631173
     
    9671177   flag.  */
    9681178
    969 static boolean
     1179static bfd_boolean
    9701180elfNN_ia64_section_flags (flags, hdr)
    9711181     flagword *flags;
    972      ElfNN_Internal_Shdr *hdr;
     1182     Elf_Internal_Shdr *hdr;
    9731183{
    9741184  if (hdr->sh_flags & SHF_IA_64_SHORT)
    9751185    *flags |= SEC_SMALL_DATA;
    9761186
    977   return true;
     1187  return TRUE;
    9781188}
    9791189
     
    9811191   section name, which is a hack, but ought to work.  */
    9821192
    983 static boolean
     1193static bfd_boolean
    9841194elfNN_ia64_fake_sections (abfd, hdr, sec)
    9851195     bfd *abfd ATTRIBUTE_UNUSED;
    986      ElfNN_Internal_Shdr *hdr;
     1196     Elf_Internal_Shdr *hdr;
    9871197     asection *sec;
    9881198{
     
    9911201  name = bfd_get_section_name (abfd, sec);
    9921202
    993   if (is_unwind_section_name (name))
     1203  if (is_unwind_section_name (abfd, name))
    9941204    {
    9951205      /* We don't have the sections numbered at this point, so sh_info
     
    10001210  else if (strcmp (name, ELF_STRING_ia64_archext) == 0)
    10011211    hdr->sh_type = SHT_IA_64_EXT;
     1212  else if (strcmp (name, ".HP.opt_annot") == 0)
     1213    hdr->sh_type = SHT_IA_64_HP_OPT_ANOT;
    10021214  else if (strcmp (name, ".reloc") == 0)
    1003     /*
    1004      * This is an ugly, but unfortunately necessary hack that is
    1005      * needed when producing EFI binaries on IA-64. It tells
    1006      * elf.c:elf_fake_sections() not to consider ".reloc" as a section
    1007      * containing ELF relocation info.  We need this hack in order to
    1008      * be able to generate ELF binaries that can be translated into
    1009      * EFI applications (which are essentially COFF objects).  Those
    1010      * files contain a COFF ".reloc" section inside an ELFNN object,
    1011      * which would normally cause BFD to segfault because it would
    1012      * attempt to interpret this section as containing relocation
    1013      * entries for section "oc".  With this hack enabled, ".reloc"
    1014      * will be treated as a normal data section, which will avoid the
    1015      * segfault.  However, you won't be able to create an ELFNN binary
    1016      * with a section named "oc" that needs relocations, but that's
    1017      * the kind of ugly side-effects you get when detecting section
    1018      * types based on their names...  In practice, this limitation is
    1019      * unlikely to bite.
    1020      */
     1215    /* This is an ugly, but unfortunately necessary hack that is
     1216       needed when producing EFI binaries on IA-64. It tells
     1217       elf.c:elf_fake_sections() not to consider ".reloc" as a section
     1218       containing ELF relocation info.  We need this hack in order to
     1219       be able to generate ELF binaries that can be translated into
     1220       EFI applications (which are essentially COFF objects).  Those
     1221       files contain a COFF ".reloc" section inside an ELFNN object,
     1222       which would normally cause BFD to segfault because it would
     1223       attempt to interpret this section as containing relocation
     1224       entries for section "oc".  With this hack enabled, ".reloc"
     1225       will be treated as a normal data section, which will avoid the
     1226       segfault.  However, you won't be able to create an ELFNN binary
     1227       with a section named "oc" that needs relocations, but that's
     1228       the kind of ugly side-effects you get when detecting section
     1229       types based on their names...  In practice, this limitation is
     1230       unlikely to bite.  */
    10211231    hdr->sh_type = SHT_PROGBITS;
    10221232
     
    10241234    hdr->sh_flags |= SHF_IA_64_SHORT;
    10251235
    1026   return true;
     1236  return TRUE;
    10271237}
    10281238
     
    10331243elfNN_ia64_final_write_processing (abfd, linker)
    10341244     bfd *abfd;
    1035      boolean linker ATTRIBUTE_UNUSED;
     1245     bfd_boolean linker ATTRIBUTE_UNUSED;
    10361246{
    10371247  Elf_Internal_Shdr *hdr;
     
    10671277              /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.t.FOO */
    10681278              size_t len2 = sizeof (".gnu.linkonce.t.") - 1;
    1069               char *once_name = alloca (len2 + strlen (sname) - len + 1);
    1070 
    1071               memcpy (once_name, ".gnu.linkonce.t.", len2);
    1072               strcpy (once_name + len2, sname + len);
    1073               text_sect = bfd_get_section_by_name (abfd, once_name);
     1279              char *once_name = bfd_malloc (len2 + strlen (sname + len) + 1);
     1280
     1281              if (once_name != NULL)
     1282                {
     1283                  memcpy (once_name, ".gnu.linkonce.t.", len2);
     1284                  strcpy (once_name + len2, sname + len);
     1285                  text_sect = bfd_get_section_by_name (abfd, once_name);
     1286                  free (once_name);
     1287                }
     1288              else
     1289                /* Should only happen if we run out of memory, in
     1290                   which case we're probably toast anyway.  Try to
     1291                   cope by finding the section the slow way.  */
     1292                for (text_sect = abfd->sections;
     1293                     text_sect != NULL;
     1294                     text_sect = text_sect->next)
     1295                  {
     1296                    if (strncmp (bfd_section_name (abfd, text_sect),
     1297                                 ".gnu.linkonce.t.", len2) == 0
     1298                        && strcmp (bfd_section_name (abfd, text_sect) + len2,
     1299                                   sname + len) == 0)
     1300                      break;
     1301                  }
    10741302            }
    10751303          else
     
    10891317        }
    10901318    }
     1319
     1320  if (! elf_flags_init (abfd))
     1321    {
     1322      unsigned long flags = 0;
     1323
     1324      if (abfd->xvec->byteorder == BFD_ENDIAN_BIG)
     1325        flags |= EF_IA_64_BE;
     1326      if (bfd_get_mach (abfd) == bfd_mach_ia64_elf64)
     1327        flags |= EF_IA_64_ABI64;
     1328
     1329      elf_elfheader(abfd)->e_flags = flags;
     1330      elf_flags_init (abfd) = TRUE;
     1331    }
    10911332}
    10921333
     
    10941335   file.  We use it to put .comm items in .sbss, and not .bss.  */
    10951336
    1096 static boolean
     1337static bfd_boolean
    10971338elfNN_ia64_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
    10981339     bfd *abfd;
     
    11061347  if (sym->st_shndx == SHN_COMMON
    11071348      && !info->relocateable
    1108       && sym->st_size <= (unsigned) bfd_get_gp_size (abfd))
     1349      && sym->st_size <= elf_gp_size (abfd))
    11091350    {
    11101351      /* Common symbols less than or equal to -G nn bytes are
     
    11201361                                                       | SEC_IS_COMMON
    11211362                                                       | SEC_LINKER_CREATED)))
    1122             return false;
     1363            return FALSE;
    11231364        }
    11241365
     
    11271368    }
    11281369
    1129   return true;
     1370  return TRUE;
     1371}
     1372
     1373static bfd_boolean
     1374elfNN_ia64_aix_vec (const bfd_target *vec)
     1375{
     1376  extern const bfd_target bfd_elfNN_ia64_aix_little_vec;
     1377  extern const bfd_target bfd_elfNN_ia64_aix_big_vec;
     1378
     1379  return (/**/vec == & bfd_elfNN_ia64_aix_little_vec
     1380          ||  vec == & bfd_elfNN_ia64_aix_big_vec);
     1381}
     1382
     1383/* Hook called by the linker routine which adds symbols from an object
     1384   file.  We use it to handle OS-specific symbols.  */
     1385
     1386static bfd_boolean
     1387elfNN_ia64_aix_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
     1388     bfd *abfd;
     1389     struct bfd_link_info *info;
     1390     const Elf_Internal_Sym *sym;
     1391     const char **namep;
     1392     flagword *flagsp;
     1393     asection **secp;
     1394     bfd_vma *valp;
     1395{
     1396  if (strcmp (*namep, "__GLOB_DATA_PTR") == 0)
     1397    {
     1398      /* Define __GLOB_DATA_PTR when it is encountered.  This is expected to
     1399         be a linker-defined symbol by the Aix C runtime startup code. IBM sez
     1400         no one else should use it b/c it is undocumented.  */
     1401      struct elf_link_hash_entry *h;
     1402
     1403      h = elf_link_hash_lookup (elf_hash_table (info), *namep,
     1404                                FALSE, FALSE, FALSE);
     1405      if (h == NULL)
     1406        {
     1407          struct elf_backend_data *bed;
     1408          struct elfNN_ia64_link_hash_table *ia64_info;
     1409          struct bfd_link_hash_entry *bh = NULL;
     1410
     1411          bed = get_elf_backend_data (abfd);
     1412          ia64_info = elfNN_ia64_hash_table (info);
     1413
     1414          if (!(_bfd_generic_link_add_one_symbol
     1415                (info, abfd, *namep, BSF_GLOBAL,
     1416                 bfd_get_section_by_name (abfd, ".bss"),
     1417                 bed->got_symbol_offset, (const char *) NULL, FALSE,
     1418                 bed->collect, &bh)))
     1419            return FALSE;
     1420
     1421          h = (struct elf_link_hash_entry *) bh;
     1422          h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
     1423          h->type = STT_OBJECT;
     1424
     1425          if (! _bfd_elf_link_record_dynamic_symbol (info, h))
     1426            return FALSE;
     1427        }
     1428
     1429      return TRUE;
     1430    }
     1431  else if (sym->st_shndx == SHN_LOOS)
     1432    {
     1433      unsigned int i;
     1434
     1435      /* SHN_AIX_SYSCALL: Treat this as any other symbol.  The special symbol
     1436         is only relevant when compiling code for extended system calls.
     1437         Replace the "special" section with .text, if possible.
     1438         Note that these symbols are always assumed to be in .text. */
     1439      for (i = 1; i < elf_numsections (abfd); i++)
     1440        {
     1441          asection * sec = bfd_section_from_elf_index (abfd, i);
     1442
     1443          if (sec && strcmp (sec->name, ".text") == 0)
     1444            {
     1445              *secp = sec;
     1446              break;
     1447            }
     1448        }
     1449
     1450      if (*secp == NULL)
     1451        *secp = bfd_abs_section_ptr;
     1452
     1453      *valp = sym->st_size;
     1454
     1455      return TRUE;
     1456    }
     1457  else
     1458    {
     1459      return elfNN_ia64_add_symbol_hook (abfd, info, sym,
     1460                                         namep, flagsp, secp, valp);
     1461    }
     1462}
     1463
     1464bfd_boolean
     1465elfNN_ia64_aix_link_add_symbols (abfd, info)
     1466     bfd *abfd;
     1467     struct bfd_link_info *info;
     1468{
     1469  /* Make sure dynamic sections are always created.  */
     1470  if (! elf_hash_table (info)->dynamic_sections_created
     1471      && abfd->xvec == info->hash->creator)
     1472    {
     1473      if (! bfd_elfNN_link_create_dynamic_sections (abfd, info))
     1474        return FALSE;
     1475    }
     1476
     1477  /* Now do the standard call.  */
     1478  return bfd_elfNN_bfd_link_add_symbols (abfd, info);
    11301479}
    11311480
     
    11461495  /* Count how many PT_IA_64_UNWIND segments we need.  */
    11471496  for (s = abfd->sections; s; s = s->next)
    1148     if (is_unwind_section_name(s->name) && (s->flags & SEC_LOAD))
     1497    if (is_unwind_section_name (abfd, s->name) && (s->flags & SEC_LOAD))
    11491498      ++ret;
    11501499
     
    11521501}
    11531502
    1154 static boolean
     1503static bfd_boolean
    11551504elfNN_ia64_modify_segment_map (abfd)
    11561505     bfd *abfd;
     
    11701519      if (m == NULL)
    11711520        {
    1172           m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
     1521          m = ((struct elf_segment_map *)
     1522               bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
    11731523          if (m == NULL)
    1174             return false;
     1524            return FALSE;
    11751525
    11761526          m->p_type = PT_IA_64_ARCHEXT;
     
    12001550        {
    12011551          for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
    1202             if (m->p_type == PT_IA_64_UNWIND && m->sections[0] == s)
    1203               break;
     1552            if (m->p_type == PT_IA_64_UNWIND)
     1553              {
     1554                int i;
     1555
     1556                /* Look through all sections in the unwind segment
     1557                   for a match since there may be multiple sections
     1558                   to a segment.  */
     1559                for (i = m->count - 1; i >= 0; --i)
     1560                  if (m->sections[i] == s)
     1561                    break;
     1562
     1563                if (i >= 0)
     1564                  break;
     1565              }
    12041566
    12051567          if (m == NULL)
    12061568            {
    1207               m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
     1569              m = ((struct elf_segment_map *)
     1570                   bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
    12081571              if (m == NULL)
    1209                 return false;
     1572                return FALSE;
    12101573
    12111574              m->p_type = PT_IA_64_UNWIND;
     
    12511614      }
    12521615
    1253   return true;
     1616  return TRUE;
    12541617}
    12551618
     
    12571620   '.' are local.  */
    12581621
    1259 static boolean
     1622static bfd_boolean
    12601623elfNN_ia64_is_local_label_name (abfd, name)
    12611624     bfd *abfd ATTRIBUTE_UNUSED;
     
    12671630/* Should we do dynamic things to this symbol?  */
    12681631
    1269 static boolean
     1632static bfd_boolean
    12701633elfNN_ia64_dynamic_symbol_p (h, info)
    12711634     struct elf_link_hash_entry *h;
     
    12731636{
    12741637  if (h == NULL)
    1275     return false;
     1638    return FALSE;
    12761639
    12771640  while (h->root.type == bfd_link_hash_indirect
     
    12801643
    12811644  if (h->dynindx == -1)
    1282     return false;
     1645    return FALSE;
    12831646  switch (ELF_ST_VISIBILITY (h->other))
    12841647    {
    12851648    case STV_INTERNAL:
    12861649    case STV_HIDDEN:
    1287       return false;
     1650      return FALSE;
     1651    default:
     1652      break;
    12881653    }
    12891654
    12901655  if (h->root.type == bfd_link_hash_undefweak
    12911656      || h->root.type == bfd_link_hash_defweak)
    1292     return true;
    1293 
    1294   if ((info->shared && !info->symbolic)
     1657    return TRUE;
     1658
     1659  if ((info->shared && (!info->symbolic || info->allow_shlib_undefined))
    12951660      || ((h->elf_link_hash_flags
    12961661           & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))
    12971662          == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)))
    1298     return true;
    1299 
    1300   return false;
    1301 }
    1302 
    1303 
    1304 static boolean
     1663    return TRUE;
     1664
     1665  return FALSE;
     1666}
     1667
     1668
     1669static bfd_boolean
    13051670elfNN_ia64_local_hash_table_init (ht, abfd, new)
    13061671     struct elfNN_ia64_local_hash_table *ht;
     
    13701735
    13711736static void
    1372 elfNN_ia64_hash_copy_indirect (xdir, xind)
     1737elfNN_ia64_hash_copy_indirect (bed, xdir, xind)
     1738     struct elf_backend_data *bed ATTRIBUTE_UNUSED;
    13731739     struct elf_link_hash_entry *xdir, *xind;
    13741740{
    13751741  struct elfNN_ia64_link_hash_entry *dir, *ind;
    13761742
    1377   dir = (struct elfNN_ia64_link_hash_entry *)xdir;
    1378   ind = (struct elfNN_ia64_link_hash_entry *)xind;
     1743  dir = (struct elfNN_ia64_link_hash_entry *) xdir;
     1744  ind = (struct elfNN_ia64_link_hash_entry *) xind;
    13791745
    13801746  /* Copy down any references that we may have already seen to the
     
    13871753        | ELF_LINK_HASH_REF_REGULAR_NONWEAK));
    13881754
     1755  if (ind->root.root.type != bfd_link_hash_indirect)
     1756    return;
     1757
    13891758  /* Copy over the got and plt data.  This would have been done
    13901759     by check_relocs.  */
     
    14161785
    14171786static void
    1418 elfNN_ia64_hash_hide_symbol (info, xh)
    1419      struct bfd_link_info *info ATTRIBUTE_UNUSED;
     1787elfNN_ia64_hash_hide_symbol (info, xh, force_local)
     1788     struct bfd_link_info *info;
    14201789     struct elf_link_hash_entry *xh;
     1790     bfd_boolean force_local;
    14211791{
    14221792  struct elfNN_ia64_link_hash_entry *h;
     
    14251795  h = (struct elfNN_ia64_link_hash_entry *)xh;
    14261796
    1427   h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
    1428   if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
    1429     h->root.dynindx = -1;
     1797  _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local);
    14301798
    14311799  for (dyn_i = h->info; dyn_i; dyn_i = dyn_i->next)
     
    14431811  struct elfNN_ia64_link_hash_table *ret;
    14441812
    1445   ret = bfd_alloc (abfd, sizeof (*ret));
     1813  ret = bfd_zmalloc ((bfd_size_type) sizeof (*ret));
    14461814  if (!ret)
    14471815    return 0;
     1816
    14481817  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
    14491818                                      elfNN_ia64_new_elf_hash_entry))
    14501819    {
    1451       bfd_release (abfd, ret);
     1820      free (ret);
    14521821      return 0;
    14531822    }
     
    14551824  if (!elfNN_ia64_local_hash_table_init (&ret->loc_hash_table, abfd,
    14561825                                         elfNN_ia64_new_loc_hash_entry))
    1457     return 0;
     1826    {
     1827      free (ret);
     1828      return 0;
     1829    }
     1830
    14581831  return &ret->root.root;
    14591832}
     
    14651838     struct elfNN_ia64_local_hash_table *table;
    14661839     const char *string;
    1467      boolean create, copy;
     1840     bfd_boolean create, copy;
    14681841{
    14691842  return ((struct elfNN_ia64_local_hash_entry *)
     
    14751848struct elfNN_ia64_dyn_sym_traverse_data
    14761849{
    1477   boolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR));
     1850  bfd_boolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR));
    14781851  PTR data;
    14791852};
    14801853
    1481 static boolean
     1854static bfd_boolean
    14821855elfNN_ia64_global_dyn_sym_thunk (xentry, xdata)
    14831856     struct bfd_hash_entry *xentry;
     
    14901863  struct elfNN_ia64_dyn_sym_info *dyn_i;
    14911864
     1865  if (entry->root.root.type == bfd_link_hash_warning)
     1866    entry = (struct elfNN_ia64_link_hash_entry *) entry->root.root.u.i.link;
     1867
    14921868  for (dyn_i = entry->info; dyn_i; dyn_i = dyn_i->next)
    14931869    if (! (*data->func) (dyn_i, data->data))
    1494       return false;
    1495   return true;
    1496 }
    1497 
    1498 static boolean
     1870      return FALSE;
     1871  return TRUE;
     1872}
     1873
     1874static bfd_boolean
    14991875elfNN_ia64_local_dyn_sym_thunk (xentry, xdata)
    15001876     struct bfd_hash_entry *xentry;
     
    15091885  for (dyn_i = entry->info; dyn_i; dyn_i = dyn_i->next)
    15101886    if (! (*data->func) (dyn_i, data->data))
    1511       return false;
    1512   return true;
     1887      return FALSE;
     1888  return TRUE;
    15131889}
    15141890
     
    15161892elfNN_ia64_dyn_sym_traverse (ia64_info, func, data)
    15171893     struct elfNN_ia64_link_hash_table *ia64_info;
    1518      boolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR));
     1894     bfd_boolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR));
    15191895     PTR data;
    15201896{
     
    15311907
    15321908
    1533 static boolean
     1909static bfd_boolean
    15341910elfNN_ia64_create_dynamic_sections (abfd, info)
    15351911     bfd *abfd;
     
    15401916
    15411917  if (! _bfd_elf_create_dynamic_sections (abfd, info))
    1542     return false;
     1918    return FALSE;
    15431919
    15441920  ia64_info = elfNN_ia64_hash_table (info);
     
    15531929
    15541930  if (!get_pltoff (abfd, info, ia64_info))
    1555     return false;
     1931    return FALSE;
    15561932
    15571933  s = bfd_make_section(abfd, ".rela.IA_64.pltoff");
     
    15631939                                           | SEC_READONLY))
    15641940      || !bfd_set_section_alignment (abfd, s, 3))
    1565     return false;
     1941    return FALSE;
    15661942  ia64_info->rel_pltoff_sec = s;
    15671943
     
    15741950                                           | SEC_READONLY))
    15751951      || !bfd_set_section_alignment (abfd, s, 3))
    1576     return false;
     1952    return FALSE;
    15771953  ia64_info->rel_got_sec = s;
    15781954
    1579   return true;
     1955  return TRUE;
     1956}
     1957
     1958/* Find and/or create a hash entry for local symbol.  */
     1959static struct elfNN_ia64_local_hash_entry *
     1960get_local_sym_hash (ia64_info, abfd, rel, create)
     1961     struct elfNN_ia64_link_hash_table *ia64_info;
     1962     bfd *abfd;
     1963     const Elf_Internal_Rela *rel;
     1964     bfd_boolean create;
     1965{
     1966  struct elfNN_ia64_local_hash_entry *ret;
     1967  asection *sec = abfd->sections;
     1968  char addr_name [34];
     1969
     1970  BFD_ASSERT ((sizeof (sec->id)*2 + 1 + sizeof (unsigned long)*2 + 1) <= 34);
     1971  BFD_ASSERT (sec);
     1972
     1973  /* Construct a string for use in the elfNN_ia64_local_hash_table.
     1974     name describes what was once anonymous memory.  */
     1975
     1976  sprintf (addr_name, "%x:%lx",
     1977           sec->id, (unsigned long) ELFNN_R_SYM (rel->r_info));
     1978
     1979  /* Collect the canonical entry data for this address.  */
     1980  ret = elfNN_ia64_local_hash_lookup (&ia64_info->loc_hash_table,
     1981                                      addr_name, create, create);
     1982  return ret;
    15801983}
    15811984
     
    15891992     bfd *abfd;
    15901993     const Elf_Internal_Rela *rel;
    1591      boolean create;
     1994     bfd_boolean create;
    15921995{
    15931996  struct elfNN_ia64_dyn_sym_info **pp;
     
    16002003    {
    16012004      struct elfNN_ia64_local_hash_entry *loc_h;
    1602       char *addr_name;
    1603       size_t len;
    1604 
    1605       /* Construct a string for use in the elfNN_ia64_local_hash_table.
    1606          The name describes what was once anonymous memory.  */
    1607 
    1608       len = sizeof (void*)*2 + 1 + sizeof (bfd_vma)*4 + 1 + 1;
    1609       len += 10;        /* %p slop */
    1610 
    1611       addr_name = alloca (len);
    1612       sprintf (addr_name, "%p:%lx", (void *) abfd, ELFNN_R_SYM (rel->r_info));
    1613 
    1614       /* Collect the canonical entry data for this address.  */
    1615       loc_h = elfNN_ia64_local_hash_lookup (&ia64_info->loc_hash_table,
    1616                                             addr_name, create, create);
    1617       BFD_ASSERT (loc_h);
     2005
     2006      loc_h = get_local_sym_hash (ia64_info, abfd, rel, create);
     2007      if (!loc_h)
     2008        {
     2009          BFD_ASSERT (!create);
     2010          return NULL;
     2011        }
    16182012
    16192013      pp = &loc_h->info;
     
    16252019  if (dyn_i == NULL && create)
    16262020    {
    1627       dyn_i = (struct elfNN_ia64_dyn_sym_info *)
    1628         bfd_zalloc (abfd, sizeof *dyn_i);
     2021      dyn_i = ((struct elfNN_ia64_dyn_sym_info *)
     2022               bfd_zalloc (abfd, (bfd_size_type) sizeof *dyn_i));
    16292023      *pp = dyn_i;
    16302024      dyn_i->addend = addend;
     
    17492143     struct elfNN_ia64_link_hash_table *ia64_info;
    17502144     asection *sec;
    1751      boolean create;
     2145     bfd_boolean create;
    17522146{
    17532147  const char *srel_name;
     
    17882182    }
    17892183
     2184  if (sec->flags & SEC_READONLY)
     2185    ia64_info->reltext = 1;
     2186
    17902187  return srel;
    17912188}
    17922189
    1793 static boolean
     2190static bfd_boolean
    17942191count_dyn_reloc (abfd, dyn_i, srel, type)
    17952192     bfd *abfd;
     
    18062203  if (!rent)
    18072204    {
    1808       rent = (struct elfNN_ia64_dyn_reloc_entry *)
    1809         bfd_alloc (abfd, sizeof (*rent));
     2205      rent = ((struct elfNN_ia64_dyn_reloc_entry *)
     2206              bfd_alloc (abfd, (bfd_size_type) sizeof (*rent)));
    18102207      if (!rent)
    1811         return false;
     2208        return FALSE;
    18122209
    18132210      rent->next = dyn_i->reloc_entries;
     
    18192216  rent->count++;
    18202217
    1821   return true;
    1822 }
    1823 
    1824 static boolean
     2218  return TRUE;
     2219}
     2220
     2221static bfd_boolean
    18252222elfNN_ia64_check_relocs (abfd, info, sec, relocs)
    18262223     bfd *abfd;
     
    18362233
    18372234  if (info->relocateable)
    1838     return true;
     2235    return TRUE;
    18392236
    18402237  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
     
    18482245      enum {
    18492246        NEED_GOT = 1,
    1850         NEED_FPTR = 2,
    1851         NEED_PLTOFF = 4,
    1852         NEED_MIN_PLT = 8,
    1853         NEED_FULL_PLT = 16,
    1854         NEED_DYNREL = 32,
    1855         NEED_LTOFF_FPTR = 64,
     2247        NEED_GOTX = 2,
     2248        NEED_FPTR = 4,
     2249        NEED_PLTOFF = 8,
     2250        NEED_MIN_PLT = 16,
     2251        NEED_FULL_PLT = 32,
     2252        NEED_DYNREL = 64,
     2253        NEED_LTOFF_FPTR = 128,
     2254        NEED_TPREL = 256,
     2255        NEED_DTPMOD = 512,
     2256        NEED_DTPREL = 1024
    18562257      };
    18572258
     
    18602261      struct elfNN_ia64_dyn_sym_info *dyn_i;
    18612262      int need_entry;
    1862       boolean maybe_dynamic;
     2263      bfd_boolean maybe_dynamic;
    18632264      int dynrel_type = R_IA64_NONE;
    18642265
     
    18802281         have yet been processed.  Do something with what we know, as
    18812282         this may help reduce memory usage and processing time later.  */
    1882       maybe_dynamic = false;
    1883       if (h && ((info->shared && ! info->symbolic)
     2283      maybe_dynamic = FALSE;
     2284      if (h && ((info->shared
     2285                      && (!info->symbolic || info->allow_shlib_undefined))
    18842286                || ! (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
    1885                 || h->root.type == bfd_link_hash_defweak))
    1886         maybe_dynamic = true;
     2287                || h->root.type == bfd_link_hash_defweak
     2288                || elfNN_ia64_aix_vec (abfd->xvec)))
     2289        maybe_dynamic = TRUE;
    18872290
    18882291      need_entry = 0;
    18892292      switch (ELFNN_R_TYPE (rel->r_info))
    18902293        {
    1891         case R_IA64_TPREL22:
    18922294        case R_IA64_TPREL64MSB:
    18932295        case R_IA64_TPREL64LSB:
    1894         case R_IA64_LTOFF_TP22:
    1895           return false;
     2296          if (info->shared || maybe_dynamic)
     2297            need_entry = NEED_DYNREL;
     2298          dynrel_type = R_IA64_TPREL64LSB;
     2299          if (info->shared)
     2300            info->flags |= DF_STATIC_TLS;
     2301          break;
     2302
     2303        case R_IA64_LTOFF_TPREL22:
     2304          need_entry = NEED_TPREL;
     2305          if (info->shared)
     2306            info->flags |= DF_STATIC_TLS;
     2307          break;
     2308
     2309        case R_IA64_DTPREL64MSB:
     2310        case R_IA64_DTPREL64LSB:
     2311          if (info->shared || maybe_dynamic)
     2312            need_entry = NEED_DYNREL;
     2313          dynrel_type = R_IA64_DTPREL64LSB;
     2314          break;
     2315
     2316        case R_IA64_LTOFF_DTPREL22:
     2317          need_entry = NEED_DTPREL;
     2318          break;
     2319
     2320        case R_IA64_DTPMOD64MSB:
     2321        case R_IA64_DTPMOD64LSB:
     2322          if (info->shared || maybe_dynamic)
     2323            need_entry = NEED_DYNREL;
     2324          dynrel_type = R_IA64_DTPMOD64LSB;
     2325          break;
     2326
     2327        case R_IA64_LTOFF_DTPMOD22:
     2328          need_entry = NEED_DTPMOD;
     2329          break;
    18962330
    18972331        case R_IA64_LTOFF_FPTR22:
    18982332        case R_IA64_LTOFF_FPTR64I:
     2333        case R_IA64_LTOFF_FPTR32MSB:
     2334        case R_IA64_LTOFF_FPTR32LSB:
    18992335        case R_IA64_LTOFF_FPTR64MSB:
    19002336        case R_IA64_LTOFF_FPTR64LSB:
     
    19072343        case R_IA64_FPTR64MSB:
    19082344        case R_IA64_FPTR64LSB:
    1909           if (info->shared || h)
     2345          if (info->shared || h || elfNN_ia64_aix_vec (abfd->xvec))
    19102346            need_entry = NEED_FPTR | NEED_DYNREL;
    19112347          else
     
    19152351
    19162352        case R_IA64_LTOFF22:
    1917         case R_IA64_LTOFF22X:
    19182353        case R_IA64_LTOFF64I:
    19192354          need_entry = NEED_GOT;
     2355          break;
     2356
     2357        case R_IA64_LTOFF22X:
     2358          need_entry = NEED_GOTX;
    19202359          break;
    19212360
     
    19342373              (*info->callbacks->warning)
    19352374                (info, _("@pltoff reloc against local symbol"), 0,
    1936                  abfd, 0, 0);
     2375                 abfd, 0, (bfd_vma) 0);
    19372376            }
    19382377          break;
     
    19562395        case R_IA64_DIR64LSB:
    19572396          /* Shared objects will always need at least a REL relocation.  */
    1958           if (info->shared || maybe_dynamic)
     2397          if (info->shared || maybe_dynamic
     2398              || (elfNN_ia64_aix_vec (abfd->xvec)
     2399                  && (!h || strcmp (h->root.root.string,
     2400                                    "__GLOB_DATA_PTR") != 0)))
    19592401            need_entry = NEED_DYNREL;
    19602402          dynrel_type = R_IA64_DIR64LSB;
     
    19892431          (*info->callbacks->warning)
    19902432            (info, _("non-zero addend in @fptr reloc"), 0,
    1991              abfd, 0, 0);
    1992         }
    1993 
    1994       dyn_i = get_dyn_sym_info (ia64_info, h, abfd, rel, true);
     2433             abfd, 0, (bfd_vma) 0);
     2434        }
     2435
     2436      dyn_i = get_dyn_sym_info (ia64_info, h, abfd, rel, TRUE);
    19952437
    19962438      /* Record whether or not this is a local symbol.  */
     
    19982440
    19992441      /* Create what's needed.  */
    2000       if (need_entry & NEED_GOT)
     2442      if (need_entry & (NEED_GOT | NEED_GOTX | NEED_TPREL
     2443                        | NEED_DTPMOD | NEED_DTPREL))
    20012444        {
    20022445          if (!got)
     
    20042447              got = get_got (abfd, info, ia64_info);
    20052448              if (!got)
    2006                 return false;
     2449                return FALSE;
    20072450            }
    2008           dyn_i->want_got = 1;
     2451          if (need_entry & NEED_GOT)
     2452            dyn_i->want_got = 1;
     2453          if (need_entry & NEED_GOTX)
     2454            dyn_i->want_gotx = 1;
     2455          if (need_entry & NEED_TPREL)
     2456            dyn_i->want_tprel = 1;
     2457          if (need_entry & NEED_DTPMOD)
     2458            dyn_i->want_dtpmod = 1;
     2459          if (need_entry & NEED_DTPREL)
     2460            dyn_i->want_dtprel = 1;
    20092461        }
    20102462      if (need_entry & NEED_FPTR)
     
    20142466              fptr = get_fptr (abfd, info, ia64_info);
    20152467              if (!fptr)
    2016                 return false;
     2468                return FALSE;
    20172469            }
    20182470
     
    20202472             linker.  Make sure this local symbol will appear in the
    20212473             dynamic symbol table.  */
    2022           if (!h && info->shared)
     2474          if (!h && (info->shared
     2475                     /* AIX also needs one */
     2476                     || elfNN_ia64_aix_vec (abfd->xvec)))
    20232477            {
    20242478              if (! (_bfd_elfNN_link_record_local_dynamic_symbol
    2025                      (info, abfd, r_symndx)))
    2026                 return false;
     2479                     (info, abfd, (long) r_symndx)))
     2480                return FALSE;
    20272481            }
    20282482
     
    20462500          if (!srel)
    20472501            {
    2048               srel = get_reloc_section (abfd, ia64_info, sec, true);
     2502              srel = get_reloc_section (abfd, ia64_info, sec, TRUE);
    20492503              if (!srel)
    2050                 return false;
     2504                return FALSE;
    20512505            }
    20522506          if (!count_dyn_reloc (abfd, dyn_i, srel, dynrel_type))
    2053             return false;
    2054         }
    2055     }
    2056 
    2057   return true;
    2058 }
    2059 
    2060 struct elfNN_ia64_allocate_data
    2061 {
    2062   struct bfd_link_info *info;
    2063   bfd_size_type ofs;
    2064 };
     2507            return FALSE;
     2508        }
     2509    }
     2510
     2511  return TRUE;
     2512}
    20652513
    20662514/* For cleanliness, and potentially faster dynamic loading, allocate
    20672515   external GOT entries first.  */
    20682516
    2069 static boolean
     2517static bfd_boolean
    20702518allocate_global_data_got (dyn_i, data)
    20712519     struct elfNN_ia64_dyn_sym_info *dyn_i;
     
    20742522  struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
    20752523
    2076   if (dyn_i->want_got
     2524  if ((dyn_i->want_got || dyn_i->want_gotx)
    20772525      && ! dyn_i->want_fptr
    2078       && elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info))
     2526      && (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
     2527          || (elfNN_ia64_aix_vec (x->info->hash->creator)
     2528              && (!dyn_i->h || strcmp (dyn_i->h->root.root.string,
     2529                                       "__GLOB_DATA_PTR") != 0))))
    20792530     {
    20802531       dyn_i->got_offset = x->ofs;
    20812532       x->ofs += 8;
    20822533     }
    2083   return true;
     2534  if (dyn_i->want_tprel)
     2535    {
     2536      dyn_i->tprel_offset = x->ofs;
     2537      x->ofs += 8;
     2538    }
     2539  if (dyn_i->want_dtpmod)
     2540    {
     2541      if (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info))
     2542        {
     2543          dyn_i->dtpmod_offset = x->ofs;
     2544          x->ofs += 8;
     2545        }
     2546      else
     2547        {
     2548          struct elfNN_ia64_link_hash_table *ia64_info;
     2549
     2550          ia64_info = elfNN_ia64_hash_table (x->info);
     2551          if (ia64_info->self_dtpmod_offset == (bfd_vma) -1)
     2552            {
     2553              ia64_info->self_dtpmod_offset = x->ofs;
     2554              x->ofs += 8;
     2555            }
     2556          dyn_i->dtpmod_offset = ia64_info->self_dtpmod_offset;
     2557        }
     2558    }
     2559  if (dyn_i->want_dtprel)
     2560    {
     2561      dyn_i->dtprel_offset = x->ofs;
     2562      x->ofs += 8;
     2563    }
     2564  return TRUE;
    20842565}
    20852566
    20862567/* Next, allocate all the GOT entries used by LTOFF_FPTR relocs.  */
    20872568
    2088 static boolean
     2569static bfd_boolean
    20892570allocate_global_fptr_got (dyn_i, data)
    20902571     struct elfNN_ia64_dyn_sym_info *dyn_i;
     
    20952576  if (dyn_i->want_got
    20962577      && dyn_i->want_fptr
    2097       && elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info))
     2578      && (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
     2579          || elfNN_ia64_aix_vec (x->info->hash->creator)))
    20982580    {
    20992581      dyn_i->got_offset = x->ofs;
    21002582      x->ofs += 8;
    21012583    }
    2102   return true;
     2584  return TRUE;
    21032585}
    21042586
    21052587/* Lastly, allocate all the GOT entries for local data.  */
    21062588
    2107 static boolean
     2589static bfd_boolean
    21082590allocate_local_got (dyn_i, data)
    21092591     struct elfNN_ia64_dyn_sym_info *dyn_i;
     
    21122594  struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
    21132595
    2114   if (dyn_i->want_got
    2115       && ! elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info))
     2596  if ((dyn_i->want_got || dyn_i->want_gotx)
     2597      && ! (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
     2598            || elfNN_ia64_aix_vec (x->info->hash->creator)))
    21162599    {
    21172600      dyn_i->got_offset = x->ofs;
    21182601      x->ofs += 8;
    21192602    }
    2120   return true;
     2603  return TRUE;
    21212604}
    21222605
    21232606/* Search for the index of a global symbol in it's defining object file.  */
    21242607
    2125 static unsigned long
     2608static long
    21262609global_sym_index (h)
    21272610     struct elf_link_hash_entry *h;
     
    21432626   in a main executable that is not exported.  */
    21442627
    2145 static boolean
     2628static bfd_boolean
    21462629allocate_fptr (dyn_i, data)
    21472630     struct elfNN_ia64_dyn_sym_info *dyn_i;
     
    21592642          h = (struct elf_link_hash_entry *) h->root.u.i.link;
    21602643
    2161       if (x->info->shared)
     2644      if (x->info->shared
     2645          /* AIX needs an FPTR in this case. */
     2646          || (elfNN_ia64_aix_vec (x->info->hash->creator)
     2647              && (!h
     2648                  || h->root.type == bfd_link_hash_defined
     2649                  || h->root.type == bfd_link_hash_defweak)))
    21622650        {
    21632651          if (h && h->dynindx == -1)
     
    21692657                    (x->info, h->root.u.def.section->owner,
    21702658                     global_sym_index (h)))
    2171                 return false;
     2659                return FALSE;
    21722660            }
    21732661
     
    21822670        dyn_i->want_fptr = 0;
    21832671    }
    2184   return true;
     2672  return TRUE;
    21852673}
    21862674
    21872675/* Allocate all the minimal PLT entries.  */
    21882676
    2189 static boolean
     2677static bfd_boolean
    21902678allocate_plt_entries (dyn_i, data)
    21912679     struct elfNN_ia64_dyn_sym_info *dyn_i;
     
    22202708        }
    22212709    }
    2222   return true;
     2710  return TRUE;
    22232711}
    22242712
    22252713/* Allocate all the full PLT entries.  */
    22262714
    2227 static boolean
     2715static bfd_boolean
    22282716allocate_plt2_entries (dyn_i, data)
    22292717     struct elfNN_ia64_dyn_sym_info *dyn_i;
     
    22452733      dyn_i->h->plt.offset = ofs;
    22462734    }
    2247   return true;
     2735  return TRUE;
    22482736}
    22492737
     
    22532741   ??? Relaxation might be able to determine that they are.  */
    22542742
    2255 static boolean
     2743static bfd_boolean
    22562744allocate_pltoff_entries (dyn_i, data)
    22572745     struct elfNN_ia64_dyn_sym_info *dyn_i;
     
    22652753      x->ofs += 16;
    22662754    }
    2267   return true;
     2755  return TRUE;
    22682756}
    22692757
     
    22712759   to be dynamic.  */
    22722760
    2273 static boolean
     2761static bfd_boolean
    22742762allocate_dynrel_entries (dyn_i, data)
    22752763     struct elfNN_ia64_dyn_sym_info *dyn_i;
     
    22792767  struct elfNN_ia64_link_hash_table *ia64_info;
    22802768  struct elfNN_ia64_dyn_reloc_entry *rent;
    2281   boolean dynamic_symbol, shared;
     2769  bfd_boolean dynamic_symbol, shared;
    22822770
    22832771  ia64_info = elfNN_ia64_hash_table (x->info);
    2284   dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info);
     2772  dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
     2773    || (elfNN_ia64_aix_vec (x->info->hash->creator)
     2774        /* Don't allocate an entry for __GLOB_DATA_PTR */
     2775        && (!dyn_i->h || strcmp (dyn_i->h->root.root.string,
     2776          "__GLOB_DATA_PTR") != 0));
    22852777  shared = x->info->shared;
    22862778
     
    23162808            count *= 2;
    23172809          break;
     2810        case R_IA64_TPREL64LSB:
     2811        case R_IA64_DTPREL64LSB:
     2812        case R_IA64_DTPMOD64LSB:
     2813          break;
    23182814        default:
    23192815          abort ();
     
    23242820  /* Take care of the GOT and PLT relocations.  */
    23252821
    2326   if (((dynamic_symbol || shared) && dyn_i->want_got)
     2822  if (((dynamic_symbol || shared) && (dyn_i->want_got || dyn_i->want_gotx))
    23272823      || (dyn_i->want_ltoff_fptr && dyn_i->h && dyn_i->h->dynindx != -1))
     2824    ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
     2825  if ((dynamic_symbol || shared) && dyn_i->want_tprel)
     2826    ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
     2827  if (dynamic_symbol && dyn_i->want_dtpmod)
     2828    ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
     2829  if (dynamic_symbol && dyn_i->want_dtprel)
    23282830    ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
    23292831
     
    23432845    }
    23442846
    2345   return true;
    2346 }
    2347 
    2348 static boolean
     2847  return TRUE;
     2848}
     2849
     2850static bfd_boolean
    23492851elfNN_ia64_adjust_dynamic_symbol (info, h)
    23502852     struct bfd_link_info *info ATTRIBUTE_UNUSED;
     
    23632865      h->root.u.def.section = h->weakdef->root.u.def.section;
    23642866      h->root.u.def.value = h->weakdef->root.u.def.value;
    2365       return true;
     2867      return TRUE;
    23662868    }
    23672869
     
    23732875     of hackery.  */
    23742876
    2375   return true;
    2376 }
    2377 
    2378 static boolean
     2877  return TRUE;
     2878}
     2879
     2880static bfd_boolean
    23792881elfNN_ia64_size_dynamic_sections (output_bfd, info)
    23802882     bfd *output_bfd;
     
    23852887  asection *sec;
    23862888  bfd *dynobj;
    2387   boolean reltext = false;
    2388   boolean relplt = false;
     2889  bfd_boolean relplt = FALSE;
    23892890
    23902891  dynobj = elf_hash_table(info)->dynobj;
    23912892  ia64_info = elfNN_ia64_hash_table (info);
     2893  ia64_info->self_dtpmod_offset = (bfd_vma) -1;
    23922894  BFD_ASSERT(dynobj != NULL);
    23932895  data.info = info;
     
    23992901      sec = bfd_get_section_by_name (dynobj, ".interp");
    24002902      BFD_ASSERT (sec != NULL);
    2401       sec->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
    2402       sec->_raw_size = strlen (ELF_DYNAMIC_INTERPRETER) + 1;
     2903      sec->contents = (bfd_byte *) DYNAMIC_INTERPRETER (output_bfd);
     2904      sec->_raw_size = strlen (DYNAMIC_INTERPRETER (output_bfd)) + 1;
    24032905    }
    24042906
     
    24252927  /* Now that we've seen all of the input files, we can decide which
    24262928     symbols need plt entries.  Allocate the minimal PLT entries first.
    2427      We do this even though dynamic_sections_created may be false, because
     2929     We do this even though dynamic_sections_created may be FALSE, because
    24282930     this has the side-effect of clearing want_plt and want_plt2.  */
    24292931
     
    24392941
    24402942  /* Align the pointer for the plt2 entries.  */
    2441   data.ofs = (data.ofs + 31) & -32;
     2943  data.ofs = (data.ofs + 31) & (bfd_vma) -32;
    24422944
    24432945  elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_plt2_entries, &data);
     
    24682970         required.  */
    24692971
     2972      if (info->shared && ia64_info->self_dtpmod_offset != (bfd_vma) -1)
     2973        ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
    24702974      elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_dynrel_entries, &data);
    24712975    }
     
    24752979  for (sec = dynobj->sections; sec != NULL; sec = sec->next)
    24762980    {
    2477       boolean strip;
     2981      bfd_boolean strip;
    24782982
    24792983      if (!(sec->flags & SEC_LINKER_CREATED))
     
    24912995
    24922996      if (sec == ia64_info->got_sec)
    2493         strip = false;
     2997        strip = FALSE;
    24942998      else if (sec == ia64_info->rel_got_sec)
    24952999        {
     
    25223026          else
    25233027            {
    2524               relplt = true;
     3028              relplt = TRUE;
    25253029              /* We use the reloc_count field as a counter if we need to
    25263030                 copy relocs into the output file.  */
     
    25373041
    25383042          if (strcmp (name, ".got.plt") == 0)
    2539             strip = false;
     3043            strip = FALSE;
    25403044          else if (strncmp (name, ".rel", 4) == 0)
    25413045            {
    25423046              if (!strip)
    25433047                {
    2544                   const char *outname;
    2545                   asection *target;
    2546 
    2547                   /* If this relocation section applies to a read only
    2548                      section, then we probably need a DT_TEXTREL entry.  */
    2549                   outname = bfd_get_section_name (output_bfd,
    2550                                                   sec->output_section);
    2551                   if (outname[4] == 'a')
    2552                     outname += 5;
    2553                   else
    2554                     outname += 4;
    2555 
    2556                   target = bfd_get_section_by_name (output_bfd, outname);
    2557                   if (target != NULL
    2558                       && (target->flags & SEC_READONLY) != 0
    2559                       && (target->flags & SEC_ALLOC) != 0)
    2560                     reltext = true;
    2561 
    25623048                  /* We use the reloc_count field as a counter if we need to
    25633049                     copy relocs into the output file.  */
     
    25743060        {
    25753061          /* Allocate memory for the section contents.  */
    2576           sec->contents = (bfd_byte *) bfd_zalloc(dynobj, sec->_raw_size);
     3062          sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->_raw_size);
    25773063          if (sec->contents == NULL && sec->_raw_size != 0)
    2578             return false;
     3064            return FALSE;
    25793065        }
    25803066    }
     
    25903076          /* The DT_DEBUG entry is filled in by the dynamic linker and used
    25913077             by the debugger.  */
    2592           if (!bfd_elfNN_add_dynamic_entry (info, DT_DEBUG, 0))
    2593             return false;
    2594         }
    2595 
    2596       if (! bfd_elfNN_add_dynamic_entry (info, DT_IA_64_PLT_RESERVE, 0))
    2597         return false;
    2598       if (! bfd_elfNN_add_dynamic_entry (info, DT_PLTGOT, 0))
    2599         return false;
     3078#define add_dynamic_entry(TAG, VAL) \
     3079  bfd_elfNN_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
     3080
     3081          if (!add_dynamic_entry (DT_DEBUG, 0))
     3082            return FALSE;
     3083        }
     3084
     3085      if (!add_dynamic_entry (DT_IA_64_PLT_RESERVE, 0))
     3086        return FALSE;
     3087      if (!add_dynamic_entry (DT_PLTGOT, 0))
     3088        return FALSE;
    26003089
    26013090      if (relplt)
    26023091        {
    2603           if (! bfd_elfNN_add_dynamic_entry (info, DT_PLTRELSZ, 0)
    2604               || ! bfd_elfNN_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
    2605               || ! bfd_elfNN_add_dynamic_entry (info, DT_JMPREL, 0))
    2606             return false;
    2607         }
    2608 
    2609       if (! bfd_elfNN_add_dynamic_entry (info, DT_RELA, 0)
    2610           || ! bfd_elfNN_add_dynamic_entry (info, DT_RELASZ, 0)
    2611           || ! bfd_elfNN_add_dynamic_entry (info, DT_RELAENT,
    2612                                             sizeof (ElfNN_External_Rela)))
    2613         return false;
    2614 
    2615       if (reltext)
    2616         {
    2617           if (! bfd_elfNN_add_dynamic_entry (info, DT_TEXTREL, 0))
    2618             return false;
     3092          if (!add_dynamic_entry (DT_PLTRELSZ, 0)
     3093              || !add_dynamic_entry (DT_PLTREL, DT_RELA)
     3094              || !add_dynamic_entry (DT_JMPREL, 0))
     3095            return FALSE;
     3096        }
     3097
     3098      if (!add_dynamic_entry (DT_RELA, 0)
     3099          || !add_dynamic_entry (DT_RELASZ, 0)
     3100          || !add_dynamic_entry (DT_RELAENT, sizeof (ElfNN_External_Rela)))
     3101        return FALSE;
     3102
     3103      if (ia64_info->reltext)
     3104        {
     3105          if (!add_dynamic_entry (DT_TEXTREL, 0))
     3106            return FALSE;
    26193107          info->flags |= DF_TEXTREL;
    26203108        }
     
    26233111  /* ??? Perhaps force __gp local.  */
    26243112
    2625   return true;
     3113  return TRUE;
    26263114}
    26273115
    26283116static bfd_reloc_status_type
    2629 elfNN_ia64_install_value (abfd, hit_addr, val, r_type)
     3117elfNN_ia64_install_value (abfd, hit_addr, v, r_type)
    26303118     bfd *abfd;
    26313119     bfd_byte *hit_addr;
    2632      bfd_vma val;
     3120     bfd_vma v;
    26333121     unsigned int r_type;
    26343122{
     
    26393127  const char *err;
    26403128  size_t size = 8;
     3129#ifdef BFD_HOST_U_64_BIT
     3130  BFD_HOST_U_64_BIT val = (BFD_HOST_U_64_BIT) v;
     3131#else
     3132  bfd_vma val = v;
     3133#endif
    26413134
    26423135  opnd = IA64_OPND_NIL;
     
    26493142      /* Instruction relocations.  */
    26503143
    2651     case R_IA64_IMM14:          opnd = IA64_OPND_IMM14; break;
     3144    case R_IA64_IMM14:
     3145    case R_IA64_TPREL14:
     3146    case R_IA64_DTPREL14:
     3147      opnd = IA64_OPND_IMM14;
     3148      break;
    26523149
    26533150    case R_IA64_PCREL21F:       opnd = IA64_OPND_TGT25; break;
     
    26663163    case R_IA64_PCREL22:
    26673164    case R_IA64_LTOFF_FPTR22:
     3165    case R_IA64_TPREL22:
     3166    case R_IA64_DTPREL22:
     3167    case R_IA64_LTOFF_TPREL22:
     3168    case R_IA64_LTOFF_DTPMOD22:
     3169    case R_IA64_LTOFF_DTPREL22:
    26683170      opnd = IA64_OPND_IMM22;
    26693171      break;
     
    26763178    case R_IA64_FPTR64I:
    26773179    case R_IA64_LTOFF_FPTR64I:
     3180    case R_IA64_TPREL64I:
     3181    case R_IA64_DTPREL64I:
    26783182      opnd = IA64_OPND_IMMU64;
    26793183      break;
     
    26853189    case R_IA64_FPTR32MSB:
    26863190    case R_IA64_PCREL32MSB:
     3191    case R_IA64_LTOFF_FPTR32MSB:
    26873192    case R_IA64_SEGREL32MSB:
    26883193    case R_IA64_SECREL32MSB:
    26893194    case R_IA64_LTV32MSB:
     3195    case R_IA64_DTPREL32MSB:
    26903196      size = 4; bigendian = 1;
    26913197      break;
     
    26953201    case R_IA64_FPTR32LSB:
    26963202    case R_IA64_PCREL32LSB:
     3203    case R_IA64_LTOFF_FPTR32LSB:
    26973204    case R_IA64_SEGREL32LSB:
    26983205    case R_IA64_SECREL32LSB:
    26993206    case R_IA64_LTV32LSB:
     3207    case R_IA64_DTPREL32LSB:
    27003208      size = 4; bigendian = 0;
    27013209      break;
     
    27103218    case R_IA64_SECREL64MSB:
    27113219    case R_IA64_LTV64MSB:
     3220    case R_IA64_TPREL64MSB:
     3221    case R_IA64_DTPMOD64MSB:
     3222    case R_IA64_DTPREL64MSB:
    27123223      size = 8; bigendian = 1;
    27133224      break;
     
    27223233    case R_IA64_SECREL64LSB:
    27233234    case R_IA64_LTV64LSB:
     3235    case R_IA64_TPREL64LSB:
     3236    case R_IA64_DTPMOD64LSB:
     3237    case R_IA64_DTPREL64LSB:
    27243238      size = 8; bigendian = 0;
    27253239      break;
     
    27983312
    27993313      op = elf64_ia64_operands + opnd;
    2800       err = (*op->insert) (op, val, &insn);
     3314      err = (*op->insert) (op, val, (ia64_insn *)& insn);
    28013315      if (err)
    28023316        return bfd_reloc_overflow;
     
    28383352{
    28393353  Elf_Internal_Rela outrel;
    2840 
    2841   outrel.r_offset = (sec->output_section->vma
    2842                      + sec->output_offset
    2843                      + offset);
     3354  bfd_byte *loc;
    28443355
    28453356  BFD_ASSERT (dynindx != -1);
    28463357  outrel.r_info = ELFNN_R_INFO (dynindx, type);
    28473358  outrel.r_addend = addend;
    2848 
    2849   if (elf_section_data (sec)->stab_info != NULL)
    2850     {
    2851       /* This may be NULL for linker-generated relocations, as it is
    2852          inconvenient to pass all the bits around.  And this shouldn't
    2853          happen.  */
    2854       BFD_ASSERT (info != NULL);
    2855 
    2856       offset = (_bfd_stab_section_offset
    2857                 (abfd, &elf_hash_table (info)->stab_info, sec,
    2858                  &elf_section_data (sec)->stab_info, offset));
    2859       if (offset == (bfd_vma) -1)
    2860         {
    2861           /* Run for the hills.  We shouldn't be outputting a relocation
    2862              for this.  So do what everyone else does and output a no-op.  */
    2863           outrel.r_info = ELFNN_R_INFO (0, R_IA64_NONE);
    2864           outrel.r_addend = 0;
    2865           offset = 0;
    2866         }
    2867       outrel.r_offset = offset;
    2868     }
    2869 
    2870   bfd_elfNN_swap_reloca_out (abfd, &outrel,
    2871                              ((ElfNN_External_Rela *) srel->contents
    2872                               + srel->reloc_count++));
     3359  outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset);
     3360  if (outrel.r_offset >= (bfd_vma) -2)
     3361    {
     3362      /* Run for the hills.  We shouldn't be outputting a relocation
     3363         for this.  So do what everyone else does and output a no-op.  */
     3364      outrel.r_info = ELFNN_R_INFO (0, R_IA64_NONE);
     3365      outrel.r_addend = 0;
     3366      outrel.r_offset = 0;
     3367    }
     3368  else
     3369    outrel.r_offset += sec->output_section->vma + sec->output_offset;
     3370
     3371  loc = srel->contents;
     3372  loc += srel->reloc_count++ * sizeof (ElfNN_External_Rela);
     3373  bfd_elfNN_swap_reloca_out (abfd, &outrel, loc);
    28733374  BFD_ASSERT (sizeof (ElfNN_External_Rela) * srel->reloc_count
    28743375              <= srel->_cooked_size);
     
    28903391  struct elfNN_ia64_link_hash_table *ia64_info;
    28913392  asection *got_sec;
     3393  bfd_boolean done;
     3394  bfd_vma got_offset;
    28923395
    28933396  ia64_info = elfNN_ia64_hash_table (info);
    28943397  got_sec = ia64_info->got_sec;
    28953398
    2896   BFD_ASSERT ((dyn_i->got_offset & 7) == 0);
    2897 
    2898   if (! dyn_i->got_done)
    2899     {
    2900       dyn_i->got_done = true;
    2901 
     3399  switch (dyn_r_type)
     3400    {
     3401    case R_IA64_TPREL64LSB:
     3402      done = dyn_i->tprel_done;
     3403      dyn_i->tprel_done = TRUE;
     3404      got_offset = dyn_i->tprel_offset;
     3405      break;
     3406    case R_IA64_DTPMOD64LSB:
     3407      if (dyn_i->dtpmod_offset != ia64_info->self_dtpmod_offset)
     3408        {
     3409          done = dyn_i->dtpmod_done;
     3410          dyn_i->dtpmod_done = TRUE;
     3411        }
     3412      else
     3413        {
     3414          done = ia64_info->self_dtpmod_done;
     3415          ia64_info->self_dtpmod_done = TRUE;
     3416          dynindx = 0;
     3417        }
     3418      got_offset = dyn_i->dtpmod_offset;
     3419      break;
     3420    case R_IA64_DTPREL64LSB:
     3421      done = dyn_i->dtprel_done;
     3422      dyn_i->dtprel_done = TRUE;
     3423      got_offset = dyn_i->dtprel_offset;
     3424      break;
     3425    default:
     3426      done = dyn_i->got_done;
     3427      dyn_i->got_done = TRUE;
     3428      got_offset = dyn_i->got_offset;
     3429      break;
     3430    }
     3431
     3432  BFD_ASSERT ((got_offset & 7) == 0);
     3433
     3434  if (! done)
     3435    {
    29023436      /* Store the target address in the linkage table entry.  */
    2903       bfd_put_64 (abfd, value, got_sec->contents + dyn_i->got_offset);
     3437      bfd_put_64 (abfd, value, got_sec->contents + got_offset);
    29043438
    29053439      /* Install a dynamic relocation if needed.  */
    2906       if (info->shared
     3440      if ((info->shared && dyn_r_type != R_IA64_DTPREL64LSB)
    29073441          || elfNN_ia64_dynamic_symbol_p (dyn_i->h, info)
     3442          || elfNN_ia64_aix_vec (abfd->xvec)
    29083443          || (dynindx != -1 && dyn_r_type == R_IA64_FPTR64LSB))
    29093444        {
    2910           if (dynindx == -1)
     3445          if (dynindx == -1
     3446              && dyn_r_type != R_IA64_TPREL64LSB
     3447              && dyn_r_type != R_IA64_DTPMOD64LSB
     3448              && dyn_r_type != R_IA64_DTPREL64LSB)
    29113449            {
    29123450              dyn_r_type = R_IA64_REL64LSB;
     
    29283466                  dyn_r_type = R_IA64_FPTR64MSB;
    29293467                  break;
     3468                case R_IA64_TPREL64LSB:
     3469                  dyn_r_type = R_IA64_TPREL64MSB;
     3470                  break;
     3471                case R_IA64_DTPMOD64LSB:
     3472                  dyn_r_type = R_IA64_DTPMOD64MSB;
     3473                  break;
     3474                case R_IA64_DTPREL64LSB:
     3475                  dyn_r_type = R_IA64_DTPREL64MSB;
     3476                  break;
    29303477                default:
    2931                   BFD_ASSERT (false);
     3478                  BFD_ASSERT (FALSE);
    29323479                  break;
    29333480                }
     
    29363483          elfNN_ia64_install_dyn_reloc (abfd, NULL, got_sec,
    29373484                                        ia64_info->rel_got_sec,
    2938                                         dyn_i->got_offset, dyn_r_type,
     3485                                        got_offset, dyn_r_type,
    29393486                                        dynindx, addend);
    29403487        }
     
    29443491  value = (got_sec->output_section->vma
    29453492           + got_sec->output_offset
    2946            + dyn_i->got_offset);
     3493           + got_offset);
    29473494
    29483495  return value;
     
    29923539     struct elfNN_ia64_dyn_sym_info *dyn_i;
    29933540     bfd_vma value;
    2994      boolean is_plt;
     3541     bfd_boolean is_plt;
    29953542{
    29963543  struct elfNN_ia64_link_hash_table *ia64_info;
     
    30423589}
    30433590
     3591/* Return the base VMA address which should be subtracted from real addresses
     3592   when resolving @tprel() relocation.
     3593   Main program TLS (whose template starts at PT_TLS p_vaddr)
     3594   is assigned offset round(16, PT_TLS p_align).  */
     3595
     3596static bfd_vma
     3597elfNN_ia64_tprel_base (info)
     3598     struct bfd_link_info *info;
     3599{
     3600  struct elf_link_tls_segment *tls_segment
     3601    = elf_hash_table (info)->tls_segment;
     3602
     3603  BFD_ASSERT (tls_segment != NULL);
     3604  return (tls_segment->start
     3605          - align_power ((bfd_vma) 16, tls_segment->align));
     3606}
     3607
     3608/* Return the base VMA address which should be subtracted from real addresses
     3609   when resolving @dtprel() relocation.
     3610   This is PT_TLS segment p_vaddr.  */
     3611
     3612static bfd_vma
     3613elfNN_ia64_dtprel_base (info)
     3614     struct bfd_link_info *info;
     3615{
     3616  BFD_ASSERT (elf_hash_table (info)->tls_segment != NULL);
     3617  return elf_hash_table (info)->tls_segment->start;
     3618}
     3619
    30443620/* Called through qsort to sort the .IA_64.unwind section during a
    30453621   non-relocatable link.  Set elfNN_ia64_unwind_entry_compare_bfd
     
    30503626static int
    30513627elfNN_ia64_unwind_entry_compare (a, b)
    3052      PTR a;
    3053      PTR b;
     3628     const PTR a;
     3629     const PTR b;
    30543630{
    30553631  bfd_vma av, bv;
     
    30613637}
    30623638
    3063 static boolean
     3639/* Make sure we've got ourselves a nice fat __gp value.  */
     3640static bfd_boolean
     3641elfNN_ia64_choose_gp (abfd, info)
     3642     bfd *abfd;
     3643     struct bfd_link_info *info;
     3644{
     3645  bfd_vma min_vma = (bfd_vma) -1, max_vma = 0;
     3646  bfd_vma min_short_vma = min_vma, max_short_vma = 0;
     3647  struct elf_link_hash_entry *gp;
     3648  bfd_vma gp_val;
     3649  asection *os;
     3650  struct elfNN_ia64_link_hash_table *ia64_info;
     3651
     3652  ia64_info = elfNN_ia64_hash_table (info);
     3653
     3654  /* Find the min and max vma of all sections marked short.  Also collect
     3655     min and max vma of any type, for use in selecting a nice gp.  */
     3656  for (os = abfd->sections; os ; os = os->next)
     3657    {
     3658      bfd_vma lo, hi;
     3659
     3660      if ((os->flags & SEC_ALLOC) == 0)
     3661        continue;
     3662
     3663      lo = os->vma;
     3664      hi = os->vma + os->_raw_size;
     3665      if (hi < lo)
     3666        hi = (bfd_vma) -1;
     3667
     3668      if (min_vma > lo)
     3669        min_vma = lo;
     3670      if (max_vma < hi)
     3671        max_vma = hi;
     3672      if (os->flags & SEC_SMALL_DATA)
     3673        {
     3674          if (min_short_vma > lo)
     3675            min_short_vma = lo;
     3676          if (max_short_vma < hi)
     3677            max_short_vma = hi;
     3678        }
     3679    }
     3680
     3681  /* See if the user wants to force a value.  */
     3682  gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
     3683                             FALSE, FALSE);
     3684
     3685  if (gp
     3686      && (gp->root.type == bfd_link_hash_defined
     3687          || gp->root.type == bfd_link_hash_defweak))
     3688    {
     3689      asection *gp_sec = gp->root.u.def.section;
     3690      gp_val = (gp->root.u.def.value
     3691                + gp_sec->output_section->vma
     3692                + gp_sec->output_offset);
     3693    }
     3694  else
     3695    {
     3696      /* Pick a sensible value.  */
     3697
     3698      asection *got_sec = ia64_info->got_sec;
     3699
     3700      /* Start with just the address of the .got.  */
     3701      if (got_sec)
     3702        gp_val = got_sec->output_section->vma;
     3703      else if (max_short_vma != 0)
     3704        gp_val = min_short_vma;
     3705      else
     3706        gp_val = min_vma;
     3707
     3708      /* If it is possible to address the entire image, but we
     3709         don't with the choice above, adjust.  */
     3710      if (max_vma - min_vma < 0x400000
     3711          && max_vma - gp_val <= 0x200000
     3712          && gp_val - min_vma > 0x200000)
     3713        gp_val = min_vma + 0x200000;
     3714      else if (max_short_vma != 0)
     3715        {
     3716          /* If we don't cover all the short data, adjust.  */
     3717          if (max_short_vma - gp_val >= 0x200000)
     3718            gp_val = min_short_vma + 0x200000;
     3719
     3720          /* If we're addressing stuff past the end, adjust back.  */
     3721          if (gp_val > max_vma)
     3722            gp_val = max_vma - 0x200000 + 8;
     3723        }
     3724    }
     3725
     3726  /* Validate whether all SHF_IA_64_SHORT sections are within
     3727     range of the chosen GP.  */
     3728
     3729  if (max_short_vma != 0)
     3730    {
     3731      if (max_short_vma - min_short_vma >= 0x400000)
     3732        {
     3733          (*_bfd_error_handler)
     3734            (_("%s: short data segment overflowed (0x%lx >= 0x400000)"),
     3735             bfd_get_filename (abfd),
     3736             (unsigned long) (max_short_vma - min_short_vma));
     3737          return FALSE;
     3738        }
     3739      else if ((gp_val > min_short_vma
     3740                && gp_val - min_short_vma > 0x200000)
     3741               || (gp_val < max_short_vma
     3742                   && max_short_vma - gp_val >= 0x200000))
     3743        {
     3744          (*_bfd_error_handler)
     3745            (_("%s: __gp does not cover short data segment"),
     3746             bfd_get_filename (abfd));
     3747          return FALSE;
     3748        }
     3749    }
     3750
     3751  _bfd_set_gp_value (abfd, gp_val);
     3752
     3753  return TRUE;
     3754}
     3755
     3756static bfd_boolean
    30643757elfNN_ia64_final_link (abfd, info)
    30653758     bfd *abfd;
     
    30743767  if (!info->relocateable)
    30753768    {
    3076       bfd_vma min_vma = (bfd_vma) -1, max_vma = 0;
    3077       bfd_vma min_short_vma = min_vma, max_short_vma = 0;
     3769      bfd_vma gp_val = _bfd_get_gp_value (abfd);
    30783770      struct elf_link_hash_entry *gp;
    3079       bfd_vma gp_val;
    3080       asection *os;
    3081 
    3082       /* Find the min and max vma of all sections marked short.  Also
    3083          collect min and max vma of any type, for use in selecting a
    3084          nice gp.  */
    3085       for (os = abfd->sections; os ; os = os->next)
    3086         {
    3087           bfd_vma lo, hi;
    3088 
    3089           if ((os->flags & SEC_ALLOC) == 0)
    3090             continue;
    3091 
    3092           lo = os->vma;
    3093           hi = os->vma + os->_raw_size;
    3094           if (hi < lo)
    3095             hi = (bfd_vma) -1;
    3096 
    3097           if (min_vma > lo)
    3098             min_vma = lo;
    3099           if (max_vma < hi)
    3100             max_vma = hi;
    3101           if (os->flags & SEC_SMALL_DATA)
    3102             {
    3103               if (min_short_vma > lo)
    3104                 min_short_vma = lo;
    3105               if (max_short_vma < hi)
    3106                 max_short_vma = hi;
    3107             }
    3108         }
    3109 
    3110       /* See if the user wants to force a value.  */
    3111       gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", false,
    3112                                  false, false);
    3113 
    3114       if (gp
    3115           && (gp->root.type == bfd_link_hash_defined
    3116               || gp->root.type == bfd_link_hash_defweak))
    3117         {
    3118           asection *gp_sec = gp->root.u.def.section;
    3119           gp_val = (gp->root.u.def.value
    3120                     + gp_sec->output_section->vma
    3121                     + gp_sec->output_offset);
    3122         }
    3123       else
    3124         {
    3125           /* Pick a sensible value.  */
    3126 
    3127           asection *got_sec = ia64_info->got_sec;
    3128 
    3129           /* Start with just the address of the .got.  */
    3130           if (got_sec)
    3131             gp_val = got_sec->output_section->vma;
    3132           else if (max_short_vma != 0)
    3133             gp_val = min_short_vma;
    3134           else
    3135             gp_val = min_vma;
    3136 
    3137           /* If it is possible to address the entire image, but we
    3138              don't with the choice above, adjust.  */
    3139           if (max_vma - min_vma < 0x400000
    3140               && max_vma - gp_val <= 0x200000
    3141               && gp_val - min_vma > 0x200000)
    3142             gp_val = min_vma + 0x200000;
    3143           else if (max_short_vma != 0)
    3144             {
    3145               /* If we don't cover all the short data, adjust.  */
    3146               if (max_short_vma - gp_val >= 0x200000)
    3147                 gp_val = min_short_vma + 0x200000;
    3148 
    3149               /* If we're addressing stuff past the end, adjust back.  */
    3150               if (gp_val > max_vma)
    3151                 gp_val = max_vma - 0x200000 + 8;
    3152             }
    3153         }
    3154 
    3155       /* Validate whether all SHF_IA_64_SHORT sections are within
    3156          range of the chosen GP.  */
    3157 
    3158       if (max_short_vma != 0)
    3159         {
    3160           if (max_short_vma - min_short_vma >= 0x400000)
    3161             {
    3162               (*_bfd_error_handler)
    3163                 (_("%s: short data segment overflowed (0x%lx >= 0x400000)"),
    3164                  bfd_get_filename (abfd),
    3165                  (unsigned long) (max_short_vma - min_short_vma));
    3166               return false;
    3167             }
    3168           else if ((gp_val > min_short_vma
    3169                     && gp_val - min_short_vma > 0x200000)
    3170                    || (gp_val < max_short_vma
    3171                        && max_short_vma - gp_val >= 0x200000))
    3172             {
    3173               (*_bfd_error_handler)
    3174                 (_("%s: __gp does not cover short data segment"),
    3175                  bfd_get_filename (abfd));
    3176               return false;
    3177             }
    3178         }
    3179 
    3180       _bfd_set_gp_value (abfd, gp_val);
    3181 
     3771
     3772      if (gp_val == 0)
     3773        {
     3774          if (! elfNN_ia64_choose_gp (abfd, info))
     3775            return FALSE;
     3776          gp_val = _bfd_get_gp_value (abfd);
     3777        }
     3778
     3779      gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
     3780                                 FALSE, FALSE);
    31823781      if (gp)
    31833782        {
     
    32013800            = bfd_malloc (unwind_output_sec->_raw_size);
    32023801          if (unwind_output_sec->contents == NULL)
    3203             return false;
     3802            return FALSE;
    32043803        }
    32053804    }
     
    32073806  /* Invoke the regular ELF backend linker to do all the work.  */
    32083807  if (!bfd_elfNN_bfd_final_link (abfd, info))
    3209     return false;
     3808    return FALSE;
    32103809
    32113810  if (unwind_output_sec)
    32123811    {
    32133812      elfNN_ia64_unwind_entry_compare_bfd = abfd;
    3214       qsort (unwind_output_sec->contents, unwind_output_sec->_raw_size / 24,
    3215              24, elfNN_ia64_unwind_entry_compare);
     3813      qsort (unwind_output_sec->contents,
     3814             (size_t) (unwind_output_sec->_raw_size / 24),
     3815             24,
     3816             elfNN_ia64_unwind_entry_compare);
    32163817
    32173818      if (! bfd_set_section_contents (abfd, unwind_output_sec,
    3218                                       unwind_output_sec->contents, 0,
     3819                                      unwind_output_sec->contents, (bfd_vma) 0,
    32193820                                      unwind_output_sec->_raw_size))
    3220         return false;
    3221     }
    3222 
    3223   return true;
    3224 }
    3225 
    3226 static boolean
     3821        return FALSE;
     3822    }
     3823
     3824  return TRUE;
     3825}
     3826
     3827static bfd_boolean
    32273828elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
    32283829                             contents, relocs, local_syms, local_sections)
     
    32413842  Elf_Internal_Rela *relend;
    32423843  asection *srel;
    3243   boolean ret_val = true;       /* for non-fatal errors */
     3844  bfd_boolean ret_val = TRUE;   /* for non-fatal errors */
    32443845  bfd_vma gp_val;
    32453846
     
    32573858      elf_section_data(input_section->output_section)
    32583859        ->this_hdr.sh_flags |= flags;
     3860      return TRUE;
    32593861    }
    32603862
    32613863  gp_val = _bfd_get_gp_value (output_bfd);
    3262   srel = get_reloc_section (input_bfd, ia64_info, input_section, false);
     3864  srel = get_reloc_section (input_bfd, ia64_info, input_section, FALSE);
    32633865
    32643866  rel = relocs;
     
    32763878      asection *sym_sec;
    32773879      bfd_byte *hit_addr;
    3278       boolean dynamic_symbol_p;
    3279       boolean undef_weak_ref;
     3880      bfd_boolean dynamic_symbol_p;
     3881      bfd_boolean undef_weak_ref;
    32803882
    32813883      r_type = ELFNN_R_TYPE (rel->r_info);
     
    32843886          (*_bfd_error_handler)
    32853887            (_("%s: unknown relocation type %d"),
    3286              bfd_get_filename (input_bfd), (int)r_type);
     3888             bfd_archive_filename (input_bfd), (int)r_type);
    32873889          bfd_set_error (bfd_error_bad_value);
    3288           ret_val = false;
     3890          ret_val = FALSE;
    32893891          continue;
    32903892        }
     3893
    32913894      howto = lookup_howto (r_type);
    32923895      r_symndx = ELFNN_R_SYM (rel->r_info);
    3293 
    3294       if (info->relocateable)
    3295         {
    3296           /* This is a relocateable link.  We don't have to change
    3297              anything, unless the reloc is against a section symbol,
    3298              in which case we have to adjust according to where the
    3299              section symbol winds up in the output section.  */
    3300           if (r_symndx < symtab_hdr->sh_info)
    3301             {
    3302               sym = local_syms + r_symndx;
    3303               if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
    3304                 {
    3305                   sym_sec = local_sections[r_symndx];
    3306                   rel->r_addend += sym_sec->output_offset;
    3307                 }
    3308             }
    3309           continue;
    3310         }
    3311 
    3312       /* This is a final link.  */
    3313 
    33143896      h = NULL;
    33153897      sym = NULL;
    33163898      sym_sec = NULL;
    3317       undef_weak_ref = false;
     3899      undef_weak_ref = FALSE;
    33183900
    33193901      if (r_symndx < symtab_hdr->sh_info)
     
    33223904          sym = local_syms + r_symndx;
    33233905          sym_sec = local_sections[r_symndx];
    3324           value  = (sym_sec->output_section->vma
    3325                     + sym_sec->output_offset
    3326                     + sym->st_value);
     3906          value = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
     3907          if ((sym_sec->flags & SEC_MERGE)
     3908              && ELF_ST_TYPE (sym->st_info) == STT_SECTION
     3909              && sym_sec->sec_info_type == ELF_INFO_TYPE_MERGE)
     3910            {
     3911              struct elfNN_ia64_local_hash_entry *loc_h;
     3912
     3913              loc_h = get_local_sym_hash (ia64_info, input_bfd, rel, FALSE);
     3914              if (loc_h && ! loc_h->sec_merge_done)
     3915                {
     3916                  struct elfNN_ia64_dyn_sym_info *dynent;
     3917                  asection *msec;
     3918
     3919                  for (dynent = loc_h->info; dynent; dynent = dynent->next)
     3920                    {
     3921                      msec = sym_sec;
     3922                      dynent->addend =
     3923                        _bfd_merged_section_offset (output_bfd, &msec,
     3924                                                    elf_section_data (msec)->
     3925                                                    sec_info,
     3926                                                    sym->st_value
     3927                                                    + dynent->addend,
     3928                                                    (bfd_vma) 0);
     3929                      dynent->addend -= sym->st_value;
     3930                      dynent->addend += msec->output_section->vma
     3931                                        + msec->output_offset
     3932                                        - sym_sec->output_section->vma
     3933                                        - sym_sec->output_offset;
     3934                    }
     3935                  loc_h->sec_merge_done = 1;
     3936                }
     3937            }
    33273938        }
    33283939      else
     
    33593970            }
    33603971          else if (h->root.type == bfd_link_hash_undefweak)
    3361             undef_weak_ref = true;
    3362           else if (info->shared && !info->symbolic
     3972            undef_weak_ref = TRUE;
     3973          else if (info->shared
    33633974                   && !info->no_undefined
    33643975                   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
     
    33713982                      (!info->shared || info->no_undefined
    33723983                       || ELF_ST_VISIBILITY (h->other)))))
    3373                 return false;
    3374               ret_val = false;
     3984                return FALSE;
    33753985              continue;
    33763986            }
     
    33954005        case R_IA64_DIR64LSB:
    33964006          /* Install a dynamic relocation for this reloc.  */
    3397           if ((dynamic_symbol_p || info->shared)
     4007          if ((dynamic_symbol_p || info->shared
     4008               || (elfNN_ia64_aix_vec (info->hash->creator)
     4009                   /* Don't emit relocs for __GLOB_DATA_PTR on AIX. */
     4010                   && (!h || strcmp (h->root.root.string,
     4011                                     "__GLOB_DATA_PTR") != 0)))
     4012              && r_symndx != 0
    33984013              && (input_section->flags & SEC_ALLOC) != 0)
    33994014            {
     
    34394054                      (*_bfd_error_handler)
    34404055                        (_("%s: linking non-pic code in a shared library"),
    3441                          bfd_get_filename (input_bfd));
    3442                       ret_val = false;
     4056                         bfd_archive_filename (input_bfd));
     4057                      ret_val = FALSE;
    34434058                      continue;
    34444059                    }
     
    34474062                }
    34484063
     4064              if (elfNN_ia64_aix_vec (info->hash->creator))
     4065                rel->r_addend = value;
    34494066              elfNN_ia64_install_dyn_reloc (output_bfd, info, input_section,
    34504067                                            srel, rel->r_offset, dyn_r_type,
    34514068                                            dynindx, addend);
    34524069            }
    3453           /* FALLTHRU */
     4070          /* Fall through. */
    34544071
    34554072        case R_IA64_LTV32MSB:
     
    34704087              (*_bfd_error_handler)
    34714088                (_("%s: @gprel relocation against dynamic symbol %s"),
    3472                  bfd_get_filename (input_bfd), h->root.root.string);
    3473               ret_val = false;
     4089                 bfd_archive_filename (input_bfd), h->root.root.string);
     4090              ret_val = FALSE;
    34744091              continue;
    34754092            }
     
    34814098        case R_IA64_LTOFF22X:
    34824099        case R_IA64_LTOFF64I:
    3483           dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false);
     4100          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
    34844101          value = set_got_entry (input_bfd, info, dyn_i, (h ? h->dynindx : -1),
    34854102                                 rel->r_addend, value, R_IA64_DIR64LSB);
     
    34924109        case R_IA64_PLTOFF64MSB:
    34934110        case R_IA64_PLTOFF64LSB:
    3494           dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false);
    3495           value = set_pltoff_entry (output_bfd, info, dyn_i, value, false);
     4111          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
     4112          value = set_pltoff_entry (output_bfd, info, dyn_i, value, FALSE);
    34964113          value -= gp_val;
    34974114          r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type);
     
    35034120        case R_IA64_FPTR64MSB:
    35044121        case R_IA64_FPTR64LSB:
    3505           dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false);
     4122          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
    35064123          if (dyn_i->want_fptr)
    35074124            {
     
    35284145                {
    35294146                  dynindx = (_bfd_elf_link_lookup_local_dynindx
    3530                              (info, input_bfd, r_symndx));
     4147                             (info, input_bfd, (long) r_symndx));
    35314148                }
    35324149
     
    35424159        case R_IA64_LTOFF_FPTR22:
    35434160        case R_IA64_LTOFF_FPTR64I:
     4161        case R_IA64_LTOFF_FPTR32MSB:
     4162        case R_IA64_LTOFF_FPTR32LSB:
    35444163        case R_IA64_LTOFF_FPTR64MSB:
    35454164        case R_IA64_LTOFF_FPTR64LSB:
     
    35474166            long dynindx;
    35484167
    3549             dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false);
     4168            dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
    35504169            if (dyn_i->want_fptr)
    35514170              {
     
    35704189                else
    35714190                  dynindx = (_bfd_elf_link_lookup_local_dynindx
    3572                              (info, input_bfd, r_symndx));
     4191                             (info, input_bfd, (long) r_symndx));
    35734192                value = 0;
    35744193              }
     
    35864205        case R_IA64_PCREL64LSB:
    35874206          /* Install a dynamic relocation for this reloc.  */
    3588           if (dynamic_symbol_p)
     4207          if ((dynamic_symbol_p
     4208               || elfNN_ia64_aix_vec (info->hash->creator))
     4209              && r_symndx != 0)
    35894210            {
    35904211              BFD_ASSERT (srel != NULL);
     
    35964217          goto finish_pcrel;
    35974218
    3598         case R_IA64_PCREL21BI:
    3599         case R_IA64_PCREL21F:
    3600         case R_IA64_PCREL21M:
    3601           /* ??? These two are only used for speculation fixup code.
    3602              They should never be dynamic.  */
    3603           if (dynamic_symbol_p)
    3604             {
    3605               (*_bfd_error_handler)
    3606                 (_("%s: dynamic relocation against speculation fixup"),
    3607                  bfd_get_filename (input_bfd));
    3608               ret_val = false;
    3609               continue;
    3610             }
    3611           if (undef_weak_ref)
    3612             {
    3613               (*_bfd_error_handler)
    3614                 (_("%s: speculation fixup against undefined weak symbol"),
    3615                  bfd_get_filename (input_bfd));
    3616               ret_val = false;
    3617               continue;
    3618             }
    3619           goto finish_pcrel;
    3620 
    36214219        case R_IA64_PCREL21B:
    36224220        case R_IA64_PCREL60B:
     
    36244222          dyn_i = NULL;
    36254223          if (h)
    3626             dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, false);
     4224            dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, FALSE);
    36274225
    36284226          if (dyn_i && dyn_i->want_plt2)
     
    36504248          goto finish_pcrel;
    36514249
     4250        case R_IA64_PCREL21BI:
     4251        case R_IA64_PCREL21F:
     4252        case R_IA64_PCREL21M:
    36524253        case R_IA64_PCREL22:
    36534254        case R_IA64_PCREL64I:
     4255          /* The PCREL21BI reloc is specifically not intended for use with
     4256             dynamic relocs.  PCREL21F and PCREL21M are used for speculation
     4257             fixup code, and thus probably ought not be dynamic.  The
     4258             PCREL22 and PCREL64I relocs aren't emitted as dynamic relocs.  */
     4259          if (dynamic_symbol_p)
     4260            {
     4261              const char *msg;
     4262
     4263              if (r_type == R_IA64_PCREL21BI)
     4264                msg = _("%s: @internal branch to dynamic symbol %s");
     4265              else if (r_type == R_IA64_PCREL21F || r_type == R_IA64_PCREL21M)
     4266                msg = _("%s: speculation fixup to dynamic symbol %s");
     4267              else
     4268                msg = _("%s: @pcrel relocation against dynamic symbol %s");
     4269              (*_bfd_error_handler) (msg, bfd_archive_filename (input_bfd),
     4270                                     h->root.root.string);
     4271              ret_val = FALSE;
     4272              continue;
     4273            }
     4274          goto finish_pcrel;
     4275
    36544276        finish_pcrel:
    36554277          /* Make pc-relative.  */
     
    36644286        case R_IA64_SEGREL64MSB:
    36654287        case R_IA64_SEGREL64LSB:
    3666           {
    3667             struct elf_segment_map *m;
    3668             Elf_Internal_Phdr *p;
    3669 
    3670             /* Find the segment that contains the output_section.  */
    3671             for (m = elf_tdata (output_bfd)->segment_map,
    3672                    p = elf_tdata (output_bfd)->phdr;
    3673                  m != NULL;
    3674                  m = m->next, p++)
    3675               {
    3676                 int i;
    3677                 for (i = m->count - 1; i >= 0; i--)
    3678                   if (m->sections[i] == sym_sec->output_section)
     4288          if (r_symndx == 0)
     4289            {
     4290              /* If the input section was discarded from the output, then
     4291                 do nothing.  */
     4292              r = bfd_reloc_ok;
     4293            }
     4294          else
     4295            {
     4296              struct elf_segment_map *m;
     4297              Elf_Internal_Phdr *p;
     4298
     4299              /* Find the segment that contains the output_section.  */
     4300              for (m = elf_tdata (output_bfd)->segment_map,
     4301                     p = elf_tdata (output_bfd)->phdr;
     4302                   m != NULL;
     4303                   m = m->next, p++)
     4304                {
     4305                  int i;
     4306                  for (i = m->count - 1; i >= 0; i--)
     4307                    if (m->sections[i] == sym_sec->output_section)
     4308                      break;
     4309                  if (i >= 0)
    36794310                    break;
    3680                 if (i >= 0)
    3681                   break;
    3682               }
    3683 
    3684             if (m == NULL)
    3685               {
    3686                 /* If the input section was discarded from the output, then
    3687                    do nothing.  */
    3688 
    3689                 if (bfd_is_abs_section (sym_sec->output_section))
    3690                   r = bfd_reloc_ok;
    3691                 else
     4311                }
     4312
     4313              if (m == NULL)
     4314                {
    36924315                  r = bfd_reloc_notsupported;
    3693               }
    3694             else
    3695               {
    3696                 /* The VMA of the segment is the vaddr of the associated
    3697                    program header.  */
    3698                 if (value > p->p_vaddr)
    3699                   value -= p->p_vaddr;
    3700                 else
    3701                   value = 0;
    3702                 r = elfNN_ia64_install_value (output_bfd, hit_addr, value,
    3703                                               r_type);
    3704               }
    3705             break;
    3706           }
     4316                }
     4317              else
     4318                {
     4319                  /* The VMA of the segment is the vaddr of the associated
     4320                     program header.  */
     4321                  if (value > p->p_vaddr)
     4322                    value -= p->p_vaddr;
     4323                  else
     4324                    value = 0;
     4325                  r = elfNN_ia64_install_value (output_bfd, hit_addr, value,
     4326                                                r_type);
     4327                }
     4328              break;
     4329            }
    37074330
    37084331        case R_IA64_SECREL32MSB:
     
    37614384          break;
    37624385
     4386        case R_IA64_TPREL14:
     4387        case R_IA64_TPREL22:
     4388        case R_IA64_TPREL64I:
     4389          value -= elfNN_ia64_tprel_base (info);
     4390          r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type);
     4391          break;
     4392
     4393        case R_IA64_DTPREL14:
     4394        case R_IA64_DTPREL22:
     4395        case R_IA64_DTPREL64I:
     4396        case R_IA64_DTPREL64LSB:
     4397        case R_IA64_DTPREL64MSB:
     4398          value -= elfNN_ia64_dtprel_base (info);
     4399          r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type);
     4400          break;
     4401
     4402        case R_IA64_LTOFF_TPREL22:
     4403        case R_IA64_LTOFF_DTPMOD22:
     4404        case R_IA64_LTOFF_DTPREL22:
     4405          {
     4406            int got_r_type;
     4407            long dynindx = h ? h->dynindx : -1;
     4408            bfd_vma r_addend = rel->r_addend;
     4409
     4410            switch (r_type)
     4411              {
     4412              default:
     4413              case R_IA64_LTOFF_TPREL22:
     4414                if (!dynamic_symbol_p)
     4415                  {
     4416                    if (!info->shared)
     4417                      value -= elfNN_ia64_tprel_base (info);
     4418                    else
     4419                      {
     4420                        r_addend += value - elfNN_ia64_dtprel_base (info);
     4421                        dynindx = 0;
     4422                      }
     4423                  }
     4424                got_r_type = R_IA64_TPREL64LSB;
     4425                break;
     4426              case R_IA64_LTOFF_DTPMOD22:
     4427                if (!dynamic_symbol_p && !info->shared)
     4428                  value = 1;
     4429                got_r_type = R_IA64_DTPMOD64LSB;
     4430                break;
     4431              case R_IA64_LTOFF_DTPREL22:
     4432                if (!dynamic_symbol_p)
     4433                  value -= elfNN_ia64_dtprel_base (info);
     4434                got_r_type = R_IA64_DTPREL64LSB;
     4435                break;
     4436              }
     4437            dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
     4438            value = set_got_entry (input_bfd, info, dyn_i, dynindx, r_addend,
     4439                                   value, got_r_type);
     4440            value -= gp_val;
     4441            r = elfNN_ia64_install_value (output_bfd, hit_addr, value,
     4442                                          r_type);
     4443          }
     4444          break;
     4445
    37634446        default:
    37644447          r = bfd_reloc_notsupported;
     
    37774460          (*info->callbacks->undefined_symbol)
    37784461            (info, "__gp", input_bfd, input_section, rel->r_offset, 1);
    3779           return false;
     4462          return FALSE;
    37804463
    37814464        case bfd_reloc_notsupported:
     
    37914474                                                        sym->st_name);
    37924475                if (name == NULL)
    3793                   return false;
     4476                  return FALSE;
    37944477                if (*name == '\0')
    37954478                  name = bfd_section_name (input_bfd, input_section);
     
    37984481                                              name, input_bfd,
    37994482                                              input_section, rel->r_offset))
    3800               return false;
    3801             ret_val = false;
     4483              return FALSE;
     4484            ret_val = FALSE;
    38024485          }
    38034486          break;
     
    38184501                                                        sym->st_name);
    38194502                if (name == NULL)
    3820                   return false;
     4503                  return FALSE;
    38214504                if (*name == '\0')
    38224505                  name = bfd_section_name (input_bfd, input_section);
    38234506              }
    38244507            if (!(*info->callbacks->reloc_overflow) (info, name,
    3825                                                      howto->name, 0,
     4508                                                     howto->name,
     4509                                                     (bfd_vma) 0,
    38264510                                                     input_bfd,
    38274511                                                     input_section,
    38284512                                                     rel->r_offset))
    3829               return false;
    3830             ret_val = false;
     4513              return FALSE;
     4514            ret_val = FALSE;
    38314515          }
    38324516          break;
     
    38374521}
    38384522
    3839 static boolean
     4523static bfd_boolean
    38404524elfNN_ia64_finish_dynamic_symbol (output_bfd, info, h, sym)
    38414525     bfd *output_bfd;
     
    38484532
    38494533  ia64_info = elfNN_ia64_hash_table (info);
    3850   dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, false);
     4534  dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, FALSE);
    38514535
    38524536  /* Fill in the PLT data, if required.  */
     
    38574541      asection *plt_sec;
    38584542      bfd_vma plt_addr, pltoff_addr, gp_val, index;
    3859       ElfNN_External_Rela *rel;
    38604543
    38614544      gp_val = _bfd_get_gp_value (output_bfd);
     
    38754558                  + plt_sec->output_offset
    38764559                  + dyn_i->plt_offset);
    3877       pltoff_addr = set_pltoff_entry (output_bfd, info, dyn_i, plt_addr, true);
     4560      pltoff_addr = set_pltoff_entry (output_bfd, info, dyn_i, plt_addr, TRUE);
    38784561
    38794562      /* Initialize the FULL PLT entry, if needed.  */
     
    39144597         PLT relocations.  */
    39154598
    3916       rel = (ElfNN_External_Rela *)ia64_info->rel_pltoff_sec->contents;
    3917       rel += ia64_info->rel_pltoff_sec->reloc_count;
    3918 
    3919       bfd_elfNN_swap_reloca_out (output_bfd, &outrel, rel + index);
     4599      loc = ia64_info->rel_pltoff_sec->contents;
     4600      loc += ((ia64_info->rel_pltoff_sec->reloc_count + index)
     4601              * sizeof (Elf64_External_Rela));
     4602      bfd_elfNN_swap_reloca_out (output_bfd, &outrel, loc);
    39204603    }
    39214604
     
    39264609    sym->st_shndx = SHN_ABS;
    39274610
    3928   return true;
    3929 }
    3930 
    3931 static boolean
     4611  return TRUE;
     4612}
     4613
     4614static bfd_boolean
    39324615elfNN_ia64_finish_dynamic_sections (abfd, info)
    39334616     bfd *abfd;
     
    39954678        }
    39964679
    3997       /* Initialize the PLT0 entry */
     4680      /* Initialize the PLT0 entry. */
    39984681      if (ia64_info->plt_sec)
    39994682        {
     
    40114694    }
    40124695
    4013   return true;
    4014 }
    4015 
    4016 
    4017 /* ELF file flag handling: */
     4696  return TRUE;
     4697}
     4698
     4699
     4700/* ELF file flag handling:  */
    40184701
    40194702/* Function to keep IA-64 specific file flags.  */
    4020 static boolean
     4703static bfd_boolean
    40214704elfNN_ia64_set_private_flags (abfd, flags)
    40224705     bfd *abfd;
     
    40274710
    40284711  elf_elfheader (abfd)->e_flags = flags;
    4029   elf_flags_init (abfd) = true;
    4030   return true;
    4031 }
    4032 
    4033 /* Copy backend specific data from one object module to another */
    4034 static boolean
    4035 elfNN_ia64_copy_private_bfd_data (ibfd, obfd)
    4036      bfd *ibfd, *obfd;
    4037 {
    4038   if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    4039       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    4040     return true;
    4041 
    4042   BFD_ASSERT (!elf_flags_init (obfd)
    4043               || (elf_elfheader (obfd)->e_flags
    4044                   == elf_elfheader (ibfd)->e_flags));
    4045 
    4046   elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
    4047   elf_flags_init (obfd) = true;
    4048   return true;
     4712  elf_flags_init (abfd) = TRUE;
     4713  return TRUE;
    40494714}
    40504715
    40514716/* Merge backend specific data from an object file to the output
    40524717   object file when linking.  */
    4053 static boolean
     4718static bfd_boolean
    40544719elfNN_ia64_merge_private_bfd_data (ibfd, obfd)
    40554720     bfd *ibfd, *obfd;
     
    40574722  flagword out_flags;
    40584723  flagword in_flags;
    4059   boolean ok = true;
     4724  bfd_boolean ok = TRUE;
    40604725
    40614726  /* Don't even pretend to support mixed-format linking.  */
    40624727  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    40634728      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    4064     return false;
     4729    return FALSE;
    40654730
    40664731  in_flags  = elf_elfheader (ibfd)->e_flags;
     
    40694734  if (! elf_flags_init (obfd))
    40704735    {
    4071       elf_flags_init (obfd) = true;
     4736      elf_flags_init (obfd) = TRUE;
    40724737      elf_elfheader (obfd)->e_flags = in_flags;
    40734738
     
    40794744        }
    40804745
    4081       return true;
     4746      return TRUE;
    40824747    }
    40834748
    40844749  /* Check flag compatibility.  */
    40854750  if (in_flags == out_flags)
    4086     return true;
     4751    return TRUE;
    40874752
    40884753  /* Output has EF_IA_64_REDUCEDFP set only if all inputs have it set.  */
     
    40944759      (*_bfd_error_handler)
    40954760        (_("%s: linking trap-on-NULL-dereference with non-trapping files"),
    4096          bfd_get_filename (ibfd));
     4761         bfd_archive_filename (ibfd));
    40974762
    40984763      bfd_set_error (bfd_error_bad_value);
    4099       ok = false;
     4764      ok = FALSE;
    41004765    }
    41014766  if ((in_flags & EF_IA_64_BE) != (out_flags & EF_IA_64_BE))
     
    41034768      (*_bfd_error_handler)
    41044769        (_("%s: linking big-endian files with little-endian files"),
    4105          bfd_get_filename (ibfd));
     4770         bfd_archive_filename (ibfd));
    41064771
    41074772      bfd_set_error (bfd_error_bad_value);
    4108       ok = false;
     4773      ok = FALSE;
    41094774    }
    41104775  if ((in_flags & EF_IA_64_ABI64) != (out_flags & EF_IA_64_ABI64))
     
    41124777      (*_bfd_error_handler)
    41134778        (_("%s: linking 64-bit files with 32-bit files"),
    4114          bfd_get_filename (ibfd));
     4779         bfd_archive_filename (ibfd));
    41154780
    41164781      bfd_set_error (bfd_error_bad_value);
    4117       ok = false;
     4782      ok = FALSE;
    41184783    }
    41194784  if ((in_flags & EF_IA_64_CONS_GP) != (out_flags & EF_IA_64_CONS_GP))
     
    41214786      (*_bfd_error_handler)
    41224787        (_("%s: linking constant-gp files with non-constant-gp files"),
    4123          bfd_get_filename (ibfd));
     4788         bfd_archive_filename (ibfd));
    41244789
    41254790      bfd_set_error (bfd_error_bad_value);
    4126       ok = false;
     4791      ok = FALSE;
    41274792    }
    41284793  if ((in_flags & EF_IA_64_NOFUNCDESC_CONS_GP)
     
    41314796      (*_bfd_error_handler)
    41324797        (_("%s: linking auto-pic files with non-auto-pic files"),
    4133          bfd_get_filename (ibfd));
     4798         bfd_archive_filename (ibfd));
    41344799
    41354800      bfd_set_error (bfd_error_bad_value);
    4136       ok = false;
     4801      ok = FALSE;
    41374802    }
    41384803
     
    41404805}
    41414806
    4142 static boolean
     4807static bfd_boolean
    41434808elfNN_ia64_print_private_bfd_data (abfd, ptr)
    41444809     bfd *abfd;
     
    41614826
    41624827  _bfd_elf_print_private_bfd_data (abfd, ptr);
    4163   return true;
     4828  return TRUE;
     4829}
     4830
     4831static enum elf_reloc_type_class
     4832elfNN_ia64_reloc_type_class (rela)
     4833     const Elf_Internal_Rela *rela;
     4834{
     4835  switch ((int) ELFNN_R_TYPE (rela->r_info))
     4836    {
     4837    case R_IA64_REL32MSB:
     4838    case R_IA64_REL32LSB:
     4839    case R_IA64_REL64MSB:
     4840    case R_IA64_REL64LSB:
     4841      return reloc_class_relative;
     4842    case R_IA64_IPLTMSB:
     4843    case R_IA64_IPLTLSB:
     4844      return reloc_class_plt;
     4845    case R_IA64_COPY:
     4846      return reloc_class_copy;
     4847    default:
     4848      return reloc_class_normal;
     4849    }
     4850}
     4851
     4852static bfd_boolean
     4853elfNN_ia64_hpux_vec (const bfd_target *vec)
     4854{
     4855  extern const bfd_target bfd_elfNN_ia64_hpux_big_vec;
     4856  return (vec == & bfd_elfNN_ia64_hpux_big_vec);
     4857}
     4858
     4859static void
     4860elfNN_hpux_post_process_headers (abfd, info)
     4861        bfd *abfd;
     4862        struct bfd_link_info *info ATTRIBUTE_UNUSED;
     4863{
     4864  Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
     4865
     4866  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_HPUX;
     4867  i_ehdrp->e_ident[EI_ABIVERSION] = 1;
     4868}
     4869
     4870bfd_boolean
     4871elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval)
     4872        bfd *abfd ATTRIBUTE_UNUSED;
     4873        asection *sec;
     4874        int *retval;
     4875{
     4876  if (bfd_is_com_section (sec))
     4877    {
     4878      *retval = SHN_IA_64_ANSI_COMMON;
     4879      return TRUE;
     4880    }
     4881  return FALSE;
    41644882}
    41654883
     
    42194937        elfNN_ia64_final_link
    42204938
    4221 #define bfd_elfNN_bfd_copy_private_bfd_data \
    4222         elfNN_ia64_copy_private_bfd_data
    42234939#define bfd_elfNN_bfd_merge_private_bfd_data \
    42244940        elfNN_ia64_merge_private_bfd_data
     
    42404956#define elf_backend_copy_indirect_symbol elfNN_ia64_hash_copy_indirect
    42414957#define elf_backend_hide_symbol         elfNN_ia64_hash_hide_symbol
     4958#define elf_backend_reloc_type_class    elfNN_ia64_reloc_type_class
     4959#define elf_backend_rela_normal         1
    42424960
    42434961#include "elfNN-target.h"
     4962
     4963/* AIX-specific vectors.  */
     4964
     4965#undef  TARGET_LITTLE_SYM
     4966#define TARGET_LITTLE_SYM               bfd_elfNN_ia64_aix_little_vec
     4967#undef  TARGET_LITTLE_NAME
     4968#define TARGET_LITTLE_NAME              "elfNN-ia64-aix-little"
     4969#undef  TARGET_BIG_SYM
     4970#define TARGET_BIG_SYM                  bfd_elfNN_ia64_aix_big_vec
     4971#undef  TARGET_BIG_NAME
     4972#define TARGET_BIG_NAME                 "elfNN-ia64-aix-big"
     4973
     4974#undef  elf_backend_add_symbol_hook
     4975#define elf_backend_add_symbol_hook     elfNN_ia64_aix_add_symbol_hook
     4976
     4977#undef  bfd_elfNN_bfd_link_add_symbols
     4978#define bfd_elfNN_bfd_link_add_symbols  elfNN_ia64_aix_link_add_symbols
     4979
     4980#define elfNN_bed elfNN_ia64_aix_bed
     4981
     4982#include "elfNN-target.h"
     4983
     4984/* HPUX-specific vectors.  */
     4985
     4986#undef  TARGET_LITTLE_SYM
     4987#undef  TARGET_LITTLE_NAME
     4988#undef  TARGET_BIG_SYM
     4989#define TARGET_BIG_SYM                  bfd_elfNN_ia64_hpux_big_vec
     4990#undef  TARGET_BIG_NAME
     4991#define TARGET_BIG_NAME                 "elfNN-ia64-hpux-big"
     4992
     4993/* We need to undo the AIX specific functions.  */
     4994
     4995#undef  elf_backend_add_symbol_hook
     4996#define elf_backend_add_symbol_hook     elfNN_ia64_add_symbol_hook
     4997
     4998#undef  bfd_elfNN_bfd_link_add_symbols
     4999#define bfd_elfNN_bfd_link_add_symbols  _bfd_generic_link_add_symbols
     5000
     5001/* These are HP-UX specific functions.  */
     5002
     5003#undef  elf_backend_post_process_headers
     5004#define elf_backend_post_process_headers elfNN_hpux_post_process_headers
     5005
     5006#undef  elf_backend_section_from_bfd_section
     5007#define elf_backend_section_from_bfd_section elfNN_hpux_backend_section_from_bfd_section
     5008
     5009#undef  elf_backend_want_p_paddr_set_to_zero
     5010#define elf_backend_want_p_paddr_set_to_zero 1
     5011
     5012#undef  ELF_MAXPAGESIZE
     5013#define ELF_MAXPAGESIZE                 0x1000  /* 1K */
     5014
     5015#undef  elfNN_bed
     5016#define elfNN_bed elfNN_ia64_hpux_bed
     5017
     5018#include "elfNN-target.h"
     5019
     5020#undef  elf_backend_want_p_paddr_set_to_zero
Note: See TracChangeset for help on using the changeset viewer.