Changeset 609 for branches/GNU/src/binutils/bfd/elf64-sparc.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/elf64-sparc.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* 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 modify8 it under the terms of the GNU General Public License as published by9 the Free Software Foundation; either version 2 of the License, or10 (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 of14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 GNU General Public License for more details.16 17 You should have received a copy of the GNU General Public License18 along with this program; if not, write to the Free Software19 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. */ 20 20 21 21 #include "bfd.h" … … 36 36 37 37 static struct bfd_link_hash_table * sparc64_elf_bfd_link_hash_table_create 38 PARAMS((bfd *)); 38 PARAMS ((bfd *)); 39 static bfd_reloc_status_type init_insn_reloc 40 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, 41 bfd *, bfd_vma *, bfd_vma *)); 39 42 static reloc_howto_type *sparc64_elf_reloc_type_lookup 40 43 PARAMS ((bfd *, bfd_reloc_code_real_type)); … … 43 46 44 47 static void sparc64_elf_build_plt 45 PARAMS ((bfd *, unsigned char *, int));48 PARAMS ((bfd *, unsigned char *, int)); 46 49 static bfd_vma sparc64_elf_plt_entry_offset 47 PARAMS ((int));50 PARAMS ((bfd_vma)); 48 51 static bfd_vma sparc64_elf_plt_ptr_offset 49 PARAMS ((int, int));50 51 static b oolean sparc64_elf_check_relocs52 PARAMS ((bfd *, struct bfd_link_info *, asection *sec,53 const Elf_Internal_Rela *));54 static b oolean sparc64_elf_adjust_dynamic_symbol55 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));56 static b oolean sparc64_elf_size_dynamic_sections57 PARAMS ((bfd *, struct bfd_link_info *));52 PARAMS ((bfd_vma, bfd_vma)); 53 54 static bfd_boolean sparc64_elf_check_relocs 55 PARAMS ((bfd *, struct bfd_link_info *, asection *sec, 56 const Elf_Internal_Rela *)); 57 static bfd_boolean sparc64_elf_adjust_dynamic_symbol 58 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); 59 static bfd_boolean sparc64_elf_size_dynamic_sections 60 PARAMS ((bfd *, struct bfd_link_info *)); 58 61 static int sparc64_elf_get_symbol_type 59 62 PARAMS (( Elf_Internal_Sym *, int)); 60 static b oolean sparc64_elf_add_symbol_hook63 static bfd_boolean sparc64_elf_add_symbol_hook 61 64 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, 62 const char **, flagword *, asection **, bfd_vma *)); 65 const char **, flagword *, asection **, bfd_vma *)); 66 static 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 *))); 63 69 static void sparc64_elf_symbol_processing 64 70 PARAMS ((bfd *, asymbol *)); 65 71 66 static b oolean sparc64_elf_copy_private_bfd_data72 static bfd_boolean sparc64_elf_merge_private_bfd_data 67 73 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 75 static bfd_boolean sparc64_elf_fake_sections 76 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); 77 78 static const char *sparc64_elf_print_symbol_all 79 PARAMS ((bfd *, PTR, asymbol *)); 80 static bfd_boolean sparc64_elf_new_section_hook 81 PARAMS ((bfd *, asection *)); 82 static bfd_boolean sparc64_elf_relax_section 83 PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *)); 84 static bfd_boolean sparc64_elf_relocate_section 74 85 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 75 86 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); 76 static boolean sparc64_elf_object_p PARAMS ((bfd *)); 87 static bfd_boolean sparc64_elf_finish_dynamic_symbol 88 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, 89 Elf_Internal_Sym *)); 90 static bfd_boolean sparc64_elf_finish_dynamic_sections 91 PARAMS ((bfd *, struct bfd_link_info *)); 92 static bfd_boolean sparc64_elf_object_p PARAMS ((bfd *)); 77 93 static long sparc64_elf_get_reloc_upper_bound PARAMS ((bfd *, asection *)); 78 94 static 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)); 95 static bfd_boolean sparc64_elf_slurp_one_reloc_table 96 PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, asymbol **, bfd_boolean)); 97 static bfd_boolean sparc64_elf_slurp_reloc_table 98 PARAMS ((bfd *, asection *, asymbol **, bfd_boolean)); 99 static long sparc64_elf_canonicalize_reloc 100 PARAMS ((bfd *, asection *, arelent **, asymbol **)); 83 101 static long sparc64_elf_canonicalize_dynamic_reloc 84 102 PARAMS ((bfd *, arelent **, asymbol **)); 85 103 static void sparc64_elf_write_relocs PARAMS ((bfd *, asection *, PTR)); 104 static enum elf_reloc_type_class sparc64_elf_reloc_type_class 105 PARAMS ((const Elf_Internal_Rela *)); 86 106 87 107 … … 99 119 static reloc_howto_type sparc64_elf_howto_table[] = 100 120 { 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), 125 145 #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), 126 147 /* 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), 133 153 #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) 160 204 }; 161 205 … … 165 209 }; 166 210 167 static CONSTstruct elf_reloc_map sparc_reloc_map[] =211 static const struct elf_reloc_map sparc_reloc_map[] = 168 212 { 169 213 { BFD_RELOC_NONE, R_SPARC_NONE, }, 170 214 { BFD_RELOC_16, R_SPARC_16, }, 215 { BFD_RELOC_16_PCREL, R_SPARC_DISP16 }, 171 216 { BFD_RELOC_8, R_SPARC_8 }, 172 217 { BFD_RELOC_8_PCREL, R_SPARC_DISP8 }, … … 177 222 { BFD_RELOC_LO10, R_SPARC_LO10, }, 178 223 { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 }, 224 { BFD_RELOC_64_PCREL, R_SPARC_DISP64 }, 179 225 { BFD_RELOC_SPARC22, R_SPARC_22 }, 180 226 { BFD_RELOC_SPARC13, R_SPARC_13 }, … … 209 255 { BFD_RELOC_SPARC_6, R_SPARC_6 }, 210 256 { 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 211 284 { BFD_RELOC_SPARC_PLT64, R_SPARC_PLT64 }, 212 285 { BFD_RELOC_SPARC_HIX22, R_SPARC_HIX22 }, … … 236 309 bfd *abfd ATTRIBUTE_UNUSED; 237 310 arelent *cache_ptr; 238 Elf 64_Internal_Rela *dst;311 Elf_Internal_Rela *dst; 239 312 { 240 313 BFD_ASSERT (ELF64_R_TYPE_ID (dst->r_info) < (unsigned int) R_SPARC_max_std); … … 242 315 } 243 316 317 318 struct 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 244 328 245 329 /* Due to the way how we handle R_SPARC_OLO10, each entry in a SHT_RELA … … 267 351 for the same location, R_SPARC_LO10 and R_SPARC_13. */ 268 352 269 static b oolean353 static bfd_boolean 270 354 sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr, symbols, dynamic) 271 355 bfd *abfd; … … 273 357 Elf_Internal_Shdr *rel_hdr; 274 358 asymbol **symbols; 275 b oolean dynamic;359 bfd_boolean dynamic; 276 360 { 277 361 PTR allocated = NULL; … … 283 367 arelent *relents; 284 368 285 allocated = (PTR) bfd_malloc ( (size_t)rel_hdr->sh_size);369 allocated = (PTR) bfd_malloc (rel_hdr->sh_size); 286 370 if (allocated == NULL) 287 371 goto error_return; 288 372 289 373 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) 292 375 goto error_return; 293 376 294 377 native_relocs = (bfd_byte *) allocated; 295 378 296 relents = asect->relocation + asect->reloc_count;379 relents = asect->relocation + canon_reloc_count (asect); 297 380 298 381 entsize = rel_hdr->sh_entsize; … … 306 389 Elf_Internal_Rela rela; 307 390 308 bfd_elf64_swap_reloca_in (abfd, (Elf64_External_Rela *)native_relocs, &rela);391 bfd_elf64_swap_reloca_in (abfd, native_relocs, &rela); 309 392 310 393 /* The address of an ELF reloc is section relative for an object … … 349 432 } 350 433 351 asect->reloc_count+= relent - relents;434 canon_reloc_count (asect) += relent - relents; 352 435 353 436 if (allocated != NULL) 354 437 free (allocated); 355 438 356 return true;439 return TRUE; 357 440 358 441 error_return: 359 442 if (allocated != NULL) 360 443 free (allocated); 361 return false;444 return FALSE; 362 445 } 363 446 364 447 /* Read in and swap the external relocs. */ 365 448 366 static b oolean449 static bfd_boolean 367 450 sparc64_elf_slurp_reloc_table (abfd, asect, symbols, dynamic) 368 451 bfd *abfd; 369 452 asection *asect; 370 453 asymbol **symbols; 371 b oolean dynamic;454 bfd_boolean dynamic; 372 455 { 373 456 struct bfd_elf_section_data * const d = elf_section_data (asect); 374 457 Elf_Internal_Shdr *rel_hdr; 375 458 Elf_Internal_Shdr *rel_hdr2; 459 bfd_size_type amt; 376 460 377 461 if (asect->relocation != NULL) 378 return true;462 return TRUE; 379 463 380 464 if (! dynamic) … … 382 466 if ((asect->flags & SEC_RELOC) == 0 383 467 || asect->reloc_count == 0) 384 return true;468 return TRUE; 385 469 386 470 rel_hdr = &d->rel_hdr; … … 397 481 in elf.c does not update the RELOC_COUNT. */ 398 482 if (asect->_raw_size == 0) 399 return true;483 return TRUE; 400 484 401 485 rel_hdr = &d->this_hdr; … … 404 488 } 405 489 406 a sect->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); 409 493 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; 414 499 415 500 if (!sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr, symbols, 416 501 dynamic)) 417 return false;502 return FALSE; 418 503 419 504 if (rel_hdr2 420 505 && !sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr2, symbols, 421 506 dynamic)) 422 return false; 423 424 return true; 425 } 507 return FALSE; 508 509 return TRUE; 510 } 511 512 /* Canonicalize the relocs. */ 513 514 static long 515 sparc64_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 426 537 427 538 /* Canonicalize the dynamic relocation entries. Note that we return … … 458 569 long count, i; 459 570 460 if (! sparc64_elf_slurp_reloc_table (abfd, s, syms, true))571 if (! sparc64_elf_slurp_reloc_table (abfd, s, syms, TRUE)) 461 572 return -1; 462 count = s->reloc_count;573 count = canon_reloc_count (s); 463 574 p = s->relocation; 464 575 for (i = 0; i < count; i++) … … 481 592 PTR data; 482 593 { 483 b oolean *failedp = (boolean *) data;594 bfd_boolean *failedp = (bfd_boolean *) data; 484 595 Elf_Internal_Shdr *rela_hdr; 485 596 Elf64_External_Rela *outbound_relocas, *src_rela; … … 532 643 if (rela_hdr->contents == NULL) 533 644 { 534 *failedp = true;645 *failedp = TRUE; 535 646 return; 536 647 } … … 572 683 if (n < 0) 573 684 { 574 *failedp = true;685 *failedp = TRUE; 575 686 return; 576 687 } … … 582 693 && ! _bfd_elf_validate_reloc (abfd, ptr)) 583 694 { 584 *failedp = true;695 *failedp = TRUE; 585 696 return; 586 697 } … … 608 719 609 720 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); 611 722 ++src_rela; 612 723 } … … 643 754 { 644 755 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); 648 759 if (ret == (struct sparc64_elf_link_hash_table *) NULL) 649 760 return NULL; … … 652 763 _bfd_elf_link_hash_newfunc)) 653 764 { 654 bfd_release (abfd,ret);765 free (ret); 655 766 return NULL; 656 767 } … … 698 809 } 699 810 700 /* This works because partial_inplace == false. */811 /* This works because partial_inplace is FALSE. */ 701 812 if (output_bfd != NULL) 702 813 return bfd_reloc_continue; … … 764 875 return status; 765 876 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); 768 879 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address); 769 880 … … 803 914 804 915 relocation ^= MINUS_ONE; 805 insn = (insn & ~0x3fffff) | ((relocation >> 10) & 0x3fffff);916 insn = (insn &~ (bfd_vma) 0x3fffff) | ((relocation >> 10) & 0x3fffff); 806 917 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address); 807 918 … … 839 950 return status; 840 951 841 insn = (insn & ~0x1fff) | 0x1c00 | (relocation & 0x3ff);952 insn = (insn &~ (bfd_vma) 0x1fff) | 0x1c00 | (relocation & 0x3ff); 842 953 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address); 843 954 … … 871 982 872 983 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); 874 985 875 986 /* The first 32768 entries are close enough to plt1 to get there via … … 887 998 ba = 0x30680000 | (((contents+PLT_ENTRY_SIZE) - (entry+4)) / 4 & 0x7ffff); 888 999 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); 897 1008 } 898 1009 … … 912 1023 ptr = contents + i*PLT_ENTRY_SIZE + block*4*6 + j*8; 913 1024 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); 925 1042 } 926 1043 } … … 931 1048 static bfd_vma 932 1049 sparc64_elf_plt_entry_offset (index) 933 intindex;934 { 935 intblock, ofs;1050 bfd_vma index; 1051 { 1052 bfd_vma block, ofs; 936 1053 937 1054 if (index < LARGE_PLT_THRESHOLD) … … 943 1060 ofs = (index - LARGE_PLT_THRESHOLD) % 160; 944 1061 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; 947 1063 } 948 1064 949 1065 static bfd_vma 950 1066 sparc64_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; 954 1071 955 1072 BFD_ASSERT(index >= LARGE_PLT_THRESHOLD); … … 957 1074 /* See above for details. */ 958 1075 959 block = (((index - LARGE_PLT_THRESHOLD) / 160) * 160) 960 + LARGE_PLT_THRESHOLD; 1076 block = (((index - LARGE_PLT_THRESHOLD) / 160) * 160) + LARGE_PLT_THRESHOLD; 961 1077 ofs = index - block; 962 1078 if (block + 160 > max) … … 975 1091 table. */ 976 1092 977 static b oolean1093 static bfd_boolean 978 1094 sparc64_elf_check_relocs (abfd, info, sec, relocs) 979 1095 bfd *abfd; … … 993 1109 994 1110 if (info->relocateable || !(sec->flags & SEC_ALLOC)) 995 return true;1111 return TRUE; 996 1112 997 1113 dynobj = elf_hash_table (info)->dynobj; … … 1028 1144 elf_hash_table (info)->dynobj = dynobj = abfd; 1029 1145 if (! _bfd_elf_create_got_section (dynobj, info)) 1030 return false;1146 return FALSE; 1031 1147 } 1032 1148 … … 1052 1168 | SEC_READONLY)) 1053 1169 || ! bfd_set_section_alignment (dynobj, srelgot, 3)) 1054 return false;1170 return FALSE; 1055 1171 } 1056 1172 } … … 1069 1185 { 1070 1186 if (! bfd_elf64_link_record_dynamic_symbol (info, h)) 1071 return false;1187 return FALSE; 1072 1188 } 1073 1189 … … 1080 1196 if (local_got_offsets == NULL) 1081 1197 { 1082 size_tsize;1198 bfd_size_type size; 1083 1199 register unsigned int i; 1084 1200 1085 size = symtab_hdr->sh_info * sizeof (bfd_vma); 1201 size = symtab_hdr->sh_info; 1202 size *= sizeof (bfd_vma); 1086 1203 local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size); 1087 1204 if (local_got_offsets == NULL) 1088 return false;1205 return FALSE; 1089 1206 elf_local_got_offsets (abfd) = local_got_offsets; 1090 1207 for (i = 0; i < symtab_hdr->sh_info; i++) … … 1144 1261 table entry for a local symbol. */ 1145 1262 bfd_set_error (bfd_error_bad_value); 1146 return false;1263 return FALSE; 1147 1264 } 1148 1265 … … 1151 1268 { 1152 1269 if (! bfd_elf64_link_record_dynamic_symbol (info, h)) 1153 return false;1270 return FALSE; 1154 1271 } 1155 1272 1156 1273 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. */ 1159 1278 case R_SPARC_PC10: 1160 1279 case R_SPARC_PC22: … … 1221 1340 elf_section_data (sec)->rel_hdr.sh_name)); 1222 1341 if (name == NULL) 1223 return false;1342 return FALSE; 1224 1343 1225 1344 BFD_ASSERT (strncmp (name, ".rela", 5) == 0 … … 1240 1359 || ! bfd_set_section_flags (dynobj, sreloc, flags) 1241 1360 || ! bfd_set_section_alignment (dynobj, sreloc, 3)) 1242 return false;1361 return FALSE; 1243 1362 } 1363 if (sec->flags & SEC_READONLY) 1364 info->flags |= DF_TEXTREL; 1244 1365 } 1245 1366 … … 1254 1375 default: 1255 1376 (*_bfd_error_handler) (_("%s: check_relocs: unhandled reloc type %d"), 1256 bfd_ get_filename(abfd),1377 bfd_archive_filename (abfd), 1257 1378 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; 1263 1384 } 1264 1385 … … 1266 1387 file. We use it for STT_REGISTER symbols. */ 1267 1388 1268 static b oolean1389 static bfd_boolean 1269 1390 sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 1270 1391 bfd *abfd; … … 1276 1397 bfd_vma *valp ATTRIBUTE_UNUSED; 1277 1398 { 1278 static c har *stt_types[] = { "NOTYPE", "OBJECT", "FUNCTION" };1399 static const char *const stt_types[] = { "NOTYPE", "OBJECT", "FUNCTION" }; 1279 1400 1280 1401 if (ELF_ST_TYPE (sym->st_info) == STT_REGISTER) … … 1291 1412 (*_bfd_error_handler) 1292 1413 (_("%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; 1295 1416 } 1296 1417 … … 1302 1423 the output bfd. The dynamic linker will recheck it. */ 1303 1424 *namep = NULL; 1304 return true;1425 return TRUE; 1305 1426 } 1306 1427 … … 1310 1431 { 1311 1432 (*_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; 1318 1438 } 1319 1439 … … 1325 1445 1326 1446 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); 1328 1448 1329 1449 if (h != NULL) … … 1331 1451 unsigned char type = h->type; 1332 1452 1333 if (type > STT_FUNC) type = 0; 1453 if (type > STT_FUNC) 1454 type = 0; 1334 1455 (*_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; 1339 1460 } 1340 1461 … … 1342 1463 strlen (*namep) + 1); 1343 1464 if (!p->name) 1344 return false;1465 return FALSE; 1345 1466 1346 1467 strcpy (p->name, *namep); … … 1362 1483 } 1363 1484 *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) 1369 1489 { 1370 1490 int i; … … 1377 1497 unsigned char type = ELF_ST_TYPE (sym->st_info); 1378 1498 1379 if (type > STT_FUNC) type = 0; 1499 if (type > STT_FUNC) 1500 type = 0; 1380 1501 (*_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; 1386 1506 } 1387 1507 } 1388 return true;1508 return TRUE; 1389 1509 } 1390 1510 … … 1392 1512 which we cannot easily keep in the symbol hash table. */ 1393 1513 1394 static b oolean1514 static bfd_boolean 1395 1515 sparc64_elf_output_arch_syms (output_bfd, info, finfo, func) 1396 1516 bfd *output_bfd ATTRIBUTE_UNUSED; 1397 1517 struct bfd_link_info *info; 1398 1518 PTR finfo; 1399 b oolean (*func) PARAMS ((PTR, const char *,1400 1519 bfd_boolean (*func) 1520 PARAMS ((PTR, const char *, Elf_Internal_Sym *, asection *)); 1401 1521 { 1402 1522 int reg; … … 1426 1546 1427 1547 if (info->strip == strip_all) 1428 return true;1548 return TRUE; 1429 1549 1430 1550 for (reg = 0; reg < 4; reg++) … … 1434 1554 && bfd_hash_lookup (info->keep_hash, 1435 1555 app_regs [reg].name, 1436 false, false) == NULL)1556 FALSE, FALSE) == NULL) 1437 1557 continue; 1438 1558 … … 1445 1565 sym.st_shndx == SHN_ABS 1446 1566 ? bfd_abs_section_ptr : bfd_und_section_ptr)) 1447 return false;1567 return FALSE; 1448 1568 } 1449 1569 1450 return true;1570 return TRUE; 1451 1571 } 1452 1572 … … 1486 1606 understand. */ 1487 1607 1488 static b oolean1608 static bfd_boolean 1489 1609 sparc64_elf_adjust_dynamic_symbol (info, h) 1490 1610 struct bfd_link_info *info; … … 1530 1650 reloc instead. */ 1531 1651 BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0); 1532 return true;1652 return TRUE; 1533 1653 } 1534 1654 … … 1539 1659 if (s->_raw_size == 0) 1540 1660 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; 1541 1664 1542 1665 /* If this symbol is not defined in a regular file, and we are … … 1549 1672 { 1550 1673 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 } 1556 1676 1557 1677 /* Make room for this entry. */ … … 1570 1690 { 1571 1691 bfd_set_error (bfd_error_bad_value); 1572 return false;1573 } 1574 1575 return true;1692 return FALSE; 1693 } 1694 1695 return TRUE; 1576 1696 } 1577 1697 … … 1585 1705 h->root.u.def.section = h->weakdef->root.u.def.section; 1586 1706 h->root.u.def.value = h->weakdef->root.u.def.value; 1587 return true;1707 return TRUE; 1588 1708 } 1589 1709 … … 1596 1716 be handled correctly by relocate_section. */ 1597 1717 if (info->shared) 1598 return true;1718 return TRUE; 1599 1719 1600 1720 /* We must allocate the symbol in our .dynbss section, which will … … 1638 1758 { 1639 1759 if (! bfd_set_section_alignment (dynobj, s, power_of_two)) 1640 return false;1760 return FALSE; 1641 1761 } 1642 1762 … … 1648 1768 s->_raw_size += h->size; 1649 1769 1650 return true;1770 return TRUE; 1651 1771 } 1652 1772 1653 1773 /* Set the sizes of the dynamic sections. */ 1654 1774 1655 static b oolean1775 static bfd_boolean 1656 1776 sparc64_elf_size_dynamic_sections (output_bfd, info) 1657 1777 bfd *output_bfd; … … 1660 1780 bfd *dynobj; 1661 1781 asection *s; 1662 boolean reltext; 1663 boolean relplt; 1782 bfd_boolean relplt; 1664 1783 1665 1784 dynobj = elf_hash_table (info)->dynobj; … … 1692 1811 determined the sizes of the various dynamic sections. Allocate 1693 1812 memory for them. */ 1694 reltext = false; 1695 relplt = false; 1813 relplt = FALSE; 1696 1814 for (s = dynobj->sections; s != NULL; s = s->next) 1697 1815 { 1698 1816 const char *name; 1699 b oolean strip;1817 bfd_boolean strip; 1700 1818 1701 1819 if ((s->flags & SEC_LINKER_CREATED) == 0) … … 1706 1824 name = bfd_get_section_name (dynobj, s); 1707 1825 1708 strip = false;1826 strip = FALSE; 1709 1827 1710 1828 if (strncmp (name, ".rela", 5) == 0) … … 1721 1839 function which decides whether anything needs to go 1722 1840 into these sections. */ 1723 strip = true;1841 strip = TRUE; 1724 1842 } 1725 1843 else 1726 1844 { 1727 const char *outname;1728 asection *target;1729 1730 /* If this relocation section applies to a read only1731 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 != NULL1736 && (target->flags & SEC_READONLY) != 0)1737 reltext = true;1738 1739 1845 if (strcmp (name, ".rela.plt") == 0) 1740 relplt = true;1846 relplt = TRUE; 1741 1847 1742 1848 /* We use the reloc_count field as a counter if we need … … 1763 1869 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); 1764 1870 if (s->contents == NULL && s->_raw_size != 0) 1765 return false;1871 return FALSE; 1766 1872 } 1767 1873 … … 1773 1879 the .dynamic section. The DT_DEBUG entry is filled in by the 1774 1880 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 1775 1884 int reg; 1776 1885 struct sparc64_elf_app_reg * app_regs; 1777 struct bfd_strtab_hash *dynstr;1886 struct elf_strtab_hash *dynstr; 1778 1887 struct elf_link_hash_table *eht = elf_hash_table (info); 1779 1888 1780 if (! 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; 1784 1893 } 1785 1894 1786 1895 if (relplt) 1787 1896 { 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; 1806 1913 } 1807 1914 … … 1816 1923 struct elf_link_local_dynamic_entry *entry, *e; 1817 1924 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; 1820 1927 1821 1928 entry = (struct elf_link_local_dynamic_entry *) 1822 1929 bfd_hash_allocate (&info->hash->table, sizeof (*entry)); 1823 1930 if (entry == NULL) 1824 return false;1931 return FALSE; 1825 1932 1826 1933 /* We cheat here a little bit: the symbol will not be local, so we … … 1831 1938 if (*app_regs [reg].name != '\0') 1832 1939 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); 1834 1941 else 1835 1942 entry->isym.st_name = 0; … … 1853 1960 } 1854 1961 } 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 1968 static bfd_boolean 1969 sparc64_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 1984 static bfd_boolean 1864 1985 sparc64_elf_relax_section (abfd, section, link_info, again) 1865 1986 bfd *abfd ATTRIBUTE_UNUSED; 1866 1987 asection *section ATTRIBUTE_UNUSED; 1867 1988 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)) 1875 2007 1876 2008 /* Relocate a SPARC64 ELF section. */ 1877 2009 1878 static b oolean2010 static bfd_boolean 1879 2011 sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 1880 2012 contents, relocs, local_syms, local_sections) … … 1899 2031 Elf_Internal_Rela *relend; 1900 2032 2033 if (info->relocateable) 2034 return TRUE; 2035 1901 2036 dynobj = elf_hash_table (info)->dynobj; 1902 2037 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; … … 1921 2056 Elf_Internal_Sym *sym; 1922 2057 asection *sec; 1923 bfd_vma relocation ;2058 bfd_vma relocation, off; 1924 2059 bfd_reloc_status_type r; 2060 bfd_boolean is_plt = FALSE; 2061 bfd_boolean unresolved_reloc; 1925 2062 1926 2063 r_type = ELF64_R_TYPE_ID (rel->r_info); … … 1928 2065 { 1929 2066 bfd_set_error (bfd_error_bad_value); 1930 return false;2067 return FALSE; 1931 2068 } 1932 2069 howto = sparc64_elf_howto_table + r_type; 1933 2070 2071 /* This is a final link. */ 1934 2072 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 change1939 anything, unless the reloc is against a section symbol,1940 in which case we have to adjust according to where the1941 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. */1956 2073 h = NULL; 1957 2074 sym = NULL; 1958 2075 sec = NULL; 2076 unresolved_reloc = FALSE; 1959 2077 if (r_symndx < symtab_hdr->sh_info) 1960 2078 { 1961 2079 sym = local_syms + r_symndx; 1962 2080 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); 1966 2082 } 1967 2083 else … … 1971 2087 || h->root.type == bfd_link_hash_warning) 1972 2088 h = (struct elf_link_hash_entry *) h->root.u.i.link; 2089 2090 relocation = 0; 1973 2091 if (h->root.type == bfd_link_hash_defined 1974 2092 || h->root.type == bfd_link_hash_defweak) 1975 2093 { 1976 boolean skip_it = false;1977 2094 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; 2061 2101 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); 2067 2105 } 2068 2106 else if (h->root.type == bfd_link_hash_undefweak) 2069 relocation = 0;2070 else if (info->shared && !info->symbolic2107 ; 2108 else if (info->shared 2071 2109 && !info->no_undefined 2072 2110 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) 2073 relocation = 0;2111 ; 2074 2112 else 2075 2113 { … … 2079 2117 (!info->shared || info->no_undefined 2080 2118 || ELF_ST_VISIBILITY (h->other))))) 2081 return false;2119 return FALSE; 2082 2120 2083 2121 /* To avoid generating warning messages about truncated 2084 2122 relocations, set the relocation's address to be the same as 2085 2123 the start of this section. */ 2086 2087 2124 if (input_section->output_section != NULL) 2088 2125 relocation = input_section->output_section->vma; … … 2092 2129 } 2093 2130 2131 do_dynreloc: 2094 2132 /* When generating a shared object, these relocations are copied 2095 2133 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)) 2097 2135 { 2098 2136 switch (r_type) … … 2110 2148 case R_SPARC_DISP16: 2111 2149 case R_SPARC_DISP32: 2150 case R_SPARC_DISP64: 2112 2151 case R_SPARC_WDISP30: 2113 2152 case R_SPARC_WDISP22: 2114 2153 case R_SPARC_WDISP19: 2115 2154 case R_SPARC_WDISP16: 2116 case R_SPARC_DISP64:2117 2155 if (h == NULL) 2118 2156 break; … … 2145 2183 { 2146 2184 Elf_Internal_Rela outrel; 2147 boolean skip; 2185 bfd_byte *loc; 2186 bfd_boolean skip, relocate; 2148 2187 2149 2188 if (sreloc == NULL) … … 2156 2195 2157 2196 if (name == NULL) 2158 return false;2197 return FALSE; 2159 2198 2160 2199 BFD_ASSERT (strncmp (name, ".rela", 5) == 0 … … 2167 2206 } 2168 2207 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; 2186 2218 2187 2219 outrel.r_offset += (input_section->output_section->vma … … 2210 2242 if (!(outrel.r_offset & 7)) r_type = R_SPARC_64; 2211 2243 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; 2212 2256 } 2213 2257 … … 2216 2260 /* h->dynindx may be -1 if the symbol was marked to 2217 2261 become local. */ 2218 else if (h != NULL 2262 else if (h != NULL && ! is_plt 2219 2263 && ((! info->symbolic && h->dynindx != -1) 2220 2264 || (h->elf_link_hash_flags … … 2231 2275 else 2232 2276 { 2277 outrel.r_addend = relocation + rel->r_addend; 2233 2278 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); 2238 2280 else 2239 2281 { 2240 2282 long indx; 2241 2283 2242 if (h == NULL) 2284 if (is_plt) 2285 sec = splt; 2286 else if (h == NULL) 2243 2287 sec = local_sections[r_symndx]; 2244 2288 else … … 2254 2298 { 2255 2299 bfd_set_error (bfd_error_bad_value); 2256 return false;2300 return FALSE; 2257 2301 } 2258 2302 else … … 2262 2306 osec = sec->output_section; 2263 2307 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; 2264 2315 2265 2316 /* FIXME: we really should be able to link non-pic … … 2270 2321 (*_bfd_error_handler) 2271 2322 (_("%s: probably compiled without -fPIC?"), 2272 bfd_ get_filename (input_bfd));2323 bfd_archive_filename (input_bfd)); 2273 2324 bfd_set_error (bfd_error_bad_value); 2274 return false;2325 return FALSE; 2275 2326 } 2276 2327 } … … 2281 2332 ELF64_R_TYPE_DATA (rel->r_info), 2282 2333 r_type)); 2283 outrel.r_addend = relocation + rel->r_addend;2284 2334 } 2285 2335 } 2286 2336 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); 2292 2340 2293 2341 /* 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) 2299 2344 continue; 2300 2345 } … … 2318 2363 if (h != NULL) 2319 2364 { 2320 bfd_vma off = h->got.offset; 2365 bfd_boolean dyn; 2366 2367 off = h->got.offset; 2321 2368 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) 2324 2372 || (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))) 2328 2377 { 2329 2378 /* This is actually a static link, or it is a -Bsymbolic … … 2348 2397 } 2349 2398 } 2350 relocation = sgot->output_offset + off - got_base; 2399 else 2400 unresolved_reloc = FALSE; 2351 2401 } 2352 2402 else 2353 2403 { 2354 bfd_vma off;2355 2356 2404 BFD_ASSERT (local_got_offsets != NULL); 2357 2405 off = local_got_offsets[r_symndx]; … … 2369 2417 if (info->shared) 2370 2418 { 2371 asection *s relgot;2419 asection *s; 2372 2420 Elf_Internal_Rela outrel; 2421 bfd_byte *loc; 2373 2422 2374 2423 /* The Solaris 2.7 64-bit linker adds the contents … … 2377 2426 32-bit linker, which both adds the contents 2378 2427 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); 2380 2430 2381 2431 /* We need to generate a R_SPARC_RELATIVE reloc 2382 2432 for the dynamic linker. */ 2383 s relgot= bfd_get_section_by_name(dynobj, ".rela.got");2384 BFD_ASSERT (s relgot!= NULL);2433 s = bfd_get_section_by_name(dynobj, ".rela.got"); 2434 BFD_ASSERT (s != NULL); 2385 2435 2386 2436 outrel.r_offset = (sgot->output_section->vma … … 2389 2439 outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE); 2390 2440 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); 2396 2444 } 2397 2445 else 2398 2446 bfd_put_64 (output_bfd, relocation, sgot->contents + off); 2399 2447 } 2400 relocation = sgot->output_offset + off - got_base;2401 2448 } 2449 relocation = sgot->output_offset + off - got_base; 2402 2450 goto do_default; 2403 2451 … … 2431 2479 + splt->output_offset 2432 2480 + sparc64_elf_plt_entry_offset (h->plt.offset)); 2481 unresolved_reloc = FALSE; 2433 2482 if (r_type == R_SPARC_WPLT30) 2434 2483 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 } 2435 2490 goto do_default; 2436 2491 … … 2443 2498 2444 2499 x = bfd_get_32 (input_bfd, contents + rel->r_offset); 2445 x = (x & ~ 0x1fff) | (relocation & 0x1fff);2500 x = (x & ~(bfd_vma) 0x1fff) | (relocation & 0x1fff); 2446 2501 bfd_put_32 (input_bfd, x, contents + rel->r_offset); 2447 2502 … … 2464 2519 2465 2520 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)); 2468 2524 bfd_put_32 (input_bfd, x, contents + rel->r_offset); 2469 2525 … … 2483 2539 2484 2540 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); 2486 2542 bfd_put_32 (input_bfd, x, contents + rel->r_offset); 2487 2543 … … 2501 2557 2502 2558 x = bfd_get_32 (input_bfd, contents + rel->r_offset); 2503 x = (x & ~ 0x1fff) | relocation;2559 x = (x & ~(bfd_vma) 0x1fff) | relocation; 2504 2560 bfd_put_32 (input_bfd, x, contents + rel->r_offset); 2505 2561 … … 2510 2566 case R_SPARC_WDISP30: 2511 2567 do_wplt30: 2512 if ( SEC_DO_RELAX(input_section)2568 if (sec_do_relax (input_section) 2513 2569 && rel->r_offset + 4 < input_section->_raw_size) 2514 2570 { … … 2590 2646 break; 2591 2647 2592 bfd_put_32 (input_bfd, INSN_NOP,2648 bfd_put_32 (input_bfd, (bfd_vma) INSN_NOP, 2593 2649 contents + rel->r_offset + 4); 2594 2650 } … … 2597 2653 } 2598 2654 } 2599 /* F ALLTHROUGH*/2655 /* Fall through. */ 2600 2656 2601 2657 default: … … 2607 2663 } 2608 2664 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 2609 2678 switch (r) 2610 2679 { … … 2619 2688 { 2620 2689 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; 2621 2699 2622 2700 if (h != NULL) … … 2642 2720 sym->st_name)); 2643 2721 if (name == NULL) 2644 return false;2722 return FALSE; 2645 2723 if (*name == '\0') 2646 2724 name = bfd_section_name (input_bfd, sec); … … 2649 2727 (info, name, howto->name, (bfd_vma) 0, 2650 2728 input_bfd, input_section, rel->r_offset))) 2651 return false;2729 return FALSE; 2652 2730 } 2653 2731 break; … … 2655 2733 } 2656 2734 2657 return true;2735 return TRUE; 2658 2736 } 2659 2737 … … 2661 2739 dynamic sections here. */ 2662 2740 2663 static b oolean2741 static bfd_boolean 2664 2742 sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) 2665 2743 bfd *output_bfd; … … 2677 2755 asection *srela; 2678 2756 Elf_Internal_Rela rela; 2757 bfd_byte *loc; 2679 2758 2680 2759 /* This symbol has an entry in the PLT. Set it up. */ … … 2695 2774 else 2696 2775 { 2697 intmax = splt->_raw_size / PLT_ENTRY_SIZE;2776 bfd_vma max = splt->_raw_size / PLT_ENTRY_SIZE; 2698 2777 rela.r_offset = sparc64_elf_plt_ptr_offset (h->plt.offset, max); 2699 2778 rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4) … … 2708 2787 thus .plt[4] has corresponding .rela.plt[0] and so on. */ 2709 2788 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); 2713 2792 2714 2793 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) … … 2732 2811 asection *srela; 2733 2812 Elf_Internal_Rela rela; 2813 bfd_byte *loc; 2734 2814 2735 2815 /* This symbol has an entry in the GOT. Set it up. */ … … 2741 2821 rela.r_offset = (sgot->output_section->vma 2742 2822 + sgot->output_offset 2743 + (h->got.offset &~ 1));2823 + (h->got.offset &~ (bfd_vma) 1)); 2744 2824 2745 2825 /* If this is a -Bsymbolic link, and the symbol is defined … … 2760 2840 else 2761 2841 { 2762 bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);2763 2842 rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_GLOB_DAT); 2764 2843 rela.r_addend = 0; 2765 2844 } 2766 2845 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); 2771 2851 } 2772 2852 … … 2775 2855 asection *s; 2776 2856 Elf_Internal_Rela rela; 2857 bfd_byte *loc; 2777 2858 2778 2859 /* This symbols needs a copy reloc. Set it up. */ 2779 2780 2860 BFD_ASSERT (h->dynindx != -1); 2781 2861 … … 2789 2869 rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_COPY); 2790 2870 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); 2795 2873 } 2796 2874 … … 2801 2879 sym->st_shndx = SHN_ABS; 2802 2880 2803 return true;2881 return TRUE; 2804 2882 } 2805 2883 2806 2884 /* Finish up the dynamic sections. */ 2807 2885 2808 static b oolean2886 static bfd_boolean 2809 2887 sparc64_elf_finish_dynamic_sections (output_bfd, info) 2810 2888 bfd *output_bfd; … … 2834 2912 Elf_Internal_Dyn dyn; 2835 2913 const char *name; 2836 b oolean size;2914 bfd_boolean size; 2837 2915 2838 2916 bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn); … … 2840 2918 switch (dyn.d_tag) 2841 2919 { 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; 2845 2923 case DT_SPARC_REGISTER: 2846 2924 if (stt_regidx == -1) … … 2849 2927 _bfd_elf_link_lookup_local_dynindx (info, output_bfd, -1); 2850 2928 if (stt_regidx == -1) 2851 return false;2929 return FALSE; 2852 2930 } 2853 2931 dyn.d_un.d_val = stt_regidx++; 2854 2932 bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); 2855 2933 /* fallthrough */ 2856 default: name = NULL; size = false; break;2934 default: name = NULL; size = FALSE; break; 2857 2935 } 2858 2936 … … 2882 2960 /* Initialize the contents of the .plt section. */ 2883 2961 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)); 2888 2964 2889 2965 elf_section_data (splt->output_section)->this_hdr.sh_entsize = … … 2907 2983 elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 8; 2908 2984 2909 return true; 2985 return TRUE; 2986 } 2987 2988 static enum elf_reloc_type_class 2989 sparc64_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 } 2910 3003 } 2911 3004 2912 3005 2913 3006 /* Functions for dealing with the e_flags field. */ 2914 2915 /* Copy backend specific data from one object module to another */2916 static boolean2917 sparc64_elf_copy_private_bfd_data (ibfd, obfd)2918 bfd *ibfd, *obfd;2919 {2920 if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour2921 || bfd_get_flavour (obfd) != bfd_target_elf_flavour)2922 return true;2923 2924 BFD_ASSERT (!elf_flags_init (obfd)2925 || (elf_elfheader (obfd)->e_flags2926 == 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 }2932 3007 2933 3008 /* Merge backend specific data from an object file to the output 2934 3009 object file when linking. */ 2935 3010 2936 static b oolean3011 static bfd_boolean 2937 3012 sparc64_elf_merge_private_bfd_data (ibfd, obfd) 2938 3013 bfd *ibfd; 2939 3014 bfd *obfd; 2940 3015 { 2941 b oolean error;3016 bfd_boolean error; 2942 3017 flagword new_flags, old_flags; 2943 3018 int new_mm, old_mm; … … 2945 3020 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour 2946 3021 || bfd_get_flavour (obfd) != bfd_target_elf_flavour) 2947 return true;3022 return TRUE; 2948 3023 2949 3024 new_flags = elf_elfheader (ibfd)->e_flags; … … 2952 3027 if (!elf_flags_init (obfd)) /* First call, no flags set */ 2953 3028 { 2954 elf_flags_init (obfd) = true;3029 elf_flags_init (obfd) = TRUE; 2955 3030 elf_elfheader (obfd)->e_flags = new_flags; 2956 3031 } … … 2961 3036 else /* Incompatible flags */ 2962 3037 { 2963 error = false;3038 error = FALSE; 2964 3039 2965 3040 #define EF_SPARC_ISA_EXTENSIONS \ … … 2983 3058 && (old_flags & EF_SPARC_HAL_R1)) 2984 3059 { 2985 error = true;3060 error = TRUE; 2986 3061 (*_bfd_error_handler) 2987 3062 (_("%s: linking UltraSPARC specific with HAL specific code"), 2988 bfd_ get_filename (ibfd));3063 bfd_archive_filename (ibfd)); 2989 3064 } 2990 3065 /* Choose the most restrictive memory ordering. */ … … 3002 3077 if (new_flags != old_flags) 3003 3078 { 3004 error = true;3079 error = TRUE; 3005 3080 (*_bfd_error_handler) 3006 3081 (_("%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); 3008 3083 } 3009 3084 … … 3013 3088 { 3014 3089 bfd_set_error (bfd_error_bad_value); 3015 return false;3090 return FALSE; 3016 3091 } 3017 3092 } 3018 return true; 3093 return TRUE; 3094 } 3095 3096 /* MARCO: Set the correct entry size for the .stab section. */ 3097 3098 static bfd_boolean 3099 sparc64_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; 3019 3115 } 3020 3116 … … 3040 3136 ((type & BSF_LOCAL) 3041 3137 ? (type & BSF_GLOBAL) ? '!' : 'l' 3042 3043 3138 : (type & BSF_GLOBAL) ? 'g' : ' '), 3139 (type & BSF_WEAK) ? 'w' : ' '); 3044 3140 if (symbol->name == NULL || symbol->name [0] == '\0') 3045 3141 return "#scratch"; … … 3051 3147 /* Set the right machine number for a SPARC64 ELF file. */ 3052 3148 3053 static b oolean3149 static bfd_boolean 3054 3150 sparc64_elf_object_p (abfd) 3055 3151 bfd *abfd; … … 3079 3175 sizeof (Elf64_External_Dyn), 3080 3176 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. 3083 3179 For link purposes we use just 1 internal per 3084 3180 1 external, for assembly and slurp symbol table 3085 3181 we use 2. */ 3086 3182 1, 3087 64, /* arch_size */3088 8, /* file_align */3183 64, /* arch_size. */ 3184 8, /* file_align. */ 3089 3185 ELFCLASS64, 3090 3186 EV_CURRENT, … … 3092 3188 bfd_elf64_write_shdrs_and_ehdr, 3093 3189 sparc64_elf_write_relocs, 3190 bfd_elf64_swap_symbol_in, 3094 3191 bfd_elf64_swap_symbol_out, 3095 3192 sparc64_elf_slurp_reloc_table, … … 3097 3194 bfd_elf64_swap_dyn_in, 3098 3195 bfd_elf64_swap_dyn_out, 3099 NULL,3100 NULL,3101 NULL,3102 NULL3196 bfd_elf64_swap_reloc_in, 3197 bfd_elf64_swap_reloc_out, 3198 bfd_elf64_swap_reloca_in, 3199 bfd_elf64_swap_reloca_out 3103 3200 }; 3104 3201 … … 3123 3220 #define bfd_elf64_get_dynamic_reloc_upper_bound \ 3124 3221 sparc64_elf_get_dynamic_reloc_upper_bound 3222 #define bfd_elf64_canonicalize_reloc \ 3223 sparc64_elf_canonicalize_reloc 3125 3224 #define bfd_elf64_canonicalize_dynamic_reloc \ 3126 3225 sparc64_elf_canonicalize_dynamic_reloc … … 3129 3228 #define bfd_elf64_bfd_relax_section \ 3130 3229 sparc64_elf_relax_section 3230 #define bfd_elf64_new_section_hook \ 3231 sparc64_elf_new_section_hook 3131 3232 3132 3233 #define elf_backend_create_dynamic_sections \ … … 3154 3255 #define elf_backend_output_arch_syms \ 3155 3256 sparc64_elf_output_arch_syms 3156 #define bfd_elf64_bfd_copy_private_bfd_data \3157 sparc64_elf_copy_private_bfd_data3158 3257 #define bfd_elf64_bfd_merge_private_bfd_data \ 3159 3258 sparc64_elf_merge_private_bfd_data 3259 #define elf_backend_fake_sections \ 3260 sparc64_elf_fake_sections 3160 3261 3161 3262 #define elf_backend_size_info \ … … 3163 3264 #define elf_backend_object_p \ 3164 3265 sparc64_elf_object_p 3266 #define elf_backend_reloc_type_class \ 3267 sparc64_elf_reloc_type_class 3165 3268 3166 3269 #define elf_backend_want_got_plt 0 3167 3270 #define elf_backend_plt_readonly 0 3168 3271 #define elf_backend_want_plt_sym 1 3272 #define elf_backend_rela_normal 1 3169 3273 3170 3274 /* Section 5.2.4 of the ABI specifies a 256-byte boundary for the table. */ -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.