Changeset 609 for branches/GNU/src/binutils/bfd/elfxx-ia64.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/elfxx-ia64.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* IA-64 support for 64-bit ELF 2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.2 Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 3 3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com> 4 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. */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" … … 26 26 #include "elf/ia64.h" 27 27 28 /* 29 * THE RULES for all the stuff the linker creates -- 30 * 31 * GOT Entries created in response to LTOFF or LTOFF_FPTR 32 * relocations. Dynamic relocs created for dynamic 33 * symbols in an application; REL relocs for locals 34 * in a shared library. 35 * 36 * FPTR The canonical function descriptor. Created for local 37 * symbols in applications. Descriptors for dynamic symbols 38 * and local symbols in shared libraries are created by 39 * ld.so. Thus there are no dynamic relocs against these 40 * objects. The FPTR relocs for such _are_ passed through 41 * to the dynamic relocation tables. 42 * 43 * FULL_PLT Created for a PCREL21B relocation against a dynamic symbol. 44 * Requires the creation of a PLTOFF entry. This does not 45 * require any dynamic relocations. 46 * 47 * PLTOFF Created by PLTOFF relocations. For local symbols, this 48 * is an alternate function descriptor, and in shared libraries 49 * requires two REL relocations. Note that this cannot be 50 * transformed into an FPTR relocation, since it must be in 51 * range of the GP. For dynamic symbols, this is a function 52 * descriptor for a MIN_PLT entry, and requires one IPLT reloc. 53 * 54 * MIN_PLT Created by PLTOFF entries against dynamic symbols. This 55 * does not reqire dynamic relocations. 56 */ 57 58 #define USE_RELA /* we want RELA relocs, not REL */ 28 /* THE RULES for all the stuff the linker creates -- 29 30 GOT Entries created in response to LTOFF or LTOFF_FPTR 31 relocations. Dynamic relocs created for dynamic 32 symbols in an application; REL relocs for locals 33 in a shared library. 34 35 FPTR The canonical function descriptor. Created for local 36 symbols in applications. Descriptors for dynamic symbols 37 and local symbols in shared libraries are created by 38 ld.so. Thus there are no dynamic relocs against these 39 objects. The FPTR relocs for such _are_ passed through 40 to the dynamic relocation tables. 41 42 FULL_PLT Created for a PCREL21B relocation against a dynamic symbol. 43 Requires the creation of a PLTOFF entry. This does not 44 require any dynamic relocations. 45 46 PLTOFF Created by PLTOFF relocations. For local symbols, this 47 is an alternate function descriptor, and in shared libraries 48 requires two REL relocations. Note that this cannot be 49 transformed into an FPTR relocation, since it must be in 50 range of the GP. For dynamic symbols, this is a function 51 descriptor for a MIN_PLT entry, and requires one IPLT reloc. 52 53 MIN_PLT Created by PLTOFF entries against dynamic symbols. This 54 does not reqire dynamic relocations. */ 59 55 60 56 #define NELEMS(a) ((int) (sizeof (a) / sizeof ((a)[0]))) … … 80 76 bfd_vma plt_offset; 81 77 bfd_vma plt2_offset; 78 bfd_vma tprel_offset; 79 bfd_vma dtpmod_offset; 80 bfd_vma dtprel_offset; 82 81 83 82 /* The symbol table entry, if any, that this was derrived from. */ … … 94 93 } *reloc_entries; 95 94 96 /* T ruewhen the section contents have been updated. */95 /* TRUE when the section contents have been updated. */ 97 96 unsigned got_done : 1; 98 97 unsigned fptr_done : 1; 99 98 unsigned pltoff_done : 1; 100 101 /* True for the different kinds of linker data we want created. */ 99 unsigned tprel_done : 1; 100 unsigned dtpmod_done : 1; 101 unsigned dtprel_done : 1; 102 103 /* TRUE for the different kinds of linker data we want created. */ 102 104 unsigned want_got : 1; 105 unsigned want_gotx : 1; 103 106 unsigned want_fptr : 1; 104 107 unsigned want_ltoff_fptr : 1; … … 106 109 unsigned want_plt2 : 1; 107 110 unsigned want_pltoff : 1; 111 unsigned want_tprel : 1; 112 unsigned want_dtpmod : 1; 113 unsigned want_dtprel : 1; 108 114 }; 109 115 … … 112 118 struct bfd_hash_entry root; 113 119 struct elfNN_ia64_dyn_sym_info *info; 120 121 /* TRUE if this hash entry's addends was translated for 122 SHF_MERGE optimization. */ 123 unsigned sec_merge_done : 1; 114 124 }; 115 125 … … 128 138 struct elfNN_ia64_link_hash_table 129 139 { 130 /* The main hash table */140 /* The main hash table. */ 131 141 struct elf_link_hash_table root; 132 142 … … 139 149 140 150 bfd_size_type minplt_entries; /* number of minplt entries */ 151 unsigned reltext : 1; /* are there relocs against readonly sections? */ 152 unsigned self_dtpmod_done : 1;/* has self DTPMOD entry been finished? */ 153 bfd_vma self_dtpmod_offset; /* .got offset to self DTPMOD entry */ 141 154 142 155 struct elfNN_ia64_local_hash_table loc_hash_table; 156 }; 157 158 struct elfNN_ia64_allocate_data 159 { 160 struct bfd_link_info *info; 161 bfd_size_type ofs; 143 162 }; 144 163 … … 154 173 PARAMS ((bfd *abfd, bfd_reloc_code_real_type bfd_code)); 155 174 static void elfNN_ia64_info_to_howto 156 PARAMS ((bfd *abfd, arelent *bfd_reloc, Elf NN_Internal_Rela *elf_reloc));157 static b oolean elfNN_ia64_relax_section175 PARAMS ((bfd *abfd, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc)); 176 static bfd_boolean elfNN_ia64_relax_section 158 177 PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info, 159 boolean *again)); 160 static boolean is_unwind_section_name 161 PARAMS ((const char *)); 162 static boolean elfNN_ia64_section_from_shdr 163 PARAMS ((bfd *, ElfNN_Internal_Shdr *, char *)); 164 static boolean elfNN_ia64_fake_sections 165 PARAMS ((bfd *abfd, ElfNN_Internal_Shdr *hdr, asection *sec)); 178 bfd_boolean *again)); 179 static void elfNN_ia64_relax_ldxmov 180 PARAMS((bfd *abfd, bfd_byte *contents, bfd_vma off)); 181 static bfd_boolean is_unwind_section_name 182 PARAMS ((bfd *abfd, const char *)); 183 static bfd_boolean elfNN_ia64_section_from_shdr 184 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *)); 185 static bfd_boolean elfNN_ia64_section_flags 186 PARAMS ((flagword *, Elf_Internal_Shdr *)); 187 static bfd_boolean elfNN_ia64_fake_sections 188 PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec)); 166 189 static void elfNN_ia64_final_write_processing 167 PARAMS ((bfd *abfd, b oolean linker));168 static b oolean elfNN_ia64_add_symbol_hook190 PARAMS ((bfd *abfd, bfd_boolean linker)); 191 static bfd_boolean elfNN_ia64_add_symbol_hook 169 192 PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym, 170 193 const char **namep, flagword *flagsp, asection **secp, 171 194 bfd_vma *valp)); 195 static bfd_boolean elfNN_ia64_aix_vec 196 PARAMS ((const bfd_target *vec)); 197 static bfd_boolean elfNN_ia64_aix_add_symbol_hook 198 PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym, 199 const char **namep, flagword *flagsp, asection **secp, 200 bfd_vma *valp)); 201 static bfd_boolean elfNN_ia64_aix_link_add_symbols 202 PARAMS ((bfd *abfd, struct bfd_link_info *info)); 172 203 static int elfNN_ia64_additional_program_headers 173 204 PARAMS ((bfd *abfd)); 174 static boolean elfNN_ia64_is_local_label_name 205 static bfd_boolean elfNN_ia64_modify_segment_map 206 PARAMS ((bfd *)); 207 static bfd_boolean elfNN_ia64_is_local_label_name 175 208 PARAMS ((bfd *abfd, const char *name)); 176 static b oolean elfNN_ia64_dynamic_symbol_p209 static bfd_boolean elfNN_ia64_dynamic_symbol_p 177 210 PARAMS ((struct elf_link_hash_entry *h, struct bfd_link_info *info)); 178 static b oolean elfNN_ia64_local_hash_table_init211 static bfd_boolean elfNN_ia64_local_hash_table_init 179 212 PARAMS ((struct elfNN_ia64_local_hash_table *ht, bfd *abfd, 180 213 new_hash_entry_func new)); … … 185 218 PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table, 186 219 const char *string)); 220 static void elfNN_ia64_hash_copy_indirect 221 PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *, 222 struct elf_link_hash_entry *)); 223 static void elfNN_ia64_hash_hide_symbol 224 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean)); 187 225 static struct bfd_link_hash_table *elfNN_ia64_hash_table_create 188 226 PARAMS ((bfd *abfd)); 189 227 static struct elfNN_ia64_local_hash_entry *elfNN_ia64_local_hash_lookup 190 228 PARAMS ((struct elfNN_ia64_local_hash_table *table, const char *string, 191 boolean create, boolean copy)); 229 bfd_boolean create, bfd_boolean copy)); 230 static bfd_boolean elfNN_ia64_global_dyn_sym_thunk 231 PARAMS ((struct bfd_hash_entry *, PTR)); 232 static bfd_boolean elfNN_ia64_local_dyn_sym_thunk 233 PARAMS ((struct bfd_hash_entry *, PTR)); 192 234 static void elfNN_ia64_dyn_sym_traverse 193 235 PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info, 194 b oolean (*func) (struct elfNN_ia64_dyn_sym_info *, PTR),236 bfd_boolean (*func) (struct elfNN_ia64_dyn_sym_info *, PTR), 195 237 PTR info)); 196 static b oolean elfNN_ia64_create_dynamic_sections238 static bfd_boolean elfNN_ia64_create_dynamic_sections 197 239 PARAMS ((bfd *abfd, struct bfd_link_info *info)); 240 static struct elfNN_ia64_local_hash_entry * get_local_sym_hash 241 PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info, 242 bfd *abfd, const Elf_Internal_Rela *rel, bfd_boolean create)); 198 243 static struct elfNN_ia64_dyn_sym_info * get_dyn_sym_info 199 244 PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info, 200 245 struct elf_link_hash_entry *h, 201 bfd *abfd, const Elf_Internal_Rela *rel, b oolean create));246 bfd *abfd, const Elf_Internal_Rela *rel, bfd_boolean create)); 202 247 static asection *get_got 203 248 PARAMS ((bfd *abfd, struct bfd_link_info *info, … … 211 256 static asection *get_reloc_section 212 257 PARAMS ((bfd *abfd, struct elfNN_ia64_link_hash_table *ia64_info, 213 asection *sec, b oolean create));214 static b oolean count_dyn_reloc258 asection *sec, bfd_boolean create)); 259 static bfd_boolean count_dyn_reloc 215 260 PARAMS ((bfd *abfd, struct elfNN_ia64_dyn_sym_info *dyn_i, 216 261 asection *srel, int type)); 217 static b oolean elfNN_ia64_check_relocs262 static bfd_boolean elfNN_ia64_check_relocs 218 263 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec, 219 264 const Elf_Internal_Rela *relocs)); 220 static b oolean elfNN_ia64_adjust_dynamic_symbol265 static bfd_boolean elfNN_ia64_adjust_dynamic_symbol 221 266 PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h)); 222 static unsignedlong global_sym_index267 static long global_sym_index 223 268 PARAMS ((struct elf_link_hash_entry *h)); 224 static b oolean allocate_fptr269 static bfd_boolean allocate_fptr 225 270 PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); 226 static b oolean allocate_global_data_got271 static bfd_boolean allocate_global_data_got 227 272 PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); 228 static b oolean allocate_global_fptr_got273 static bfd_boolean allocate_global_fptr_got 229 274 PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); 230 static b oolean allocate_local_got275 static bfd_boolean allocate_local_got 231 276 PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); 232 static b oolean allocate_pltoff_entries277 static bfd_boolean allocate_pltoff_entries 233 278 PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); 234 static b oolean allocate_plt_entries279 static bfd_boolean allocate_plt_entries 235 280 PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); 236 static b oolean allocate_plt2_entries281 static bfd_boolean allocate_plt2_entries 237 282 PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); 238 static b oolean allocate_dynrel_entries283 static bfd_boolean allocate_dynrel_entries 239 284 PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); 240 static b oolean elfNN_ia64_size_dynamic_sections285 static bfd_boolean elfNN_ia64_size_dynamic_sections 241 286 PARAMS ((bfd *output_bfd, struct bfd_link_info *info)); 242 287 static bfd_reloc_status_type elfNN_ia64_install_value … … 257 302 PARAMS ((bfd *abfd, struct bfd_link_info *info, 258 303 struct elfNN_ia64_dyn_sym_info *dyn_i, 259 bfd_vma value, boolean)); 260 static boolean elfNN_ia64_final_link 304 bfd_vma value, bfd_boolean)); 305 static bfd_vma elfNN_ia64_tprel_base 306 PARAMS ((struct bfd_link_info *info)); 307 static bfd_vma elfNN_ia64_dtprel_base 308 PARAMS ((struct bfd_link_info *info)); 309 static int elfNN_ia64_unwind_entry_compare 310 PARAMS ((const PTR, const PTR)); 311 static bfd_boolean elfNN_ia64_choose_gp 261 312 PARAMS ((bfd *abfd, struct bfd_link_info *info)); 262 static boolean elfNN_ia64_relocate_section 313 static bfd_boolean elfNN_ia64_final_link 314 PARAMS ((bfd *abfd, struct bfd_link_info *info)); 315 static bfd_boolean elfNN_ia64_relocate_section 263 316 PARAMS ((bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd, 264 317 asection *input_section, bfd_byte *contents, 265 318 Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, 266 319 asection **local_sections)); 267 static b oolean elfNN_ia64_finish_dynamic_symbol320 static bfd_boolean elfNN_ia64_finish_dynamic_symbol 268 321 PARAMS ((bfd *output_bfd, struct bfd_link_info *info, 269 322 struct elf_link_hash_entry *h, Elf_Internal_Sym *sym)); 270 static b oolean elfNN_ia64_finish_dynamic_sections323 static bfd_boolean elfNN_ia64_finish_dynamic_sections 271 324 PARAMS ((bfd *abfd, struct bfd_link_info *info)); 272 static b oolean elfNN_ia64_set_private_flags325 static bfd_boolean elfNN_ia64_set_private_flags 273 326 PARAMS ((bfd *abfd, flagword flags)); 274 static b oolean elfNN_ia64_copy_private_bfd_data327 static bfd_boolean elfNN_ia64_merge_private_bfd_data 275 328 PARAMS ((bfd *ibfd, bfd *obfd)); 276 static boolean elfNN_ia64_merge_private_bfd_data 277 PARAMS ((bfd *ibfd, bfd *obfd)); 278 static boolean elfNN_ia64_print_private_bfd_data 329 static bfd_boolean elfNN_ia64_print_private_bfd_data 279 330 PARAMS ((bfd *abfd, PTR ptr)); 280 281 282 /* ia64-specific relocation */ 331 static enum elf_reloc_type_class elfNN_ia64_reloc_type_class 332 PARAMS ((const Elf_Internal_Rela *)); 333 static bfd_boolean elfNN_ia64_hpux_vec 334 PARAMS ((const bfd_target *vec)); 335 static void elfNN_hpux_post_process_headers 336 PARAMS ((bfd *abfd, struct bfd_link_info *info)); 337 bfd_boolean elfNN_hpux_backend_section_from_bfd_section 338 PARAMS ((bfd *abfd, asection *sec, int *retval)); 339 340 341 /* ia64-specific relocation. */ 283 342 284 343 /* Perform a relocation. Not much to do here as all the hard work is … … 300 359 return bfd_reloc_ok; 301 360 } 361 362 if (input_section->flags & SEC_DEBUGGING) 363 return bfd_reloc_continue; 364 302 365 *error_message = "Unsupported call to elfNN_ia64_reloc"; 303 366 return bfd_reloc_notsupported; … … 306 369 #define IA64_HOWTO(TYPE, NAME, SIZE, PCREL, IN) \ 307 370 HOWTO (TYPE, 0, SIZE, 0, PCREL, 0, complain_overflow_signed, \ 308 elfNN_ia64_reloc, NAME, false, 0, 0, IN)371 elfNN_ia64_reloc, NAME, FALSE, 0, 0, IN) 309 372 310 373 /* This table has to be sorted according to increasing number of the … … 312 375 static reloc_howto_type ia64_howto_table[] = 313 376 { 314 IA64_HOWTO (R_IA64_NONE, "NONE", 0, false, true), 315 316 IA64_HOWTO (R_IA64_IMM14, "IMM14", 0, false, true), 317 IA64_HOWTO (R_IA64_IMM22, "IMM22", 0, false, true), 318 IA64_HOWTO (R_IA64_IMM64, "IMM64", 0, false, true), 319 IA64_HOWTO (R_IA64_DIR32MSB, "DIR32MSB", 2, false, true), 320 IA64_HOWTO (R_IA64_DIR32LSB, "DIR32LSB", 2, false, true), 321 IA64_HOWTO (R_IA64_DIR64MSB, "DIR64MSB", 4, false, true), 322 IA64_HOWTO (R_IA64_DIR64LSB, "DIR64LSB", 4, false, true), 323 324 IA64_HOWTO (R_IA64_GPREL22, "GPREL22", 0, false, true), 325 IA64_HOWTO (R_IA64_GPREL64I, "GPREL64I", 0, false, true), 326 IA64_HOWTO (R_IA64_GPREL32MSB, "GPREL32MSB", 2, false, true), 327 IA64_HOWTO (R_IA64_GPREL32LSB, "GPREL32LSB", 2, false, true), 328 IA64_HOWTO (R_IA64_GPREL64MSB, "GPREL64MSB", 4, false, true), 329 IA64_HOWTO (R_IA64_GPREL64LSB, "GPREL64LSB", 4, false, true), 330 331 IA64_HOWTO (R_IA64_LTOFF22, "LTOFF22", 0, false, true), 332 IA64_HOWTO (R_IA64_LTOFF64I, "LTOFF64I", 0, false, true), 333 334 IA64_HOWTO (R_IA64_PLTOFF22, "PLTOFF22", 0, false, true), 335 IA64_HOWTO (R_IA64_PLTOFF64I, "PLTOFF64I", 0, false, true), 336 IA64_HOWTO (R_IA64_PLTOFF64MSB, "PLTOFF64MSB", 4, false, true), 337 IA64_HOWTO (R_IA64_PLTOFF64LSB, "PLTOFF64LSB", 4, false, true), 338 339 IA64_HOWTO (R_IA64_FPTR64I, "FPTR64I", 0, false, true), 340 IA64_HOWTO (R_IA64_FPTR32MSB, "FPTR32MSB", 2, false, true), 341 IA64_HOWTO (R_IA64_FPTR32LSB, "FPTR32LSB", 2, false, true), 342 IA64_HOWTO (R_IA64_FPTR64MSB, "FPTR64MSB", 4, false, true), 343 IA64_HOWTO (R_IA64_FPTR64LSB, "FPTR64LSB", 4, false, true), 344 345 IA64_HOWTO (R_IA64_PCREL60B, "PCREL60B", 0, true, true), 346 IA64_HOWTO (R_IA64_PCREL21B, "PCREL21B", 0, true, true), 347 IA64_HOWTO (R_IA64_PCREL21M, "PCREL21M", 0, true, true), 348 IA64_HOWTO (R_IA64_PCREL21F, "PCREL21F", 0, true, true), 349 IA64_HOWTO (R_IA64_PCREL32MSB, "PCREL32MSB", 2, true, true), 350 IA64_HOWTO (R_IA64_PCREL32LSB, "PCREL32LSB", 2, true, true), 351 IA64_HOWTO (R_IA64_PCREL64MSB, "PCREL64MSB", 4, true, true), 352 IA64_HOWTO (R_IA64_PCREL64LSB, "PCREL64LSB", 4, true, true), 353 354 IA64_HOWTO (R_IA64_LTOFF_FPTR22, "LTOFF_FPTR22", 0, false, true), 355 IA64_HOWTO (R_IA64_LTOFF_FPTR64I, "LTOFF_FPTR64I", 0, false, true), 356 IA64_HOWTO (R_IA64_LTOFF_FPTR64MSB, "LTOFF_FPTR64MSB", 4, false, true), 357 IA64_HOWTO (R_IA64_LTOFF_FPTR64LSB, "LTOFF_FPTR64LSB", 4, false, true), 358 359 IA64_HOWTO (R_IA64_SEGREL32MSB, "SEGREL32MSB", 2, false, true), 360 IA64_HOWTO (R_IA64_SEGREL32LSB, "SEGREL32LSB", 2, false, true), 361 IA64_HOWTO (R_IA64_SEGREL64MSB, "SEGREL64MSB", 4, false, true), 362 IA64_HOWTO (R_IA64_SEGREL64LSB, "SEGREL64LSB", 4, false, true), 363 364 IA64_HOWTO (R_IA64_SECREL32MSB, "SECREL32MSB", 2, false, true), 365 IA64_HOWTO (R_IA64_SECREL32LSB, "SECREL32LSB", 2, false, true), 366 IA64_HOWTO (R_IA64_SECREL64MSB, "SECREL64MSB", 4, false, true), 367 IA64_HOWTO (R_IA64_SECREL64LSB, "SECREL64LSB", 4, false, true), 368 369 IA64_HOWTO (R_IA64_REL32MSB, "REL32MSB", 2, false, true), 370 IA64_HOWTO (R_IA64_REL32LSB, "REL32LSB", 2, false, true), 371 IA64_HOWTO (R_IA64_REL64MSB, "REL64MSB", 4, false, true), 372 IA64_HOWTO (R_IA64_REL64LSB, "REL64LSB", 4, false, true), 373 374 IA64_HOWTO (R_IA64_LTV32MSB, "LTV32MSB", 2, false, true), 375 IA64_HOWTO (R_IA64_LTV32LSB, "LTV32LSB", 2, false, true), 376 IA64_HOWTO (R_IA64_LTV64MSB, "LTV64MSB", 4, false, true), 377 IA64_HOWTO (R_IA64_LTV64LSB, "LTV64LSB", 4, false, true), 378 379 IA64_HOWTO (R_IA64_PCREL21BI, "PCREL21BI", 0, true, true), 380 IA64_HOWTO (R_IA64_PCREL22, "PCREL22", 0, true, true), 381 IA64_HOWTO (R_IA64_PCREL64I, "PCREL64I", 0, true, true), 382 383 IA64_HOWTO (R_IA64_IPLTMSB, "IPLTMSB", 4, false, true), 384 IA64_HOWTO (R_IA64_IPLTLSB, "IPLTLSB", 4, false, true), 385 IA64_HOWTO (R_IA64_COPY, "COPY", 4, false, true), 386 IA64_HOWTO (R_IA64_LTOFF22X, "LTOFF22X", 0, false, true), 387 IA64_HOWTO (R_IA64_LDXMOV, "LDXMOV", 0, false, true), 388 389 IA64_HOWTO (R_IA64_TPREL22, "TPREL22", 0, false, false), 390 IA64_HOWTO (R_IA64_TPREL64MSB, "TPREL64MSB", 8, false, false), 391 IA64_HOWTO (R_IA64_TPREL64LSB, "TPREL64LSB", 8, false, false), 392 IA64_HOWTO (R_IA64_LTOFF_TP22, "LTOFF_TP22", 0, false, false), 377 IA64_HOWTO (R_IA64_NONE, "NONE", 0, FALSE, TRUE), 378 379 IA64_HOWTO (R_IA64_IMM14, "IMM14", 0, FALSE, TRUE), 380 IA64_HOWTO (R_IA64_IMM22, "IMM22", 0, FALSE, TRUE), 381 IA64_HOWTO (R_IA64_IMM64, "IMM64", 0, FALSE, TRUE), 382 IA64_HOWTO (R_IA64_DIR32MSB, "DIR32MSB", 2, FALSE, TRUE), 383 IA64_HOWTO (R_IA64_DIR32LSB, "DIR32LSB", 2, FALSE, TRUE), 384 IA64_HOWTO (R_IA64_DIR64MSB, "DIR64MSB", 4, FALSE, TRUE), 385 IA64_HOWTO (R_IA64_DIR64LSB, "DIR64LSB", 4, FALSE, TRUE), 386 387 IA64_HOWTO (R_IA64_GPREL22, "GPREL22", 0, FALSE, TRUE), 388 IA64_HOWTO (R_IA64_GPREL64I, "GPREL64I", 0, FALSE, TRUE), 389 IA64_HOWTO (R_IA64_GPREL32MSB, "GPREL32MSB", 2, FALSE, TRUE), 390 IA64_HOWTO (R_IA64_GPREL32LSB, "GPREL32LSB", 2, FALSE, TRUE), 391 IA64_HOWTO (R_IA64_GPREL64MSB, "GPREL64MSB", 4, FALSE, TRUE), 392 IA64_HOWTO (R_IA64_GPREL64LSB, "GPREL64LSB", 4, FALSE, TRUE), 393 394 IA64_HOWTO (R_IA64_LTOFF22, "LTOFF22", 0, FALSE, TRUE), 395 IA64_HOWTO (R_IA64_LTOFF64I, "LTOFF64I", 0, FALSE, TRUE), 396 397 IA64_HOWTO (R_IA64_PLTOFF22, "PLTOFF22", 0, FALSE, TRUE), 398 IA64_HOWTO (R_IA64_PLTOFF64I, "PLTOFF64I", 0, FALSE, TRUE), 399 IA64_HOWTO (R_IA64_PLTOFF64MSB, "PLTOFF64MSB", 4, FALSE, TRUE), 400 IA64_HOWTO (R_IA64_PLTOFF64LSB, "PLTOFF64LSB", 4, FALSE, TRUE), 401 402 IA64_HOWTO (R_IA64_FPTR64I, "FPTR64I", 0, FALSE, TRUE), 403 IA64_HOWTO (R_IA64_FPTR32MSB, "FPTR32MSB", 2, FALSE, TRUE), 404 IA64_HOWTO (R_IA64_FPTR32LSB, "FPTR32LSB", 2, FALSE, TRUE), 405 IA64_HOWTO (R_IA64_FPTR64MSB, "FPTR64MSB", 4, FALSE, TRUE), 406 IA64_HOWTO (R_IA64_FPTR64LSB, "FPTR64LSB", 4, FALSE, TRUE), 407 408 IA64_HOWTO (R_IA64_PCREL60B, "PCREL60B", 0, TRUE, TRUE), 409 IA64_HOWTO (R_IA64_PCREL21B, "PCREL21B", 0, TRUE, TRUE), 410 IA64_HOWTO (R_IA64_PCREL21M, "PCREL21M", 0, TRUE, TRUE), 411 IA64_HOWTO (R_IA64_PCREL21F, "PCREL21F", 0, TRUE, TRUE), 412 IA64_HOWTO (R_IA64_PCREL32MSB, "PCREL32MSB", 2, TRUE, TRUE), 413 IA64_HOWTO (R_IA64_PCREL32LSB, "PCREL32LSB", 2, TRUE, TRUE), 414 IA64_HOWTO (R_IA64_PCREL64MSB, "PCREL64MSB", 4, TRUE, TRUE), 415 IA64_HOWTO (R_IA64_PCREL64LSB, "PCREL64LSB", 4, TRUE, TRUE), 416 417 IA64_HOWTO (R_IA64_LTOFF_FPTR22, "LTOFF_FPTR22", 0, FALSE, TRUE), 418 IA64_HOWTO (R_IA64_LTOFF_FPTR64I, "LTOFF_FPTR64I", 0, FALSE, TRUE), 419 IA64_HOWTO (R_IA64_LTOFF_FPTR32MSB, "LTOFF_FPTR32MSB", 2, FALSE, TRUE), 420 IA64_HOWTO (R_IA64_LTOFF_FPTR32LSB, "LTOFF_FPTR32LSB", 2, FALSE, TRUE), 421 IA64_HOWTO (R_IA64_LTOFF_FPTR64MSB, "LTOFF_FPTR64MSB", 4, FALSE, TRUE), 422 IA64_HOWTO (R_IA64_LTOFF_FPTR64LSB, "LTOFF_FPTR64LSB", 4, FALSE, TRUE), 423 424 IA64_HOWTO (R_IA64_SEGREL32MSB, "SEGREL32MSB", 2, FALSE, TRUE), 425 IA64_HOWTO (R_IA64_SEGREL32LSB, "SEGREL32LSB", 2, FALSE, TRUE), 426 IA64_HOWTO (R_IA64_SEGREL64MSB, "SEGREL64MSB", 4, FALSE, TRUE), 427 IA64_HOWTO (R_IA64_SEGREL64LSB, "SEGREL64LSB", 4, FALSE, TRUE), 428 429 IA64_HOWTO (R_IA64_SECREL32MSB, "SECREL32MSB", 2, FALSE, TRUE), 430 IA64_HOWTO (R_IA64_SECREL32LSB, "SECREL32LSB", 2, FALSE, TRUE), 431 IA64_HOWTO (R_IA64_SECREL64MSB, "SECREL64MSB", 4, FALSE, TRUE), 432 IA64_HOWTO (R_IA64_SECREL64LSB, "SECREL64LSB", 4, FALSE, TRUE), 433 434 IA64_HOWTO (R_IA64_REL32MSB, "REL32MSB", 2, FALSE, TRUE), 435 IA64_HOWTO (R_IA64_REL32LSB, "REL32LSB", 2, FALSE, TRUE), 436 IA64_HOWTO (R_IA64_REL64MSB, "REL64MSB", 4, FALSE, TRUE), 437 IA64_HOWTO (R_IA64_REL64LSB, "REL64LSB", 4, FALSE, TRUE), 438 439 IA64_HOWTO (R_IA64_LTV32MSB, "LTV32MSB", 2, FALSE, TRUE), 440 IA64_HOWTO (R_IA64_LTV32LSB, "LTV32LSB", 2, FALSE, TRUE), 441 IA64_HOWTO (R_IA64_LTV64MSB, "LTV64MSB", 4, FALSE, TRUE), 442 IA64_HOWTO (R_IA64_LTV64LSB, "LTV64LSB", 4, FALSE, TRUE), 443 444 IA64_HOWTO (R_IA64_PCREL21BI, "PCREL21BI", 0, TRUE, TRUE), 445 IA64_HOWTO (R_IA64_PCREL22, "PCREL22", 0, TRUE, TRUE), 446 IA64_HOWTO (R_IA64_PCREL64I, "PCREL64I", 0, TRUE, TRUE), 447 448 IA64_HOWTO (R_IA64_IPLTMSB, "IPLTMSB", 4, FALSE, TRUE), 449 IA64_HOWTO (R_IA64_IPLTLSB, "IPLTLSB", 4, FALSE, TRUE), 450 IA64_HOWTO (R_IA64_COPY, "COPY", 4, FALSE, TRUE), 451 IA64_HOWTO (R_IA64_LTOFF22X, "LTOFF22X", 0, FALSE, TRUE), 452 IA64_HOWTO (R_IA64_LDXMOV, "LDXMOV", 0, FALSE, TRUE), 453 454 IA64_HOWTO (R_IA64_TPREL14, "TPREL14", 0, FALSE, FALSE), 455 IA64_HOWTO (R_IA64_TPREL22, "TPREL22", 0, FALSE, FALSE), 456 IA64_HOWTO (R_IA64_TPREL64I, "TPREL64I", 0, FALSE, FALSE), 457 IA64_HOWTO (R_IA64_TPREL64MSB, "TPREL64MSB", 8, FALSE, FALSE), 458 IA64_HOWTO (R_IA64_TPREL64LSB, "TPREL64LSB", 8, FALSE, FALSE), 459 IA64_HOWTO (R_IA64_LTOFF_TPREL22, "LTOFF_TPREL22", 0, FALSE, FALSE), 460 461 IA64_HOWTO (R_IA64_DTPMOD64MSB, "TPREL64MSB", 8, FALSE, FALSE), 462 IA64_HOWTO (R_IA64_DTPMOD64LSB, "TPREL64LSB", 8, FALSE, FALSE), 463 IA64_HOWTO (R_IA64_LTOFF_DTPMOD22, "LTOFF_DTPMOD22", 0, FALSE, FALSE), 464 465 IA64_HOWTO (R_IA64_DTPREL14, "DTPREL14", 0, FALSE, FALSE), 466 IA64_HOWTO (R_IA64_DTPREL22, "DTPREL22", 0, FALSE, FALSE), 467 IA64_HOWTO (R_IA64_DTPREL64I, "DTPREL64I", 0, FALSE, FALSE), 468 IA64_HOWTO (R_IA64_DTPREL32MSB, "DTPREL32MSB", 4, FALSE, FALSE), 469 IA64_HOWTO (R_IA64_DTPREL32LSB, "DTPREL32LSB", 4, FALSE, FALSE), 470 IA64_HOWTO (R_IA64_DTPREL64MSB, "DTPREL64MSB", 8, FALSE, FALSE), 471 IA64_HOWTO (R_IA64_DTPREL64LSB, "DTPREL64LSB", 8, FALSE, FALSE), 472 IA64_HOWTO (R_IA64_LTOFF_DTPREL22, "LTOFF_DTPREL22", 0, FALSE, FALSE), 393 473 }; 394 474 … … 397 477 /* Given a BFD reloc type, return the matching HOWTO structure. */ 398 478 399 static reloc_howto_type *479 static reloc_howto_type * 400 480 lookup_howto (rtype) 401 481 unsigned int rtype; … … 474 554 case BFD_RELOC_IA64_LTOFF_FPTR22: rtype = R_IA64_LTOFF_FPTR22; break; 475 555 case BFD_RELOC_IA64_LTOFF_FPTR64I: rtype = R_IA64_LTOFF_FPTR64I; break; 556 case BFD_RELOC_IA64_LTOFF_FPTR32MSB: rtype = R_IA64_LTOFF_FPTR32MSB; break; 557 case BFD_RELOC_IA64_LTOFF_FPTR32LSB: rtype = R_IA64_LTOFF_FPTR32LSB; break; 476 558 case BFD_RELOC_IA64_LTOFF_FPTR64MSB: rtype = R_IA64_LTOFF_FPTR64MSB; break; 477 559 case BFD_RELOC_IA64_LTOFF_FPTR64LSB: rtype = R_IA64_LTOFF_FPTR64LSB; break; … … 503 585 case BFD_RELOC_IA64_LDXMOV: rtype = R_IA64_LDXMOV; break; 504 586 587 case BFD_RELOC_IA64_TPREL14: rtype = R_IA64_TPREL14; break; 505 588 case BFD_RELOC_IA64_TPREL22: rtype = R_IA64_TPREL22; break; 589 case BFD_RELOC_IA64_TPREL64I: rtype = R_IA64_TPREL64I; break; 506 590 case BFD_RELOC_IA64_TPREL64MSB: rtype = R_IA64_TPREL64MSB; break; 507 591 case BFD_RELOC_IA64_TPREL64LSB: rtype = R_IA64_TPREL64LSB; break; 508 case BFD_RELOC_IA64_LTOFF_TP22: rtype = R_IA64_LTOFF_TP22; break; 592 case BFD_RELOC_IA64_LTOFF_TPREL22: rtype = R_IA64_LTOFF_TPREL22; break; 593 594 case BFD_RELOC_IA64_DTPMOD64MSB: rtype = R_IA64_DTPMOD64MSB; break; 595 case BFD_RELOC_IA64_DTPMOD64LSB: rtype = R_IA64_DTPMOD64LSB; break; 596 case BFD_RELOC_IA64_LTOFF_DTPMOD22: rtype = R_IA64_LTOFF_DTPMOD22; break; 597 598 case BFD_RELOC_IA64_DTPREL14: rtype = R_IA64_DTPREL14; break; 599 case BFD_RELOC_IA64_DTPREL22: rtype = R_IA64_DTPREL22; break; 600 case BFD_RELOC_IA64_DTPREL64I: rtype = R_IA64_DTPREL64I; break; 601 case BFD_RELOC_IA64_DTPREL32MSB: rtype = R_IA64_DTPREL32MSB; break; 602 case BFD_RELOC_IA64_DTPREL32LSB: rtype = R_IA64_DTPREL32LSB; break; 603 case BFD_RELOC_IA64_DTPREL64MSB: rtype = R_IA64_DTPREL64MSB; break; 604 case BFD_RELOC_IA64_DTPREL64LSB: rtype = R_IA64_DTPREL64LSB; break; 605 case BFD_RELOC_IA64_LTOFF_DTPREL22: rtype = R_IA64_LTOFF_DTPREL22; break; 509 606 510 607 default: return 0; … … 519 616 bfd *abfd ATTRIBUTE_UNUSED; 520 617 arelent *bfd_reloc; 521 ElfNN_Internal_Rela *elf_reloc; 522 { 523 bfd_reloc->howto = lookup_howto (ELFNN_R_TYPE (elf_reloc->r_info)); 618 Elf_Internal_Rela *elf_reloc; 619 { 620 bfd_reloc->howto 621 = lookup_howto ((unsigned int) ELFNN_R_TYPE (elf_reloc->r_info)); 524 622 } 525 623 … … 561 659 562 660 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" 563 564 /* Select out of range branch fixup type. Note that Itanium does 565 not support brl, and so it gets emulated by the kernel. */ 566 #undef USE_BRL 661 #define AIX_DYNAMIC_INTERPRETER "/usr/lib/ia64l64/libc.so.1" 662 #define DYNAMIC_INTERPRETER(abfd) \ 663 (elfNN_ia64_aix_vec (abfd->xvec) ? AIX_DYNAMIC_INTERPRETER : ELF_DYNAMIC_INTERPRETER) 567 664 568 665 static const bfd_byte oor_brl[16] = … … 573 670 }; 574 671 575 static const bfd_byte oor_ip[48] = 576 { 577 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MLX] nop.m 0 */ 578 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, /* movl r15=0 */ 579 0x01, 0x00, 0x00, 0x60, 580 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MII] nop.m 0 */ 581 0x00, 0x01, 0x00, 0x60, 0x00, 0x00, /* mov r16=ip;; */ 582 0xf2, 0x80, 0x00, 0x80, /* add r16=r15,r16;; */ 583 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MIB] nop.m 0 */ 584 0x60, 0x80, 0x04, 0x80, 0x03, 0x00, /* mov b6=r16 */ 585 0x60, 0x00, 0x80, 0x00 /* br b6;; */ 586 }; 587 588 589 /* These functions do relaxation for IA-64 ELF. 590 591 This is primarily to support branches to targets out of range; 592 relaxation of R_IA64_LTOFF22X and R_IA64_LDXMOV not yet supported. */ 593 594 static boolean 672 673 /* These functions do relaxation for IA-64 ELF. */ 674 675 static bfd_boolean 595 676 elfNN_ia64_relax_section (abfd, sec, link_info, again) 596 677 bfd *abfd; 597 678 asection *sec; 598 679 struct bfd_link_info *link_info; 599 b oolean *again;680 bfd_boolean *again; 600 681 { 601 682 struct one_fixup … … 609 690 Elf_Internal_Shdr *symtab_hdr; 610 691 Elf_Internal_Rela *internal_relocs; 611 Elf_Internal_Rela *free_relocs = NULL;612 692 Elf_Internal_Rela *irel, *irelend; 613 693 bfd_byte *contents; 614 bfd_byte *free_contents = NULL; 615 ElfNN_External_Sym *extsyms; 616 ElfNN_External_Sym *free_extsyms = NULL; 694 Elf_Internal_Sym *isymbuf = NULL; 617 695 struct elfNN_ia64_link_hash_table *ia64_info; 618 696 struct one_fixup *fixups = NULL; 619 boolean changed_contents = false; 620 boolean changed_relocs = false; 697 bfd_boolean changed_contents = FALSE; 698 bfd_boolean changed_relocs = FALSE; 699 bfd_boolean changed_got = FALSE; 700 bfd_vma gp = 0; 621 701 622 702 /* Assume we're not going to change any sizes, and we'll only need 623 703 one pass. */ 624 *again = false; 625 626 /* Nothing to do if there are no relocations. */ 704 *again = FALSE; 705 706 /* Don't even try to relax for non-ELF outputs. */ 707 if (link_info->hash->creator->flavour != bfd_target_elf_flavour) 708 return FALSE; 709 710 /* Nothing to do if there are no relocations or there is no need for 711 the relax finalize pass. */ 627 712 if ((sec->flags & SEC_RELOC) == 0 628 || sec->reloc_count == 0) 629 return true; 713 || sec->reloc_count == 0 714 || (link_info->relax_finalizing 715 && sec->need_finalize_relax == 0)) 716 return TRUE; 630 717 631 718 /* If this is the first time we have been called for this section, … … 641 728 link_info->keep_memory)); 642 729 if (internal_relocs == NULL) 643 goto error_return; 644 645 if (! link_info->keep_memory) 646 free_relocs = internal_relocs; 730 return FALSE; 647 731 648 732 ia64_info = elfNN_ia64_hash_table (link_info); 649 733 irelend = internal_relocs + sec->reloc_count; 650 651 for (irel = internal_relocs; irel < irelend; irel++)652 if (ELFNN_R_TYPE (irel->r_info) == (int) R_IA64_PCREL21B)653 break;654 655 /* No branch-type relocations. */656 if (irel == irelend)657 {658 if (free_relocs != NULL)659 free (free_relocs);660 return true;661 }662 734 663 735 /* Get the section contents. */ … … 669 741 if (contents == NULL) 670 742 goto error_return; 671 free_contents = contents;672 743 673 744 if (! bfd_get_section_contents (abfd, sec, contents, … … 676 747 } 677 748 678 /* Read this BFD's symbols. */ 679 if (symtab_hdr->contents != NULL) 680 extsyms = (ElfNN_External_Sym *) symtab_hdr->contents; 681 else 682 { 683 extsyms = (ElfNN_External_Sym *) bfd_malloc (symtab_hdr->sh_size); 684 if (extsyms == NULL) 685 goto error_return; 686 free_extsyms = extsyms; 687 if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 688 || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd) 689 != symtab_hdr->sh_size)) 690 goto error_return; 691 } 692 693 for (; irel < irelend; irel++) 694 { 749 for (irel = internal_relocs; irel < irelend; irel++) 750 { 751 unsigned long r_type = ELFNN_R_TYPE (irel->r_info); 695 752 bfd_vma symaddr, reladdr, trampoff, toff, roff; 696 Elf_Internal_Sym isym;697 753 asection *tsec; 698 754 struct one_fixup *f; 699 700 if (ELFNN_R_TYPE (irel->r_info) != (int) R_IA64_PCREL21B) 701 continue; 755 bfd_size_type amt; 756 bfd_boolean is_branch; 757 struct elfNN_ia64_dyn_sym_info *dyn_i; 758 759 switch (r_type) 760 { 761 case R_IA64_PCREL21B: 762 case R_IA64_PCREL21BI: 763 case R_IA64_PCREL21M: 764 case R_IA64_PCREL21F: 765 if (link_info->relax_finalizing) 766 continue; 767 is_branch = TRUE; 768 break; 769 770 case R_IA64_LTOFF22X: 771 case R_IA64_LDXMOV: 772 if (!link_info->relax_finalizing) 773 { 774 sec->need_finalize_relax = 1; 775 continue; 776 } 777 is_branch = FALSE; 778 break; 779 780 default: 781 continue; 782 } 702 783 703 784 /* Get the value of the symbol referred to by the reloc. */ … … 705 786 { 706 787 /* A local symbol. */ 707 bfd_elfNN_swap_symbol_in (abfd, 708 extsyms + ELFNN_R_SYM (irel->r_info), 709 &isym); 710 if (isym.st_shndx == SHN_UNDEF) 788 Elf_Internal_Sym *isym; 789 790 /* Read this BFD's local symbols. */ 791 if (isymbuf == NULL) 792 { 793 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; 794 if (isymbuf == NULL) 795 isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr, 796 symtab_hdr->sh_info, 0, 797 NULL, NULL, NULL); 798 if (isymbuf == 0) 799 goto error_return; 800 } 801 802 isym = isymbuf + ELFNN_R_SYM (irel->r_info); 803 if (isym->st_shndx == SHN_UNDEF) 711 804 continue; /* We can't do anthing with undefined symbols. */ 712 else if (isym .st_shndx == SHN_ABS)805 else if (isym->st_shndx == SHN_ABS) 713 806 tsec = bfd_abs_section_ptr; 714 else if (isym .st_shndx == SHN_COMMON)807 else if (isym->st_shndx == SHN_COMMON) 715 808 tsec = bfd_com_section_ptr; 716 else if (isym .st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)717 tsec = bfd_ section_from_elf_index (abfd, isym.st_shndx);809 else if (isym->st_shndx == SHN_IA_64_ANSI_COMMON) 810 tsec = bfd_com_section_ptr; 718 811 else 719 continue; /* who knows. */ 720 721 toff = isym.st_value; 812 tsec = bfd_section_from_elf_index (abfd, isym->st_shndx); 813 814 toff = isym->st_value; 815 dyn_i = get_dyn_sym_info (ia64_info, NULL, abfd, irel, FALSE); 722 816 } 723 817 else … … 725 819 unsigned long indx; 726 820 struct elf_link_hash_entry *h; 727 struct elfNN_ia64_dyn_sym_info *dyn_i;728 821 729 822 indx = ELFNN_R_SYM (irel->r_info) - symtab_hdr->sh_info; … … 735 828 h = (struct elf_link_hash_entry *) h->root.u.i.link; 736 829 737 dyn_i = get_dyn_sym_info (ia64_info, h, abfd, irel, false);830 dyn_i = get_dyn_sym_info (ia64_info, h, abfd, irel, FALSE); 738 831 739 832 /* For branches to dynamic symbols, we're interested instead 740 833 in a branch to the PLT entry. */ 741 if ( dyn_i && dyn_i->want_plt2)834 if (is_branch && dyn_i && dyn_i->want_plt2) 742 835 { 836 /* Internal branches shouldn't be sent to the PLT. 837 Leave this for now and we'll give an error later. */ 838 if (r_type != R_IA64_PCREL21B) 839 continue; 840 743 841 tsec = ia64_info->plt_sec; 744 842 toff = dyn_i->plt2_offset; 843 BFD_ASSERT (irel->r_addend == 0); 745 844 } 845 846 /* Can't do anything else with dynamic symbols. */ 847 else if (elfNN_ia64_dynamic_symbol_p (h, link_info)) 848 continue; 849 746 850 else 747 851 { … … 756 860 } 757 861 758 symaddr = (tsec->output_section->vma 759 + tsec->output_offset 760 + toff 761 + irel->r_addend); 862 if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE) 863 toff = _bfd_merged_section_offset (abfd, &tsec, 864 elf_section_data (tsec)->sec_info, 865 toff + irel->r_addend, 866 (bfd_vma) 0); 867 else 868 toff += irel->r_addend; 869 870 symaddr = tsec->output_section->vma + tsec->output_offset + toff; 762 871 763 872 roff = irel->r_offset; 764 reladdr = (sec->output_section->vma 765 + sec->output_offset 766 + roff) & -4; 767 768 /* If the branch is in range, no need to do anything. */ 769 if ((bfd_signed_vma) (symaddr - reladdr) >= -0x1000000 770 && (bfd_signed_vma) (symaddr - reladdr) <= 0x0FFFFF0) 771 continue; 772 773 /* If the branch and target are in the same section, you've 774 got one honking big section and we can't help you. You'll 775 get an error message later. */ 776 if (tsec == sec) 777 continue; 778 779 /* Look for an existing fixup to this address. */ 780 for (f = fixups; f ; f = f->next) 781 if (f->tsec == tsec && f->toff == toff) 782 break; 783 784 if (f == NULL) 785 { 786 /* Two alternatives: If it's a branch to a PLT entry, we can 787 make a copy of the FULL_PLT entry. Otherwise, we'll have 788 to use a `brl' insn to get where we're going. */ 789 790 int size; 791 792 if (tsec == ia64_info->plt_sec) 793 size = sizeof (plt_full_entry); 794 else 873 874 if (is_branch) 875 { 876 reladdr = (sec->output_section->vma 877 + sec->output_offset 878 + roff) & (bfd_vma) -4; 879 880 /* If the branch is in range, no need to do anything. */ 881 if ((bfd_signed_vma) (symaddr - reladdr) >= -0x1000000 882 && (bfd_signed_vma) (symaddr - reladdr) <= 0x0FFFFF0) 883 continue; 884 885 /* If the branch and target are in the same section, you've 886 got one honking big section and we can't help you. You'll 887 get an error message later. */ 888 if (tsec == sec) 889 continue; 890 891 /* Look for an existing fixup to this address. */ 892 for (f = fixups; f ; f = f->next) 893 if (f->tsec == tsec && f->toff == toff) 894 break; 895 896 if (f == NULL) 795 897 { 796 #ifdef USE_BRL 797 size = sizeof (oor_brl); 798 #else 799 size = sizeof (oor_ip); 800 #endif 801 } 802 803 /* Resize the current section to make room for the new branch. */ 804 trampoff = (sec->_cooked_size + 15) & -16; 805 contents = (bfd_byte *) bfd_realloc (contents, trampoff + size); 806 if (contents == NULL) 807 goto error_return; 808 sec->_cooked_size = trampoff + size; 809 810 if (tsec == ia64_info->plt_sec) 811 { 812 memcpy (contents + trampoff, plt_full_entry, size); 813 814 /* Hijack the old relocation for use as the PLTOFF reloc. */ 815 irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info), 816 R_IA64_PLTOFF22); 817 irel->r_offset = trampoff; 898 /* Two alternatives: If it's a branch to a PLT entry, we can 899 make a copy of the FULL_PLT entry. Otherwise, we'll have 900 to use a `brl' insn to get where we're going. */ 901 902 size_t size; 903 904 if (tsec == ia64_info->plt_sec) 905 size = sizeof (plt_full_entry); 906 else 907 { 908 size = sizeof (oor_brl); 909 } 910 911 /* Resize the current section to make room for the new branch. */ 912 trampoff = (sec->_cooked_size + 15) & (bfd_vma) -16; 913 amt = trampoff + size; 914 contents = (bfd_byte *) bfd_realloc (contents, amt); 915 if (contents == NULL) 916 goto error_return; 917 sec->_cooked_size = amt; 918 919 if (tsec == ia64_info->plt_sec) 920 { 921 memcpy (contents + trampoff, plt_full_entry, size); 922 923 /* Hijack the old relocation for use as the PLTOFF reloc. */ 924 irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info), 925 R_IA64_PLTOFF22); 926 irel->r_offset = trampoff; 927 } 928 else 929 { 930 memcpy (contents + trampoff, oor_brl, size); 931 irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info), 932 R_IA64_PCREL60B); 933 irel->r_offset = trampoff + 2; 934 } 935 936 /* Record the fixup so we don't do it again this section. */ 937 f = (struct one_fixup *) 938 bfd_malloc ((bfd_size_type) sizeof (*f)); 939 f->next = fixups; 940 f->tsec = tsec; 941 f->toff = toff; 942 f->trampoff = trampoff; 943 fixups = f; 818 944 } 819 945 else 820 946 { 821 #ifdef USE_BRL 822 memcpy (contents + trampoff, oor_brl, size); 947 /* Nop out the reloc, since we're finalizing things here. */ 948 irel->r_info = ELFNN_R_INFO (0, R_IA64_NONE); 949 } 950 951 /* Fix up the existing branch to hit the trampoline. Hope like 952 hell this doesn't overflow too. */ 953 if (elfNN_ia64_install_value (abfd, contents + roff, 954 f->trampoff - (roff & (bfd_vma) -4), 955 r_type) != bfd_reloc_ok) 956 goto error_return; 957 958 changed_contents = TRUE; 959 changed_relocs = TRUE; 960 } 961 else 962 { 963 /* Fetch the gp. */ 964 if (gp == 0) 965 { 966 bfd *obfd = sec->output_section->owner; 967 gp = _bfd_get_gp_value (obfd); 968 if (gp == 0) 969 { 970 if (!elfNN_ia64_choose_gp (obfd, link_info)) 971 goto error_return; 972 gp = _bfd_get_gp_value (obfd); 973 } 974 } 975 976 /* If the data is out of range, do nothing. */ 977 if ((bfd_signed_vma) (symaddr - gp) >= 0x200000 978 ||(bfd_signed_vma) (symaddr - gp) < -0x200000) 979 continue; 980 981 if (r_type == R_IA64_LTOFF22X) 982 { 823 983 irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info), 824 R_IA64_PCREL60B); 825 irel->r_offset = trampoff + 2; 826 #else 827 memcpy (contents + trampoff, oor_ip, size); 828 irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info), 829 R_IA64_PCREL64I); 830 irel->r_addend -= 16; 831 irel->r_offset = trampoff + 2; 832 #endif 984 R_IA64_GPREL22); 985 changed_relocs = TRUE; 986 if (dyn_i->want_gotx) 987 { 988 dyn_i->want_gotx = 0; 989 changed_got |= !dyn_i->want_got; 990 } 833 991 } 834 835 /* Record the fixup so we don't do it again this section. */ 836 f = (struct one_fixup *) bfd_malloc (sizeof (*f)); 837 f->next = fixups; 838 f->tsec = tsec; 839 f->toff = toff; 840 f->trampoff = trampoff; 841 fixups = f; 842 } 843 else 844 { 845 /* Nop out the reloc, since we're finalizing things here. */ 846 irel->r_info = ELFNN_R_INFO (0, R_IA64_NONE); 847 } 848 849 /* Fix up the existing branch to hit the trampoline. Hope like 850 hell this doesn't overflow too. */ 851 if (elfNN_ia64_install_value (abfd, contents + roff, 852 f->trampoff - (roff & -4), 853 R_IA64_PCREL21B) != bfd_reloc_ok) 854 goto error_return; 855 856 changed_contents = true; 857 changed_relocs = true; 858 } 859 992 else 993 { 994 elfNN_ia64_relax_ldxmov (abfd, contents, roff); 995 irel->r_info = ELFNN_R_INFO (0, R_IA64_NONE); 996 changed_contents = TRUE; 997 changed_relocs = TRUE; 998 } 999 } 1000 } 1001 1002 /* ??? If we created fixups, this may push the code segment large 1003 enough that the data segment moves, which will change the GP. 1004 Reset the GP so that we re-calculate next round. We need to 1005 do this at the _beginning_ of the next round; now will not do. */ 1006 860 1007 /* Clean up and go home. */ 861 1008 while (fixups) … … 866 1013 } 867 1014 868 if (changed_relocs) 869 elf_section_data (sec)->relocs = internal_relocs; 870 else if (free_relocs != NULL) 871 free (free_relocs); 872 873 if (changed_contents) 874 elf_section_data (sec)->this_hdr.contents = contents; 875 else if (free_contents != NULL) 1015 if (isymbuf != NULL 1016 && symtab_hdr->contents != (unsigned char *) isymbuf) 876 1017 { 877 1018 if (! link_info->keep_memory) 878 free (free_contents); 1019 free (isymbuf); 1020 else 1021 { 1022 /* Cache the symbols for elf_link_input_bfd. */ 1023 symtab_hdr->contents = (unsigned char *) isymbuf; 1024 } 1025 } 1026 1027 if (contents != NULL 1028 && elf_section_data (sec)->this_hdr.contents != contents) 1029 { 1030 if (!changed_contents && !link_info->keep_memory) 1031 free (contents); 879 1032 else 880 1033 { … … 884 1037 } 885 1038 886 if ( free_extsyms != NULL)887 { 888 if (! link_info->keep_memory)889 free ( free_extsyms);1039 if (elf_section_data (sec)->relocs != internal_relocs) 1040 { 1041 if (!changed_relocs) 1042 free (internal_relocs); 890 1043 else 891 { 892 /* Cache the symbols for elf_link_input_bfd. */ 893 symtab_hdr->contents = extsyms; 894 } 895 } 1044 elf_section_data (sec)->relocs = internal_relocs; 1045 } 1046 1047 if (changed_got) 1048 { 1049 struct elfNN_ia64_allocate_data data; 1050 data.info = link_info; 1051 data.ofs = 0; 1052 ia64_info->self_dtpmod_offset = (bfd_vma) -1; 1053 1054 elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_data_got, &data); 1055 elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_fptr_got, &data); 1056 elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_local_got, &data); 1057 ia64_info->got_sec->_raw_size = data.ofs; 1058 ia64_info->got_sec->_cooked_size = data.ofs; 1059 1060 /* ??? Resize .rela.got too. */ 1061 } 1062 1063 if (link_info->relax_finalizing) 1064 sec->need_finalize_relax = 0; 896 1065 897 1066 *again = changed_contents || changed_relocs; 898 return true;1067 return TRUE; 899 1068 900 1069 error_return: 901 if (free_relocs != NULL) 902 free (free_relocs); 903 if (free_contents != NULL) 904 free (free_contents); 905 if (free_extsyms != NULL) 906 free (free_extsyms); 907 return false; 908 } 909 910 911 /* Return true if NAME is an unwind table section name. */ 912 913 static inline boolean 914 is_unwind_section_name (name) 1070 if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents) 1071 free (isymbuf); 1072 if (contents != NULL 1073 && elf_section_data (sec)->this_hdr.contents != contents) 1074 free (contents); 1075 if (internal_relocs != NULL 1076 && elf_section_data (sec)->relocs != internal_relocs) 1077 free (internal_relocs); 1078 return FALSE; 1079 } 1080 1081 static void 1082 elfNN_ia64_relax_ldxmov (abfd, contents, off) 1083 bfd *abfd; 1084 bfd_byte *contents; 1085 bfd_vma off; 1086 { 1087 int shift, r1, r3; 1088 bfd_vma dword, insn; 1089 1090 switch ((int)off & 0x3) 1091 { 1092 case 0: shift = 5; break; 1093 case 1: shift = 14; off += 3; break; 1094 case 2: shift = 23; off += 6; break; 1095 default: 1096 abort (); 1097 } 1098 1099 dword = bfd_get_64 (abfd, contents + off); 1100 insn = (dword >> shift) & 0x1ffffffffffLL; 1101 1102 r1 = (insn >> 6) & 127; 1103 r3 = (insn >> 20) & 127; 1104 if (r1 == r3) 1105 insn = 0x8000000; /* nop */ 1106 else 1107 insn = (insn & 0x7f01fff) | 0x10800000000LL; /* (qp) mov r1 = r3 */ 1108 1109 dword &= ~(0x1ffffffffffLL << shift); 1110 dword |= (insn << shift); 1111 bfd_put_64 (abfd, dword, contents + off); 1112 } 1113 1114 1115 /* Return TRUE if NAME is an unwind table section name. */ 1116 1117 static inline bfd_boolean 1118 is_unwind_section_name (abfd, name) 1119 bfd *abfd; 915 1120 const char *name; 916 1121 { 917 1122 size_t len1, len2, len3; 1123 1124 if (elfNN_ia64_hpux_vec (abfd->xvec) 1125 && !strcmp (name, ELF_STRING_ia64_unwind_hdr)) 1126 return FALSE; 918 1127 919 1128 len1 = sizeof (ELF_STRING_ia64_unwind) - 1; … … 928 1137 is called when elfcode.h finds a section with an unknown type. */ 929 1138 930 static b oolean1139 static bfd_boolean 931 1140 elfNN_ia64_section_from_shdr (abfd, hdr, name) 932 1141 bfd *abfd; 933 Elf NN_Internal_Shdr *hdr;934 c har *name;1142 Elf_Internal_Shdr *hdr; 1143 const char *name; 935 1144 { 936 1145 asection *newsect; … … 944 1153 { 945 1154 case SHT_IA_64_UNWIND: 1155 case SHT_IA_64_HP_OPT_ANOT: 946 1156 break; 947 1157 948 1158 case SHT_IA_64_EXT: 949 1159 if (strcmp (name, ELF_STRING_ia64_archext) != 0) 950 return false;1160 return FALSE; 951 1161 break; 952 1162 953 1163 default: 954 return false;1164 return FALSE; 955 1165 } 956 1166 957 1167 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) 958 return false;1168 return FALSE; 959 1169 newsect = hdr->bfd_section; 960 1170 961 return true;1171 return TRUE; 962 1172 } 963 1173 … … 967 1177 flag. */ 968 1178 969 static b oolean1179 static bfd_boolean 970 1180 elfNN_ia64_section_flags (flags, hdr) 971 1181 flagword *flags; 972 Elf NN_Internal_Shdr *hdr;1182 Elf_Internal_Shdr *hdr; 973 1183 { 974 1184 if (hdr->sh_flags & SHF_IA_64_SHORT) 975 1185 *flags |= SEC_SMALL_DATA; 976 1186 977 return true;1187 return TRUE; 978 1188 } 979 1189 … … 981 1191 section name, which is a hack, but ought to work. */ 982 1192 983 static b oolean1193 static bfd_boolean 984 1194 elfNN_ia64_fake_sections (abfd, hdr, sec) 985 1195 bfd *abfd ATTRIBUTE_UNUSED; 986 Elf NN_Internal_Shdr *hdr;1196 Elf_Internal_Shdr *hdr; 987 1197 asection *sec; 988 1198 { … … 991 1201 name = bfd_get_section_name (abfd, sec); 992 1202 993 if (is_unwind_section_name ( name))1203 if (is_unwind_section_name (abfd, name)) 994 1204 { 995 1205 /* We don't have the sections numbered at this point, so sh_info … … 1000 1210 else if (strcmp (name, ELF_STRING_ia64_archext) == 0) 1001 1211 hdr->sh_type = SHT_IA_64_EXT; 1212 else if (strcmp (name, ".HP.opt_annot") == 0) 1213 hdr->sh_type = SHT_IA_64_HP_OPT_ANOT; 1002 1214 else if (strcmp (name, ".reloc") == 0) 1003 /* 1004 * This is an ugly, but unfortunately necessary hack that is 1005 * needed when producing EFI binaries on IA-64. It tells 1006 * elf.c:elf_fake_sections() not to consider ".reloc" as a section 1007 * containing ELF relocation info. We need this hack in order to 1008 * be able to generate ELF binaries that can be translated into 1009 * EFI applications (which are essentially COFF objects). Those 1010 * files contain a COFF ".reloc" section inside an ELFNN object, 1011 * which would normally cause BFD to segfault because it would 1012 * attempt to interpret this section as containing relocation 1013 * entries for section "oc". With this hack enabled, ".reloc" 1014 * will be treated as a normal data section, which will avoid the 1015 * segfault. However, you won't be able to create an ELFNN binary 1016 * with a section named "oc" that needs relocations, but that's 1017 * the kind of ugly side-effects you get when detecting section 1018 * types based on their names... In practice, this limitation is 1019 * unlikely to bite. 1020 */ 1215 /* This is an ugly, but unfortunately necessary hack that is 1216 needed when producing EFI binaries on IA-64. It tells 1217 elf.c:elf_fake_sections() not to consider ".reloc" as a section 1218 containing ELF relocation info. We need this hack in order to 1219 be able to generate ELF binaries that can be translated into 1220 EFI applications (which are essentially COFF objects). Those 1221 files contain a COFF ".reloc" section inside an ELFNN object, 1222 which would normally cause BFD to segfault because it would 1223 attempt to interpret this section as containing relocation 1224 entries for section "oc". With this hack enabled, ".reloc" 1225 will be treated as a normal data section, which will avoid the 1226 segfault. However, you won't be able to create an ELFNN binary 1227 with a section named "oc" that needs relocations, but that's 1228 the kind of ugly side-effects you get when detecting section 1229 types based on their names... In practice, this limitation is 1230 unlikely to bite. */ 1021 1231 hdr->sh_type = SHT_PROGBITS; 1022 1232 … … 1024 1234 hdr->sh_flags |= SHF_IA_64_SHORT; 1025 1235 1026 return true;1236 return TRUE; 1027 1237 } 1028 1238 … … 1033 1243 elfNN_ia64_final_write_processing (abfd, linker) 1034 1244 bfd *abfd; 1035 b oolean linker ATTRIBUTE_UNUSED;1245 bfd_boolean linker ATTRIBUTE_UNUSED; 1036 1246 { 1037 1247 Elf_Internal_Shdr *hdr; … … 1067 1277 /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.t.FOO */ 1068 1278 size_t len2 = sizeof (".gnu.linkonce.t.") - 1; 1069 char *once_name = alloca (len2 + strlen (sname) - len + 1); 1070 1071 memcpy (once_name, ".gnu.linkonce.t.", len2); 1072 strcpy (once_name + len2, sname + len); 1073 text_sect = bfd_get_section_by_name (abfd, once_name); 1279 char *once_name = bfd_malloc (len2 + strlen (sname + len) + 1); 1280 1281 if (once_name != NULL) 1282 { 1283 memcpy (once_name, ".gnu.linkonce.t.", len2); 1284 strcpy (once_name + len2, sname + len); 1285 text_sect = bfd_get_section_by_name (abfd, once_name); 1286 free (once_name); 1287 } 1288 else 1289 /* Should only happen if we run out of memory, in 1290 which case we're probably toast anyway. Try to 1291 cope by finding the section the slow way. */ 1292 for (text_sect = abfd->sections; 1293 text_sect != NULL; 1294 text_sect = text_sect->next) 1295 { 1296 if (strncmp (bfd_section_name (abfd, text_sect), 1297 ".gnu.linkonce.t.", len2) == 0 1298 && strcmp (bfd_section_name (abfd, text_sect) + len2, 1299 sname + len) == 0) 1300 break; 1301 } 1074 1302 } 1075 1303 else … … 1089 1317 } 1090 1318 } 1319 1320 if (! elf_flags_init (abfd)) 1321 { 1322 unsigned long flags = 0; 1323 1324 if (abfd->xvec->byteorder == BFD_ENDIAN_BIG) 1325 flags |= EF_IA_64_BE; 1326 if (bfd_get_mach (abfd) == bfd_mach_ia64_elf64) 1327 flags |= EF_IA_64_ABI64; 1328 1329 elf_elfheader(abfd)->e_flags = flags; 1330 elf_flags_init (abfd) = TRUE; 1331 } 1091 1332 } 1092 1333 … … 1094 1335 file. We use it to put .comm items in .sbss, and not .bss. */ 1095 1336 1096 static b oolean1337 static bfd_boolean 1097 1338 elfNN_ia64_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 1098 1339 bfd *abfd; … … 1106 1347 if (sym->st_shndx == SHN_COMMON 1107 1348 && !info->relocateable 1108 && sym->st_size <= (unsigned) bfd_get_gp_size (abfd))1349 && sym->st_size <= elf_gp_size (abfd)) 1109 1350 { 1110 1351 /* Common symbols less than or equal to -G nn bytes are … … 1120 1361 | SEC_IS_COMMON 1121 1362 | SEC_LINKER_CREATED))) 1122 return false;1363 return FALSE; 1123 1364 } 1124 1365 … … 1127 1368 } 1128 1369 1129 return true; 1370 return TRUE; 1371 } 1372 1373 static bfd_boolean 1374 elfNN_ia64_aix_vec (const bfd_target *vec) 1375 { 1376 extern const bfd_target bfd_elfNN_ia64_aix_little_vec; 1377 extern const bfd_target bfd_elfNN_ia64_aix_big_vec; 1378 1379 return (/**/vec == & bfd_elfNN_ia64_aix_little_vec 1380 || vec == & bfd_elfNN_ia64_aix_big_vec); 1381 } 1382 1383 /* Hook called by the linker routine which adds symbols from an object 1384 file. We use it to handle OS-specific symbols. */ 1385 1386 static bfd_boolean 1387 elfNN_ia64_aix_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 1388 bfd *abfd; 1389 struct bfd_link_info *info; 1390 const Elf_Internal_Sym *sym; 1391 const char **namep; 1392 flagword *flagsp; 1393 asection **secp; 1394 bfd_vma *valp; 1395 { 1396 if (strcmp (*namep, "__GLOB_DATA_PTR") == 0) 1397 { 1398 /* Define __GLOB_DATA_PTR when it is encountered. This is expected to 1399 be a linker-defined symbol by the Aix C runtime startup code. IBM sez 1400 no one else should use it b/c it is undocumented. */ 1401 struct elf_link_hash_entry *h; 1402 1403 h = elf_link_hash_lookup (elf_hash_table (info), *namep, 1404 FALSE, FALSE, FALSE); 1405 if (h == NULL) 1406 { 1407 struct elf_backend_data *bed; 1408 struct elfNN_ia64_link_hash_table *ia64_info; 1409 struct bfd_link_hash_entry *bh = NULL; 1410 1411 bed = get_elf_backend_data (abfd); 1412 ia64_info = elfNN_ia64_hash_table (info); 1413 1414 if (!(_bfd_generic_link_add_one_symbol 1415 (info, abfd, *namep, BSF_GLOBAL, 1416 bfd_get_section_by_name (abfd, ".bss"), 1417 bed->got_symbol_offset, (const char *) NULL, FALSE, 1418 bed->collect, &bh))) 1419 return FALSE; 1420 1421 h = (struct elf_link_hash_entry *) bh; 1422 h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; 1423 h->type = STT_OBJECT; 1424 1425 if (! _bfd_elf_link_record_dynamic_symbol (info, h)) 1426 return FALSE; 1427 } 1428 1429 return TRUE; 1430 } 1431 else if (sym->st_shndx == SHN_LOOS) 1432 { 1433 unsigned int i; 1434 1435 /* SHN_AIX_SYSCALL: Treat this as any other symbol. The special symbol 1436 is only relevant when compiling code for extended system calls. 1437 Replace the "special" section with .text, if possible. 1438 Note that these symbols are always assumed to be in .text. */ 1439 for (i = 1; i < elf_numsections (abfd); i++) 1440 { 1441 asection * sec = bfd_section_from_elf_index (abfd, i); 1442 1443 if (sec && strcmp (sec->name, ".text") == 0) 1444 { 1445 *secp = sec; 1446 break; 1447 } 1448 } 1449 1450 if (*secp == NULL) 1451 *secp = bfd_abs_section_ptr; 1452 1453 *valp = sym->st_size; 1454 1455 return TRUE; 1456 } 1457 else 1458 { 1459 return elfNN_ia64_add_symbol_hook (abfd, info, sym, 1460 namep, flagsp, secp, valp); 1461 } 1462 } 1463 1464 bfd_boolean 1465 elfNN_ia64_aix_link_add_symbols (abfd, info) 1466 bfd *abfd; 1467 struct bfd_link_info *info; 1468 { 1469 /* Make sure dynamic sections are always created. */ 1470 if (! elf_hash_table (info)->dynamic_sections_created 1471 && abfd->xvec == info->hash->creator) 1472 { 1473 if (! bfd_elfNN_link_create_dynamic_sections (abfd, info)) 1474 return FALSE; 1475 } 1476 1477 /* Now do the standard call. */ 1478 return bfd_elfNN_bfd_link_add_symbols (abfd, info); 1130 1479 } 1131 1480 … … 1146 1495 /* Count how many PT_IA_64_UNWIND segments we need. */ 1147 1496 for (s = abfd->sections; s; s = s->next) 1148 if (is_unwind_section_name (s->name) && (s->flags & SEC_LOAD))1497 if (is_unwind_section_name (abfd, s->name) && (s->flags & SEC_LOAD)) 1149 1498 ++ret; 1150 1499 … … 1152 1501 } 1153 1502 1154 static b oolean1503 static bfd_boolean 1155 1504 elfNN_ia64_modify_segment_map (abfd) 1156 1505 bfd *abfd; … … 1170 1519 if (m == NULL) 1171 1520 { 1172 m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m); 1521 m = ((struct elf_segment_map *) 1522 bfd_zalloc (abfd, (bfd_size_type) sizeof *m)); 1173 1523 if (m == NULL) 1174 return false;1524 return FALSE; 1175 1525 1176 1526 m->p_type = PT_IA_64_ARCHEXT; … … 1200 1550 { 1201 1551 for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) 1202 if (m->p_type == PT_IA_64_UNWIND && m->sections[0] == s) 1203 break; 1552 if (m->p_type == PT_IA_64_UNWIND) 1553 { 1554 int i; 1555 1556 /* Look through all sections in the unwind segment 1557 for a match since there may be multiple sections 1558 to a segment. */ 1559 for (i = m->count - 1; i >= 0; --i) 1560 if (m->sections[i] == s) 1561 break; 1562 1563 if (i >= 0) 1564 break; 1565 } 1204 1566 1205 1567 if (m == NULL) 1206 1568 { 1207 m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m); 1569 m = ((struct elf_segment_map *) 1570 bfd_zalloc (abfd, (bfd_size_type) sizeof *m)); 1208 1571 if (m == NULL) 1209 return false;1572 return FALSE; 1210 1573 1211 1574 m->p_type = PT_IA_64_UNWIND; … … 1251 1614 } 1252 1615 1253 return true;1616 return TRUE; 1254 1617 } 1255 1618 … … 1257 1620 '.' are local. */ 1258 1621 1259 static b oolean1622 static bfd_boolean 1260 1623 elfNN_ia64_is_local_label_name (abfd, name) 1261 1624 bfd *abfd ATTRIBUTE_UNUSED; … … 1267 1630 /* Should we do dynamic things to this symbol? */ 1268 1631 1269 static b oolean1632 static bfd_boolean 1270 1633 elfNN_ia64_dynamic_symbol_p (h, info) 1271 1634 struct elf_link_hash_entry *h; … … 1273 1636 { 1274 1637 if (h == NULL) 1275 return false;1638 return FALSE; 1276 1639 1277 1640 while (h->root.type == bfd_link_hash_indirect … … 1280 1643 1281 1644 if (h->dynindx == -1) 1282 return false;1645 return FALSE; 1283 1646 switch (ELF_ST_VISIBILITY (h->other)) 1284 1647 { 1285 1648 case STV_INTERNAL: 1286 1649 case STV_HIDDEN: 1287 return false; 1650 return FALSE; 1651 default: 1652 break; 1288 1653 } 1289 1654 1290 1655 if (h->root.type == bfd_link_hash_undefweak 1291 1656 || h->root.type == bfd_link_hash_defweak) 1292 return true;1293 1294 if ((info->shared && !info->symbolic)1657 return TRUE; 1658 1659 if ((info->shared && (!info->symbolic || info->allow_shlib_undefined)) 1295 1660 || ((h->elf_link_hash_flags 1296 1661 & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)) 1297 1662 == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))) 1298 return true;1299 1300 return false;1301 } 1302 1303 1304 static b oolean1663 return TRUE; 1664 1665 return FALSE; 1666 } 1667 1668 1669 static bfd_boolean 1305 1670 elfNN_ia64_local_hash_table_init (ht, abfd, new) 1306 1671 struct elfNN_ia64_local_hash_table *ht; … … 1370 1735 1371 1736 static void 1372 elfNN_ia64_hash_copy_indirect (xdir, xind) 1737 elfNN_ia64_hash_copy_indirect (bed, xdir, xind) 1738 struct elf_backend_data *bed ATTRIBUTE_UNUSED; 1373 1739 struct elf_link_hash_entry *xdir, *xind; 1374 1740 { 1375 1741 struct elfNN_ia64_link_hash_entry *dir, *ind; 1376 1742 1377 dir = (struct elfNN_ia64_link_hash_entry *) xdir;1378 ind = (struct elfNN_ia64_link_hash_entry *) xind;1743 dir = (struct elfNN_ia64_link_hash_entry *) xdir; 1744 ind = (struct elfNN_ia64_link_hash_entry *) xind; 1379 1745 1380 1746 /* Copy down any references that we may have already seen to the … … 1387 1753 | ELF_LINK_HASH_REF_REGULAR_NONWEAK)); 1388 1754 1755 if (ind->root.root.type != bfd_link_hash_indirect) 1756 return; 1757 1389 1758 /* Copy over the got and plt data. This would have been done 1390 1759 by check_relocs. */ … … 1416 1785 1417 1786 static void 1418 elfNN_ia64_hash_hide_symbol (info, xh )1419 struct bfd_link_info *info ATTRIBUTE_UNUSED;1787 elfNN_ia64_hash_hide_symbol (info, xh, force_local) 1788 struct bfd_link_info *info; 1420 1789 struct elf_link_hash_entry *xh; 1790 bfd_boolean force_local; 1421 1791 { 1422 1792 struct elfNN_ia64_link_hash_entry *h; … … 1425 1795 h = (struct elfNN_ia64_link_hash_entry *)xh; 1426 1796 1427 h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; 1428 if ((h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0) 1429 h->root.dynindx = -1; 1797 _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local); 1430 1798 1431 1799 for (dyn_i = h->info; dyn_i; dyn_i = dyn_i->next) … … 1443 1811 struct elfNN_ia64_link_hash_table *ret; 1444 1812 1445 ret = bfd_ alloc (abfd,sizeof (*ret));1813 ret = bfd_zmalloc ((bfd_size_type) sizeof (*ret)); 1446 1814 if (!ret) 1447 1815 return 0; 1816 1448 1817 if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, 1449 1818 elfNN_ia64_new_elf_hash_entry)) 1450 1819 { 1451 bfd_release (abfd,ret);1820 free (ret); 1452 1821 return 0; 1453 1822 } … … 1455 1824 if (!elfNN_ia64_local_hash_table_init (&ret->loc_hash_table, abfd, 1456 1825 elfNN_ia64_new_loc_hash_entry)) 1457 return 0; 1826 { 1827 free (ret); 1828 return 0; 1829 } 1830 1458 1831 return &ret->root.root; 1459 1832 } … … 1465 1838 struct elfNN_ia64_local_hash_table *table; 1466 1839 const char *string; 1467 b oolean create, copy;1840 bfd_boolean create, copy; 1468 1841 { 1469 1842 return ((struct elfNN_ia64_local_hash_entry *) … … 1475 1848 struct elfNN_ia64_dyn_sym_traverse_data 1476 1849 { 1477 b oolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR));1850 bfd_boolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR)); 1478 1851 PTR data; 1479 1852 }; 1480 1853 1481 static b oolean1854 static bfd_boolean 1482 1855 elfNN_ia64_global_dyn_sym_thunk (xentry, xdata) 1483 1856 struct bfd_hash_entry *xentry; … … 1490 1863 struct elfNN_ia64_dyn_sym_info *dyn_i; 1491 1864 1865 if (entry->root.root.type == bfd_link_hash_warning) 1866 entry = (struct elfNN_ia64_link_hash_entry *) entry->root.root.u.i.link; 1867 1492 1868 for (dyn_i = entry->info; dyn_i; dyn_i = dyn_i->next) 1493 1869 if (! (*data->func) (dyn_i, data->data)) 1494 return false;1495 return true;1496 } 1497 1498 static b oolean1870 return FALSE; 1871 return TRUE; 1872 } 1873 1874 static bfd_boolean 1499 1875 elfNN_ia64_local_dyn_sym_thunk (xentry, xdata) 1500 1876 struct bfd_hash_entry *xentry; … … 1509 1885 for (dyn_i = entry->info; dyn_i; dyn_i = dyn_i->next) 1510 1886 if (! (*data->func) (dyn_i, data->data)) 1511 return false;1512 return true;1887 return FALSE; 1888 return TRUE; 1513 1889 } 1514 1890 … … 1516 1892 elfNN_ia64_dyn_sym_traverse (ia64_info, func, data) 1517 1893 struct elfNN_ia64_link_hash_table *ia64_info; 1518 b oolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR));1894 bfd_boolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR)); 1519 1895 PTR data; 1520 1896 { … … 1531 1907 1532 1908 1533 static b oolean1909 static bfd_boolean 1534 1910 elfNN_ia64_create_dynamic_sections (abfd, info) 1535 1911 bfd *abfd; … … 1540 1916 1541 1917 if (! _bfd_elf_create_dynamic_sections (abfd, info)) 1542 return false;1918 return FALSE; 1543 1919 1544 1920 ia64_info = elfNN_ia64_hash_table (info); … … 1553 1929 1554 1930 if (!get_pltoff (abfd, info, ia64_info)) 1555 return false;1931 return FALSE; 1556 1932 1557 1933 s = bfd_make_section(abfd, ".rela.IA_64.pltoff"); … … 1563 1939 | SEC_READONLY)) 1564 1940 || !bfd_set_section_alignment (abfd, s, 3)) 1565 return false;1941 return FALSE; 1566 1942 ia64_info->rel_pltoff_sec = s; 1567 1943 … … 1574 1950 | SEC_READONLY)) 1575 1951 || !bfd_set_section_alignment (abfd, s, 3)) 1576 return false;1952 return FALSE; 1577 1953 ia64_info->rel_got_sec = s; 1578 1954 1579 return true; 1955 return TRUE; 1956 } 1957 1958 /* Find and/or create a hash entry for local symbol. */ 1959 static struct elfNN_ia64_local_hash_entry * 1960 get_local_sym_hash (ia64_info, abfd, rel, create) 1961 struct elfNN_ia64_link_hash_table *ia64_info; 1962 bfd *abfd; 1963 const Elf_Internal_Rela *rel; 1964 bfd_boolean create; 1965 { 1966 struct elfNN_ia64_local_hash_entry *ret; 1967 asection *sec = abfd->sections; 1968 char addr_name [34]; 1969 1970 BFD_ASSERT ((sizeof (sec->id)*2 + 1 + sizeof (unsigned long)*2 + 1) <= 34); 1971 BFD_ASSERT (sec); 1972 1973 /* Construct a string for use in the elfNN_ia64_local_hash_table. 1974 name describes what was once anonymous memory. */ 1975 1976 sprintf (addr_name, "%x:%lx", 1977 sec->id, (unsigned long) ELFNN_R_SYM (rel->r_info)); 1978 1979 /* Collect the canonical entry data for this address. */ 1980 ret = elfNN_ia64_local_hash_lookup (&ia64_info->loc_hash_table, 1981 addr_name, create, create); 1982 return ret; 1580 1983 } 1581 1984 … … 1589 1992 bfd *abfd; 1590 1993 const Elf_Internal_Rela *rel; 1591 b oolean create;1994 bfd_boolean create; 1592 1995 { 1593 1996 struct elfNN_ia64_dyn_sym_info **pp; … … 1600 2003 { 1601 2004 struct elfNN_ia64_local_hash_entry *loc_h; 1602 char *addr_name; 1603 size_t len; 1604 1605 /* Construct a string for use in the elfNN_ia64_local_hash_table. 1606 The name describes what was once anonymous memory. */ 1607 1608 len = sizeof (void*)*2 + 1 + sizeof (bfd_vma)*4 + 1 + 1; 1609 len += 10; /* %p slop */ 1610 1611 addr_name = alloca (len); 1612 sprintf (addr_name, "%p:%lx", (void *) abfd, ELFNN_R_SYM (rel->r_info)); 1613 1614 /* Collect the canonical entry data for this address. */ 1615 loc_h = elfNN_ia64_local_hash_lookup (&ia64_info->loc_hash_table, 1616 addr_name, create, create); 1617 BFD_ASSERT (loc_h); 2005 2006 loc_h = get_local_sym_hash (ia64_info, abfd, rel, create); 2007 if (!loc_h) 2008 { 2009 BFD_ASSERT (!create); 2010 return NULL; 2011 } 1618 2012 1619 2013 pp = &loc_h->info; … … 1625 2019 if (dyn_i == NULL && create) 1626 2020 { 1627 dyn_i = ( struct elfNN_ia64_dyn_sym_info *)1628 bfd_zalloc (abfd, sizeof *dyn_i);2021 dyn_i = ((struct elfNN_ia64_dyn_sym_info *) 2022 bfd_zalloc (abfd, (bfd_size_type) sizeof *dyn_i)); 1629 2023 *pp = dyn_i; 1630 2024 dyn_i->addend = addend; … … 1749 2143 struct elfNN_ia64_link_hash_table *ia64_info; 1750 2144 asection *sec; 1751 b oolean create;2145 bfd_boolean create; 1752 2146 { 1753 2147 const char *srel_name; … … 1788 2182 } 1789 2183 2184 if (sec->flags & SEC_READONLY) 2185 ia64_info->reltext = 1; 2186 1790 2187 return srel; 1791 2188 } 1792 2189 1793 static b oolean2190 static bfd_boolean 1794 2191 count_dyn_reloc (abfd, dyn_i, srel, type) 1795 2192 bfd *abfd; … … 1806 2203 if (!rent) 1807 2204 { 1808 rent = ( struct elfNN_ia64_dyn_reloc_entry *)1809 bfd_alloc (abfd, sizeof (*rent));2205 rent = ((struct elfNN_ia64_dyn_reloc_entry *) 2206 bfd_alloc (abfd, (bfd_size_type) sizeof (*rent))); 1810 2207 if (!rent) 1811 return false;2208 return FALSE; 1812 2209 1813 2210 rent->next = dyn_i->reloc_entries; … … 1819 2216 rent->count++; 1820 2217 1821 return true;1822 } 1823 1824 static b oolean2218 return TRUE; 2219 } 2220 2221 static bfd_boolean 1825 2222 elfNN_ia64_check_relocs (abfd, info, sec, relocs) 1826 2223 bfd *abfd; … … 1836 2233 1837 2234 if (info->relocateable) 1838 return true;2235 return TRUE; 1839 2236 1840 2237 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; … … 1848 2245 enum { 1849 2246 NEED_GOT = 1, 1850 NEED_FPTR = 2, 1851 NEED_PLTOFF = 4, 1852 NEED_MIN_PLT = 8, 1853 NEED_FULL_PLT = 16, 1854 NEED_DYNREL = 32, 1855 NEED_LTOFF_FPTR = 64, 2247 NEED_GOTX = 2, 2248 NEED_FPTR = 4, 2249 NEED_PLTOFF = 8, 2250 NEED_MIN_PLT = 16, 2251 NEED_FULL_PLT = 32, 2252 NEED_DYNREL = 64, 2253 NEED_LTOFF_FPTR = 128, 2254 NEED_TPREL = 256, 2255 NEED_DTPMOD = 512, 2256 NEED_DTPREL = 1024 1856 2257 }; 1857 2258 … … 1860 2261 struct elfNN_ia64_dyn_sym_info *dyn_i; 1861 2262 int need_entry; 1862 b oolean maybe_dynamic;2263 bfd_boolean maybe_dynamic; 1863 2264 int dynrel_type = R_IA64_NONE; 1864 2265 … … 1880 2281 have yet been processed. Do something with what we know, as 1881 2282 this may help reduce memory usage and processing time later. */ 1882 maybe_dynamic = false; 1883 if (h && ((info->shared && ! info->symbolic) 2283 maybe_dynamic = FALSE; 2284 if (h && ((info->shared 2285 && (!info->symbolic || info->allow_shlib_undefined)) 1884 2286 || ! (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) 1885 || h->root.type == bfd_link_hash_defweak)) 1886 maybe_dynamic = true; 2287 || h->root.type == bfd_link_hash_defweak 2288 || elfNN_ia64_aix_vec (abfd->xvec))) 2289 maybe_dynamic = TRUE; 1887 2290 1888 2291 need_entry = 0; 1889 2292 switch (ELFNN_R_TYPE (rel->r_info)) 1890 2293 { 1891 case R_IA64_TPREL22:1892 2294 case R_IA64_TPREL64MSB: 1893 2295 case R_IA64_TPREL64LSB: 1894 case R_IA64_LTOFF_TP22: 1895 return false; 2296 if (info->shared || maybe_dynamic) 2297 need_entry = NEED_DYNREL; 2298 dynrel_type = R_IA64_TPREL64LSB; 2299 if (info->shared) 2300 info->flags |= DF_STATIC_TLS; 2301 break; 2302 2303 case R_IA64_LTOFF_TPREL22: 2304 need_entry = NEED_TPREL; 2305 if (info->shared) 2306 info->flags |= DF_STATIC_TLS; 2307 break; 2308 2309 case R_IA64_DTPREL64MSB: 2310 case R_IA64_DTPREL64LSB: 2311 if (info->shared || maybe_dynamic) 2312 need_entry = NEED_DYNREL; 2313 dynrel_type = R_IA64_DTPREL64LSB; 2314 break; 2315 2316 case R_IA64_LTOFF_DTPREL22: 2317 need_entry = NEED_DTPREL; 2318 break; 2319 2320 case R_IA64_DTPMOD64MSB: 2321 case R_IA64_DTPMOD64LSB: 2322 if (info->shared || maybe_dynamic) 2323 need_entry = NEED_DYNREL; 2324 dynrel_type = R_IA64_DTPMOD64LSB; 2325 break; 2326 2327 case R_IA64_LTOFF_DTPMOD22: 2328 need_entry = NEED_DTPMOD; 2329 break; 1896 2330 1897 2331 case R_IA64_LTOFF_FPTR22: 1898 2332 case R_IA64_LTOFF_FPTR64I: 2333 case R_IA64_LTOFF_FPTR32MSB: 2334 case R_IA64_LTOFF_FPTR32LSB: 1899 2335 case R_IA64_LTOFF_FPTR64MSB: 1900 2336 case R_IA64_LTOFF_FPTR64LSB: … … 1907 2343 case R_IA64_FPTR64MSB: 1908 2344 case R_IA64_FPTR64LSB: 1909 if (info->shared || h )2345 if (info->shared || h || elfNN_ia64_aix_vec (abfd->xvec)) 1910 2346 need_entry = NEED_FPTR | NEED_DYNREL; 1911 2347 else … … 1915 2351 1916 2352 case R_IA64_LTOFF22: 1917 case R_IA64_LTOFF22X:1918 2353 case R_IA64_LTOFF64I: 1919 2354 need_entry = NEED_GOT; 2355 break; 2356 2357 case R_IA64_LTOFF22X: 2358 need_entry = NEED_GOTX; 1920 2359 break; 1921 2360 … … 1934 2373 (*info->callbacks->warning) 1935 2374 (info, _("@pltoff reloc against local symbol"), 0, 1936 abfd, 0, 0);2375 abfd, 0, (bfd_vma) 0); 1937 2376 } 1938 2377 break; … … 1956 2395 case R_IA64_DIR64LSB: 1957 2396 /* Shared objects will always need at least a REL relocation. */ 1958 if (info->shared || maybe_dynamic) 2397 if (info->shared || maybe_dynamic 2398 || (elfNN_ia64_aix_vec (abfd->xvec) 2399 && (!h || strcmp (h->root.root.string, 2400 "__GLOB_DATA_PTR") != 0))) 1959 2401 need_entry = NEED_DYNREL; 1960 2402 dynrel_type = R_IA64_DIR64LSB; … … 1989 2431 (*info->callbacks->warning) 1990 2432 (info, _("non-zero addend in @fptr reloc"), 0, 1991 abfd, 0, 0);1992 } 1993 1994 dyn_i = get_dyn_sym_info (ia64_info, h, abfd, rel, true);2433 abfd, 0, (bfd_vma) 0); 2434 } 2435 2436 dyn_i = get_dyn_sym_info (ia64_info, h, abfd, rel, TRUE); 1995 2437 1996 2438 /* Record whether or not this is a local symbol. */ … … 1998 2440 1999 2441 /* Create what's needed. */ 2000 if (need_entry & NEED_GOT) 2442 if (need_entry & (NEED_GOT | NEED_GOTX | NEED_TPREL 2443 | NEED_DTPMOD | NEED_DTPREL)) 2001 2444 { 2002 2445 if (!got) … … 2004 2447 got = get_got (abfd, info, ia64_info); 2005 2448 if (!got) 2006 return false;2449 return FALSE; 2007 2450 } 2008 dyn_i->want_got = 1; 2451 if (need_entry & NEED_GOT) 2452 dyn_i->want_got = 1; 2453 if (need_entry & NEED_GOTX) 2454 dyn_i->want_gotx = 1; 2455 if (need_entry & NEED_TPREL) 2456 dyn_i->want_tprel = 1; 2457 if (need_entry & NEED_DTPMOD) 2458 dyn_i->want_dtpmod = 1; 2459 if (need_entry & NEED_DTPREL) 2460 dyn_i->want_dtprel = 1; 2009 2461 } 2010 2462 if (need_entry & NEED_FPTR) … … 2014 2466 fptr = get_fptr (abfd, info, ia64_info); 2015 2467 if (!fptr) 2016 return false;2468 return FALSE; 2017 2469 } 2018 2470 … … 2020 2472 linker. Make sure this local symbol will appear in the 2021 2473 dynamic symbol table. */ 2022 if (!h && info->shared) 2474 if (!h && (info->shared 2475 /* AIX also needs one */ 2476 || elfNN_ia64_aix_vec (abfd->xvec))) 2023 2477 { 2024 2478 if (! (_bfd_elfNN_link_record_local_dynamic_symbol 2025 (info, abfd, r_symndx)))2026 return false;2479 (info, abfd, (long) r_symndx))) 2480 return FALSE; 2027 2481 } 2028 2482 … … 2046 2500 if (!srel) 2047 2501 { 2048 srel = get_reloc_section (abfd, ia64_info, sec, true);2502 srel = get_reloc_section (abfd, ia64_info, sec, TRUE); 2049 2503 if (!srel) 2050 return false;2504 return FALSE; 2051 2505 } 2052 2506 if (!count_dyn_reloc (abfd, dyn_i, srel, dynrel_type)) 2053 return false; 2054 } 2055 } 2056 2057 return true; 2058 } 2059 2060 struct elfNN_ia64_allocate_data 2061 { 2062 struct bfd_link_info *info; 2063 bfd_size_type ofs; 2064 }; 2507 return FALSE; 2508 } 2509 } 2510 2511 return TRUE; 2512 } 2065 2513 2066 2514 /* For cleanliness, and potentially faster dynamic loading, allocate 2067 2515 external GOT entries first. */ 2068 2516 2069 static b oolean2517 static bfd_boolean 2070 2518 allocate_global_data_got (dyn_i, data) 2071 2519 struct elfNN_ia64_dyn_sym_info *dyn_i; … … 2074 2522 struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; 2075 2523 2076 if ( dyn_i->want_got2524 if ((dyn_i->want_got || dyn_i->want_gotx) 2077 2525 && ! dyn_i->want_fptr 2078 && elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)) 2526 && (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info) 2527 || (elfNN_ia64_aix_vec (x->info->hash->creator) 2528 && (!dyn_i->h || strcmp (dyn_i->h->root.root.string, 2529 "__GLOB_DATA_PTR") != 0)))) 2079 2530 { 2080 2531 dyn_i->got_offset = x->ofs; 2081 2532 x->ofs += 8; 2082 2533 } 2083 return true; 2534 if (dyn_i->want_tprel) 2535 { 2536 dyn_i->tprel_offset = x->ofs; 2537 x->ofs += 8; 2538 } 2539 if (dyn_i->want_dtpmod) 2540 { 2541 if (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)) 2542 { 2543 dyn_i->dtpmod_offset = x->ofs; 2544 x->ofs += 8; 2545 } 2546 else 2547 { 2548 struct elfNN_ia64_link_hash_table *ia64_info; 2549 2550 ia64_info = elfNN_ia64_hash_table (x->info); 2551 if (ia64_info->self_dtpmod_offset == (bfd_vma) -1) 2552 { 2553 ia64_info->self_dtpmod_offset = x->ofs; 2554 x->ofs += 8; 2555 } 2556 dyn_i->dtpmod_offset = ia64_info->self_dtpmod_offset; 2557 } 2558 } 2559 if (dyn_i->want_dtprel) 2560 { 2561 dyn_i->dtprel_offset = x->ofs; 2562 x->ofs += 8; 2563 } 2564 return TRUE; 2084 2565 } 2085 2566 2086 2567 /* Next, allocate all the GOT entries used by LTOFF_FPTR relocs. */ 2087 2568 2088 static b oolean2569 static bfd_boolean 2089 2570 allocate_global_fptr_got (dyn_i, data) 2090 2571 struct elfNN_ia64_dyn_sym_info *dyn_i; … … 2095 2576 if (dyn_i->want_got 2096 2577 && dyn_i->want_fptr 2097 && elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)) 2578 && (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info) 2579 || elfNN_ia64_aix_vec (x->info->hash->creator))) 2098 2580 { 2099 2581 dyn_i->got_offset = x->ofs; 2100 2582 x->ofs += 8; 2101 2583 } 2102 return true;2584 return TRUE; 2103 2585 } 2104 2586 2105 2587 /* Lastly, allocate all the GOT entries for local data. */ 2106 2588 2107 static b oolean2589 static bfd_boolean 2108 2590 allocate_local_got (dyn_i, data) 2109 2591 struct elfNN_ia64_dyn_sym_info *dyn_i; … … 2112 2594 struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; 2113 2595 2114 if (dyn_i->want_got 2115 && ! elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)) 2596 if ((dyn_i->want_got || dyn_i->want_gotx) 2597 && ! (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info) 2598 || elfNN_ia64_aix_vec (x->info->hash->creator))) 2116 2599 { 2117 2600 dyn_i->got_offset = x->ofs; 2118 2601 x->ofs += 8; 2119 2602 } 2120 return true;2603 return TRUE; 2121 2604 } 2122 2605 2123 2606 /* Search for the index of a global symbol in it's defining object file. */ 2124 2607 2125 static unsignedlong2608 static long 2126 2609 global_sym_index (h) 2127 2610 struct elf_link_hash_entry *h; … … 2143 2626 in a main executable that is not exported. */ 2144 2627 2145 static b oolean2628 static bfd_boolean 2146 2629 allocate_fptr (dyn_i, data) 2147 2630 struct elfNN_ia64_dyn_sym_info *dyn_i; … … 2159 2642 h = (struct elf_link_hash_entry *) h->root.u.i.link; 2160 2643 2161 if (x->info->shared) 2644 if (x->info->shared 2645 /* AIX needs an FPTR in this case. */ 2646 || (elfNN_ia64_aix_vec (x->info->hash->creator) 2647 && (!h 2648 || h->root.type == bfd_link_hash_defined 2649 || h->root.type == bfd_link_hash_defweak))) 2162 2650 { 2163 2651 if (h && h->dynindx == -1) … … 2169 2657 (x->info, h->root.u.def.section->owner, 2170 2658 global_sym_index (h))) 2171 return false;2659 return FALSE; 2172 2660 } 2173 2661 … … 2182 2670 dyn_i->want_fptr = 0; 2183 2671 } 2184 return true;2672 return TRUE; 2185 2673 } 2186 2674 2187 2675 /* Allocate all the minimal PLT entries. */ 2188 2676 2189 static b oolean2677 static bfd_boolean 2190 2678 allocate_plt_entries (dyn_i, data) 2191 2679 struct elfNN_ia64_dyn_sym_info *dyn_i; … … 2220 2708 } 2221 2709 } 2222 return true;2710 return TRUE; 2223 2711 } 2224 2712 2225 2713 /* Allocate all the full PLT entries. */ 2226 2714 2227 static b oolean2715 static bfd_boolean 2228 2716 allocate_plt2_entries (dyn_i, data) 2229 2717 struct elfNN_ia64_dyn_sym_info *dyn_i; … … 2245 2733 dyn_i->h->plt.offset = ofs; 2246 2734 } 2247 return true;2735 return TRUE; 2248 2736 } 2249 2737 … … 2253 2741 ??? Relaxation might be able to determine that they are. */ 2254 2742 2255 static b oolean2743 static bfd_boolean 2256 2744 allocate_pltoff_entries (dyn_i, data) 2257 2745 struct elfNN_ia64_dyn_sym_info *dyn_i; … … 2265 2753 x->ofs += 16; 2266 2754 } 2267 return true;2755 return TRUE; 2268 2756 } 2269 2757 … … 2271 2759 to be dynamic. */ 2272 2760 2273 static b oolean2761 static bfd_boolean 2274 2762 allocate_dynrel_entries (dyn_i, data) 2275 2763 struct elfNN_ia64_dyn_sym_info *dyn_i; … … 2279 2767 struct elfNN_ia64_link_hash_table *ia64_info; 2280 2768 struct elfNN_ia64_dyn_reloc_entry *rent; 2281 b oolean dynamic_symbol, shared;2769 bfd_boolean dynamic_symbol, shared; 2282 2770 2283 2771 ia64_info = elfNN_ia64_hash_table (x->info); 2284 dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info); 2772 dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info) 2773 || (elfNN_ia64_aix_vec (x->info->hash->creator) 2774 /* Don't allocate an entry for __GLOB_DATA_PTR */ 2775 && (!dyn_i->h || strcmp (dyn_i->h->root.root.string, 2776 "__GLOB_DATA_PTR") != 0)); 2285 2777 shared = x->info->shared; 2286 2778 … … 2316 2808 count *= 2; 2317 2809 break; 2810 case R_IA64_TPREL64LSB: 2811 case R_IA64_DTPREL64LSB: 2812 case R_IA64_DTPMOD64LSB: 2813 break; 2318 2814 default: 2319 2815 abort (); … … 2324 2820 /* Take care of the GOT and PLT relocations. */ 2325 2821 2326 if (((dynamic_symbol || shared) && dyn_i->want_got)2822 if (((dynamic_symbol || shared) && (dyn_i->want_got || dyn_i->want_gotx)) 2327 2823 || (dyn_i->want_ltoff_fptr && dyn_i->h && dyn_i->h->dynindx != -1)) 2824 ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); 2825 if ((dynamic_symbol || shared) && dyn_i->want_tprel) 2826 ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); 2827 if (dynamic_symbol && dyn_i->want_dtpmod) 2828 ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); 2829 if (dynamic_symbol && dyn_i->want_dtprel) 2328 2830 ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); 2329 2831 … … 2343 2845 } 2344 2846 2345 return true;2346 } 2347 2348 static b oolean2847 return TRUE; 2848 } 2849 2850 static bfd_boolean 2349 2851 elfNN_ia64_adjust_dynamic_symbol (info, h) 2350 2852 struct bfd_link_info *info ATTRIBUTE_UNUSED; … … 2363 2865 h->root.u.def.section = h->weakdef->root.u.def.section; 2364 2866 h->root.u.def.value = h->weakdef->root.u.def.value; 2365 return true;2867 return TRUE; 2366 2868 } 2367 2869 … … 2373 2875 of hackery. */ 2374 2876 2375 return true;2376 } 2377 2378 static b oolean2877 return TRUE; 2878 } 2879 2880 static bfd_boolean 2379 2881 elfNN_ia64_size_dynamic_sections (output_bfd, info) 2380 2882 bfd *output_bfd; … … 2385 2887 asection *sec; 2386 2888 bfd *dynobj; 2387 boolean reltext = false; 2388 boolean relplt = false; 2889 bfd_boolean relplt = FALSE; 2389 2890 2390 2891 dynobj = elf_hash_table(info)->dynobj; 2391 2892 ia64_info = elfNN_ia64_hash_table (info); 2893 ia64_info->self_dtpmod_offset = (bfd_vma) -1; 2392 2894 BFD_ASSERT(dynobj != NULL); 2393 2895 data.info = info; … … 2399 2901 sec = bfd_get_section_by_name (dynobj, ".interp"); 2400 2902 BFD_ASSERT (sec != NULL); 2401 sec->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;2402 sec->_raw_size = strlen ( ELF_DYNAMIC_INTERPRETER) + 1;2903 sec->contents = (bfd_byte *) DYNAMIC_INTERPRETER (output_bfd); 2904 sec->_raw_size = strlen (DYNAMIC_INTERPRETER (output_bfd)) + 1; 2403 2905 } 2404 2906 … … 2425 2927 /* Now that we've seen all of the input files, we can decide which 2426 2928 symbols need plt entries. Allocate the minimal PLT entries first. 2427 We do this even though dynamic_sections_created may be false, because2929 We do this even though dynamic_sections_created may be FALSE, because 2428 2930 this has the side-effect of clearing want_plt and want_plt2. */ 2429 2931 … … 2439 2941 2440 2942 /* Align the pointer for the plt2 entries. */ 2441 data.ofs = (data.ofs + 31) & -32;2943 data.ofs = (data.ofs + 31) & (bfd_vma) -32; 2442 2944 2443 2945 elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_plt2_entries, &data); … … 2468 2970 required. */ 2469 2971 2972 if (info->shared && ia64_info->self_dtpmod_offset != (bfd_vma) -1) 2973 ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); 2470 2974 elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_dynrel_entries, &data); 2471 2975 } … … 2475 2979 for (sec = dynobj->sections; sec != NULL; sec = sec->next) 2476 2980 { 2477 b oolean strip;2981 bfd_boolean strip; 2478 2982 2479 2983 if (!(sec->flags & SEC_LINKER_CREATED)) … … 2491 2995 2492 2996 if (sec == ia64_info->got_sec) 2493 strip = false;2997 strip = FALSE; 2494 2998 else if (sec == ia64_info->rel_got_sec) 2495 2999 { … … 2522 3026 else 2523 3027 { 2524 relplt = true;3028 relplt = TRUE; 2525 3029 /* We use the reloc_count field as a counter if we need to 2526 3030 copy relocs into the output file. */ … … 2537 3041 2538 3042 if (strcmp (name, ".got.plt") == 0) 2539 strip = false;3043 strip = FALSE; 2540 3044 else if (strncmp (name, ".rel", 4) == 0) 2541 3045 { 2542 3046 if (!strip) 2543 3047 { 2544 const char *outname;2545 asection *target;2546 2547 /* If this relocation section applies to a read only2548 section, then we probably need a DT_TEXTREL entry. */2549 outname = bfd_get_section_name (output_bfd,2550 sec->output_section);2551 if (outname[4] == 'a')2552 outname += 5;2553 else2554 outname += 4;2555 2556 target = bfd_get_section_by_name (output_bfd, outname);2557 if (target != NULL2558 && (target->flags & SEC_READONLY) != 02559 && (target->flags & SEC_ALLOC) != 0)2560 reltext = true;2561 2562 3048 /* We use the reloc_count field as a counter if we need to 2563 3049 copy relocs into the output file. */ … … 2574 3060 { 2575 3061 /* Allocate memory for the section contents. */ 2576 sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->_raw_size);3062 sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->_raw_size); 2577 3063 if (sec->contents == NULL && sec->_raw_size != 0) 2578 return false;3064 return FALSE; 2579 3065 } 2580 3066 } … … 2590 3076 /* The DT_DEBUG entry is filled in by the dynamic linker and used 2591 3077 by the debugger. */ 2592 if (!bfd_elfNN_add_dynamic_entry (info, DT_DEBUG, 0)) 2593 return false; 2594 } 2595 2596 if (! bfd_elfNN_add_dynamic_entry (info, DT_IA_64_PLT_RESERVE, 0)) 2597 return false; 2598 if (! bfd_elfNN_add_dynamic_entry (info, DT_PLTGOT, 0)) 2599 return false; 3078 #define add_dynamic_entry(TAG, VAL) \ 3079 bfd_elfNN_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) 3080 3081 if (!add_dynamic_entry (DT_DEBUG, 0)) 3082 return FALSE; 3083 } 3084 3085 if (!add_dynamic_entry (DT_IA_64_PLT_RESERVE, 0)) 3086 return FALSE; 3087 if (!add_dynamic_entry (DT_PLTGOT, 0)) 3088 return FALSE; 2600 3089 2601 3090 if (relplt) 2602 3091 { 2603 if (! bfd_elfNN_add_dynamic_entry (info, DT_PLTRELSZ, 0) 2604 || ! bfd_elfNN_add_dynamic_entry (info, DT_PLTREL, DT_RELA) 2605 || ! bfd_elfNN_add_dynamic_entry (info, DT_JMPREL, 0)) 2606 return false; 2607 } 2608 2609 if (! bfd_elfNN_add_dynamic_entry (info, DT_RELA, 0) 2610 || ! bfd_elfNN_add_dynamic_entry (info, DT_RELASZ, 0) 2611 || ! bfd_elfNN_add_dynamic_entry (info, DT_RELAENT, 2612 sizeof (ElfNN_External_Rela))) 2613 return false; 2614 2615 if (reltext) 2616 { 2617 if (! bfd_elfNN_add_dynamic_entry (info, DT_TEXTREL, 0)) 2618 return false; 3092 if (!add_dynamic_entry (DT_PLTRELSZ, 0) 3093 || !add_dynamic_entry (DT_PLTREL, DT_RELA) 3094 || !add_dynamic_entry (DT_JMPREL, 0)) 3095 return FALSE; 3096 } 3097 3098 if (!add_dynamic_entry (DT_RELA, 0) 3099 || !add_dynamic_entry (DT_RELASZ, 0) 3100 || !add_dynamic_entry (DT_RELAENT, sizeof (ElfNN_External_Rela))) 3101 return FALSE; 3102 3103 if (ia64_info->reltext) 3104 { 3105 if (!add_dynamic_entry (DT_TEXTREL, 0)) 3106 return FALSE; 2619 3107 info->flags |= DF_TEXTREL; 2620 3108 } … … 2623 3111 /* ??? Perhaps force __gp local. */ 2624 3112 2625 return true;3113 return TRUE; 2626 3114 } 2627 3115 2628 3116 static bfd_reloc_status_type 2629 elfNN_ia64_install_value (abfd, hit_addr, v al, r_type)3117 elfNN_ia64_install_value (abfd, hit_addr, v, r_type) 2630 3118 bfd *abfd; 2631 3119 bfd_byte *hit_addr; 2632 bfd_vma v al;3120 bfd_vma v; 2633 3121 unsigned int r_type; 2634 3122 { … … 2639 3127 const char *err; 2640 3128 size_t size = 8; 3129 #ifdef BFD_HOST_U_64_BIT 3130 BFD_HOST_U_64_BIT val = (BFD_HOST_U_64_BIT) v; 3131 #else 3132 bfd_vma val = v; 3133 #endif 2641 3134 2642 3135 opnd = IA64_OPND_NIL; … … 2649 3142 /* Instruction relocations. */ 2650 3143 2651 case R_IA64_IMM14: opnd = IA64_OPND_IMM14; break; 3144 case R_IA64_IMM14: 3145 case R_IA64_TPREL14: 3146 case R_IA64_DTPREL14: 3147 opnd = IA64_OPND_IMM14; 3148 break; 2652 3149 2653 3150 case R_IA64_PCREL21F: opnd = IA64_OPND_TGT25; break; … … 2666 3163 case R_IA64_PCREL22: 2667 3164 case R_IA64_LTOFF_FPTR22: 3165 case R_IA64_TPREL22: 3166 case R_IA64_DTPREL22: 3167 case R_IA64_LTOFF_TPREL22: 3168 case R_IA64_LTOFF_DTPMOD22: 3169 case R_IA64_LTOFF_DTPREL22: 2668 3170 opnd = IA64_OPND_IMM22; 2669 3171 break; … … 2676 3178 case R_IA64_FPTR64I: 2677 3179 case R_IA64_LTOFF_FPTR64I: 3180 case R_IA64_TPREL64I: 3181 case R_IA64_DTPREL64I: 2678 3182 opnd = IA64_OPND_IMMU64; 2679 3183 break; … … 2685 3189 case R_IA64_FPTR32MSB: 2686 3190 case R_IA64_PCREL32MSB: 3191 case R_IA64_LTOFF_FPTR32MSB: 2687 3192 case R_IA64_SEGREL32MSB: 2688 3193 case R_IA64_SECREL32MSB: 2689 3194 case R_IA64_LTV32MSB: 3195 case R_IA64_DTPREL32MSB: 2690 3196 size = 4; bigendian = 1; 2691 3197 break; … … 2695 3201 case R_IA64_FPTR32LSB: 2696 3202 case R_IA64_PCREL32LSB: 3203 case R_IA64_LTOFF_FPTR32LSB: 2697 3204 case R_IA64_SEGREL32LSB: 2698 3205 case R_IA64_SECREL32LSB: 2699 3206 case R_IA64_LTV32LSB: 3207 case R_IA64_DTPREL32LSB: 2700 3208 size = 4; bigendian = 0; 2701 3209 break; … … 2710 3218 case R_IA64_SECREL64MSB: 2711 3219 case R_IA64_LTV64MSB: 3220 case R_IA64_TPREL64MSB: 3221 case R_IA64_DTPMOD64MSB: 3222 case R_IA64_DTPREL64MSB: 2712 3223 size = 8; bigendian = 1; 2713 3224 break; … … 2722 3233 case R_IA64_SECREL64LSB: 2723 3234 case R_IA64_LTV64LSB: 3235 case R_IA64_TPREL64LSB: 3236 case R_IA64_DTPMOD64LSB: 3237 case R_IA64_DTPREL64LSB: 2724 3238 size = 8; bigendian = 0; 2725 3239 break; … … 2798 3312 2799 3313 op = elf64_ia64_operands + opnd; 2800 err = (*op->insert) (op, val, &insn);3314 err = (*op->insert) (op, val, (ia64_insn *)& insn); 2801 3315 if (err) 2802 3316 return bfd_reloc_overflow; … … 2838 3352 { 2839 3353 Elf_Internal_Rela outrel; 2840 2841 outrel.r_offset = (sec->output_section->vma 2842 + sec->output_offset 2843 + offset); 3354 bfd_byte *loc; 2844 3355 2845 3356 BFD_ASSERT (dynindx != -1); 2846 3357 outrel.r_info = ELFNN_R_INFO (dynindx, type); 2847 3358 outrel.r_addend = addend; 2848 2849 if (elf_section_data (sec)->stab_info != NULL) 2850 { 2851 /* This may be NULL for linker-generated relocations, as it is 2852 inconvenient to pass all the bits around. And this shouldn't 2853 happen. */ 2854 BFD_ASSERT (info != NULL); 2855 2856 offset = (_bfd_stab_section_offset 2857 (abfd, &elf_hash_table (info)->stab_info, sec, 2858 &elf_section_data (sec)->stab_info, offset)); 2859 if (offset == (bfd_vma) -1) 2860 { 2861 /* Run for the hills. We shouldn't be outputting a relocation 2862 for this. So do what everyone else does and output a no-op. */ 2863 outrel.r_info = ELFNN_R_INFO (0, R_IA64_NONE); 2864 outrel.r_addend = 0; 2865 offset = 0; 2866 } 2867 outrel.r_offset = offset; 2868 } 2869 2870 bfd_elfNN_swap_reloca_out (abfd, &outrel, 2871 ((ElfNN_External_Rela *) srel->contents 2872 + srel->reloc_count++)); 3359 outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset); 3360 if (outrel.r_offset >= (bfd_vma) -2) 3361 { 3362 /* Run for the hills. We shouldn't be outputting a relocation 3363 for this. So do what everyone else does and output a no-op. */ 3364 outrel.r_info = ELFNN_R_INFO (0, R_IA64_NONE); 3365 outrel.r_addend = 0; 3366 outrel.r_offset = 0; 3367 } 3368 else 3369 outrel.r_offset += sec->output_section->vma + sec->output_offset; 3370 3371 loc = srel->contents; 3372 loc += srel->reloc_count++ * sizeof (ElfNN_External_Rela); 3373 bfd_elfNN_swap_reloca_out (abfd, &outrel, loc); 2873 3374 BFD_ASSERT (sizeof (ElfNN_External_Rela) * srel->reloc_count 2874 3375 <= srel->_cooked_size); … … 2890 3391 struct elfNN_ia64_link_hash_table *ia64_info; 2891 3392 asection *got_sec; 3393 bfd_boolean done; 3394 bfd_vma got_offset; 2892 3395 2893 3396 ia64_info = elfNN_ia64_hash_table (info); 2894 3397 got_sec = ia64_info->got_sec; 2895 3398 2896 BFD_ASSERT ((dyn_i->got_offset & 7) == 0); 2897 2898 if (! dyn_i->got_done) 2899 { 2900 dyn_i->got_done = true; 2901 3399 switch (dyn_r_type) 3400 { 3401 case R_IA64_TPREL64LSB: 3402 done = dyn_i->tprel_done; 3403 dyn_i->tprel_done = TRUE; 3404 got_offset = dyn_i->tprel_offset; 3405 break; 3406 case R_IA64_DTPMOD64LSB: 3407 if (dyn_i->dtpmod_offset != ia64_info->self_dtpmod_offset) 3408 { 3409 done = dyn_i->dtpmod_done; 3410 dyn_i->dtpmod_done = TRUE; 3411 } 3412 else 3413 { 3414 done = ia64_info->self_dtpmod_done; 3415 ia64_info->self_dtpmod_done = TRUE; 3416 dynindx = 0; 3417 } 3418 got_offset = dyn_i->dtpmod_offset; 3419 break; 3420 case R_IA64_DTPREL64LSB: 3421 done = dyn_i->dtprel_done; 3422 dyn_i->dtprel_done = TRUE; 3423 got_offset = dyn_i->dtprel_offset; 3424 break; 3425 default: 3426 done = dyn_i->got_done; 3427 dyn_i->got_done = TRUE; 3428 got_offset = dyn_i->got_offset; 3429 break; 3430 } 3431 3432 BFD_ASSERT ((got_offset & 7) == 0); 3433 3434 if (! done) 3435 { 2902 3436 /* Store the target address in the linkage table entry. */ 2903 bfd_put_64 (abfd, value, got_sec->contents + dyn_i->got_offset);3437 bfd_put_64 (abfd, value, got_sec->contents + got_offset); 2904 3438 2905 3439 /* Install a dynamic relocation if needed. */ 2906 if ( info->shared3440 if ((info->shared && dyn_r_type != R_IA64_DTPREL64LSB) 2907 3441 || elfNN_ia64_dynamic_symbol_p (dyn_i->h, info) 3442 || elfNN_ia64_aix_vec (abfd->xvec) 2908 3443 || (dynindx != -1 && dyn_r_type == R_IA64_FPTR64LSB)) 2909 3444 { 2910 if (dynindx == -1) 3445 if (dynindx == -1 3446 && dyn_r_type != R_IA64_TPREL64LSB 3447 && dyn_r_type != R_IA64_DTPMOD64LSB 3448 && dyn_r_type != R_IA64_DTPREL64LSB) 2911 3449 { 2912 3450 dyn_r_type = R_IA64_REL64LSB; … … 2928 3466 dyn_r_type = R_IA64_FPTR64MSB; 2929 3467 break; 3468 case R_IA64_TPREL64LSB: 3469 dyn_r_type = R_IA64_TPREL64MSB; 3470 break; 3471 case R_IA64_DTPMOD64LSB: 3472 dyn_r_type = R_IA64_DTPMOD64MSB; 3473 break; 3474 case R_IA64_DTPREL64LSB: 3475 dyn_r_type = R_IA64_DTPREL64MSB; 3476 break; 2930 3477 default: 2931 BFD_ASSERT ( false);3478 BFD_ASSERT (FALSE); 2932 3479 break; 2933 3480 } … … 2936 3483 elfNN_ia64_install_dyn_reloc (abfd, NULL, got_sec, 2937 3484 ia64_info->rel_got_sec, 2938 dyn_i->got_offset, dyn_r_type,3485 got_offset, dyn_r_type, 2939 3486 dynindx, addend); 2940 3487 } … … 2944 3491 value = (got_sec->output_section->vma 2945 3492 + got_sec->output_offset 2946 + dyn_i->got_offset);3493 + got_offset); 2947 3494 2948 3495 return value; … … 2992 3539 struct elfNN_ia64_dyn_sym_info *dyn_i; 2993 3540 bfd_vma value; 2994 b oolean is_plt;3541 bfd_boolean is_plt; 2995 3542 { 2996 3543 struct elfNN_ia64_link_hash_table *ia64_info; … … 3042 3589 } 3043 3590 3591 /* Return the base VMA address which should be subtracted from real addresses 3592 when resolving @tprel() relocation. 3593 Main program TLS (whose template starts at PT_TLS p_vaddr) 3594 is assigned offset round(16, PT_TLS p_align). */ 3595 3596 static bfd_vma 3597 elfNN_ia64_tprel_base (info) 3598 struct bfd_link_info *info; 3599 { 3600 struct elf_link_tls_segment *tls_segment 3601 = elf_hash_table (info)->tls_segment; 3602 3603 BFD_ASSERT (tls_segment != NULL); 3604 return (tls_segment->start 3605 - align_power ((bfd_vma) 16, tls_segment->align)); 3606 } 3607 3608 /* Return the base VMA address which should be subtracted from real addresses 3609 when resolving @dtprel() relocation. 3610 This is PT_TLS segment p_vaddr. */ 3611 3612 static bfd_vma 3613 elfNN_ia64_dtprel_base (info) 3614 struct bfd_link_info *info; 3615 { 3616 BFD_ASSERT (elf_hash_table (info)->tls_segment != NULL); 3617 return elf_hash_table (info)->tls_segment->start; 3618 } 3619 3044 3620 /* Called through qsort to sort the .IA_64.unwind section during a 3045 3621 non-relocatable link. Set elfNN_ia64_unwind_entry_compare_bfd … … 3050 3626 static int 3051 3627 elfNN_ia64_unwind_entry_compare (a, b) 3052 PTR a;3053 PTR b;3628 const PTR a; 3629 const PTR b; 3054 3630 { 3055 3631 bfd_vma av, bv; … … 3061 3637 } 3062 3638 3063 static boolean 3639 /* Make sure we've got ourselves a nice fat __gp value. */ 3640 static bfd_boolean 3641 elfNN_ia64_choose_gp (abfd, info) 3642 bfd *abfd; 3643 struct bfd_link_info *info; 3644 { 3645 bfd_vma min_vma = (bfd_vma) -1, max_vma = 0; 3646 bfd_vma min_short_vma = min_vma, max_short_vma = 0; 3647 struct elf_link_hash_entry *gp; 3648 bfd_vma gp_val; 3649 asection *os; 3650 struct elfNN_ia64_link_hash_table *ia64_info; 3651 3652 ia64_info = elfNN_ia64_hash_table (info); 3653 3654 /* Find the min and max vma of all sections marked short. Also collect 3655 min and max vma of any type, for use in selecting a nice gp. */ 3656 for (os = abfd->sections; os ; os = os->next) 3657 { 3658 bfd_vma lo, hi; 3659 3660 if ((os->flags & SEC_ALLOC) == 0) 3661 continue; 3662 3663 lo = os->vma; 3664 hi = os->vma + os->_raw_size; 3665 if (hi < lo) 3666 hi = (bfd_vma) -1; 3667 3668 if (min_vma > lo) 3669 min_vma = lo; 3670 if (max_vma < hi) 3671 max_vma = hi; 3672 if (os->flags & SEC_SMALL_DATA) 3673 { 3674 if (min_short_vma > lo) 3675 min_short_vma = lo; 3676 if (max_short_vma < hi) 3677 max_short_vma = hi; 3678 } 3679 } 3680 3681 /* See if the user wants to force a value. */ 3682 gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE, 3683 FALSE, FALSE); 3684 3685 if (gp 3686 && (gp->root.type == bfd_link_hash_defined 3687 || gp->root.type == bfd_link_hash_defweak)) 3688 { 3689 asection *gp_sec = gp->root.u.def.section; 3690 gp_val = (gp->root.u.def.value 3691 + gp_sec->output_section->vma 3692 + gp_sec->output_offset); 3693 } 3694 else 3695 { 3696 /* Pick a sensible value. */ 3697 3698 asection *got_sec = ia64_info->got_sec; 3699 3700 /* Start with just the address of the .got. */ 3701 if (got_sec) 3702 gp_val = got_sec->output_section->vma; 3703 else if (max_short_vma != 0) 3704 gp_val = min_short_vma; 3705 else 3706 gp_val = min_vma; 3707 3708 /* If it is possible to address the entire image, but we 3709 don't with the choice above, adjust. */ 3710 if (max_vma - min_vma < 0x400000 3711 && max_vma - gp_val <= 0x200000 3712 && gp_val - min_vma > 0x200000) 3713 gp_val = min_vma + 0x200000; 3714 else if (max_short_vma != 0) 3715 { 3716 /* If we don't cover all the short data, adjust. */ 3717 if (max_short_vma - gp_val >= 0x200000) 3718 gp_val = min_short_vma + 0x200000; 3719 3720 /* If we're addressing stuff past the end, adjust back. */ 3721 if (gp_val > max_vma) 3722 gp_val = max_vma - 0x200000 + 8; 3723 } 3724 } 3725 3726 /* Validate whether all SHF_IA_64_SHORT sections are within 3727 range of the chosen GP. */ 3728 3729 if (max_short_vma != 0) 3730 { 3731 if (max_short_vma - min_short_vma >= 0x400000) 3732 { 3733 (*_bfd_error_handler) 3734 (_("%s: short data segment overflowed (0x%lx >= 0x400000)"), 3735 bfd_get_filename (abfd), 3736 (unsigned long) (max_short_vma - min_short_vma)); 3737 return FALSE; 3738 } 3739 else if ((gp_val > min_short_vma 3740 && gp_val - min_short_vma > 0x200000) 3741 || (gp_val < max_short_vma 3742 && max_short_vma - gp_val >= 0x200000)) 3743 { 3744 (*_bfd_error_handler) 3745 (_("%s: __gp does not cover short data segment"), 3746 bfd_get_filename (abfd)); 3747 return FALSE; 3748 } 3749 } 3750 3751 _bfd_set_gp_value (abfd, gp_val); 3752 3753 return TRUE; 3754 } 3755 3756 static bfd_boolean 3064 3757 elfNN_ia64_final_link (abfd, info) 3065 3758 bfd *abfd; … … 3074 3767 if (!info->relocateable) 3075 3768 { 3076 bfd_vma min_vma = (bfd_vma) -1, max_vma = 0; 3077 bfd_vma min_short_vma = min_vma, max_short_vma = 0; 3769 bfd_vma gp_val = _bfd_get_gp_value (abfd); 3078 3770 struct elf_link_hash_entry *gp; 3079 bfd_vma gp_val; 3080 asection *os; 3081 3082 /* Find the min and max vma of all sections marked short. Also 3083 collect min and max vma of any type, for use in selecting a 3084 nice gp. */ 3085 for (os = abfd->sections; os ; os = os->next) 3086 { 3087 bfd_vma lo, hi; 3088 3089 if ((os->flags & SEC_ALLOC) == 0) 3090 continue; 3091 3092 lo = os->vma; 3093 hi = os->vma + os->_raw_size; 3094 if (hi < lo) 3095 hi = (bfd_vma) -1; 3096 3097 if (min_vma > lo) 3098 min_vma = lo; 3099 if (max_vma < hi) 3100 max_vma = hi; 3101 if (os->flags & SEC_SMALL_DATA) 3102 { 3103 if (min_short_vma > lo) 3104 min_short_vma = lo; 3105 if (max_short_vma < hi) 3106 max_short_vma = hi; 3107 } 3108 } 3109 3110 /* See if the user wants to force a value. */ 3111 gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", false, 3112 false, false); 3113 3114 if (gp 3115 && (gp->root.type == bfd_link_hash_defined 3116 || gp->root.type == bfd_link_hash_defweak)) 3117 { 3118 asection *gp_sec = gp->root.u.def.section; 3119 gp_val = (gp->root.u.def.value 3120 + gp_sec->output_section->vma 3121 + gp_sec->output_offset); 3122 } 3123 else 3124 { 3125 /* Pick a sensible value. */ 3126 3127 asection *got_sec = ia64_info->got_sec; 3128 3129 /* Start with just the address of the .got. */ 3130 if (got_sec) 3131 gp_val = got_sec->output_section->vma; 3132 else if (max_short_vma != 0) 3133 gp_val = min_short_vma; 3134 else 3135 gp_val = min_vma; 3136 3137 /* If it is possible to address the entire image, but we 3138 don't with the choice above, adjust. */ 3139 if (max_vma - min_vma < 0x400000 3140 && max_vma - gp_val <= 0x200000 3141 && gp_val - min_vma > 0x200000) 3142 gp_val = min_vma + 0x200000; 3143 else if (max_short_vma != 0) 3144 { 3145 /* If we don't cover all the short data, adjust. */ 3146 if (max_short_vma - gp_val >= 0x200000) 3147 gp_val = min_short_vma + 0x200000; 3148 3149 /* If we're addressing stuff past the end, adjust back. */ 3150 if (gp_val > max_vma) 3151 gp_val = max_vma - 0x200000 + 8; 3152 } 3153 } 3154 3155 /* Validate whether all SHF_IA_64_SHORT sections are within 3156 range of the chosen GP. */ 3157 3158 if (max_short_vma != 0) 3159 { 3160 if (max_short_vma - min_short_vma >= 0x400000) 3161 { 3162 (*_bfd_error_handler) 3163 (_("%s: short data segment overflowed (0x%lx >= 0x400000)"), 3164 bfd_get_filename (abfd), 3165 (unsigned long) (max_short_vma - min_short_vma)); 3166 return false; 3167 } 3168 else if ((gp_val > min_short_vma 3169 && gp_val - min_short_vma > 0x200000) 3170 || (gp_val < max_short_vma 3171 && max_short_vma - gp_val >= 0x200000)) 3172 { 3173 (*_bfd_error_handler) 3174 (_("%s: __gp does not cover short data segment"), 3175 bfd_get_filename (abfd)); 3176 return false; 3177 } 3178 } 3179 3180 _bfd_set_gp_value (abfd, gp_val); 3181 3771 3772 if (gp_val == 0) 3773 { 3774 if (! elfNN_ia64_choose_gp (abfd, info)) 3775 return FALSE; 3776 gp_val = _bfd_get_gp_value (abfd); 3777 } 3778 3779 gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE, 3780 FALSE, FALSE); 3182 3781 if (gp) 3183 3782 { … … 3201 3800 = bfd_malloc (unwind_output_sec->_raw_size); 3202 3801 if (unwind_output_sec->contents == NULL) 3203 return false;3802 return FALSE; 3204 3803 } 3205 3804 } … … 3207 3806 /* Invoke the regular ELF backend linker to do all the work. */ 3208 3807 if (!bfd_elfNN_bfd_final_link (abfd, info)) 3209 return false;3808 return FALSE; 3210 3809 3211 3810 if (unwind_output_sec) 3212 3811 { 3213 3812 elfNN_ia64_unwind_entry_compare_bfd = abfd; 3214 qsort (unwind_output_sec->contents, unwind_output_sec->_raw_size / 24, 3215 24, elfNN_ia64_unwind_entry_compare); 3813 qsort (unwind_output_sec->contents, 3814 (size_t) (unwind_output_sec->_raw_size / 24), 3815 24, 3816 elfNN_ia64_unwind_entry_compare); 3216 3817 3217 3818 if (! bfd_set_section_contents (abfd, unwind_output_sec, 3218 unwind_output_sec->contents, 0,3819 unwind_output_sec->contents, (bfd_vma) 0, 3219 3820 unwind_output_sec->_raw_size)) 3220 return false;3221 } 3222 3223 return true;3224 } 3225 3226 static b oolean3821 return FALSE; 3822 } 3823 3824 return TRUE; 3825 } 3826 3827 static bfd_boolean 3227 3828 elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, 3228 3829 contents, relocs, local_syms, local_sections) … … 3241 3842 Elf_Internal_Rela *relend; 3242 3843 asection *srel; 3243 b oolean ret_val = true; /* for non-fatal errors */3844 bfd_boolean ret_val = TRUE; /* for non-fatal errors */ 3244 3845 bfd_vma gp_val; 3245 3846 … … 3257 3858 elf_section_data(input_section->output_section) 3258 3859 ->this_hdr.sh_flags |= flags; 3860 return TRUE; 3259 3861 } 3260 3862 3261 3863 gp_val = _bfd_get_gp_value (output_bfd); 3262 srel = get_reloc_section (input_bfd, ia64_info, input_section, false);3864 srel = get_reloc_section (input_bfd, ia64_info, input_section, FALSE); 3263 3865 3264 3866 rel = relocs; … … 3276 3878 asection *sym_sec; 3277 3879 bfd_byte *hit_addr; 3278 b oolean dynamic_symbol_p;3279 b oolean undef_weak_ref;3880 bfd_boolean dynamic_symbol_p; 3881 bfd_boolean undef_weak_ref; 3280 3882 3281 3883 r_type = ELFNN_R_TYPE (rel->r_info); … … 3284 3886 (*_bfd_error_handler) 3285 3887 (_("%s: unknown relocation type %d"), 3286 bfd_ get_filename (input_bfd), (int)r_type);3888 bfd_archive_filename (input_bfd), (int)r_type); 3287 3889 bfd_set_error (bfd_error_bad_value); 3288 ret_val = false;3890 ret_val = FALSE; 3289 3891 continue; 3290 3892 } 3893 3291 3894 howto = lookup_howto (r_type); 3292 3895 r_symndx = ELFNN_R_SYM (rel->r_info); 3293 3294 if (info->relocateable)3295 {3296 /* This is a relocateable link. We don't have to change3297 anything, unless the reloc is against a section symbol,3298 in which case we have to adjust according to where the3299 section symbol winds up in the output section. */3300 if (r_symndx < symtab_hdr->sh_info)3301 {3302 sym = local_syms + r_symndx;3303 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)3304 {3305 sym_sec = local_sections[r_symndx];3306 rel->r_addend += sym_sec->output_offset;3307 }3308 }3309 continue;3310 }3311 3312 /* This is a final link. */3313 3314 3896 h = NULL; 3315 3897 sym = NULL; 3316 3898 sym_sec = NULL; 3317 undef_weak_ref = false;3899 undef_weak_ref = FALSE; 3318 3900 3319 3901 if (r_symndx < symtab_hdr->sh_info) … … 3322 3904 sym = local_syms + r_symndx; 3323 3905 sym_sec = local_sections[r_symndx]; 3324 value = (sym_sec->output_section->vma 3325 + sym_sec->output_offset 3326 + sym->st_value); 3906 value = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel); 3907 if ((sym_sec->flags & SEC_MERGE) 3908 && ELF_ST_TYPE (sym->st_info) == STT_SECTION 3909 && sym_sec->sec_info_type == ELF_INFO_TYPE_MERGE) 3910 { 3911 struct elfNN_ia64_local_hash_entry *loc_h; 3912 3913 loc_h = get_local_sym_hash (ia64_info, input_bfd, rel, FALSE); 3914 if (loc_h && ! loc_h->sec_merge_done) 3915 { 3916 struct elfNN_ia64_dyn_sym_info *dynent; 3917 asection *msec; 3918 3919 for (dynent = loc_h->info; dynent; dynent = dynent->next) 3920 { 3921 msec = sym_sec; 3922 dynent->addend = 3923 _bfd_merged_section_offset (output_bfd, &msec, 3924 elf_section_data (msec)-> 3925 sec_info, 3926 sym->st_value 3927 + dynent->addend, 3928 (bfd_vma) 0); 3929 dynent->addend -= sym->st_value; 3930 dynent->addend += msec->output_section->vma 3931 + msec->output_offset 3932 - sym_sec->output_section->vma 3933 - sym_sec->output_offset; 3934 } 3935 loc_h->sec_merge_done = 1; 3936 } 3937 } 3327 3938 } 3328 3939 else … … 3359 3970 } 3360 3971 else if (h->root.type == bfd_link_hash_undefweak) 3361 undef_weak_ref = true;3362 else if (info->shared && !info->symbolic3972 undef_weak_ref = TRUE; 3973 else if (info->shared 3363 3974 && !info->no_undefined 3364 3975 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) … … 3371 3982 (!info->shared || info->no_undefined 3372 3983 || ELF_ST_VISIBILITY (h->other))))) 3373 return false; 3374 ret_val = false; 3984 return FALSE; 3375 3985 continue; 3376 3986 } … … 3395 4005 case R_IA64_DIR64LSB: 3396 4006 /* Install a dynamic relocation for this reloc. */ 3397 if ((dynamic_symbol_p || info->shared) 4007 if ((dynamic_symbol_p || info->shared 4008 || (elfNN_ia64_aix_vec (info->hash->creator) 4009 /* Don't emit relocs for __GLOB_DATA_PTR on AIX. */ 4010 && (!h || strcmp (h->root.root.string, 4011 "__GLOB_DATA_PTR") != 0))) 4012 && r_symndx != 0 3398 4013 && (input_section->flags & SEC_ALLOC) != 0) 3399 4014 { … … 3439 4054 (*_bfd_error_handler) 3440 4055 (_("%s: linking non-pic code in a shared library"), 3441 bfd_ get_filename (input_bfd));3442 ret_val = false;4056 bfd_archive_filename (input_bfd)); 4057 ret_val = FALSE; 3443 4058 continue; 3444 4059 } … … 3447 4062 } 3448 4063 4064 if (elfNN_ia64_aix_vec (info->hash->creator)) 4065 rel->r_addend = value; 3449 4066 elfNN_ia64_install_dyn_reloc (output_bfd, info, input_section, 3450 4067 srel, rel->r_offset, dyn_r_type, 3451 4068 dynindx, addend); 3452 4069 } 3453 /* F ALLTHRU*/4070 /* Fall through. */ 3454 4071 3455 4072 case R_IA64_LTV32MSB: … … 3470 4087 (*_bfd_error_handler) 3471 4088 (_("%s: @gprel relocation against dynamic symbol %s"), 3472 bfd_ get_filename (input_bfd), h->root.root.string);3473 ret_val = false;4089 bfd_archive_filename (input_bfd), h->root.root.string); 4090 ret_val = FALSE; 3474 4091 continue; 3475 4092 } … … 3481 4098 case R_IA64_LTOFF22X: 3482 4099 case R_IA64_LTOFF64I: 3483 dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false);4100 dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE); 3484 4101 value = set_got_entry (input_bfd, info, dyn_i, (h ? h->dynindx : -1), 3485 4102 rel->r_addend, value, R_IA64_DIR64LSB); … … 3492 4109 case R_IA64_PLTOFF64MSB: 3493 4110 case R_IA64_PLTOFF64LSB: 3494 dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false);3495 value = set_pltoff_entry (output_bfd, info, dyn_i, value, false);4111 dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE); 4112 value = set_pltoff_entry (output_bfd, info, dyn_i, value, FALSE); 3496 4113 value -= gp_val; 3497 4114 r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); … … 3503 4120 case R_IA64_FPTR64MSB: 3504 4121 case R_IA64_FPTR64LSB: 3505 dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false);4122 dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE); 3506 4123 if (dyn_i->want_fptr) 3507 4124 { … … 3528 4145 { 3529 4146 dynindx = (_bfd_elf_link_lookup_local_dynindx 3530 (info, input_bfd, r_symndx));4147 (info, input_bfd, (long) r_symndx)); 3531 4148 } 3532 4149 … … 3542 4159 case R_IA64_LTOFF_FPTR22: 3543 4160 case R_IA64_LTOFF_FPTR64I: 4161 case R_IA64_LTOFF_FPTR32MSB: 4162 case R_IA64_LTOFF_FPTR32LSB: 3544 4163 case R_IA64_LTOFF_FPTR64MSB: 3545 4164 case R_IA64_LTOFF_FPTR64LSB: … … 3547 4166 long dynindx; 3548 4167 3549 dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false);4168 dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE); 3550 4169 if (dyn_i->want_fptr) 3551 4170 { … … 3570 4189 else 3571 4190 dynindx = (_bfd_elf_link_lookup_local_dynindx 3572 (info, input_bfd, r_symndx));4191 (info, input_bfd, (long) r_symndx)); 3573 4192 value = 0; 3574 4193 } … … 3586 4205 case R_IA64_PCREL64LSB: 3587 4206 /* Install a dynamic relocation for this reloc. */ 3588 if (dynamic_symbol_p) 4207 if ((dynamic_symbol_p 4208 || elfNN_ia64_aix_vec (info->hash->creator)) 4209 && r_symndx != 0) 3589 4210 { 3590 4211 BFD_ASSERT (srel != NULL); … … 3596 4217 goto finish_pcrel; 3597 4218 3598 case R_IA64_PCREL21BI:3599 case R_IA64_PCREL21F:3600 case R_IA64_PCREL21M:3601 /* ??? These two are only used for speculation fixup code.3602 They should never be dynamic. */3603 if (dynamic_symbol_p)3604 {3605 (*_bfd_error_handler)3606 (_("%s: dynamic relocation against speculation fixup"),3607 bfd_get_filename (input_bfd));3608 ret_val = false;3609 continue;3610 }3611 if (undef_weak_ref)3612 {3613 (*_bfd_error_handler)3614 (_("%s: speculation fixup against undefined weak symbol"),3615 bfd_get_filename (input_bfd));3616 ret_val = false;3617 continue;3618 }3619 goto finish_pcrel;3620 3621 4219 case R_IA64_PCREL21B: 3622 4220 case R_IA64_PCREL60B: … … 3624 4222 dyn_i = NULL; 3625 4223 if (h) 3626 dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, false);4224 dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, FALSE); 3627 4225 3628 4226 if (dyn_i && dyn_i->want_plt2) … … 3650 4248 goto finish_pcrel; 3651 4249 4250 case R_IA64_PCREL21BI: 4251 case R_IA64_PCREL21F: 4252 case R_IA64_PCREL21M: 3652 4253 case R_IA64_PCREL22: 3653 4254 case R_IA64_PCREL64I: 4255 /* The PCREL21BI reloc is specifically not intended for use with 4256 dynamic relocs. PCREL21F and PCREL21M are used for speculation 4257 fixup code, and thus probably ought not be dynamic. The 4258 PCREL22 and PCREL64I relocs aren't emitted as dynamic relocs. */ 4259 if (dynamic_symbol_p) 4260 { 4261 const char *msg; 4262 4263 if (r_type == R_IA64_PCREL21BI) 4264 msg = _("%s: @internal branch to dynamic symbol %s"); 4265 else if (r_type == R_IA64_PCREL21F || r_type == R_IA64_PCREL21M) 4266 msg = _("%s: speculation fixup to dynamic symbol %s"); 4267 else 4268 msg = _("%s: @pcrel relocation against dynamic symbol %s"); 4269 (*_bfd_error_handler) (msg, bfd_archive_filename (input_bfd), 4270 h->root.root.string); 4271 ret_val = FALSE; 4272 continue; 4273 } 4274 goto finish_pcrel; 4275 3654 4276 finish_pcrel: 3655 4277 /* Make pc-relative. */ … … 3664 4286 case R_IA64_SEGREL64MSB: 3665 4287 case R_IA64_SEGREL64LSB: 3666 { 3667 struct elf_segment_map *m; 3668 Elf_Internal_Phdr *p; 3669 3670 /* Find the segment that contains the output_section. */ 3671 for (m = elf_tdata (output_bfd)->segment_map, 3672 p = elf_tdata (output_bfd)->phdr; 3673 m != NULL; 3674 m = m->next, p++) 3675 { 3676 int i; 3677 for (i = m->count - 1; i >= 0; i--) 3678 if (m->sections[i] == sym_sec->output_section) 4288 if (r_symndx == 0) 4289 { 4290 /* If the input section was discarded from the output, then 4291 do nothing. */ 4292 r = bfd_reloc_ok; 4293 } 4294 else 4295 { 4296 struct elf_segment_map *m; 4297 Elf_Internal_Phdr *p; 4298 4299 /* Find the segment that contains the output_section. */ 4300 for (m = elf_tdata (output_bfd)->segment_map, 4301 p = elf_tdata (output_bfd)->phdr; 4302 m != NULL; 4303 m = m->next, p++) 4304 { 4305 int i; 4306 for (i = m->count - 1; i >= 0; i--) 4307 if (m->sections[i] == sym_sec->output_section) 4308 break; 4309 if (i >= 0) 3679 4310 break; 3680 if (i >= 0) 3681 break; 3682 } 3683 3684 if (m == NULL) 3685 { 3686 /* If the input section was discarded from the output, then 3687 do nothing. */ 3688 3689 if (bfd_is_abs_section (sym_sec->output_section)) 3690 r = bfd_reloc_ok; 3691 else 4311 } 4312 4313 if (m == NULL) 4314 { 3692 4315 r = bfd_reloc_notsupported; 3693 3694 else3695 3696 /* The VMA of the segment is the vaddr of the associated3697 program header. */3698 if (value > p->p_vaddr)3699 value -= p->p_vaddr;3700 else3701 value = 0;3702 r = elfNN_ia64_install_value (output_bfd, hit_addr, value,3703 3704 3705 break;3706 }4316 } 4317 else 4318 { 4319 /* The VMA of the segment is the vaddr of the associated 4320 program header. */ 4321 if (value > p->p_vaddr) 4322 value -= p->p_vaddr; 4323 else 4324 value = 0; 4325 r = elfNN_ia64_install_value (output_bfd, hit_addr, value, 4326 r_type); 4327 } 4328 break; 4329 } 3707 4330 3708 4331 case R_IA64_SECREL32MSB: … … 3761 4384 break; 3762 4385 4386 case R_IA64_TPREL14: 4387 case R_IA64_TPREL22: 4388 case R_IA64_TPREL64I: 4389 value -= elfNN_ia64_tprel_base (info); 4390 r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); 4391 break; 4392 4393 case R_IA64_DTPREL14: 4394 case R_IA64_DTPREL22: 4395 case R_IA64_DTPREL64I: 4396 case R_IA64_DTPREL64LSB: 4397 case R_IA64_DTPREL64MSB: 4398 value -= elfNN_ia64_dtprel_base (info); 4399 r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); 4400 break; 4401 4402 case R_IA64_LTOFF_TPREL22: 4403 case R_IA64_LTOFF_DTPMOD22: 4404 case R_IA64_LTOFF_DTPREL22: 4405 { 4406 int got_r_type; 4407 long dynindx = h ? h->dynindx : -1; 4408 bfd_vma r_addend = rel->r_addend; 4409 4410 switch (r_type) 4411 { 4412 default: 4413 case R_IA64_LTOFF_TPREL22: 4414 if (!dynamic_symbol_p) 4415 { 4416 if (!info->shared) 4417 value -= elfNN_ia64_tprel_base (info); 4418 else 4419 { 4420 r_addend += value - elfNN_ia64_dtprel_base (info); 4421 dynindx = 0; 4422 } 4423 } 4424 got_r_type = R_IA64_TPREL64LSB; 4425 break; 4426 case R_IA64_LTOFF_DTPMOD22: 4427 if (!dynamic_symbol_p && !info->shared) 4428 value = 1; 4429 got_r_type = R_IA64_DTPMOD64LSB; 4430 break; 4431 case R_IA64_LTOFF_DTPREL22: 4432 if (!dynamic_symbol_p) 4433 value -= elfNN_ia64_dtprel_base (info); 4434 got_r_type = R_IA64_DTPREL64LSB; 4435 break; 4436 } 4437 dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE); 4438 value = set_got_entry (input_bfd, info, dyn_i, dynindx, r_addend, 4439 value, got_r_type); 4440 value -= gp_val; 4441 r = elfNN_ia64_install_value (output_bfd, hit_addr, value, 4442 r_type); 4443 } 4444 break; 4445 3763 4446 default: 3764 4447 r = bfd_reloc_notsupported; … … 3777 4460 (*info->callbacks->undefined_symbol) 3778 4461 (info, "__gp", input_bfd, input_section, rel->r_offset, 1); 3779 return false;4462 return FALSE; 3780 4463 3781 4464 case bfd_reloc_notsupported: … … 3791 4474 sym->st_name); 3792 4475 if (name == NULL) 3793 return false;4476 return FALSE; 3794 4477 if (*name == '\0') 3795 4478 name = bfd_section_name (input_bfd, input_section); … … 3798 4481 name, input_bfd, 3799 4482 input_section, rel->r_offset)) 3800 return false;3801 ret_val = false;4483 return FALSE; 4484 ret_val = FALSE; 3802 4485 } 3803 4486 break; … … 3818 4501 sym->st_name); 3819 4502 if (name == NULL) 3820 return false;4503 return FALSE; 3821 4504 if (*name == '\0') 3822 4505 name = bfd_section_name (input_bfd, input_section); 3823 4506 } 3824 4507 if (!(*info->callbacks->reloc_overflow) (info, name, 3825 howto->name, 0, 4508 howto->name, 4509 (bfd_vma) 0, 3826 4510 input_bfd, 3827 4511 input_section, 3828 4512 rel->r_offset)) 3829 return false;3830 ret_val = false;4513 return FALSE; 4514 ret_val = FALSE; 3831 4515 } 3832 4516 break; … … 3837 4521 } 3838 4522 3839 static b oolean4523 static bfd_boolean 3840 4524 elfNN_ia64_finish_dynamic_symbol (output_bfd, info, h, sym) 3841 4525 bfd *output_bfd; … … 3848 4532 3849 4533 ia64_info = elfNN_ia64_hash_table (info); 3850 dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, false);4534 dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, FALSE); 3851 4535 3852 4536 /* Fill in the PLT data, if required. */ … … 3857 4541 asection *plt_sec; 3858 4542 bfd_vma plt_addr, pltoff_addr, gp_val, index; 3859 ElfNN_External_Rela *rel;3860 4543 3861 4544 gp_val = _bfd_get_gp_value (output_bfd); … … 3875 4558 + plt_sec->output_offset 3876 4559 + dyn_i->plt_offset); 3877 pltoff_addr = set_pltoff_entry (output_bfd, info, dyn_i, plt_addr, true);4560 pltoff_addr = set_pltoff_entry (output_bfd, info, dyn_i, plt_addr, TRUE); 3878 4561 3879 4562 /* Initialize the FULL PLT entry, if needed. */ … … 3914 4597 PLT relocations. */ 3915 4598 3916 rel = (ElfNN_External_Rela *)ia64_info->rel_pltoff_sec->contents;3917 rel += ia64_info->rel_pltoff_sec->reloc_count;3918 3919 bfd_elfNN_swap_reloca_out (output_bfd, &outrel, rel + index);4599 loc = ia64_info->rel_pltoff_sec->contents; 4600 loc += ((ia64_info->rel_pltoff_sec->reloc_count + index) 4601 * sizeof (Elf64_External_Rela)); 4602 bfd_elfNN_swap_reloca_out (output_bfd, &outrel, loc); 3920 4603 } 3921 4604 … … 3926 4609 sym->st_shndx = SHN_ABS; 3927 4610 3928 return true;3929 } 3930 3931 static b oolean4611 return TRUE; 4612 } 4613 4614 static bfd_boolean 3932 4615 elfNN_ia64_finish_dynamic_sections (abfd, info) 3933 4616 bfd *abfd; … … 3995 4678 } 3996 4679 3997 /* Initialize the PLT0 entry */4680 /* Initialize the PLT0 entry. */ 3998 4681 if (ia64_info->plt_sec) 3999 4682 { … … 4011 4694 } 4012 4695 4013 return true;4014 } 4015 4016 4017 /* ELF file flag handling: */4696 return TRUE; 4697 } 4698 4699 4700 /* ELF file flag handling: */ 4018 4701 4019 4702 /* Function to keep IA-64 specific file flags. */ 4020 static b oolean4703 static bfd_boolean 4021 4704 elfNN_ia64_set_private_flags (abfd, flags) 4022 4705 bfd *abfd; … … 4027 4710 4028 4711 elf_elfheader (abfd)->e_flags = flags; 4029 elf_flags_init (abfd) = true; 4030 return true; 4031 } 4032 4033 /* Copy backend specific data from one object module to another */ 4034 static boolean 4035 elfNN_ia64_copy_private_bfd_data (ibfd, obfd) 4036 bfd *ibfd, *obfd; 4037 { 4038 if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour 4039 || bfd_get_flavour (obfd) != bfd_target_elf_flavour) 4040 return true; 4041 4042 BFD_ASSERT (!elf_flags_init (obfd) 4043 || (elf_elfheader (obfd)->e_flags 4044 == elf_elfheader (ibfd)->e_flags)); 4045 4046 elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; 4047 elf_flags_init (obfd) = true; 4048 return true; 4712 elf_flags_init (abfd) = TRUE; 4713 return TRUE; 4049 4714 } 4050 4715 4051 4716 /* Merge backend specific data from an object file to the output 4052 4717 object file when linking. */ 4053 static b oolean4718 static bfd_boolean 4054 4719 elfNN_ia64_merge_private_bfd_data (ibfd, obfd) 4055 4720 bfd *ibfd, *obfd; … … 4057 4722 flagword out_flags; 4058 4723 flagword in_flags; 4059 b oolean ok = true;4724 bfd_boolean ok = TRUE; 4060 4725 4061 4726 /* Don't even pretend to support mixed-format linking. */ 4062 4727 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour 4063 4728 || bfd_get_flavour (obfd) != bfd_target_elf_flavour) 4064 return false;4729 return FALSE; 4065 4730 4066 4731 in_flags = elf_elfheader (ibfd)->e_flags; … … 4069 4734 if (! elf_flags_init (obfd)) 4070 4735 { 4071 elf_flags_init (obfd) = true;4736 elf_flags_init (obfd) = TRUE; 4072 4737 elf_elfheader (obfd)->e_flags = in_flags; 4073 4738 … … 4079 4744 } 4080 4745 4081 return true;4746 return TRUE; 4082 4747 } 4083 4748 4084 4749 /* Check flag compatibility. */ 4085 4750 if (in_flags == out_flags) 4086 return true;4751 return TRUE; 4087 4752 4088 4753 /* Output has EF_IA_64_REDUCEDFP set only if all inputs have it set. */ … … 4094 4759 (*_bfd_error_handler) 4095 4760 (_("%s: linking trap-on-NULL-dereference with non-trapping files"), 4096 bfd_ get_filename (ibfd));4761 bfd_archive_filename (ibfd)); 4097 4762 4098 4763 bfd_set_error (bfd_error_bad_value); 4099 ok = false;4764 ok = FALSE; 4100 4765 } 4101 4766 if ((in_flags & EF_IA_64_BE) != (out_flags & EF_IA_64_BE)) … … 4103 4768 (*_bfd_error_handler) 4104 4769 (_("%s: linking big-endian files with little-endian files"), 4105 bfd_ get_filename (ibfd));4770 bfd_archive_filename (ibfd)); 4106 4771 4107 4772 bfd_set_error (bfd_error_bad_value); 4108 ok = false;4773 ok = FALSE; 4109 4774 } 4110 4775 if ((in_flags & EF_IA_64_ABI64) != (out_flags & EF_IA_64_ABI64)) … … 4112 4777 (*_bfd_error_handler) 4113 4778 (_("%s: linking 64-bit files with 32-bit files"), 4114 bfd_ get_filename (ibfd));4779 bfd_archive_filename (ibfd)); 4115 4780 4116 4781 bfd_set_error (bfd_error_bad_value); 4117 ok = false;4782 ok = FALSE; 4118 4783 } 4119 4784 if ((in_flags & EF_IA_64_CONS_GP) != (out_flags & EF_IA_64_CONS_GP)) … … 4121 4786 (*_bfd_error_handler) 4122 4787 (_("%s: linking constant-gp files with non-constant-gp files"), 4123 bfd_ get_filename (ibfd));4788 bfd_archive_filename (ibfd)); 4124 4789 4125 4790 bfd_set_error (bfd_error_bad_value); 4126 ok = false;4791 ok = FALSE; 4127 4792 } 4128 4793 if ((in_flags & EF_IA_64_NOFUNCDESC_CONS_GP) … … 4131 4796 (*_bfd_error_handler) 4132 4797 (_("%s: linking auto-pic files with non-auto-pic files"), 4133 bfd_ get_filename (ibfd));4798 bfd_archive_filename (ibfd)); 4134 4799 4135 4800 bfd_set_error (bfd_error_bad_value); 4136 ok = false;4801 ok = FALSE; 4137 4802 } 4138 4803 … … 4140 4805 } 4141 4806 4142 static b oolean4807 static bfd_boolean 4143 4808 elfNN_ia64_print_private_bfd_data (abfd, ptr) 4144 4809 bfd *abfd; … … 4161 4826 4162 4827 _bfd_elf_print_private_bfd_data (abfd, ptr); 4163 return true; 4828 return TRUE; 4829 } 4830 4831 static enum elf_reloc_type_class 4832 elfNN_ia64_reloc_type_class (rela) 4833 const Elf_Internal_Rela *rela; 4834 { 4835 switch ((int) ELFNN_R_TYPE (rela->r_info)) 4836 { 4837 case R_IA64_REL32MSB: 4838 case R_IA64_REL32LSB: 4839 case R_IA64_REL64MSB: 4840 case R_IA64_REL64LSB: 4841 return reloc_class_relative; 4842 case R_IA64_IPLTMSB: 4843 case R_IA64_IPLTLSB: 4844 return reloc_class_plt; 4845 case R_IA64_COPY: 4846 return reloc_class_copy; 4847 default: 4848 return reloc_class_normal; 4849 } 4850 } 4851 4852 static bfd_boolean 4853 elfNN_ia64_hpux_vec (const bfd_target *vec) 4854 { 4855 extern const bfd_target bfd_elfNN_ia64_hpux_big_vec; 4856 return (vec == & bfd_elfNN_ia64_hpux_big_vec); 4857 } 4858 4859 static void 4860 elfNN_hpux_post_process_headers (abfd, info) 4861 bfd *abfd; 4862 struct bfd_link_info *info ATTRIBUTE_UNUSED; 4863 { 4864 Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd); 4865 4866 i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_HPUX; 4867 i_ehdrp->e_ident[EI_ABIVERSION] = 1; 4868 } 4869 4870 bfd_boolean 4871 elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval) 4872 bfd *abfd ATTRIBUTE_UNUSED; 4873 asection *sec; 4874 int *retval; 4875 { 4876 if (bfd_is_com_section (sec)) 4877 { 4878 *retval = SHN_IA_64_ANSI_COMMON; 4879 return TRUE; 4880 } 4881 return FALSE; 4164 4882 } 4165 4883 … … 4219 4937 elfNN_ia64_final_link 4220 4938 4221 #define bfd_elfNN_bfd_copy_private_bfd_data \4222 elfNN_ia64_copy_private_bfd_data4223 4939 #define bfd_elfNN_bfd_merge_private_bfd_data \ 4224 4940 elfNN_ia64_merge_private_bfd_data … … 4240 4956 #define elf_backend_copy_indirect_symbol elfNN_ia64_hash_copy_indirect 4241 4957 #define elf_backend_hide_symbol elfNN_ia64_hash_hide_symbol 4958 #define elf_backend_reloc_type_class elfNN_ia64_reloc_type_class 4959 #define elf_backend_rela_normal 1 4242 4960 4243 4961 #include "elfNN-target.h" 4962 4963 /* AIX-specific vectors. */ 4964 4965 #undef TARGET_LITTLE_SYM 4966 #define TARGET_LITTLE_SYM bfd_elfNN_ia64_aix_little_vec 4967 #undef TARGET_LITTLE_NAME 4968 #define TARGET_LITTLE_NAME "elfNN-ia64-aix-little" 4969 #undef TARGET_BIG_SYM 4970 #define TARGET_BIG_SYM bfd_elfNN_ia64_aix_big_vec 4971 #undef TARGET_BIG_NAME 4972 #define TARGET_BIG_NAME "elfNN-ia64-aix-big" 4973 4974 #undef elf_backend_add_symbol_hook 4975 #define elf_backend_add_symbol_hook elfNN_ia64_aix_add_symbol_hook 4976 4977 #undef bfd_elfNN_bfd_link_add_symbols 4978 #define bfd_elfNN_bfd_link_add_symbols elfNN_ia64_aix_link_add_symbols 4979 4980 #define elfNN_bed elfNN_ia64_aix_bed 4981 4982 #include "elfNN-target.h" 4983 4984 /* HPUX-specific vectors. */ 4985 4986 #undef TARGET_LITTLE_SYM 4987 #undef TARGET_LITTLE_NAME 4988 #undef TARGET_BIG_SYM 4989 #define TARGET_BIG_SYM bfd_elfNN_ia64_hpux_big_vec 4990 #undef TARGET_BIG_NAME 4991 #define TARGET_BIG_NAME "elfNN-ia64-hpux-big" 4992 4993 /* We need to undo the AIX specific functions. */ 4994 4995 #undef elf_backend_add_symbol_hook 4996 #define elf_backend_add_symbol_hook elfNN_ia64_add_symbol_hook 4997 4998 #undef bfd_elfNN_bfd_link_add_symbols 4999 #define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols 5000 5001 /* These are HP-UX specific functions. */ 5002 5003 #undef elf_backend_post_process_headers 5004 #define elf_backend_post_process_headers elfNN_hpux_post_process_headers 5005 5006 #undef elf_backend_section_from_bfd_section 5007 #define elf_backend_section_from_bfd_section elfNN_hpux_backend_section_from_bfd_section 5008 5009 #undef elf_backend_want_p_paddr_set_to_zero 5010 #define elf_backend_want_p_paddr_set_to_zero 1 5011 5012 #undef ELF_MAXPAGESIZE 5013 #define ELF_MAXPAGESIZE 0x1000 /* 1K */ 5014 5015 #undef elfNN_bed 5016 #define elfNN_bed elfNN_ia64_hpux_bed 5017 5018 #include "elfNN-target.h" 5019 5020 #undef elf_backend_want_p_paddr_set_to_zero -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.