Changeset 609 for branches/GNU/src/binutils/bfd/elf64-alpha.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/elf64-alpha.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Alpha specific support for 64-bit ELF 2 Copyright 1996, 1997, 1998, 1999, 2000, 2001 2 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 3 3 Free Software Foundation, Inc. 4 4 Contributed by Richard Henderson <rth@tamu.edu>. 5 5 6 This file is part of BFD, the Binary File Descriptor library.7 8 This program is free software; you can redistribute it and/or modify9 it under the terms of the GNU General Public License as published by10 the Free Software Foundation; either version 2 of the License, or11 (at your option) any later version.12 13 This program is distributed in the hope that it will be useful,14 but WITHOUT ANY WARRANTY; without even the implied warranty of15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 GNU General Public License for more details.17 18 You should have received a copy of the GNU General Public License19 along with this program; if not, write to the Free Software20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */6 This file is part of BFD, the Binary File Descriptor library. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 21 22 22 /* We need a published ABI spec for this. Until one comes out, don't … … 49 49 50 50 static int alpha_elf_dynamic_symbol_p 51 PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *));51 PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *)); 52 52 static struct bfd_hash_entry * elf64_alpha_link_hash_newfunc 53 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));53 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 54 54 static struct bfd_link_hash_table * elf64_alpha_bfd_link_hash_table_create 55 PARAMS ((bfd *));55 PARAMS ((bfd *)); 56 56 57 57 static bfd_reloc_status_type elf64_alpha_reloc_nil 58 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));58 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 59 59 static bfd_reloc_status_type elf64_alpha_reloc_bad 60 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));60 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 61 61 static bfd_reloc_status_type elf64_alpha_do_reloc_gpdisp 62 PARAMS ((bfd *, bfd_vma, bfd_byte *, bfd_byte *));62 PARAMS ((bfd *, bfd_vma, bfd_byte *, bfd_byte *)); 63 63 static bfd_reloc_status_type elf64_alpha_reloc_gpdisp 64 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));64 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 65 65 66 66 static reloc_howto_type * elf64_alpha_bfd_reloc_type_lookup 67 PARAMS ((bfd *, bfd_reloc_code_real_type));67 PARAMS ((bfd *, bfd_reloc_code_real_type)); 68 68 static void elf64_alpha_info_to_howto 69 PARAMS((bfd *, arelent *, Elf64_Internal_Rela *)); 70 71 static boolean elf64_alpha_mkobject 72 PARAMS((bfd *)); 73 static boolean elf64_alpha_object_p 74 PARAMS((bfd *)); 75 static boolean elf64_alpha_section_from_shdr 76 PARAMS((bfd *, Elf64_Internal_Shdr *, char *)); 77 static boolean elf64_alpha_fake_sections 78 PARAMS((bfd *, Elf64_Internal_Shdr *, asection *)); 79 static boolean elf64_alpha_create_got_section 80 PARAMS((bfd *, struct bfd_link_info *)); 81 static boolean elf64_alpha_create_dynamic_sections 82 PARAMS((bfd *, struct bfd_link_info *)); 83 84 static boolean elf64_alpha_read_ecoff_info 85 PARAMS((bfd *, asection *, struct ecoff_debug_info *)); 86 static boolean elf64_alpha_is_local_label_name 87 PARAMS((bfd *, const char *)); 88 static boolean elf64_alpha_find_nearest_line 89 PARAMS((bfd *, asection *, asymbol **, bfd_vma, const char **, 90 const char **, unsigned int *)); 69 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); 70 71 static bfd_boolean elf64_alpha_mkobject 72 PARAMS ((bfd *)); 73 static bfd_boolean elf64_alpha_object_p 74 PARAMS ((bfd *)); 75 static bfd_boolean elf64_alpha_section_from_shdr 76 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *)); 77 static bfd_boolean elf64_alpha_section_flags 78 PARAMS ((flagword *, Elf_Internal_Shdr *)); 79 static bfd_boolean elf64_alpha_fake_sections 80 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); 81 static bfd_boolean elf64_alpha_create_got_section 82 PARAMS ((bfd *, struct bfd_link_info *)); 83 static bfd_boolean elf64_alpha_create_dynamic_sections 84 PARAMS ((bfd *, struct bfd_link_info *)); 85 86 static bfd_boolean elf64_alpha_read_ecoff_info 87 PARAMS ((bfd *, asection *, struct ecoff_debug_info *)); 88 static bfd_boolean elf64_alpha_is_local_label_name 89 PARAMS ((bfd *, const char *)); 90 static bfd_boolean elf64_alpha_find_nearest_line 91 PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, 92 const char **, unsigned int *)); 91 93 92 94 #if defined(__STDC__) || defined(ALMOST_STDC) … … 94 96 #endif 95 97 96 static b oolean elf64_alpha_output_extsym97 PARAMS ((struct alpha_elf_link_hash_entry *, PTR));98 99 static b oolean elf64_alpha_can_merge_gots100 PARAMS ((bfd *, bfd *));98 static bfd_boolean elf64_alpha_output_extsym 99 PARAMS ((struct alpha_elf_link_hash_entry *, PTR)); 100 101 static bfd_boolean elf64_alpha_can_merge_gots 102 PARAMS ((bfd *, bfd *)); 101 103 static void elf64_alpha_merge_gots 102 PARAMS ((bfd *, bfd *));103 static b oolean elf64_alpha_calc_got_offsets_for_symbol104 PARAMS ((bfd *, bfd *)); 105 static bfd_boolean elf64_alpha_calc_got_offsets_for_symbol 104 106 PARAMS ((struct alpha_elf_link_hash_entry *, PTR)); 105 static void elf64_alpha_calc_got_offsets PARAMS ((struct bfd_link_info *)); 106 static boolean elf64_alpha_size_got_sections 107 static void elf64_alpha_calc_got_offsets 108 PARAMS ((struct bfd_link_info *)); 109 static bfd_boolean elf64_alpha_size_got_sections 110 PARAMS ((struct bfd_link_info *)); 111 static bfd_boolean elf64_alpha_size_plt_section 112 PARAMS ((struct bfd_link_info *)); 113 static bfd_boolean elf64_alpha_size_plt_section_1 114 PARAMS ((struct alpha_elf_link_hash_entry *, PTR)); 115 static bfd_boolean elf64_alpha_always_size_sections 107 116 PARAMS ((bfd *, struct bfd_link_info *)); 108 static boolean elf64_alpha_always_size_sections109 PARAMS (( bfd *, struct bfd_link_info *));110 static b oolean elf64_alpha_calc_dynrel_sizes117 static int alpha_dynamic_entries_for_reloc 118 PARAMS ((int, int, int)); 119 static bfd_boolean elf64_alpha_calc_dynrel_sizes 111 120 PARAMS ((struct alpha_elf_link_hash_entry *, struct bfd_link_info *)); 112 static boolean elf64_alpha_add_symbol_hook 121 static bfd_boolean elf64_alpha_size_rela_got_section 122 PARAMS ((struct bfd_link_info *)); 123 static bfd_boolean elf64_alpha_size_rela_got_1 124 PARAMS ((struct alpha_elf_link_hash_entry *, struct bfd_link_info *)); 125 static bfd_boolean elf64_alpha_add_symbol_hook 113 126 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, 114 127 const char **, flagword *, asection **, bfd_vma *)); 115 static boolean elf64_alpha_check_relocs 116 PARAMS((bfd *, struct bfd_link_info *, asection *sec, 128 static struct alpha_elf_got_entry *get_got_entry 129 PARAMS ((bfd *, struct alpha_elf_link_hash_entry *, unsigned long, 130 unsigned long, bfd_vma)); 131 static bfd_boolean elf64_alpha_check_relocs 132 PARAMS ((bfd *, struct bfd_link_info *, asection *sec, 117 133 const Elf_Internal_Rela *)); 118 static boolean elf64_alpha_adjust_dynamic_symbol 119 PARAMS((struct bfd_link_info *, struct elf_link_hash_entry *)); 120 static boolean elf64_alpha_size_dynamic_sections 121 PARAMS((bfd *, struct bfd_link_info *)); 122 static boolean elf64_alpha_relocate_section 123 PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 134 static bfd_boolean elf64_alpha_adjust_dynamic_symbol 135 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); 136 static bfd_boolean elf64_alpha_size_dynamic_sections 137 PARAMS ((bfd *, struct bfd_link_info *)); 138 static void elf64_alpha_emit_dynrel 139 PARAMS ((bfd *, struct bfd_link_info *, asection *, asection *, 140 bfd_vma, long, long, bfd_vma)); 141 static bfd_boolean elf64_alpha_relocate_section_r 142 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 143 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); 144 static bfd_boolean elf64_alpha_relocate_section 145 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 124 146 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); 125 static b oolean elf64_alpha_finish_dynamic_symbol126 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,127 Elf_Internal_Sym *));128 static b oolean elf64_alpha_finish_dynamic_sections129 PARAMS ((bfd *, struct bfd_link_info *));130 static b oolean elf64_alpha_final_link131 PARAMS ((bfd *, struct bfd_link_info *));132 static b oolean elf64_alpha_merge_ind_symbols133 PARAMS ((struct alpha_elf_link_hash_entry *, PTR));147 static bfd_boolean elf64_alpha_finish_dynamic_symbol 148 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, 149 Elf_Internal_Sym *)); 150 static bfd_boolean elf64_alpha_finish_dynamic_sections 151 PARAMS ((bfd *, struct bfd_link_info *)); 152 static bfd_boolean elf64_alpha_final_link 153 PARAMS ((bfd *, struct bfd_link_info *)); 154 static bfd_boolean elf64_alpha_merge_ind_symbols 155 PARAMS ((struct alpha_elf_link_hash_entry *, PTR)); 134 156 static Elf_Internal_Rela * elf64_alpha_find_reloc_at_ofs 135 157 PARAMS ((Elf_Internal_Rela *, Elf_Internal_Rela *, bfd_vma, int)); 158 static enum elf_reloc_type_class elf64_alpha_reloc_type_class 159 PARAMS ((const Elf_Internal_Rela *)); 136 160 137 161 … … 146 170 int flags; 147 171 148 /* Contexts (LITUSE) in which a literal was referenced. */ 149 #define ALPHA_ELF_LINK_HASH_LU_ADDR 0x01 150 #define ALPHA_ELF_LINK_HASH_LU_MEM 0x02 151 #define ALPHA_ELF_LINK_HASH_LU_BYTE 0x04 152 #define ALPHA_ELF_LINK_HASH_LU_FUNC 0x08 172 /* Contexts in which a literal was referenced. */ 173 #define ALPHA_ELF_LINK_HASH_LU_ADDR 0x01 174 #define ALPHA_ELF_LINK_HASH_LU_MEM 0x02 175 #define ALPHA_ELF_LINK_HASH_LU_BYTE 0x04 176 #define ALPHA_ELF_LINK_HASH_LU_JSR 0x08 177 #define ALPHA_ELF_LINK_HASH_LU_TLSGD 0x10 178 #define ALPHA_ELF_LINK_HASH_LU_TLSLDM 0x20 179 #define ALPHA_ELF_LINK_HASH_LU_FUNC 0x38 180 #define ALPHA_ELF_LINK_HASH_TLS_IE 0x40 181 #define ALPHA_ELF_LINK_HASH_PLT_LOC 0x80 182 183 /* Used to undo the localization of a plt symbol. */ 184 asection *plt_old_section; 185 bfd_vma plt_old_value; 153 186 154 187 /* Used to implement multiple .got subsections. */ … … 157 190 struct alpha_elf_got_entry *next; 158 191 159 /* which .got subsection? */192 /* Which .got subsection? */ 160 193 bfd *gotobj; 161 194 162 /* the addend in effect for this entry. */195 /* The addend in effect for this entry. */ 163 196 bfd_vma addend; 164 197 165 /* the .got offset for this entry. */198 /* The .got offset for this entry. */ 166 199 int got_offset; 167 200 168 int flags; 169 170 /* An additional flag. */ 171 #define ALPHA_ELF_GOT_ENTRY_RELOCS_DONE 0x10 172 201 /* How many references to this entry? */ 173 202 int use_count; 203 204 /* The relocation type of this entry. */ 205 unsigned char reloc_type; 206 207 /* How a LITERAL is used. */ 208 unsigned char flags; 209 210 /* Have we initialized the dynamic relocation for this entry? */ 211 unsigned char reloc_done; 212 213 /* Have we adjusted this entry for SEC_MERGE? */ 214 unsigned char reloc_xlated; 174 215 } *got_entries; 175 216 176 /* used to count non-got, non-plt relocations for delayed sizing217 /* Used to count non-got, non-plt relocations for delayed sizing 177 218 of relocation sections. */ 178 219 struct alpha_elf_reloc_entry … … 180 221 struct alpha_elf_reloc_entry *next; 181 222 182 /* which .reloc section? */223 /* Which .reloc section? */ 183 224 asection *srel; 184 225 185 /* what kind of relocation? */ 186 unsigned long rtype; 187 188 /* how many did we find? */ 226 /* What kind of relocation? */ 227 unsigned int rtype; 228 229 /* Is this against read-only section? */ 230 unsigned int reltext : 1; 231 232 /* How many did we find? */ 189 233 unsigned long count; 190 234 } *reloc_entries; … … 214 258 (elf_link_hash_traverse \ 215 259 (&(table)->root, \ 216 (b oolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func),\260 (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \ 217 261 (info))) 218 262 … … 235 279 { 236 280 if (h == NULL) 237 return false;281 return FALSE; 238 282 239 283 while (h->root.type == bfd_link_hash_indirect … … 242 286 243 287 if (h->dynindx == -1) 244 return false;288 return FALSE; 245 289 246 290 if (h->root.type == bfd_link_hash_undefweak 247 291 || h->root.type == bfd_link_hash_defweak) 248 return true;292 return TRUE; 249 293 250 294 switch (ELF_ST_VISIBILITY (h->other)) … … 254 298 case STV_HIDDEN: 255 299 case STV_INTERNAL: 256 return false;300 return FALSE; 257 301 case STV_PROTECTED: 258 302 if (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) 259 return false;303 return FALSE; 260 304 break; 261 305 } … … 263 307 if ((info->shared && !info->symbolic) 264 308 || ((h->elf_link_hash_flags 265 & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)) 309 & (ELF_LINK_HASH_DEF_DYNAMIC 310 | ELF_LINK_HASH_DEF_REGULAR 311 | ELF_LINK_HASH_REF_REGULAR)) 266 312 == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))) 267 return true;268 269 return false;313 return TRUE; 314 315 return FALSE; 270 316 } 271 317 … … 316 362 { 317 363 struct alpha_elf_link_hash_table *ret; 318 319 ret = ((struct alpha_elf_link_hash_table *) 320 bfd_zalloc (abfd, sizeof (struct alpha_elf_link_hash_table)));364 bfd_size_type amt = sizeof (struct alpha_elf_link_hash_table); 365 366 ret = (struct alpha_elf_link_hash_table *) bfd_zmalloc (amt); 321 367 if (ret == (struct alpha_elf_link_hash_table *) NULL) 322 368 return NULL; … … 325 371 elf64_alpha_link_hash_newfunc)) 326 372 { 327 bfd_release (abfd,ret);373 free (ret); 328 374 return NULL; 329 375 } … … 356 402 asection *got; 357 403 358 /* For every got, this is it's total number of *entries*. */359 int total_got_ entries;360 361 /* For every got, this is the sum of the number of *entries*required404 /* For every got, this is it's total number of words. */ 405 int total_got_size; 406 407 /* For every got, this is the sum of the number of words required 362 408 to hold all of the member object's local got. */ 363 int n_local_got_entries;409 int local_got_size; 364 410 }; 365 411 … … 367 413 ((struct alpha_elf_obj_tdata *) (abfd)->tdata.any) 368 414 369 static b oolean415 static bfd_boolean 370 416 elf64_alpha_mkobject (abfd) 371 417 bfd *abfd; 372 418 { 373 abfd->tdata.any = bfd_zalloc (abfd, sizeof (struct alpha_elf_obj_tdata)); 419 bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata); 420 abfd->tdata.any = bfd_zalloc (abfd, amt); 374 421 if (abfd->tdata.any == NULL) 375 return false;376 return true;422 return FALSE; 423 return TRUE; 377 424 } 378 425 379 static b oolean426 static bfd_boolean 380 427 elf64_alpha_object_p (abfd) 381 428 bfd *abfd; … … 383 430 /* Allocate our special target data. */ 384 431 struct alpha_elf_obj_tdata *new_tdata; 385 new_tdata = bfd_zalloc (abfd, sizeof (struct alpha_elf_obj_tdata)); 432 bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata); 433 new_tdata = bfd_zalloc (abfd, amt); 386 434 if (new_tdata == NULL) 387 return false;435 return FALSE; 388 436 new_tdata->root = *abfd->tdata.elf_obj_data; 389 437 abfd->tdata.any = new_tdata; … … 397 445 from smaller values. Start with zero, widen, *then* decrement. */ 398 446 #define MINUS_ONE (((bfd_vma)0) - 1) 447 448 #define SKIP_HOWTO(N) \ 449 HOWTO(N, 0, 0, 0, 0, 0, 0, elf64_alpha_reloc_bad, 0, 0, 0, 0, 0) 399 450 400 451 static reloc_howto_type elf64_alpha_howto_table[] = … … 404 455 0, /* size (0 = byte, 1 = short, 2 = long) */ 405 456 8, /* bitsize */ 406 true, /* pc_relative */457 TRUE, /* pc_relative */ 407 458 0, /* bitpos */ 408 459 complain_overflow_dont, /* complain_on_overflow */ 409 460 elf64_alpha_reloc_nil, /* special_function */ 410 461 "NONE", /* name */ 411 false, /* partial_inplace */462 FALSE, /* partial_inplace */ 412 463 0, /* src_mask */ 413 464 0, /* dst_mask */ 414 true), /* pcrel_offset */465 TRUE), /* pcrel_offset */ 415 466 416 467 /* A 32 bit reference to a symbol. */ … … 419 470 2, /* size (0 = byte, 1 = short, 2 = long) */ 420 471 32, /* bitsize */ 421 false, /* pc_relative */472 FALSE, /* pc_relative */ 422 473 0, /* bitpos */ 423 474 complain_overflow_bitfield, /* complain_on_overflow */ 424 475 0, /* special_function */ 425 476 "REFLONG", /* name */ 426 false, /* partial_inplace */477 FALSE, /* partial_inplace */ 427 478 0xffffffff, /* src_mask */ 428 479 0xffffffff, /* dst_mask */ 429 false), /* pcrel_offset */480 FALSE), /* pcrel_offset */ 430 481 431 482 /* A 64 bit reference to a symbol. */ … … 434 485 4, /* size (0 = byte, 1 = short, 2 = long) */ 435 486 64, /* bitsize */ 436 false, /* pc_relative */487 FALSE, /* pc_relative */ 437 488 0, /* bitpos */ 438 489 complain_overflow_bitfield, /* complain_on_overflow */ 439 490 0, /* special_function */ 440 491 "REFQUAD", /* name */ 441 false, /* partial_inplace */492 FALSE, /* partial_inplace */ 442 493 MINUS_ONE, /* src_mask */ 443 494 MINUS_ONE, /* dst_mask */ 444 false), /* pcrel_offset */495 FALSE), /* pcrel_offset */ 445 496 446 497 /* A 32 bit GP relative offset. This is just like REFLONG except … … 451 502 2, /* size (0 = byte, 1 = short, 2 = long) */ 452 503 32, /* bitsize */ 453 false, /* pc_relative */504 FALSE, /* pc_relative */ 454 505 0, /* bitpos */ 455 506 complain_overflow_bitfield, /* complain_on_overflow */ 456 507 0, /* special_function */ 457 508 "GPREL32", /* name */ 458 false, /* partial_inplace */509 FALSE, /* partial_inplace */ 459 510 0xffffffff, /* src_mask */ 460 511 0xffffffff, /* dst_mask */ 461 false), /* pcrel_offset */512 FALSE), /* pcrel_offset */ 462 513 463 514 /* Used for an instruction that refers to memory off the GP register. */ 464 515 HOWTO (R_ALPHA_LITERAL, /* type */ 465 516 0, /* rightshift */ 466 2, /* size (0 = byte, 1 = short, 2 = long) */517 1, /* size (0 = byte, 1 = short, 2 = long) */ 467 518 16, /* bitsize */ 468 false, /* pc_relative */519 FALSE, /* pc_relative */ 469 520 0, /* bitpos */ 470 521 complain_overflow_signed, /* complain_on_overflow */ 471 522 0, /* special_function */ 472 523 "ELF_LITERAL", /* name */ 473 false, /* partial_inplace */524 FALSE, /* partial_inplace */ 474 525 0xffff, /* src_mask */ 475 526 0xffff, /* dst_mask */ 476 false), /* pcrel_offset */527 FALSE), /* pcrel_offset */ 477 528 478 529 /* This reloc only appears immediately following an ELF_LITERAL reloc. … … 485 536 HOWTO (R_ALPHA_LITUSE, /* type */ 486 537 0, /* rightshift */ 487 2, /* size (0 = byte, 1 = short, 2 = long) */538 1, /* size (0 = byte, 1 = short, 2 = long) */ 488 539 32, /* bitsize */ 489 false, /* pc_relative */540 FALSE, /* pc_relative */ 490 541 0, /* bitpos */ 491 542 complain_overflow_dont, /* complain_on_overflow */ 492 543 elf64_alpha_reloc_nil, /* special_function */ 493 544 "LITUSE", /* name */ 494 false, /* partial_inplace */545 FALSE, /* partial_inplace */ 495 546 0, /* src_mask */ 496 547 0, /* dst_mask */ 497 false), /* pcrel_offset */548 FALSE), /* pcrel_offset */ 498 549 499 550 /* Load the gp register. This is always used for a ldah instruction … … 517 568 2, /* size (0 = byte, 1 = short, 2 = long) */ 518 569 16, /* bitsize */ 519 false, /* pc_relative */570 FALSE, /* pc_relative */ 520 571 0, /* bitpos */ 521 572 complain_overflow_dont, /* complain_on_overflow */ 522 573 elf64_alpha_reloc_gpdisp, /* special_function */ 523 574 "GPDISP", /* name */ 524 false, /* partial_inplace */575 FALSE, /* partial_inplace */ 525 576 0xffff, /* src_mask */ 526 577 0xffff, /* dst_mask */ 527 true), /* pcrel_offset */578 TRUE), /* pcrel_offset */ 528 579 529 580 /* A 21 bit branch. */ … … 532 583 2, /* size (0 = byte, 1 = short, 2 = long) */ 533 584 21, /* bitsize */ 534 true, /* pc_relative */585 TRUE, /* pc_relative */ 535 586 0, /* bitpos */ 536 587 complain_overflow_signed, /* complain_on_overflow */ 537 588 0, /* special_function */ 538 589 "BRADDR", /* name */ 539 false, /* partial_inplace */590 FALSE, /* partial_inplace */ 540 591 0x1fffff, /* src_mask */ 541 592 0x1fffff, /* dst_mask */ 542 true), /* pcrel_offset */593 TRUE), /* pcrel_offset */ 543 594 544 595 /* A hint for a jump to a register. */ 545 596 HOWTO (R_ALPHA_HINT, /* type */ 546 597 2, /* rightshift */ 547 2, /* size (0 = byte, 1 = short, 2 = long) */598 1, /* size (0 = byte, 1 = short, 2 = long) */ 548 599 14, /* bitsize */ 549 true, /* pc_relative */600 TRUE, /* pc_relative */ 550 601 0, /* bitpos */ 551 602 complain_overflow_dont, /* complain_on_overflow */ 552 603 0, /* special_function */ 553 604 "HINT", /* name */ 554 false, /* partial_inplace */605 FALSE, /* partial_inplace */ 555 606 0x3fff, /* src_mask */ 556 607 0x3fff, /* dst_mask */ 557 true), /* pcrel_offset */608 TRUE), /* pcrel_offset */ 558 609 559 610 /* 16 bit PC relative offset. */ … … 562 613 1, /* size (0 = byte, 1 = short, 2 = long) */ 563 614 16, /* bitsize */ 564 true, /* pc_relative */615 TRUE, /* pc_relative */ 565 616 0, /* bitpos */ 566 617 complain_overflow_signed, /* complain_on_overflow */ 567 618 0, /* special_function */ 568 619 "SREL16", /* name */ 569 false, /* partial_inplace */620 FALSE, /* partial_inplace */ 570 621 0xffff, /* src_mask */ 571 622 0xffff, /* dst_mask */ 572 true), /* pcrel_offset */623 TRUE), /* pcrel_offset */ 573 624 574 625 /* 32 bit PC relative offset. */ … … 577 628 2, /* size (0 = byte, 1 = short, 2 = long) */ 578 629 32, /* bitsize */ 579 true, /* pc_relative */630 TRUE, /* pc_relative */ 580 631 0, /* bitpos */ 581 632 complain_overflow_signed, /* complain_on_overflow */ 582 633 0, /* special_function */ 583 634 "SREL32", /* name */ 584 false, /* partial_inplace */635 FALSE, /* partial_inplace */ 585 636 0xffffffff, /* src_mask */ 586 637 0xffffffff, /* dst_mask */ 587 true), /* pcrel_offset */638 TRUE), /* pcrel_offset */ 588 639 589 640 /* A 64 bit PC relative offset. */ … … 592 643 4, /* size (0 = byte, 1 = short, 2 = long) */ 593 644 64, /* bitsize */ 594 true, /* pc_relative */645 TRUE, /* pc_relative */ 595 646 0, /* bitpos */ 596 647 complain_overflow_signed, /* complain_on_overflow */ 597 648 0, /* special_function */ 598 649 "SREL64", /* name */ 599 false, /* partial_inplace */650 FALSE, /* partial_inplace */ 600 651 MINUS_ONE, /* src_mask */ 601 652 MINUS_ONE, /* dst_mask */ 602 true), /* pcrel_offset */ 603 604 /* Push a value on the reloc evaluation stack. */ 605 /* Not implemented -- it's dumb. */ 606 HOWTO (R_ALPHA_OP_PUSH, /* type */ 607 0, /* rightshift */ 608 0, /* size (0 = byte, 1 = short, 2 = long) */ 609 0, /* bitsize */ 610 false, /* pc_relative */ 611 0, /* bitpos */ 612 complain_overflow_dont, /* complain_on_overflow */ 613 elf64_alpha_reloc_bad, /* special_function */ 614 "OP_PUSH", /* name */ 615 false, /* partial_inplace */ 616 0, /* src_mask */ 617 0, /* dst_mask */ 618 false), /* pcrel_offset */ 619 620 /* Store the value from the stack at the given address. Store it in 621 a bitfield of size r_size starting at bit position r_offset. */ 622 /* Not implemented -- it's dumb. */ 623 HOWTO (R_ALPHA_OP_STORE, /* type */ 624 0, /* rightshift */ 625 4, /* size (0 = byte, 1 = short, 2 = long) */ 626 64, /* bitsize */ 627 false, /* pc_relative */ 628 0, /* bitpos */ 629 complain_overflow_dont, /* complain_on_overflow */ 630 elf64_alpha_reloc_bad, /* special_function */ 631 "OP_STORE", /* name */ 632 false, /* partial_inplace */ 633 0, /* src_mask */ 634 MINUS_ONE, /* dst_mask */ 635 false), /* pcrel_offset */ 636 637 /* Subtract the reloc address from the value on the top of the 638 relocation stack. */ 639 /* Not implemented -- it's dumb. */ 640 HOWTO (R_ALPHA_OP_PSUB, /* type */ 641 0, /* rightshift */ 642 0, /* size (0 = byte, 1 = short, 2 = long) */ 643 0, /* bitsize */ 644 false, /* pc_relative */ 645 0, /* bitpos */ 646 complain_overflow_dont, /* complain_on_overflow */ 647 elf64_alpha_reloc_bad, /* special_function */ 648 "OP_PSUB", /* name */ 649 false, /* partial_inplace */ 650 0, /* src_mask */ 651 0, /* dst_mask */ 652 false), /* pcrel_offset */ 653 654 /* Shift the value on the top of the relocation stack right by the 655 given value. */ 656 /* Not implemented -- it's dumb. */ 657 HOWTO (R_ALPHA_OP_PRSHIFT, /* type */ 658 0, /* rightshift */ 659 0, /* size (0 = byte, 1 = short, 2 = long) */ 660 0, /* bitsize */ 661 false, /* pc_relative */ 662 0, /* bitpos */ 663 complain_overflow_dont, /* complain_on_overflow */ 664 elf64_alpha_reloc_bad, /* special_function */ 665 "OP_PRSHIFT", /* name */ 666 false, /* partial_inplace */ 667 0, /* src_mask */ 668 0, /* dst_mask */ 669 false), /* pcrel_offset */ 670 671 /* Change the value of GP used by +r_addend until the next GPVALUE or the 672 end of the input bfd. */ 673 /* Not implemented -- it's dumb. */ 674 HOWTO (R_ALPHA_GPVALUE, 675 0, /* rightshift */ 676 0, /* size (0 = byte, 1 = short, 2 = long) */ 677 0, /* bitsize */ 678 false, /* pc_relative */ 679 0, /* bitpos */ 680 complain_overflow_dont, /* complain_on_overflow */ 681 elf64_alpha_reloc_bad, /* special_function */ 682 "GPVALUE", /* name */ 683 false, /* partial_inplace */ 684 0, /* src_mask */ 685 0, /* dst_mask */ 686 false), /* pcrel_offset */ 653 TRUE), /* pcrel_offset */ 654 655 /* Skip 12 - 16; deprecated ECOFF relocs. */ 656 SKIP_HOWTO (12), 657 SKIP_HOWTO (13), 658 SKIP_HOWTO (14), 659 SKIP_HOWTO (15), 660 SKIP_HOWTO (16), 687 661 688 662 /* The high 16 bits of the displacement from GP to the target. */ 689 663 HOWTO (R_ALPHA_GPRELHIGH, 690 664 0, /* rightshift */ 691 2, /* size (0 = byte, 1 = short, 2 = long) */665 1, /* size (0 = byte, 1 = short, 2 = long) */ 692 666 16, /* bitsize */ 693 false, /* pc_relative */667 FALSE, /* pc_relative */ 694 668 0, /* bitpos */ 695 669 complain_overflow_signed, /* complain_on_overflow */ 696 elf64_alpha_reloc_bad,/* special_function */670 0, /* special_function */ 697 671 "GPRELHIGH", /* name */ 698 false, /* partial_inplace */672 FALSE, /* partial_inplace */ 699 673 0xffff, /* src_mask */ 700 674 0xffff, /* dst_mask */ 701 false), /* pcrel_offset */675 FALSE), /* pcrel_offset */ 702 676 703 677 /* The low 16 bits of the displacement from GP to the target. */ 704 678 HOWTO (R_ALPHA_GPRELLOW, 705 679 0, /* rightshift */ 706 2, /* size (0 = byte, 1 = short, 2 = long) */680 1, /* size (0 = byte, 1 = short, 2 = long) */ 707 681 16, /* bitsize */ 708 false, /* pc_relative */682 FALSE, /* pc_relative */ 709 683 0, /* bitpos */ 710 684 complain_overflow_dont, /* complain_on_overflow */ 711 elf64_alpha_reloc_bad,/* special_function */685 0, /* special_function */ 712 686 "GPRELLOW", /* name */ 713 false, /* partial_inplace */687 FALSE, /* partial_inplace */ 714 688 0xffff, /* src_mask */ 715 689 0xffff, /* dst_mask */ 716 false), /* pcrel_offset */690 FALSE), /* pcrel_offset */ 717 691 718 692 /* A 16-bit displacement from the GP to the target. */ 719 /* XXX: Not implemented. */ 720 HOWTO (R_ALPHA_IMMED_GP_16, 693 HOWTO (R_ALPHA_GPREL16, 721 694 0, /* rightshift */ 722 2, /* size (0 = byte, 1 = short, 2 = long) */695 1, /* size (0 = byte, 1 = short, 2 = long) */ 723 696 16, /* bitsize */ 724 false, /* pc_relative */697 FALSE, /* pc_relative */ 725 698 0, /* bitpos */ 726 699 complain_overflow_signed, /* complain_on_overflow */ 727 700 0, /* special_function */ 728 " IMMED_GP_16", /* name */729 false, /* partial_inplace */701 "GPREL16", /* name */ 702 FALSE, /* partial_inplace */ 730 703 0xffff, /* src_mask */ 731 704 0xffff, /* dst_mask */ 732 false), /* pcrel_offset */ 733 734 /* The high bits of a 32-bit displacement from the GP to the target; the 735 low bits are supplied in the subsequent R_ALPHA_IMMED_LO32 relocs. */ 736 /* XXX: Not implemented. */ 737 HOWTO (R_ALPHA_IMMED_GP_HI32, 738 0, /* rightshift */ 739 0, /* size (0 = byte, 1 = short, 2 = long) */ 740 0, /* bitsize */ 741 false, /* pc_relative */ 742 0, /* bitpos */ 743 complain_overflow_dont, /* complain_on_overflow */ 744 elf64_alpha_reloc_bad, /* special_function */ 745 "IMMED_GP_HI32", /* name */ 746 false, /* partial_inplace */ 747 0, /* src_mask */ 748 0, /* dst_mask */ 749 false), /* pcrel_offset */ 750 751 /* The high bits of a 32-bit displacement to the starting address of the 752 current section (the relocation target is ignored); the low bits are 753 supplied in the subsequent R_ALPHA_IMMED_LO32 relocs. */ 754 /* XXX: Not implemented. */ 755 HOWTO (R_ALPHA_IMMED_SCN_HI32, 756 0, /* rightshift */ 757 0, /* size (0 = byte, 1 = short, 2 = long) */ 758 0, /* bitsize */ 759 false, /* pc_relative */ 760 0, /* bitpos */ 761 complain_overflow_dont, /* complain_on_overflow */ 762 elf64_alpha_reloc_bad, /* special_function */ 763 "IMMED_SCN_HI32", /* name */ 764 false, /* partial_inplace */ 765 0, /* src_mask */ 766 0, /* dst_mask */ 767 false), /* pcrel_offset */ 768 769 /* The high bits of a 32-bit displacement from the previous br, bsr, jsr 770 or jmp insn (as tagged by a BRADDR or HINT reloc) to the target; the 771 low bits are supplied by subsequent R_ALPHA_IMMED_LO32 relocs. */ 772 /* XXX: Not implemented. */ 773 HOWTO (R_ALPHA_IMMED_BR_HI32, 774 0, /* rightshift */ 775 0, /* size (0 = byte, 1 = short, 2 = long) */ 776 0, /* bitsize */ 777 false, /* pc_relative */ 778 0, /* bitpos */ 779 complain_overflow_dont, /* complain_on_overflow */ 780 elf64_alpha_reloc_bad, /* special_function */ 781 "IMMED_BR_HI32", /* name */ 782 false, /* partial_inplace */ 783 0, /* src_mask */ 784 0, /* dst_mask */ 785 false), /* pcrel_offset */ 786 787 /* The low 16 bits of a displacement calculated in a previous HI32 reloc. */ 788 /* XXX: Not implemented. */ 789 HOWTO (R_ALPHA_IMMED_LO32, 790 0, /* rightshift */ 791 0, /* size (0 = byte, 1 = short, 2 = long) */ 792 0, /* bitsize */ 793 false, /* pc_relative */ 794 0, /* bitpos */ 795 complain_overflow_dont, /* complain_on_overflow */ 796 elf64_alpha_reloc_bad, /* special_function */ 797 "IMMED_LO32", /* name */ 798 false, /* partial_inplace */ 799 0, /* src_mask */ 800 0, /* dst_mask */ 801 false), /* pcrel_offset */ 705 FALSE), /* pcrel_offset */ 706 707 /* Skip 20 - 23; deprecated ECOFF relocs. */ 708 SKIP_HOWTO (20), 709 SKIP_HOWTO (21), 710 SKIP_HOWTO (22), 711 SKIP_HOWTO (23), 802 712 803 713 /* Misc ELF relocations. */ … … 811 721 0, 812 722 0, 813 false,723 FALSE, 814 724 0, 815 725 complain_overflow_dont, 816 726 bfd_elf_generic_reloc, 817 727 "COPY", 818 false,728 FALSE, 819 729 0, 820 730 0, 821 true),731 TRUE), 822 732 823 733 /* A dynamic relocation for a .got entry. */ … … 826 736 0, 827 737 0, 828 false,738 FALSE, 829 739 0, 830 740 complain_overflow_dont, 831 741 bfd_elf_generic_reloc, 832 742 "GLOB_DAT", 833 false,743 FALSE, 834 744 0, 835 745 0, 836 true),746 TRUE), 837 747 838 748 /* A dynamic relocation for a .plt entry. */ … … 841 751 0, 842 752 0, 843 false,753 FALSE, 844 754 0, 845 755 complain_overflow_dont, 846 756 bfd_elf_generic_reloc, 847 757 "JMP_SLOT", 848 false,758 FALSE, 849 759 0, 850 760 0, 851 true),761 TRUE), 852 762 853 763 /* A dynamic relocation to add the base of the DSO to a 64-bit field. */ … … 856 766 0, 857 767 0, 858 false,768 FALSE, 859 769 0, 860 770 complain_overflow_dont, 861 771 bfd_elf_generic_reloc, 862 772 "RELATIVE", 863 false,773 FALSE, 864 774 0, 865 775 0, 866 true) 776 TRUE), 777 778 /* A 21 bit branch that adjusts for gp loads. */ 779 HOWTO (R_ALPHA_BRSGP, /* type */ 780 2, /* rightshift */ 781 2, /* size (0 = byte, 1 = short, 2 = long) */ 782 21, /* bitsize */ 783 TRUE, /* pc_relative */ 784 0, /* bitpos */ 785 complain_overflow_signed, /* complain_on_overflow */ 786 0, /* special_function */ 787 "BRSGP", /* name */ 788 FALSE, /* partial_inplace */ 789 0x1fffff, /* src_mask */ 790 0x1fffff, /* dst_mask */ 791 TRUE), /* pcrel_offset */ 792 793 /* Creates a tls_index for the symbol in the got. */ 794 HOWTO (R_ALPHA_TLSGD, /* type */ 795 0, /* rightshift */ 796 1, /* size (0 = byte, 1 = short, 2 = long) */ 797 16, /* bitsize */ 798 FALSE, /* pc_relative */ 799 0, /* bitpos */ 800 complain_overflow_signed, /* complain_on_overflow */ 801 0, /* special_function */ 802 "TLSGD", /* name */ 803 FALSE, /* partial_inplace */ 804 0xffff, /* src_mask */ 805 0xffff, /* dst_mask */ 806 FALSE), /* pcrel_offset */ 807 808 /* Creates a tls_index for the (current) module in the got. */ 809 HOWTO (R_ALPHA_TLSLDM, /* type */ 810 0, /* rightshift */ 811 1, /* size (0 = byte, 1 = short, 2 = long) */ 812 16, /* bitsize */ 813 FALSE, /* pc_relative */ 814 0, /* bitpos */ 815 complain_overflow_signed, /* complain_on_overflow */ 816 0, /* special_function */ 817 "TLSLDM", /* name */ 818 FALSE, /* partial_inplace */ 819 0xffff, /* src_mask */ 820 0xffff, /* dst_mask */ 821 FALSE), /* pcrel_offset */ 822 823 /* A dynamic relocation for a DTP module entry. */ 824 HOWTO (R_ALPHA_DTPMOD64, /* type */ 825 0, /* rightshift */ 826 4, /* size (0 = byte, 1 = short, 2 = long) */ 827 64, /* bitsize */ 828 FALSE, /* pc_relative */ 829 0, /* bitpos */ 830 complain_overflow_bitfield, /* complain_on_overflow */ 831 0, /* special_function */ 832 "DTPMOD64", /* name */ 833 FALSE, /* partial_inplace */ 834 MINUS_ONE, /* src_mask */ 835 MINUS_ONE, /* dst_mask */ 836 FALSE), /* pcrel_offset */ 837 838 /* Creates a 64-bit offset in the got for the displacement 839 from DTP to the target. */ 840 HOWTO (R_ALPHA_GOTDTPREL, /* type */ 841 0, /* rightshift */ 842 1, /* size (0 = byte, 1 = short, 2 = long) */ 843 16, /* bitsize */ 844 FALSE, /* pc_relative */ 845 0, /* bitpos */ 846 complain_overflow_signed, /* complain_on_overflow */ 847 0, /* special_function */ 848 "GOTDTPREL", /* name */ 849 FALSE, /* partial_inplace */ 850 0xffff, /* src_mask */ 851 0xffff, /* dst_mask */ 852 FALSE), /* pcrel_offset */ 853 854 /* A dynamic relocation for a displacement from DTP to the target. */ 855 HOWTO (R_ALPHA_DTPREL64, /* type */ 856 0, /* rightshift */ 857 4, /* size (0 = byte, 1 = short, 2 = long) */ 858 64, /* bitsize */ 859 FALSE, /* pc_relative */ 860 0, /* bitpos */ 861 complain_overflow_bitfield, /* complain_on_overflow */ 862 0, /* special_function */ 863 "DTPREL64", /* name */ 864 FALSE, /* partial_inplace */ 865 MINUS_ONE, /* src_mask */ 866 MINUS_ONE, /* dst_mask */ 867 FALSE), /* pcrel_offset */ 868 869 /* The high 16 bits of the displacement from DTP to the target. */ 870 HOWTO (R_ALPHA_DTPRELHI, /* type */ 871 0, /* rightshift */ 872 1, /* size (0 = byte, 1 = short, 2 = long) */ 873 16, /* bitsize */ 874 FALSE, /* pc_relative */ 875 0, /* bitpos */ 876 complain_overflow_signed, /* complain_on_overflow */ 877 0, /* special_function */ 878 "DTPRELHI", /* name */ 879 FALSE, /* partial_inplace */ 880 0xffff, /* src_mask */ 881 0xffff, /* dst_mask */ 882 FALSE), /* pcrel_offset */ 883 884 /* The low 16 bits of the displacement from DTP to the target. */ 885 HOWTO (R_ALPHA_DTPRELLO, /* type */ 886 0, /* rightshift */ 887 1, /* size (0 = byte, 1 = short, 2 = long) */ 888 16, /* bitsize */ 889 FALSE, /* pc_relative */ 890 0, /* bitpos */ 891 complain_overflow_dont, /* complain_on_overflow */ 892 0, /* special_function */ 893 "DTPRELLO", /* name */ 894 FALSE, /* partial_inplace */ 895 0xffff, /* src_mask */ 896 0xffff, /* dst_mask */ 897 FALSE), /* pcrel_offset */ 898 899 /* A 16-bit displacement from DTP to the target. */ 900 HOWTO (R_ALPHA_DTPREL16, /* type */ 901 0, /* rightshift */ 902 1, /* size (0 = byte, 1 = short, 2 = long) */ 903 16, /* bitsize */ 904 FALSE, /* pc_relative */ 905 0, /* bitpos */ 906 complain_overflow_signed, /* complain_on_overflow */ 907 0, /* special_function */ 908 "DTPREL16", /* name */ 909 FALSE, /* partial_inplace */ 910 0xffff, /* src_mask */ 911 0xffff, /* dst_mask */ 912 FALSE), /* pcrel_offset */ 913 914 /* Creates a 64-bit offset in the got for the displacement 915 from TP to the target. */ 916 HOWTO (R_ALPHA_GOTTPREL, /* type */ 917 0, /* rightshift */ 918 1, /* size (0 = byte, 1 = short, 2 = long) */ 919 16, /* bitsize */ 920 FALSE, /* pc_relative */ 921 0, /* bitpos */ 922 complain_overflow_signed, /* complain_on_overflow */ 923 0, /* special_function */ 924 "GOTTPREL", /* name */ 925 FALSE, /* partial_inplace */ 926 0xffff, /* src_mask */ 927 0xffff, /* dst_mask */ 928 FALSE), /* pcrel_offset */ 929 930 /* A dynamic relocation for a displacement from TP to the target. */ 931 HOWTO (R_ALPHA_TPREL64, /* type */ 932 0, /* rightshift */ 933 4, /* size (0 = byte, 1 = short, 2 = long) */ 934 64, /* bitsize */ 935 FALSE, /* pc_relative */ 936 0, /* bitpos */ 937 complain_overflow_bitfield, /* complain_on_overflow */ 938 0, /* special_function */ 939 "TPREL64", /* name */ 940 FALSE, /* partial_inplace */ 941 MINUS_ONE, /* src_mask */ 942 MINUS_ONE, /* dst_mask */ 943 FALSE), /* pcrel_offset */ 944 945 /* The high 16 bits of the displacement from TP to the target. */ 946 HOWTO (R_ALPHA_TPRELHI, /* type */ 947 0, /* rightshift */ 948 1, /* size (0 = byte, 1 = short, 2 = long) */ 949 16, /* bitsize */ 950 FALSE, /* pc_relative */ 951 0, /* bitpos */ 952 complain_overflow_signed, /* complain_on_overflow */ 953 0, /* special_function */ 954 "TPRELHI", /* name */ 955 FALSE, /* partial_inplace */ 956 0xffff, /* src_mask */ 957 0xffff, /* dst_mask */ 958 FALSE), /* pcrel_offset */ 959 960 /* The low 16 bits of the displacement from TP to the target. */ 961 HOWTO (R_ALPHA_TPRELLO, /* type */ 962 0, /* rightshift */ 963 1, /* size (0 = byte, 1 = short, 2 = long) */ 964 16, /* bitsize */ 965 FALSE, /* pc_relative */ 966 0, /* bitpos */ 967 complain_overflow_dont, /* complain_on_overflow */ 968 0, /* special_function */ 969 "TPRELLO", /* name */ 970 FALSE, /* partial_inplace */ 971 0xffff, /* src_mask */ 972 0xffff, /* dst_mask */ 973 FALSE), /* pcrel_offset */ 974 975 /* A 16-bit displacement from TP to the target. */ 976 HOWTO (R_ALPHA_TPREL16, /* type */ 977 0, /* rightshift */ 978 1, /* size (0 = byte, 1 = short, 2 = long) */ 979 16, /* bitsize */ 980 FALSE, /* pc_relative */ 981 0, /* bitpos */ 982 complain_overflow_signed, /* complain_on_overflow */ 983 0, /* special_function */ 984 "TPREL16", /* name */ 985 FALSE, /* partial_inplace */ 986 0xffff, /* src_mask */ 987 0xffff, /* dst_mask */ 988 FALSE), /* pcrel_offset */ 867 989 }; 868 990 … … 938 1060 i_lda = (i_lda & 0xffff0000) | (gpdisp & 0xffff); 939 1061 940 bfd_put_32 (abfd, i_ldah, p_ldah);941 bfd_put_32 (abfd, i_lda, p_lda);1062 bfd_put_32 (abfd, (bfd_vma) i_ldah, p_ldah); 1063 bfd_put_32 (abfd, (bfd_vma) i_lda, p_lda); 942 1064 943 1065 return ret; … … 1002 1124 static const struct elf_reloc_map elf64_alpha_reloc_map[] = 1003 1125 { 1004 {BFD_RELOC_NONE, R_ALPHA_NONE}, 1005 {BFD_RELOC_32, R_ALPHA_REFLONG}, 1006 {BFD_RELOC_64, R_ALPHA_REFQUAD}, 1007 {BFD_RELOC_CTOR, R_ALPHA_REFQUAD}, 1008 {BFD_RELOC_GPREL32, R_ALPHA_GPREL32}, 1009 {BFD_RELOC_ALPHA_ELF_LITERAL, R_ALPHA_LITERAL}, 1010 {BFD_RELOC_ALPHA_LITUSE, R_ALPHA_LITUSE}, 1011 {BFD_RELOC_ALPHA_GPDISP, R_ALPHA_GPDISP}, 1012 {BFD_RELOC_23_PCREL_S2, R_ALPHA_BRADDR}, 1013 {BFD_RELOC_ALPHA_HINT, R_ALPHA_HINT}, 1014 {BFD_RELOC_16_PCREL, R_ALPHA_SREL16}, 1015 {BFD_RELOC_32_PCREL, R_ALPHA_SREL32}, 1016 {BFD_RELOC_64_PCREL, R_ALPHA_SREL64}, 1017 1018 /* The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to process 1019 the explicit !<reloc>!sequence relocations, and are mapped into the normal 1020 relocations at the end of processing. */ 1021 {BFD_RELOC_ALPHA_USER_LITERAL, R_ALPHA_LITERAL}, 1022 {BFD_RELOC_ALPHA_USER_LITUSE_BASE, R_ALPHA_LITUSE}, 1023 {BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF, R_ALPHA_LITUSE}, 1024 {BFD_RELOC_ALPHA_USER_LITUSE_JSR, R_ALPHA_LITUSE}, 1025 {BFD_RELOC_ALPHA_USER_GPDISP, R_ALPHA_GPDISP}, 1026 {BFD_RELOC_ALPHA_USER_GPRELHIGH, R_ALPHA_GPRELHIGH}, 1027 {BFD_RELOC_ALPHA_USER_GPRELLOW, R_ALPHA_GPRELLOW}, 1126 {BFD_RELOC_NONE, R_ALPHA_NONE}, 1127 {BFD_RELOC_32, R_ALPHA_REFLONG}, 1128 {BFD_RELOC_64, R_ALPHA_REFQUAD}, 1129 {BFD_RELOC_CTOR, R_ALPHA_REFQUAD}, 1130 {BFD_RELOC_GPREL32, R_ALPHA_GPREL32}, 1131 {BFD_RELOC_ALPHA_ELF_LITERAL, R_ALPHA_LITERAL}, 1132 {BFD_RELOC_ALPHA_LITUSE, R_ALPHA_LITUSE}, 1133 {BFD_RELOC_ALPHA_GPDISP, R_ALPHA_GPDISP}, 1134 {BFD_RELOC_23_PCREL_S2, R_ALPHA_BRADDR}, 1135 {BFD_RELOC_ALPHA_HINT, R_ALPHA_HINT}, 1136 {BFD_RELOC_16_PCREL, R_ALPHA_SREL16}, 1137 {BFD_RELOC_32_PCREL, R_ALPHA_SREL32}, 1138 {BFD_RELOC_64_PCREL, R_ALPHA_SREL64}, 1139 {BFD_RELOC_ALPHA_GPREL_HI16, R_ALPHA_GPRELHIGH}, 1140 {BFD_RELOC_ALPHA_GPREL_LO16, R_ALPHA_GPRELLOW}, 1141 {BFD_RELOC_GPREL16, R_ALPHA_GPREL16}, 1142 {BFD_RELOC_ALPHA_BRSGP, R_ALPHA_BRSGP}, 1143 {BFD_RELOC_ALPHA_TLSGD, R_ALPHA_TLSGD}, 1144 {BFD_RELOC_ALPHA_TLSLDM, R_ALPHA_TLSLDM}, 1145 {BFD_RELOC_ALPHA_DTPMOD64, R_ALPHA_DTPMOD64}, 1146 {BFD_RELOC_ALPHA_GOTDTPREL16, R_ALPHA_GOTDTPREL}, 1147 {BFD_RELOC_ALPHA_DTPREL64, R_ALPHA_DTPREL64}, 1148 {BFD_RELOC_ALPHA_DTPREL_HI16, R_ALPHA_DTPRELHI}, 1149 {BFD_RELOC_ALPHA_DTPREL_LO16, R_ALPHA_DTPRELLO}, 1150 {BFD_RELOC_ALPHA_DTPREL16, R_ALPHA_DTPREL16}, 1151 {BFD_RELOC_ALPHA_GOTTPREL16, R_ALPHA_GOTTPREL}, 1152 {BFD_RELOC_ALPHA_TPREL64, R_ALPHA_TPREL64}, 1153 {BFD_RELOC_ALPHA_TPREL_HI16, R_ALPHA_TPRELHI}, 1154 {BFD_RELOC_ALPHA_TPREL_LO16, R_ALPHA_TPRELLO}, 1155 {BFD_RELOC_ALPHA_TPREL16, R_ALPHA_TPREL16}, 1028 1156 }; 1029 1157 … … 1052 1180 bfd *abfd ATTRIBUTE_UNUSED; 1053 1181 arelent *cache_ptr; 1054 Elf 64_Internal_Rela *dst;1182 Elf_Internal_Rela *dst; 1055 1183 { 1056 1184 unsigned r_type; … … 1060 1188 cache_ptr->howto = &elf64_alpha_howto_table[r_type]; 1061 1189 } 1190 1191 /* These two relocations create a two-word entry in the got. */ 1192 #define alpha_got_entry_size(r_type) \ 1193 (r_type == R_ALPHA_TLSGD || r_type == R_ALPHA_TLSLDM ? 16 : 8) 1194 1195 /* This is PT_TLS segment p_vaddr. */ 1196 #define alpha_get_dtprel_base(tlss) \ 1197 ((tlss)->start) 1198 1199 /* Main program TLS (whose template starts at PT_TLS p_vaddr) 1200 is assigned offset round(16, PT_TLS p_align). */ 1201 #define alpha_get_tprel_base(tlss) \ 1202 ((tlss)->start - align_power ((bfd_vma) 16, (tlss)->align)) 1062 1203 1063 1204 … … 1082 1223 #define OP_BR 0x30 1083 1224 #define OP_BSR 0x34 1084 #define INSN_UNOP 0x2fe00000 1225 #define INSN_UNOP 0x2ffe0000 1226 #define INSN_ADDQ 0x40000400 1227 #define INSN_RDUNIQ 0x0000009e 1085 1228 1086 1229 struct alpha_relax_info … … 1089 1232 asection *sec; 1090 1233 bfd_byte *contents; 1234 Elf_Internal_Shdr *symtab_hdr; 1091 1235 Elf_Internal_Rela *relocs, *relend; 1092 1236 struct bfd_link_info *link_info; 1093 boolean changed_contents; 1094 boolean changed_relocs; 1237 struct elf_link_tls_segment *tls_segment; 1095 1238 bfd_vma gp; 1096 1239 bfd *gotobj; 1097 1240 asection *tsec; 1098 1241 struct alpha_elf_link_hash_entry *h; 1242 struct alpha_elf_got_entry **first_gotent; 1099 1243 struct alpha_elf_got_entry *gotent; 1244 bfd_boolean changed_contents; 1245 bfd_boolean changed_relocs; 1100 1246 unsigned char other; 1101 1247 }; 1102 1248 1103 static Elf_Internal_Rela * elf64_alpha_relax_with_lituse 1104 PARAMS((struct alpha_relax_info *info, bfd_vma symval, 1105 Elf_Internal_Rela *irel, Elf_Internal_Rela *irelend)); 1106 1107 static boolean elf64_alpha_relax_without_lituse 1249 static bfd_boolean elf64_alpha_relax_with_lituse 1108 1250 PARAMS((struct alpha_relax_info *info, bfd_vma symval, 1109 1251 Elf_Internal_Rela *irel)); 1110 1111 1252 static bfd_vma elf64_alpha_relax_opt_call 1112 1253 PARAMS((struct alpha_relax_info *info, bfd_vma symval)); 1113 1114 static boolean elf64_alpha_relax_section 1254 static bfd_boolean elf64_alpha_relax_got_load 1255 PARAMS((struct alpha_relax_info *info, bfd_vma symval, 1256 Elf_Internal_Rela *irel, unsigned long)); 1257 static bfd_boolean elf64_alpha_relax_gprelhilo 1258 PARAMS((struct alpha_relax_info *info, bfd_vma symval, 1259 Elf_Internal_Rela *irel, bfd_boolean)); 1260 static bfd_boolean elf64_alpha_relax_tls_get_addr 1261 PARAMS((struct alpha_relax_info *info, bfd_vma symval, 1262 Elf_Internal_Rela *irel, bfd_boolean)); 1263 static struct elf_link_tls_segment *elf64_alpha_relax_find_tls_segment 1264 PARAMS((struct alpha_relax_info *, struct elf_link_tls_segment *)); 1265 static bfd_boolean elf64_alpha_relax_section 1115 1266 PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info, 1116 b oolean *again));1267 bfd_boolean *again)); 1117 1268 1118 1269 static Elf_Internal_Rela * … … 1124 1275 while (rel < relend) 1125 1276 { 1126 if (rel->r_offset == offset && ELF64_R_TYPE (rel->r_info) == type) 1277 if (rel->r_offset == offset 1278 && ELF64_R_TYPE (rel->r_info) == (unsigned int) type) 1127 1279 return rel; 1128 1280 ++rel; … … 1131 1283 } 1132 1284 1133 static Elf_Internal_Rela *1134 elf64_alpha_relax_with_lituse (info, symval, irel , irelend)1285 static bfd_boolean 1286 elf64_alpha_relax_with_lituse (info, symval, irel) 1135 1287 struct alpha_relax_info *info; 1136 1288 bfd_vma symval; 1137 Elf_Internal_Rela *irel , *irelend;1138 { 1139 Elf_Internal_Rela *urel ;1289 Elf_Internal_Rela *irel; 1290 { 1291 Elf_Internal_Rela *urel, *irelend = info->relend; 1140 1292 int flags, count, i; 1141 1293 bfd_signed_vma disp; 1142 b oolean fits16;1143 b oolean fits32;1144 b oolean lit_reused = false;1145 b oolean all_optimized = true;1294 bfd_boolean fits16; 1295 bfd_boolean fits32; 1296 bfd_boolean lit_reused = FALSE; 1297 bfd_boolean all_optimized = TRUE; 1146 1298 unsigned int lit_insn; 1147 1299 … … 1151 1303 ((*_bfd_error_handler) 1152 1304 ("%s: %s+0x%lx: warning: LITERAL relocation against unexpected insn", 1153 bfd_get_filename (info->abfd), info->sec->name, 1154 (unsigned long)irel->r_offset)); 1155 return irel; 1156 } 1305 bfd_archive_filename (info->abfd), info->sec->name, 1306 (unsigned long) irel->r_offset)); 1307 return TRUE; 1308 } 1309 1310 /* Can't relax dynamic symbols. */ 1311 if (alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info)) 1312 return TRUE; 1157 1313 1158 1314 /* Summarize how this particular LITERAL is used. */ … … 1161 1317 if (ELF64_R_TYPE (urel->r_info) != R_ALPHA_LITUSE) 1162 1318 break; 1163 if (urel->r_addend >= 0 && urel->r_addend<= 3)1319 if (urel->r_addend <= 3) 1164 1320 flags |= 1 << urel->r_addend; 1165 1321 } … … 1178 1334 switch (urel->r_addend) 1179 1335 { 1180 default: /* 0 = ADDRESS FORMAT */ 1336 case LITUSE_ALPHA_ADDR: 1337 default: 1181 1338 /* This type is really just a placeholder to note that all 1182 1339 uses cannot be optimized, but to still allow some. */ 1183 all_optimized = false;1340 all_optimized = FALSE; 1184 1341 break; 1185 1342 1186 case 1: /* MEM FORMAT */1343 case LITUSE_ALPHA_BASE: 1187 1344 /* We can always optimize 16-bit displacements. */ 1188 1345 … … 1191 1348 displacement from GP. */ 1192 1349 insn_disp = insn & 0x0000ffff; 1193 if (insn_disp & 0x 00008000)1194 insn_disp |= 0xffff0000; /* Negative: sign-extend. */1350 if (insn_disp & 0x8000) 1351 insn_disp |= ~0xffff; /* Negative: sign-extend. */ 1195 1352 1196 1353 xdisp = disp + insn_disp; 1197 fits16 = (xdisp >= - (bfd_signed_vma) 0x00008000 && xdisp < 0x00008000); 1198 fits32 = (xdisp >= - (bfd_signed_vma) 0x80000000 && xdisp < 0x7fff8000); 1354 fits16 = (xdisp >= - (bfd_signed_vma) 0x8000 && xdisp < 0x8000); 1355 fits32 = (xdisp >= - (bfd_signed_vma) 0x80000000 1356 && xdisp < 0x7fff8000); 1199 1357 1200 1358 if (fits16) … … 1204 1362 insn = (insn & 0xffe0ffff) | (lit_insn & 0x001f0000); 1205 1363 urel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), 1206 R_ALPHA_GPREL LOW);1364 R_ALPHA_GPREL16); 1207 1365 urel->r_addend = irel->r_addend; 1208 info->changed_relocs = true; 1209 1210 bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset); 1211 info->changed_contents = true; 1366 info->changed_relocs = TRUE; 1367 1368 bfd_put_32 (info->abfd, (bfd_vma) insn, 1369 info->contents + urel->r_offset); 1370 info->changed_contents = TRUE; 1212 1371 } 1213 1372 … … 1220 1379 R_ALPHA_GPRELHIGH); 1221 1380 lit_insn = (OP_LDAH << 26) | (lit_insn & 0x03ff0000); 1222 bfd_put_32 (info->abfd, lit_insn,1381 bfd_put_32 (info->abfd, (bfd_vma) lit_insn, 1223 1382 info->contents + irel->r_offset); 1224 lit_reused = true;1225 info->changed_contents = true;1383 lit_reused = TRUE; 1384 info->changed_contents = TRUE; 1226 1385 1227 1386 urel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), 1228 1387 R_ALPHA_GPRELLOW); 1229 1388 urel->r_addend = irel->r_addend; 1230 info->changed_relocs = true;1389 info->changed_relocs = TRUE; 1231 1390 } 1232 1391 else 1233 all_optimized = false;1392 all_optimized = FALSE; 1234 1393 break; 1235 1394 1236 case 2: /* BYTE OFFSET FORMAT */1395 case LITUSE_ALPHA_BYTOFF: 1237 1396 /* We can always optimize byte instructions. */ 1238 1397 … … 1240 1399 literal dest reg is indeed Rb in the byte insn. */ 1241 1400 1242 insn = (insn & ~0x001ff000) | ((symval & 7) << 13) | 0x1000; 1401 insn &= ~ (unsigned) 0x001ff000; 1402 insn |= ((symval & 7) << 13) | 0x1000; 1243 1403 1244 1404 urel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1245 1405 urel->r_addend = 0; 1246 info->changed_relocs = true; 1247 1248 bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset); 1249 info->changed_contents = true; 1406 info->changed_relocs = TRUE; 1407 1408 bfd_put_32 (info->abfd, (bfd_vma) insn, 1409 info->contents + urel->r_offset); 1410 info->changed_contents = TRUE; 1250 1411 break; 1251 1412 1252 case 3: /* CALL FORMAT */ 1413 case LITUSE_ALPHA_JSR: 1414 case LITUSE_ALPHA_TLSGD: 1415 case LITUSE_ALPHA_TLSLDM: 1253 1416 { 1417 bfd_vma optdest, org; 1418 bfd_signed_vma odisp; 1419 1254 1420 /* If not zero, place to jump without needing pv. */ 1255 bfd_vma optdest = elf64_alpha_relax_opt_call (info, symval); 1256 bfd_vma org = (info->sec->output_section->vma 1257 + info->sec->output_offset 1258 + urel->r_offset + 4); 1259 bfd_signed_vma odisp; 1260 1421 optdest = elf64_alpha_relax_opt_call (info, symval); 1422 org = (info->sec->output_section->vma 1423 + info->sec->output_offset 1424 + urel->r_offset + 4); 1261 1425 odisp = (optdest ? optdest : symval) - org; 1426 1262 1427 if (odisp >= -0x400000 && odisp < 0x400000) 1263 1428 { … … 1277 1442 urel->r_addend += optdest - symval; 1278 1443 else 1279 all_optimized = false; 1280 1281 bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset); 1444 all_optimized = FALSE; 1445 1446 bfd_put_32 (info->abfd, (bfd_vma) insn, 1447 info->contents + urel->r_offset); 1282 1448 1283 1449 /* Kill any HINT reloc that might exist for this insn. */ … … 1288 1454 xrel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1289 1455 1290 info->changed_contents = true;1291 info->changed_relocs = true;1456 info->changed_contents = TRUE; 1457 info->changed_relocs = TRUE; 1292 1458 } 1293 1459 else 1294 all_optimized = false; 1295 1296 /* ??? If target gp == current gp we can eliminate the gp reload. 1297 This does depend on every place a gp could be reloaded will 1298 be, which currently happens for all code produced by gcc, but 1299 not necessarily by hand-coded assembly, or if sibling calls 1300 are enabled in gcc. 1301 1302 Perhaps conditionalize this on a flag being set in the target 1303 object file's header, and have gcc set it? */ 1460 all_optimized = FALSE; 1461 1462 /* Even if the target is not in range for a direct branch, 1463 if we share a GP, we can eliminate the gp reload. */ 1464 if (optdest) 1465 { 1466 Elf_Internal_Rela *gpdisp 1467 = (elf64_alpha_find_reloc_at_ofs 1468 (info->relocs, irelend, urel->r_offset + 4, 1469 R_ALPHA_GPDISP)); 1470 if (gpdisp) 1471 { 1472 bfd_byte *p_ldah = info->contents + gpdisp->r_offset; 1473 bfd_byte *p_lda = p_ldah + gpdisp->r_addend; 1474 unsigned int ldah = bfd_get_32 (info->abfd, p_ldah); 1475 unsigned int lda = bfd_get_32 (info->abfd, p_lda); 1476 1477 /* Verify that the instruction is "ldah $29,0($26)". 1478 Consider a function that ends in a noreturn call, 1479 and that the next function begins with an ldgp, 1480 and that by accident there is no padding between. 1481 In that case the insn would use $27 as the base. */ 1482 if (ldah == 0x27ba0000 && lda == 0x23bd0000) 1483 { 1484 bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, p_ldah); 1485 bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, p_lda); 1486 1487 gpdisp->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1488 info->changed_contents = TRUE; 1489 info->changed_relocs = TRUE; 1490 } 1491 } 1492 } 1304 1493 } 1305 1494 break; … … 1311 1500 if (all_optimized) 1312 1501 { 1313 info->gotent->use_count -= 1; 1314 alpha_elf_tdata (info->gotent->gotobj)->total_got_entries -= 1; 1315 if (!info->h) 1316 alpha_elf_tdata (info->gotent->gotobj)->n_local_got_entries -= 1; 1502 if (--info->gotent->use_count == 0) 1503 { 1504 int sz = alpha_got_entry_size (R_ALPHA_LITERAL); 1505 alpha_elf_tdata (info->gotobj)->total_got_size -= sz; 1506 if (!info->h) 1507 alpha_elf_tdata (info->gotobj)->local_got_size -= sz; 1508 } 1317 1509 1318 1510 /* If the literal instruction is no longer needed (it may have been 1319 reused. We can eliminate it. 1320 1511 reused. We can eliminate it. */ 1512 /* ??? For now, I don't want to deal with compacting the section, 1321 1513 so just nop it out. */ 1322 1514 if (!lit_reused) 1323 1515 { 1324 1516 irel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1325 info->changed_relocs = true; 1326 1327 bfd_put_32 (info->abfd, INSN_UNOP, info->contents + irel->r_offset); 1328 info->changed_contents = true; 1329 } 1330 } 1331 1332 return irel + count; 1517 info->changed_relocs = TRUE; 1518 1519 bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, 1520 info->contents + irel->r_offset); 1521 info->changed_contents = TRUE; 1522 } 1523 } 1524 1525 return TRUE; 1333 1526 } 1334 1527 … … 1405 1598 } 1406 1599 1407 static b oolean1408 elf64_alpha_relax_ without_lituse (info, symval, irel)1600 static bfd_boolean 1601 elf64_alpha_relax_got_load (info, symval, irel, r_type) 1409 1602 struct alpha_relax_info *info; 1410 1603 bfd_vma symval; 1411 1604 Elf_Internal_Rela *irel; 1605 unsigned long r_type; 1412 1606 { 1413 1607 unsigned int insn; … … 1419 1613 if (insn >> 26 != OP_LDQ) 1420 1614 { 1615 reloc_howto_type *howto = elf64_alpha_howto_table + r_type; 1421 1616 ((*_bfd_error_handler) 1422 ("%s: %s+0x%lx: warning: LITERAL relocation against unexpected insn", 1423 bfd_get_filename (info->abfd), info->sec->name, 1424 (unsigned long) irel->r_offset)); 1425 return true; 1426 } 1427 1428 /* So we aren't told much. Do what we can with the address load and 1429 fake the rest. All of the optimizations here require that the 1430 offset from the GP fit in 16 bits. */ 1431 1432 disp = symval - info->gp; 1617 ("%s: %s+0x%lx: warning: %s relocation against unexpected insn", 1618 bfd_archive_filename (info->abfd), info->sec->name, 1619 (unsigned long) irel->r_offset, howto->name)); 1620 return TRUE; 1621 } 1622 1623 /* Can't relax dynamic symbols. */ 1624 if (alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info)) 1625 return TRUE; 1626 1627 /* Can't use local-exec relocations in shared libraries. */ 1628 if (r_type == R_ALPHA_GOTTPREL && info->link_info->shared) 1629 return TRUE; 1630 1631 if (r_type == R_ALPHA_LITERAL) 1632 disp = symval - info->gp; 1633 else 1634 { 1635 bfd_vma dtp_base, tp_base; 1636 1637 BFD_ASSERT (info->tls_segment != NULL); 1638 dtp_base = alpha_get_dtprel_base (info->tls_segment); 1639 tp_base = alpha_get_tprel_base (info->tls_segment); 1640 disp = symval - (r_type == R_ALPHA_GOTDTPREL ? dtp_base : tp_base); 1641 } 1642 1433 1643 if (disp < -0x8000 || disp >= 0x8000) 1434 return true; 1435 1436 /* On the LITERAL instruction itself, consider exchanging 1437 `ldq R,X(gp)' for `lda R,Y(gp)'. */ 1438 1439 insn = (OP_LDA << 26) | (insn & 0x03ff0000); 1440 bfd_put_32 (info->abfd, insn, info->contents + irel->r_offset); 1441 info->changed_contents = true; 1442 1443 irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), R_ALPHA_GPRELLOW); 1444 info->changed_relocs = true; 1644 return TRUE; 1645 1646 /* Exchange LDQ for LDA. In the case of the TLS relocs, we're loading 1647 a constant, so force the base register to be $31. */ 1648 if (r_type == R_ALPHA_LITERAL) 1649 insn = (OP_LDA << 26) | (insn & 0x03ff0000); 1650 else 1651 insn = (OP_LDA << 26) | (insn & (31 << 21)) | (31 << 16); 1652 bfd_put_32 (info->abfd, (bfd_vma) insn, info->contents + irel->r_offset); 1653 info->changed_contents = TRUE; 1445 1654 1446 1655 /* Reduce the use count on this got entry by one, possibly 1447 1656 eliminating it. */ 1448 info->gotent->use_count -= 1; 1449 alpha_elf_tdata (info->gotent->gotobj)->total_got_entries -= 1; 1450 if (!info->h) 1451 alpha_elf_tdata (info->gotent->gotobj)->n_local_got_entries -= 1; 1657 if (--info->gotent->use_count == 0) 1658 { 1659 int sz = alpha_got_entry_size (r_type); 1660 alpha_elf_tdata (info->gotobj)->total_got_size -= sz; 1661 if (!info->h) 1662 alpha_elf_tdata (info->gotobj)->local_got_size -= sz; 1663 } 1664 1665 /* Smash the existing GOT relocation for its 16-bit immediate pair. */ 1666 switch (r_type) 1667 { 1668 case R_ALPHA_LITERAL: 1669 r_type = R_ALPHA_GPREL16; 1670 break; 1671 case R_ALPHA_GOTDTPREL: 1672 r_type = R_ALPHA_DTPREL16; 1673 break; 1674 case R_ALPHA_GOTTPREL: 1675 r_type = R_ALPHA_TPREL16; 1676 break; 1677 default: 1678 BFD_ASSERT (0); 1679 return FALSE; 1680 } 1681 1682 irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), r_type); 1683 info->changed_relocs = TRUE; 1452 1684 1453 1685 /* ??? Search forward through this basic block looking for insns … … 1464 1696 which gives one pause. */ 1465 1697 1466 return true;1698 return TRUE; 1467 1699 } 1468 1700 1469 static boolean 1701 static bfd_boolean 1702 elf64_alpha_relax_gprelhilo (info, symval, irel, hi) 1703 struct alpha_relax_info *info; 1704 bfd_vma symval; 1705 Elf_Internal_Rela *irel; 1706 bfd_boolean hi; 1707 { 1708 unsigned int insn; 1709 bfd_signed_vma disp; 1710 bfd_byte *pos = info->contents + irel->r_offset; 1711 1712 /* ??? This assumes that the compiler doesn't render 1713 1714 array[i] 1715 as 1716 ldah t, array(gp) !gprelhigh 1717 s8addl i, t, t 1718 ldq r, array(t) !gprellow 1719 1720 which would indeed be the most efficient way to implement this. */ 1721 1722 return TRUE; 1723 1724 disp = symval - info->gp; 1725 if (disp < -0x8000 || disp >= 0x8000) 1726 return TRUE; 1727 1728 if (hi) 1729 { 1730 /* Nop out the high instruction. */ 1731 1732 bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos); 1733 info->changed_contents = TRUE; 1734 1735 irel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1736 irel->r_addend = 0; 1737 info->changed_relocs = TRUE; 1738 } 1739 else 1740 { 1741 /* Adjust the low instruction to reference GP directly. */ 1742 1743 insn = bfd_get_32 (info->abfd, pos); 1744 insn = (insn & 0xffe00000) | (29 << 16); 1745 bfd_put_32 (info->abfd, (bfd_vma) insn, pos); 1746 info->changed_contents = TRUE; 1747 1748 irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), 1749 R_ALPHA_GPREL16); 1750 info->changed_relocs = TRUE; 1751 } 1752 1753 return TRUE; 1754 } 1755 1756 static bfd_boolean 1757 elf64_alpha_relax_tls_get_addr (info, symval, irel, is_gd) 1758 struct alpha_relax_info *info; 1759 bfd_vma symval; 1760 Elf_Internal_Rela *irel; 1761 bfd_boolean is_gd; 1762 { 1763 bfd_byte *pos[5]; 1764 unsigned int insn; 1765 Elf_Internal_Rela *gpdisp, *hint; 1766 bfd_boolean dynamic, use_gottprel, pos1_unusable; 1767 unsigned long new_symndx; 1768 1769 dynamic = alpha_elf_dynamic_symbol_p (&info->h->root, info->link_info); 1770 1771 /* If a TLS symbol is accessed using IE at least once, there is no point 1772 to use dynamic model for it. */ 1773 if (is_gd && info->h && (info->h->flags & ALPHA_ELF_LINK_HASH_TLS_IE)) 1774 ; 1775 1776 /* If the symbol is local, and we've already committed to DF_STATIC_TLS, 1777 then we might as well relax to IE. */ 1778 else if (info->link_info->shared && !dynamic 1779 && (info->link_info->flags & DF_STATIC_TLS)) 1780 ; 1781 1782 /* Otherwise we must be building an executable to do anything. */ 1783 else if (info->link_info->shared) 1784 return TRUE; 1785 1786 /* The TLSGD/TLSLDM relocation must be followed by a LITERAL and 1787 the matching LITUSE_TLS relocations. */ 1788 if (irel + 2 >= info->relend) 1789 return TRUE; 1790 if (ELF64_R_TYPE (irel[1].r_info) != R_ALPHA_LITERAL 1791 || ELF64_R_TYPE (irel[2].r_info) != R_ALPHA_LITUSE 1792 || irel[2].r_addend != (is_gd ? LITUSE_ALPHA_TLSGD : LITUSE_ALPHA_TLSLDM)) 1793 return TRUE; 1794 1795 /* There must be a GPDISP relocation positioned immediately after the 1796 LITUSE relocation. */ 1797 gpdisp = elf64_alpha_find_reloc_at_ofs (info->relocs, info->relend, 1798 irel[2].r_offset + 4, R_ALPHA_GPDISP); 1799 if (!gpdisp) 1800 return TRUE; 1801 1802 pos[0] = info->contents + irel[0].r_offset; 1803 pos[1] = info->contents + irel[1].r_offset; 1804 pos[2] = info->contents + irel[2].r_offset; 1805 pos[3] = info->contents + gpdisp->r_offset; 1806 pos[4] = pos[3] + gpdisp->r_addend; 1807 pos1_unusable = FALSE; 1808 1809 /* Generally, the positions are not allowed to be out of order, lest the 1810 modified insn sequence have different register lifetimes. We can make 1811 an exception when pos 1 is adjacent to pos 0. */ 1812 if (pos[1] + 4 == pos[0]) 1813 { 1814 bfd_byte *tmp = pos[0]; 1815 pos[0] = pos[1]; 1816 pos[1] = tmp; 1817 } 1818 else if (pos[1] < pos[0]) 1819 pos1_unusable = TRUE; 1820 if (pos[1] >= pos[2] || pos[2] >= pos[3]) 1821 return TRUE; 1822 1823 /* Reduce the use count on the LITERAL relocation. Do this before we 1824 smash the symndx when we adjust the relocations below. */ 1825 { 1826 struct alpha_elf_got_entry *lit_gotent; 1827 struct alpha_elf_link_hash_entry *lit_h; 1828 unsigned long indx; 1829 1830 BFD_ASSERT (ELF64_R_SYM (irel[1].r_info) >= info->symtab_hdr->sh_info); 1831 indx = ELF64_R_SYM (irel[1].r_info) - info->symtab_hdr->sh_info; 1832 lit_h = alpha_elf_sym_hashes (info->abfd)[indx]; 1833 1834 while (lit_h->root.root.type == bfd_link_hash_indirect 1835 || lit_h->root.root.type == bfd_link_hash_warning) 1836 lit_h = (struct alpha_elf_link_hash_entry *) lit_h->root.root.u.i.link; 1837 1838 for (lit_gotent = lit_h->got_entries; lit_gotent ; 1839 lit_gotent = lit_gotent->next) 1840 if (lit_gotent->gotobj == info->gotobj 1841 && lit_gotent->reloc_type == R_ALPHA_LITERAL 1842 && lit_gotent->addend == irel[1].r_addend) 1843 break; 1844 BFD_ASSERT (lit_gotent); 1845 1846 if (--lit_gotent->use_count == 0) 1847 { 1848 int sz = alpha_got_entry_size (R_ALPHA_LITERAL); 1849 alpha_elf_tdata (info->gotobj)->total_got_size -= sz; 1850 } 1851 } 1852 1853 /* Change 1854 1855 lda $16,x($gp) !tlsgd!1 1856 ldq $27,__tls_get_addr($gp) !literal!1 1857 jsr $26,($27)__tls_get_addr !lituse_tlsgd!1 1858 ldah $29,0($26) !gpdisp!2 1859 lda $29,0($29) !gpdisp!2 1860 to 1861 ldq $16,x($gp) !gottprel 1862 unop 1863 call_pal rduniq 1864 addq $16,$0,$0 1865 unop 1866 or the first pair to 1867 lda $16,x($gp) !tprel 1868 unop 1869 or 1870 ldah $16,x($gp) !tprelhi 1871 lda $16,x($16) !tprello 1872 1873 as appropriate. */ 1874 1875 use_gottprel = FALSE; 1876 new_symndx = is_gd ? ELF64_R_SYM (irel->r_info) : 0; 1877 switch (!dynamic && !info->link_info->shared) 1878 { 1879 case 1: 1880 { 1881 bfd_vma tp_base; 1882 bfd_signed_vma disp; 1883 1884 BFD_ASSERT (info->tls_segment != NULL); 1885 tp_base = alpha_get_tprel_base (info->tls_segment); 1886 disp = symval - tp_base; 1887 1888 if (disp >= -0x8000 && disp < 0x8000) 1889 { 1890 insn = (OP_LDA << 26) | (16 << 21) | (31 << 16); 1891 bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]); 1892 bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]); 1893 1894 irel[0].r_offset = pos[0] - info->contents; 1895 irel[0].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_TPREL16); 1896 irel[1].r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1897 break; 1898 } 1899 else if (disp >= -(bfd_signed_vma) 0x80000000 1900 && disp < (bfd_signed_vma) 0x7fff8000 1901 && !pos1_unusable) 1902 { 1903 insn = (OP_LDAH << 26) | (16 << 21) | (31 << 16); 1904 bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]); 1905 insn = (OP_LDA << 26) | (16 << 21) | (16 << 16); 1906 bfd_put_32 (info->abfd, (bfd_vma) insn, pos[1]); 1907 1908 irel[0].r_offset = pos[0] - info->contents; 1909 irel[0].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_TPRELHI); 1910 irel[1].r_offset = pos[1] - info->contents; 1911 irel[1].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_TPRELLO); 1912 break; 1913 } 1914 } 1915 /* FALLTHRU */ 1916 1917 default: 1918 use_gottprel = TRUE; 1919 1920 insn = (OP_LDQ << 26) | (16 << 21) | (29 << 16); 1921 bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]); 1922 bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]); 1923 1924 irel[0].r_offset = pos[0] - info->contents; 1925 irel[0].r_info = ELF64_R_INFO (new_symndx, R_ALPHA_GOTTPREL); 1926 irel[1].r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1927 break; 1928 } 1929 1930 bfd_put_32 (info->abfd, (bfd_vma) INSN_RDUNIQ, pos[2]); 1931 1932 insn = INSN_ADDQ | (16 << 21) | (0 << 16) | (0 << 0); 1933 bfd_put_32 (info->abfd, (bfd_vma) insn, pos[3]); 1934 1935 bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[4]); 1936 1937 irel[2].r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1938 gpdisp->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1939 1940 hint = elf64_alpha_find_reloc_at_ofs (info->relocs, info->relend, 1941 irel[2].r_offset, R_ALPHA_HINT); 1942 if (hint) 1943 hint->r_info = ELF64_R_INFO (0, R_ALPHA_NONE); 1944 1945 info->changed_contents = TRUE; 1946 info->changed_relocs = TRUE; 1947 1948 /* Reduce the use count on the TLSGD/TLSLDM relocation. */ 1949 if (--info->gotent->use_count == 0) 1950 { 1951 int sz = alpha_got_entry_size (info->gotent->reloc_type); 1952 alpha_elf_tdata (info->gotobj)->total_got_size -= sz; 1953 if (!info->h) 1954 alpha_elf_tdata (info->gotobj)->local_got_size -= sz; 1955 } 1956 1957 /* If we've switched to a GOTTPREL relocation, increment the reference 1958 count on that got entry. */ 1959 if (use_gottprel) 1960 { 1961 struct alpha_elf_got_entry *tprel_gotent; 1962 1963 for (tprel_gotent = *info->first_gotent; tprel_gotent ; 1964 tprel_gotent = tprel_gotent->next) 1965 if (tprel_gotent->gotobj == info->gotobj 1966 && tprel_gotent->reloc_type == R_ALPHA_GOTTPREL 1967 && tprel_gotent->addend == irel->r_addend) 1968 break; 1969 if (tprel_gotent) 1970 tprel_gotent->use_count++; 1971 else 1972 { 1973 if (info->gotent->use_count == 0) 1974 tprel_gotent = info->gotent; 1975 else 1976 { 1977 tprel_gotent = (struct alpha_elf_got_entry *) 1978 bfd_alloc (info->abfd, sizeof (struct alpha_elf_got_entry)); 1979 if (!tprel_gotent) 1980 return FALSE; 1981 1982 tprel_gotent->next = *info->first_gotent; 1983 *info->first_gotent = tprel_gotent; 1984 1985 tprel_gotent->gotobj = info->gotobj; 1986 tprel_gotent->addend = irel->r_addend; 1987 tprel_gotent->got_offset = -1; 1988 tprel_gotent->reloc_done = 0; 1989 tprel_gotent->reloc_xlated = 0; 1990 } 1991 1992 tprel_gotent->use_count = 1; 1993 tprel_gotent->reloc_type = R_ALPHA_GOTTPREL; 1994 } 1995 } 1996 1997 return TRUE; 1998 } 1999 2000 static struct elf_link_tls_segment * 2001 elf64_alpha_relax_find_tls_segment (info, seg) 2002 struct alpha_relax_info *info; 2003 struct elf_link_tls_segment *seg; 2004 { 2005 bfd *output_bfd = info->sec->output_section->owner; 2006 asection *o; 2007 unsigned int align; 2008 bfd_vma base, end; 2009 2010 for (o = output_bfd->sections; o ; o = o->next) 2011 if ((o->flags & SEC_THREAD_LOCAL) != 0 2012 && (o->flags & SEC_LOAD) != 0) 2013 break; 2014 if (!o) 2015 return NULL; 2016 2017 base = o->vma; 2018 align = 0; 2019 2020 do 2021 { 2022 bfd_vma size; 2023 2024 if (bfd_get_section_alignment (output_bfd, o) > align) 2025 align = bfd_get_section_alignment (output_bfd, o); 2026 2027 size = o->_raw_size; 2028 if (size == 0 && (o->flags & SEC_HAS_CONTENTS) == 0) 2029 { 2030 struct bfd_link_order *lo; 2031 for (lo = o->link_order_head; lo ; lo = lo->next) 2032 if (size < lo->offset + lo->size) 2033 size = lo->offset + lo->size; 2034 } 2035 end = o->vma + size; 2036 o = o->next; 2037 } 2038 while (o && (o->flags & SEC_THREAD_LOCAL)); 2039 2040 seg->start = base; 2041 seg->size = end - base; 2042 seg->align = align; 2043 2044 return seg; 2045 } 2046 2047 static bfd_boolean 1470 2048 elf64_alpha_relax_section (abfd, sec, link_info, again) 1471 2049 bfd *abfd; 1472 2050 asection *sec; 1473 2051 struct bfd_link_info *link_info; 1474 b oolean *again;2052 bfd_boolean *again; 1475 2053 { 1476 2054 Elf_Internal_Shdr *symtab_hdr; 1477 2055 Elf_Internal_Rela *internal_relocs; 1478 Elf_Internal_Rela *free_relocs = NULL;1479 2056 Elf_Internal_Rela *irel, *irelend; 1480 bfd_byte *free_contents = NULL; 1481 Elf64_External_Sym *extsyms = NULL; 1482 Elf64_External_Sym *free_extsyms = NULL; 2057 Elf_Internal_Sym *isymbuf = NULL; 1483 2058 struct alpha_elf_got_entry **local_got_entries; 1484 2059 struct alpha_relax_info info; 2060 struct elf_link_tls_segment tls_segment; 1485 2061 1486 2062 /* We are not currently changing any sizes, so only one pass. */ 1487 *again = false;2063 *again = FALSE; 1488 2064 1489 2065 if (link_info->relocateable 1490 2066 || (sec->flags & SEC_RELOC) == 0 1491 2067 || sec->reloc_count == 0) 1492 return true;2068 return TRUE; 1493 2069 1494 2070 /* If this is the first time we have been called for this section, … … 1505 2081 link_info->keep_memory)); 1506 2082 if (internal_relocs == NULL) 1507 goto error_return; 1508 if (! link_info->keep_memory) 1509 free_relocs = internal_relocs; 2083 return FALSE; 1510 2084 1511 2085 memset(&info, 0, sizeof (info)); … … 1513 2087 info.sec = sec; 1514 2088 info.link_info = link_info; 2089 info.symtab_hdr = symtab_hdr; 1515 2090 info.relocs = internal_relocs; 1516 2091 info.relend = irelend = internal_relocs + sec->reloc_count; 1517 2092 1518 /* Find the GP for this object. */ 2093 /* Find the GP for this object. Do not store the result back via 2094 _bfd_set_gp_value, since this could change again before final. */ 1519 2095 info.gotobj = alpha_elf_tdata (abfd)->gotobj; 1520 2096 if (info.gotobj) 1521 2097 { 1522 2098 asection *sgot = alpha_elf_tdata (info.gotobj)->got; 1523 info.gp = _bfd_get_gp_value (info.gotobj); 1524 if (info.gp == 0) 1525 { 1526 info.gp = (sgot->output_section->vma 1527 + sgot->output_offset 1528 + 0x8000); 1529 _bfd_set_gp_value (info.gotobj, info.gp); 1530 } 1531 } 2099 info.gp = (sgot->output_section->vma 2100 + sgot->output_offset 2101 + 0x8000); 2102 } 2103 2104 /* Get the section contents. */ 2105 if (elf_section_data (sec)->this_hdr.contents != NULL) 2106 info.contents = elf_section_data (sec)->this_hdr.contents; 2107 else 2108 { 2109 info.contents = (bfd_byte *) bfd_malloc (sec->_raw_size); 2110 if (info.contents == NULL) 2111 goto error_return; 2112 2113 if (! bfd_get_section_contents (abfd, sec, info.contents, 2114 (file_ptr) 0, sec->_raw_size)) 2115 goto error_return; 2116 } 2117 2118 /* Compute the TLS segment information. The version normally found in 2119 elf_hash_table (link_info)->tls_segment isn't built until final_link. 2120 ??? Probably should look into extracting this into a common function. */ 2121 info.tls_segment = elf64_alpha_relax_find_tls_segment (&info, &tls_segment); 1532 2122 1533 2123 for (irel = internal_relocs; irel < irelend; irel++) 1534 2124 { 1535 2125 bfd_vma symval; 1536 Elf_Internal_Sym isym;1537 2126 struct alpha_elf_got_entry *gotent; 1538 1539 if (ELF64_R_TYPE (irel->r_info) != (int) R_ALPHA_LITERAL) 1540 continue; 1541 1542 /* Get the section contents. */ 1543 if (info.contents == NULL) 1544 { 1545 if (elf_section_data (sec)->this_hdr.contents != NULL) 1546 info.contents = elf_section_data (sec)->this_hdr.contents; 2127 unsigned long r_type = ELF64_R_TYPE (irel->r_info); 2128 unsigned long r_symndx = ELF64_R_SYM (irel->r_info); 2129 2130 /* Early exit for unhandled or unrelaxable relocations. */ 2131 switch (r_type) 2132 { 2133 case R_ALPHA_LITERAL: 2134 case R_ALPHA_GPRELHIGH: 2135 case R_ALPHA_GPRELLOW: 2136 case R_ALPHA_GOTDTPREL: 2137 case R_ALPHA_GOTTPREL: 2138 case R_ALPHA_TLSGD: 2139 break; 2140 2141 case R_ALPHA_TLSLDM: 2142 /* The symbol for a TLSLDM reloc is ignored. Collapse the 2143 reloc to the 0 symbol so that they all match. */ 2144 r_symndx = 0; 2145 break; 2146 2147 default: 2148 continue; 2149 } 2150 2151 /* Get the value of the symbol referred to by the reloc. */ 2152 if (r_symndx < symtab_hdr->sh_info) 2153 { 2154 /* A local symbol. */ 2155 Elf_Internal_Sym *isym; 2156 2157 /* Read this BFD's local symbols. */ 2158 if (isymbuf == NULL) 2159 { 2160 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; 2161 if (isymbuf == NULL) 2162 isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr, 2163 symtab_hdr->sh_info, 0, 2164 NULL, NULL, NULL); 2165 if (isymbuf == NULL) 2166 goto error_return; 2167 } 2168 2169 isym = isymbuf + r_symndx; 2170 2171 /* Given the symbol for a TLSLDM reloc is ignored, this also 2172 means forcing the symbol value to the tp base. */ 2173 if (r_type == R_ALPHA_TLSLDM) 2174 { 2175 info.tsec = bfd_abs_section_ptr; 2176 symval = alpha_get_tprel_base (info.tls_segment); 2177 } 1547 2178 else 1548 2179 { 1549 info.contents = (bfd_byte *) bfd_malloc (sec->_raw_size); 1550 if (info.contents == NULL) 1551 goto error_return; 1552 free_contents = info.contents; 1553 1554 if (! bfd_get_section_contents (abfd, sec, info.contents, 1555 (file_ptr) 0, sec->_raw_size)) 1556 goto error_return; 2180 symval = isym->st_value; 2181 if (isym->st_shndx == SHN_UNDEF) 2182 continue; 2183 else if (isym->st_shndx == SHN_ABS) 2184 info.tsec = bfd_abs_section_ptr; 2185 else if (isym->st_shndx == SHN_COMMON) 2186 info.tsec = bfd_com_section_ptr; 2187 else 2188 info.tsec = bfd_section_from_elf_index (abfd, isym->st_shndx); 1557 2189 } 1558 } 1559 1560 /* Read this BFD's symbols if we haven't done so already. */ 1561 if (extsyms == NULL) 1562 { 1563 if (symtab_hdr->contents != NULL) 1564 extsyms = (Elf64_External_Sym *) symtab_hdr->contents; 2190 2191 info.h = NULL; 2192 info.other = isym->st_other; 2193 if (local_got_entries) 2194 info.first_gotent = &local_got_entries[r_symndx]; 1565 2195 else 1566 2196 { 1567 extsyms = ((Elf64_External_Sym *) 1568 bfd_malloc (symtab_hdr->sh_size)); 1569 if (extsyms == NULL) 1570 goto error_return; 1571 free_extsyms = extsyms; 1572 if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 1573 || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd) 1574 != symtab_hdr->sh_size)) 1575 goto error_return; 2197 info.first_gotent = &info.gotent; 2198 info.gotent = NULL; 1576 2199 } 1577 }1578 1579 /* Get the value of the symbol referred to by the reloc. */1580 if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)1581 {1582 /* A local symbol. */1583 bfd_elf64_swap_symbol_in (abfd,1584 extsyms + ELF64_R_SYM (irel->r_info),1585 &isym);1586 if (isym.st_shndx == SHN_UNDEF)1587 info.tsec = bfd_und_section_ptr;1588 else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE)1589 info.tsec = bfd_section_from_elf_index (abfd, isym.st_shndx);1590 else if (isym.st_shndx == SHN_ABS)1591 info.tsec = bfd_abs_section_ptr;1592 else if (isym.st_shndx == SHN_COMMON)1593 info.tsec = bfd_com_section_ptr;1594 else1595 continue; /* who knows. */1596 1597 info.h = NULL;1598 info.other = isym.st_other;1599 gotent = local_got_entries[ELF64_R_SYM(irel->r_info)];1600 symval = isym.st_value;1601 2200 } 1602 2201 else … … 1605 2204 struct alpha_elf_link_hash_entry *h; 1606 2205 1607 indx = ELF64_R_SYM (irel->r_info)- symtab_hdr->sh_info;2206 indx = r_symndx - symtab_hdr->sh_info; 1608 2207 h = alpha_elf_sym_hashes (abfd)[indx]; 1609 2208 BFD_ASSERT (h != NULL); … … 1613 2212 h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link; 1614 2213 1615 /* We can't do anthing with undefined or dynamic symbols. */ 1616 if (h->root.root.type == bfd_link_hash_undefined 1617 || h->root.root.type == bfd_link_hash_undefweak 1618 || alpha_elf_dynamic_symbol_p (&h->root, link_info)) 2214 /* If the symbol is undefined, we can't do anything with it. */ 2215 if (h->root.root.type == bfd_link_hash_undefweak 2216 || h->root.root.type == bfd_link_hash_undefined) 1619 2217 continue; 1620 2218 2219 /* If the symbol isn't defined in the current module, again 2220 we can't do anything. */ 2221 if (!(h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) 2222 { 2223 /* Except for TLSGD relocs, which can sometimes be 2224 relaxed to GOTTPREL relocs. */ 2225 if (r_type != R_ALPHA_TLSGD) 2226 continue; 2227 info.tsec = bfd_abs_section_ptr; 2228 symval = 0; 2229 } 2230 else 2231 { 2232 info.tsec = h->root.root.u.def.section; 2233 symval = h->root.root.u.def.value; 2234 } 2235 1621 2236 info.h = h; 1622 info.gotent = gotent;1623 info.tsec = h->root.root.u.def.section;1624 2237 info.other = h->root.other; 1625 gotent = h->got_entries; 1626 symval = h->root.root.u.def.value; 2238 info.first_gotent = &h->got_entries; 1627 2239 } 1628 2240 1629 2241 /* Search for the got entry to be used by this relocation. */ 1630 while (gotent->gotobj != info.gotobj || gotent->addend != irel->r_addend) 1631 gotent = gotent->next; 2242 for (gotent = *info.first_gotent; gotent ; gotent = gotent->next) 2243 if (gotent->gotobj == info.gotobj 2244 && gotent->reloc_type == r_type 2245 && gotent->addend == irel->r_addend) 2246 break; 1632 2247 info.gotent = gotent; 1633 2248 … … 1635 2250 symval += irel->r_addend; 1636 2251 1637 BFD_ASSERT(info.gotent != NULL); 1638 1639 /* If there exist LITUSE relocations immediately following, this 1640 opens up all sorts of interesting optimizations, because we 1641 now know every location that this address load is used. */ 1642 1643 if (irel+1 < irelend && ELF64_R_TYPE (irel[1].r_info) == R_ALPHA_LITUSE) 1644 { 1645 irel = elf64_alpha_relax_with_lituse (&info, symval, irel, irelend); 1646 if (irel == NULL) 2252 switch (r_type) 2253 { 2254 case R_ALPHA_LITERAL: 2255 BFD_ASSERT(info.gotent != NULL); 2256 2257 /* If there exist LITUSE relocations immediately following, this 2258 opens up all sorts of interesting optimizations, because we 2259 now know every location that this address load is used. */ 2260 if (irel+1 < irelend 2261 && ELF64_R_TYPE (irel[1].r_info) == R_ALPHA_LITUSE) 2262 { 2263 if (!elf64_alpha_relax_with_lituse (&info, symval, irel)) 2264 goto error_return; 2265 } 2266 else 2267 { 2268 if (!elf64_alpha_relax_got_load (&info, symval, irel, r_type)) 2269 goto error_return; 2270 } 2271 break; 2272 2273 case R_ALPHA_GPRELHIGH: 2274 case R_ALPHA_GPRELLOW: 2275 if (!elf64_alpha_relax_gprelhilo (&info, symval, irel, 2276 r_type == R_ALPHA_GPRELHIGH)) 1647 2277 goto error_return; 1648 } 2278 break; 2279 2280 case R_ALPHA_GOTDTPREL: 2281 case R_ALPHA_GOTTPREL: 2282 BFD_ASSERT(info.gotent != NULL); 2283 if (!elf64_alpha_relax_got_load (&info, symval, irel, r_type)) 2284 goto error_return; 2285 break; 2286 2287 case R_ALPHA_TLSGD: 2288 case R_ALPHA_TLSLDM: 2289 BFD_ASSERT(info.gotent != NULL); 2290 if (!elf64_alpha_relax_tls_get_addr (&info, symval, irel, 2291 r_type == R_ALPHA_TLSGD)) 2292 goto error_return; 2293 break; 2294 } 2295 } 2296 2297 if (!elf64_alpha_size_plt_section (link_info)) 2298 return FALSE; 2299 if (!elf64_alpha_size_got_sections (link_info)) 2300 return FALSE; 2301 if (!elf64_alpha_size_rela_got_section (link_info)) 2302 return FALSE; 2303 2304 if (isymbuf != NULL 2305 && symtab_hdr->contents != (unsigned char *) isymbuf) 2306 { 2307 if (!link_info->keep_memory) 2308 free (isymbuf); 1649 2309 else 1650 2310 { 1651 if (!elf64_alpha_relax_without_lituse (&info, symval, irel)) 1652 goto error_return; 1653 } 1654 } 1655 1656 if (!elf64_alpha_size_got_sections (abfd, link_info)) 1657 return false; 1658 1659 if (info.changed_relocs) 1660 { 1661 elf_section_data (sec)->relocs = internal_relocs; 1662 } 1663 else if (free_relocs != NULL) 1664 { 1665 free (free_relocs); 1666 } 1667 1668 if (info.changed_contents) 1669 { 1670 elf_section_data (sec)->this_hdr.contents = info.contents; 1671 } 1672 else if (free_contents != NULL) 1673 { 1674 if (! link_info->keep_memory) 1675 free (free_contents); 2311 /* Cache the symbols for elf_link_input_bfd. */ 2312 symtab_hdr->contents = (unsigned char *) isymbuf; 2313 } 2314 } 2315 2316 if (info.contents != NULL 2317 && elf_section_data (sec)->this_hdr.contents != info.contents) 2318 { 2319 if (!info.changed_contents && !link_info->keep_memory) 2320 free (info.contents); 1676 2321 else 1677 2322 { … … 1681 2326 } 1682 2327 1683 if ( free_extsyms != NULL)1684 { 1685 if (! link_info->keep_memory)1686 free ( free_extsyms);2328 if (elf_section_data (sec)->relocs != internal_relocs) 2329 { 2330 if (!info.changed_relocs) 2331 free (internal_relocs); 1687 2332 else 1688 { 1689 /* Cache the symbols for elf_link_input_bfd. */ 1690 symtab_hdr->contents = extsyms; 1691 } 2333 elf_section_data (sec)->relocs = internal_relocs; 1692 2334 } 1693 2335 1694 2336 *again = info.changed_contents || info.changed_relocs; 1695 2337 1696 return true;2338 return TRUE; 1697 2339 1698 2340 error_return: 1699 if (free_relocs != NULL) 1700 free (free_relocs); 1701 if (free_contents != NULL) 1702 free (free_contents); 1703 if (free_extsyms != NULL) 1704 free (free_extsyms); 1705 return false; 2341 if (isymbuf != NULL 2342 && symtab_hdr->contents != (unsigned char *) isymbuf) 2343 free (isymbuf); 2344 if (info.contents != NULL 2345 && elf_section_data (sec)->this_hdr.contents != info.contents) 2346 free (info.contents); 2347 if (internal_relocs != NULL 2348 && elf_section_data (sec)->relocs != internal_relocs) 2349 free (internal_relocs); 2350 return FALSE; 1706 2351 } 1707 2352 … … 1709 2354 /* PLT/GOT Stuff */ 1710 2355 #define PLT_HEADER_SIZE 32 1711 #define PLT_HEADER_WORD1 0xc3600000 /* br $27,.+4 */1712 #define PLT_HEADER_WORD2 0xa77b000c /* ldq $27,12($27) */1713 #define PLT_HEADER_WORD3 0x47ff041f /* nop */1714 #define PLT_HEADER_WORD4 0x6b7b0000 /* jmp $27,($27) */2356 #define PLT_HEADER_WORD1 (bfd_vma) 0xc3600000 /* br $27,.+4 */ 2357 #define PLT_HEADER_WORD2 (bfd_vma) 0xa77b000c /* ldq $27,12($27) */ 2358 #define PLT_HEADER_WORD3 (bfd_vma) 0x47ff041f /* nop */ 2359 #define PLT_HEADER_WORD4 (bfd_vma) 0x6b7b0000 /* jmp $27,($27) */ 1715 2360 1716 2361 #define PLT_ENTRY_SIZE 12 … … 1719 2364 #define PLT_ENTRY_WORD3 0 1720 2365 1721 #define MAX_GOT_ ENTRIES (64*1024 / 8)2366 #define MAX_GOT_SIZE (64*1024) 1722 2367 1723 2368 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so" … … 1729 2374 how to. */ 1730 2375 1731 static b oolean2376 static bfd_boolean 1732 2377 elf64_alpha_section_from_shdr (abfd, hdr, name) 1733 2378 bfd *abfd; 1734 Elf 64_Internal_Shdr *hdr;1735 c har *name;2379 Elf_Internal_Shdr *hdr; 2380 const char *name; 1736 2381 { 1737 2382 asection *newsect; … … 1746 2391 case SHT_ALPHA_DEBUG: 1747 2392 if (strcmp (name, ".mdebug") != 0) 1748 return false;2393 return FALSE; 1749 2394 break; 1750 #ifdef ERIC_neverdef1751 case SHT_ALPHA_REGINFO:1752 if (strcmp (name, ".reginfo") != 01753 || hdr->sh_size != sizeof (Elf64_External_RegInfo))1754 return false;1755 break;1756 #endif1757 2395 default: 1758 return false;2396 return FALSE; 1759 2397 } 1760 2398 1761 2399 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) 1762 return false;2400 return FALSE; 1763 2401 newsect = hdr->bfd_section; 1764 2402 … … 1768 2406 (bfd_get_section_flags (abfd, newsect) 1769 2407 | SEC_DEBUGGING))) 1770 return false; 1771 } 1772 1773 #ifdef ERIC_neverdef 1774 /* For a .reginfo section, set the gp value in the tdata information 1775 from the contents of this section. We need the gp value while 1776 processing relocs, so we just get it now. */ 1777 if (hdr->sh_type == SHT_ALPHA_REGINFO) 1778 { 1779 Elf64_External_RegInfo ext; 1780 Elf64_RegInfo s; 1781 1782 if (! bfd_get_section_contents (abfd, newsect, (PTR) &ext, 1783 (file_ptr) 0, sizeof ext)) 1784 return false; 1785 bfd_alpha_elf64_swap_reginfo_in (abfd, &ext, &s); 1786 elf_gp (abfd) = s.ri_gp_value; 1787 } 1788 #endif 1789 1790 return true; 2408 return FALSE; 2409 } 2410 2411 return TRUE; 2412 } 2413 2414 /* Convert Alpha specific section flags to bfd internal section flags. */ 2415 2416 static bfd_boolean 2417 elf64_alpha_section_flags (flags, hdr) 2418 flagword *flags; 2419 Elf_Internal_Shdr *hdr; 2420 { 2421 if (hdr->sh_flags & SHF_ALPHA_GPREL) 2422 *flags |= SEC_SMALL_DATA; 2423 2424 return TRUE; 1791 2425 } 1792 2426 … … 1794 2428 section name, which is a hack, but ought to work. */ 1795 2429 1796 static b oolean2430 static bfd_boolean 1797 2431 elf64_alpha_fake_sections (abfd, hdr, sec) 1798 2432 bfd *abfd; 1799 Elf 64_Internal_Shdr *hdr;2433 Elf_Internal_Shdr *hdr; 1800 2434 asection *sec; 1801 2435 { … … 1814 2448 hdr->sh_entsize = 1; 1815 2449 } 1816 #ifdef ERIC_neverdef 1817 else if (strcmp (name, ".reginfo") == 0) 1818 { 1819 hdr->sh_type = SHT_ALPHA_REGINFO; 1820 /* In a shared object on Irix 5.3, the .reginfo section has an 1821 entsize of 0x18. FIXME: Does this matter? */ 1822 if ((abfd->flags & DYNAMIC) != 0) 1823 hdr->sh_entsize = sizeof (Elf64_External_RegInfo); 1824 else 1825 hdr->sh_entsize = 1; 1826 1827 /* Force the section size to the correct value, even if the 1828 linker thinks it is larger. The link routine below will only 1829 write out this much data for .reginfo. */ 1830 hdr->sh_size = sec->_raw_size = sizeof (Elf64_External_RegInfo); 1831 } 1832 else if (strcmp (name, ".hash") == 0 1833 || strcmp (name, ".dynamic") == 0 1834 || strcmp (name, ".dynstr") == 0) 1835 { 1836 hdr->sh_entsize = 0; 1837 hdr->sh_info = SIZEOF_ALPHA_DYNSYM_SECNAMES; 1838 } 1839 #endif 1840 else if (strcmp (name, ".sdata") == 0 2450 else if ((sec->flags & SEC_SMALL_DATA) 2451 || strcmp (name, ".sdata") == 0 1841 2452 || strcmp (name, ".sbss") == 0 1842 2453 || strcmp (name, ".lit4") == 0 … … 1844 2455 hdr->sh_flags |= SHF_ALPHA_GPREL; 1845 2456 1846 return true;2457 return TRUE; 1847 2458 } 1848 2459 … … 1850 2461 file. We use it to put .comm items in .sbss, and not .bss. */ 1851 2462 1852 static b oolean2463 static bfd_boolean 1853 2464 elf64_alpha_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 1854 2465 bfd *abfd; … … 1862 2473 if (sym->st_shndx == SHN_COMMON 1863 2474 && !info->relocateable 1864 && sym->st_size <= bfd_get_gp_size (abfd))2475 && sym->st_size <= elf_gp_size (abfd)) 1865 2476 { 1866 2477 /* Common symbols less than or equal to -G nn bytes are … … 1876 2487 | SEC_IS_COMMON 1877 2488 | SEC_LINKER_CREATED))) 1878 return false;2489 return FALSE; 1879 2490 } 1880 2491 … … 1883 2494 } 1884 2495 1885 return true;2496 return TRUE; 1886 2497 } 1887 2498 1888 2499 /* Create the .got section. */ 1889 2500 1890 static b oolean2501 static bfd_boolean 1891 2502 elf64_alpha_create_got_section(abfd, info) 1892 2503 bfd *abfd; … … 1896 2507 1897 2508 if (bfd_get_section_by_name (abfd, ".got")) 1898 return true;2509 return TRUE; 1899 2510 1900 2511 s = bfd_make_section (abfd, ".got"); … … 1905 2516 | SEC_LINKER_CREATED)) 1906 2517 || !bfd_set_section_alignment (abfd, s, 3)) 1907 return false;2518 return FALSE; 1908 2519 1909 2520 alpha_elf_tdata (abfd)->got = s; 1910 2521 1911 return true;2522 return TRUE; 1912 2523 } 1913 2524 1914 2525 /* Create all the dynamic sections. */ 1915 2526 1916 static b oolean2527 static bfd_boolean 1917 2528 elf64_alpha_create_dynamic_sections (abfd, info) 1918 2529 bfd *abfd; … … 1921 2532 asection *s; 1922 2533 struct elf_link_hash_entry *h; 2534 struct bfd_link_hash_entry *bh; 1923 2535 1924 2536 /* We need to create .plt, .rela.plt, .got, and .rela.got sections. */ … … 1932 2544 | SEC_CODE)) 1933 2545 || ! bfd_set_section_alignment (abfd, s, 3)) 1934 return false;2546 return FALSE; 1935 2547 1936 2548 /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the 1937 2549 .plt section. */ 1938 h = NULL;2550 bh = NULL; 1939 2551 if (! (_bfd_generic_link_add_one_symbol 1940 2552 (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, 1941 (bfd_vma) 0, (const char *) NULL, false,1942 get_elf_backend_data (abfd)->collect, 1943 (struct bfd_link_hash_entry **) &h))) 1944 return false;2553 (bfd_vma) 0, (const char *) NULL, FALSE, 2554 get_elf_backend_data (abfd)->collect, &bh))) 2555 return FALSE; 2556 h = (struct elf_link_hash_entry *) bh; 1945 2557 h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; 1946 2558 h->type = STT_OBJECT; … … 1948 2560 if (info->shared 1949 2561 && ! _bfd_elf_link_record_dynamic_symbol (info, h)) 1950 return false;2562 return FALSE; 1951 2563 1952 2564 s = bfd_make_section (abfd, ".rela.plt"); … … 1958 2570 | SEC_READONLY)) 1959 2571 || ! bfd_set_section_alignment (abfd, s, 3)) 1960 return false;2572 return FALSE; 1961 2573 1962 2574 /* We may or may not have created a .got section for this object, but … … 1964 2576 1965 2577 if (!elf64_alpha_create_got_section (abfd, info)) 1966 return false;2578 return FALSE; 1967 2579 1968 2580 s = bfd_make_section(abfd, ".rela.got"); … … 1974 2586 | SEC_READONLY)) 1975 2587 || !bfd_set_section_alignment (abfd, s, 3)) 1976 return false;2588 return FALSE; 1977 2589 1978 2590 /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the … … 1980 2592 because we don't want to define the symbol if we are not creating 1981 2593 a global offset table. */ 1982 h = NULL;2594 bh = NULL; 1983 2595 if (!(_bfd_generic_link_add_one_symbol 1984 2596 (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, 1985 2597 alpha_elf_tdata(abfd)->got, (bfd_vma) 0, (const char *) NULL, 1986 false, get_elf_backend_data (abfd)->collect,1987 (struct bfd_link_hash_entry **) &h))) 1988 return false;2598 FALSE, get_elf_backend_data (abfd)->collect, &bh))) 2599 return FALSE; 2600 h = (struct elf_link_hash_entry *) bh; 1989 2601 h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; 1990 2602 h->type = STT_OBJECT; … … 1992 2604 if (info->shared 1993 2605 && ! _bfd_elf_link_record_dynamic_symbol (info, h)) 1994 return false;2606 return FALSE; 1995 2607 1996 2608 elf_hash_table (info)->hgot = h; 1997 2609 1998 return true;2610 return TRUE; 1999 2611 } 2000 2612 … … 2003 2615 ecoff_debug_info structure. */ 2004 2616 2005 static b oolean2617 static bfd_boolean 2006 2618 elf64_alpha_read_ecoff_info (abfd, section, debug) 2007 2619 bfd *abfd; … … 2016 2628 memset (debug, 0, sizeof (*debug)); 2017 2629 2018 ext_hdr = (char *) bfd_malloc ( (size_t)swap->external_hdr_size);2630 ext_hdr = (char *) bfd_malloc (swap->external_hdr_size); 2019 2631 if (ext_hdr == NULL && swap->external_hdr_size != 0) 2020 2632 goto error_return; 2021 2633 2022 if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0, 2023 swap->external_hdr_size) 2024 == false) 2634 if (! bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0, 2635 swap->external_hdr_size)) 2025 2636 goto error_return; 2026 2637 … … 2035 2646 else \ 2036 2647 { \ 2037 debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \ 2648 bfd_size_type amt = (bfd_size_type) size * symhdr->count; \ 2649 debug->ptr = (type) bfd_malloc (amt); \ 2038 2650 if (debug->ptr == NULL) \ 2039 2651 goto error_return; \ 2040 2652 if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0 \ 2041 || (bfd_read (debug->ptr, size, symhdr->count, \ 2042 abfd) != size * symhdr->count)) \ 2653 || bfd_bread (debug->ptr, amt, abfd) != amt) \ 2043 2654 goto error_return; \ 2044 2655 } … … 2061 2672 debug->adjust = NULL; 2062 2673 2063 return true;2674 return TRUE; 2064 2675 2065 2676 error_return: … … 2088 2699 if (debug->external_ext != NULL) 2089 2700 free (debug->external_ext); 2090 return false;2701 return FALSE; 2091 2702 } 2092 2703 2093 2704 /* Alpha ELF local labels start with '$'. */ 2094 2705 2095 static b oolean2706 static bfd_boolean 2096 2707 elf64_alpha_is_local_label_name (abfd, name) 2097 2708 bfd *abfd ATTRIBUTE_UNUSED; … … 2112 2723 }; 2113 2724 2114 static b oolean2725 static bfd_boolean 2115 2726 elf64_alpha_find_nearest_line (abfd, section, symbols, offset, filename_ptr, 2116 2727 functionname_ptr, line_ptr) … … 2129 2740 line_ptr, 0, 2130 2741 &elf_tdata (abfd)->dwarf2_find_line_info)) 2131 return true;2742 return TRUE; 2132 2743 2133 2744 msec = bfd_get_section_by_name (abfd, ".mdebug"); … … 2153 2764 char *fraw_end; 2154 2765 struct fdr *fdr_ptr; 2155 2156 fi = ((struct mips_elf_find_line *) 2157 bfd_zalloc (abfd, sizeof (struct mips_elf_find_line)));2766 bfd_size_type amt = sizeof (struct mips_elf_find_line); 2767 2768 fi = (struct mips_elf_find_line *) bfd_zalloc (abfd, amt); 2158 2769 if (fi == NULL) 2159 2770 { 2160 2771 msec->flags = origflags; 2161 return false;2772 return FALSE; 2162 2773 } 2163 2774 … … 2165 2776 { 2166 2777 msec->flags = origflags; 2167 return false;2778 return FALSE; 2168 2779 } 2169 2780 2170 2781 /* Swap in the FDR information. */ 2171 fi->d.fdr = ((struct fdr *) 2172 bfd_alloc (abfd, 2173 (fi->d.symbolic_header.ifdMax * 2174 sizeof (struct fdr)))); 2782 amt = fi->d.symbolic_header.ifdMax * sizeof (struct fdr); 2783 fi->d.fdr = (struct fdr *) bfd_alloc (abfd, amt); 2175 2784 if (fi->d.fdr == NULL) 2176 2785 { 2177 2786 msec->flags = origflags; 2178 return false;2787 return FALSE; 2179 2788 } 2180 2789 external_fdr_size = swap->external_fdr_size; … … 2201 2810 { 2202 2811 msec->flags = origflags; 2203 return true;2812 return TRUE; 2204 2813 } 2205 2814 … … 2223 2832 struct ecoff_debug_info *debug; 2224 2833 const struct ecoff_debug_swap *swap; 2225 b oolean failed;2834 bfd_boolean failed; 2226 2835 }; 2227 2836 2228 static b oolean2837 static bfd_boolean 2229 2838 elf64_alpha_output_extsym (h, data) 2230 2839 struct alpha_elf_link_hash_entry *h; … … 2232 2841 { 2233 2842 struct extsym_info *einfo = (struct extsym_info *) data; 2234 b oolean strip;2843 bfd_boolean strip; 2235 2844 asection *sec, *output_section; 2236 2845 2846 if (h->root.root.type == bfd_link_hash_warning) 2847 h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link; 2848 2237 2849 if (h->root.indx == -2) 2238 strip = false;2850 strip = FALSE; 2239 2851 else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0 2240 2241 2242 2243 strip = true;2852 || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0) 2853 && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0 2854 && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0) 2855 strip = TRUE; 2244 2856 else if (einfo->info->strip == strip_all 2245 2246 2247 2248 false, false) == NULL))2249 strip = true;2857 || (einfo->info->strip == strip_some 2858 && bfd_hash_lookup (einfo->info->keep_hash, 2859 h->root.root.root.string, 2860 FALSE, FALSE) == NULL)) 2861 strip = TRUE; 2250 2862 else 2251 strip = false;2863 strip = FALSE; 2252 2864 2253 2865 if (strip) 2254 return true;2866 return TRUE; 2255 2867 2256 2868 if (h->esym.ifd == -2) … … 2265 2877 2266 2878 if (h->root.root.type != bfd_link_hash_defined 2267 2268 2879 && h->root.root.type != bfd_link_hash_defweak) 2880 h->esym.asym.sc = scAbs; 2269 2881 else 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2882 { 2883 const char *name; 2884 2885 sec = h->root.root.u.def.section; 2886 output_section = sec->output_section; 2887 2888 /* When making a shared library and symbol h is the one from 2889 the another shared library, OUTPUT_SECTION may be null. */ 2890 if (output_section == NULL) 2891 h->esym.asym.sc = scUndefined; 2892 else 2893 { 2894 name = bfd_section_name (output_section->owner, output_section); 2895 2896 if (strcmp (name, ".text") == 0) 2897 h->esym.asym.sc = scText; 2898 else if (strcmp (name, ".data") == 0) 2899 h->esym.asym.sc = scData; 2900 else if (strcmp (name, ".sdata") == 0) 2901 h->esym.asym.sc = scSData; 2902 else if (strcmp (name, ".rodata") == 0 2903 || strcmp (name, ".rdata") == 0) 2904 h->esym.asym.sc = scRData; 2905 else if (strcmp (name, ".bss") == 0) 2906 h->esym.asym.sc = scBss; 2907 else if (strcmp (name, ".sbss") == 0) 2908 h->esym.asym.sc = scSBss; 2909 else if (strcmp (name, ".init") == 0) 2910 h->esym.asym.sc = scInit; 2911 else if (strcmp (name, ".fini") == 0) 2912 h->esym.asym.sc = scFini; 2913 else 2914 h->esym.asym.sc = scAbs; 2915 } 2916 } 2305 2917 2306 2918 h->esym.asym.reserved = 0; … … 2314 2926 { 2315 2927 if (h->esym.asym.sc == scCommon) 2316 2928 h->esym.asym.sc = scBss; 2317 2929 else if (h->esym.asym.sc == scSCommon) 2318 2930 h->esym.asym.sc = scSBss; 2319 2931 2320 2932 sec = h->root.root.u.def.section; 2321 2933 output_section = sec->output_section; 2322 2934 if (output_section != NULL) 2323 2324 2325 2935 h->esym.asym.value = (h->root.root.u.def.value 2936 + sec->output_offset 2937 + output_section->vma); 2326 2938 else 2327 2939 h->esym.asym.value = 0; 2328 2940 } 2329 2941 else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) … … 2344 2956 h->esym.asym.value = 0; 2345 2957 } 2346 #if 0 /* FIXME? */2347 h->esym.ifd = 0;2348 #endif2349 2958 } 2350 2959 2351 2960 if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap, 2352 2353 2354 { 2355 einfo->failed = true;2356 return false;2357 } 2358 2359 return true;2961 h->root.root.root.string, 2962 &h->esym)) 2963 { 2964 einfo->failed = TRUE; 2965 return FALSE; 2966 } 2967 2968 return TRUE; 2360 2969 } 2361 2970 2362 /* FIXME: Create a runtime procedure table from the .mdebug section. 2363 2364 static boolean 2365 mips_elf_create_procedure_table (handle, abfd, info, s, debug) 2366 PTR handle; 2971 2972 /* Search for and possibly create a got entry. */ 2973 2974 static struct alpha_elf_got_entry * 2975 get_got_entry (abfd, h, r_type, r_symndx, r_addend) 2367 2976 bfd *abfd; 2368 struct bfd_link_info *info; 2369 asection *s; 2370 struct ecoff_debug_info *debug; 2371 */ 2372 2977 struct alpha_elf_link_hash_entry *h; 2978 unsigned long r_type, r_symndx; 2979 bfd_vma r_addend; 2980 { 2981 struct alpha_elf_got_entry *gotent; 2982 struct alpha_elf_got_entry **slot; 2983 2984 if (h) 2985 slot = &h->got_entries; 2986 else 2987 { 2988 /* This is a local .got entry -- record for merge. */ 2989 2990 struct alpha_elf_got_entry **local_got_entries; 2991 2992 local_got_entries = alpha_elf_tdata(abfd)->local_got_entries; 2993 if (!local_got_entries) 2994 { 2995 bfd_size_type size; 2996 Elf_Internal_Shdr *symtab_hdr; 2997 2998 symtab_hdr = &elf_tdata(abfd)->symtab_hdr; 2999 size = symtab_hdr->sh_info; 3000 size *= sizeof (struct alpha_elf_got_entry *); 3001 3002 local_got_entries 3003 = (struct alpha_elf_got_entry **) bfd_zalloc (abfd, size); 3004 if (!local_got_entries) 3005 return NULL; 3006 3007 alpha_elf_tdata (abfd)->local_got_entries = local_got_entries; 3008 } 3009 3010 slot = &local_got_entries[r_symndx]; 3011 } 3012 3013 for (gotent = *slot; gotent ; gotent = gotent->next) 3014 if (gotent->gotobj == abfd 3015 && gotent->reloc_type == r_type 3016 && gotent->addend == r_addend) 3017 break; 3018 3019 if (!gotent) 3020 { 3021 int entry_size; 3022 bfd_size_type amt; 3023 3024 amt = sizeof (struct alpha_elf_got_entry); 3025 gotent = (struct alpha_elf_got_entry *) bfd_alloc (abfd, amt); 3026 if (!gotent) 3027 return NULL; 3028 3029 gotent->gotobj = abfd; 3030 gotent->addend = r_addend; 3031 gotent->got_offset = -1; 3032 gotent->use_count = 1; 3033 gotent->reloc_type = r_type; 3034 gotent->reloc_done = 0; 3035 gotent->reloc_xlated = 0; 3036 3037 gotent->next = *slot; 3038 *slot = gotent; 3039 3040 entry_size = alpha_got_entry_size (r_type); 3041 alpha_elf_tdata (abfd)->total_got_size += entry_size; 3042 if (!h) 3043 alpha_elf_tdata(abfd)->local_got_size += entry_size; 3044 } 3045 else 3046 gotent->use_count += 1; 3047 3048 return gotent; 3049 } 2373 3050 2374 3051 /* Handle dynamic relocations when doing an Alpha ELF link. */ 2375 3052 2376 static b oolean3053 static bfd_boolean 2377 3054 elf64_alpha_check_relocs (abfd, info, sec, relocs) 2378 3055 bfd *abfd; … … 2386 3063 Elf_Internal_Shdr *symtab_hdr; 2387 3064 struct alpha_elf_link_hash_entry **sym_hashes; 2388 struct alpha_elf_got_entry **local_got_entries;2389 3065 const Elf_Internal_Rela *rel, *relend; 2390 int got_created; 3066 bfd_boolean got_created; 3067 bfd_size_type amt; 2391 3068 2392 3069 if (info->relocateable) 2393 return true;3070 return TRUE; 2394 3071 2395 3072 dynobj = elf_hash_table(info)->dynobj; … … 2401 3078 symtab_hdr = &elf_tdata(abfd)->symtab_hdr; 2402 3079 sym_hashes = alpha_elf_sym_hashes(abfd); 2403 local_got_entries = alpha_elf_tdata(abfd)->local_got_entries; 2404 got_created = 0; 3080 got_created = FALSE; 2405 3081 2406 3082 relend = relocs + sec->reloc_count; 2407 3083 for (rel = relocs; rel < relend; ++rel) 2408 3084 { 3085 enum { 3086 NEED_GOT = 1, 3087 NEED_GOT_ENTRY = 2, 3088 NEED_DYNREL = 4 3089 }; 3090 2409 3091 unsigned long r_symndx, r_type; 2410 3092 struct alpha_elf_link_hash_entry *h; 3093 unsigned int gotent_flags; 3094 bfd_boolean maybe_dynamic; 3095 unsigned int need; 3096 bfd_vma addend; 2411 3097 2412 3098 r_symndx = ELF64_R_SYM (rel->r_info); … … 2423 3109 h->root.elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR; 2424 3110 } 3111 3112 /* We can only get preliminary data on whether a symbol is 3113 locally or externally defined, as not all of the input files 3114 have yet been processed. Do something with what we know, as 3115 this may help reduce memory usage and processing time later. */ 3116 maybe_dynamic = FALSE; 3117 if (h && ((info->shared 3118 && (!info->symbolic || info->allow_shlib_undefined)) 3119 || ! (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) 3120 || h->root.root.type == bfd_link_hash_defweak)) 3121 maybe_dynamic = TRUE; 3122 3123 need = 0; 3124 gotent_flags = 0; 2425 3125 r_type = ELF64_R_TYPE (rel->r_info); 3126 addend = rel->r_addend; 2426 3127 2427 3128 switch (r_type) 2428 3129 { 2429 3130 case R_ALPHA_LITERAL: 2430 { 2431 struct alpha_elf_got_entry *gotent; 2432 int flags = 0; 2433 2434 if (h) 2435 { 2436 /* Search for and possibly create a got entry. */ 2437 for (gotent = h->got_entries; gotent ; gotent = gotent->next) 2438 if (gotent->gotobj == abfd && 2439 gotent->addend == rel->r_addend) 2440 break; 2441 2442 if (!gotent) 2443 { 2444 gotent = ((struct alpha_elf_got_entry *) 2445 bfd_alloc (abfd, 2446 sizeof (struct alpha_elf_got_entry))); 2447 if (!gotent) 2448 return false; 2449 2450 gotent->gotobj = abfd; 2451 gotent->addend = rel->r_addend; 2452 gotent->got_offset = -1; 2453 gotent->flags = 0; 2454 gotent->use_count = 1; 2455 2456 gotent->next = h->got_entries; 2457 h->got_entries = gotent; 2458 2459 alpha_elf_tdata (abfd)->total_got_entries++; 2460 } 2461 else 2462 gotent->use_count += 1; 2463 } 2464 else 2465 { 2466 /* This is a local .got entry -- record for merge. */ 2467 if (!local_got_entries) 2468 { 2469 size_t size; 2470 size = (symtab_hdr->sh_info 2471 * sizeof (struct alpha_elf_got_entry *)); 2472 2473 local_got_entries = ((struct alpha_elf_got_entry **) 2474 bfd_alloc (abfd, size)); 2475 if (!local_got_entries) 2476 return false; 2477 2478 memset (local_got_entries, 0, size); 2479 alpha_elf_tdata (abfd)->local_got_entries = 2480 local_got_entries; 2481 } 2482 2483 for (gotent = local_got_entries[ELF64_R_SYM(rel->r_info)]; 2484 gotent != NULL && gotent->addend != rel->r_addend; 2485 gotent = gotent->next) 2486 continue; 2487 if (!gotent) 2488 { 2489 gotent = ((struct alpha_elf_got_entry *) 2490 bfd_alloc (abfd, 2491 sizeof (struct alpha_elf_got_entry))); 2492 if (!gotent) 2493 return false; 2494 2495 gotent->gotobj = abfd; 2496 gotent->addend = rel->r_addend; 2497 gotent->got_offset = -1; 2498 gotent->flags = 0; 2499 gotent->use_count = 1; 2500 2501 gotent->next = local_got_entries[ELF64_R_SYM(rel->r_info)]; 2502 local_got_entries[ELF64_R_SYM(rel->r_info)] = gotent; 2503 2504 alpha_elf_tdata(abfd)->total_got_entries++; 2505 alpha_elf_tdata(abfd)->n_local_got_entries++; 2506 } 2507 else 2508 gotent->use_count += 1; 2509 } 2510 2511 /* Remember how this literal is used from its LITUSEs. 2512 This will be important when it comes to decide if we can 2513 create a .plt entry for a function symbol. */ 2514 if (rel+1 < relend 2515 && ELF64_R_TYPE (rel[1].r_info) == R_ALPHA_LITUSE) 2516 { 2517 do 2518 { 2519 ++rel; 2520 if (rel->r_addend >= 1 && rel->r_addend <= 3) 2521 flags |= 1 << rel->r_addend; 2522 } 2523 while (rel+1 < relend && 2524 ELF64_R_TYPE (rel[1].r_info) == R_ALPHA_LITUSE); 2525 } 2526 else 2527 { 2528 /* No LITUSEs -- presumably the address is not being 2529 loaded for nothing. */ 2530 flags = ALPHA_ELF_LINK_HASH_LU_ADDR; 2531 } 2532 2533 gotent->flags |= flags; 2534 if (h) 2535 { 2536 /* Make a guess as to whether a .plt entry will be needed. */ 2537 if ((h->flags |= flags) == ALPHA_ELF_LINK_HASH_LU_FUNC) 2538 h->root.elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; 2539 else 2540 h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; 2541 } 2542 } 2543 /* FALLTHRU */ 3131 need = NEED_GOT | NEED_GOT_ENTRY; 3132 3133 /* Remember how this literal is used from its LITUSEs. 3134 This will be important when it comes to decide if we can 3135 create a .plt entry for a function symbol. */ 3136 while (++rel < relend && ELF64_R_TYPE (rel->r_info) == R_ALPHA_LITUSE) 3137 if (rel->r_addend >= 1 && rel->r_addend <= 5) 3138 gotent_flags |= 1 << rel->r_addend; 3139 --rel; 3140 3141 /* No LITUSEs -- presumably the address is used somehow. */ 3142 if (gotent_flags == 0) 3143 gotent_flags = ALPHA_ELF_LINK_HASH_LU_ADDR; 3144 break; 2544 3145 2545 3146 case R_ALPHA_GPDISP: 3147 case R_ALPHA_GPREL16: 2546 3148 case R_ALPHA_GPREL32: 2547 3149 case R_ALPHA_GPRELHIGH: 2548 3150 case R_ALPHA_GPRELLOW: 2549 /* We don't actually use the .got here, but the sections must 2550 be created before the linker maps input sections to output 2551 sections. */ 3151 case R_ALPHA_BRSGP: 3152 need = NEED_GOT; 3153 break; 3154 3155 case R_ALPHA_REFLONG: 3156 case R_ALPHA_REFQUAD: 3157 if ((info->shared && (sec->flags & SEC_ALLOC)) || maybe_dynamic) 3158 need = NEED_DYNREL; 3159 break; 3160 3161 case R_ALPHA_TLSLDM: 3162 /* The symbol for a TLSLDM reloc is ignored. Collapse the 3163 reloc to the 0 symbol so that they all match. */ 3164 r_symndx = 0; 3165 h = 0; 3166 maybe_dynamic = FALSE; 3167 /* FALLTHRU */ 3168 3169 case R_ALPHA_TLSGD: 3170 case R_ALPHA_GOTDTPREL: 3171 need = NEED_GOT | NEED_GOT_ENTRY; 3172 break; 3173 3174 case R_ALPHA_GOTTPREL: 3175 need = NEED_GOT | NEED_GOT_ENTRY; 3176 gotent_flags = ALPHA_ELF_LINK_HASH_TLS_IE; 3177 if (info->shared) 3178 info->flags |= DF_STATIC_TLS; 3179 break; 3180 3181 case R_ALPHA_TPREL64: 3182 if (info->shared || maybe_dynamic) 3183 need = NEED_DYNREL; 3184 if (info->shared) 3185 info->flags |= DF_STATIC_TLS; 3186 break; 3187 } 3188 3189 if (need & NEED_GOT) 3190 { 2552 3191 if (!got_created) 2553 3192 { 2554 3193 if (!elf64_alpha_create_got_section (abfd, info)) 2555 return false;3194 return FALSE; 2556 3195 2557 3196 /* Make sure the object's gotobj is set to itself so … … 2563 3202 got_created = 1; 2564 3203 } 2565 break; 2566 2567 case R_ALPHA_SREL16: 2568 case R_ALPHA_SREL32: 2569 case R_ALPHA_SREL64: 2570 if (h == NULL) 2571 break; 2572 /* FALLTHRU */ 2573 2574 case R_ALPHA_REFLONG: 2575 case R_ALPHA_REFQUAD: 3204 } 3205 3206 if (need & NEED_GOT_ENTRY) 3207 { 3208 struct alpha_elf_got_entry *gotent; 3209 3210 gotent = get_got_entry (abfd, h, r_type, r_symndx, addend); 3211 if (!gotent) 3212 return FALSE; 3213 3214 if (gotent_flags) 3215 { 3216 gotent->flags |= gotent_flags; 3217 if (h) 3218 { 3219 gotent_flags |= h->flags; 3220 h->flags = gotent_flags; 3221 3222 /* Make a guess as to whether a .plt entry is needed. */ 3223 if ((gotent_flags & ALPHA_ELF_LINK_HASH_LU_FUNC) 3224 && !(gotent_flags & ~ALPHA_ELF_LINK_HASH_LU_FUNC)) 3225 h->root.elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; 3226 else 3227 h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; 3228 } 3229 } 3230 } 3231 3232 if (need & NEED_DYNREL) 3233 { 2576 3234 if (rel_sec_name == NULL) 2577 3235 { … … 2580 3238 elf_section_data(sec)->rel_hdr.sh_name)); 2581 3239 if (rel_sec_name == NULL) 2582 return false;3240 return FALSE; 2583 3241 2584 3242 BFD_ASSERT (strncmp (rel_sec_name, ".rela", 5) == 0 … … 2596 3254 if (sreloc == NULL) 2597 3255 { 3256 flagword flags; 3257 2598 3258 sreloc = bfd_make_section (dynobj, rel_sec_name); 3259 flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY 3260 | SEC_LINKER_CREATED | SEC_READONLY); 3261 if (sec->flags & SEC_ALLOC) 3262 flags |= SEC_ALLOC | SEC_LOAD; 2599 3263 if (sreloc == NULL 2600 || !bfd_set_section_flags (dynobj, sreloc, 2601 ((sec->flags & (SEC_ALLOC 2602 | SEC_LOAD)) 2603 | SEC_HAS_CONTENTS 2604 | SEC_IN_MEMORY 2605 | SEC_LINKER_CREATED 2606 | SEC_READONLY)) 3264 || !bfd_set_section_flags (dynobj, sreloc, flags) 2607 3265 || !bfd_set_section_alignment (dynobj, sreloc, 3)) 2608 return false;3266 return FALSE; 2609 3267 } 2610 3268 } … … 2626 3284 if (!rent) 2627 3285 { 2628 rent = ((struct alpha_elf_reloc_entry *) 2629 bfd_alloc (abfd, 2630 sizeof (struct alpha_elf_reloc_entry))); 3286 amt = sizeof (struct alpha_elf_reloc_entry); 3287 rent = (struct alpha_elf_reloc_entry *) bfd_alloc (abfd, amt); 2631 3288 if (!rent) 2632 return false;3289 return FALSE; 2633 3290 2634 3291 rent->srel = sreloc; 2635 3292 rent->rtype = r_type; 2636 3293 rent->count = 1; 3294 rent->reltext = ((sec->flags & (SEC_READONLY | SEC_ALLOC)) 3295 == (SEC_READONLY | SEC_ALLOC)); 2637 3296 2638 3297 rent->next = h->reloc_entries; … … 2642 3301 rent->count++; 2643 3302 } 2644 else if (info->shared && (sec->flags & SEC_ALLOC))3303 else if (info->shared) 2645 3304 { 2646 3305 /* If this is a shared library, and the section is to be 2647 3306 loaded into memory, we need a RELATIVE reloc. */ 2648 3307 sreloc->_raw_size += sizeof (Elf64_External_Rela); 3308 if ((sec->flags & (SEC_READONLY | SEC_ALLOC)) 3309 == (SEC_READONLY | SEC_ALLOC)) 3310 info->flags |= DF_TEXTREL; 2649 3311 } 2650 break; 2651 } 2652 } 2653 2654 return true; 3312 } 3313 } 3314 3315 return TRUE; 2655 3316 } 2656 3317 … … 2661 3322 understand. */ 2662 3323 2663 static b oolean3324 static bfd_boolean 2664 3325 elf64_alpha_adjust_dynamic_symbol (info, h) 2665 3326 struct bfd_link_info *info; … … 2676 3337 about whether this symbol should get a .plt entry. */ 2677 3338 2678 if (h->root.type != bfd_link_hash_undefweak 2679 && alpha_elf_dynamic_symbol_p (h, info) 3339 if (alpha_elf_dynamic_symbol_p (h, info) 2680 3340 && ((h->type == STT_FUNC 2681 3341 && !(ah->flags & ALPHA_ELF_LINK_HASH_LU_ADDR)) 2682 3342 || (h->type == STT_NOTYPE 2683 && ah->flags == ALPHA_ELF_LINK_HASH_LU_FUNC)) 3343 && (ah->flags & ALPHA_ELF_LINK_HASH_LU_FUNC) 3344 && !(ah->flags & ~ALPHA_ELF_LINK_HASH_LU_FUNC))) 2684 3345 /* Don't prevent otherwise valid programs from linking by attempting 2685 3346 to create a new .got entry somewhere. A Correct Solution would be … … 2692 3353 s = bfd_get_section_by_name(dynobj, ".plt"); 2693 3354 if (!s && !elf64_alpha_create_dynamic_sections (dynobj, info)) 2694 return false;3355 return FALSE; 2695 3356 2696 3357 /* The first bit of the .plt is reserved. */ … … 2708 3369 && h->root.type != bfd_link_hash_defweak) 2709 3370 { 3371 ah->plt_old_section = h->root.u.def.section; 3372 ah->plt_old_value = h->root.u.def.value; 3373 ah->flags |= ALPHA_ELF_LINK_HASH_PLT_LOC; 2710 3374 h->root.u.def.section = s; 2711 3375 h->root.u.def.value = h->plt.offset; … … 2717 3381 s->_raw_size += sizeof (Elf64_External_Rela); 2718 3382 2719 return true;3383 return TRUE; 2720 3384 } 2721 3385 else … … 2731 3395 h->root.u.def.section = h->weakdef->root.u.def.section; 2732 3396 h->root.u.def.value = h->weakdef->root.u.def.value; 2733 return true;3397 return TRUE; 2734 3398 } 2735 3399 … … 2739 3403 .dynbss section and COPY dynamic relocations. */ 2740 3404 2741 return true;3405 return TRUE; 2742 3406 } 2743 3407 … … 2746 3410 in these situations. */ 2747 3411 2748 static b oolean3412 static bfd_boolean 2749 3413 elf64_alpha_merge_ind_symbols (hi, dummy) 2750 3414 struct alpha_elf_link_hash_entry *hi; … … 2754 3418 2755 3419 if (hi->root.root.type != bfd_link_hash_indirect) 2756 return true;3420 return TRUE; 2757 3421 hs = hi; 2758 3422 do { … … 2778 3442 gin = gi->next; 2779 3443 for (gs = gsh; gs ; gs = gs->next) 2780 if (gi->gotobj == gs->gotobj && gi->addend == gs->addend) 2781 goto got_found; 3444 if (gi->gotobj == gs->gotobj 3445 && gi->reloc_type == gs->reloc_type 3446 && gi->addend == gs->addend) 3447 { 3448 gi->use_count += gs->use_count; 3449 goto got_found; 3450 } 2782 3451 gi->next = hs->got_entries; 2783 3452 hs->got_entries = gi; … … 2800 3469 rin = ri->next; 2801 3470 for (rs = rsh; rs ; rs = rs->next) 2802 if (ri->rtype == rs->rtype )3471 if (ri->rtype == rs->rtype && ri->srel == rs->srel) 2803 3472 { 2804 3473 rs->count += ri->count; … … 2812 3481 hi->reloc_entries = NULL; 2813 3482 2814 return true;3483 return TRUE; 2815 3484 } 2816 3485 2817 3486 /* Is it possible to merge two object file's .got tables? */ 2818 3487 2819 static b oolean3488 static bfd_boolean 2820 3489 elf64_alpha_can_merge_gots (a, b) 2821 3490 bfd *a, *b; 2822 3491 { 2823 int total = alpha_elf_tdata (a)->total_got_ entries;3492 int total = alpha_elf_tdata (a)->total_got_size; 2824 3493 bfd *bsub; 2825 3494 2826 3495 /* Trivial quick fallout test. */ 2827 if (total + alpha_elf_tdata (b)->total_got_ entries <= MAX_GOT_ENTRIES)2828 return true;3496 if (total + alpha_elf_tdata (b)->total_got_size <= MAX_GOT_SIZE) 3497 return TRUE; 2829 3498 2830 3499 /* By their nature, local .got entries cannot be merged. */ 2831 if ((total += alpha_elf_tdata (b)-> n_local_got_entries) > MAX_GOT_ENTRIES)2832 return false;3500 if ((total += alpha_elf_tdata (b)->local_got_size) > MAX_GOT_SIZE) 3501 return FALSE; 2833 3502 2834 3503 /* Failing the common trivial comparison, we must effectively … … 2860 3529 2861 3530 for (ae = h->got_entries; ae ; ae = ae->next) 2862 if (ae->gotobj == a && ae->addend == be->addend) 3531 if (ae->gotobj == a 3532 && ae->reloc_type == be->reloc_type 3533 && ae->addend == be->addend) 2863 3534 goto global_found; 2864 3535 2865 if (++total > MAX_GOT_ENTRIES) 2866 return false; 3536 total += alpha_got_entry_size (be->reloc_type); 3537 if (total > MAX_GOT_SIZE) 3538 return FALSE; 2867 3539 global_found:; 2868 3540 } … … 2870 3542 } 2871 3543 2872 return true;3544 return TRUE; 2873 3545 } 2874 3546 … … 2879 3551 bfd *a, *b; 2880 3552 { 2881 int total = alpha_elf_tdata (a)->total_got_ entries;3553 int total = alpha_elf_tdata (a)->total_got_size; 2882 3554 bfd *bsub; 2883 3555 2884 3556 /* Remember local expansion. */ 2885 3557 { 2886 int e = alpha_elf_tdata (b)-> n_local_got_entries;3558 int e = alpha_elf_tdata (b)->local_got_size; 2887 3559 total += e; 2888 alpha_elf_tdata (a)-> n_local_got_entries+= e;3560 alpha_elf_tdata (a)->local_got_size += e; 2889 3561 } 2890 3562 … … 2936 3608 2937 3609 for (ae = *start; ae ; ae = ae->next) 2938 if (ae->gotobj == a && ae->addend == be->addend) 3610 if (ae->gotobj == a 3611 && ae->reloc_type == be->reloc_type 3612 && ae->addend == be->addend) 2939 3613 { 2940 3614 ae->flags |= be->flags; … … 2944 3618 } 2945 3619 be->gotobj = a; 2946 total += 1;3620 total += alpha_got_entry_size (be->reloc_type); 2947 3621 2948 3622 global_found:; … … 2952 3626 alpha_elf_tdata (bsub)->gotobj = a; 2953 3627 } 2954 alpha_elf_tdata (a)->total_got_ entries= total;3628 alpha_elf_tdata (a)->total_got_size = total; 2955 3629 2956 3630 /* Merge the two in_got chains. */ … … 2968 3642 /* Calculate the offsets for the got entries. */ 2969 3643 2970 static b oolean3644 static bfd_boolean 2971 3645 elf64_alpha_calc_got_offsets_for_symbol (h, arg) 2972 3646 struct alpha_elf_link_hash_entry *h; 2973 PTR arg ;3647 PTR arg ATTRIBUTE_UNUSED; 2974 3648 { 2975 3649 struct alpha_elf_got_entry *gotent; 3650 3651 if (h->root.root.type == bfd_link_hash_warning) 3652 h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link; 2976 3653 2977 3654 for (gotent = h->got_entries; gotent; gotent = gotent->next) … … 2982 3659 2983 3660 gotent->got_offset = *plge; 2984 *plge += 8;3661 *plge += alpha_got_entry_size (gotent->reloc_type); 2985 3662 } 2986 3663 2987 return true;3664 return TRUE; 2988 3665 } 2989 3666 … … 3024 3701 { 3025 3702 gotent->got_offset = got_offset; 3026 got_offset += 8;3703 got_offset += alpha_got_entry_size (gotent->reloc_type); 3027 3704 } 3028 3705 } … … 3035 3712 /* Constructs the gots. */ 3036 3713 3037 static boolean 3038 elf64_alpha_size_got_sections (output_bfd, info) 3039 bfd *output_bfd; 3714 static bfd_boolean 3715 elf64_alpha_size_got_sections (info) 3040 3716 struct bfd_link_info *info; 3041 3717 { 3042 bfd *i, *got_list, *cur_got_obj ;3718 bfd *i, *got_list, *cur_got_obj = NULL; 3043 3719 int something_changed = 0; 3044 3720 … … 3058 3734 BFD_ASSERT (this_got == i); 3059 3735 3060 if (alpha_elf_tdata (this_got)->total_got_ entries > MAX_GOT_ENTRIES)3736 if (alpha_elf_tdata (this_got)->total_got_size > MAX_GOT_SIZE) 3061 3737 { 3062 3738 /* Yikes! A single object file has too many entries. */ 3063 3739 (*_bfd_error_handler) 3064 3740 (_("%s: .got subsegment exceeds 64K (size %d)"), 3065 bfd_ get_filename (i),3066 alpha_elf_tdata (this_got)->total_got_ entries * 8);3067 return false;3741 bfd_archive_filename (i), 3742 alpha_elf_tdata (this_got)->total_got_size); 3743 return FALSE; 3068 3744 } 3069 3745 … … 3077 3753 /* Strange degenerate case of no got references. */ 3078 3754 if (got_list == NULL) 3079 return true;3755 return TRUE; 3080 3756 3081 3757 alpha_elf_hash_table (info)->got_list = got_list; … … 3108 3784 elf64_alpha_calc_got_offsets (info); 3109 3785 3110 return true;3786 return TRUE; 3111 3787 } 3112 3788 3113 static boolean 3789 /* Called from relax_section to rebuild the PLT in light of 3790 potential changes in the function's status. */ 3791 3792 static bfd_boolean 3793 elf64_alpha_size_plt_section (info) 3794 struct bfd_link_info *info; 3795 { 3796 asection *splt, *spltrel; 3797 unsigned long entries; 3798 bfd *dynobj; 3799 3800 dynobj = elf_hash_table(info)->dynobj; 3801 splt = bfd_get_section_by_name(dynobj, ".plt"); 3802 if (splt == NULL) 3803 return TRUE; 3804 3805 splt->_raw_size = 0; 3806 3807 alpha_elf_link_hash_traverse (alpha_elf_hash_table (info), 3808 elf64_alpha_size_plt_section_1, splt); 3809 3810 splt->_cooked_size = splt->_raw_size; 3811 3812 /* Every plt entry requires a JMP_SLOT relocation. */ 3813 spltrel = bfd_get_section_by_name (dynobj, ".rela.plt"); 3814 if (splt->_raw_size) 3815 entries = (splt->_raw_size - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE; 3816 else 3817 entries = 0; 3818 spltrel->_raw_size = entries * sizeof (Elf64_External_Rela); 3819 spltrel->_cooked_size = spltrel->_raw_size; 3820 3821 return TRUE; 3822 } 3823 3824 static bfd_boolean 3825 elf64_alpha_size_plt_section_1 (h, data) 3826 struct alpha_elf_link_hash_entry *h; 3827 PTR data; 3828 { 3829 asection *splt = (asection *) data; 3830 struct alpha_elf_got_entry *gotent; 3831 3832 /* If we didn't need an entry before, we still don't. */ 3833 if (!(h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)) 3834 return TRUE; 3835 3836 /* There must still be a LITERAL got entry for the function. */ 3837 for (gotent = h->got_entries; gotent ; gotent = gotent->next) 3838 if (gotent->reloc_type == R_ALPHA_LITERAL 3839 && gotent->use_count > 0) 3840 break; 3841 3842 /* If there is, reset the PLT offset. If not, there's no longer 3843 a need for the PLT entry. */ 3844 if (gotent) 3845 { 3846 if (splt->_raw_size == 0) 3847 splt->_raw_size = PLT_HEADER_SIZE; 3848 h->root.plt.offset = splt->_raw_size; 3849 splt->_raw_size += PLT_ENTRY_SIZE; 3850 } 3851 else 3852 { 3853 h->root.elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; 3854 h->root.plt.offset = -1; 3855 3856 /* Undo the definition frobbing begun in adjust_dynamic_symbol. */ 3857 if (h->flags & ALPHA_ELF_LINK_HASH_PLT_LOC) 3858 { 3859 h->root.root.u.def.section = h->plt_old_section; 3860 h->root.root.u.def.value = h->plt_old_value; 3861 h->flags &= ~ALPHA_ELF_LINK_HASH_PLT_LOC; 3862 } 3863 } 3864 3865 return TRUE; 3866 } 3867 3868 static bfd_boolean 3114 3869 elf64_alpha_always_size_sections (output_bfd, info) 3115 bfd *output_bfd ;3870 bfd *output_bfd ATTRIBUTE_UNUSED; 3116 3871 struct bfd_link_info *info; 3117 3872 { … … 3119 3874 3120 3875 if (info->relocateable) 3121 return true;3876 return TRUE; 3122 3877 3123 3878 /* First, take care of the indirect symbols created by versioning. */ … … 3126 3881 NULL); 3127 3882 3128 if (!elf64_alpha_size_got_sections ( output_bfd,info))3129 return false;3883 if (!elf64_alpha_size_got_sections (info)) 3884 return FALSE; 3130 3885 3131 3886 /* Allocate space for all of the .got subsections. */ … … 3138 3893 s->contents = (bfd_byte *) bfd_zalloc (i, s->_raw_size); 3139 3894 if (s->contents == NULL) 3140 return false;3141 } 3142 } 3143 3144 return true;3895 return FALSE; 3896 } 3897 } 3898 3899 return TRUE; 3145 3900 } 3146 3901 3902 /* The number of dynamic relocations required by a static relocation. */ 3903 3904 static int 3905 alpha_dynamic_entries_for_reloc (r_type, dynamic, shared) 3906 int r_type, dynamic, shared; 3907 { 3908 switch (r_type) 3909 { 3910 /* May appear in GOT entries. */ 3911 case R_ALPHA_TLSGD: 3912 return (dynamic ? 2 : shared ? 1 : 0); 3913 case R_ALPHA_TLSLDM: 3914 return shared; 3915 case R_ALPHA_LITERAL: 3916 case R_ALPHA_GOTTPREL: 3917 return dynamic || shared; 3918 case R_ALPHA_GOTDTPREL: 3919 return dynamic; 3920 3921 /* May appear in data sections. */ 3922 case R_ALPHA_REFLONG: 3923 case R_ALPHA_REFQUAD: 3924 case R_ALPHA_TPREL64: 3925 return dynamic || shared; 3926 3927 /* Everything else is illegal. We'll issue an error during 3928 relocate_section. */ 3929 default: 3930 return 0; 3931 } 3932 } 3933 3147 3934 /* Work out the sizes of the dynamic relocation entries. */ 3148 3935 3149 static b oolean3936 static bfd_boolean 3150 3937 elf64_alpha_calc_dynrel_sizes (h, info) 3151 3938 struct alpha_elf_link_hash_entry *h; 3152 3939 struct bfd_link_info *info; 3153 3940 { 3941 bfd_boolean dynamic; 3942 struct alpha_elf_reloc_entry *relent; 3943 unsigned long entries; 3944 3945 if (h->root.root.type == bfd_link_hash_warning) 3946 h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link; 3947 3154 3948 /* If the symbol was defined as a common symbol in a regular object 3155 3949 file, and there was no definition in any dynamic object, then the … … 3167 3961 || h->root.root.type == bfd_link_hash_defweak) 3168 3962 && !(h->root.root.u.def.section->owner->flags & DYNAMIC)) 3169 { 3170 h->root.elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; 3171 } 3963 h->root.elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; 3172 3964 3173 3965 /* If the symbol is dynamic, we'll need all the relocations in their … … 3175 3967 local, we'll need the same number of RELATIVE relocations. */ 3176 3968 3177 if (alpha_elf_dynamic_symbol_p (&h->root, info) || info->shared) 3178 { 3179 struct alpha_elf_reloc_entry *relent; 3180 bfd *dynobj; 3181 struct alpha_elf_got_entry *gotent; 3182 bfd_size_type count; 3183 asection *srel; 3184 3185 for (relent = h->reloc_entries; relent; relent = relent->next) 3186 if (relent->rtype == R_ALPHA_REFLONG 3187 || relent->rtype == R_ALPHA_REFQUAD) 3188 { 3189 relent->srel->_raw_size += 3190 sizeof (Elf64_External_Rela) * relent->count; 3191 } 3192 3193 dynobj = elf_hash_table(info)->dynobj; 3194 count = 0; 3195 3196 for (gotent = h->got_entries; gotent ; gotent = gotent->next) 3197 count++; 3198 3199 /* If we are using a .plt entry, subtract one, as the first 3200 reference uses a .rela.plt entry instead. */ 3201 if (h->root.plt.offset != MINUS_ONE) 3202 count--; 3203 3204 if (count > 0) 3205 { 3206 srel = bfd_get_section_by_name (dynobj, ".rela.got"); 3207 BFD_ASSERT (srel != NULL); 3208 srel->_raw_size += sizeof (Elf64_External_Rela) * count; 3209 } 3210 } 3211 3212 return true; 3969 dynamic = alpha_elf_dynamic_symbol_p (&h->root, info); 3970 3971 for (relent = h->reloc_entries; relent; relent = relent->next) 3972 { 3973 entries = alpha_dynamic_entries_for_reloc (relent->rtype, dynamic, 3974 info->shared); 3975 if (entries) 3976 { 3977 relent->srel->_raw_size += 3978 entries * sizeof (Elf64_External_Rela) * relent->count; 3979 if (relent->reltext) 3980 info->flags |= DT_TEXTREL; 3981 } 3982 } 3983 3984 return TRUE; 3213 3985 } 3214 3986 3987 /* Set the sizes of the dynamic relocation sections. */ 3988 3989 static bfd_boolean 3990 elf64_alpha_size_rela_got_section (info) 3991 struct bfd_link_info *info; 3992 { 3993 unsigned long entries; 3994 bfd *i, *dynobj; 3995 asection *srel; 3996 3997 /* Shared libraries often require RELATIVE relocs, and some relocs 3998 require attention for the main application as well. */ 3999 4000 entries = 0; 4001 for (i = alpha_elf_hash_table(info)->got_list; 4002 i ; i = alpha_elf_tdata(i)->got_link_next) 4003 { 4004 bfd *j; 4005 4006 for (j = i; j ; j = alpha_elf_tdata(j)->in_got_link_next) 4007 { 4008 struct alpha_elf_got_entry **local_got_entries, *gotent; 4009 int k, n; 4010 4011 local_got_entries = alpha_elf_tdata(j)->local_got_entries; 4012 if (!local_got_entries) 4013 continue; 4014 4015 for (k = 0, n = elf_tdata(j)->symtab_hdr.sh_info; k < n; ++k) 4016 for (gotent = local_got_entries[k]; 4017 gotent ; gotent = gotent->next) 4018 if (gotent->use_count > 0) 4019 entries += (alpha_dynamic_entries_for_reloc 4020 (gotent->reloc_type, 0, info->shared)); 4021 } 4022 } 4023 4024 dynobj = elf_hash_table(info)->dynobj; 4025 srel = bfd_get_section_by_name (dynobj, ".rela.got"); 4026 if (!srel) 4027 { 4028 BFD_ASSERT (entries == 0); 4029 return TRUE; 4030 } 4031 srel->_raw_size = sizeof (Elf64_External_Rela) * entries; 4032 4033 /* Now do the non-local symbols. */ 4034 alpha_elf_link_hash_traverse (alpha_elf_hash_table (info), 4035 elf64_alpha_size_rela_got_1, info); 4036 4037 srel->_cooked_size = srel->_raw_size; 4038 4039 return TRUE; 4040 } 4041 4042 /* Subroutine of elf64_alpha_size_rela_got_section for doing the 4043 global symbols. */ 4044 4045 static bfd_boolean 4046 elf64_alpha_size_rela_got_1 (h, info) 4047 struct alpha_elf_link_hash_entry *h; 4048 struct bfd_link_info *info; 4049 { 4050 bfd_boolean dynamic; 4051 struct alpha_elf_got_entry *gotent; 4052 unsigned long entries; 4053 4054 if (h->root.root.type == bfd_link_hash_warning) 4055 h = (struct alpha_elf_link_hash_entry *) h->root.root.u.i.link; 4056 4057 /* If the symbol is dynamic, we'll need all the relocations in their 4058 natural form. If this is a shared object, and it has been forced 4059 local, we'll need the same number of RELATIVE relocations. */ 4060 4061 dynamic = alpha_elf_dynamic_symbol_p (&h->root, info); 4062 4063 entries = 0; 4064 for (gotent = h->got_entries; gotent ; gotent = gotent->next) 4065 if (gotent->use_count > 0) 4066 entries += alpha_dynamic_entries_for_reloc (gotent->reloc_type, 4067 dynamic, info->shared); 4068 4069 /* If we are using a .plt entry, subtract one, as the first 4070 reference uses a .rela.plt entry instead. */ 4071 if (h->root.plt.offset != MINUS_ONE) 4072 entries--; 4073 4074 if (entries > 0) 4075 { 4076 bfd *dynobj = elf_hash_table(info)->dynobj; 4077 asection *srel = bfd_get_section_by_name (dynobj, ".rela.got"); 4078 BFD_ASSERT (srel != NULL); 4079 srel->_raw_size += sizeof (Elf64_External_Rela) * entries; 4080 } 4081 4082 return TRUE; 4083 } 4084 3215 4085 /* Set the sizes of the dynamic sections. */ 3216 4086 3217 static b oolean4087 static bfd_boolean 3218 4088 elf64_alpha_size_dynamic_sections (output_bfd, info) 3219 bfd *output_bfd ;4089 bfd *output_bfd ATTRIBUTE_UNUSED; 3220 4090 struct bfd_link_info *info; 3221 4091 { 3222 4092 bfd *dynobj; 3223 4093 asection *s; 3224 boolean reltext; 3225 boolean relplt; 4094 bfd_boolean relplt; 3226 4095 3227 4096 dynobj = elf_hash_table(info)->dynobj; … … 3244 4113 size the dynamic relocation sections. */ 3245 4114 alpha_elf_link_hash_traverse (alpha_elf_hash_table (info), 3246 elf64_alpha_calc_dynrel_sizes, 3247 info); 3248 3249 /* When building shared libraries, each local .got entry needs a 3250 RELATIVE reloc. */ 3251 if (info->shared) 3252 { 3253 bfd *i; 3254 asection *srel; 3255 bfd_size_type count; 3256 3257 srel = bfd_get_section_by_name (dynobj, ".rela.got"); 3258 BFD_ASSERT (srel != NULL); 3259 3260 for (i = alpha_elf_hash_table(info)->got_list, count = 0; 3261 i != NULL; 3262 i = alpha_elf_tdata(i)->got_link_next) 3263 count += alpha_elf_tdata(i)->n_local_got_entries; 3264 3265 srel->_raw_size += count * sizeof (Elf64_External_Rela); 3266 } 4115 elf64_alpha_calc_dynrel_sizes, info); 4116 4117 elf64_alpha_size_rela_got_section (info); 3267 4118 } 3268 4119 /* else we're not dynamic and by definition we don't need such things. */ … … 3271 4122 determined the sizes of the various dynamic sections. Allocate 3272 4123 memory for them. */ 3273 reltext = false; 3274 relplt = false; 4124 relplt = FALSE; 3275 4125 for (s = dynobj->sections; s != NULL; s = s->next) 3276 4126 { 3277 4127 const char *name; 3278 b oolean strip;4128 bfd_boolean strip; 3279 4129 3280 4130 if (!(s->flags & SEC_LINKER_CREATED)) … … 3293 4143 go into these sections. */ 3294 4144 3295 strip = false;4145 strip = FALSE; 3296 4146 3297 4147 if (strncmp (name, ".rela", 5) == 0) … … 3301 4151 if (!strip) 3302 4152 { 3303 const char *outname;3304 asection *target;3305 3306 /* If this relocation section applies to a read only3307 section, then we probably need a DT_TEXTREL entry. */3308 outname = bfd_get_section_name (output_bfd,3309 s->output_section);3310 target = bfd_get_section_by_name (output_bfd, outname + 5);3311 if (target != NULL3312 && (target->flags & SEC_READONLY) != 03313 && (target->flags & SEC_ALLOC) != 0)3314 reltext = true;3315 3316 4153 if (strcmp(name, ".rela.plt") == 0) 3317 relplt = true;4154 relplt = TRUE; 3318 4155 3319 4156 /* We use the reloc_count field as a counter if we need … … 3333 4170 { 3334 4171 /* Allocate memory for the section contents. */ 3335 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);4172 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); 3336 4173 if (s->contents == NULL && s->_raw_size != 0) 3337 return false;4174 return FALSE; 3338 4175 } 3339 4176 } … … 3346 4183 the .dynamic section. The DT_DEBUG entry is filled in by the 3347 4184 dynamic linker and used by the debugger. */ 4185 #define add_dynamic_entry(TAG, VAL) \ 4186 bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) 4187 3348 4188 if (!info->shared) 3349 4189 { 3350 if (!bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0)) 3351 return false; 3352 } 3353 3354 if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)) 3355 return false; 4190 if (!add_dynamic_entry (DT_DEBUG, 0)) 4191 return FALSE; 4192 } 3356 4193 3357 4194 if (relplt) 3358 4195 { 3359 if (! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)3360 || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)3361 || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))3362 return false;3363 }3364 3365 if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0) 3366 || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)3367 || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,3368 3369 return false;3370 3371 if ( reltext)3372 { 3373 if (! bfd_elf64_add_dynamic_entry (info,DT_TEXTREL, 0))3374 return false;3375 info->flags |= DF_TEXTREL;3376 3377 } 3378 3379 return true;4196 if (!add_dynamic_entry (DT_PLTGOT, 0) 4197 || !add_dynamic_entry (DT_PLTRELSZ, 0) 4198 || !add_dynamic_entry (DT_PLTREL, DT_RELA) 4199 || !add_dynamic_entry (DT_JMPREL, 0)) 4200 return FALSE; 4201 } 4202 4203 if (!add_dynamic_entry (DT_RELA, 0) 4204 || !add_dynamic_entry (DT_RELASZ, 0) 4205 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela))) 4206 return FALSE; 4207 4208 if (info->flags & DF_TEXTREL) 4209 { 4210 if (!add_dynamic_entry (DT_TEXTREL, 0)) 4211 return FALSE; 4212 } 4213 } 4214 #undef add_dynamic_entry 4215 4216 return TRUE; 3380 4217 } 3381 4218 4219 /* Emit a dynamic relocation for (DYNINDX, RTYPE, ADDEND) at (SEC, OFFSET) 4220 into the next available slot in SREL. */ 4221 4222 static void 4223 elf64_alpha_emit_dynrel (abfd, info, sec, srel, offset, dynindx, rtype, addend) 4224 bfd *abfd; 4225 struct bfd_link_info *info; 4226 asection *sec, *srel; 4227 bfd_vma offset, addend; 4228 long dynindx, rtype; 4229 { 4230 Elf_Internal_Rela outrel; 4231 bfd_byte *loc; 4232 4233 BFD_ASSERT (srel != NULL); 4234 4235 outrel.r_info = ELF64_R_INFO (dynindx, rtype); 4236 outrel.r_addend = addend; 4237 4238 offset = _bfd_elf_section_offset (abfd, info, sec, offset); 4239 if ((offset | 1) != (bfd_vma) -1) 4240 outrel.r_offset = sec->output_section->vma + sec->output_offset + offset; 4241 else 4242 memset (&outrel, 0, sizeof (outrel)); 4243 4244 loc = srel->contents; 4245 loc += srel->reloc_count++ * sizeof (Elf64_External_Rela); 4246 bfd_elf64_swap_reloca_out (abfd, &outrel, loc); 4247 BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count 4248 <= srel->_cooked_size); 4249 } 4250 4251 /* Relocate an Alpha ELF section for a relocatable link. 4252 4253 We don't have to change anything unless the reloc is against a section 4254 symbol, in which case we have to adjust according to where the section 4255 symbol winds up in the output section. */ 4256 4257 static bfd_boolean 4258 elf64_alpha_relocate_section_r (output_bfd, info, input_bfd, input_section, 4259 contents, relocs, local_syms, local_sections) 4260 bfd *output_bfd ATTRIBUTE_UNUSED; 4261 struct bfd_link_info *info ATTRIBUTE_UNUSED; 4262 bfd *input_bfd; 4263 asection *input_section; 4264 bfd_byte *contents ATTRIBUTE_UNUSED; 4265 Elf_Internal_Rela *relocs; 4266 Elf_Internal_Sym *local_syms; 4267 asection **local_sections; 4268 { 4269 unsigned long symtab_hdr_sh_info; 4270 Elf_Internal_Rela *rel; 4271 Elf_Internal_Rela *relend; 4272 bfd_boolean ret_val = TRUE; 4273 4274 symtab_hdr_sh_info = elf_tdata (input_bfd)->symtab_hdr.sh_info; 4275 4276 relend = relocs + input_section->reloc_count; 4277 for (rel = relocs; rel < relend; rel++) 4278 { 4279 unsigned long r_symndx; 4280 Elf_Internal_Sym *sym; 4281 asection *sec; 4282 unsigned long r_type; 4283 4284 r_type = ELF64_R_TYPE(rel->r_info); 4285 if (r_type >= R_ALPHA_max) 4286 { 4287 (*_bfd_error_handler) 4288 (_("%s: unknown relocation type %d"), 4289 bfd_archive_filename (input_bfd), (int)r_type); 4290 bfd_set_error (bfd_error_bad_value); 4291 ret_val = FALSE; 4292 continue; 4293 } 4294 4295 r_symndx = ELF64_R_SYM(rel->r_info); 4296 4297 /* The symbol associated with GPDISP and LITUSE is 4298 immaterial. Only the addend is significant. */ 4299 if (r_type == R_ALPHA_GPDISP || r_type == R_ALPHA_LITUSE) 4300 continue; 4301 4302 if (r_symndx < symtab_hdr_sh_info) 4303 { 4304 sym = local_syms + r_symndx; 4305 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) 4306 { 4307 sec = local_sections[r_symndx]; 4308 rel->r_addend += sec->output_offset + sym->st_value; 4309 } 4310 } 4311 } 4312 4313 return ret_val; 4314 } 4315 3382 4316 /* Relocate an Alpha ELF section. */ 3383 4317 3384 static b oolean4318 static bfd_boolean 3385 4319 elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, 3386 4320 contents, relocs, local_syms, local_sections) … … 3397 4331 Elf_Internal_Rela *rel; 3398 4332 Elf_Internal_Rela *relend; 3399 asection *sec, *sgot, *srel, *srelgot; 4333 struct elf_link_tls_segment *tls_segment; 4334 asection *sgot, *srel, *srelgot; 3400 4335 bfd *dynobj, *gotobj; 3401 bfd_vma gp; 3402 3403 srelgot = srel = NULL; 4336 bfd_vma gp, tp_base, dtp_base; 4337 struct alpha_elf_got_entry **local_got_entries; 4338 bfd_boolean ret_val; 4339 const char *section_name; 4340 4341 /* Handle relocatable links with a smaller loop. */ 4342 if (info->relocateable) 4343 return elf64_alpha_relocate_section_r (output_bfd, info, input_bfd, 4344 input_section, contents, relocs, 4345 local_syms, local_sections); 4346 4347 /* This is a final link. */ 4348 4349 ret_val = TRUE; 4350 3404 4351 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; 4352 3405 4353 dynobj = elf_hash_table (info)->dynobj; 3406 4354 if (dynobj) 3407 { 3408 srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); 3409 } 4355 srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); 4356 else 4357 srelgot = NULL; 4358 4359 section_name = (bfd_elf_string_from_elf_section 4360 (input_bfd, elf_elfheader(input_bfd)->e_shstrndx, 4361 elf_section_data(input_section)->rel_hdr.sh_name)); 4362 BFD_ASSERT(section_name != NULL); 4363 srel = bfd_get_section_by_name (dynobj, section_name); 3410 4364 3411 4365 /* Find the gp value for this input bfd. */ 3412 sgot = NULL;3413 gp = 0;3414 4366 gotobj = alpha_elf_tdata (input_bfd)->gotobj; 3415 4367 if (gotobj) … … 3425 4377 } 3426 4378 } 3427 3428 rel = relocs; 4379 else 4380 { 4381 sgot = NULL; 4382 gp = 0; 4383 } 4384 4385 local_got_entries = alpha_elf_tdata(input_bfd)->local_got_entries; 4386 4387 tls_segment = elf_hash_table (info)->tls_segment; 4388 if (tls_segment) 4389 { 4390 dtp_base = alpha_get_dtprel_base (tls_segment); 4391 tp_base = alpha_get_tprel_base (tls_segment); 4392 } 4393 else 4394 dtp_base = tp_base = 0; 4395 3429 4396 relend = relocs + input_section->reloc_count; 3430 for (; rel < relend; rel++) 3431 { 3432 int r_type; 4397 for (rel = relocs; rel < relend; rel++) 4398 { 4399 struct alpha_elf_link_hash_entry *h = NULL; 4400 struct alpha_elf_got_entry *gotent; 4401 bfd_reloc_status_type r; 3433 4402 reloc_howto_type *howto; 3434 4403 unsigned long r_symndx; 3435 struct alpha_elf_link_hash_entry *h;3436 Elf_Internal_Sym *sym;3437 bfd_vma relocation;4404 Elf_Internal_Sym *sym = NULL; 4405 asection *sec = NULL; 4406 bfd_vma value; 3438 4407 bfd_vma addend; 3439 bfd_reloc_status_type r; 4408 bfd_boolean dynamic_symbol_p; 4409 bfd_boolean undef_weak_ref = FALSE; 4410 unsigned long r_type; 3440 4411 3441 4412 r_type = ELF64_R_TYPE(rel->r_info); 3442 if (r_type < 0 || r_type >= (int) R_ALPHA_max) 3443 { 4413 if (r_type >= R_ALPHA_max) 4414 { 4415 (*_bfd_error_handler) 4416 (_("%s: unknown relocation type %d"), 4417 bfd_archive_filename (input_bfd), (int)r_type); 3444 4418 bfd_set_error (bfd_error_bad_value); 3445 return false; 3446 } 4419 ret_val = FALSE; 4420 continue; 4421 } 4422 3447 4423 howto = elf64_alpha_howto_table + r_type; 3448 3449 4424 r_symndx = ELF64_R_SYM(rel->r_info); 3450 4425 3451 if (info->relocateable) 3452 { 3453 /* This is a relocateable link. We don't have to change 3454 anything, unless the reloc is against a section symbol, 3455 in which case we have to adjust according to where the 3456 section symbol winds up in the output section. */ 3457 3458 /* The symbol associated with GPDISP and LITUSE is 3459 immaterial. Only the addend is significant. */ 3460 if (r_type == R_ALPHA_GPDISP || r_type == R_ALPHA_LITUSE) 3461 continue; 3462 3463 if (r_symndx < symtab_hdr->sh_info) 4426 /* The symbol for a TLSLDM reloc is ignored. Collapse the 4427 reloc to the 0 symbol so that they all match. */ 4428 if (r_type == R_ALPHA_TLSLDM) 4429 r_symndx = 0; 4430 4431 if (r_symndx < symtab_hdr->sh_info) 4432 { 4433 sym = local_syms + r_symndx; 4434 sec = local_sections[r_symndx]; 4435 value = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); 4436 4437 /* If this is a tp-relative relocation against sym 0, 4438 this is hackery from relax_section. Force the value to 4439 be the tls base. */ 4440 if (r_symndx == 0 4441 && (r_type == R_ALPHA_TLSLDM 4442 || r_type == R_ALPHA_GOTTPREL 4443 || r_type == R_ALPHA_TPREL64 4444 || r_type == R_ALPHA_TPRELHI 4445 || r_type == R_ALPHA_TPRELLO 4446 || r_type == R_ALPHA_TPREL16)) 4447 value = tp_base; 4448 4449 if (local_got_entries) 4450 gotent = local_got_entries[r_symndx]; 4451 else 4452 gotent = NULL; 4453 4454 /* Need to adjust local GOT entries' addends for SEC_MERGE 4455 unless it has been done already. */ 4456 if ((sec->flags & SEC_MERGE) 4457 && ELF_ST_TYPE (sym->st_info) == STT_SECTION 4458 && sec->sec_info_type == ELF_INFO_TYPE_MERGE 4459 && gotent 4460 && !gotent->reloc_xlated) 3464 4461 { 3465 sym = local_syms + r_symndx; 3466 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) 4462 struct alpha_elf_got_entry *ent; 4463 asection *msec; 4464 4465 for (ent = gotent; ent; ent = ent->next) 3467 4466 { 3468 sec = local_sections[r_symndx]; 3469 rel->r_addend += sec->output_offset + sym->st_value; 4467 ent->reloc_xlated = 1; 4468 if (ent->use_count == 0) 4469 continue; 4470 msec = sec; 4471 ent->addend = 4472 _bfd_merged_section_offset (output_bfd, &msec, 4473 elf_section_data (sec)-> 4474 sec_info, 4475 sym->st_value + ent->addend, 4476 (bfd_vma) 0); 4477 ent->addend -= sym->st_value; 4478 ent->addend += msec->output_section->vma 4479 + msec->output_offset 4480 - sec->output_section->vma 4481 - sec->output_offset; 3470 4482 } 3471 4483 } 3472 4484 3473 continue; 3474 } 3475 3476 /* This is a final link. */ 3477 3478 h = NULL; 3479 sym = NULL; 3480 sec = NULL; 3481 3482 if (r_symndx < symtab_hdr->sh_info) 3483 { 3484 sym = local_syms + r_symndx; 3485 sec = local_sections[r_symndx]; 3486 relocation = (sec->output_section->vma 3487 + sec->output_offset 3488 + sym->st_value); 4485 dynamic_symbol_p = FALSE; 3489 4486 } 3490 4487 else … … 3496 4493 h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link; 3497 4494 4495 value = 0; 3498 4496 if (h->root.root.type == bfd_link_hash_defined 3499 4497 || h->root.root.type == bfd_link_hash_defweak) … … 3501 4499 sec = h->root.root.u.def.section; 3502 4500 3503 #if rth_notdef 3504 if ((r_type == R_ALPHA_LITERAL 3505 && elf_hash_table(info)->dynamic_sections_created 3506 && (!info->shared 3507 || !info->symbolic 3508 || !(h->root.elf_link_hash_flags 3509 & ELF_LINK_HASH_DEF_REGULAR))) 3510 || (info->shared 3511 && (!info->symbolic 3512 || !(h->root.elf_link_hash_flags 3513 & ELF_LINK_HASH_DEF_REGULAR)) 3514 && (input_section->flags & SEC_ALLOC) 3515 && (r_type == R_ALPHA_REFLONG 3516 || r_type == R_ALPHA_REFQUAD 3517 || r_type == R_ALPHA_LITERAL))) 3518 { 3519 /* In these cases, we don't need the relocation value. 3520 We check specially because in some obscure cases 3521 sec->output_section will be NULL. */ 3522 relocation = 0; 3523 } 3524 #else 3525 /* FIXME: Are not these obscure cases simply bugs? Let's 3526 get something working and come back to this. */ 3527 if (sec->output_section == NULL) 3528 relocation = 0; 3529 #endif /* rth_notdef */ 3530 else 3531 { 3532 relocation = (h->root.root.u.def.value 3533 + sec->output_section->vma 3534 + sec->output_offset); 3535 } 4501 /* Detect the cases that sym_sec->output_section is 4502 expected to be NULL -- all cases in which the symbol 4503 is defined in another shared module. This includes 4504 PLT relocs for which we've created a PLT entry and 4505 other relocs for which we're prepared to create 4506 dynamic relocations. */ 4507 /* ??? Just accept it NULL and continue. */ 4508 4509 if (sec->output_section != NULL) 4510 value = (h->root.root.u.def.value 4511 + sec->output_section->vma 4512 + sec->output_offset); 3536 4513 } 3537 4514 else if (h->root.root.type == bfd_link_hash_undefweak) 3538 relocation = 0;3539 else if (info->shared && !info->symbolic4515 undef_weak_ref = TRUE; 4516 else if (info->shared 3540 4517 && !info->no_undefined 3541 4518 && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT) 3542 relocation = 0;4519 ; 3543 4520 else 3544 4521 { … … 3548 4525 (!info->shared || info->no_undefined 3549 4526 || ELF_ST_VISIBILITY (h->root.other))))) 3550 return false;3551 relocation = 0;4527 return FALSE; 4528 continue; 3552 4529 } 3553 } 4530 4531 dynamic_symbol_p = alpha_elf_dynamic_symbol_p (&h->root, info); 4532 gotent = h->got_entries; 4533 } 4534 3554 4535 addend = rel->r_addend; 4536 value += addend; 4537 4538 /* Search for the proper got entry. */ 4539 for (; gotent ; gotent = gotent->next) 4540 if (gotent->gotobj == gotobj 4541 && gotent->reloc_type == r_type 4542 && gotent->addend == addend) 4543 break; 3555 4544 3556 4545 switch (r_type) … … 3562 4551 BFD_ASSERT(gp != 0); 3563 4552 3564 relocation= (input_section->output_section->vma3565 3566 3567 3568 p_ldah = contents + rel->r_offset - input_section->vma;4553 value = (input_section->output_section->vma 4554 + input_section->output_offset 4555 + rel->r_offset); 4556 4557 p_ldah = contents + rel->r_offset; 3569 4558 p_lda = p_ldah + rel->r_addend; 3570 4559 3571 r = elf64_alpha_do_reloc_gpdisp (input_bfd, gp - relocation,4560 r = elf64_alpha_do_reloc_gpdisp (input_bfd, gp - value, 3572 4561 p_ldah, p_lda); 3573 4562 } 3574 4563 break; 3575 4564 3576 case R_ALPHA_OP_PUSH:3577 case R_ALPHA_OP_STORE:3578 case R_ALPHA_OP_PSUB:3579 case R_ALPHA_OP_PRSHIFT:3580 /* We hate these silly beasts. */3581 abort ();3582 3583 4565 case R_ALPHA_LITERAL: 3584 { 3585 struct alpha_elf_got_entry *gotent; 3586 boolean dynamic_symbol; 3587 3588 BFD_ASSERT(sgot != NULL); 3589 BFD_ASSERT(gp != 0); 3590 3591 if (h != NULL) 3592 { 3593 gotent = h->got_entries; 3594 dynamic_symbol = alpha_elf_dynamic_symbol_p (&h->root, info); 3595 } 3596 else 3597 { 3598 gotent = (alpha_elf_tdata(input_bfd)-> 3599 local_got_entries[r_symndx]); 3600 dynamic_symbol = false; 3601 } 3602 3603 BFD_ASSERT(gotent != NULL); 3604 3605 while (gotent->gotobj != gotobj || gotent->addend != addend) 3606 gotent = gotent->next; 3607 3608 BFD_ASSERT(gotent->use_count >= 1); 3609 3610 /* Initialize the .got entry's value. */ 3611 if (!(gotent->flags & ALPHA_ELF_GOT_ENTRY_RELOCS_DONE)) 3612 { 3613 bfd_put_64 (output_bfd, relocation+addend, 3614 sgot->contents + gotent->got_offset); 3615 3616 /* If the symbol has been forced local, output a 3617 RELATIVE reloc, otherwise it will be handled in 3618 finish_dynamic_symbol. */ 3619 if (info->shared && !dynamic_symbol) 3620 { 3621 Elf_Internal_Rela outrel; 3622 3623 BFD_ASSERT(srelgot != NULL); 3624 3625 outrel.r_offset = (sgot->output_section->vma 3626 + sgot->output_offset 3627 + gotent->got_offset); 3628 outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE); 3629 outrel.r_addend = 0; 3630 3631 bfd_elf64_swap_reloca_out (output_bfd, &outrel, 3632 ((Elf64_External_Rela *) 3633 srelgot->contents) 3634 + srelgot->reloc_count++); 3635 BFD_ASSERT (sizeof (Elf64_External_Rela) 3636 * srelgot->reloc_count 3637 <= srelgot->_cooked_size); 3638 } 3639 3640 gotent->flags |= ALPHA_ELF_GOT_ENTRY_RELOCS_DONE; 3641 } 3642 3643 /* Figure the gprel relocation. */ 3644 addend = 0; 3645 relocation = (sgot->output_section->vma 3646 + sgot->output_offset 3647 + gotent->got_offset); 3648 relocation -= gp; 3649 } 3650 /* overflow handled by _bfd_final_link_relocate */ 4566 BFD_ASSERT(sgot != NULL); 4567 BFD_ASSERT(gp != 0); 4568 BFD_ASSERT(gotent != NULL); 4569 BFD_ASSERT(gotent->use_count >= 1); 4570 4571 if (!gotent->reloc_done) 4572 { 4573 gotent->reloc_done = 1; 4574 4575 bfd_put_64 (output_bfd, value, 4576 sgot->contents + gotent->got_offset); 4577 4578 /* If the symbol has been forced local, output a 4579 RELATIVE reloc, otherwise it will be handled in 4580 finish_dynamic_symbol. */ 4581 if (info->shared && !dynamic_symbol_p) 4582 elf64_alpha_emit_dynrel (output_bfd, info, sgot, srelgot, 4583 gotent->got_offset, 0, 4584 R_ALPHA_RELATIVE, value); 4585 } 4586 4587 value = (sgot->output_section->vma 4588 + sgot->output_offset 4589 + gotent->got_offset); 4590 value -= gp; 3651 4591 goto default_reloc; 3652 4592 3653 4593 case R_ALPHA_GPREL32: 4594 /* If the target section was a removed linkonce section, 4595 r_symndx will be zero. In this case, assume that the 4596 switch will not be used, so don't fill it in. If we 4597 do nothing here, we'll get relocation truncated messages, 4598 due to the placement of the application above 4GB. */ 4599 if (r_symndx == 0) 4600 { 4601 r = bfd_reloc_ok; 4602 break; 4603 } 4604 /* FALLTHRU */ 4605 4606 case R_ALPHA_GPREL16: 3654 4607 case R_ALPHA_GPRELLOW: 4608 if (dynamic_symbol_p) 4609 { 4610 (*_bfd_error_handler) 4611 (_("%s: gp-relative relocation against dynamic symbol %s"), 4612 bfd_archive_filename (input_bfd), h->root.root.root.string); 4613 ret_val = FALSE; 4614 } 3655 4615 BFD_ASSERT(gp != 0); 3656 relocation-= gp;4616 value -= gp; 3657 4617 goto default_reloc; 3658 4618 3659 4619 case R_ALPHA_GPRELHIGH: 4620 if (dynamic_symbol_p) 4621 { 4622 (*_bfd_error_handler) 4623 (_("%s: gp-relative relocation against dynamic symbol %s"), 4624 bfd_archive_filename (input_bfd), h->root.root.root.string); 4625 ret_val = FALSE; 4626 } 3660 4627 BFD_ASSERT(gp != 0); 3661 relocation -= gp; 3662 relocation += addend; 3663 addend = 0; 3664 relocation = (((bfd_signed_vma) relocation >> 16) 3665 + ((relocation >> 15) & 1)); 4628 value -= gp; 4629 value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1); 3666 4630 goto default_reloc; 3667 4631 3668 case R_ALPHA_BRADDR:3669 4632 case R_ALPHA_HINT: 4633 /* A call to a dynamic symbol is definitely out of range of 4634 the 16-bit displacement. Don't bother writing anything. */ 4635 if (dynamic_symbol_p) 4636 { 4637 r = bfd_reloc_ok; 4638 break; 4639 } 3670 4640 /* The regular PC-relative stuff measures from the start of 3671 4641 the instruction rather than the end. */ 3672 addend-= 4;4642 value -= 4; 3673 4643 goto default_reloc; 4644 4645 case R_ALPHA_BRADDR: 4646 if (dynamic_symbol_p) 4647 { 4648 (*_bfd_error_handler) 4649 (_("%s: pc-relative relocation against dynamic symbol %s"), 4650 bfd_archive_filename (input_bfd), h->root.root.root.string); 4651 ret_val = FALSE; 4652 } 4653 /* The regular PC-relative stuff measures from the start of 4654 the instruction rather than the end. */ 4655 value -= 4; 4656 goto default_reloc; 4657 4658 case R_ALPHA_BRSGP: 4659 { 4660 int other; 4661 const char *name; 4662 4663 /* The regular PC-relative stuff measures from the start of 4664 the instruction rather than the end. */ 4665 value -= 4; 4666 4667 /* The source and destination gp must be the same. Note that 4668 the source will always have an assigned gp, since we forced 4669 one in check_relocs, but that the destination may not, as 4670 it might not have had any relocations at all. Also take 4671 care not to crash if H is an undefined symbol. */ 4672 if (h != NULL && sec != NULL 4673 && alpha_elf_tdata (sec->owner)->gotobj 4674 && gotobj != alpha_elf_tdata (sec->owner)->gotobj) 4675 { 4676 (*_bfd_error_handler) 4677 (_("%s: change in gp: BRSGP %s"), 4678 bfd_archive_filename (input_bfd), h->root.root.root.string); 4679 ret_val = FALSE; 4680 } 4681 4682 /* The symbol should be marked either NOPV or STD_GPLOAD. */ 4683 if (h != NULL) 4684 other = h->root.other; 4685 else 4686 other = sym->st_other; 4687 switch (other & STO_ALPHA_STD_GPLOAD) 4688 { 4689 case STO_ALPHA_NOPV: 4690 break; 4691 case STO_ALPHA_STD_GPLOAD: 4692 value += 8; 4693 break; 4694 default: 4695 if (h != NULL) 4696 name = h->root.root.root.string; 4697 else 4698 { 4699 name = (bfd_elf_string_from_elf_section 4700 (input_bfd, symtab_hdr->sh_link, sym->st_name)); 4701 if (name == NULL) 4702 name = _("<unknown>"); 4703 else if (name[0] == 0) 4704 name = bfd_section_name (input_bfd, sec); 4705 } 4706 (*_bfd_error_handler) 4707 (_("%s: !samegp reloc against symbol without .prologue: %s"), 4708 bfd_archive_filename (input_bfd), name); 4709 ret_val = FALSE; 4710 break; 4711 } 4712 4713 goto default_reloc; 4714 } 3674 4715 3675 4716 case R_ALPHA_REFLONG: 3676 4717 case R_ALPHA_REFQUAD: 4718 case R_ALPHA_DTPREL64: 4719 case R_ALPHA_TPREL64: 3677 4720 { 3678 Elf_Internal_Rela outrel;3679 b oolean skip;4721 long dynindx, dyntype = r_type; 4722 bfd_vma dynaddend; 3680 4723 3681 4724 /* Careful here to remember RELATIVE relocations for global 3682 4725 variables for symbolic shared objects. */ 3683 4726 3684 if ( h && alpha_elf_dynamic_symbol_p (&h->root, info))4727 if (dynamic_symbol_p) 3685 4728 { 3686 4729 BFD_ASSERT(h->root.dynindx != -1); 3687 outrel.r_info = ELF64_R_INFO(h->root.dynindx, r_type);3688 outrel.r_addend = addend;3689 addend = 0, relocation= 0;4730 dynindx = h->root.dynindx; 4731 dynaddend = addend; 4732 addend = 0, value = 0; 3690 4733 } 3691 else if ( info->shared && (input_section->flags & SEC_ALLOC))4734 else if (r_type == R_ALPHA_DTPREL64) 3692 4735 { 3693 outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE); 3694 outrel.r_addend = 0; 4736 BFD_ASSERT(tls_segment != NULL); 4737 value -= dtp_base; 4738 goto default_reloc; 4739 } 4740 else if (r_type == R_ALPHA_TPREL64) 4741 { 4742 BFD_ASSERT(tls_segment != NULL); 4743 if (!info->shared) 4744 { 4745 value -= tp_base; 4746 goto default_reloc; 4747 } 4748 dynindx = 0; 4749 dynaddend = value - dtp_base; 4750 } 4751 else if (info->shared 4752 && r_symndx != 0 4753 && (input_section->flags & SEC_ALLOC)) 4754 { 4755 if (r_type == R_ALPHA_REFLONG) 4756 { 4757 (*_bfd_error_handler) 4758 (_("%s: unhandled dynamic relocation against %s"), 4759 bfd_archive_filename (input_bfd), 4760 h->root.root.root.string); 4761 ret_val = FALSE; 4762 } 4763 dynindx = 0; 4764 dyntype = R_ALPHA_RELATIVE; 4765 dynaddend = value; 3695 4766 } 3696 4767 else 3697 4768 goto default_reloc; 3698 4769 3699 if (!srel) 3700 { 3701 const char *name; 3702 3703 name = (bfd_elf_string_from_elf_section 3704 (input_bfd, elf_elfheader(input_bfd)->e_shstrndx, 3705 elf_section_data(input_section)->rel_hdr.sh_name)); 3706 BFD_ASSERT(name != NULL); 3707 3708 srel = bfd_get_section_by_name (dynobj, name); 3709 BFD_ASSERT(srel != NULL); 3710 } 3711 3712 skip = false; 3713 3714 if (elf_section_data (input_section)->stab_info == NULL) 3715 outrel.r_offset = rel->r_offset; 3716 else 3717 { 3718 bfd_vma off; 3719 3720 off = (_bfd_stab_section_offset 3721 (output_bfd, &elf_hash_table (info)->stab_info, 3722 input_section, 3723 &elf_section_data (input_section)->stab_info, 3724 rel->r_offset)); 3725 if (off == (bfd_vma) -1) 3726 skip = true; 3727 outrel.r_offset = off; 3728 } 3729 3730 if (! skip) 3731 outrel.r_offset += (input_section->output_section->vma 3732 + input_section->output_offset); 3733 else 3734 memset (&outrel, 0, sizeof outrel); 3735 3736 bfd_elf64_swap_reloca_out (output_bfd, &outrel, 3737 ((Elf64_External_Rela *) 3738 srel->contents) 3739 + srel->reloc_count++); 3740 BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count 3741 <= srel->_cooked_size); 4770 elf64_alpha_emit_dynrel (output_bfd, info, input_section, 4771 srel, rel->r_offset, dynindx, 4772 dyntype, dynaddend); 3742 4773 } 4774 goto default_reloc; 4775 4776 case R_ALPHA_SREL16: 4777 case R_ALPHA_SREL32: 4778 case R_ALPHA_SREL64: 4779 if (dynamic_symbol_p) 4780 { 4781 (*_bfd_error_handler) 4782 (_("%s: pc-relative relocation against dynamic symbol %s"), 4783 bfd_archive_filename (input_bfd), h->root.root.root.string); 4784 ret_val = FALSE; 4785 } 4786 4787 /* ??? .eh_frame references to discarded sections will be smashed 4788 to relocations against SHN_UNDEF. The .eh_frame format allows 4789 NULL to be encoded as 0 in any format, so this works here. */ 4790 if (r_symndx == 0) 4791 howto = (elf64_alpha_howto_table 4792 + (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG)); 4793 goto default_reloc; 4794 4795 case R_ALPHA_TLSLDM: 4796 /* Ignore the symbol for the relocation. The result is always 4797 the current module. */ 4798 dynamic_symbol_p = 0; 4799 /* FALLTHRU */ 4800 4801 case R_ALPHA_TLSGD: 4802 if (!gotent->reloc_done) 4803 { 4804 gotent->reloc_done = 1; 4805 4806 /* Note that the module index for the main program is 1. */ 4807 bfd_put_64 (output_bfd, !info->shared && !dynamic_symbol_p, 4808 sgot->contents + gotent->got_offset); 4809 4810 /* If the symbol has been forced local, output a 4811 DTPMOD64 reloc, otherwise it will be handled in 4812 finish_dynamic_symbol. */ 4813 if (info->shared && !dynamic_symbol_p) 4814 elf64_alpha_emit_dynrel (output_bfd, info, sgot, srelgot, 4815 gotent->got_offset, 0, 4816 R_ALPHA_DTPMOD64, 0); 4817 4818 if (dynamic_symbol_p || r_type == R_ALPHA_TLSLDM) 4819 value = 0; 4820 else 4821 { 4822 BFD_ASSERT(tls_segment != NULL); 4823 value -= dtp_base; 4824 } 4825 bfd_put_64 (output_bfd, value, 4826 sgot->contents + gotent->got_offset + 8); 4827 } 4828 4829 value = (sgot->output_section->vma 4830 + sgot->output_offset 4831 + gotent->got_offset); 4832 value -= gp; 4833 goto default_reloc; 4834 4835 case R_ALPHA_DTPRELHI: 4836 case R_ALPHA_DTPRELLO: 4837 case R_ALPHA_DTPREL16: 4838 if (dynamic_symbol_p) 4839 { 4840 (*_bfd_error_handler) 4841 (_("%s: dtp-relative relocation against dynamic symbol %s"), 4842 bfd_archive_filename (input_bfd), h->root.root.root.string); 4843 ret_val = FALSE; 4844 } 4845 BFD_ASSERT(tls_segment != NULL); 4846 value -= dtp_base; 4847 if (r_type == R_ALPHA_DTPRELHI) 4848 value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1); 4849 goto default_reloc; 4850 4851 case R_ALPHA_TPRELHI: 4852 case R_ALPHA_TPRELLO: 4853 case R_ALPHA_TPREL16: 4854 if (info->shared) 4855 { 4856 (*_bfd_error_handler) 4857 (_("%s: TLS local exec code cannot be linked into shared objects"), 4858 bfd_archive_filename (input_bfd)); 4859 ret_val = FALSE; 4860 } 4861 else if (dynamic_symbol_p) 4862 { 4863 (*_bfd_error_handler) 4864 (_("%s: tp-relative relocation against dynamic symbol %s"), 4865 bfd_archive_filename (input_bfd), h->root.root.root.string); 4866 ret_val = FALSE; 4867 } 4868 BFD_ASSERT(tls_segment != NULL); 4869 value -= tp_base; 4870 if (r_type == R_ALPHA_TPRELHI) 4871 value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1); 4872 goto default_reloc; 4873 4874 case R_ALPHA_GOTDTPREL: 4875 case R_ALPHA_GOTTPREL: 4876 BFD_ASSERT(sgot != NULL); 4877 BFD_ASSERT(gp != 0); 4878 BFD_ASSERT(gotent != NULL); 4879 BFD_ASSERT(gotent->use_count >= 1); 4880 4881 if (!gotent->reloc_done) 4882 { 4883 gotent->reloc_done = 1; 4884 4885 if (dynamic_symbol_p) 4886 value = 0; 4887 else 4888 { 4889 BFD_ASSERT(tls_segment != NULL); 4890 if (r_type == R_ALPHA_GOTDTPREL) 4891 value -= dtp_base; 4892 else if (!info->shared) 4893 value -= tp_base; 4894 else 4895 { 4896 elf64_alpha_emit_dynrel (output_bfd, info, sgot, srelgot, 4897 gotent->got_offset, 0, 4898 R_ALPHA_TPREL64, 4899 value - dtp_base); 4900 value = 0; 4901 } 4902 } 4903 bfd_put_64 (output_bfd, value, 4904 sgot->contents + gotent->got_offset); 4905 } 4906 4907 value = (sgot->output_section->vma 4908 + sgot->output_offset 4909 + gotent->got_offset); 4910 value -= gp; 3743 4911 goto default_reloc; 3744 4912 … … 3746 4914 default_reloc: 3747 4915 r = _bfd_final_link_relocate (howto, input_bfd, input_section, 3748 contents, rel->r_offset, relocation, 3749 addend); 4916 contents, rel->r_offset, value, 0); 3750 4917 break; 3751 4918 } … … 3759 4926 { 3760 4927 const char *name; 4928 4929 /* Don't warn if the overflow is due to pc relative reloc 4930 against discarded section. Section optimization code should 4931 handle it. */ 4932 4933 if (r_symndx < symtab_hdr->sh_info 4934 && sec != NULL && howto->pc_relative 4935 && elf_discarded_section (sec)) 4936 break; 3761 4937 3762 4938 if (h != NULL) … … 3767 4943 (input_bfd, symtab_hdr->sh_link, sym->st_name)); 3768 4944 if (name == NULL) 3769 return false;4945 return FALSE; 3770 4946 if (*name == '\0') 3771 4947 name = bfd_section_name (input_bfd, sec); … … 3774 4950 (info, name, howto->name, (bfd_vma) 0, 3775 4951 input_bfd, input_section, rel->r_offset))) 3776 ret urn false;4952 ret_val = FALSE; 3777 4953 } 3778 4954 break; … … 3784 4960 } 3785 4961 3786 return true;4962 return ret_val; 3787 4963 } 3788 4964 … … 3790 4966 dynamic sections here. */ 3791 4967 3792 static b oolean4968 static bfd_boolean 3793 4969 elf64_alpha_finish_dynamic_symbol (output_bfd, info, h, sym) 3794 4970 bfd *output_bfd; … … 3804 4980 asection *splt, *sgot, *srel; 3805 4981 Elf_Internal_Rela outrel; 4982 bfd_byte *loc; 3806 4983 bfd_vma got_addr, plt_addr; 3807 4984 bfd_vma plt_index; … … 3833 5010 /* Fill in the entry in the procedure linkage table. */ 3834 5011 { 3835 unsignedinsn1, insn2, insn3;5012 bfd_vma insn1, insn2, insn3; 3836 5013 3837 5014 insn1 = PLT_ENTRY_WORD1 | ((-(h->plt.offset + 4) >> 2) & 0x1fffff); … … 3849 5026 outrel.r_addend = 0; 3850 5027 3851 bfd_elf64_swap_reloca_out (output_bfd, &outrel, 3852 ((Elf64_External_Rela *)srel->contents 3853 + plt_index)); 5028 loc = srel->contents + plt_index * sizeof (Elf64_External_Rela); 5029 bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); 3854 5030 3855 5031 if (!(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) … … 3880 5056 3881 5057 if (info->shared) 3882 { 3883 outrel.r_offset = (sgot->output_section->vma 3884 + sgot->output_offset 3885 + gotent->got_offset); 3886 outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE); 3887 outrel.r_addend = 0; 3888 3889 bfd_elf64_swap_reloca_out (output_bfd, &outrel, 3890 ((Elf64_External_Rela *) 3891 srel->contents) 3892 + srel->reloc_count++); 3893 BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count 3894 <= srel->_cooked_size); 3895 } 5058 elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel, 5059 gotent->got_offset, 0, 5060 R_ALPHA_RELATIVE, plt_addr); 3896 5061 3897 5062 gotent = gotent->next; … … 3904 5069 /* Fill in the dynamic relocations for this symbol's .got entries. */ 3905 5070 asection *srel; 3906 Elf_Internal_Rela outrel;3907 5071 struct alpha_elf_got_entry *gotent; 3908 5072 … … 3910 5074 BFD_ASSERT (srel != NULL); 3911 5075 3912 outrel.r_info = ELF64_R_INFO (h->dynindx, R_ALPHA_GLOB_DAT);3913 5076 for (gotent = ((struct alpha_elf_link_hash_entry *) h)->got_entries; 3914 5077 gotent != NULL; 3915 5078 gotent = gotent->next) 3916 5079 { 3917 asection *sgot = alpha_elf_tdata (gotent->gotobj)->got; 3918 outrel.r_offset = (sgot->output_section->vma 3919 + sgot->output_offset 3920 + gotent->got_offset); 3921 outrel.r_addend = gotent->addend; 3922 3923 bfd_elf64_swap_reloca_out (output_bfd, &outrel, 3924 ((Elf64_External_Rela *)srel->contents 3925 + srel->reloc_count++)); 3926 BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count 3927 <= srel->_cooked_size); 5080 asection *sgot; 5081 long r_type; 5082 5083 if (gotent->use_count == 0) 5084 continue; 5085 5086 sgot = alpha_elf_tdata (gotent->gotobj)->got; 5087 5088 r_type = gotent->reloc_type; 5089 switch (r_type) 5090 { 5091 case R_ALPHA_LITERAL: 5092 r_type = R_ALPHA_GLOB_DAT; 5093 break; 5094 case R_ALPHA_TLSGD: 5095 r_type = R_ALPHA_DTPMOD64; 5096 break; 5097 case R_ALPHA_GOTDTPREL: 5098 r_type = R_ALPHA_DTPREL64; 5099 break; 5100 case R_ALPHA_GOTTPREL: 5101 r_type = R_ALPHA_TPREL64; 5102 break; 5103 case R_ALPHA_TLSLDM: 5104 default: 5105 abort (); 5106 } 5107 5108 elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel, 5109 gotent->got_offset, h->dynindx, 5110 r_type, gotent->addend); 5111 5112 if (gotent->reloc_type == R_ALPHA_TLSGD) 5113 elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel, 5114 gotent->got_offset + 8, h->dynindx, 5115 R_ALPHA_DTPREL64, gotent->addend); 3928 5116 } 3929 5117 } … … 3935 5123 sym->st_shndx = SHN_ABS; 3936 5124 3937 return true;5125 return TRUE; 3938 5126 } 3939 5127 3940 5128 /* Finish up the dynamic sections. */ 3941 5129 3942 static b oolean5130 static bfd_boolean 3943 5131 elf64_alpha_finish_dynamic_sections (output_bfd, info) 3944 5132 bfd *output_bfd; … … 4010 5198 } 4011 5199 4012 /* Initialize the PLT0 entry */5200 /* Initialize the PLT0 entry. */ 4013 5201 if (splt->_raw_size > 0) 4014 5202 { … … 4019 5207 4020 5208 /* The next two words will be filled in by ld.so */ 4021 bfd_put_64 (output_bfd, 0, splt->contents + 16); 4022 bfd_put_64 (output_bfd, 0, splt->contents + 24); 4023 4024 elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4025 PLT_HEADER_SIZE; 4026 } 4027 } 4028 4029 return true; 5209 bfd_put_64 (output_bfd, (bfd_vma) 0, splt->contents + 16); 5210 bfd_put_64 (output_bfd, (bfd_vma) 0, splt->contents + 24); 5211 5212 elf_section_data (splt->output_section)->this_hdr.sh_entsize = 0; 5213 } 5214 } 5215 5216 return TRUE; 4030 5217 } 4031 5218 4032 /* We need to use a special link routine to handle the . reginfo and4033 the .mdebug sections. We need to merge all instances of these4034 sections together, not writethem all out sequentially. */4035 4036 static b oolean5219 /* We need to use a special link routine to handle the .mdebug section. 5220 We need to merge all instances of these sections together, not write 5221 them all out sequentially. */ 5222 5223 static bfd_boolean 4037 5224 elf64_alpha_final_link (abfd, info) 4038 5225 bfd *abfd; … … 4041 5228 asection *o; 4042 5229 struct bfd_link_order *p; 4043 asection * reginfo_sec, *mdebug_sec, *gptab_data_sec, *gptab_bss_sec;5230 asection *mdebug_sec; 4044 5231 struct ecoff_debug_info debug; 4045 5232 const struct ecoff_debug_swap *swap … … 4048 5235 PTR mdebug_handle = NULL; 4049 5236 4050 #if 0 4051 if (++ngots == 2) 4052 { 4053 (*info->callbacks->warning) 4054 (info, _("using multiple gp values"), (char *) NULL, 4055 output_bfd, (asection *) NULL, (bfd_vma) 0); 4056 } 4057 #endif 4058 4059 /* Go through the sections and collect the .reginfo and .mdebug 4060 information. */ 4061 reginfo_sec = NULL; 5237 /* Go through the sections and collect the mdebug information. */ 4062 5238 mdebug_sec = NULL; 4063 gptab_data_sec = NULL;4064 gptab_bss_sec = NULL;4065 5239 for (o = abfd->sections; o != (asection *) NULL; o = o->next) 4066 5240 { 4067 #ifdef ERIC_neverdef4068 if (strcmp (o->name, ".reginfo") == 0)4069 {4070 memset (®info, 0, sizeof reginfo);4071 4072 /* We have found the .reginfo section in the output file.4073 Look through all the link_orders comprising it and merge4074 the information together. */4075 for (p = o->link_order_head;4076 p != (struct bfd_link_order *) NULL;4077 p = p->next)4078 {4079 asection *input_section;4080 bfd *input_bfd;4081 Elf64_External_RegInfo ext;4082 Elf64_RegInfo sub;4083 4084 if (p->type != bfd_indirect_link_order)4085 {4086 if (p->type == bfd_fill_link_order)4087 continue;4088 abort ();4089 }4090 4091 input_section = p->u.indirect.section;4092 input_bfd = input_section->owner;4093 4094 /* The linker emulation code has probably clobbered the4095 size to be zero bytes. */4096 if (input_section->_raw_size == 0)4097 input_section->_raw_size = sizeof (Elf64_External_RegInfo);4098 4099 if (! bfd_get_section_contents (input_bfd, input_section,4100 (PTR) &ext,4101 (file_ptr) 0,4102 sizeof ext))4103 return false;4104 4105 bfd_alpha_elf64_swap_reginfo_in (input_bfd, &ext, &sub);4106 4107 reginfo.ri_gprmask |= sub.ri_gprmask;4108 reginfo.ri_cprmask[0] |= sub.ri_cprmask[0];4109 reginfo.ri_cprmask[1] |= sub.ri_cprmask[1];4110 reginfo.ri_cprmask[2] |= sub.ri_cprmask[2];4111 reginfo.ri_cprmask[3] |= sub.ri_cprmask[3];4112 4113 /* ri_gp_value is set by the function4114 alpha_elf_section_processing when the section is4115 finally written out. */4116 4117 /* Hack: reset the SEC_HAS_CONTENTS flag so that4118 elf_link_input_bfd ignores this section. */4119 input_section->flags &=~ SEC_HAS_CONTENTS;4120 }4121 4122 /* Force the section size to the value we want. */4123 o->_raw_size = sizeof (Elf64_External_RegInfo);4124 4125 /* Skip this section later on (I don't think this currently4126 matters, but someday it might). */4127 o->link_order_head = (struct bfd_link_order *) NULL;4128 4129 reginfo_sec = o;4130 }4131 #endif4132 4133 5241 if (strcmp (o->name, ".mdebug") == 0) 4134 5242 { … … 4170 5278 mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info); 4171 5279 if (mdebug_handle == (PTR) NULL) 4172 return false;5280 return FALSE; 4173 5281 4174 5282 if (1) … … 4176 5284 asection *s; 4177 5285 EXTR esym; 4178 bfd_vma last ;5286 bfd_vma last = 0; 4179 5287 unsigned int i; 4180 5288 static const char * const name[] = … … 4209 5317 if (! bfd_ecoff_debug_one_external (abfd, &debug, swap, 4210 5318 name[i], &esym)) 4211 return false;5319 return FALSE; 4212 5320 } 4213 5321 } … … 4226 5334 if (p->type != bfd_indirect_link_order) 4227 5335 { 4228 if (p->type == bfd_ fill_link_order)5336 if (p->type == bfd_data_link_order) 4229 5337 continue; 4230 5338 abort (); … … 4254 5362 if (!elf64_alpha_read_ecoff_info (input_bfd, input_section, 4255 5363 &input_debug)) 4256 return false;5364 return FALSE; 4257 5365 4258 5366 if (! (bfd_ecoff_debug_accumulate 4259 5367 (mdebug_handle, abfd, &debug, swap, input_bfd, 4260 5368 &input_debug, input_swap, info))) 4261 return false;5369 return FALSE; 4262 5370 4263 5371 /* Loop through the external symbols. For each one with … … 4285 5393 name = input_debug.ssext + ext.asym.iss; 4286 5394 h = alpha_elf_link_hash_lookup (alpha_elf_hash_table (info), 4287 name, false, false, true);5395 name, FALSE, FALSE, TRUE); 4288 5396 if (h == NULL || h->esym.ifd != -2) 4289 5397 continue; … … 4317 5425 } 4318 5426 4319 #ifdef ERIC_neverdef4320 if (info->shared)4321 {4322 /* Create .rtproc section. */4323 rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");4324 if (rtproc_sec == NULL)4325 {4326 flagword flags = (SEC_HAS_CONTENTS4327 | SEC_IN_MEMORY4328 | SEC_LINKER_CREATED4329 | SEC_READONLY);4330 4331 rtproc_sec = bfd_make_section (abfd, ".rtproc");4332 if (rtproc_sec == NULL4333 || ! bfd_set_section_flags (abfd, rtproc_sec, flags)4334 || ! bfd_set_section_alignment (abfd, rtproc_sec, 12))4335 return false;4336 }4337 4338 if (! alpha_elf_create_procedure_table (mdebug_handle, abfd,4339 info, rtproc_sec, &debug))4340 return false;4341 }4342 #endif4343 4344 5427 /* Build the external symbol information. */ 4345 5428 einfo.abfd = abfd; … … 4347 5430 einfo.debug = &debug; 4348 5431 einfo.swap = swap; 4349 einfo.failed = false;5432 einfo.failed = FALSE; 4350 5433 elf_link_hash_traverse (elf_hash_table (info), 4351 5434 elf64_alpha_output_extsym, 4352 5435 (PTR) &einfo); 4353 5436 if (einfo.failed) 4354 return false;5437 return FALSE; 4355 5438 4356 5439 /* Set the size of the .mdebug section. */ … … 4363 5446 mdebug_sec = o; 4364 5447 } 4365 4366 #ifdef ERIC_neverdef4367 if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0)4368 {4369 const char *subname;4370 unsigned int c;4371 Elf64_gptab *tab;4372 Elf64_External_gptab *ext_tab;4373 unsigned int i;4374 4375 /* The .gptab.sdata and .gptab.sbss sections hold4376 information describing how the small data area would4377 change depending upon the -G switch. These sections4378 not used in executables files. */4379 if (! info->relocateable)4380 {4381 asection **secpp;4382 4383 for (p = o->link_order_head;4384 p != (struct bfd_link_order *) NULL;4385 p = p->next)4386 {4387 asection *input_section;4388 4389 if (p->type != bfd_indirect_link_order)4390 {4391 if (p->type == bfd_fill_link_order)4392 continue;4393 abort ();4394 }4395 4396 input_section = p->u.indirect.section;4397 4398 /* Hack: reset the SEC_HAS_CONTENTS flag so that4399 elf_link_input_bfd ignores this section. */4400 input_section->flags &=~ SEC_HAS_CONTENTS;4401 }4402 4403 /* Skip this section later on (I don't think this4404 currently matters, but someday it might). */4405 o->link_order_head = (struct bfd_link_order *) NULL;4406 4407 /* Really remove the section. */4408 for (secpp = &abfd->sections;4409 *secpp != o;4410 secpp = &(*secpp)->next)4411 ;4412 *secpp = (*secpp)->next;4413 --abfd->section_count;4414 4415 continue;4416 }4417 4418 /* There is one gptab for initialized data, and one for4419 uninitialized data. */4420 if (strcmp (o->name, ".gptab.sdata") == 0)4421 gptab_data_sec = o;4422 else if (strcmp (o->name, ".gptab.sbss") == 0)4423 gptab_bss_sec = o;4424 else4425 {4426 (*_bfd_error_handler)4427 (_("%s: illegal section name `%s'"),4428 bfd_get_filename (abfd), o->name);4429 bfd_set_error (bfd_error_nonrepresentable_section);4430 return false;4431 }4432 4433 /* The linker script always combines .gptab.data and4434 .gptab.sdata into .gptab.sdata, and likewise for4435 .gptab.bss and .gptab.sbss. It is possible that there is4436 no .sdata or .sbss section in the output file, in which4437 case we must change the name of the output section. */4438 subname = o->name + sizeof ".gptab" - 1;4439 if (bfd_get_section_by_name (abfd, subname) == NULL)4440 {4441 if (o == gptab_data_sec)4442 o->name = ".gptab.data";4443 else4444 o->name = ".gptab.bss";4445 subname = o->name + sizeof ".gptab" - 1;4446 BFD_ASSERT (bfd_get_section_by_name (abfd, subname) != NULL);4447 }4448 4449 /* Set up the first entry. */4450 c = 1;4451 tab = (Elf64_gptab *) bfd_malloc (c * sizeof (Elf64_gptab));4452 if (tab == NULL)4453 return false;4454 tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd);4455 tab[0].gt_header.gt_unused = 0;4456 4457 /* Combine the input sections. */4458 for (p = o->link_order_head;4459 p != (struct bfd_link_order *) NULL;4460 p = p->next)4461 {4462 asection *input_section;4463 bfd *input_bfd;4464 bfd_size_type size;4465 unsigned long last;4466 bfd_size_type gpentry;4467 4468 if (p->type != bfd_indirect_link_order)4469 {4470 if (p->type == bfd_fill_link_order)4471 continue;4472 abort ();4473 }4474 4475 input_section = p->u.indirect.section;4476 input_bfd = input_section->owner;4477 4478 /* Combine the gptab entries for this input section one4479 by one. We know that the input gptab entries are4480 sorted by ascending -G value. */4481 size = bfd_section_size (input_bfd, input_section);4482 last = 0;4483 for (gpentry = sizeof (Elf64_External_gptab);4484 gpentry < size;4485 gpentry += sizeof (Elf64_External_gptab))4486 {4487 Elf64_External_gptab ext_gptab;4488 Elf64_gptab int_gptab;4489 unsigned long val;4490 unsigned long add;4491 boolean exact;4492 unsigned int look;4493 4494 if (! (bfd_get_section_contents4495 (input_bfd, input_section, (PTR) &ext_gptab,4496 gpentry, sizeof (Elf64_External_gptab))))4497 {4498 free (tab);4499 return false;4500 }4501 4502 bfd_alpha_elf64_swap_gptab_in (input_bfd, &ext_gptab,4503 &int_gptab);4504 val = int_gptab.gt_entry.gt_g_value;4505 add = int_gptab.gt_entry.gt_bytes - last;4506 4507 exact = false;4508 for (look = 1; look < c; look++)4509 {4510 if (tab[look].gt_entry.gt_g_value >= val)4511 tab[look].gt_entry.gt_bytes += add;4512 4513 if (tab[look].gt_entry.gt_g_value == val)4514 exact = true;4515 }4516 4517 if (! exact)4518 {4519 Elf64_gptab *new_tab;4520 unsigned int max;4521 4522 /* We need a new table entry. */4523 new_tab = ((Elf64_gptab *)4524 bfd_realloc ((PTR) tab,4525 (c + 1) * sizeof (Elf64_gptab)));4526 if (new_tab == NULL)4527 {4528 free (tab);4529 return false;4530 }4531 tab = new_tab;4532 tab[c].gt_entry.gt_g_value = val;4533 tab[c].gt_entry.gt_bytes = add;4534 4535 /* Merge in the size for the next smallest -G4536 value, since that will be implied by this new4537 value. */4538 max = 0;4539 for (look = 1; look < c; look++)4540 {4541 if (tab[look].gt_entry.gt_g_value < val4542 && (max == 04543 || (tab[look].gt_entry.gt_g_value4544 > tab[max].gt_entry.gt_g_value)))4545 max = look;4546 }4547 if (max != 0)4548 tab[c].gt_entry.gt_bytes +=4549 tab[max].gt_entry.gt_bytes;4550 4551 ++c;4552 }4553 4554 last = int_gptab.gt_entry.gt_bytes;4555 }4556 4557 /* Hack: reset the SEC_HAS_CONTENTS flag so that4558 elf_link_input_bfd ignores this section. */4559 input_section->flags &=~ SEC_HAS_CONTENTS;4560 }4561 4562 /* The table must be sorted by -G value. */4563 if (c > 2)4564 qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare);4565 4566 /* Swap out the table. */4567 ext_tab = ((Elf64_External_gptab *)4568 bfd_alloc (abfd, c * sizeof (Elf64_External_gptab)));4569 if (ext_tab == NULL)4570 {4571 free (tab);4572 return false;4573 }4574 4575 for (i = 0; i < c; i++)4576 bfd_alpha_elf64_swap_gptab_out (abfd, tab + i, ext_tab + i);4577 free (tab);4578 4579 o->_raw_size = c * sizeof (Elf64_External_gptab);4580 o->contents = (bfd_byte *) ext_tab;4581 4582 /* Skip this section later on (I don't think this currently4583 matters, but someday it might). */4584 o->link_order_head = (struct bfd_link_order *) NULL;4585 }4586 #endif4587 4588 5448 } 4589 5449 4590 5450 /* Invoke the regular ELF backend linker to do all the work. */ 4591 5451 if (! bfd_elf64_bfd_final_link (abfd, info)) 4592 return false;5452 return FALSE; 4593 5453 4594 5454 /* Now write out the computed sections. */ … … 4609 5469 sgot = alpha_elf_tdata(i)->got; 4610 5470 if (! bfd_set_section_contents (abfd, sgot->output_section, 4611 sgot->contents, sgot->output_offset, 5471 sgot->contents, 5472 (file_ptr) sgot->output_offset, 4612 5473 sgot->_raw_size)) 4613 return false;5474 return FALSE; 4614 5475 } 4615 5476 } 4616 4617 #ifdef ERIC_neverdef4618 if (reginfo_sec != (asection *) NULL)4619 {4620 Elf64_External_RegInfo ext;4621 4622 bfd_alpha_elf64_swap_reginfo_out (abfd, ®info, &ext);4623 if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext,4624 (file_ptr) 0, sizeof ext))4625 return false;4626 }4627 #endif4628 5477 4629 5478 if (mdebug_sec != (asection *) NULL) … … 4633 5482 swap, info, 4634 5483 mdebug_sec->filepos)) 4635 return false;5484 return FALSE; 4636 5485 4637 5486 bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info); 4638 5487 } 4639 5488 4640 if (gptab_data_sec != (asection *) NULL) 4641 { 4642 if (! bfd_set_section_contents (abfd, gptab_data_sec, 4643 gptab_data_sec->contents, 4644 (file_ptr) 0, 4645 gptab_data_sec->_raw_size)) 4646 return false; 4647 } 4648 4649 if (gptab_bss_sec != (asection *) NULL) 4650 { 4651 if (! bfd_set_section_contents (abfd, gptab_bss_sec, 4652 gptab_bss_sec->contents, 4653 (file_ptr) 0, 4654 gptab_bss_sec->_raw_size)) 4655 return false; 4656 } 4657 4658 return true; 5489 return TRUE; 5490 } 5491 5492 static enum elf_reloc_type_class 5493 elf64_alpha_reloc_type_class (rela) 5494 const Elf_Internal_Rela *rela; 5495 { 5496 switch ((int) ELF64_R_TYPE (rela->r_info)) 5497 { 5498 case R_ALPHA_RELATIVE: 5499 return reloc_class_relative; 5500 case R_ALPHA_JMP_SLOT: 5501 return reloc_class_plt; 5502 case R_ALPHA_COPY: 5503 return reloc_class_copy; 5504 default: 5505 return reloc_class_normal; 5506 } 4659 5507 } 4660 5508 … … 4708 5556 /* Use a non-standard hash bucket size of 8. */ 4709 5557 4710 const struct elf_size_info alpha_elf_size_info =5558 static const struct elf_size_info alpha_elf_size_info = 4711 5559 { 4712 5560 sizeof (Elf64_External_Ehdr), … … 4725 5573 bfd_elf64_write_shdrs_and_ehdr, 4726 5574 bfd_elf64_write_relocs, 5575 bfd_elf64_swap_symbol_in, 4727 5576 bfd_elf64_swap_symbol_out, 4728 5577 bfd_elf64_slurp_reloc_table, … … 4730 5579 bfd_elf64_swap_dyn_in, 4731 5580 bfd_elf64_swap_dyn_out, 4732 NULL,4733 NULL,4734 NULL,4735 NULL5581 bfd_elf64_swap_reloc_in, 5582 bfd_elf64_swap_reloc_out, 5583 bfd_elf64_swap_reloca_in, 5584 bfd_elf64_swap_reloca_out 4736 5585 }; 4737 5586 … … 4757 5606 #define elf_backend_section_from_shdr \ 4758 5607 elf64_alpha_section_from_shdr 5608 #define elf_backend_section_flags \ 5609 elf64_alpha_section_flags 4759 5610 #define elf_backend_fake_sections \ 4760 5611 elf64_alpha_fake_sections … … 4787 5638 #define bfd_elf64_bfd_final_link \ 4788 5639 elf64_alpha_final_link 5640 #define elf_backend_reloc_type_class \ 5641 elf64_alpha_reloc_type_class 4789 5642 4790 5643 #define elf_backend_ecoff_debug_swap \ … … 4802 5655 4803 5656 #include "elf64-target.h" 5657 5658 5659 /* FreeBSD support. */ 5660 5661 #undef TARGET_LITTLE_SYM 5662 #define TARGET_LITTLE_SYM bfd_elf64_alpha_freebsd_vec 5663 #undef TARGET_LITTLE_NAME 5664 #define TARGET_LITTLE_NAME "elf64-alpha-freebsd" 5665 5666 /* The kernel recognizes executables as valid only if they carry a 5667 "FreeBSD" label in the ELF header. So we put this label on all 5668 executables and (for simplicity) also all other object files. */ 5669 5670 static void elf64_alpha_fbsd_post_process_headers 5671 PARAMS ((bfd *, struct bfd_link_info *)); 5672 5673 static void 5674 elf64_alpha_fbsd_post_process_headers (abfd, link_info) 5675 bfd * abfd; 5676 struct bfd_link_info * link_info ATTRIBUTE_UNUSED; 5677 { 5678 Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */ 5679 5680 i_ehdrp = elf_elfheader (abfd); 5681 5682 /* Put an ABI label supported by FreeBSD >= 4.1. */ 5683 i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD; 5684 #ifdef OLD_FREEBSD_ABI_LABEL 5685 /* The ABI label supported by FreeBSD <= 4.0 is quite nonstandard. */ 5686 memcpy (&i_ehdrp->e_ident[EI_ABIVERSION], "FreeBSD", 8); 5687 #endif 5688 } 5689 5690 #undef elf_backend_post_process_headers 5691 #define elf_backend_post_process_headers \ 5692 elf64_alpha_fbsd_post_process_headers 5693 5694 #undef elf64_bed 5695 #define elf64_bed elf64_alpha_fbsd_bed 5696 5697 #include "elf64-target.h" -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.