Changeset 609 for branches/GNU/src/binutils/bfd/elf-m10300.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/elf-m10300.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Matsushita 10300 specific support for 32-bit ELF 2 Copyright 1996, 1997, 1998, 1999, 2000, 2001 2 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 … … 24 24 #include "elf-bfd.h" 25 25 #include "elf/mn10300.h" 26 27 static bfd_reloc_status_type mn10300_elf_final_link_relocate 28 PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *, bfd_byte *, 29 bfd_vma, bfd_vma, bfd_vma, struct bfd_link_info *, 30 asection *, int)); 31 static bfd_boolean mn10300_elf_relocate_section 32 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 33 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); 34 static bfd_boolean mn10300_elf_relax_section 35 PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *)); 36 static bfd_byte * mn10300_elf_get_relocated_section_contents 37 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, 38 bfd_byte *, bfd_boolean, asymbol **)); 39 static unsigned long elf_mn10300_mach 40 PARAMS ((flagword)); 41 void _bfd_mn10300_elf_final_write_processing 42 PARAMS ((bfd *, bfd_boolean)); 43 bfd_boolean _bfd_mn10300_elf_object_p 44 PARAMS ((bfd *)); 45 bfd_boolean _bfd_mn10300_elf_merge_private_bfd_data 46 PARAMS ((bfd *,bfd *)); 26 47 27 48 struct elf32_mn10300_link_hash_entry { … … 87 108 (elf_link_hash_traverse \ 88 109 (&(table)->root, \ 89 (b oolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func),\110 (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \ 90 111 (info))) 91 112 … … 94 115 static struct bfd_link_hash_table *elf32_mn10300_link_hash_table_create 95 116 PARAMS ((bfd *)); 117 static void elf32_mn10300_link_hash_table_free 118 PARAMS ((struct bfd_link_hash_table *)); 96 119 97 120 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup 98 121 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); 99 122 static void mn10300_info_to_howto 100 PARAMS ((bfd *, arelent *, Elf 32_Internal_Rela *));101 static b oolean mn10300_elf_check_relocs123 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); 124 static bfd_boolean mn10300_elf_check_relocs 102 125 PARAMS ((bfd *, struct bfd_link_info *, asection *, 103 126 const Elf_Internal_Rela *)); 104 127 static asection *mn10300_elf_gc_mark_hook 105 PARAMS (( bfd*, struct bfd_link_info *info, Elf_Internal_Rela *,128 PARAMS ((asection *, struct bfd_link_info *info, Elf_Internal_Rela *, 106 129 struct elf_link_hash_entry *, Elf_Internal_Sym *)); 107 static b oolean mn10300_elf_relax_delete_bytes130 static bfd_boolean mn10300_elf_relax_delete_bytes 108 131 PARAMS ((bfd *, asection *, bfd_vma, int)); 109 static b oolean mn10300_elf_symbol_address_p110 PARAMS ((bfd *, asection *, Elf 32_External_Sym *, bfd_vma));111 static b oolean elf32_mn10300_finish_hash_table_entry132 static bfd_boolean mn10300_elf_symbol_address_p 133 PARAMS ((bfd *, asection *, Elf_Internal_Sym *, bfd_vma)); 134 static bfd_boolean elf32_mn10300_finish_hash_table_entry 112 135 PARAMS ((struct bfd_hash_entry *, PTR)); 113 136 static void compute_function_info 114 137 PARAMS ((bfd *, struct elf32_mn10300_link_hash_entry *, 115 138 bfd_vma, unsigned char *)); 116 117 /* We have to use RELA instructions since md_apply_fix3 in the assembler118 does absolutely nothing. */119 #define USE_RELA120 139 121 140 static reloc_howto_type elf_mn10300_howto_table[] = { … … 125 144 2, 126 145 16, 127 false,146 FALSE, 128 147 0, 129 148 complain_overflow_bitfield, 130 149 bfd_elf_generic_reloc, 131 150 "R_MN10300_NONE", 132 false,151 FALSE, 133 152 0, 134 153 0, 135 false),154 FALSE), 136 155 /* Standard 32 bit reloc. */ 137 156 HOWTO (R_MN10300_32, … … 139 158 2, 140 159 32, 141 false,160 FALSE, 142 161 0, 143 162 complain_overflow_bitfield, 144 163 bfd_elf_generic_reloc, 145 164 "R_MN10300_32", 146 false,165 FALSE, 147 166 0xffffffff, 148 167 0xffffffff, 149 false),168 FALSE), 150 169 /* Standard 16 bit reloc. */ 151 170 HOWTO (R_MN10300_16, … … 153 172 1, 154 173 16, 155 false,174 FALSE, 156 175 0, 157 176 complain_overflow_bitfield, 158 177 bfd_elf_generic_reloc, 159 178 "R_MN10300_16", 160 false,179 FALSE, 161 180 0xffff, 162 181 0xffff, 163 false),182 FALSE), 164 183 /* Standard 8 bit reloc. */ 165 184 HOWTO (R_MN10300_8, … … 167 186 0, 168 187 8, 169 false,188 FALSE, 170 189 0, 171 190 complain_overflow_bitfield, 172 191 bfd_elf_generic_reloc, 173 192 "R_MN10300_8", 174 false,193 FALSE, 175 194 0xff, 176 195 0xff, 177 false),196 FALSE), 178 197 /* Standard 32bit pc-relative reloc. */ 179 198 HOWTO (R_MN10300_PCREL32, … … 181 200 2, 182 201 32, 183 true,202 TRUE, 184 203 0, 185 204 complain_overflow_bitfield, 186 205 bfd_elf_generic_reloc, 187 206 "R_MN10300_PCREL32", 188 false,207 FALSE, 189 208 0xffffffff, 190 209 0xffffffff, 191 true),210 TRUE), 192 211 /* Standard 16bit pc-relative reloc. */ 193 212 HOWTO (R_MN10300_PCREL16, … … 195 214 1, 196 215 16, 197 true,216 TRUE, 198 217 0, 199 218 complain_overflow_bitfield, 200 219 bfd_elf_generic_reloc, 201 220 "R_MN10300_PCREL16", 202 false,221 FALSE, 203 222 0xffff, 204 223 0xffff, 205 true),224 TRUE), 206 225 /* Standard 8 pc-relative reloc. */ 207 226 HOWTO (R_MN10300_PCREL8, … … 209 228 0, 210 229 8, 211 true,230 TRUE, 212 231 0, 213 232 complain_overflow_bitfield, 214 233 bfd_elf_generic_reloc, 215 234 "R_MN10300_PCREL8", 216 false,235 FALSE, 217 236 0xff, 218 237 0xff, 219 true),238 TRUE), 220 239 221 240 /* GNU extension to record C++ vtable hierarchy */ … … 224 243 0, /* size (0 = byte, 1 = short, 2 = long) */ 225 244 0, /* bitsize */ 226 false, /* pc_relative */245 FALSE, /* pc_relative */ 227 246 0, /* bitpos */ 228 247 complain_overflow_dont, /* complain_on_overflow */ 229 248 NULL, /* special_function */ 230 249 "R_MN10300_GNU_VTINHERIT", /* name */ 231 false, /* partial_inplace */250 FALSE, /* partial_inplace */ 232 251 0, /* src_mask */ 233 252 0, /* dst_mask */ 234 false), /* pcrel_offset */253 FALSE), /* pcrel_offset */ 235 254 236 255 /* GNU extension to record C++ vtable member usage */ … … 239 258 0, /* size (0 = byte, 1 = short, 2 = long) */ 240 259 0, /* bitsize */ 241 false, /* pc_relative */260 FALSE, /* pc_relative */ 242 261 0, /* bitpos */ 243 262 complain_overflow_dont, /* complain_on_overflow */ 244 263 NULL, /* special_function */ 245 264 "R_MN10300_GNU_VTENTRY", /* name */ 246 false, /* partial_inplace */265 FALSE, /* partial_inplace */ 247 266 0, /* src_mask */ 248 267 0, /* dst_mask */ 249 false), /* pcrel_offset */268 FALSE), /* pcrel_offset */ 250 269 251 270 /* Standard 24 bit reloc. */ … … 254 273 2, 255 274 24, 256 false,275 FALSE, 257 276 0, 258 277 complain_overflow_bitfield, 259 278 bfd_elf_generic_reloc, 260 279 "R_MN10300_24", 261 false,280 FALSE, 262 281 0xffffff, 263 282 0xffffff, 264 false),283 FALSE), 265 284 }; 266 285 … … 307 326 bfd *abfd ATTRIBUTE_UNUSED; 308 327 arelent *cache_ptr; 309 Elf 32_Internal_Rela *dst;328 Elf_Internal_Rela *dst; 310 329 { 311 330 unsigned int r_type; … … 320 339 virtual table relocs for gc. */ 321 340 322 static b oolean341 static bfd_boolean 323 342 mn10300_elf_check_relocs (abfd, info, sec, relocs) 324 343 bfd *abfd; … … 333 352 334 353 if (info->relocateable) 335 return true;354 return TRUE; 336 355 337 356 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; … … 359 378 case R_MN10300_GNU_VTINHERIT: 360 379 if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) 361 return false;380 return FALSE; 362 381 break; 363 382 … … 366 385 case R_MN10300_GNU_VTENTRY: 367 386 if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) 368 return false;387 return FALSE; 369 388 break; 370 389 } 371 390 } 372 391 373 return true;392 return TRUE; 374 393 } 375 394 … … 378 397 379 398 static asection * 380 mn10300_elf_gc_mark_hook ( abfd, info, rel, h, sym)381 bfd *abfd;399 mn10300_elf_gc_mark_hook (sec, info, rel, h, sym) 400 asection *sec; 382 401 struct bfd_link_info *info ATTRIBUTE_UNUSED; 383 402 Elf_Internal_Rela *rel; … … 409 428 } 410 429 else 411 { 412 if (!(elf_bad_symtab (abfd) 413 && ELF_ST_BIND (sym->st_info) != STB_LOCAL) 414 && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE) 415 && sym->st_shndx != SHN_COMMON)) 416 { 417 return bfd_section_from_elf_index (abfd, sym->st_shndx); 418 } 419 } 430 return bfd_section_from_elf_index (sec->owner, sym->st_shndx); 420 431 421 432 return NULL; … … 525 536 526 537 /* Relocate an MN10300 ELF section. */ 527 static b oolean538 static bfd_boolean 528 539 mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section, 529 540 contents, relocs, local_syms, local_sections) … … 541 552 Elf_Internal_Rela *rel, *relend; 542 553 554 if (info->relocateable) 555 return TRUE; 556 543 557 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; 544 558 sym_hashes = (struct elf32_mn10300_link_hash_entry **) … … 567 581 continue; 568 582 569 if (info->relocateable)570 {571 /* This is a relocateable link. We don't have to change572 anything, unless the reloc is against a section symbol,573 in which case we have to adjust according to where the574 section symbol winds up in the output section. */575 if (r_symndx < symtab_hdr->sh_info)576 {577 sym = local_syms + r_symndx;578 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)579 {580 sec = local_sections[r_symndx];581 rel->r_addend += sec->output_offset + sym->st_value;582 }583 }584 585 continue;586 }587 588 /* This is a final link. */589 583 h = NULL; 590 584 sym = NULL; … … 594 588 sym = local_syms + r_symndx; 595 589 sec = local_sections[r_symndx]; 596 relocation = (sec->output_section->vma 597 + sec->output_offset 598 + sym->st_value); 590 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); 599 591 } 600 592 else 601 593 { 602 594 h = sym_hashes[r_symndx - symtab_hdr->sh_info]; 603 while (h->root. type == bfd_link_hash_indirect604 || h->root. type == bfd_link_hash_warning)595 while (h->root.root.type == bfd_link_hash_indirect 596 || h->root.root.type == bfd_link_hash_warning) 605 597 h = (struct elf32_mn10300_link_hash_entry *) h->root.root.u.i.link; 606 598 if (h->root.root.type == bfd_link_hash_defined … … 618 610 if (! ((*info->callbacks->undefined_symbol) 619 611 (info, h->root.root.root.string, input_bfd, 620 input_section, rel->r_offset, true)))621 return false;612 input_section, rel->r_offset, TRUE))) 613 return FALSE; 622 614 relocation = 0; 623 615 } … … 651 643 (info, name, howto->name, (bfd_vma) 0, 652 644 input_bfd, input_section, rel->r_offset))) 653 return false;645 return FALSE; 654 646 break; 655 647 … … 657 649 if (! ((*info->callbacks->undefined_symbol) 658 650 (info, name, input_bfd, input_section, 659 rel->r_offset, true)))660 return false;651 rel->r_offset, TRUE))) 652 return FALSE; 661 653 break; 662 654 … … 681 673 (info, msg, name, input_bfd, input_section, 682 674 rel->r_offset))) 683 return false;675 return FALSE; 684 676 break; 685 677 } … … 687 679 } 688 680 689 return true;681 return TRUE; 690 682 } 691 683 692 684 /* Finish initializing one hash table entry. */ 693 static b oolean685 static bfd_boolean 694 686 elf32_mn10300_finish_hash_table_entry (gen_entry, in_args) 695 687 struct bfd_hash_entry *gen_entry; … … 701 693 entry = (struct elf32_mn10300_link_hash_entry *) gen_entry; 702 694 695 if (entry->root.root.type == bfd_link_hash_warning) 696 entry = (struct elf32_mn10300_link_hash_entry *) entry->root.root.u.i.link; 697 703 698 /* If we already know we want to convert "call" to "calls" for calls 704 699 to this symbol, then return now. */ 705 700 if (entry->flags == MN10300_CONVERT_CALL_TO_CALLS) 706 return true;701 return TRUE; 707 702 708 703 /* If there are no named calls to this symbol, or there's nothing we … … 716 711 instructions for calls to this symbol. */ 717 712 entry->flags |= MN10300_CONVERT_CALL_TO_CALLS; 718 return true;713 return TRUE; 719 714 } 720 715 … … 739 734 740 735 /* This routine never fails. */ 741 return true;736 return TRUE; 742 737 } 743 738 … … 781 776 and somewhat more difficult to support. */ 782 777 783 static b oolean778 static bfd_boolean 784 779 mn10300_elf_relax_section (abfd, sec, link_info, again) 785 780 bfd *abfd; 786 781 asection *sec; 787 782 struct bfd_link_info *link_info; 788 b oolean *again;783 bfd_boolean *again; 789 784 { 790 785 Elf_Internal_Shdr *symtab_hdr; 791 786 Elf_Internal_Rela *internal_relocs = NULL; 792 Elf_Internal_Rela *free_relocs = NULL;793 787 Elf_Internal_Rela *irel, *irelend; 794 788 bfd_byte *contents = NULL; 795 bfd_byte *free_contents = NULL; 796 Elf32_External_Sym *extsyms = NULL; 797 Elf32_External_Sym *free_extsyms = NULL; 789 Elf_Internal_Sym *isymbuf = NULL; 798 790 struct elf32_mn10300_link_hash_table *hash_table; 791 asection *section = sec; 799 792 800 793 /* Assume nothing changes. */ 801 *again = false;794 *again = FALSE; 802 795 803 796 /* We need a pointer to the mn10300 specific hash table. */ … … 814 807 input_bfd = input_bfd->link_next) 815 808 { 816 asection *section;817 818 809 /* We're going to need all the symbols for each bfd. */ 819 810 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; 820 821 /* Get cached copy if it exists. */ 822 if (symtab_hdr->contents != NULL) 823 extsyms = (Elf32_External_Sym *) symtab_hdr->contents; 824 else 811 if (symtab_hdr->sh_info != 0) 825 812 { 826 /* Go get them off disk. */ 827 extsyms = ((Elf32_External_Sym *) 828 bfd_malloc (symtab_hdr->sh_size)); 829 if (extsyms == NULL) 830 goto error_return; 831 free_extsyms = extsyms; 832 if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 833 || (bfd_read (extsyms, 1, symtab_hdr->sh_size, input_bfd) 834 != symtab_hdr->sh_size)) 813 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; 814 if (isymbuf == NULL) 815 isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, 816 symtab_hdr->sh_info, 0, 817 NULL, NULL, NULL); 818 if (isymbuf == NULL) 835 819 goto error_return; 836 820 } … … 847 831 char *new_name; 848 832 833 /* If there's nothing to do in this section, skip it. */ 834 if (! (((section->flags & SEC_RELOC) != 0 835 && section->reloc_count != 0) 836 || (section->flags & SEC_CODE) != 0)) 837 continue; 838 849 839 /* Get cached copy of section contents if it exists. */ 850 840 if (elf_section_data (section)->this_hdr.contents != NULL) … … 856 846 if (contents == NULL) 857 847 goto error_return; 858 free_contents = contents;859 848 860 849 if (!bfd_get_section_contents (input_bfd, section, … … 864 853 } 865 854 else 866 { 867 contents = NULL; 868 free_contents = NULL; 869 } 855 contents = NULL; 870 856 871 857 /* If there aren't any relocs, then there's nothing to do. */ … … 881 867 if (internal_relocs == NULL) 882 868 goto error_return; 883 if (! link_info->keep_memory)884 free_relocs = internal_relocs;885 869 886 870 /* Now examine each relocation. */ … … 908 892 { 909 893 /* A local symbol. */ 910 Elf_Internal_Sym isym;911 912 bfd_ elf32_swap_symbol_in (input_bfd,913 extsyms + r_index, &isym); 914 915 if (isym .st_shndx == SHN_UNDEF)894 Elf_Internal_Sym *isym; 895 struct elf_link_hash_table *elftab; 896 bfd_size_type amt; 897 898 isym = isymbuf + r_index; 899 if (isym->st_shndx == SHN_UNDEF) 916 900 sym_sec = bfd_und_section_ptr; 917 else if (isym.st_shndx > 0 918 && isym.st_shndx < SHN_LORESERVE) 901 else if (isym->st_shndx == SHN_ABS) 902 sym_sec = bfd_abs_section_ptr; 903 else if (isym->st_shndx == SHN_COMMON) 904 sym_sec = bfd_com_section_ptr; 905 else 919 906 sym_sec 920 907 = bfd_section_from_elf_index (input_bfd, 921 isym.st_shndx); 922 else if (isym.st_shndx == SHN_ABS) 923 sym_sec = bfd_abs_section_ptr; 924 else if (isym.st_shndx == SHN_COMMON) 925 sym_sec = bfd_com_section_ptr; 926 927 sym_name = bfd_elf_string_from_elf_section (input_bfd, 928 symtab_hdr->sh_link, 929 isym.st_name); 908 isym->st_shndx); 909 910 sym_name 911 = bfd_elf_string_from_elf_section (input_bfd, 912 (symtab_hdr 913 ->sh_link), 914 isym->st_name); 930 915 931 916 /* If it isn't a function, then we don't care 932 917 about it. */ 933 if (r_index < symtab_hdr->sh_info 934 && ELF_ST_TYPE (isym.st_info) != STT_FUNC) 918 if (ELF_ST_TYPE (isym->st_info) != STT_FUNC) 935 919 continue; 936 920 937 921 /* Tack on an ID so we can uniquely identify this 938 922 local symbol in the global hash table. */ 939 new_name = bfd_malloc (strlen (sym_name) + 10); 923 amt = strlen (sym_name) + 10; 924 new_name = bfd_malloc (amt); 940 925 if (new_name == 0) 941 926 goto error_return; … … 945 930 sym_name = new_name; 946 931 947 hash = (struct elf32_mn10300_link_hash_entry *)948 elf_link_hash_lookup (&hash_table->static_hash_table->root,949 sym_name, true,950 true, false);932 elftab = &hash_table->static_hash_table->root; 933 hash = ((struct elf32_mn10300_link_hash_entry *) 934 elf_link_hash_lookup (elftab, sym_name, 935 TRUE, TRUE, FALSE)); 951 936 free (new_name); 952 937 } … … 966 951 hash->flags |= MN10300_CONVERT_CALL_TO_CALLS; 967 952 968 /* If this is a jump/call, then bump the direct_calls 969 counter. Else force "call" to "calls" conversions. */ 953 /* If this is a jump/call, then bump the 954 direct_calls counter. Else force "call" to 955 "calls" conversions. */ 970 956 if (r_type == R_MN10300_PCREL32 971 957 || r_type == R_MN10300_PCREL16) … … 981 967 if ((section->flags & SEC_CODE) != 0) 982 968 { 983 984 Elf32_External_Sym *esym, *esymend; 985 int idx, shndx; 986 987 shndx = _bfd_elf_section_from_bfd_section (input_bfd, 988 section); 969 Elf_Internal_Sym *isym, *isymend; 970 unsigned int sec_shndx; 971 struct elf_link_hash_entry **hashes; 972 struct elf_link_hash_entry **end_hashes; 973 unsigned int symcount; 974 975 sec_shndx = _bfd_elf_section_from_bfd_section (input_bfd, 976 section); 989 977 990 978 /* Look at each function defined in this section and 991 979 update info for that function. */ 992 esym = extsyms; 993 esymend = esym + symtab_hdr->sh_info; 994 for (; esym < esymend; esym++) 980 isymend = isymbuf + symtab_hdr->sh_info; 981 for (isym = isymbuf; isym < isymend; isym++) 995 982 { 996 Elf_Internal_Sym isym; 997 998 bfd_elf32_swap_symbol_in (input_bfd, esym, &isym); 999 if (isym.st_shndx == shndx 1000 && ELF_ST_TYPE (isym.st_info) == STT_FUNC) 983 if (isym->st_shndx == sec_shndx 984 && ELF_ST_TYPE (isym->st_info) == STT_FUNC) 1001 985 { 1002 if (isym.st_shndx == SHN_UNDEF) 986 struct elf_link_hash_table *elftab; 987 bfd_size_type amt; 988 989 if (isym->st_shndx == SHN_UNDEF) 1003 990 sym_sec = bfd_und_section_ptr; 1004 else if (isym.st_shndx > 0 1005 && isym.st_shndx < SHN_LORESERVE) 991 else if (isym->st_shndx == SHN_ABS) 992 sym_sec = bfd_abs_section_ptr; 993 else if (isym->st_shndx == SHN_COMMON) 994 sym_sec = bfd_com_section_ptr; 995 else 1006 996 sym_sec 1007 997 = bfd_section_from_elf_index (input_bfd, 1008 isym.st_shndx); 1009 else if (isym.st_shndx == SHN_ABS) 1010 sym_sec = bfd_abs_section_ptr; 1011 else if (isym.st_shndx == SHN_COMMON) 1012 sym_sec = bfd_com_section_ptr; 1013 1014 sym_name = bfd_elf_string_from_elf_section (input_bfd, 1015 symtab_hdr->sh_link, 1016 isym.st_name); 998 isym->st_shndx); 999 1000 sym_name = (bfd_elf_string_from_elf_section 1001 (input_bfd, symtab_hdr->sh_link, 1002 isym->st_name)); 1017 1003 1018 1004 /* Tack on an ID so we can uniquely identify this 1019 1005 local symbol in the global hash table. */ 1020 new_name = bfd_malloc (strlen (sym_name) + 10); 1006 amt = strlen (sym_name) + 10; 1007 new_name = bfd_malloc (amt); 1021 1008 if (new_name == 0) 1022 1009 goto error_return; … … 1026 1013 sym_name = new_name; 1027 1014 1028 hash = (struct elf32_mn10300_link_hash_entry *)1029 elf_link_hash_lookup (&hash_table->static_hash_table->root,1030 sym_name, true,1031 true, false);1015 elftab = &hash_table->static_hash_table->root; 1016 hash = ((struct elf32_mn10300_link_hash_entry *) 1017 elf_link_hash_lookup (elftab, sym_name, 1018 TRUE, TRUE, FALSE)); 1032 1019 free (new_name); 1033 1020 compute_function_info (input_bfd, hash, 1034 isym .st_value, contents);1021 isym->st_value, contents); 1035 1022 } 1036 1023 } 1037 1024 1038 esym = extsyms + symtab_hdr->sh_info; 1039 esymend = extsyms + (symtab_hdr->sh_size 1040 / sizeof (Elf32_External_Sym)); 1041 for (idx = 0; esym < esymend; esym++, idx++) 1025 symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym) 1026 - symtab_hdr->sh_info); 1027 hashes = elf_sym_hashes (abfd); 1028 end_hashes = hashes + symcount; 1029 for (; hashes < end_hashes; hashes++) 1042 1030 { 1043 Elf_Internal_Sym isym; 1044 1045 bfd_elf32_swap_symbol_in (input_bfd, esym, &isym); 1046 hash = (struct elf32_mn10300_link_hash_entry *) 1047 elf_sym_hashes (input_bfd)[idx]; 1048 if (isym.st_shndx == shndx 1049 && ELF_ST_TYPE (isym.st_info) == STT_FUNC 1050 && (hash)->root.root.u.def.section == section 1051 && ((hash)->root.root.type == bfd_link_hash_defined 1052 || (hash)->root.root.type == bfd_link_hash_defweak)) 1031 hash = (struct elf32_mn10300_link_hash_entry *) *hashes; 1032 if ((hash->root.root.type == bfd_link_hash_defined 1033 || hash->root.root.type == bfd_link_hash_defweak) 1034 && hash->root.root.u.def.section == section 1035 && ELF_ST_TYPE (isym->st_info) == STT_FUNC) 1053 1036 compute_function_info (input_bfd, hash, 1054 1037 (hash)->root.root.u.def.value, … … 1058 1041 1059 1042 /* Cache or free any memory we allocated for the relocs. */ 1060 if (free_relocs != NULL) 1061 { 1062 free (free_relocs); 1063 free_relocs = NULL; 1064 } 1043 if (internal_relocs != NULL 1044 && elf_section_data (section)->relocs != internal_relocs) 1045 free (internal_relocs); 1046 internal_relocs = NULL; 1065 1047 1066 1048 /* Cache or free any memory we allocated for the contents. */ 1067 if (free_contents != NULL) 1049 if (contents != NULL 1050 && elf_section_data (section)->this_hdr.contents != contents) 1068 1051 { 1069 1052 if (! link_info->keep_memory) 1070 free ( free_contents);1053 free (contents); 1071 1054 else 1072 1055 { … … 1074 1057 elf_section_data (section)->this_hdr.contents = contents; 1075 1058 } 1076 free_contents = NULL;1077 1059 } 1060 contents = NULL; 1078 1061 } 1079 1062 1080 1063 /* Cache or free any memory we allocated for the symbols. */ 1081 if (free_extsyms != NULL) 1064 if (isymbuf != NULL 1065 && symtab_hdr->contents != (unsigned char *) isymbuf) 1082 1066 { 1083 1067 if (! link_info->keep_memory) 1084 free ( free_extsyms);1068 free (isymbuf); 1085 1069 else 1086 1070 { 1087 1071 /* Cache the symbols for elf_link_input_bfd. */ 1088 symtab_hdr->contents = extsyms;1072 symtab_hdr->contents = (unsigned char *) isymbuf; 1089 1073 } 1090 free_extsyms = NULL;1091 1074 } 1075 isymbuf = NULL; 1092 1076 } 1093 1077 … … 1112 1096 input_bfd = input_bfd->link_next) 1113 1097 { 1114 asection *section; 1115 1116 /* We're going to need all the symbols for each bfd. */ 1098 /* We're going to need all the local symbols for each bfd. */ 1117 1099 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; 1118 1119 /* Get cached copy if it exists. */ 1120 if (symtab_hdr->contents != NULL) 1121 extsyms = (Elf32_External_Sym *) symtab_hdr->contents; 1122 else 1100 if (symtab_hdr->sh_info != 0) 1123 1101 { 1124 /* Go get them off disk. */ 1125 extsyms = ((Elf32_External_Sym *) 1126 bfd_malloc (symtab_hdr->sh_size)); 1127 if (extsyms == NULL) 1128 goto error_return; 1129 free_extsyms = extsyms; 1130 if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 1131 || (bfd_read (extsyms, 1, symtab_hdr->sh_size, input_bfd) 1132 != symtab_hdr->sh_size)) 1102 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; 1103 if (isymbuf == NULL) 1104 isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, 1105 symtab_hdr->sh_info, 0, 1106 NULL, NULL, NULL); 1107 if (isymbuf == NULL) 1133 1108 goto error_return; 1134 1109 } … … 1139 1114 section = section->next) 1140 1115 { 1141 int shndx; 1142 Elf32_External_Sym *esym, *esymend; 1143 int idx; 1116 unsigned int sec_shndx; 1117 Elf_Internal_Sym *isym, *isymend; 1118 struct elf_link_hash_entry **hashes; 1119 struct elf_link_hash_entry **end_hashes; 1120 unsigned int symcount; 1144 1121 1145 1122 /* Skip non-code sections and empty sections. */ … … 1156 1133 if (internal_relocs == NULL) 1157 1134 goto error_return; 1158 if (! link_info->keep_memory)1159 free_relocs = internal_relocs;1160 1135 } 1161 1136 … … 1169 1144 if (contents == NULL) 1170 1145 goto error_return; 1171 free_contents = contents;1172 1146 1173 1147 if (!bfd_get_section_contents (input_bfd, section, … … 1177 1151 } 1178 1152 1179 shndx = _bfd_elf_section_from_bfd_section (input_bfd, section); 1153 sec_shndx = _bfd_elf_section_from_bfd_section (input_bfd, 1154 section); 1180 1155 1181 1156 /* Now look for any function in this section which needs 1182 1157 insns deleted from its prologue. */ 1183 esym = extsyms; 1184 esymend = esym + symtab_hdr->sh_info; 1185 for (; esym < esymend; esym++) 1158 isymend = isymbuf + symtab_hdr->sh_info; 1159 for (isym = isymbuf; isym < isymend; isym++) 1186 1160 { 1187 Elf_Internal_Sym isym;1188 1161 struct elf32_mn10300_link_hash_entry *sym_hash; 1189 1162 asection *sym_sec = NULL; 1190 1163 const char *sym_name; 1191 1164 char *new_name; 1192 1193 bfd_ elf32_swap_symbol_in (input_bfd, esym, &isym);1194 1195 if (isym .st_shndx !=shndx)1165 struct elf_link_hash_table *elftab; 1166 bfd_size_type amt; 1167 1168 if (isym->st_shndx != sec_shndx) 1196 1169 continue; 1197 1170 1198 if (isym .st_shndx == SHN_UNDEF)1171 if (isym->st_shndx == SHN_UNDEF) 1199 1172 sym_sec = bfd_und_section_ptr; 1200 else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE) 1201 sym_sec 1202 = bfd_section_from_elf_index (input_bfd, isym.st_shndx); 1203 else if (isym.st_shndx == SHN_ABS) 1173 else if (isym->st_shndx == SHN_ABS) 1204 1174 sym_sec = bfd_abs_section_ptr; 1205 else if (isym .st_shndx == SHN_COMMON)1175 else if (isym->st_shndx == SHN_COMMON) 1206 1176 sym_sec = bfd_com_section_ptr; 1207 1177 else 1208 abort (); 1209 1210 sym_name = bfd_elf_string_from_elf_section (input_bfd, 1211 symtab_hdr->sh_link, 1212 isym.st_name); 1178 sym_sec 1179 = bfd_section_from_elf_index (input_bfd, isym->st_shndx); 1180 1181 sym_name 1182 = bfd_elf_string_from_elf_section (input_bfd, 1183 symtab_hdr->sh_link, 1184 isym->st_name); 1213 1185 1214 1186 /* Tack on an ID so we can uniquely identify this 1215 1187 local symbol in the global hash table. */ 1216 new_name = bfd_malloc (strlen (sym_name) + 10); 1188 amt = strlen (sym_name) + 10; 1189 new_name = bfd_malloc (amt); 1217 1190 if (new_name == 0) 1218 1191 goto error_return; … … 1220 1193 sym_name = new_name; 1221 1194 1222 sym_hash = (struct elf32_mn10300_link_hash_entry *)1223 elf_link_hash_lookup (&hash_table->static_hash_table->root,1224 sym_name, false,1225 false, false);1195 elftab = &hash_table->static_hash_table->root; 1196 sym_hash = ((struct elf32_mn10300_link_hash_entry *) 1197 elf_link_hash_lookup (elftab, sym_name, 1198 FALSE, FALSE, FALSE)); 1226 1199 1227 1200 free (new_name); … … 1229 1202 continue; 1230 1203 1231 if (! ( (sym_hash)->flags & MN10300_CONVERT_CALL_TO_CALLS)1232 && ! ( (sym_hash)->flags & MN10300_DELETED_PROLOGUE_BYTES))1204 if (! (sym_hash->flags & MN10300_CONVERT_CALL_TO_CALLS) 1205 && ! (sym_hash->flags & MN10300_DELETED_PROLOGUE_BYTES)) 1233 1206 { 1234 1207 int bytes = 0; … … 1236 1209 /* Note that we've changed things. */ 1237 1210 elf_section_data (section)->relocs = internal_relocs; 1238 free_relocs = NULL;1239 1240 1211 elf_section_data (section)->this_hdr.contents = contents; 1241 free_contents = NULL; 1242 1243 symtab_hdr->contents = (bfd_byte *) extsyms; 1244 free_extsyms = NULL; 1212 symtab_hdr->contents = (unsigned char *) isymbuf; 1245 1213 1246 1214 /* Count how many bytes we're going to delete. */ … … 1261 1229 if (!mn10300_elf_relax_delete_bytes (input_bfd, 1262 1230 section, 1263 isym .st_value,1231 isym->st_value, 1264 1232 bytes)) 1265 1233 goto error_return; … … 1267 1235 /* Something changed. Not strictly necessary, but 1268 1236 may lead to more relaxing opportunities. */ 1269 *again = true;1237 *again = TRUE; 1270 1238 } 1271 1239 } … … 1273 1241 /* Look for any global functions in this section which 1274 1242 need insns deleted from their prologues. */ 1275 esym = extsyms + symtab_hdr->sh_info; 1276 esymend = extsyms + (symtab_hdr->sh_size 1277 / sizeof (Elf32_External_Sym)); 1278 for (idx = 0; esym < esymend; esym++, idx++) 1243 symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym) 1244 - symtab_hdr->sh_info); 1245 hashes = elf_sym_hashes (abfd); 1246 end_hashes = hashes + symcount; 1247 for (; hashes < end_hashes; hashes++) 1279 1248 { 1280 Elf_Internal_Sym isym;1281 1249 struct elf32_mn10300_link_hash_entry *sym_hash; 1282 1250 1283 bfd_elf32_swap_symbol_in (input_bfd, esym, &isym); 1284 sym_hash = (struct elf32_mn10300_link_hash_entry *) 1285 (elf_sym_hashes (input_bfd)[idx]); 1286 if (isym.st_shndx == shndx 1287 && (sym_hash)->root.root.u.def.section == section 1288 && ! ((sym_hash)->flags & MN10300_CONVERT_CALL_TO_CALLS) 1289 && ! ((sym_hash)->flags & MN10300_DELETED_PROLOGUE_BYTES)) 1251 sym_hash = (struct elf32_mn10300_link_hash_entry *) *hashes; 1252 if ((sym_hash->root.root.type == bfd_link_hash_defined 1253 || sym_hash->root.root.type == bfd_link_hash_defweak) 1254 && sym_hash->root.root.u.def.section == section 1255 && ! (sym_hash->flags & MN10300_CONVERT_CALL_TO_CALLS) 1256 && ! (sym_hash->flags & MN10300_DELETED_PROLOGUE_BYTES)) 1290 1257 { 1291 1258 int bytes = 0; 1259 bfd_vma symval; 1292 1260 1293 1261 /* Note that we've changed things. */ 1294 1262 elf_section_data (section)->relocs = internal_relocs; 1295 free_relocs = NULL;1296 1297 1263 elf_section_data (section)->this_hdr.contents = contents; 1298 free_contents = NULL; 1299 1300 symtab_hdr->contents = (bfd_byte *) extsyms; 1301 free_extsyms = NULL; 1264 symtab_hdr->contents = (unsigned char *) isymbuf; 1302 1265 1303 1266 /* Count how many bytes we're going to delete. */ … … 1316 1279 1317 1280 /* Actually delete the bytes. */ 1281 symval = sym_hash->root.root.u.def.value; 1318 1282 if (!mn10300_elf_relax_delete_bytes (input_bfd, 1319 1283 section, 1320 (sym_hash)->root.root.u.def.value,1284 symval, 1321 1285 bytes)) 1322 1286 goto error_return; … … 1324 1288 /* Something changed. Not strictly necessary, but 1325 1289 may lead to more relaxing opportunities. */ 1326 *again = true;1290 *again = TRUE; 1327 1291 } 1328 1292 } 1329 1293 1330 1294 /* Cache or free any memory we allocated for the relocs. */ 1331 if (free_relocs != NULL) 1332 { 1333 free (free_relocs); 1334 free_relocs = NULL; 1335 } 1295 if (internal_relocs != NULL 1296 && elf_section_data (section)->relocs != internal_relocs) 1297 free (internal_relocs); 1298 internal_relocs = NULL; 1336 1299 1337 1300 /* Cache or free any memory we allocated for the contents. */ 1338 if (free_contents != NULL) 1301 if (contents != NULL 1302 && elf_section_data (section)->this_hdr.contents != contents) 1339 1303 { 1340 1304 if (! link_info->keep_memory) 1341 free ( free_contents);1305 free (contents); 1342 1306 else 1343 1307 { … … 1345 1309 elf_section_data (section)->this_hdr.contents = contents; 1346 1310 } 1347 free_contents = NULL;1348 1311 } 1312 contents = NULL; 1349 1313 } 1350 1314 1351 1315 /* Cache or free any memory we allocated for the symbols. */ 1352 if (free_extsyms != NULL) 1316 if (isymbuf != NULL 1317 && symtab_hdr->contents != (unsigned char *) isymbuf) 1353 1318 { 1354 1319 if (! link_info->keep_memory) 1355 free ( free_extsyms);1320 free (isymbuf); 1356 1321 else 1357 1322 { 1358 1323 /* Cache the symbols for elf_link_input_bfd. */ 1359 symtab_hdr->contents = extsyms;1324 symtab_hdr->contents = (unsigned char *) isymbuf; 1360 1325 } 1361 free_extsyms = NULL;1362 1326 } 1327 isymbuf = NULL; 1363 1328 } 1364 1329 } … … 1366 1331 /* (Re)initialize for the basic instruction shortening/relaxing pass. */ 1367 1332 contents = NULL; 1368 extsyms = NULL;1369 1333 internal_relocs = NULL; 1370 free_relocs= NULL;1371 free_contents = NULL;1372 free_extsyms = NULL;1334 isymbuf = NULL; 1335 /* For error_return. */ 1336 section = sec; 1373 1337 1374 1338 /* We don't have to do anything for a relocateable link, if … … 1379 1343 || sec->reloc_count == 0 1380 1344 || (sec->flags & SEC_CODE) == 0) 1381 return true;1345 return TRUE; 1382 1346 1383 1347 /* If this is the first time we have been called for this section, … … 1394 1358 if (internal_relocs == NULL) 1395 1359 goto error_return; 1396 if (! link_info->keep_memory)1397 free_relocs = internal_relocs;1398 1360 1399 1361 /* Walk through them looking for relaxing opportunities. */ … … 1423 1385 if (contents == NULL) 1424 1386 goto error_return; 1425 free_contents = contents;1426 1387 1427 1388 if (! bfd_get_section_contents (abfd, sec, contents, … … 1432 1393 1433 1394 /* Read this BFD's symbols if we haven't done so already. */ 1434 if ( extsyms == NULL)1395 if (isymbuf == NULL && symtab_hdr->sh_info != 0) 1435 1396 { 1436 /* Get cached copy if it exists. */ 1437 if (symtab_hdr->contents != NULL) 1438 extsyms = (Elf32_External_Sym *) symtab_hdr->contents; 1439 else 1440 { 1441 /* Go get them off disk. */ 1442 extsyms = ((Elf32_External_Sym *) 1443 bfd_malloc (symtab_hdr->sh_size)); 1444 if (extsyms == NULL) 1445 goto error_return; 1446 free_extsyms = extsyms; 1447 if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 1448 || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd) 1449 != symtab_hdr->sh_size)) 1450 goto error_return; 1451 } 1397 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; 1398 if (isymbuf == NULL) 1399 isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr, 1400 symtab_hdr->sh_info, 0, 1401 NULL, NULL, NULL); 1402 if (isymbuf == NULL) 1403 goto error_return; 1452 1404 } 1453 1405 … … 1455 1407 if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info) 1456 1408 { 1457 Elf_Internal_Sym isym;1409 Elf_Internal_Sym *isym; 1458 1410 asection *sym_sec = NULL; 1459 1411 const char *sym_name; … … 1461 1413 1462 1414 /* A local symbol. */ 1463 bfd_elf32_swap_symbol_in (abfd, 1464 extsyms + ELF32_R_SYM (irel->r_info), 1465 &isym); 1466 1467 if (isym.st_shndx == SHN_UNDEF) 1415 isym = isymbuf + ELF32_R_SYM (irel->r_info); 1416 if (isym->st_shndx == SHN_UNDEF) 1468 1417 sym_sec = bfd_und_section_ptr; 1469 else if (isym.st_shndx > 0 && isym.st_shndx < SHN_LORESERVE) 1470 sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx); 1471 else if (isym.st_shndx == SHN_ABS) 1418 else if (isym->st_shndx == SHN_ABS) 1472 1419 sym_sec = bfd_abs_section_ptr; 1473 else if (isym .st_shndx == SHN_COMMON)1420 else if (isym->st_shndx == SHN_COMMON) 1474 1421 sym_sec = bfd_com_section_ptr; 1475 1422 else 1476 abort ();1477 1478 symval = (isym .st_value1423 sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx); 1424 1425 symval = (isym->st_value 1479 1426 + sym_sec->output_section->vma 1480 1427 + sym_sec->output_offset); 1481 1428 sym_name = bfd_elf_string_from_elf_section (abfd, 1482 1429 symtab_hdr->sh_link, 1483 isym .st_name);1430 isym->st_name); 1484 1431 1485 1432 /* Tack on an ID so we can uniquely identify this 1486 1433 local symbol in the global hash table. */ 1487 new_name = bfd_malloc ( strlen (sym_name) + 10);1434 new_name = bfd_malloc ((bfd_size_type) strlen (sym_name) + 10); 1488 1435 if (new_name == 0) 1489 1436 goto error_return; … … 1493 1440 h = (struct elf32_mn10300_link_hash_entry *) 1494 1441 elf_link_hash_lookup (&hash_table->static_hash_table->root, 1495 sym_name, false, false, false);1442 sym_name, FALSE, FALSE, FALSE); 1496 1443 free (new_name); 1497 1444 } … … 1549 1496 etc. */ 1550 1497 elf_section_data (sec)->relocs = internal_relocs; 1551 free_relocs = NULL;1552 1553 1498 elf_section_data (sec)->this_hdr.contents = contents; 1554 free_contents = NULL; 1555 1556 symtab_hdr->contents = (bfd_byte *) extsyms; 1557 free_extsyms = NULL; 1499 symtab_hdr->contents = (unsigned char *) isymbuf; 1558 1500 1559 1501 /* Fix the opcode. */ … … 1572 1514 /* That will change things, so, we should relax again. 1573 1515 Note that this is not required, and it may be slow. */ 1574 *again = true;1516 *again = TRUE; 1575 1517 } 1576 1518 } … … 1614 1556 /* Note that we've changed the relocs, section contents, etc. */ 1615 1557 elf_section_data (sec)->relocs = internal_relocs; 1616 free_relocs = NULL;1617 1618 1558 elf_section_data (sec)->this_hdr.contents = contents; 1619 free_contents = NULL; 1620 1621 symtab_hdr->contents = (bfd_byte *) extsyms; 1622 free_extsyms = NULL; 1559 symtab_hdr->contents = (unsigned char *) isymbuf; 1623 1560 1624 1561 /* Fix the opcode. */ … … 1641 1578 /* That will change things, so, we should relax again. 1642 1579 Note that this is not required, and it may be slow. */ 1643 *again = true;1580 *again = TRUE; 1644 1581 } 1645 1582 } … … 1666 1603 etc. */ 1667 1604 elf_section_data (sec)->relocs = internal_relocs; 1668 free_relocs = NULL;1669 1670 1605 elf_section_data (sec)->this_hdr.contents = contents; 1671 free_contents = NULL; 1672 1673 symtab_hdr->contents = (bfd_byte *) extsyms; 1674 free_extsyms = NULL; 1606 symtab_hdr->contents = (unsigned char *) isymbuf; 1675 1607 1676 1608 /* Fix the opcode. */ … … 1689 1621 /* That will change things, so, we should relax again. 1690 1622 Note that this is not required, and it may be slow. */ 1691 *again = true;1623 *again = TRUE; 1692 1624 } 1693 1625 } … … 1729 1661 /* Note that we've changed the relocs, section contents, etc. */ 1730 1662 elf_section_data (sec)->relocs = internal_relocs; 1731 free_relocs = NULL;1732 1733 1663 elf_section_data (sec)->this_hdr.contents = contents; 1734 free_contents = NULL; 1735 1736 symtab_hdr->contents = (bfd_byte *) extsyms; 1737 free_extsyms = NULL; 1664 symtab_hdr->contents = (unsigned char *) isymbuf; 1738 1665 1739 1666 /* Fix the opcode. */ … … 1751 1678 /* That will change things, so, we should relax again. 1752 1679 Note that this is not required, and it may be slow. */ 1753 *again = true;1680 *again = TRUE; 1754 1681 } 1755 1682 } … … 1819 1746 /* We also have to be sure there is no symbol/label 1820 1747 at the unconditional branch. */ 1821 if (mn10300_elf_symbol_address_p (abfd, sec, extsyms,1748 if (mn10300_elf_symbol_address_p (abfd, sec, isymbuf, 1822 1749 irel->r_offset + 1)) 1823 1750 continue; … … 1825 1752 /* Note that we've changed the relocs, section contents, etc. */ 1826 1753 elf_section_data (sec)->relocs = internal_relocs; 1827 free_relocs = NULL;1828 1829 1754 elf_section_data (sec)->this_hdr.contents = contents; 1830 free_contents = NULL; 1831 1832 symtab_hdr->contents = (bfd_byte *) extsyms; 1833 free_extsyms = NULL; 1755 symtab_hdr->contents = (unsigned char *) isymbuf; 1834 1756 1835 1757 /* Reverse the condition of the first branch. */ … … 1896 1818 /* That will change things, so, we should relax again. 1897 1819 Note that this is not required, and it may be slow. */ 1898 *again = true;1820 *again = TRUE; 1899 1821 } 1900 1822 … … 1939 1861 etc. */ 1940 1862 elf_section_data (sec)->relocs = internal_relocs; 1941 free_relocs = NULL;1942 1943 1863 elf_section_data (sec)->this_hdr.contents = contents; 1944 free_contents = NULL; 1945 1946 symtab_hdr->contents = (bfd_byte *) extsyms; 1947 free_extsyms = NULL; 1864 symtab_hdr->contents = (unsigned char *) isymbuf; 1948 1865 1949 1866 /* Fix the opcode. */ … … 1964 1881 again. Note that this is not required, and it 1965 1882 may be slow. */ 1966 *again = true;1883 *again = TRUE; 1967 1884 break; 1968 1885 } … … 2015 1932 etc. */ 2016 1933 elf_section_data (sec)->relocs = internal_relocs; 2017 free_relocs = NULL;2018 2019 1934 elf_section_data (sec)->this_hdr.contents = contents; 2020 free_contents = NULL; 2021 2022 symtab_hdr->contents = (bfd_byte *) extsyms; 2023 free_extsyms = NULL; 1935 symtab_hdr->contents = (unsigned char *) isymbuf; 2024 1936 2025 1937 /* Fix the opcode. */ … … 2040 1952 again. Note that this is not required, and it 2041 1953 may be slow. */ 2042 *again = true;1954 *again = TRUE; 2043 1955 break; 2044 1956 } … … 2099 2011 /* Note that we've changed the relocation contents, etc. */ 2100 2012 elf_section_data (sec)->relocs = internal_relocs; 2101 free_relocs = NULL;2102 2103 2013 elf_section_data (sec)->this_hdr.contents = contents; 2104 free_contents = NULL; 2105 2106 symtab_hdr->contents = (bfd_byte *) extsyms; 2107 free_extsyms = NULL; 2014 symtab_hdr->contents = (unsigned char *) isymbuf; 2108 2015 2109 2016 /* Fix the opcode. */ … … 2122 2029 /* That will change things, so, we should relax again. 2123 2030 Note that this is not required, and it may be slow. */ 2124 *again = true;2031 *again = TRUE; 2125 2032 break; 2126 2033 } … … 2137 2044 /* Note that we've changed the relocation contents, etc. */ 2138 2045 elf_section_data (sec)->relocs = internal_relocs; 2139 free_relocs = NULL;2140 2141 2046 elf_section_data (sec)->this_hdr.contents = contents; 2142 free_contents = NULL; 2143 2144 symtab_hdr->contents = (bfd_byte *) extsyms; 2145 free_extsyms = NULL; 2047 symtab_hdr->contents = (unsigned char *) isymbuf; 2146 2048 2147 2049 if ((code & 0xf3) == 0x81) … … 2172 2074 /* That will change things, so, we should relax again. 2173 2075 Note that this is not required, and it may be slow. */ 2174 *again = true;2076 *again = TRUE; 2175 2077 break; 2176 2078 … … 2192 2094 /* Note that we've changed the relocation contents, etc. */ 2193 2095 elf_section_data (sec)->relocs = internal_relocs; 2194 free_relocs = NULL;2195 2196 2096 elf_section_data (sec)->this_hdr.contents = contents; 2197 free_contents = NULL; 2198 2199 symtab_hdr->contents = (bfd_byte *) extsyms; 2200 free_extsyms = NULL; 2097 symtab_hdr->contents = (unsigned char *) isymbuf; 2201 2098 2202 2099 /* Fix the opcode. */ … … 2215 2112 /* That will change things, so, we should relax again. 2216 2113 Note that this is not required, and it may be slow. */ 2217 *again = true;2114 *again = TRUE; 2218 2115 break; 2219 2116 } … … 2245 2142 /* Note that we've changed the relocation contents, etc. */ 2246 2143 elf_section_data (sec)->relocs = internal_relocs; 2247 free_relocs = NULL;2248 2249 2144 elf_section_data (sec)->this_hdr.contents = contents; 2250 free_contents = NULL; 2251 2252 symtab_hdr->contents = (bfd_byte *) extsyms; 2253 free_extsyms = NULL; 2145 symtab_hdr->contents = (unsigned char *) isymbuf; 2254 2146 2255 2147 if ((code & 0xfc) == 0xcc) … … 2284 2176 /* That will change things, so, we should relax again. 2285 2177 Note that this is not required, and it may be slow. */ 2286 *again = true;2178 *again = TRUE; 2287 2179 break; 2288 2180 … … 2327 2219 /* Note that we've changed the relocation contents, etc. */ 2328 2220 elf_section_data (sec)->relocs = internal_relocs; 2329 free_relocs = NULL;2330 2331 2221 elf_section_data (sec)->this_hdr.contents = contents; 2332 free_contents = NULL; 2333 2334 symtab_hdr->contents = (bfd_byte *) extsyms; 2335 free_extsyms = NULL; 2222 symtab_hdr->contents = (unsigned char *) isymbuf; 2336 2223 2337 2224 /* Fix the opcode. */ … … 2350 2237 /* That will change things, so, we should relax again. 2351 2238 Note that this is not required, and it may be slow. */ 2352 *again = true;2239 *again = TRUE; 2353 2240 break; 2354 2241 } … … 2359 2246 /* Note that we've changed the relocation contents, etc. */ 2360 2247 elf_section_data (sec)->relocs = internal_relocs; 2361 free_relocs = NULL;2362 2363 2248 elf_section_data (sec)->this_hdr.contents = contents; 2364 free_contents = NULL; 2365 2366 symtab_hdr->contents = (bfd_byte *) extsyms; 2367 free_extsyms = NULL; 2249 symtab_hdr->contents = (unsigned char *) isymbuf; 2368 2250 2369 2251 /* Fix the opcode. */ … … 2382 2264 /* That will change things, so, we should relax again. 2383 2265 Note that this is not required, and it may be slow. */ 2384 *again = true;2266 *again = TRUE; 2385 2267 break; 2386 2268 } … … 2389 2271 } 2390 2272 2391 if (free_relocs != NULL) 2392 { 2393 free (free_relocs); 2394 free_relocs = NULL; 2395 } 2396 2397 if (free_contents != NULL) 2273 if (isymbuf != NULL 2274 && symtab_hdr->contents != (unsigned char *) isymbuf) 2398 2275 { 2399 2276 if (! link_info->keep_memory) 2400 free (free_contents); 2277 free (isymbuf); 2278 else 2279 { 2280 /* Cache the symbols for elf_link_input_bfd. */ 2281 symtab_hdr->contents = (unsigned char *) isymbuf; 2282 } 2283 } 2284 2285 if (contents != NULL 2286 && elf_section_data (sec)->this_hdr.contents != contents) 2287 { 2288 if (! link_info->keep_memory) 2289 free (contents); 2401 2290 else 2402 2291 { … … 2404 2293 elf_section_data (sec)->this_hdr.contents = contents; 2405 2294 } 2406 free_contents = NULL;2407 2295 } 2408 2296 2409 if (free_extsyms != NULL) 2410 { 2411 if (! link_info->keep_memory) 2412 free (free_extsyms); 2413 else 2414 { 2415 /* Cache the symbols for elf_link_input_bfd. */ 2416 symtab_hdr->contents = extsyms; 2417 } 2418 free_extsyms = NULL; 2419 } 2420 2421 return true; 2297 if (internal_relocs != NULL 2298 && elf_section_data (sec)->relocs != internal_relocs) 2299 free (internal_relocs); 2300 2301 return TRUE; 2422 2302 2423 2303 error_return: 2424 if (free_relocs != NULL) 2425 free (free_relocs); 2426 if (free_contents != NULL) 2427 free (free_contents); 2428 if (free_extsyms != NULL) 2429 free (free_extsyms); 2430 return false; 2304 if (isymbuf != NULL 2305 && symtab_hdr->contents != (unsigned char *) isymbuf) 2306 free (isymbuf); 2307 if (contents != NULL 2308 && elf_section_data (section)->this_hdr.contents != contents) 2309 free (contents); 2310 if (internal_relocs != NULL 2311 && elf_section_data (section)->relocs != internal_relocs) 2312 free (internal_relocs); 2313 2314 return FALSE; 2431 2315 } 2432 2316 … … 2533 2417 /* Delete some bytes from a section while relaxing. */ 2534 2418 2535 static b oolean2419 static bfd_boolean 2536 2420 mn10300_elf_relax_delete_bytes (abfd, sec, addr, count) 2537 2421 bfd *abfd; … … 2541 2425 { 2542 2426 Elf_Internal_Shdr *symtab_hdr; 2543 Elf32_External_Sym *extsyms; 2544 int shndx, index; 2427 unsigned int sec_shndx; 2545 2428 bfd_byte *contents; 2546 2429 Elf_Internal_Rela *irel, *irelend; 2547 2430 Elf_Internal_Rela *irelalign; 2548 2431 bfd_vma toaddr; 2549 Elf32_External_Sym *esym, *esymend; 2550 struct elf32_mn10300_link_hash_entry *sym_hash; 2551 2552 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; 2553 extsyms = (Elf32_External_Sym *) symtab_hdr->contents; 2554 2555 shndx = _bfd_elf_section_from_bfd_section (abfd, sec); 2432 Elf_Internal_Sym *isym, *isymend; 2433 struct elf_link_hash_entry **sym_hashes; 2434 struct elf_link_hash_entry **end_hashes; 2435 unsigned int symcount; 2436 2437 sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec); 2556 2438 2557 2439 contents = elf_section_data (sec)->this_hdr.contents; … … 2567 2449 2568 2450 /* Actually delete the bytes. */ 2569 memmove (contents + addr, contents + addr + count, toaddr - addr - count); 2451 memmove (contents + addr, contents + addr + count, 2452 (size_t) (toaddr - addr - count)); 2570 2453 sec->_cooked_size -= count; 2571 2454 … … 2580 2463 2581 2464 /* Adjust the local symbols defined in this section. */ 2582 esym = extsyms;2583 esymend = esym + symtab_hdr->sh_info;2584 for ( ; esym < esymend; esym++)2465 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; 2466 isym = (Elf_Internal_Sym *) symtab_hdr->contents; 2467 for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++) 2585 2468 { 2586 Elf_Internal_Sym isym; 2587 2588 bfd_elf32_swap_symbol_in (abfd, esym, &isym); 2589 2590 if (isym.st_shndx == shndx 2591 && isym.st_value > addr 2592 && isym.st_value < toaddr) 2469 if (isym->st_shndx == sec_shndx 2470 && isym->st_value > addr 2471 && isym->st_value < toaddr) 2472 isym->st_value -= count; 2473 } 2474 2475 /* Now adjust the global symbols defined in this section. */ 2476 symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym) 2477 - symtab_hdr->sh_info); 2478 sym_hashes = elf_sym_hashes (abfd); 2479 end_hashes = sym_hashes + symcount; 2480 for (; sym_hashes < end_hashes; sym_hashes++) 2481 { 2482 struct elf_link_hash_entry *sym_hash = *sym_hashes; 2483 if ((sym_hash->root.type == bfd_link_hash_defined 2484 || sym_hash->root.type == bfd_link_hash_defweak) 2485 && sym_hash->root.u.def.section == sec 2486 && sym_hash->root.u.def.value > addr 2487 && sym_hash->root.u.def.value < toaddr) 2593 2488 { 2594 isym.st_value -= count; 2595 bfd_elf32_swap_symbol_out (abfd, &isym, esym); 2489 sym_hash->root.u.def.value -= count; 2596 2490 } 2597 2491 } 2598 2492 2599 /* Now adjust the global symbols defined in this section. */ 2600 esym = extsyms + symtab_hdr->sh_info; 2601 esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)); 2602 for (index = 0; esym < esymend; esym++, index++) 2603 { 2604 Elf_Internal_Sym isym; 2605 2606 bfd_elf32_swap_symbol_in (abfd, esym, &isym); 2607 sym_hash = (struct elf32_mn10300_link_hash_entry *) 2608 (elf_sym_hashes (abfd)[index]); 2609 if (isym.st_shndx == shndx 2610 && ((sym_hash)->root.root.type == bfd_link_hash_defined 2611 || (sym_hash)->root.root.type == bfd_link_hash_defweak) 2612 && (sym_hash)->root.root.u.def.section == sec 2613 && (sym_hash)->root.root.u.def.value > addr 2614 && (sym_hash)->root.root.u.def.value < toaddr) 2615 { 2616 (sym_hash)->root.root.u.def.value -= count; 2617 } 2618 } 2619 2620 return true; 2493 return TRUE; 2621 2494 } 2622 2495 2623 /* Return trueif a symbol exists at the given address, else return2624 false. */2625 static b oolean2626 mn10300_elf_symbol_address_p (abfd, sec, extsyms, addr)2496 /* Return TRUE if a symbol exists at the given address, else return 2497 FALSE. */ 2498 static bfd_boolean 2499 mn10300_elf_symbol_address_p (abfd, sec, isym, addr) 2627 2500 bfd *abfd; 2628 2501 asection *sec; 2629 Elf 32_External_Sym *extsyms;2502 Elf_Internal_Sym *isym; 2630 2503 bfd_vma addr; 2631 2504 { 2632 2505 Elf_Internal_Shdr *symtab_hdr; 2633 int shndx; 2634 Elf32_External_Sym *esym, *esymend; 2635 struct elf32_mn10300_link_hash_entry **sym_hash, **sym_hash_end; 2636 2506 unsigned int sec_shndx; 2507 Elf_Internal_Sym *isymend; 2508 struct elf_link_hash_entry **sym_hashes; 2509 struct elf_link_hash_entry **end_hashes; 2510 unsigned int symcount; 2511 2512 sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec); 2513 2514 /* Examine all the symbols. */ 2637 2515 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; 2638 shndx = _bfd_elf_section_from_bfd_section (abfd, sec); 2639 2640 /* Examine all the symbols. */ 2641 esym = extsyms; 2642 esymend = esym + symtab_hdr->sh_info; 2643 for (; esym < esymend; esym++) 2516 for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++) 2644 2517 { 2645 Elf_Internal_Sym isym; 2646 2647 bfd_elf32_swap_symbol_in (abfd, esym, &isym); 2648 2649 if (isym.st_shndx == shndx 2650 && isym.st_value == addr) 2651 return true; 2518 if (isym->st_shndx == sec_shndx 2519 && isym->st_value == addr) 2520 return TRUE; 2652 2521 } 2653 2522 2654 sym _hash = (struct elf32_mn10300_link_hash_entry **) (elf_sym_hashes (abfd));2655 sym_hash_end = (sym_hash 2656 + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym) 2657 - symtab_hdr->sh_info));2658 for (; sym_hash < sym_hash_end; sym_hash++)2523 symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym) 2524 - symtab_hdr->sh_info); 2525 sym_hashes = elf_sym_hashes (abfd); 2526 end_hashes = sym_hashes + symcount; 2527 for (; sym_hashes < end_hashes; sym_hashes++) 2659 2528 { 2660 if (((*sym_hash)->root.root.type == bfd_link_hash_defined 2661 || (*sym_hash)->root.root.type == bfd_link_hash_defweak) 2662 && (*sym_hash)->root.root.u.def.section == sec 2663 && (*sym_hash)->root.root.u.def.value == addr) 2664 return true; 2529 struct elf_link_hash_entry *sym_hash = *sym_hashes; 2530 if ((sym_hash->root.type == bfd_link_hash_defined 2531 || sym_hash->root.type == bfd_link_hash_defweak) 2532 && sym_hash->root.u.def.section == sec 2533 && sym_hash->root.u.def.value == addr) 2534 return TRUE; 2665 2535 } 2666 return false; 2536 2537 return FALSE; 2667 2538 } 2668 2539 … … 2677 2548 struct bfd_link_order *link_order; 2678 2549 bfd_byte *data; 2679 b oolean relocateable;2550 bfd_boolean relocateable; 2680 2551 asymbol **symbols; 2681 2552 { … … 2685 2556 asection **sections = NULL; 2686 2557 Elf_Internal_Rela *internal_relocs = NULL; 2687 Elf32_External_Sym *external_syms = NULL; 2688 Elf_Internal_Sym *internal_syms = NULL; 2558 Elf_Internal_Sym *isymbuf = NULL; 2689 2559 2690 2560 /* We only need to handle the case of relaxing, or of having a … … 2700 2570 2701 2571 memcpy (data, elf_section_data (input_section)->this_hdr.contents, 2702 input_section->_raw_size);2572 (size_t) input_section->_raw_size); 2703 2573 2704 2574 if ((input_section->flags & SEC_RELOC) != 0 2705 2575 && input_section->reloc_count > 0) 2706 2576 { 2707 Elf_Internal_Sym *isymp;2708 2577 asection **secpp; 2709 Elf32_External_Sym *esym, *esymend; 2710 2711 if (symtab_hdr->contents != NULL) 2712 external_syms = (Elf32_External_Sym *) symtab_hdr->contents; 2713 else 2578 Elf_Internal_Sym *isym, *isymend; 2579 bfd_size_type amt; 2580 2581 internal_relocs = (_bfd_elf32_link_read_relocs 2582 (input_bfd, input_section, (PTR) NULL, 2583 (Elf_Internal_Rela *) NULL, FALSE)); 2584 if (internal_relocs == NULL) 2585 goto error_return; 2586 2587 if (symtab_hdr->sh_info != 0) 2714 2588 { 2715 external_syms = ((Elf32_External_Sym *) 2716 bfd_malloc (symtab_hdr->sh_info 2717 * sizeof (Elf32_External_Sym))); 2718 if (external_syms == NULL && symtab_hdr->sh_info > 0) 2719 goto error_return; 2720 if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 2721 || (bfd_read (external_syms, sizeof (Elf32_External_Sym), 2722 symtab_hdr->sh_info, input_bfd) 2723 != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym)))) 2589 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; 2590 if (isymbuf == NULL) 2591 isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, 2592 symtab_hdr->sh_info, 0, 2593 NULL, NULL, NULL); 2594 if (isymbuf == NULL) 2724 2595 goto error_return; 2725 2596 } 2726 2597 2727 internal_relocs = (_bfd_elf32_link_read_relocs2728 (input_bfd, input_section, (PTR) NULL, 2729 (Elf_Internal_Rela *) NULL, false));2730 if ( internal_relocs == NULL)2598 amt = symtab_hdr->sh_info; 2599 amt *= sizeof (asection *); 2600 sections = (asection **) bfd_malloc (amt); 2601 if (sections == NULL && amt != 0) 2731 2602 goto error_return; 2732 2603 2733 internal_syms = ((Elf_Internal_Sym *) 2734 bfd_malloc (symtab_hdr->sh_info 2735 * sizeof (Elf_Internal_Sym))); 2736 if (internal_syms == NULL && symtab_hdr->sh_info > 0) 2737 goto error_return; 2738 2739 sections = (asection **) bfd_malloc (symtab_hdr->sh_info 2740 * sizeof (asection *)); 2741 if (sections == NULL && symtab_hdr->sh_info > 0) 2742 goto error_return; 2743 2744 isymp = internal_syms; 2745 secpp = sections; 2746 esym = external_syms; 2747 esymend = esym + symtab_hdr->sh_info; 2748 for (; esym < esymend; ++esym, ++isymp, ++secpp) 2604 isymend = isymbuf + symtab_hdr->sh_info; 2605 for (isym = isymbuf, secpp = sections; isym < isymend; ++isym, ++secpp) 2749 2606 { 2750 2607 asection *isec; 2751 2608 2752 bfd_elf32_swap_symbol_in (input_bfd, esym, isymp); 2753 2754 if (isymp->st_shndx == SHN_UNDEF) 2609 if (isym->st_shndx == SHN_UNDEF) 2755 2610 isec = bfd_und_section_ptr; 2756 else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE) 2757 isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx); 2758 else if (isymp->st_shndx == SHN_ABS) 2611 else if (isym->st_shndx == SHN_ABS) 2759 2612 isec = bfd_abs_section_ptr; 2760 else if (isym p->st_shndx == SHN_COMMON)2613 else if (isym->st_shndx == SHN_COMMON) 2761 2614 isec = bfd_com_section_ptr; 2762 2615 else 2763 { 2764 /* Who knows? */ 2765 isec = NULL; 2766 } 2616 isec = bfd_section_from_elf_index (input_bfd, isym->st_shndx); 2767 2617 2768 2618 *secpp = isec; … … 2771 2621 if (! mn10300_elf_relocate_section (output_bfd, link_info, input_bfd, 2772 2622 input_section, data, internal_relocs, 2773 i nternal_syms, sections))2623 isymbuf, sections)) 2774 2624 goto error_return; 2775 2625 2776 2626 if (sections != NULL) 2777 2627 free (sections); 2778 sections = NULL; 2779 if (internal_syms != NULL) 2780 free (internal_syms); 2781 internal_syms = NULL; 2782 if (external_syms != NULL && symtab_hdr->contents == NULL) 2783 free (external_syms); 2784 external_syms = NULL; 2628 if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) 2629 free (isymbuf); 2785 2630 if (internal_relocs != elf_section_data (input_section)->relocs) 2786 2631 free (internal_relocs); 2787 internal_relocs = NULL;2788 2632 } 2789 2633 … … 2791 2635 2792 2636 error_return: 2637 if (sections != NULL) 2638 free (sections); 2639 if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf) 2640 free (isymbuf); 2793 2641 if (internal_relocs != NULL 2794 2642 && internal_relocs != elf_section_data (input_section)->relocs) 2795 2643 free (internal_relocs); 2796 if (external_syms != NULL && symtab_hdr->contents == NULL)2797 free (external_syms);2798 if (internal_syms != NULL)2799 free (internal_syms);2800 if (sections != NULL)2801 free (sections);2802 2644 return NULL; 2803 2645 } … … 2835 2677 ret->direct_calls = 0; 2836 2678 ret->stack_size = 0; 2679 ret->movm_args = 0; 2837 2680 ret->movm_stack_size = 0; 2838 2681 ret->flags = 0; 2839 ret->movm_args = 0;2840 2682 } 2841 2683 … … 2850 2692 { 2851 2693 struct elf32_mn10300_link_hash_table *ret; 2852 2853 ret = ((struct elf32_mn10300_link_hash_table *) 2854 bfd_alloc (abfd, sizeof (struct elf32_mn10300_link_hash_table)));2694 bfd_size_type amt = sizeof (struct elf32_mn10300_link_hash_table); 2695 2696 ret = (struct elf32_mn10300_link_hash_table *) bfd_malloc (amt); 2855 2697 if (ret == (struct elf32_mn10300_link_hash_table *) NULL) 2856 2698 return NULL; … … 2859 2701 elf32_mn10300_link_hash_newfunc)) 2860 2702 { 2861 bfd_release (abfd,ret);2703 free (ret); 2862 2704 return NULL; 2863 2705 } 2864 2706 2865 2707 ret->flags = 0; 2708 amt = sizeof (struct elf_link_hash_table); 2866 2709 ret->static_hash_table 2867 = ((struct elf32_mn10300_link_hash_table *) 2868 bfd_alloc (abfd, sizeof (struct elf_link_hash_table))); 2710 = (struct elf32_mn10300_link_hash_table *) bfd_malloc (amt); 2869 2711 if (ret->static_hash_table == NULL) 2870 2712 { 2871 bfd_release (abfd,ret);2713 free (ret); 2872 2714 return NULL; 2873 2715 } … … 2876 2718 elf32_mn10300_link_hash_newfunc)) 2877 2719 { 2878 bfd_release (abfd,ret->static_hash_table);2879 bfd_release (abfd,ret);2720 free (ret->static_hash_table); 2721 free (ret); 2880 2722 return NULL; 2881 2723 } … … 2883 2725 } 2884 2726 2885 static int 2727 /* Free an mn10300 ELF linker hash table. */ 2728 2729 static void 2730 elf32_mn10300_link_hash_table_free (hash) 2731 struct bfd_link_hash_table *hash; 2732 { 2733 struct elf32_mn10300_link_hash_table *ret 2734 = (struct elf32_mn10300_link_hash_table *) hash; 2735 2736 _bfd_generic_link_hash_table_free 2737 ((struct bfd_link_hash_table *) ret->static_hash_table); 2738 _bfd_generic_link_hash_table_free 2739 ((struct bfd_link_hash_table *) ret); 2740 } 2741 2742 static unsigned long 2886 2743 elf_mn10300_mach (flags) 2887 2744 flagword flags; … … 2905 2762 _bfd_mn10300_elf_final_write_processing (abfd, linker) 2906 2763 bfd *abfd; 2907 b oolean linker ATTRIBUTE_UNUSED;2764 bfd_boolean linker ATTRIBUTE_UNUSED; 2908 2765 { 2909 2766 unsigned long val; … … 2925 2782 } 2926 2783 2927 b oolean2784 bfd_boolean 2928 2785 _bfd_mn10300_elf_object_p (abfd) 2929 2786 bfd *abfd; … … 2931 2788 bfd_default_set_arch_mach (abfd, bfd_arch_mn10300, 2932 2789 elf_mn10300_mach (elf_elfheader (abfd)->e_flags)); 2933 return true;2790 return TRUE; 2934 2791 } 2935 2792 … … 2937 2794 object file when linking. */ 2938 2795 2939 b oolean2796 bfd_boolean 2940 2797 _bfd_mn10300_elf_merge_private_bfd_data (ibfd, obfd) 2941 2798 bfd *ibfd; … … 2944 2801 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour 2945 2802 || bfd_get_flavour (obfd) != bfd_target_elf_flavour) 2946 return true;2803 return TRUE; 2947 2804 2948 2805 if (bfd_get_arch (obfd) == bfd_get_arch (ibfd) … … 2951 2808 if (! bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), 2952 2809 bfd_get_mach (ibfd))) 2953 return false;2810 return FALSE; 2954 2811 } 2955 2812 2956 return true;2813 return TRUE; 2957 2814 } 2958 2815 … … 2960 2817 #define TARGET_LITTLE_NAME "elf32-mn10300" 2961 2818 #define ELF_ARCH bfd_arch_mn10300 2962 #define ELF_MACHINE_CODE EM_CYGNUS_MN10300 2819 #define ELF_MACHINE_CODE EM_MN10300 2820 #define ELF_MACHINE_ALT1 EM_CYGNUS_MN10300 2963 2821 #define ELF_MAXPAGESIZE 0x1000 2964 2822 … … 2966 2824 #define elf_info_to_howto_rel 0 2967 2825 #define elf_backend_can_gc_sections 1 2826 #define elf_backend_rela_normal 1 2968 2827 #define elf_backend_check_relocs mn10300_elf_check_relocs 2969 2828 #define elf_backend_gc_mark_hook mn10300_elf_gc_mark_hook … … 2974 2833 #define bfd_elf32_bfd_link_hash_table_create \ 2975 2834 elf32_mn10300_link_hash_table_create 2835 #define bfd_elf32_bfd_link_hash_table_free \ 2836 elf32_mn10300_link_hash_table_free 2976 2837 2977 2838 #define elf_symbol_leading_char '_' -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.