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

binutils v2.14 - offical sources.

File:
1 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Support for HPPA 64-bit ELF
    2    Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
    3 
    4 This file is part of BFD, the Binary File Descriptor library.
    5 
    6 This program is free software; you can redistribute it and/or modify
    7 it under the terms of the GNU General Public License as published by
    8 the Free Software Foundation; either version 2 of the License, or
    9 (at your option) any later version.
    10 
    11 This program is distributed in the hope that it will be useful,
    12 but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 GNU General Public License for more details.
    15 
    16 You should have received a copy of the GNU General Public License
    17 along with this program; if not, write to the Free Software
    18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     2   Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
     3
     4   This file is part of BFD, the Binary File Descriptor library.
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2 of the License, or
     9   (at your option) any later version.
     10
     11   This program is distributed in the hope that it will be useful,
     12   but WITHOUT ANY WARRANTY; without even the implied warranty of
     13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14   GNU General Public License for more details.
     15
     16   You should have received a copy of the GNU General Public License
     17   along with this program; if not, write to the Free Software
     18   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    1919
    2020#include "alloca-conf.h"
     
    6363     associated BFD.  Needed so that we can have relocs against local
    6464     symbols in shared libraries.  */
    65   unsigned long sym_indx;
     65  long sym_indx;
    6666  bfd *owner;
    6767
     
    157157  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
    158158
    159 static boolean elf64_hppa_dyn_hash_table_init
     159static bfd_boolean elf64_hppa_dyn_hash_table_init
    160160  PARAMS ((struct elf64_hppa_dyn_hash_table *ht, bfd *abfd,
    161161           new_hash_entry_func new));
     
    167167static struct elf64_hppa_dyn_hash_entry *elf64_hppa_dyn_hash_lookup
    168168  PARAMS ((struct elf64_hppa_dyn_hash_table *table, const char *string,
    169            boolean create, boolean copy));
     169           bfd_boolean create, bfd_boolean copy));
    170170static void elf64_hppa_dyn_hash_traverse
    171171  PARAMS ((struct elf64_hppa_dyn_hash_table *table,
    172            boolean (*func) (struct elf64_hppa_dyn_hash_entry *, PTR),
     172           bfd_boolean (*func) (struct elf64_hppa_dyn_hash_entry *, PTR),
    173173           PTR info));
    174174
     
    181181#include "elf-hppa.h"
    182182
    183 static boolean elf64_hppa_object_p
     183static bfd_boolean elf64_hppa_object_p
    184184  PARAMS ((bfd *));
    185185
    186 static boolean elf64_hppa_section_from_shdr
    187   PARAMS ((bfd *, Elf64_Internal_Shdr *, char *));
     186static bfd_boolean elf64_hppa_section_from_shdr
     187  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
    188188
    189189static void elf64_hppa_post_process_headers
    190190  PARAMS ((bfd *, struct bfd_link_info *));
    191191
    192 static boolean elf64_hppa_create_dynamic_sections
     192static bfd_boolean elf64_hppa_create_dynamic_sections
    193193  PARAMS ((bfd *, struct bfd_link_info *));
    194194
    195 static boolean elf64_hppa_adjust_dynamic_symbol
     195static bfd_boolean elf64_hppa_adjust_dynamic_symbol
    196196  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
    197197
    198 static boolean elf64_hppa_size_dynamic_sections
     198static bfd_boolean elf64_hppa_mark_milli_and_exported_functions
     199  PARAMS ((struct elf_link_hash_entry *, PTR));
     200
     201static bfd_boolean elf64_hppa_size_dynamic_sections
    199202  PARAMS ((bfd *, struct bfd_link_info *));
    200203
    201 static boolean elf64_hppa_finish_dynamic_symbol
     204static bfd_boolean elf64_hppa_link_output_symbol_hook
     205  PARAMS ((bfd *abfd, struct bfd_link_info *, const char *,
     206           Elf_Internal_Sym *, asection *input_sec));
     207
     208static bfd_boolean elf64_hppa_finish_dynamic_symbol
    202209  PARAMS ((bfd *, struct bfd_link_info *,
    203210           struct elf_link_hash_entry *, Elf_Internal_Sym *));
    204211
    205 static boolean elf64_hppa_finish_dynamic_sections
     212static int elf64_hppa_additional_program_headers
     213  PARAMS ((bfd *));
     214
     215static bfd_boolean elf64_hppa_modify_segment_map
     216  PARAMS ((bfd *));
     217
     218static enum elf_reloc_type_class elf64_hppa_reloc_type_class
     219  PARAMS ((const Elf_Internal_Rela *));
     220
     221static bfd_boolean elf64_hppa_finish_dynamic_sections
    206222  PARAMS ((bfd *, struct bfd_link_info *));
    207223
    208 static boolean elf64_hppa_check_relocs
     224static bfd_boolean elf64_hppa_check_relocs
    209225  PARAMS ((bfd *, struct bfd_link_info *,
    210226           asection *, const Elf_Internal_Rela *));
    211227
    212 static boolean elf64_hppa_dynamic_symbol_p
     228static bfd_boolean elf64_hppa_dynamic_symbol_p
    213229  PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *));
    214230
    215 static boolean elf64_hppa_mark_exported_functions
     231static bfd_boolean elf64_hppa_mark_exported_functions
    216232  PARAMS ((struct elf_link_hash_entry *, PTR));
    217233
    218 static boolean elf64_hppa_finalize_opd
     234static bfd_boolean elf64_hppa_finalize_opd
    219235  PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
    220236
    221 static boolean elf64_hppa_finalize_dlt
     237static bfd_boolean elf64_hppa_finalize_dlt
    222238  PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
    223239
    224 static boolean allocate_global_data_dlt
     240static bfd_boolean allocate_global_data_dlt
    225241  PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
    226242
    227 static boolean allocate_global_data_plt
     243static bfd_boolean allocate_global_data_plt
    228244  PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
    229245
    230 static boolean allocate_global_data_stub
     246static bfd_boolean allocate_global_data_stub
    231247  PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
    232248
    233 static boolean allocate_global_data_opd
     249static bfd_boolean allocate_global_data_opd
    234250  PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
    235251
    236 static boolean get_reloc_section
     252static bfd_boolean get_reloc_section
    237253  PARAMS ((bfd *, struct elf64_hppa_link_hash_table *, asection *));
    238254
    239 static boolean count_dyn_reloc
     255static bfd_boolean count_dyn_reloc
    240256  PARAMS ((bfd *, struct elf64_hppa_dyn_hash_entry *,
    241257           int, asection *, int, bfd_vma, bfd_vma));
    242258
    243 static boolean allocate_dynrel_entries
     259static bfd_boolean allocate_dynrel_entries
    244260  PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
    245261
    246 static boolean elf64_hppa_finalize_dynreloc
     262static bfd_boolean elf64_hppa_finalize_dynreloc
    247263  PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
    248264
    249 static boolean get_opd
     265static bfd_boolean get_opd
    250266  PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));
    251267
    252 static boolean get_plt
     268static bfd_boolean get_plt
    253269  PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));
    254270
    255 static boolean get_dlt
     271static bfd_boolean get_dlt
    256272  PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));
    257273
    258 static boolean get_stub
     274static bfd_boolean get_stub
    259275  PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *));
    260276
     
    262278  PARAMS ((Elf_Internal_Sym *, int));
    263279
    264 static boolean
     280static bfd_boolean
    265281elf64_hppa_dyn_hash_table_init (ht, abfd, new)
    266282     struct elf64_hppa_dyn_hash_table *ht;
     
    310326  struct elf64_hppa_link_hash_table *ret;
    311327
    312   ret = bfd_zalloc (abfd, sizeof (*ret));
     328  ret = bfd_zalloc (abfd, (bfd_size_type) sizeof (*ret));
    313329  if (!ret)
    314330    return 0;
     
    332348     struct elf64_hppa_dyn_hash_table *table;
    333349     const char *string;
    334      boolean create, copy;
     350     bfd_boolean create, copy;
    335351{
    336352  return ((struct elf64_hppa_dyn_hash_entry *)
     
    343359elf64_hppa_dyn_hash_traverse (table, func, info)
    344360     struct elf64_hppa_dyn_hash_table *table;
    345      boolean (*func) PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
     361     bfd_boolean (*func) PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));
    346362     PTR info;
    347363{
    348364  (bfd_hash_traverse
    349365   (&table->root,
    350     (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) func,
     366    (bfd_boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) func,
    351367    info));
    352368}
     
    356372
    357373   Additionally we set the default architecture and machine.  */
    358 static boolean
     374static bfd_boolean
    359375elf64_hppa_object_p (abfd)
    360376     bfd *abfd;
     
    367383    {
    368384      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX)
    369         return false;
     385        return FALSE;
    370386    }
    371387  else
    372388    {
    373389      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX)
    374         return false;
     390        return FALSE;
    375391    }
    376392
     
    388404    }
    389405  /* Don't be fussy.  */
    390   return true;
     406  return TRUE;
    391407}
    392408
    393409/* Given section type (hdr->sh_type), return a boolean indicating
    394410   whether or not the section is an elf64-hppa specific section.  */
    395 static boolean
     411static bfd_boolean
    396412elf64_hppa_section_from_shdr (abfd, hdr, name)
    397413     bfd *abfd;
    398      Elf64_Internal_Shdr *hdr;
    399      char *name;
     414     Elf_Internal_Shdr *hdr;
     415     const char *name;
    400416{
    401417  asection *newsect;
     
    405421    case SHT_PARISC_EXT:
    406422      if (strcmp (name, ".PARISC.archext") != 0)
    407         return false;
     423        return FALSE;
    408424      break;
    409425    case SHT_PARISC_UNWIND:
    410426      if (strcmp (name, ".PARISC.unwind") != 0)
    411         return false;
     427        return FALSE;
    412428      break;
    413429    case SHT_PARISC_DOC:
    414430    case SHT_PARISC_ANNOT:
    415431    default:
    416       return false;
     432      return FALSE;
    417433    }
    418434
    419435  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
    420     return false;
     436    return FALSE;
    421437  newsect = hdr->bfd_section;
    422438
    423   return true;
     439  return TRUE;
    424440}
    425441
     
    485501   a suitable section for holding relocs in the output BFD for a link.  */
    486502
    487 static boolean
     503static bfd_boolean
    488504get_reloc_section (abfd, hppa_info, sec)
    489505     bfd *abfd;
     
    499515                elf_section_data(sec)->rel_hdr.sh_name));
    500516  if (srel_name == NULL)
    501     return false;
     517    return FALSE;
    502518
    503519  BFD_ASSERT ((strncmp (srel_name, ".rela", 5) == 0
     
    525541                                      | SEC_READONLY))
    526542          || !bfd_set_section_alignment (dynobj, srel, 3))
    527         return false;
     543        return FALSE;
    528544    }
    529545
    530546  hppa_info->other_rel_sec = srel;
    531   return true;
     547  return TRUE;
    532548}
    533549
     
    538554   output file.  */
    539555
    540 static boolean
     556static bfd_boolean
    541557count_dyn_reloc (abfd, dyn_h, type, sec, sec_symndx, offset, addend)
    542558     bfd *abfd;
     
    551567
    552568  rent = (struct elf64_hppa_dyn_reloc_entry *)
    553   bfd_alloc (abfd, sizeof (*rent));
     569  bfd_alloc (abfd, (bfd_size_type) sizeof (*rent));
    554570  if (!rent)
    555     return false;
     571    return FALSE;
    556572
    557573  rent->next = dyn_h->reloc_entries;
     
    563579  dyn_h->reloc_entries = rent;
    564580
    565   return true;
     581  return TRUE;
    566582}
    567583
     
    569585   referenced symbol needs.  */
    570586
    571 static boolean
     587static bfd_boolean
    572588elf64_hppa_check_relocs (abfd, info, sec, relocs)
    573589     bfd *abfd;
     
    586602
    587603  if (info->relocateable)
    588     return true;
     604    return TRUE;
    589605
    590606  /* If this is the first dynamic object found in the link, create
     
    593609    {
    594610      if (! bfd_elf64_link_create_dynamic_sections (abfd, info))
    595         return false;
     611        return FALSE;
    596612    }
    597613
     
    600616
    601617  /* If necessary, build a new table holding section symbols indices
    602      for this BFD.  This is disgusting.  */
     618     for this BFD.  */
    603619
    604620  if (info->shared && hppa_info->section_syms_bfd != abfd)
    605621    {
    606622      unsigned long i;
    607       int highest_shndx;
    608       Elf_Internal_Sym *local_syms, *isym;
    609       Elf64_External_Sym *ext_syms, *esym;
     623      unsigned int highest_shndx;
     624      Elf_Internal_Sym *local_syms = NULL;
     625      Elf_Internal_Sym *isym, *isymend;
     626      bfd_size_type amt;
    610627
    611628      /* We're done with the old cache of section index to section symbol
     
    617634        free (hppa_info->section_syms);
    618635
    619       /* Allocate memory for the internal and external symbols.  */
    620       local_syms
    621         = (Elf_Internal_Sym *) bfd_malloc (symtab_hdr->sh_info
    622                                            * sizeof (Elf_Internal_Sym));
    623       if (local_syms == NULL)
    624         return false;
    625 
    626       ext_syms
    627         = (Elf64_External_Sym *) bfd_malloc (symtab_hdr->sh_info
    628                                              * sizeof (Elf64_External_Sym));
    629       if (ext_syms == NULL)
    630         {
    631           free (local_syms);
    632           return false;
    633         }
    634 
    635       /* Read in the local symbols.  */
    636       if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
    637           || bfd_read (ext_syms, 1,
    638                        (symtab_hdr->sh_info
    639                         * sizeof (Elf64_External_Sym)), abfd)
    640           != (symtab_hdr->sh_info * sizeof (Elf64_External_Sym)))
    641         {
    642           free (local_syms);
    643           free (ext_syms);
    644           return false;
    645         }
    646 
    647       /* Swap in the local symbols, also record the highest section index
    648          referenced by the local symbols.  */
    649       isym = local_syms;
    650       esym = ext_syms;
     636      /* Read this BFD's local symbols.  */
     637      if (symtab_hdr->sh_info != 0)
     638        {
     639          local_syms = (Elf_Internal_Sym *) symtab_hdr->contents;
     640          if (local_syms == NULL)
     641            local_syms = bfd_elf_get_elf_syms (abfd, symtab_hdr,
     642                                               symtab_hdr->sh_info, 0,
     643                                               NULL, NULL, NULL);
     644          if (local_syms == NULL)
     645            return FALSE;
     646        }
     647
     648      /* Record the highest section index referenced by the local symbols.  */
    651649      highest_shndx = 0;
    652       for (i = 0; i < symtab_hdr->sh_info; i++, esym++, isym++)
    653         {
    654           bfd_elf64_swap_symbol_in (abfd, esym, isym);
     650      isymend = local_syms + symtab_hdr->sh_info;
     651      for (isym = local_syms; isym < isymend; isym++)
     652        {
    655653          if (isym->st_shndx > highest_shndx)
    656654            highest_shndx = isym->st_shndx;
    657655        }
    658 
    659       /* Now we can free the external symbols.  */
    660       free (ext_syms);
    661656
    662657      /* Allocate an array to hold the section index to section symbol index
    663658         mapping.  Bump by one since we start counting at zero.  */
    664659      highest_shndx++;
    665       hppa_info->section_syms = (int *) bfd_malloc (highest_shndx
    666                                                     * sizeof (int));
     660      amt = highest_shndx;
     661      amt *= sizeof (int);
     662      hppa_info->section_syms = (int *) bfd_malloc (amt);
    667663
    668664      /* Now walk the local symbols again.  If we find a section symbol,
    669665         record the index of the symbol into the section_syms array.  */
    670       for (isym = local_syms, i = 0; i < symtab_hdr->sh_info; i++, isym++)
     666      for (i = 0, isym = local_syms; isym < isymend; i++, isym++)
    671667        {
    672668          if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
     
    674670        }
    675671
    676       /* We are finished with the local symbols.  Get rid of them.  */
    677       free (local_syms);
     672      /* We are finished with the local symbols.  */
     673      if (local_syms != NULL
     674          && symtab_hdr->contents != (unsigned char *) local_syms)
     675        {
     676          if (! info->keep_memory)
     677            free (local_syms);
     678          else
     679            {
     680              /* Cache the symbols for elf_link_input_bfd.  */
     681              symtab_hdr->contents = (unsigned char *) local_syms;
     682            }
     683        }
    678684
    679685      /* Record which BFD we built the section_syms mapping for.  */
     
    692698         something went terribly wrong above.  */
    693699      if (sec_symndx == -1)
    694         return false;
     700        return FALSE;
    695701
    696702      sec_symndx = hppa_info->section_syms[sec_symndx];
     
    719725      int need_entry;
    720726      const char *addr_name;
    721       boolean maybe_dynamic;
     727      bfd_boolean maybe_dynamic;
    722728      int dynrel_type = R_PARISC_NONE;
    723729      static reloc_howto_type *howto;
     
    740746         have yet been processed.  Do something with what we know, as
    741747         this may help reduce memory usage and processing time later.  */
    742       maybe_dynamic = false;
    743       if (h && ((info->shared && ! info->symbolic)
     748      maybe_dynamic = FALSE;
     749      if (h && ((info->shared
     750                    && (!info->symbolic || info->allow_shlib_undefined) )
    744751                || ! (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
    745752                || h->root.type == bfd_link_hash_defweak))
    746         maybe_dynamic = true;
     753        maybe_dynamic = TRUE;
    747754
    748755      howto = elf_hppa_howto_table + ELF64_R_TYPE (rel->r_info);
     
    853860      /* Collect the canonical entry data for this address.  */
    854861      dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
    855                                           addr_name, true, true);
     862                                          addr_name, TRUE, TRUE);
    856863      BFD_ASSERT (dyn_h);
    857864
     
    924931              && ! (_bfd_elf64_link_record_local_dynamic_symbol
    925932                    (info, abfd, sec_symndx)))
    926             return false;
     933            return FALSE;
    927934        }
    928935    }
     
    930937  if (buf)
    931938    free (buf);
    932   return true;
     939  return TRUE;
    933940
    934941 err_out:
    935942  if (buf)
    936943    free (buf);
    937   return false;
     944  return FALSE;
    938945}
    939946
     
    946953/* Should we do dynamic things to this symbol?  */
    947954
    948 static boolean
     955static bfd_boolean
    949956elf64_hppa_dynamic_symbol_p (h, info)
    950957     struct elf_link_hash_entry *h;
     
    952959{
    953960  if (h == NULL)
    954     return false;
     961    return FALSE;
    955962
    956963  while (h->root.type == bfd_link_hash_indirect
     
    959966
    960967  if (h->dynindx == -1)
    961     return false;
     968    return FALSE;
    962969
    963970  if (h->root.type == bfd_link_hash_undefweak
    964971      || h->root.type == bfd_link_hash_defweak)
    965     return true;
     972    return TRUE;
    966973
    967974  if (h->root.root.string[0] == '$' && h->root.root.string[1] == '$')
    968     return false;
    969 
    970   if ((info->shared && !info->symbolic)
     975    return FALSE;
     976
     977  if ((info->shared && (!info->symbolic || info->allow_shlib_undefined))
    971978      || ((h->elf_link_hash_flags
    972979           & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))
    973980          == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)))
    974     return true;
    975 
    976   return false;
     981    return TRUE;
     982
     983  return FALSE;
    977984}
    978985
     
    980987   entries in .opd for them.  */
    981988
    982 static boolean
     989static bfd_boolean
    983990elf64_hppa_mark_exported_functions (h, data)
    984991     struct elf_link_hash_entry *h;
     
    989996
    990997  hppa_info = elf64_hppa_hash_table (info);
     998
     999  if (h->root.type == bfd_link_hash_warning)
     1000    h = (struct elf_link_hash_entry *) h->root.u.i.link;
    9911001
    9921002  if (h
     
    10001010      /* Add this symbol to the PA64 linker hash table.  */
    10011011      dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
    1002                                           h->root.root.string, true, true);
     1012                                          h->root.root.string, TRUE, TRUE);
    10031013      BFD_ASSERT (dyn_h);
    10041014      dyn_h->h = h;
     
    10061016      if (! hppa_info->opd_sec
    10071017          && ! get_opd (hppa_info->root.dynobj, info, hppa_info))
    1008         return false;
     1018        return FALSE;
    10091019
    10101020      dyn_h->want_opd = 1;
     
    10141024    }
    10151025
    1016   return true;
     1026  return TRUE;
    10171027}
    10181028
    10191029/* Allocate space for a DLT entry.  */
    10201030
    1021 static boolean
     1031static bfd_boolean
    10221032allocate_global_data_dlt (dyn_h, data)
    10231033     struct elf64_hppa_dyn_hash_entry *dyn_h;
     
    10361046             against it.  */
    10371047          if (! h
    1038               || (h && h->dynindx == -1))
     1048              || (h->dynindx == -1 && h->type != STT_PARISC_MILLI))
    10391049            {
    10401050              bfd *owner;
    10411051              owner = (h ? h->root.u.def.section->owner : dyn_h->owner);
    10421052
    1043               if (!_bfd_elf64_link_record_local_dynamic_symbol
    1044                     (x->info, owner, dyn_h->sym_indx))
    1045                 return false;
     1053              if (! (_bfd_elf64_link_record_local_dynamic_symbol
     1054                     (x->info, owner, dyn_h->sym_indx)))
     1055                return FALSE;
    10461056            }
    10471057        }
     
    10501060      x->ofs += DLT_ENTRY_SIZE;
    10511061    }
    1052   return true;
     1062  return TRUE;
    10531063}
    10541064
    10551065/* Allocate space for a DLT.PLT entry.  */
    10561066
    1057 static boolean
     1067static bfd_boolean
    10581068allocate_global_data_plt (dyn_h, data)
    10591069     struct elf64_hppa_dyn_hash_entry *dyn_h;
     
    10761086    dyn_h->want_plt = 0;
    10771087
    1078   return true;
     1088  return TRUE;
    10791089}
    10801090
    10811091/* Allocate space for a STUB entry.  */
    10821092
    1083 static boolean
     1093static bfd_boolean
    10841094allocate_global_data_stub (dyn_h, data)
    10851095     struct elf64_hppa_dyn_hash_entry *dyn_h;
     
    10991109  else
    11001110    dyn_h->want_stub = 0;
    1101   return true;
     1111  return TRUE;
    11021112}
    11031113
    11041114/* Allocate space for a FPTR entry.  */
    11051115
    1106 static boolean
     1116static bfd_boolean
    11071117allocate_global_data_opd (dyn_h, data)
    11081118     struct elf64_hppa_dyn_hash_entry *dyn_h;
     
    11221132      /* We never need an opd entry for a symbol which is not
    11231133         defined by this output file.  */
    1124       if (h && h->root.type == bfd_link_hash_undefined)
     1134      if (h && (h->root.type == bfd_link_hash_undefined
     1135                || h->root.u.def.section->output_section == NULL))
    11251136        dyn_h->want_opd = 0;
    11261137
     
    11301141      else if (x->info->shared
    11311142               || h == NULL
    1132                || h->dynindx == -1
    1133                || ((h->root.type == bfd_link_hash_defined
    1134                     || h->root.type == bfd_link_hash_defweak)
    1135                    && h->root.u.def.section->output_section != NULL))
     1143               || (h->dynindx == -1 && h->type != STT_PARISC_MILLI)
     1144               || (h->root.type == bfd_link_hash_defined
     1145                   || h->root.type == bfd_link_hash_defweak))
    11361146        {
    11371147          /* If we are creating a shared library, then we will have to
     
    11471157              if (!_bfd_elf64_link_record_local_dynamic_symbol
    11481158                    (x->info, owner, dyn_h->sym_indx))
    1149                 return false;
     1159                return FALSE;
    11501160            }
    11511161
     
    11651175
    11661176              nh = elf_link_hash_lookup (elf_hash_table (x->info),
    1167                                          new_name, true, true, true);
     1177                                         new_name, TRUE, TRUE, TRUE);
    11681178
    11691179              nh->root.type = h->root.type;
     
    11721182
    11731183              if (! bfd_elf64_link_record_dynamic_symbol (x->info, nh))
    1174                 return false;
     1184                return FALSE;
    11751185
    11761186             }
     
    11831193        dyn_h->want_opd = 0;
    11841194    }
    1185   return true;
     1195  return TRUE;
    11861196}
    11871197
     
    12141224   of a procedure, thus ensuring a unique address for each procedure.  */
    12151225
    1216 static boolean
     1226static bfd_boolean
    12171227get_opd (abfd, info, hppa_info)
    12181228     bfd *abfd;
     
    12411251        {
    12421252          BFD_ASSERT (0);
    1243           return false;
     1253          return FALSE;
    12441254        }
    12451255
     
    12471257    }
    12481258
    1249   return true;
     1259  return TRUE;
    12501260}
    12511261
    12521262/* Create the PLT section.  */
    12531263
    1254 static boolean
     1264static bfd_boolean
    12551265get_plt (abfd, info, hppa_info)
    12561266     bfd *abfd;
     
    12791289        {
    12801290          BFD_ASSERT (0);
    1281           return false;
     1291          return FALSE;
    12821292        }
    12831293
     
    12851295    }
    12861296
    1287   return true;
     1297  return TRUE;
    12881298}
    12891299
    12901300/* Create the DLT section.  */
    12911301
    1292 static boolean
     1302static bfd_boolean
    12931303get_dlt (abfd, info, hppa_info)
    12941304     bfd *abfd;
     
    13171327        {
    13181328          BFD_ASSERT (0);
    1319           return false;
     1329          return FALSE;
    13201330        }
    13211331
     
    13231333    }
    13241334
    1325   return true;
     1335  return TRUE;
    13261336}
    13271337
    13281338/* Create the stubs section.  */
    13291339
    1330 static boolean
     1340static bfd_boolean
    13311341get_stub (abfd, info, hppa_info)
    13321342     bfd *abfd;
     
    13561366        {
    13571367          BFD_ASSERT (0);
    1358           return false;
     1368          return FALSE;
    13591369        }
    13601370
     
    13621372    }
    13631373
    1364   return true;
     1374  return TRUE;
    13651375}
    13661376
     
    14031413        EPLT relocations for symbols exported from shared libraries.  */
    14041414
    1405 static boolean
     1415static bfd_boolean
    14061416elf64_hppa_create_dynamic_sections (abfd, info)
    14071417     bfd *abfd;
     
    14111421
    14121422  if (! get_stub (abfd, info, elf64_hppa_hash_table (info)))
    1413     return false;
     1423    return FALSE;
    14141424
    14151425  if (! get_dlt (abfd, info, elf64_hppa_hash_table (info)))
    1416     return false;
     1426    return FALSE;
    14171427
    14181428  if (! get_plt (abfd, info, elf64_hppa_hash_table (info)))
    1419     return false;
     1429    return FALSE;
    14201430
    14211431  if (! get_opd (abfd, info, elf64_hppa_hash_table (info)))
    1422     return false;
     1432    return FALSE;
    14231433
    14241434  s = bfd_make_section(abfd, ".rela.dlt");
     
    14301440                                           | SEC_LINKER_CREATED))
    14311441      || !bfd_set_section_alignment (abfd, s, 3))
    1432     return false;
     1442    return FALSE;
    14331443  elf64_hppa_hash_table (info)->dlt_rel_sec = s;
    14341444
     
    14411451                                           | SEC_LINKER_CREATED))
    14421452      || !bfd_set_section_alignment (abfd, s, 3))
    1443     return false;
     1453    return FALSE;
    14441454  elf64_hppa_hash_table (info)->plt_rel_sec = s;
    14451455
     
    14521462                                           | SEC_LINKER_CREATED))
    14531463      || !bfd_set_section_alignment (abfd, s, 3))
    1454     return false;
     1464    return FALSE;
    14551465  elf64_hppa_hash_table (info)->other_rel_sec = s;
    14561466
     
    14631473                                           | SEC_LINKER_CREATED))
    14641474      || !bfd_set_section_alignment (abfd, s, 3))
    1465     return false;
     1475    return FALSE;
    14661476  elf64_hppa_hash_table (info)->opd_rel_sec = s;
    14671477
    1468   return true;
     1478  return TRUE;
    14691479}
    14701480
     
    14721482   to be dynamic.  */
    14731483
    1474 static boolean
     1484static bfd_boolean
    14751485allocate_dynrel_entries (dyn_h, data)
    14761486     struct elf64_hppa_dyn_hash_entry *dyn_h;
     
    14801490  struct elf64_hppa_link_hash_table *hppa_info;
    14811491  struct elf64_hppa_dyn_reloc_entry *rent;
    1482   boolean dynamic_symbol, shared;
     1492  bfd_boolean dynamic_symbol, shared;
    14831493
    14841494  hppa_info = elf64_hppa_hash_table (x->info);
     
    14891499     when creating a shared library.  */
    14901500  if (!dynamic_symbol && !shared)
    1491     return true;
     1501    return TRUE;
    14921502
    14931503  /* Take care of the normal data relocations.  */
     
    14951505  for (rent = dyn_h->reloc_entries; rent; rent = rent->next)
    14961506    {
    1497       switch (rent->type)
    1498         {
    1499         case R_PARISC_FPTR64:
    1500           /* Allocate one iff we are not building a shared library and
    1501              !want_opd, which by this point will be true only if we're
    1502              actually allocating one statically in the main executable.  */
    1503           if (!x->info->shared && dyn_h->want_opd)
    1504             continue;
    1505           break;
    1506         }
     1507      /* Allocate one iff we are building a shared library, the relocation
     1508         isn't a R_PARISC_FPTR64, or we don't want an opd entry.  */
     1509      if (!shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd)
     1510        continue;
     1511
    15071512      hppa_info->other_rel_sec->_raw_size += sizeof (Elf64_External_Rela);
    15081513
     
    15101515         not already recorded.  ?!? This should not be in the loop since
    15111516         the symbol need only be added once.  */
    1512       if (dyn_h->h == 0 || dyn_h->h->dynindx == -1)
     1517      if (dyn_h->h == 0
     1518          || (dyn_h->h->dynindx == -1 && dyn_h->h->type != STT_PARISC_MILLI))
    15131519        if (!_bfd_elf64_link_record_local_dynamic_symbol
    15141520            (x->info, rent->sec->owner, dyn_h->sym_indx))
    1515           return false;
     1521          return FALSE;
    15161522    }
    15171523
     
    15421548    }
    15431549
    1544   return true;
     1550  return TRUE;
    15451551}
    15461552
     
    15481554   regular object.  */
    15491555
    1550 static boolean
     1556static bfd_boolean
    15511557elf64_hppa_adjust_dynamic_symbol (info, h)
    15521558     struct bfd_link_info *info ATTRIBUTE_UNUSED;
     
    15651571      h->root.u.def.section = h->weakdef->root.u.def.section;
    15661572      h->root.u.def.value = h->weakdef->root.u.def.value;
    1567       return true;
     1573      return TRUE;
    15681574    }
    15691575
     
    15751581     of hackery.  */
    15761582
    1577   return true;
     1583  return TRUE;
     1584}
     1585
     1586/* This function is called via elf_link_hash_traverse to mark millicode
     1587   symbols with a dynindx of -1 and to remove the string table reference
     1588   from the dynamic symbol table.  If the symbol is not a millicode symbol,
     1589   elf64_hppa_mark_exported_functions is called.  */
     1590
     1591static bfd_boolean
     1592elf64_hppa_mark_milli_and_exported_functions (h, data)
     1593     struct elf_link_hash_entry *h;
     1594     PTR data;
     1595{
     1596  struct bfd_link_info *info = (struct bfd_link_info *)data;
     1597  struct elf_link_hash_entry *elf = h;
     1598
     1599  if (elf->root.type == bfd_link_hash_warning)
     1600    elf = (struct elf_link_hash_entry *) elf->root.u.i.link;
     1601
     1602  if (elf->type == STT_PARISC_MILLI)
     1603    {
     1604      if (elf->dynindx != -1)
     1605        {
     1606          elf->dynindx = -1;
     1607          _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
     1608                                  elf->dynstr_index);
     1609        }
     1610      return TRUE;
     1611    }
     1612
     1613  return elf64_hppa_mark_exported_functions (h, data);
    15781614}
    15791615
     
    15811617   the contents of our special sections.  */
    15821618
    1583 static boolean
     1619static bfd_boolean
    15841620elf64_hppa_size_dynamic_sections (output_bfd, info)
    15851621     bfd *output_bfd;
     
    15881624  bfd *dynobj;
    15891625  asection *s;
    1590   boolean plt;
    1591   boolean relocs;
    1592   boolean reltext;
     1626  bfd_boolean plt;
     1627  bfd_boolean relocs;
     1628  bfd_boolean reltext;
    15931629  struct elf64_hppa_allocate_data data;
    15941630  struct elf64_hppa_link_hash_table *hppa_info;
     
    15981634  dynobj = elf_hash_table (info)->dynobj;
    15991635  BFD_ASSERT (dynobj != NULL);
     1636
     1637  /* Mark each function this program exports so that we will allocate
     1638     space in the .opd section for each function's FPTR.  If we are
     1639     creating dynamic sections, change the dynamic index of millicode
     1640     symbols to -1 and remove them from the string table for .dynstr.
     1641
     1642     We have to traverse the main linker hash table since we have to
     1643     find functions which may not have been mentioned in any relocs.  */
     1644  elf_link_hash_traverse (elf_hash_table (info),
     1645                          (elf_hash_table (info)->dynamic_sections_created
     1646                           ? elf64_hppa_mark_milli_and_exported_functions
     1647                           : elf64_hppa_mark_exported_functions),
     1648                          info);
    16001649
    16011650  if (elf_hash_table (info)->dynamic_sections_created)
     
    16431692    }
    16441693
    1645   /* Mark each function this program exports so that we will allocate
    1646      space in the .opd section for each function's FPTR.
    1647 
    1648      We have to traverse the main linker hash table since we have to
    1649      find functions which may not have been mentioned in any relocs.  */
    1650   elf_link_hash_traverse (elf_hash_table (info),
    1651                           elf64_hppa_mark_exported_functions,
    1652                           info);
    1653 
    16541694  /* Allocate space for entries in the .opd section.  */
    16551695  if (elf64_hppa_hash_table (info)->opd_sec)
     
    16671707
    16681708  /* The sizes of all the sections are set.  Allocate memory for them.  */
    1669   plt = false;
    1670   relocs = false;
    1671   reltext = false;
     1709  plt = FALSE;
     1710  relocs = FALSE;
     1711  reltext = FALSE;
    16721712  for (s = dynobj->sections; s != NULL; s = s->next)
    16731713    {
    16741714      const char *name;
    1675       boolean strip;
     1715      bfd_boolean strip;
    16761716
    16771717      if ((s->flags & SEC_LINKER_CREATED) == 0)
     
    16861726      if (strcmp (name, ".plt") == 0)
    16871727        {
     1728          /* Strip this section if we don't need it; see the comment below.  */
    16881729          if (s->_raw_size == 0)
    16891730            {
    1690               /* Strip this section if we don't need it; see the
    1691                  comment below.  */
    1692               strip = true;
     1731              strip = TRUE;
    16931732            }
    16941733          else
    16951734            {
    16961735              /* Remember whether there is a PLT.  */
    1697               plt = true;
     1736              plt = TRUE;
    16981737            }
    16991738        }
    17001739      else if (strcmp (name, ".dlt") == 0)
    17011740        {
     1741          /* Strip this section if we don't need it; see the comment below.  */
    17021742          if (s->_raw_size == 0)
    17031743            {
    1704               /* Strip this section if we don't need it; see the
    1705                  comment below.  */
    1706               strip = true;
     1744              strip = TRUE;
    17071745            }
    17081746        }
    17091747      else if (strcmp (name, ".opd") == 0)
    17101748        {
     1749          /* Strip this section if we don't need it; see the comment below.  */
    17111750          if (s->_raw_size == 0)
    17121751            {
    1713               /* Strip this section if we don't need it; see the
    1714                  comment below.  */
    1715               strip = true;
     1752              strip = TRUE;
    17161753            }
    17171754        }
    1718       else if (strncmp (name, ".rela", 4) == 0)
    1719         {
     1755      else if (strncmp (name, ".rela", 5) == 0)
     1756        {
     1757          /* If we don't need this section, strip it from the output file.
     1758             This is mostly to handle .rela.bss and .rela.plt.  We must
     1759             create both sections in create_dynamic_sections, because they
     1760             must be created before the linker maps input sections to output
     1761             sections.  The linker does that before adjust_dynamic_symbol
     1762             is called, and it is that function which decides whether
     1763             anything needs to go into these sections.  */
    17201764          if (s->_raw_size == 0)
    17211765            {
     
    17291773                 function which decides whether anything needs to go
    17301774                 into these sections.  */
    1731               strip = true;
     1775              strip = TRUE;
    17321776            }
    17331777          else
     
    17411785                  const char *outname;
    17421786
    1743                   relocs = true;
     1787                  relocs = TRUE;
    17441788
    17451789                  /* If this relocation section applies to a read only
     
    17541798                      && (target->flags & SEC_READONLY) != 0
    17551799                      && (target->flags & SEC_ALLOC) != 0)
    1756                     reltext = true;
     1800                    reltext = TRUE;
    17571801                }
    17581802
     
    17861830          s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
    17871831          if (s->contents == NULL && s->_raw_size != 0)
    1788             return false;
     1832            return FALSE;
    17891833        }
    17901834    }
     
    17951839         the PLT, it is how we communicate the __gp value of a load
    17961840         module to the dynamic linker.  */
    1797       if (! bfd_elf64_add_dynamic_entry (info, DT_HP_DLD_FLAGS, 0)
    1798           || ! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0))
    1799         return false;
     1841#define add_dynamic_entry(TAG, VAL) \
     1842  bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
     1843
     1844      if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0)
     1845          || !add_dynamic_entry (DT_PLTGOT, 0))
     1846        return FALSE;
    18001847
    18011848      /* Add some entries to the .dynamic section.  We fill in the
     
    18061853      if (! info->shared)
    18071854        {
    1808           if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0)
    1809               || ! bfd_elf64_add_dynamic_entry (info, DT_HP_DLD_HOOK, 0)
    1810               || ! bfd_elf64_add_dynamic_entry (info, DT_HP_LOAD_MAP, 0))
    1811             return false;
    1812         }
     1855          if (!add_dynamic_entry (DT_DEBUG, 0)
     1856              || !add_dynamic_entry (DT_HP_DLD_HOOK, 0)
     1857              || !add_dynamic_entry (DT_HP_LOAD_MAP, 0))
     1858            return FALSE;
     1859        }
     1860
     1861      /* Force DT_FLAGS to always be set.
     1862         Required by HPUX 11.00 patch PHSS_26559.  */
     1863      if (!add_dynamic_entry (DT_FLAGS, (info)->flags))
     1864        return FALSE;
    18131865
    18141866      if (plt)
    18151867        {
    1816           if (! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
    1817               || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
    1818               || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
    1819             return false;
     1868          if (!add_dynamic_entry (DT_PLTRELSZ, 0)
     1869              || !add_dynamic_entry (DT_PLTREL, DT_RELA)
     1870              || !add_dynamic_entry (DT_JMPREL, 0))
     1871            return FALSE;
    18201872        }
    18211873
    18221874      if (relocs)
    18231875        {
    1824           if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
    1825               || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
    1826               || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
    1827                                                 sizeof (Elf64_External_Rela)))
    1828             return false;
     1876          if (!add_dynamic_entry (DT_RELA, 0)
     1877              || !add_dynamic_entry (DT_RELASZ, 0)
     1878              || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
     1879            return FALSE;
    18291880        }
    18301881
    18311882      if (reltext)
    18321883        {
    1833           if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
    1834             return false;
     1884          if (!add_dynamic_entry (DT_TEXTREL, 0))
     1885            return FALSE;
    18351886          info->flags |= DF_TEXTREL;
    18361887        }
    18371888    }
    1838 
    1839   return true;
     1889#undef add_dynamic_entry
     1890
     1891  return TRUE;
    18401892}
    18411893
     
    18491901   table.  Ick.  */
    18501902
    1851 static boolean
     1903static bfd_boolean
    18521904elf64_hppa_link_output_symbol_hook (abfd, info, name, sym, input_sec)
    18531905     bfd *abfd ATTRIBUTE_UNUSED;
     
    18631915     They never need munging, so it is safe to ignore them.  */
    18641916  if (!name)
    1865     return true;
     1917    return TRUE;
    18661918
    18671919  /* Get the PA dyn_symbol (if any) associated with NAME.  */
    18681920  hppa_info = elf64_hppa_hash_table (info);
    18691921  dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
    1870                                       name, false, false);
     1922                                      name, FALSE, FALSE);
    18711923
    18721924  /* Function symbols for which we created .opd entries *may* have been
     
    18841936    }
    18851937
    1886   return true;
     1938  return TRUE;
    18871939}
    18881940
     
    18901942   dynamic sections here.  */
    18911943
    1892 static boolean
     1944static bfd_boolean
    18931945elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
    18941946     bfd *output_bfd;
     
    19031955  hppa_info = elf64_hppa_hash_table (info);
    19041956  dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
    1905                                       h->root.root.string, false, false);
     1957                                      h->root.root.string, FALSE, FALSE);
    19061958
    19071959  stub = hppa_info->stub_sec;
     
    19121964  sdltrel = hppa_info->dlt_rel_sec;
    19131965
    1914   BFD_ASSERT (stub != NULL && splt != NULL
    1915               && sopd != NULL && sdlt != NULL)
    1916 
    19171966  /* Incredible.  It is actually necessary to NOT use the symbol's real
    19181967     value when building the dynamic symbol table for a shared library.
     
    19241973  if (dyn_h && dyn_h->want_opd)
    19251974    {
     1975      BFD_ASSERT (sopd != NULL)
     1976
    19261977      /* Save away the original value and section index so that we
    19271978         can restore them later.  */
     
    19441995      bfd_vma value;
    19451996      Elf_Internal_Rela rel;
     1997      bfd_byte *loc;
     1998
     1999      BFD_ASSERT (splt != NULL && spltrel != NULL)
    19462000
    19472001      /* We do not actually care about the value in the PLT entry
     
    19802034      rel.r_addend = 0;
    19812035
    1982       bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel,
    1983                                  (((Elf64_External_Rela *)
    1984                                    spltrel->contents)
    1985                                   + spltrel->reloc_count));
    1986       spltrel->reloc_count++;
     2036      loc = spltrel->contents;
     2037      loc += spltrel->reloc_count++ * sizeof (Elf64_External_Rela);
     2038      bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel, loc);
    19872039    }
    19882040
     
    19942046      int insn;
    19952047      unsigned int max_offset;
     2048
     2049      BFD_ASSERT (stub != NULL)
    19962050
    19972051      /* Install the generic stub template.
     
    20202074          max_offset = 32768;
    20212075          insn &= ~ 0xfff1;
    2022           insn |= re_assemble_16 (value);
     2076          insn |= re_assemble_16 ((int) value);
    20232077        }
    20242078      else
     
    20262080          max_offset = 8192;
    20272081          insn &= ~ 0x3ff1;
    2028           insn |= re_assemble_14 (value);
     2082          insn |= re_assemble_14 ((int) value);
    20292083        }
    20302084
     
    20342088                                 dyn_h->root.string,
    20352089                                 (long) value);
    2036           return false;
    2037         }
    2038 
    2039       bfd_put_32 (stub->owner, insn,
     2090          return FALSE;
     2091        }
     2092
     2093      bfd_put_32 (stub->owner, (bfd_vma) insn,
    20402094                  stub->contents + dyn_h->stub_offset);
    20412095
     
    20462100        {
    20472101          insn &= ~ 0xfff1;
    2048           insn |= re_assemble_16 (value);
     2102          insn |= re_assemble_16 ((int) value);
    20492103        }
    20502104      else
    20512105        {
    20522106          insn &= ~ 0x3ff1;
    2053           insn |= re_assemble_14 (value);
    2054         }
    2055       bfd_put_32 (stub->owner, insn,
     2107          insn |= re_assemble_14 ((int) value);
     2108        }
     2109      bfd_put_32 (stub->owner, (bfd_vma) insn,
    20562110                  stub->contents + dyn_h->stub_offset + 8);
    20572111    }
    20582112
    2059   /* Millicode symbols should not be put in the dynamic
    2060      symbol table under any circumstances.  */
    2061   if (ELF_ST_TYPE (sym->st_info) == STT_PARISC_MILLI)
    2062     h->dynindx = -1;
    2063 
    2064   return true;
     2113  return TRUE;
    20652114}
    20662115
     
    20682117   exports.  Initialize the FPTR entries.  */
    20692118
    2070 static boolean
     2119static bfd_boolean
    20712120elf64_hppa_finalize_opd (dyn_h, data)
    20722121     struct elf64_hppa_dyn_hash_entry *dyn_h;
     
    20752124  struct bfd_link_info *info = (struct bfd_link_info *)data;
    20762125  struct elf64_hppa_link_hash_table *hppa_info;
    2077   struct elf_link_hash_entry *h = dyn_h->h;
     2126  struct elf_link_hash_entry *h = dyn_h ? dyn_h->h : NULL;
    20782127  asection *sopd;
    20792128  asection *sopdrel;
     
    20832132  sopdrel = hppa_info->opd_rel_sec;
    20842133
    2085   if (h && dyn_h && dyn_h->want_opd)
     2134  if (h && dyn_h->want_opd)
    20862135    {
    20872136      bfd_vma value;
     
    21102159  if (info->shared && dyn_h && dyn_h->want_opd)
    21112160    {
    2112       Elf64_Internal_Rela rel;
     2161      Elf_Internal_Rela rel;
     2162      bfd_byte *loc;
    21132163      int dynindx;
    21142164
     
    21652215
    21662216          nh = elf_link_hash_lookup (elf_hash_table (info),
    2167                                      new_name, false, false, false);
     2217                                     new_name, FALSE, FALSE, FALSE);
    21682218
    21692219          /* All we really want from the new symbol is its dynamic
     
    21752225      rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_EPLT);
    21762226
    2177       bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel,
    2178                                  (((Elf64_External_Rela *)
    2179                                    sopdrel->contents)
    2180                                   + sopdrel->reloc_count));
    2181       sopdrel->reloc_count++;
    2182     }
    2183   return true;
     2227      loc = sopdrel->contents;
     2228      loc += sopdrel->reloc_count++ * sizeof (Elf64_External_Rela);
     2229      bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel, loc);
     2230    }
     2231  return TRUE;
    21842232}
    21852233
     
    21882236   we can not depend on finish_dynamic_symbol to initialize the .dlt.  */
    21892237
    2190 static boolean
     2238static bfd_boolean
    21912239elf64_hppa_finalize_dlt (dyn_h, data)
    21922240     struct elf64_hppa_dyn_hash_entry *dyn_h;
     
    21962244  struct elf64_hppa_link_hash_table *hppa_info;
    21972245  asection *sdlt, *sdltrel;
    2198   struct elf_link_hash_entry *h = dyn_h->h;
     2246  struct elf_link_hash_entry *h = dyn_h ? dyn_h->h : NULL;
    21992247
    22002248  hppa_info = elf64_hppa_hash_table (info);
     
    22072255     the proper value into the DLT, note this shortcut can not be
    22082256     skipped when building a shared library.  */
    2209   if (! info->shared && h && dyn_h && dyn_h->want_dlt)
     2257  if (! info->shared && h && dyn_h->want_dlt)
    22102258    {
    22112259      bfd_vma value;
     
    22232271                   + hppa_info->opd_sec->output_section->vma);
    22242272        }
    2225       else
    2226         {
    2227           value = (h->root.u.def.value
    2228                    + h->root.u.def.section->output_offset);
    2229 
     2273      else if (h->root.u.def.section)
     2274        {
     2275          value = h->root.u.def.value + h->root.u.def.section->output_offset;
    22302276          if (h->root.u.def.section->output_section)
    22312277            value += h->root.u.def.section->output_section->vma;
     
    22332279            value += h->root.u.def.section->vma;
    22342280        }
     2281      else
     2282        /* We have an undefined function reference.  */
     2283        value = 0;
    22352284
    22362285      /* We do not need to include the output offset of the DLT section
     
    22442293      && (elf64_hppa_dynamic_symbol_p (dyn_h->h, info) || info->shared))
    22452294    {
    2246       Elf64_Internal_Rela rel;
     2295      Elf_Internal_Rela rel;
     2296      bfd_byte *loc;
    22472297      int dynindx;
    22482298
     
    22682318      rel.r_addend = 0;
    22692319
    2270       bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel,
    2271                                  (((Elf64_External_Rela *)
    2272                                    sdltrel->contents)
    2273                                   + sdltrel->reloc_count));
    2274       sdltrel->reloc_count++;
    2275     }
    2276   return true;
     2320      loc = sdltrel->contents;
     2321      loc += sdltrel->reloc_count++ * sizeof (Elf64_External_Rela);
     2322      bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel, loc);
     2323    }
     2324  return TRUE;
    22772325}
    22782326
     
    22802328   for dynamic functions used to initialize static data.  */
    22812329
    2282 static boolean
     2330static bfd_boolean
    22832331elf64_hppa_finalize_dynreloc (dyn_h, data)
    22842332     struct elf64_hppa_dyn_hash_entry *dyn_h;
     
    22932341
    22942342  if (!dynamic_symbol && !info->shared)
    2295     return true;
     2343    return TRUE;
    22962344
    22972345  if (dyn_h->reloc_entries)
     
    23152363      for (rent = dyn_h->reloc_entries; rent; rent = rent->next)
    23162364        {
    2317           Elf64_Internal_Rela rel;
    2318 
    2319           switch (rent->type)
    2320             {
    2321               case R_PARISC_FPTR64:
    2322               /* Allocate one iff we are not building a shared library and
    2323                  !want_opd, which by this point will be true only if we're
    2324                  actually allocating one statically in the main executable.  */
    2325               if (!info->shared && dyn_h->want_opd)
    2326                 continue;
    2327               break;
    2328             }
     2365          Elf_Internal_Rela rel;
     2366          bfd_byte *loc;
     2367
     2368          /* 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.  */
     2370          if (!info->shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd)
     2371            continue;
    23292372
    23302373          /* Create a dynamic relocation for this entry.
     
    23552398             base symbol for the relocation.  The addend is the difference
    23562399             between the section symbol and the address of the .opd entry.  */
    2357           if (info->shared && rent->type == R_PARISC_FPTR64)
     2400          if (info->shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd)
    23582401            {
    23592402              bfd_vma value, value2;
     
    23882431          rel.r_info = ELF64_R_INFO (dynindx, rent->type);
    23892432
     2433          loc = hppa_info->other_rel_sec->contents;
     2434          loc += (hppa_info->other_rel_sec->reloc_count++
     2435                  * sizeof (Elf64_External_Rela));
    23902436          bfd_elf64_swap_reloca_out (hppa_info->other_rel_sec->output_section->owner,
    2391                                      &rel,
    2392                                      (((Elf64_External_Rela *)
    2393                                       hppa_info->other_rel_sec->contents)
    2394                                       + hppa_info->other_rel_sec->reloc_count));
    2395           hppa_info->other_rel_sec->reloc_count++;
    2396         }
    2397     }
    2398 
    2399   return true;
     2437                                     &rel, loc);
     2438        }
     2439    }
     2440
     2441  return TRUE;
     2442}
     2443
     2444/* Used to decide how to sort relocs in an optimal manner for the
     2445   dynamic linker, before writing them out.  */
     2446
     2447static enum elf_reloc_type_class
     2448elf64_hppa_reloc_type_class (rela)
     2449     const Elf_Internal_Rela *rela;
     2450{
     2451  if (ELF64_R_SYM (rela->r_info) == 0)
     2452    return reloc_class_relative;
     2453
     2454  switch ((int) ELF64_R_TYPE (rela->r_info))
     2455    {
     2456    case R_PARISC_IPLT:
     2457      return reloc_class_plt;
     2458    case R_PARISC_COPY:
     2459      return reloc_class_copy;
     2460    default:
     2461      return reloc_class_normal;
     2462    }
    24002463}
    24012464
    24022465/* Finish up the dynamic sections.  */
    24032466
    2404 static boolean
     2467static bfd_boolean
    24052468elf64_hppa_finish_dynamic_sections (output_bfd, info)
    24062469     bfd *output_bfd;
     
    24832546            case DT_RELA:
    24842547              s = hppa_info->other_rel_sec;
    2485               if (! s)
     2548              if (! s || ! s->_raw_size)
    24862549                s = hppa_info->dlt_rel_sec;
     2550              if (! s || ! s->_raw_size)
     2551                s = hppa_info->opd_rel_sec;
    24872552              dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
    24882553              bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
     
    25082573    }
    25092574
    2510   return true;
     2575  return TRUE;
    25112576}
    25122577
     
    25502615   existence of a .interp section.  */
    25512616
    2552 static boolean
     2617static bfd_boolean
    25532618elf64_hppa_modify_segment_map (abfd)
    25542619     bfd *abfd;
     
    25652630      if (m == NULL)
    25662631        {
    2567           m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
     2632          m = ((struct elf_segment_map *)
     2633               bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
    25682634          if (m == NULL)
    2569             return false;
     2635            return FALSE;
    25702636
    25712637          m->p_type = PT_PHDR;
     
    25982664      }
    25992665
    2600   return true;
     2666  return TRUE;
    26012667}
    26022668
     
    26332699  bfd_elf64_write_shdrs_and_ehdr,
    26342700  bfd_elf64_write_relocs,
     2701  bfd_elf64_swap_symbol_in,
    26352702  bfd_elf64_swap_symbol_out,
    26362703  bfd_elf64_slurp_reloc_table,
     
    26382705  bfd_elf64_swap_dyn_in,
    26392706  bfd_elf64_swap_dyn_out,
    2640   NULL,
    2641   NULL,
    2642   NULL,
    2643   NULL
     2707  bfd_elf64_swap_reloc_in,
     2708  bfd_elf64_swap_reloc_out,
     2709  bfd_elf64_swap_reloca_in,
     2710  bfd_elf64_swap_reloca_out
    26442711};
    26452712
     
    26602727#define elf_backend_final_write_processing \
    26612728                                        elf_hppa_final_write_processing
    2662 #define elf_backend_fake_sections       elf_hppa_fake_sections
     2729#define elf_backend_fake_sections       elf_hppa_fake_sections
    26632730#define elf_backend_add_symbol_hook     elf_hppa_add_symbol_hook
    26642731
    2665 #define elf_backend_relocate_section        elf_hppa_relocate_section
     2732#define elf_backend_relocate_section    elf_hppa_relocate_section
    26662733
    26672734#define bfd_elf64_bfd_final_link        elf_hppa_final_link
     
    27062773#define elf_backend_got_header_size     0
    27072774#define elf_backend_plt_header_size     0
    2708 #define elf_backend_type_change_ok true
    2709 #define elf_backend_get_symbol_type          elf64_hppa_elf_get_symbol_type
     2775#define elf_backend_type_change_ok      TRUE
     2776#define elf_backend_get_symbol_type     elf64_hppa_elf_get_symbol_type
     2777#define elf_backend_reloc_type_class    elf64_hppa_reloc_type_class
     2778#define elf_backend_rela_normal         1
    27102779
    27112780#include "elf64-target.h"
Note: See TracChangeset for help on using the changeset viewer.