Home | History | Annotate | Line # | Download | only in bfd
elf64-ia64-vms.c revision 1.1.1.2.4.2
      1  1.1.1.2.4.2  tls /* IA-64 support for OpenVMS
      2  1.1.1.2.4.2  tls    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
      3  1.1.1.2.4.2  tls    2008, 2009, 2010, 2012  Free Software Foundation, Inc.
      4  1.1.1.2.4.2  tls 
      5  1.1.1.2.4.2  tls    This file is part of BFD, the Binary File Descriptor library.
      6  1.1.1.2.4.2  tls 
      7  1.1.1.2.4.2  tls    This program is free software; you can redistribute it and/or modify
      8  1.1.1.2.4.2  tls    it under the terms of the GNU General Public License as published by
      9  1.1.1.2.4.2  tls    the Free Software Foundation; either version 3 of the License, or
     10  1.1.1.2.4.2  tls    (at your option) any later version.
     11  1.1.1.2.4.2  tls 
     12  1.1.1.2.4.2  tls    This program is distributed in the hope that it will be useful,
     13  1.1.1.2.4.2  tls    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  1.1.1.2.4.2  tls    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15  1.1.1.2.4.2  tls    GNU General Public License for more details.
     16  1.1.1.2.4.2  tls 
     17  1.1.1.2.4.2  tls    You should have received a copy of the GNU General Public License
     18  1.1.1.2.4.2  tls    along with this program; if not, write to the Free Software
     19  1.1.1.2.4.2  tls    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     20  1.1.1.2.4.2  tls    MA 02110-1301, USA.  */
     21  1.1.1.2.4.2  tls 
     22  1.1.1.2.4.2  tls #include "sysdep.h"
     23  1.1.1.2.4.2  tls #include "bfd.h"
     24  1.1.1.2.4.2  tls #include "libbfd.h"
     25  1.1.1.2.4.2  tls #include "elf-bfd.h"
     26  1.1.1.2.4.2  tls #include "opcode/ia64.h"
     27  1.1.1.2.4.2  tls #include "elf/ia64.h"
     28  1.1.1.2.4.2  tls #include "objalloc.h"
     29  1.1.1.2.4.2  tls #include "hashtab.h"
     30  1.1.1.2.4.2  tls #include "elfxx-ia64.h"
     31  1.1.1.2.4.2  tls #include "vms.h"
     32  1.1.1.2.4.2  tls #include "bfdver.h"
     33  1.1.1.2.4.2  tls 
     34  1.1.1.2.4.2  tls /* THE RULES for all the stuff the linker creates --
     35  1.1.1.2.4.2  tls 
     36  1.1.1.2.4.2  tls   GOT		Entries created in response to LTOFF or LTOFF_FPTR
     37  1.1.1.2.4.2  tls 		relocations.  Dynamic relocs created for dynamic
     38  1.1.1.2.4.2  tls 		symbols in an application; REL relocs for locals
     39  1.1.1.2.4.2  tls 		in a shared library.
     40  1.1.1.2.4.2  tls 
     41  1.1.1.2.4.2  tls   FPTR		The canonical function descriptor.  Created for local
     42  1.1.1.2.4.2  tls 		symbols in applications.  Descriptors for dynamic symbols
     43  1.1.1.2.4.2  tls 		and local symbols in shared libraries are created by
     44  1.1.1.2.4.2  tls 		ld.so.  Thus there are no dynamic relocs against these
     45  1.1.1.2.4.2  tls 		objects.  The FPTR relocs for such _are_ passed through
     46  1.1.1.2.4.2  tls 		to the dynamic relocation tables.
     47  1.1.1.2.4.2  tls 
     48  1.1.1.2.4.2  tls   FULL_PLT	Created for a PCREL21B relocation against a dynamic symbol.
     49  1.1.1.2.4.2  tls 		Requires the creation of a PLTOFF entry.  This does not
     50  1.1.1.2.4.2  tls 		require any dynamic relocations.
     51  1.1.1.2.4.2  tls 
     52  1.1.1.2.4.2  tls   PLTOFF	Created by PLTOFF relocations.  For local symbols, this
     53  1.1.1.2.4.2  tls 		is an alternate function descriptor, and in shared libraries
     54  1.1.1.2.4.2  tls 		requires two REL relocations.  Note that this cannot be
     55  1.1.1.2.4.2  tls 		transformed into an FPTR relocation, since it must be in
     56  1.1.1.2.4.2  tls 		range of the GP.  For dynamic symbols, this is a function
     57  1.1.1.2.4.2  tls 		descriptor.  */
     58  1.1.1.2.4.2  tls 
     59  1.1.1.2.4.2  tls typedef struct bfd_hash_entry *(*new_hash_entry_func)
     60  1.1.1.2.4.2  tls   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
     61  1.1.1.2.4.2  tls 
     62  1.1.1.2.4.2  tls /* In dynamically (linker-) created sections, we generally need to keep track
     63  1.1.1.2.4.2  tls    of the place a symbol or expression got allocated to. This is done via hash
     64  1.1.1.2.4.2  tls    tables that store entries of the following type.  */
     65  1.1.1.2.4.2  tls 
     66  1.1.1.2.4.2  tls struct elf64_ia64_dyn_sym_info
     67  1.1.1.2.4.2  tls {
     68  1.1.1.2.4.2  tls   /* The addend for which this entry is relevant.  */
     69  1.1.1.2.4.2  tls   bfd_vma addend;
     70  1.1.1.2.4.2  tls 
     71  1.1.1.2.4.2  tls   bfd_vma got_offset;
     72  1.1.1.2.4.2  tls   bfd_vma fptr_offset;
     73  1.1.1.2.4.2  tls   bfd_vma pltoff_offset;
     74  1.1.1.2.4.2  tls   bfd_vma plt_offset;
     75  1.1.1.2.4.2  tls   bfd_vma plt2_offset;
     76  1.1.1.2.4.2  tls 
     77  1.1.1.2.4.2  tls   /* The symbol table entry, if any, that this was derived from.  */
     78  1.1.1.2.4.2  tls   struct elf_link_hash_entry *h;
     79  1.1.1.2.4.2  tls 
     80  1.1.1.2.4.2  tls   /* Used to count non-got, non-plt relocations for delayed sizing
     81  1.1.1.2.4.2  tls      of relocation sections.  */
     82  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_reloc_entry
     83  1.1.1.2.4.2  tls   {
     84  1.1.1.2.4.2  tls     struct elf64_ia64_dyn_reloc_entry *next;
     85  1.1.1.2.4.2  tls     asection *srel;
     86  1.1.1.2.4.2  tls     int type;
     87  1.1.1.2.4.2  tls     int count;
     88  1.1.1.2.4.2  tls   } *reloc_entries;
     89  1.1.1.2.4.2  tls 
     90  1.1.1.2.4.2  tls   /* TRUE when the section contents have been updated.  */
     91  1.1.1.2.4.2  tls   unsigned got_done : 1;
     92  1.1.1.2.4.2  tls   unsigned fptr_done : 1;
     93  1.1.1.2.4.2  tls   unsigned pltoff_done : 1;
     94  1.1.1.2.4.2  tls 
     95  1.1.1.2.4.2  tls   /* TRUE for the different kinds of linker data we want created.  */
     96  1.1.1.2.4.2  tls   unsigned want_got : 1;
     97  1.1.1.2.4.2  tls   unsigned want_gotx : 1;
     98  1.1.1.2.4.2  tls   unsigned want_fptr : 1;
     99  1.1.1.2.4.2  tls   unsigned want_ltoff_fptr : 1;
    100  1.1.1.2.4.2  tls   unsigned want_plt : 1;	/* A MIN_PLT entry.  */
    101  1.1.1.2.4.2  tls   unsigned want_plt2 : 1;	/* A FULL_PLT.  */
    102  1.1.1.2.4.2  tls   unsigned want_pltoff : 1;
    103  1.1.1.2.4.2  tls };
    104  1.1.1.2.4.2  tls 
    105  1.1.1.2.4.2  tls struct elf64_ia64_local_hash_entry
    106  1.1.1.2.4.2  tls {
    107  1.1.1.2.4.2  tls   int id;
    108  1.1.1.2.4.2  tls   unsigned int r_sym;
    109  1.1.1.2.4.2  tls   /* The number of elements in elf64_ia64_dyn_sym_info array.  */
    110  1.1.1.2.4.2  tls   unsigned int count;
    111  1.1.1.2.4.2  tls   /* The number of sorted elements in elf64_ia64_dyn_sym_info array.  */
    112  1.1.1.2.4.2  tls   unsigned int sorted_count;
    113  1.1.1.2.4.2  tls   /* The size of elf64_ia64_dyn_sym_info array.  */
    114  1.1.1.2.4.2  tls   unsigned int size;
    115  1.1.1.2.4.2  tls   /* The array of elf64_ia64_dyn_sym_info.  */
    116  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_info *info;
    117  1.1.1.2.4.2  tls 
    118  1.1.1.2.4.2  tls   /* TRUE if this hash entry's addends was translated for
    119  1.1.1.2.4.2  tls      SHF_MERGE optimization.  */
    120  1.1.1.2.4.2  tls   unsigned sec_merge_done : 1;
    121  1.1.1.2.4.2  tls };
    122  1.1.1.2.4.2  tls 
    123  1.1.1.2.4.2  tls struct elf64_ia64_link_hash_entry
    124  1.1.1.2.4.2  tls {
    125  1.1.1.2.4.2  tls   struct elf_link_hash_entry root;
    126  1.1.1.2.4.2  tls 
    127  1.1.1.2.4.2  tls   /* Set if this symbol is defined in a shared library.
    128  1.1.1.2.4.2  tls      We can't use root.u.def.section->owner as the symbol is an absolute
    129  1.1.1.2.4.2  tls      symbol.  */
    130  1.1.1.2.4.2  tls   bfd *shl;
    131  1.1.1.2.4.2  tls 
    132  1.1.1.2.4.2  tls   /* The number of elements in elf64_ia64_dyn_sym_info array.  */
    133  1.1.1.2.4.2  tls   unsigned int count;
    134  1.1.1.2.4.2  tls   /* The number of sorted elements in elf64_ia64_dyn_sym_info array.  */
    135  1.1.1.2.4.2  tls   unsigned int sorted_count;
    136  1.1.1.2.4.2  tls   /* The size of elf64_ia64_dyn_sym_info array.  */
    137  1.1.1.2.4.2  tls   unsigned int size;
    138  1.1.1.2.4.2  tls   /* The array of elf64_ia64_dyn_sym_info.  */
    139  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_info *info;
    140  1.1.1.2.4.2  tls };
    141  1.1.1.2.4.2  tls 
    142  1.1.1.2.4.2  tls struct elf64_ia64_link_hash_table
    143  1.1.1.2.4.2  tls {
    144  1.1.1.2.4.2  tls   /* The main hash table.  */
    145  1.1.1.2.4.2  tls   struct elf_link_hash_table root;
    146  1.1.1.2.4.2  tls 
    147  1.1.1.2.4.2  tls   asection *fptr_sec;		/* Function descriptor table (or NULL).  */
    148  1.1.1.2.4.2  tls   asection *rel_fptr_sec;	/* Dynamic relocation section for same.  */
    149  1.1.1.2.4.2  tls   asection *pltoff_sec;		/* Private descriptors for plt (or NULL).  */
    150  1.1.1.2.4.2  tls   asection *fixups_sec;		/* Fixups section.  */
    151  1.1.1.2.4.2  tls   asection *transfer_sec;	/* Transfer vector section.  */
    152  1.1.1.2.4.2  tls   asection *note_sec;		/* .note section.  */
    153  1.1.1.2.4.2  tls 
    154  1.1.1.2.4.2  tls   /* There are maybe R_IA64_GPREL22 relocations, including those
    155  1.1.1.2.4.2  tls      optimized from R_IA64_LTOFF22X, against non-SHF_IA_64_SHORT
    156  1.1.1.2.4.2  tls      sections.  We need to record those sections so that we can choose
    157  1.1.1.2.4.2  tls      a proper GP to cover all R_IA64_GPREL22 relocations.  */
    158  1.1.1.2.4.2  tls   asection *max_short_sec;	/* Maximum short output section.  */
    159  1.1.1.2.4.2  tls   bfd_vma max_short_offset;	/* Maximum short offset.  */
    160  1.1.1.2.4.2  tls   asection *min_short_sec;	/* Minimum short output section.  */
    161  1.1.1.2.4.2  tls   bfd_vma min_short_offset;	/* Minimum short offset.  */
    162  1.1.1.2.4.2  tls 
    163  1.1.1.2.4.2  tls   htab_t loc_hash_table;
    164  1.1.1.2.4.2  tls   void *loc_hash_memory;
    165  1.1.1.2.4.2  tls };
    166  1.1.1.2.4.2  tls 
    167  1.1.1.2.4.2  tls struct elf64_ia64_allocate_data
    168  1.1.1.2.4.2  tls {
    169  1.1.1.2.4.2  tls   struct bfd_link_info *info;
    170  1.1.1.2.4.2  tls   bfd_size_type ofs;
    171  1.1.1.2.4.2  tls };
    172  1.1.1.2.4.2  tls 
    173  1.1.1.2.4.2  tls #define elf64_ia64_hash_table(p) \
    174  1.1.1.2.4.2  tls   (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
    175  1.1.1.2.4.2  tls   == IA64_ELF_DATA ? ((struct elf64_ia64_link_hash_table *) ((p)->hash)) : NULL)
    176  1.1.1.2.4.2  tls 
    177  1.1.1.2.4.2  tls struct elf64_ia64_vms_obj_tdata
    178  1.1.1.2.4.2  tls {
    179  1.1.1.2.4.2  tls   struct elf_obj_tdata root;
    180  1.1.1.2.4.2  tls 
    181  1.1.1.2.4.2  tls   /* Ident for shared library.  */
    182  1.1.1.2.4.2  tls   bfd_uint64_t ident;
    183  1.1.1.2.4.2  tls 
    184  1.1.1.2.4.2  tls   /* Used only during link: offset in the .fixups section for this bfd.  */
    185  1.1.1.2.4.2  tls   bfd_vma fixups_off;
    186  1.1.1.2.4.2  tls 
    187  1.1.1.2.4.2  tls   /* Max number of shared libraries.  */
    188  1.1.1.2.4.2  tls   unsigned int needed_count;
    189  1.1.1.2.4.2  tls };
    190  1.1.1.2.4.2  tls 
    191  1.1.1.2.4.2  tls #define elf_ia64_vms_tdata(abfd) \
    192  1.1.1.2.4.2  tls   ((struct elf64_ia64_vms_obj_tdata *)((abfd)->tdata.any))
    193  1.1.1.2.4.2  tls #define elf_ia64_vms_ident(abfd) (elf_ia64_vms_tdata(abfd)->ident)
    194  1.1.1.2.4.2  tls 
    195  1.1.1.2.4.2  tls struct elf64_vms_transfer
    196  1.1.1.2.4.2  tls {
    197  1.1.1.2.4.2  tls   unsigned char size[4];
    198  1.1.1.2.4.2  tls   unsigned char spare[4];
    199  1.1.1.2.4.2  tls   unsigned char tfradr1[8];
    200  1.1.1.2.4.2  tls   unsigned char tfradr2[8];
    201  1.1.1.2.4.2  tls   unsigned char tfradr3[8];
    202  1.1.1.2.4.2  tls   unsigned char tfradr4[8];
    203  1.1.1.2.4.2  tls   unsigned char tfradr5[8];
    204  1.1.1.2.4.2  tls 
    205  1.1.1.2.4.2  tls   /* Local function descriptor for tfr3.  */
    206  1.1.1.2.4.2  tls   unsigned char tfr3_func[8];
    207  1.1.1.2.4.2  tls   unsigned char tfr3_gp[8];
    208  1.1.1.2.4.2  tls };
    209  1.1.1.2.4.2  tls 
    210  1.1.1.2.4.2  tls typedef struct
    211  1.1.1.2.4.2  tls {
    212  1.1.1.2.4.2  tls   Elf64_External_Ehdr ehdr;
    213  1.1.1.2.4.2  tls   unsigned char vms_needed_count[8];
    214  1.1.1.2.4.2  tls } Elf64_External_VMS_Ehdr;
    215  1.1.1.2.4.2  tls 
    216  1.1.1.2.4.2  tls static struct elf64_ia64_dyn_sym_info * get_dyn_sym_info
    217  1.1.1.2.4.2  tls   (struct elf64_ia64_link_hash_table *,
    218  1.1.1.2.4.2  tls    struct elf_link_hash_entry *,
    219  1.1.1.2.4.2  tls    bfd *, const Elf_Internal_Rela *, bfd_boolean);
    220  1.1.1.2.4.2  tls static bfd_boolean elf64_ia64_dynamic_symbol_p
    221  1.1.1.2.4.2  tls   (struct elf_link_hash_entry *);
    222  1.1.1.2.4.2  tls static bfd_boolean elf64_ia64_choose_gp
    223  1.1.1.2.4.2  tls   (bfd *, struct bfd_link_info *, bfd_boolean);
    224  1.1.1.2.4.2  tls static void elf64_ia64_dyn_sym_traverse
    225  1.1.1.2.4.2  tls   (struct elf64_ia64_link_hash_table *,
    226  1.1.1.2.4.2  tls    bfd_boolean (*) (struct elf64_ia64_dyn_sym_info *, void *),
    227  1.1.1.2.4.2  tls    void *);
    228  1.1.1.2.4.2  tls static bfd_boolean allocate_global_data_got
    229  1.1.1.2.4.2  tls   (struct elf64_ia64_dyn_sym_info *, void *);
    230  1.1.1.2.4.2  tls static bfd_boolean allocate_global_fptr_got
    231  1.1.1.2.4.2  tls   (struct elf64_ia64_dyn_sym_info *, void *);
    232  1.1.1.2.4.2  tls static bfd_boolean allocate_local_got
    233  1.1.1.2.4.2  tls   (struct elf64_ia64_dyn_sym_info *, void *);
    234  1.1.1.2.4.2  tls static bfd_boolean allocate_dynrel_entries
    235  1.1.1.2.4.2  tls   (struct elf64_ia64_dyn_sym_info *, void *);
    236  1.1.1.2.4.2  tls static asection *get_pltoff
    237  1.1.1.2.4.2  tls   (bfd *, struct elf64_ia64_link_hash_table *);
    238  1.1.1.2.4.2  tls static asection *get_got
    239  1.1.1.2.4.2  tls   (bfd *, struct elf64_ia64_link_hash_table *);
    240  1.1.1.2.4.2  tls 
    241  1.1.1.2.4.2  tls 
    242  1.1.1.2.4.2  tls /* Given a ELF reloc, return the matching HOWTO structure.  */
    243  1.1.1.2.4.2  tls 
    244  1.1.1.2.4.2  tls static void
    245  1.1.1.2.4.2  tls elf64_ia64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
    246  1.1.1.2.4.2  tls 			  arelent *bfd_reloc,
    247  1.1.1.2.4.2  tls 			  Elf_Internal_Rela *elf_reloc)
    248  1.1.1.2.4.2  tls {
    249  1.1.1.2.4.2  tls   bfd_reloc->howto
    250  1.1.1.2.4.2  tls     = ia64_elf_lookup_howto ((unsigned int) ELF64_R_TYPE (elf_reloc->r_info));
    251  1.1.1.2.4.2  tls }
    252  1.1.1.2.4.2  tls 
    253  1.1.1.2.4.2  tls 
    254  1.1.1.2.4.2  tls #define PLT_FULL_ENTRY_SIZE	(2 * 16)
    255  1.1.1.2.4.2  tls 
    256  1.1.1.2.4.2  tls static const bfd_byte plt_full_entry[PLT_FULL_ENTRY_SIZE] =
    257  1.1.1.2.4.2  tls {
    258  1.1.1.2.4.2  tls   0x0b, 0x78, 0x00, 0x02, 0x00, 0x24,  /*   [MMI]       addl r15=0,r1;;   */
    259  1.1.1.2.4.2  tls   0x00, 0x41, 0x3c, 0x70, 0x29, 0xc0,  /*               ld8.acq r16=[r15],8*/
    260  1.1.1.2.4.2  tls   0x01, 0x08, 0x00, 0x84,              /*               mov r14=r1;;      */
    261  1.1.1.2.4.2  tls   0x11, 0x08, 0x00, 0x1e, 0x18, 0x10,  /*   [MIB]       ld8 r1=[r15]      */
    262  1.1.1.2.4.2  tls   0x60, 0x80, 0x04, 0x80, 0x03, 0x00,  /*               mov b6=r16        */
    263  1.1.1.2.4.2  tls   0x60, 0x00, 0x80, 0x00               /*               br.few b6;;       */
    264  1.1.1.2.4.2  tls };
    265  1.1.1.2.4.2  tls 
    266  1.1.1.2.4.2  tls static const bfd_byte oor_brl[16] =
    267  1.1.1.2.4.2  tls {
    268  1.1.1.2.4.2  tls   0x05, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MLX]        nop.m 0           */
    269  1.1.1.2.4.2  tls   0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /*               brl.sptk.few tgt;;*/
    270  1.1.1.2.4.2  tls   0x00, 0x00, 0x00, 0xc0
    271  1.1.1.2.4.2  tls };
    272  1.1.1.2.4.2  tls 
    273  1.1.1.2.4.2  tls 
    274  1.1.1.2.4.2  tls /* These functions do relaxation for IA-64 ELF.  */
    275  1.1.1.2.4.2  tls 
    276  1.1.1.2.4.2  tls /* Rename some of the generic section flags to better document how they
    277  1.1.1.2.4.2  tls    are used here.  */
    278  1.1.1.2.4.2  tls #define skip_relax_pass_0 sec_flg0
    279  1.1.1.2.4.2  tls #define skip_relax_pass_1 sec_flg1
    280  1.1.1.2.4.2  tls 
    281  1.1.1.2.4.2  tls static void
    282  1.1.1.2.4.2  tls elf64_ia64_update_short_info (asection *sec, bfd_vma offset,
    283  1.1.1.2.4.2  tls 			      struct elf64_ia64_link_hash_table *ia64_info)
    284  1.1.1.2.4.2  tls {
    285  1.1.1.2.4.2  tls   /* Skip ABS and SHF_IA_64_SHORT sections.  */
    286  1.1.1.2.4.2  tls   if (sec == bfd_abs_section_ptr
    287  1.1.1.2.4.2  tls       || (sec->flags & SEC_SMALL_DATA) != 0)
    288  1.1.1.2.4.2  tls     return;
    289  1.1.1.2.4.2  tls 
    290  1.1.1.2.4.2  tls   if (!ia64_info->min_short_sec)
    291  1.1.1.2.4.2  tls     {
    292  1.1.1.2.4.2  tls       ia64_info->max_short_sec = sec;
    293  1.1.1.2.4.2  tls       ia64_info->max_short_offset = offset;
    294  1.1.1.2.4.2  tls       ia64_info->min_short_sec = sec;
    295  1.1.1.2.4.2  tls       ia64_info->min_short_offset = offset;
    296  1.1.1.2.4.2  tls     }
    297  1.1.1.2.4.2  tls   else if (sec == ia64_info->max_short_sec
    298  1.1.1.2.4.2  tls 	   && offset > ia64_info->max_short_offset)
    299  1.1.1.2.4.2  tls     ia64_info->max_short_offset = offset;
    300  1.1.1.2.4.2  tls   else if (sec == ia64_info->min_short_sec
    301  1.1.1.2.4.2  tls 	   && offset < ia64_info->min_short_offset)
    302  1.1.1.2.4.2  tls     ia64_info->min_short_offset = offset;
    303  1.1.1.2.4.2  tls   else if (sec->output_section->vma
    304  1.1.1.2.4.2  tls 	   > ia64_info->max_short_sec->vma)
    305  1.1.1.2.4.2  tls     {
    306  1.1.1.2.4.2  tls       ia64_info->max_short_sec = sec;
    307  1.1.1.2.4.2  tls       ia64_info->max_short_offset = offset;
    308  1.1.1.2.4.2  tls     }
    309  1.1.1.2.4.2  tls   else if (sec->output_section->vma
    310  1.1.1.2.4.2  tls 	   < ia64_info->min_short_sec->vma)
    311  1.1.1.2.4.2  tls     {
    312  1.1.1.2.4.2  tls       ia64_info->min_short_sec = sec;
    313  1.1.1.2.4.2  tls       ia64_info->min_short_offset = offset;
    314  1.1.1.2.4.2  tls     }
    315  1.1.1.2.4.2  tls }
    316  1.1.1.2.4.2  tls 
    317  1.1.1.2.4.2  tls /* Use a two passes algorithm.  In the first pass, branches are relaxed
    318  1.1.1.2.4.2  tls    (which may increase the size of the section).  In the second pass,
    319  1.1.1.2.4.2  tls    the other relaxations are done.
    320  1.1.1.2.4.2  tls */
    321  1.1.1.2.4.2  tls 
    322  1.1.1.2.4.2  tls static bfd_boolean
    323  1.1.1.2.4.2  tls elf64_ia64_relax_section (bfd *abfd, asection *sec,
    324  1.1.1.2.4.2  tls 			  struct bfd_link_info *link_info,
    325  1.1.1.2.4.2  tls 			  bfd_boolean *again)
    326  1.1.1.2.4.2  tls {
    327  1.1.1.2.4.2  tls   struct one_fixup
    328  1.1.1.2.4.2  tls     {
    329  1.1.1.2.4.2  tls       struct one_fixup *next;
    330  1.1.1.2.4.2  tls       asection *tsec;
    331  1.1.1.2.4.2  tls       bfd_vma toff;
    332  1.1.1.2.4.2  tls       bfd_vma trampoff;
    333  1.1.1.2.4.2  tls     };
    334  1.1.1.2.4.2  tls 
    335  1.1.1.2.4.2  tls   Elf_Internal_Shdr *symtab_hdr;
    336  1.1.1.2.4.2  tls   Elf_Internal_Rela *internal_relocs;
    337  1.1.1.2.4.2  tls   Elf_Internal_Rela *irel, *irelend;
    338  1.1.1.2.4.2  tls   bfd_byte *contents;
    339  1.1.1.2.4.2  tls   Elf_Internal_Sym *isymbuf = NULL;
    340  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
    341  1.1.1.2.4.2  tls   struct one_fixup *fixups = NULL;
    342  1.1.1.2.4.2  tls   bfd_boolean changed_contents = FALSE;
    343  1.1.1.2.4.2  tls   bfd_boolean changed_relocs = FALSE;
    344  1.1.1.2.4.2  tls   bfd_boolean skip_relax_pass_0 = TRUE;
    345  1.1.1.2.4.2  tls   bfd_boolean skip_relax_pass_1 = TRUE;
    346  1.1.1.2.4.2  tls   bfd_vma gp = 0;
    347  1.1.1.2.4.2  tls 
    348  1.1.1.2.4.2  tls   /* Assume we're not going to change any sizes, and we'll only need
    349  1.1.1.2.4.2  tls      one pass.  */
    350  1.1.1.2.4.2  tls   *again = FALSE;
    351  1.1.1.2.4.2  tls 
    352  1.1.1.2.4.2  tls   if (link_info->relocatable)
    353  1.1.1.2.4.2  tls     (*link_info->callbacks->einfo)
    354  1.1.1.2.4.2  tls       (_("%P%F: --relax and -r may not be used together\n"));
    355  1.1.1.2.4.2  tls 
    356  1.1.1.2.4.2  tls   /* Don't even try to relax for non-ELF outputs.  */
    357  1.1.1.2.4.2  tls   if (!is_elf_hash_table (link_info->hash))
    358  1.1.1.2.4.2  tls     return FALSE;
    359  1.1.1.2.4.2  tls 
    360  1.1.1.2.4.2  tls   /* Nothing to do if there are no relocations or there is no need for
    361  1.1.1.2.4.2  tls      the current pass.  */
    362  1.1.1.2.4.2  tls   if ((sec->flags & SEC_RELOC) == 0
    363  1.1.1.2.4.2  tls       || sec->reloc_count == 0
    364  1.1.1.2.4.2  tls       || (link_info->relax_pass == 0 && sec->skip_relax_pass_0)
    365  1.1.1.2.4.2  tls       || (link_info->relax_pass == 1 && sec->skip_relax_pass_1))
    366  1.1.1.2.4.2  tls     return TRUE;
    367  1.1.1.2.4.2  tls 
    368  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (link_info);
    369  1.1.1.2.4.2  tls   if (ia64_info == NULL)
    370  1.1.1.2.4.2  tls     return FALSE;
    371  1.1.1.2.4.2  tls 
    372  1.1.1.2.4.2  tls   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
    373  1.1.1.2.4.2  tls 
    374  1.1.1.2.4.2  tls   /* Load the relocations for this section.  */
    375  1.1.1.2.4.2  tls   internal_relocs = (_bfd_elf_link_read_relocs
    376  1.1.1.2.4.2  tls 		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
    377  1.1.1.2.4.2  tls 		      link_info->keep_memory));
    378  1.1.1.2.4.2  tls   if (internal_relocs == NULL)
    379  1.1.1.2.4.2  tls     return FALSE;
    380  1.1.1.2.4.2  tls 
    381  1.1.1.2.4.2  tls   irelend = internal_relocs + sec->reloc_count;
    382  1.1.1.2.4.2  tls 
    383  1.1.1.2.4.2  tls   /* Get the section contents.  */
    384  1.1.1.2.4.2  tls   if (elf_section_data (sec)->this_hdr.contents != NULL)
    385  1.1.1.2.4.2  tls     contents = elf_section_data (sec)->this_hdr.contents;
    386  1.1.1.2.4.2  tls   else
    387  1.1.1.2.4.2  tls     {
    388  1.1.1.2.4.2  tls       if (!bfd_malloc_and_get_section (abfd, sec, &contents))
    389  1.1.1.2.4.2  tls 	goto error_return;
    390  1.1.1.2.4.2  tls     }
    391  1.1.1.2.4.2  tls 
    392  1.1.1.2.4.2  tls   for (irel = internal_relocs; irel < irelend; irel++)
    393  1.1.1.2.4.2  tls     {
    394  1.1.1.2.4.2  tls       unsigned long r_type = ELF64_R_TYPE (irel->r_info);
    395  1.1.1.2.4.2  tls       bfd_vma symaddr, reladdr, trampoff, toff, roff;
    396  1.1.1.2.4.2  tls       asection *tsec;
    397  1.1.1.2.4.2  tls       struct one_fixup *f;
    398  1.1.1.2.4.2  tls       bfd_size_type amt;
    399  1.1.1.2.4.2  tls       bfd_boolean is_branch;
    400  1.1.1.2.4.2  tls       struct elf64_ia64_dyn_sym_info *dyn_i;
    401  1.1.1.2.4.2  tls 
    402  1.1.1.2.4.2  tls       switch (r_type)
    403  1.1.1.2.4.2  tls 	{
    404  1.1.1.2.4.2  tls 	case R_IA64_PCREL21B:
    405  1.1.1.2.4.2  tls 	case R_IA64_PCREL21BI:
    406  1.1.1.2.4.2  tls 	case R_IA64_PCREL21M:
    407  1.1.1.2.4.2  tls 	case R_IA64_PCREL21F:
    408  1.1.1.2.4.2  tls 	  /* In pass 1, all br relaxations are done. We can skip it. */
    409  1.1.1.2.4.2  tls 	  if (link_info->relax_pass == 1)
    410  1.1.1.2.4.2  tls 	    continue;
    411  1.1.1.2.4.2  tls 	  skip_relax_pass_0 = FALSE;
    412  1.1.1.2.4.2  tls 	  is_branch = TRUE;
    413  1.1.1.2.4.2  tls 	  break;
    414  1.1.1.2.4.2  tls 
    415  1.1.1.2.4.2  tls 	case R_IA64_PCREL60B:
    416  1.1.1.2.4.2  tls 	  /* We can't optimize brl to br in pass 0 since br relaxations
    417  1.1.1.2.4.2  tls 	     will increase the code size. Defer it to pass 1.  */
    418  1.1.1.2.4.2  tls 	  if (link_info->relax_pass == 0)
    419  1.1.1.2.4.2  tls 	    {
    420  1.1.1.2.4.2  tls 	      skip_relax_pass_1 = FALSE;
    421  1.1.1.2.4.2  tls 	      continue;
    422  1.1.1.2.4.2  tls 	    }
    423  1.1.1.2.4.2  tls 	  is_branch = TRUE;
    424  1.1.1.2.4.2  tls 	  break;
    425  1.1.1.2.4.2  tls 
    426  1.1.1.2.4.2  tls 	case R_IA64_GPREL22:
    427  1.1.1.2.4.2  tls 	  /* Update max_short_sec/min_short_sec.  */
    428  1.1.1.2.4.2  tls 
    429  1.1.1.2.4.2  tls 	case R_IA64_LTOFF22X:
    430  1.1.1.2.4.2  tls 	case R_IA64_LDXMOV:
    431  1.1.1.2.4.2  tls 	  /* We can't relax ldx/mov in pass 0 since br relaxations will
    432  1.1.1.2.4.2  tls 	     increase the code size. Defer it to pass 1.  */
    433  1.1.1.2.4.2  tls 	  if (link_info->relax_pass == 0)
    434  1.1.1.2.4.2  tls 	    {
    435  1.1.1.2.4.2  tls 	      skip_relax_pass_1 = FALSE;
    436  1.1.1.2.4.2  tls 	      continue;
    437  1.1.1.2.4.2  tls 	    }
    438  1.1.1.2.4.2  tls 	  is_branch = FALSE;
    439  1.1.1.2.4.2  tls 	  break;
    440  1.1.1.2.4.2  tls 
    441  1.1.1.2.4.2  tls 	default:
    442  1.1.1.2.4.2  tls 	  continue;
    443  1.1.1.2.4.2  tls 	}
    444  1.1.1.2.4.2  tls 
    445  1.1.1.2.4.2  tls       /* Get the value of the symbol referred to by the reloc.  */
    446  1.1.1.2.4.2  tls       if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
    447  1.1.1.2.4.2  tls 	{
    448  1.1.1.2.4.2  tls 	  /* A local symbol.  */
    449  1.1.1.2.4.2  tls 	  Elf_Internal_Sym *isym;
    450  1.1.1.2.4.2  tls 
    451  1.1.1.2.4.2  tls 	  /* Read this BFD's local symbols.  */
    452  1.1.1.2.4.2  tls 	  if (isymbuf == NULL)
    453  1.1.1.2.4.2  tls 	    {
    454  1.1.1.2.4.2  tls 	      isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
    455  1.1.1.2.4.2  tls 	      if (isymbuf == NULL)
    456  1.1.1.2.4.2  tls 		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
    457  1.1.1.2.4.2  tls 						symtab_hdr->sh_info, 0,
    458  1.1.1.2.4.2  tls 						NULL, NULL, NULL);
    459  1.1.1.2.4.2  tls 	      if (isymbuf == 0)
    460  1.1.1.2.4.2  tls 		goto error_return;
    461  1.1.1.2.4.2  tls 	    }
    462  1.1.1.2.4.2  tls 
    463  1.1.1.2.4.2  tls 	  isym = isymbuf + ELF64_R_SYM (irel->r_info);
    464  1.1.1.2.4.2  tls 	  if (isym->st_shndx == SHN_UNDEF)
    465  1.1.1.2.4.2  tls 	    continue;	/* We can't do anything with undefined symbols.  */
    466  1.1.1.2.4.2  tls 	  else if (isym->st_shndx == SHN_ABS)
    467  1.1.1.2.4.2  tls 	    tsec = bfd_abs_section_ptr;
    468  1.1.1.2.4.2  tls 	  else if (isym->st_shndx == SHN_COMMON)
    469  1.1.1.2.4.2  tls 	    tsec = bfd_com_section_ptr;
    470  1.1.1.2.4.2  tls 	  else if (isym->st_shndx == SHN_IA_64_ANSI_COMMON)
    471  1.1.1.2.4.2  tls 	    tsec = bfd_com_section_ptr;
    472  1.1.1.2.4.2  tls 	  else
    473  1.1.1.2.4.2  tls 	    tsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
    474  1.1.1.2.4.2  tls 
    475  1.1.1.2.4.2  tls 	  toff = isym->st_value;
    476  1.1.1.2.4.2  tls 	  dyn_i = get_dyn_sym_info (ia64_info, NULL, abfd, irel, FALSE);
    477  1.1.1.2.4.2  tls 	}
    478  1.1.1.2.4.2  tls       else
    479  1.1.1.2.4.2  tls 	{
    480  1.1.1.2.4.2  tls 	  unsigned long indx;
    481  1.1.1.2.4.2  tls 	  struct elf_link_hash_entry *h;
    482  1.1.1.2.4.2  tls 
    483  1.1.1.2.4.2  tls 	  indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
    484  1.1.1.2.4.2  tls 	  h = elf_sym_hashes (abfd)[indx];
    485  1.1.1.2.4.2  tls 	  BFD_ASSERT (h != NULL);
    486  1.1.1.2.4.2  tls 
    487  1.1.1.2.4.2  tls 	  while (h->root.type == bfd_link_hash_indirect
    488  1.1.1.2.4.2  tls 		 || h->root.type == bfd_link_hash_warning)
    489  1.1.1.2.4.2  tls 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
    490  1.1.1.2.4.2  tls 
    491  1.1.1.2.4.2  tls 	  dyn_i = get_dyn_sym_info (ia64_info, h, abfd, irel, FALSE);
    492  1.1.1.2.4.2  tls 
    493  1.1.1.2.4.2  tls 	  /* For branches to dynamic symbols, we're interested instead
    494  1.1.1.2.4.2  tls 	     in a branch to the PLT entry.  */
    495  1.1.1.2.4.2  tls 	  if (is_branch && dyn_i && dyn_i->want_plt2)
    496  1.1.1.2.4.2  tls 	    {
    497  1.1.1.2.4.2  tls 	      /* Internal branches shouldn't be sent to the PLT.
    498  1.1.1.2.4.2  tls 		 Leave this for now and we'll give an error later.  */
    499  1.1.1.2.4.2  tls 	      if (r_type != R_IA64_PCREL21B)
    500  1.1.1.2.4.2  tls 		continue;
    501  1.1.1.2.4.2  tls 
    502  1.1.1.2.4.2  tls 	      tsec = ia64_info->root.splt;
    503  1.1.1.2.4.2  tls 	      toff = dyn_i->plt2_offset;
    504  1.1.1.2.4.2  tls 	      BFD_ASSERT (irel->r_addend == 0);
    505  1.1.1.2.4.2  tls 	    }
    506  1.1.1.2.4.2  tls 
    507  1.1.1.2.4.2  tls 	  /* Can't do anything else with dynamic symbols.  */
    508  1.1.1.2.4.2  tls 	  else if (elf64_ia64_dynamic_symbol_p (h))
    509  1.1.1.2.4.2  tls 	    continue;
    510  1.1.1.2.4.2  tls 
    511  1.1.1.2.4.2  tls 	  else
    512  1.1.1.2.4.2  tls 	    {
    513  1.1.1.2.4.2  tls 	      /* We can't do anything with undefined symbols.  */
    514  1.1.1.2.4.2  tls 	      if (h->root.type == bfd_link_hash_undefined
    515  1.1.1.2.4.2  tls 		  || h->root.type == bfd_link_hash_undefweak)
    516  1.1.1.2.4.2  tls 		continue;
    517  1.1.1.2.4.2  tls 
    518  1.1.1.2.4.2  tls 	      tsec = h->root.u.def.section;
    519  1.1.1.2.4.2  tls 	      toff = h->root.u.def.value;
    520  1.1.1.2.4.2  tls 	    }
    521  1.1.1.2.4.2  tls 	}
    522  1.1.1.2.4.2  tls 
    523  1.1.1.2.4.2  tls       toff += irel->r_addend;
    524  1.1.1.2.4.2  tls 
    525  1.1.1.2.4.2  tls       symaddr = tsec->output_section->vma + tsec->output_offset + toff;
    526  1.1.1.2.4.2  tls 
    527  1.1.1.2.4.2  tls       roff = irel->r_offset;
    528  1.1.1.2.4.2  tls 
    529  1.1.1.2.4.2  tls       if (is_branch)
    530  1.1.1.2.4.2  tls 	{
    531  1.1.1.2.4.2  tls 	  bfd_signed_vma offset;
    532  1.1.1.2.4.2  tls 
    533  1.1.1.2.4.2  tls 	  reladdr = (sec->output_section->vma
    534  1.1.1.2.4.2  tls 		     + sec->output_offset
    535  1.1.1.2.4.2  tls 		     + roff) & (bfd_vma) -4;
    536  1.1.1.2.4.2  tls 
    537  1.1.1.2.4.2  tls 	  /* The .plt section is aligned at 32byte and the .text section
    538  1.1.1.2.4.2  tls 	     is aligned at 64byte. The .text section is right after the
    539  1.1.1.2.4.2  tls 	     .plt section.  After the first relaxation pass, linker may
    540  1.1.1.2.4.2  tls 	     increase the gap between the .plt and .text sections up
    541  1.1.1.2.4.2  tls 	     to 32byte.  We assume linker will always insert 32byte
    542  1.1.1.2.4.2  tls 	     between the .plt and .text sections after the first
    543  1.1.1.2.4.2  tls 	     relaxation pass.  */
    544  1.1.1.2.4.2  tls 	  if (tsec == ia64_info->root.splt)
    545  1.1.1.2.4.2  tls 	    offset = -0x1000000 + 32;
    546  1.1.1.2.4.2  tls 	  else
    547  1.1.1.2.4.2  tls 	    offset = -0x1000000;
    548  1.1.1.2.4.2  tls 
    549  1.1.1.2.4.2  tls 	  /* If the branch is in range, no need to do anything.  */
    550  1.1.1.2.4.2  tls 	  if ((bfd_signed_vma) (symaddr - reladdr) >= offset
    551  1.1.1.2.4.2  tls 	      && (bfd_signed_vma) (symaddr - reladdr) <= 0x0FFFFF0)
    552  1.1.1.2.4.2  tls 	    {
    553  1.1.1.2.4.2  tls 	      /* If the 60-bit branch is in 21-bit range, optimize it. */
    554  1.1.1.2.4.2  tls 	      if (r_type == R_IA64_PCREL60B)
    555  1.1.1.2.4.2  tls 		{
    556  1.1.1.2.4.2  tls 		  ia64_elf_relax_brl (contents, roff);
    557  1.1.1.2.4.2  tls 
    558  1.1.1.2.4.2  tls 		  irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
    559  1.1.1.2.4.2  tls                                                R_IA64_PCREL21B);
    560  1.1.1.2.4.2  tls 
    561  1.1.1.2.4.2  tls 		  /* If the original relocation offset points to slot
    562  1.1.1.2.4.2  tls 		     1, change it to slot 2.  */
    563  1.1.1.2.4.2  tls 		  if ((irel->r_offset & 3) == 1)
    564  1.1.1.2.4.2  tls 		    irel->r_offset += 1;
    565  1.1.1.2.4.2  tls 		}
    566  1.1.1.2.4.2  tls 
    567  1.1.1.2.4.2  tls 	      continue;
    568  1.1.1.2.4.2  tls 	    }
    569  1.1.1.2.4.2  tls 	  else if (r_type == R_IA64_PCREL60B)
    570  1.1.1.2.4.2  tls 	    continue;
    571  1.1.1.2.4.2  tls 	  else if (ia64_elf_relax_br (contents, roff))
    572  1.1.1.2.4.2  tls 	    {
    573  1.1.1.2.4.2  tls 	      irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
    574  1.1.1.2.4.2  tls                                            R_IA64_PCREL60B);
    575  1.1.1.2.4.2  tls 
    576  1.1.1.2.4.2  tls 	      /* Make the relocation offset point to slot 1.  */
    577  1.1.1.2.4.2  tls 	      irel->r_offset = (irel->r_offset & ~((bfd_vma) 0x3)) + 1;
    578  1.1.1.2.4.2  tls 	      continue;
    579  1.1.1.2.4.2  tls 	    }
    580  1.1.1.2.4.2  tls 
    581  1.1.1.2.4.2  tls 	  /* We can't put a trampoline in a .init/.fini section. Issue
    582  1.1.1.2.4.2  tls 	     an error.  */
    583  1.1.1.2.4.2  tls 	  if (strcmp (sec->output_section->name, ".init") == 0
    584  1.1.1.2.4.2  tls 	      || strcmp (sec->output_section->name, ".fini") == 0)
    585  1.1.1.2.4.2  tls 	    {
    586  1.1.1.2.4.2  tls 	      (*_bfd_error_handler)
    587  1.1.1.2.4.2  tls 		(_("%B: Can't relax br at 0x%lx in section `%A'. Please use brl or indirect branch."),
    588  1.1.1.2.4.2  tls 		 sec->owner, sec, (unsigned long) roff);
    589  1.1.1.2.4.2  tls 	      bfd_set_error (bfd_error_bad_value);
    590  1.1.1.2.4.2  tls 	      goto error_return;
    591  1.1.1.2.4.2  tls 	    }
    592  1.1.1.2.4.2  tls 
    593  1.1.1.2.4.2  tls 	  /* If the branch and target are in the same section, you've
    594  1.1.1.2.4.2  tls 	     got one honking big section and we can't help you unless
    595  1.1.1.2.4.2  tls 	     you are branching backwards.  You'll get an error message
    596  1.1.1.2.4.2  tls 	     later.  */
    597  1.1.1.2.4.2  tls 	  if (tsec == sec && toff > roff)
    598  1.1.1.2.4.2  tls 	    continue;
    599  1.1.1.2.4.2  tls 
    600  1.1.1.2.4.2  tls 	  /* Look for an existing fixup to this address.  */
    601  1.1.1.2.4.2  tls 	  for (f = fixups; f ; f = f->next)
    602  1.1.1.2.4.2  tls 	    if (f->tsec == tsec && f->toff == toff)
    603  1.1.1.2.4.2  tls 	      break;
    604  1.1.1.2.4.2  tls 
    605  1.1.1.2.4.2  tls 	  if (f == NULL)
    606  1.1.1.2.4.2  tls 	    {
    607  1.1.1.2.4.2  tls 	      /* Two alternatives: If it's a branch to a PLT entry, we can
    608  1.1.1.2.4.2  tls 		 make a copy of the FULL_PLT entry.  Otherwise, we'll have
    609  1.1.1.2.4.2  tls 		 to use a `brl' insn to get where we're going.  */
    610  1.1.1.2.4.2  tls 
    611  1.1.1.2.4.2  tls 	      size_t size;
    612  1.1.1.2.4.2  tls 
    613  1.1.1.2.4.2  tls 	      if (tsec == ia64_info->root.splt)
    614  1.1.1.2.4.2  tls 		size = sizeof (plt_full_entry);
    615  1.1.1.2.4.2  tls 	      else
    616  1.1.1.2.4.2  tls 		size = sizeof (oor_brl);
    617  1.1.1.2.4.2  tls 
    618  1.1.1.2.4.2  tls 	      /* Resize the current section to make room for the new branch. */
    619  1.1.1.2.4.2  tls 	      trampoff = (sec->size + 15) & (bfd_vma) -16;
    620  1.1.1.2.4.2  tls 
    621  1.1.1.2.4.2  tls 	      /* If trampoline is out of range, there is nothing we
    622  1.1.1.2.4.2  tls 		 can do.  */
    623  1.1.1.2.4.2  tls 	      offset = trampoff - (roff & (bfd_vma) -4);
    624  1.1.1.2.4.2  tls 	      if (offset < -0x1000000 || offset > 0x0FFFFF0)
    625  1.1.1.2.4.2  tls 		continue;
    626  1.1.1.2.4.2  tls 
    627  1.1.1.2.4.2  tls 	      amt = trampoff + size;
    628  1.1.1.2.4.2  tls 	      contents = (bfd_byte *) bfd_realloc (contents, amt);
    629  1.1.1.2.4.2  tls 	      if (contents == NULL)
    630  1.1.1.2.4.2  tls 		goto error_return;
    631  1.1.1.2.4.2  tls 	      sec->size = amt;
    632  1.1.1.2.4.2  tls 
    633  1.1.1.2.4.2  tls 	      if (tsec == ia64_info->root.splt)
    634  1.1.1.2.4.2  tls 		{
    635  1.1.1.2.4.2  tls 		  memcpy (contents + trampoff, plt_full_entry, size);
    636  1.1.1.2.4.2  tls 
    637  1.1.1.2.4.2  tls 		  /* Hijack the old relocation for use as the PLTOFF reloc.  */
    638  1.1.1.2.4.2  tls 		  irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
    639  1.1.1.2.4.2  tls 					       R_IA64_PLTOFF22);
    640  1.1.1.2.4.2  tls 		  irel->r_offset = trampoff;
    641  1.1.1.2.4.2  tls 		}
    642  1.1.1.2.4.2  tls 	      else
    643  1.1.1.2.4.2  tls 		{
    644  1.1.1.2.4.2  tls                   memcpy (contents + trampoff, oor_brl, size);
    645  1.1.1.2.4.2  tls                   irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
    646  1.1.1.2.4.2  tls                                                R_IA64_PCREL60B);
    647  1.1.1.2.4.2  tls                   irel->r_offset = trampoff + 2;
    648  1.1.1.2.4.2  tls 		}
    649  1.1.1.2.4.2  tls 
    650  1.1.1.2.4.2  tls 	      /* Record the fixup so we don't do it again this section.  */
    651  1.1.1.2.4.2  tls 	      f = (struct one_fixup *)
    652  1.1.1.2.4.2  tls 		bfd_malloc ((bfd_size_type) sizeof (*f));
    653  1.1.1.2.4.2  tls 	      f->next = fixups;
    654  1.1.1.2.4.2  tls 	      f->tsec = tsec;
    655  1.1.1.2.4.2  tls 	      f->toff = toff;
    656  1.1.1.2.4.2  tls 	      f->trampoff = trampoff;
    657  1.1.1.2.4.2  tls 	      fixups = f;
    658  1.1.1.2.4.2  tls 	    }
    659  1.1.1.2.4.2  tls 	  else
    660  1.1.1.2.4.2  tls 	    {
    661  1.1.1.2.4.2  tls 	      /* If trampoline is out of range, there is nothing we
    662  1.1.1.2.4.2  tls 		 can do.  */
    663  1.1.1.2.4.2  tls 	      offset = f->trampoff - (roff & (bfd_vma) -4);
    664  1.1.1.2.4.2  tls 	      if (offset < -0x1000000 || offset > 0x0FFFFF0)
    665  1.1.1.2.4.2  tls 		continue;
    666  1.1.1.2.4.2  tls 
    667  1.1.1.2.4.2  tls 	      /* Nop out the reloc, since we're finalizing things here.  */
    668  1.1.1.2.4.2  tls 	      irel->r_info = ELF64_R_INFO (0, R_IA64_NONE);
    669  1.1.1.2.4.2  tls 	    }
    670  1.1.1.2.4.2  tls 
    671  1.1.1.2.4.2  tls 	  /* Fix up the existing branch to hit the trampoline.  */
    672  1.1.1.2.4.2  tls 	  if (ia64_elf_install_value (contents + roff, offset, r_type)
    673  1.1.1.2.4.2  tls 	      != bfd_reloc_ok)
    674  1.1.1.2.4.2  tls 	    goto error_return;
    675  1.1.1.2.4.2  tls 
    676  1.1.1.2.4.2  tls 	  changed_contents = TRUE;
    677  1.1.1.2.4.2  tls 	  changed_relocs = TRUE;
    678  1.1.1.2.4.2  tls 	}
    679  1.1.1.2.4.2  tls       else
    680  1.1.1.2.4.2  tls 	{
    681  1.1.1.2.4.2  tls 	  /* Fetch the gp.  */
    682  1.1.1.2.4.2  tls 	  if (gp == 0)
    683  1.1.1.2.4.2  tls 	    {
    684  1.1.1.2.4.2  tls 	      bfd *obfd = sec->output_section->owner;
    685  1.1.1.2.4.2  tls 	      gp = _bfd_get_gp_value (obfd);
    686  1.1.1.2.4.2  tls 	      if (gp == 0)
    687  1.1.1.2.4.2  tls 		{
    688  1.1.1.2.4.2  tls 		  if (!elf64_ia64_choose_gp (obfd, link_info, FALSE))
    689  1.1.1.2.4.2  tls 		    goto error_return;
    690  1.1.1.2.4.2  tls 		  gp = _bfd_get_gp_value (obfd);
    691  1.1.1.2.4.2  tls 		}
    692  1.1.1.2.4.2  tls 	    }
    693  1.1.1.2.4.2  tls 
    694  1.1.1.2.4.2  tls 	  /* If the data is out of range, do nothing.  */
    695  1.1.1.2.4.2  tls 	  if ((bfd_signed_vma) (symaddr - gp) >= 0x200000
    696  1.1.1.2.4.2  tls 	      ||(bfd_signed_vma) (symaddr - gp) < -0x200000)
    697  1.1.1.2.4.2  tls 	    continue;
    698  1.1.1.2.4.2  tls 
    699  1.1.1.2.4.2  tls 	  if (r_type == R_IA64_GPREL22)
    700  1.1.1.2.4.2  tls 	    elf64_ia64_update_short_info (tsec->output_section,
    701  1.1.1.2.4.2  tls 					  tsec->output_offset + toff,
    702  1.1.1.2.4.2  tls 					  ia64_info);
    703  1.1.1.2.4.2  tls 	  else if (r_type == R_IA64_LTOFF22X)
    704  1.1.1.2.4.2  tls 	    {
    705  1.1.1.2.4.2  tls               /* Can't deal yet correctly with ABS symbols.  */
    706  1.1.1.2.4.2  tls               if (bfd_is_abs_section (tsec))
    707  1.1.1.2.4.2  tls                 continue;
    708  1.1.1.2.4.2  tls 
    709  1.1.1.2.4.2  tls 	      irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
    710  1.1.1.2.4.2  tls 					   R_IA64_GPREL22);
    711  1.1.1.2.4.2  tls 	      changed_relocs = TRUE;
    712  1.1.1.2.4.2  tls 
    713  1.1.1.2.4.2  tls 	      elf64_ia64_update_short_info (tsec->output_section,
    714  1.1.1.2.4.2  tls 					    tsec->output_offset + toff,
    715  1.1.1.2.4.2  tls 					    ia64_info);
    716  1.1.1.2.4.2  tls 	    }
    717  1.1.1.2.4.2  tls 	  else
    718  1.1.1.2.4.2  tls 	    {
    719  1.1.1.2.4.2  tls 	      ia64_elf_relax_ldxmov (contents, roff);
    720  1.1.1.2.4.2  tls 	      irel->r_info = ELF64_R_INFO (0, R_IA64_NONE);
    721  1.1.1.2.4.2  tls 	      changed_contents = TRUE;
    722  1.1.1.2.4.2  tls 	      changed_relocs = TRUE;
    723  1.1.1.2.4.2  tls 	    }
    724  1.1.1.2.4.2  tls 	}
    725  1.1.1.2.4.2  tls     }
    726  1.1.1.2.4.2  tls 
    727  1.1.1.2.4.2  tls   /* ??? If we created fixups, this may push the code segment large
    728  1.1.1.2.4.2  tls      enough that the data segment moves, which will change the GP.
    729  1.1.1.2.4.2  tls      Reset the GP so that we re-calculate next round.  We need to
    730  1.1.1.2.4.2  tls      do this at the _beginning_ of the next round; now will not do.  */
    731  1.1.1.2.4.2  tls 
    732  1.1.1.2.4.2  tls   /* Clean up and go home.  */
    733  1.1.1.2.4.2  tls   while (fixups)
    734  1.1.1.2.4.2  tls     {
    735  1.1.1.2.4.2  tls       struct one_fixup *f = fixups;
    736  1.1.1.2.4.2  tls       fixups = fixups->next;
    737  1.1.1.2.4.2  tls       free (f);
    738  1.1.1.2.4.2  tls     }
    739  1.1.1.2.4.2  tls 
    740  1.1.1.2.4.2  tls   if (isymbuf != NULL
    741  1.1.1.2.4.2  tls       && symtab_hdr->contents != (unsigned char *) isymbuf)
    742  1.1.1.2.4.2  tls     {
    743  1.1.1.2.4.2  tls       if (! link_info->keep_memory)
    744  1.1.1.2.4.2  tls 	free (isymbuf);
    745  1.1.1.2.4.2  tls       else
    746  1.1.1.2.4.2  tls 	{
    747  1.1.1.2.4.2  tls 	  /* Cache the symbols for elf_link_input_bfd.  */
    748  1.1.1.2.4.2  tls 	  symtab_hdr->contents = (unsigned char *) isymbuf;
    749  1.1.1.2.4.2  tls 	}
    750  1.1.1.2.4.2  tls     }
    751  1.1.1.2.4.2  tls 
    752  1.1.1.2.4.2  tls   if (contents != NULL
    753  1.1.1.2.4.2  tls       && elf_section_data (sec)->this_hdr.contents != contents)
    754  1.1.1.2.4.2  tls     {
    755  1.1.1.2.4.2  tls       if (!changed_contents && !link_info->keep_memory)
    756  1.1.1.2.4.2  tls 	free (contents);
    757  1.1.1.2.4.2  tls       else
    758  1.1.1.2.4.2  tls 	{
    759  1.1.1.2.4.2  tls 	  /* Cache the section contents for elf_link_input_bfd.  */
    760  1.1.1.2.4.2  tls 	  elf_section_data (sec)->this_hdr.contents = contents;
    761  1.1.1.2.4.2  tls 	}
    762  1.1.1.2.4.2  tls     }
    763  1.1.1.2.4.2  tls 
    764  1.1.1.2.4.2  tls   if (elf_section_data (sec)->relocs != internal_relocs)
    765  1.1.1.2.4.2  tls     {
    766  1.1.1.2.4.2  tls       if (!changed_relocs)
    767  1.1.1.2.4.2  tls 	free (internal_relocs);
    768  1.1.1.2.4.2  tls       else
    769  1.1.1.2.4.2  tls 	elf_section_data (sec)->relocs = internal_relocs;
    770  1.1.1.2.4.2  tls     }
    771  1.1.1.2.4.2  tls 
    772  1.1.1.2.4.2  tls   if (link_info->relax_pass == 0)
    773  1.1.1.2.4.2  tls     {
    774  1.1.1.2.4.2  tls       /* Pass 0 is only needed to relax br.  */
    775  1.1.1.2.4.2  tls       sec->skip_relax_pass_0 = skip_relax_pass_0;
    776  1.1.1.2.4.2  tls       sec->skip_relax_pass_1 = skip_relax_pass_1;
    777  1.1.1.2.4.2  tls     }
    778  1.1.1.2.4.2  tls 
    779  1.1.1.2.4.2  tls   *again = changed_contents || changed_relocs;
    780  1.1.1.2.4.2  tls   return TRUE;
    781  1.1.1.2.4.2  tls 
    782  1.1.1.2.4.2  tls  error_return:
    783  1.1.1.2.4.2  tls   if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
    784  1.1.1.2.4.2  tls     free (isymbuf);
    785  1.1.1.2.4.2  tls   if (contents != NULL
    786  1.1.1.2.4.2  tls       && elf_section_data (sec)->this_hdr.contents != contents)
    787  1.1.1.2.4.2  tls     free (contents);
    788  1.1.1.2.4.2  tls   if (internal_relocs != NULL
    789  1.1.1.2.4.2  tls       && elf_section_data (sec)->relocs != internal_relocs)
    790  1.1.1.2.4.2  tls     free (internal_relocs);
    791  1.1.1.2.4.2  tls   return FALSE;
    792  1.1.1.2.4.2  tls }
    793  1.1.1.2.4.2  tls #undef skip_relax_pass_0
    794  1.1.1.2.4.2  tls #undef skip_relax_pass_1
    795  1.1.1.2.4.2  tls 
    796  1.1.1.2.4.2  tls /* Return TRUE if NAME is an unwind table section name.  */
    797  1.1.1.2.4.2  tls 
    798  1.1.1.2.4.2  tls static inline bfd_boolean
    799  1.1.1.2.4.2  tls is_unwind_section_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
    800  1.1.1.2.4.2  tls {
    801  1.1.1.2.4.2  tls   return ((CONST_STRNEQ (name, ELF_STRING_ia64_unwind)
    802  1.1.1.2.4.2  tls 	   && ! CONST_STRNEQ (name, ELF_STRING_ia64_unwind_info))
    803  1.1.1.2.4.2  tls 	  || CONST_STRNEQ (name, ELF_STRING_ia64_unwind_once));
    804  1.1.1.2.4.2  tls }
    805  1.1.1.2.4.2  tls 
    806  1.1.1.2.4.2  tls 
    807  1.1.1.2.4.2  tls /* Convert IA-64 specific section flags to bfd internal section flags.  */
    808  1.1.1.2.4.2  tls 
    809  1.1.1.2.4.2  tls /* ??? There is no bfd internal flag equivalent to the SHF_IA_64_NORECOV
    810  1.1.1.2.4.2  tls    flag.  */
    811  1.1.1.2.4.2  tls 
    812  1.1.1.2.4.2  tls static bfd_boolean
    813  1.1.1.2.4.2  tls elf64_ia64_section_flags (flagword *flags,
    814  1.1.1.2.4.2  tls 			  const Elf_Internal_Shdr *hdr)
    815  1.1.1.2.4.2  tls {
    816  1.1.1.2.4.2  tls   if (hdr->sh_flags & SHF_IA_64_SHORT)
    817  1.1.1.2.4.2  tls     *flags |= SEC_SMALL_DATA;
    818  1.1.1.2.4.2  tls 
    819  1.1.1.2.4.2  tls   return TRUE;
    820  1.1.1.2.4.2  tls }
    821  1.1.1.2.4.2  tls 
    822  1.1.1.2.4.2  tls /* Set the correct type for an IA-64 ELF section.  We do this by the
    823  1.1.1.2.4.2  tls    section name, which is a hack, but ought to work.  */
    824  1.1.1.2.4.2  tls 
    825  1.1.1.2.4.2  tls static bfd_boolean
    826  1.1.1.2.4.2  tls elf64_ia64_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr,
    827  1.1.1.2.4.2  tls 			  asection *sec)
    828  1.1.1.2.4.2  tls {
    829  1.1.1.2.4.2  tls   const char *name;
    830  1.1.1.2.4.2  tls 
    831  1.1.1.2.4.2  tls   name = bfd_get_section_name (abfd, sec);
    832  1.1.1.2.4.2  tls 
    833  1.1.1.2.4.2  tls   if (is_unwind_section_name (abfd, name))
    834  1.1.1.2.4.2  tls     {
    835  1.1.1.2.4.2  tls       /* We don't have the sections numbered at this point, so sh_info
    836  1.1.1.2.4.2  tls 	 is set later, in elf64_ia64_final_write_processing.  */
    837  1.1.1.2.4.2  tls       hdr->sh_type = SHT_IA_64_UNWIND;
    838  1.1.1.2.4.2  tls       hdr->sh_flags |= SHF_LINK_ORDER;
    839  1.1.1.2.4.2  tls     }
    840  1.1.1.2.4.2  tls   else if (strcmp (name, ELF_STRING_ia64_archext) == 0)
    841  1.1.1.2.4.2  tls     hdr->sh_type = SHT_IA_64_EXT;
    842  1.1.1.2.4.2  tls 
    843  1.1.1.2.4.2  tls   if (sec->flags & SEC_SMALL_DATA)
    844  1.1.1.2.4.2  tls     hdr->sh_flags |= SHF_IA_64_SHORT;
    845  1.1.1.2.4.2  tls 
    846  1.1.1.2.4.2  tls   return TRUE;
    847  1.1.1.2.4.2  tls }
    848  1.1.1.2.4.2  tls 
    849  1.1.1.2.4.2  tls /* Hook called by the linker routine which adds symbols from an object
    850  1.1.1.2.4.2  tls    file.  We use it to put .comm items in .sbss, and not .bss.  */
    851  1.1.1.2.4.2  tls 
    852  1.1.1.2.4.2  tls static bfd_boolean
    853  1.1.1.2.4.2  tls elf64_ia64_add_symbol_hook (bfd *abfd,
    854  1.1.1.2.4.2  tls 			    struct bfd_link_info *info,
    855  1.1.1.2.4.2  tls 			    Elf_Internal_Sym *sym,
    856  1.1.1.2.4.2  tls 			    const char **namep ATTRIBUTE_UNUSED,
    857  1.1.1.2.4.2  tls 			    flagword *flagsp ATTRIBUTE_UNUSED,
    858  1.1.1.2.4.2  tls 			    asection **secp,
    859  1.1.1.2.4.2  tls 			    bfd_vma *valp)
    860  1.1.1.2.4.2  tls {
    861  1.1.1.2.4.2  tls   if (sym->st_shndx == SHN_COMMON
    862  1.1.1.2.4.2  tls       && !info->relocatable
    863  1.1.1.2.4.2  tls       && sym->st_size <= elf_gp_size (abfd))
    864  1.1.1.2.4.2  tls     {
    865  1.1.1.2.4.2  tls       /* Common symbols less than or equal to -G nn bytes are
    866  1.1.1.2.4.2  tls 	 automatically put into .sbss.  */
    867  1.1.1.2.4.2  tls 
    868  1.1.1.2.4.2  tls       asection *scomm = bfd_get_section_by_name (abfd, ".scommon");
    869  1.1.1.2.4.2  tls 
    870  1.1.1.2.4.2  tls       if (scomm == NULL)
    871  1.1.1.2.4.2  tls 	{
    872  1.1.1.2.4.2  tls 	  scomm = bfd_make_section_with_flags (abfd, ".scommon",
    873  1.1.1.2.4.2  tls 					       (SEC_ALLOC
    874  1.1.1.2.4.2  tls 						| SEC_IS_COMMON
    875  1.1.1.2.4.2  tls 						| SEC_LINKER_CREATED));
    876  1.1.1.2.4.2  tls 	  if (scomm == NULL)
    877  1.1.1.2.4.2  tls 	    return FALSE;
    878  1.1.1.2.4.2  tls 	}
    879  1.1.1.2.4.2  tls 
    880  1.1.1.2.4.2  tls       *secp = scomm;
    881  1.1.1.2.4.2  tls       *valp = sym->st_size;
    882  1.1.1.2.4.2  tls     }
    883  1.1.1.2.4.2  tls 
    884  1.1.1.2.4.2  tls   return TRUE;
    885  1.1.1.2.4.2  tls }
    886  1.1.1.2.4.2  tls 
    887  1.1.1.2.4.2  tls /* According to the Tahoe assembler spec, all labels starting with a
    888  1.1.1.2.4.2  tls    '.' are local.  */
    889  1.1.1.2.4.2  tls 
    890  1.1.1.2.4.2  tls static bfd_boolean
    891  1.1.1.2.4.2  tls elf64_ia64_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
    892  1.1.1.2.4.2  tls 				const char *name)
    893  1.1.1.2.4.2  tls {
    894  1.1.1.2.4.2  tls   return name[0] == '.';
    895  1.1.1.2.4.2  tls }
    896  1.1.1.2.4.2  tls 
    897  1.1.1.2.4.2  tls /* Should we do dynamic things to this symbol?  */
    898  1.1.1.2.4.2  tls 
    899  1.1.1.2.4.2  tls static bfd_boolean
    900  1.1.1.2.4.2  tls elf64_ia64_dynamic_symbol_p (struct elf_link_hash_entry *h)
    901  1.1.1.2.4.2  tls {
    902  1.1.1.2.4.2  tls   return h != NULL && h->def_dynamic;
    903  1.1.1.2.4.2  tls }
    904  1.1.1.2.4.2  tls 
    905  1.1.1.2.4.2  tls static struct bfd_hash_entry*
    906  1.1.1.2.4.2  tls elf64_ia64_new_elf_hash_entry (struct bfd_hash_entry *entry,
    907  1.1.1.2.4.2  tls 			       struct bfd_hash_table *table,
    908  1.1.1.2.4.2  tls 			       const char *string)
    909  1.1.1.2.4.2  tls {
    910  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_entry *ret;
    911  1.1.1.2.4.2  tls   ret = (struct elf64_ia64_link_hash_entry *) entry;
    912  1.1.1.2.4.2  tls 
    913  1.1.1.2.4.2  tls   /* Allocate the structure if it has not already been allocated by a
    914  1.1.1.2.4.2  tls      subclass.  */
    915  1.1.1.2.4.2  tls   if (!ret)
    916  1.1.1.2.4.2  tls     ret = bfd_hash_allocate (table, sizeof (*ret));
    917  1.1.1.2.4.2  tls 
    918  1.1.1.2.4.2  tls   if (!ret)
    919  1.1.1.2.4.2  tls     return 0;
    920  1.1.1.2.4.2  tls 
    921  1.1.1.2.4.2  tls   /* Call the allocation method of the superclass.  */
    922  1.1.1.2.4.2  tls   ret = ((struct elf64_ia64_link_hash_entry *)
    923  1.1.1.2.4.2  tls 	 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
    924  1.1.1.2.4.2  tls 				     table, string));
    925  1.1.1.2.4.2  tls 
    926  1.1.1.2.4.2  tls   ret->info = NULL;
    927  1.1.1.2.4.2  tls   ret->count = 0;
    928  1.1.1.2.4.2  tls   ret->sorted_count = 0;
    929  1.1.1.2.4.2  tls   ret->size = 0;
    930  1.1.1.2.4.2  tls   return (struct bfd_hash_entry *) ret;
    931  1.1.1.2.4.2  tls }
    932  1.1.1.2.4.2  tls 
    933  1.1.1.2.4.2  tls static void
    934  1.1.1.2.4.2  tls elf64_ia64_hash_hide_symbol (struct bfd_link_info *info,
    935  1.1.1.2.4.2  tls 			     struct elf_link_hash_entry *xh,
    936  1.1.1.2.4.2  tls 			     bfd_boolean force_local)
    937  1.1.1.2.4.2  tls {
    938  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_entry *h;
    939  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_info *dyn_i;
    940  1.1.1.2.4.2  tls   unsigned int count;
    941  1.1.1.2.4.2  tls 
    942  1.1.1.2.4.2  tls   h = (struct elf64_ia64_link_hash_entry *)xh;
    943  1.1.1.2.4.2  tls 
    944  1.1.1.2.4.2  tls   _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local);
    945  1.1.1.2.4.2  tls 
    946  1.1.1.2.4.2  tls   for (count = h->count, dyn_i = h->info;
    947  1.1.1.2.4.2  tls        count != 0;
    948  1.1.1.2.4.2  tls        count--, dyn_i++)
    949  1.1.1.2.4.2  tls     {
    950  1.1.1.2.4.2  tls       dyn_i->want_plt2 = 0;
    951  1.1.1.2.4.2  tls       dyn_i->want_plt = 0;
    952  1.1.1.2.4.2  tls     }
    953  1.1.1.2.4.2  tls }
    954  1.1.1.2.4.2  tls 
    955  1.1.1.2.4.2  tls /* Compute a hash of a local hash entry.  */
    956  1.1.1.2.4.2  tls 
    957  1.1.1.2.4.2  tls static hashval_t
    958  1.1.1.2.4.2  tls elf64_ia64_local_htab_hash (const void *ptr)
    959  1.1.1.2.4.2  tls {
    960  1.1.1.2.4.2  tls   struct elf64_ia64_local_hash_entry *entry
    961  1.1.1.2.4.2  tls     = (struct elf64_ia64_local_hash_entry *) ptr;
    962  1.1.1.2.4.2  tls 
    963  1.1.1.2.4.2  tls   return ELF_LOCAL_SYMBOL_HASH (entry->id, entry->r_sym);
    964  1.1.1.2.4.2  tls }
    965  1.1.1.2.4.2  tls 
    966  1.1.1.2.4.2  tls /* Compare local hash entries.  */
    967  1.1.1.2.4.2  tls 
    968  1.1.1.2.4.2  tls static int
    969  1.1.1.2.4.2  tls elf64_ia64_local_htab_eq (const void *ptr1, const void *ptr2)
    970  1.1.1.2.4.2  tls {
    971  1.1.1.2.4.2  tls   struct elf64_ia64_local_hash_entry *entry1
    972  1.1.1.2.4.2  tls     = (struct elf64_ia64_local_hash_entry *) ptr1;
    973  1.1.1.2.4.2  tls   struct elf64_ia64_local_hash_entry *entry2
    974  1.1.1.2.4.2  tls     = (struct elf64_ia64_local_hash_entry *) ptr2;
    975  1.1.1.2.4.2  tls 
    976  1.1.1.2.4.2  tls   return entry1->id == entry2->id && entry1->r_sym == entry2->r_sym;
    977  1.1.1.2.4.2  tls }
    978  1.1.1.2.4.2  tls 
    979  1.1.1.2.4.2  tls /* Create the derived linker hash table.  The IA-64 ELF port uses this
    980  1.1.1.2.4.2  tls    derived hash table to keep information specific to the IA-64 ElF
    981  1.1.1.2.4.2  tls    linker (without using static variables).  */
    982  1.1.1.2.4.2  tls 
    983  1.1.1.2.4.2  tls static struct bfd_link_hash_table *
    984  1.1.1.2.4.2  tls elf64_ia64_hash_table_create (bfd *abfd)
    985  1.1.1.2.4.2  tls {
    986  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ret;
    987  1.1.1.2.4.2  tls 
    988  1.1.1.2.4.2  tls   ret = bfd_zmalloc ((bfd_size_type) sizeof (*ret));
    989  1.1.1.2.4.2  tls   if (!ret)
    990  1.1.1.2.4.2  tls     return NULL;
    991  1.1.1.2.4.2  tls 
    992  1.1.1.2.4.2  tls   if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
    993  1.1.1.2.4.2  tls 				      elf64_ia64_new_elf_hash_entry,
    994  1.1.1.2.4.2  tls 				      sizeof (struct elf64_ia64_link_hash_entry),
    995  1.1.1.2.4.2  tls 				      IA64_ELF_DATA))
    996  1.1.1.2.4.2  tls     {
    997  1.1.1.2.4.2  tls       free (ret);
    998  1.1.1.2.4.2  tls       return NULL;
    999  1.1.1.2.4.2  tls     }
   1000  1.1.1.2.4.2  tls 
   1001  1.1.1.2.4.2  tls   ret->loc_hash_table = htab_try_create (1024, elf64_ia64_local_htab_hash,
   1002  1.1.1.2.4.2  tls 					 elf64_ia64_local_htab_eq, NULL);
   1003  1.1.1.2.4.2  tls   ret->loc_hash_memory = objalloc_create ();
   1004  1.1.1.2.4.2  tls   if (!ret->loc_hash_table || !ret->loc_hash_memory)
   1005  1.1.1.2.4.2  tls     {
   1006  1.1.1.2.4.2  tls       free (ret);
   1007  1.1.1.2.4.2  tls       return NULL;
   1008  1.1.1.2.4.2  tls     }
   1009  1.1.1.2.4.2  tls 
   1010  1.1.1.2.4.2  tls   return &ret->root.root;
   1011  1.1.1.2.4.2  tls }
   1012  1.1.1.2.4.2  tls 
   1013  1.1.1.2.4.2  tls /* Free the global elf64_ia64_dyn_sym_info array.  */
   1014  1.1.1.2.4.2  tls 
   1015  1.1.1.2.4.2  tls static bfd_boolean
   1016  1.1.1.2.4.2  tls elf64_ia64_global_dyn_info_free (void **xentry,
   1017  1.1.1.2.4.2  tls 				 void * unused ATTRIBUTE_UNUSED)
   1018  1.1.1.2.4.2  tls {
   1019  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_entry *entry
   1020  1.1.1.2.4.2  tls     = (struct elf64_ia64_link_hash_entry *) xentry;
   1021  1.1.1.2.4.2  tls 
   1022  1.1.1.2.4.2  tls   if (entry->root.root.type == bfd_link_hash_warning)
   1023  1.1.1.2.4.2  tls     entry = (struct elf64_ia64_link_hash_entry *) entry->root.root.u.i.link;
   1024  1.1.1.2.4.2  tls 
   1025  1.1.1.2.4.2  tls   if (entry->info)
   1026  1.1.1.2.4.2  tls     {
   1027  1.1.1.2.4.2  tls       free (entry->info);
   1028  1.1.1.2.4.2  tls       entry->info = NULL;
   1029  1.1.1.2.4.2  tls       entry->count = 0;
   1030  1.1.1.2.4.2  tls       entry->sorted_count = 0;
   1031  1.1.1.2.4.2  tls       entry->size = 0;
   1032  1.1.1.2.4.2  tls     }
   1033  1.1.1.2.4.2  tls 
   1034  1.1.1.2.4.2  tls   return TRUE;
   1035  1.1.1.2.4.2  tls }
   1036  1.1.1.2.4.2  tls 
   1037  1.1.1.2.4.2  tls /* Free the local elf64_ia64_dyn_sym_info array.  */
   1038  1.1.1.2.4.2  tls 
   1039  1.1.1.2.4.2  tls static bfd_boolean
   1040  1.1.1.2.4.2  tls elf64_ia64_local_dyn_info_free (void **slot,
   1041  1.1.1.2.4.2  tls 				void * unused ATTRIBUTE_UNUSED)
   1042  1.1.1.2.4.2  tls {
   1043  1.1.1.2.4.2  tls   struct elf64_ia64_local_hash_entry *entry
   1044  1.1.1.2.4.2  tls     = (struct elf64_ia64_local_hash_entry *) *slot;
   1045  1.1.1.2.4.2  tls 
   1046  1.1.1.2.4.2  tls   if (entry->info)
   1047  1.1.1.2.4.2  tls     {
   1048  1.1.1.2.4.2  tls       free (entry->info);
   1049  1.1.1.2.4.2  tls       entry->info = NULL;
   1050  1.1.1.2.4.2  tls       entry->count = 0;
   1051  1.1.1.2.4.2  tls       entry->sorted_count = 0;
   1052  1.1.1.2.4.2  tls       entry->size = 0;
   1053  1.1.1.2.4.2  tls     }
   1054  1.1.1.2.4.2  tls 
   1055  1.1.1.2.4.2  tls   return TRUE;
   1056  1.1.1.2.4.2  tls }
   1057  1.1.1.2.4.2  tls 
   1058  1.1.1.2.4.2  tls /* Destroy IA-64 linker hash table.  */
   1059  1.1.1.2.4.2  tls 
   1060  1.1.1.2.4.2  tls static void
   1061  1.1.1.2.4.2  tls elf64_ia64_hash_table_free (struct bfd_link_hash_table *hash)
   1062  1.1.1.2.4.2  tls {
   1063  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info
   1064  1.1.1.2.4.2  tls     = (struct elf64_ia64_link_hash_table *) hash;
   1065  1.1.1.2.4.2  tls   if (ia64_info->loc_hash_table)
   1066  1.1.1.2.4.2  tls     {
   1067  1.1.1.2.4.2  tls       htab_traverse (ia64_info->loc_hash_table,
   1068  1.1.1.2.4.2  tls 		     elf64_ia64_local_dyn_info_free, NULL);
   1069  1.1.1.2.4.2  tls       htab_delete (ia64_info->loc_hash_table);
   1070  1.1.1.2.4.2  tls     }
   1071  1.1.1.2.4.2  tls   if (ia64_info->loc_hash_memory)
   1072  1.1.1.2.4.2  tls     objalloc_free ((struct objalloc *) ia64_info->loc_hash_memory);
   1073  1.1.1.2.4.2  tls   elf_link_hash_traverse (&ia64_info->root,
   1074  1.1.1.2.4.2  tls 			  elf64_ia64_global_dyn_info_free, NULL);
   1075  1.1.1.2.4.2  tls   _bfd_elf_link_hash_table_free (hash);
   1076  1.1.1.2.4.2  tls }
   1077  1.1.1.2.4.2  tls 
   1078  1.1.1.2.4.2  tls /* Traverse both local and global hash tables.  */
   1079  1.1.1.2.4.2  tls 
   1080  1.1.1.2.4.2  tls struct elf64_ia64_dyn_sym_traverse_data
   1081  1.1.1.2.4.2  tls {
   1082  1.1.1.2.4.2  tls   bfd_boolean (*func) (struct elf64_ia64_dyn_sym_info *, void *);
   1083  1.1.1.2.4.2  tls   void * data;
   1084  1.1.1.2.4.2  tls };
   1085  1.1.1.2.4.2  tls 
   1086  1.1.1.2.4.2  tls static bfd_boolean
   1087  1.1.1.2.4.2  tls elf64_ia64_global_dyn_sym_thunk (struct bfd_hash_entry *xentry,
   1088  1.1.1.2.4.2  tls 				 void * xdata)
   1089  1.1.1.2.4.2  tls {
   1090  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_entry *entry
   1091  1.1.1.2.4.2  tls     = (struct elf64_ia64_link_hash_entry *) xentry;
   1092  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_traverse_data *data
   1093  1.1.1.2.4.2  tls     = (struct elf64_ia64_dyn_sym_traverse_data *) xdata;
   1094  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_info *dyn_i;
   1095  1.1.1.2.4.2  tls   unsigned int count;
   1096  1.1.1.2.4.2  tls 
   1097  1.1.1.2.4.2  tls   if (entry->root.root.type == bfd_link_hash_warning)
   1098  1.1.1.2.4.2  tls     entry = (struct elf64_ia64_link_hash_entry *) entry->root.root.u.i.link;
   1099  1.1.1.2.4.2  tls 
   1100  1.1.1.2.4.2  tls   for (count = entry->count, dyn_i = entry->info;
   1101  1.1.1.2.4.2  tls        count != 0;
   1102  1.1.1.2.4.2  tls        count--, dyn_i++)
   1103  1.1.1.2.4.2  tls     if (! (*data->func) (dyn_i, data->data))
   1104  1.1.1.2.4.2  tls       return FALSE;
   1105  1.1.1.2.4.2  tls   return TRUE;
   1106  1.1.1.2.4.2  tls }
   1107  1.1.1.2.4.2  tls 
   1108  1.1.1.2.4.2  tls static bfd_boolean
   1109  1.1.1.2.4.2  tls elf64_ia64_local_dyn_sym_thunk (void **slot, void * xdata)
   1110  1.1.1.2.4.2  tls {
   1111  1.1.1.2.4.2  tls   struct elf64_ia64_local_hash_entry *entry
   1112  1.1.1.2.4.2  tls     = (struct elf64_ia64_local_hash_entry *) *slot;
   1113  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_traverse_data *data
   1114  1.1.1.2.4.2  tls     = (struct elf64_ia64_dyn_sym_traverse_data *) xdata;
   1115  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_info *dyn_i;
   1116  1.1.1.2.4.2  tls   unsigned int count;
   1117  1.1.1.2.4.2  tls 
   1118  1.1.1.2.4.2  tls   for (count = entry->count, dyn_i = entry->info;
   1119  1.1.1.2.4.2  tls        count != 0;
   1120  1.1.1.2.4.2  tls        count--, dyn_i++)
   1121  1.1.1.2.4.2  tls     if (! (*data->func) (dyn_i, data->data))
   1122  1.1.1.2.4.2  tls       return FALSE;
   1123  1.1.1.2.4.2  tls   return TRUE;
   1124  1.1.1.2.4.2  tls }
   1125  1.1.1.2.4.2  tls 
   1126  1.1.1.2.4.2  tls static void
   1127  1.1.1.2.4.2  tls elf64_ia64_dyn_sym_traverse (struct elf64_ia64_link_hash_table *ia64_info,
   1128  1.1.1.2.4.2  tls 			     bfd_boolean (*func) (struct elf64_ia64_dyn_sym_info *, void *),
   1129  1.1.1.2.4.2  tls 			     void * data)
   1130  1.1.1.2.4.2  tls {
   1131  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_traverse_data xdata;
   1132  1.1.1.2.4.2  tls 
   1133  1.1.1.2.4.2  tls   xdata.func = func;
   1134  1.1.1.2.4.2  tls   xdata.data = data;
   1135  1.1.1.2.4.2  tls 
   1136  1.1.1.2.4.2  tls   elf_link_hash_traverse (&ia64_info->root,
   1137  1.1.1.2.4.2  tls 			  elf64_ia64_global_dyn_sym_thunk, &xdata);
   1138  1.1.1.2.4.2  tls   htab_traverse (ia64_info->loc_hash_table,
   1139  1.1.1.2.4.2  tls 		 elf64_ia64_local_dyn_sym_thunk, &xdata);
   1140  1.1.1.2.4.2  tls }
   1141  1.1.1.2.4.2  tls 
   1142  1.1.1.2.4.2  tls #define NOTE_NAME "IPF/VMS"
   1143  1.1.1.2.4.2  tls 
   1144  1.1.1.2.4.2  tls static bfd_boolean
   1145  1.1.1.2.4.2  tls create_ia64_vms_notes (bfd *abfd, struct bfd_link_info *info,
   1146  1.1.1.2.4.2  tls                        unsigned int time_hi, unsigned int time_lo)
   1147  1.1.1.2.4.2  tls {
   1148  1.1.1.2.4.2  tls #define NBR_NOTES 7
   1149  1.1.1.2.4.2  tls   Elf_Internal_Note notes[NBR_NOTES];
   1150  1.1.1.2.4.2  tls   char *module_name;
   1151  1.1.1.2.4.2  tls   int module_name_len;
   1152  1.1.1.2.4.2  tls   unsigned char cur_time[8];
   1153  1.1.1.2.4.2  tls   Elf64_External_VMS_ORIG_DYN_Note *orig_dyn;
   1154  1.1.1.2.4.2  tls   unsigned int orig_dyn_size;
   1155  1.1.1.2.4.2  tls   unsigned int note_size;
   1156  1.1.1.2.4.2  tls   int i;
   1157  1.1.1.2.4.2  tls   unsigned char *noteptr;
   1158  1.1.1.2.4.2  tls   unsigned char *note_contents;
   1159  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   1160  1.1.1.2.4.2  tls 
   1161  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   1162  1.1.1.2.4.2  tls 
   1163  1.1.1.2.4.2  tls   module_name = vms_get_module_name (bfd_get_filename (abfd), TRUE);
   1164  1.1.1.2.4.2  tls   module_name_len = strlen (module_name) + 1;
   1165  1.1.1.2.4.2  tls 
   1166  1.1.1.2.4.2  tls   bfd_putl32 (time_lo, cur_time + 0);
   1167  1.1.1.2.4.2  tls   bfd_putl32 (time_hi, cur_time + 4);
   1168  1.1.1.2.4.2  tls 
   1169  1.1.1.2.4.2  tls   /* Note 0: IMGNAM.  */
   1170  1.1.1.2.4.2  tls   notes[0].type = NT_VMS_IMGNAM;
   1171  1.1.1.2.4.2  tls   notes[0].descdata = module_name;
   1172  1.1.1.2.4.2  tls   notes[0].descsz = module_name_len;
   1173  1.1.1.2.4.2  tls 
   1174  1.1.1.2.4.2  tls   /* Note 1: GSTNAM.  */
   1175  1.1.1.2.4.2  tls   notes[1].type = NT_VMS_GSTNAM;
   1176  1.1.1.2.4.2  tls   notes[1].descdata = module_name;
   1177  1.1.1.2.4.2  tls   notes[1].descsz = module_name_len;
   1178  1.1.1.2.4.2  tls 
   1179  1.1.1.2.4.2  tls   /* Note 2: IMGID.  */
   1180  1.1.1.2.4.2  tls #define IMG_ID "V1.0"
   1181  1.1.1.2.4.2  tls   notes[2].type = NT_VMS_IMGID;
   1182  1.1.1.2.4.2  tls   notes[2].descdata = IMG_ID;
   1183  1.1.1.2.4.2  tls   notes[2].descsz = sizeof (IMG_ID);
   1184  1.1.1.2.4.2  tls 
   1185  1.1.1.2.4.2  tls   /* Note 3: Linktime.  */
   1186  1.1.1.2.4.2  tls   notes[3].type = NT_VMS_LINKTIME;
   1187  1.1.1.2.4.2  tls   notes[3].descdata = (char *)cur_time;
   1188  1.1.1.2.4.2  tls   notes[3].descsz = sizeof (cur_time);
   1189  1.1.1.2.4.2  tls 
   1190  1.1.1.2.4.2  tls   /* Note 4: Linker id.  */
   1191  1.1.1.2.4.2  tls   notes[4].type = NT_VMS_LINKID;
   1192  1.1.1.2.4.2  tls   notes[4].descdata = "GNU ld " BFD_VERSION_STRING;
   1193  1.1.1.2.4.2  tls   notes[4].descsz = strlen (notes[4].descdata) + 1;
   1194  1.1.1.2.4.2  tls 
   1195  1.1.1.2.4.2  tls   /* Note 5: Original dyn.  */
   1196  1.1.1.2.4.2  tls   orig_dyn_size = (sizeof (*orig_dyn) + sizeof (IMG_ID) - 1 + 7) & ~7;
   1197  1.1.1.2.4.2  tls   orig_dyn = bfd_zalloc (abfd, orig_dyn_size);
   1198  1.1.1.2.4.2  tls   if (orig_dyn == NULL)
   1199  1.1.1.2.4.2  tls     return FALSE;
   1200  1.1.1.2.4.2  tls   bfd_putl32 (1, orig_dyn->major_id);
   1201  1.1.1.2.4.2  tls   bfd_putl32 (3, orig_dyn->minor_id);
   1202  1.1.1.2.4.2  tls   memcpy (orig_dyn->manipulation_date, cur_time, sizeof (cur_time));
   1203  1.1.1.2.4.2  tls   bfd_putl64 (VMS_LF_IMGSTA | VMS_LF_MAIN, orig_dyn->link_flags);
   1204  1.1.1.2.4.2  tls   bfd_putl32 (EF_IA_64_ABI64, orig_dyn->elf_flags);
   1205  1.1.1.2.4.2  tls   memcpy (orig_dyn->imgid, IMG_ID, sizeof (IMG_ID));
   1206  1.1.1.2.4.2  tls   notes[5].type = NT_VMS_ORIG_DYN;
   1207  1.1.1.2.4.2  tls   notes[5].descdata = (char *)orig_dyn;
   1208  1.1.1.2.4.2  tls   notes[5].descsz = orig_dyn_size;
   1209  1.1.1.2.4.2  tls 
   1210  1.1.1.2.4.2  tls   /* Note 3: Patchtime.  */
   1211  1.1.1.2.4.2  tls   notes[6].type = NT_VMS_PATCHTIME;
   1212  1.1.1.2.4.2  tls   notes[6].descdata = (char *)cur_time;
   1213  1.1.1.2.4.2  tls   notes[6].descsz = sizeof (cur_time);
   1214  1.1.1.2.4.2  tls 
   1215  1.1.1.2.4.2  tls   /* Compute notes size.  */
   1216  1.1.1.2.4.2  tls   note_size = 0;
   1217  1.1.1.2.4.2  tls   for (i = 0; i < NBR_NOTES; i++)
   1218  1.1.1.2.4.2  tls     note_size += sizeof (Elf64_External_VMS_Note) - 1
   1219  1.1.1.2.4.2  tls       + ((sizeof (NOTE_NAME) - 1 + 7) & ~7)
   1220  1.1.1.2.4.2  tls       + ((notes[i].descsz + 7) & ~7);
   1221  1.1.1.2.4.2  tls 
   1222  1.1.1.2.4.2  tls   /* Malloc a temporary buffer large enough for most notes */
   1223  1.1.1.2.4.2  tls   note_contents = (unsigned char *) bfd_zalloc (abfd, note_size);
   1224  1.1.1.2.4.2  tls   if (note_contents == NULL)
   1225  1.1.1.2.4.2  tls     return FALSE;
   1226  1.1.1.2.4.2  tls   noteptr = note_contents;
   1227  1.1.1.2.4.2  tls 
   1228  1.1.1.2.4.2  tls   /* Fill notes.  */
   1229  1.1.1.2.4.2  tls   for (i = 0; i < NBR_NOTES; i++)
   1230  1.1.1.2.4.2  tls     {
   1231  1.1.1.2.4.2  tls       Elf64_External_VMS_Note *enote = (Elf64_External_VMS_Note *) noteptr;
   1232  1.1.1.2.4.2  tls 
   1233  1.1.1.2.4.2  tls       bfd_putl64 (sizeof (NOTE_NAME) - 1, enote->namesz);
   1234  1.1.1.2.4.2  tls       bfd_putl64 (notes[i].descsz, enote->descsz);
   1235  1.1.1.2.4.2  tls       bfd_putl64 (notes[i].type, enote->type);
   1236  1.1.1.2.4.2  tls 
   1237  1.1.1.2.4.2  tls       noteptr = (unsigned char *)enote->name;
   1238  1.1.1.2.4.2  tls       memcpy (noteptr, NOTE_NAME, sizeof (NOTE_NAME) - 1);
   1239  1.1.1.2.4.2  tls       noteptr += (sizeof (NOTE_NAME) - 1 + 7) & ~7;
   1240  1.1.1.2.4.2  tls       memcpy (noteptr, notes[i].descdata, notes[i].descsz);
   1241  1.1.1.2.4.2  tls       noteptr += (notes[i].descsz + 7) & ~7;
   1242  1.1.1.2.4.2  tls     }
   1243  1.1.1.2.4.2  tls 
   1244  1.1.1.2.4.2  tls   ia64_info->note_sec->contents = note_contents;
   1245  1.1.1.2.4.2  tls   ia64_info->note_sec->size = note_size;
   1246  1.1.1.2.4.2  tls 
   1247  1.1.1.2.4.2  tls   free (module_name);
   1248  1.1.1.2.4.2  tls 
   1249  1.1.1.2.4.2  tls   return TRUE;
   1250  1.1.1.2.4.2  tls }
   1251  1.1.1.2.4.2  tls 
   1252  1.1.1.2.4.2  tls static bfd_boolean
   1253  1.1.1.2.4.2  tls elf64_ia64_create_dynamic_sections (bfd *abfd,
   1254  1.1.1.2.4.2  tls 				    struct bfd_link_info *info)
   1255  1.1.1.2.4.2  tls {
   1256  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   1257  1.1.1.2.4.2  tls   asection *s;
   1258  1.1.1.2.4.2  tls   flagword flags;
   1259  1.1.1.2.4.2  tls   const struct elf_backend_data *bed;
   1260  1.1.1.2.4.2  tls 
   1261  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   1262  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   1263  1.1.1.2.4.2  tls     return FALSE;
   1264  1.1.1.2.4.2  tls 
   1265  1.1.1.2.4.2  tls   if (elf_hash_table (info)->dynamic_sections_created)
   1266  1.1.1.2.4.2  tls     return TRUE;
   1267  1.1.1.2.4.2  tls 
   1268  1.1.1.2.4.2  tls   abfd = elf_hash_table (info)->dynobj;
   1269  1.1.1.2.4.2  tls   bed = get_elf_backend_data (abfd);
   1270  1.1.1.2.4.2  tls 
   1271  1.1.1.2.4.2  tls   flags = bed->dynamic_sec_flags;
   1272  1.1.1.2.4.2  tls 
   1273  1.1.1.2.4.2  tls   s = bfd_make_section_anyway_with_flags (abfd, ".dynamic",
   1274  1.1.1.2.4.2  tls 					  flags | SEC_READONLY);
   1275  1.1.1.2.4.2  tls   if (s == NULL
   1276  1.1.1.2.4.2  tls       || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
   1277  1.1.1.2.4.2  tls     return FALSE;
   1278  1.1.1.2.4.2  tls 
   1279  1.1.1.2.4.2  tls   s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags | SEC_READONLY);
   1280  1.1.1.2.4.2  tls   if (s == NULL
   1281  1.1.1.2.4.2  tls       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
   1282  1.1.1.2.4.2  tls     return FALSE;
   1283  1.1.1.2.4.2  tls   ia64_info->root.splt = s;
   1284  1.1.1.2.4.2  tls 
   1285  1.1.1.2.4.2  tls   if (!get_got (abfd, ia64_info))
   1286  1.1.1.2.4.2  tls     return FALSE;
   1287  1.1.1.2.4.2  tls 
   1288  1.1.1.2.4.2  tls   if (!get_pltoff (abfd, ia64_info))
   1289  1.1.1.2.4.2  tls     return FALSE;
   1290  1.1.1.2.4.2  tls 
   1291  1.1.1.2.4.2  tls   s = bfd_make_section_anyway_with_flags (abfd, ".vmsdynstr",
   1292  1.1.1.2.4.2  tls 					  (SEC_ALLOC
   1293  1.1.1.2.4.2  tls 					   | SEC_HAS_CONTENTS
   1294  1.1.1.2.4.2  tls 					   | SEC_IN_MEMORY
   1295  1.1.1.2.4.2  tls 					   | SEC_LINKER_CREATED));
   1296  1.1.1.2.4.2  tls   if (s == NULL
   1297  1.1.1.2.4.2  tls       || !bfd_set_section_alignment (abfd, s, 0))
   1298  1.1.1.2.4.2  tls     return FALSE;
   1299  1.1.1.2.4.2  tls 
   1300  1.1.1.2.4.2  tls   /* Create a fixup section.  */
   1301  1.1.1.2.4.2  tls   s = bfd_make_section_anyway_with_flags (abfd, ".fixups",
   1302  1.1.1.2.4.2  tls 					  (SEC_ALLOC
   1303  1.1.1.2.4.2  tls 					   | SEC_HAS_CONTENTS
   1304  1.1.1.2.4.2  tls 					   | SEC_IN_MEMORY
   1305  1.1.1.2.4.2  tls 					   | SEC_LINKER_CREATED));
   1306  1.1.1.2.4.2  tls   if (s == NULL
   1307  1.1.1.2.4.2  tls       || !bfd_set_section_alignment (abfd, s, 3))
   1308  1.1.1.2.4.2  tls     return FALSE;
   1309  1.1.1.2.4.2  tls   ia64_info->fixups_sec = s;
   1310  1.1.1.2.4.2  tls 
   1311  1.1.1.2.4.2  tls   /* Create the transfer fixup section.  */
   1312  1.1.1.2.4.2  tls   s = bfd_make_section_anyway_with_flags (abfd, ".transfer",
   1313  1.1.1.2.4.2  tls 					  (SEC_ALLOC
   1314  1.1.1.2.4.2  tls 					   | SEC_HAS_CONTENTS
   1315  1.1.1.2.4.2  tls 					   | SEC_IN_MEMORY
   1316  1.1.1.2.4.2  tls 					   | SEC_LINKER_CREATED));
   1317  1.1.1.2.4.2  tls   if (s == NULL
   1318  1.1.1.2.4.2  tls       || !bfd_set_section_alignment (abfd, s, 3))
   1319  1.1.1.2.4.2  tls     return FALSE;
   1320  1.1.1.2.4.2  tls   s->size = sizeof (struct elf64_vms_transfer);
   1321  1.1.1.2.4.2  tls   ia64_info->transfer_sec = s;
   1322  1.1.1.2.4.2  tls 
   1323  1.1.1.2.4.2  tls   /* Create note section.  */
   1324  1.1.1.2.4.2  tls   s = bfd_make_section_anyway_with_flags (abfd, ".vms.note",
   1325  1.1.1.2.4.2  tls                                           (SEC_LINKER_CREATED
   1326  1.1.1.2.4.2  tls                                            | SEC_HAS_CONTENTS
   1327  1.1.1.2.4.2  tls                                            | SEC_IN_MEMORY
   1328  1.1.1.2.4.2  tls                                            | SEC_READONLY));
   1329  1.1.1.2.4.2  tls   if (s == NULL
   1330  1.1.1.2.4.2  tls       || !bfd_set_section_alignment (abfd, s, 3))
   1331  1.1.1.2.4.2  tls     return FALSE;
   1332  1.1.1.2.4.2  tls   ia64_info->note_sec = s;
   1333  1.1.1.2.4.2  tls 
   1334  1.1.1.2.4.2  tls   elf_hash_table (info)->dynamic_sections_created = TRUE;
   1335  1.1.1.2.4.2  tls   return TRUE;
   1336  1.1.1.2.4.2  tls }
   1337  1.1.1.2.4.2  tls 
   1338  1.1.1.2.4.2  tls /* Find and/or create a hash entry for local symbol.  */
   1339  1.1.1.2.4.2  tls static struct elf64_ia64_local_hash_entry *
   1340  1.1.1.2.4.2  tls get_local_sym_hash (struct elf64_ia64_link_hash_table *ia64_info,
   1341  1.1.1.2.4.2  tls 		    bfd *abfd, const Elf_Internal_Rela *rel,
   1342  1.1.1.2.4.2  tls 		    bfd_boolean create)
   1343  1.1.1.2.4.2  tls {
   1344  1.1.1.2.4.2  tls   struct elf64_ia64_local_hash_entry e, *ret;
   1345  1.1.1.2.4.2  tls   asection *sec = abfd->sections;
   1346  1.1.1.2.4.2  tls   hashval_t h = ELF_LOCAL_SYMBOL_HASH (sec->id,
   1347  1.1.1.2.4.2  tls 				       ELF64_R_SYM (rel->r_info));
   1348  1.1.1.2.4.2  tls   void **slot;
   1349  1.1.1.2.4.2  tls 
   1350  1.1.1.2.4.2  tls   e.id = sec->id;
   1351  1.1.1.2.4.2  tls   e.r_sym = ELF64_R_SYM (rel->r_info);
   1352  1.1.1.2.4.2  tls   slot = htab_find_slot_with_hash (ia64_info->loc_hash_table, &e, h,
   1353  1.1.1.2.4.2  tls 				   create ? INSERT : NO_INSERT);
   1354  1.1.1.2.4.2  tls 
   1355  1.1.1.2.4.2  tls   if (!slot)
   1356  1.1.1.2.4.2  tls     return NULL;
   1357  1.1.1.2.4.2  tls 
   1358  1.1.1.2.4.2  tls   if (*slot)
   1359  1.1.1.2.4.2  tls     return (struct elf64_ia64_local_hash_entry *) *slot;
   1360  1.1.1.2.4.2  tls 
   1361  1.1.1.2.4.2  tls   ret = (struct elf64_ia64_local_hash_entry *)
   1362  1.1.1.2.4.2  tls 	objalloc_alloc ((struct objalloc *) ia64_info->loc_hash_memory,
   1363  1.1.1.2.4.2  tls 			sizeof (struct elf64_ia64_local_hash_entry));
   1364  1.1.1.2.4.2  tls   if (ret)
   1365  1.1.1.2.4.2  tls     {
   1366  1.1.1.2.4.2  tls       memset (ret, 0, sizeof (*ret));
   1367  1.1.1.2.4.2  tls       ret->id = sec->id;
   1368  1.1.1.2.4.2  tls       ret->r_sym = ELF64_R_SYM (rel->r_info);
   1369  1.1.1.2.4.2  tls       *slot = ret;
   1370  1.1.1.2.4.2  tls     }
   1371  1.1.1.2.4.2  tls   return ret;
   1372  1.1.1.2.4.2  tls }
   1373  1.1.1.2.4.2  tls 
   1374  1.1.1.2.4.2  tls /* Used to sort elf64_ia64_dyn_sym_info array.  */
   1375  1.1.1.2.4.2  tls 
   1376  1.1.1.2.4.2  tls static int
   1377  1.1.1.2.4.2  tls addend_compare (const void *xp, const void *yp)
   1378  1.1.1.2.4.2  tls {
   1379  1.1.1.2.4.2  tls   const struct elf64_ia64_dyn_sym_info *x
   1380  1.1.1.2.4.2  tls     = (const struct elf64_ia64_dyn_sym_info *) xp;
   1381  1.1.1.2.4.2  tls   const struct elf64_ia64_dyn_sym_info *y
   1382  1.1.1.2.4.2  tls     = (const struct elf64_ia64_dyn_sym_info *) yp;
   1383  1.1.1.2.4.2  tls 
   1384  1.1.1.2.4.2  tls   return x->addend < y->addend ? -1 : x->addend > y->addend ? 1 : 0;
   1385  1.1.1.2.4.2  tls }
   1386  1.1.1.2.4.2  tls 
   1387  1.1.1.2.4.2  tls /* Sort elf64_ia64_dyn_sym_info array and remove duplicates.  */
   1388  1.1.1.2.4.2  tls 
   1389  1.1.1.2.4.2  tls static unsigned int
   1390  1.1.1.2.4.2  tls sort_dyn_sym_info (struct elf64_ia64_dyn_sym_info *info,
   1391  1.1.1.2.4.2  tls 		   unsigned int count)
   1392  1.1.1.2.4.2  tls {
   1393  1.1.1.2.4.2  tls   bfd_vma curr, prev, got_offset;
   1394  1.1.1.2.4.2  tls   unsigned int i, kept, dupes, diff, dest, src, len;
   1395  1.1.1.2.4.2  tls 
   1396  1.1.1.2.4.2  tls   qsort (info, count, sizeof (*info), addend_compare);
   1397  1.1.1.2.4.2  tls 
   1398  1.1.1.2.4.2  tls   /* Find the first duplicate.  */
   1399  1.1.1.2.4.2  tls   prev = info [0].addend;
   1400  1.1.1.2.4.2  tls   got_offset = info [0].got_offset;
   1401  1.1.1.2.4.2  tls   for (i = 1; i < count; i++)
   1402  1.1.1.2.4.2  tls     {
   1403  1.1.1.2.4.2  tls       curr = info [i].addend;
   1404  1.1.1.2.4.2  tls       if (curr == prev)
   1405  1.1.1.2.4.2  tls 	{
   1406  1.1.1.2.4.2  tls 	  /* For duplicates, make sure that GOT_OFFSET is valid.  */
   1407  1.1.1.2.4.2  tls 	  if (got_offset == (bfd_vma) -1)
   1408  1.1.1.2.4.2  tls 	    got_offset = info [i].got_offset;
   1409  1.1.1.2.4.2  tls 	  break;
   1410  1.1.1.2.4.2  tls 	}
   1411  1.1.1.2.4.2  tls       got_offset = info [i].got_offset;
   1412  1.1.1.2.4.2  tls       prev = curr;
   1413  1.1.1.2.4.2  tls     }
   1414  1.1.1.2.4.2  tls 
   1415  1.1.1.2.4.2  tls   /* We may move a block of elements to here.  */
   1416  1.1.1.2.4.2  tls   dest = i++;
   1417  1.1.1.2.4.2  tls 
   1418  1.1.1.2.4.2  tls   /* Remove duplicates.  */
   1419  1.1.1.2.4.2  tls   if (i < count)
   1420  1.1.1.2.4.2  tls     {
   1421  1.1.1.2.4.2  tls       while (i < count)
   1422  1.1.1.2.4.2  tls 	{
   1423  1.1.1.2.4.2  tls 	  /* For duplicates, make sure that the kept one has a valid
   1424  1.1.1.2.4.2  tls 	     got_offset.  */
   1425  1.1.1.2.4.2  tls 	  kept = dest - 1;
   1426  1.1.1.2.4.2  tls 	  if (got_offset != (bfd_vma) -1)
   1427  1.1.1.2.4.2  tls 	    info [kept].got_offset = got_offset;
   1428  1.1.1.2.4.2  tls 
   1429  1.1.1.2.4.2  tls 	  curr = info [i].addend;
   1430  1.1.1.2.4.2  tls 	  got_offset = info [i].got_offset;
   1431  1.1.1.2.4.2  tls 
   1432  1.1.1.2.4.2  tls 	  /* Move a block of elements whose first one is different from
   1433  1.1.1.2.4.2  tls 	     the previous.  */
   1434  1.1.1.2.4.2  tls 	  if (curr == prev)
   1435  1.1.1.2.4.2  tls 	    {
   1436  1.1.1.2.4.2  tls 	      for (src = i + 1; src < count; src++)
   1437  1.1.1.2.4.2  tls 		{
   1438  1.1.1.2.4.2  tls 		  if (info [src].addend != curr)
   1439  1.1.1.2.4.2  tls 		    break;
   1440  1.1.1.2.4.2  tls 		  /* For duplicates, make sure that GOT_OFFSET is
   1441  1.1.1.2.4.2  tls 		     valid.  */
   1442  1.1.1.2.4.2  tls 		  if (got_offset == (bfd_vma) -1)
   1443  1.1.1.2.4.2  tls 		    got_offset = info [src].got_offset;
   1444  1.1.1.2.4.2  tls 		}
   1445  1.1.1.2.4.2  tls 
   1446  1.1.1.2.4.2  tls 	      /* Make sure that the kept one has a valid got_offset.  */
   1447  1.1.1.2.4.2  tls 	      if (got_offset != (bfd_vma) -1)
   1448  1.1.1.2.4.2  tls 		info [kept].got_offset = got_offset;
   1449  1.1.1.2.4.2  tls 	    }
   1450  1.1.1.2.4.2  tls 	  else
   1451  1.1.1.2.4.2  tls 	    src = i;
   1452  1.1.1.2.4.2  tls 
   1453  1.1.1.2.4.2  tls 	  if (src >= count)
   1454  1.1.1.2.4.2  tls 	    break;
   1455  1.1.1.2.4.2  tls 
   1456  1.1.1.2.4.2  tls 	  /* Find the next duplicate.  SRC will be kept.  */
   1457  1.1.1.2.4.2  tls 	  prev = info [src].addend;
   1458  1.1.1.2.4.2  tls 	  got_offset = info [src].got_offset;
   1459  1.1.1.2.4.2  tls 	  for (dupes = src + 1; dupes < count; dupes ++)
   1460  1.1.1.2.4.2  tls 	    {
   1461  1.1.1.2.4.2  tls 	      curr = info [dupes].addend;
   1462  1.1.1.2.4.2  tls 	      if (curr == prev)
   1463  1.1.1.2.4.2  tls 		{
   1464  1.1.1.2.4.2  tls 		  /* Make sure that got_offset is valid.  */
   1465  1.1.1.2.4.2  tls 		  if (got_offset == (bfd_vma) -1)
   1466  1.1.1.2.4.2  tls 		    got_offset = info [dupes].got_offset;
   1467  1.1.1.2.4.2  tls 
   1468  1.1.1.2.4.2  tls 		  /* For duplicates, make sure that the kept one has
   1469  1.1.1.2.4.2  tls 		     a valid got_offset.  */
   1470  1.1.1.2.4.2  tls 		  if (got_offset != (bfd_vma) -1)
   1471  1.1.1.2.4.2  tls 		    info [dupes - 1].got_offset = got_offset;
   1472  1.1.1.2.4.2  tls 		  break;
   1473  1.1.1.2.4.2  tls 		}
   1474  1.1.1.2.4.2  tls 	      got_offset = info [dupes].got_offset;
   1475  1.1.1.2.4.2  tls 	      prev = curr;
   1476  1.1.1.2.4.2  tls 	    }
   1477  1.1.1.2.4.2  tls 
   1478  1.1.1.2.4.2  tls 	  /* How much to move.  */
   1479  1.1.1.2.4.2  tls 	  len = dupes - src;
   1480  1.1.1.2.4.2  tls 	  i = dupes + 1;
   1481  1.1.1.2.4.2  tls 
   1482  1.1.1.2.4.2  tls 	  if (len == 1 && dupes < count)
   1483  1.1.1.2.4.2  tls 	    {
   1484  1.1.1.2.4.2  tls 	      /* If we only move 1 element, we combine it with the next
   1485  1.1.1.2.4.2  tls 		 one.  There must be at least a duplicate.  Find the
   1486  1.1.1.2.4.2  tls 		 next different one.  */
   1487  1.1.1.2.4.2  tls 	      for (diff = dupes + 1, src++; diff < count; diff++, src++)
   1488  1.1.1.2.4.2  tls 		{
   1489  1.1.1.2.4.2  tls 		  if (info [diff].addend != curr)
   1490  1.1.1.2.4.2  tls 		    break;
   1491  1.1.1.2.4.2  tls 		  /* Make sure that got_offset is valid.  */
   1492  1.1.1.2.4.2  tls 		  if (got_offset == (bfd_vma) -1)
   1493  1.1.1.2.4.2  tls 		    got_offset = info [diff].got_offset;
   1494  1.1.1.2.4.2  tls 		}
   1495  1.1.1.2.4.2  tls 
   1496  1.1.1.2.4.2  tls 	      /* Makre sure that the last duplicated one has an valid
   1497  1.1.1.2.4.2  tls 		 offset.  */
   1498  1.1.1.2.4.2  tls 	      BFD_ASSERT (curr == prev);
   1499  1.1.1.2.4.2  tls 	      if (got_offset != (bfd_vma) -1)
   1500  1.1.1.2.4.2  tls 		info [diff - 1].got_offset = got_offset;
   1501  1.1.1.2.4.2  tls 
   1502  1.1.1.2.4.2  tls 	      if (diff < count)
   1503  1.1.1.2.4.2  tls 		{
   1504  1.1.1.2.4.2  tls 		  /* Find the next duplicate.  Track the current valid
   1505  1.1.1.2.4.2  tls 		     offset.  */
   1506  1.1.1.2.4.2  tls 		  prev = info [diff].addend;
   1507  1.1.1.2.4.2  tls 		  got_offset = info [diff].got_offset;
   1508  1.1.1.2.4.2  tls 		  for (dupes = diff + 1; dupes < count; dupes ++)
   1509  1.1.1.2.4.2  tls 		    {
   1510  1.1.1.2.4.2  tls 		      curr = info [dupes].addend;
   1511  1.1.1.2.4.2  tls 		      if (curr == prev)
   1512  1.1.1.2.4.2  tls 			{
   1513  1.1.1.2.4.2  tls 			  /* For duplicates, make sure that GOT_OFFSET
   1514  1.1.1.2.4.2  tls 			     is valid.  */
   1515  1.1.1.2.4.2  tls 			  if (got_offset == (bfd_vma) -1)
   1516  1.1.1.2.4.2  tls 			    got_offset = info [dupes].got_offset;
   1517  1.1.1.2.4.2  tls 			  break;
   1518  1.1.1.2.4.2  tls 			}
   1519  1.1.1.2.4.2  tls 		      got_offset = info [dupes].got_offset;
   1520  1.1.1.2.4.2  tls 		      prev = curr;
   1521  1.1.1.2.4.2  tls 		      diff++;
   1522  1.1.1.2.4.2  tls 		    }
   1523  1.1.1.2.4.2  tls 
   1524  1.1.1.2.4.2  tls 		  len = diff - src + 1;
   1525  1.1.1.2.4.2  tls 		  i = diff + 1;
   1526  1.1.1.2.4.2  tls 		}
   1527  1.1.1.2.4.2  tls 	    }
   1528  1.1.1.2.4.2  tls 
   1529  1.1.1.2.4.2  tls 	  memmove (&info [dest], &info [src], len * sizeof (*info));
   1530  1.1.1.2.4.2  tls 
   1531  1.1.1.2.4.2  tls 	  dest += len;
   1532  1.1.1.2.4.2  tls 	}
   1533  1.1.1.2.4.2  tls 
   1534  1.1.1.2.4.2  tls       count = dest;
   1535  1.1.1.2.4.2  tls     }
   1536  1.1.1.2.4.2  tls   else
   1537  1.1.1.2.4.2  tls     {
   1538  1.1.1.2.4.2  tls       /* When we get here, either there is no duplicate at all or
   1539  1.1.1.2.4.2  tls 	 the only duplicate is the last element.  */
   1540  1.1.1.2.4.2  tls       if (dest < count)
   1541  1.1.1.2.4.2  tls 	{
   1542  1.1.1.2.4.2  tls 	  /* If the last element is a duplicate, make sure that the
   1543  1.1.1.2.4.2  tls 	     kept one has a valid got_offset.  We also update count.  */
   1544  1.1.1.2.4.2  tls 	  if (got_offset != (bfd_vma) -1)
   1545  1.1.1.2.4.2  tls 	    info [dest - 1].got_offset = got_offset;
   1546  1.1.1.2.4.2  tls 	  count = dest;
   1547  1.1.1.2.4.2  tls 	}
   1548  1.1.1.2.4.2  tls     }
   1549  1.1.1.2.4.2  tls 
   1550  1.1.1.2.4.2  tls   return count;
   1551  1.1.1.2.4.2  tls }
   1552  1.1.1.2.4.2  tls 
   1553  1.1.1.2.4.2  tls /* Find and/or create a descriptor for dynamic symbol info.  This will
   1554  1.1.1.2.4.2  tls    vary based on global or local symbol, and the addend to the reloc.
   1555  1.1.1.2.4.2  tls 
   1556  1.1.1.2.4.2  tls    We don't sort when inserting.  Also, we sort and eliminate
   1557  1.1.1.2.4.2  tls    duplicates if there is an unsorted section.  Typically, this will
   1558  1.1.1.2.4.2  tls    only happen once, because we do all insertions before lookups.  We
   1559  1.1.1.2.4.2  tls    then use bsearch to do a lookup.  This also allows lookups to be
   1560  1.1.1.2.4.2  tls    fast.  So we have fast insertion (O(log N) due to duplicate check),
   1561  1.1.1.2.4.2  tls    fast lookup (O(log N)) and one sort (O(N log N) expected time).
   1562  1.1.1.2.4.2  tls    Previously, all lookups were O(N) because of the use of the linked
   1563  1.1.1.2.4.2  tls    list and also all insertions were O(N) because of the check for
   1564  1.1.1.2.4.2  tls    duplicates.  There are some complications here because the array
   1565  1.1.1.2.4.2  tls    size grows occasionally, which may add an O(N) factor, but this
   1566  1.1.1.2.4.2  tls    should be rare.  Also,  we free the excess array allocation, which
   1567  1.1.1.2.4.2  tls    requires a copy which is O(N), but this only happens once.  */
   1568  1.1.1.2.4.2  tls 
   1569  1.1.1.2.4.2  tls static struct elf64_ia64_dyn_sym_info *
   1570  1.1.1.2.4.2  tls get_dyn_sym_info (struct elf64_ia64_link_hash_table *ia64_info,
   1571  1.1.1.2.4.2  tls 		  struct elf_link_hash_entry *h, bfd *abfd,
   1572  1.1.1.2.4.2  tls 		  const Elf_Internal_Rela *rel, bfd_boolean create)
   1573  1.1.1.2.4.2  tls {
   1574  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_info **info_p, *info, *dyn_i, key;
   1575  1.1.1.2.4.2  tls   unsigned int *count_p, *sorted_count_p, *size_p;
   1576  1.1.1.2.4.2  tls   unsigned int count, sorted_count, size;
   1577  1.1.1.2.4.2  tls   bfd_vma addend = rel ? rel->r_addend : 0;
   1578  1.1.1.2.4.2  tls   bfd_size_type amt;
   1579  1.1.1.2.4.2  tls 
   1580  1.1.1.2.4.2  tls   if (h)
   1581  1.1.1.2.4.2  tls     {
   1582  1.1.1.2.4.2  tls       struct elf64_ia64_link_hash_entry *global_h;
   1583  1.1.1.2.4.2  tls 
   1584  1.1.1.2.4.2  tls       global_h = (struct elf64_ia64_link_hash_entry *) h;
   1585  1.1.1.2.4.2  tls       info_p = &global_h->info;
   1586  1.1.1.2.4.2  tls       count_p = &global_h->count;
   1587  1.1.1.2.4.2  tls       sorted_count_p = &global_h->sorted_count;
   1588  1.1.1.2.4.2  tls       size_p = &global_h->size;
   1589  1.1.1.2.4.2  tls     }
   1590  1.1.1.2.4.2  tls   else
   1591  1.1.1.2.4.2  tls     {
   1592  1.1.1.2.4.2  tls       struct elf64_ia64_local_hash_entry *loc_h;
   1593  1.1.1.2.4.2  tls 
   1594  1.1.1.2.4.2  tls       loc_h = get_local_sym_hash (ia64_info, abfd, rel, create);
   1595  1.1.1.2.4.2  tls       if (!loc_h)
   1596  1.1.1.2.4.2  tls 	{
   1597  1.1.1.2.4.2  tls 	  BFD_ASSERT (!create);
   1598  1.1.1.2.4.2  tls 	  return NULL;
   1599  1.1.1.2.4.2  tls 	}
   1600  1.1.1.2.4.2  tls 
   1601  1.1.1.2.4.2  tls       info_p = &loc_h->info;
   1602  1.1.1.2.4.2  tls       count_p = &loc_h->count;
   1603  1.1.1.2.4.2  tls       sorted_count_p = &loc_h->sorted_count;
   1604  1.1.1.2.4.2  tls       size_p = &loc_h->size;
   1605  1.1.1.2.4.2  tls     }
   1606  1.1.1.2.4.2  tls 
   1607  1.1.1.2.4.2  tls   count = *count_p;
   1608  1.1.1.2.4.2  tls   sorted_count = *sorted_count_p;
   1609  1.1.1.2.4.2  tls   size = *size_p;
   1610  1.1.1.2.4.2  tls   info = *info_p;
   1611  1.1.1.2.4.2  tls   if (create)
   1612  1.1.1.2.4.2  tls     {
   1613  1.1.1.2.4.2  tls       /* When we create the array, we don't check for duplicates,
   1614  1.1.1.2.4.2  tls          except in the previously sorted section if one exists, and
   1615  1.1.1.2.4.2  tls 	 against the last inserted entry.  This allows insertions to
   1616  1.1.1.2.4.2  tls 	 be fast.  */
   1617  1.1.1.2.4.2  tls       if (info)
   1618  1.1.1.2.4.2  tls 	{
   1619  1.1.1.2.4.2  tls 	  if (sorted_count)
   1620  1.1.1.2.4.2  tls 	    {
   1621  1.1.1.2.4.2  tls 	      /* Try bsearch first on the sorted section.  */
   1622  1.1.1.2.4.2  tls 	      key.addend = addend;
   1623  1.1.1.2.4.2  tls 	      dyn_i = bsearch (&key, info, sorted_count,
   1624  1.1.1.2.4.2  tls 			       sizeof (*info), addend_compare);
   1625  1.1.1.2.4.2  tls 
   1626  1.1.1.2.4.2  tls 	      if (dyn_i)
   1627  1.1.1.2.4.2  tls 		{
   1628  1.1.1.2.4.2  tls 		  return dyn_i;
   1629  1.1.1.2.4.2  tls 		}
   1630  1.1.1.2.4.2  tls 	    }
   1631  1.1.1.2.4.2  tls 
   1632  1.1.1.2.4.2  tls 	  /* Do a quick check for the last inserted entry.  */
   1633  1.1.1.2.4.2  tls 	  dyn_i = info + count - 1;
   1634  1.1.1.2.4.2  tls 	  if (dyn_i->addend == addend)
   1635  1.1.1.2.4.2  tls 	    {
   1636  1.1.1.2.4.2  tls 	      return dyn_i;
   1637  1.1.1.2.4.2  tls 	    }
   1638  1.1.1.2.4.2  tls 	}
   1639  1.1.1.2.4.2  tls 
   1640  1.1.1.2.4.2  tls       if (size == 0)
   1641  1.1.1.2.4.2  tls 	{
   1642  1.1.1.2.4.2  tls 	  /* It is the very first element. We create the array of size
   1643  1.1.1.2.4.2  tls 	     1.  */
   1644  1.1.1.2.4.2  tls 	  size = 1;
   1645  1.1.1.2.4.2  tls 	  amt = size * sizeof (*info);
   1646  1.1.1.2.4.2  tls 	  info = bfd_malloc (amt);
   1647  1.1.1.2.4.2  tls 	}
   1648  1.1.1.2.4.2  tls       else if (size <= count)
   1649  1.1.1.2.4.2  tls 	{
   1650  1.1.1.2.4.2  tls 	  /* We double the array size every time when we reach the
   1651  1.1.1.2.4.2  tls 	     size limit.  */
   1652  1.1.1.2.4.2  tls 	  size += size;
   1653  1.1.1.2.4.2  tls 	  amt = size * sizeof (*info);
   1654  1.1.1.2.4.2  tls 	  info = bfd_realloc (info, amt);
   1655  1.1.1.2.4.2  tls 	}
   1656  1.1.1.2.4.2  tls       else
   1657  1.1.1.2.4.2  tls 	goto has_space;
   1658  1.1.1.2.4.2  tls 
   1659  1.1.1.2.4.2  tls       if (info == NULL)
   1660  1.1.1.2.4.2  tls 	return NULL;
   1661  1.1.1.2.4.2  tls       *size_p = size;
   1662  1.1.1.2.4.2  tls       *info_p = info;
   1663  1.1.1.2.4.2  tls 
   1664  1.1.1.2.4.2  tls has_space:
   1665  1.1.1.2.4.2  tls       /* Append the new one to the array.  */
   1666  1.1.1.2.4.2  tls       dyn_i = info + count;
   1667  1.1.1.2.4.2  tls       memset (dyn_i, 0, sizeof (*dyn_i));
   1668  1.1.1.2.4.2  tls       dyn_i->got_offset = (bfd_vma) -1;
   1669  1.1.1.2.4.2  tls       dyn_i->addend = addend;
   1670  1.1.1.2.4.2  tls 
   1671  1.1.1.2.4.2  tls       /* We increment count only since the new ones are unsorted and
   1672  1.1.1.2.4.2  tls 	 may have duplicate.  */
   1673  1.1.1.2.4.2  tls       (*count_p)++;
   1674  1.1.1.2.4.2  tls     }
   1675  1.1.1.2.4.2  tls   else
   1676  1.1.1.2.4.2  tls     {
   1677  1.1.1.2.4.2  tls       /* It is a lookup without insertion.  Sort array if part of the
   1678  1.1.1.2.4.2  tls 	 array isn't sorted.  */
   1679  1.1.1.2.4.2  tls       if (count != sorted_count)
   1680  1.1.1.2.4.2  tls 	{
   1681  1.1.1.2.4.2  tls 	  count = sort_dyn_sym_info (info, count);
   1682  1.1.1.2.4.2  tls 	  *count_p = count;
   1683  1.1.1.2.4.2  tls 	  *sorted_count_p = count;
   1684  1.1.1.2.4.2  tls 	}
   1685  1.1.1.2.4.2  tls 
   1686  1.1.1.2.4.2  tls       /* Free unused memory.  */
   1687  1.1.1.2.4.2  tls       if (size != count)
   1688  1.1.1.2.4.2  tls 	{
   1689  1.1.1.2.4.2  tls 	  amt = count * sizeof (*info);
   1690  1.1.1.2.4.2  tls 	  info = bfd_malloc (amt);
   1691  1.1.1.2.4.2  tls 	  if (info != NULL)
   1692  1.1.1.2.4.2  tls 	    {
   1693  1.1.1.2.4.2  tls 	      memcpy (info, *info_p, amt);
   1694  1.1.1.2.4.2  tls 	      free (*info_p);
   1695  1.1.1.2.4.2  tls 	      *size_p = count;
   1696  1.1.1.2.4.2  tls 	      *info_p = info;
   1697  1.1.1.2.4.2  tls 	    }
   1698  1.1.1.2.4.2  tls 	}
   1699  1.1.1.2.4.2  tls 
   1700  1.1.1.2.4.2  tls       key.addend = addend;
   1701  1.1.1.2.4.2  tls       dyn_i = bsearch (&key, info, count,
   1702  1.1.1.2.4.2  tls 		       sizeof (*info), addend_compare);
   1703  1.1.1.2.4.2  tls     }
   1704  1.1.1.2.4.2  tls 
   1705  1.1.1.2.4.2  tls   return dyn_i;
   1706  1.1.1.2.4.2  tls }
   1707  1.1.1.2.4.2  tls 
   1708  1.1.1.2.4.2  tls static asection *
   1709  1.1.1.2.4.2  tls get_got (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
   1710  1.1.1.2.4.2  tls {
   1711  1.1.1.2.4.2  tls   asection *got;
   1712  1.1.1.2.4.2  tls   bfd *dynobj;
   1713  1.1.1.2.4.2  tls 
   1714  1.1.1.2.4.2  tls   got = ia64_info->root.sgot;
   1715  1.1.1.2.4.2  tls   if (!got)
   1716  1.1.1.2.4.2  tls     {
   1717  1.1.1.2.4.2  tls       flagword flags;
   1718  1.1.1.2.4.2  tls 
   1719  1.1.1.2.4.2  tls       dynobj = ia64_info->root.dynobj;
   1720  1.1.1.2.4.2  tls       if (!dynobj)
   1721  1.1.1.2.4.2  tls 	ia64_info->root.dynobj = dynobj = abfd;
   1722  1.1.1.2.4.2  tls 
   1723  1.1.1.2.4.2  tls       /* The .got section is always aligned at 8 bytes.  */
   1724  1.1.1.2.4.2  tls       flags = get_elf_backend_data (dynobj)->dynamic_sec_flags;
   1725  1.1.1.2.4.2  tls       got = bfd_make_section_anyway_with_flags (dynobj, ".got",
   1726  1.1.1.2.4.2  tls 						flags | SEC_SMALL_DATA);
   1727  1.1.1.2.4.2  tls       if (got == NULL
   1728  1.1.1.2.4.2  tls           || !bfd_set_section_alignment (dynobj, got, 3))
   1729  1.1.1.2.4.2  tls         return NULL;
   1730  1.1.1.2.4.2  tls       ia64_info->root.sgot = got;
   1731  1.1.1.2.4.2  tls     }
   1732  1.1.1.2.4.2  tls 
   1733  1.1.1.2.4.2  tls   return got;
   1734  1.1.1.2.4.2  tls }
   1735  1.1.1.2.4.2  tls 
   1736  1.1.1.2.4.2  tls /* Create function descriptor section (.opd).  This section is called .opd
   1737  1.1.1.2.4.2  tls    because it contains "official procedure descriptors".  The "official"
   1738  1.1.1.2.4.2  tls    refers to the fact that these descriptors are used when taking the address
   1739  1.1.1.2.4.2  tls    of a procedure, thus ensuring a unique address for each procedure.  */
   1740  1.1.1.2.4.2  tls 
   1741  1.1.1.2.4.2  tls static asection *
   1742  1.1.1.2.4.2  tls get_fptr (bfd *abfd, struct bfd_link_info *info,
   1743  1.1.1.2.4.2  tls 	  struct elf64_ia64_link_hash_table *ia64_info)
   1744  1.1.1.2.4.2  tls {
   1745  1.1.1.2.4.2  tls   asection *fptr;
   1746  1.1.1.2.4.2  tls   bfd *dynobj;
   1747  1.1.1.2.4.2  tls 
   1748  1.1.1.2.4.2  tls   fptr = ia64_info->fptr_sec;
   1749  1.1.1.2.4.2  tls   if (!fptr)
   1750  1.1.1.2.4.2  tls     {
   1751  1.1.1.2.4.2  tls       dynobj = ia64_info->root.dynobj;
   1752  1.1.1.2.4.2  tls       if (!dynobj)
   1753  1.1.1.2.4.2  tls 	ia64_info->root.dynobj = dynobj = abfd;
   1754  1.1.1.2.4.2  tls 
   1755  1.1.1.2.4.2  tls       fptr = bfd_make_section_anyway_with_flags (dynobj, ".opd",
   1756  1.1.1.2.4.2  tls 						 (SEC_ALLOC
   1757  1.1.1.2.4.2  tls 						  | SEC_LOAD
   1758  1.1.1.2.4.2  tls 						  | SEC_HAS_CONTENTS
   1759  1.1.1.2.4.2  tls 						  | SEC_IN_MEMORY
   1760  1.1.1.2.4.2  tls 						  | (info->pie ? 0
   1761  1.1.1.2.4.2  tls 						     : SEC_READONLY)
   1762  1.1.1.2.4.2  tls 						  | SEC_LINKER_CREATED));
   1763  1.1.1.2.4.2  tls       if (!fptr
   1764  1.1.1.2.4.2  tls 	  || !bfd_set_section_alignment (dynobj, fptr, 4))
   1765  1.1.1.2.4.2  tls 	{
   1766  1.1.1.2.4.2  tls 	  BFD_ASSERT (0);
   1767  1.1.1.2.4.2  tls 	  return NULL;
   1768  1.1.1.2.4.2  tls 	}
   1769  1.1.1.2.4.2  tls 
   1770  1.1.1.2.4.2  tls       ia64_info->fptr_sec = fptr;
   1771  1.1.1.2.4.2  tls 
   1772  1.1.1.2.4.2  tls       if (info->pie)
   1773  1.1.1.2.4.2  tls 	{
   1774  1.1.1.2.4.2  tls 	  asection *fptr_rel;
   1775  1.1.1.2.4.2  tls 	  fptr_rel = bfd_make_section_anyway_with_flags (dynobj, ".rela.opd",
   1776  1.1.1.2.4.2  tls 							 (SEC_ALLOC | SEC_LOAD
   1777  1.1.1.2.4.2  tls 							  | SEC_HAS_CONTENTS
   1778  1.1.1.2.4.2  tls 							  | SEC_IN_MEMORY
   1779  1.1.1.2.4.2  tls 							  | SEC_LINKER_CREATED
   1780  1.1.1.2.4.2  tls 							  | SEC_READONLY));
   1781  1.1.1.2.4.2  tls 	  if (fptr_rel == NULL
   1782  1.1.1.2.4.2  tls 	      || !bfd_set_section_alignment (dynobj, fptr_rel, 3))
   1783  1.1.1.2.4.2  tls 	    {
   1784  1.1.1.2.4.2  tls 	      BFD_ASSERT (0);
   1785  1.1.1.2.4.2  tls 	      return NULL;
   1786  1.1.1.2.4.2  tls 	    }
   1787  1.1.1.2.4.2  tls 
   1788  1.1.1.2.4.2  tls 	  ia64_info->rel_fptr_sec = fptr_rel;
   1789  1.1.1.2.4.2  tls 	}
   1790  1.1.1.2.4.2  tls     }
   1791  1.1.1.2.4.2  tls 
   1792  1.1.1.2.4.2  tls   return fptr;
   1793  1.1.1.2.4.2  tls }
   1794  1.1.1.2.4.2  tls 
   1795  1.1.1.2.4.2  tls static asection *
   1796  1.1.1.2.4.2  tls get_pltoff (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
   1797  1.1.1.2.4.2  tls {
   1798  1.1.1.2.4.2  tls   asection *pltoff;
   1799  1.1.1.2.4.2  tls   bfd *dynobj;
   1800  1.1.1.2.4.2  tls 
   1801  1.1.1.2.4.2  tls   pltoff = ia64_info->pltoff_sec;
   1802  1.1.1.2.4.2  tls   if (!pltoff)
   1803  1.1.1.2.4.2  tls     {
   1804  1.1.1.2.4.2  tls       dynobj = ia64_info->root.dynobj;
   1805  1.1.1.2.4.2  tls       if (!dynobj)
   1806  1.1.1.2.4.2  tls 	ia64_info->root.dynobj = dynobj = abfd;
   1807  1.1.1.2.4.2  tls 
   1808  1.1.1.2.4.2  tls       pltoff = bfd_make_section_anyway_with_flags (dynobj,
   1809  1.1.1.2.4.2  tls 						   ELF_STRING_ia64_pltoff,
   1810  1.1.1.2.4.2  tls 						   (SEC_ALLOC
   1811  1.1.1.2.4.2  tls 						    | SEC_LOAD
   1812  1.1.1.2.4.2  tls 						    | SEC_HAS_CONTENTS
   1813  1.1.1.2.4.2  tls 						    | SEC_IN_MEMORY
   1814  1.1.1.2.4.2  tls 						    | SEC_SMALL_DATA
   1815  1.1.1.2.4.2  tls 						    | SEC_LINKER_CREATED));
   1816  1.1.1.2.4.2  tls       if (!pltoff
   1817  1.1.1.2.4.2  tls 	  || !bfd_set_section_alignment (dynobj, pltoff, 4))
   1818  1.1.1.2.4.2  tls 	{
   1819  1.1.1.2.4.2  tls 	  BFD_ASSERT (0);
   1820  1.1.1.2.4.2  tls 	  return NULL;
   1821  1.1.1.2.4.2  tls 	}
   1822  1.1.1.2.4.2  tls 
   1823  1.1.1.2.4.2  tls       ia64_info->pltoff_sec = pltoff;
   1824  1.1.1.2.4.2  tls     }
   1825  1.1.1.2.4.2  tls 
   1826  1.1.1.2.4.2  tls   return pltoff;
   1827  1.1.1.2.4.2  tls }
   1828  1.1.1.2.4.2  tls 
   1829  1.1.1.2.4.2  tls static asection *
   1830  1.1.1.2.4.2  tls get_reloc_section (bfd *abfd,
   1831  1.1.1.2.4.2  tls 		   struct elf64_ia64_link_hash_table *ia64_info,
   1832  1.1.1.2.4.2  tls 		   asection *sec, bfd_boolean create)
   1833  1.1.1.2.4.2  tls {
   1834  1.1.1.2.4.2  tls   const char *srel_name;
   1835  1.1.1.2.4.2  tls   asection *srel;
   1836  1.1.1.2.4.2  tls   bfd *dynobj;
   1837  1.1.1.2.4.2  tls 
   1838  1.1.1.2.4.2  tls   srel_name = (bfd_elf_string_from_elf_section
   1839  1.1.1.2.4.2  tls 	       (abfd, elf_elfheader(abfd)->e_shstrndx,
   1840  1.1.1.2.4.2  tls 		_bfd_elf_single_rel_hdr (sec)->sh_name));
   1841  1.1.1.2.4.2  tls   if (srel_name == NULL)
   1842  1.1.1.2.4.2  tls     return NULL;
   1843  1.1.1.2.4.2  tls 
   1844  1.1.1.2.4.2  tls   BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela")
   1845  1.1.1.2.4.2  tls 	       && strcmp (bfd_get_section_name (abfd, sec),
   1846  1.1.1.2.4.2  tls 			  srel_name+5) == 0)
   1847  1.1.1.2.4.2  tls 	      || (CONST_STRNEQ (srel_name, ".rel")
   1848  1.1.1.2.4.2  tls 		  && strcmp (bfd_get_section_name (abfd, sec),
   1849  1.1.1.2.4.2  tls 			     srel_name+4) == 0));
   1850  1.1.1.2.4.2  tls 
   1851  1.1.1.2.4.2  tls   dynobj = ia64_info->root.dynobj;
   1852  1.1.1.2.4.2  tls   if (!dynobj)
   1853  1.1.1.2.4.2  tls     ia64_info->root.dynobj = dynobj = abfd;
   1854  1.1.1.2.4.2  tls 
   1855  1.1.1.2.4.2  tls   srel = bfd_get_linker_section (dynobj, srel_name);
   1856  1.1.1.2.4.2  tls   if (srel == NULL && create)
   1857  1.1.1.2.4.2  tls     {
   1858  1.1.1.2.4.2  tls       srel = bfd_make_section_anyway_with_flags (dynobj, srel_name,
   1859  1.1.1.2.4.2  tls 						 (SEC_ALLOC | SEC_LOAD
   1860  1.1.1.2.4.2  tls 						  | SEC_HAS_CONTENTS
   1861  1.1.1.2.4.2  tls 						  | SEC_IN_MEMORY
   1862  1.1.1.2.4.2  tls 						  | SEC_LINKER_CREATED
   1863  1.1.1.2.4.2  tls 						  | SEC_READONLY));
   1864  1.1.1.2.4.2  tls       if (srel == NULL
   1865  1.1.1.2.4.2  tls 	  || !bfd_set_section_alignment (dynobj, srel, 3))
   1866  1.1.1.2.4.2  tls 	return NULL;
   1867  1.1.1.2.4.2  tls     }
   1868  1.1.1.2.4.2  tls 
   1869  1.1.1.2.4.2  tls   return srel;
   1870  1.1.1.2.4.2  tls }
   1871  1.1.1.2.4.2  tls 
   1872  1.1.1.2.4.2  tls static bfd_boolean
   1873  1.1.1.2.4.2  tls count_dyn_reloc (bfd *abfd, struct elf64_ia64_dyn_sym_info *dyn_i,
   1874  1.1.1.2.4.2  tls 		 asection *srel, int type)
   1875  1.1.1.2.4.2  tls {
   1876  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_reloc_entry *rent;
   1877  1.1.1.2.4.2  tls 
   1878  1.1.1.2.4.2  tls   for (rent = dyn_i->reloc_entries; rent; rent = rent->next)
   1879  1.1.1.2.4.2  tls     if (rent->srel == srel && rent->type == type)
   1880  1.1.1.2.4.2  tls       break;
   1881  1.1.1.2.4.2  tls 
   1882  1.1.1.2.4.2  tls   if (!rent)
   1883  1.1.1.2.4.2  tls     {
   1884  1.1.1.2.4.2  tls       rent = ((struct elf64_ia64_dyn_reloc_entry *)
   1885  1.1.1.2.4.2  tls 	      bfd_alloc (abfd, (bfd_size_type) sizeof (*rent)));
   1886  1.1.1.2.4.2  tls       if (!rent)
   1887  1.1.1.2.4.2  tls 	return FALSE;
   1888  1.1.1.2.4.2  tls 
   1889  1.1.1.2.4.2  tls       rent->next = dyn_i->reloc_entries;
   1890  1.1.1.2.4.2  tls       rent->srel = srel;
   1891  1.1.1.2.4.2  tls       rent->type = type;
   1892  1.1.1.2.4.2  tls       rent->count = 0;
   1893  1.1.1.2.4.2  tls       dyn_i->reloc_entries = rent;
   1894  1.1.1.2.4.2  tls     }
   1895  1.1.1.2.4.2  tls   rent->count++;
   1896  1.1.1.2.4.2  tls 
   1897  1.1.1.2.4.2  tls   return TRUE;
   1898  1.1.1.2.4.2  tls }
   1899  1.1.1.2.4.2  tls 
   1900  1.1.1.2.4.2  tls static bfd_boolean
   1901  1.1.1.2.4.2  tls elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
   1902  1.1.1.2.4.2  tls 			 asection *sec,
   1903  1.1.1.2.4.2  tls 			 const Elf_Internal_Rela *relocs)
   1904  1.1.1.2.4.2  tls {
   1905  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   1906  1.1.1.2.4.2  tls   const Elf_Internal_Rela *relend;
   1907  1.1.1.2.4.2  tls   Elf_Internal_Shdr *symtab_hdr;
   1908  1.1.1.2.4.2  tls   const Elf_Internal_Rela *rel;
   1909  1.1.1.2.4.2  tls   asection *got, *fptr, *srel, *pltoff;
   1910  1.1.1.2.4.2  tls   enum {
   1911  1.1.1.2.4.2  tls     NEED_GOT = 1,
   1912  1.1.1.2.4.2  tls     NEED_GOTX = 2,
   1913  1.1.1.2.4.2  tls     NEED_FPTR = 4,
   1914  1.1.1.2.4.2  tls     NEED_PLTOFF = 8,
   1915  1.1.1.2.4.2  tls     NEED_MIN_PLT = 16,
   1916  1.1.1.2.4.2  tls     NEED_FULL_PLT = 32,
   1917  1.1.1.2.4.2  tls     NEED_DYNREL = 64,
   1918  1.1.1.2.4.2  tls     NEED_LTOFF_FPTR = 128
   1919  1.1.1.2.4.2  tls   };
   1920  1.1.1.2.4.2  tls   int need_entry;
   1921  1.1.1.2.4.2  tls   struct elf_link_hash_entry *h;
   1922  1.1.1.2.4.2  tls   unsigned long r_symndx;
   1923  1.1.1.2.4.2  tls   bfd_boolean maybe_dynamic;
   1924  1.1.1.2.4.2  tls 
   1925  1.1.1.2.4.2  tls   if (info->relocatable)
   1926  1.1.1.2.4.2  tls     return TRUE;
   1927  1.1.1.2.4.2  tls 
   1928  1.1.1.2.4.2  tls   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   1929  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   1930  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   1931  1.1.1.2.4.2  tls     return FALSE;
   1932  1.1.1.2.4.2  tls 
   1933  1.1.1.2.4.2  tls   got = fptr = srel = pltoff = NULL;
   1934  1.1.1.2.4.2  tls 
   1935  1.1.1.2.4.2  tls   relend = relocs + sec->reloc_count;
   1936  1.1.1.2.4.2  tls 
   1937  1.1.1.2.4.2  tls   /* We scan relocations first to create dynamic relocation arrays.  We
   1938  1.1.1.2.4.2  tls      modified get_dyn_sym_info to allow fast insertion and support fast
   1939  1.1.1.2.4.2  tls      lookup in the next loop.  */
   1940  1.1.1.2.4.2  tls   for (rel = relocs; rel < relend; ++rel)
   1941  1.1.1.2.4.2  tls     {
   1942  1.1.1.2.4.2  tls       r_symndx = ELF64_R_SYM (rel->r_info);
   1943  1.1.1.2.4.2  tls       if (r_symndx >= symtab_hdr->sh_info)
   1944  1.1.1.2.4.2  tls 	{
   1945  1.1.1.2.4.2  tls 	  long indx = r_symndx - symtab_hdr->sh_info;
   1946  1.1.1.2.4.2  tls 	  h = elf_sym_hashes (abfd)[indx];
   1947  1.1.1.2.4.2  tls 	  while (h->root.type == bfd_link_hash_indirect
   1948  1.1.1.2.4.2  tls 		 || h->root.type == bfd_link_hash_warning)
   1949  1.1.1.2.4.2  tls 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
   1950  1.1.1.2.4.2  tls 	}
   1951  1.1.1.2.4.2  tls       else
   1952  1.1.1.2.4.2  tls 	h = NULL;
   1953  1.1.1.2.4.2  tls 
   1954  1.1.1.2.4.2  tls       /* We can only get preliminary data on whether a symbol is
   1955  1.1.1.2.4.2  tls 	 locally or externally defined, as not all of the input files
   1956  1.1.1.2.4.2  tls 	 have yet been processed.  Do something with what we know, as
   1957  1.1.1.2.4.2  tls 	 this may help reduce memory usage and processing time later.  */
   1958  1.1.1.2.4.2  tls       maybe_dynamic = (h && ((!info->executable
   1959  1.1.1.2.4.2  tls 			      && (!SYMBOLIC_BIND (info, h)
   1960  1.1.1.2.4.2  tls 				  || info->unresolved_syms_in_shared_libs == RM_IGNORE))
   1961  1.1.1.2.4.2  tls 			     || !h->def_regular
   1962  1.1.1.2.4.2  tls 			     || h->root.type == bfd_link_hash_defweak));
   1963  1.1.1.2.4.2  tls 
   1964  1.1.1.2.4.2  tls       need_entry = 0;
   1965  1.1.1.2.4.2  tls       switch (ELF64_R_TYPE (rel->r_info))
   1966  1.1.1.2.4.2  tls 	{
   1967  1.1.1.2.4.2  tls 	case R_IA64_TPREL64MSB:
   1968  1.1.1.2.4.2  tls 	case R_IA64_TPREL64LSB:
   1969  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_TPREL22:
   1970  1.1.1.2.4.2  tls 	case R_IA64_DTPREL32MSB:
   1971  1.1.1.2.4.2  tls 	case R_IA64_DTPREL32LSB:
   1972  1.1.1.2.4.2  tls 	case R_IA64_DTPREL64MSB:
   1973  1.1.1.2.4.2  tls 	case R_IA64_DTPREL64LSB:
   1974  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_DTPREL22:
   1975  1.1.1.2.4.2  tls 	case R_IA64_DTPMOD64MSB:
   1976  1.1.1.2.4.2  tls 	case R_IA64_DTPMOD64LSB:
   1977  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_DTPMOD22:
   1978  1.1.1.2.4.2  tls           abort ();
   1979  1.1.1.2.4.2  tls 	  break;
   1980  1.1.1.2.4.2  tls 
   1981  1.1.1.2.4.2  tls 	case R_IA64_IPLTMSB:
   1982  1.1.1.2.4.2  tls 	case R_IA64_IPLTLSB:
   1983  1.1.1.2.4.2  tls           break;
   1984  1.1.1.2.4.2  tls 
   1985  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR22:
   1986  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR64I:
   1987  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR32MSB:
   1988  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR32LSB:
   1989  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR64MSB:
   1990  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR64LSB:
   1991  1.1.1.2.4.2  tls 	  need_entry = NEED_FPTR | NEED_GOT | NEED_LTOFF_FPTR;
   1992  1.1.1.2.4.2  tls 	  break;
   1993  1.1.1.2.4.2  tls 
   1994  1.1.1.2.4.2  tls 	case R_IA64_FPTR64I:
   1995  1.1.1.2.4.2  tls 	case R_IA64_FPTR32MSB:
   1996  1.1.1.2.4.2  tls 	case R_IA64_FPTR32LSB:
   1997  1.1.1.2.4.2  tls 	case R_IA64_FPTR64MSB:
   1998  1.1.1.2.4.2  tls 	case R_IA64_FPTR64LSB:
   1999  1.1.1.2.4.2  tls 	  if (info->shared || h)
   2000  1.1.1.2.4.2  tls 	    need_entry = NEED_FPTR | NEED_DYNREL;
   2001  1.1.1.2.4.2  tls 	  else
   2002  1.1.1.2.4.2  tls 	    need_entry = NEED_FPTR;
   2003  1.1.1.2.4.2  tls 	  break;
   2004  1.1.1.2.4.2  tls 
   2005  1.1.1.2.4.2  tls 	case R_IA64_LTOFF22:
   2006  1.1.1.2.4.2  tls 	case R_IA64_LTOFF64I:
   2007  1.1.1.2.4.2  tls 	  need_entry = NEED_GOT;
   2008  1.1.1.2.4.2  tls 	  break;
   2009  1.1.1.2.4.2  tls 
   2010  1.1.1.2.4.2  tls 	case R_IA64_LTOFF22X:
   2011  1.1.1.2.4.2  tls 	  need_entry = NEED_GOTX;
   2012  1.1.1.2.4.2  tls 	  break;
   2013  1.1.1.2.4.2  tls 
   2014  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF22:
   2015  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF64I:
   2016  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF64MSB:
   2017  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF64LSB:
   2018  1.1.1.2.4.2  tls 	  need_entry = NEED_PLTOFF;
   2019  1.1.1.2.4.2  tls 	  if (h)
   2020  1.1.1.2.4.2  tls 	    {
   2021  1.1.1.2.4.2  tls 	      if (maybe_dynamic)
   2022  1.1.1.2.4.2  tls 		need_entry |= NEED_MIN_PLT;
   2023  1.1.1.2.4.2  tls 	    }
   2024  1.1.1.2.4.2  tls 	  else
   2025  1.1.1.2.4.2  tls 	    {
   2026  1.1.1.2.4.2  tls 	      (*info->callbacks->warning)
   2027  1.1.1.2.4.2  tls 		(info, _("@pltoff reloc against local symbol"), 0,
   2028  1.1.1.2.4.2  tls 		 abfd, 0, (bfd_vma) 0);
   2029  1.1.1.2.4.2  tls 	    }
   2030  1.1.1.2.4.2  tls 	  break;
   2031  1.1.1.2.4.2  tls 
   2032  1.1.1.2.4.2  tls 	case R_IA64_PCREL21B:
   2033  1.1.1.2.4.2  tls         case R_IA64_PCREL60B:
   2034  1.1.1.2.4.2  tls 	  /* Depending on where this symbol is defined, we may or may not
   2035  1.1.1.2.4.2  tls 	     need a full plt entry.  Only skip if we know we'll not need
   2036  1.1.1.2.4.2  tls 	     the entry -- static or symbolic, and the symbol definition
   2037  1.1.1.2.4.2  tls 	     has already been seen.  */
   2038  1.1.1.2.4.2  tls 	  if (maybe_dynamic && rel->r_addend == 0)
   2039  1.1.1.2.4.2  tls 	    need_entry = NEED_FULL_PLT;
   2040  1.1.1.2.4.2  tls 	  break;
   2041  1.1.1.2.4.2  tls 
   2042  1.1.1.2.4.2  tls 	case R_IA64_IMM14:
   2043  1.1.1.2.4.2  tls 	case R_IA64_IMM22:
   2044  1.1.1.2.4.2  tls 	case R_IA64_IMM64:
   2045  1.1.1.2.4.2  tls 	case R_IA64_DIR32MSB:
   2046  1.1.1.2.4.2  tls 	case R_IA64_DIR32LSB:
   2047  1.1.1.2.4.2  tls 	case R_IA64_DIR64MSB:
   2048  1.1.1.2.4.2  tls 	case R_IA64_DIR64LSB:
   2049  1.1.1.2.4.2  tls 	  /* Shared objects will always need at least a REL relocation.  */
   2050  1.1.1.2.4.2  tls 	  if (info->shared || maybe_dynamic)
   2051  1.1.1.2.4.2  tls 	    need_entry = NEED_DYNREL;
   2052  1.1.1.2.4.2  tls 	  break;
   2053  1.1.1.2.4.2  tls 
   2054  1.1.1.2.4.2  tls 	case R_IA64_PCREL22:
   2055  1.1.1.2.4.2  tls 	case R_IA64_PCREL64I:
   2056  1.1.1.2.4.2  tls 	case R_IA64_PCREL32MSB:
   2057  1.1.1.2.4.2  tls 	case R_IA64_PCREL32LSB:
   2058  1.1.1.2.4.2  tls 	case R_IA64_PCREL64MSB:
   2059  1.1.1.2.4.2  tls 	case R_IA64_PCREL64LSB:
   2060  1.1.1.2.4.2  tls 	  if (maybe_dynamic)
   2061  1.1.1.2.4.2  tls 	    need_entry = NEED_DYNREL;
   2062  1.1.1.2.4.2  tls 	  break;
   2063  1.1.1.2.4.2  tls 	}
   2064  1.1.1.2.4.2  tls 
   2065  1.1.1.2.4.2  tls       if (!need_entry)
   2066  1.1.1.2.4.2  tls 	continue;
   2067  1.1.1.2.4.2  tls 
   2068  1.1.1.2.4.2  tls       if ((need_entry & NEED_FPTR) != 0
   2069  1.1.1.2.4.2  tls 	  && rel->r_addend)
   2070  1.1.1.2.4.2  tls 	{
   2071  1.1.1.2.4.2  tls 	  (*info->callbacks->warning)
   2072  1.1.1.2.4.2  tls 	    (info, _("non-zero addend in @fptr reloc"), 0,
   2073  1.1.1.2.4.2  tls 	     abfd, 0, (bfd_vma) 0);
   2074  1.1.1.2.4.2  tls 	}
   2075  1.1.1.2.4.2  tls 
   2076  1.1.1.2.4.2  tls       if (get_dyn_sym_info (ia64_info, h, abfd, rel, TRUE) == NULL)
   2077  1.1.1.2.4.2  tls 	return FALSE;
   2078  1.1.1.2.4.2  tls     }
   2079  1.1.1.2.4.2  tls 
   2080  1.1.1.2.4.2  tls   /* Now, we only do lookup without insertion, which is very fast
   2081  1.1.1.2.4.2  tls      with the modified get_dyn_sym_info.  */
   2082  1.1.1.2.4.2  tls   for (rel = relocs; rel < relend; ++rel)
   2083  1.1.1.2.4.2  tls     {
   2084  1.1.1.2.4.2  tls       struct elf64_ia64_dyn_sym_info *dyn_i;
   2085  1.1.1.2.4.2  tls       int dynrel_type = R_IA64_NONE;
   2086  1.1.1.2.4.2  tls 
   2087  1.1.1.2.4.2  tls       r_symndx = ELF64_R_SYM (rel->r_info);
   2088  1.1.1.2.4.2  tls       if (r_symndx >= symtab_hdr->sh_info)
   2089  1.1.1.2.4.2  tls 	{
   2090  1.1.1.2.4.2  tls 	  /* We're dealing with a global symbol -- find its hash entry
   2091  1.1.1.2.4.2  tls 	     and mark it as being referenced.  */
   2092  1.1.1.2.4.2  tls 	  long indx = r_symndx - symtab_hdr->sh_info;
   2093  1.1.1.2.4.2  tls 	  h = elf_sym_hashes (abfd)[indx];
   2094  1.1.1.2.4.2  tls 	  while (h->root.type == bfd_link_hash_indirect
   2095  1.1.1.2.4.2  tls 		 || h->root.type == bfd_link_hash_warning)
   2096  1.1.1.2.4.2  tls 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
   2097  1.1.1.2.4.2  tls 
   2098  1.1.1.2.4.2  tls 	  /* PR15323, ref flags aren't set for references in the same
   2099  1.1.1.2.4.2  tls 	     object.  */
   2100  1.1.1.2.4.2  tls 	  h->root.non_ir_ref = 1;
   2101  1.1.1.2.4.2  tls 	  h->ref_regular = 1;
   2102  1.1.1.2.4.2  tls 	}
   2103  1.1.1.2.4.2  tls       else
   2104  1.1.1.2.4.2  tls 	h = NULL;
   2105  1.1.1.2.4.2  tls 
   2106  1.1.1.2.4.2  tls       /* We can only get preliminary data on whether a symbol is
   2107  1.1.1.2.4.2  tls 	 locally or externally defined, as not all of the input files
   2108  1.1.1.2.4.2  tls 	 have yet been processed.  Do something with what we know, as
   2109  1.1.1.2.4.2  tls 	 this may help reduce memory usage and processing time later.  */
   2110  1.1.1.2.4.2  tls       maybe_dynamic = (h && ((!info->executable
   2111  1.1.1.2.4.2  tls 			      && (!SYMBOLIC_BIND (info, h)
   2112  1.1.1.2.4.2  tls 				  || info->unresolved_syms_in_shared_libs == RM_IGNORE))
   2113  1.1.1.2.4.2  tls 			     || !h->def_regular
   2114  1.1.1.2.4.2  tls 			     || h->root.type == bfd_link_hash_defweak));
   2115  1.1.1.2.4.2  tls 
   2116  1.1.1.2.4.2  tls       need_entry = 0;
   2117  1.1.1.2.4.2  tls       switch (ELF64_R_TYPE (rel->r_info))
   2118  1.1.1.2.4.2  tls 	{
   2119  1.1.1.2.4.2  tls 	case R_IA64_TPREL64MSB:
   2120  1.1.1.2.4.2  tls 	case R_IA64_TPREL64LSB:
   2121  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_TPREL22:
   2122  1.1.1.2.4.2  tls 	case R_IA64_DTPREL32MSB:
   2123  1.1.1.2.4.2  tls 	case R_IA64_DTPREL32LSB:
   2124  1.1.1.2.4.2  tls 	case R_IA64_DTPREL64MSB:
   2125  1.1.1.2.4.2  tls 	case R_IA64_DTPREL64LSB:
   2126  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_DTPREL22:
   2127  1.1.1.2.4.2  tls 	case R_IA64_DTPMOD64MSB:
   2128  1.1.1.2.4.2  tls 	case R_IA64_DTPMOD64LSB:
   2129  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_DTPMOD22:
   2130  1.1.1.2.4.2  tls           abort ();
   2131  1.1.1.2.4.2  tls 	  break;
   2132  1.1.1.2.4.2  tls 
   2133  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR22:
   2134  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR64I:
   2135  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR32MSB:
   2136  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR32LSB:
   2137  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR64MSB:
   2138  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR64LSB:
   2139  1.1.1.2.4.2  tls 	  need_entry = NEED_FPTR | NEED_GOT | NEED_LTOFF_FPTR;
   2140  1.1.1.2.4.2  tls 	  break;
   2141  1.1.1.2.4.2  tls 
   2142  1.1.1.2.4.2  tls 	case R_IA64_FPTR64I:
   2143  1.1.1.2.4.2  tls 	case R_IA64_FPTR32MSB:
   2144  1.1.1.2.4.2  tls 	case R_IA64_FPTR32LSB:
   2145  1.1.1.2.4.2  tls 	case R_IA64_FPTR64MSB:
   2146  1.1.1.2.4.2  tls 	case R_IA64_FPTR64LSB:
   2147  1.1.1.2.4.2  tls 	  if (info->shared || h)
   2148  1.1.1.2.4.2  tls 	    need_entry = NEED_FPTR | NEED_DYNREL;
   2149  1.1.1.2.4.2  tls 	  else
   2150  1.1.1.2.4.2  tls 	    need_entry = NEED_FPTR;
   2151  1.1.1.2.4.2  tls 	  dynrel_type = R_IA64_FPTR64LSB;
   2152  1.1.1.2.4.2  tls 	  break;
   2153  1.1.1.2.4.2  tls 
   2154  1.1.1.2.4.2  tls 	case R_IA64_LTOFF22:
   2155  1.1.1.2.4.2  tls 	case R_IA64_LTOFF64I:
   2156  1.1.1.2.4.2  tls 	  need_entry = NEED_GOT;
   2157  1.1.1.2.4.2  tls 	  break;
   2158  1.1.1.2.4.2  tls 
   2159  1.1.1.2.4.2  tls 	case R_IA64_LTOFF22X:
   2160  1.1.1.2.4.2  tls 	  need_entry = NEED_GOTX;
   2161  1.1.1.2.4.2  tls 	  break;
   2162  1.1.1.2.4.2  tls 
   2163  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF22:
   2164  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF64I:
   2165  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF64MSB:
   2166  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF64LSB:
   2167  1.1.1.2.4.2  tls 	  need_entry = NEED_PLTOFF;
   2168  1.1.1.2.4.2  tls 	  if (h)
   2169  1.1.1.2.4.2  tls 	    {
   2170  1.1.1.2.4.2  tls 	      if (maybe_dynamic)
   2171  1.1.1.2.4.2  tls 		need_entry |= NEED_MIN_PLT;
   2172  1.1.1.2.4.2  tls 	    }
   2173  1.1.1.2.4.2  tls 	  break;
   2174  1.1.1.2.4.2  tls 
   2175  1.1.1.2.4.2  tls 	case R_IA64_PCREL21B:
   2176  1.1.1.2.4.2  tls         case R_IA64_PCREL60B:
   2177  1.1.1.2.4.2  tls 	  /* Depending on where this symbol is defined, we may or may not
   2178  1.1.1.2.4.2  tls 	     need a full plt entry.  Only skip if we know we'll not need
   2179  1.1.1.2.4.2  tls 	     the entry -- static or symbolic, and the symbol definition
   2180  1.1.1.2.4.2  tls 	     has already been seen.  */
   2181  1.1.1.2.4.2  tls 	  if (maybe_dynamic && rel->r_addend == 0)
   2182  1.1.1.2.4.2  tls 	    need_entry = NEED_FULL_PLT;
   2183  1.1.1.2.4.2  tls 	  break;
   2184  1.1.1.2.4.2  tls 
   2185  1.1.1.2.4.2  tls 	case R_IA64_IMM14:
   2186  1.1.1.2.4.2  tls 	case R_IA64_IMM22:
   2187  1.1.1.2.4.2  tls 	case R_IA64_IMM64:
   2188  1.1.1.2.4.2  tls 	case R_IA64_DIR32MSB:
   2189  1.1.1.2.4.2  tls 	case R_IA64_DIR32LSB:
   2190  1.1.1.2.4.2  tls 	case R_IA64_DIR64MSB:
   2191  1.1.1.2.4.2  tls 	case R_IA64_DIR64LSB:
   2192  1.1.1.2.4.2  tls 	  /* Shared objects will always need at least a REL relocation.  */
   2193  1.1.1.2.4.2  tls 	  if (info->shared || maybe_dynamic)
   2194  1.1.1.2.4.2  tls 	    need_entry = NEED_DYNREL;
   2195  1.1.1.2.4.2  tls 	  dynrel_type = R_IA64_DIR64LSB;
   2196  1.1.1.2.4.2  tls 	  break;
   2197  1.1.1.2.4.2  tls 
   2198  1.1.1.2.4.2  tls 	case R_IA64_IPLTMSB:
   2199  1.1.1.2.4.2  tls 	case R_IA64_IPLTLSB:
   2200  1.1.1.2.4.2  tls 	  break;
   2201  1.1.1.2.4.2  tls 
   2202  1.1.1.2.4.2  tls 	case R_IA64_PCREL22:
   2203  1.1.1.2.4.2  tls 	case R_IA64_PCREL64I:
   2204  1.1.1.2.4.2  tls 	case R_IA64_PCREL32MSB:
   2205  1.1.1.2.4.2  tls 	case R_IA64_PCREL32LSB:
   2206  1.1.1.2.4.2  tls 	case R_IA64_PCREL64MSB:
   2207  1.1.1.2.4.2  tls 	case R_IA64_PCREL64LSB:
   2208  1.1.1.2.4.2  tls 	  if (maybe_dynamic)
   2209  1.1.1.2.4.2  tls 	    need_entry = NEED_DYNREL;
   2210  1.1.1.2.4.2  tls 	  dynrel_type = R_IA64_PCREL64LSB;
   2211  1.1.1.2.4.2  tls 	  break;
   2212  1.1.1.2.4.2  tls 	}
   2213  1.1.1.2.4.2  tls 
   2214  1.1.1.2.4.2  tls       if (!need_entry)
   2215  1.1.1.2.4.2  tls 	continue;
   2216  1.1.1.2.4.2  tls 
   2217  1.1.1.2.4.2  tls       dyn_i = get_dyn_sym_info (ia64_info, h, abfd, rel, FALSE);
   2218  1.1.1.2.4.2  tls 
   2219  1.1.1.2.4.2  tls       /* Record whether or not this is a local symbol.  */
   2220  1.1.1.2.4.2  tls       dyn_i->h = h;
   2221  1.1.1.2.4.2  tls 
   2222  1.1.1.2.4.2  tls       /* Create what's needed.  */
   2223  1.1.1.2.4.2  tls       if (need_entry & (NEED_GOT | NEED_GOTX))
   2224  1.1.1.2.4.2  tls 	{
   2225  1.1.1.2.4.2  tls 	  if (!got)
   2226  1.1.1.2.4.2  tls 	    {
   2227  1.1.1.2.4.2  tls 	      got = get_got (abfd, ia64_info);
   2228  1.1.1.2.4.2  tls 	      if (!got)
   2229  1.1.1.2.4.2  tls 		return FALSE;
   2230  1.1.1.2.4.2  tls 	    }
   2231  1.1.1.2.4.2  tls 	  if (need_entry & NEED_GOT)
   2232  1.1.1.2.4.2  tls 	    dyn_i->want_got = 1;
   2233  1.1.1.2.4.2  tls 	  if (need_entry & NEED_GOTX)
   2234  1.1.1.2.4.2  tls 	    dyn_i->want_gotx = 1;
   2235  1.1.1.2.4.2  tls 	}
   2236  1.1.1.2.4.2  tls       if (need_entry & NEED_FPTR)
   2237  1.1.1.2.4.2  tls 	{
   2238  1.1.1.2.4.2  tls           /* Create the .opd section.  */
   2239  1.1.1.2.4.2  tls 	  if (!fptr)
   2240  1.1.1.2.4.2  tls 	    {
   2241  1.1.1.2.4.2  tls 	      fptr = get_fptr (abfd, info, ia64_info);
   2242  1.1.1.2.4.2  tls 	      if (!fptr)
   2243  1.1.1.2.4.2  tls 		return FALSE;
   2244  1.1.1.2.4.2  tls 	    }
   2245  1.1.1.2.4.2  tls 	  dyn_i->want_fptr = 1;
   2246  1.1.1.2.4.2  tls 	}
   2247  1.1.1.2.4.2  tls       if (need_entry & NEED_LTOFF_FPTR)
   2248  1.1.1.2.4.2  tls 	dyn_i->want_ltoff_fptr = 1;
   2249  1.1.1.2.4.2  tls       if (need_entry & (NEED_MIN_PLT | NEED_FULL_PLT))
   2250  1.1.1.2.4.2  tls 	{
   2251  1.1.1.2.4.2  tls           if (!ia64_info->root.dynobj)
   2252  1.1.1.2.4.2  tls 	    ia64_info->root.dynobj = abfd;
   2253  1.1.1.2.4.2  tls 	  h->needs_plt = 1;
   2254  1.1.1.2.4.2  tls 	  dyn_i->want_plt = 1;
   2255  1.1.1.2.4.2  tls 	}
   2256  1.1.1.2.4.2  tls       if (need_entry & NEED_FULL_PLT)
   2257  1.1.1.2.4.2  tls 	dyn_i->want_plt2 = 1;
   2258  1.1.1.2.4.2  tls       if (need_entry & NEED_PLTOFF)
   2259  1.1.1.2.4.2  tls 	{
   2260  1.1.1.2.4.2  tls 	  /* This is needed here, in case @pltoff is used in a non-shared
   2261  1.1.1.2.4.2  tls 	     link.  */
   2262  1.1.1.2.4.2  tls 	  if (!pltoff)
   2263  1.1.1.2.4.2  tls 	    {
   2264  1.1.1.2.4.2  tls 	      pltoff = get_pltoff (abfd, ia64_info);
   2265  1.1.1.2.4.2  tls 	      if (!pltoff)
   2266  1.1.1.2.4.2  tls 		return FALSE;
   2267  1.1.1.2.4.2  tls 	    }
   2268  1.1.1.2.4.2  tls 
   2269  1.1.1.2.4.2  tls 	  dyn_i->want_pltoff = 1;
   2270  1.1.1.2.4.2  tls 	}
   2271  1.1.1.2.4.2  tls       if ((need_entry & NEED_DYNREL) && (sec->flags & SEC_ALLOC))
   2272  1.1.1.2.4.2  tls 	{
   2273  1.1.1.2.4.2  tls 	  if (!srel)
   2274  1.1.1.2.4.2  tls 	    {
   2275  1.1.1.2.4.2  tls 	      srel = get_reloc_section (abfd, ia64_info, sec, TRUE);
   2276  1.1.1.2.4.2  tls 	      if (!srel)
   2277  1.1.1.2.4.2  tls 		return FALSE;
   2278  1.1.1.2.4.2  tls 	    }
   2279  1.1.1.2.4.2  tls 	  if (!count_dyn_reloc (abfd, dyn_i, srel, dynrel_type))
   2280  1.1.1.2.4.2  tls 	    return FALSE;
   2281  1.1.1.2.4.2  tls 	}
   2282  1.1.1.2.4.2  tls     }
   2283  1.1.1.2.4.2  tls 
   2284  1.1.1.2.4.2  tls   return TRUE;
   2285  1.1.1.2.4.2  tls }
   2286  1.1.1.2.4.2  tls 
   2287  1.1.1.2.4.2  tls /* For cleanliness, and potentially faster dynamic loading, allocate
   2288  1.1.1.2.4.2  tls    external GOT entries first.  */
   2289  1.1.1.2.4.2  tls 
   2290  1.1.1.2.4.2  tls static bfd_boolean
   2291  1.1.1.2.4.2  tls allocate_global_data_got (struct elf64_ia64_dyn_sym_info *dyn_i,
   2292  1.1.1.2.4.2  tls 			  void * data)
   2293  1.1.1.2.4.2  tls {
   2294  1.1.1.2.4.2  tls   struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
   2295  1.1.1.2.4.2  tls 
   2296  1.1.1.2.4.2  tls   if ((dyn_i->want_got || dyn_i->want_gotx)
   2297  1.1.1.2.4.2  tls       && ! dyn_i->want_fptr
   2298  1.1.1.2.4.2  tls       && elf64_ia64_dynamic_symbol_p (dyn_i->h))
   2299  1.1.1.2.4.2  tls      {
   2300  1.1.1.2.4.2  tls        /* GOT entry with FPTR is done by allocate_global_fptr_got.  */
   2301  1.1.1.2.4.2  tls        dyn_i->got_offset = x->ofs;
   2302  1.1.1.2.4.2  tls        x->ofs += 8;
   2303  1.1.1.2.4.2  tls      }
   2304  1.1.1.2.4.2  tls   return TRUE;
   2305  1.1.1.2.4.2  tls }
   2306  1.1.1.2.4.2  tls 
   2307  1.1.1.2.4.2  tls /* Next, allocate all the GOT entries used by LTOFF_FPTR relocs.  */
   2308  1.1.1.2.4.2  tls 
   2309  1.1.1.2.4.2  tls static bfd_boolean
   2310  1.1.1.2.4.2  tls allocate_global_fptr_got (struct elf64_ia64_dyn_sym_info *dyn_i,
   2311  1.1.1.2.4.2  tls 			  void * data)
   2312  1.1.1.2.4.2  tls {
   2313  1.1.1.2.4.2  tls   struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
   2314  1.1.1.2.4.2  tls 
   2315  1.1.1.2.4.2  tls   if (dyn_i->want_got
   2316  1.1.1.2.4.2  tls       && dyn_i->want_fptr
   2317  1.1.1.2.4.2  tls       && elf64_ia64_dynamic_symbol_p (dyn_i->h))
   2318  1.1.1.2.4.2  tls     {
   2319  1.1.1.2.4.2  tls       dyn_i->got_offset = x->ofs;
   2320  1.1.1.2.4.2  tls       x->ofs += 8;
   2321  1.1.1.2.4.2  tls     }
   2322  1.1.1.2.4.2  tls   return TRUE;
   2323  1.1.1.2.4.2  tls }
   2324  1.1.1.2.4.2  tls 
   2325  1.1.1.2.4.2  tls /* Lastly, allocate all the GOT entries for local data.  */
   2326  1.1.1.2.4.2  tls 
   2327  1.1.1.2.4.2  tls static bfd_boolean
   2328  1.1.1.2.4.2  tls allocate_local_got (struct elf64_ia64_dyn_sym_info *dyn_i,
   2329  1.1.1.2.4.2  tls 		    void * data)
   2330  1.1.1.2.4.2  tls {
   2331  1.1.1.2.4.2  tls   struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *) data;
   2332  1.1.1.2.4.2  tls 
   2333  1.1.1.2.4.2  tls   if ((dyn_i->want_got || dyn_i->want_gotx)
   2334  1.1.1.2.4.2  tls       && !elf64_ia64_dynamic_symbol_p (dyn_i->h))
   2335  1.1.1.2.4.2  tls     {
   2336  1.1.1.2.4.2  tls       dyn_i->got_offset = x->ofs;
   2337  1.1.1.2.4.2  tls       x->ofs += 8;
   2338  1.1.1.2.4.2  tls     }
   2339  1.1.1.2.4.2  tls   return TRUE;
   2340  1.1.1.2.4.2  tls }
   2341  1.1.1.2.4.2  tls 
   2342  1.1.1.2.4.2  tls /* Allocate function descriptors.  We can do these for every function
   2343  1.1.1.2.4.2  tls    in a main executable that is not exported.  */
   2344  1.1.1.2.4.2  tls 
   2345  1.1.1.2.4.2  tls static bfd_boolean
   2346  1.1.1.2.4.2  tls allocate_fptr (struct elf64_ia64_dyn_sym_info *dyn_i, void * data)
   2347  1.1.1.2.4.2  tls {
   2348  1.1.1.2.4.2  tls   struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *) data;
   2349  1.1.1.2.4.2  tls 
   2350  1.1.1.2.4.2  tls   if (dyn_i->want_fptr)
   2351  1.1.1.2.4.2  tls     {
   2352  1.1.1.2.4.2  tls       struct elf_link_hash_entry *h = dyn_i->h;
   2353  1.1.1.2.4.2  tls 
   2354  1.1.1.2.4.2  tls       if (h)
   2355  1.1.1.2.4.2  tls 	while (h->root.type == bfd_link_hash_indirect
   2356  1.1.1.2.4.2  tls 	       || h->root.type == bfd_link_hash_warning)
   2357  1.1.1.2.4.2  tls 	  h = (struct elf_link_hash_entry *) h->root.u.i.link;
   2358  1.1.1.2.4.2  tls 
   2359  1.1.1.2.4.2  tls       if (h == NULL || !h->def_dynamic)
   2360  1.1.1.2.4.2  tls 	{
   2361  1.1.1.2.4.2  tls           /*  A non dynamic symbol.  */
   2362  1.1.1.2.4.2  tls 	  dyn_i->fptr_offset = x->ofs;
   2363  1.1.1.2.4.2  tls 	  x->ofs += 16;
   2364  1.1.1.2.4.2  tls 	}
   2365  1.1.1.2.4.2  tls       else
   2366  1.1.1.2.4.2  tls 	dyn_i->want_fptr = 0;
   2367  1.1.1.2.4.2  tls     }
   2368  1.1.1.2.4.2  tls   return TRUE;
   2369  1.1.1.2.4.2  tls }
   2370  1.1.1.2.4.2  tls 
   2371  1.1.1.2.4.2  tls /* Allocate all the minimal PLT entries.  */
   2372  1.1.1.2.4.2  tls 
   2373  1.1.1.2.4.2  tls static bfd_boolean
   2374  1.1.1.2.4.2  tls allocate_plt_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
   2375  1.1.1.2.4.2  tls 		      void * data ATTRIBUTE_UNUSED)
   2376  1.1.1.2.4.2  tls {
   2377  1.1.1.2.4.2  tls   if (dyn_i->want_plt)
   2378  1.1.1.2.4.2  tls     {
   2379  1.1.1.2.4.2  tls       struct elf_link_hash_entry *h = dyn_i->h;
   2380  1.1.1.2.4.2  tls 
   2381  1.1.1.2.4.2  tls       if (h)
   2382  1.1.1.2.4.2  tls 	while (h->root.type == bfd_link_hash_indirect
   2383  1.1.1.2.4.2  tls 	       || h->root.type == bfd_link_hash_warning)
   2384  1.1.1.2.4.2  tls 	  h = (struct elf_link_hash_entry *) h->root.u.i.link;
   2385  1.1.1.2.4.2  tls 
   2386  1.1.1.2.4.2  tls       /* ??? Versioned symbols seem to lose NEEDS_PLT.  */
   2387  1.1.1.2.4.2  tls       if (elf64_ia64_dynamic_symbol_p (h))
   2388  1.1.1.2.4.2  tls 	{
   2389  1.1.1.2.4.2  tls 	  dyn_i->want_pltoff = 1;
   2390  1.1.1.2.4.2  tls 	}
   2391  1.1.1.2.4.2  tls       else
   2392  1.1.1.2.4.2  tls 	{
   2393  1.1.1.2.4.2  tls 	  dyn_i->want_plt = 0;
   2394  1.1.1.2.4.2  tls 	  dyn_i->want_plt2 = 0;
   2395  1.1.1.2.4.2  tls 	}
   2396  1.1.1.2.4.2  tls     }
   2397  1.1.1.2.4.2  tls   return TRUE;
   2398  1.1.1.2.4.2  tls }
   2399  1.1.1.2.4.2  tls 
   2400  1.1.1.2.4.2  tls /* Allocate all the full PLT entries.  */
   2401  1.1.1.2.4.2  tls 
   2402  1.1.1.2.4.2  tls static bfd_boolean
   2403  1.1.1.2.4.2  tls allocate_plt2_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
   2404  1.1.1.2.4.2  tls 		       void * data)
   2405  1.1.1.2.4.2  tls {
   2406  1.1.1.2.4.2  tls   struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
   2407  1.1.1.2.4.2  tls 
   2408  1.1.1.2.4.2  tls   if (dyn_i->want_plt2)
   2409  1.1.1.2.4.2  tls     {
   2410  1.1.1.2.4.2  tls       struct elf_link_hash_entry *h = dyn_i->h;
   2411  1.1.1.2.4.2  tls       bfd_size_type ofs = x->ofs;
   2412  1.1.1.2.4.2  tls 
   2413  1.1.1.2.4.2  tls       dyn_i->plt2_offset = ofs;
   2414  1.1.1.2.4.2  tls       x->ofs = ofs + PLT_FULL_ENTRY_SIZE;
   2415  1.1.1.2.4.2  tls 
   2416  1.1.1.2.4.2  tls       while (h->root.type == bfd_link_hash_indirect
   2417  1.1.1.2.4.2  tls 	     || h->root.type == bfd_link_hash_warning)
   2418  1.1.1.2.4.2  tls 	h = (struct elf_link_hash_entry *) h->root.u.i.link;
   2419  1.1.1.2.4.2  tls       dyn_i->h->plt.offset = ofs;
   2420  1.1.1.2.4.2  tls     }
   2421  1.1.1.2.4.2  tls   return TRUE;
   2422  1.1.1.2.4.2  tls }
   2423  1.1.1.2.4.2  tls 
   2424  1.1.1.2.4.2  tls /* Allocate all the PLTOFF entries requested by relocations and
   2425  1.1.1.2.4.2  tls    plt entries.  We can't share space with allocated FPTR entries,
   2426  1.1.1.2.4.2  tls    because the latter are not necessarily addressable by the GP.
   2427  1.1.1.2.4.2  tls    ??? Relaxation might be able to determine that they are.  */
   2428  1.1.1.2.4.2  tls 
   2429  1.1.1.2.4.2  tls static bfd_boolean
   2430  1.1.1.2.4.2  tls allocate_pltoff_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
   2431  1.1.1.2.4.2  tls 			 void * data)
   2432  1.1.1.2.4.2  tls {
   2433  1.1.1.2.4.2  tls   struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
   2434  1.1.1.2.4.2  tls 
   2435  1.1.1.2.4.2  tls   if (dyn_i->want_pltoff)
   2436  1.1.1.2.4.2  tls     {
   2437  1.1.1.2.4.2  tls       dyn_i->pltoff_offset = x->ofs;
   2438  1.1.1.2.4.2  tls       x->ofs += 16;
   2439  1.1.1.2.4.2  tls     }
   2440  1.1.1.2.4.2  tls   return TRUE;
   2441  1.1.1.2.4.2  tls }
   2442  1.1.1.2.4.2  tls 
   2443  1.1.1.2.4.2  tls /* Allocate dynamic relocations for those symbols that turned out
   2444  1.1.1.2.4.2  tls    to be dynamic.  */
   2445  1.1.1.2.4.2  tls 
   2446  1.1.1.2.4.2  tls static bfd_boolean
   2447  1.1.1.2.4.2  tls allocate_dynrel_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
   2448  1.1.1.2.4.2  tls 			 void * data)
   2449  1.1.1.2.4.2  tls {
   2450  1.1.1.2.4.2  tls   struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
   2451  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   2452  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_reloc_entry *rent;
   2453  1.1.1.2.4.2  tls   bfd_boolean dynamic_symbol, shared, resolved_zero;
   2454  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_entry *h_ia64;
   2455  1.1.1.2.4.2  tls 
   2456  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (x->info);
   2457  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   2458  1.1.1.2.4.2  tls     return FALSE;
   2459  1.1.1.2.4.2  tls 
   2460  1.1.1.2.4.2  tls   /* Note that this can't be used in relation to FPTR relocs below.  */
   2461  1.1.1.2.4.2  tls   dynamic_symbol = elf64_ia64_dynamic_symbol_p (dyn_i->h);
   2462  1.1.1.2.4.2  tls 
   2463  1.1.1.2.4.2  tls   shared = x->info->shared;
   2464  1.1.1.2.4.2  tls   resolved_zero = (dyn_i->h
   2465  1.1.1.2.4.2  tls 		   && ELF_ST_VISIBILITY (dyn_i->h->other)
   2466  1.1.1.2.4.2  tls 		   && dyn_i->h->root.type == bfd_link_hash_undefweak);
   2467  1.1.1.2.4.2  tls 
   2468  1.1.1.2.4.2  tls   /* Take care of the GOT and PLT relocations.  */
   2469  1.1.1.2.4.2  tls 
   2470  1.1.1.2.4.2  tls   if ((!resolved_zero
   2471  1.1.1.2.4.2  tls        && (dynamic_symbol || shared)
   2472  1.1.1.2.4.2  tls        && (dyn_i->want_got || dyn_i->want_gotx))
   2473  1.1.1.2.4.2  tls       || (dyn_i->want_ltoff_fptr
   2474  1.1.1.2.4.2  tls 	  && dyn_i->h
   2475  1.1.1.2.4.2  tls 	  && dyn_i->h->def_dynamic))
   2476  1.1.1.2.4.2  tls     {
   2477  1.1.1.2.4.2  tls       /* VMS: FIX64.  */
   2478  1.1.1.2.4.2  tls       if (dyn_i->h != NULL && dyn_i->h->def_dynamic)
   2479  1.1.1.2.4.2  tls         {
   2480  1.1.1.2.4.2  tls           h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
   2481  1.1.1.2.4.2  tls           elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
   2482  1.1.1.2.4.2  tls             sizeof (Elf64_External_VMS_IMAGE_FIXUP);
   2483  1.1.1.2.4.2  tls           ia64_info->fixups_sec->size +=
   2484  1.1.1.2.4.2  tls             sizeof (Elf64_External_VMS_IMAGE_FIXUP);
   2485  1.1.1.2.4.2  tls         }
   2486  1.1.1.2.4.2  tls     }
   2487  1.1.1.2.4.2  tls 
   2488  1.1.1.2.4.2  tls   if (ia64_info->rel_fptr_sec && dyn_i->want_fptr)
   2489  1.1.1.2.4.2  tls     {
   2490  1.1.1.2.4.2  tls       /* VMS: only image reloc.  */
   2491  1.1.1.2.4.2  tls       if (dyn_i->h == NULL || dyn_i->h->root.type != bfd_link_hash_undefweak)
   2492  1.1.1.2.4.2  tls 	ia64_info->rel_fptr_sec->size += sizeof (Elf64_External_Rela);
   2493  1.1.1.2.4.2  tls     }
   2494  1.1.1.2.4.2  tls 
   2495  1.1.1.2.4.2  tls   if (!resolved_zero && dyn_i->want_pltoff)
   2496  1.1.1.2.4.2  tls     {
   2497  1.1.1.2.4.2  tls       /* VMS: FIXFD.  */
   2498  1.1.1.2.4.2  tls       if (dyn_i->h != NULL && dyn_i->h->def_dynamic)
   2499  1.1.1.2.4.2  tls         {
   2500  1.1.1.2.4.2  tls           h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
   2501  1.1.1.2.4.2  tls           elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
   2502  1.1.1.2.4.2  tls             sizeof (Elf64_External_VMS_IMAGE_FIXUP);
   2503  1.1.1.2.4.2  tls           ia64_info->fixups_sec->size +=
   2504  1.1.1.2.4.2  tls             sizeof (Elf64_External_VMS_IMAGE_FIXUP);
   2505  1.1.1.2.4.2  tls         }
   2506  1.1.1.2.4.2  tls     }
   2507  1.1.1.2.4.2  tls 
   2508  1.1.1.2.4.2  tls   /* Take care of the normal data relocations.  */
   2509  1.1.1.2.4.2  tls 
   2510  1.1.1.2.4.2  tls   for (rent = dyn_i->reloc_entries; rent; rent = rent->next)
   2511  1.1.1.2.4.2  tls     {
   2512  1.1.1.2.4.2  tls       int count = rent->count;
   2513  1.1.1.2.4.2  tls 
   2514  1.1.1.2.4.2  tls       switch (rent->type)
   2515  1.1.1.2.4.2  tls 	{
   2516  1.1.1.2.4.2  tls 	case R_IA64_FPTR32LSB:
   2517  1.1.1.2.4.2  tls 	case R_IA64_FPTR64LSB:
   2518  1.1.1.2.4.2  tls 	  /* Allocate one iff !want_fptr and not PIE, which by this point
   2519  1.1.1.2.4.2  tls 	     will be true only if we're actually allocating one statically
   2520  1.1.1.2.4.2  tls 	     in the main executable.  Position independent executables
   2521  1.1.1.2.4.2  tls 	     need a relative reloc.  */
   2522  1.1.1.2.4.2  tls 	  if (dyn_i->want_fptr && !x->info->pie)
   2523  1.1.1.2.4.2  tls 	    continue;
   2524  1.1.1.2.4.2  tls 	  break;
   2525  1.1.1.2.4.2  tls 	case R_IA64_PCREL32LSB:
   2526  1.1.1.2.4.2  tls 	case R_IA64_PCREL64LSB:
   2527  1.1.1.2.4.2  tls 	  if (!dynamic_symbol)
   2528  1.1.1.2.4.2  tls 	    continue;
   2529  1.1.1.2.4.2  tls 	  break;
   2530  1.1.1.2.4.2  tls 	case R_IA64_DIR32LSB:
   2531  1.1.1.2.4.2  tls 	case R_IA64_DIR64LSB:
   2532  1.1.1.2.4.2  tls 	  if (!dynamic_symbol && !shared)
   2533  1.1.1.2.4.2  tls 	    continue;
   2534  1.1.1.2.4.2  tls 	  break;
   2535  1.1.1.2.4.2  tls 	case R_IA64_IPLTLSB:
   2536  1.1.1.2.4.2  tls 	  if (!dynamic_symbol && !shared)
   2537  1.1.1.2.4.2  tls 	    continue;
   2538  1.1.1.2.4.2  tls 	  /* Use two REL relocations for IPLT relocations
   2539  1.1.1.2.4.2  tls 	     against local symbols.  */
   2540  1.1.1.2.4.2  tls 	  if (!dynamic_symbol)
   2541  1.1.1.2.4.2  tls 	    count *= 2;
   2542  1.1.1.2.4.2  tls 	  break;
   2543  1.1.1.2.4.2  tls 	case R_IA64_DTPREL32LSB:
   2544  1.1.1.2.4.2  tls 	case R_IA64_TPREL64LSB:
   2545  1.1.1.2.4.2  tls 	case R_IA64_DTPREL64LSB:
   2546  1.1.1.2.4.2  tls 	case R_IA64_DTPMOD64LSB:
   2547  1.1.1.2.4.2  tls 	  break;
   2548  1.1.1.2.4.2  tls 	default:
   2549  1.1.1.2.4.2  tls 	  abort ();
   2550  1.1.1.2.4.2  tls 	}
   2551  1.1.1.2.4.2  tls 
   2552  1.1.1.2.4.2  tls       /* Add a fixup.  */
   2553  1.1.1.2.4.2  tls       if (!dynamic_symbol)
   2554  1.1.1.2.4.2  tls         abort ();
   2555  1.1.1.2.4.2  tls 
   2556  1.1.1.2.4.2  tls       h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
   2557  1.1.1.2.4.2  tls       elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
   2558  1.1.1.2.4.2  tls         sizeof (Elf64_External_VMS_IMAGE_FIXUP);
   2559  1.1.1.2.4.2  tls       ia64_info->fixups_sec->size +=
   2560  1.1.1.2.4.2  tls         sizeof (Elf64_External_VMS_IMAGE_FIXUP);
   2561  1.1.1.2.4.2  tls     }
   2562  1.1.1.2.4.2  tls 
   2563  1.1.1.2.4.2  tls   return TRUE;
   2564  1.1.1.2.4.2  tls }
   2565  1.1.1.2.4.2  tls 
   2566  1.1.1.2.4.2  tls static bfd_boolean
   2567  1.1.1.2.4.2  tls elf64_ia64_adjust_dynamic_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED,
   2568  1.1.1.2.4.2  tls 				  struct elf_link_hash_entry *h)
   2569  1.1.1.2.4.2  tls {
   2570  1.1.1.2.4.2  tls   /* ??? Undefined symbols with PLT entries should be re-defined
   2571  1.1.1.2.4.2  tls      to be the PLT entry.  */
   2572  1.1.1.2.4.2  tls 
   2573  1.1.1.2.4.2  tls   /* If this is a weak symbol, and there is a real definition, the
   2574  1.1.1.2.4.2  tls      processor independent code will have arranged for us to see the
   2575  1.1.1.2.4.2  tls      real definition first, and we can just use the same value.  */
   2576  1.1.1.2.4.2  tls   if (h->u.weakdef != NULL)
   2577  1.1.1.2.4.2  tls     {
   2578  1.1.1.2.4.2  tls       BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
   2579  1.1.1.2.4.2  tls                   || h->u.weakdef->root.type == bfd_link_hash_defweak);
   2580  1.1.1.2.4.2  tls       h->root.u.def.section = h->u.weakdef->root.u.def.section;
   2581  1.1.1.2.4.2  tls       h->root.u.def.value = h->u.weakdef->root.u.def.value;
   2582  1.1.1.2.4.2  tls       return TRUE;
   2583  1.1.1.2.4.2  tls     }
   2584  1.1.1.2.4.2  tls 
   2585  1.1.1.2.4.2  tls   /* If this is a reference to a symbol defined by a dynamic object which
   2586  1.1.1.2.4.2  tls      is not a function, we might allocate the symbol in our .dynbss section
   2587  1.1.1.2.4.2  tls      and allocate a COPY dynamic relocation.
   2588  1.1.1.2.4.2  tls 
   2589  1.1.1.2.4.2  tls      But IA-64 code is canonically PIC, so as a rule we can avoid this sort
   2590  1.1.1.2.4.2  tls      of hackery.  */
   2591  1.1.1.2.4.2  tls 
   2592  1.1.1.2.4.2  tls   return TRUE;
   2593  1.1.1.2.4.2  tls }
   2594  1.1.1.2.4.2  tls 
   2595  1.1.1.2.4.2  tls static bfd_boolean
   2596  1.1.1.2.4.2  tls elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   2597  1.1.1.2.4.2  tls 				  struct bfd_link_info *info)
   2598  1.1.1.2.4.2  tls {
   2599  1.1.1.2.4.2  tls   struct elf64_ia64_allocate_data data;
   2600  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   2601  1.1.1.2.4.2  tls   asection *sec;
   2602  1.1.1.2.4.2  tls   bfd *dynobj;
   2603  1.1.1.2.4.2  tls   struct elf_link_hash_table *hash_table;
   2604  1.1.1.2.4.2  tls 
   2605  1.1.1.2.4.2  tls   hash_table = elf_hash_table (info);
   2606  1.1.1.2.4.2  tls   dynobj = hash_table->dynobj;
   2607  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   2608  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   2609  1.1.1.2.4.2  tls     return FALSE;
   2610  1.1.1.2.4.2  tls   BFD_ASSERT(dynobj != NULL);
   2611  1.1.1.2.4.2  tls   data.info = info;
   2612  1.1.1.2.4.2  tls 
   2613  1.1.1.2.4.2  tls   /* Allocate the GOT entries.  */
   2614  1.1.1.2.4.2  tls 
   2615  1.1.1.2.4.2  tls   if (ia64_info->root.sgot)
   2616  1.1.1.2.4.2  tls     {
   2617  1.1.1.2.4.2  tls       data.ofs = 0;
   2618  1.1.1.2.4.2  tls       elf64_ia64_dyn_sym_traverse (ia64_info, allocate_global_data_got, &data);
   2619  1.1.1.2.4.2  tls       elf64_ia64_dyn_sym_traverse (ia64_info, allocate_global_fptr_got, &data);
   2620  1.1.1.2.4.2  tls       elf64_ia64_dyn_sym_traverse (ia64_info, allocate_local_got, &data);
   2621  1.1.1.2.4.2  tls       ia64_info->root.sgot->size = data.ofs;
   2622  1.1.1.2.4.2  tls     }
   2623  1.1.1.2.4.2  tls 
   2624  1.1.1.2.4.2  tls   /* Allocate the FPTR entries.  */
   2625  1.1.1.2.4.2  tls 
   2626  1.1.1.2.4.2  tls   if (ia64_info->fptr_sec)
   2627  1.1.1.2.4.2  tls     {
   2628  1.1.1.2.4.2  tls       data.ofs = 0;
   2629  1.1.1.2.4.2  tls       elf64_ia64_dyn_sym_traverse (ia64_info, allocate_fptr, &data);
   2630  1.1.1.2.4.2  tls       ia64_info->fptr_sec->size = data.ofs;
   2631  1.1.1.2.4.2  tls     }
   2632  1.1.1.2.4.2  tls 
   2633  1.1.1.2.4.2  tls   /* Now that we've seen all of the input files, we can decide which
   2634  1.1.1.2.4.2  tls      symbols need plt entries.  Allocate the minimal PLT entries first.
   2635  1.1.1.2.4.2  tls      We do this even though dynamic_sections_created may be FALSE, because
   2636  1.1.1.2.4.2  tls      this has the side-effect of clearing want_plt and want_plt2.  */
   2637  1.1.1.2.4.2  tls 
   2638  1.1.1.2.4.2  tls   data.ofs = 0;
   2639  1.1.1.2.4.2  tls   elf64_ia64_dyn_sym_traverse (ia64_info, allocate_plt_entries, &data);
   2640  1.1.1.2.4.2  tls 
   2641  1.1.1.2.4.2  tls   /* Align the pointer for the plt2 entries.  */
   2642  1.1.1.2.4.2  tls   data.ofs = (data.ofs + 31) & (bfd_vma) -32;
   2643  1.1.1.2.4.2  tls 
   2644  1.1.1.2.4.2  tls   elf64_ia64_dyn_sym_traverse (ia64_info, allocate_plt2_entries, &data);
   2645  1.1.1.2.4.2  tls   if (data.ofs != 0 || ia64_info->root.dynamic_sections_created)
   2646  1.1.1.2.4.2  tls     {
   2647  1.1.1.2.4.2  tls       /* FIXME: we always reserve the memory for dynamic linker even if
   2648  1.1.1.2.4.2  tls 	 there are no PLT entries since dynamic linker may assume the
   2649  1.1.1.2.4.2  tls 	 reserved memory always exists.  */
   2650  1.1.1.2.4.2  tls 
   2651  1.1.1.2.4.2  tls       BFD_ASSERT (ia64_info->root.dynamic_sections_created);
   2652  1.1.1.2.4.2  tls 
   2653  1.1.1.2.4.2  tls       ia64_info->root.splt->size = data.ofs;
   2654  1.1.1.2.4.2  tls     }
   2655  1.1.1.2.4.2  tls 
   2656  1.1.1.2.4.2  tls   /* Allocate the PLTOFF entries.  */
   2657  1.1.1.2.4.2  tls 
   2658  1.1.1.2.4.2  tls   if (ia64_info->pltoff_sec)
   2659  1.1.1.2.4.2  tls     {
   2660  1.1.1.2.4.2  tls       data.ofs = 0;
   2661  1.1.1.2.4.2  tls       elf64_ia64_dyn_sym_traverse (ia64_info, allocate_pltoff_entries, &data);
   2662  1.1.1.2.4.2  tls       ia64_info->pltoff_sec->size = data.ofs;
   2663  1.1.1.2.4.2  tls     }
   2664  1.1.1.2.4.2  tls 
   2665  1.1.1.2.4.2  tls   if (ia64_info->root.dynamic_sections_created)
   2666  1.1.1.2.4.2  tls     {
   2667  1.1.1.2.4.2  tls       /* Allocate space for the dynamic relocations that turned out to be
   2668  1.1.1.2.4.2  tls 	 required.  */
   2669  1.1.1.2.4.2  tls       elf64_ia64_dyn_sym_traverse (ia64_info, allocate_dynrel_entries, &data);
   2670  1.1.1.2.4.2  tls     }
   2671  1.1.1.2.4.2  tls 
   2672  1.1.1.2.4.2  tls   /* We have now determined the sizes of the various dynamic sections.
   2673  1.1.1.2.4.2  tls      Allocate memory for them.  */
   2674  1.1.1.2.4.2  tls   for (sec = dynobj->sections; sec != NULL; sec = sec->next)
   2675  1.1.1.2.4.2  tls     {
   2676  1.1.1.2.4.2  tls       bfd_boolean strip;
   2677  1.1.1.2.4.2  tls 
   2678  1.1.1.2.4.2  tls       if (!(sec->flags & SEC_LINKER_CREATED))
   2679  1.1.1.2.4.2  tls 	continue;
   2680  1.1.1.2.4.2  tls 
   2681  1.1.1.2.4.2  tls       /* If we don't need this section, strip it from the output file.
   2682  1.1.1.2.4.2  tls 	 There were several sections primarily related to dynamic
   2683  1.1.1.2.4.2  tls 	 linking that must be create before the linker maps input
   2684  1.1.1.2.4.2  tls 	 sections to output sections.  The linker does that before
   2685  1.1.1.2.4.2  tls 	 bfd_elf_size_dynamic_sections is called, and it is that
   2686  1.1.1.2.4.2  tls 	 function which decides whether anything needs to go into
   2687  1.1.1.2.4.2  tls 	 these sections.  */
   2688  1.1.1.2.4.2  tls 
   2689  1.1.1.2.4.2  tls       strip = (sec->size == 0);
   2690  1.1.1.2.4.2  tls 
   2691  1.1.1.2.4.2  tls       if (sec == ia64_info->root.sgot)
   2692  1.1.1.2.4.2  tls 	strip = FALSE;
   2693  1.1.1.2.4.2  tls       else if (sec == ia64_info->root.srelgot)
   2694  1.1.1.2.4.2  tls 	{
   2695  1.1.1.2.4.2  tls 	  if (strip)
   2696  1.1.1.2.4.2  tls 	    ia64_info->root.srelgot = NULL;
   2697  1.1.1.2.4.2  tls 	  else
   2698  1.1.1.2.4.2  tls 	    /* We use the reloc_count field as a counter if we need to
   2699  1.1.1.2.4.2  tls 	       copy relocs into the output file.  */
   2700  1.1.1.2.4.2  tls 	    sec->reloc_count = 0;
   2701  1.1.1.2.4.2  tls 	}
   2702  1.1.1.2.4.2  tls       else if (sec == ia64_info->fptr_sec)
   2703  1.1.1.2.4.2  tls 	{
   2704  1.1.1.2.4.2  tls 	  if (strip)
   2705  1.1.1.2.4.2  tls 	    ia64_info->fptr_sec = NULL;
   2706  1.1.1.2.4.2  tls 	}
   2707  1.1.1.2.4.2  tls       else if (sec == ia64_info->rel_fptr_sec)
   2708  1.1.1.2.4.2  tls 	{
   2709  1.1.1.2.4.2  tls 	  if (strip)
   2710  1.1.1.2.4.2  tls 	    ia64_info->rel_fptr_sec = NULL;
   2711  1.1.1.2.4.2  tls 	  else
   2712  1.1.1.2.4.2  tls 	    /* We use the reloc_count field as a counter if we need to
   2713  1.1.1.2.4.2  tls 	       copy relocs into the output file.  */
   2714  1.1.1.2.4.2  tls 	    sec->reloc_count = 0;
   2715  1.1.1.2.4.2  tls 	}
   2716  1.1.1.2.4.2  tls       else if (sec == ia64_info->root.splt)
   2717  1.1.1.2.4.2  tls 	{
   2718  1.1.1.2.4.2  tls 	  if (strip)
   2719  1.1.1.2.4.2  tls 	    ia64_info->root.splt = NULL;
   2720  1.1.1.2.4.2  tls 	}
   2721  1.1.1.2.4.2  tls       else if (sec == ia64_info->pltoff_sec)
   2722  1.1.1.2.4.2  tls 	{
   2723  1.1.1.2.4.2  tls 	  if (strip)
   2724  1.1.1.2.4.2  tls 	    ia64_info->pltoff_sec = NULL;
   2725  1.1.1.2.4.2  tls 	}
   2726  1.1.1.2.4.2  tls       else if (sec == ia64_info->fixups_sec)
   2727  1.1.1.2.4.2  tls 	{
   2728  1.1.1.2.4.2  tls           if (strip)
   2729  1.1.1.2.4.2  tls             ia64_info->fixups_sec = NULL;
   2730  1.1.1.2.4.2  tls 	}
   2731  1.1.1.2.4.2  tls       else if (sec == ia64_info->transfer_sec)
   2732  1.1.1.2.4.2  tls         {
   2733  1.1.1.2.4.2  tls           ;
   2734  1.1.1.2.4.2  tls         }
   2735  1.1.1.2.4.2  tls       else
   2736  1.1.1.2.4.2  tls 	{
   2737  1.1.1.2.4.2  tls 	  const char *name;
   2738  1.1.1.2.4.2  tls 
   2739  1.1.1.2.4.2  tls 	  /* It's OK to base decisions on the section name, because none
   2740  1.1.1.2.4.2  tls 	     of the dynobj section names depend upon the input files.  */
   2741  1.1.1.2.4.2  tls 	  name = bfd_get_section_name (dynobj, sec);
   2742  1.1.1.2.4.2  tls 
   2743  1.1.1.2.4.2  tls 	  if (strcmp (name, ".got.plt") == 0)
   2744  1.1.1.2.4.2  tls 	    strip = FALSE;
   2745  1.1.1.2.4.2  tls 	  else if (CONST_STRNEQ (name, ".rel"))
   2746  1.1.1.2.4.2  tls 	    {
   2747  1.1.1.2.4.2  tls 	      if (!strip)
   2748  1.1.1.2.4.2  tls 		{
   2749  1.1.1.2.4.2  tls 		  /* We use the reloc_count field as a counter if we need to
   2750  1.1.1.2.4.2  tls 		     copy relocs into the output file.  */
   2751  1.1.1.2.4.2  tls 		  sec->reloc_count = 0;
   2752  1.1.1.2.4.2  tls 		}
   2753  1.1.1.2.4.2  tls 	    }
   2754  1.1.1.2.4.2  tls 	  else
   2755  1.1.1.2.4.2  tls 	    continue;
   2756  1.1.1.2.4.2  tls 	}
   2757  1.1.1.2.4.2  tls 
   2758  1.1.1.2.4.2  tls       if (strip)
   2759  1.1.1.2.4.2  tls 	sec->flags |= SEC_EXCLUDE;
   2760  1.1.1.2.4.2  tls       else
   2761  1.1.1.2.4.2  tls 	{
   2762  1.1.1.2.4.2  tls 	  /* Allocate memory for the section contents.  */
   2763  1.1.1.2.4.2  tls 	  sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->size);
   2764  1.1.1.2.4.2  tls 	  if (sec->contents == NULL && sec->size != 0)
   2765  1.1.1.2.4.2  tls 	    return FALSE;
   2766  1.1.1.2.4.2  tls 	}
   2767  1.1.1.2.4.2  tls     }
   2768  1.1.1.2.4.2  tls 
   2769  1.1.1.2.4.2  tls   if (elf_hash_table (info)->dynamic_sections_created)
   2770  1.1.1.2.4.2  tls     {
   2771  1.1.1.2.4.2  tls       bfd *abfd;
   2772  1.1.1.2.4.2  tls       asection *dynsec;
   2773  1.1.1.2.4.2  tls       asection *dynstrsec;
   2774  1.1.1.2.4.2  tls       Elf_Internal_Dyn dyn;
   2775  1.1.1.2.4.2  tls       const struct elf_backend_data *bed;
   2776  1.1.1.2.4.2  tls       unsigned int shl_num = 0;
   2777  1.1.1.2.4.2  tls       bfd_vma fixups_off = 0;
   2778  1.1.1.2.4.2  tls       bfd_vma strdyn_off;
   2779  1.1.1.2.4.2  tls       unsigned int time_hi, time_lo;
   2780  1.1.1.2.4.2  tls 
   2781  1.1.1.2.4.2  tls       /* The .dynamic section must exist and be empty.  */
   2782  1.1.1.2.4.2  tls       dynsec = bfd_get_linker_section (hash_table->dynobj, ".dynamic");
   2783  1.1.1.2.4.2  tls       BFD_ASSERT (dynsec != NULL);
   2784  1.1.1.2.4.2  tls       BFD_ASSERT (dynsec->size == 0);
   2785  1.1.1.2.4.2  tls 
   2786  1.1.1.2.4.2  tls       dynstrsec = bfd_get_linker_section (hash_table->dynobj, ".vmsdynstr");
   2787  1.1.1.2.4.2  tls       BFD_ASSERT (dynstrsec != NULL);
   2788  1.1.1.2.4.2  tls       BFD_ASSERT (dynstrsec->size == 0);
   2789  1.1.1.2.4.2  tls       dynstrsec->size = 1;	/* Initial blank.  */
   2790  1.1.1.2.4.2  tls 
   2791  1.1.1.2.4.2  tls       /* Ident + link time.  */
   2792  1.1.1.2.4.2  tls       vms_get_time (&time_hi, &time_lo);
   2793  1.1.1.2.4.2  tls 
   2794  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_IDENT, 0))
   2795  1.1.1.2.4.2  tls         return FALSE;
   2796  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_LINKTIME,
   2797  1.1.1.2.4.2  tls                                        (((bfd_uint64_t)time_hi) << 32)
   2798  1.1.1.2.4.2  tls                                        + time_lo))
   2799  1.1.1.2.4.2  tls         return FALSE;
   2800  1.1.1.2.4.2  tls 
   2801  1.1.1.2.4.2  tls       /* Strtab.  */
   2802  1.1.1.2.4.2  tls       strdyn_off = dynsec->size;
   2803  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_STRTAB_OFFSET, 0))
   2804  1.1.1.2.4.2  tls         return FALSE;
   2805  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_STRSZ, 0))
   2806  1.1.1.2.4.2  tls         return FALSE;
   2807  1.1.1.2.4.2  tls 
   2808  1.1.1.2.4.2  tls       /* PLTGOT  */
   2809  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_PLTGOT_SEG, 0))
   2810  1.1.1.2.4.2  tls         return FALSE;
   2811  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_PLTGOT_OFFSET, 0))
   2812  1.1.1.2.4.2  tls         return FALSE;
   2813  1.1.1.2.4.2  tls 
   2814  1.1.1.2.4.2  tls       /* Misc.  */
   2815  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FPMODE, 0x9800000))
   2816  1.1.1.2.4.2  tls         return FALSE;
   2817  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_LNKFLAGS,
   2818  1.1.1.2.4.2  tls                                        VMS_LF_IMGSTA | VMS_LF_MAIN))
   2819  1.1.1.2.4.2  tls         return FALSE;
   2820  1.1.1.2.4.2  tls 
   2821  1.1.1.2.4.2  tls       /* Add entries for shared libraries.  */
   2822  1.1.1.2.4.2  tls       for (abfd = info->input_bfds; abfd; abfd = abfd->link_next)
   2823  1.1.1.2.4.2  tls         {
   2824  1.1.1.2.4.2  tls           char *soname;
   2825  1.1.1.2.4.2  tls           size_t soname_len;
   2826  1.1.1.2.4.2  tls           bfd_size_type strindex;
   2827  1.1.1.2.4.2  tls           bfd_byte *newcontents;
   2828  1.1.1.2.4.2  tls           bfd_vma fixups_shl_off;
   2829  1.1.1.2.4.2  tls 
   2830  1.1.1.2.4.2  tls           if (!(abfd->flags & DYNAMIC))
   2831  1.1.1.2.4.2  tls             continue;
   2832  1.1.1.2.4.2  tls           BFD_ASSERT (abfd->xvec == output_bfd->xvec);
   2833  1.1.1.2.4.2  tls 
   2834  1.1.1.2.4.2  tls           if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_NEEDED_IDENT,
   2835  1.1.1.2.4.2  tls                                            elf_ia64_vms_ident (abfd)))
   2836  1.1.1.2.4.2  tls             return FALSE;
   2837  1.1.1.2.4.2  tls 
   2838  1.1.1.2.4.2  tls           soname = vms_get_module_name (abfd->filename, TRUE);
   2839  1.1.1.2.4.2  tls           if (soname == NULL)
   2840  1.1.1.2.4.2  tls             return FALSE;
   2841  1.1.1.2.4.2  tls           strindex = dynstrsec->size;
   2842  1.1.1.2.4.2  tls           soname_len = strlen (soname) + 1;
   2843  1.1.1.2.4.2  tls           newcontents = (bfd_byte *) bfd_realloc (dynstrsec->contents,
   2844  1.1.1.2.4.2  tls                                                   strindex + soname_len);
   2845  1.1.1.2.4.2  tls           if (newcontents == NULL)
   2846  1.1.1.2.4.2  tls             return FALSE;
   2847  1.1.1.2.4.2  tls           memcpy (newcontents + strindex, soname, soname_len);
   2848  1.1.1.2.4.2  tls           dynstrsec->size += soname_len;
   2849  1.1.1.2.4.2  tls           dynstrsec->contents = newcontents;
   2850  1.1.1.2.4.2  tls 
   2851  1.1.1.2.4.2  tls           if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex))
   2852  1.1.1.2.4.2  tls             return FALSE;
   2853  1.1.1.2.4.2  tls 
   2854  1.1.1.2.4.2  tls           if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FIXUP_NEEDED,
   2855  1.1.1.2.4.2  tls                                            shl_num))
   2856  1.1.1.2.4.2  tls             return FALSE;
   2857  1.1.1.2.4.2  tls           shl_num++;
   2858  1.1.1.2.4.2  tls 
   2859  1.1.1.2.4.2  tls           /* The fixups_off was in fact containing the size of the fixup
   2860  1.1.1.2.4.2  tls              section.  Remap into the offset.  */
   2861  1.1.1.2.4.2  tls           fixups_shl_off = elf_ia64_vms_tdata (abfd)->fixups_off;
   2862  1.1.1.2.4.2  tls           elf_ia64_vms_tdata (abfd)->fixups_off = fixups_off;
   2863  1.1.1.2.4.2  tls 
   2864  1.1.1.2.4.2  tls           if (!_bfd_elf_add_dynamic_entry
   2865  1.1.1.2.4.2  tls               (info, DT_IA_64_VMS_FIXUP_RELA_CNT,
   2866  1.1.1.2.4.2  tls                fixups_shl_off / sizeof (Elf64_External_VMS_IMAGE_FIXUP)))
   2867  1.1.1.2.4.2  tls             return FALSE;
   2868  1.1.1.2.4.2  tls           if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FIXUP_RELA_OFF,
   2869  1.1.1.2.4.2  tls                                            fixups_off))
   2870  1.1.1.2.4.2  tls             return FALSE;
   2871  1.1.1.2.4.2  tls           fixups_off += fixups_shl_off;
   2872  1.1.1.2.4.2  tls         }
   2873  1.1.1.2.4.2  tls 
   2874  1.1.1.2.4.2  tls       /* Unwind.  */
   2875  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWINDSZ, 0))
   2876  1.1.1.2.4.2  tls         return FALSE;
   2877  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_CODSEG, 0))
   2878  1.1.1.2.4.2  tls         return FALSE;
   2879  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_INFOSEG, 0))
   2880  1.1.1.2.4.2  tls         return FALSE;
   2881  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_OFFSET, 0))
   2882  1.1.1.2.4.2  tls         return FALSE;
   2883  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_SEG, 0))
   2884  1.1.1.2.4.2  tls         return FALSE;
   2885  1.1.1.2.4.2  tls 
   2886  1.1.1.2.4.2  tls       if (!_bfd_elf_add_dynamic_entry (info, DT_NULL, 0xdead))
   2887  1.1.1.2.4.2  tls             return FALSE;
   2888  1.1.1.2.4.2  tls 
   2889  1.1.1.2.4.2  tls       /* Fix the strtab entries.  */
   2890  1.1.1.2.4.2  tls       bed = get_elf_backend_data (hash_table->dynobj);
   2891  1.1.1.2.4.2  tls 
   2892  1.1.1.2.4.2  tls       if (dynstrsec->size > 1)
   2893  1.1.1.2.4.2  tls         dynstrsec->contents[0] = 0;
   2894  1.1.1.2.4.2  tls       else
   2895  1.1.1.2.4.2  tls         dynstrsec->size = 0;
   2896  1.1.1.2.4.2  tls 
   2897  1.1.1.2.4.2  tls       /* Note: one 'spare' (ie DT_NULL) entry is added by
   2898  1.1.1.2.4.2  tls          bfd_elf_size_dynsym_hash_dynstr.  */
   2899  1.1.1.2.4.2  tls       dyn.d_tag = DT_IA_64_VMS_STRTAB_OFFSET;
   2900  1.1.1.2.4.2  tls       dyn.d_un.d_val = dynsec->size /* + sizeof (Elf64_External_Dyn) */;
   2901  1.1.1.2.4.2  tls       bed->s->swap_dyn_out (hash_table->dynobj, &dyn,
   2902  1.1.1.2.4.2  tls                             dynsec->contents + strdyn_off);
   2903  1.1.1.2.4.2  tls 
   2904  1.1.1.2.4.2  tls       dyn.d_tag = DT_STRSZ;
   2905  1.1.1.2.4.2  tls       dyn.d_un.d_val = dynstrsec->size;
   2906  1.1.1.2.4.2  tls       bed->s->swap_dyn_out (hash_table->dynobj, &dyn,
   2907  1.1.1.2.4.2  tls                             dynsec->contents + strdyn_off + bed->s->sizeof_dyn);
   2908  1.1.1.2.4.2  tls 
   2909  1.1.1.2.4.2  tls       elf_ia64_vms_tdata (output_bfd)->needed_count = shl_num;
   2910  1.1.1.2.4.2  tls 
   2911  1.1.1.2.4.2  tls       /* Note section.  */
   2912  1.1.1.2.4.2  tls       if (!create_ia64_vms_notes (output_bfd, info, time_hi, time_lo))
   2913  1.1.1.2.4.2  tls         return FALSE;
   2914  1.1.1.2.4.2  tls     }
   2915  1.1.1.2.4.2  tls 
   2916  1.1.1.2.4.2  tls   /* ??? Perhaps force __gp local.  */
   2917  1.1.1.2.4.2  tls 
   2918  1.1.1.2.4.2  tls   return TRUE;
   2919  1.1.1.2.4.2  tls }
   2920  1.1.1.2.4.2  tls 
   2921  1.1.1.2.4.2  tls static void
   2922  1.1.1.2.4.2  tls elf64_ia64_install_fixup (bfd *output_bfd,
   2923  1.1.1.2.4.2  tls                           struct elf64_ia64_link_hash_table *ia64_info,
   2924  1.1.1.2.4.2  tls                           struct elf_link_hash_entry *h,
   2925  1.1.1.2.4.2  tls                           unsigned int type, asection *sec, bfd_vma offset,
   2926  1.1.1.2.4.2  tls                           bfd_vma addend)
   2927  1.1.1.2.4.2  tls {
   2928  1.1.1.2.4.2  tls   asection *relsec;
   2929  1.1.1.2.4.2  tls   Elf64_External_VMS_IMAGE_FIXUP *fixup;
   2930  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_entry *h_ia64;
   2931  1.1.1.2.4.2  tls   bfd_vma fixoff;
   2932  1.1.1.2.4.2  tls   Elf_Internal_Phdr *phdr;
   2933  1.1.1.2.4.2  tls 
   2934  1.1.1.2.4.2  tls   if (h == NULL || !h->def_dynamic)
   2935  1.1.1.2.4.2  tls     abort ();
   2936  1.1.1.2.4.2  tls 
   2937  1.1.1.2.4.2  tls   h_ia64 = (struct elf64_ia64_link_hash_entry *) h;
   2938  1.1.1.2.4.2  tls   fixoff = elf_ia64_vms_tdata (h_ia64->shl)->fixups_off;
   2939  1.1.1.2.4.2  tls   elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
   2940  1.1.1.2.4.2  tls     sizeof (Elf64_External_VMS_IMAGE_FIXUP);
   2941  1.1.1.2.4.2  tls   relsec = ia64_info->fixups_sec;
   2942  1.1.1.2.4.2  tls 
   2943  1.1.1.2.4.2  tls   fixup = (Elf64_External_VMS_IMAGE_FIXUP *)(relsec->contents + fixoff);
   2944  1.1.1.2.4.2  tls   offset += sec->output_section->vma + sec->output_offset;
   2945  1.1.1.2.4.2  tls 
   2946  1.1.1.2.4.2  tls   /* FIXME: this is slow.  We should cache the last one used, or create a
   2947  1.1.1.2.4.2  tls      map.  */
   2948  1.1.1.2.4.2  tls   phdr = _bfd_elf_find_segment_containing_section
   2949  1.1.1.2.4.2  tls     (output_bfd, sec->output_section);
   2950  1.1.1.2.4.2  tls   BFD_ASSERT (phdr != NULL);
   2951  1.1.1.2.4.2  tls 
   2952  1.1.1.2.4.2  tls   bfd_putl64 (offset - phdr->p_vaddr, fixup->fixup_offset);
   2953  1.1.1.2.4.2  tls   bfd_putl32 (type, fixup->type);
   2954  1.1.1.2.4.2  tls   bfd_putl32 (phdr - elf_tdata (output_bfd)->phdr, fixup->fixup_seg);
   2955  1.1.1.2.4.2  tls   bfd_putl64 (addend, fixup->addend);
   2956  1.1.1.2.4.2  tls   bfd_putl32 (h->root.u.def.value, fixup->symvec_index);
   2957  1.1.1.2.4.2  tls   bfd_putl32 (2, fixup->data_type);
   2958  1.1.1.2.4.2  tls }
   2959  1.1.1.2.4.2  tls 
   2960  1.1.1.2.4.2  tls /* Store an entry for target address TARGET_ADDR in the linkage table
   2961  1.1.1.2.4.2  tls    and return the gp-relative address of the linkage table entry.  */
   2962  1.1.1.2.4.2  tls 
   2963  1.1.1.2.4.2  tls static bfd_vma
   2964  1.1.1.2.4.2  tls set_got_entry (bfd *abfd, struct bfd_link_info *info,
   2965  1.1.1.2.4.2  tls 	       struct elf64_ia64_dyn_sym_info *dyn_i,
   2966  1.1.1.2.4.2  tls 	       bfd_vma addend, bfd_vma value, unsigned int dyn_r_type)
   2967  1.1.1.2.4.2  tls {
   2968  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   2969  1.1.1.2.4.2  tls   asection *got_sec;
   2970  1.1.1.2.4.2  tls   bfd_boolean done;
   2971  1.1.1.2.4.2  tls   bfd_vma got_offset;
   2972  1.1.1.2.4.2  tls 
   2973  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   2974  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   2975  1.1.1.2.4.2  tls     return 0;
   2976  1.1.1.2.4.2  tls 
   2977  1.1.1.2.4.2  tls   got_sec = ia64_info->root.sgot;
   2978  1.1.1.2.4.2  tls 
   2979  1.1.1.2.4.2  tls   switch (dyn_r_type)
   2980  1.1.1.2.4.2  tls     {
   2981  1.1.1.2.4.2  tls     case R_IA64_TPREL64LSB:
   2982  1.1.1.2.4.2  tls     case R_IA64_DTPMOD64LSB:
   2983  1.1.1.2.4.2  tls     case R_IA64_DTPREL32LSB:
   2984  1.1.1.2.4.2  tls     case R_IA64_DTPREL64LSB:
   2985  1.1.1.2.4.2  tls       abort ();
   2986  1.1.1.2.4.2  tls       break;
   2987  1.1.1.2.4.2  tls     default:
   2988  1.1.1.2.4.2  tls       done = dyn_i->got_done;
   2989  1.1.1.2.4.2  tls       dyn_i->got_done = TRUE;
   2990  1.1.1.2.4.2  tls       got_offset = dyn_i->got_offset;
   2991  1.1.1.2.4.2  tls       break;
   2992  1.1.1.2.4.2  tls     }
   2993  1.1.1.2.4.2  tls 
   2994  1.1.1.2.4.2  tls   BFD_ASSERT ((got_offset & 7) == 0);
   2995  1.1.1.2.4.2  tls 
   2996  1.1.1.2.4.2  tls   if (! done)
   2997  1.1.1.2.4.2  tls     {
   2998  1.1.1.2.4.2  tls       /* Store the target address in the linkage table entry.  */
   2999  1.1.1.2.4.2  tls       bfd_put_64 (abfd, value, got_sec->contents + got_offset);
   3000  1.1.1.2.4.2  tls 
   3001  1.1.1.2.4.2  tls       /* Install a dynamic relocation if needed.  */
   3002  1.1.1.2.4.2  tls       if (((info->shared
   3003  1.1.1.2.4.2  tls 	    && (!dyn_i->h
   3004  1.1.1.2.4.2  tls 		|| ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
   3005  1.1.1.2.4.2  tls 		|| dyn_i->h->root.type != bfd_link_hash_undefweak))
   3006  1.1.1.2.4.2  tls            || elf64_ia64_dynamic_symbol_p (dyn_i->h))
   3007  1.1.1.2.4.2  tls 	  && (!dyn_i->want_ltoff_fptr
   3008  1.1.1.2.4.2  tls 	      || !info->pie
   3009  1.1.1.2.4.2  tls 	      || !dyn_i->h
   3010  1.1.1.2.4.2  tls 	      || dyn_i->h->root.type != bfd_link_hash_undefweak))
   3011  1.1.1.2.4.2  tls 	{
   3012  1.1.1.2.4.2  tls 	  if (!dyn_i->h || !dyn_i->h->def_dynamic)
   3013  1.1.1.2.4.2  tls 	    {
   3014  1.1.1.2.4.2  tls 	      dyn_r_type = R_IA64_REL64LSB;
   3015  1.1.1.2.4.2  tls 	      addend = value;
   3016  1.1.1.2.4.2  tls 	    }
   3017  1.1.1.2.4.2  tls 
   3018  1.1.1.2.4.2  tls           /* VMS: install a FIX32 or FIX64.  */
   3019  1.1.1.2.4.2  tls           switch (dyn_r_type)
   3020  1.1.1.2.4.2  tls             {
   3021  1.1.1.2.4.2  tls             case R_IA64_DIR32LSB:
   3022  1.1.1.2.4.2  tls             case R_IA64_FPTR32LSB:
   3023  1.1.1.2.4.2  tls               dyn_r_type = R_IA64_VMS_FIX32;
   3024  1.1.1.2.4.2  tls               break;
   3025  1.1.1.2.4.2  tls             case R_IA64_DIR64LSB:
   3026  1.1.1.2.4.2  tls             case R_IA64_FPTR64LSB:
   3027  1.1.1.2.4.2  tls               dyn_r_type = R_IA64_VMS_FIX64;
   3028  1.1.1.2.4.2  tls               break;
   3029  1.1.1.2.4.2  tls             default:
   3030  1.1.1.2.4.2  tls               BFD_ASSERT (FALSE);
   3031  1.1.1.2.4.2  tls               break;
   3032  1.1.1.2.4.2  tls             }
   3033  1.1.1.2.4.2  tls           elf64_ia64_install_fixup
   3034  1.1.1.2.4.2  tls             (info->output_bfd, ia64_info, dyn_i->h,
   3035  1.1.1.2.4.2  tls              dyn_r_type, got_sec, got_offset, addend);
   3036  1.1.1.2.4.2  tls         }
   3037  1.1.1.2.4.2  tls     }
   3038  1.1.1.2.4.2  tls 
   3039  1.1.1.2.4.2  tls   /* Return the address of the linkage table entry.  */
   3040  1.1.1.2.4.2  tls   value = (got_sec->output_section->vma
   3041  1.1.1.2.4.2  tls 	   + got_sec->output_offset
   3042  1.1.1.2.4.2  tls 	   + got_offset);
   3043  1.1.1.2.4.2  tls 
   3044  1.1.1.2.4.2  tls   return value;
   3045  1.1.1.2.4.2  tls }
   3046  1.1.1.2.4.2  tls 
   3047  1.1.1.2.4.2  tls /* Fill in a function descriptor consisting of the function's code
   3048  1.1.1.2.4.2  tls    address and its global pointer.  Return the descriptor's address.  */
   3049  1.1.1.2.4.2  tls 
   3050  1.1.1.2.4.2  tls static bfd_vma
   3051  1.1.1.2.4.2  tls set_fptr_entry (bfd *abfd, struct bfd_link_info *info,
   3052  1.1.1.2.4.2  tls 		struct elf64_ia64_dyn_sym_info *dyn_i,
   3053  1.1.1.2.4.2  tls 		bfd_vma value)
   3054  1.1.1.2.4.2  tls {
   3055  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   3056  1.1.1.2.4.2  tls   asection *fptr_sec;
   3057  1.1.1.2.4.2  tls 
   3058  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   3059  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   3060  1.1.1.2.4.2  tls     return 0;
   3061  1.1.1.2.4.2  tls 
   3062  1.1.1.2.4.2  tls   fptr_sec = ia64_info->fptr_sec;
   3063  1.1.1.2.4.2  tls 
   3064  1.1.1.2.4.2  tls   if (!dyn_i->fptr_done)
   3065  1.1.1.2.4.2  tls     {
   3066  1.1.1.2.4.2  tls       dyn_i->fptr_done = 1;
   3067  1.1.1.2.4.2  tls 
   3068  1.1.1.2.4.2  tls       /* Fill in the function descriptor.  */
   3069  1.1.1.2.4.2  tls       bfd_put_64 (abfd, value, fptr_sec->contents + dyn_i->fptr_offset);
   3070  1.1.1.2.4.2  tls       bfd_put_64 (abfd, _bfd_get_gp_value (abfd),
   3071  1.1.1.2.4.2  tls 		  fptr_sec->contents + dyn_i->fptr_offset + 8);
   3072  1.1.1.2.4.2  tls     }
   3073  1.1.1.2.4.2  tls 
   3074  1.1.1.2.4.2  tls   /* Return the descriptor's address.  */
   3075  1.1.1.2.4.2  tls   value = (fptr_sec->output_section->vma
   3076  1.1.1.2.4.2  tls 	   + fptr_sec->output_offset
   3077  1.1.1.2.4.2  tls 	   + dyn_i->fptr_offset);
   3078  1.1.1.2.4.2  tls 
   3079  1.1.1.2.4.2  tls   return value;
   3080  1.1.1.2.4.2  tls }
   3081  1.1.1.2.4.2  tls 
   3082  1.1.1.2.4.2  tls /* Fill in a PLTOFF entry consisting of the function's code address
   3083  1.1.1.2.4.2  tls    and its global pointer.  Return the descriptor's address.  */
   3084  1.1.1.2.4.2  tls 
   3085  1.1.1.2.4.2  tls static bfd_vma
   3086  1.1.1.2.4.2  tls set_pltoff_entry (bfd *abfd, struct bfd_link_info *info,
   3087  1.1.1.2.4.2  tls 		  struct elf64_ia64_dyn_sym_info *dyn_i,
   3088  1.1.1.2.4.2  tls 		  bfd_vma value, bfd_boolean is_plt)
   3089  1.1.1.2.4.2  tls {
   3090  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   3091  1.1.1.2.4.2  tls   asection *pltoff_sec;
   3092  1.1.1.2.4.2  tls 
   3093  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   3094  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   3095  1.1.1.2.4.2  tls     return 0;
   3096  1.1.1.2.4.2  tls 
   3097  1.1.1.2.4.2  tls   pltoff_sec = ia64_info->pltoff_sec;
   3098  1.1.1.2.4.2  tls 
   3099  1.1.1.2.4.2  tls   /* Don't do anything if this symbol uses a real PLT entry.  In
   3100  1.1.1.2.4.2  tls      that case, we'll fill this in during finish_dynamic_symbol.  */
   3101  1.1.1.2.4.2  tls   if ((! dyn_i->want_plt || is_plt)
   3102  1.1.1.2.4.2  tls       && !dyn_i->pltoff_done)
   3103  1.1.1.2.4.2  tls     {
   3104  1.1.1.2.4.2  tls       bfd_vma gp = _bfd_get_gp_value (abfd);
   3105  1.1.1.2.4.2  tls 
   3106  1.1.1.2.4.2  tls       /* Fill in the function descriptor.  */
   3107  1.1.1.2.4.2  tls       bfd_put_64 (abfd, value, pltoff_sec->contents + dyn_i->pltoff_offset);
   3108  1.1.1.2.4.2  tls       bfd_put_64 (abfd, gp, pltoff_sec->contents + dyn_i->pltoff_offset + 8);
   3109  1.1.1.2.4.2  tls 
   3110  1.1.1.2.4.2  tls       /* Install dynamic relocations if needed.  */
   3111  1.1.1.2.4.2  tls       if (!is_plt
   3112  1.1.1.2.4.2  tls 	  && info->shared
   3113  1.1.1.2.4.2  tls 	  && (!dyn_i->h
   3114  1.1.1.2.4.2  tls 	      || ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
   3115  1.1.1.2.4.2  tls 	      || dyn_i->h->root.type != bfd_link_hash_undefweak))
   3116  1.1.1.2.4.2  tls 	{
   3117  1.1.1.2.4.2  tls           /* VMS:  */
   3118  1.1.1.2.4.2  tls           abort ();
   3119  1.1.1.2.4.2  tls 	}
   3120  1.1.1.2.4.2  tls 
   3121  1.1.1.2.4.2  tls       dyn_i->pltoff_done = 1;
   3122  1.1.1.2.4.2  tls     }
   3123  1.1.1.2.4.2  tls 
   3124  1.1.1.2.4.2  tls   /* Return the descriptor's address.  */
   3125  1.1.1.2.4.2  tls   value = (pltoff_sec->output_section->vma
   3126  1.1.1.2.4.2  tls 	   + pltoff_sec->output_offset
   3127  1.1.1.2.4.2  tls 	   + dyn_i->pltoff_offset);
   3128  1.1.1.2.4.2  tls 
   3129  1.1.1.2.4.2  tls   return value;
   3130  1.1.1.2.4.2  tls }
   3131  1.1.1.2.4.2  tls 
   3132  1.1.1.2.4.2  tls /* Called through qsort to sort the .IA_64.unwind section during a
   3133  1.1.1.2.4.2  tls    non-relocatable link.  Set elf64_ia64_unwind_entry_compare_bfd
   3134  1.1.1.2.4.2  tls    to the output bfd so we can do proper endianness frobbing.  */
   3135  1.1.1.2.4.2  tls 
   3136  1.1.1.2.4.2  tls static bfd *elf64_ia64_unwind_entry_compare_bfd;
   3137  1.1.1.2.4.2  tls 
   3138  1.1.1.2.4.2  tls static int
   3139  1.1.1.2.4.2  tls elf64_ia64_unwind_entry_compare (const void * a, const void * b)
   3140  1.1.1.2.4.2  tls {
   3141  1.1.1.2.4.2  tls   bfd_vma av, bv;
   3142  1.1.1.2.4.2  tls 
   3143  1.1.1.2.4.2  tls   av = bfd_get_64 (elf64_ia64_unwind_entry_compare_bfd, a);
   3144  1.1.1.2.4.2  tls   bv = bfd_get_64 (elf64_ia64_unwind_entry_compare_bfd, b);
   3145  1.1.1.2.4.2  tls 
   3146  1.1.1.2.4.2  tls   return (av < bv ? -1 : av > bv ? 1 : 0);
   3147  1.1.1.2.4.2  tls }
   3148  1.1.1.2.4.2  tls 
   3149  1.1.1.2.4.2  tls /* Make sure we've got ourselves a nice fat __gp value.  */
   3150  1.1.1.2.4.2  tls static bfd_boolean
   3151  1.1.1.2.4.2  tls elf64_ia64_choose_gp (bfd *abfd, struct bfd_link_info *info, bfd_boolean final)
   3152  1.1.1.2.4.2  tls {
   3153  1.1.1.2.4.2  tls   bfd_vma min_vma = (bfd_vma) -1, max_vma = 0;
   3154  1.1.1.2.4.2  tls   bfd_vma min_short_vma = min_vma, max_short_vma = 0;
   3155  1.1.1.2.4.2  tls   struct elf_link_hash_entry *gp;
   3156  1.1.1.2.4.2  tls   bfd_vma gp_val;
   3157  1.1.1.2.4.2  tls   asection *os;
   3158  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   3159  1.1.1.2.4.2  tls 
   3160  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   3161  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   3162  1.1.1.2.4.2  tls     return FALSE;
   3163  1.1.1.2.4.2  tls 
   3164  1.1.1.2.4.2  tls   /* Find the min and max vma of all sections marked short.  Also collect
   3165  1.1.1.2.4.2  tls      min and max vma of any type, for use in selecting a nice gp.  */
   3166  1.1.1.2.4.2  tls   for (os = abfd->sections; os ; os = os->next)
   3167  1.1.1.2.4.2  tls     {
   3168  1.1.1.2.4.2  tls       bfd_vma lo, hi;
   3169  1.1.1.2.4.2  tls 
   3170  1.1.1.2.4.2  tls       if ((os->flags & SEC_ALLOC) == 0)
   3171  1.1.1.2.4.2  tls 	continue;
   3172  1.1.1.2.4.2  tls 
   3173  1.1.1.2.4.2  tls       lo = os->vma;
   3174  1.1.1.2.4.2  tls       /* When this function is called from elfNN_ia64_final_link
   3175  1.1.1.2.4.2  tls 	 the correct value to use is os->size.  When called from
   3176  1.1.1.2.4.2  tls 	 elfNN_ia64_relax_section we are in the middle of section
   3177  1.1.1.2.4.2  tls 	 sizing; some sections will already have os->size set, others
   3178  1.1.1.2.4.2  tls 	 will have os->size zero and os->rawsize the previous size.  */
   3179  1.1.1.2.4.2  tls       hi = os->vma + (!final && os->rawsize ? os->rawsize : os->size);
   3180  1.1.1.2.4.2  tls       if (hi < lo)
   3181  1.1.1.2.4.2  tls 	hi = (bfd_vma) -1;
   3182  1.1.1.2.4.2  tls 
   3183  1.1.1.2.4.2  tls       if (min_vma > lo)
   3184  1.1.1.2.4.2  tls 	min_vma = lo;
   3185  1.1.1.2.4.2  tls       if (max_vma < hi)
   3186  1.1.1.2.4.2  tls 	max_vma = hi;
   3187  1.1.1.2.4.2  tls       if (os->flags & SEC_SMALL_DATA)
   3188  1.1.1.2.4.2  tls 	{
   3189  1.1.1.2.4.2  tls 	  if (min_short_vma > lo)
   3190  1.1.1.2.4.2  tls 	    min_short_vma = lo;
   3191  1.1.1.2.4.2  tls 	  if (max_short_vma < hi)
   3192  1.1.1.2.4.2  tls 	    max_short_vma = hi;
   3193  1.1.1.2.4.2  tls 	}
   3194  1.1.1.2.4.2  tls     }
   3195  1.1.1.2.4.2  tls 
   3196  1.1.1.2.4.2  tls   if (ia64_info->min_short_sec)
   3197  1.1.1.2.4.2  tls     {
   3198  1.1.1.2.4.2  tls       if (min_short_vma
   3199  1.1.1.2.4.2  tls 	  > (ia64_info->min_short_sec->vma
   3200  1.1.1.2.4.2  tls 	     + ia64_info->min_short_offset))
   3201  1.1.1.2.4.2  tls 	min_short_vma = (ia64_info->min_short_sec->vma
   3202  1.1.1.2.4.2  tls 			 + ia64_info->min_short_offset);
   3203  1.1.1.2.4.2  tls       if (max_short_vma
   3204  1.1.1.2.4.2  tls 	  < (ia64_info->max_short_sec->vma
   3205  1.1.1.2.4.2  tls 	     + ia64_info->max_short_offset))
   3206  1.1.1.2.4.2  tls 	max_short_vma = (ia64_info->max_short_sec->vma
   3207  1.1.1.2.4.2  tls 			 + ia64_info->max_short_offset);
   3208  1.1.1.2.4.2  tls     }
   3209  1.1.1.2.4.2  tls 
   3210  1.1.1.2.4.2  tls   /* See if the user wants to force a value.  */
   3211  1.1.1.2.4.2  tls   gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
   3212  1.1.1.2.4.2  tls 			     FALSE, FALSE);
   3213  1.1.1.2.4.2  tls 
   3214  1.1.1.2.4.2  tls   if (gp
   3215  1.1.1.2.4.2  tls       && (gp->root.type == bfd_link_hash_defined
   3216  1.1.1.2.4.2  tls 	  || gp->root.type == bfd_link_hash_defweak))
   3217  1.1.1.2.4.2  tls     {
   3218  1.1.1.2.4.2  tls       asection *gp_sec = gp->root.u.def.section;
   3219  1.1.1.2.4.2  tls       gp_val = (gp->root.u.def.value
   3220  1.1.1.2.4.2  tls 		+ gp_sec->output_section->vma
   3221  1.1.1.2.4.2  tls 		+ gp_sec->output_offset);
   3222  1.1.1.2.4.2  tls     }
   3223  1.1.1.2.4.2  tls   else
   3224  1.1.1.2.4.2  tls     {
   3225  1.1.1.2.4.2  tls       /* Pick a sensible value.  */
   3226  1.1.1.2.4.2  tls 
   3227  1.1.1.2.4.2  tls       if (ia64_info->min_short_sec)
   3228  1.1.1.2.4.2  tls 	{
   3229  1.1.1.2.4.2  tls 	  bfd_vma short_range = max_short_vma - min_short_vma;
   3230  1.1.1.2.4.2  tls 
   3231  1.1.1.2.4.2  tls 	  /* If min_short_sec is set, pick one in the middle bewteen
   3232  1.1.1.2.4.2  tls 	     min_short_vma and max_short_vma.  */
   3233  1.1.1.2.4.2  tls 	  if (short_range >= 0x400000)
   3234  1.1.1.2.4.2  tls 	    goto overflow;
   3235  1.1.1.2.4.2  tls 	  gp_val = min_short_vma + short_range / 2;
   3236  1.1.1.2.4.2  tls 	}
   3237  1.1.1.2.4.2  tls       else
   3238  1.1.1.2.4.2  tls 	{
   3239  1.1.1.2.4.2  tls 	  asection *got_sec = ia64_info->root.sgot;
   3240  1.1.1.2.4.2  tls 
   3241  1.1.1.2.4.2  tls 	  /* Start with just the address of the .got.  */
   3242  1.1.1.2.4.2  tls 	  if (got_sec)
   3243  1.1.1.2.4.2  tls 	    gp_val = got_sec->output_section->vma;
   3244  1.1.1.2.4.2  tls 	  else if (max_short_vma != 0)
   3245  1.1.1.2.4.2  tls 	    gp_val = min_short_vma;
   3246  1.1.1.2.4.2  tls 	  else if (max_vma - min_vma < 0x200000)
   3247  1.1.1.2.4.2  tls 	    gp_val = min_vma;
   3248  1.1.1.2.4.2  tls 	  else
   3249  1.1.1.2.4.2  tls 	    gp_val = max_vma - 0x200000 + 8;
   3250  1.1.1.2.4.2  tls 	}
   3251  1.1.1.2.4.2  tls 
   3252  1.1.1.2.4.2  tls       /* If it is possible to address the entire image, but we
   3253  1.1.1.2.4.2  tls 	 don't with the choice above, adjust.  */
   3254  1.1.1.2.4.2  tls       if (max_vma - min_vma < 0x400000
   3255  1.1.1.2.4.2  tls 	  && (max_vma - gp_val >= 0x200000
   3256  1.1.1.2.4.2  tls 	      || gp_val - min_vma > 0x200000))
   3257  1.1.1.2.4.2  tls 	gp_val = min_vma + 0x200000;
   3258  1.1.1.2.4.2  tls       else if (max_short_vma != 0)
   3259  1.1.1.2.4.2  tls 	{
   3260  1.1.1.2.4.2  tls 	  /* If we don't cover all the short data, adjust.  */
   3261  1.1.1.2.4.2  tls 	  if (max_short_vma - gp_val >= 0x200000)
   3262  1.1.1.2.4.2  tls 	    gp_val = min_short_vma + 0x200000;
   3263  1.1.1.2.4.2  tls 
   3264  1.1.1.2.4.2  tls 	  /* If we're addressing stuff past the end, adjust back.  */
   3265  1.1.1.2.4.2  tls 	  if (gp_val > max_vma)
   3266  1.1.1.2.4.2  tls 	    gp_val = max_vma - 0x200000 + 8;
   3267  1.1.1.2.4.2  tls 	}
   3268  1.1.1.2.4.2  tls     }
   3269  1.1.1.2.4.2  tls 
   3270  1.1.1.2.4.2  tls   /* Validate whether all SHF_IA_64_SHORT sections are within
   3271  1.1.1.2.4.2  tls      range of the chosen GP.  */
   3272  1.1.1.2.4.2  tls 
   3273  1.1.1.2.4.2  tls   if (max_short_vma != 0)
   3274  1.1.1.2.4.2  tls     {
   3275  1.1.1.2.4.2  tls       if (max_short_vma - min_short_vma >= 0x400000)
   3276  1.1.1.2.4.2  tls 	{
   3277  1.1.1.2.4.2  tls overflow:
   3278  1.1.1.2.4.2  tls 	  (*_bfd_error_handler)
   3279  1.1.1.2.4.2  tls 	    (_("%s: short data segment overflowed (0x%lx >= 0x400000)"),
   3280  1.1.1.2.4.2  tls 	     bfd_get_filename (abfd),
   3281  1.1.1.2.4.2  tls 	     (unsigned long) (max_short_vma - min_short_vma));
   3282  1.1.1.2.4.2  tls 	  return FALSE;
   3283  1.1.1.2.4.2  tls 	}
   3284  1.1.1.2.4.2  tls       else if ((gp_val > min_short_vma
   3285  1.1.1.2.4.2  tls 		&& gp_val - min_short_vma > 0x200000)
   3286  1.1.1.2.4.2  tls 	       || (gp_val < max_short_vma
   3287  1.1.1.2.4.2  tls 		   && max_short_vma - gp_val >= 0x200000))
   3288  1.1.1.2.4.2  tls 	{
   3289  1.1.1.2.4.2  tls 	  (*_bfd_error_handler)
   3290  1.1.1.2.4.2  tls 	    (_("%s: __gp does not cover short data segment"),
   3291  1.1.1.2.4.2  tls 	     bfd_get_filename (abfd));
   3292  1.1.1.2.4.2  tls 	  return FALSE;
   3293  1.1.1.2.4.2  tls 	}
   3294  1.1.1.2.4.2  tls     }
   3295  1.1.1.2.4.2  tls 
   3296  1.1.1.2.4.2  tls   _bfd_set_gp_value (abfd, gp_val);
   3297  1.1.1.2.4.2  tls 
   3298  1.1.1.2.4.2  tls   return TRUE;
   3299  1.1.1.2.4.2  tls }
   3300  1.1.1.2.4.2  tls 
   3301  1.1.1.2.4.2  tls static bfd_boolean
   3302  1.1.1.2.4.2  tls elf64_ia64_final_link (bfd *abfd, struct bfd_link_info *info)
   3303  1.1.1.2.4.2  tls {
   3304  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   3305  1.1.1.2.4.2  tls   asection *unwind_output_sec;
   3306  1.1.1.2.4.2  tls 
   3307  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   3308  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   3309  1.1.1.2.4.2  tls     return FALSE;
   3310  1.1.1.2.4.2  tls 
   3311  1.1.1.2.4.2  tls   /* Make sure we've got ourselves a nice fat __gp value.  */
   3312  1.1.1.2.4.2  tls   if (!info->relocatable)
   3313  1.1.1.2.4.2  tls     {
   3314  1.1.1.2.4.2  tls       bfd_vma gp_val;
   3315  1.1.1.2.4.2  tls       struct elf_link_hash_entry *gp;
   3316  1.1.1.2.4.2  tls 
   3317  1.1.1.2.4.2  tls       /* We assume after gp is set, section size will only decrease. We
   3318  1.1.1.2.4.2  tls 	 need to adjust gp for it.  */
   3319  1.1.1.2.4.2  tls       _bfd_set_gp_value (abfd, 0);
   3320  1.1.1.2.4.2  tls       if (! elf64_ia64_choose_gp (abfd, info, TRUE))
   3321  1.1.1.2.4.2  tls 	return FALSE;
   3322  1.1.1.2.4.2  tls       gp_val = _bfd_get_gp_value (abfd);
   3323  1.1.1.2.4.2  tls 
   3324  1.1.1.2.4.2  tls       gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
   3325  1.1.1.2.4.2  tls 			         FALSE, FALSE);
   3326  1.1.1.2.4.2  tls       if (gp)
   3327  1.1.1.2.4.2  tls 	{
   3328  1.1.1.2.4.2  tls 	  gp->root.type = bfd_link_hash_defined;
   3329  1.1.1.2.4.2  tls 	  gp->root.u.def.value = gp_val;
   3330  1.1.1.2.4.2  tls 	  gp->root.u.def.section = bfd_abs_section_ptr;
   3331  1.1.1.2.4.2  tls 	}
   3332  1.1.1.2.4.2  tls     }
   3333  1.1.1.2.4.2  tls 
   3334  1.1.1.2.4.2  tls   /* If we're producing a final executable, we need to sort the contents
   3335  1.1.1.2.4.2  tls      of the .IA_64.unwind section.  Force this section to be relocated
   3336  1.1.1.2.4.2  tls      into memory rather than written immediately to the output file.  */
   3337  1.1.1.2.4.2  tls   unwind_output_sec = NULL;
   3338  1.1.1.2.4.2  tls   if (!info->relocatable)
   3339  1.1.1.2.4.2  tls     {
   3340  1.1.1.2.4.2  tls       asection *s = bfd_get_section_by_name (abfd, ELF_STRING_ia64_unwind);
   3341  1.1.1.2.4.2  tls       if (s)
   3342  1.1.1.2.4.2  tls 	{
   3343  1.1.1.2.4.2  tls 	  unwind_output_sec = s->output_section;
   3344  1.1.1.2.4.2  tls 	  unwind_output_sec->contents
   3345  1.1.1.2.4.2  tls 	    = bfd_malloc (unwind_output_sec->size);
   3346  1.1.1.2.4.2  tls 	  if (unwind_output_sec->contents == NULL)
   3347  1.1.1.2.4.2  tls 	    return FALSE;
   3348  1.1.1.2.4.2  tls 	}
   3349  1.1.1.2.4.2  tls     }
   3350  1.1.1.2.4.2  tls 
   3351  1.1.1.2.4.2  tls   /* Invoke the regular ELF backend linker to do all the work.  */
   3352  1.1.1.2.4.2  tls   if (!bfd_elf_final_link (abfd, info))
   3353  1.1.1.2.4.2  tls     return FALSE;
   3354  1.1.1.2.4.2  tls 
   3355  1.1.1.2.4.2  tls   if (unwind_output_sec)
   3356  1.1.1.2.4.2  tls     {
   3357  1.1.1.2.4.2  tls       elf64_ia64_unwind_entry_compare_bfd = abfd;
   3358  1.1.1.2.4.2  tls       qsort (unwind_output_sec->contents,
   3359  1.1.1.2.4.2  tls 	     (size_t) (unwind_output_sec->size / 24),
   3360  1.1.1.2.4.2  tls 	     24,
   3361  1.1.1.2.4.2  tls 	     elf64_ia64_unwind_entry_compare);
   3362  1.1.1.2.4.2  tls 
   3363  1.1.1.2.4.2  tls       if (! bfd_set_section_contents (abfd, unwind_output_sec,
   3364  1.1.1.2.4.2  tls 				      unwind_output_sec->contents, (bfd_vma) 0,
   3365  1.1.1.2.4.2  tls 				      unwind_output_sec->size))
   3366  1.1.1.2.4.2  tls 	return FALSE;
   3367  1.1.1.2.4.2  tls     }
   3368  1.1.1.2.4.2  tls 
   3369  1.1.1.2.4.2  tls   return TRUE;
   3370  1.1.1.2.4.2  tls }
   3371  1.1.1.2.4.2  tls 
   3372  1.1.1.2.4.2  tls static bfd_boolean
   3373  1.1.1.2.4.2  tls elf64_ia64_relocate_section (bfd *output_bfd,
   3374  1.1.1.2.4.2  tls 			     struct bfd_link_info *info,
   3375  1.1.1.2.4.2  tls 			     bfd *input_bfd,
   3376  1.1.1.2.4.2  tls 			     asection *input_section,
   3377  1.1.1.2.4.2  tls 			     bfd_byte *contents,
   3378  1.1.1.2.4.2  tls 			     Elf_Internal_Rela *relocs,
   3379  1.1.1.2.4.2  tls 			     Elf_Internal_Sym *local_syms,
   3380  1.1.1.2.4.2  tls 			     asection **local_sections)
   3381  1.1.1.2.4.2  tls {
   3382  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   3383  1.1.1.2.4.2  tls   Elf_Internal_Shdr *symtab_hdr;
   3384  1.1.1.2.4.2  tls   Elf_Internal_Rela *rel;
   3385  1.1.1.2.4.2  tls   Elf_Internal_Rela *relend;
   3386  1.1.1.2.4.2  tls   bfd_boolean ret_val = TRUE;	/* for non-fatal errors */
   3387  1.1.1.2.4.2  tls   bfd_vma gp_val;
   3388  1.1.1.2.4.2  tls 
   3389  1.1.1.2.4.2  tls   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   3390  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   3391  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   3392  1.1.1.2.4.2  tls     return FALSE;
   3393  1.1.1.2.4.2  tls 
   3394  1.1.1.2.4.2  tls   /* Infect various flags from the input section to the output section.  */
   3395  1.1.1.2.4.2  tls   if (info->relocatable)
   3396  1.1.1.2.4.2  tls     {
   3397  1.1.1.2.4.2  tls       bfd_vma flags;
   3398  1.1.1.2.4.2  tls 
   3399  1.1.1.2.4.2  tls       flags = elf_section_data(input_section)->this_hdr.sh_flags;
   3400  1.1.1.2.4.2  tls       flags &= SHF_IA_64_NORECOV;
   3401  1.1.1.2.4.2  tls 
   3402  1.1.1.2.4.2  tls       elf_section_data(input_section->output_section)
   3403  1.1.1.2.4.2  tls 	->this_hdr.sh_flags |= flags;
   3404  1.1.1.2.4.2  tls     }
   3405  1.1.1.2.4.2  tls 
   3406  1.1.1.2.4.2  tls   gp_val = _bfd_get_gp_value (output_bfd);
   3407  1.1.1.2.4.2  tls 
   3408  1.1.1.2.4.2  tls   rel = relocs;
   3409  1.1.1.2.4.2  tls   relend = relocs + input_section->reloc_count;
   3410  1.1.1.2.4.2  tls   for (; rel < relend; ++rel)
   3411  1.1.1.2.4.2  tls     {
   3412  1.1.1.2.4.2  tls       struct elf_link_hash_entry *h;
   3413  1.1.1.2.4.2  tls       struct elf64_ia64_dyn_sym_info *dyn_i;
   3414  1.1.1.2.4.2  tls       bfd_reloc_status_type r;
   3415  1.1.1.2.4.2  tls       reloc_howto_type *howto;
   3416  1.1.1.2.4.2  tls       unsigned long r_symndx;
   3417  1.1.1.2.4.2  tls       Elf_Internal_Sym *sym;
   3418  1.1.1.2.4.2  tls       unsigned int r_type;
   3419  1.1.1.2.4.2  tls       bfd_vma value;
   3420  1.1.1.2.4.2  tls       asection *sym_sec;
   3421  1.1.1.2.4.2  tls       bfd_byte *hit_addr;
   3422  1.1.1.2.4.2  tls       bfd_boolean dynamic_symbol_p;
   3423  1.1.1.2.4.2  tls       bfd_boolean undef_weak_ref;
   3424  1.1.1.2.4.2  tls 
   3425  1.1.1.2.4.2  tls       r_type = ELF64_R_TYPE (rel->r_info);
   3426  1.1.1.2.4.2  tls       if (r_type > R_IA64_MAX_RELOC_CODE)
   3427  1.1.1.2.4.2  tls 	{
   3428  1.1.1.2.4.2  tls 	  (*_bfd_error_handler)
   3429  1.1.1.2.4.2  tls 	    (_("%B: unknown relocation type %d"),
   3430  1.1.1.2.4.2  tls 	     input_bfd, (int) r_type);
   3431  1.1.1.2.4.2  tls 	  bfd_set_error (bfd_error_bad_value);
   3432  1.1.1.2.4.2  tls 	  ret_val = FALSE;
   3433  1.1.1.2.4.2  tls 	  continue;
   3434  1.1.1.2.4.2  tls 	}
   3435  1.1.1.2.4.2  tls 
   3436  1.1.1.2.4.2  tls       howto = ia64_elf_lookup_howto (r_type);
   3437  1.1.1.2.4.2  tls       r_symndx = ELF64_R_SYM (rel->r_info);
   3438  1.1.1.2.4.2  tls       h = NULL;
   3439  1.1.1.2.4.2  tls       sym = NULL;
   3440  1.1.1.2.4.2  tls       sym_sec = NULL;
   3441  1.1.1.2.4.2  tls       undef_weak_ref = FALSE;
   3442  1.1.1.2.4.2  tls 
   3443  1.1.1.2.4.2  tls       if (r_symndx < symtab_hdr->sh_info)
   3444  1.1.1.2.4.2  tls 	{
   3445  1.1.1.2.4.2  tls 	  /* Reloc against local symbol.  */
   3446  1.1.1.2.4.2  tls 	  asection *msec;
   3447  1.1.1.2.4.2  tls 	  sym = local_syms + r_symndx;
   3448  1.1.1.2.4.2  tls 	  sym_sec = local_sections[r_symndx];
   3449  1.1.1.2.4.2  tls 	  msec = sym_sec;
   3450  1.1.1.2.4.2  tls 	  value = _bfd_elf_rela_local_sym (output_bfd, sym, &msec, rel);
   3451  1.1.1.2.4.2  tls 	  if (!info->relocatable
   3452  1.1.1.2.4.2  tls 	      && (sym_sec->flags & SEC_MERGE) != 0
   3453  1.1.1.2.4.2  tls 	      && ELF_ST_TYPE (sym->st_info) == STT_SECTION
   3454  1.1.1.2.4.2  tls 	      && sym_sec->sec_info_type == SEC_INFO_TYPE_MERGE)
   3455  1.1.1.2.4.2  tls 	    {
   3456  1.1.1.2.4.2  tls 	      struct elf64_ia64_local_hash_entry *loc_h;
   3457  1.1.1.2.4.2  tls 
   3458  1.1.1.2.4.2  tls 	      loc_h = get_local_sym_hash (ia64_info, input_bfd, rel, FALSE);
   3459  1.1.1.2.4.2  tls 	      if (loc_h && ! loc_h->sec_merge_done)
   3460  1.1.1.2.4.2  tls 		{
   3461  1.1.1.2.4.2  tls 		  struct elf64_ia64_dyn_sym_info *dynent;
   3462  1.1.1.2.4.2  tls 		  unsigned int count;
   3463  1.1.1.2.4.2  tls 
   3464  1.1.1.2.4.2  tls 		  for (count = loc_h->count, dynent = loc_h->info;
   3465  1.1.1.2.4.2  tls 		       count != 0;
   3466  1.1.1.2.4.2  tls 		       count--, dynent++)
   3467  1.1.1.2.4.2  tls 		    {
   3468  1.1.1.2.4.2  tls 		      msec = sym_sec;
   3469  1.1.1.2.4.2  tls 		      dynent->addend =
   3470  1.1.1.2.4.2  tls 			_bfd_merged_section_offset (output_bfd, &msec,
   3471  1.1.1.2.4.2  tls 						    elf_section_data (msec)->
   3472  1.1.1.2.4.2  tls 						    sec_info,
   3473  1.1.1.2.4.2  tls 						    sym->st_value
   3474  1.1.1.2.4.2  tls 						    + dynent->addend);
   3475  1.1.1.2.4.2  tls 		      dynent->addend -= sym->st_value;
   3476  1.1.1.2.4.2  tls 		      dynent->addend += msec->output_section->vma
   3477  1.1.1.2.4.2  tls 					+ msec->output_offset
   3478  1.1.1.2.4.2  tls 					- sym_sec->output_section->vma
   3479  1.1.1.2.4.2  tls 					- sym_sec->output_offset;
   3480  1.1.1.2.4.2  tls 		    }
   3481  1.1.1.2.4.2  tls 
   3482  1.1.1.2.4.2  tls 		  /* We may have introduced duplicated entries. We need
   3483  1.1.1.2.4.2  tls 		     to remove them properly.  */
   3484  1.1.1.2.4.2  tls 		  count = sort_dyn_sym_info (loc_h->info, loc_h->count);
   3485  1.1.1.2.4.2  tls 		  if (count != loc_h->count)
   3486  1.1.1.2.4.2  tls 		    {
   3487  1.1.1.2.4.2  tls 		      loc_h->count = count;
   3488  1.1.1.2.4.2  tls 		      loc_h->sorted_count = count;
   3489  1.1.1.2.4.2  tls 		    }
   3490  1.1.1.2.4.2  tls 
   3491  1.1.1.2.4.2  tls 		  loc_h->sec_merge_done = 1;
   3492  1.1.1.2.4.2  tls 		}
   3493  1.1.1.2.4.2  tls 	    }
   3494  1.1.1.2.4.2  tls 	}
   3495  1.1.1.2.4.2  tls       else
   3496  1.1.1.2.4.2  tls 	{
   3497  1.1.1.2.4.2  tls 	  bfd_boolean unresolved_reloc;
   3498  1.1.1.2.4.2  tls 	  bfd_boolean warned, ignored;
   3499  1.1.1.2.4.2  tls 	  struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
   3500  1.1.1.2.4.2  tls 
   3501  1.1.1.2.4.2  tls 	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
   3502  1.1.1.2.4.2  tls 				   r_symndx, symtab_hdr, sym_hashes,
   3503  1.1.1.2.4.2  tls 				   h, sym_sec, value,
   3504  1.1.1.2.4.2  tls 				   unresolved_reloc, warned, ignored);
   3505  1.1.1.2.4.2  tls 
   3506  1.1.1.2.4.2  tls 	  if (h->root.type == bfd_link_hash_undefweak)
   3507  1.1.1.2.4.2  tls 	    undef_weak_ref = TRUE;
   3508  1.1.1.2.4.2  tls 	  else if (warned)
   3509  1.1.1.2.4.2  tls 	    continue;
   3510  1.1.1.2.4.2  tls 	}
   3511  1.1.1.2.4.2  tls 
   3512  1.1.1.2.4.2  tls       /* For relocs against symbols from removed linkonce sections,
   3513  1.1.1.2.4.2  tls 	 or sections discarded by a linker script, we just want the
   3514  1.1.1.2.4.2  tls 	 section contents zeroed.  Avoid any special processing.  */
   3515  1.1.1.2.4.2  tls       if (sym_sec != NULL && discarded_section (sym_sec))
   3516  1.1.1.2.4.2  tls 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
   3517  1.1.1.2.4.2  tls 					 rel, 1, relend, howto, 0, contents);
   3518  1.1.1.2.4.2  tls 
   3519  1.1.1.2.4.2  tls       if (info->relocatable)
   3520  1.1.1.2.4.2  tls 	continue;
   3521  1.1.1.2.4.2  tls 
   3522  1.1.1.2.4.2  tls       hit_addr = contents + rel->r_offset;
   3523  1.1.1.2.4.2  tls       value += rel->r_addend;
   3524  1.1.1.2.4.2  tls       dynamic_symbol_p = elf64_ia64_dynamic_symbol_p (h);
   3525  1.1.1.2.4.2  tls 
   3526  1.1.1.2.4.2  tls       switch (r_type)
   3527  1.1.1.2.4.2  tls 	{
   3528  1.1.1.2.4.2  tls 	case R_IA64_NONE:
   3529  1.1.1.2.4.2  tls 	case R_IA64_LDXMOV:
   3530  1.1.1.2.4.2  tls 	  continue;
   3531  1.1.1.2.4.2  tls 
   3532  1.1.1.2.4.2  tls 	case R_IA64_IMM14:
   3533  1.1.1.2.4.2  tls 	case R_IA64_IMM22:
   3534  1.1.1.2.4.2  tls 	case R_IA64_IMM64:
   3535  1.1.1.2.4.2  tls 	case R_IA64_DIR32MSB:
   3536  1.1.1.2.4.2  tls 	case R_IA64_DIR32LSB:
   3537  1.1.1.2.4.2  tls 	case R_IA64_DIR64MSB:
   3538  1.1.1.2.4.2  tls 	case R_IA64_DIR64LSB:
   3539  1.1.1.2.4.2  tls 	  /* Install a dynamic relocation for this reloc.  */
   3540  1.1.1.2.4.2  tls 	  if ((dynamic_symbol_p || info->shared)
   3541  1.1.1.2.4.2  tls 	      && r_symndx != 0
   3542  1.1.1.2.4.2  tls 	      && (input_section->flags & SEC_ALLOC) != 0)
   3543  1.1.1.2.4.2  tls 	    {
   3544  1.1.1.2.4.2  tls 	      unsigned int dyn_r_type;
   3545  1.1.1.2.4.2  tls 	      bfd_vma addend;
   3546  1.1.1.2.4.2  tls 
   3547  1.1.1.2.4.2  tls 	      switch (r_type)
   3548  1.1.1.2.4.2  tls 		{
   3549  1.1.1.2.4.2  tls 		case R_IA64_IMM14:
   3550  1.1.1.2.4.2  tls 		case R_IA64_IMM22:
   3551  1.1.1.2.4.2  tls 		case R_IA64_IMM64:
   3552  1.1.1.2.4.2  tls 		  /* ??? People shouldn't be doing non-pic code in
   3553  1.1.1.2.4.2  tls 		     shared libraries nor dynamic executables.  */
   3554  1.1.1.2.4.2  tls 		  (*_bfd_error_handler)
   3555  1.1.1.2.4.2  tls 		    (_("%B: non-pic code with imm relocation against dynamic symbol `%s'"),
   3556  1.1.1.2.4.2  tls 		     input_bfd,
   3557  1.1.1.2.4.2  tls 		     h ? h->root.root.string
   3558  1.1.1.2.4.2  tls 		       : bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
   3559  1.1.1.2.4.2  tls 					   sym_sec));
   3560  1.1.1.2.4.2  tls 		  ret_val = FALSE;
   3561  1.1.1.2.4.2  tls 		  continue;
   3562  1.1.1.2.4.2  tls 
   3563  1.1.1.2.4.2  tls 		default:
   3564  1.1.1.2.4.2  tls 		  break;
   3565  1.1.1.2.4.2  tls 		}
   3566  1.1.1.2.4.2  tls 
   3567  1.1.1.2.4.2  tls 	      /* If we don't need dynamic symbol lookup, find a
   3568  1.1.1.2.4.2  tls 		 matching RELATIVE relocation.  */
   3569  1.1.1.2.4.2  tls 	      dyn_r_type = r_type;
   3570  1.1.1.2.4.2  tls 	      if (dynamic_symbol_p)
   3571  1.1.1.2.4.2  tls 		{
   3572  1.1.1.2.4.2  tls 		  addend = rel->r_addend;
   3573  1.1.1.2.4.2  tls 		  value = 0;
   3574  1.1.1.2.4.2  tls 		}
   3575  1.1.1.2.4.2  tls 	      else
   3576  1.1.1.2.4.2  tls 		{
   3577  1.1.1.2.4.2  tls 		  addend = value;
   3578  1.1.1.2.4.2  tls 		}
   3579  1.1.1.2.4.2  tls 
   3580  1.1.1.2.4.2  tls               /* VMS: install a FIX64.  */
   3581  1.1.1.2.4.2  tls               switch (dyn_r_type)
   3582  1.1.1.2.4.2  tls                 {
   3583  1.1.1.2.4.2  tls                 case R_IA64_DIR32LSB:
   3584  1.1.1.2.4.2  tls                   dyn_r_type = R_IA64_VMS_FIX32;
   3585  1.1.1.2.4.2  tls                   break;
   3586  1.1.1.2.4.2  tls                 case R_IA64_DIR64LSB:
   3587  1.1.1.2.4.2  tls                   dyn_r_type = R_IA64_VMS_FIX64;
   3588  1.1.1.2.4.2  tls                   break;
   3589  1.1.1.2.4.2  tls                 default:
   3590  1.1.1.2.4.2  tls                   BFD_ASSERT (FALSE);
   3591  1.1.1.2.4.2  tls                   break;
   3592  1.1.1.2.4.2  tls                 }
   3593  1.1.1.2.4.2  tls               elf64_ia64_install_fixup
   3594  1.1.1.2.4.2  tls                 (output_bfd, ia64_info, h,
   3595  1.1.1.2.4.2  tls                  dyn_r_type, input_section, rel->r_offset, addend);
   3596  1.1.1.2.4.2  tls               r = bfd_reloc_ok;
   3597  1.1.1.2.4.2  tls               break;
   3598  1.1.1.2.4.2  tls 	    }
   3599  1.1.1.2.4.2  tls 	  /* Fall through.  */
   3600  1.1.1.2.4.2  tls 
   3601  1.1.1.2.4.2  tls 	case R_IA64_LTV32MSB:
   3602  1.1.1.2.4.2  tls 	case R_IA64_LTV32LSB:
   3603  1.1.1.2.4.2  tls 	case R_IA64_LTV64MSB:
   3604  1.1.1.2.4.2  tls 	case R_IA64_LTV64LSB:
   3605  1.1.1.2.4.2  tls 	  r = ia64_elf_install_value (hit_addr, value, r_type);
   3606  1.1.1.2.4.2  tls 	  break;
   3607  1.1.1.2.4.2  tls 
   3608  1.1.1.2.4.2  tls 	case R_IA64_GPREL22:
   3609  1.1.1.2.4.2  tls 	case R_IA64_GPREL64I:
   3610  1.1.1.2.4.2  tls 	case R_IA64_GPREL32MSB:
   3611  1.1.1.2.4.2  tls 	case R_IA64_GPREL32LSB:
   3612  1.1.1.2.4.2  tls 	case R_IA64_GPREL64MSB:
   3613  1.1.1.2.4.2  tls 	case R_IA64_GPREL64LSB:
   3614  1.1.1.2.4.2  tls 	  if (dynamic_symbol_p)
   3615  1.1.1.2.4.2  tls 	    {
   3616  1.1.1.2.4.2  tls 	      (*_bfd_error_handler)
   3617  1.1.1.2.4.2  tls 		(_("%B: @gprel relocation against dynamic symbol %s"),
   3618  1.1.1.2.4.2  tls 		 input_bfd,
   3619  1.1.1.2.4.2  tls 		 h ? h->root.root.string
   3620  1.1.1.2.4.2  tls 		   : bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
   3621  1.1.1.2.4.2  tls 				       sym_sec));
   3622  1.1.1.2.4.2  tls 	      ret_val = FALSE;
   3623  1.1.1.2.4.2  tls 	      continue;
   3624  1.1.1.2.4.2  tls 	    }
   3625  1.1.1.2.4.2  tls 	  value -= gp_val;
   3626  1.1.1.2.4.2  tls 	  r = ia64_elf_install_value (hit_addr, value, r_type);
   3627  1.1.1.2.4.2  tls 	  break;
   3628  1.1.1.2.4.2  tls 
   3629  1.1.1.2.4.2  tls 	case R_IA64_LTOFF22:
   3630  1.1.1.2.4.2  tls 	case R_IA64_LTOFF22X:
   3631  1.1.1.2.4.2  tls 	case R_IA64_LTOFF64I:
   3632  1.1.1.2.4.2  tls           dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
   3633  1.1.1.2.4.2  tls 	  value = set_got_entry (input_bfd, info, dyn_i,
   3634  1.1.1.2.4.2  tls 				 rel->r_addend, value, R_IA64_DIR64LSB);
   3635  1.1.1.2.4.2  tls 	  value -= gp_val;
   3636  1.1.1.2.4.2  tls 	  r = ia64_elf_install_value (hit_addr, value, r_type);
   3637  1.1.1.2.4.2  tls 	  break;
   3638  1.1.1.2.4.2  tls 
   3639  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF22:
   3640  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF64I:
   3641  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF64MSB:
   3642  1.1.1.2.4.2  tls 	case R_IA64_PLTOFF64LSB:
   3643  1.1.1.2.4.2  tls           dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
   3644  1.1.1.2.4.2  tls 	  value = set_pltoff_entry (output_bfd, info, dyn_i, value, FALSE);
   3645  1.1.1.2.4.2  tls 	  value -= gp_val;
   3646  1.1.1.2.4.2  tls 	  r = ia64_elf_install_value (hit_addr, value, r_type);
   3647  1.1.1.2.4.2  tls 	  break;
   3648  1.1.1.2.4.2  tls 
   3649  1.1.1.2.4.2  tls 	case R_IA64_FPTR64I:
   3650  1.1.1.2.4.2  tls 	case R_IA64_FPTR32MSB:
   3651  1.1.1.2.4.2  tls 	case R_IA64_FPTR32LSB:
   3652  1.1.1.2.4.2  tls 	case R_IA64_FPTR64MSB:
   3653  1.1.1.2.4.2  tls 	case R_IA64_FPTR64LSB:
   3654  1.1.1.2.4.2  tls           dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
   3655  1.1.1.2.4.2  tls 	  if (dyn_i->want_fptr)
   3656  1.1.1.2.4.2  tls 	    {
   3657  1.1.1.2.4.2  tls 	      if (!undef_weak_ref)
   3658  1.1.1.2.4.2  tls 		value = set_fptr_entry (output_bfd, info, dyn_i, value);
   3659  1.1.1.2.4.2  tls 	    }
   3660  1.1.1.2.4.2  tls 	  if (!dyn_i->want_fptr || info->pie)
   3661  1.1.1.2.4.2  tls 	    {
   3662  1.1.1.2.4.2  tls 	      /* Otherwise, we expect the dynamic linker to create
   3663  1.1.1.2.4.2  tls 		 the entry.  */
   3664  1.1.1.2.4.2  tls 
   3665  1.1.1.2.4.2  tls 	      if (dyn_i->want_fptr)
   3666  1.1.1.2.4.2  tls 		{
   3667  1.1.1.2.4.2  tls 		  if (r_type == R_IA64_FPTR64I)
   3668  1.1.1.2.4.2  tls 		    {
   3669  1.1.1.2.4.2  tls 		      /* We can't represent this without a dynamic symbol.
   3670  1.1.1.2.4.2  tls 			 Adjust the relocation to be against an output
   3671  1.1.1.2.4.2  tls 			 section symbol, which are always present in the
   3672  1.1.1.2.4.2  tls 			 dynamic symbol table.  */
   3673  1.1.1.2.4.2  tls 		      /* ??? People shouldn't be doing non-pic code in
   3674  1.1.1.2.4.2  tls 			 shared libraries.  Hork.  */
   3675  1.1.1.2.4.2  tls 		      (*_bfd_error_handler)
   3676  1.1.1.2.4.2  tls 			(_("%B: linking non-pic code in a position independent executable"),
   3677  1.1.1.2.4.2  tls 			 input_bfd);
   3678  1.1.1.2.4.2  tls 		      ret_val = FALSE;
   3679  1.1.1.2.4.2  tls 		      continue;
   3680  1.1.1.2.4.2  tls 		    }
   3681  1.1.1.2.4.2  tls 		}
   3682  1.1.1.2.4.2  tls 	      else
   3683  1.1.1.2.4.2  tls 		{
   3684  1.1.1.2.4.2  tls 		  value = 0;
   3685  1.1.1.2.4.2  tls 		}
   3686  1.1.1.2.4.2  tls 
   3687  1.1.1.2.4.2  tls               /* VMS: FIXFD.  */
   3688  1.1.1.2.4.2  tls               elf64_ia64_install_fixup
   3689  1.1.1.2.4.2  tls                 (output_bfd, ia64_info, h, R_IA64_VMS_FIXFD,
   3690  1.1.1.2.4.2  tls                  input_section, rel->r_offset, 0);
   3691  1.1.1.2.4.2  tls               r = bfd_reloc_ok;
   3692  1.1.1.2.4.2  tls               break;
   3693  1.1.1.2.4.2  tls 	    }
   3694  1.1.1.2.4.2  tls 
   3695  1.1.1.2.4.2  tls 	  r = ia64_elf_install_value (hit_addr, value, r_type);
   3696  1.1.1.2.4.2  tls 	  break;
   3697  1.1.1.2.4.2  tls 
   3698  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR22:
   3699  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR64I:
   3700  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR32MSB:
   3701  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR32LSB:
   3702  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR64MSB:
   3703  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_FPTR64LSB:
   3704  1.1.1.2.4.2  tls           dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
   3705  1.1.1.2.4.2  tls           if (dyn_i->want_fptr)
   3706  1.1.1.2.4.2  tls             {
   3707  1.1.1.2.4.2  tls               BFD_ASSERT (h == NULL || !h->def_dynamic);
   3708  1.1.1.2.4.2  tls               if (!undef_weak_ref)
   3709  1.1.1.2.4.2  tls                 value = set_fptr_entry (output_bfd, info, dyn_i, value);
   3710  1.1.1.2.4.2  tls             }
   3711  1.1.1.2.4.2  tls           else
   3712  1.1.1.2.4.2  tls             value = 0;
   3713  1.1.1.2.4.2  tls 
   3714  1.1.1.2.4.2  tls           value = set_got_entry (output_bfd, info, dyn_i,
   3715  1.1.1.2.4.2  tls                                  rel->r_addend, value, R_IA64_FPTR64LSB);
   3716  1.1.1.2.4.2  tls           value -= gp_val;
   3717  1.1.1.2.4.2  tls           r = ia64_elf_install_value (hit_addr, value, r_type);
   3718  1.1.1.2.4.2  tls 	  break;
   3719  1.1.1.2.4.2  tls 
   3720  1.1.1.2.4.2  tls 	case R_IA64_PCREL32MSB:
   3721  1.1.1.2.4.2  tls 	case R_IA64_PCREL32LSB:
   3722  1.1.1.2.4.2  tls 	case R_IA64_PCREL64MSB:
   3723  1.1.1.2.4.2  tls 	case R_IA64_PCREL64LSB:
   3724  1.1.1.2.4.2  tls 	  /* Install a dynamic relocation for this reloc.  */
   3725  1.1.1.2.4.2  tls 	  if (dynamic_symbol_p && r_symndx != 0)
   3726  1.1.1.2.4.2  tls 	    {
   3727  1.1.1.2.4.2  tls               /* VMS: doesn't exist ???  */
   3728  1.1.1.2.4.2  tls               abort ();
   3729  1.1.1.2.4.2  tls 	    }
   3730  1.1.1.2.4.2  tls 	  goto finish_pcrel;
   3731  1.1.1.2.4.2  tls 
   3732  1.1.1.2.4.2  tls 	case R_IA64_PCREL21B:
   3733  1.1.1.2.4.2  tls 	case R_IA64_PCREL60B:
   3734  1.1.1.2.4.2  tls 	  /* We should have created a PLT entry for any dynamic symbol.  */
   3735  1.1.1.2.4.2  tls 	  dyn_i = NULL;
   3736  1.1.1.2.4.2  tls 	  if (h)
   3737  1.1.1.2.4.2  tls 	    dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, FALSE);
   3738  1.1.1.2.4.2  tls 
   3739  1.1.1.2.4.2  tls 	  if (dyn_i && dyn_i->want_plt2)
   3740  1.1.1.2.4.2  tls 	    {
   3741  1.1.1.2.4.2  tls 	      /* Should have caught this earlier.  */
   3742  1.1.1.2.4.2  tls 	      BFD_ASSERT (rel->r_addend == 0);
   3743  1.1.1.2.4.2  tls 
   3744  1.1.1.2.4.2  tls 	      value = (ia64_info->root.splt->output_section->vma
   3745  1.1.1.2.4.2  tls 		       + ia64_info->root.splt->output_offset
   3746  1.1.1.2.4.2  tls 		       + dyn_i->plt2_offset);
   3747  1.1.1.2.4.2  tls 	    }
   3748  1.1.1.2.4.2  tls 	  else
   3749  1.1.1.2.4.2  tls 	    {
   3750  1.1.1.2.4.2  tls 	      /* Since there's no PLT entry, Validate that this is
   3751  1.1.1.2.4.2  tls 		 locally defined.  */
   3752  1.1.1.2.4.2  tls 	      BFD_ASSERT (undef_weak_ref || sym_sec->output_section != NULL);
   3753  1.1.1.2.4.2  tls 
   3754  1.1.1.2.4.2  tls 	      /* If the symbol is undef_weak, we shouldn't be trying
   3755  1.1.1.2.4.2  tls 		 to call it.  There's every chance that we'd wind up
   3756  1.1.1.2.4.2  tls 		 with an out-of-range fixup here.  Don't bother setting
   3757  1.1.1.2.4.2  tls 		 any value at all.  */
   3758  1.1.1.2.4.2  tls 	      if (undef_weak_ref)
   3759  1.1.1.2.4.2  tls 		continue;
   3760  1.1.1.2.4.2  tls 	    }
   3761  1.1.1.2.4.2  tls 	  goto finish_pcrel;
   3762  1.1.1.2.4.2  tls 
   3763  1.1.1.2.4.2  tls 	case R_IA64_PCREL21BI:
   3764  1.1.1.2.4.2  tls 	case R_IA64_PCREL21F:
   3765  1.1.1.2.4.2  tls 	case R_IA64_PCREL21M:
   3766  1.1.1.2.4.2  tls 	case R_IA64_PCREL22:
   3767  1.1.1.2.4.2  tls 	case R_IA64_PCREL64I:
   3768  1.1.1.2.4.2  tls 	  /* The PCREL21BI reloc is specifically not intended for use with
   3769  1.1.1.2.4.2  tls 	     dynamic relocs.  PCREL21F and PCREL21M are used for speculation
   3770  1.1.1.2.4.2  tls 	     fixup code, and thus probably ought not be dynamic.  The
   3771  1.1.1.2.4.2  tls 	     PCREL22 and PCREL64I relocs aren't emitted as dynamic relocs.  */
   3772  1.1.1.2.4.2  tls 	  if (dynamic_symbol_p)
   3773  1.1.1.2.4.2  tls 	    {
   3774  1.1.1.2.4.2  tls 	      const char *msg;
   3775  1.1.1.2.4.2  tls 
   3776  1.1.1.2.4.2  tls 	      if (r_type == R_IA64_PCREL21BI)
   3777  1.1.1.2.4.2  tls 		msg = _("%B: @internal branch to dynamic symbol %s");
   3778  1.1.1.2.4.2  tls 	      else if (r_type == R_IA64_PCREL21F || r_type == R_IA64_PCREL21M)
   3779  1.1.1.2.4.2  tls 		msg = _("%B: speculation fixup to dynamic symbol %s");
   3780  1.1.1.2.4.2  tls 	      else
   3781  1.1.1.2.4.2  tls 		msg = _("%B: @pcrel relocation against dynamic symbol %s");
   3782  1.1.1.2.4.2  tls 	      (*_bfd_error_handler) (msg, input_bfd,
   3783  1.1.1.2.4.2  tls 				     h ? h->root.root.string
   3784  1.1.1.2.4.2  tls 				       : bfd_elf_sym_name (input_bfd,
   3785  1.1.1.2.4.2  tls 							   symtab_hdr,
   3786  1.1.1.2.4.2  tls 							   sym,
   3787  1.1.1.2.4.2  tls 							   sym_sec));
   3788  1.1.1.2.4.2  tls 	      ret_val = FALSE;
   3789  1.1.1.2.4.2  tls 	      continue;
   3790  1.1.1.2.4.2  tls 	    }
   3791  1.1.1.2.4.2  tls 	  goto finish_pcrel;
   3792  1.1.1.2.4.2  tls 
   3793  1.1.1.2.4.2  tls 	finish_pcrel:
   3794  1.1.1.2.4.2  tls 	  /* Make pc-relative.  */
   3795  1.1.1.2.4.2  tls 	  value -= (input_section->output_section->vma
   3796  1.1.1.2.4.2  tls 		    + input_section->output_offset
   3797  1.1.1.2.4.2  tls 		    + rel->r_offset) & ~ (bfd_vma) 0x3;
   3798  1.1.1.2.4.2  tls 	  r = ia64_elf_install_value (hit_addr, value, r_type);
   3799  1.1.1.2.4.2  tls 	  break;
   3800  1.1.1.2.4.2  tls 
   3801  1.1.1.2.4.2  tls 	case R_IA64_SEGREL32MSB:
   3802  1.1.1.2.4.2  tls 	case R_IA64_SEGREL32LSB:
   3803  1.1.1.2.4.2  tls 	case R_IA64_SEGREL64MSB:
   3804  1.1.1.2.4.2  tls 	case R_IA64_SEGREL64LSB:
   3805  1.1.1.2.4.2  tls 	    {
   3806  1.1.1.2.4.2  tls 	      /* Find the segment that contains the output_section.  */
   3807  1.1.1.2.4.2  tls 	      Elf_Internal_Phdr *p = _bfd_elf_find_segment_containing_section
   3808  1.1.1.2.4.2  tls 		(output_bfd, sym_sec->output_section);
   3809  1.1.1.2.4.2  tls 
   3810  1.1.1.2.4.2  tls 	      if (p == NULL)
   3811  1.1.1.2.4.2  tls 		{
   3812  1.1.1.2.4.2  tls 		  r = bfd_reloc_notsupported;
   3813  1.1.1.2.4.2  tls 		}
   3814  1.1.1.2.4.2  tls 	      else
   3815  1.1.1.2.4.2  tls 		{
   3816  1.1.1.2.4.2  tls 		  /* The VMA of the segment is the vaddr of the associated
   3817  1.1.1.2.4.2  tls 		     program header.  */
   3818  1.1.1.2.4.2  tls 		  if (value > p->p_vaddr)
   3819  1.1.1.2.4.2  tls 		    value -= p->p_vaddr;
   3820  1.1.1.2.4.2  tls 		  else
   3821  1.1.1.2.4.2  tls 		    value = 0;
   3822  1.1.1.2.4.2  tls 		  r = ia64_elf_install_value (hit_addr, value, r_type);
   3823  1.1.1.2.4.2  tls 		}
   3824  1.1.1.2.4.2  tls 	      break;
   3825  1.1.1.2.4.2  tls 	    }
   3826  1.1.1.2.4.2  tls 
   3827  1.1.1.2.4.2  tls 	case R_IA64_SECREL32MSB:
   3828  1.1.1.2.4.2  tls 	case R_IA64_SECREL32LSB:
   3829  1.1.1.2.4.2  tls 	case R_IA64_SECREL64MSB:
   3830  1.1.1.2.4.2  tls 	case R_IA64_SECREL64LSB:
   3831  1.1.1.2.4.2  tls 	  /* Make output-section relative to section where the symbol
   3832  1.1.1.2.4.2  tls 	     is defined. PR 475  */
   3833  1.1.1.2.4.2  tls 	  if (sym_sec)
   3834  1.1.1.2.4.2  tls 	    value -= sym_sec->output_section->vma;
   3835  1.1.1.2.4.2  tls 	  r = ia64_elf_install_value (hit_addr, value, r_type);
   3836  1.1.1.2.4.2  tls 	  break;
   3837  1.1.1.2.4.2  tls 
   3838  1.1.1.2.4.2  tls 	case R_IA64_IPLTMSB:
   3839  1.1.1.2.4.2  tls 	case R_IA64_IPLTLSB:
   3840  1.1.1.2.4.2  tls 	  /* Install a dynamic relocation for this reloc.  */
   3841  1.1.1.2.4.2  tls 	  if ((dynamic_symbol_p || info->shared)
   3842  1.1.1.2.4.2  tls 	      && (input_section->flags & SEC_ALLOC) != 0)
   3843  1.1.1.2.4.2  tls 	    {
   3844  1.1.1.2.4.2  tls               /* VMS: FIXFD ??  */
   3845  1.1.1.2.4.2  tls               abort ();
   3846  1.1.1.2.4.2  tls 	    }
   3847  1.1.1.2.4.2  tls 
   3848  1.1.1.2.4.2  tls 	  if (r_type == R_IA64_IPLTMSB)
   3849  1.1.1.2.4.2  tls 	    r_type = R_IA64_DIR64MSB;
   3850  1.1.1.2.4.2  tls 	  else
   3851  1.1.1.2.4.2  tls 	    r_type = R_IA64_DIR64LSB;
   3852  1.1.1.2.4.2  tls 	  ia64_elf_install_value (hit_addr, value, r_type);
   3853  1.1.1.2.4.2  tls 	  r = ia64_elf_install_value (hit_addr + 8, gp_val, r_type);
   3854  1.1.1.2.4.2  tls 	  break;
   3855  1.1.1.2.4.2  tls 
   3856  1.1.1.2.4.2  tls 	case R_IA64_TPREL14:
   3857  1.1.1.2.4.2  tls 	case R_IA64_TPREL22:
   3858  1.1.1.2.4.2  tls 	case R_IA64_TPREL64I:
   3859  1.1.1.2.4.2  tls 	  r = bfd_reloc_notsupported;
   3860  1.1.1.2.4.2  tls 	  break;
   3861  1.1.1.2.4.2  tls 
   3862  1.1.1.2.4.2  tls 	case R_IA64_DTPREL14:
   3863  1.1.1.2.4.2  tls 	case R_IA64_DTPREL22:
   3864  1.1.1.2.4.2  tls 	case R_IA64_DTPREL64I:
   3865  1.1.1.2.4.2  tls 	case R_IA64_DTPREL32LSB:
   3866  1.1.1.2.4.2  tls 	case R_IA64_DTPREL32MSB:
   3867  1.1.1.2.4.2  tls 	case R_IA64_DTPREL64LSB:
   3868  1.1.1.2.4.2  tls 	case R_IA64_DTPREL64MSB:
   3869  1.1.1.2.4.2  tls 	  r = bfd_reloc_notsupported;
   3870  1.1.1.2.4.2  tls 	  break;
   3871  1.1.1.2.4.2  tls 
   3872  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_TPREL22:
   3873  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_DTPMOD22:
   3874  1.1.1.2.4.2  tls 	case R_IA64_LTOFF_DTPREL22:
   3875  1.1.1.2.4.2  tls 	  r = bfd_reloc_notsupported;
   3876  1.1.1.2.4.2  tls 	  break;
   3877  1.1.1.2.4.2  tls 
   3878  1.1.1.2.4.2  tls 	default:
   3879  1.1.1.2.4.2  tls 	  r = bfd_reloc_notsupported;
   3880  1.1.1.2.4.2  tls 	  break;
   3881  1.1.1.2.4.2  tls 	}
   3882  1.1.1.2.4.2  tls 
   3883  1.1.1.2.4.2  tls       switch (r)
   3884  1.1.1.2.4.2  tls 	{
   3885  1.1.1.2.4.2  tls 	case bfd_reloc_ok:
   3886  1.1.1.2.4.2  tls 	  break;
   3887  1.1.1.2.4.2  tls 
   3888  1.1.1.2.4.2  tls 	case bfd_reloc_undefined:
   3889  1.1.1.2.4.2  tls 	  /* This can happen for global table relative relocs if
   3890  1.1.1.2.4.2  tls 	     __gp is undefined.  This is a panic situation so we
   3891  1.1.1.2.4.2  tls 	     don't try to continue.  */
   3892  1.1.1.2.4.2  tls 	  (*info->callbacks->undefined_symbol)
   3893  1.1.1.2.4.2  tls 	    (info, "__gp", input_bfd, input_section, rel->r_offset, 1);
   3894  1.1.1.2.4.2  tls 	  return FALSE;
   3895  1.1.1.2.4.2  tls 
   3896  1.1.1.2.4.2  tls 	case bfd_reloc_notsupported:
   3897  1.1.1.2.4.2  tls 	  {
   3898  1.1.1.2.4.2  tls 	    const char *name;
   3899  1.1.1.2.4.2  tls 
   3900  1.1.1.2.4.2  tls 	    if (h)
   3901  1.1.1.2.4.2  tls 	      name = h->root.root.string;
   3902  1.1.1.2.4.2  tls 	    else
   3903  1.1.1.2.4.2  tls 	      name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
   3904  1.1.1.2.4.2  tls 				       sym_sec);
   3905  1.1.1.2.4.2  tls 	    if (!(*info->callbacks->warning) (info, _("unsupported reloc"),
   3906  1.1.1.2.4.2  tls 					      name, input_bfd,
   3907  1.1.1.2.4.2  tls 					      input_section, rel->r_offset))
   3908  1.1.1.2.4.2  tls 	      return FALSE;
   3909  1.1.1.2.4.2  tls 	    ret_val = FALSE;
   3910  1.1.1.2.4.2  tls 	  }
   3911  1.1.1.2.4.2  tls 	  break;
   3912  1.1.1.2.4.2  tls 
   3913  1.1.1.2.4.2  tls 	case bfd_reloc_dangerous:
   3914  1.1.1.2.4.2  tls 	case bfd_reloc_outofrange:
   3915  1.1.1.2.4.2  tls 	case bfd_reloc_overflow:
   3916  1.1.1.2.4.2  tls 	default:
   3917  1.1.1.2.4.2  tls 	  {
   3918  1.1.1.2.4.2  tls 	    const char *name;
   3919  1.1.1.2.4.2  tls 
   3920  1.1.1.2.4.2  tls 	    if (h)
   3921  1.1.1.2.4.2  tls 	      name = h->root.root.string;
   3922  1.1.1.2.4.2  tls 	    else
   3923  1.1.1.2.4.2  tls 	      name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
   3924  1.1.1.2.4.2  tls 				       sym_sec);
   3925  1.1.1.2.4.2  tls 
   3926  1.1.1.2.4.2  tls 	    switch (r_type)
   3927  1.1.1.2.4.2  tls 	      {
   3928  1.1.1.2.4.2  tls 	      case R_IA64_TPREL14:
   3929  1.1.1.2.4.2  tls 	      case R_IA64_TPREL22:
   3930  1.1.1.2.4.2  tls 	      case R_IA64_TPREL64I:
   3931  1.1.1.2.4.2  tls 	      case R_IA64_DTPREL14:
   3932  1.1.1.2.4.2  tls 	      case R_IA64_DTPREL22:
   3933  1.1.1.2.4.2  tls 	      case R_IA64_DTPREL64I:
   3934  1.1.1.2.4.2  tls 	      case R_IA64_DTPREL32LSB:
   3935  1.1.1.2.4.2  tls 	      case R_IA64_DTPREL32MSB:
   3936  1.1.1.2.4.2  tls 	      case R_IA64_DTPREL64LSB:
   3937  1.1.1.2.4.2  tls 	      case R_IA64_DTPREL64MSB:
   3938  1.1.1.2.4.2  tls 	      case R_IA64_LTOFF_TPREL22:
   3939  1.1.1.2.4.2  tls 	      case R_IA64_LTOFF_DTPMOD22:
   3940  1.1.1.2.4.2  tls 	      case R_IA64_LTOFF_DTPREL22:
   3941  1.1.1.2.4.2  tls 		(*_bfd_error_handler)
   3942  1.1.1.2.4.2  tls 		  (_("%B: missing TLS section for relocation %s against `%s' at 0x%lx in section `%A'."),
   3943  1.1.1.2.4.2  tls 		   input_bfd, input_section, howto->name, name,
   3944  1.1.1.2.4.2  tls 		   rel->r_offset);
   3945  1.1.1.2.4.2  tls 		break;
   3946  1.1.1.2.4.2  tls 
   3947  1.1.1.2.4.2  tls 	      case R_IA64_PCREL21B:
   3948  1.1.1.2.4.2  tls 	      case R_IA64_PCREL21BI:
   3949  1.1.1.2.4.2  tls 	      case R_IA64_PCREL21M:
   3950  1.1.1.2.4.2  tls 	      case R_IA64_PCREL21F:
   3951  1.1.1.2.4.2  tls 		if (is_elf_hash_table (info->hash))
   3952  1.1.1.2.4.2  tls 		  {
   3953  1.1.1.2.4.2  tls 		    /* Relaxtion is always performed for ELF output.
   3954  1.1.1.2.4.2  tls 		       Overflow failures for those relocations mean
   3955  1.1.1.2.4.2  tls 		       that the section is too big to relax.  */
   3956  1.1.1.2.4.2  tls 		    (*_bfd_error_handler)
   3957  1.1.1.2.4.2  tls 		      (_("%B: Can't relax br (%s) to `%s' at 0x%lx in section `%A' with size 0x%lx (> 0x1000000)."),
   3958  1.1.1.2.4.2  tls 		       input_bfd, input_section, howto->name, name,
   3959  1.1.1.2.4.2  tls 		       rel->r_offset, input_section->size);
   3960  1.1.1.2.4.2  tls 		    break;
   3961  1.1.1.2.4.2  tls 		  }
   3962  1.1.1.2.4.2  tls 	      default:
   3963  1.1.1.2.4.2  tls 		if (!(*info->callbacks->reloc_overflow) (info,
   3964  1.1.1.2.4.2  tls 							 &h->root,
   3965  1.1.1.2.4.2  tls 							 name,
   3966  1.1.1.2.4.2  tls 							 howto->name,
   3967  1.1.1.2.4.2  tls 							 (bfd_vma) 0,
   3968  1.1.1.2.4.2  tls 							 input_bfd,
   3969  1.1.1.2.4.2  tls 							 input_section,
   3970  1.1.1.2.4.2  tls 							 rel->r_offset))
   3971  1.1.1.2.4.2  tls 		  return FALSE;
   3972  1.1.1.2.4.2  tls 		break;
   3973  1.1.1.2.4.2  tls 	      }
   3974  1.1.1.2.4.2  tls 
   3975  1.1.1.2.4.2  tls 	    ret_val = FALSE;
   3976  1.1.1.2.4.2  tls 	  }
   3977  1.1.1.2.4.2  tls 	  break;
   3978  1.1.1.2.4.2  tls 	}
   3979  1.1.1.2.4.2  tls     }
   3980  1.1.1.2.4.2  tls 
   3981  1.1.1.2.4.2  tls   return ret_val;
   3982  1.1.1.2.4.2  tls }
   3983  1.1.1.2.4.2  tls 
   3984  1.1.1.2.4.2  tls static bfd_boolean
   3985  1.1.1.2.4.2  tls elf64_ia64_finish_dynamic_symbol (bfd *output_bfd,
   3986  1.1.1.2.4.2  tls 				  struct bfd_link_info *info,
   3987  1.1.1.2.4.2  tls 				  struct elf_link_hash_entry *h,
   3988  1.1.1.2.4.2  tls 				  Elf_Internal_Sym *sym)
   3989  1.1.1.2.4.2  tls {
   3990  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   3991  1.1.1.2.4.2  tls   struct elf64_ia64_dyn_sym_info *dyn_i;
   3992  1.1.1.2.4.2  tls 
   3993  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   3994  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   3995  1.1.1.2.4.2  tls     return FALSE;
   3996  1.1.1.2.4.2  tls 
   3997  1.1.1.2.4.2  tls   dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, FALSE);
   3998  1.1.1.2.4.2  tls 
   3999  1.1.1.2.4.2  tls   /* Fill in the PLT data, if required.  */
   4000  1.1.1.2.4.2  tls   if (dyn_i && dyn_i->want_plt)
   4001  1.1.1.2.4.2  tls     {
   4002  1.1.1.2.4.2  tls       bfd_byte *loc;
   4003  1.1.1.2.4.2  tls       asection *plt_sec;
   4004  1.1.1.2.4.2  tls       bfd_vma plt_addr, pltoff_addr, gp_val;
   4005  1.1.1.2.4.2  tls 
   4006  1.1.1.2.4.2  tls       gp_val = _bfd_get_gp_value (output_bfd);
   4007  1.1.1.2.4.2  tls 
   4008  1.1.1.2.4.2  tls       plt_sec = ia64_info->root.splt;
   4009  1.1.1.2.4.2  tls       plt_addr = 0;  /* Not used as overriden by FIXUPs.  */
   4010  1.1.1.2.4.2  tls       pltoff_addr = set_pltoff_entry (output_bfd, info, dyn_i, plt_addr, TRUE);
   4011  1.1.1.2.4.2  tls 
   4012  1.1.1.2.4.2  tls       /* Initialize the FULL PLT entry, if needed.  */
   4013  1.1.1.2.4.2  tls       if (dyn_i->want_plt2)
   4014  1.1.1.2.4.2  tls 	{
   4015  1.1.1.2.4.2  tls 	  loc = plt_sec->contents + dyn_i->plt2_offset;
   4016  1.1.1.2.4.2  tls 
   4017  1.1.1.2.4.2  tls 	  memcpy (loc, plt_full_entry, PLT_FULL_ENTRY_SIZE);
   4018  1.1.1.2.4.2  tls 	  ia64_elf_install_value (loc, pltoff_addr - gp_val, R_IA64_IMM22);
   4019  1.1.1.2.4.2  tls 
   4020  1.1.1.2.4.2  tls 	  /* Mark the symbol as undefined, rather than as defined in the
   4021  1.1.1.2.4.2  tls 	     plt section.  Leave the value alone.  */
   4022  1.1.1.2.4.2  tls 	  /* ??? We didn't redefine it in adjust_dynamic_symbol in the
   4023  1.1.1.2.4.2  tls 	     first place.  But perhaps elflink.c did some for us.  */
   4024  1.1.1.2.4.2  tls 	  if (!h->def_regular)
   4025  1.1.1.2.4.2  tls 	    sym->st_shndx = SHN_UNDEF;
   4026  1.1.1.2.4.2  tls 	}
   4027  1.1.1.2.4.2  tls 
   4028  1.1.1.2.4.2  tls       /* VMS: FIXFD.  */
   4029  1.1.1.2.4.2  tls       elf64_ia64_install_fixup
   4030  1.1.1.2.4.2  tls         (output_bfd, ia64_info, h, R_IA64_VMS_FIXFD, ia64_info->pltoff_sec,
   4031  1.1.1.2.4.2  tls          pltoff_addr - (ia64_info->pltoff_sec->output_section->vma
   4032  1.1.1.2.4.2  tls                         + ia64_info->pltoff_sec->output_offset), 0);
   4033  1.1.1.2.4.2  tls     }
   4034  1.1.1.2.4.2  tls 
   4035  1.1.1.2.4.2  tls   /* Mark some specially defined symbols as absolute.  */
   4036  1.1.1.2.4.2  tls   if (h == ia64_info->root.hdynamic
   4037  1.1.1.2.4.2  tls       || h == ia64_info->root.hgot
   4038  1.1.1.2.4.2  tls       || h == ia64_info->root.hplt)
   4039  1.1.1.2.4.2  tls     sym->st_shndx = SHN_ABS;
   4040  1.1.1.2.4.2  tls 
   4041  1.1.1.2.4.2  tls   return TRUE;
   4042  1.1.1.2.4.2  tls }
   4043  1.1.1.2.4.2  tls 
   4044  1.1.1.2.4.2  tls static bfd_boolean
   4045  1.1.1.2.4.2  tls elf64_ia64_finish_dynamic_sections (bfd *abfd,
   4046  1.1.1.2.4.2  tls 				    struct bfd_link_info *info)
   4047  1.1.1.2.4.2  tls {
   4048  1.1.1.2.4.2  tls   struct elf64_ia64_link_hash_table *ia64_info;
   4049  1.1.1.2.4.2  tls   bfd *dynobj;
   4050  1.1.1.2.4.2  tls 
   4051  1.1.1.2.4.2  tls   ia64_info = elf64_ia64_hash_table (info);
   4052  1.1.1.2.4.2  tls   if (ia64_info == NULL)
   4053  1.1.1.2.4.2  tls     return FALSE;
   4054  1.1.1.2.4.2  tls 
   4055  1.1.1.2.4.2  tls   dynobj = ia64_info->root.dynobj;
   4056  1.1.1.2.4.2  tls 
   4057  1.1.1.2.4.2  tls   if (elf_hash_table (info)->dynamic_sections_created)
   4058  1.1.1.2.4.2  tls     {
   4059  1.1.1.2.4.2  tls       Elf64_External_Dyn *dyncon, *dynconend;
   4060  1.1.1.2.4.2  tls       asection *sdyn;
   4061  1.1.1.2.4.2  tls       asection *unwind_sec;
   4062  1.1.1.2.4.2  tls       bfd_vma gp_val;
   4063  1.1.1.2.4.2  tls       unsigned int gp_seg;
   4064  1.1.1.2.4.2  tls       bfd_vma gp_off;
   4065  1.1.1.2.4.2  tls       Elf_Internal_Phdr *phdr;
   4066  1.1.1.2.4.2  tls       Elf_Internal_Phdr *base_phdr;
   4067  1.1.1.2.4.2  tls       unsigned int unwind_seg = 0;
   4068  1.1.1.2.4.2  tls       unsigned int code_seg = 0;
   4069  1.1.1.2.4.2  tls 
   4070  1.1.1.2.4.2  tls       sdyn = bfd_get_linker_section (dynobj, ".dynamic");
   4071  1.1.1.2.4.2  tls       BFD_ASSERT (sdyn != NULL);
   4072  1.1.1.2.4.2  tls       dyncon = (Elf64_External_Dyn *) sdyn->contents;
   4073  1.1.1.2.4.2  tls       dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
   4074  1.1.1.2.4.2  tls 
   4075  1.1.1.2.4.2  tls       gp_val = _bfd_get_gp_value (abfd);
   4076  1.1.1.2.4.2  tls       phdr = _bfd_elf_find_segment_containing_section
   4077  1.1.1.2.4.2  tls         (info->output_bfd, ia64_info->pltoff_sec->output_section);
   4078  1.1.1.2.4.2  tls       BFD_ASSERT (phdr != NULL);
   4079  1.1.1.2.4.2  tls       base_phdr = elf_tdata (info->output_bfd)->phdr;
   4080  1.1.1.2.4.2  tls       gp_seg = phdr - base_phdr;
   4081  1.1.1.2.4.2  tls       gp_off = gp_val - phdr->p_vaddr;
   4082  1.1.1.2.4.2  tls 
   4083  1.1.1.2.4.2  tls       unwind_sec = bfd_get_section_by_name (abfd, ELF_STRING_ia64_unwind);
   4084  1.1.1.2.4.2  tls       if (unwind_sec != NULL)
   4085  1.1.1.2.4.2  tls         {
   4086  1.1.1.2.4.2  tls           asection *code_sec;
   4087  1.1.1.2.4.2  tls 
   4088  1.1.1.2.4.2  tls           phdr = _bfd_elf_find_segment_containing_section (abfd, unwind_sec);
   4089  1.1.1.2.4.2  tls           BFD_ASSERT (phdr != NULL);
   4090  1.1.1.2.4.2  tls           unwind_seg = phdr - base_phdr;
   4091  1.1.1.2.4.2  tls 
   4092  1.1.1.2.4.2  tls           code_sec = bfd_get_section_by_name (abfd, "$CODE$");
   4093  1.1.1.2.4.2  tls           phdr = _bfd_elf_find_segment_containing_section (abfd, code_sec);
   4094  1.1.1.2.4.2  tls           BFD_ASSERT (phdr != NULL);
   4095  1.1.1.2.4.2  tls           code_seg = phdr - base_phdr;
   4096  1.1.1.2.4.2  tls         }
   4097  1.1.1.2.4.2  tls 
   4098  1.1.1.2.4.2  tls       for (; dyncon < dynconend; dyncon++)
   4099  1.1.1.2.4.2  tls 	{
   4100  1.1.1.2.4.2  tls 	  Elf_Internal_Dyn dyn;
   4101  1.1.1.2.4.2  tls 
   4102  1.1.1.2.4.2  tls 	  bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
   4103  1.1.1.2.4.2  tls 
   4104  1.1.1.2.4.2  tls 	  switch (dyn.d_tag)
   4105  1.1.1.2.4.2  tls 	    {
   4106  1.1.1.2.4.2  tls             case DT_IA_64_VMS_FIXUP_RELA_OFF:
   4107  1.1.1.2.4.2  tls               dyn.d_un.d_val +=
   4108  1.1.1.2.4.2  tls                 (ia64_info->fixups_sec->output_section->vma
   4109  1.1.1.2.4.2  tls                  + ia64_info->fixups_sec->output_offset)
   4110  1.1.1.2.4.2  tls                 - (sdyn->output_section->vma + sdyn->output_offset);
   4111  1.1.1.2.4.2  tls               break;
   4112  1.1.1.2.4.2  tls 
   4113  1.1.1.2.4.2  tls             case DT_IA_64_VMS_PLTGOT_OFFSET:
   4114  1.1.1.2.4.2  tls               dyn.d_un.d_val = gp_off;
   4115  1.1.1.2.4.2  tls               break;
   4116  1.1.1.2.4.2  tls 
   4117  1.1.1.2.4.2  tls             case DT_IA_64_VMS_PLTGOT_SEG:
   4118  1.1.1.2.4.2  tls               dyn.d_un.d_val = gp_seg;
   4119  1.1.1.2.4.2  tls               break;
   4120  1.1.1.2.4.2  tls 
   4121  1.1.1.2.4.2  tls             case DT_IA_64_VMS_UNWINDSZ:
   4122  1.1.1.2.4.2  tls               if (unwind_sec == NULL)
   4123  1.1.1.2.4.2  tls                 {
   4124  1.1.1.2.4.2  tls                   dyn.d_tag = DT_NULL;
   4125  1.1.1.2.4.2  tls                   dyn.d_un.d_val = 0xdead;
   4126  1.1.1.2.4.2  tls                 }
   4127  1.1.1.2.4.2  tls               else
   4128  1.1.1.2.4.2  tls                 dyn.d_un.d_val = unwind_sec->size;
   4129  1.1.1.2.4.2  tls               break;
   4130  1.1.1.2.4.2  tls 
   4131  1.1.1.2.4.2  tls             case DT_IA_64_VMS_UNWIND_CODSEG:
   4132  1.1.1.2.4.2  tls               dyn.d_un.d_val = code_seg;
   4133  1.1.1.2.4.2  tls               break;
   4134  1.1.1.2.4.2  tls 
   4135  1.1.1.2.4.2  tls             case DT_IA_64_VMS_UNWIND_INFOSEG:
   4136  1.1.1.2.4.2  tls             case DT_IA_64_VMS_UNWIND_SEG:
   4137  1.1.1.2.4.2  tls               dyn.d_un.d_val = unwind_seg;
   4138  1.1.1.2.4.2  tls               break;
   4139  1.1.1.2.4.2  tls 
   4140  1.1.1.2.4.2  tls             case DT_IA_64_VMS_UNWIND_OFFSET:
   4141  1.1.1.2.4.2  tls               break;
   4142  1.1.1.2.4.2  tls 
   4143  1.1.1.2.4.2  tls             default:
   4144  1.1.1.2.4.2  tls               /* No need to rewrite the entry.  */
   4145  1.1.1.2.4.2  tls               continue;
   4146  1.1.1.2.4.2  tls 	    }
   4147  1.1.1.2.4.2  tls 
   4148  1.1.1.2.4.2  tls 	  bfd_elf64_swap_dyn_out (abfd, &dyn, dyncon);
   4149  1.1.1.2.4.2  tls 	}
   4150  1.1.1.2.4.2  tls     }
   4151  1.1.1.2.4.2  tls 
   4152  1.1.1.2.4.2  tls   /* Handle transfer addresses.  */
   4153  1.1.1.2.4.2  tls   {
   4154  1.1.1.2.4.2  tls     asection *tfr_sec = ia64_info->transfer_sec;
   4155  1.1.1.2.4.2  tls     struct elf64_vms_transfer *tfr;
   4156  1.1.1.2.4.2  tls     struct elf_link_hash_entry *tfr3;
   4157  1.1.1.2.4.2  tls 
   4158  1.1.1.2.4.2  tls     tfr = (struct elf64_vms_transfer *)tfr_sec->contents;
   4159  1.1.1.2.4.2  tls     bfd_putl32 (6 * 8, tfr->size);
   4160  1.1.1.2.4.2  tls     bfd_putl64 (tfr_sec->output_section->vma
   4161  1.1.1.2.4.2  tls                 + tfr_sec->output_offset
   4162  1.1.1.2.4.2  tls                 + 6 * 8, tfr->tfradr3);
   4163  1.1.1.2.4.2  tls 
   4164  1.1.1.2.4.2  tls     tfr3 = elf_link_hash_lookup (elf_hash_table (info), "ELF$TFRADR", FALSE,
   4165  1.1.1.2.4.2  tls                                  FALSE, FALSE);
   4166  1.1.1.2.4.2  tls 
   4167  1.1.1.2.4.2  tls     if (tfr3
   4168  1.1.1.2.4.2  tls         && (tfr3->root.type == bfd_link_hash_defined
   4169  1.1.1.2.4.2  tls             || tfr3->root.type == bfd_link_hash_defweak))
   4170  1.1.1.2.4.2  tls       {
   4171  1.1.1.2.4.2  tls         asection *tfr3_sec = tfr3->root.u.def.section;
   4172  1.1.1.2.4.2  tls         bfd_vma tfr3_val;
   4173  1.1.1.2.4.2  tls 
   4174  1.1.1.2.4.2  tls         tfr3_val = (tfr3->root.u.def.value
   4175  1.1.1.2.4.2  tls                     + tfr3_sec->output_section->vma
   4176  1.1.1.2.4.2  tls                     + tfr3_sec->output_offset);
   4177  1.1.1.2.4.2  tls 
   4178  1.1.1.2.4.2  tls         bfd_putl64 (tfr3_val, tfr->tfr3_func);
   4179  1.1.1.2.4.2  tls         bfd_putl64 (_bfd_get_gp_value (info->output_bfd), tfr->tfr3_gp);
   4180  1.1.1.2.4.2  tls       }
   4181  1.1.1.2.4.2  tls 
   4182  1.1.1.2.4.2  tls     /* FIXME: set linker flags,
   4183  1.1.1.2.4.2  tls        handle lib$initialize.  */
   4184  1.1.1.2.4.2  tls   }
   4185  1.1.1.2.4.2  tls 
   4186  1.1.1.2.4.2  tls   return TRUE;
   4187  1.1.1.2.4.2  tls }
   4188  1.1.1.2.4.2  tls 
   4189  1.1.1.2.4.2  tls /* ELF file flag handling:  */
   4190  1.1.1.2.4.2  tls 
   4191  1.1.1.2.4.2  tls /* Function to keep IA-64 specific file flags.  */
   4192  1.1.1.2.4.2  tls static bfd_boolean
   4193  1.1.1.2.4.2  tls elf64_ia64_set_private_flags (bfd *abfd, flagword flags)
   4194  1.1.1.2.4.2  tls {
   4195  1.1.1.2.4.2  tls   BFD_ASSERT (!elf_flags_init (abfd)
   4196  1.1.1.2.4.2  tls 	      || elf_elfheader (abfd)->e_flags == flags);
   4197  1.1.1.2.4.2  tls 
   4198  1.1.1.2.4.2  tls   elf_elfheader (abfd)->e_flags = flags;
   4199  1.1.1.2.4.2  tls   elf_flags_init (abfd) = TRUE;
   4200  1.1.1.2.4.2  tls   return TRUE;
   4201  1.1.1.2.4.2  tls }
   4202  1.1.1.2.4.2  tls 
   4203  1.1.1.2.4.2  tls /* Merge backend specific data from an object file to the output
   4204  1.1.1.2.4.2  tls    object file when linking.  */
   4205  1.1.1.2.4.2  tls static bfd_boolean
   4206  1.1.1.2.4.2  tls elf64_ia64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
   4207  1.1.1.2.4.2  tls {
   4208  1.1.1.2.4.2  tls   flagword out_flags;
   4209  1.1.1.2.4.2  tls   flagword in_flags;
   4210  1.1.1.2.4.2  tls   bfd_boolean ok = TRUE;
   4211  1.1.1.2.4.2  tls 
   4212  1.1.1.2.4.2  tls   /* Don't even pretend to support mixed-format linking.  */
   4213  1.1.1.2.4.2  tls   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
   4214  1.1.1.2.4.2  tls       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
   4215  1.1.1.2.4.2  tls     return FALSE;
   4216  1.1.1.2.4.2  tls 
   4217  1.1.1.2.4.2  tls   in_flags  = elf_elfheader (ibfd)->e_flags;
   4218  1.1.1.2.4.2  tls   out_flags = elf_elfheader (obfd)->e_flags;
   4219  1.1.1.2.4.2  tls 
   4220  1.1.1.2.4.2  tls   if (! elf_flags_init (obfd))
   4221  1.1.1.2.4.2  tls     {
   4222  1.1.1.2.4.2  tls       elf_flags_init (obfd) = TRUE;
   4223  1.1.1.2.4.2  tls       elf_elfheader (obfd)->e_flags = in_flags;
   4224  1.1.1.2.4.2  tls 
   4225  1.1.1.2.4.2  tls       if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
   4226  1.1.1.2.4.2  tls 	  && bfd_get_arch_info (obfd)->the_default)
   4227  1.1.1.2.4.2  tls 	{
   4228  1.1.1.2.4.2  tls 	  return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
   4229  1.1.1.2.4.2  tls 				    bfd_get_mach (ibfd));
   4230  1.1.1.2.4.2  tls 	}
   4231  1.1.1.2.4.2  tls 
   4232  1.1.1.2.4.2  tls       return TRUE;
   4233  1.1.1.2.4.2  tls     }
   4234  1.1.1.2.4.2  tls 
   4235  1.1.1.2.4.2  tls   /* Check flag compatibility.  */
   4236  1.1.1.2.4.2  tls   if (in_flags == out_flags)
   4237  1.1.1.2.4.2  tls     return TRUE;
   4238  1.1.1.2.4.2  tls 
   4239  1.1.1.2.4.2  tls   /* Output has EF_IA_64_REDUCEDFP set only if all inputs have it set.  */
   4240  1.1.1.2.4.2  tls   if (!(in_flags & EF_IA_64_REDUCEDFP) && (out_flags & EF_IA_64_REDUCEDFP))
   4241  1.1.1.2.4.2  tls     elf_elfheader (obfd)->e_flags &= ~EF_IA_64_REDUCEDFP;
   4242  1.1.1.2.4.2  tls 
   4243  1.1.1.2.4.2  tls   if ((in_flags & EF_IA_64_TRAPNIL) != (out_flags & EF_IA_64_TRAPNIL))
   4244  1.1.1.2.4.2  tls     {
   4245  1.1.1.2.4.2  tls       (*_bfd_error_handler)
   4246  1.1.1.2.4.2  tls 	(_("%B: linking trap-on-NULL-dereference with non-trapping files"),
   4247  1.1.1.2.4.2  tls 	 ibfd);
   4248  1.1.1.2.4.2  tls 
   4249  1.1.1.2.4.2  tls       bfd_set_error (bfd_error_bad_value);
   4250  1.1.1.2.4.2  tls       ok = FALSE;
   4251  1.1.1.2.4.2  tls     }
   4252  1.1.1.2.4.2  tls   if ((in_flags & EF_IA_64_BE) != (out_flags & EF_IA_64_BE))
   4253  1.1.1.2.4.2  tls     {
   4254  1.1.1.2.4.2  tls       (*_bfd_error_handler)
   4255  1.1.1.2.4.2  tls 	(_("%B: linking big-endian files with little-endian files"),
   4256  1.1.1.2.4.2  tls 	 ibfd);
   4257  1.1.1.2.4.2  tls 
   4258  1.1.1.2.4.2  tls       bfd_set_error (bfd_error_bad_value);
   4259  1.1.1.2.4.2  tls       ok = FALSE;
   4260  1.1.1.2.4.2  tls     }
   4261  1.1.1.2.4.2  tls   if ((in_flags & EF_IA_64_ABI64) != (out_flags & EF_IA_64_ABI64))
   4262  1.1.1.2.4.2  tls     {
   4263  1.1.1.2.4.2  tls       (*_bfd_error_handler)
   4264  1.1.1.2.4.2  tls 	(_("%B: linking 64-bit files with 32-bit files"),
   4265  1.1.1.2.4.2  tls 	 ibfd);
   4266  1.1.1.2.4.2  tls 
   4267  1.1.1.2.4.2  tls       bfd_set_error (bfd_error_bad_value);
   4268  1.1.1.2.4.2  tls       ok = FALSE;
   4269  1.1.1.2.4.2  tls     }
   4270  1.1.1.2.4.2  tls   if ((in_flags & EF_IA_64_CONS_GP) != (out_flags & EF_IA_64_CONS_GP))
   4271  1.1.1.2.4.2  tls     {
   4272  1.1.1.2.4.2  tls       (*_bfd_error_handler)
   4273  1.1.1.2.4.2  tls 	(_("%B: linking constant-gp files with non-constant-gp files"),
   4274  1.1.1.2.4.2  tls 	 ibfd);
   4275  1.1.1.2.4.2  tls 
   4276  1.1.1.2.4.2  tls       bfd_set_error (bfd_error_bad_value);
   4277  1.1.1.2.4.2  tls       ok = FALSE;
   4278  1.1.1.2.4.2  tls     }
   4279  1.1.1.2.4.2  tls   if ((in_flags & EF_IA_64_NOFUNCDESC_CONS_GP)
   4280  1.1.1.2.4.2  tls       != (out_flags & EF_IA_64_NOFUNCDESC_CONS_GP))
   4281  1.1.1.2.4.2  tls     {
   4282  1.1.1.2.4.2  tls       (*_bfd_error_handler)
   4283  1.1.1.2.4.2  tls 	(_("%B: linking auto-pic files with non-auto-pic files"),
   4284  1.1.1.2.4.2  tls 	 ibfd);
   4285  1.1.1.2.4.2  tls 
   4286  1.1.1.2.4.2  tls       bfd_set_error (bfd_error_bad_value);
   4287  1.1.1.2.4.2  tls       ok = FALSE;
   4288  1.1.1.2.4.2  tls     }
   4289  1.1.1.2.4.2  tls 
   4290  1.1.1.2.4.2  tls   return ok;
   4291  1.1.1.2.4.2  tls }
   4292  1.1.1.2.4.2  tls 
   4293  1.1.1.2.4.2  tls static bfd_boolean
   4294  1.1.1.2.4.2  tls elf64_ia64_print_private_bfd_data (bfd *abfd, void * ptr)
   4295  1.1.1.2.4.2  tls {
   4296  1.1.1.2.4.2  tls   FILE *file = (FILE *) ptr;
   4297  1.1.1.2.4.2  tls   flagword flags = elf_elfheader (abfd)->e_flags;
   4298  1.1.1.2.4.2  tls 
   4299  1.1.1.2.4.2  tls   BFD_ASSERT (abfd != NULL && ptr != NULL);
   4300  1.1.1.2.4.2  tls 
   4301  1.1.1.2.4.2  tls   fprintf (file, "private flags = %s%s%s%s%s%s%s%s\n",
   4302  1.1.1.2.4.2  tls 	   (flags & EF_IA_64_TRAPNIL) ? "TRAPNIL, " : "",
   4303  1.1.1.2.4.2  tls 	   (flags & EF_IA_64_EXT) ? "EXT, " : "",
   4304  1.1.1.2.4.2  tls 	   (flags & EF_IA_64_BE) ? "BE, " : "LE, ",
   4305  1.1.1.2.4.2  tls 	   (flags & EF_IA_64_REDUCEDFP) ? "REDUCEDFP, " : "",
   4306  1.1.1.2.4.2  tls 	   (flags & EF_IA_64_CONS_GP) ? "CONS_GP, " : "",
   4307  1.1.1.2.4.2  tls 	   (flags & EF_IA_64_NOFUNCDESC_CONS_GP) ? "NOFUNCDESC_CONS_GP, " : "",
   4308  1.1.1.2.4.2  tls 	   (flags & EF_IA_64_ABSOLUTE) ? "ABSOLUTE, " : "",
   4309  1.1.1.2.4.2  tls 	   (flags & EF_IA_64_ABI64) ? "ABI64" : "ABI32");
   4310  1.1.1.2.4.2  tls 
   4311  1.1.1.2.4.2  tls   _bfd_elf_print_private_bfd_data (abfd, ptr);
   4312  1.1.1.2.4.2  tls   return TRUE;
   4313  1.1.1.2.4.2  tls }
   4314  1.1.1.2.4.2  tls 
   4315  1.1.1.2.4.2  tls static enum elf_reloc_type_class
   4316  1.1.1.2.4.2  tls elf64_ia64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
   4317  1.1.1.2.4.2  tls 			     const asection *rel_sec ATTRIBUTE_UNUSED,
   4318  1.1.1.2.4.2  tls 			     const Elf_Internal_Rela *rela)
   4319  1.1.1.2.4.2  tls {
   4320  1.1.1.2.4.2  tls   switch ((int) ELF64_R_TYPE (rela->r_info))
   4321  1.1.1.2.4.2  tls     {
   4322  1.1.1.2.4.2  tls     case R_IA64_REL32MSB:
   4323  1.1.1.2.4.2  tls     case R_IA64_REL32LSB:
   4324  1.1.1.2.4.2  tls     case R_IA64_REL64MSB:
   4325  1.1.1.2.4.2  tls     case R_IA64_REL64LSB:
   4326  1.1.1.2.4.2  tls       return reloc_class_relative;
   4327  1.1.1.2.4.2  tls     case R_IA64_IPLTMSB:
   4328  1.1.1.2.4.2  tls     case R_IA64_IPLTLSB:
   4329  1.1.1.2.4.2  tls       return reloc_class_plt;
   4330  1.1.1.2.4.2  tls     case R_IA64_COPY:
   4331  1.1.1.2.4.2  tls       return reloc_class_copy;
   4332  1.1.1.2.4.2  tls     default:
   4333  1.1.1.2.4.2  tls       return reloc_class_normal;
   4334  1.1.1.2.4.2  tls     }
   4335  1.1.1.2.4.2  tls }
   4336  1.1.1.2.4.2  tls 
   4337  1.1.1.2.4.2  tls static const struct bfd_elf_special_section elf64_ia64_special_sections[] =
   4338  1.1.1.2.4.2  tls {
   4339  1.1.1.2.4.2  tls   { STRING_COMMA_LEN (".sbss"),  -1, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
   4340  1.1.1.2.4.2  tls   { STRING_COMMA_LEN (".sdata"), -1, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
   4341  1.1.1.2.4.2  tls   { NULL,                    0,   0, 0,            0 }
   4342  1.1.1.2.4.2  tls };
   4343  1.1.1.2.4.2  tls 
   4344  1.1.1.2.4.2  tls static bfd_boolean
   4345  1.1.1.2.4.2  tls elf64_ia64_object_p (bfd *abfd)
   4346  1.1.1.2.4.2  tls {
   4347  1.1.1.2.4.2  tls   asection *sec;
   4348  1.1.1.2.4.2  tls   asection *group, *unwi, *unw;
   4349  1.1.1.2.4.2  tls   flagword flags;
   4350  1.1.1.2.4.2  tls   const char *name;
   4351  1.1.1.2.4.2  tls   char *unwi_name, *unw_name;
   4352  1.1.1.2.4.2  tls   bfd_size_type amt;
   4353  1.1.1.2.4.2  tls 
   4354  1.1.1.2.4.2  tls   if (abfd->flags & DYNAMIC)
   4355  1.1.1.2.4.2  tls     return TRUE;
   4356  1.1.1.2.4.2  tls 
   4357  1.1.1.2.4.2  tls   /* Flags for fake group section.  */
   4358  1.1.1.2.4.2  tls   flags = (SEC_LINKER_CREATED | SEC_GROUP | SEC_LINK_ONCE
   4359  1.1.1.2.4.2  tls 	   | SEC_EXCLUDE);
   4360  1.1.1.2.4.2  tls 
   4361  1.1.1.2.4.2  tls   /* We add a fake section group for each .gnu.linkonce.t.* section,
   4362  1.1.1.2.4.2  tls      which isn't in a section group, and its unwind sections.  */
   4363  1.1.1.2.4.2  tls   for (sec = abfd->sections; sec != NULL; sec = sec->next)
   4364  1.1.1.2.4.2  tls     {
   4365  1.1.1.2.4.2  tls       if (elf_sec_group (sec) == NULL
   4366  1.1.1.2.4.2  tls 	  && ((sec->flags & (SEC_LINK_ONCE | SEC_CODE | SEC_GROUP))
   4367  1.1.1.2.4.2  tls 	      == (SEC_LINK_ONCE | SEC_CODE))
   4368  1.1.1.2.4.2  tls 	  && CONST_STRNEQ (sec->name, ".gnu.linkonce.t."))
   4369  1.1.1.2.4.2  tls 	{
   4370  1.1.1.2.4.2  tls 	  name = sec->name + 16;
   4371  1.1.1.2.4.2  tls 
   4372  1.1.1.2.4.2  tls 	  amt = strlen (name) + sizeof (".gnu.linkonce.ia64unwi.");
   4373  1.1.1.2.4.2  tls 	  unwi_name = bfd_alloc (abfd, amt);
   4374  1.1.1.2.4.2  tls 	  if (!unwi_name)
   4375  1.1.1.2.4.2  tls 	    return FALSE;
   4376  1.1.1.2.4.2  tls 
   4377  1.1.1.2.4.2  tls 	  strcpy (stpcpy (unwi_name, ".gnu.linkonce.ia64unwi."), name);
   4378  1.1.1.2.4.2  tls 	  unwi = bfd_get_section_by_name (abfd, unwi_name);
   4379  1.1.1.2.4.2  tls 
   4380  1.1.1.2.4.2  tls 	  amt = strlen (name) + sizeof (".gnu.linkonce.ia64unw.");
   4381  1.1.1.2.4.2  tls 	  unw_name = bfd_alloc (abfd, amt);
   4382  1.1.1.2.4.2  tls 	  if (!unw_name)
   4383  1.1.1.2.4.2  tls 	    return FALSE;
   4384  1.1.1.2.4.2  tls 
   4385  1.1.1.2.4.2  tls 	  strcpy (stpcpy (unw_name, ".gnu.linkonce.ia64unw."), name);
   4386  1.1.1.2.4.2  tls 	  unw = bfd_get_section_by_name (abfd, unw_name);
   4387  1.1.1.2.4.2  tls 
   4388  1.1.1.2.4.2  tls 	  /* We need to create a fake group section for it and its
   4389  1.1.1.2.4.2  tls 	     unwind sections.  */
   4390  1.1.1.2.4.2  tls 	  group = bfd_make_section_anyway_with_flags (abfd, name,
   4391  1.1.1.2.4.2  tls 						      flags);
   4392  1.1.1.2.4.2  tls 	  if (group == NULL)
   4393  1.1.1.2.4.2  tls 	    return FALSE;
   4394  1.1.1.2.4.2  tls 
   4395  1.1.1.2.4.2  tls 	  /* Move the fake group section to the beginning.  */
   4396  1.1.1.2.4.2  tls 	  bfd_section_list_remove (abfd, group);
   4397  1.1.1.2.4.2  tls 	  bfd_section_list_prepend (abfd, group);
   4398  1.1.1.2.4.2  tls 
   4399  1.1.1.2.4.2  tls 	  elf_next_in_group (group) = sec;
   4400  1.1.1.2.4.2  tls 
   4401  1.1.1.2.4.2  tls 	  elf_group_name (sec) = name;
   4402  1.1.1.2.4.2  tls 	  elf_next_in_group (sec) = sec;
   4403  1.1.1.2.4.2  tls 	  elf_sec_group (sec) = group;
   4404  1.1.1.2.4.2  tls 
   4405  1.1.1.2.4.2  tls 	  if (unwi)
   4406  1.1.1.2.4.2  tls 	    {
   4407  1.1.1.2.4.2  tls 	      elf_group_name (unwi) = name;
   4408  1.1.1.2.4.2  tls 	      elf_next_in_group (unwi) = sec;
   4409  1.1.1.2.4.2  tls 	      elf_next_in_group (sec) = unwi;
   4410  1.1.1.2.4.2  tls 	      elf_sec_group (unwi) = group;
   4411  1.1.1.2.4.2  tls 	    }
   4412  1.1.1.2.4.2  tls 
   4413  1.1.1.2.4.2  tls 	   if (unw)
   4414  1.1.1.2.4.2  tls 	     {
   4415  1.1.1.2.4.2  tls 	       elf_group_name (unw) = name;
   4416  1.1.1.2.4.2  tls 	       if (unwi)
   4417  1.1.1.2.4.2  tls 		 {
   4418  1.1.1.2.4.2  tls 		   elf_next_in_group (unw) = elf_next_in_group (unwi);
   4419  1.1.1.2.4.2  tls 		   elf_next_in_group (unwi) = unw;
   4420  1.1.1.2.4.2  tls 		 }
   4421  1.1.1.2.4.2  tls 	       else
   4422  1.1.1.2.4.2  tls 		 {
   4423  1.1.1.2.4.2  tls 		   elf_next_in_group (unw) = sec;
   4424  1.1.1.2.4.2  tls 		   elf_next_in_group (sec) = unw;
   4425  1.1.1.2.4.2  tls 		 }
   4426  1.1.1.2.4.2  tls 	       elf_sec_group (unw) = group;
   4427  1.1.1.2.4.2  tls 	     }
   4428  1.1.1.2.4.2  tls 
   4429  1.1.1.2.4.2  tls 	   /* Fake SHT_GROUP section header.  */
   4430  1.1.1.2.4.2  tls 	  elf_section_data (group)->this_hdr.bfd_section = group;
   4431  1.1.1.2.4.2  tls 	  elf_section_data (group)->this_hdr.sh_type = SHT_GROUP;
   4432  1.1.1.2.4.2  tls 	}
   4433  1.1.1.2.4.2  tls     }
   4434  1.1.1.2.4.2  tls   return TRUE;
   4435  1.1.1.2.4.2  tls }
   4436  1.1.1.2.4.2  tls 
   4437  1.1.1.2.4.2  tls /* Handle an IA-64 specific section when reading an object file.  This
   4438  1.1.1.2.4.2  tls    is called when bfd_section_from_shdr finds a section with an unknown
   4439  1.1.1.2.4.2  tls    type.  */
   4440  1.1.1.2.4.2  tls 
   4441  1.1.1.2.4.2  tls static bfd_boolean
   4442  1.1.1.2.4.2  tls elf64_vms_section_from_shdr (bfd *abfd,
   4443  1.1.1.2.4.2  tls 			     Elf_Internal_Shdr *hdr,
   4444  1.1.1.2.4.2  tls 			     const char *name,
   4445  1.1.1.2.4.2  tls 			     int shindex)
   4446  1.1.1.2.4.2  tls {
   4447  1.1.1.2.4.2  tls   flagword secflags = 0;
   4448  1.1.1.2.4.2  tls 
   4449  1.1.1.2.4.2  tls   switch (hdr->sh_type)
   4450  1.1.1.2.4.2  tls     {
   4451  1.1.1.2.4.2  tls     case SHT_IA_64_VMS_TRACE:
   4452  1.1.1.2.4.2  tls     case SHT_IA_64_VMS_DEBUG:
   4453  1.1.1.2.4.2  tls     case SHT_IA_64_VMS_DEBUG_STR:
   4454  1.1.1.2.4.2  tls       secflags = SEC_DEBUGGING;
   4455  1.1.1.2.4.2  tls       break;
   4456  1.1.1.2.4.2  tls 
   4457  1.1.1.2.4.2  tls     case SHT_IA_64_UNWIND:
   4458  1.1.1.2.4.2  tls     case SHT_IA_64_HP_OPT_ANOT:
   4459  1.1.1.2.4.2  tls       break;
   4460  1.1.1.2.4.2  tls 
   4461  1.1.1.2.4.2  tls     case SHT_IA_64_EXT:
   4462  1.1.1.2.4.2  tls       if (strcmp (name, ELF_STRING_ia64_archext) != 0)
   4463  1.1.1.2.4.2  tls 	return FALSE;
   4464  1.1.1.2.4.2  tls       break;
   4465  1.1.1.2.4.2  tls 
   4466  1.1.1.2.4.2  tls     default:
   4467  1.1.1.2.4.2  tls       return FALSE;
   4468  1.1.1.2.4.2  tls     }
   4469  1.1.1.2.4.2  tls 
   4470  1.1.1.2.4.2  tls   if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
   4471  1.1.1.2.4.2  tls     return FALSE;
   4472  1.1.1.2.4.2  tls 
   4473  1.1.1.2.4.2  tls   if (secflags != 0)
   4474  1.1.1.2.4.2  tls     {
   4475  1.1.1.2.4.2  tls       asection *newsect = hdr->bfd_section;
   4476  1.1.1.2.4.2  tls 
   4477  1.1.1.2.4.2  tls       if (! bfd_set_section_flags
   4478  1.1.1.2.4.2  tls           (abfd, newsect, bfd_get_section_flags (abfd, newsect) | secflags))
   4479  1.1.1.2.4.2  tls 	return FALSE;
   4480  1.1.1.2.4.2  tls     }
   4481  1.1.1.2.4.2  tls 
   4482  1.1.1.2.4.2  tls   return TRUE;
   4483  1.1.1.2.4.2  tls }
   4484  1.1.1.2.4.2  tls 
   4485  1.1.1.2.4.2  tls static bfd_boolean
   4486  1.1.1.2.4.2  tls elf64_vms_object_p (bfd *abfd)
   4487  1.1.1.2.4.2  tls {
   4488  1.1.1.2.4.2  tls   Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
   4489  1.1.1.2.4.2  tls   Elf_Internal_Phdr *i_phdr = elf_tdata (abfd)->phdr;
   4490  1.1.1.2.4.2  tls   unsigned int i;
   4491  1.1.1.2.4.2  tls   unsigned int num_text = 0;
   4492  1.1.1.2.4.2  tls   unsigned int num_data = 0;
   4493  1.1.1.2.4.2  tls   unsigned int num_rodata = 0;
   4494  1.1.1.2.4.2  tls   char name[16];
   4495  1.1.1.2.4.2  tls 
   4496  1.1.1.2.4.2  tls   if (!elf64_ia64_object_p (abfd))
   4497  1.1.1.2.4.2  tls     return FALSE;
   4498  1.1.1.2.4.2  tls 
   4499  1.1.1.2.4.2  tls   /* Many VMS compilers do not generate sections for the corresponding
   4500  1.1.1.2.4.2  tls      segment.  This is boring as binutils tools won't be able to disassemble
   4501  1.1.1.2.4.2  tls      the code.  So we simply create all the missing sections.  */
   4502  1.1.1.2.4.2  tls   for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
   4503  1.1.1.2.4.2  tls     {
   4504  1.1.1.2.4.2  tls       /* Is there a section for this segment?  */
   4505  1.1.1.2.4.2  tls       bfd_vma base_vma = i_phdr->p_vaddr;
   4506  1.1.1.2.4.2  tls       bfd_vma limit_vma = base_vma + i_phdr->p_filesz;
   4507  1.1.1.2.4.2  tls 
   4508  1.1.1.2.4.2  tls       if (i_phdr->p_type != PT_LOAD)
   4509  1.1.1.2.4.2  tls 	continue;
   4510  1.1.1.2.4.2  tls 
   4511  1.1.1.2.4.2  tls       /* We need to cover from base_vms to limit_vma.  */
   4512  1.1.1.2.4.2  tls     again:
   4513  1.1.1.2.4.2  tls       while (base_vma < limit_vma)
   4514  1.1.1.2.4.2  tls 	{
   4515  1.1.1.2.4.2  tls 	  bfd_vma next_vma = limit_vma;
   4516  1.1.1.2.4.2  tls 	  asection *nsec;
   4517  1.1.1.2.4.2  tls 	  asection *sec;
   4518  1.1.1.2.4.2  tls 	  flagword flags;
   4519  1.1.1.2.4.2  tls 	  char *nname = NULL;
   4520  1.1.1.2.4.2  tls 
   4521  1.1.1.2.4.2  tls 	  /* Find a section covering [base_vma;limit_vma)  */
   4522  1.1.1.2.4.2  tls 	  for (sec = abfd->sections; sec != NULL; sec = sec->next)
   4523  1.1.1.2.4.2  tls 	    {
   4524  1.1.1.2.4.2  tls 	      /* Skip uninteresting sections (either not in memory or
   4525  1.1.1.2.4.2  tls 		 below base_vma.  */
   4526  1.1.1.2.4.2  tls 	      if ((sec->flags & (SEC_ALLOC | SEC_LOAD)) == 0
   4527  1.1.1.2.4.2  tls 		  || sec->vma + sec->size <= base_vma)
   4528  1.1.1.2.4.2  tls 		continue;
   4529  1.1.1.2.4.2  tls 	      if (sec->vma <= base_vma)
   4530  1.1.1.2.4.2  tls 		{
   4531  1.1.1.2.4.2  tls 		  /* This section covers (maybe partially) the beginning
   4532  1.1.1.2.4.2  tls 		     of the range.  */
   4533  1.1.1.2.4.2  tls 		  base_vma = sec->vma + sec->size;
   4534  1.1.1.2.4.2  tls 		  goto again;
   4535  1.1.1.2.4.2  tls 		}
   4536  1.1.1.2.4.2  tls 	      if (sec->vma < next_vma)
   4537  1.1.1.2.4.2  tls 		{
   4538  1.1.1.2.4.2  tls 		  /* This section partially covers the end of the range.
   4539  1.1.1.2.4.2  tls 		     Used to compute the size of the hole.  */
   4540  1.1.1.2.4.2  tls 		  next_vma = sec->vma;
   4541  1.1.1.2.4.2  tls 		}
   4542  1.1.1.2.4.2  tls 	    }
   4543  1.1.1.2.4.2  tls 
   4544  1.1.1.2.4.2  tls 	  /* No section covering [base_vma; next_vma).  Create a fake one.  */
   4545  1.1.1.2.4.2  tls 	  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   4546  1.1.1.2.4.2  tls 	  if (i_phdr->p_flags & PF_X)
   4547  1.1.1.2.4.2  tls 	    {
   4548  1.1.1.2.4.2  tls 	      flags |= SEC_CODE;
   4549  1.1.1.2.4.2  tls 	      if (num_text++ == 0)
   4550  1.1.1.2.4.2  tls 		nname = ".text";
   4551  1.1.1.2.4.2  tls 	      else
   4552  1.1.1.2.4.2  tls 		sprintf (name, ".text$%u", num_text);
   4553  1.1.1.2.4.2  tls 	    }
   4554  1.1.1.2.4.2  tls 	  else if ((i_phdr->p_flags & (PF_R | PF_W)) == PF_R)
   4555  1.1.1.2.4.2  tls 	    {
   4556  1.1.1.2.4.2  tls 	      flags |= SEC_READONLY;
   4557  1.1.1.2.4.2  tls 	      sprintf (name, ".rodata$%u", num_rodata++);
   4558  1.1.1.2.4.2  tls 	    }
   4559  1.1.1.2.4.2  tls 	  else
   4560  1.1.1.2.4.2  tls 	    {
   4561  1.1.1.2.4.2  tls 	      flags |= SEC_DATA;
   4562  1.1.1.2.4.2  tls 	      sprintf (name, ".data$%u", num_data++);
   4563  1.1.1.2.4.2  tls 	    }
   4564  1.1.1.2.4.2  tls 
   4565  1.1.1.2.4.2  tls 	  /* Allocate name.  */
   4566  1.1.1.2.4.2  tls 	  if (nname == NULL)
   4567  1.1.1.2.4.2  tls 	    {
   4568  1.1.1.2.4.2  tls 	      size_t name_len = strlen (name) + 1;
   4569  1.1.1.2.4.2  tls 	      nname = bfd_alloc (abfd, name_len);
   4570  1.1.1.2.4.2  tls 	      if (nname == NULL)
   4571  1.1.1.2.4.2  tls 		return FALSE;
   4572  1.1.1.2.4.2  tls 	      memcpy (nname, name, name_len);
   4573  1.1.1.2.4.2  tls 	    }
   4574  1.1.1.2.4.2  tls 
   4575  1.1.1.2.4.2  tls 	  /* Create and fill new section.  */
   4576  1.1.1.2.4.2  tls 	  nsec = bfd_make_section_anyway_with_flags (abfd, nname, flags);
   4577  1.1.1.2.4.2  tls 	  if (nsec == NULL)
   4578  1.1.1.2.4.2  tls 	    return FALSE;
   4579  1.1.1.2.4.2  tls 	  nsec->vma = base_vma;
   4580  1.1.1.2.4.2  tls 	  nsec->size = next_vma - base_vma;
   4581  1.1.1.2.4.2  tls 	  nsec->filepos = i_phdr->p_offset + (base_vma - i_phdr->p_vaddr);
   4582  1.1.1.2.4.2  tls 
   4583  1.1.1.2.4.2  tls 	  base_vma = next_vma;
   4584  1.1.1.2.4.2  tls 	}
   4585  1.1.1.2.4.2  tls     }
   4586  1.1.1.2.4.2  tls   return TRUE;
   4587  1.1.1.2.4.2  tls }
   4588  1.1.1.2.4.2  tls 
   4589  1.1.1.2.4.2  tls static void
   4590  1.1.1.2.4.2  tls elf64_vms_post_process_headers (bfd *abfd,
   4591  1.1.1.2.4.2  tls 				struct bfd_link_info *info ATTRIBUTE_UNUSED)
   4592  1.1.1.2.4.2  tls {
   4593  1.1.1.2.4.2  tls   Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
   4594  1.1.1.2.4.2  tls 
   4595  1.1.1.2.4.2  tls   i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_OPENVMS;
   4596  1.1.1.2.4.2  tls   i_ehdrp->e_ident[EI_ABIVERSION] = 2;
   4597  1.1.1.2.4.2  tls }
   4598  1.1.1.2.4.2  tls 
   4599  1.1.1.2.4.2  tls static bfd_boolean
   4600  1.1.1.2.4.2  tls elf64_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED,
   4601  1.1.1.2.4.2  tls 			      Elf_Internal_Shdr *hdr)
   4602  1.1.1.2.4.2  tls {
   4603  1.1.1.2.4.2  tls   if (hdr->bfd_section != NULL)
   4604  1.1.1.2.4.2  tls     {
   4605  1.1.1.2.4.2  tls       const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
   4606  1.1.1.2.4.2  tls 
   4607  1.1.1.2.4.2  tls       if (strcmp (name, ".text") == 0)
   4608  1.1.1.2.4.2  tls 	hdr->sh_flags |= SHF_IA_64_VMS_SHARED;
   4609  1.1.1.2.4.2  tls       else if ((strcmp (name, ".debug") == 0)
   4610  1.1.1.2.4.2  tls 	    || (strcmp (name, ".debug_abbrev") == 0)
   4611  1.1.1.2.4.2  tls 	    || (strcmp (name, ".debug_aranges") == 0)
   4612  1.1.1.2.4.2  tls 	    || (strcmp (name, ".debug_frame") == 0)
   4613  1.1.1.2.4.2  tls 	    || (strcmp (name, ".debug_info") == 0)
   4614  1.1.1.2.4.2  tls 	    || (strcmp (name, ".debug_loc") == 0)
   4615  1.1.1.2.4.2  tls 	    || (strcmp (name, ".debug_macinfo") == 0)
   4616  1.1.1.2.4.2  tls 	    || (strcmp (name, ".debug_pubnames") == 0)
   4617  1.1.1.2.4.2  tls 	    || (strcmp (name, ".debug_pubtypes") == 0))
   4618  1.1.1.2.4.2  tls 	hdr->sh_type = SHT_IA_64_VMS_DEBUG;
   4619  1.1.1.2.4.2  tls       else if ((strcmp (name, ".debug_line") == 0)
   4620  1.1.1.2.4.2  tls 	    || (strcmp (name, ".debug_ranges") == 0)
   4621  1.1.1.2.4.2  tls 	    || (strcmp (name, ".trace_info") == 0)
   4622  1.1.1.2.4.2  tls 	    || (strcmp (name, ".trace_abbrev") == 0)
   4623  1.1.1.2.4.2  tls 	    || (strcmp (name, ".trace_aranges") == 0))
   4624  1.1.1.2.4.2  tls 	hdr->sh_type = SHT_IA_64_VMS_TRACE;
   4625  1.1.1.2.4.2  tls       else if (strcmp (name, ".debug_str") == 0)
   4626  1.1.1.2.4.2  tls 	hdr->sh_type = SHT_IA_64_VMS_DEBUG_STR;
   4627  1.1.1.2.4.2  tls     }
   4628  1.1.1.2.4.2  tls 
   4629  1.1.1.2.4.2  tls   return TRUE;
   4630  1.1.1.2.4.2  tls }
   4631  1.1.1.2.4.2  tls 
   4632  1.1.1.2.4.2  tls /* The final processing done just before writing out a VMS IA-64 ELF
   4633  1.1.1.2.4.2  tls    object file.  */
   4634  1.1.1.2.4.2  tls 
   4635  1.1.1.2.4.2  tls static void
   4636  1.1.1.2.4.2  tls elf64_vms_final_write_processing (bfd *abfd,
   4637  1.1.1.2.4.2  tls 				  bfd_boolean linker ATTRIBUTE_UNUSED)
   4638  1.1.1.2.4.2  tls {
   4639  1.1.1.2.4.2  tls   Elf_Internal_Shdr *hdr;
   4640  1.1.1.2.4.2  tls   asection *s;
   4641  1.1.1.2.4.2  tls   int unwind_info_sect_idx = 0;
   4642  1.1.1.2.4.2  tls 
   4643  1.1.1.2.4.2  tls   for (s = abfd->sections; s; s = s->next)
   4644  1.1.1.2.4.2  tls     {
   4645  1.1.1.2.4.2  tls       hdr = &elf_section_data (s)->this_hdr;
   4646  1.1.1.2.4.2  tls 
   4647  1.1.1.2.4.2  tls       if (strcmp (bfd_get_section_name (abfd, hdr->bfd_section),
   4648  1.1.1.2.4.2  tls 		  ".IA_64.unwind_info") == 0)
   4649  1.1.1.2.4.2  tls 	unwind_info_sect_idx = elf_section_data (s)->this_idx;
   4650  1.1.1.2.4.2  tls 
   4651  1.1.1.2.4.2  tls       switch (hdr->sh_type)
   4652  1.1.1.2.4.2  tls 	{
   4653  1.1.1.2.4.2  tls 	case SHT_IA_64_UNWIND:
   4654  1.1.1.2.4.2  tls 	  /* VMS requires sh_info to point to the unwind info section.  */
   4655  1.1.1.2.4.2  tls           hdr->sh_info = unwind_info_sect_idx;
   4656  1.1.1.2.4.2  tls 	  break;
   4657  1.1.1.2.4.2  tls 	}
   4658  1.1.1.2.4.2  tls     }
   4659  1.1.1.2.4.2  tls 
   4660  1.1.1.2.4.2  tls   if (! elf_flags_init (abfd))
   4661  1.1.1.2.4.2  tls     {
   4662  1.1.1.2.4.2  tls       unsigned long flags = 0;
   4663  1.1.1.2.4.2  tls 
   4664  1.1.1.2.4.2  tls       if (abfd->xvec->byteorder == BFD_ENDIAN_BIG)
   4665  1.1.1.2.4.2  tls 	flags |= EF_IA_64_BE;
   4666  1.1.1.2.4.2  tls       if (bfd_get_mach (abfd) == bfd_mach_ia64_elf64)
   4667  1.1.1.2.4.2  tls 	flags |= EF_IA_64_ABI64;
   4668  1.1.1.2.4.2  tls 
   4669  1.1.1.2.4.2  tls       elf_elfheader (abfd)->e_flags = flags;
   4670  1.1.1.2.4.2  tls       elf_flags_init (abfd) = TRUE;
   4671  1.1.1.2.4.2  tls     }
   4672  1.1.1.2.4.2  tls }
   4673  1.1.1.2.4.2  tls 
   4674  1.1.1.2.4.2  tls static bfd_boolean
   4675  1.1.1.2.4.2  tls elf64_vms_write_shdrs_and_ehdr (bfd *abfd)
   4676  1.1.1.2.4.2  tls {
   4677  1.1.1.2.4.2  tls   unsigned char needed_count[8];
   4678  1.1.1.2.4.2  tls 
   4679  1.1.1.2.4.2  tls   if (!bfd_elf64_write_shdrs_and_ehdr (abfd))
   4680  1.1.1.2.4.2  tls     return FALSE;
   4681  1.1.1.2.4.2  tls 
   4682  1.1.1.2.4.2  tls   bfd_putl64 (elf_ia64_vms_tdata (abfd)->needed_count, needed_count);
   4683  1.1.1.2.4.2  tls 
   4684  1.1.1.2.4.2  tls   if (bfd_seek (abfd, sizeof (Elf64_External_Ehdr), SEEK_SET) != 0
   4685  1.1.1.2.4.2  tls       || bfd_bwrite (needed_count, 8, abfd) != 8)
   4686  1.1.1.2.4.2  tls     return FALSE;
   4687  1.1.1.2.4.2  tls 
   4688  1.1.1.2.4.2  tls   return TRUE;
   4689  1.1.1.2.4.2  tls }
   4690  1.1.1.2.4.2  tls 
   4691  1.1.1.2.4.2  tls static bfd_boolean
   4692  1.1.1.2.4.2  tls elf64_vms_close_and_cleanup (bfd *abfd)
   4693  1.1.1.2.4.2  tls {
   4694  1.1.1.2.4.2  tls   if (bfd_get_format (abfd) == bfd_object)
   4695  1.1.1.2.4.2  tls     {
   4696  1.1.1.2.4.2  tls       long isize;
   4697  1.1.1.2.4.2  tls 
   4698  1.1.1.2.4.2  tls       /* Pad to 8 byte boundary for IPF/VMS.  */
   4699  1.1.1.2.4.2  tls       isize = bfd_get_size (abfd);
   4700  1.1.1.2.4.2  tls       if ((isize & 7) != 0)
   4701  1.1.1.2.4.2  tls 	{
   4702  1.1.1.2.4.2  tls 	  int ishort = 8 - (isize & 7);
   4703  1.1.1.2.4.2  tls           bfd_uint64_t pad = 0;
   4704  1.1.1.2.4.2  tls 
   4705  1.1.1.2.4.2  tls 	  bfd_seek (abfd, isize, SEEK_SET);
   4706  1.1.1.2.4.2  tls 	  bfd_bwrite (&pad, ishort, abfd);
   4707  1.1.1.2.4.2  tls 	}
   4708  1.1.1.2.4.2  tls     }
   4709  1.1.1.2.4.2  tls 
   4710  1.1.1.2.4.2  tls   return _bfd_elf_close_and_cleanup (abfd);
   4711  1.1.1.2.4.2  tls }
   4712  1.1.1.2.4.2  tls 
   4713  1.1.1.2.4.2  tls /* Add symbols from an ELF object file to the linker hash table.  */
   4714  1.1.1.2.4.2  tls 
   4715  1.1.1.2.4.2  tls static bfd_boolean
   4716  1.1.1.2.4.2  tls elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
   4717  1.1.1.2.4.2  tls {
   4718  1.1.1.2.4.2  tls   Elf_Internal_Shdr *hdr;
   4719  1.1.1.2.4.2  tls   bfd_size_type symcount;
   4720  1.1.1.2.4.2  tls   bfd_size_type extsymcount;
   4721  1.1.1.2.4.2  tls   bfd_size_type extsymoff;
   4722  1.1.1.2.4.2  tls   struct elf_link_hash_entry **sym_hash;
   4723  1.1.1.2.4.2  tls   bfd_boolean dynamic;
   4724  1.1.1.2.4.2  tls   Elf_Internal_Sym *isymbuf = NULL;
   4725  1.1.1.2.4.2  tls   Elf_Internal_Sym *isym;
   4726  1.1.1.2.4.2  tls   Elf_Internal_Sym *isymend;
   4727  1.1.1.2.4.2  tls   const struct elf_backend_data *bed;
   4728  1.1.1.2.4.2  tls   struct elf_link_hash_table *htab;
   4729  1.1.1.2.4.2  tls   bfd_size_type amt;
   4730  1.1.1.2.4.2  tls 
   4731  1.1.1.2.4.2  tls   htab = elf_hash_table (info);
   4732  1.1.1.2.4.2  tls   bed = get_elf_backend_data (abfd);
   4733  1.1.1.2.4.2  tls 
   4734  1.1.1.2.4.2  tls   if ((abfd->flags & DYNAMIC) == 0)
   4735  1.1.1.2.4.2  tls     dynamic = FALSE;
   4736  1.1.1.2.4.2  tls   else
   4737  1.1.1.2.4.2  tls     {
   4738  1.1.1.2.4.2  tls       dynamic = TRUE;
   4739  1.1.1.2.4.2  tls 
   4740  1.1.1.2.4.2  tls       /* You can't use -r against a dynamic object.  Also, there's no
   4741  1.1.1.2.4.2  tls 	 hope of using a dynamic object which does not exactly match
   4742  1.1.1.2.4.2  tls 	 the format of the output file.  */
   4743  1.1.1.2.4.2  tls       if (info->relocatable
   4744  1.1.1.2.4.2  tls 	  || !is_elf_hash_table (htab)
   4745  1.1.1.2.4.2  tls 	  || info->output_bfd->xvec != abfd->xvec)
   4746  1.1.1.2.4.2  tls 	{
   4747  1.1.1.2.4.2  tls 	  if (info->relocatable)
   4748  1.1.1.2.4.2  tls 	    bfd_set_error (bfd_error_invalid_operation);
   4749  1.1.1.2.4.2  tls 	  else
   4750  1.1.1.2.4.2  tls 	    bfd_set_error (bfd_error_wrong_format);
   4751  1.1.1.2.4.2  tls 	  goto error_return;
   4752  1.1.1.2.4.2  tls 	}
   4753  1.1.1.2.4.2  tls     }
   4754  1.1.1.2.4.2  tls 
   4755  1.1.1.2.4.2  tls   if (! dynamic)
   4756  1.1.1.2.4.2  tls     {
   4757  1.1.1.2.4.2  tls       /* If we are creating a shared library, create all the dynamic
   4758  1.1.1.2.4.2  tls 	 sections immediately.  We need to attach them to something,
   4759  1.1.1.2.4.2  tls 	 so we attach them to this BFD, provided it is the right
   4760  1.1.1.2.4.2  tls 	 format.  FIXME: If there are no input BFD's of the same
   4761  1.1.1.2.4.2  tls 	 format as the output, we can't make a shared library.  */
   4762  1.1.1.2.4.2  tls       if (info->shared
   4763  1.1.1.2.4.2  tls 	  && is_elf_hash_table (htab)
   4764  1.1.1.2.4.2  tls 	  && info->output_bfd->xvec == abfd->xvec
   4765  1.1.1.2.4.2  tls 	  && !htab->dynamic_sections_created)
   4766  1.1.1.2.4.2  tls 	{
   4767  1.1.1.2.4.2  tls 	  if (! elf64_ia64_create_dynamic_sections (abfd, info))
   4768  1.1.1.2.4.2  tls 	    goto error_return;
   4769  1.1.1.2.4.2  tls 	}
   4770  1.1.1.2.4.2  tls     }
   4771  1.1.1.2.4.2  tls   else if (!is_elf_hash_table (htab))
   4772  1.1.1.2.4.2  tls     goto error_return;
   4773  1.1.1.2.4.2  tls   else
   4774  1.1.1.2.4.2  tls     {
   4775  1.1.1.2.4.2  tls       asection *s;
   4776  1.1.1.2.4.2  tls       bfd_byte *dynbuf;
   4777  1.1.1.2.4.2  tls       bfd_byte *extdyn;
   4778  1.1.1.2.4.2  tls 
   4779  1.1.1.2.4.2  tls       /* ld --just-symbols and dynamic objects don't mix very well.
   4780  1.1.1.2.4.2  tls 	 ld shouldn't allow it.  */
   4781  1.1.1.2.4.2  tls       if ((s = abfd->sections) != NULL
   4782  1.1.1.2.4.2  tls 	  && s->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
   4783  1.1.1.2.4.2  tls 	abort ();
   4784  1.1.1.2.4.2  tls 
   4785  1.1.1.2.4.2  tls       /* Be sure there are dynamic sections.  */
   4786  1.1.1.2.4.2  tls       if (! elf64_ia64_create_dynamic_sections (htab->dynobj, info))
   4787  1.1.1.2.4.2  tls         goto error_return;
   4788  1.1.1.2.4.2  tls 
   4789  1.1.1.2.4.2  tls       s = bfd_get_section_by_name (abfd, ".dynamic");
   4790  1.1.1.2.4.2  tls       if (s == NULL)
   4791  1.1.1.2.4.2  tls         {
   4792  1.1.1.2.4.2  tls           /* VMS libraries do not have dynamic sections.  Create one from
   4793  1.1.1.2.4.2  tls              the segment.  */
   4794  1.1.1.2.4.2  tls           Elf_Internal_Phdr *phdr;
   4795  1.1.1.2.4.2  tls           unsigned int i, phnum;
   4796  1.1.1.2.4.2  tls 
   4797  1.1.1.2.4.2  tls           phdr = elf_tdata (abfd)->phdr;
   4798  1.1.1.2.4.2  tls           if (phdr == NULL)
   4799  1.1.1.2.4.2  tls             goto error_return;
   4800  1.1.1.2.4.2  tls           phnum = elf_elfheader (abfd)->e_phnum;
   4801  1.1.1.2.4.2  tls           for (i = 0; i < phnum; phdr++)
   4802  1.1.1.2.4.2  tls             if (phdr->p_type == PT_DYNAMIC)
   4803  1.1.1.2.4.2  tls               {
   4804  1.1.1.2.4.2  tls                 s = bfd_make_section (abfd, ".dynamic");
   4805  1.1.1.2.4.2  tls                 if (s == NULL)
   4806  1.1.1.2.4.2  tls                   goto error_return;
   4807  1.1.1.2.4.2  tls                 s->vma = phdr->p_vaddr;
   4808  1.1.1.2.4.2  tls                 s->lma = phdr->p_paddr;
   4809  1.1.1.2.4.2  tls                 s->size = phdr->p_filesz;
   4810  1.1.1.2.4.2  tls                 s->filepos = phdr->p_offset;
   4811  1.1.1.2.4.2  tls                 s->flags |= SEC_HAS_CONTENTS;
   4812  1.1.1.2.4.2  tls                 s->alignment_power = bfd_log2 (phdr->p_align);
   4813  1.1.1.2.4.2  tls                 break;
   4814  1.1.1.2.4.2  tls               }
   4815  1.1.1.2.4.2  tls           if (s == NULL)
   4816  1.1.1.2.4.2  tls             goto error_return;
   4817  1.1.1.2.4.2  tls         }
   4818  1.1.1.2.4.2  tls 
   4819  1.1.1.2.4.2  tls       /* Extract IDENT.  */
   4820  1.1.1.2.4.2  tls       if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
   4821  1.1.1.2.4.2  tls         {
   4822  1.1.1.2.4.2  tls error_free_dyn:
   4823  1.1.1.2.4.2  tls           free (dynbuf);
   4824  1.1.1.2.4.2  tls           goto error_return;
   4825  1.1.1.2.4.2  tls         }
   4826  1.1.1.2.4.2  tls 
   4827  1.1.1.2.4.2  tls       for (extdyn = dynbuf;
   4828  1.1.1.2.4.2  tls            extdyn < dynbuf + s->size;
   4829  1.1.1.2.4.2  tls            extdyn += bed->s->sizeof_dyn)
   4830  1.1.1.2.4.2  tls         {
   4831  1.1.1.2.4.2  tls           Elf_Internal_Dyn dyn;
   4832  1.1.1.2.4.2  tls 
   4833  1.1.1.2.4.2  tls           bed->s->swap_dyn_in (abfd, extdyn, &dyn);
   4834  1.1.1.2.4.2  tls           if (dyn.d_tag == DT_IA_64_VMS_IDENT)
   4835  1.1.1.2.4.2  tls             {
   4836  1.1.1.2.4.2  tls               bfd_uint64_t tagv = dyn.d_un.d_val;
   4837  1.1.1.2.4.2  tls               elf_ia64_vms_ident (abfd) = tagv;
   4838  1.1.1.2.4.2  tls               break;
   4839  1.1.1.2.4.2  tls             }
   4840  1.1.1.2.4.2  tls         }
   4841  1.1.1.2.4.2  tls       if (extdyn >= dynbuf + s->size)
   4842  1.1.1.2.4.2  tls         {
   4843  1.1.1.2.4.2  tls           /* Ident not found.  */
   4844  1.1.1.2.4.2  tls           goto error_free_dyn;
   4845  1.1.1.2.4.2  tls         }
   4846  1.1.1.2.4.2  tls       free (dynbuf);
   4847  1.1.1.2.4.2  tls 
   4848  1.1.1.2.4.2  tls       /* We do not want to include any of the sections in a dynamic
   4849  1.1.1.2.4.2  tls 	 object in the output file.  We hack by simply clobbering the
   4850  1.1.1.2.4.2  tls 	 list of sections in the BFD.  This could be handled more
   4851  1.1.1.2.4.2  tls 	 cleanly by, say, a new section flag; the existing
   4852  1.1.1.2.4.2  tls 	 SEC_NEVER_LOAD flag is not the one we want, because that one
   4853  1.1.1.2.4.2  tls 	 still implies that the section takes up space in the output
   4854  1.1.1.2.4.2  tls 	 file.  */
   4855  1.1.1.2.4.2  tls       bfd_section_list_clear (abfd);
   4856  1.1.1.2.4.2  tls 
   4857  1.1.1.2.4.2  tls       /* FIXME: should we detect if this library is already included ?
   4858  1.1.1.2.4.2  tls          This should be harmless and shouldn't happen in practice.  */
   4859  1.1.1.2.4.2  tls     }
   4860  1.1.1.2.4.2  tls 
   4861  1.1.1.2.4.2  tls   hdr = &elf_tdata (abfd)->symtab_hdr;
   4862  1.1.1.2.4.2  tls   symcount = hdr->sh_size / bed->s->sizeof_sym;
   4863  1.1.1.2.4.2  tls 
   4864  1.1.1.2.4.2  tls   /* The sh_info field of the symtab header tells us where the
   4865  1.1.1.2.4.2  tls      external symbols start.  We don't care about the local symbols at
   4866  1.1.1.2.4.2  tls      this point.  */
   4867  1.1.1.2.4.2  tls   extsymcount = symcount - hdr->sh_info;
   4868  1.1.1.2.4.2  tls   extsymoff = hdr->sh_info;
   4869  1.1.1.2.4.2  tls 
   4870  1.1.1.2.4.2  tls   sym_hash = NULL;
   4871  1.1.1.2.4.2  tls   if (extsymcount != 0)
   4872  1.1.1.2.4.2  tls     {
   4873  1.1.1.2.4.2  tls       isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff,
   4874  1.1.1.2.4.2  tls 				      NULL, NULL, NULL);
   4875  1.1.1.2.4.2  tls       if (isymbuf == NULL)
   4876  1.1.1.2.4.2  tls 	goto error_return;
   4877  1.1.1.2.4.2  tls 
   4878  1.1.1.2.4.2  tls       /* We store a pointer to the hash table entry for each external
   4879  1.1.1.2.4.2  tls 	 symbol.  */
   4880  1.1.1.2.4.2  tls       amt = extsymcount * sizeof (struct elf_link_hash_entry *);
   4881  1.1.1.2.4.2  tls       sym_hash = (struct elf_link_hash_entry **) bfd_alloc (abfd, amt);
   4882  1.1.1.2.4.2  tls       if (sym_hash == NULL)
   4883  1.1.1.2.4.2  tls 	goto error_free_sym;
   4884  1.1.1.2.4.2  tls       elf_sym_hashes (abfd) = sym_hash;
   4885  1.1.1.2.4.2  tls     }
   4886  1.1.1.2.4.2  tls 
   4887  1.1.1.2.4.2  tls   for (isym = isymbuf, isymend = isymbuf + extsymcount;
   4888  1.1.1.2.4.2  tls        isym < isymend;
   4889  1.1.1.2.4.2  tls        isym++, sym_hash++)
   4890  1.1.1.2.4.2  tls     {
   4891  1.1.1.2.4.2  tls       int bind;
   4892  1.1.1.2.4.2  tls       bfd_vma value;
   4893  1.1.1.2.4.2  tls       asection *sec, *new_sec;
   4894  1.1.1.2.4.2  tls       flagword flags;
   4895  1.1.1.2.4.2  tls       const char *name;
   4896  1.1.1.2.4.2  tls       struct elf_link_hash_entry *h;
   4897  1.1.1.2.4.2  tls       bfd_boolean definition;
   4898  1.1.1.2.4.2  tls       bfd_boolean size_change_ok;
   4899  1.1.1.2.4.2  tls       bfd_boolean type_change_ok;
   4900  1.1.1.2.4.2  tls       bfd_boolean common;
   4901  1.1.1.2.4.2  tls       unsigned int old_alignment;
   4902  1.1.1.2.4.2  tls       bfd *old_bfd;
   4903  1.1.1.2.4.2  tls 
   4904  1.1.1.2.4.2  tls       flags = BSF_NO_FLAGS;
   4905  1.1.1.2.4.2  tls       sec = NULL;
   4906  1.1.1.2.4.2  tls       value = isym->st_value;
   4907  1.1.1.2.4.2  tls       *sym_hash = NULL;
   4908  1.1.1.2.4.2  tls       common = bed->common_definition (isym);
   4909  1.1.1.2.4.2  tls 
   4910  1.1.1.2.4.2  tls       bind = ELF_ST_BIND (isym->st_info);
   4911  1.1.1.2.4.2  tls       switch (bind)
   4912  1.1.1.2.4.2  tls 	{
   4913  1.1.1.2.4.2  tls 	case STB_LOCAL:
   4914  1.1.1.2.4.2  tls 	  /* This should be impossible, since ELF requires that all
   4915  1.1.1.2.4.2  tls 	     global symbols follow all local symbols, and that sh_info
   4916  1.1.1.2.4.2  tls 	     point to the first global symbol.  Unfortunately, Irix 5
   4917  1.1.1.2.4.2  tls 	     screws this up.  */
   4918  1.1.1.2.4.2  tls 	  continue;
   4919  1.1.1.2.4.2  tls 
   4920  1.1.1.2.4.2  tls 	case STB_GLOBAL:
   4921  1.1.1.2.4.2  tls 	  if (isym->st_shndx != SHN_UNDEF && !common)
   4922  1.1.1.2.4.2  tls 	    flags = BSF_GLOBAL;
   4923  1.1.1.2.4.2  tls 	  break;
   4924  1.1.1.2.4.2  tls 
   4925  1.1.1.2.4.2  tls 	case STB_WEAK:
   4926  1.1.1.2.4.2  tls 	  flags = BSF_WEAK;
   4927  1.1.1.2.4.2  tls 	  break;
   4928  1.1.1.2.4.2  tls 
   4929  1.1.1.2.4.2  tls 	case STB_GNU_UNIQUE:
   4930  1.1.1.2.4.2  tls 	  flags = BSF_GNU_UNIQUE;
   4931  1.1.1.2.4.2  tls 	  break;
   4932  1.1.1.2.4.2  tls 
   4933  1.1.1.2.4.2  tls 	default:
   4934  1.1.1.2.4.2  tls 	  /* Leave it up to the processor backend.  */
   4935  1.1.1.2.4.2  tls 	  break;
   4936  1.1.1.2.4.2  tls 	}
   4937  1.1.1.2.4.2  tls 
   4938  1.1.1.2.4.2  tls       if (isym->st_shndx == SHN_UNDEF)
   4939  1.1.1.2.4.2  tls 	sec = bfd_und_section_ptr;
   4940  1.1.1.2.4.2  tls       else if (isym->st_shndx == SHN_ABS)
   4941  1.1.1.2.4.2  tls 	sec = bfd_abs_section_ptr;
   4942  1.1.1.2.4.2  tls       else if (isym->st_shndx == SHN_COMMON)
   4943  1.1.1.2.4.2  tls 	{
   4944  1.1.1.2.4.2  tls 	  sec = bfd_com_section_ptr;
   4945  1.1.1.2.4.2  tls 	  /* What ELF calls the size we call the value.  What ELF
   4946  1.1.1.2.4.2  tls 	     calls the value we call the alignment.  */
   4947  1.1.1.2.4.2  tls 	  value = isym->st_size;
   4948  1.1.1.2.4.2  tls 	}
   4949  1.1.1.2.4.2  tls       else
   4950  1.1.1.2.4.2  tls 	{
   4951  1.1.1.2.4.2  tls 	  sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
   4952  1.1.1.2.4.2  tls 	  if (sec == NULL)
   4953  1.1.1.2.4.2  tls 	    sec = bfd_abs_section_ptr;
   4954  1.1.1.2.4.2  tls 	  else if (sec->kept_section)
   4955  1.1.1.2.4.2  tls 	    {
   4956  1.1.1.2.4.2  tls 	      /* Symbols from discarded section are undefined.  We keep
   4957  1.1.1.2.4.2  tls 		 its visibility.  */
   4958  1.1.1.2.4.2  tls 	      sec = bfd_und_section_ptr;
   4959  1.1.1.2.4.2  tls 	      isym->st_shndx = SHN_UNDEF;
   4960  1.1.1.2.4.2  tls 	    }
   4961  1.1.1.2.4.2  tls 	  else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
   4962  1.1.1.2.4.2  tls 	    value -= sec->vma;
   4963  1.1.1.2.4.2  tls 	}
   4964  1.1.1.2.4.2  tls 
   4965  1.1.1.2.4.2  tls       name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
   4966  1.1.1.2.4.2  tls 					      isym->st_name);
   4967  1.1.1.2.4.2  tls       if (name == NULL)
   4968  1.1.1.2.4.2  tls 	goto error_free_vers;
   4969  1.1.1.2.4.2  tls 
   4970  1.1.1.2.4.2  tls       if (bed->elf_add_symbol_hook)
   4971  1.1.1.2.4.2  tls 	{
   4972  1.1.1.2.4.2  tls 	  if (! (*bed->elf_add_symbol_hook) (abfd, info, isym, &name, &flags,
   4973  1.1.1.2.4.2  tls 					     &sec, &value))
   4974  1.1.1.2.4.2  tls 	    goto error_free_vers;
   4975  1.1.1.2.4.2  tls 
   4976  1.1.1.2.4.2  tls 	  /* The hook function sets the name to NULL if this symbol
   4977  1.1.1.2.4.2  tls 	     should be skipped for some reason.  */
   4978  1.1.1.2.4.2  tls 	  if (name == NULL)
   4979  1.1.1.2.4.2  tls 	    continue;
   4980  1.1.1.2.4.2  tls 	}
   4981  1.1.1.2.4.2  tls 
   4982  1.1.1.2.4.2  tls       /* Sanity check that all possibilities were handled.  */
   4983  1.1.1.2.4.2  tls       if (sec == NULL)
   4984  1.1.1.2.4.2  tls 	{
   4985  1.1.1.2.4.2  tls 	  bfd_set_error (bfd_error_bad_value);
   4986  1.1.1.2.4.2  tls 	  goto error_free_vers;
   4987  1.1.1.2.4.2  tls 	}
   4988  1.1.1.2.4.2  tls 
   4989  1.1.1.2.4.2  tls       if (bfd_is_und_section (sec)
   4990  1.1.1.2.4.2  tls 	  || bfd_is_com_section (sec))
   4991  1.1.1.2.4.2  tls 	definition = FALSE;
   4992  1.1.1.2.4.2  tls       else
   4993  1.1.1.2.4.2  tls 	definition = TRUE;
   4994  1.1.1.2.4.2  tls 
   4995  1.1.1.2.4.2  tls       size_change_ok = FALSE;
   4996  1.1.1.2.4.2  tls       type_change_ok = bed->type_change_ok;
   4997  1.1.1.2.4.2  tls       old_alignment = 0;
   4998  1.1.1.2.4.2  tls       old_bfd = NULL;
   4999  1.1.1.2.4.2  tls       new_sec = sec;
   5000  1.1.1.2.4.2  tls 
   5001  1.1.1.2.4.2  tls       if (! bfd_is_und_section (sec))
   5002  1.1.1.2.4.2  tls         h = elf_link_hash_lookup (htab, name, TRUE, FALSE, FALSE);
   5003  1.1.1.2.4.2  tls       else
   5004  1.1.1.2.4.2  tls         h = ((struct elf_link_hash_entry *) bfd_wrapped_link_hash_lookup
   5005  1.1.1.2.4.2  tls              (abfd, info, name, TRUE, FALSE, FALSE));
   5006  1.1.1.2.4.2  tls       if (h == NULL)
   5007  1.1.1.2.4.2  tls         goto error_free_sym;
   5008  1.1.1.2.4.2  tls 
   5009  1.1.1.2.4.2  tls       *sym_hash = h;
   5010  1.1.1.2.4.2  tls 
   5011  1.1.1.2.4.2  tls       if (is_elf_hash_table (htab))
   5012  1.1.1.2.4.2  tls 	{
   5013  1.1.1.2.4.2  tls 	  while (h->root.type == bfd_link_hash_indirect
   5014  1.1.1.2.4.2  tls 		 || h->root.type == bfd_link_hash_warning)
   5015  1.1.1.2.4.2  tls 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
   5016  1.1.1.2.4.2  tls 
   5017  1.1.1.2.4.2  tls 	  /* Remember the old alignment if this is a common symbol, so
   5018  1.1.1.2.4.2  tls 	     that we don't reduce the alignment later on.  We can't
   5019  1.1.1.2.4.2  tls 	     check later, because _bfd_generic_link_add_one_symbol
   5020  1.1.1.2.4.2  tls 	     will set a default for the alignment which we want to
   5021  1.1.1.2.4.2  tls 	     override. We also remember the old bfd where the existing
   5022  1.1.1.2.4.2  tls 	     definition comes from.  */
   5023  1.1.1.2.4.2  tls 	  switch (h->root.type)
   5024  1.1.1.2.4.2  tls 	    {
   5025  1.1.1.2.4.2  tls 	    default:
   5026  1.1.1.2.4.2  tls 	      break;
   5027  1.1.1.2.4.2  tls 
   5028  1.1.1.2.4.2  tls 	    case bfd_link_hash_defined:
   5029  1.1.1.2.4.2  tls               if (abfd->selective_search)
   5030  1.1.1.2.4.2  tls                 continue;
   5031  1.1.1.2.4.2  tls               /* Fall-through.  */
   5032  1.1.1.2.4.2  tls 	    case bfd_link_hash_defweak:
   5033  1.1.1.2.4.2  tls 	      old_bfd = h->root.u.def.section->owner;
   5034  1.1.1.2.4.2  tls 	      break;
   5035  1.1.1.2.4.2  tls 
   5036  1.1.1.2.4.2  tls 	    case bfd_link_hash_common:
   5037  1.1.1.2.4.2  tls 	      old_bfd = h->root.u.c.p->section->owner;
   5038  1.1.1.2.4.2  tls 	      old_alignment = h->root.u.c.p->alignment_power;
   5039  1.1.1.2.4.2  tls 	      break;
   5040  1.1.1.2.4.2  tls 	    }
   5041  1.1.1.2.4.2  tls 	}
   5042  1.1.1.2.4.2  tls 
   5043  1.1.1.2.4.2  tls       if (! (_bfd_generic_link_add_one_symbol
   5044  1.1.1.2.4.2  tls 	     (info, abfd, name, flags, sec, value, NULL, FALSE, bed->collect,
   5045  1.1.1.2.4.2  tls 	      (struct bfd_link_hash_entry **) sym_hash)))
   5046  1.1.1.2.4.2  tls 	goto error_free_vers;
   5047  1.1.1.2.4.2  tls 
   5048  1.1.1.2.4.2  tls       h = *sym_hash;
   5049  1.1.1.2.4.2  tls       while (h->root.type == bfd_link_hash_indirect
   5050  1.1.1.2.4.2  tls 	     || h->root.type == bfd_link_hash_warning)
   5051  1.1.1.2.4.2  tls 	h = (struct elf_link_hash_entry *) h->root.u.i.link;
   5052  1.1.1.2.4.2  tls 
   5053  1.1.1.2.4.2  tls       *sym_hash = h;
   5054  1.1.1.2.4.2  tls       if (definition)
   5055  1.1.1.2.4.2  tls 	h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
   5056  1.1.1.2.4.2  tls 
   5057  1.1.1.2.4.2  tls       /* Set the alignment of a common symbol.  */
   5058  1.1.1.2.4.2  tls       if ((common || bfd_is_com_section (sec))
   5059  1.1.1.2.4.2  tls 	  && h->root.type == bfd_link_hash_common)
   5060  1.1.1.2.4.2  tls 	{
   5061  1.1.1.2.4.2  tls 	  unsigned int align;
   5062  1.1.1.2.4.2  tls 
   5063  1.1.1.2.4.2  tls 	  if (common)
   5064  1.1.1.2.4.2  tls 	    align = bfd_log2 (isym->st_value);
   5065  1.1.1.2.4.2  tls 	  else
   5066  1.1.1.2.4.2  tls 	    {
   5067  1.1.1.2.4.2  tls 	      /* The new symbol is a common symbol in a shared object.
   5068  1.1.1.2.4.2  tls 		 We need to get the alignment from the section.  */
   5069  1.1.1.2.4.2  tls 	      align = new_sec->alignment_power;
   5070  1.1.1.2.4.2  tls 	    }
   5071  1.1.1.2.4.2  tls 	  if (align > old_alignment
   5072  1.1.1.2.4.2  tls 	      /* Permit an alignment power of zero if an alignment of one
   5073  1.1.1.2.4.2  tls 		 is specified and no other alignments have been specified.  */
   5074  1.1.1.2.4.2  tls 	      || (isym->st_value == 1 && old_alignment == 0))
   5075  1.1.1.2.4.2  tls 	    h->root.u.c.p->alignment_power = align;
   5076  1.1.1.2.4.2  tls 	  else
   5077  1.1.1.2.4.2  tls 	    h->root.u.c.p->alignment_power = old_alignment;
   5078  1.1.1.2.4.2  tls 	}
   5079  1.1.1.2.4.2  tls 
   5080  1.1.1.2.4.2  tls       if (is_elf_hash_table (htab))
   5081  1.1.1.2.4.2  tls 	{
   5082  1.1.1.2.4.2  tls 	  /* Check the alignment when a common symbol is involved. This
   5083  1.1.1.2.4.2  tls 	     can change when a common symbol is overridden by a normal
   5084  1.1.1.2.4.2  tls 	     definition or a common symbol is ignored due to the old
   5085  1.1.1.2.4.2  tls 	     normal definition. We need to make sure the maximum
   5086  1.1.1.2.4.2  tls 	     alignment is maintained.  */
   5087  1.1.1.2.4.2  tls 	  if ((old_alignment || common)
   5088  1.1.1.2.4.2  tls 	      && h->root.type != bfd_link_hash_common)
   5089  1.1.1.2.4.2  tls 	    {
   5090  1.1.1.2.4.2  tls 	      unsigned int common_align;
   5091  1.1.1.2.4.2  tls 	      unsigned int normal_align;
   5092  1.1.1.2.4.2  tls 	      unsigned int symbol_align;
   5093  1.1.1.2.4.2  tls 	      bfd *normal_bfd;
   5094  1.1.1.2.4.2  tls 	      bfd *common_bfd;
   5095  1.1.1.2.4.2  tls 
   5096  1.1.1.2.4.2  tls 	      symbol_align = ffs (h->root.u.def.value) - 1;
   5097  1.1.1.2.4.2  tls 	      if (h->root.u.def.section->owner != NULL
   5098  1.1.1.2.4.2  tls 		  && (h->root.u.def.section->owner->flags & DYNAMIC) == 0)
   5099  1.1.1.2.4.2  tls 		{
   5100  1.1.1.2.4.2  tls 		  normal_align = h->root.u.def.section->alignment_power;
   5101  1.1.1.2.4.2  tls 		  if (normal_align > symbol_align)
   5102  1.1.1.2.4.2  tls 		    normal_align = symbol_align;
   5103  1.1.1.2.4.2  tls 		}
   5104  1.1.1.2.4.2  tls 	      else
   5105  1.1.1.2.4.2  tls 		normal_align = symbol_align;
   5106  1.1.1.2.4.2  tls 
   5107  1.1.1.2.4.2  tls 	      if (old_alignment)
   5108  1.1.1.2.4.2  tls 		{
   5109  1.1.1.2.4.2  tls 		  common_align = old_alignment;
   5110  1.1.1.2.4.2  tls 		  common_bfd = old_bfd;
   5111  1.1.1.2.4.2  tls 		  normal_bfd = abfd;
   5112  1.1.1.2.4.2  tls 		}
   5113  1.1.1.2.4.2  tls 	      else
   5114  1.1.1.2.4.2  tls 		{
   5115  1.1.1.2.4.2  tls 		  common_align = bfd_log2 (isym->st_value);
   5116  1.1.1.2.4.2  tls 		  common_bfd = abfd;
   5117  1.1.1.2.4.2  tls 		  normal_bfd = old_bfd;
   5118  1.1.1.2.4.2  tls 		}
   5119  1.1.1.2.4.2  tls 
   5120  1.1.1.2.4.2  tls 	      if (normal_align < common_align)
   5121  1.1.1.2.4.2  tls 		{
   5122  1.1.1.2.4.2  tls 		  /* PR binutils/2735 */
   5123  1.1.1.2.4.2  tls 		  if (normal_bfd == NULL)
   5124  1.1.1.2.4.2  tls 		    (*_bfd_error_handler)
   5125  1.1.1.2.4.2  tls 		      (_("Warning: alignment %u of common symbol `%s' in %B"
   5126  1.1.1.2.4.2  tls 			 " is greater than the alignment (%u) of its section %A"),
   5127  1.1.1.2.4.2  tls 		       common_bfd, h->root.u.def.section,
   5128  1.1.1.2.4.2  tls 		       1 << common_align, name, 1 << normal_align);
   5129  1.1.1.2.4.2  tls 		  else
   5130  1.1.1.2.4.2  tls 		    (*_bfd_error_handler)
   5131  1.1.1.2.4.2  tls 		      (_("Warning: alignment %u of symbol `%s' in %B"
   5132  1.1.1.2.4.2  tls 			 " is smaller than %u in %B"),
   5133  1.1.1.2.4.2  tls 		       normal_bfd, common_bfd,
   5134  1.1.1.2.4.2  tls 		       1 << normal_align, name, 1 << common_align);
   5135  1.1.1.2.4.2  tls 		}
   5136  1.1.1.2.4.2  tls 	    }
   5137  1.1.1.2.4.2  tls 
   5138  1.1.1.2.4.2  tls 	  /* Remember the symbol size if it isn't undefined.  */
   5139  1.1.1.2.4.2  tls 	  if ((isym->st_size != 0 && isym->st_shndx != SHN_UNDEF)
   5140  1.1.1.2.4.2  tls 	      && (definition || h->size == 0))
   5141  1.1.1.2.4.2  tls 	    {
   5142  1.1.1.2.4.2  tls 	      if (h->size != 0
   5143  1.1.1.2.4.2  tls 		  && h->size != isym->st_size
   5144  1.1.1.2.4.2  tls 		  && ! size_change_ok)
   5145  1.1.1.2.4.2  tls 		(*_bfd_error_handler)
   5146  1.1.1.2.4.2  tls 		  (_("Warning: size of symbol `%s' changed"
   5147  1.1.1.2.4.2  tls 		     " from %lu in %B to %lu in %B"),
   5148  1.1.1.2.4.2  tls 		   old_bfd, abfd,
   5149  1.1.1.2.4.2  tls 		   name, (unsigned long) h->size,
   5150  1.1.1.2.4.2  tls 		   (unsigned long) isym->st_size);
   5151  1.1.1.2.4.2  tls 
   5152  1.1.1.2.4.2  tls 	      h->size = isym->st_size;
   5153  1.1.1.2.4.2  tls 	    }
   5154  1.1.1.2.4.2  tls 
   5155  1.1.1.2.4.2  tls 	  /* If this is a common symbol, then we always want H->SIZE
   5156  1.1.1.2.4.2  tls 	     to be the size of the common symbol.  The code just above
   5157  1.1.1.2.4.2  tls 	     won't fix the size if a common symbol becomes larger.  We
   5158  1.1.1.2.4.2  tls 	     don't warn about a size change here, because that is
   5159  1.1.1.2.4.2  tls 	     covered by --warn-common.  Allow changed between different
   5160  1.1.1.2.4.2  tls 	     function types.  */
   5161  1.1.1.2.4.2  tls 	  if (h->root.type == bfd_link_hash_common)
   5162  1.1.1.2.4.2  tls 	    h->size = h->root.u.c.size;
   5163  1.1.1.2.4.2  tls 
   5164  1.1.1.2.4.2  tls 	  if (ELF_ST_TYPE (isym->st_info) != STT_NOTYPE
   5165  1.1.1.2.4.2  tls 	      && (definition || h->type == STT_NOTYPE))
   5166  1.1.1.2.4.2  tls 	    {
   5167  1.1.1.2.4.2  tls 	      unsigned int type = ELF_ST_TYPE (isym->st_info);
   5168  1.1.1.2.4.2  tls 
   5169  1.1.1.2.4.2  tls 	      if (h->type != type)
   5170  1.1.1.2.4.2  tls 		{
   5171  1.1.1.2.4.2  tls 		  if (h->type != STT_NOTYPE && ! type_change_ok)
   5172  1.1.1.2.4.2  tls 		    (*_bfd_error_handler)
   5173  1.1.1.2.4.2  tls 		      (_("Warning: type of symbol `%s' changed"
   5174  1.1.1.2.4.2  tls 			 " from %d to %d in %B"),
   5175  1.1.1.2.4.2  tls 		       abfd, name, h->type, type);
   5176  1.1.1.2.4.2  tls 
   5177  1.1.1.2.4.2  tls 		  h->type = type;
   5178  1.1.1.2.4.2  tls 		}
   5179  1.1.1.2.4.2  tls 	    }
   5180  1.1.1.2.4.2  tls 
   5181  1.1.1.2.4.2  tls 	  /* Set a flag in the hash table entry indicating the type of
   5182  1.1.1.2.4.2  tls 	     reference or definition we just found.  Keep a count of
   5183  1.1.1.2.4.2  tls 	     the number of dynamic symbols we find.  A dynamic symbol
   5184  1.1.1.2.4.2  tls 	     is one which is referenced or defined by both a regular
   5185  1.1.1.2.4.2  tls 	     object and a shared object.  */
   5186  1.1.1.2.4.2  tls 	  if (! dynamic)
   5187  1.1.1.2.4.2  tls 	    {
   5188  1.1.1.2.4.2  tls 	      if (! definition)
   5189  1.1.1.2.4.2  tls 		{
   5190  1.1.1.2.4.2  tls 		  h->ref_regular = 1;
   5191  1.1.1.2.4.2  tls 		  if (bind != STB_WEAK)
   5192  1.1.1.2.4.2  tls 		    h->ref_regular_nonweak = 1;
   5193  1.1.1.2.4.2  tls 		}
   5194  1.1.1.2.4.2  tls 	      else
   5195  1.1.1.2.4.2  tls 		{
   5196  1.1.1.2.4.2  tls                   BFD_ASSERT (!h->def_dynamic);
   5197  1.1.1.2.4.2  tls 		  h->def_regular = 1;
   5198  1.1.1.2.4.2  tls 		}
   5199  1.1.1.2.4.2  tls 	    }
   5200  1.1.1.2.4.2  tls 	  else
   5201  1.1.1.2.4.2  tls 	    {
   5202  1.1.1.2.4.2  tls 	      BFD_ASSERT (definition);
   5203  1.1.1.2.4.2  tls               h->def_dynamic = 1;
   5204  1.1.1.2.4.2  tls               h->dynindx = -2;
   5205  1.1.1.2.4.2  tls               ((struct elf64_ia64_link_hash_entry *)h)->shl = abfd;
   5206  1.1.1.2.4.2  tls 	    }
   5207  1.1.1.2.4.2  tls 	}
   5208  1.1.1.2.4.2  tls     }
   5209  1.1.1.2.4.2  tls 
   5210  1.1.1.2.4.2  tls   if (isymbuf != NULL)
   5211  1.1.1.2.4.2  tls     {
   5212  1.1.1.2.4.2  tls       free (isymbuf);
   5213  1.1.1.2.4.2  tls       isymbuf = NULL;
   5214  1.1.1.2.4.2  tls     }
   5215  1.1.1.2.4.2  tls 
   5216  1.1.1.2.4.2  tls   /* If this object is the same format as the output object, and it is
   5217  1.1.1.2.4.2  tls      not a shared library, then let the backend look through the
   5218  1.1.1.2.4.2  tls      relocs.
   5219  1.1.1.2.4.2  tls 
   5220  1.1.1.2.4.2  tls      This is required to build global offset table entries and to
   5221  1.1.1.2.4.2  tls      arrange for dynamic relocs.  It is not required for the
   5222  1.1.1.2.4.2  tls      particular common case of linking non PIC code, even when linking
   5223  1.1.1.2.4.2  tls      against shared libraries, but unfortunately there is no way of
   5224  1.1.1.2.4.2  tls      knowing whether an object file has been compiled PIC or not.
   5225  1.1.1.2.4.2  tls      Looking through the relocs is not particularly time consuming.
   5226  1.1.1.2.4.2  tls      The problem is that we must either (1) keep the relocs in memory,
   5227  1.1.1.2.4.2  tls      which causes the linker to require additional runtime memory or
   5228  1.1.1.2.4.2  tls      (2) read the relocs twice from the input file, which wastes time.
   5229  1.1.1.2.4.2  tls      This would be a good case for using mmap.
   5230  1.1.1.2.4.2  tls 
   5231  1.1.1.2.4.2  tls      I have no idea how to handle linking PIC code into a file of a
   5232  1.1.1.2.4.2  tls      different format.  It probably can't be done.  */
   5233  1.1.1.2.4.2  tls   if (! dynamic
   5234  1.1.1.2.4.2  tls       && is_elf_hash_table (htab)
   5235  1.1.1.2.4.2  tls       && bed->check_relocs != NULL
   5236  1.1.1.2.4.2  tls       && (*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec))
   5237  1.1.1.2.4.2  tls     {
   5238  1.1.1.2.4.2  tls       asection *o;
   5239  1.1.1.2.4.2  tls 
   5240  1.1.1.2.4.2  tls       for (o = abfd->sections; o != NULL; o = o->next)
   5241  1.1.1.2.4.2  tls 	{
   5242  1.1.1.2.4.2  tls 	  Elf_Internal_Rela *internal_relocs;
   5243  1.1.1.2.4.2  tls 	  bfd_boolean ok;
   5244  1.1.1.2.4.2  tls 
   5245  1.1.1.2.4.2  tls 	  if ((o->flags & SEC_RELOC) == 0
   5246  1.1.1.2.4.2  tls 	      || o->reloc_count == 0
   5247  1.1.1.2.4.2  tls 	      || ((info->strip == strip_all || info->strip == strip_debugger)
   5248  1.1.1.2.4.2  tls 		  && (o->flags & SEC_DEBUGGING) != 0)
   5249  1.1.1.2.4.2  tls 	      || bfd_is_abs_section (o->output_section))
   5250  1.1.1.2.4.2  tls 	    continue;
   5251  1.1.1.2.4.2  tls 
   5252  1.1.1.2.4.2  tls 	  internal_relocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL,
   5253  1.1.1.2.4.2  tls 						       info->keep_memory);
   5254  1.1.1.2.4.2  tls 	  if (internal_relocs == NULL)
   5255  1.1.1.2.4.2  tls 	    goto error_return;
   5256  1.1.1.2.4.2  tls 
   5257  1.1.1.2.4.2  tls 	  ok = (*bed->check_relocs) (abfd, info, o, internal_relocs);
   5258  1.1.1.2.4.2  tls 
   5259  1.1.1.2.4.2  tls 	  if (elf_section_data (o)->relocs != internal_relocs)
   5260  1.1.1.2.4.2  tls 	    free (internal_relocs);
   5261  1.1.1.2.4.2  tls 
   5262  1.1.1.2.4.2  tls 	  if (! ok)
   5263  1.1.1.2.4.2  tls 	    goto error_return;
   5264  1.1.1.2.4.2  tls 	}
   5265  1.1.1.2.4.2  tls     }
   5266  1.1.1.2.4.2  tls 
   5267  1.1.1.2.4.2  tls   return TRUE;
   5268  1.1.1.2.4.2  tls 
   5269  1.1.1.2.4.2  tls  error_free_vers:
   5270  1.1.1.2.4.2  tls  error_free_sym:
   5271  1.1.1.2.4.2  tls   if (isymbuf != NULL)
   5272  1.1.1.2.4.2  tls     free (isymbuf);
   5273  1.1.1.2.4.2  tls  error_return:
   5274  1.1.1.2.4.2  tls   return FALSE;
   5275  1.1.1.2.4.2  tls }
   5276  1.1.1.2.4.2  tls 
   5277  1.1.1.2.4.2  tls static bfd_boolean
   5278  1.1.1.2.4.2  tls elf64_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
   5279  1.1.1.2.4.2  tls {
   5280  1.1.1.2.4.2  tls   int pass;
   5281  1.1.1.2.4.2  tls   struct bfd_link_hash_entry **pundef;
   5282  1.1.1.2.4.2  tls   struct bfd_link_hash_entry **next_pundef;
   5283  1.1.1.2.4.2  tls 
   5284  1.1.1.2.4.2  tls   /* We only accept VMS libraries.  */
   5285  1.1.1.2.4.2  tls   if (info->output_bfd->xvec != abfd->xvec)
   5286  1.1.1.2.4.2  tls     {
   5287  1.1.1.2.4.2  tls       bfd_set_error (bfd_error_wrong_format);
   5288  1.1.1.2.4.2  tls       return FALSE;
   5289  1.1.1.2.4.2  tls     }
   5290  1.1.1.2.4.2  tls 
   5291  1.1.1.2.4.2  tls   /* The archive_pass field in the archive itself is used to
   5292  1.1.1.2.4.2  tls      initialize PASS, since we may search the same archive multiple
   5293  1.1.1.2.4.2  tls      times.  */
   5294  1.1.1.2.4.2  tls   pass = ++abfd->archive_pass;
   5295  1.1.1.2.4.2  tls 
   5296  1.1.1.2.4.2  tls   /* Look through the list of undefined symbols.  */
   5297  1.1.1.2.4.2  tls   for (pundef = &info->hash->undefs; *pundef != NULL; pundef = next_pundef)
   5298  1.1.1.2.4.2  tls     {
   5299  1.1.1.2.4.2  tls       struct bfd_link_hash_entry *h;
   5300  1.1.1.2.4.2  tls       symindex symidx;
   5301  1.1.1.2.4.2  tls       bfd *element;
   5302  1.1.1.2.4.2  tls       bfd *orig_element;
   5303  1.1.1.2.4.2  tls 
   5304  1.1.1.2.4.2  tls       h = *pundef;
   5305  1.1.1.2.4.2  tls       next_pundef = &(*pundef)->u.undef.next;
   5306  1.1.1.2.4.2  tls 
   5307  1.1.1.2.4.2  tls       /* When a symbol is defined, it is not necessarily removed from
   5308  1.1.1.2.4.2  tls 	 the list.  */
   5309  1.1.1.2.4.2  tls       if (h->type != bfd_link_hash_undefined
   5310  1.1.1.2.4.2  tls 	  && h->type != bfd_link_hash_common)
   5311  1.1.1.2.4.2  tls 	{
   5312  1.1.1.2.4.2  tls 	  /* Remove this entry from the list, for general cleanliness
   5313  1.1.1.2.4.2  tls 	     and because we are going to look through the list again
   5314  1.1.1.2.4.2  tls 	     if we search any more libraries.  We can't remove the
   5315  1.1.1.2.4.2  tls 	     entry if it is the tail, because that would lose any
   5316  1.1.1.2.4.2  tls 	     entries we add to the list later on.  */
   5317  1.1.1.2.4.2  tls 	  if (*pundef != info->hash->undefs_tail)
   5318  1.1.1.2.4.2  tls             {
   5319  1.1.1.2.4.2  tls               *pundef = *next_pundef;
   5320  1.1.1.2.4.2  tls               next_pundef = pundef;
   5321  1.1.1.2.4.2  tls             }
   5322  1.1.1.2.4.2  tls 	  continue;
   5323  1.1.1.2.4.2  tls 	}
   5324  1.1.1.2.4.2  tls 
   5325  1.1.1.2.4.2  tls       /* Look for this symbol in the archive hash table.  */
   5326  1.1.1.2.4.2  tls       symidx = _bfd_vms_lib_find_symbol (abfd, h->root.string);
   5327  1.1.1.2.4.2  tls       if (symidx == BFD_NO_MORE_SYMBOLS)
   5328  1.1.1.2.4.2  tls 	{
   5329  1.1.1.2.4.2  tls 	  /* Nothing in this slot.  */
   5330  1.1.1.2.4.2  tls 	  continue;
   5331  1.1.1.2.4.2  tls 	}
   5332  1.1.1.2.4.2  tls 
   5333  1.1.1.2.4.2  tls       element = bfd_get_elt_at_index (abfd, symidx);
   5334  1.1.1.2.4.2  tls       if (element == NULL)
   5335  1.1.1.2.4.2  tls 	return FALSE;
   5336  1.1.1.2.4.2  tls 
   5337  1.1.1.2.4.2  tls       if (element->archive_pass == -1 || element->archive_pass == pass)
   5338  1.1.1.2.4.2  tls         {
   5339  1.1.1.2.4.2  tls           /* Next symbol if this archive is wrong or already handled.  */
   5340  1.1.1.2.4.2  tls           continue;
   5341  1.1.1.2.4.2  tls         }
   5342  1.1.1.2.4.2  tls 
   5343  1.1.1.2.4.2  tls       orig_element = element;
   5344  1.1.1.2.4.2  tls       if (bfd_is_thin_archive (abfd))
   5345  1.1.1.2.4.2  tls         {
   5346  1.1.1.2.4.2  tls           element = _bfd_vms_lib_get_imagelib_file (element);
   5347  1.1.1.2.4.2  tls           if (element == NULL || !bfd_check_format (element, bfd_object))
   5348  1.1.1.2.4.2  tls             {
   5349  1.1.1.2.4.2  tls               orig_element->archive_pass = -1;
   5350  1.1.1.2.4.2  tls               return FALSE;
   5351  1.1.1.2.4.2  tls             }
   5352  1.1.1.2.4.2  tls         }
   5353  1.1.1.2.4.2  tls       else if (! bfd_check_format (element, bfd_object))
   5354  1.1.1.2.4.2  tls         {
   5355  1.1.1.2.4.2  tls           element->archive_pass = -1;
   5356  1.1.1.2.4.2  tls           return FALSE;
   5357  1.1.1.2.4.2  tls         }
   5358  1.1.1.2.4.2  tls 
   5359  1.1.1.2.4.2  tls       /* Unlike the generic linker, we know that this element provides
   5360  1.1.1.2.4.2  tls 	 a definition for an undefined symbol and we know that we want
   5361  1.1.1.2.4.2  tls 	 to include it.  We don't need to check anything.  */
   5362  1.1.1.2.4.2  tls       if (! (*info->callbacks->add_archive_element) (info, element,
   5363  1.1.1.2.4.2  tls                                                      h->root.string, &element))
   5364  1.1.1.2.4.2  tls 	return FALSE;
   5365  1.1.1.2.4.2  tls       if (! elf64_vms_link_add_object_symbols (element, info))
   5366  1.1.1.2.4.2  tls 	return FALSE;
   5367  1.1.1.2.4.2  tls 
   5368  1.1.1.2.4.2  tls       orig_element->archive_pass = pass;
   5369  1.1.1.2.4.2  tls     }
   5370  1.1.1.2.4.2  tls 
   5371  1.1.1.2.4.2  tls   return TRUE;
   5372  1.1.1.2.4.2  tls }
   5373  1.1.1.2.4.2  tls 
   5374  1.1.1.2.4.2  tls static bfd_boolean
   5375  1.1.1.2.4.2  tls elf64_vms_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
   5376  1.1.1.2.4.2  tls {
   5377  1.1.1.2.4.2  tls   switch (bfd_get_format (abfd))
   5378  1.1.1.2.4.2  tls     {
   5379  1.1.1.2.4.2  tls     case bfd_object:
   5380  1.1.1.2.4.2  tls       return elf64_vms_link_add_object_symbols (abfd, info);
   5381  1.1.1.2.4.2  tls       break;
   5382  1.1.1.2.4.2  tls     case bfd_archive:
   5383  1.1.1.2.4.2  tls       return elf64_vms_link_add_archive_symbols (abfd, info);
   5384  1.1.1.2.4.2  tls       break;
   5385  1.1.1.2.4.2  tls     default:
   5386  1.1.1.2.4.2  tls       bfd_set_error (bfd_error_wrong_format);
   5387  1.1.1.2.4.2  tls       return FALSE;
   5388  1.1.1.2.4.2  tls     }
   5389  1.1.1.2.4.2  tls }
   5390  1.1.1.2.4.2  tls 
   5391  1.1.1.2.4.2  tls static bfd_boolean
   5392  1.1.1.2.4.2  tls elf64_ia64_vms_mkobject (bfd *abfd)
   5393  1.1.1.2.4.2  tls {
   5394  1.1.1.2.4.2  tls   return bfd_elf_allocate_object
   5395  1.1.1.2.4.2  tls     (abfd, sizeof (struct elf64_ia64_vms_obj_tdata), IA64_ELF_DATA);
   5396  1.1.1.2.4.2  tls }
   5397  1.1.1.2.4.2  tls 
   5398  1.1.1.2.4.2  tls 
   5399  1.1.1.2.4.2  tls /* Size-dependent data and functions.  */
   5400  1.1.1.2.4.2  tls static const struct elf_size_info elf64_ia64_vms_size_info = {
   5401  1.1.1.2.4.2  tls   sizeof (Elf64_External_VMS_Ehdr),
   5402  1.1.1.2.4.2  tls   sizeof (Elf64_External_Phdr),
   5403  1.1.1.2.4.2  tls   sizeof (Elf64_External_Shdr),
   5404  1.1.1.2.4.2  tls   sizeof (Elf64_External_Rel),
   5405  1.1.1.2.4.2  tls   sizeof (Elf64_External_Rela),
   5406  1.1.1.2.4.2  tls   sizeof (Elf64_External_Sym),
   5407  1.1.1.2.4.2  tls   sizeof (Elf64_External_Dyn),
   5408  1.1.1.2.4.2  tls   sizeof (Elf_External_Note),
   5409  1.1.1.2.4.2  tls   4,
   5410  1.1.1.2.4.2  tls   1,
   5411  1.1.1.2.4.2  tls   64, 3, /* ARCH_SIZE, LOG_FILE_ALIGN */
   5412  1.1.1.2.4.2  tls   ELFCLASS64, EV_CURRENT,
   5413  1.1.1.2.4.2  tls   bfd_elf64_write_out_phdrs,
   5414  1.1.1.2.4.2  tls   elf64_vms_write_shdrs_and_ehdr,
   5415  1.1.1.2.4.2  tls   bfd_elf64_checksum_contents,
   5416  1.1.1.2.4.2  tls   bfd_elf64_write_relocs,
   5417  1.1.1.2.4.2  tls   bfd_elf64_swap_symbol_in,
   5418  1.1.1.2.4.2  tls   bfd_elf64_swap_symbol_out,
   5419  1.1.1.2.4.2  tls   bfd_elf64_slurp_reloc_table,
   5420  1.1.1.2.4.2  tls   bfd_elf64_slurp_symbol_table,
   5421  1.1.1.2.4.2  tls   bfd_elf64_swap_dyn_in,
   5422  1.1.1.2.4.2  tls   bfd_elf64_swap_dyn_out,
   5423  1.1.1.2.4.2  tls   bfd_elf64_swap_reloc_in,
   5424  1.1.1.2.4.2  tls   bfd_elf64_swap_reloc_out,
   5425  1.1.1.2.4.2  tls   bfd_elf64_swap_reloca_in,
   5426  1.1.1.2.4.2  tls   bfd_elf64_swap_reloca_out
   5427  1.1.1.2.4.2  tls };
   5428  1.1.1.2.4.2  tls 
   5429  1.1.1.2.4.2  tls #define ELF_ARCH			bfd_arch_ia64
   5430  1.1.1.2.4.2  tls #define ELF_MACHINE_CODE		EM_IA_64
   5431  1.1.1.2.4.2  tls #define ELF_MAXPAGESIZE			0x10000	/* 64KB */
   5432  1.1.1.2.4.2  tls #define ELF_COMMONPAGESIZE		0x200	/* 16KB */
   5433  1.1.1.2.4.2  tls 
   5434  1.1.1.2.4.2  tls #define elf_backend_section_from_shdr \
   5435  1.1.1.2.4.2  tls 	elf64_ia64_section_from_shdr
   5436  1.1.1.2.4.2  tls #define elf_backend_section_flags \
   5437  1.1.1.2.4.2  tls 	elf64_ia64_section_flags
   5438  1.1.1.2.4.2  tls #define elf_backend_fake_sections \
   5439  1.1.1.2.4.2  tls 	elf64_ia64_fake_sections
   5440  1.1.1.2.4.2  tls #define elf_backend_final_write_processing \
   5441  1.1.1.2.4.2  tls 	elf64_ia64_final_write_processing
   5442  1.1.1.2.4.2  tls #define elf_backend_add_symbol_hook \
   5443  1.1.1.2.4.2  tls 	elf64_ia64_add_symbol_hook
   5444  1.1.1.2.4.2  tls #define elf_info_to_howto \
   5445  1.1.1.2.4.2  tls 	elf64_ia64_info_to_howto
   5446  1.1.1.2.4.2  tls 
   5447  1.1.1.2.4.2  tls #define bfd_elf64_bfd_reloc_type_lookup \
   5448  1.1.1.2.4.2  tls 	ia64_elf_reloc_type_lookup
   5449  1.1.1.2.4.2  tls #define bfd_elf64_bfd_reloc_name_lookup \
   5450  1.1.1.2.4.2  tls 	ia64_elf_reloc_name_lookup
   5451  1.1.1.2.4.2  tls #define bfd_elf64_bfd_is_local_label_name \
   5452  1.1.1.2.4.2  tls 	elf64_ia64_is_local_label_name
   5453  1.1.1.2.4.2  tls #define bfd_elf64_bfd_relax_section \
   5454  1.1.1.2.4.2  tls 	elf64_ia64_relax_section
   5455  1.1.1.2.4.2  tls 
   5456  1.1.1.2.4.2  tls #define elf_backend_object_p \
   5457  1.1.1.2.4.2  tls 	elf64_ia64_object_p
   5458  1.1.1.2.4.2  tls 
   5459  1.1.1.2.4.2  tls /* Stuff for the BFD linker: */
   5460  1.1.1.2.4.2  tls #define bfd_elf64_bfd_link_hash_table_create \
   5461  1.1.1.2.4.2  tls 	elf64_ia64_hash_table_create
   5462  1.1.1.2.4.2  tls #define bfd_elf64_bfd_link_hash_table_free \
   5463  1.1.1.2.4.2  tls 	elf64_ia64_hash_table_free
   5464  1.1.1.2.4.2  tls #define elf_backend_create_dynamic_sections \
   5465  1.1.1.2.4.2  tls 	elf64_ia64_create_dynamic_sections
   5466  1.1.1.2.4.2  tls #define elf_backend_check_relocs \
   5467  1.1.1.2.4.2  tls 	elf64_ia64_check_relocs
   5468  1.1.1.2.4.2  tls #define elf_backend_adjust_dynamic_symbol \
   5469  1.1.1.2.4.2  tls 	elf64_ia64_adjust_dynamic_symbol
   5470  1.1.1.2.4.2  tls #define elf_backend_size_dynamic_sections \
   5471  1.1.1.2.4.2  tls 	elf64_ia64_size_dynamic_sections
   5472  1.1.1.2.4.2  tls #define elf_backend_omit_section_dynsym \
   5473  1.1.1.2.4.2  tls   ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
   5474  1.1.1.2.4.2  tls #define elf_backend_relocate_section \
   5475  1.1.1.2.4.2  tls 	elf64_ia64_relocate_section
   5476  1.1.1.2.4.2  tls #define elf_backend_finish_dynamic_symbol \
   5477  1.1.1.2.4.2  tls 	elf64_ia64_finish_dynamic_symbol
   5478  1.1.1.2.4.2  tls #define elf_backend_finish_dynamic_sections \
   5479  1.1.1.2.4.2  tls 	elf64_ia64_finish_dynamic_sections
   5480  1.1.1.2.4.2  tls #define bfd_elf64_bfd_final_link \
   5481  1.1.1.2.4.2  tls 	elf64_ia64_final_link
   5482  1.1.1.2.4.2  tls 
   5483  1.1.1.2.4.2  tls #define bfd_elf64_bfd_merge_private_bfd_data \
   5484  1.1.1.2.4.2  tls 	elf64_ia64_merge_private_bfd_data
   5485  1.1.1.2.4.2  tls #define bfd_elf64_bfd_set_private_flags \
   5486  1.1.1.2.4.2  tls 	elf64_ia64_set_private_flags
   5487  1.1.1.2.4.2  tls #define bfd_elf64_bfd_print_private_bfd_data \
   5488  1.1.1.2.4.2  tls 	elf64_ia64_print_private_bfd_data
   5489  1.1.1.2.4.2  tls 
   5490  1.1.1.2.4.2  tls #define elf_backend_plt_readonly	1
   5491  1.1.1.2.4.2  tls #define elf_backend_want_plt_sym	0
   5492  1.1.1.2.4.2  tls #define elf_backend_plt_alignment	5
   5493  1.1.1.2.4.2  tls #define elf_backend_got_header_size	0
   5494  1.1.1.2.4.2  tls #define elf_backend_want_got_plt	1
   5495  1.1.1.2.4.2  tls #define elf_backend_may_use_rel_p	1
   5496  1.1.1.2.4.2  tls #define elf_backend_may_use_rela_p	1
   5497  1.1.1.2.4.2  tls #define elf_backend_default_use_rela_p	1
   5498  1.1.1.2.4.2  tls #define elf_backend_want_dynbss		0
   5499  1.1.1.2.4.2  tls #define elf_backend_hide_symbol		elf64_ia64_hash_hide_symbol
   5500  1.1.1.2.4.2  tls #define elf_backend_fixup_symbol	_bfd_elf_link_hash_fixup_symbol
   5501  1.1.1.2.4.2  tls #define elf_backend_reloc_type_class	elf64_ia64_reloc_type_class
   5502  1.1.1.2.4.2  tls #define elf_backend_rela_normal		1
   5503  1.1.1.2.4.2  tls #define elf_backend_special_sections	elf64_ia64_special_sections
   5504  1.1.1.2.4.2  tls #define elf_backend_default_execstack	0
   5505  1.1.1.2.4.2  tls 
   5506  1.1.1.2.4.2  tls /* FIXME: PR 290: The Intel C compiler generates SHT_IA_64_UNWIND with
   5507  1.1.1.2.4.2  tls    SHF_LINK_ORDER. But it doesn't set the sh_link or sh_info fields.
   5508  1.1.1.2.4.2  tls    We don't want to flood users with so many error messages. We turn
   5509  1.1.1.2.4.2  tls    off the warning for now. It will be turned on later when the Intel
   5510  1.1.1.2.4.2  tls    compiler is fixed.   */
   5511  1.1.1.2.4.2  tls #define elf_backend_link_order_error_handler NULL
   5512  1.1.1.2.4.2  tls 
   5513  1.1.1.2.4.2  tls /* VMS-specific vectors.  */
   5514  1.1.1.2.4.2  tls 
   5515  1.1.1.2.4.2  tls #undef  TARGET_LITTLE_SYM
   5516  1.1.1.2.4.2  tls #define TARGET_LITTLE_SYM		bfd_elf64_ia64_vms_vec
   5517  1.1.1.2.4.2  tls #undef  TARGET_LITTLE_NAME
   5518  1.1.1.2.4.2  tls #define TARGET_LITTLE_NAME		"elf64-ia64-vms"
   5519  1.1.1.2.4.2  tls #undef  TARGET_BIG_SYM
   5520  1.1.1.2.4.2  tls #undef  TARGET_BIG_NAME
   5521  1.1.1.2.4.2  tls 
   5522  1.1.1.2.4.2  tls /* These are VMS specific functions.  */
   5523  1.1.1.2.4.2  tls 
   5524  1.1.1.2.4.2  tls #undef  elf_backend_object_p
   5525  1.1.1.2.4.2  tls #define elf_backend_object_p elf64_vms_object_p
   5526  1.1.1.2.4.2  tls 
   5527  1.1.1.2.4.2  tls #undef  elf_backend_section_from_shdr
   5528  1.1.1.2.4.2  tls #define elf_backend_section_from_shdr elf64_vms_section_from_shdr
   5529  1.1.1.2.4.2  tls 
   5530  1.1.1.2.4.2  tls #undef  elf_backend_post_process_headers
   5531  1.1.1.2.4.2  tls #define elf_backend_post_process_headers elf64_vms_post_process_headers
   5532  1.1.1.2.4.2  tls 
   5533  1.1.1.2.4.2  tls #undef  elf_backend_section_processing
   5534  1.1.1.2.4.2  tls #define elf_backend_section_processing elf64_vms_section_processing
   5535  1.1.1.2.4.2  tls 
   5536  1.1.1.2.4.2  tls #undef  elf_backend_final_write_processing
   5537  1.1.1.2.4.2  tls #define elf_backend_final_write_processing elf64_vms_final_write_processing
   5538  1.1.1.2.4.2  tls 
   5539  1.1.1.2.4.2  tls #undef  bfd_elf64_close_and_cleanup
   5540  1.1.1.2.4.2  tls #define bfd_elf64_close_and_cleanup elf64_vms_close_and_cleanup
   5541  1.1.1.2.4.2  tls 
   5542  1.1.1.2.4.2  tls #undef  elf_backend_section_from_bfd_section
   5543  1.1.1.2.4.2  tls 
   5544  1.1.1.2.4.2  tls #undef  elf_backend_symbol_processing
   5545  1.1.1.2.4.2  tls 
   5546  1.1.1.2.4.2  tls #undef  elf_backend_want_p_paddr_set_to_zero
   5547  1.1.1.2.4.2  tls 
   5548  1.1.1.2.4.2  tls #undef  ELF_OSABI
   5549  1.1.1.2.4.2  tls #define ELF_OSABI			ELFOSABI_OPENVMS
   5550  1.1.1.2.4.2  tls 
   5551  1.1.1.2.4.2  tls #undef  ELF_MAXPAGESIZE
   5552  1.1.1.2.4.2  tls #define ELF_MAXPAGESIZE			0x10000	/* 64KB */
   5553  1.1.1.2.4.2  tls 
   5554  1.1.1.2.4.2  tls #undef  elf64_bed
   5555  1.1.1.2.4.2  tls #define elf64_bed elf64_ia64_vms_bed
   5556  1.1.1.2.4.2  tls 
   5557  1.1.1.2.4.2  tls #define elf_backend_size_info elf64_ia64_vms_size_info
   5558  1.1.1.2.4.2  tls 
   5559  1.1.1.2.4.2  tls /* Use VMS-style archives (in particular, don't use the standard coff
   5560  1.1.1.2.4.2  tls    archive format).  */
   5561  1.1.1.2.4.2  tls #define bfd_elf64_archive_functions
   5562  1.1.1.2.4.2  tls 
   5563  1.1.1.2.4.2  tls #undef bfd_elf64_archive_p
   5564  1.1.1.2.4.2  tls #define bfd_elf64_archive_p _bfd_vms_lib_ia64_archive_p
   5565  1.1.1.2.4.2  tls #undef bfd_elf64_write_archive_contents
   5566  1.1.1.2.4.2  tls #define bfd_elf64_write_archive_contents _bfd_vms_lib_write_archive_contents
   5567  1.1.1.2.4.2  tls #undef bfd_elf64_mkarchive
   5568  1.1.1.2.4.2  tls #define bfd_elf64_mkarchive _bfd_vms_lib_ia64_mkarchive
   5569  1.1.1.2.4.2  tls 
   5570  1.1.1.2.4.2  tls #define bfd_elf64_archive_slurp_armap \
   5571  1.1.1.2.4.2  tls   _bfd_vms_lib_slurp_armap
   5572  1.1.1.2.4.2  tls #define bfd_elf64_archive_slurp_extended_name_table \
   5573  1.1.1.2.4.2  tls   _bfd_vms_lib_slurp_extended_name_table
   5574  1.1.1.2.4.2  tls #define bfd_elf64_archive_construct_extended_name_table \
   5575  1.1.1.2.4.2  tls   _bfd_vms_lib_construct_extended_name_table
   5576  1.1.1.2.4.2  tls #define bfd_elf64_archive_truncate_arname \
   5577  1.1.1.2.4.2  tls   _bfd_vms_lib_truncate_arname
   5578  1.1.1.2.4.2  tls #define bfd_elf64_archive_write_armap \
   5579  1.1.1.2.4.2  tls   _bfd_vms_lib_write_armap
   5580  1.1.1.2.4.2  tls #define bfd_elf64_archive_read_ar_hdr \
   5581  1.1.1.2.4.2  tls   _bfd_vms_lib_read_ar_hdr
   5582  1.1.1.2.4.2  tls #define bfd_elf64_archive_write_ar_hdr \
   5583  1.1.1.2.4.2  tls   _bfd_vms_lib_write_ar_hdr
   5584  1.1.1.2.4.2  tls #define bfd_elf64_archive_openr_next_archived_file \
   5585  1.1.1.2.4.2  tls   _bfd_vms_lib_openr_next_archived_file
   5586  1.1.1.2.4.2  tls #define bfd_elf64_archive_get_elt_at_index \
   5587  1.1.1.2.4.2  tls   _bfd_vms_lib_get_elt_at_index
   5588  1.1.1.2.4.2  tls #define bfd_elf64_archive_generic_stat_arch_elt \
   5589  1.1.1.2.4.2  tls   _bfd_vms_lib_generic_stat_arch_elt
   5590  1.1.1.2.4.2  tls #define bfd_elf64_archive_update_armap_timestamp \
   5591  1.1.1.2.4.2  tls   _bfd_vms_lib_update_armap_timestamp
   5592  1.1.1.2.4.2  tls 
   5593  1.1.1.2.4.2  tls /* VMS link methods.  */
   5594  1.1.1.2.4.2  tls #undef  bfd_elf64_bfd_link_add_symbols
   5595  1.1.1.2.4.2  tls #define bfd_elf64_bfd_link_add_symbols 	elf64_vms_bfd_link_add_symbols
   5596  1.1.1.2.4.2  tls 
   5597  1.1.1.2.4.2  tls #undef  elf_backend_want_got_sym
   5598  1.1.1.2.4.2  tls #define elf_backend_want_got_sym 	0
   5599  1.1.1.2.4.2  tls 
   5600  1.1.1.2.4.2  tls #undef  bfd_elf64_mkobject
   5601  1.1.1.2.4.2  tls #define bfd_elf64_mkobject		elf64_ia64_vms_mkobject
   5602  1.1.1.2.4.2  tls 
   5603  1.1.1.2.4.2  tls /* Redefine to align segments on block size.  */
   5604  1.1.1.2.4.2  tls #undef  ELF_MAXPAGESIZE
   5605  1.1.1.2.4.2  tls #define ELF_MAXPAGESIZE			0x200 /* 512B  */
   5606  1.1.1.2.4.2  tls 
   5607  1.1.1.2.4.2  tls #undef  elf_backend_want_got_plt
   5608  1.1.1.2.4.2  tls #define elf_backend_want_got_plt	0
   5609  1.1.1.2.4.2  tls 
   5610  1.1.1.2.4.2  tls #include "elf64-target.h"
   5611