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-sparc.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* SPARC-specific support for 64-bit ELF
    2    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
    3    Free Software Foundation, Inc.
    4 
    5 This file is part of BFD, the Binary File Descriptor library.
    6 
    7 This program is free software; you can redistribute it and/or modify
    8 it under the terms of the GNU General Public License as published by
    9 the Free Software Foundation; either version 2 of the License, or
    10 (at your option) any later version.
    11 
    12 This program is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with this program; if not, write to the Free Software
    19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     2   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
     3   2003 Free Software Foundation, Inc.
     4
     5   This file is part of BFD, the Binary File Descriptor library.
     6
     7   This program is free software; you can redistribute it and/or modify
     8   it under the terms of the GNU General Public License as published by
     9   the Free Software Foundation; either version 2 of the License, or
     10   (at your option) any later version.
     11
     12   This program is distributed in the hope that it will be useful,
     13   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15   GNU General Public License for more details.
     16
     17   You should have received a copy of the GNU General Public License
     18   along with this program; if not, write to the Free Software
     19   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    2020
    2121#include "bfd.h"
     
    3636
    3737static struct bfd_link_hash_table * sparc64_elf_bfd_link_hash_table_create
    38   PARAMS((bfd *));
     38  PARAMS ((bfd *));
     39static bfd_reloc_status_type init_insn_reloc
     40  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *,
     41           bfd *, bfd_vma *, bfd_vma *));
    3942static reloc_howto_type *sparc64_elf_reloc_type_lookup
    4043  PARAMS ((bfd *, bfd_reloc_code_real_type));
     
    4346
    4447static void sparc64_elf_build_plt
    45   PARAMS((bfd *, unsigned char *, int));
     48  PARAMS ((bfd *, unsigned char *, int));
    4649static bfd_vma sparc64_elf_plt_entry_offset
    47   PARAMS((int));
     50  PARAMS ((bfd_vma));
    4851static bfd_vma sparc64_elf_plt_ptr_offset
    49   PARAMS((int, int));
    50 
    51 static boolean sparc64_elf_check_relocs
    52   PARAMS((bfd *, struct bfd_link_info *, asection *sec,
    53           const Elf_Internal_Rela *));
    54 static boolean sparc64_elf_adjust_dynamic_symbol
    55   PARAMS((struct bfd_link_info *, struct elf_link_hash_entry *));
    56 static boolean sparc64_elf_size_dynamic_sections
    57   PARAMS((bfd *, struct bfd_link_info *));
     52  PARAMS ((bfd_vma, bfd_vma));
     53
     54static bfd_boolean sparc64_elf_check_relocs
     55  PARAMS ((bfd *, struct bfd_link_info *, asection *sec,
     56           const Elf_Internal_Rela *));
     57static bfd_boolean sparc64_elf_adjust_dynamic_symbol
     58  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
     59static bfd_boolean sparc64_elf_size_dynamic_sections
     60  PARAMS ((bfd *, struct bfd_link_info *));
    5861static int sparc64_elf_get_symbol_type
    5962  PARAMS (( Elf_Internal_Sym *, int));
    60 static boolean sparc64_elf_add_symbol_hook
     63static bfd_boolean sparc64_elf_add_symbol_hook
    6164  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
    62         const char **, flagword *, asection **, bfd_vma *));
     65           const char **, flagword *, asection **, bfd_vma *));
     66static bfd_boolean sparc64_elf_output_arch_syms
     67  PARAMS ((bfd *, struct bfd_link_info *, PTR,
     68           bfd_boolean (*) (PTR, const char *, Elf_Internal_Sym *, asection *)));
    6369static void sparc64_elf_symbol_processing
    6470  PARAMS ((bfd *, asymbol *));
    6571
    66 static boolean sparc64_elf_copy_private_bfd_data
     72static bfd_boolean sparc64_elf_merge_private_bfd_data
    6773  PARAMS ((bfd *, bfd *));
    68 static boolean sparc64_elf_merge_private_bfd_data
    69   PARAMS ((bfd *, bfd *));
    70 
    71 static boolean sparc64_elf_relax_section
    72   PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
    73 static boolean sparc64_elf_relocate_section
     74
     75static bfd_boolean sparc64_elf_fake_sections
     76  PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
     77
     78static const char *sparc64_elf_print_symbol_all
     79  PARAMS ((bfd *, PTR, asymbol *));
     80static bfd_boolean sparc64_elf_new_section_hook
     81  PARAMS ((bfd *, asection *));
     82static bfd_boolean sparc64_elf_relax_section
     83  PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
     84static bfd_boolean sparc64_elf_relocate_section
    7485  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    7586           Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
    76 static boolean sparc64_elf_object_p PARAMS ((bfd *));
     87static bfd_boolean sparc64_elf_finish_dynamic_symbol
     88  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
     89           Elf_Internal_Sym *));
     90static bfd_boolean sparc64_elf_finish_dynamic_sections
     91  PARAMS ((bfd *, struct bfd_link_info *));
     92static bfd_boolean sparc64_elf_object_p PARAMS ((bfd *));
    7793static long sparc64_elf_get_reloc_upper_bound PARAMS ((bfd *, asection *));
    7894static long sparc64_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
    79 static boolean sparc64_elf_slurp_one_reloc_table
    80   PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, asymbol **, boolean));
    81 static boolean sparc64_elf_slurp_reloc_table
    82   PARAMS ((bfd *, asection *, asymbol **, boolean));
     95static bfd_boolean sparc64_elf_slurp_one_reloc_table
     96  PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, asymbol **, bfd_boolean));
     97static bfd_boolean sparc64_elf_slurp_reloc_table
     98  PARAMS ((bfd *, asection *, asymbol **, bfd_boolean));
     99static long sparc64_elf_canonicalize_reloc
     100  PARAMS ((bfd *, asection *, arelent **, asymbol **));
    83101static long sparc64_elf_canonicalize_dynamic_reloc
    84102  PARAMS ((bfd *, arelent **, asymbol **));
    85103static void sparc64_elf_write_relocs PARAMS ((bfd *, asection *, PTR));
     104static enum elf_reloc_type_class sparc64_elf_reloc_type_class
     105  PARAMS ((const Elf_Internal_Rela *));
    86106
    87107
     
    99119static reloc_howto_type sparc64_elf_howto_table[] =
    100120{
    101   HOWTO(R_SPARC_NONE,      0,0, 0,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_NONE",    false,0,0x00000000,true),
    102   HOWTO(R_SPARC_8,         0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_8",       false,0,0x000000ff,true),
    103   HOWTO(R_SPARC_16,        0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_16",      false,0,0x0000ffff,true),
    104   HOWTO(R_SPARC_32,        0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_32",      false,0,0xffffffff,true),
    105   HOWTO(R_SPARC_DISP8,     0,0, 8,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP8",   false,0,0x000000ff,true),
    106   HOWTO(R_SPARC_DISP16,    0,1,16,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP16",  false,0,0x0000ffff,true),
    107   HOWTO(R_SPARC_DISP32,    0,2,32,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP32",  false,0,0x00ffffff,true),
    108   HOWTO(R_SPARC_WDISP30,   2,2,30,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WDISP30", false,0,0x3fffffff,true),
    109   HOWTO(R_SPARC_WDISP22,   2,2,22,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WDISP22", false,0,0x003fffff,true),
    110   HOWTO(R_SPARC_HI22,     10,2,22,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_HI22",    false,0,0x003fffff,true),
    111   HOWTO(R_SPARC_22,        0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_22",      false,0,0x003fffff,true),
    112   HOWTO(R_SPARC_13,        0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_13",      false,0,0x00001fff,true),
    113   HOWTO(R_SPARC_LO10,      0,2,10,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_LO10",    false,0,0x000003ff,true),
    114   HOWTO(R_SPARC_GOT10,     0,2,10,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GOT10",   false,0,0x000003ff,true),
    115   HOWTO(R_SPARC_GOT13,     0,2,13,false,0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_GOT13",   false,0,0x00001fff,true),
    116   HOWTO(R_SPARC_GOT22,    10,2,22,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GOT22",   false,0,0x003fffff,true),
    117   HOWTO(R_SPARC_PC10,      0,2,10,true, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_PC10",    false,0,0x000003ff,true),
    118   HOWTO(R_SPARC_PC22,     10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_PC22",    false,0,0x003fffff,true),
    119   HOWTO(R_SPARC_WPLT30,    2,2,30,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WPLT30",  false,0,0x3fffffff,true),
    120   HOWTO(R_SPARC_COPY,      0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_COPY",    false,0,0x00000000,true),
    121   HOWTO(R_SPARC_GLOB_DAT,  0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
    122   HOWTO(R_SPARC_JMP_SLOT,  0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_JMP_SLOT",false,0,0x00000000,true),
    123   HOWTO(R_SPARC_RELATIVE,  0,0,00,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_RELATIVE",false,0,0x00000000,true),
    124   HOWTO(R_SPARC_UA32,      0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_UA32",    false,0,0xffffffff,true),
     121  HOWTO(R_SPARC_NONE,      0,0, 0,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_NONE",    FALSE,0,0x00000000,TRUE),
     122  HOWTO(R_SPARC_8,         0,0, 8,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_8",       FALSE,0,0x000000ff,TRUE),
     123  HOWTO(R_SPARC_16,        0,1,16,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_16",      FALSE,0,0x0000ffff,TRUE),
     124  HOWTO(R_SPARC_32,        0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_32",      FALSE,0,0xffffffff,TRUE),
     125  HOWTO(R_SPARC_DISP8,     0,0, 8,TRUE, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP8",   FALSE,0,0x000000ff,TRUE),
     126  HOWTO(R_SPARC_DISP16,    0,1,16,TRUE, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP16",  FALSE,0,0x0000ffff,TRUE),
     127  HOWTO(R_SPARC_DISP32,    0,2,32,TRUE, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP32",  FALSE,0,0xffffffff,TRUE),
     128  HOWTO(R_SPARC_WDISP30,   2,2,30,TRUE, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WDISP30", FALSE,0,0x3fffffff,TRUE),
     129  HOWTO(R_SPARC_WDISP22,   2,2,22,TRUE, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WDISP22", FALSE,0,0x003fffff,TRUE),
     130  HOWTO(R_SPARC_HI22,     10,2,22,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_HI22",    FALSE,0,0x003fffff,TRUE),
     131  HOWTO(R_SPARC_22,        0,2,22,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_22",      FALSE,0,0x003fffff,TRUE),
     132  HOWTO(R_SPARC_13,        0,2,13,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_13",      FALSE,0,0x00001fff,TRUE),
     133  HOWTO(R_SPARC_LO10,      0,2,10,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_LO10",    FALSE,0,0x000003ff,TRUE),
     134  HOWTO(R_SPARC_GOT10,     0,2,10,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GOT10",   FALSE,0,0x000003ff,TRUE),
     135  HOWTO(R_SPARC_GOT13,     0,2,13,FALSE,0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_GOT13",   FALSE,0,0x00001fff,TRUE),
     136  HOWTO(R_SPARC_GOT22,    10,2,22,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GOT22",   FALSE,0,0x003fffff,TRUE),
     137  HOWTO(R_SPARC_PC10,      0,2,10,TRUE, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_PC10",    FALSE,0,0x000003ff,TRUE),
     138  HOWTO(R_SPARC_PC22,     10,2,22,TRUE, 0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_PC22",    FALSE,0,0x003fffff,TRUE),
     139  HOWTO(R_SPARC_WPLT30,    2,2,30,TRUE, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WPLT30",  FALSE,0,0x3fffffff,TRUE),
     140  HOWTO(R_SPARC_COPY,      0,0,00,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_COPY",    FALSE,0,0x00000000,TRUE),
     141  HOWTO(R_SPARC_GLOB_DAT,  0,0,00,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_GLOB_DAT",FALSE,0,0x00000000,TRUE),
     142  HOWTO(R_SPARC_JMP_SLOT,  0,0,00,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_JMP_SLOT",FALSE,0,0x00000000,TRUE),
     143  HOWTO(R_SPARC_RELATIVE,  0,0,00,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_RELATIVE",FALSE,0,0x00000000,TRUE),
     144  HOWTO(R_SPARC_UA32,      0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_UA32",    FALSE,0,0xffffffff,TRUE),
    125145#ifndef SPARC64_OLD_RELOCS
     146  HOWTO(R_SPARC_PLT32,     0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_PLT32",   FALSE,0,0xffffffff,TRUE),
    126147  /* These aren't implemented yet.  */
    127   HOWTO(R_SPARC_PLT32,     0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_PLT32",    false,0,0x00000000,true),
    128   HOWTO(R_SPARC_HIPLT22,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_HIPLT22",  false,0,0x00000000,true),
    129   HOWTO(R_SPARC_LOPLT10,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_LOPLT10",  false,0,0x00000000,true),
    130   HOWTO(R_SPARC_PCPLT32,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_PCPLT32",  false,0,0x00000000,true),
    131   HOWTO(R_SPARC_PCPLT22,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_PCPLT22",  false,0,0x00000000,true),
    132   HOWTO(R_SPARC_PCPLT10,   0,0,00,false,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_PCPLT10",  false,0,0x00000000,true),
     148  HOWTO(R_SPARC_HIPLT22,   0,0,00,FALSE,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_HIPLT22",  FALSE,0,0x00000000,TRUE),
     149  HOWTO(R_SPARC_LOPLT10,   0,0,00,FALSE,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_LOPLT10",  FALSE,0,0x00000000,TRUE),
     150  HOWTO(R_SPARC_PCPLT32,   0,0,00,FALSE,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_PCPLT32",  FALSE,0,0x00000000,TRUE),
     151  HOWTO(R_SPARC_PCPLT22,   0,0,00,FALSE,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_PCPLT22",  FALSE,0,0x00000000,TRUE),
     152  HOWTO(R_SPARC_PCPLT10,   0,0,00,FALSE,0,complain_overflow_dont,    sparc_elf_notsup_reloc, "R_SPARC_PCPLT10",  FALSE,0,0x00000000,TRUE),
    133153#endif
    134   HOWTO(R_SPARC_10,        0,2,10,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_10",      false,0,0x000003ff,true),
    135   HOWTO(R_SPARC_11,        0,2,11,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_11",      false,0,0x000007ff,true),
    136   HOWTO(R_SPARC_64,        0,4,64,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_64",      false,0,MINUS_ONE, true),
    137   HOWTO(R_SPARC_OLO10,     0,2,13,false,0,complain_overflow_signed,  sparc_elf_notsup_reloc, "R_SPARC_OLO10",   false,0,0x00001fff,true),
    138   HOWTO(R_SPARC_HH22,     42,2,22,false,0,complain_overflow_unsigned,bfd_elf_generic_reloc,  "R_SPARC_HH22",    false,0,0x003fffff,true),
    139   HOWTO(R_SPARC_HM10,     32,2,10,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_HM10",    false,0,0x000003ff,true),
    140   HOWTO(R_SPARC_LM22,     10,2,22,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_LM22",    false,0,0x003fffff,true),
    141   HOWTO(R_SPARC_PC_HH22,  42,2,22,true, 0,complain_overflow_unsigned,bfd_elf_generic_reloc,  "R_SPARC_PC_HH22",    false,0,0x003fffff,true),
    142   HOWTO(R_SPARC_PC_HM10,  32,2,10,true, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_PC_HM10",    false,0,0x000003ff,true),
    143   HOWTO(R_SPARC_PC_LM22,  10,2,22,true, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_PC_LM22",    false,0,0x003fffff,true),
    144   HOWTO(R_SPARC_WDISP16,   2,2,16,true, 0,complain_overflow_signed,  sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", false,0,0x00000000,true),
    145   HOWTO(R_SPARC_WDISP19,   2,2,19,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WDISP19", false,0,0x0007ffff,true),
    146   HOWTO(R_SPARC_UNUSED_42, 0,0, 0,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_UNUSED_42",false,0,0x00000000,true),
    147   HOWTO(R_SPARC_7,         0,2, 7,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_7",       false,0,0x0000007f,true),
    148   HOWTO(R_SPARC_5,         0,2, 5,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_5",       false,0,0x0000001f,true),
    149   HOWTO(R_SPARC_6,         0,2, 6,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_6",       false,0,0x0000003f,true),
    150   HOWTO(R_SPARC_DISP64,    0,4,64,true, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP64",  false,0,MINUS_ONE, true),
    151   HOWTO(R_SPARC_PLT64,     0,4,64,false,0,complain_overflow_bitfield,sparc_elf_notsup_reloc, "R_SPARC_PLT64",   false,0,MINUS_ONE, false),
    152   HOWTO(R_SPARC_HIX22,     0,4, 0,false,0,complain_overflow_bitfield,sparc_elf_hix22_reloc,  "R_SPARC_HIX22",   false,0,MINUS_ONE, false),
    153   HOWTO(R_SPARC_LOX10,     0,4, 0,false,0,complain_overflow_dont,    sparc_elf_lox10_reloc,  "R_SPARC_LOX10",   false,0,MINUS_ONE, false),
    154   HOWTO(R_SPARC_H44,      22,2,22,false,0,complain_overflow_unsigned,bfd_elf_generic_reloc,  "R_SPARC_H44",     false,0,0x003fffff,false),
    155   HOWTO(R_SPARC_M44,      12,2,10,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_M44",     false,0,0x000003ff,false),
    156   HOWTO(R_SPARC_L44,       0,2,13,false,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_L44",     false,0,0x00000fff,false),
    157   HOWTO(R_SPARC_REGISTER,  0,4, 0,false,0,complain_overflow_bitfield,sparc_elf_notsup_reloc, "R_SPARC_REGISTER",false,0,MINUS_ONE, false),
    158   HOWTO(R_SPARC_UA64,        0,4,64,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_UA64",      false,0,MINUS_ONE, true),
    159   HOWTO(R_SPARC_UA16,        0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_UA16",      false,0,0x0000ffff,true)
     154  HOWTO(R_SPARC_10,        0,2,10,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_10",      FALSE,0,0x000003ff,TRUE),
     155  HOWTO(R_SPARC_11,        0,2,11,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_11",      FALSE,0,0x000007ff,TRUE),
     156  HOWTO(R_SPARC_64,        0,4,64,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_64",      FALSE,0,MINUS_ONE, TRUE),
     157  HOWTO(R_SPARC_OLO10,     0,2,13,FALSE,0,complain_overflow_signed,  sparc_elf_notsup_reloc, "R_SPARC_OLO10",   FALSE,0,0x00001fff,TRUE),
     158  HOWTO(R_SPARC_HH22,     42,2,22,FALSE,0,complain_overflow_unsigned,bfd_elf_generic_reloc,  "R_SPARC_HH22",    FALSE,0,0x003fffff,TRUE),
     159  HOWTO(R_SPARC_HM10,     32,2,10,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_HM10",    FALSE,0,0x000003ff,TRUE),
     160  HOWTO(R_SPARC_LM22,     10,2,22,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_LM22",    FALSE,0,0x003fffff,TRUE),
     161  HOWTO(R_SPARC_PC_HH22,  42,2,22,TRUE, 0,complain_overflow_unsigned,bfd_elf_generic_reloc,  "R_SPARC_PC_HH22",    FALSE,0,0x003fffff,TRUE),
     162  HOWTO(R_SPARC_PC_HM10,  32,2,10,TRUE, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_PC_HM10",    FALSE,0,0x000003ff,TRUE),
     163  HOWTO(R_SPARC_PC_LM22,  10,2,22,TRUE, 0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_PC_LM22",    FALSE,0,0x003fffff,TRUE),
     164  HOWTO(R_SPARC_WDISP16,   2,2,16,TRUE, 0,complain_overflow_signed,  sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", FALSE,0,0x00000000,TRUE),
     165  HOWTO(R_SPARC_WDISP19,   2,2,19,TRUE, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_WDISP19", FALSE,0,0x0007ffff,TRUE),
     166  HOWTO(R_SPARC_UNUSED_42, 0,0, 0,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_UNUSED_42",FALSE,0,0x00000000,TRUE),
     167  HOWTO(R_SPARC_7,         0,2, 7,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_7",       FALSE,0,0x0000007f,TRUE),
     168  HOWTO(R_SPARC_5,         0,2, 5,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_5",       FALSE,0,0x0000001f,TRUE),
     169  HOWTO(R_SPARC_6,         0,2, 6,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_6",       FALSE,0,0x0000003f,TRUE),
     170  HOWTO(R_SPARC_DISP64,    0,4,64,TRUE, 0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_DISP64",  FALSE,0,MINUS_ONE, TRUE),
     171  HOWTO(R_SPARC_PLT64,     0,4,64,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_PLT64",   FALSE,0,MINUS_ONE, TRUE),
     172  HOWTO(R_SPARC_HIX22,     0,4, 0,FALSE,0,complain_overflow_bitfield,sparc_elf_hix22_reloc,  "R_SPARC_HIX22",   FALSE,0,MINUS_ONE, FALSE),
     173  HOWTO(R_SPARC_LOX10,     0,4, 0,FALSE,0,complain_overflow_dont,    sparc_elf_lox10_reloc,  "R_SPARC_LOX10",   FALSE,0,MINUS_ONE, FALSE),
     174  HOWTO(R_SPARC_H44,      22,2,22,FALSE,0,complain_overflow_unsigned,bfd_elf_generic_reloc,  "R_SPARC_H44",     FALSE,0,0x003fffff,FALSE),
     175  HOWTO(R_SPARC_M44,      12,2,10,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_M44",     FALSE,0,0x000003ff,FALSE),
     176  HOWTO(R_SPARC_L44,       0,2,13,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_L44",     FALSE,0,0x00000fff,FALSE),
     177  HOWTO(R_SPARC_REGISTER,  0,4, 0,FALSE,0,complain_overflow_bitfield,sparc_elf_notsup_reloc, "R_SPARC_REGISTER",FALSE,0,MINUS_ONE, FALSE),
     178  HOWTO(R_SPARC_UA64,        0,4,64,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_UA64",      FALSE,0,MINUS_ONE, TRUE),
     179  HOWTO(R_SPARC_UA16,        0,1,16,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,  "R_SPARC_UA16",      FALSE,0,0x0000ffff,TRUE),
     180  HOWTO(R_SPARC_TLS_GD_HI22,10,2,22,FALSE,0,complain_overflow_dont,  bfd_elf_generic_reloc,  "R_SPARC_TLS_GD_HI22",FALSE,0,0x003fffff,TRUE),
     181  HOWTO(R_SPARC_TLS_GD_LO10,0,2,10,FALSE,0,complain_overflow_dont,   bfd_elf_generic_reloc,  "R_SPARC_TLS_GD_LO10",FALSE,0,0x000003ff,TRUE),
     182  HOWTO(R_SPARC_TLS_GD_ADD,0,0, 0,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_TLS_GD_ADD",FALSE,0,0x00000000,TRUE),
     183  HOWTO(R_SPARC_TLS_GD_CALL,2,2,30,TRUE,0,complain_overflow_signed,  bfd_elf_generic_reloc,  "R_SPARC_TLS_GD_CALL",FALSE,0,0x3fffffff,TRUE),
     184  HOWTO(R_SPARC_TLS_LDM_HI22,10,2,22,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc,  "R_SPARC_TLS_LDM_HI22",FALSE,0,0x003fffff,TRUE),
     185  HOWTO(R_SPARC_TLS_LDM_LO10,0,2,10,FALSE,0,complain_overflow_dont,  bfd_elf_generic_reloc,  "R_SPARC_TLS_LDM_LO10",FALSE,0,0x000003ff,TRUE),
     186  HOWTO(R_SPARC_TLS_LDM_ADD,0,0, 0,FALSE,0,complain_overflow_dont,   bfd_elf_generic_reloc,  "R_SPARC_TLS_LDM_ADD",FALSE,0,0x00000000,TRUE),
     187  HOWTO(R_SPARC_TLS_LDM_CALL,2,2,30,TRUE,0,complain_overflow_signed, bfd_elf_generic_reloc,  "R_SPARC_TLS_LDM_CALL",FALSE,0,0x3fffffff,TRUE),
     188  HOWTO(R_SPARC_TLS_LDO_HIX22,0,2,0,FALSE,0,complain_overflow_bitfield,sparc_elf_hix22_reloc,"R_SPARC_TLS_LDO_HIX22",FALSE,0,0x003fffff, FALSE),
     189  HOWTO(R_SPARC_TLS_LDO_LOX10,0,2,0,FALSE,0,complain_overflow_dont,  sparc_elf_lox10_reloc,  "R_SPARC_TLS_LDO_LOX10",FALSE,0,0x000003ff, FALSE),
     190  HOWTO(R_SPARC_TLS_LDO_ADD,0,0, 0,FALSE,0,complain_overflow_dont,   bfd_elf_generic_reloc,  "R_SPARC_TLS_LDO_ADD",FALSE,0,0x00000000,TRUE),
     191  HOWTO(R_SPARC_TLS_IE_HI22,10,2,22,FALSE,0,complain_overflow_dont,  bfd_elf_generic_reloc,  "R_SPARC_TLS_IE_HI22",FALSE,0,0x003fffff,TRUE),
     192  HOWTO(R_SPARC_TLS_IE_LO10,0,2,10,FALSE,0,complain_overflow_dont,   bfd_elf_generic_reloc,  "R_SPARC_TLS_IE_LO10",FALSE,0,0x000003ff,TRUE),
     193  HOWTO(R_SPARC_TLS_IE_LD,0,0, 0,FALSE,0,complain_overflow_dont,     bfd_elf_generic_reloc,  "R_SPARC_TLS_IE_LD",FALSE,0,0x00000000,TRUE),
     194  HOWTO(R_SPARC_TLS_IE_LDX,0,0, 0,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_TLS_IE_LDX",FALSE,0,0x00000000,TRUE),
     195  HOWTO(R_SPARC_TLS_IE_ADD,0,0, 0,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_TLS_IE_ADD",FALSE,0,0x00000000,TRUE),
     196  HOWTO(R_SPARC_TLS_LE_HIX22,0,2,0,FALSE,0,complain_overflow_bitfield,sparc_elf_hix22_reloc, "R_SPARC_TLS_LE_HIX22",FALSE,0,0x003fffff, FALSE),
     197  HOWTO(R_SPARC_TLS_LE_LOX10,0,2,0,FALSE,0,complain_overflow_dont,   sparc_elf_lox10_reloc,  "R_SPARC_TLS_LE_LOX10",FALSE,0,0x000003ff, FALSE),
     198  HOWTO(R_SPARC_TLS_DTPMOD32,0,0, 0,FALSE,0,complain_overflow_dont,  bfd_elf_generic_reloc,  "R_SPARC_TLS_DTPMOD32",FALSE,0,0x00000000,TRUE),
     199  HOWTO(R_SPARC_TLS_DTPMOD64,0,0, 0,FALSE,0,complain_overflow_dont,  bfd_elf_generic_reloc,  "R_SPARC_TLS_DTPMOD64",FALSE,0,0x00000000,TRUE),
     200  HOWTO(R_SPARC_TLS_DTPOFF32,0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_TLS_DTPOFF32",FALSE,0,0xffffffff,TRUE),
     201  HOWTO(R_SPARC_TLS_DTPOFF64,0,4,64,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_TLS_DTPOFF64",FALSE,0,MINUS_ONE,TRUE),
     202  HOWTO(R_SPARC_TLS_TPOFF32,0,0, 0,FALSE,0,complain_overflow_dont,   bfd_elf_generic_reloc,  "R_SPARC_TLS_TPOFF32",FALSE,0,0x00000000,TRUE),
     203  HOWTO(R_SPARC_TLS_TPOFF64,0,0, 0,FALSE,0,complain_overflow_dont,   bfd_elf_generic_reloc,  "R_SPARC_TLS_TPOFF64",FALSE,0,0x00000000,TRUE)
    160204};
    161205
     
    165209};
    166210
    167 static CONST struct elf_reloc_map sparc_reloc_map[] =
     211static const struct elf_reloc_map sparc_reloc_map[] =
    168212{
    169213  { BFD_RELOC_NONE, R_SPARC_NONE, },
    170214  { BFD_RELOC_16, R_SPARC_16, },
     215  { BFD_RELOC_16_PCREL, R_SPARC_DISP16 },
    171216  { BFD_RELOC_8, R_SPARC_8 },
    172217  { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
     
    177222  { BFD_RELOC_LO10, R_SPARC_LO10, },
    178223  { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
     224  { BFD_RELOC_64_PCREL, R_SPARC_DISP64 },
    179225  { BFD_RELOC_SPARC22, R_SPARC_22 },
    180226  { BFD_RELOC_SPARC13, R_SPARC_13 },
     
    209255  { BFD_RELOC_SPARC_6, R_SPARC_6 },
    210256  { BFD_RELOC_SPARC_DISP64, R_SPARC_DISP64 },
     257  { BFD_RELOC_SPARC_TLS_GD_HI22, R_SPARC_TLS_GD_HI22 },
     258  { BFD_RELOC_SPARC_TLS_GD_LO10, R_SPARC_TLS_GD_LO10 },
     259  { BFD_RELOC_SPARC_TLS_GD_ADD, R_SPARC_TLS_GD_ADD },
     260  { BFD_RELOC_SPARC_TLS_GD_CALL, R_SPARC_TLS_GD_CALL },
     261  { BFD_RELOC_SPARC_TLS_LDM_HI22, R_SPARC_TLS_LDM_HI22 },
     262  { BFD_RELOC_SPARC_TLS_LDM_LO10, R_SPARC_TLS_LDM_LO10 },
     263  { BFD_RELOC_SPARC_TLS_LDM_ADD, R_SPARC_TLS_LDM_ADD },
     264  { BFD_RELOC_SPARC_TLS_LDM_CALL, R_SPARC_TLS_LDM_CALL },
     265  { BFD_RELOC_SPARC_TLS_LDO_HIX22, R_SPARC_TLS_LDO_HIX22 },
     266  { BFD_RELOC_SPARC_TLS_LDO_LOX10, R_SPARC_TLS_LDO_LOX10 },
     267  { BFD_RELOC_SPARC_TLS_LDO_ADD, R_SPARC_TLS_LDO_ADD },
     268  { BFD_RELOC_SPARC_TLS_IE_HI22, R_SPARC_TLS_IE_HI22 },
     269  { BFD_RELOC_SPARC_TLS_IE_LO10, R_SPARC_TLS_IE_LO10 },
     270  { BFD_RELOC_SPARC_TLS_IE_LD, R_SPARC_TLS_IE_LD },
     271  { BFD_RELOC_SPARC_TLS_IE_LDX, R_SPARC_TLS_IE_LDX },
     272  { BFD_RELOC_SPARC_TLS_IE_ADD, R_SPARC_TLS_IE_ADD },
     273  { BFD_RELOC_SPARC_TLS_LE_HIX22, R_SPARC_TLS_LE_HIX22 },
     274  { BFD_RELOC_SPARC_TLS_LE_LOX10, R_SPARC_TLS_LE_LOX10 },
     275  { BFD_RELOC_SPARC_TLS_DTPMOD32, R_SPARC_TLS_DTPMOD32 },
     276  { BFD_RELOC_SPARC_TLS_DTPMOD64, R_SPARC_TLS_DTPMOD64 },
     277  { BFD_RELOC_SPARC_TLS_DTPOFF32, R_SPARC_TLS_DTPOFF32 },
     278  { BFD_RELOC_SPARC_TLS_DTPOFF64, R_SPARC_TLS_DTPOFF64 },
     279  { BFD_RELOC_SPARC_TLS_TPOFF32, R_SPARC_TLS_TPOFF32 },
     280  { BFD_RELOC_SPARC_TLS_TPOFF64, R_SPARC_TLS_TPOFF64 },
     281#ifndef SPARC64_OLD_RELOCS
     282  { BFD_RELOC_SPARC_PLT32, R_SPARC_PLT32 },
     283#endif
    211284  { BFD_RELOC_SPARC_PLT64, R_SPARC_PLT64 },
    212285  { BFD_RELOC_SPARC_HIX22, R_SPARC_HIX22 },
     
    236309     bfd *abfd ATTRIBUTE_UNUSED;
    237310     arelent *cache_ptr;
    238      Elf64_Internal_Rela *dst;
     311     Elf_Internal_Rela *dst;
    239312{
    240313  BFD_ASSERT (ELF64_R_TYPE_ID (dst->r_info) < (unsigned int) R_SPARC_max_std);
     
    242315}
    243316
     317
     318struct sparc64_elf_section_data
     319{
     320  struct bfd_elf_section_data elf;
     321  unsigned int do_relax, reloc_count;
     322};
     323
     324#define sec_do_relax(sec) \
     325  ((struct sparc64_elf_section_data *) elf_section_data (sec))->do_relax
     326#define canon_reloc_count(sec) \
     327  ((struct sparc64_elf_section_data *) elf_section_data (sec))->reloc_count
    244328
    245329/* Due to the way how we handle R_SPARC_OLO10, each entry in a SHT_RELA
     
    267351   for the same location,  R_SPARC_LO10 and R_SPARC_13.  */
    268352
    269 static boolean
     353static bfd_boolean
    270354sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr, symbols, dynamic)
    271355     bfd *abfd;
     
    273357     Elf_Internal_Shdr *rel_hdr;
    274358     asymbol **symbols;
    275      boolean dynamic;
     359     bfd_boolean dynamic;
    276360{
    277361  PTR allocated = NULL;
     
    283367  arelent *relents;
    284368
    285   allocated = (PTR) bfd_malloc ((size_t) rel_hdr->sh_size);
     369  allocated = (PTR) bfd_malloc (rel_hdr->sh_size);
    286370  if (allocated == NULL)
    287371    goto error_return;
    288372
    289373  if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0
    290       || (bfd_read (allocated, 1, rel_hdr->sh_size, abfd)
    291           != rel_hdr->sh_size))
     374      || bfd_bread (allocated, rel_hdr->sh_size, abfd) != rel_hdr->sh_size)
    292375    goto error_return;
    293376
    294377  native_relocs = (bfd_byte *) allocated;
    295378
    296   relents = asect->relocation + asect->reloc_count;
     379  relents = asect->relocation + canon_reloc_count (asect);
    297380
    298381  entsize = rel_hdr->sh_entsize;
     
    306389      Elf_Internal_Rela rela;
    307390
    308       bfd_elf64_swap_reloca_in (abfd, (Elf64_External_Rela *) native_relocs, &rela);
     391      bfd_elf64_swap_reloca_in (abfd, native_relocs, &rela);
    309392
    310393      /* The address of an ELF reloc is section relative for an object
     
    349432    }
    350433
    351   asect->reloc_count += relent - relents;
     434  canon_reloc_count (asect) += relent - relents;
    352435
    353436  if (allocated != NULL)
    354437    free (allocated);
    355438
    356   return true;
     439  return TRUE;
    357440
    358441 error_return:
    359442  if (allocated != NULL)
    360443    free (allocated);
    361   return false;
     444  return FALSE;
    362445}
    363446
    364447/* Read in and swap the external relocs.  */
    365448
    366 static boolean
     449static bfd_boolean
    367450sparc64_elf_slurp_reloc_table (abfd, asect, symbols, dynamic)
    368451     bfd *abfd;
    369452     asection *asect;
    370453     asymbol **symbols;
    371      boolean dynamic;
     454     bfd_boolean dynamic;
    372455{
    373456  struct bfd_elf_section_data * const d = elf_section_data (asect);
    374457  Elf_Internal_Shdr *rel_hdr;
    375458  Elf_Internal_Shdr *rel_hdr2;
     459  bfd_size_type amt;
    376460
    377461  if (asect->relocation != NULL)
    378     return true;
     462    return TRUE;
    379463
    380464  if (! dynamic)
     
    382466      if ((asect->flags & SEC_RELOC) == 0
    383467          || asect->reloc_count == 0)
    384         return true;
     468        return TRUE;
    385469
    386470      rel_hdr = &d->rel_hdr;
     
    397481         in elf.c does not update the RELOC_COUNT.  */
    398482      if (asect->_raw_size == 0)
    399         return true;
     483        return TRUE;
    400484
    401485      rel_hdr = &d->this_hdr;
     
    404488    }
    405489
    406   asect->relocation = ((arelent *)
    407                        bfd_alloc (abfd,
    408                                   asect->reloc_count * 2 * sizeof (arelent)));
     490  amt = asect->reloc_count;
     491  amt *= 2 * sizeof (arelent);
     492  asect->relocation = (arelent *) bfd_alloc (abfd, amt);
    409493  if (asect->relocation == NULL)
    410     return false;
    411 
    412   /* The sparc64_elf_slurp_one_reloc_table routine increments reloc_count.  */
    413   asect->reloc_count = 0;
     494    return FALSE;
     495
     496  /* The sparc64_elf_slurp_one_reloc_table routine increments
     497     canon_reloc_count.  */
     498  canon_reloc_count (asect) = 0;
    414499
    415500  if (!sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr, symbols,
    416501                                          dynamic))
    417     return false;
     502    return FALSE;
    418503
    419504  if (rel_hdr2
    420505      && !sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr2, symbols,
    421506                                             dynamic))
    422     return false;
    423 
    424   return true;
    425 }
     507    return FALSE;
     508
     509  return TRUE;
     510}
     511
     512/* Canonicalize the relocs.  */
     513
     514static long
     515sparc64_elf_canonicalize_reloc (abfd, section, relptr, symbols)
     516     bfd *abfd;
     517     sec_ptr section;
     518     arelent **relptr;
     519     asymbol **symbols;
     520{
     521  arelent *tblptr;
     522  unsigned int i;
     523  struct elf_backend_data *bed = get_elf_backend_data (abfd);
     524
     525  if (! bed->s->slurp_reloc_table (abfd, section, symbols, FALSE))
     526    return -1;
     527
     528  tblptr = section->relocation;
     529  for (i = 0; i < canon_reloc_count (section); i++)
     530    *relptr++ = tblptr++;
     531
     532  *relptr = NULL;
     533
     534  return canon_reloc_count (section);
     535}
     536
    426537
    427538/* Canonicalize the dynamic relocation entries.  Note that we return
     
    458569          long count, i;
    459570
    460           if (! sparc64_elf_slurp_reloc_table (abfd, s, syms, true))
     571          if (! sparc64_elf_slurp_reloc_table (abfd, s, syms, TRUE))
    461572            return -1;
    462           count = s->reloc_count;
     573          count = canon_reloc_count (s);
    463574          p = s->relocation;
    464575          for (i = 0; i < count; i++)
     
    481592     PTR data;
    482593{
    483   boolean *failedp = (boolean *) data;
     594  bfd_boolean *failedp = (bfd_boolean *) data;
    484595  Elf_Internal_Shdr *rela_hdr;
    485596  Elf64_External_Rela *outbound_relocas, *src_rela;
     
    532643  if (rela_hdr->contents == NULL)
    533644    {
    534       *failedp = true;
     645      *failedp = TRUE;
    535646      return;
    536647    }
     
    572683          if (n < 0)
    573684            {
    574               *failedp = true;
     685              *failedp = TRUE;
    575686              return;
    576687            }
     
    582693          && ! _bfd_elf_validate_reloc (abfd, ptr))
    583694        {
    584           *failedp = true;
     695          *failedp = TRUE;
    585696          return;
    586697        }
     
    608719
    609720      dst_rela.r_addend = ptr->addend;
    610       bfd_elf64_swap_reloca_out (abfd, &dst_rela, src_rela);
     721      bfd_elf64_swap_reloca_out (abfd, &dst_rela, (bfd_byte *) src_rela);
    611722      ++src_rela;
    612723    }
     
    643754{
    644755  struct sparc64_elf_link_hash_table *ret;
    645 
    646   ret = ((struct sparc64_elf_link_hash_table *)
    647          bfd_zalloc (abfd, sizeof (struct sparc64_elf_link_hash_table)));
     756  bfd_size_type amt = sizeof (struct sparc64_elf_link_hash_table);
     757
     758  ret = (struct sparc64_elf_link_hash_table *) bfd_zmalloc (amt);
    648759  if (ret == (struct sparc64_elf_link_hash_table *) NULL)
    649760    return NULL;
     
    652763                                       _bfd_elf_link_hash_newfunc))
    653764    {
    654       bfd_release (abfd, ret);
     765      free (ret);
    655766      return NULL;
    656767    }
     
    698809    }
    699810
    700   /* This works because partial_inplace == false.  */
     811  /* This works because partial_inplace is FALSE.  */
    701812  if (output_bfd != NULL)
    702813    return bfd_reloc_continue;
     
    764875    return status;
    765876
    766   insn = (insn & ~0x303fff) | ((((relocation >> 2) & 0xc000) << 6)
    767                                | ((relocation >> 2) & 0x3fff));
     877  insn &= ~ (bfd_vma) 0x303fff;
     878  insn |= (((relocation >> 2) & 0xc000) << 6) | ((relocation >> 2) & 0x3fff);
    768879  bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
    769880
     
    803914
    804915  relocation ^= MINUS_ONE;
    805   insn = (insn & ~0x3fffff) | ((relocation >> 10) & 0x3fffff);
     916  insn = (insn &~ (bfd_vma) 0x3fffff) | ((relocation >> 10) & 0x3fffff);
    806917  bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
    807918
     
    839950    return status;
    840951
    841   insn = (insn & ~0x1fff) | 0x1c00 | (relocation & 0x3ff);
     952  insn = (insn &~ (bfd_vma) 0x1fff) | 0x1c00 | (relocation & 0x3ff);
    842953  bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
    843954
     
    871982
    872983  for (i = 0; i < PLT_HEADER_SIZE/4; ++i)
    873     bfd_put_32 (output_bfd, 0, contents+i*4);
     984    bfd_put_32 (output_bfd, (bfd_vma) 0, contents+i*4);
    874985
    875986  /* The first 32768 entries are close enough to plt1 to get there via
     
    887998      ba = 0x30680000 | (((contents+PLT_ENTRY_SIZE) - (entry+4)) / 4 & 0x7ffff);
    888999
    889       bfd_put_32 (output_bfd, sethi, entry);
    890       bfd_put_32 (output_bfd, ba, entry+4);
    891       bfd_put_32 (output_bfd, nop, entry+8);
    892       bfd_put_32 (output_bfd, nop, entry+12);
    893       bfd_put_32 (output_bfd, nop, entry+16);
    894       bfd_put_32 (output_bfd, nop, entry+20);
    895       bfd_put_32 (output_bfd, nop, entry+24);
    896       bfd_put_32 (output_bfd, nop, entry+28);
     1000      bfd_put_32 (output_bfd, (bfd_vma) sethi, entry);
     1001      bfd_put_32 (output_bfd, (bfd_vma) ba,    entry + 4);
     1002      bfd_put_32 (output_bfd, (bfd_vma) nop,   entry + 8);
     1003      bfd_put_32 (output_bfd, (bfd_vma) nop,   entry + 12);
     1004      bfd_put_32 (output_bfd, (bfd_vma) nop,   entry + 16);
     1005      bfd_put_32 (output_bfd, (bfd_vma) nop,   entry + 20);
     1006      bfd_put_32 (output_bfd, (bfd_vma) nop,   entry + 24);
     1007      bfd_put_32 (output_bfd, (bfd_vma) nop,   entry + 28);
    8971008    }
    8981009
     
    9121023          ptr = contents + i*PLT_ENTRY_SIZE + block*4*6 + j*8;
    9131024
    914           /* ldx [%o7 + ptr - entry+4], %g1 */
    915           ldx = 0xc25be000 | ((ptr - entry+4) & 0x1fff);
    916 
    917           bfd_put_32 (output_bfd, 0x8a10000f, entry);    /* mov %o7,%g5 */
    918           bfd_put_32 (output_bfd, 0x40000002, entry+4);  /* call .+8 */
    919           bfd_put_32 (output_bfd, nop, entry+8);         /* nop */
    920           bfd_put_32 (output_bfd, ldx, entry+12);        /* ldx [%o7+P],%g1 */
    921           bfd_put_32 (output_bfd, 0x83c3c001, entry+16); /* jmpl %o7+%g1,%g1 */
    922           bfd_put_32 (output_bfd, 0x9e100005, entry+20); /* mov %g5,%o7 */
    923 
    924           bfd_put_64 (output_bfd, contents - (entry+4), ptr);
     1025          /* ldx [%o7 + ptr - (entry+4)], %g1 */
     1026          ldx = 0xc25be000 | ((ptr - (entry+4)) & 0x1fff);
     1027
     1028          /* mov %o7,%g5
     1029             call .+8
     1030             nop
     1031             ldx [%o7+P],%g1
     1032             jmpl %o7+%g1,%g1
     1033             mov %g5,%o7  */
     1034          bfd_put_32 (output_bfd, (bfd_vma) 0x8a10000f, entry);
     1035          bfd_put_32 (output_bfd, (bfd_vma) 0x40000002, entry + 4);
     1036          bfd_put_32 (output_bfd, (bfd_vma) nop,        entry + 8);
     1037          bfd_put_32 (output_bfd, (bfd_vma) ldx,        entry + 12);
     1038          bfd_put_32 (output_bfd, (bfd_vma) 0x83c3c001, entry + 16);
     1039          bfd_put_32 (output_bfd, (bfd_vma) 0x9e100005, entry + 20);
     1040
     1041          bfd_put_64 (output_bfd, (bfd_vma) (contents - (entry + 4)), ptr);
    9251042        }
    9261043    }
     
    9311048static bfd_vma
    9321049sparc64_elf_plt_entry_offset (index)
    933      int index;
    934 {
    935   int block, ofs;
     1050     bfd_vma index;
     1051{
     1052  bfd_vma block, ofs;
    9361053
    9371054  if (index < LARGE_PLT_THRESHOLD)
     
    9431060  ofs = (index - LARGE_PLT_THRESHOLD) % 160;
    9441061
    945   return ((bfd_vma) (LARGE_PLT_THRESHOLD + block*160) * PLT_ENTRY_SIZE
    946           + ofs * 6*4);
     1062  return (LARGE_PLT_THRESHOLD + block * 160) * PLT_ENTRY_SIZE + ofs * 6 * 4;
    9471063}
    9481064
    9491065static bfd_vma
    9501066sparc64_elf_plt_ptr_offset (index, max)
    951      int index, max;
    952 {
    953   int block, ofs, last;
     1067     bfd_vma index;
     1068     bfd_vma max;
     1069{
     1070  bfd_vma block, ofs, last;
    9541071
    9551072  BFD_ASSERT(index >= LARGE_PLT_THRESHOLD);
     
    9571074  /* See above for details.  */
    9581075
    959   block = (((index - LARGE_PLT_THRESHOLD) / 160) * 160)
    960           + LARGE_PLT_THRESHOLD;
     1076  block = (((index - LARGE_PLT_THRESHOLD) / 160) * 160) + LARGE_PLT_THRESHOLD;
    9611077  ofs = index - block;
    9621078  if (block + 160 > max)
     
    9751091   table.  */
    9761092
    977 static boolean
     1093static bfd_boolean
    9781094sparc64_elf_check_relocs (abfd, info, sec, relocs)
    9791095     bfd *abfd;
     
    9931109
    9941110  if (info->relocateable || !(sec->flags & SEC_ALLOC))
    995     return true;
     1111    return TRUE;
    9961112
    9971113  dynobj = elf_hash_table (info)->dynobj;
     
    10281144              elf_hash_table (info)->dynobj = dynobj = abfd;
    10291145              if (! _bfd_elf_create_got_section (dynobj, info))
    1030                 return false;
     1146                return FALSE;
    10311147            }
    10321148
     
    10521168                                                   | SEC_READONLY))
    10531169                      || ! bfd_set_section_alignment (dynobj, srelgot, 3))
    1054                     return false;
     1170                    return FALSE;
    10551171                }
    10561172            }
     
    10691185                {
    10701186                  if (! bfd_elf64_link_record_dynamic_symbol (info, h))
    1071                     return false;
     1187                    return FALSE;
    10721188                }
    10731189
     
    10801196              if (local_got_offsets == NULL)
    10811197                {
    1082                   size_t size;
     1198                  bfd_size_type size;
    10831199                  register unsigned int i;
    10841200
    1085                   size = symtab_hdr->sh_info * sizeof (bfd_vma);
     1201                  size = symtab_hdr->sh_info;
     1202                  size *= sizeof (bfd_vma);
    10861203                  local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
    10871204                  if (local_got_offsets == NULL)
    1088                     return false;
     1205                    return FALSE;
    10891206                  elf_local_got_offsets (abfd) = local_got_offsets;
    10901207                  for (i = 0; i < symtab_hdr->sh_info; i++)
     
    11441261                 table entry for a local symbol.  */
    11451262              bfd_set_error (bfd_error_bad_value);
    1146               return false;
     1263              return FALSE;
    11471264            }
    11481265
     
    11511268            {
    11521269              if (! bfd_elf64_link_record_dynamic_symbol (info, h))
    1153                 return false;
     1270                return FALSE;
    11541271            }
    11551272
    11561273          h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
    1157           break;
    1158 
     1274          if (ELF64_R_TYPE_ID (rel->r_info) != R_SPARC_PLT32
     1275              && ELF64_R_TYPE_ID (rel->r_info) != R_SPARC_PLT64)
     1276            break;
     1277          /* Fall through.  */
    11591278        case R_SPARC_PC10:
    11601279        case R_SPARC_PC22:
     
    12211340                           elf_section_data (sec)->rel_hdr.sh_name));
    12221341                  if (name == NULL)
    1223                     return false;
     1342                    return FALSE;
    12241343
    12251344                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
     
    12401359                          || ! bfd_set_section_flags (dynobj, sreloc, flags)
    12411360                          || ! bfd_set_section_alignment (dynobj, sreloc, 3))
    1242                         return false;
     1361                        return FALSE;
    12431362                    }
     1363                  if (sec->flags & SEC_READONLY)
     1364                    info->flags |= DF_TEXTREL;
    12441365                }
    12451366
     
    12541375        default:
    12551376          (*_bfd_error_handler) (_("%s: check_relocs: unhandled reloc type %d"),
    1256                                 bfd_get_filename(abfd),
     1377                                bfd_archive_filename (abfd),
    12571378                                ELF64_R_TYPE_ID (rel->r_info));
    1258           return false;
    1259         }
    1260     }
    1261 
    1262   return true;
     1379          return FALSE;
     1380        }
     1381    }
     1382
     1383  return TRUE;
    12631384}
    12641385
     
    12661387   file.  We use it for STT_REGISTER symbols.  */
    12671388
    1268 static boolean
     1389static bfd_boolean
    12691390sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
    12701391     bfd *abfd;
     
    12761397     bfd_vma *valp ATTRIBUTE_UNUSED;
    12771398{
    1278   static char *stt_types[] = { "NOTYPE", "OBJECT", "FUNCTION" };
     1399  static const char *const stt_types[] = { "NOTYPE", "OBJECT", "FUNCTION" };
    12791400
    12801401  if (ELF_ST_TYPE (sym->st_info) == STT_REGISTER)
     
    12911412          (*_bfd_error_handler)
    12921413            (_("%s: Only registers %%g[2367] can be declared using STT_REGISTER"),
    1293              bfd_get_filename (abfd));
    1294           return false;
     1414             bfd_archive_filename (abfd));
     1415          return FALSE;
    12951416        }
    12961417
     
    13021423             the output bfd.  The dynamic linker will recheck it.  */
    13031424          *namep = NULL;
    1304           return true;
     1425          return TRUE;
    13051426        }
    13061427
     
    13101431        {
    13111432          (*_bfd_error_handler)
    1312             (_("Register %%g%d used incompatibly: "
    1313                "previously declared in %s to %s, in %s redefined to %s"),
    1314              (int)sym->st_value,
    1315              bfd_get_filename (p->abfd), *p->name ? p->name : "#scratch",
    1316              bfd_get_filename (abfd), **namep ? *namep : "#scratch");
    1317           return false;
     1433            (_("Register %%g%d used incompatibly: %s in %s, previously %s in %s"),
     1434             (int) sym->st_value,
     1435             **namep ? *namep : "#scratch", bfd_archive_filename (abfd),
     1436             *p->name ? p->name : "#scratch", bfd_archive_filename (p->abfd));
     1437          return FALSE;
    13181438        }
    13191439
     
    13251445
    13261446              h = (struct elf_link_hash_entry *)
    1327                 bfd_link_hash_lookup (info->hash, *namep, false, false, false);
     1447                bfd_link_hash_lookup (info->hash, *namep, FALSE, FALSE, FALSE);
    13281448
    13291449              if (h != NULL)
     
    13311451                  unsigned char type = h->type;
    13321452
    1333                   if (type > STT_FUNC) type = 0;
     1453                  if (type > STT_FUNC)
     1454                    type = 0;
    13341455                  (*_bfd_error_handler)
    1335                     (_("Symbol `%s' has differing types: "
    1336                        "previously %s, REGISTER in %s"),
    1337                      *namep, stt_types [type], bfd_get_filename (abfd));
    1338                   return false;
     1456                    (_("Symbol `%s' has differing types: REGISTER in %s, previously %s in %s"),
     1457                     *namep, bfd_archive_filename (abfd),
     1458                     stt_types[type], bfd_archive_filename (p->abfd));
     1459                  return FALSE;
    13391460                }
    13401461
     
    13421463                                           strlen (*namep) + 1);
    13431464              if (!p->name)
    1344                 return false;
     1465                return FALSE;
    13451466
    13461467              strcpy (p->name, *namep);
     
    13621483        }
    13631484      *namep = NULL;
    1364       return true;
    1365     }
    1366   else if (! *namep || ! **namep)
    1367     return true;
    1368   else
     1485      return TRUE;
     1486    }
     1487  else if (*namep && **namep
     1488           && info->hash->creator == abfd->xvec)
    13691489    {
    13701490      int i;
     
    13771497            unsigned char type = ELF_ST_TYPE (sym->st_info);
    13781498
    1379             if (type > STT_FUNC) type = 0;
     1499            if (type > STT_FUNC)
     1500              type = 0;
    13801501            (*_bfd_error_handler)
    1381               (_("Symbol `%s' has differing types: "
    1382                  "REGISTER in %s, %s in %s"),
    1383                *namep, bfd_get_filename (p->abfd), stt_types [type],
    1384                bfd_get_filename (abfd));
    1385             return false;
     1502              (_("Symbol `%s' has differing types: %s in %s, previously REGISTER in %s"),
     1503               *namep, stt_types[type], bfd_archive_filename (abfd),
     1504               bfd_archive_filename (p->abfd));
     1505            return FALSE;
    13861506          }
    13871507    }
    1388   return true;
     1508  return TRUE;
    13891509}
    13901510
     
    13921512   which we cannot easily keep in the symbol hash table.  */
    13931513
    1394 static boolean
     1514static bfd_boolean
    13951515sparc64_elf_output_arch_syms (output_bfd, info, finfo, func)
    13961516     bfd *output_bfd ATTRIBUTE_UNUSED;
    13971517     struct bfd_link_info *info;
    13981518     PTR finfo;
    1399      boolean (*func) PARAMS ((PTR, const char *,
    1400                               Elf_Internal_Sym *, asection *));
     1519     bfd_boolean (*func)
     1520       PARAMS ((PTR, const char *, Elf_Internal_Sym *, asection *));
    14011521{
    14021522  int reg;
     
    14261546
    14271547  if (info->strip == strip_all)
    1428     return true;
     1548    return TRUE;
    14291549
    14301550  for (reg = 0; reg < 4; reg++)
     
    14341554            && bfd_hash_lookup (info->keep_hash,
    14351555                                app_regs [reg].name,
    1436                                 false, false) == NULL)
     1556                                FALSE, FALSE) == NULL)
    14371557          continue;
    14381558
     
    14451565                       sym.st_shndx == SHN_ABS
    14461566                         ? bfd_abs_section_ptr : bfd_und_section_ptr))
    1447           return false;
     1567          return FALSE;
    14481568      }
    14491569
    1450   return true;
     1570  return TRUE;
    14511571}
    14521572
     
    14861606   understand.  */
    14871607
    1488 static boolean
     1608static bfd_boolean
    14891609sparc64_elf_adjust_dynamic_symbol (info, h)
    14901610     struct bfd_link_info *info;
     
    15301650             reloc instead.  */
    15311651          BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
    1532           return true;
     1652          return TRUE;
    15331653        }
    15341654
     
    15391659      if (s->_raw_size == 0)
    15401660        s->_raw_size = PLT_HEADER_SIZE;
     1661
     1662      /* To simplify matters later, just store the plt index here.  */
     1663      h->plt.offset = s->_raw_size / PLT_ENTRY_SIZE;
    15411664
    15421665      /* If this symbol is not defined in a regular file, and we are
     
    15491672        {
    15501673          h->root.u.def.section = s;
    1551           h->root.u.def.value = s->_raw_size;
    1552         }
    1553 
    1554       /* To simplify matters later, just store the plt index here.  */
    1555       h->plt.offset = s->_raw_size / PLT_ENTRY_SIZE;
     1674          h->root.u.def.value = sparc64_elf_plt_entry_offset (h->plt.offset);
     1675        }
    15561676
    15571677      /* Make room for this entry.  */
     
    15701690        {
    15711691          bfd_set_error (bfd_error_bad_value);
    1572           return false;
    1573         }
    1574 
    1575       return true;
     1692          return FALSE;
     1693        }
     1694
     1695      return TRUE;
    15761696    }
    15771697
     
    15851705      h->root.u.def.section = h->weakdef->root.u.def.section;
    15861706      h->root.u.def.value = h->weakdef->root.u.def.value;
    1587       return true;
     1707      return TRUE;
    15881708    }
    15891709
     
    15961716     be handled correctly by relocate_section.  */
    15971717  if (info->shared)
    1598     return true;
     1718    return TRUE;
    15991719
    16001720  /* We must allocate the symbol in our .dynbss section, which will
     
    16381758    {
    16391759      if (! bfd_set_section_alignment (dynobj, s, power_of_two))
    1640         return false;
     1760        return FALSE;
    16411761    }
    16421762
     
    16481768  s->_raw_size += h->size;
    16491769
    1650   return true;
     1770  return TRUE;
    16511771}
    16521772
    16531773/* Set the sizes of the dynamic sections.  */
    16541774
    1655 static boolean
     1775static bfd_boolean
    16561776sparc64_elf_size_dynamic_sections (output_bfd, info)
    16571777     bfd *output_bfd;
     
    16601780  bfd *dynobj;
    16611781  asection *s;
    1662   boolean reltext;
    1663   boolean relplt;
     1782  bfd_boolean relplt;
    16641783
    16651784  dynobj = elf_hash_table (info)->dynobj;
     
    16921811     determined the sizes of the various dynamic sections.  Allocate
    16931812     memory for them.  */
    1694   reltext = false;
    1695   relplt = false;
     1813  relplt = FALSE;
    16961814  for (s = dynobj->sections; s != NULL; s = s->next)
    16971815    {
    16981816      const char *name;
    1699       boolean strip;
     1817      bfd_boolean strip;
    17001818
    17011819      if ((s->flags & SEC_LINKER_CREATED) == 0)
     
    17061824      name = bfd_get_section_name (dynobj, s);
    17071825
    1708       strip = false;
     1826      strip = FALSE;
    17091827
    17101828      if (strncmp (name, ".rela", 5) == 0)
     
    17211839                 function which decides whether anything needs to go
    17221840                 into these sections.  */
    1723               strip = true;
     1841              strip = TRUE;
    17241842            }
    17251843          else
    17261844            {
    1727               const char *outname;
    1728               asection *target;
    1729 
    1730               /* If this relocation section applies to a read only
    1731                  section, then we probably need a DT_TEXTREL entry.  */
    1732               outname = bfd_get_section_name (output_bfd,
    1733                                               s->output_section);
    1734               target = bfd_get_section_by_name (output_bfd, outname + 5);
    1735               if (target != NULL
    1736                   && (target->flags & SEC_READONLY) != 0)
    1737                 reltext = true;
    1738 
    17391845              if (strcmp (name, ".rela.plt") == 0)
    1740                 relplt = true;
     1846                relplt = TRUE;
    17411847
    17421848              /* We use the reloc_count field as a counter if we need
     
    17631869      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
    17641870      if (s->contents == NULL && s->_raw_size != 0)
    1765         return false;
     1871        return FALSE;
    17661872    }
    17671873
     
    17731879         the .dynamic section.  The DT_DEBUG entry is filled in by the
    17741880         dynamic linker and used by the debugger.  */
     1881#define add_dynamic_entry(TAG, VAL) \
     1882  bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
     1883
    17751884      int reg;
    17761885      struct sparc64_elf_app_reg * app_regs;
    1777       struct bfd_strtab_hash *dynstr;
     1886      struct elf_strtab_hash *dynstr;
    17781887      struct elf_link_hash_table *eht = elf_hash_table (info);
    17791888
    1780       if (! info->shared)
    1781         {
    1782           if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
    1783             return false;
     1889      if (!info->shared)
     1890        {
     1891          if (!add_dynamic_entry (DT_DEBUG, 0))
     1892            return FALSE;
    17841893        }
    17851894
    17861895      if (relplt)
    17871896        {
    1788           if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)
    1789               || ! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
    1790               || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
    1791               || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
    1792             return false;
    1793         }
    1794 
    1795       if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
    1796           || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
    1797           || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
    1798                                             sizeof (Elf64_External_Rela)))
    1799         return false;
    1800 
    1801       if (reltext)
    1802         {
    1803           if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
    1804             return false;
    1805           info->flags |= DF_TEXTREL;
     1897          if (!add_dynamic_entry (DT_PLTGOT, 0)
     1898              || !add_dynamic_entry (DT_PLTRELSZ, 0)
     1899              || !add_dynamic_entry (DT_PLTREL, DT_RELA)
     1900              || !add_dynamic_entry (DT_JMPREL, 0))
     1901            return FALSE;
     1902        }
     1903
     1904      if (!add_dynamic_entry (DT_RELA, 0)
     1905          || !add_dynamic_entry (DT_RELASZ, 0)
     1906          || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
     1907        return FALSE;
     1908
     1909      if (info->flags & DF_TEXTREL)
     1910        {
     1911          if (!add_dynamic_entry (DT_TEXTREL, 0))
     1912            return FALSE;
    18061913        }
    18071914
     
    18161923            struct elf_link_local_dynamic_entry *entry, *e;
    18171924
    1818             if (! bfd_elf64_add_dynamic_entry (info, DT_SPARC_REGISTER, 0))
    1819               return false;
     1925            if (!add_dynamic_entry (DT_SPARC_REGISTER, 0))
     1926              return FALSE;
    18201927
    18211928            entry = (struct elf_link_local_dynamic_entry *)
    18221929              bfd_hash_allocate (&info->hash->table, sizeof (*entry));
    18231930            if (entry == NULL)
    1824               return false;
     1931              return FALSE;
    18251932
    18261933            /* We cheat here a little bit: the symbol will not be local, so we
     
    18311938            if (*app_regs [reg].name != '\0')
    18321939              entry->isym.st_name
    1833                 = _bfd_stringtab_add (dynstr, app_regs[reg].name, true, false);
     1940                = _bfd_elf_strtab_add (dynstr, app_regs[reg].name, FALSE);
    18341941            else
    18351942              entry->isym.st_name = 0;
     
    18531960          }
    18541961    }
    1855 
    1856   return true;
    1857 }
    1858 
    1859 
    1860 #define SET_SEC_DO_RELAX(section) do { elf_section_data(section)->tdata = (void *)1; } while (0)
    1861 #define SEC_DO_RELAX(section) (elf_section_data(section)->tdata == (void *)1)
    1862 
    1863 static boolean
     1962#undef add_dynamic_entry
     1963
     1964  return TRUE;
     1965}
     1966
     1967
     1968static bfd_boolean
     1969sparc64_elf_new_section_hook (abfd, sec)
     1970     bfd *abfd;
     1971     asection *sec;
     1972{
     1973  struct sparc64_elf_section_data *sdata;
     1974  bfd_size_type amt = sizeof (*sdata);
     1975
     1976  sdata = (struct sparc64_elf_section_data *) bfd_zalloc (abfd, amt);
     1977  if (sdata == NULL)
     1978    return FALSE;
     1979  sec->used_by_bfd = (PTR) sdata;
     1980
     1981  return _bfd_elf_new_section_hook (abfd, sec);
     1982}
     1983
     1984static bfd_boolean
    18641985sparc64_elf_relax_section (abfd, section, link_info, again)
    18651986     bfd *abfd ATTRIBUTE_UNUSED;
    18661987     asection *section ATTRIBUTE_UNUSED;
    18671988     struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
    1868      boolean *again;
    1869 {
    1870   *again = false;
    1871   SET_SEC_DO_RELAX (section);
    1872   return true;
    1873 }
    1874 
     1989     bfd_boolean *again;
     1990{
     1991  *again = FALSE;
     1992  sec_do_relax (section) = 1;
     1993  return TRUE;
     1994}
     1995
     1996
     1997/* This is the condition under which finish_dynamic_symbol will be called
     1998   from elflink.h.  If elflink.h doesn't call our finish_dynamic_symbol
     1999   routine, we'll need to do something about initializing any .plt and
     2000   .got entries in relocate_section.  */
     2001#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H)                   \
     2002  ((DYN)                                                                \
     2003   && ((INFO)->shared                                                   \
     2004       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)      \
     2005   && ((H)->dynindx != -1                                               \
     2006       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
    18752007
    18762008/* Relocate a SPARC64 ELF section.  */
    18772009
    1878 static boolean
     2010static bfd_boolean
    18792011sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
    18802012                              contents, relocs, local_syms, local_sections)
     
    18992031  Elf_Internal_Rela *relend;
    19002032
     2033  if (info->relocateable)
     2034    return TRUE;
     2035
    19012036  dynobj = elf_hash_table (info)->dynobj;
    19022037  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
     
    19212056      Elf_Internal_Sym *sym;
    19222057      asection *sec;
    1923       bfd_vma relocation;
     2058      bfd_vma relocation, off;
    19242059      bfd_reloc_status_type r;
     2060      bfd_boolean is_plt = FALSE;
     2061      bfd_boolean unresolved_reloc;
    19252062
    19262063      r_type = ELF64_R_TYPE_ID (rel->r_info);
     
    19282065        {
    19292066          bfd_set_error (bfd_error_bad_value);
    1930           return false;
     2067          return FALSE;
    19312068        }
    19322069      howto = sparc64_elf_howto_table + r_type;
    19332070
     2071      /* This is a final link.  */
    19342072      r_symndx = ELF64_R_SYM (rel->r_info);
    1935 
    1936       if (info->relocateable)
    1937         {
    1938           /* This is a relocateable link.  We don't have to change
    1939              anything, unless the reloc is against a section symbol,
    1940              in which case we have to adjust according to where the
    1941              section symbol winds up in the output section.  */
    1942           if (r_symndx < symtab_hdr->sh_info)
    1943             {
    1944               sym = local_syms + r_symndx;
    1945               if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
    1946                 {
    1947                   sec = local_sections[r_symndx];
    1948                   rel->r_addend += sec->output_offset + sym->st_value;
    1949                 }
    1950             }
    1951 
    1952           continue;
    1953         }
    1954 
    1955       /* This is a final link.  */
    19562073      h = NULL;
    19572074      sym = NULL;
    19582075      sec = NULL;
     2076      unresolved_reloc = FALSE;
    19592077      if (r_symndx < symtab_hdr->sh_info)
    19602078        {
    19612079          sym = local_syms + r_symndx;
    19622080          sec = local_sections[r_symndx];
    1963           relocation = (sec->output_section->vma
    1964                         + sec->output_offset
    1965                         + sym->st_value);
     2081          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
    19662082        }
    19672083      else
     
    19712087                 || h->root.type == bfd_link_hash_warning)
    19722088            h = (struct elf_link_hash_entry *) h->root.u.i.link;
     2089
     2090          relocation = 0;
    19732091          if (h->root.type == bfd_link_hash_defined
    19742092              || h->root.type == bfd_link_hash_defweak)
    19752093            {
    1976               boolean skip_it = false;
    19772094              sec = h->root.u.def.section;
    1978 
    1979               switch (r_type)
    1980                 {
    1981                 case R_SPARC_WPLT30:
    1982                 case R_SPARC_PLT32:
    1983                 case R_SPARC_HIPLT22:
    1984                 case R_SPARC_LOPLT10:
    1985                 case R_SPARC_PCPLT32:
    1986                 case R_SPARC_PCPLT22:
    1987                 case R_SPARC_PCPLT10:
    1988                 case R_SPARC_PLT64:
    1989                   if (h->plt.offset != (bfd_vma) -1)
    1990                     skip_it = true;
    1991                   break;
    1992 
    1993                 case R_SPARC_GOT10:
    1994                 case R_SPARC_GOT13:
    1995                 case R_SPARC_GOT22:
    1996                   if (elf_hash_table(info)->dynamic_sections_created
    1997                       && (!info->shared
    1998                           || (!info->symbolic && h->dynindx != -1)
    1999                           || !(h->elf_link_hash_flags
    2000                                & ELF_LINK_HASH_DEF_REGULAR)))
    2001                     skip_it = true;
    2002                   break;
    2003 
    2004                 case R_SPARC_PC10:
    2005                 case R_SPARC_PC22:
    2006                 case R_SPARC_PC_HH22:
    2007                 case R_SPARC_PC_HM10:
    2008                 case R_SPARC_PC_LM22:
    2009                   if (!strcmp(h->root.root.string, "_GLOBAL_OFFSET_TABLE_"))
    2010                     break;
    2011                   /* FALLTHRU */
    2012 
    2013                 case R_SPARC_8:
    2014                 case R_SPARC_16:
    2015                 case R_SPARC_32:
    2016                 case R_SPARC_DISP8:
    2017                 case R_SPARC_DISP16:
    2018                 case R_SPARC_DISP32:
    2019                 case R_SPARC_WDISP30:
    2020                 case R_SPARC_WDISP22:
    2021                 case R_SPARC_HI22:
    2022                 case R_SPARC_22:
    2023                 case R_SPARC_13:
    2024                 case R_SPARC_LO10:
    2025                 case R_SPARC_UA32:
    2026                 case R_SPARC_10:
    2027                 case R_SPARC_11:
    2028                 case R_SPARC_64:
    2029                 case R_SPARC_OLO10:
    2030                 case R_SPARC_HH22:
    2031                 case R_SPARC_HM10:
    2032                 case R_SPARC_LM22:
    2033                 case R_SPARC_WDISP19:
    2034                 case R_SPARC_WDISP16:
    2035                 case R_SPARC_7:
    2036                 case R_SPARC_5:
    2037                 case R_SPARC_6:
    2038                 case R_SPARC_DISP64:
    2039                 case R_SPARC_HIX22:
    2040                 case R_SPARC_LOX10:
    2041                 case R_SPARC_H44:
    2042                 case R_SPARC_M44:
    2043                 case R_SPARC_L44:
    2044                 case R_SPARC_UA64:
    2045                 case R_SPARC_UA16:
    2046                   if (info->shared
    2047                       && ((!info->symbolic && h->dynindx != -1)
    2048                           || !(h->elf_link_hash_flags
    2049                                & ELF_LINK_HASH_DEF_REGULAR)))
    2050                     skip_it = true;
    2051                   break;
    2052                 }
    2053 
    2054               if (skip_it)
    2055                 {
    2056                   /* In these cases, we don't need the relocation
    2057                      value.  We check specially because in some
    2058                      obscure cases sec->output_section will be NULL.  */
    2059                   relocation = 0;
    2060                 }
     2095              if (sec->output_section == NULL)
     2096                /* Set a flag that will be cleared later if we find a
     2097                   relocation value for this symbol.  output_section
     2098                   is typically NULL for symbols satisfied by a shared
     2099                   library.  */
     2100                unresolved_reloc = TRUE;
    20612101              else
    2062                 {
    2063                   relocation = (h->root.u.def.value
    2064                                 + sec->output_section->vma
    2065                                 + sec->output_offset);
    2066                 }
     2102                relocation = (h->root.u.def.value
     2103                              + sec->output_section->vma
     2104                              + sec->output_offset);
    20672105            }
    20682106          else if (h->root.type == bfd_link_hash_undefweak)
    2069             relocation = 0;
    2070           else if (info->shared && !info->symbolic
     2107            ;
     2108          else if (info->shared
    20712109                   && !info->no_undefined
    20722110                   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
    2073             relocation = 0;
     2111            ;
    20742112          else
    20752113            {
     
    20792117                      (!info->shared || info->no_undefined
    20802118                       || ELF_ST_VISIBILITY (h->other)))))
    2081                 return false;
     2119                return FALSE;
    20822120
    20832121              /* To avoid generating warning messages about truncated
    20842122                 relocations, set the relocation's address to be the same as
    20852123                 the start of this section.  */
    2086 
    20872124              if (input_section->output_section != NULL)
    20882125                relocation = input_section->output_section->vma;
     
    20922129        }
    20932130
     2131 do_dynreloc:
    20942132      /* When generating a shared object, these relocations are copied
    20952133         into the output file to be resolved at run time.  */
    2096       if (info->shared && (input_section->flags & SEC_ALLOC))
     2134      if (info->shared && r_symndx != 0 && (input_section->flags & SEC_ALLOC))
    20972135        {
    20982136          switch (r_type)
     
    21102148            case R_SPARC_DISP16:
    21112149            case R_SPARC_DISP32:
     2150            case R_SPARC_DISP64:
    21122151            case R_SPARC_WDISP30:
    21132152            case R_SPARC_WDISP22:
    21142153            case R_SPARC_WDISP19:
    21152154            case R_SPARC_WDISP16:
    2116             case R_SPARC_DISP64:
    21172155              if (h == NULL)
    21182156                break;
     
    21452183              {
    21462184                Elf_Internal_Rela outrel;
    2147                 boolean skip;
     2185                bfd_byte *loc;
     2186                bfd_boolean skip, relocate;
    21482187
    21492188                if (sreloc == NULL)
     
    21562195
    21572196                    if (name == NULL)
    2158                       return false;
     2197                      return FALSE;
    21592198
    21602199                    BFD_ASSERT (strncmp (name, ".rela", 5) == 0
     
    21672206                  }
    21682207
    2169                 skip = false;
    2170 
    2171                 if (elf_section_data (input_section)->stab_info == NULL)
    2172                   outrel.r_offset = rel->r_offset;
    2173                 else
    2174                   {
    2175                     bfd_vma off;
    2176 
    2177                     off = (_bfd_stab_section_offset
    2178                            (output_bfd, &elf_hash_table (info)->stab_info,
    2179                             input_section,
    2180                             &elf_section_data (input_section)->stab_info,
    2181                             rel->r_offset));
    2182                     if (off == MINUS_ONE)
    2183                       skip = true;
    2184                     outrel.r_offset = off;
    2185                   }
     2208                skip = FALSE;
     2209                relocate = FALSE;
     2210
     2211                outrel.r_offset =
     2212                  _bfd_elf_section_offset (output_bfd, info, input_section,
     2213                                           rel->r_offset);
     2214                if (outrel.r_offset == (bfd_vma) -1)
     2215                  skip = TRUE;
     2216                else if (outrel.r_offset == (bfd_vma) -2)
     2217                  skip = TRUE, relocate = TRUE;
    21862218
    21872219                outrel.r_offset += (input_section->output_section->vma
     
    22102242                    if (!(outrel.r_offset & 7)) r_type = R_SPARC_64;
    22112243                    break;
     2244                  case R_SPARC_DISP8:
     2245                  case R_SPARC_DISP16:
     2246                  case R_SPARC_DISP32:
     2247                  case R_SPARC_DISP64:
     2248                    /* If the symbol is not dynamic, we should not keep
     2249                       a dynamic relocation.  But an .rela.* slot has been
     2250                       allocated for it, output R_SPARC_NONE.
     2251                       FIXME: Add code tracking needed dynamic relocs as
     2252                       e.g. i386 has.  */
     2253                    if (h->dynindx == -1)
     2254                      skip = TRUE, relocate = TRUE;
     2255                    break;
    22122256                  }
    22132257
     
    22162260                /* h->dynindx may be -1 if the symbol was marked to
    22172261                   become local.  */
    2218                 else if (h != NULL
     2262                else if (h != NULL && ! is_plt
    22192263                         && ((! info->symbolic && h->dynindx != -1)
    22202264                             || (h->elf_link_hash_flags
     
    22312275                else
    22322276                  {
     2277                    outrel.r_addend = relocation + rel->r_addend;
    22332278                    if (r_type == R_SPARC_64)
    2234                       {
    2235                         outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
    2236                         outrel.r_addend = relocation + rel->r_addend;
    2237                       }
     2279                      outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
    22382280                    else
    22392281                      {
    22402282                        long indx;
    22412283
    2242                         if (h == NULL)
     2284                        if (is_plt)
     2285                          sec = splt;
     2286                        else if (h == NULL)
    22432287                          sec = local_sections[r_symndx];
    22442288                        else
     
    22542298                          {
    22552299                            bfd_set_error (bfd_error_bad_value);
    2256                             return false;
     2300                            return FALSE;
    22572301                          }
    22582302                        else
     
    22622306                            osec = sec->output_section;
    22632307                            indx = elf_section_data (osec)->dynindx;
     2308
     2309                            /* We are turning this relocation into one
     2310                               against a section symbol, so subtract out
     2311                               the output section's address but not the
     2312                               offset of the input section in the output
     2313                               section.  */
     2314                            outrel.r_addend -= osec->vma;
    22642315
    22652316                            /* FIXME: we really should be able to link non-pic
     
    22702321                                (*_bfd_error_handler)
    22712322                                  (_("%s: probably compiled without -fPIC?"),
    2272                                    bfd_get_filename (input_bfd));
     2323                                   bfd_archive_filename (input_bfd));
    22732324                                bfd_set_error (bfd_error_bad_value);
    2274                                 return false;
     2325                                return FALSE;
    22752326                              }
    22762327                          }
     
    22812332                                            ELF64_R_TYPE_DATA (rel->r_info),
    22822333                                                               r_type));
    2283                         outrel.r_addend = relocation + rel->r_addend;
    22842334                      }
    22852335                  }
    22862336
    2287                 bfd_elf64_swap_reloca_out (output_bfd, &outrel,
    2288                                            (((Elf64_External_Rela *)
    2289                                              sreloc->contents)
    2290                                             + sreloc->reloc_count));
    2291                 ++sreloc->reloc_count;
     2337                loc = sreloc->contents;
     2338                loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
     2339                bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
    22922340
    22932341                /* This reloc will be computed at runtime, so there's no
    2294                    need to do anything now, unless this is a RELATIVE
    2295                    reloc in an unallocated section.  */
    2296                 if (skip
    2297                     || (input_section->flags & SEC_ALLOC) != 0
    2298                     || ELF64_R_TYPE_ID (outrel.r_info) != R_SPARC_RELATIVE)
     2342                   need to do anything now.  */
     2343                if (! relocate)
    22992344                  continue;
    23002345              }
     
    23182363          if (h != NULL)
    23192364            {
    2320               bfd_vma off = h->got.offset;
     2365              bfd_boolean dyn;
     2366
     2367              off = h->got.offset;
    23212368              BFD_ASSERT (off != (bfd_vma) -1);
    2322 
    2323               if (! elf_hash_table (info)->dynamic_sections_created
     2369              dyn = elf_hash_table (info)->dynamic_sections_created;
     2370
     2371              if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
    23242372                  || (info->shared
    2325                       && (info->symbolic || h->dynindx == -1)
    2326                       && (h->elf_link_hash_flags
    2327                           & ELF_LINK_HASH_DEF_REGULAR)))
     2373                      && (info->symbolic
     2374                          || h->dynindx == -1
     2375                          || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
     2376                      && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
    23282377                {
    23292378                  /* This is actually a static link, or it is a -Bsymbolic
     
    23482397                    }
    23492398                }
    2350               relocation = sgot->output_offset + off - got_base;
     2399              else
     2400                unresolved_reloc = FALSE;
    23512401            }
    23522402          else
    23532403            {
    2354               bfd_vma off;
    2355 
    23562404              BFD_ASSERT (local_got_offsets != NULL);
    23572405              off = local_got_offsets[r_symndx];
     
    23692417                  if (info->shared)
    23702418                    {
    2371                       asection *srelgot;
     2419                      asection *s;
    23722420                      Elf_Internal_Rela outrel;
     2421                      bfd_byte *loc;
    23732422
    23742423                      /* The Solaris 2.7 64-bit linker adds the contents
     
    23772426                         32-bit linker, which both adds the contents
    23782427                         and ignores the addend.  So clear the location.  */
    2379                       bfd_put_64 (output_bfd, 0, sgot->contents + off);
     2428                      bfd_put_64 (output_bfd, (bfd_vma) 0,
     2429                                  sgot->contents + off);
    23802430
    23812431                      /* We need to generate a R_SPARC_RELATIVE reloc
    23822432                         for the dynamic linker.  */
    2383                       srelgot = bfd_get_section_by_name(dynobj, ".rela.got");
    2384                       BFD_ASSERT (srelgot != NULL);
     2433                      s = bfd_get_section_by_name(dynobj, ".rela.got");
     2434                      BFD_ASSERT (s != NULL);
    23852435
    23862436                      outrel.r_offset = (sgot->output_section->vma
     
    23892439                      outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
    23902440                      outrel.r_addend = relocation;
    2391                       bfd_elf64_swap_reloca_out (output_bfd, &outrel,
    2392                                                  (((Elf64_External_Rela *)
    2393                                                    srelgot->contents)
    2394                                                   + srelgot->reloc_count));
    2395                       ++srelgot->reloc_count;
     2441                      loc = s->contents;
     2442                      loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
     2443                      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
    23962444                    }
    23972445                  else
    23982446                    bfd_put_64 (output_bfd, relocation, sgot->contents + off);
    23992447                }
    2400               relocation = sgot->output_offset + off - got_base;
    24012448            }
     2449          relocation = sgot->output_offset + off - got_base;
    24022450          goto do_default;
    24032451
     
    24312479                        + splt->output_offset
    24322480                        + sparc64_elf_plt_entry_offset (h->plt.offset));
     2481          unresolved_reloc = FALSE;
    24332482          if (r_type == R_SPARC_WPLT30)
    24342483            goto do_wplt30;
     2484          if (r_type == R_SPARC_PLT32 || r_type == R_SPARC_PLT64)
     2485            {
     2486              r_type = r_type == R_SPARC_PLT32 ? R_SPARC_32 : R_SPARC_64;
     2487              is_plt = TRUE;
     2488              goto do_dynreloc;
     2489            }
    24352490          goto do_default;
    24362491
     
    24432498
    24442499            x = bfd_get_32 (input_bfd, contents + rel->r_offset);
    2445             x = (x & ~0x1fff) | (relocation & 0x1fff);
     2500            x = (x & ~(bfd_vma) 0x1fff) | (relocation & 0x1fff);
    24462501            bfd_put_32 (input_bfd, x, contents + rel->r_offset);
    24472502
     
    24642519
    24652520            x = bfd_get_32 (input_bfd, contents + rel->r_offset);
    2466             x = (x & ~0x303fff) | ((((relocation >> 2) & 0xc000) << 6)
    2467                                    | ((relocation >> 2) & 0x3fff));
     2521            x &= ~(bfd_vma) 0x303fff;
     2522            x |= ((((relocation >> 2) & 0xc000) << 6)
     2523                  | ((relocation >> 2) & 0x3fff));
    24682524            bfd_put_32 (input_bfd, x, contents + rel->r_offset);
    24692525
     
    24832539
    24842540            x = bfd_get_32 (input_bfd, contents + rel->r_offset);
    2485             x = (x & ~0x3fffff) | ((relocation >> 10) & 0x3fffff);
     2541            x = (x & ~(bfd_vma) 0x3fffff) | ((relocation >> 10) & 0x3fffff);
    24862542            bfd_put_32 (input_bfd, x, contents + rel->r_offset);
    24872543
     
    25012557
    25022558            x = bfd_get_32 (input_bfd, contents + rel->r_offset);
    2503             x = (x & ~0x1fff) | relocation;
     2559            x = (x & ~(bfd_vma) 0x1fff) | relocation;
    25042560            bfd_put_32 (input_bfd, x, contents + rel->r_offset);
    25052561
     
    25102566        case R_SPARC_WDISP30:
    25112567        do_wplt30:
    2512           if (SEC_DO_RELAX (input_section)
     2568          if (sec_do_relax (input_section)
    25132569              && rel->r_offset + 4 < input_section->_raw_size)
    25142570            {
     
    25902646                            break;
    25912647
    2592                           bfd_put_32 (input_bfd, INSN_NOP,
     2648                          bfd_put_32 (input_bfd, (bfd_vma) INSN_NOP,
    25932649                                      contents + rel->r_offset + 4);
    25942650                        }
     
    25972653                }
    25982654            }
    2599           /* FALLTHROUGH */
     2655          /* Fall through. */
    26002656
    26012657        default:
     
    26072663        }
    26082664
     2665      /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
     2666         because such sections are not SEC_ALLOC and thus ld.so will
     2667         not process them.  */
     2668      if (unresolved_reloc
     2669          && !((input_section->flags & SEC_DEBUGGING) != 0
     2670               && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
     2671        (*_bfd_error_handler)
     2672          (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
     2673           bfd_archive_filename (input_bfd),
     2674           bfd_get_section_name (input_bfd, input_section),
     2675           (long) rel->r_offset,
     2676           h->root.root.string);
     2677
    26092678      switch (r)
    26102679        {
     
    26192688          {
    26202689            const char *name;
     2690
     2691            /* The Solaris native linker silently disregards
     2692               overflows.  We don't, but this breaks stabs debugging
     2693               info, whose relocations are only 32-bits wide.  Ignore
     2694               overflows for discarded entries.  */
     2695            if (r_type == R_SPARC_32
     2696                && _bfd_elf_section_offset (output_bfd, info, input_section,
     2697                                            rel->r_offset) == (bfd_vma) -1)
     2698              break;
    26212699
    26222700            if (h != NULL)
     
    26422720                         sym->st_name));
    26432721                if (name == NULL)
    2644                   return false;
     2722                  return FALSE;
    26452723                if (*name == '\0')
    26462724                  name = bfd_section_name (input_bfd, sec);
     
    26492727                   (info, name, howto->name, (bfd_vma) 0,
    26502728                    input_bfd, input_section, rel->r_offset)))
    2651               return false;
     2729              return FALSE;
    26522730          }
    26532731        break;
     
    26552733    }
    26562734
    2657   return true;
     2735  return TRUE;
    26582736}
    26592737
     
    26612739   dynamic sections here.  */
    26622740
    2663 static boolean
     2741static bfd_boolean
    26642742sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
    26652743     bfd *output_bfd;
     
    26772755      asection *srela;
    26782756      Elf_Internal_Rela rela;
     2757      bfd_byte *loc;
    26792758
    26802759      /* This symbol has an entry in the PLT.  Set it up.  */
     
    26952774      else
    26962775        {
    2697           int max = splt->_raw_size / PLT_ENTRY_SIZE;
     2776          bfd_vma max = splt->_raw_size / PLT_ENTRY_SIZE;
    26982777          rela.r_offset = sparc64_elf_plt_ptr_offset (h->plt.offset, max);
    26992778          rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4)
     
    27082787         thus .plt[4] has corresponding .rela.plt[0] and so on.  */
    27092788
    2710       bfd_elf64_swap_reloca_out (output_bfd, &rela,
    2711                                  ((Elf64_External_Rela *) srela->contents
    2712                                   + (h->plt.offset - 4)));
     2789      loc = srela->contents;
     2790      loc += (h->plt.offset - 4) * sizeof (Elf64_External_Rela);
     2791      bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
    27132792
    27142793      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
     
    27322811      asection *srela;
    27332812      Elf_Internal_Rela rela;
     2813      bfd_byte *loc;
    27342814
    27352815      /* This symbol has an entry in the GOT.  Set it up.  */
     
    27412821      rela.r_offset = (sgot->output_section->vma
    27422822                       + sgot->output_offset
    2743                        + (h->got.offset &~ 1));
     2823                       + (h->got.offset &~ (bfd_vma) 1));
    27442824
    27452825      /* If this is a -Bsymbolic link, and the symbol is defined
     
    27602840      else
    27612841        {
    2762           bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
    27632842          rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_GLOB_DAT);
    27642843          rela.r_addend = 0;
    27652844        }
    27662845
    2767       bfd_elf64_swap_reloca_out (output_bfd, &rela,
    2768                                  ((Elf64_External_Rela *) srela->contents
    2769                                   + srela->reloc_count));
    2770       ++srela->reloc_count;
     2846      bfd_put_64 (output_bfd, (bfd_vma) 0,
     2847                  sgot->contents + (h->got.offset &~ (bfd_vma) 1));
     2848      loc = srela->contents;
     2849      loc += srela->reloc_count++ * sizeof (Elf64_External_Rela);
     2850      bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
    27712851    }
    27722852
     
    27752855      asection *s;
    27762856      Elf_Internal_Rela rela;
     2857      bfd_byte *loc;
    27772858
    27782859      /* This symbols needs a copy reloc.  Set it up.  */
    2779 
    27802860      BFD_ASSERT (h->dynindx != -1);
    27812861
     
    27892869      rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_COPY);
    27902870      rela.r_addend = 0;
    2791       bfd_elf64_swap_reloca_out (output_bfd, &rela,
    2792                                  ((Elf64_External_Rela *) s->contents
    2793                                   + s->reloc_count));
    2794       ++s->reloc_count;
     2871      loc = s->contents + s->reloc_count++ * sizeof (Elf64_External_Rela);
     2872      bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
    27952873    }
    27962874
     
    28012879    sym->st_shndx = SHN_ABS;
    28022880
    2803   return true;
     2881  return TRUE;
    28042882}
    28052883
    28062884/* Finish up the dynamic sections.  */
    28072885
    2808 static boolean
     2886static bfd_boolean
    28092887sparc64_elf_finish_dynamic_sections (output_bfd, info)
    28102888     bfd *output_bfd;
     
    28342912          Elf_Internal_Dyn dyn;
    28352913          const char *name;
    2836           boolean size;
     2914          bfd_boolean size;
    28372915
    28382916          bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
     
    28402918          switch (dyn.d_tag)
    28412919            {
    2842             case DT_PLTGOT:   name = ".plt"; size = false; break;
    2843             case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;
    2844             case DT_JMPREL:   name = ".rela.plt"; size = false; break;
     2920            case DT_PLTGOT:   name = ".plt"; size = FALSE; break;
     2921            case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break;
     2922            case DT_JMPREL:   name = ".rela.plt"; size = FALSE; break;
    28452923            case DT_SPARC_REGISTER:
    28462924              if (stt_regidx == -1)
     
    28492927                    _bfd_elf_link_lookup_local_dynindx (info, output_bfd, -1);
    28502928                  if (stt_regidx == -1)
    2851                     return false;
     2929                    return FALSE;
    28522930                }
    28532931              dyn.d_un.d_val = stt_regidx++;
    28542932              bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
    28552933              /* fallthrough */
    2856             default:          name = NULL; size = false; break;
     2934            default:          name = NULL; size = FALSE; break;
    28572935            }
    28582936
     
    28822960      /* Initialize the contents of the .plt section.  */
    28832961      if (splt->_raw_size > 0)
    2884         {
    2885           sparc64_elf_build_plt(output_bfd, splt->contents,
    2886                                 splt->_raw_size / PLT_ENTRY_SIZE);
    2887         }
     2962        sparc64_elf_build_plt (output_bfd, splt->contents,
     2963                               (int) (splt->_raw_size / PLT_ENTRY_SIZE));
    28882964
    28892965      elf_section_data (splt->output_section)->this_hdr.sh_entsize =
     
    29072983  elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 8;
    29082984
    2909   return true;
     2985  return TRUE;
     2986}
     2987
     2988static enum elf_reloc_type_class
     2989sparc64_elf_reloc_type_class (rela)
     2990     const Elf_Internal_Rela *rela;
     2991{
     2992  switch ((int) ELF64_R_TYPE (rela->r_info))
     2993    {
     2994    case R_SPARC_RELATIVE:
     2995      return reloc_class_relative;
     2996    case R_SPARC_JMP_SLOT:
     2997      return reloc_class_plt;
     2998    case R_SPARC_COPY:
     2999      return reloc_class_copy;
     3000    default:
     3001      return reloc_class_normal;
     3002    }
    29103003}
    29113004
    29123005
    29133006/* Functions for dealing with the e_flags field.  */
    2914 
    2915 /* Copy backend specific data from one object module to another */
    2916 static boolean
    2917 sparc64_elf_copy_private_bfd_data (ibfd, obfd)
    2918      bfd *ibfd, *obfd;
    2919 {
    2920   if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    2921       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    2922     return true;
    2923 
    2924   BFD_ASSERT (!elf_flags_init (obfd)
    2925               || (elf_elfheader (obfd)->e_flags
    2926                   == elf_elfheader (ibfd)->e_flags));
    2927 
    2928   elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
    2929   elf_flags_init (obfd) = true;
    2930   return true;
    2931 }
    29323007
    29333008/* Merge backend specific data from an object file to the output
    29343009   object file when linking.  */
    29353010
    2936 static boolean
     3011static bfd_boolean
    29373012sparc64_elf_merge_private_bfd_data (ibfd, obfd)
    29383013     bfd *ibfd;
    29393014     bfd *obfd;
    29403015{
    2941   boolean error;
     3016  bfd_boolean error;
    29423017  flagword new_flags, old_flags;
    29433018  int new_mm, old_mm;
     
    29453020  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    29463021      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    2947     return true;
     3022    return TRUE;
    29483023
    29493024  new_flags = elf_elfheader (ibfd)->e_flags;
     
    29523027  if (!elf_flags_init (obfd))   /* First call, no flags set */
    29533028    {
    2954       elf_flags_init (obfd) = true;
     3029      elf_flags_init (obfd) = TRUE;
    29553030      elf_elfheader (obfd)->e_flags = new_flags;
    29563031    }
     
    29613036  else                                  /* Incompatible flags */
    29623037    {
    2963       error = false;
     3038      error = FALSE;
    29643039
    29653040#define EF_SPARC_ISA_EXTENSIONS \
     
    29833058              && (old_flags & EF_SPARC_HAL_R1))
    29843059            {
    2985               error = true;
     3060              error = TRUE;
    29863061              (*_bfd_error_handler)
    29873062                (_("%s: linking UltraSPARC specific with HAL specific code"),
    2988                  bfd_get_filename (ibfd));
     3063                 bfd_archive_filename (ibfd));
    29893064            }
    29903065          /* Choose the most restrictive memory ordering.  */
     
    30023077      if (new_flags != old_flags)
    30033078        {
    3004           error = true;
     3079          error = TRUE;
    30053080          (*_bfd_error_handler)
    30063081            (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
    3007              bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
     3082             bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags);
    30083083        }
    30093084
     
    30133088        {
    30143089          bfd_set_error (bfd_error_bad_value);
    3015           return false;
     3090          return FALSE;
    30163091        }
    30173092    }
    3018   return true;
     3093  return TRUE;
     3094}
     3095
     3096/* MARCO: Set the correct entry size for the .stab section.  */
     3097
     3098static bfd_boolean
     3099sparc64_elf_fake_sections (abfd, hdr, sec)
     3100     bfd *abfd ATTRIBUTE_UNUSED;
     3101     Elf_Internal_Shdr *hdr ATTRIBUTE_UNUSED;
     3102     asection *sec;
     3103{
     3104  const char *name;
     3105
     3106  name = bfd_get_section_name (abfd, sec);
     3107
     3108  if (strcmp (name, ".stab") == 0)
     3109    {
     3110      /* Even in the 64bit case the stab entries are only 12 bytes long.  */
     3111      elf_section_data (sec)->this_hdr.sh_entsize = 12;
     3112    }
     3113
     3114  return TRUE;
    30193115}
    30203116
     
    30403136                 ((type & BSF_LOCAL)
    30413137                  ? (type & BSF_GLOBAL) ? '!' : 'l'
    3042                   : (type & BSF_GLOBAL) ? 'g' : ' '),
    3043                  (type & BSF_WEAK) ? 'w' : ' ');
     3138                  : (type & BSF_GLOBAL) ? 'g' : ' '),
     3139                 (type & BSF_WEAK) ? 'w' : ' ');
    30443140  if (symbol->name == NULL || symbol->name [0] == '\0')
    30453141    return "#scratch";
     
    30513147/* Set the right machine number for a SPARC64 ELF file.  */
    30523148
    3053 static boolean
     3149static bfd_boolean
    30543150sparc64_elf_object_p (abfd)
    30553151     bfd *abfd;
     
    30793175  sizeof (Elf64_External_Dyn),
    30803176  sizeof (Elf_External_Note),
    3081   4,            /* hash-table entry size */
    3082   /* internal relocations per external relocations.
     3177  4,            /* hash-table entry size. */
     3178  /* Internal relocations per external relocations.
    30833179     For link purposes we use just 1 internal per
    30843180     1 external, for assembly and slurp symbol table
    30853181     we use 2.  */
    30863182  1,
    3087   64,           /* arch_size */
    3088   8,            /* file_align */
     3183  64,           /* arch_size. */
     3184  8,            /* file_align. */
    30893185  ELFCLASS64,
    30903186  EV_CURRENT,
     
    30923188  bfd_elf64_write_shdrs_and_ehdr,
    30933189  sparc64_elf_write_relocs,
     3190  bfd_elf64_swap_symbol_in,
    30943191  bfd_elf64_swap_symbol_out,
    30953192  sparc64_elf_slurp_reloc_table,
     
    30973194  bfd_elf64_swap_dyn_in,
    30983195  bfd_elf64_swap_dyn_out,
    3099   NULL,
    3100   NULL,
    3101   NULL,
    3102   NULL
     3196  bfd_elf64_swap_reloc_in,
     3197  bfd_elf64_swap_reloc_out,
     3198  bfd_elf64_swap_reloca_in,
     3199  bfd_elf64_swap_reloca_out
    31033200};
    31043201
     
    31233220#define bfd_elf64_get_dynamic_reloc_upper_bound \
    31243221  sparc64_elf_get_dynamic_reloc_upper_bound
     3222#define bfd_elf64_canonicalize_reloc \
     3223  sparc64_elf_canonicalize_reloc
    31253224#define bfd_elf64_canonicalize_dynamic_reloc \
    31263225  sparc64_elf_canonicalize_dynamic_reloc
     
    31293228#define bfd_elf64_bfd_relax_section \
    31303229  sparc64_elf_relax_section
     3230#define bfd_elf64_new_section_hook \
     3231  sparc64_elf_new_section_hook
    31313232
    31323233#define elf_backend_create_dynamic_sections \
     
    31543255#define elf_backend_output_arch_syms \
    31553256  sparc64_elf_output_arch_syms
    3156 #define bfd_elf64_bfd_copy_private_bfd_data \
    3157   sparc64_elf_copy_private_bfd_data
    31583257#define bfd_elf64_bfd_merge_private_bfd_data \
    31593258  sparc64_elf_merge_private_bfd_data
     3259#define elf_backend_fake_sections \
     3260  sparc64_elf_fake_sections
    31603261
    31613262#define elf_backend_size_info \
     
    31633264#define elf_backend_object_p \
    31643265  sparc64_elf_object_p
     3266#define elf_backend_reloc_type_class \
     3267  sparc64_elf_reloc_type_class
    31653268
    31663269#define elf_backend_want_got_plt 0
    31673270#define elf_backend_plt_readonly 0
    31683271#define elf_backend_want_plt_sym 1
     3272#define elf_backend_rela_normal 1
    31693273
    31703274/* Section 5.2.4 of the ABI specifies a 256-byte boundary for the table.  */
Note: See TracChangeset for help on using the changeset viewer.