Changeset 609 for branches/GNU/src/binutils/bfd/elf64-hppa.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-hppa.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Support for HPPA 64-bit ELF 2 Copyright 1999, 2000, 2001 Free Software Foundation, Inc.3 4 This file is part of BFD, the Binary File Descriptor library.5 6 This program is free software; you can redistribute it and/or modify7 it under the terms of the GNU General Public License as published by8 the Free Software Foundation; either version 2 of the License, or9 (at your option) any later version.10 11 This program is distributed in the hope that it will be useful,12 but WITHOUT ANY WARRANTY; without even the implied warranty of13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 GNU General Public License for more details.15 16 You should have received a copy of the GNU General Public License17 along with this program; if not, write to the Free Software18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */2 Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 3 4 This file is part of BFD, the Binary File Descriptor library. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 19 19 20 20 #include "alloca-conf.h" … … 63 63 associated BFD. Needed so that we can have relocs against local 64 64 symbols in shared libraries. */ 65 unsignedlong sym_indx;65 long sym_indx; 66 66 bfd *owner; 67 67 … … 157 157 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 158 158 159 static b oolean elf64_hppa_dyn_hash_table_init159 static bfd_boolean elf64_hppa_dyn_hash_table_init 160 160 PARAMS ((struct elf64_hppa_dyn_hash_table *ht, bfd *abfd, 161 161 new_hash_entry_func new)); … … 167 167 static struct elf64_hppa_dyn_hash_entry *elf64_hppa_dyn_hash_lookup 168 168 PARAMS ((struct elf64_hppa_dyn_hash_table *table, const char *string, 169 b oolean create,boolean copy));169 bfd_boolean create, bfd_boolean copy)); 170 170 static void elf64_hppa_dyn_hash_traverse 171 171 PARAMS ((struct elf64_hppa_dyn_hash_table *table, 172 b oolean (*func) (struct elf64_hppa_dyn_hash_entry *, PTR),172 bfd_boolean (*func) (struct elf64_hppa_dyn_hash_entry *, PTR), 173 173 PTR info)); 174 174 … … 181 181 #include "elf-hppa.h" 182 182 183 static b oolean elf64_hppa_object_p183 static bfd_boolean elf64_hppa_object_p 184 184 PARAMS ((bfd *)); 185 185 186 static b oolean elf64_hppa_section_from_shdr187 PARAMS ((bfd *, Elf 64_Internal_Shdr *,char *));186 static bfd_boolean elf64_hppa_section_from_shdr 187 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *)); 188 188 189 189 static void elf64_hppa_post_process_headers 190 190 PARAMS ((bfd *, struct bfd_link_info *)); 191 191 192 static b oolean elf64_hppa_create_dynamic_sections192 static bfd_boolean elf64_hppa_create_dynamic_sections 193 193 PARAMS ((bfd *, struct bfd_link_info *)); 194 194 195 static b oolean elf64_hppa_adjust_dynamic_symbol195 static bfd_boolean elf64_hppa_adjust_dynamic_symbol 196 196 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); 197 197 198 static boolean elf64_hppa_size_dynamic_sections 198 static bfd_boolean elf64_hppa_mark_milli_and_exported_functions 199 PARAMS ((struct elf_link_hash_entry *, PTR)); 200 201 static bfd_boolean elf64_hppa_size_dynamic_sections 199 202 PARAMS ((bfd *, struct bfd_link_info *)); 200 203 201 static boolean elf64_hppa_finish_dynamic_symbol 204 static bfd_boolean elf64_hppa_link_output_symbol_hook 205 PARAMS ((bfd *abfd, struct bfd_link_info *, const char *, 206 Elf_Internal_Sym *, asection *input_sec)); 207 208 static bfd_boolean elf64_hppa_finish_dynamic_symbol 202 209 PARAMS ((bfd *, struct bfd_link_info *, 203 210 struct elf_link_hash_entry *, Elf_Internal_Sym *)); 204 211 205 static boolean elf64_hppa_finish_dynamic_sections 212 static int elf64_hppa_additional_program_headers 213 PARAMS ((bfd *)); 214 215 static bfd_boolean elf64_hppa_modify_segment_map 216 PARAMS ((bfd *)); 217 218 static enum elf_reloc_type_class elf64_hppa_reloc_type_class 219 PARAMS ((const Elf_Internal_Rela *)); 220 221 static bfd_boolean elf64_hppa_finish_dynamic_sections 206 222 PARAMS ((bfd *, struct bfd_link_info *)); 207 223 208 static b oolean elf64_hppa_check_relocs224 static bfd_boolean elf64_hppa_check_relocs 209 225 PARAMS ((bfd *, struct bfd_link_info *, 210 226 asection *, const Elf_Internal_Rela *)); 211 227 212 static b oolean elf64_hppa_dynamic_symbol_p228 static bfd_boolean elf64_hppa_dynamic_symbol_p 213 229 PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *)); 214 230 215 static b oolean elf64_hppa_mark_exported_functions231 static bfd_boolean elf64_hppa_mark_exported_functions 216 232 PARAMS ((struct elf_link_hash_entry *, PTR)); 217 233 218 static b oolean elf64_hppa_finalize_opd234 static bfd_boolean elf64_hppa_finalize_opd 219 235 PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); 220 236 221 static b oolean elf64_hppa_finalize_dlt237 static bfd_boolean elf64_hppa_finalize_dlt 222 238 PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); 223 239 224 static b oolean allocate_global_data_dlt240 static bfd_boolean allocate_global_data_dlt 225 241 PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); 226 242 227 static b oolean allocate_global_data_plt243 static bfd_boolean allocate_global_data_plt 228 244 PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); 229 245 230 static b oolean allocate_global_data_stub246 static bfd_boolean allocate_global_data_stub 231 247 PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); 232 248 233 static b oolean allocate_global_data_opd249 static bfd_boolean allocate_global_data_opd 234 250 PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); 235 251 236 static b oolean get_reloc_section252 static bfd_boolean get_reloc_section 237 253 PARAMS ((bfd *, struct elf64_hppa_link_hash_table *, asection *)); 238 254 239 static b oolean count_dyn_reloc255 static bfd_boolean count_dyn_reloc 240 256 PARAMS ((bfd *, struct elf64_hppa_dyn_hash_entry *, 241 257 int, asection *, int, bfd_vma, bfd_vma)); 242 258 243 static b oolean allocate_dynrel_entries259 static bfd_boolean allocate_dynrel_entries 244 260 PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); 245 261 246 static b oolean elf64_hppa_finalize_dynreloc262 static bfd_boolean elf64_hppa_finalize_dynreloc 247 263 PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); 248 264 249 static b oolean get_opd265 static bfd_boolean get_opd 250 266 PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *)); 251 267 252 static b oolean get_plt268 static bfd_boolean get_plt 253 269 PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *)); 254 270 255 static b oolean get_dlt271 static bfd_boolean get_dlt 256 272 PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *)); 257 273 258 static b oolean get_stub274 static bfd_boolean get_stub 259 275 PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *)); 260 276 … … 262 278 PARAMS ((Elf_Internal_Sym *, int)); 263 279 264 static b oolean280 static bfd_boolean 265 281 elf64_hppa_dyn_hash_table_init (ht, abfd, new) 266 282 struct elf64_hppa_dyn_hash_table *ht; … … 310 326 struct elf64_hppa_link_hash_table *ret; 311 327 312 ret = bfd_zalloc (abfd, sizeof (*ret));328 ret = bfd_zalloc (abfd, (bfd_size_type) sizeof (*ret)); 313 329 if (!ret) 314 330 return 0; … … 332 348 struct elf64_hppa_dyn_hash_table *table; 333 349 const char *string; 334 b oolean create, copy;350 bfd_boolean create, copy; 335 351 { 336 352 return ((struct elf64_hppa_dyn_hash_entry *) … … 343 359 elf64_hppa_dyn_hash_traverse (table, func, info) 344 360 struct elf64_hppa_dyn_hash_table *table; 345 b oolean (*func) PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR));361 bfd_boolean (*func) PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); 346 362 PTR info; 347 363 { 348 364 (bfd_hash_traverse 349 365 (&table->root, 350 (b oolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) func,366 (bfd_boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) func, 351 367 info)); 352 368 } … … 356 372 357 373 Additionally we set the default architecture and machine. */ 358 static b oolean374 static bfd_boolean 359 375 elf64_hppa_object_p (abfd) 360 376 bfd *abfd; … … 367 383 { 368 384 if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX) 369 return false;385 return FALSE; 370 386 } 371 387 else 372 388 { 373 389 if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX) 374 return false;390 return FALSE; 375 391 } 376 392 … … 388 404 } 389 405 /* Don't be fussy. */ 390 return true;406 return TRUE; 391 407 } 392 408 393 409 /* Given section type (hdr->sh_type), return a boolean indicating 394 410 whether or not the section is an elf64-hppa specific section. */ 395 static b oolean411 static bfd_boolean 396 412 elf64_hppa_section_from_shdr (abfd, hdr, name) 397 413 bfd *abfd; 398 Elf 64_Internal_Shdr *hdr;399 c har *name;414 Elf_Internal_Shdr *hdr; 415 const char *name; 400 416 { 401 417 asection *newsect; … … 405 421 case SHT_PARISC_EXT: 406 422 if (strcmp (name, ".PARISC.archext") != 0) 407 return false;423 return FALSE; 408 424 break; 409 425 case SHT_PARISC_UNWIND: 410 426 if (strcmp (name, ".PARISC.unwind") != 0) 411 return false;427 return FALSE; 412 428 break; 413 429 case SHT_PARISC_DOC: 414 430 case SHT_PARISC_ANNOT: 415 431 default: 416 return false;432 return FALSE; 417 433 } 418 434 419 435 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) 420 return false;436 return FALSE; 421 437 newsect = hdr->bfd_section; 422 438 423 return true;439 return TRUE; 424 440 } 425 441 … … 485 501 a suitable section for holding relocs in the output BFD for a link. */ 486 502 487 static b oolean503 static bfd_boolean 488 504 get_reloc_section (abfd, hppa_info, sec) 489 505 bfd *abfd; … … 499 515 elf_section_data(sec)->rel_hdr.sh_name)); 500 516 if (srel_name == NULL) 501 return false;517 return FALSE; 502 518 503 519 BFD_ASSERT ((strncmp (srel_name, ".rela", 5) == 0 … … 525 541 | SEC_READONLY)) 526 542 || !bfd_set_section_alignment (dynobj, srel, 3)) 527 return false;543 return FALSE; 528 544 } 529 545 530 546 hppa_info->other_rel_sec = srel; 531 return true;547 return TRUE; 532 548 } 533 549 … … 538 554 output file. */ 539 555 540 static b oolean556 static bfd_boolean 541 557 count_dyn_reloc (abfd, dyn_h, type, sec, sec_symndx, offset, addend) 542 558 bfd *abfd; … … 551 567 552 568 rent = (struct elf64_hppa_dyn_reloc_entry *) 553 bfd_alloc (abfd, sizeof (*rent));569 bfd_alloc (abfd, (bfd_size_type) sizeof (*rent)); 554 570 if (!rent) 555 return false;571 return FALSE; 556 572 557 573 rent->next = dyn_h->reloc_entries; … … 563 579 dyn_h->reloc_entries = rent; 564 580 565 return true;581 return TRUE; 566 582 } 567 583 … … 569 585 referenced symbol needs. */ 570 586 571 static b oolean587 static bfd_boolean 572 588 elf64_hppa_check_relocs (abfd, info, sec, relocs) 573 589 bfd *abfd; … … 586 602 587 603 if (info->relocateable) 588 return true;604 return TRUE; 589 605 590 606 /* If this is the first dynamic object found in the link, create … … 593 609 { 594 610 if (! bfd_elf64_link_create_dynamic_sections (abfd, info)) 595 return false;611 return FALSE; 596 612 } 597 613 … … 600 616 601 617 /* If necessary, build a new table holding section symbols indices 602 for this BFD. This is disgusting.*/618 for this BFD. */ 603 619 604 620 if (info->shared && hppa_info->section_syms_bfd != abfd) 605 621 { 606 622 unsigned long i; 607 int highest_shndx; 608 Elf_Internal_Sym *local_syms, *isym; 609 Elf64_External_Sym *ext_syms, *esym; 623 unsigned int highest_shndx; 624 Elf_Internal_Sym *local_syms = NULL; 625 Elf_Internal_Sym *isym, *isymend; 626 bfd_size_type amt; 610 627 611 628 /* We're done with the old cache of section index to section symbol … … 617 634 free (hppa_info->section_syms); 618 635 619 /* Allocate memory for the internal and external symbols. */ 620 local_syms 621 = (Elf_Internal_Sym *) bfd_malloc (symtab_hdr->sh_info 622 * sizeof (Elf_Internal_Sym)); 623 if (local_syms == NULL) 624 return false; 625 626 ext_syms 627 = (Elf64_External_Sym *) bfd_malloc (symtab_hdr->sh_info 628 * sizeof (Elf64_External_Sym)); 629 if (ext_syms == NULL) 630 { 631 free (local_syms); 632 return false; 633 } 634 635 /* Read in the local symbols. */ 636 if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 637 || bfd_read (ext_syms, 1, 638 (symtab_hdr->sh_info 639 * sizeof (Elf64_External_Sym)), abfd) 640 != (symtab_hdr->sh_info * sizeof (Elf64_External_Sym))) 641 { 642 free (local_syms); 643 free (ext_syms); 644 return false; 645 } 646 647 /* Swap in the local symbols, also record the highest section index 648 referenced by the local symbols. */ 649 isym = local_syms; 650 esym = ext_syms; 636 /* Read this BFD's local symbols. */ 637 if (symtab_hdr->sh_info != 0) 638 { 639 local_syms = (Elf_Internal_Sym *) symtab_hdr->contents; 640 if (local_syms == NULL) 641 local_syms = bfd_elf_get_elf_syms (abfd, symtab_hdr, 642 symtab_hdr->sh_info, 0, 643 NULL, NULL, NULL); 644 if (local_syms == NULL) 645 return FALSE; 646 } 647 648 /* Record the highest section index referenced by the local symbols. */ 651 649 highest_shndx = 0; 652 for (i = 0; i < symtab_hdr->sh_info; i++, esym++, isym++)653 { 654 bfd_elf64_swap_symbol_in (abfd, esym, isym);650 isymend = local_syms + symtab_hdr->sh_info; 651 for (isym = local_syms; isym < isymend; isym++) 652 { 655 653 if (isym->st_shndx > highest_shndx) 656 654 highest_shndx = isym->st_shndx; 657 655 } 658 659 /* Now we can free the external symbols. */660 free (ext_syms);661 656 662 657 /* Allocate an array to hold the section index to section symbol index 663 658 mapping. Bump by one since we start counting at zero. */ 664 659 highest_shndx++; 665 hppa_info->section_syms = (int *) bfd_malloc (highest_shndx 666 * sizeof (int)); 660 amt = highest_shndx; 661 amt *= sizeof (int); 662 hppa_info->section_syms = (int *) bfd_malloc (amt); 667 663 668 664 /* Now walk the local symbols again. If we find a section symbol, 669 665 record the index of the symbol into the section_syms array. */ 670 for (i sym = local_syms, i = 0; i < symtab_hdr->sh_info; i++, isym++)666 for (i = 0, isym = local_syms; isym < isymend; i++, isym++) 671 667 { 672 668 if (ELF_ST_TYPE (isym->st_info) == STT_SECTION) … … 674 670 } 675 671 676 /* We are finished with the local symbols. Get rid of them. */ 677 free (local_syms); 672 /* We are finished with the local symbols. */ 673 if (local_syms != NULL 674 && symtab_hdr->contents != (unsigned char *) local_syms) 675 { 676 if (! info->keep_memory) 677 free (local_syms); 678 else 679 { 680 /* Cache the symbols for elf_link_input_bfd. */ 681 symtab_hdr->contents = (unsigned char *) local_syms; 682 } 683 } 678 684 679 685 /* Record which BFD we built the section_syms mapping for. */ … … 692 698 something went terribly wrong above. */ 693 699 if (sec_symndx == -1) 694 return false;700 return FALSE; 695 701 696 702 sec_symndx = hppa_info->section_syms[sec_symndx]; … … 719 725 int need_entry; 720 726 const char *addr_name; 721 b oolean maybe_dynamic;727 bfd_boolean maybe_dynamic; 722 728 int dynrel_type = R_PARISC_NONE; 723 729 static reloc_howto_type *howto; … … 740 746 have yet been processed. Do something with what we know, as 741 747 this may help reduce memory usage and processing time later. */ 742 maybe_dynamic = false; 743 if (h && ((info->shared && ! info->symbolic) 748 maybe_dynamic = FALSE; 749 if (h && ((info->shared 750 && (!info->symbolic || info->allow_shlib_undefined) ) 744 751 || ! (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) 745 752 || h->root.type == bfd_link_hash_defweak)) 746 maybe_dynamic = true;753 maybe_dynamic = TRUE; 747 754 748 755 howto = elf_hppa_howto_table + ELF64_R_TYPE (rel->r_info); … … 853 860 /* Collect the canonical entry data for this address. */ 854 861 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, 855 addr_name, true, true);862 addr_name, TRUE, TRUE); 856 863 BFD_ASSERT (dyn_h); 857 864 … … 924 931 && ! (_bfd_elf64_link_record_local_dynamic_symbol 925 932 (info, abfd, sec_symndx))) 926 return false;933 return FALSE; 927 934 } 928 935 } … … 930 937 if (buf) 931 938 free (buf); 932 return true;939 return TRUE; 933 940 934 941 err_out: 935 942 if (buf) 936 943 free (buf); 937 return false;944 return FALSE; 938 945 } 939 946 … … 946 953 /* Should we do dynamic things to this symbol? */ 947 954 948 static b oolean955 static bfd_boolean 949 956 elf64_hppa_dynamic_symbol_p (h, info) 950 957 struct elf_link_hash_entry *h; … … 952 959 { 953 960 if (h == NULL) 954 return false;961 return FALSE; 955 962 956 963 while (h->root.type == bfd_link_hash_indirect … … 959 966 960 967 if (h->dynindx == -1) 961 return false;968 return FALSE; 962 969 963 970 if (h->root.type == bfd_link_hash_undefweak 964 971 || h->root.type == bfd_link_hash_defweak) 965 return true;972 return TRUE; 966 973 967 974 if (h->root.root.string[0] == '$' && h->root.root.string[1] == '$') 968 return false;969 970 if ((info->shared && !info->symbolic)975 return FALSE; 976 977 if ((info->shared && (!info->symbolic || info->allow_shlib_undefined)) 971 978 || ((h->elf_link_hash_flags 972 979 & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)) 973 980 == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))) 974 return true;975 976 return false;981 return TRUE; 982 983 return FALSE; 977 984 } 978 985 … … 980 987 entries in .opd for them. */ 981 988 982 static b oolean989 static bfd_boolean 983 990 elf64_hppa_mark_exported_functions (h, data) 984 991 struct elf_link_hash_entry *h; … … 989 996 990 997 hppa_info = elf64_hppa_hash_table (info); 998 999 if (h->root.type == bfd_link_hash_warning) 1000 h = (struct elf_link_hash_entry *) h->root.u.i.link; 991 1001 992 1002 if (h … … 1000 1010 /* Add this symbol to the PA64 linker hash table. */ 1001 1011 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, 1002 h->root.root.string, true, true);1012 h->root.root.string, TRUE, TRUE); 1003 1013 BFD_ASSERT (dyn_h); 1004 1014 dyn_h->h = h; … … 1006 1016 if (! hppa_info->opd_sec 1007 1017 && ! get_opd (hppa_info->root.dynobj, info, hppa_info)) 1008 return false;1018 return FALSE; 1009 1019 1010 1020 dyn_h->want_opd = 1; … … 1014 1024 } 1015 1025 1016 return true;1026 return TRUE; 1017 1027 } 1018 1028 1019 1029 /* Allocate space for a DLT entry. */ 1020 1030 1021 static b oolean1031 static bfd_boolean 1022 1032 allocate_global_data_dlt (dyn_h, data) 1023 1033 struct elf64_hppa_dyn_hash_entry *dyn_h; … … 1036 1046 against it. */ 1037 1047 if (! h 1038 || (h && h->dynindx == -1))1048 || (h->dynindx == -1 && h->type != STT_PARISC_MILLI)) 1039 1049 { 1040 1050 bfd *owner; 1041 1051 owner = (h ? h->root.u.def.section->owner : dyn_h->owner); 1042 1052 1043 if (! _bfd_elf64_link_record_local_dynamic_symbol1044 (x->info, owner, dyn_h->sym_indx))1045 return false;1053 if (! (_bfd_elf64_link_record_local_dynamic_symbol 1054 (x->info, owner, dyn_h->sym_indx))) 1055 return FALSE; 1046 1056 } 1047 1057 } … … 1050 1060 x->ofs += DLT_ENTRY_SIZE; 1051 1061 } 1052 return true;1062 return TRUE; 1053 1063 } 1054 1064 1055 1065 /* Allocate space for a DLT.PLT entry. */ 1056 1066 1057 static b oolean1067 static bfd_boolean 1058 1068 allocate_global_data_plt (dyn_h, data) 1059 1069 struct elf64_hppa_dyn_hash_entry *dyn_h; … … 1076 1086 dyn_h->want_plt = 0; 1077 1087 1078 return true;1088 return TRUE; 1079 1089 } 1080 1090 1081 1091 /* Allocate space for a STUB entry. */ 1082 1092 1083 static b oolean1093 static bfd_boolean 1084 1094 allocate_global_data_stub (dyn_h, data) 1085 1095 struct elf64_hppa_dyn_hash_entry *dyn_h; … … 1099 1109 else 1100 1110 dyn_h->want_stub = 0; 1101 return true;1111 return TRUE; 1102 1112 } 1103 1113 1104 1114 /* Allocate space for a FPTR entry. */ 1105 1115 1106 static b oolean1116 static bfd_boolean 1107 1117 allocate_global_data_opd (dyn_h, data) 1108 1118 struct elf64_hppa_dyn_hash_entry *dyn_h; … … 1122 1132 /* We never need an opd entry for a symbol which is not 1123 1133 defined by this output file. */ 1124 if (h && h->root.type == bfd_link_hash_undefined) 1134 if (h && (h->root.type == bfd_link_hash_undefined 1135 || h->root.u.def.section->output_section == NULL)) 1125 1136 dyn_h->want_opd = 0; 1126 1137 … … 1130 1141 else if (x->info->shared 1131 1142 || h == NULL 1132 || h->dynindx == -1 1133 || ((h->root.type == bfd_link_hash_defined 1134 || h->root.type == bfd_link_hash_defweak) 1135 && h->root.u.def.section->output_section != NULL)) 1143 || (h->dynindx == -1 && h->type != STT_PARISC_MILLI) 1144 || (h->root.type == bfd_link_hash_defined 1145 || h->root.type == bfd_link_hash_defweak)) 1136 1146 { 1137 1147 /* If we are creating a shared library, then we will have to … … 1147 1157 if (!_bfd_elf64_link_record_local_dynamic_symbol 1148 1158 (x->info, owner, dyn_h->sym_indx)) 1149 return false;1159 return FALSE; 1150 1160 } 1151 1161 … … 1165 1175 1166 1176 nh = elf_link_hash_lookup (elf_hash_table (x->info), 1167 new_name, true, true, true);1177 new_name, TRUE, TRUE, TRUE); 1168 1178 1169 1179 nh->root.type = h->root.type; … … 1172 1182 1173 1183 if (! bfd_elf64_link_record_dynamic_symbol (x->info, nh)) 1174 return false;1184 return FALSE; 1175 1185 1176 1186 } … … 1183 1193 dyn_h->want_opd = 0; 1184 1194 } 1185 return true;1195 return TRUE; 1186 1196 } 1187 1197 … … 1214 1224 of a procedure, thus ensuring a unique address for each procedure. */ 1215 1225 1216 static b oolean1226 static bfd_boolean 1217 1227 get_opd (abfd, info, hppa_info) 1218 1228 bfd *abfd; … … 1241 1251 { 1242 1252 BFD_ASSERT (0); 1243 return false;1253 return FALSE; 1244 1254 } 1245 1255 … … 1247 1257 } 1248 1258 1249 return true;1259 return TRUE; 1250 1260 } 1251 1261 1252 1262 /* Create the PLT section. */ 1253 1263 1254 static b oolean1264 static bfd_boolean 1255 1265 get_plt (abfd, info, hppa_info) 1256 1266 bfd *abfd; … … 1279 1289 { 1280 1290 BFD_ASSERT (0); 1281 return false;1291 return FALSE; 1282 1292 } 1283 1293 … … 1285 1295 } 1286 1296 1287 return true;1297 return TRUE; 1288 1298 } 1289 1299 1290 1300 /* Create the DLT section. */ 1291 1301 1292 static b oolean1302 static bfd_boolean 1293 1303 get_dlt (abfd, info, hppa_info) 1294 1304 bfd *abfd; … … 1317 1327 { 1318 1328 BFD_ASSERT (0); 1319 return false;1329 return FALSE; 1320 1330 } 1321 1331 … … 1323 1333 } 1324 1334 1325 return true;1335 return TRUE; 1326 1336 } 1327 1337 1328 1338 /* Create the stubs section. */ 1329 1339 1330 static b oolean1340 static bfd_boolean 1331 1341 get_stub (abfd, info, hppa_info) 1332 1342 bfd *abfd; … … 1356 1366 { 1357 1367 BFD_ASSERT (0); 1358 return false;1368 return FALSE; 1359 1369 } 1360 1370 … … 1362 1372 } 1363 1373 1364 return true;1374 return TRUE; 1365 1375 } 1366 1376 … … 1403 1413 EPLT relocations for symbols exported from shared libraries. */ 1404 1414 1405 static b oolean1415 static bfd_boolean 1406 1416 elf64_hppa_create_dynamic_sections (abfd, info) 1407 1417 bfd *abfd; … … 1411 1421 1412 1422 if (! get_stub (abfd, info, elf64_hppa_hash_table (info))) 1413 return false;1423 return FALSE; 1414 1424 1415 1425 if (! get_dlt (abfd, info, elf64_hppa_hash_table (info))) 1416 return false;1426 return FALSE; 1417 1427 1418 1428 if (! get_plt (abfd, info, elf64_hppa_hash_table (info))) 1419 return false;1429 return FALSE; 1420 1430 1421 1431 if (! get_opd (abfd, info, elf64_hppa_hash_table (info))) 1422 return false;1432 return FALSE; 1423 1433 1424 1434 s = bfd_make_section(abfd, ".rela.dlt"); … … 1430 1440 | SEC_LINKER_CREATED)) 1431 1441 || !bfd_set_section_alignment (abfd, s, 3)) 1432 return false;1442 return FALSE; 1433 1443 elf64_hppa_hash_table (info)->dlt_rel_sec = s; 1434 1444 … … 1441 1451 | SEC_LINKER_CREATED)) 1442 1452 || !bfd_set_section_alignment (abfd, s, 3)) 1443 return false;1453 return FALSE; 1444 1454 elf64_hppa_hash_table (info)->plt_rel_sec = s; 1445 1455 … … 1452 1462 | SEC_LINKER_CREATED)) 1453 1463 || !bfd_set_section_alignment (abfd, s, 3)) 1454 return false;1464 return FALSE; 1455 1465 elf64_hppa_hash_table (info)->other_rel_sec = s; 1456 1466 … … 1463 1473 | SEC_LINKER_CREATED)) 1464 1474 || !bfd_set_section_alignment (abfd, s, 3)) 1465 return false;1475 return FALSE; 1466 1476 elf64_hppa_hash_table (info)->opd_rel_sec = s; 1467 1477 1468 return true;1478 return TRUE; 1469 1479 } 1470 1480 … … 1472 1482 to be dynamic. */ 1473 1483 1474 static b oolean1484 static bfd_boolean 1475 1485 allocate_dynrel_entries (dyn_h, data) 1476 1486 struct elf64_hppa_dyn_hash_entry *dyn_h; … … 1480 1490 struct elf64_hppa_link_hash_table *hppa_info; 1481 1491 struct elf64_hppa_dyn_reloc_entry *rent; 1482 b oolean dynamic_symbol, shared;1492 bfd_boolean dynamic_symbol, shared; 1483 1493 1484 1494 hppa_info = elf64_hppa_hash_table (x->info); … … 1489 1499 when creating a shared library. */ 1490 1500 if (!dynamic_symbol && !shared) 1491 return true;1501 return TRUE; 1492 1502 1493 1503 /* Take care of the normal data relocations. */ … … 1495 1505 for (rent = dyn_h->reloc_entries; rent; rent = rent->next) 1496 1506 { 1497 switch (rent->type) 1498 { 1499 case R_PARISC_FPTR64: 1500 /* Allocate one iff we are not building a shared library and 1501 !want_opd, which by this point will be true only if we're 1502 actually allocating one statically in the main executable. */ 1503 if (!x->info->shared && dyn_h->want_opd) 1504 continue; 1505 break; 1506 } 1507 /* Allocate one iff we are building a shared library, the relocation 1508 isn't a R_PARISC_FPTR64, or we don't want an opd entry. */ 1509 if (!shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd) 1510 continue; 1511 1507 1512 hppa_info->other_rel_sec->_raw_size += sizeof (Elf64_External_Rela); 1508 1513 … … 1510 1515 not already recorded. ?!? This should not be in the loop since 1511 1516 the symbol need only be added once. */ 1512 if (dyn_h->h == 0 || dyn_h->h->dynindx == -1) 1517 if (dyn_h->h == 0 1518 || (dyn_h->h->dynindx == -1 && dyn_h->h->type != STT_PARISC_MILLI)) 1513 1519 if (!_bfd_elf64_link_record_local_dynamic_symbol 1514 1520 (x->info, rent->sec->owner, dyn_h->sym_indx)) 1515 return false;1521 return FALSE; 1516 1522 } 1517 1523 … … 1542 1548 } 1543 1549 1544 return true;1550 return TRUE; 1545 1551 } 1546 1552 … … 1548 1554 regular object. */ 1549 1555 1550 static b oolean1556 static bfd_boolean 1551 1557 elf64_hppa_adjust_dynamic_symbol (info, h) 1552 1558 struct bfd_link_info *info ATTRIBUTE_UNUSED; … … 1565 1571 h->root.u.def.section = h->weakdef->root.u.def.section; 1566 1572 h->root.u.def.value = h->weakdef->root.u.def.value; 1567 return true;1573 return TRUE; 1568 1574 } 1569 1575 … … 1575 1581 of hackery. */ 1576 1582 1577 return true; 1583 return TRUE; 1584 } 1585 1586 /* This function is called via elf_link_hash_traverse to mark millicode 1587 symbols with a dynindx of -1 and to remove the string table reference 1588 from the dynamic symbol table. If the symbol is not a millicode symbol, 1589 elf64_hppa_mark_exported_functions is called. */ 1590 1591 static bfd_boolean 1592 elf64_hppa_mark_milli_and_exported_functions (h, data) 1593 struct elf_link_hash_entry *h; 1594 PTR data; 1595 { 1596 struct bfd_link_info *info = (struct bfd_link_info *)data; 1597 struct elf_link_hash_entry *elf = h; 1598 1599 if (elf->root.type == bfd_link_hash_warning) 1600 elf = (struct elf_link_hash_entry *) elf->root.u.i.link; 1601 1602 if (elf->type == STT_PARISC_MILLI) 1603 { 1604 if (elf->dynindx != -1) 1605 { 1606 elf->dynindx = -1; 1607 _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr, 1608 elf->dynstr_index); 1609 } 1610 return TRUE; 1611 } 1612 1613 return elf64_hppa_mark_exported_functions (h, data); 1578 1614 } 1579 1615 … … 1581 1617 the contents of our special sections. */ 1582 1618 1583 static b oolean1619 static bfd_boolean 1584 1620 elf64_hppa_size_dynamic_sections (output_bfd, info) 1585 1621 bfd *output_bfd; … … 1588 1624 bfd *dynobj; 1589 1625 asection *s; 1590 b oolean plt;1591 b oolean relocs;1592 b oolean reltext;1626 bfd_boolean plt; 1627 bfd_boolean relocs; 1628 bfd_boolean reltext; 1593 1629 struct elf64_hppa_allocate_data data; 1594 1630 struct elf64_hppa_link_hash_table *hppa_info; … … 1598 1634 dynobj = elf_hash_table (info)->dynobj; 1599 1635 BFD_ASSERT (dynobj != NULL); 1636 1637 /* Mark each function this program exports so that we will allocate 1638 space in the .opd section for each function's FPTR. If we are 1639 creating dynamic sections, change the dynamic index of millicode 1640 symbols to -1 and remove them from the string table for .dynstr. 1641 1642 We have to traverse the main linker hash table since we have to 1643 find functions which may not have been mentioned in any relocs. */ 1644 elf_link_hash_traverse (elf_hash_table (info), 1645 (elf_hash_table (info)->dynamic_sections_created 1646 ? elf64_hppa_mark_milli_and_exported_functions 1647 : elf64_hppa_mark_exported_functions), 1648 info); 1600 1649 1601 1650 if (elf_hash_table (info)->dynamic_sections_created) … … 1643 1692 } 1644 1693 1645 /* Mark each function this program exports so that we will allocate1646 space in the .opd section for each function's FPTR.1647 1648 We have to traverse the main linker hash table since we have to1649 find functions which may not have been mentioned in any relocs. */1650 elf_link_hash_traverse (elf_hash_table (info),1651 elf64_hppa_mark_exported_functions,1652 info);1653 1654 1694 /* Allocate space for entries in the .opd section. */ 1655 1695 if (elf64_hppa_hash_table (info)->opd_sec) … … 1667 1707 1668 1708 /* The sizes of all the sections are set. Allocate memory for them. */ 1669 plt = false;1670 relocs = false;1671 reltext = false;1709 plt = FALSE; 1710 relocs = FALSE; 1711 reltext = FALSE; 1672 1712 for (s = dynobj->sections; s != NULL; s = s->next) 1673 1713 { 1674 1714 const char *name; 1675 b oolean strip;1715 bfd_boolean strip; 1676 1716 1677 1717 if ((s->flags & SEC_LINKER_CREATED) == 0) … … 1686 1726 if (strcmp (name, ".plt") == 0) 1687 1727 { 1728 /* Strip this section if we don't need it; see the comment below. */ 1688 1729 if (s->_raw_size == 0) 1689 1730 { 1690 /* Strip this section if we don't need it; see the 1691 comment below. */ 1692 strip = true; 1731 strip = TRUE; 1693 1732 } 1694 1733 else 1695 1734 { 1696 1735 /* Remember whether there is a PLT. */ 1697 plt = true;1736 plt = TRUE; 1698 1737 } 1699 1738 } 1700 1739 else if (strcmp (name, ".dlt") == 0) 1701 1740 { 1741 /* Strip this section if we don't need it; see the comment below. */ 1702 1742 if (s->_raw_size == 0) 1703 1743 { 1704 /* Strip this section if we don't need it; see the 1705 comment below. */ 1706 strip = true; 1744 strip = TRUE; 1707 1745 } 1708 1746 } 1709 1747 else if (strcmp (name, ".opd") == 0) 1710 1748 { 1749 /* Strip this section if we don't need it; see the comment below. */ 1711 1750 if (s->_raw_size == 0) 1712 1751 { 1713 /* Strip this section if we don't need it; see the 1714 comment below. */ 1715 strip = true; 1752 strip = TRUE; 1716 1753 } 1717 1754 } 1718 else if (strncmp (name, ".rela", 4) == 0) 1719 { 1755 else if (strncmp (name, ".rela", 5) == 0) 1756 { 1757 /* If we don't need this section, strip it from the output file. 1758 This is mostly to handle .rela.bss and .rela.plt. We must 1759 create both sections in create_dynamic_sections, because they 1760 must be created before the linker maps input sections to output 1761 sections. The linker does that before adjust_dynamic_symbol 1762 is called, and it is that function which decides whether 1763 anything needs to go into these sections. */ 1720 1764 if (s->_raw_size == 0) 1721 1765 { … … 1729 1773 function which decides whether anything needs to go 1730 1774 into these sections. */ 1731 strip = true;1775 strip = TRUE; 1732 1776 } 1733 1777 else … … 1741 1785 const char *outname; 1742 1786 1743 relocs = true;1787 relocs = TRUE; 1744 1788 1745 1789 /* If this relocation section applies to a read only … … 1754 1798 && (target->flags & SEC_READONLY) != 0 1755 1799 && (target->flags & SEC_ALLOC) != 0) 1756 reltext = true;1800 reltext = TRUE; 1757 1801 } 1758 1802 … … 1786 1830 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); 1787 1831 if (s->contents == NULL && s->_raw_size != 0) 1788 return false;1832 return FALSE; 1789 1833 } 1790 1834 } … … 1795 1839 the PLT, it is how we communicate the __gp value of a load 1796 1840 module to the dynamic linker. */ 1797 if (! bfd_elf64_add_dynamic_entry (info, DT_HP_DLD_FLAGS, 0) 1798 || ! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)) 1799 return false; 1841 #define add_dynamic_entry(TAG, VAL) \ 1842 bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) 1843 1844 if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0) 1845 || !add_dynamic_entry (DT_PLTGOT, 0)) 1846 return FALSE; 1800 1847 1801 1848 /* Add some entries to the .dynamic section. We fill in the … … 1806 1853 if (! info->shared) 1807 1854 { 1808 if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0) 1809 || ! bfd_elf64_add_dynamic_entry (info, DT_HP_DLD_HOOK, 0) 1810 || ! bfd_elf64_add_dynamic_entry (info, DT_HP_LOAD_MAP, 0)) 1811 return false; 1812 } 1855 if (!add_dynamic_entry (DT_DEBUG, 0) 1856 || !add_dynamic_entry (DT_HP_DLD_HOOK, 0) 1857 || !add_dynamic_entry (DT_HP_LOAD_MAP, 0)) 1858 return FALSE; 1859 } 1860 1861 /* Force DT_FLAGS to always be set. 1862 Required by HPUX 11.00 patch PHSS_26559. */ 1863 if (!add_dynamic_entry (DT_FLAGS, (info)->flags)) 1864 return FALSE; 1813 1865 1814 1866 if (plt) 1815 1867 { 1816 if (! bfd_elf64_add_dynamic_entry (info,DT_PLTRELSZ, 0)1817 || ! bfd_elf64_add_dynamic_entry (info,DT_PLTREL, DT_RELA)1818 || ! bfd_elf64_add_dynamic_entry (info,DT_JMPREL, 0))1819 return false;1868 if (!add_dynamic_entry (DT_PLTRELSZ, 0) 1869 || !add_dynamic_entry (DT_PLTREL, DT_RELA) 1870 || !add_dynamic_entry (DT_JMPREL, 0)) 1871 return FALSE; 1820 1872 } 1821 1873 1822 1874 if (relocs) 1823 1875 { 1824 if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0) 1825 || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0) 1826 || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT, 1827 sizeof (Elf64_External_Rela))) 1828 return false; 1876 if (!add_dynamic_entry (DT_RELA, 0) 1877 || !add_dynamic_entry (DT_RELASZ, 0) 1878 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela))) 1879 return FALSE; 1829 1880 } 1830 1881 1831 1882 if (reltext) 1832 1883 { 1833 if (! bfd_elf64_add_dynamic_entry (info,DT_TEXTREL, 0))1834 return false;1884 if (!add_dynamic_entry (DT_TEXTREL, 0)) 1885 return FALSE; 1835 1886 info->flags |= DF_TEXTREL; 1836 1887 } 1837 1888 } 1838 1839 return true; 1889 #undef add_dynamic_entry 1890 1891 return TRUE; 1840 1892 } 1841 1893 … … 1849 1901 table. Ick. */ 1850 1902 1851 static b oolean1903 static bfd_boolean 1852 1904 elf64_hppa_link_output_symbol_hook (abfd, info, name, sym, input_sec) 1853 1905 bfd *abfd ATTRIBUTE_UNUSED; … … 1863 1915 They never need munging, so it is safe to ignore them. */ 1864 1916 if (!name) 1865 return true;1917 return TRUE; 1866 1918 1867 1919 /* Get the PA dyn_symbol (if any) associated with NAME. */ 1868 1920 hppa_info = elf64_hppa_hash_table (info); 1869 1921 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, 1870 name, false, false);1922 name, FALSE, FALSE); 1871 1923 1872 1924 /* Function symbols for which we created .opd entries *may* have been … … 1884 1936 } 1885 1937 1886 return true;1938 return TRUE; 1887 1939 } 1888 1940 … … 1890 1942 dynamic sections here. */ 1891 1943 1892 static b oolean1944 static bfd_boolean 1893 1945 elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym) 1894 1946 bfd *output_bfd; … … 1903 1955 hppa_info = elf64_hppa_hash_table (info); 1904 1956 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, 1905 h->root.root.string, false, false);1957 h->root.root.string, FALSE, FALSE); 1906 1958 1907 1959 stub = hppa_info->stub_sec; … … 1912 1964 sdltrel = hppa_info->dlt_rel_sec; 1913 1965 1914 BFD_ASSERT (stub != NULL && splt != NULL1915 && sopd != NULL && sdlt != NULL)1916 1917 1966 /* Incredible. It is actually necessary to NOT use the symbol's real 1918 1967 value when building the dynamic symbol table for a shared library. … … 1924 1973 if (dyn_h && dyn_h->want_opd) 1925 1974 { 1975 BFD_ASSERT (sopd != NULL) 1976 1926 1977 /* Save away the original value and section index so that we 1927 1978 can restore them later. */ … … 1944 1995 bfd_vma value; 1945 1996 Elf_Internal_Rela rel; 1997 bfd_byte *loc; 1998 1999 BFD_ASSERT (splt != NULL && spltrel != NULL) 1946 2000 1947 2001 /* We do not actually care about the value in the PLT entry … … 1980 2034 rel.r_addend = 0; 1981 2035 1982 bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel, 1983 (((Elf64_External_Rela *) 1984 spltrel->contents) 1985 + spltrel->reloc_count)); 1986 spltrel->reloc_count++; 2036 loc = spltrel->contents; 2037 loc += spltrel->reloc_count++ * sizeof (Elf64_External_Rela); 2038 bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel, loc); 1987 2039 } 1988 2040 … … 1994 2046 int insn; 1995 2047 unsigned int max_offset; 2048 2049 BFD_ASSERT (stub != NULL) 1996 2050 1997 2051 /* Install the generic stub template. … … 2020 2074 max_offset = 32768; 2021 2075 insn &= ~ 0xfff1; 2022 insn |= re_assemble_16 ( value);2076 insn |= re_assemble_16 ((int) value); 2023 2077 } 2024 2078 else … … 2026 2080 max_offset = 8192; 2027 2081 insn &= ~ 0x3ff1; 2028 insn |= re_assemble_14 ( value);2082 insn |= re_assemble_14 ((int) value); 2029 2083 } 2030 2084 … … 2034 2088 dyn_h->root.string, 2035 2089 (long) value); 2036 return false;2037 } 2038 2039 bfd_put_32 (stub->owner, insn,2090 return FALSE; 2091 } 2092 2093 bfd_put_32 (stub->owner, (bfd_vma) insn, 2040 2094 stub->contents + dyn_h->stub_offset); 2041 2095 … … 2046 2100 { 2047 2101 insn &= ~ 0xfff1; 2048 insn |= re_assemble_16 ( value);2102 insn |= re_assemble_16 ((int) value); 2049 2103 } 2050 2104 else 2051 2105 { 2052 2106 insn &= ~ 0x3ff1; 2053 insn |= re_assemble_14 ( value);2054 } 2055 bfd_put_32 (stub->owner, insn,2107 insn |= re_assemble_14 ((int) value); 2108 } 2109 bfd_put_32 (stub->owner, (bfd_vma) insn, 2056 2110 stub->contents + dyn_h->stub_offset + 8); 2057 2111 } 2058 2112 2059 /* Millicode symbols should not be put in the dynamic 2060 symbol table under any circumstances. */ 2061 if (ELF_ST_TYPE (sym->st_info) == STT_PARISC_MILLI) 2062 h->dynindx = -1; 2063 2064 return true; 2113 return TRUE; 2065 2114 } 2066 2115 … … 2068 2117 exports. Initialize the FPTR entries. */ 2069 2118 2070 static b oolean2119 static bfd_boolean 2071 2120 elf64_hppa_finalize_opd (dyn_h, data) 2072 2121 struct elf64_hppa_dyn_hash_entry *dyn_h; … … 2075 2124 struct bfd_link_info *info = (struct bfd_link_info *)data; 2076 2125 struct elf64_hppa_link_hash_table *hppa_info; 2077 struct elf_link_hash_entry *h = dyn_h ->h;2126 struct elf_link_hash_entry *h = dyn_h ? dyn_h->h : NULL; 2078 2127 asection *sopd; 2079 2128 asection *sopdrel; … … 2083 2132 sopdrel = hppa_info->opd_rel_sec; 2084 2133 2085 if (h && dyn_h && dyn_h->want_opd)2134 if (h && dyn_h->want_opd) 2086 2135 { 2087 2136 bfd_vma value; … … 2110 2159 if (info->shared && dyn_h && dyn_h->want_opd) 2111 2160 { 2112 Elf64_Internal_Rela rel; 2161 Elf_Internal_Rela rel; 2162 bfd_byte *loc; 2113 2163 int dynindx; 2114 2164 … … 2165 2215 2166 2216 nh = elf_link_hash_lookup (elf_hash_table (info), 2167 new_name, false, false, false);2217 new_name, FALSE, FALSE, FALSE); 2168 2218 2169 2219 /* All we really want from the new symbol is its dynamic … … 2175 2225 rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_EPLT); 2176 2226 2177 bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel, 2178 (((Elf64_External_Rela *) 2179 sopdrel->contents) 2180 + sopdrel->reloc_count)); 2181 sopdrel->reloc_count++; 2182 } 2183 return true; 2227 loc = sopdrel->contents; 2228 loc += sopdrel->reloc_count++ * sizeof (Elf64_External_Rela); 2229 bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel, loc); 2230 } 2231 return TRUE; 2184 2232 } 2185 2233 … … 2188 2236 we can not depend on finish_dynamic_symbol to initialize the .dlt. */ 2189 2237 2190 static b oolean2238 static bfd_boolean 2191 2239 elf64_hppa_finalize_dlt (dyn_h, data) 2192 2240 struct elf64_hppa_dyn_hash_entry *dyn_h; … … 2196 2244 struct elf64_hppa_link_hash_table *hppa_info; 2197 2245 asection *sdlt, *sdltrel; 2198 struct elf_link_hash_entry *h = dyn_h ->h;2246 struct elf_link_hash_entry *h = dyn_h ? dyn_h->h : NULL; 2199 2247 2200 2248 hppa_info = elf64_hppa_hash_table (info); … … 2207 2255 the proper value into the DLT, note this shortcut can not be 2208 2256 skipped when building a shared library. */ 2209 if (! info->shared && h && dyn_h && dyn_h->want_dlt)2257 if (! info->shared && h && dyn_h->want_dlt) 2210 2258 { 2211 2259 bfd_vma value; … … 2223 2271 + hppa_info->opd_sec->output_section->vma); 2224 2272 } 2225 else 2226 { 2227 value = (h->root.u.def.value 2228 + h->root.u.def.section->output_offset); 2229 2273 else if (h->root.u.def.section) 2274 { 2275 value = h->root.u.def.value + h->root.u.def.section->output_offset; 2230 2276 if (h->root.u.def.section->output_section) 2231 2277 value += h->root.u.def.section->output_section->vma; … … 2233 2279 value += h->root.u.def.section->vma; 2234 2280 } 2281 else 2282 /* We have an undefined function reference. */ 2283 value = 0; 2235 2284 2236 2285 /* We do not need to include the output offset of the DLT section … … 2244 2293 && (elf64_hppa_dynamic_symbol_p (dyn_h->h, info) || info->shared)) 2245 2294 { 2246 Elf64_Internal_Rela rel; 2295 Elf_Internal_Rela rel; 2296 bfd_byte *loc; 2247 2297 int dynindx; 2248 2298 … … 2268 2318 rel.r_addend = 0; 2269 2319 2270 bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel, 2271 (((Elf64_External_Rela *) 2272 sdltrel->contents) 2273 + sdltrel->reloc_count)); 2274 sdltrel->reloc_count++; 2275 } 2276 return true; 2320 loc = sdltrel->contents; 2321 loc += sdltrel->reloc_count++ * sizeof (Elf64_External_Rela); 2322 bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel, loc); 2323 } 2324 return TRUE; 2277 2325 } 2278 2326 … … 2280 2328 for dynamic functions used to initialize static data. */ 2281 2329 2282 static b oolean2330 static bfd_boolean 2283 2331 elf64_hppa_finalize_dynreloc (dyn_h, data) 2284 2332 struct elf64_hppa_dyn_hash_entry *dyn_h; … … 2293 2341 2294 2342 if (!dynamic_symbol && !info->shared) 2295 return true;2343 return TRUE; 2296 2344 2297 2345 if (dyn_h->reloc_entries) … … 2315 2363 for (rent = dyn_h->reloc_entries; rent; rent = rent->next) 2316 2364 { 2317 Elf64_Internal_Rela rel; 2318 2319 switch (rent->type) 2320 { 2321 case R_PARISC_FPTR64: 2322 /* Allocate one iff we are not building a shared library and 2323 !want_opd, which by this point will be true only if we're 2324 actually allocating one statically in the main executable. */ 2325 if (!info->shared && dyn_h->want_opd) 2326 continue; 2327 break; 2328 } 2365 Elf_Internal_Rela rel; 2366 bfd_byte *loc; 2367 2368 /* Allocate one iff we are building a shared library, the relocation 2369 isn't a R_PARISC_FPTR64, or we don't want an opd entry. */ 2370 if (!info->shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd) 2371 continue; 2329 2372 2330 2373 /* Create a dynamic relocation for this entry. … … 2355 2398 base symbol for the relocation. The addend is the difference 2356 2399 between the section symbol and the address of the .opd entry. */ 2357 if (info->shared && rent->type == R_PARISC_FPTR64 )2400 if (info->shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd) 2358 2401 { 2359 2402 bfd_vma value, value2; … … 2388 2431 rel.r_info = ELF64_R_INFO (dynindx, rent->type); 2389 2432 2433 loc = hppa_info->other_rel_sec->contents; 2434 loc += (hppa_info->other_rel_sec->reloc_count++ 2435 * sizeof (Elf64_External_Rela)); 2390 2436 bfd_elf64_swap_reloca_out (hppa_info->other_rel_sec->output_section->owner, 2391 &rel, 2392 (((Elf64_External_Rela *) 2393 hppa_info->other_rel_sec->contents) 2394 + hppa_info->other_rel_sec->reloc_count)); 2395 hppa_info->other_rel_sec->reloc_count++; 2396 } 2397 } 2398 2399 return true; 2437 &rel, loc); 2438 } 2439 } 2440 2441 return TRUE; 2442 } 2443 2444 /* Used to decide how to sort relocs in an optimal manner for the 2445 dynamic linker, before writing them out. */ 2446 2447 static enum elf_reloc_type_class 2448 elf64_hppa_reloc_type_class (rela) 2449 const Elf_Internal_Rela *rela; 2450 { 2451 if (ELF64_R_SYM (rela->r_info) == 0) 2452 return reloc_class_relative; 2453 2454 switch ((int) ELF64_R_TYPE (rela->r_info)) 2455 { 2456 case R_PARISC_IPLT: 2457 return reloc_class_plt; 2458 case R_PARISC_COPY: 2459 return reloc_class_copy; 2460 default: 2461 return reloc_class_normal; 2462 } 2400 2463 } 2401 2464 2402 2465 /* Finish up the dynamic sections. */ 2403 2466 2404 static b oolean2467 static bfd_boolean 2405 2468 elf64_hppa_finish_dynamic_sections (output_bfd, info) 2406 2469 bfd *output_bfd; … … 2483 2546 case DT_RELA: 2484 2547 s = hppa_info->other_rel_sec; 2485 if (! s )2548 if (! s || ! s->_raw_size) 2486 2549 s = hppa_info->dlt_rel_sec; 2550 if (! s || ! s->_raw_size) 2551 s = hppa_info->opd_rel_sec; 2487 2552 dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; 2488 2553 bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); … … 2508 2573 } 2509 2574 2510 return true;2575 return TRUE; 2511 2576 } 2512 2577 … … 2550 2615 existence of a .interp section. */ 2551 2616 2552 static b oolean2617 static bfd_boolean 2553 2618 elf64_hppa_modify_segment_map (abfd) 2554 2619 bfd *abfd; … … 2565 2630 if (m == NULL) 2566 2631 { 2567 m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m); 2632 m = ((struct elf_segment_map *) 2633 bfd_zalloc (abfd, (bfd_size_type) sizeof *m)); 2568 2634 if (m == NULL) 2569 return false;2635 return FALSE; 2570 2636 2571 2637 m->p_type = PT_PHDR; … … 2598 2664 } 2599 2665 2600 return true;2666 return TRUE; 2601 2667 } 2602 2668 … … 2633 2699 bfd_elf64_write_shdrs_and_ehdr, 2634 2700 bfd_elf64_write_relocs, 2701 bfd_elf64_swap_symbol_in, 2635 2702 bfd_elf64_swap_symbol_out, 2636 2703 bfd_elf64_slurp_reloc_table, … … 2638 2705 bfd_elf64_swap_dyn_in, 2639 2706 bfd_elf64_swap_dyn_out, 2640 NULL,2641 NULL,2642 NULL,2643 NULL2707 bfd_elf64_swap_reloc_in, 2708 bfd_elf64_swap_reloc_out, 2709 bfd_elf64_swap_reloca_in, 2710 bfd_elf64_swap_reloca_out 2644 2711 }; 2645 2712 … … 2660 2727 #define elf_backend_final_write_processing \ 2661 2728 elf_hppa_final_write_processing 2662 #define elf_backend_fake_sections 2729 #define elf_backend_fake_sections elf_hppa_fake_sections 2663 2730 #define elf_backend_add_symbol_hook elf_hppa_add_symbol_hook 2664 2731 2665 #define elf_backend_relocate_section 2732 #define elf_backend_relocate_section elf_hppa_relocate_section 2666 2733 2667 2734 #define bfd_elf64_bfd_final_link elf_hppa_final_link … … 2706 2773 #define elf_backend_got_header_size 0 2707 2774 #define elf_backend_plt_header_size 0 2708 #define elf_backend_type_change_ok true 2709 #define elf_backend_get_symbol_type elf64_hppa_elf_get_symbol_type 2775 #define elf_backend_type_change_ok TRUE 2776 #define elf_backend_get_symbol_type elf64_hppa_elf_get_symbol_type 2777 #define elf_backend_reloc_type_class elf64_hppa_reloc_type_class 2778 #define elf_backend_rela_normal 1 2710 2779 2711 2780 #include "elf64-target.h" -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.