/[gcl]/gcl/binutils/bfd/elf64-hppa.c
ViewVC logotype

Diff of /gcl/binutils/bfd/elf64-hppa.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by camm, Fri Aug 9 05:35:24 2002 UTC revision 1.2 by camm, Fri Sep 9 23:32:13 2005 UTC
# Line 1  Line 1 
1  /* Support for HPPA 64-bit ELF  /* Support for HPPA 64-bit ELF
2     Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.     Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
3       Free Software Foundation, Inc.
4    
5  This file is part of BFD, the Binary File Descriptor library.     This file is part of BFD, the Binary File Descriptor library.
6    
7  This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.     (at your option) any later version.
11    
12  This program is distributed in the hope that it will be useful,     This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  GNU General Public License for more details.     GNU General Public License for more details.
16    
17  You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20    
21  #include "alloca-conf.h"  #include "alloca-conf.h"
22  #include "bfd.h"  #include "bfd.h"
# Line 156  struct elf64_hppa_link_hash_table Line 157  struct elf64_hppa_link_hash_table
157  typedef struct bfd_hash_entry *(*new_hash_entry_func)  typedef struct bfd_hash_entry *(*new_hash_entry_func)
158    PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));    PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
159    
160  static boolean elf64_hppa_dyn_hash_table_init  static bfd_boolean elf64_hppa_dyn_hash_table_init
161    PARAMS ((struct elf64_hppa_dyn_hash_table *ht, bfd *abfd,    PARAMS ((struct elf64_hppa_dyn_hash_table *ht, bfd *abfd,
162             new_hash_entry_func new));             new_hash_entry_func new));
163  static struct bfd_hash_entry *elf64_hppa_new_dyn_hash_entry  static struct bfd_hash_entry *elf64_hppa_new_dyn_hash_entry
# Line 166  static struct bfd_link_hash_table *elf64 Line 167  static struct bfd_link_hash_table *elf64
167    PARAMS ((bfd *abfd));    PARAMS ((bfd *abfd));
168  static struct elf64_hppa_dyn_hash_entry *elf64_hppa_dyn_hash_lookup  static struct elf64_hppa_dyn_hash_entry *elf64_hppa_dyn_hash_lookup
169    PARAMS ((struct elf64_hppa_dyn_hash_table *table, const char *string,    PARAMS ((struct elf64_hppa_dyn_hash_table *table, const char *string,
170             boolean create, boolean copy));             bfd_boolean create, bfd_boolean copy));
171  static void elf64_hppa_dyn_hash_traverse  static void elf64_hppa_dyn_hash_traverse
172    PARAMS ((struct elf64_hppa_dyn_hash_table *table,    PARAMS ((struct elf64_hppa_dyn_hash_table *table,
173             boolean (*func) (struct elf64_hppa_dyn_hash_entry *, PTR),             bfd_boolean (*func) (struct elf64_hppa_dyn_hash_entry *, PTR),
174             PTR info));             PTR info));
175    
176  static const char *get_dyn_name  static const char *get_dyn_name
177    PARAMS ((asection *, struct elf_link_hash_entry *,    PARAMS ((bfd *, struct elf_link_hash_entry *,
178             const Elf_Internal_Rela *, char **, size_t *));             const Elf_Internal_Rela *, char **, size_t *));
179    
180  /* This must follow the definitions of the various derived linker  /* This must follow the definitions of the various derived linker
181     hash tables and shared functions.  */     hash tables and shared functions.  */
182  #include "elf-hppa.h"  #include "elf-hppa.h"
183    
184  static boolean elf64_hppa_object_p  static bfd_boolean elf64_hppa_object_p
185    PARAMS ((bfd *));    PARAMS ((bfd *));
186    
187  static boolean elf64_hppa_section_from_shdr  static bfd_boolean elf64_hppa_section_from_shdr
188    PARAMS ((bfd *, Elf64_Internal_Shdr *, const char *));    PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
189    
190  static void elf64_hppa_post_process_headers  static void elf64_hppa_post_process_headers
191    PARAMS ((bfd *, struct bfd_link_info *));    PARAMS ((bfd *, struct bfd_link_info *));
192    
193  static boolean elf64_hppa_create_dynamic_sections  static bfd_boolean elf64_hppa_create_dynamic_sections
194    PARAMS ((bfd *, struct bfd_link_info *));    PARAMS ((bfd *, struct bfd_link_info *));
195    
196  static boolean elf64_hppa_adjust_dynamic_symbol  static bfd_boolean elf64_hppa_adjust_dynamic_symbol
197    PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));    PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
198    
199  static boolean elf64_hppa_mark_milli_and_exported_functions  static bfd_boolean elf64_hppa_mark_milli_and_exported_functions
200    PARAMS ((struct elf_link_hash_entry *, PTR));    PARAMS ((struct elf_link_hash_entry *, PTR));
201    
202  static boolean elf64_hppa_size_dynamic_sections  static bfd_boolean elf64_hppa_size_dynamic_sections
203    PARAMS ((bfd *, struct bfd_link_info *));    PARAMS ((bfd *, struct bfd_link_info *));
204    
205  static boolean elf64_hppa_link_output_symbol_hook  static bfd_boolean elf64_hppa_link_output_symbol_hook
206  PARAMS ((bfd *abfd, struct bfd_link_info *, const char *,    PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *,
207           Elf_Internal_Sym *, asection *input_sec));             asection *, struct elf_link_hash_entry *));
208    
209  static boolean elf64_hppa_finish_dynamic_symbol  static bfd_boolean elf64_hppa_finish_dynamic_symbol
210    PARAMS ((bfd *, struct bfd_link_info *,    PARAMS ((bfd *, struct bfd_link_info *,
211             struct elf_link_hash_entry *, Elf_Internal_Sym *));             struct elf_link_hash_entry *, Elf_Internal_Sym *));
212    
213  static int elf64_hppa_additional_program_headers PARAMS ((bfd *));  static int elf64_hppa_additional_program_headers
214      PARAMS ((bfd *));
215    
216  static boolean elf64_hppa_modify_segment_map PARAMS ((bfd *));  static bfd_boolean elf64_hppa_modify_segment_map
217      PARAMS ((bfd *, struct bfd_link_info *));
218    
219  static enum elf_reloc_type_class elf64_hppa_reloc_type_class  static enum elf_reloc_type_class elf64_hppa_reloc_type_class
220    PARAMS ((const Elf_Internal_Rela *));    PARAMS ((const Elf_Internal_Rela *));
221    
222  static boolean elf64_hppa_finish_dynamic_sections  static bfd_boolean elf64_hppa_finish_dynamic_sections
223    PARAMS ((bfd *, struct bfd_link_info *));    PARAMS ((bfd *, struct bfd_link_info *));
224    
225  static boolean elf64_hppa_check_relocs  static bfd_boolean elf64_hppa_check_relocs
226    PARAMS ((bfd *, struct bfd_link_info *,    PARAMS ((bfd *, struct bfd_link_info *,
227             asection *, const Elf_Internal_Rela *));             asection *, const Elf_Internal_Rela *));
228    
229  static boolean elf64_hppa_dynamic_symbol_p  static bfd_boolean elf64_hppa_dynamic_symbol_p
230    PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *));    PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *));
231    
232  static boolean elf64_hppa_mark_exported_functions  static bfd_boolean elf64_hppa_mark_exported_functions
233    PARAMS ((struct elf_link_hash_entry *, PTR));    PARAMS ((struct elf_link_hash_entry *, PTR));
234    
235  static boolean elf64_hppa_finalize_opd  static bfd_boolean elf64_hppa_finalize_opd
236    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
237    
238  static boolean elf64_hppa_finalize_dlt  static bfd_boolean elf64_hppa_finalize_dlt
239    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
240    
241  static boolean allocate_global_data_dlt  static bfd_boolean allocate_global_data_dlt
242    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
243    
244  static boolean allocate_global_data_plt  static bfd_boolean allocate_global_data_plt
245    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
246    
247  static boolean allocate_global_data_stub  static bfd_boolean allocate_global_data_stub
248    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
249    
250  static boolean allocate_global_data_opd  static bfd_boolean allocate_global_data_opd
251    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
252    
253  static boolean get_reloc_section  static bfd_boolean get_reloc_section
254    PARAMS ((bfd *, struct elf64_hppa_link_hash_table *, asection *));    PARAMS ((bfd *, struct elf64_hppa_link_hash_table *, asection *));
255    
256  static boolean count_dyn_reloc  static bfd_boolean count_dyn_reloc
257    PARAMS ((bfd *, struct elf64_hppa_dyn_hash_entry *,    PARAMS ((bfd *, struct elf64_hppa_dyn_hash_entry *,
258             int, asection *, int, bfd_vma, bfd_vma));             int, asection *, int, bfd_vma, bfd_vma));
259    
260  static boolean allocate_dynrel_entries  static bfd_boolean allocate_dynrel_entries
261    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
262    
263  static boolean elf64_hppa_finalize_dynreloc  static bfd_boolean elf64_hppa_finalize_dynreloc
264    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));    PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
265    
266  static boolean get_opd  static bfd_boolean get_opd
267    PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));    PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));
268    
269  static boolean get_plt  static bfd_boolean get_plt
270    PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));    PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));
271    
272  static boolean get_dlt  static bfd_boolean get_dlt
273    PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));    PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));
274    
275  static boolean get_stub  static bfd_boolean get_stub
276    PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));    PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));
277    
278  static int elf64_hppa_elf_get_symbol_type  static int elf64_hppa_elf_get_symbol_type
279    PARAMS ((Elf_Internal_Sym *, int));    PARAMS ((Elf_Internal_Sym *, int));
280    
281  static boolean  static bfd_boolean
282  elf64_hppa_dyn_hash_table_init (ht, abfd, new)  elf64_hppa_dyn_hash_table_init (ht, abfd, new)
283       struct elf64_hppa_dyn_hash_table *ht;       struct elf64_hppa_dyn_hash_table *ht;
284       bfd *abfd ATTRIBUTE_UNUSED;       bfd *abfd ATTRIBUTE_UNUSED;
# Line 302  elf64_hppa_new_dyn_hash_entry (entry, ta Line 305  elf64_hppa_new_dyn_hash_entry (entry, ta
305    if (!ret)    if (!ret)
306      return 0;      return 0;
307    
   /* Initialize our local data.  All zeros, and definitely easier  
      than setting 8 bit fields.  */  
   memset (ret, 0, sizeof (*ret));  
   
308    /* Call the allocation method of the superclass.  */    /* Call the allocation method of the superclass.  */
309    ret = ((struct elf64_hppa_dyn_hash_entry *)    ret = ((struct elf64_hppa_dyn_hash_entry *)
310           bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));           bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
311    
312      /* Initialize our local data.  All zeros.  */
313      memset (&ret->dlt_offset, 0,
314              (sizeof (struct elf64_hppa_dyn_hash_entry)
315               - offsetof (struct elf64_hppa_dyn_hash_entry, dlt_offset)));
316    
317    return &ret->root;    return &ret->root;
318  }  }
319    
# Line 345  static struct elf64_hppa_dyn_hash_entry Line 349  static struct elf64_hppa_dyn_hash_entry
349  elf64_hppa_dyn_hash_lookup(table, string, create, copy)  elf64_hppa_dyn_hash_lookup(table, string, create, copy)
350       struct elf64_hppa_dyn_hash_table *table;       struct elf64_hppa_dyn_hash_table *table;
351       const char *string;       const char *string;
352       boolean create, copy;       bfd_boolean create, copy;
353  {  {
354    return ((struct elf64_hppa_dyn_hash_entry *)    return ((struct elf64_hppa_dyn_hash_entry *)
355            bfd_hash_lookup (&table->root, string, create, copy));            bfd_hash_lookup (&table->root, string, create, copy));
# Line 356  elf64_hppa_dyn_hash_lookup(table, string Line 360  elf64_hppa_dyn_hash_lookup(table, string
360  static void  static void
361  elf64_hppa_dyn_hash_traverse (table, func, info)  elf64_hppa_dyn_hash_traverse (table, func, info)
362       struct elf64_hppa_dyn_hash_table *table;       struct elf64_hppa_dyn_hash_table *table;
363       boolean (*func) PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));       bfd_boolean (*func) PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
364       PTR info;       PTR info;
365  {  {
366    (bfd_hash_traverse    (bfd_hash_traverse
367     (&table->root,     (&table->root,
368      (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) func,      (bfd_boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) func,
369      info));      info));
370  }  }
371    
372  /* Return nonzero if ABFD represents a PA2.0 ELF64 file.  /* Return nonzero if ABFD represents a PA2.0 ELF64 file.
373    
374     Additionally we set the default architecture and machine.  */     Additionally we set the default architecture and machine.  */
375  static boolean  static bfd_boolean
376  elf64_hppa_object_p (abfd)  elf64_hppa_object_p (abfd)
377       bfd *abfd;       bfd *abfd;
378  {  {
# Line 378  elf64_hppa_object_p (abfd) Line 382  elf64_hppa_object_p (abfd)
382    i_ehdrp = elf_elfheader (abfd);    i_ehdrp = elf_elfheader (abfd);
383    if (strcmp (bfd_get_target (abfd), "elf64-hppa-linux") == 0)    if (strcmp (bfd_get_target (abfd), "elf64-hppa-linux") == 0)
384      {      {
385        if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX)        /* GCC on hppa-linux produces binaries with OSABI=Linux,
386          return false;           but the kernel produces corefiles with OSABI=SysV.  */
387          if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX &&
388              i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */
389            return FALSE;
390      }      }
391    else    else
392      {      {
393        if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX)        if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX)
394          return false;          return FALSE;
395      }      }
396    
397    flags = i_ehdrp->e_flags;    flags = i_ehdrp->e_flags;
# Line 400  elf64_hppa_object_p (abfd) Line 407  elf64_hppa_object_p (abfd)
407        return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 25);        return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 25);
408      }      }
409    /* Don't be fussy.  */    /* Don't be fussy.  */
410    return true;    return TRUE;
411  }  }
412    
413  /* Given section type (hdr->sh_type), return a boolean indicating  /* Given section type (hdr->sh_type), return a boolean indicating
414     whether or not the section is an elf64-hppa specific section.  */     whether or not the section is an elf64-hppa specific section.  */
415  static boolean  static bfd_boolean
416  elf64_hppa_section_from_shdr (abfd, hdr, name)  elf64_hppa_section_from_shdr (abfd, hdr, name)
417       bfd *abfd;       bfd *abfd;
418       Elf64_Internal_Shdr *hdr;       Elf_Internal_Shdr *hdr;
419       const char *name;       const char *name;
420  {  {
421    asection *newsect;    asection *newsect;
# Line 417  elf64_hppa_section_from_shdr (abfd, hdr, Line 424  elf64_hppa_section_from_shdr (abfd, hdr,
424      {      {
425      case SHT_PARISC_EXT:      case SHT_PARISC_EXT:
426        if (strcmp (name, ".PARISC.archext") != 0)        if (strcmp (name, ".PARISC.archext") != 0)
427          return false;          return FALSE;
428        break;        break;
429      case SHT_PARISC_UNWIND:      case SHT_PARISC_UNWIND:
430        if (strcmp (name, ".PARISC.unwind") != 0)        if (strcmp (name, ".PARISC.unwind") != 0)
431          return false;          return FALSE;
432        break;        break;
433      case SHT_PARISC_DOC:      case SHT_PARISC_DOC:
434      case SHT_PARISC_ANNOT:      case SHT_PARISC_ANNOT:
435      default:      default:
436        return false;        return FALSE;
437      }      }
438    
439    if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))    if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
440      return false;      return FALSE;
441    newsect = hdr->bfd_section;    newsect = hdr->bfd_section;
442    
443    return true;    return TRUE;
444  }  }
445    
446  /* Construct a string for use in the elf64_hppa_dyn_hash_table.  The  /* Construct a string for use in the elf64_hppa_dyn_hash_table.  The
# Line 441  elf64_hppa_section_from_shdr (abfd, hdr, Line 448  elf64_hppa_section_from_shdr (abfd, hdr,
448     allocate memory as necessary, possibly reusing PBUF/PLEN.  */     allocate memory as necessary, possibly reusing PBUF/PLEN.  */
449    
450  static const char *  static const char *
451  get_dyn_name (sec, h, rel, pbuf, plen)  get_dyn_name (abfd, h, rel, pbuf, plen)
452       asection *sec;       bfd *abfd;
453       struct elf_link_hash_entry *h;       struct elf_link_hash_entry *h;
454       const Elf_Internal_Rela *rel;       const Elf_Internal_Rela *rel;
455       char **pbuf;       char **pbuf;
456       size_t *plen;       size_t *plen;
457  {  {
458      asection *sec = abfd->sections;
459    size_t nlen, tlen;    size_t nlen, tlen;
460    char *buf;    char *buf;
461    size_t len;    size_t len;
# Line 497  get_dyn_name (sec, h, rel, pbuf, plen) Line 505  get_dyn_name (sec, h, rel, pbuf, plen)
505  /* SEC is a section containing relocs for an input BFD when linking; return  /* SEC is a section containing relocs for an input BFD when linking; return
506     a suitable section for holding relocs in the output BFD for a link.  */     a suitable section for holding relocs in the output BFD for a link.  */
507    
508  static boolean  static bfd_boolean
509  get_reloc_section (abfd, hppa_info, sec)  get_reloc_section (abfd, hppa_info, sec)
510       bfd *abfd;       bfd *abfd;
511       struct elf64_hppa_link_hash_table *hppa_info;       struct elf64_hppa_link_hash_table *hppa_info;
# Line 511  get_reloc_section (abfd, hppa_info, sec) Line 519  get_reloc_section (abfd, hppa_info, sec)
519                 (abfd, elf_elfheader(abfd)->e_shstrndx,                 (abfd, elf_elfheader(abfd)->e_shstrndx,
520                  elf_section_data(sec)->rel_hdr.sh_name));                  elf_section_data(sec)->rel_hdr.sh_name));
521    if (srel_name == NULL)    if (srel_name == NULL)
522      return false;      return FALSE;
523    
524    BFD_ASSERT ((strncmp (srel_name, ".rela", 5) == 0    BFD_ASSERT ((strncmp (srel_name, ".rela", 5) == 0
525                 && strcmp (bfd_get_section_name (abfd, sec),                 && strcmp (bfd_get_section_name (abfd, sec),
# Line 537  get_reloc_section (abfd, hppa_info, sec) Line 545  get_reloc_section (abfd, hppa_info, sec)
545                                        | SEC_LINKER_CREATED                                        | SEC_LINKER_CREATED
546                                        | SEC_READONLY))                                        | SEC_READONLY))
547            || !bfd_set_section_alignment (dynobj, srel, 3))            || !bfd_set_section_alignment (dynobj, srel, 3))
548          return false;          return FALSE;
549      }      }
550    
551    hppa_info->other_rel_sec = srel;    hppa_info->other_rel_sec = srel;
552    return true;    return TRUE;
553  }  }
554    
555  /* Add a new entry to the list of dynamic relocations against DYN_H.  /* Add a new entry to the list of dynamic relocations against DYN_H.
# Line 550  get_reloc_section (abfd, hppa_info, sec) Line 558  get_reloc_section (abfd, hppa_info, sec)
558     particular symbol so that we can create FPTR relocations in the     particular symbol so that we can create FPTR relocations in the
559     output file.  */     output file.  */
560    
561  static boolean  static bfd_boolean
562  count_dyn_reloc (abfd, dyn_h, type, sec, sec_symndx, offset, addend)  count_dyn_reloc (abfd, dyn_h, type, sec, sec_symndx, offset, addend)
563       bfd *abfd;       bfd *abfd;
564       struct elf64_hppa_dyn_hash_entry *dyn_h;       struct elf64_hppa_dyn_hash_entry *dyn_h;
# Line 565  count_dyn_reloc (abfd, dyn_h, type, sec, Line 573  count_dyn_reloc (abfd, dyn_h, type, sec,
573    rent = (struct elf64_hppa_dyn_reloc_entry *)    rent = (struct elf64_hppa_dyn_reloc_entry *)
574    bfd_alloc (abfd, (bfd_size_type) sizeof (*rent));    bfd_alloc (abfd, (bfd_size_type) sizeof (*rent));
575    if (!rent)    if (!rent)
576      return false;      return FALSE;
577    
578    rent->next = dyn_h->reloc_entries;    rent->next = dyn_h->reloc_entries;
579    rent->type = type;    rent->type = type;
# Line 575  count_dyn_reloc (abfd, dyn_h, type, sec, Line 583  count_dyn_reloc (abfd, dyn_h, type, sec,
583    rent->addend = addend;    rent->addend = addend;
584    dyn_h->reloc_entries = rent;    dyn_h->reloc_entries = rent;
585    
586    return true;    return TRUE;
587  }  }
588    
589  /* Scan the RELOCS and record the type of dynamic entries that each  /* Scan the RELOCS and record the type of dynamic entries that each
590     referenced symbol needs.  */     referenced symbol needs.  */
591    
592  static boolean  static bfd_boolean
593  elf64_hppa_check_relocs (abfd, info, sec, relocs)  elf64_hppa_check_relocs (abfd, info, sec, relocs)
594       bfd *abfd;       bfd *abfd;
595       struct bfd_link_info *info;       struct bfd_link_info *info;
# Line 597  elf64_hppa_check_relocs (abfd, info, sec Line 605  elf64_hppa_check_relocs (abfd, info, sec
605    size_t buf_len;    size_t buf_len;
606    int sec_symndx;    int sec_symndx;
607    
608    if (info->relocateable)    if (info->relocatable)
609      return true;      return TRUE;
610    
611    /* If this is the first dynamic object found in the link, create    /* If this is the first dynamic object found in the link, create
612       the special sections required for dynamic linking.  */       the special sections required for dynamic linking.  */
613    if (! elf_hash_table (info)->dynamic_sections_created)    if (! elf_hash_table (info)->dynamic_sections_created)
614      {      {
615        if (! bfd_elf64_link_create_dynamic_sections (abfd, info))        if (! _bfd_elf_link_create_dynamic_sections (abfd, info))
616          return false;          return FALSE;
617      }      }
618    
619    hppa_info = elf64_hppa_hash_table (info);    hppa_info = elf64_hppa_hash_table (info);
# Line 639  elf64_hppa_check_relocs (abfd, info, sec Line 647  elf64_hppa_check_relocs (abfd, info, sec
647                                                 symtab_hdr->sh_info, 0,                                                 symtab_hdr->sh_info, 0,
648                                                 NULL, NULL, NULL);                                                 NULL, NULL, NULL);
649            if (local_syms == NULL)            if (local_syms == NULL)
650              return false;              return FALSE;
651          }          }
652    
653        /* Record the highest section index referenced by the local symbols.  */        /* Record the highest section index referenced by the local symbols.  */
# Line 694  elf64_hppa_check_relocs (abfd, info, sec Line 702  elf64_hppa_check_relocs (abfd, info, sec
702        /* If we did not find a section symbol for this section, then        /* If we did not find a section symbol for this section, then
703           something went terribly wrong above.  */           something went terribly wrong above.  */
704        if (sec_symndx == -1)        if (sec_symndx == -1)
705          return false;          return FALSE;
706    
707        sec_symndx = hppa_info->section_syms[sec_symndx];        sec_symndx = hppa_info->section_syms[sec_symndx];
708      }      }
# Line 708  elf64_hppa_check_relocs (abfd, info, sec Line 716  elf64_hppa_check_relocs (abfd, info, sec
716    relend = relocs + sec->reloc_count;    relend = relocs + sec->reloc_count;
717    for (rel = relocs; rel < relend; ++rel)    for (rel = relocs; rel < relend; ++rel)
718      {      {
719        enum {        enum
720          NEED_DLT = 1,          {
721          NEED_PLT = 2,            NEED_DLT = 1,
722          NEED_STUB = 4,            NEED_PLT = 2,
723          NEED_OPD = 8,            NEED_STUB = 4,
724          NEED_DYNREL = 16,            NEED_OPD = 8,
725        };            NEED_DYNREL = 16,
726            };
727    
728        struct elf_link_hash_entry *h = NULL;        struct elf_link_hash_entry *h = NULL;
729        unsigned long r_symndx = ELF64_R_SYM (rel->r_info);        unsigned long r_symndx = ELF64_R_SYM (rel->r_info);
730        struct elf64_hppa_dyn_hash_entry *dyn_h;        struct elf64_hppa_dyn_hash_entry *dyn_h;
731        int need_entry;        int need_entry;
732        const char *addr_name;        const char *addr_name;
733        boolean maybe_dynamic;        bfd_boolean maybe_dynamic;
734        int dynrel_type = R_PARISC_NONE;        int dynrel_type = R_PARISC_NONE;
735        static reloc_howto_type *howto;        static reloc_howto_type *howto;
736    
# Line 735  elf64_hppa_check_relocs (abfd, info, sec Line 744  elf64_hppa_check_relocs (abfd, info, sec
744                   || h->root.type == bfd_link_hash_warning)                   || h->root.type == bfd_link_hash_warning)
745              h = (struct elf_link_hash_entry *) h->root.u.i.link;              h = (struct elf_link_hash_entry *) h->root.u.i.link;
746    
747            h->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;            h->ref_regular = 1;
748          }          }
749    
750        /* We can only get preliminary data on whether a symbol is        /* We can only get preliminary data on whether a symbol is
751           locally or externally defined, as not all of the input files           locally or externally defined, as not all of the input files
752           have yet been processed.  Do something with what we know, as           have yet been processed.  Do something with what we know, as
753           this may help reduce memory usage and processing time later.  */           this may help reduce memory usage and processing time later.  */
754        maybe_dynamic = false;        maybe_dynamic = FALSE;
755        if (h && ((info->shared        if (h && ((info->shared
756                      && (!info->symbolic || info->allow_shlib_undefined) )                   && (!info->symbolic
757                  || ! (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)                       || info->unresolved_syms_in_shared_libs == RM_IGNORE))
758                    || !h->def_regular
759                  || h->root.type == bfd_link_hash_defweak))                  || h->root.type == bfd_link_hash_defweak))
760          maybe_dynamic = true;          maybe_dynamic = TRUE;
761    
762        howto = elf_hppa_howto_table + ELF64_R_TYPE (rel->r_info);        howto = elf_hppa_howto_table + ELF64_R_TYPE (rel->r_info);
763        need_entry = 0;        need_entry = 0;
# Line 852  elf64_hppa_check_relocs (abfd, info, sec Line 862  elf64_hppa_check_relocs (abfd, info, sec
862          continue;          continue;
863    
864        /* Collect a canonical name for this address.  */        /* Collect a canonical name for this address.  */
865        addr_name = get_dyn_name (sec, h, rel, &buf, &buf_len);        addr_name = get_dyn_name (abfd, h, rel, &buf, &buf_len);
866    
867        /* Collect the canonical entry data for this address.  */        /* Collect the canonical entry data for this address.  */
868        dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,        dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
869                                            addr_name, true, true);                                            addr_name, TRUE, TRUE);
870        BFD_ASSERT (dyn_h);        BFD_ASSERT (dyn_h);
871    
872        /* Stash away enough information to be able to find this symbol        /* Stash away enough information to be able to find this symbol
# Line 905  elf64_hppa_check_relocs (abfd, info, sec Line 915  elf64_hppa_check_relocs (abfd, info, sec
915            /* This could be a local function that had its address taken, in            /* This could be a local function that had its address taken, in
916               which case H will be NULL.  */               which case H will be NULL.  */
917            if (h)            if (h)
918              h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;              h->needs_plt = 1;
919          }          }
920    
921        /* Add a new dynamic relocation to the chain of dynamic        /* Add a new dynamic relocation to the chain of dynamic
# Line 925  elf64_hppa_check_relocs (abfd, info, sec Line 935  elf64_hppa_check_relocs (abfd, info, sec
935               section symbol for this section ends up in the dynamic               section symbol for this section ends up in the dynamic
936               symbol table.  */               symbol table.  */
937            if (info->shared && dynrel_type == R_PARISC_FPTR64            if (info->shared && dynrel_type == R_PARISC_FPTR64
938                && ! (_bfd_elf64_link_record_local_dynamic_symbol                && ! (bfd_elf_link_record_local_dynamic_symbol
939                      (info, abfd, sec_symndx)))                      (info, abfd, sec_symndx)))
940              return false;              return FALSE;
941          }          }
942      }      }
943    
944    if (buf)    if (buf)
945      free (buf);      free (buf);
946    return true;    return TRUE;
947    
948   err_out:   err_out:
949    if (buf)    if (buf)
950      free (buf);      free (buf);
951    return false;    return FALSE;
952  }  }
953    
954  struct elf64_hppa_allocate_data  struct elf64_hppa_allocate_data
# Line 949  struct elf64_hppa_allocate_data Line 959  struct elf64_hppa_allocate_data
959    
960  /* Should we do dynamic things to this symbol?  */  /* Should we do dynamic things to this symbol?  */
961    
962  static boolean  static bfd_boolean
963  elf64_hppa_dynamic_symbol_p (h, info)  elf64_hppa_dynamic_symbol_p (h, info)
964       struct elf_link_hash_entry *h;       struct elf_link_hash_entry *h;
965       struct bfd_link_info *info;       struct bfd_link_info *info;
966  {  {
967    if (h == NULL)    /* ??? What, if anything, needs to happen wrt STV_PROTECTED symbols
968      return false;       and relocations that retrieve a function descriptor?  Assume the
969         worst for now.  */
970    while (h->root.type == bfd_link_hash_indirect    if (_bfd_elf_dynamic_symbol_p (h, info, 1))
971           || h->root.type == bfd_link_hash_warning)      {
972      h = (struct elf_link_hash_entry *) h->root.u.i.link;        /* ??? Why is this here and not elsewhere is_local_label_name.  */
973          if (h->root.root.string[0] == '$' && h->root.root.string[1] == '$')
974    if (h->dynindx == -1)          return FALSE;
     return false;  
   
   if (h->root.type == bfd_link_hash_undefweak  
       || h->root.type == bfd_link_hash_defweak)  
     return true;  
   
   if (h->root.root.string[0] == '$' && h->root.root.string[1] == '$')  
     return false;  
   
   if ((info->shared && (!info->symbolic || info->allow_shlib_undefined))  
       || ((h->elf_link_hash_flags  
            & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))  
           == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)))  
     return true;  
975    
976    return false;        return TRUE;
977        }
978      else
979        return FALSE;
980  }  }
981    
982  /* Mark all funtions exported by this file so that we can later allocate  /* Mark all functions exported by this file so that we can later allocate
983     entries in .opd for them.  */     entries in .opd for them.  */
984    
985  static boolean  static bfd_boolean
986  elf64_hppa_mark_exported_functions (h, data)  elf64_hppa_mark_exported_functions (h, data)
987       struct elf_link_hash_entry *h;       struct elf_link_hash_entry *h;
988       PTR data;       PTR data;
# Line 1006  elf64_hppa_mark_exported_functions (h, d Line 1005  elf64_hppa_mark_exported_functions (h, d
1005    
1006        /* Add this symbol to the PA64 linker hash table.  */        /* Add this symbol to the PA64 linker hash table.  */
1007        dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,        dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1008                                            h->root.root.string, true, true);                                            h->root.root.string, TRUE, TRUE);
1009        BFD_ASSERT (dyn_h);        BFD_ASSERT (dyn_h);
1010        dyn_h->h = h;        dyn_h->h = h;
1011    
1012        if (! hppa_info->opd_sec        if (! hppa_info->opd_sec
1013            && ! get_opd (hppa_info->root.dynobj, info, hppa_info))            && ! get_opd (hppa_info->root.dynobj, info, hppa_info))
1014          return false;          return FALSE;
1015    
1016        dyn_h->want_opd = 1;        dyn_h->want_opd = 1;
1017        /* Put a flag here for output_symbol_hook.  */        /* Put a flag here for output_symbol_hook.  */
1018        dyn_h->st_shndx = -1;        dyn_h->st_shndx = -1;
1019        h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;        h->needs_plt = 1;
1020      }      }
1021    
1022    return true;    return TRUE;
1023  }  }
1024    
1025  /* Allocate space for a DLT entry.  */  /* Allocate space for a DLT entry.  */
1026    
1027  static boolean  static bfd_boolean
1028  allocate_global_data_dlt (dyn_h, data)  allocate_global_data_dlt (dyn_h, data)
1029       struct elf64_hppa_dyn_hash_entry *dyn_h;       struct elf64_hppa_dyn_hash_entry *dyn_h;
1030       PTR data;       PTR data;
# Line 1047  allocate_global_data_dlt (dyn_h, data) Line 1046  allocate_global_data_dlt (dyn_h, data)
1046                bfd *owner;                bfd *owner;
1047                owner = (h ? h->root.u.def.section->owner : dyn_h->owner);                owner = (h ? h->root.u.def.section->owner : dyn_h->owner);
1048    
1049                if (! (_bfd_elf64_link_record_local_dynamic_symbol                if (! (bfd_elf_link_record_local_dynamic_symbol
1050                       (x->info, owner, dyn_h->sym_indx)))                       (x->info, owner, dyn_h->sym_indx)))
1051                  return false;                  return FALSE;
1052              }              }
1053          }          }
1054    
1055        dyn_h->dlt_offset = x->ofs;        dyn_h->dlt_offset = x->ofs;
1056        x->ofs += DLT_ENTRY_SIZE;        x->ofs += DLT_ENTRY_SIZE;
1057      }      }
1058    return true;    return TRUE;
1059  }  }
1060    
1061  /* Allocate space for a DLT.PLT entry.  */  /* Allocate space for a DLT.PLT entry.  */
1062    
1063  static boolean  static bfd_boolean
1064  allocate_global_data_plt (dyn_h, data)  allocate_global_data_plt (dyn_h, data)
1065       struct elf64_hppa_dyn_hash_entry *dyn_h;       struct elf64_hppa_dyn_hash_entry *dyn_h;
1066       PTR data;       PTR data;
# Line 1082  allocate_global_data_plt (dyn_h, data) Line 1081  allocate_global_data_plt (dyn_h, data)
1081    else    else
1082      dyn_h->want_plt = 0;      dyn_h->want_plt = 0;
1083    
1084    return true;    return TRUE;
1085  }  }
1086    
1087  /* Allocate space for a STUB entry.  */  /* Allocate space for a STUB entry.  */
1088    
1089  static boolean  static bfd_boolean
1090  allocate_global_data_stub (dyn_h, data)  allocate_global_data_stub (dyn_h, data)
1091       struct elf64_hppa_dyn_hash_entry *dyn_h;       struct elf64_hppa_dyn_hash_entry *dyn_h;
1092       PTR data;       PTR data;
# Line 1105  allocate_global_data_stub (dyn_h, data) Line 1104  allocate_global_data_stub (dyn_h, data)
1104      }      }
1105    else    else
1106      dyn_h->want_stub = 0;      dyn_h->want_stub = 0;
1107    return true;    return TRUE;
1108  }  }
1109    
1110  /* Allocate space for a FPTR entry.  */  /* Allocate space for a FPTR entry.  */
1111    
1112  static boolean  static bfd_boolean
1113  allocate_global_data_opd (dyn_h, data)  allocate_global_data_opd (dyn_h, data)
1114       struct elf64_hppa_dyn_hash_entry *dyn_h;       struct elf64_hppa_dyn_hash_entry *dyn_h;
1115       PTR data;       PTR data;
# Line 1151  allocate_global_data_opd (dyn_h, data) Line 1150  allocate_global_data_opd (dyn_h, data)
1150                bfd *owner;                bfd *owner;
1151                owner = (h ? h->root.u.def.section->owner : dyn_h->owner);                owner = (h ? h->root.u.def.section->owner : dyn_h->owner);
1152    
1153                if (!_bfd_elf64_link_record_local_dynamic_symbol                if (!bfd_elf_link_record_local_dynamic_symbol
1154                      (x->info, owner, dyn_h->sym_indx))                      (x->info, owner, dyn_h->sym_indx))
1155                  return false;                  return FALSE;
1156              }              }
1157    
1158            /* This may not be necessary or desirable anymore now that            /* This may not be necessary or desirable anymore now that
# Line 1171  allocate_global_data_opd (dyn_h, data) Line 1170  allocate_global_data_opd (dyn_h, data)
1170                strcpy (new_name + 1, h->root.root.string);                strcpy (new_name + 1, h->root.root.string);
1171    
1172                nh = elf_link_hash_lookup (elf_hash_table (x->info),                nh = elf_link_hash_lookup (elf_hash_table (x->info),
1173                                           new_name, true, true, true);                                           new_name, TRUE, TRUE, TRUE);
1174    
1175                nh->root.type = h->root.type;                nh->root.type = h->root.type;
1176                nh->root.u.def.value = h->root.u.def.value;                nh->root.u.def.value = h->root.u.def.value;
1177                nh->root.u.def.section = h->root.u.def.section;                nh->root.u.def.section = h->root.u.def.section;
1178    
1179                if (! bfd_elf64_link_record_dynamic_symbol (x->info, nh))                if (! bfd_elf_link_record_dynamic_symbol (x->info, nh))
1180                  return false;                  return FALSE;
1181    
1182               }               }
1183            dyn_h->opd_offset = x->ofs;            dyn_h->opd_offset = x->ofs;
# Line 1189  allocate_global_data_opd (dyn_h, data) Line 1188  allocate_global_data_opd (dyn_h, data)
1188        else        else
1189          dyn_h->want_opd = 0;          dyn_h->want_opd = 0;
1190      }      }
1191    return true;    return TRUE;
1192  }  }
1193    
1194  /* HP requires the EI_OSABI field to be filled in.  The assignment to  /* HP requires the EI_OSABI field to be filled in.  The assignment to
# Line 1216  elf64_hppa_post_process_headers (abfd, l Line 1215  elf64_hppa_post_process_headers (abfd, l
1215  }  }
1216    
1217  /* Create function descriptor section (.opd).  This section is called .opd  /* Create function descriptor section (.opd).  This section is called .opd
1218     because it contains "official prodecure descriptors".  The "official"     because it contains "official procedure descriptors".  The "official"
1219     refers to the fact that these descriptors are used when taking the address     refers to the fact that these descriptors are used when taking the address
1220     of a procedure, thus ensuring a unique address for each procedure.  */     of a procedure, thus ensuring a unique address for each procedure.  */
1221    
1222  static boolean  static bfd_boolean
1223  get_opd (abfd, info, hppa_info)  get_opd (abfd, info, hppa_info)
1224       bfd *abfd;       bfd *abfd;
1225       struct bfd_link_info *info ATTRIBUTE_UNUSED;       struct bfd_link_info *info ATTRIBUTE_UNUSED;
# Line 1247  get_opd (abfd, info, hppa_info) Line 1246  get_opd (abfd, info, hppa_info)
1246            || !bfd_set_section_alignment (abfd, opd, 3))            || !bfd_set_section_alignment (abfd, opd, 3))
1247          {          {
1248            BFD_ASSERT (0);            BFD_ASSERT (0);
1249            return false;            return FALSE;
1250          }          }
1251    
1252        hppa_info->opd_sec = opd;        hppa_info->opd_sec = opd;
1253      }      }
1254    
1255    return true;    return TRUE;
1256  }  }
1257    
1258  /* Create the PLT section.  */  /* Create the PLT section.  */
1259    
1260  static boolean  static bfd_boolean
1261  get_plt (abfd, info, hppa_info)  get_plt (abfd, info, hppa_info)
1262       bfd *abfd;       bfd *abfd;
1263       struct bfd_link_info *info ATTRIBUTE_UNUSED;       struct bfd_link_info *info ATTRIBUTE_UNUSED;
# Line 1285  get_plt (abfd, info, hppa_info) Line 1284  get_plt (abfd, info, hppa_info)
1284            || !bfd_set_section_alignment (abfd, plt, 3))            || !bfd_set_section_alignment (abfd, plt, 3))
1285          {          {
1286            BFD_ASSERT (0);            BFD_ASSERT (0);
1287            return false;            return FALSE;
1288          }          }
1289    
1290        hppa_info->plt_sec = plt;        hppa_info->plt_sec = plt;
1291      }      }
1292    
1293    return true;    return TRUE;
1294  }  }
1295    
1296  /* Create the DLT section.  */  /* Create the DLT section.  */
1297    
1298  static boolean  static bfd_boolean
1299  get_dlt (abfd, info, hppa_info)  get_dlt (abfd, info, hppa_info)
1300       bfd *abfd;       bfd *abfd;
1301       struct bfd_link_info *info ATTRIBUTE_UNUSED;       struct bfd_link_info *info ATTRIBUTE_UNUSED;
# Line 1323  get_dlt (abfd, info, hppa_info) Line 1322  get_dlt (abfd, info, hppa_info)
1322            || !bfd_set_section_alignment (abfd, dlt, 3))            || !bfd_set_section_alignment (abfd, dlt, 3))
1323          {          {
1324            BFD_ASSERT (0);            BFD_ASSERT (0);
1325            return false;            return FALSE;
1326          }          }
1327    
1328        hppa_info->dlt_sec = dlt;        hppa_info->dlt_sec = dlt;
1329      }      }
1330    
1331    return true;    return TRUE;
1332  }  }
1333    
1334  /* Create the stubs section.  */  /* Create the stubs section.  */
1335    
1336  static boolean  static bfd_boolean
1337  get_stub (abfd, info, hppa_info)  get_stub (abfd, info, hppa_info)
1338       bfd *abfd;       bfd *abfd;
1339       struct bfd_link_info *info ATTRIBUTE_UNUSED;       struct bfd_link_info *info ATTRIBUTE_UNUSED;
# Line 1362  get_stub (abfd, info, hppa_info) Line 1361  get_stub (abfd, info, hppa_info)
1361            || !bfd_set_section_alignment (abfd, stub, 3))            || !bfd_set_section_alignment (abfd, stub, 3))
1362          {          {
1363            BFD_ASSERT (0);            BFD_ASSERT (0);
1364            return false;            return FALSE;
1365          }          }
1366    
1367        hppa_info->stub_sec = stub;        hppa_info->stub_sec = stub;
1368      }      }
1369    
1370    return true;    return TRUE;
1371  }  }
1372    
1373  /* Create sections necessary for dynamic linking.  This is only a rough  /* Create sections necessary for dynamic linking.  This is only a rough
# Line 1409  get_stub (abfd, info, hppa_info) Line 1408  get_stub (abfd, info, hppa_info)
1408     .rela.opd:     .rela.opd:
1409          EPLT relocations for symbols exported from shared libraries.  */          EPLT relocations for symbols exported from shared libraries.  */
1410    
1411  static boolean  static bfd_boolean
1412  elf64_hppa_create_dynamic_sections (abfd, info)  elf64_hppa_create_dynamic_sections (abfd, info)
1413       bfd *abfd;       bfd *abfd;
1414       struct bfd_link_info *info;       struct bfd_link_info *info;
# Line 1417  elf64_hppa_create_dynamic_sections (abfd Line 1416  elf64_hppa_create_dynamic_sections (abfd
1416    asection *s;    asection *s;
1417    
1418    if (! get_stub (abfd, info, elf64_hppa_hash_table (info)))    if (! get_stub (abfd, info, elf64_hppa_hash_table (info)))
1419      return false;      return FALSE;
1420    
1421    if (! get_dlt (abfd, info, elf64_hppa_hash_table (info)))    if (! get_dlt (abfd, info, elf64_hppa_hash_table (info)))
1422      return false;      return FALSE;
1423    
1424    if (! get_plt (abfd, info, elf64_hppa_hash_table (info)))    if (! get_plt (abfd, info, elf64_hppa_hash_table (info)))
1425      return false;      return FALSE;
1426    
1427    if (! get_opd (abfd, info, elf64_hppa_hash_table (info)))    if (! get_opd (abfd, info, elf64_hppa_hash_table (info)))
1428      return false;      return FALSE;
1429    
1430    s = bfd_make_section(abfd, ".rela.dlt");    s = bfd_make_section(abfd, ".rela.dlt");
1431    if (s == NULL    if (s == NULL
# Line 1436  elf64_hppa_create_dynamic_sections (abfd Line 1435  elf64_hppa_create_dynamic_sections (abfd
1435                                             | SEC_READONLY                                             | SEC_READONLY
1436                                             | SEC_LINKER_CREATED))                                             | SEC_LINKER_CREATED))
1437        || !bfd_set_section_alignment (abfd, s, 3))        || !bfd_set_section_alignment (abfd, s, 3))
1438      return false;      return FALSE;
1439    elf64_hppa_hash_table (info)->dlt_rel_sec = s;    elf64_hppa_hash_table (info)->dlt_rel_sec = s;
1440    
1441    s = bfd_make_section(abfd, ".rela.plt");    s = bfd_make_section(abfd, ".rela.plt");
# Line 1447  elf64_hppa_create_dynamic_sections (abfd Line 1446  elf64_hppa_create_dynamic_sections (abfd
1446                                             | SEC_READONLY                                             | SEC_READONLY
1447                                             | SEC_LINKER_CREATED))                                             | SEC_LINKER_CREATED))
1448        || !bfd_set_section_alignment (abfd, s, 3))        || !bfd_set_section_alignment (abfd, s, 3))
1449      return false;      return FALSE;
1450    elf64_hppa_hash_table (info)->plt_rel_sec = s;    elf64_hppa_hash_table (info)->plt_rel_sec = s;
1451    
1452    s = bfd_make_section(abfd, ".rela.data");    s = bfd_make_section(abfd, ".rela.data");
# Line 1458  elf64_hppa_create_dynamic_sections (abfd Line 1457  elf64_hppa_create_dynamic_sections (abfd
1457                                             | SEC_READONLY                                             | SEC_READONLY
1458                                             | SEC_LINKER_CREATED))                                             | SEC_LINKER_CREATED))
1459        || !bfd_set_section_alignment (abfd, s, 3))        || !bfd_set_section_alignment (abfd, s, 3))
1460      return false;      return FALSE;
1461    elf64_hppa_hash_table (info)->other_rel_sec = s;    elf64_hppa_hash_table (info)->other_rel_sec = s;
1462    
1463    s = bfd_make_section(abfd, ".rela.opd");    s = bfd_make_section(abfd, ".rela.opd");
# Line 1469  elf64_hppa_create_dynamic_sections (abfd Line 1468  elf64_hppa_create_dynamic_sections (abfd
1468                                             | SEC_READONLY                                             | SEC_READONLY
1469                                             | SEC_LINKER_CREATED))                                             | SEC_LINKER_CREATED))
1470        || !bfd_set_section_alignment (abfd, s, 3))        || !bfd_set_section_alignment (abfd, s, 3))
1471      return false;      return FALSE;
1472    elf64_hppa_hash_table (info)->opd_rel_sec = s;    elf64_hppa_hash_table (info)->opd_rel_sec = s;
1473    
1474    return true;    return TRUE;
1475  }  }
1476    
1477  /* Allocate dynamic relocations for those symbols that turned out  /* Allocate dynamic relocations for those symbols that turned out
1478     to be dynamic.  */     to be dynamic.  */
1479    
1480  static boolean  static bfd_boolean
1481  allocate_dynrel_entries (dyn_h, data)  allocate_dynrel_entries (dyn_h, data)
1482       struct elf64_hppa_dyn_hash_entry *dyn_h;       struct elf64_hppa_dyn_hash_entry *dyn_h;
1483       PTR data;       PTR data;
# Line 1486  allocate_dynrel_entries (dyn_h, data) Line 1485  allocate_dynrel_entries (dyn_h, data)
1485    struct elf64_hppa_allocate_data *x = (struct elf64_hppa_allocate_data *)data;    struct elf64_hppa_allocate_data *x = (struct elf64_hppa_allocate_data *)data;
1486    struct elf64_hppa_link_hash_table *hppa_info;    struct elf64_hppa_link_hash_table *hppa_info;
1487    struct elf64_hppa_dyn_reloc_entry *rent;    struct elf64_hppa_dyn_reloc_entry *rent;
1488    boolean dynamic_symbol, shared;    bfd_boolean dynamic_symbol, shared;
1489    
1490    hppa_info = elf64_hppa_hash_table (x->info);    hppa_info = elf64_hppa_hash_table (x->info);
1491    dynamic_symbol = elf64_hppa_dynamic_symbol_p (dyn_h->h, x->info);    dynamic_symbol = elf64_hppa_dynamic_symbol_p (dyn_h->h, x->info);
# Line 1495  allocate_dynrel_entries (dyn_h, data) Line 1494  allocate_dynrel_entries (dyn_h, data)
1494    /* We may need to allocate relocations for a non-dynamic symbol    /* We may need to allocate relocations for a non-dynamic symbol
1495       when creating a shared library.  */       when creating a shared library.  */
1496    if (!dynamic_symbol && !shared)    if (!dynamic_symbol && !shared)
1497      return true;      return TRUE;
1498    
1499    /* Take care of the normal data relocations.  */    /* Take care of the normal data relocations.  */
1500    
# Line 1506  allocate_dynrel_entries (dyn_h, data) Line 1505  allocate_dynrel_entries (dyn_h, data)
1505        if (!shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd)        if (!shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd)
1506          continue;          continue;
1507    
1508        hppa_info->other_rel_sec->_raw_size += sizeof (Elf64_External_Rela);        hppa_info->other_rel_sec->size += sizeof (Elf64_External_Rela);
1509    
1510        /* Make sure this symbol gets into the dynamic symbol table if it is        /* Make sure this symbol gets into the dynamic symbol table if it is
1511           not already recorded.  ?!? This should not be in the loop since           not already recorded.  ?!? This should not be in the loop since
1512           the symbol need only be added once.  */           the symbol need only be added once.  */
1513        if (dyn_h->h == 0        if (dyn_h->h == 0
1514            || (dyn_h->h->dynindx == -1 && dyn_h->h->type != STT_PARISC_MILLI))            || (dyn_h->h->dynindx == -1 && dyn_h->h->type != STT_PARISC_MILLI))
1515          if (!_bfd_elf64_link_record_local_dynamic_symbol          if (!bfd_elf_link_record_local_dynamic_symbol
1516              (x->info, rent->sec->owner, dyn_h->sym_indx))              (x->info, rent->sec->owner, dyn_h->sym_indx))
1517            return false;            return FALSE;
1518      }      }
1519    
1520    /* Take care of the GOT and PLT relocations.  */    /* Take care of the GOT and PLT relocations.  */
1521    
1522    if ((dynamic_symbol || shared) && dyn_h->want_dlt)    if ((dynamic_symbol || shared) && dyn_h->want_dlt)
1523      hppa_info->dlt_rel_sec->_raw_size += sizeof (Elf64_External_Rela);      hppa_info->dlt_rel_sec->size += sizeof (Elf64_External_Rela);
1524    
1525    /* If we are building a shared library, then every symbol that has an    /* If we are building a shared library, then every symbol that has an
1526       opd entry will need an EPLT relocation to relocate the symbol's address       opd entry will need an EPLT relocation to relocate the symbol's address
1527       and __gp value based on the runtime load address.  */       and __gp value based on the runtime load address.  */
1528    if (shared && dyn_h->want_opd)    if (shared && dyn_h->want_opd)
1529      hppa_info->opd_rel_sec->_raw_size += sizeof (Elf64_External_Rela);      hppa_info->opd_rel_sec->size += sizeof (Elf64_External_Rela);
1530    
1531    if (dyn_h->want_plt && dynamic_symbol)    if (dyn_h->want_plt && dynamic_symbol)
1532      {      {
# Line 1541  allocate_dynrel_entries (dyn_h, data) Line 1540  allocate_dynrel_entries (dyn_h, data)
1540        else if (shared)        else if (shared)
1541          t = 2 * sizeof (Elf64_External_Rela);          t = 2 * sizeof (Elf64_External_Rela);
1542    
1543        hppa_info->plt_rel_sec->_raw_size += t;        hppa_info->plt_rel_sec->size += t;
1544      }      }
1545    
1546    return true;    return TRUE;
1547  }  }
1548    
1549  /* Adjust a symbol defined by a dynamic object and referenced by a  /* Adjust a symbol defined by a dynamic object and referenced by a
1550     regular object.  */     regular object.  */
1551    
1552  static boolean  static bfd_boolean
1553  elf64_hppa_adjust_dynamic_symbol (info, h)  elf64_hppa_adjust_dynamic_symbol (info, h)
1554       struct bfd_link_info *info ATTRIBUTE_UNUSED;       struct bfd_link_info *info ATTRIBUTE_UNUSED;
1555       struct elf_link_hash_entry *h;       struct elf_link_hash_entry *h;
# Line 1561  elf64_hppa_adjust_dynamic_symbol (info, Line 1560  elf64_hppa_adjust_dynamic_symbol (info,
1560    /* If this is a weak symbol, and there is a real definition, the    /* If this is a weak symbol, and there is a real definition, the
1561       processor independent code will have arranged for us to see the       processor independent code will have arranged for us to see the
1562       real definition first, and we can just use the same value.  */       real definition first, and we can just use the same value.  */
1563    if (h->weakdef != NULL)    if (h->u.weakdef != NULL)
1564      {      {
1565        BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined        BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
1566                    || h->weakdef->root.type == bfd_link_hash_defweak);                    || h->u.weakdef->root.type == bfd_link_hash_defweak);
1567        h->root.u.def.section = h->weakdef->root.u.def.section;        h->root.u.def.section = h->u.weakdef->root.u.def.section;
1568        h->root.u.def.value = h->weakdef->root.u.def.value;        h->root.u.def.value = h->u.weakdef->root.u.def.value;
1569        return true;        return TRUE;
1570      }      }
1571    
1572    /* If this is a reference to a symbol defined by a dynamic object which    /* If this is a reference to a symbol defined by a dynamic object which
# Line 1577  elf64_hppa_adjust_dynamic_symbol (info, Line 1576  elf64_hppa_adjust_dynamic_symbol (info,
1576       But PA64 code is canonically PIC, so as a rule we can avoid this sort       But PA64 code is canonically PIC, so as a rule we can avoid this sort
1577       of hackery.  */       of hackery.  */
1578    
1579    return true;    return TRUE;
1580  }  }
1581    
1582  /* This function is called via elf_link_hash_traverse to mark millicode  /* This function is called via elf_link_hash_traverse to mark millicode
# Line 1585  elf64_hppa_adjust_dynamic_symbol (info, Line 1584  elf64_hppa_adjust_dynamic_symbol (info,
1584     from the dynamic symbol table.  If the symbol is not a millicode symbol,     from the dynamic symbol table.  If the symbol is not a millicode symbol,
1585     elf64_hppa_mark_exported_functions is called.  */     elf64_hppa_mark_exported_functions is called.  */
1586    
1587  static boolean  static bfd_boolean
1588  elf64_hppa_mark_milli_and_exported_functions (h, data)  elf64_hppa_mark_milli_and_exported_functions (h, data)
1589       struct elf_link_hash_entry *h;       struct elf_link_hash_entry *h;
1590       PTR data;       PTR data;
# Line 1604  elf64_hppa_mark_milli_and_exported_funct Line 1603  elf64_hppa_mark_milli_and_exported_funct
1603            _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,            _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
1604                                    elf->dynstr_index);                                    elf->dynstr_index);
1605          }          }
1606        return true;        return TRUE;
1607      }      }
1608    
1609    return elf64_hppa_mark_exported_functions (h, data);    return elf64_hppa_mark_exported_functions (h, data);
# Line 1613  elf64_hppa_mark_milli_and_exported_funct Line 1612  elf64_hppa_mark_milli_and_exported_funct
1612  /* Set the final sizes of the dynamic sections and allocate memory for  /* Set the final sizes of the dynamic sections and allocate memory for
1613     the contents of our special sections.  */     the contents of our special sections.  */
1614    
1615  static boolean  static bfd_boolean
1616  elf64_hppa_size_dynamic_sections (output_bfd, info)  elf64_hppa_size_dynamic_sections (output_bfd, info)
1617       bfd *output_bfd;       bfd *output_bfd;
1618       struct bfd_link_info *info;       struct bfd_link_info *info;
1619  {  {
1620    bfd *dynobj;    bfd *dynobj;
1621    asection *s;    asection *s;
1622    boolean plt;    bfd_boolean plt;
1623    boolean relocs;    bfd_boolean relocs;
1624    boolean reltext;    bfd_boolean reltext;
1625    struct elf64_hppa_allocate_data data;    struct elf64_hppa_allocate_data data;
1626    struct elf64_hppa_link_hash_table *hppa_info;    struct elf64_hppa_link_hash_table *hppa_info;
1627    
# Line 1647  elf64_hppa_size_dynamic_sections (output Line 1646  elf64_hppa_size_dynamic_sections (output
1646    if (elf_hash_table (info)->dynamic_sections_created)    if (elf_hash_table (info)->dynamic_sections_created)
1647      {      {
1648        /* Set the contents of the .interp section to the interpreter.  */        /* Set the contents of the .interp section to the interpreter.  */
1649        if (! info->shared)        if (info->executable)
1650          {          {
1651            s = bfd_get_section_by_name (dynobj, ".interp");            s = bfd_get_section_by_name (dynobj, ".interp");
1652            BFD_ASSERT (s != NULL);            BFD_ASSERT (s != NULL);
1653            s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;            s->size = sizeof ELF_DYNAMIC_INTERPRETER;
1654            s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;            s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
1655          }          }
1656      }      }
# Line 1664  elf64_hppa_size_dynamic_sections (output Line 1663  elf64_hppa_size_dynamic_sections (output
1663           below.  */           below.  */
1664        s = bfd_get_section_by_name (dynobj, ".rela.dlt");        s = bfd_get_section_by_name (dynobj, ".rela.dlt");
1665        if (s != NULL)        if (s != NULL)
1666          s->_raw_size = 0;          s->size = 0;
1667      }      }
1668    
1669    /* Allocate the GOT entries.  */    /* Allocate the GOT entries.  */
# Line 1675  elf64_hppa_size_dynamic_sections (output Line 1674  elf64_hppa_size_dynamic_sections (output
1674        data.ofs = 0x0;        data.ofs = 0x0;
1675        elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table,        elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table,
1676                                      allocate_global_data_dlt, &data);                                      allocate_global_data_dlt, &data);
1677        hppa_info->dlt_sec->_raw_size = data.ofs;        hppa_info->dlt_sec->size = data.ofs;
1678    
1679        data.ofs = 0x0;        data.ofs = 0x0;
1680        elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table,        elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table,
1681                                      allocate_global_data_plt, &data);                                      allocate_global_data_plt, &data);
1682        hppa_info->plt_sec->_raw_size = data.ofs;        hppa_info->plt_sec->size = data.ofs;
1683    
1684        data.ofs = 0x0;        data.ofs = 0x0;
1685        elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table,        elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table,
1686                                      allocate_global_data_stub, &data);                                      allocate_global_data_stub, &data);
1687        hppa_info->stub_sec->_raw_size = data.ofs;        hppa_info->stub_sec->size = data.ofs;
1688      }      }
1689    
1690    /* Allocate space for entries in the .opd section.  */    /* Allocate space for entries in the .opd section.  */
# Line 1694  elf64_hppa_size_dynamic_sections (output Line 1693  elf64_hppa_size_dynamic_sections (output
1693        data.ofs = 0;        data.ofs = 0;
1694        elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table,        elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table,
1695                                      allocate_global_data_opd, &data);                                      allocate_global_data_opd, &data);
1696        hppa_info->opd_sec->_raw_size = data.ofs;        hppa_info->opd_sec->size = data.ofs;
1697      }      }
1698    
1699    /* Now allocate space for dynamic relocations, if necessary.  */    /* Now allocate space for dynamic relocations, if necessary.  */
# Line 1703  elf64_hppa_size_dynamic_sections (output Line 1702  elf64_hppa_size_dynamic_sections (output
1702                                    allocate_dynrel_entries, &data);                                    allocate_dynrel_entries, &data);
1703    
1704    /* The sizes of all the sections are set.  Allocate memory for them.  */    /* The sizes of all the sections are set.  Allocate memory for them.  */
1705    plt = false;    plt = FALSE;
1706    relocs = false;    relocs = FALSE;
1707    reltext = false;    reltext = FALSE;
1708    for (s = dynobj->sections; s != NULL; s = s->next)    for (s = dynobj->sections; s != NULL; s = s->next)
1709      {      {
1710        const char *name;        const char *name;
1711        boolean strip;        bfd_boolean strip;
1712    
1713        if ((s->flags & SEC_LINKER_CREATED) == 0)        if ((s->flags & SEC_LINKER_CREATED) == 0)
1714          continue;          continue;
# Line 1723  elf64_hppa_size_dynamic_sections (output Line 1722  elf64_hppa_size_dynamic_sections (output
1722        if (strcmp (name, ".plt") == 0)        if (strcmp (name, ".plt") == 0)
1723          {          {
1724            /* Strip this section if we don't need it; see the comment below.  */            /* Strip this section if we don't need it; see the comment below.  */
1725            if (s->_raw_size == 0)            if (s->size == 0)
1726              {              {
1727                strip = true;                strip = TRUE;
1728              }              }
1729            else            else
1730              {              {
1731                /* Remember whether there is a PLT.  */                /* Remember whether there is a PLT.  */
1732                plt = true;                plt = TRUE;
1733              }              }
1734          }          }
1735        else if (strcmp (name, ".dlt") == 0)        else if (strcmp (name, ".dlt") == 0)
1736          {          {
1737            /* Strip this section if we don't need it; see the comment below.  */            /* Strip this section if we don't need it; see the comment below.  */
1738            if (s->_raw_size == 0)            if (s->size == 0)
1739              {              {
1740                strip = true;                strip = TRUE;
1741              }              }
1742          }          }
1743        else if (strcmp (name, ".opd") == 0)        else if (strcmp (name, ".opd") == 0)
1744          {          {
1745            /* Strip this section if we don't need it; see the comment below.  */            /* Strip this section if we don't need it; see the comment below.  */
1746            if (s->_raw_size == 0)            if (s->size == 0)
1747              {              {
1748                strip = true;                strip = TRUE;
1749              }              }
1750          }          }
1751        else if (strncmp (name, ".rela", 5) == 0)        else if (strncmp (name, ".rela", 5) == 0)
# Line 1758  elf64_hppa_size_dynamic_sections (output Line 1757  elf64_hppa_size_dynamic_sections (output
1757               sections.  The linker does that before adjust_dynamic_symbol               sections.  The linker does that before adjust_dynamic_symbol
1758               is called, and it is that function which decides whether               is called, and it is that function which decides whether
1759               anything needs to go into these sections.  */               anything needs to go into these sections.  */
1760            if (s->_raw_size == 0)            if (s->size == 0)
1761              {              {
1762                /* If we don't need this section, strip it from the                /* If we don't need this section, strip it from the
1763                   output file.  This is mostly to handle .rela.bss and                   output file.  This is mostly to handle .rela.bss and
# Line 1769  elf64_hppa_size_dynamic_sections (output Line 1768  elf64_hppa_size_dynamic_sections (output
1768                   adjust_dynamic_symbol is called, and it is that                   adjust_dynamic_symbol is called, and it is that
1769                   function which decides whether anything needs to go                   function which decides whether anything needs to go
1770                   into these sections.  */                   into these sections.  */
1771                strip = true;                strip = TRUE;
1772              }              }
1773            else            else
1774              {              {
# Line 1781  elf64_hppa_size_dynamic_sections (output Line 1780  elf64_hppa_size_dynamic_sections (output
1780                  {                  {
1781                    const char *outname;                    const char *outname;
1782    
1783                    relocs = true;                    relocs = TRUE;
1784    
1785                    /* If this relocation section applies to a read only                    /* If this relocation section applies to a read only
1786                       section, then we probably need a DT_TEXTREL                       section, then we probably need a DT_TEXTREL
# Line 1794  elf64_hppa_size_dynamic_sections (output Line 1793  elf64_hppa_size_dynamic_sections (output
1793                    if (target != NULL                    if (target != NULL
1794                        && (target->flags & SEC_READONLY) != 0                        && (target->flags & SEC_READONLY) != 0
1795                        && (target->flags & SEC_ALLOC) != 0)                        && (target->flags & SEC_ALLOC) != 0)
1796                      reltext = true;                      reltext = TRUE;
1797                  }                  }
1798    
1799                /* We use the reloc_count field as a counter if we need                /* We use the reloc_count field as a counter if we need
# Line 1824  elf64_hppa_size_dynamic_sections (output Line 1823  elf64_hppa_size_dynamic_sections (output
1823           garbage.  */           garbage.  */
1824        if (s->contents == NULL)        if (s->contents == NULL)
1825          {          {
1826            s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);            s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
1827            if (s->contents == NULL && s->_raw_size != 0)            if (s->contents == NULL && s->size != 0)
1828              return false;              return FALSE;
1829          }          }
1830      }      }
1831    
# Line 1836  elf64_hppa_size_dynamic_sections (output Line 1835  elf64_hppa_size_dynamic_sections (output
1835           the PLT, it is how we communicate the __gp value of a load           the PLT, it is how we communicate the __gp value of a load
1836           module to the dynamic linker.  */           module to the dynamic linker.  */
1837  #define add_dynamic_entry(TAG, VAL) \  #define add_dynamic_entry(TAG, VAL) \
1838    bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))    _bfd_elf_add_dynamic_entry (info, TAG, VAL)
1839    
1840        if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0)        if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0)
1841            || !add_dynamic_entry (DT_PLTGOT, 0))            || !add_dynamic_entry (DT_PLTGOT, 0))
1842          return false;          return FALSE;
1843    
1844        /* Add some entries to the .dynamic section.  We fill in the        /* Add some entries to the .dynamic section.  We fill in the
1845           values later, in elf64_hppa_finish_dynamic_sections, but we           values later, in elf64_hppa_finish_dynamic_sections, but we
# Line 1852  elf64_hppa_size_dynamic_sections (output Line 1851  elf64_hppa_size_dynamic_sections (output
1851            if (!add_dynamic_entry (DT_DEBUG, 0)            if (!add_dynamic_entry (DT_DEBUG, 0)
1852                || !add_dynamic_entry (DT_HP_DLD_HOOK, 0)                || !add_dynamic_entry (DT_HP_DLD_HOOK, 0)
1853                || !add_dynamic_entry (DT_HP_LOAD_MAP, 0))                || !add_dynamic_entry (DT_HP_LOAD_MAP, 0))
1854              return false;              return FALSE;
1855          }          }
1856    
1857          /* Force DT_FLAGS to always be set.
1858             Required by HPUX 11.00 patch PHSS_26559.  */
1859          if (!add_dynamic_entry (DT_FLAGS, (info)->flags))
1860            return FALSE;
1861    
1862        if (plt)        if (plt)
1863          {          {
1864            if (!add_dynamic_entry (DT_PLTRELSZ, 0)            if (!add_dynamic_entry (DT_PLTRELSZ, 0)
1865                || !add_dynamic_entry (DT_PLTREL, DT_RELA)                || !add_dynamic_entry (DT_PLTREL, DT_RELA)
1866                || !add_dynamic_entry (DT_JMPREL, 0))                || !add_dynamic_entry (DT_JMPREL, 0))
1867              return false;              return FALSE;
1868          }          }
1869    
1870        if (relocs)        if (relocs)
# Line 1868  elf64_hppa_size_dynamic_sections (output Line 1872  elf64_hppa_size_dynamic_sections (output
1872            if (!add_dynamic_entry (DT_RELA, 0)            if (!add_dynamic_entry (DT_RELA, 0)
1873                || !add_dynamic_entry (DT_RELASZ, 0)                || !add_dynamic_entry (DT_RELASZ, 0)
1874                || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))                || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
1875              return false;              return FALSE;
1876          }          }
1877    
1878        if (reltext)        if (reltext)
1879          {          {
1880            if (!add_dynamic_entry (DT_TEXTREL, 0))            if (!add_dynamic_entry (DT_TEXTREL, 0))
1881              return false;              return FALSE;
1882            info->flags |= DF_TEXTREL;            info->flags |= DF_TEXTREL;
1883          }          }
1884      }      }
1885  #undef add_dynamic_entry  #undef add_dynamic_entry
1886    
1887    return true;    return TRUE;
1888  }  }
1889    
1890  /* Called after we have output the symbol into the dynamic symbol  /* Called after we have output the symbol into the dynamic symbol
# Line 1892  elf64_hppa_size_dynamic_sections (output Line 1896  elf64_hppa_size_dynamic_sections (output
1896     the symbols have their expected value in the normal symbol     the symbols have their expected value in the normal symbol
1897     table.  Ick.  */     table.  Ick.  */
1898    
1899  static boolean  static bfd_boolean
1900  elf64_hppa_link_output_symbol_hook (abfd, info, name, sym, input_sec)  elf64_hppa_link_output_symbol_hook (info, name, sym, input_sec, h)
      bfd *abfd ATTRIBUTE_UNUSED;  
1901       struct bfd_link_info *info;       struct bfd_link_info *info;
1902       const char *name;       const char *name;
1903       Elf_Internal_Sym *sym;       Elf_Internal_Sym *sym;
1904       asection *input_sec ATTRIBUTE_UNUSED;       asection *input_sec ATTRIBUTE_UNUSED;
1905         struct elf_link_hash_entry *h;
1906  {  {
1907    struct elf64_hppa_link_hash_table *hppa_info;    struct elf64_hppa_link_hash_table *hppa_info;
1908    struct elf64_hppa_dyn_hash_entry *dyn_h;    struct elf64_hppa_dyn_hash_entry *dyn_h;
# Line 1906  elf64_hppa_link_output_symbol_hook (abfd Line 1910  elf64_hppa_link_output_symbol_hook (abfd
1910    /* We may be called with the file symbol or section symbols.    /* We may be called with the file symbol or section symbols.
1911       They never need munging, so it is safe to ignore them.  */       They never need munging, so it is safe to ignore them.  */
1912    if (!name)    if (!name)
1913      return true;      return TRUE;
1914    
1915    /* Get the PA dyn_symbol (if any) associated with NAME.  */    /* Get the PA dyn_symbol (if any) associated with NAME.  */
1916    hppa_info = elf64_hppa_hash_table (info);    hppa_info = elf64_hppa_hash_table (info);
1917    dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,    dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1918                                        name, false, false);                                        name, FALSE, FALSE);
1919      if (!dyn_h || dyn_h->h != h)
1920        return TRUE;
1921    
1922    /* Function symbols for which we created .opd entries *may* have been    /* Function symbols for which we created .opd entries *may* have been
1923       munged by finish_dynamic_symbol and have to be un-munged here.       munged by finish_dynamic_symbol and have to be un-munged here.
# Line 1920  elf64_hppa_link_output_symbol_hook (abfd Line 1926  elf64_hppa_link_output_symbol_hook (abfd
1926       into non-dynamic ones, so we initialize st_shndx to -1 in       into non-dynamic ones, so we initialize st_shndx to -1 in
1927       mark_exported_functions and check to see if it was overwritten       mark_exported_functions and check to see if it was overwritten
1928       here instead of just checking dyn_h->h->dynindx.  */       here instead of just checking dyn_h->h->dynindx.  */
1929    if (dyn_h && dyn_h->want_opd && dyn_h->st_shndx != -1)    if (dyn_h->want_opd && dyn_h->st_shndx != -1)
1930      {      {
1931        /* Restore the saved value and section index.  */        /* Restore the saved value and section index.  */
1932        sym->st_value = dyn_h->st_value;        sym->st_value = dyn_h->st_value;
1933        sym->st_shndx = dyn_h->st_shndx;        sym->st_shndx = dyn_h->st_shndx;
1934      }      }
1935    
1936    return true;    return TRUE;
1937  }  }
1938    
1939  /* Finish up dynamic symbol handling.  We set the contents of various  /* Finish up dynamic symbol handling.  We set the contents of various
1940     dynamic sections here.  */     dynamic sections here.  */
1941    
1942  static boolean  static bfd_boolean
1943  elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)  elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
1944       bfd *output_bfd;       bfd *output_bfd;
1945       struct bfd_link_info *info;       struct bfd_link_info *info;
# Line 1946  elf64_hppa_finish_dynamic_symbol (output Line 1952  elf64_hppa_finish_dynamic_symbol (output
1952    
1953    hppa_info = elf64_hppa_hash_table (info);    hppa_info = elf64_hppa_hash_table (info);
1954    dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,    dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1955                                        h->root.root.string, false, false);                                        h->root.root.string, FALSE, FALSE);
1956    
1957    stub = hppa_info->stub_sec;    stub = hppa_info->stub_sec;
1958    splt = hppa_info->plt_sec;    splt = hppa_info->plt_sec;
# Line 1964  elf64_hppa_finish_dynamic_symbol (output Line 1970  elf64_hppa_finish_dynamic_symbol (output
1970       the original values (in elf64_hppa_link_output_symbol_hook).  */       the original values (in elf64_hppa_link_output_symbol_hook).  */
1971    if (dyn_h && dyn_h->want_opd)    if (dyn_h && dyn_h->want_opd)
1972      {      {
1973        BFD_ASSERT (sopd != NULL)        BFD_ASSERT (sopd != NULL);
1974    
1975        /* Save away the original value and section index so that we        /* Save away the original value and section index so that we
1976           can restore them later.  */           can restore them later.  */
# Line 1986  elf64_hppa_finish_dynamic_symbol (output Line 1992  elf64_hppa_finish_dynamic_symbol (output
1992      {      {
1993        bfd_vma value;        bfd_vma value;
1994        Elf_Internal_Rela rel;        Elf_Internal_Rela rel;
1995          bfd_byte *loc;
1996    
1997        BFD_ASSERT (splt != NULL && spltrel != NULL)        BFD_ASSERT (splt != NULL && spltrel != NULL);
1998    
1999        /* We do not actually care about the value in the PLT entry        /* We do not actually care about the value in the PLT entry
2000           if we are creating a shared library and the symbol is           if we are creating a shared library and the symbol is
# Line 2024  elf64_hppa_finish_dynamic_symbol (output Line 2031  elf64_hppa_finish_dynamic_symbol (output
2031        rel.r_info = ELF64_R_INFO (h->dynindx, R_PARISC_IPLT);        rel.r_info = ELF64_R_INFO (h->dynindx, R_PARISC_IPLT);
2032        rel.r_addend = 0;        rel.r_addend = 0;
2033    
2034        bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel,        loc = spltrel->contents;
2035                                   (((Elf64_External_Rela *)        loc += spltrel->reloc_count++ * sizeof (Elf64_External_Rela);
2036                                     spltrel->contents)        bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel, loc);
                                   + spltrel->reloc_count));  
       spltrel->reloc_count++;  
2037      }      }
2038    
2039    /* Initialize an external call stub entry if requested.  */    /* Initialize an external call stub entry if requested.  */
# Line 2039  elf64_hppa_finish_dynamic_symbol (output Line 2044  elf64_hppa_finish_dynamic_symbol (output
2044        int insn;        int insn;
2045        unsigned int max_offset;        unsigned int max_offset;
2046    
2047        BFD_ASSERT (stub != NULL)        BFD_ASSERT (stub != NULL);
2048    
2049        /* Install the generic stub template.        /* Install the generic stub template.
2050    
# Line 2080  elf64_hppa_finish_dynamic_symbol (output Line 2085  elf64_hppa_finish_dynamic_symbol (output
2085            (*_bfd_error_handler) (_("stub entry for %s cannot load .plt, dp offset = %ld"),            (*_bfd_error_handler) (_("stub entry for %s cannot load .plt, dp offset = %ld"),
2086                                   dyn_h->root.string,                                   dyn_h->root.string,
2087                                   (long) value);                                   (long) value);
2088            return false;            return FALSE;
2089          }          }
2090    
2091        bfd_put_32 (stub->owner, (bfd_vma) insn,        bfd_put_32 (stub->owner, (bfd_vma) insn,
# Line 2103  elf64_hppa_finish_dynamic_symbol (output Line 2108  elf64_hppa_finish_dynamic_symbol (output
2108                    stub->contents + dyn_h->stub_offset + 8);                    stub->contents + dyn_h->stub_offset + 8);
2109      }      }
2110    
2111    return true;    return TRUE;
2112  }  }
2113    
2114  /* The .opd section contains FPTRs for each function this file  /* The .opd section contains FPTRs for each function this file
2115     exports.  Initialize the FPTR entries.  */     exports.  Initialize the FPTR entries.  */
2116    
2117  static boolean  static bfd_boolean
2118  elf64_hppa_finalize_opd (dyn_h, data)  elf64_hppa_finalize_opd (dyn_h, data)
2119       struct elf64_hppa_dyn_hash_entry *dyn_h;       struct elf64_hppa_dyn_hash_entry *dyn_h;
2120       PTR data;       PTR data;
# Line 2151  elf64_hppa_finalize_opd (dyn_h, data) Line 2156  elf64_hppa_finalize_opd (dyn_h, data)
2156       had their address taken).  */       had their address taken).  */
2157    if (info->shared && dyn_h && dyn_h->want_opd)    if (info->shared && dyn_h && dyn_h->want_opd)
2158      {      {
2159        Elf64_Internal_Rela rel;        Elf_Internal_Rela rel;
2160          bfd_byte *loc;
2161        int dynindx;        int dynindx;
2162    
2163        /* We may need to do a relocation against a local symbol, in        /* We may need to do a relocation against a local symbol, in
# Line 2206  elf64_hppa_finalize_opd (dyn_h, data) Line 2212  elf64_hppa_finalize_opd (dyn_h, data)
2212            strcpy (new_name + 1, h->root.root.string);            strcpy (new_name + 1, h->root.root.string);
2213    
2214            nh = elf_link_hash_lookup (elf_hash_table (info),            nh = elf_link_hash_lookup (elf_hash_table (info),
2215                                       new_name, false, false, false);                                       new_name, FALSE, FALSE, FALSE);
2216    
2217            /* All we really want from the new symbol is its dynamic            /* All we really want from the new symbol is its dynamic
2218               symbol index.  */               symbol index.  */
# Line 2216  elf64_hppa_finalize_opd (dyn_h, data) Line 2222  elf64_hppa_finalize_opd (dyn_h, data)
2222        rel.r_addend = 0;        rel.r_addend = 0;
2223        rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_EPLT);        rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_EPLT);
2224    
2225        bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel,        loc = sopdrel->contents;
2226                                   (((Elf64_External_Rela *)        loc += sopdrel->reloc_count++ * sizeof (Elf64_External_Rela);
2227                                     sopdrel->contents)        bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel, loc);
                                   + sopdrel->reloc_count));  
       sopdrel->reloc_count++;  
2228      }      }
2229    return true;    return TRUE;
2230  }  }
2231    
2232  /* The .dlt section contains addresses for items referenced through the  /* The .dlt section contains addresses for items referenced through the
2233     dlt.  Note that we can have a DLTIND relocation for a local symbol, thus     dlt.  Note that we can have a DLTIND relocation for a local symbol, thus
2234     we can not depend on finish_dynamic_symbol to initialize the .dlt.  */     we can not depend on finish_dynamic_symbol to initialize the .dlt.  */
2235    
2236  static boolean  static bfd_boolean
2237  elf64_hppa_finalize_dlt (dyn_h, data)  elf64_hppa_finalize_dlt (dyn_h, data)
2238       struct elf64_hppa_dyn_hash_entry *dyn_h;       struct elf64_hppa_dyn_hash_entry *dyn_h;
2239       PTR data;       PTR data;
# Line 2264  elf64_hppa_finalize_dlt (dyn_h, data) Line 2268  elf64_hppa_finalize_dlt (dyn_h, data)
2268                     + hppa_info->opd_sec->output_offset                     + hppa_info->opd_sec->output_offset
2269                     + hppa_info->opd_sec->output_section->vma);                     + hppa_info->opd_sec->output_section->vma);
2270          }          }
2271        else if (h->root.u.def.section)        else if ((h->root.type == bfd_link_hash_defined
2272                    || h->root.type == bfd_link_hash_defweak)
2273                   && h->root.u.def.section)
2274          {          {
2275            value = h->root.u.def.value + h->root.u.def.section->output_offset;            value = h->root.u.def.value + h->root.u.def.section->output_offset;
2276            if (h->root.u.def.section->output_section)            if (h->root.u.def.section->output_section)
# Line 2281  elf64_hppa_finalize_dlt (dyn_h, data) Line 2287  elf64_hppa_finalize_dlt (dyn_h, data)
2287        bfd_put_64 (sdlt->owner, value, sdlt->contents + dyn_h->dlt_offset);        bfd_put_64 (sdlt->owner, value, sdlt->contents + dyn_h->dlt_offset);
2288      }      }
2289    
2290    /* Create a relocation for the DLT entry assocated with this symbol.    /* Create a relocation for the DLT entry associated with this symbol.
2291       When building a shared library the symbol does not have to be dynamic.  */       When building a shared library the symbol does not have to be dynamic.  */
2292    if (dyn_h->want_dlt    if (dyn_h->want_dlt
2293        && (elf64_hppa_dynamic_symbol_p (dyn_h->h, info) || info->shared))        && (elf64_hppa_dynamic_symbol_p (dyn_h->h, info) || info->shared))
2294      {      {
2295        Elf64_Internal_Rela rel;        Elf_Internal_Rela rel;
2296          bfd_byte *loc;
2297        int dynindx;        int dynindx;
2298    
2299        /* We may need to do a relocation against a local symbol, in        /* We may need to do a relocation against a local symbol, in
# Line 2310  elf64_hppa_finalize_dlt (dyn_h, data) Line 2317  elf64_hppa_finalize_dlt (dyn_h, data)
2317            rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_DIR64);            rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_DIR64);
2318        rel.r_addend = 0;        rel.r_addend = 0;
2319    
2320        bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel,        loc = sdltrel->contents;
2321                                   (((Elf64_External_Rela *)        loc += sdltrel->reloc_count++ * sizeof (Elf64_External_Rela);
2322                                     sdltrel->contents)        bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel, loc);
                                   + sdltrel->reloc_count));  
       sdltrel->reloc_count++;  
2323      }      }
2324    return true;    return TRUE;
2325  }  }
2326    
2327  /* Finalize the dynamic relocations.  Specifically the FPTR relocations  /* Finalize the dynamic relocations.  Specifically the FPTR relocations
2328     for dynamic functions used to initialize static data.  */     for dynamic functions used to initialize static data.  */
2329    
2330  static boolean  static bfd_boolean
2331  elf64_hppa_finalize_dynreloc (dyn_h, data)  elf64_hppa_finalize_dynreloc (dyn_h, data)
2332       struct elf64_hppa_dyn_hash_entry *dyn_h;       struct elf64_hppa_dyn_hash_entry *dyn_h;
2333       PTR data;       PTR data;
# Line 2335  elf64_hppa_finalize_dynreloc (dyn_h, dat Line 2340  elf64_hppa_finalize_dynreloc (dyn_h, dat
2340    dynamic_symbol = elf64_hppa_dynamic_symbol_p (dyn_h->h, info);    dynamic_symbol = elf64_hppa_dynamic_symbol_p (dyn_h->h, info);
2341    
2342    if (!dynamic_symbol && !info->shared)    if (!dynamic_symbol && !info->shared)
2343      return true;      return TRUE;
2344    
2345    if (dyn_h->reloc_entries)    if (dyn_h->reloc_entries)
2346      {      {
# Line 2357  elf64_hppa_finalize_dynreloc (dyn_h, dat Line 2362  elf64_hppa_finalize_dynreloc (dyn_h, dat
2362    
2363        for (rent = dyn_h->reloc_entries; rent; rent = rent->next)        for (rent = dyn_h->reloc_entries; rent; rent = rent->next)
2364          {          {
2365            Elf64_Internal_Rela rel;            Elf_Internal_Rela rel;
2366              bfd_byte *loc;
2367    
2368            /* Allocate one iff we are building a shared library, the relocation            /* Allocate one iff we are building a shared library, the relocation
2369               isn't a R_PARISC_FPTR64, or we don't want an opd entry.  */               isn't a R_PARISC_FPTR64, or we don't want an opd entry.  */
# Line 2424  elf64_hppa_finalize_dynreloc (dyn_h, dat Line 2430  elf64_hppa_finalize_dynreloc (dyn_h, dat
2430    
2431            rel.r_info = ELF64_R_INFO (dynindx, rent->type);            rel.r_info = ELF64_R_INFO (dynindx, rent->type);
2432    
2433              loc = hppa_info->other_rel_sec->contents;
2434              loc += (hppa_info->other_rel_sec->reloc_count++
2435                      * sizeof (Elf64_External_Rela));
2436            bfd_elf64_swap_reloca_out (hppa_info->other_rel_sec->output_section->owner,            bfd_elf64_swap_reloca_out (hppa_info->other_rel_sec->output_section->owner,
2437                                       &rel,                                       &rel, loc);
                                      (((Elf64_External_Rela *)  
                                       hppa_info->other_rel_sec->contents)  
                                       + hppa_info->other_rel_sec->reloc_count));  
           hppa_info->other_rel_sec->reloc_count++;  
2438          }          }
2439      }      }
2440    
2441    return true;    return TRUE;
2442  }  }
2443    
2444  /* Used to decide how to sort relocs in an optimal manner for the  /* Used to decide how to sort relocs in an optimal manner for the
# Line 2459  elf64_hppa_reloc_type_class (rela) Line 2464  elf64_hppa_reloc_type_class (rela)
2464    
2465  /* Finish up the dynamic sections.  */  /* Finish up the dynamic sections.  */
2466    
2467  static boolean  static bfd_boolean
2468  elf64_hppa_finish_dynamic_sections (output_bfd, info)  elf64_hppa_finish_dynamic_sections (output_bfd, info)
2469       bfd *output_bfd;       bfd *output_bfd;
2470       struct bfd_link_info *info;       struct bfd_link_info *info;
# Line 2495  elf64_hppa_finish_dynamic_sections (outp Line 2500  elf64_hppa_finish_dynamic_sections (outp
2500        BFD_ASSERT (sdyn != NULL);        BFD_ASSERT (sdyn != NULL);
2501    
2502        dyncon = (Elf64_External_Dyn *) sdyn->contents;        dyncon = (Elf64_External_Dyn *) sdyn->contents;
2503        dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);        dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
2504        for (; dyncon < dynconend; dyncon++)        for (; dyncon < dynconend; dyncon++)
2505          {          {
2506            Elf_Internal_Dyn dyn;            Elf_Internal_Dyn dyn;
# Line 2534  elf64_hppa_finish_dynamic_sections (outp Line 2539  elf64_hppa_finish_dynamic_sections (outp
2539    
2540              case DT_PLTRELSZ:              case DT_PLTRELSZ:
2541                s = hppa_info->plt_rel_sec;                s = hppa_info->plt_rel_sec;
2542                dyn.d_un.d_val = s->_raw_size;                dyn.d_un.d_val = s->size;
2543                bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);                bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
2544                break;                break;
2545    
2546              case DT_RELA:              case DT_RELA:
2547                s = hppa_info->other_rel_sec;                s = hppa_info->other_rel_sec;
2548                if (! s || ! s->_raw_size)                if (! s || ! s->size)
2549                  s = hppa_info->dlt_rel_sec;                  s = hppa_info->dlt_rel_sec;
2550                if (! s || ! s->_raw_size)                if (! s || ! s->size)
2551                  s = hppa_info->opd_rel_sec;                  s = hppa_info->opd_rel_sec;
2552                dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;                dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
2553                bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);                bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
# Line 2550  elf64_hppa_finish_dynamic_sections (outp Line 2555  elf64_hppa_finish_dynamic_sections (outp
2555    
2556              case DT_RELASZ:              case DT_RELASZ:
2557                s = hppa_info->other_rel_sec;                s = hppa_info->other_rel_sec;
2558                dyn.d_un.d_val = s->_raw_size;                dyn.d_un.d_val = s->size;
2559                s = hppa_info->dlt_rel_sec;                s = hppa_info->dlt_rel_sec;
2560                dyn.d_un.d_val += s->_raw_size;                dyn.d_un.d_val += s->size;
2561                s = hppa_info->opd_rel_sec;                s = hppa_info->opd_rel_sec;
2562                dyn.d_un.d_val += s->_raw_size;                dyn.d_un.d_val += s->size;
2563                /* There is some question about whether or not the size of                /* There is some question about whether or not the size of
2564                   the PLT relocs should be included here.  HP's tools do                   the PLT relocs should be included here.  HP's tools do
2565                   it, so we'll emulate them.  */                   it, so we'll emulate them.  */
2566                s = hppa_info->plt_rel_sec;                s = hppa_info->plt_rel_sec;
2567                dyn.d_un.d_val += s->_raw_size;                dyn.d_un.d_val += s->size;
2568                bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);                bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
2569                break;                break;
2570    
# Line 2567  elf64_hppa_finish_dynamic_sections (outp Line 2572  elf64_hppa_finish_dynamic_sections (outp
2572          }          }
2573      }      }
2574    
2575    return true;    return TRUE;
2576  }  }
2577    
2578  /* Return the number of additional phdrs we will need.  /* Return the number of additional phdrs we will need.
# Line 2609  elf64_hppa_additional_program_headers (a Line 2614  elf64_hppa_additional_program_headers (a
2614     to guess whether or not we are building a shared library based on the     to guess whether or not we are building a shared library based on the
2615     existence of a .interp section.  */     existence of a .interp section.  */
2616    
2617  static boolean  static bfd_boolean
2618  elf64_hppa_modify_segment_map (abfd)  elf64_hppa_modify_segment_map (abfd, info)
2619       bfd *abfd;       bfd *abfd;
2620         struct bfd_link_info *info ATTRIBUTE_UNUSED;
2621  {  {
2622    struct elf_segment_map *m;    struct elf_segment_map *m;
2623    asection *s;    asection *s;
# Line 2627  elf64_hppa_modify_segment_map (abfd) Line 2633  elf64_hppa_modify_segment_map (abfd)
2633            m = ((struct elf_segment_map *)            m = ((struct elf_segment_map *)
2634                 bfd_zalloc (abfd, (bfd_size_type) sizeof *m));                 bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
2635            if (m == NULL)            if (m == NULL)
2636              return false;              return FALSE;
2637    
2638            m->p_type = PT_PHDR;            m->p_type = PT_PHDR;
2639            m->p_flags = PF_R | PF_X;            m->p_flags = PF_R | PF_X;
# Line 2658  elf64_hppa_modify_segment_map (abfd) Line 2664  elf64_hppa_modify_segment_map (abfd)
2664            }            }
2665        }        }
2666    
2667    return true;    return TRUE;
2668  }  }
2669    
2670  /* Called when writing out an object file to decide the type of a  /* Called when writing out an object file to decide the type of a
# Line 2674  elf64_hppa_elf_get_symbol_type (elf_sym, Line 2680  elf64_hppa_elf_get_symbol_type (elf_sym,
2680      return type;      return type;
2681  }  }
2682    
2683    static struct bfd_elf_special_section const elf64_hppa_special_sections[]=
2684    {
2685      { ".fini",    5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
2686      { ".init",    5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
2687      { NULL,       0, 0, 0,            0 }
2688    };
2689    
2690  /* The hash bucket size is the standard one, namely 4.  */  /* The hash bucket size is the standard one, namely 4.  */
2691    
2692  const struct elf_size_info hppa64_elf_size_info =  const struct elf_size_info hppa64_elf_size_info =
# Line 2688  const struct elf_size_info hppa64_elf_si Line 2701  const struct elf_size_info hppa64_elf_si
2701    sizeof (Elf_External_Note),    sizeof (Elf_External_Note),
2702    4,    4,
2703    1,    1,
2704    64, 8,    64, 3,
2705    ELFCLASS64, EV_CURRENT,    ELFCLASS64, EV_CURRENT,
2706    bfd_elf64_write_out_phdrs,    bfd_elf64_write_out_phdrs,
2707    bfd_elf64_write_shdrs_and_ehdr,    bfd_elf64_write_shdrs_and_ehdr,
# Line 2699  const struct elf_size_info hppa64_elf_si Line 2712  const struct elf_size_info hppa64_elf_si
2712    bfd_elf64_slurp_symbol_table,    bfd_elf64_slurp_symbol_table,
2713    bfd_elf64_swap_dyn_in,    bfd_elf64_swap_dyn_in,
2714    bfd_elf64_swap_dyn_out,    bfd_elf64_swap_dyn_out,
2715    NULL,    bfd_elf64_swap_reloc_in,
2716    NULL,    bfd_elf64_swap_reloc_out,
2717    NULL,    bfd_elf64_swap_reloca_in,
2718    NULL    bfd_elf64_swap_reloca_out
2719  };  };
2720    
2721  #define TARGET_BIG_SYM                  bfd_elf64_hppa_vec  #define TARGET_BIG_SYM                  bfd_elf64_hppa_vec
# Line 2724  const struct elf_size_info hppa64_elf_si Line 2737  const struct elf_size_info hppa64_elf_si
2737  #define elf_backend_fake_sections       elf_hppa_fake_sections  #define elf_backend_fake_sections       elf_hppa_fake_sections
2738  #define elf_backend_add_symbol_hook     elf_hppa_add_symbol_hook  #define elf_backend_add_symbol_hook     elf_hppa_add_symbol_hook
2739    
2740  #define elf_backend_relocate_section        elf_hppa_relocate_section  #define elf_backend_relocate_section    elf_hppa_relocate_section
2741    
2742  #define bfd_elf64_bfd_final_link        elf_hppa_final_link  #define bfd_elf64_bfd_final_link        elf_hppa_final_link
2743    
# Line 2766  const struct elf_size_info hppa64_elf_si Line 2779  const struct elf_size_info hppa64_elf_si
2779  #define elf_backend_plt_readonly        0  #define elf_backend_plt_readonly        0
2780  #define elf_backend_want_plt_sym        0  #define elf_backend_want_plt_sym        0
2781  #define elf_backend_got_header_size     0  #define elf_backend_got_header_size     0
2782  #define elf_backend_plt_header_size     0  #define elf_backend_type_change_ok      TRUE
2783  #define elf_backend_type_change_ok true  #define elf_backend_get_symbol_type     elf64_hppa_elf_get_symbol_type
2784  #define elf_backend_get_symbol_type          elf64_hppa_elf_get_symbol_type  #define elf_backend_reloc_type_class    elf64_hppa_reloc_type_class
2785  #define elf_backend_reloc_type_class         elf64_hppa_reloc_type_class  #define elf_backend_rela_normal         1
2786    #define elf_backend_special_sections    elf64_hppa_special_sections
2787    
2788  #include "elf64-target.h"  #include "elf64-target.h"
2789    
# Line 2778  const struct elf_size_info hppa64_elf_si Line 2792  const struct elf_size_info hppa64_elf_si
2792  #undef TARGET_BIG_NAME  #undef TARGET_BIG_NAME
2793  #define TARGET_BIG_NAME                 "elf64-hppa-linux"  #define TARGET_BIG_NAME                 "elf64-hppa-linux"
2794    
2795    #undef elf_backend_special_sections
2796    
2797  #define INCLUDED_TARGET_FILE 1  #define INCLUDED_TARGET_FILE 1
2798  #include "elf64-target.h"  #include "elf64-target.h"

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26