Changeset 609 for branches/GNU/src/binutils/bfd/elf32-i370.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/elf32-i370.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* i370-specific support for 32-bit ELF 2 Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001 2 Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Written by Ian Lance Taylor, Cygnus Support. … … 35 35 #include "elf/i370.h" 36 36 37 #define USE_RELA /* we want RELA relocations, not REL */38 39 /* i370 relocations */40 /* Note that there is really just one relocation that we currently41 * support (and only one that we seem to need, at the moment), and42 * that is the 31-bit address relocation. Note that the 370/39043 * only supports a 31-bit (2GB) address space.44 */45 enum i370_reloc_type46 {47 R_I370_NONE = 0,48 R_I370_ADDR31 = 1,49 R_I370_ADDR32 = 2,50 R_I370_ADDR16 = 3,51 R_I370_REL31 = 4,52 R_I370_REL32 = 5,53 R_I370_ADDR12 = 6,54 R_I370_REL12 = 7,55 R_I370_ADDR8 = 8,56 R_I370_REL8 = 9,57 R_I370_COPY = 10,58 R_I370_RELATIVE = 11,59 60 R_I370_max61 };62 63 64 37 static reloc_howto_type *i370_elf_howto_table[ (int)R_I370_max ]; 65 38 … … 71 44 2, /* size (0 = byte, 1 = short, 2 = long) */ 72 45 32, /* bitsize */ 73 false, /* pc_relative */46 FALSE, /* pc_relative */ 74 47 0, /* bitpos */ 75 48 complain_overflow_bitfield, /* complain_on_overflow */ 76 49 bfd_elf_generic_reloc, /* special_function */ 77 50 "R_I370_NONE", /* name */ 78 false, /* partial_inplace */51 FALSE, /* partial_inplace */ 79 52 0, /* src_mask */ 80 53 0, /* dst_mask */ 81 false), /* pcrel_offset */54 FALSE), /* pcrel_offset */ 82 55 83 56 /* A standard 31 bit relocation. */ … … 86 59 2, /* size (0 = byte, 1 = short, 2 = long) */ 87 60 31, /* bitsize */ 88 false, /* pc_relative */61 FALSE, /* pc_relative */ 89 62 0, /* bitpos */ 90 63 complain_overflow_bitfield, /* complain_on_overflow */ 91 64 bfd_elf_generic_reloc, /* special_function */ 92 65 "R_I370_ADDR31", /* name */ 93 false, /* partial_inplace */66 FALSE, /* partial_inplace */ 94 67 0, /* src_mask */ 95 68 0x7fffffff, /* dst_mask */ 96 false), /* pcrel_offset */69 FALSE), /* pcrel_offset */ 97 70 98 71 /* A standard 32 bit relocation. */ … … 101 74 2, /* size (0 = byte, 1 = short, 2 = long) */ 102 75 32, /* bitsize */ 103 false, /* pc_relative */76 FALSE, /* pc_relative */ 104 77 0, /* bitpos */ 105 78 complain_overflow_bitfield, /* complain_on_overflow */ 106 79 bfd_elf_generic_reloc, /* special_function */ 107 80 "R_I370_ADDR32", /* name */ 108 false, /* partial_inplace */81 FALSE, /* partial_inplace */ 109 82 0, /* src_mask */ 110 83 0xffffffff, /* dst_mask */ 111 false), /* pcrel_offset */84 FALSE), /* pcrel_offset */ 112 85 113 86 /* A standard 16 bit relocation. */ … … 116 89 1, /* size (0 = byte, 1 = short, 2 = long) */ 117 90 16, /* bitsize */ 118 false, /* pc_relative */91 FALSE, /* pc_relative */ 119 92 0, /* bitpos */ 120 93 complain_overflow_bitfield, /* complain_on_overflow */ 121 94 bfd_elf_generic_reloc, /* special_function */ 122 95 "R_I370_ADDR16", /* name */ 123 false, /* partial_inplace */96 FALSE, /* partial_inplace */ 124 97 0, /* src_mask */ 125 98 0xffff, /* dst_mask */ 126 false), /* pcrel_offset */99 FALSE), /* pcrel_offset */ 127 100 128 101 /* 31-bit PC relative */ … … 131 104 2, /* size (0 = byte, 1 = short, 2 = long) */ 132 105 31, /* bitsize */ 133 true, /* pc_relative */106 TRUE, /* pc_relative */ 134 107 0, /* bitpos */ 135 108 complain_overflow_bitfield, /* complain_on_overflow */ 136 109 bfd_elf_generic_reloc, /* special_function */ 137 110 "R_I370_REL31", /* name */ 138 false, /* partial_inplace */111 FALSE, /* partial_inplace */ 139 112 0, /* src_mask */ 140 113 0x7fffffff, /* dst_mask */ 141 true), /* pcrel_offset */114 TRUE), /* pcrel_offset */ 142 115 143 116 /* 32-bit PC relative */ … … 146 119 2, /* size (0 = byte, 1 = short, 2 = long) */ 147 120 32, /* bitsize */ 148 true, /* pc_relative */121 TRUE, /* pc_relative */ 149 122 0, /* bitpos */ 150 123 complain_overflow_bitfield, /* complain_on_overflow */ 151 124 bfd_elf_generic_reloc, /* special_function */ 152 125 "R_I370_REL32", /* name */ 153 false, /* partial_inplace */126 FALSE, /* partial_inplace */ 154 127 0, /* src_mask */ 155 128 0xffffffff, /* dst_mask */ 156 true), /* pcrel_offset */129 TRUE), /* pcrel_offset */ 157 130 158 131 /* A standard 12 bit relocation. */ … … 161 134 1, /* size (0 = byte, 1 = short, 2 = long) */ 162 135 12, /* bitsize */ 163 false, /* pc_relative */136 FALSE, /* pc_relative */ 164 137 0, /* bitpos */ 165 138 complain_overflow_bitfield, /* complain_on_overflow */ 166 139 bfd_elf_generic_reloc, /* special_function */ 167 140 "R_I370_ADDR12", /* name */ 168 false, /* partial_inplace */141 FALSE, /* partial_inplace */ 169 142 0, /* src_mask */ 170 143 0xfff, /* dst_mask */ 171 false), /* pcrel_offset */144 FALSE), /* pcrel_offset */ 172 145 173 146 /* 12-bit PC relative */ … … 176 149 1, /* size (0 = byte, 1 = short, 2 = long) */ 177 150 12, /* bitsize */ 178 true, /* pc_relative */151 TRUE, /* pc_relative */ 179 152 0, /* bitpos */ 180 153 complain_overflow_bitfield, /* complain_on_overflow */ 181 154 bfd_elf_generic_reloc, /* special_function */ 182 155 "R_I370_REL12", /* name */ 183 false, /* partial_inplace */156 FALSE, /* partial_inplace */ 184 157 0, /* src_mask */ 185 158 0xfff, /* dst_mask */ 186 true), /* pcrel_offset */159 TRUE), /* pcrel_offset */ 187 160 188 161 /* A standard 8 bit relocation. */ … … 191 164 0, /* size (0 = byte, 1 = short, 2 = long) */ 192 165 8, /* bitsize */ 193 false, /* pc_relative */166 FALSE, /* pc_relative */ 194 167 0, /* bitpos */ 195 168 complain_overflow_bitfield, /* complain_on_overflow */ 196 169 bfd_elf_generic_reloc, /* special_function */ 197 170 "R_I370_ADDR8", /* name */ 198 false, /* partial_inplace */171 FALSE, /* partial_inplace */ 199 172 0, /* src_mask */ 200 173 0xff, /* dst_mask */ 201 false), /* pcrel_offset */174 FALSE), /* pcrel_offset */ 202 175 203 176 /* 8-bit PC relative */ … … 206 179 0, /* size (0 = byte, 1 = short, 2 = long) */ 207 180 8, /* bitsize */ 208 true, /* pc_relative */181 TRUE, /* pc_relative */ 209 182 0, /* bitpos */ 210 183 complain_overflow_bitfield, /* complain_on_overflow */ 211 184 bfd_elf_generic_reloc, /* special_function */ 212 185 "R_I370_REL8", /* name */ 213 false, /* partial_inplace */186 FALSE, /* partial_inplace */ 214 187 0, /* src_mask */ 215 188 0xff, /* dst_mask */ 216 true), /* pcrel_offset */189 TRUE), /* pcrel_offset */ 217 190 218 191 /* This is used only by the dynamic linker. The symbol should exist … … 225 198 2, /* size (0 = byte, 1 = short, 2 = long) */ 226 199 32, /* bitsize */ 227 false, /* pc_relative */200 FALSE, /* pc_relative */ 228 201 0, /* bitpos */ 229 202 complain_overflow_bitfield, /* complain_on_overflow */ 230 203 bfd_elf_generic_reloc, /* special_function */ 231 204 "R_I370_COPY", /* name */ 232 false, /* partial_inplace */205 FALSE, /* partial_inplace */ 233 206 0, /* src_mask */ 234 207 0, /* dst_mask */ 235 false), /* pcrel_offset */208 FALSE), /* pcrel_offset */ 236 209 237 210 /* Used only by the dynamic linker. When the object is run, this … … 242 215 2, /* size (0 = byte, 1 = short, 2 = long) */ 243 216 32, /* bitsize */ 244 false, /* pc_relative */217 FALSE, /* pc_relative */ 245 218 0, /* bitpos */ 246 219 complain_overflow_bitfield, /* complain_on_overflow */ 247 220 bfd_elf_generic_reloc, /* special_function */ 248 221 "R_I370_RELATIVE", /* name */ 249 false, /* partial_inplace */222 FALSE, /* partial_inplace */ 250 223 0, /* src_mask */ 251 224 0xffffffff, /* dst_mask */ 252 false), /* pcrel_offset */225 FALSE), /* pcrel_offset */ 253 226 254 227 }; 255 228 256 229 257 static void i370_elf_howto_init PARAMS ((void)); 258 static void i370_elf_info_to_howto PARAMS ((bfd *abfd, arelent *cache_ptr, 259 Elf32_Internal_Rela *dst)); 260 static boolean i370_elf_set_private_flags PARAMS ((bfd *, flagword)); 230 static void i370_elf_howto_init 231 PARAMS ((void)); 232 static reloc_howto_type *i370_elf_reloc_type_lookup 233 PARAMS ((bfd *, bfd_reloc_code_real_type)); 234 static void i370_elf_info_to_howto 235 PARAMS ((bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)); 236 static bfd_boolean i370_elf_set_private_flags 237 PARAMS ((bfd *, flagword)); 261 238 262 239 … … 303 280 }; 304 281 305 static boolean i370_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *)); 306 static boolean i370_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); 307 308 static boolean i370_elf_relocate_section PARAMS ((bfd *, 309 struct bfd_link_info *info, 310 bfd *, 311 asection *, 312 bfd_byte *, 313 Elf_Internal_Rela *relocs, 314 Elf_Internal_Sym *local_syms, 315 asection **)); 316 317 static boolean i370_elf_create_dynamic_sections PARAMS ((bfd *, 318 struct bfd_link_info *)); 319 320 static boolean i370_elf_section_from_shdr PARAMS ((bfd *, 321 Elf32_Internal_Shdr *, 322 char *)); 323 static boolean i370_elf_fake_sections PARAMS ((bfd *, 324 Elf32_Internal_Shdr *, 325 asection *)); 282 static bfd_boolean i370_elf_merge_private_bfd_data 283 PARAMS ((bfd *, bfd *)); 284 static bfd_boolean i370_elf_relocate_section 285 PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *, 286 Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, 287 asection **)); 288 static void i370_elf_post_process_headers 289 PARAMS ((bfd *, struct bfd_link_info *)); 290 static bfd_boolean i370_elf_create_dynamic_sections 291 PARAMS ((bfd *, struct bfd_link_info *)); 292 static bfd_boolean i370_elf_section_from_shdr 293 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *)); 294 static bfd_boolean i370_elf_fake_sections 295 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); 326 296 #if 0 327 297 static elf_linker_section_t *i370_elf_create_linker_section 328 PARAMS ((bfd *abfd, 329 struct bfd_link_info *info, 298 PARAMS ((bfd *abfd, struct bfd_link_info *info, 330 299 enum elf_linker_section_enum)); 331 300 #endif 332 static boolean i370_elf_check_relocs PARAMS ((bfd *, 333 struct bfd_link_info *, 334 asection *, 335 const Elf_Internal_Rela *)); 336 337 static boolean i370_elf_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *, 338 struct elf_link_hash_entry *)); 339 340 static boolean i370_elf_adjust_dynindx PARAMS ((struct elf_link_hash_entry *, PTR)); 341 342 static boolean i370_elf_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); 343 344 static boolean i370_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); 301 static bfd_boolean i370_elf_check_relocs 302 PARAMS ((bfd *, struct bfd_link_info *, asection *, 303 const Elf_Internal_Rela *)); 304 static bfd_boolean i370_elf_adjust_dynamic_symbol 305 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); 306 static bfd_boolean i370_elf_adjust_dynindx 307 PARAMS ((struct elf_link_hash_entry *, PTR)); 308 static bfd_boolean i370_elf_size_dynamic_sections 309 PARAMS ((bfd *, struct bfd_link_info *)); 310 static bfd_boolean i370_elf_finish_dynamic_sections 311 PARAMS ((bfd *, struct bfd_link_info *)); 345 312 346 313 /* The name of the dynamic interpreter. This is put in the .interp … … 355 322 bfd *abfd ATTRIBUTE_UNUSED; 356 323 arelent *cache_ptr; 357 Elf 32_Internal_Rela *dst;324 Elf_Internal_Rela *dst; 358 325 { 359 326 if (!i370_elf_howto_table[ R_I370_ADDR31 ]) /* Initialize howto table */ … … 368 335 */ 369 336 /* Function to set whether a module needs the -mrelocatable bit set. */ 370 static b oolean337 static bfd_boolean 371 338 i370_elf_set_private_flags (abfd, flags) 372 339 bfd *abfd; … … 377 344 378 345 elf_elfheader (abfd)->e_flags = flags; 379 elf_flags_init (abfd) = true; 380 return true; 381 } 382 383 /* Copy backend specific data from one object module to another */ 384 static boolean 385 i370_elf_copy_private_bfd_data (ibfd, obfd) 386 bfd *ibfd; 387 bfd *obfd; 388 { 389 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour 390 || bfd_get_flavour (obfd) != bfd_target_elf_flavour) 391 return true; 392 393 BFD_ASSERT (!elf_flags_init (obfd) 394 || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags); 395 396 elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; 397 elf_flags_init (obfd) = true; 398 return true; 346 elf_flags_init (abfd) = TRUE; 347 return TRUE; 399 348 } 400 349 401 350 /* Merge backend specific data from an object file to the output 402 351 object file when linking */ 403 static b oolean352 static bfd_boolean 404 353 i370_elf_merge_private_bfd_data (ibfd, obfd) 405 354 bfd *ibfd; … … 411 360 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour 412 361 || bfd_get_flavour (obfd) != bfd_target_elf_flavour) 413 return true;362 return TRUE; 414 363 415 364 new_flags = elf_elfheader (ibfd)->e_flags; … … 417 366 if (!elf_flags_init (obfd)) /* First call, no flags set */ 418 367 { 419 elf_flags_init (obfd) = true;368 elf_flags_init (obfd) = TRUE; 420 369 elf_elfheader (obfd)->e_flags = new_flags; 421 370 } … … 428 377 (*_bfd_error_handler) 429 378 ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)", 430 bfd_ get_filename (ibfd), (long)new_flags, (long)old_flags);379 bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags); 431 380 432 381 bfd_set_error (bfd_error_bad_value); 433 return false;434 } 435 436 return true;382 return FALSE; 383 } 384 385 return TRUE; 437 386 } 438 387 … … 445 394 */ 446 395 447 static b oolean396 static bfd_boolean 448 397 i370_elf_section_from_shdr (abfd, hdr, name) 449 398 bfd *abfd; 450 Elf 32_Internal_Shdr *hdr;451 c har *name;399 Elf_Internal_Shdr *hdr; 400 const char *name; 452 401 { 453 402 asection *newsect; … … 455 404 456 405 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) 457 return false;406 return FALSE; 458 407 459 408 newsect = hdr->bfd_section; … … 466 415 467 416 bfd_set_section_flags (abfd, newsect, flags); 468 return true;417 return TRUE; 469 418 } 470 419 … … 476 425 */ 477 426 478 static b oolean427 static bfd_boolean 479 428 i370_elf_fake_sections (abfd, shdr, asect) 480 429 bfd *abfd ATTRIBUTE_UNUSED; 481 Elf 32_Internal_Shdr *shdr;430 Elf_Internal_Shdr *shdr; 482 431 asection *asect; 483 432 { … … 488 437 shdr->sh_type = SHT_ORDERED; 489 438 490 return true;439 return TRUE; 491 440 } 492 441 … … 521 470 defaults = zero_section; 522 471 defaults.which = which; 523 defaults.hole_written_p = false;472 defaults.hole_written_p = FALSE; 524 473 defaults.alignment = 2; 525 474 … … 539 488 default: 540 489 (*_bfd_error_handler) ("%s: Unknown special linker type %d", 541 bfd_ get_filename (abfd),542 (int) which);490 bfd_archive_filename (abfd), 491 (int) which); 543 492 544 493 bfd_set_error (bfd_error_bad_value); … … 579 528 */ 580 529 581 static b oolean530 static bfd_boolean 582 531 i370_elf_create_dynamic_sections (abfd, info) 583 532 bfd *abfd; … … 588 537 589 538 if (!_bfd_elf_create_dynamic_sections(abfd, info)) 590 return false;539 return FALSE; 591 540 592 541 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY … … 596 545 if (s == NULL 597 546 || ! bfd_set_section_flags (abfd, s, SEC_ALLOC)) 598 return false;547 return FALSE; 599 548 600 549 if (! info->shared) … … 604 553 || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) 605 554 || ! bfd_set_section_alignment (abfd, s, 2)) 606 return false;555 return FALSE; 607 556 } 608 557 … … 612 561 || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) 613 562 || ! bfd_set_section_alignment (abfd, s, 2)) 614 return false;615 return true;563 return FALSE; 564 return TRUE; 616 565 } 617 566 … … 626 575 */ 627 576 628 static b oolean577 static bfd_boolean 629 578 i370_elf_adjust_dynamic_symbol (info, h) 630 579 struct bfd_link_info *info; … … 664 613 h->root.u.def.section = h->weakdef->root.u.def.section; 665 614 h->root.u.def.value = h->weakdef->root.u.def.value; 666 return true;615 return TRUE; 667 616 } 668 617 … … 675 624 be handled correctly by relocate_section. */ 676 625 if (info->shared) 677 return true;626 return TRUE; 678 627 679 628 /* We must allocate the symbol in our .dynbss section, which will … … 726 675 { 727 676 if (! bfd_set_section_alignment (dynobj, s, power_of_two)) 728 return false;677 return FALSE; 729 678 } 730 679 … … 736 685 s->_raw_size += h->size; 737 686 738 return true;687 return TRUE; 739 688 } 740 689 … … 747 696 */ 748 697 749 static b oolean698 static bfd_boolean 750 699 i370_elf_adjust_dynindx (h, cparg) 751 700 struct elf_link_hash_entry *h; … … 760 709 #endif 761 710 711 if (h->root.type == bfd_link_hash_warning) 712 h = (struct elf_link_hash_entry *) h->root.u.i.link; 713 762 714 if (h->dynindx != -1) 763 715 h->dynindx += *cp; 764 716 765 return true;717 return TRUE; 766 718 } 767 719 … … 773 725 */ 774 726 775 static b oolean727 static bfd_boolean 776 728 i370_elf_size_dynamic_sections (output_bfd, info) 777 729 bfd *output_bfd; … … 780 732 bfd *dynobj; 781 733 asection *s; 782 b oolean plt;783 b oolean relocs;784 b oolean reltext;734 bfd_boolean plt; 735 bfd_boolean relocs; 736 bfd_boolean reltext; 785 737 786 738 #ifdef DEBUG … … 825 777 determined the sizes of the various dynamic sections. Allocate 826 778 memory for them. */ 827 plt = false;828 relocs = false;829 reltext = false;779 plt = FALSE; 780 relocs = FALSE; 781 reltext = FALSE; 830 782 for (s = dynobj->sections; s != NULL; s = s->next) 831 783 { 832 784 const char *name; 833 b oolean strip;785 bfd_boolean strip; 834 786 835 787 if ((s->flags & SEC_LINKER_CREATED) == 0) … … 839 791 of the dynobj section names depend upon the input files. */ 840 792 name = bfd_get_section_name (dynobj, s); 841 strip = false;793 strip = FALSE; 842 794 843 795 if (strcmp (name, ".plt") == 0) … … 847 799 /* Strip this section if we don't need it; see the 848 800 comment below. */ 849 strip = true;801 strip = TRUE; 850 802 } 851 803 else 852 804 { 853 805 /* Remember whether there is a PLT. */ 854 plt = true;806 plt = TRUE; 855 807 } 856 808 } … … 868 820 function which decides whether anything needs to go 869 821 into these sections. */ 870 strip = true;822 strip = TRUE; 871 823 } 872 824 else … … 876 828 877 829 /* Remember whether there are any relocation sections. */ 878 relocs = true;830 relocs = TRUE; 879 831 880 832 /* If this relocation section applies to a read only … … 886 838 && (target->flags & SEC_READONLY) != 0 887 839 && (target->flags & SEC_ALLOC) != 0) 888 reltext = true;840 reltext = TRUE; 889 841 890 842 /* We use the reloc_count field as a counter if we need … … 906 858 907 859 for (spp = &s->output_section->owner->sections; 908 *spp != s->output_section;860 *spp != NULL; 909 861 spp = &(*spp)->next) 910 ; 911 *spp = s->output_section->next; 912 --s->output_section->owner->section_count; 913 862 { 863 if (*spp == s->output_section) 864 { 865 bfd_section_list_remove (s->output_section->owner, spp); 866 --s->output_section->owner->section_count; 867 break; 868 } 869 } 914 870 continue; 915 871 } … … 917 873 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); 918 874 if (s->contents == NULL && s->_raw_size != 0) 919 return false;875 return FALSE; 920 876 } 921 877 … … 927 883 the .dynamic section. The DT_DEBUG entry is filled in by the 928 884 dynamic linker and used by the debugger. */ 929 if (! info->shared) 930 { 931 if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0)) 932 return false; 885 #define add_dynamic_entry(TAG, VAL) \ 886 bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) 887 888 if (!info->shared) 889 { 890 if (!add_dynamic_entry (DT_DEBUG, 0)) 891 return FALSE; 933 892 } 934 893 935 894 if (plt) 936 895 { 937 if (! bfd_elf32_add_dynamic_entry (info,DT_PLTGOT, 0)938 || ! bfd_elf32_add_dynamic_entry (info,DT_PLTRELSZ, 0)939 || ! bfd_elf32_add_dynamic_entry (info,DT_PLTREL, DT_RELA)940 || ! bfd_elf32_add_dynamic_entry (info,DT_JMPREL, 0))941 return false;896 if (!add_dynamic_entry (DT_PLTGOT, 0) 897 || !add_dynamic_entry (DT_PLTRELSZ, 0) 898 || !add_dynamic_entry (DT_PLTREL, DT_RELA) 899 || !add_dynamic_entry (DT_JMPREL, 0)) 900 return FALSE; 942 901 } 943 902 944 903 if (relocs) 945 904 { 946 if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0) 947 || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0) 948 || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT, 949 sizeof (Elf32_External_Rela))) 950 return false; 905 if (!add_dynamic_entry (DT_RELA, 0) 906 || !add_dynamic_entry (DT_RELASZ, 0) 907 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))) 908 return FALSE; 951 909 } 952 910 953 911 if (reltext) 954 912 { 955 if (! bfd_elf32_add_dynamic_entry (info,DT_TEXTREL, 0))956 return false;913 if (!add_dynamic_entry (DT_TEXTREL, 0)) 914 return FALSE; 957 915 info->flags |= DF_TEXTREL; 958 916 } 959 917 } 918 #undef add_dynamic_entry 960 919 961 920 /* If we are generating a shared library, we generate a section … … 996 955 } 997 956 998 return true;957 return TRUE; 999 958 } 1000 959 … … 1008 967 */ 1009 968 1010 static b oolean969 static bfd_boolean 1011 970 i370_elf_check_relocs (abfd, info, sec, relocs) 1012 971 bfd *abfd; … … 1024 983 1025 984 if (info->relocateable) 1026 return true;985 return TRUE; 1027 986 1028 987 #ifdef DEBUG 1029 988 fprintf (stderr, "i370_elf_check_relocs called for section %s in %s\n", 1030 989 bfd_get_section_name (abfd, sec), 1031 bfd_ get_filename (abfd));990 bfd_archive_filename (abfd)); 1032 991 #endif 1033 992 … … 1068 1027 elf_section_data (sec)->rel_hdr.sh_name)); 1069 1028 if (name == NULL) 1070 return false;1029 return FALSE; 1071 1030 1072 1031 BFD_ASSERT (strncmp (name, ".rela", 5) == 0 … … 1086 1045 || ! bfd_set_section_flags (dynobj, sreloc, flags) 1087 1046 || ! bfd_set_section_alignment (dynobj, sreloc, 2)) 1088 return false;1047 return FALSE; 1089 1048 } 1090 1049 } … … 1101 1060 } 1102 1061 1103 return true;1062 return TRUE; 1104 1063 } 1105 1064 … … 1111 1070 */ 1112 1071 1113 static b oolean1072 static bfd_boolean 1114 1073 i370_elf_finish_dynamic_sections (output_bfd, info) 1115 1074 bfd *output_bfd; … … 1140 1099 Elf_Internal_Dyn dyn; 1141 1100 const char *name; 1142 b oolean size;1101 bfd_boolean size; 1143 1102 1144 1103 bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); … … 1146 1105 switch (dyn.d_tag) 1147 1106 { 1148 case DT_PLTGOT: name = ".plt"; size = false; break;1149 case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;1150 case DT_JMPREL: name = ".rela.plt"; size = false; break;1151 default: name = NULL; size = false; break;1107 case DT_PLTGOT: name = ".plt"; size = FALSE; break; 1108 case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break; 1109 case DT_JMPREL: name = ".rela.plt"; size = FALSE; break; 1110 default: name = NULL; size = FALSE; break; 1152 1111 } 1153 1112 … … 1182 1141 { 1183 1142 unsigned char *contents = sgot->contents; 1184 bfd_put_32 (output_bfd, 0x4e800021 /* blrl */, contents);1143 bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents); 1185 1144 1186 1145 if (sdyn == NULL) … … 1214 1173 { 1215 1174 int indx, dindx; 1175 Elf32_External_Sym *esym; 1216 1176 1217 1177 sym.st_value = s->vma; … … 1229 1189 sym.st_shndx = indx; 1230 1190 1231 bfd_elf32_swap_symbol_out (output_bfd, &sym, 1232 (PTR) (((Elf32_External_Sym *) 1233 sdynsym->contents) 1234 + dindx)); 1191 esym = (Elf32_External_Sym *) sdynsym->contents + dindx; 1192 bfd_elf32_swap_symbol_out (output_bfd, &sym, (PTR) esym, (PTR) 0); 1235 1193 } 1236 1194 } … … 1242 1200 } 1243 1201 1244 return true;1202 return TRUE; 1245 1203 } 1246 1204 … … 1275 1233 accordingly. */ 1276 1234 1277 static b oolean1235 static bfd_boolean 1278 1236 i370_elf_relocate_section (output_bfd, info, input_bfd, input_section, 1279 contents, relocs, local_syms, local_sections)1237 contents, relocs, local_syms, local_sections) 1280 1238 bfd *output_bfd; 1281 1239 struct bfd_link_info *info; … … 1287 1245 asection **local_sections; 1288 1246 { 1289 Elf_Internal_Shdr *symtab_hdr 1247 Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; 1290 1248 struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); 1291 bfd *dynobj 1292 Elf_Internal_Rela *rel 1293 Elf_Internal_Rela *relend 1294 asection *sreloc 1249 bfd *dynobj = elf_hash_table (info)->dynobj; 1250 Elf_Internal_Rela *rel = relocs; 1251 Elf_Internal_Rela *relend = relocs + input_section->reloc_count; 1252 asection *sreloc = NULL; 1295 1253 bfd_vma *local_got_offsets; 1296 boolean ret = true; 1254 bfd_boolean ret = TRUE; 1255 1256 if (info->relocateable) 1257 return TRUE; 1297 1258 1298 1259 #ifdef DEBUG 1299 1260 fprintf (stderr, "i370_elf_relocate_section called for %s section %s, %ld relocations%s\n", 1300 bfd_ get_filename (input_bfd),1261 bfd_archive_filename (input_bfd), 1301 1262 bfd_section_name(input_bfd, input_section), 1302 (long) input_section->reloc_count,1263 (long) input_section->reloc_count, 1303 1264 (info->relocateable) ? " (relocatable)" : ""); 1304 1265 #endif … … 1328 1289 { 1329 1290 (*_bfd_error_handler) ("%s: unknown relocation type %d", 1330 bfd_ get_filename (input_bfd),1331 (int) r_type);1291 bfd_archive_filename (input_bfd), 1292 (int) r_type); 1332 1293 1333 1294 bfd_set_error (bfd_error_bad_value); 1334 ret = false;1295 ret = FALSE; 1335 1296 continue; 1336 1297 } … … 1339 1300 r_symndx = ELF32_R_SYM (rel->r_info); 1340 1301 1341 if (info->relocateable)1342 {1343 /* This is a relocateable link. We don't have to change1344 anything, unless the reloc is against a section symbol,1345 in which case we have to adjust according to where the1346 section symbol winds up in the output section. */1347 if (r_symndx < symtab_hdr->sh_info)1348 {1349 sym = local_syms + r_symndx;1350 if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)1351 {1352 sec = local_sections[r_symndx];1353 addend = rel->r_addend += sec->output_offset + sym->st_value;1354 }1355 }1356 1357 #ifdef DEBUG1358 fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",1359 howto->name,1360 (int)r_type,1361 r_symndx,1362 (long)offset,1363 (long)addend);1364 #endif1365 continue;1366 }1367 1368 /* This is a final link. */1369 1302 if (r_symndx < symtab_hdr->sh_info) 1370 1303 { … … 1373 1306 sym_name = "<local symbol>"; 1374 1307 1375 relocation = (sec->output_section->vma 1376 + sec->output_offset 1377 + sym->st_value); 1308 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); 1309 addend = rel->r_addend; 1378 1310 } 1379 1311 else … … 1420 1352 input_section, 1421 1353 rel->r_offset, 1422 true);1423 ret = false;1354 TRUE); 1355 ret = FALSE; 1424 1356 continue; 1425 1357 } 1426 1358 } 1427 1359 1428 switch ((int) r_type)1360 switch ((int) r_type) 1429 1361 { 1430 1362 default: 1431 (*_bfd_error_handler) ("%s: unknown relocation type %d for symbol %s", 1432 bfd_get_filename (input_bfd), 1433 (int)r_type, sym_name); 1363 (*_bfd_error_handler) 1364 ("%s: unknown relocation type %d for symbol %s", 1365 bfd_archive_filename (input_bfd), 1366 (int) r_type, sym_name); 1434 1367 1435 1368 bfd_set_error (bfd_error_bad_value); 1436 ret = false; 1369 ret = FALSE; 1370 continue; 1371 1372 case (int)R_I370_NONE: 1437 1373 continue; 1438 1374 … … 1449 1385 /* Relocations that always need to be propagated if this is a shared 1450 1386 object. */ 1451 case (int)R_I370_NONE:1452 1387 case (int)R_I370_ADDR31: 1453 1388 case (int)R_I370_ADDR16: 1454 if (info->shared) 1389 if (info->shared 1390 && r_symndx != 0) 1455 1391 { 1456 1392 Elf_Internal_Rela outrel; 1457 boolean skip; 1393 bfd_byte *loc; 1394 int skip; 1458 1395 1459 1396 #ifdef DEBUG … … 1476 1413 elf_section_data (input_section)->rel_hdr.sh_name)); 1477 1414 if (name == NULL) 1478 return false;1415 return FALSE; 1479 1416 1480 1417 BFD_ASSERT (strncmp (name, ".rela", 5) == 0 … … 1487 1424 } 1488 1425 1489 skip = false; 1490 1491 if (elf_section_data (input_section)->stab_info == NULL) 1492 outrel.r_offset = rel->r_offset; 1493 else 1494 { 1495 bfd_vma off; 1496 1497 off = (_bfd_stab_section_offset 1498 (output_bfd, &elf_hash_table (info)->stab_info, 1499 input_section, 1500 &elf_section_data (input_section)->stab_info, 1501 rel->r_offset)); 1502 if (off == (bfd_vma) -1) 1503 skip = true; 1504 outrel.r_offset = off; 1505 } 1506 1426 skip = 0; 1427 1428 outrel.r_offset = 1429 _bfd_elf_section_offset (output_bfd, info, input_section, 1430 rel->r_offset); 1431 if (outrel.r_offset == (bfd_vma) -1 1432 || outrel.r_offset == (bfd_vma) -2) 1433 skip = (int) outrel.r_offset; 1507 1434 outrel.r_offset += (input_section->output_section->vma 1508 1435 + input_section->output_offset); … … 1546 1473 { 1547 1474 bfd_set_error (bfd_error_bad_value); 1548 return false;1475 return FALSE; 1549 1476 } 1550 1477 else … … 1570 1497 } 1571 1498 1572 bfd_elf32_swap_reloca_out (output_bfd, &outrel, 1573 (((Elf32_External_Rela *) 1574 sreloc->contents) 1575 + sreloc->reloc_count)); 1576 ++sreloc->reloc_count; 1499 loc = sreloc->contents; 1500 loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela); 1501 bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); 1577 1502 1578 1503 /* This reloc will be computed at runtime, so there's no 1579 1504 need to do anything now, unless this is a RELATIVE 1580 1505 reloc in an unallocated section. */ 1581 if (skip 1506 if (skip == -1 1582 1507 || (input_section->flags & SEC_ALLOC) != 0 1583 1508 || ELF32_R_TYPE (outrel.r_info) != R_I370_RELATIVE) … … 1588 1513 case (int)R_I370_COPY: 1589 1514 case (int)R_I370_RELATIVE: 1590 (*_bfd_error_handler) ("%s: Relocation %s is not yet supported for symbol %s.", 1591 bfd_get_filename (input_bfd), 1592 i370_elf_howto_table[ (int)r_type ]->name, 1593 sym_name); 1515 (*_bfd_error_handler) 1516 ("%s: Relocation %s is not yet supported for symbol %s.", 1517 bfd_archive_filename (input_bfd), 1518 i370_elf_howto_table[(int) r_type]->name, 1519 sym_name); 1594 1520 1595 1521 bfd_set_error (bfd_error_invalid_operation); 1596 ret = false;1522 ret = FALSE; 1597 1523 continue; 1598 1524 } … … 1618 1544 if (r != bfd_reloc_ok) 1619 1545 { 1620 ret = false;1546 ret = FALSE; 1621 1547 switch (r) 1622 1548 { … … 1687 1613 #define elf_backend_plt_not_loaded 1 1688 1614 #define elf_backend_got_symbol_offset 4 1615 #define elf_backend_rela_normal 1 1689 1616 1690 1617 #define bfd_elf32_bfd_reloc_type_lookup i370_elf_reloc_type_lookup 1691 1618 #define bfd_elf32_bfd_set_private_flags i370_elf_set_private_flags 1692 #define bfd_elf32_bfd_copy_private_bfd_data i370_elf_copy_private_bfd_data1693 1619 #define bfd_elf32_bfd_merge_private_bfd_data i370_elf_merge_private_bfd_data 1694 1620 #define elf_backend_relocate_section i370_elf_relocate_section … … 1714 1640 #define elf_backend_post_process_headers i370_elf_post_process_headers 1715 1641 1716 int i370_noop() 1642 static int i370_noop 1643 PARAMS ((void)); 1644 1645 static int i370_noop () 1717 1646 { 1718 1647 return 1; … … 1722 1651 1723 1652 #define elf_backend_add_symbol_hook \ 1724 (b oolean (*) PARAMS ((bfd *, struct bfd_link_info *,\1725 const Elf_Internal_Sym *, const char **, flagword*, \1726 asection **, bfd_vma *)))i370_noop1653 (bfd_boolean (*) \ 1654 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, \ 1655 const char **, flagword *, asection **, bfd_vma *))) i370_noop 1727 1656 #define elf_backend_finish_dynamic_symbol \ 1728 (b oolean (*) PARAMS ((bfd *, struct bfd_link_info *,\1729 1730 Elf_Internal_Sym *)))i370_noop1657 (bfd_boolean (*) \ 1658 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, \ 1659 Elf_Internal_Sym *))) i370_noop 1731 1660 #define elf_backend_additional_program_headers \ 1732 (int (*) PARAMS ((bfd *))) 1661 (int (*) PARAMS ((bfd *))) i370_noop 1733 1662 #define elf_backend_modify_segment_map \ 1734 (b oolean (*) PARAMS ((bfd *)))i370_noop1663 (bfd_boolean (*) PARAMS ((bfd *))) i370_noop 1735 1664 1736 1665 #include "elf32-target.h" -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.