Changeset 609 for branches/GNU/src/binutils/bfd/linker.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/linker.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* linker.c -- BFD linker routines 2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 3 3 Free Software Foundation, Inc. 4 4 Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support 5 5 6 This file is part of BFD, the Binary File Descriptor library.7 8 This program is free software; you can redistribute it and/or modify9 it under the terms of the GNU General Public License as published by10 the Free Software Foundation; either version 2 of the License, or11 (at your option) any later version.12 13 This program is distributed in the hope that it will be useful,14 but WITHOUT ANY WARRANTY; without even the implied warranty of15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 GNU General Public License for more details.17 18 You should have received a copy of the GNU General Public License19 along with this program; if not, write to the Free Software20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */6 This file is part of BFD, the Binary File Descriptor library. 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 21 22 22 #include "bfd.h" … … 201 201 routine should save it somewhere attached to the object file 202 202 BFD. However, the information should only be saved if the 203 <<keep_memory>> field of the <<info>> argument is true, so203 <<keep_memory>> field of the <<info>> argument is TRUE, so 204 204 that the <<-no-keep-memory>> linker switch is effective. 205 205 … … 407 407 */ 408 408 409 static b oolean generic_link_read_symbols409 static bfd_boolean generic_link_read_symbols 410 410 PARAMS ((bfd *)); 411 static boolean generic_link_add_symbols 412 PARAMS ((bfd *, struct bfd_link_info *, boolean collect)); 413 static boolean generic_link_add_object_symbols 414 PARAMS ((bfd *, struct bfd_link_info *, boolean collect)); 415 static boolean generic_link_check_archive_element_no_collect 416 PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded)); 417 static boolean generic_link_check_archive_element_collect 418 PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded)); 419 static boolean generic_link_check_archive_element 420 PARAMS ((bfd *, struct bfd_link_info *, boolean *pneeded, boolean collect)); 421 static boolean generic_link_add_symbol_list 411 static bfd_boolean generic_link_add_symbols 412 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean collect)); 413 static bfd_boolean generic_link_add_object_symbols 414 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean collect)); 415 static bfd_boolean generic_link_check_archive_element_no_collect 416 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean *pneeded)); 417 static bfd_boolean generic_link_check_archive_element_collect 418 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean *pneeded)); 419 static bfd_boolean generic_link_check_archive_element 420 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean *pneeded, 421 bfd_boolean collect)); 422 static bfd_boolean generic_link_add_symbol_list 422 423 PARAMS ((bfd *, struct bfd_link_info *, bfd_size_type count, asymbol **, 423 boolean collect)); 424 static bfd *hash_entry_bfd PARAMS ((struct bfd_link_hash_entry *)); 424 bfd_boolean collect)); 425 static bfd *hash_entry_bfd 426 PARAMS ((struct bfd_link_hash_entry *)); 425 427 static void set_symbol_from_hash 426 428 PARAMS ((asymbol *, struct bfd_link_hash_entry *)); 427 static b oolean generic_add_output_symbol429 static bfd_boolean generic_add_output_symbol 428 430 PARAMS ((bfd *, size_t *psymalloc, asymbol *)); 429 static b oolean default_fill_link_order431 static bfd_boolean default_data_link_order 430 432 PARAMS ((bfd *, struct bfd_link_info *, asection *, 431 433 struct bfd_link_order *)); 432 static b oolean default_indirect_link_order434 static bfd_boolean default_indirect_link_order 433 435 PARAMS ((bfd *, struct bfd_link_info *, asection *, 434 struct bfd_link_order *, b oolean));436 struct bfd_link_order *, bfd_boolean)); 435 437 436 438 /* The link hash table structure is defined in bfdlink.h. It provides … … 446 448 const char *string; 447 449 { 448 struct bfd_link_hash_entry *ret = (struct bfd_link_hash_entry *) entry;449 450 450 /* Allocate the structure if it has not already been allocated by a 451 451 subclass. */ 452 if (ret == (struct bfd_link_hash_entry *) NULL) 453 ret = ((struct bfd_link_hash_entry *) 454 bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry))); 455 if (ret == (struct bfd_link_hash_entry *) NULL) 456 return NULL; 452 if (entry == NULL) 453 { 454 entry = (struct bfd_hash_entry *) 455 bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry)); 456 if (entry == NULL) 457 return entry; 458 } 457 459 458 460 /* Call the allocation method of the superclass. */ 459 ret = ((struct bfd_link_hash_entry *)460 bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); 461 462 if (ret)463 { 461 entry = bfd_hash_newfunc (entry, table, string); 462 if (entry) 463 { 464 struct bfd_link_hash_entry *h = (struct bfd_link_hash_entry *) entry; 465 464 466 /* Initialize the local fields. */ 465 ret->type = bfd_link_hash_new;466 ret->next = NULL;467 } 468 469 return (struct bfd_hash_entry *) ret;467 h->type = bfd_link_hash_new; 468 h->next = NULL; 469 } 470 471 return entry; 470 472 } 471 473 … … 473 475 responsible for creating this table. */ 474 476 475 b oolean477 bfd_boolean 476 478 _bfd_link_hash_table_init (table, abfd, newfunc) 477 479 struct bfd_link_hash_table *table; … … 484 486 table->undefs = NULL; 485 487 table->undefs_tail = NULL; 488 table->type = bfd_link_generic_hash_table; 489 486 490 return bfd_hash_table_init (&table->table, newfunc); 487 491 } 488 492 489 /* Look up a symbol in a link hash table. If follow is true, we493 /* Look up a symbol in a link hash table. If follow is TRUE, we 490 494 follow bfd_link_hash_indirect and bfd_link_hash_warning links to 491 495 the real symbol. */ … … 495 499 struct bfd_link_hash_table *table; 496 500 const char *string; 497 b oolean create;498 b oolean copy;499 b oolean follow;501 bfd_boolean create; 502 bfd_boolean copy; 503 bfd_boolean follow; 500 504 { 501 505 struct bfd_link_hash_entry *ret; … … 523 527 struct bfd_link_info *info; 524 528 const char *string; 525 boolean create; 526 boolean copy; 527 boolean follow; 528 { 529 bfd_boolean create; 530 bfd_boolean copy; 531 bfd_boolean follow; 532 { 533 bfd_size_type amt; 534 529 535 if (info->wrap_hash != NULL) 530 536 { … … 538 544 #define WRAP "__wrap_" 539 545 540 if (bfd_hash_lookup (info->wrap_hash, l, false, false) != NULL)546 if (bfd_hash_lookup (info->wrap_hash, l, FALSE, FALSE) != NULL) 541 547 { 542 548 char *n; … … 546 552 references to SYM with references to __wrap_SYM. */ 547 553 548 n = (char *) bfd_malloc (strlen (l) + sizeof WRAP + 1); 554 amt = strlen (l) + sizeof WRAP + 1; 555 n = (char *) bfd_malloc (amt); 549 556 if (n == NULL) 550 557 return NULL; … … 555 562 strcat (n, WRAP); 556 563 strcat (n, l); 557 h = bfd_link_hash_lookup (info->hash, n, create, true, follow);564 h = bfd_link_hash_lookup (info->hash, n, create, TRUE, follow); 558 565 free (n); 559 566 return h; … … 568 575 && strncmp (l, REAL, sizeof REAL - 1) == 0 569 576 && bfd_hash_lookup (info->wrap_hash, l + sizeof REAL - 1, 570 false, false) != NULL)577 FALSE, FALSE) != NULL) 571 578 { 572 579 char *n; … … 577 584 with references to SYM. */ 578 585 579 n = (char *) bfd_malloc (strlen (l + sizeof REAL - 1) + 2); 586 amt = strlen (l + sizeof REAL - 1) + 2; 587 n = (char *) bfd_malloc (amt); 580 588 if (n == NULL) 581 589 return NULL; … … 585 593 n[1] = '\0'; 586 594 strcat (n, l + sizeof REAL - 1); 587 h = bfd_link_hash_lookup (info->hash, n, create, true, follow);595 h = bfd_link_hash_lookup (info->hash, n, create, TRUE, follow); 588 596 free (n); 589 597 return h; … … 605 613 bfd_link_hash_traverse (table, func, info) 606 614 struct bfd_link_hash_table *table; 607 b oolean (*func) PARAMS ((struct bfd_link_hash_entry *, PTR));615 bfd_boolean (*func) PARAMS ((struct bfd_link_hash_entry *, PTR)); 608 616 PTR info; 609 617 { 610 618 bfd_hash_traverse (&table->table, 611 ((b oolean (*) PARAMS ((struct bfd_hash_entry *, PTR)))619 ((bfd_boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) 612 620 func), 613 621 info); … … 630 638 631 639 632 /* Routine to create an entry in a ngeneric link hash table. */640 /* Routine to create an entry in a generic link hash table. */ 633 641 634 642 struct bfd_hash_entry * … … 638 646 const char *string; 639 647 { 640 struct generic_link_hash_entry *ret =641 (struct generic_link_hash_entry *) entry;642 643 648 /* Allocate the structure if it has not already been allocated by a 644 649 subclass. */ 645 if (ret == (struct generic_link_hash_entry *) NULL) 646 ret = ((struct generic_link_hash_entry *) 647 bfd_hash_allocate (table, sizeof (struct generic_link_hash_entry))); 648 if (ret == (struct generic_link_hash_entry *) NULL) 649 return NULL; 650 if (entry == NULL) 651 { 652 entry = (struct bfd_hash_entry *) 653 bfd_hash_allocate (table, sizeof (struct generic_link_hash_entry)); 654 if (entry == NULL) 655 return entry; 656 } 650 657 651 658 /* Call the allocation method of the superclass. */ 652 ret = ((struct generic_link_hash_entry *) 653 _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret, 654 table, string)); 655 656 if (ret) 657 { 659 entry = _bfd_link_hash_newfunc (entry, table, string); 660 if (entry) 661 { 662 struct generic_link_hash_entry *ret; 663 658 664 /* Set local fields. */ 659 ret->written = false; 665 ret = (struct generic_link_hash_entry *) entry; 666 ret->written = FALSE; 660 667 ret->sym = NULL; 661 668 } 662 669 663 return (struct bfd_hash_entry *) ret;664 } 665 666 /* Create a ngeneric link hash table. */670 return entry; 671 } 672 673 /* Create a generic link hash table. */ 667 674 668 675 struct bfd_link_hash_table * … … 671 678 { 672 679 struct generic_link_hash_table *ret; 673 674 ret = ((struct generic_link_hash_table *) 675 bfd_alloc (abfd, sizeof (struct generic_link_hash_table)));680 bfd_size_type amt = sizeof (struct generic_link_hash_table); 681 682 ret = (struct generic_link_hash_table *) bfd_malloc (amt); 676 683 if (ret == NULL) 677 684 return (struct bfd_link_hash_table *) NULL; … … 683 690 } 684 691 return &ret->root; 692 } 693 694 void 695 _bfd_generic_link_hash_table_free (hash) 696 struct bfd_link_hash_table *hash; 697 { 698 struct generic_link_hash_table *ret 699 = (struct generic_link_hash_table *) hash; 700 701 bfd_hash_table_free (&ret->root.table); 702 free (ret); 685 703 } 686 704 … … 692 710 structure. */ 693 711 694 static b oolean712 static bfd_boolean 695 713 generic_link_read_symbols (abfd) 696 714 bfd *abfd; … … 703 721 symsize = bfd_get_symtab_upper_bound (abfd); 704 722 if (symsize < 0) 705 return false; 706 bfd_get_outsymbols (abfd) = (asymbol **) bfd_alloc (abfd, symsize); 723 return FALSE; 724 bfd_get_outsymbols (abfd) = 725 (asymbol **) bfd_alloc (abfd, (bfd_size_type) symsize); 707 726 if (bfd_get_outsymbols (abfd) == NULL && symsize != 0) 708 return false;727 return FALSE; 709 728 symcount = bfd_canonicalize_symtab (abfd, bfd_get_outsymbols (abfd)); 710 729 if (symcount < 0) 711 return false;730 return FALSE; 712 731 bfd_get_symcount (abfd) = symcount; 713 732 } 714 733 715 return true;734 return TRUE; 716 735 } 717 736 … … 721 740 constructors by name. */ 722 741 723 b oolean742 bfd_boolean 724 743 _bfd_generic_link_add_symbols (abfd, info) 725 744 bfd *abfd; 726 745 struct bfd_link_info *info; 727 746 { 728 return generic_link_add_symbols (abfd, info, false);747 return generic_link_add_symbols (abfd, info, FALSE); 729 748 } 730 749 … … 736 755 for which gcc uses collect2 and do not support stabs. */ 737 756 738 b oolean757 bfd_boolean 739 758 _bfd_generic_link_add_symbols_collect (abfd, info) 740 759 bfd *abfd; 741 760 struct bfd_link_info *info; 742 761 { 743 return generic_link_add_symbols (abfd, info, true); 762 return generic_link_add_symbols (abfd, info, TRUE); 763 } 764 765 /* Indicate that we are only retrieving symbol values from this 766 section. We want the symbols to act as though the values in the 767 file are absolute. */ 768 769 void 770 _bfd_generic_link_just_syms (sec, info) 771 asection *sec; 772 struct bfd_link_info *info ATTRIBUTE_UNUSED; 773 { 774 sec->output_section = bfd_abs_section_ptr; 775 sec->output_offset = sec->vma; 744 776 } 745 777 746 778 /* Add symbols from an object file to the global hash table. */ 747 779 748 static b oolean780 static bfd_boolean 749 781 generic_link_add_symbols (abfd, info, collect) 750 782 bfd *abfd; 751 783 struct bfd_link_info *info; 752 b oolean collect;753 { 754 b oolean ret;784 bfd_boolean collect; 785 { 786 bfd_boolean ret; 755 787 756 788 switch (bfd_get_format (abfd)) … … 768 800 default: 769 801 bfd_set_error (bfd_error_wrong_format); 770 ret = false;802 ret = FALSE; 771 803 } 772 804 … … 776 808 /* Add symbols from an object file to the global hash table. */ 777 809 778 static b oolean810 static bfd_boolean 779 811 generic_link_add_object_symbols (abfd, info, collect) 780 812 bfd *abfd; 781 813 struct bfd_link_info *info; 782 boolean collect; 783 { 814 bfd_boolean collect; 815 { 816 bfd_size_type symcount; 817 struct symbol_cache_entry **outsyms; 818 784 819 if (! generic_link_read_symbols (abfd)) 785 return false; 786 return generic_link_add_symbol_list (abfd, info, 787 _bfd_generic_link_get_symcount (abfd), 788 _bfd_generic_link_get_symbols (abfd), 789 collect); 820 return FALSE; 821 symcount = _bfd_generic_link_get_symcount (abfd); 822 outsyms = _bfd_generic_link_get_symbols (abfd); 823 return generic_link_add_symbol_list (abfd, info, symcount, outsyms, collect); 790 824 } 791 825 … … 799 833 { 800 834 struct archive_list *next; 801 int indx;835 unsigned int indx; 802 836 }; 803 837 … … 820 854 static struct bfd_hash_entry *archive_hash_newfunc 821 855 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 822 static b oolean archive_hash_table_init856 static bfd_boolean archive_hash_table_init 823 857 PARAMS ((struct archive_hash_table *, 824 858 struct bfd_hash_entry *(*) (struct bfd_hash_entry *, … … 859 893 /* Initialize an archive hash table. */ 860 894 861 static b oolean895 static bfd_boolean 862 896 archive_hash_table_init (table, newfunc) 863 897 struct archive_hash_table *table; … … 899 933 900 934 The CHECKFN argument is used to see if an object file should be 901 included. CHECKFN should set *PNEEDED to trueif the object file935 included. CHECKFN should set *PNEEDED to TRUE if the object file 902 936 should be included, and must also call the bfd_link_info 903 937 add_archive_element callback function and handle adding the symbols 904 to the global hash table. CHECKFN should only return falseif some938 to the global hash table. CHECKFN should only return FALSE if some 905 939 sort of error occurs. 906 940 … … 916 950 object file to be included. */ 917 951 918 b oolean952 bfd_boolean 919 953 _bfd_generic_link_add_archive_symbols (abfd, info, checkfn) 920 954 bfd *abfd; 921 955 struct bfd_link_info *info; 922 b oolean (*checkfn) PARAMS ((bfd *, struct bfd_link_info *,923 956 bfd_boolean (*checkfn) 957 PARAMS ((bfd *, struct bfd_link_info *, bfd_boolean *pneeded)); 924 958 { 925 959 carsym *arsyms; … … 928 962 int pass; 929 963 struct archive_hash_table arsym_hash; 930 int indx;964 unsigned int indx; 931 965 struct bfd_link_hash_entry **pundef; 932 966 … … 935 969 /* An empty archive is a special case. */ 936 970 if (bfd_openr_next_archived_file (abfd, (bfd *) NULL) == NULL) 937 return true;971 return TRUE; 938 972 bfd_set_error (bfd_error_no_armap); 939 return false;973 return FALSE; 940 974 } 941 975 … … 946 980 this archive, we build a hash table of the symbols. */ 947 981 if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc)) 948 return false;982 return FALSE; 949 983 for (arsym = arsyms, indx = 0; arsym < arsym_end; arsym++, indx++) 950 984 { … … 952 986 struct archive_list *l, **pp; 953 987 954 arh = archive_hash_lookup (&arsym_hash, arsym->name, true, false);988 arh = archive_hash_lookup (&arsym_hash, arsym->name, TRUE, FALSE); 955 989 if (arh == (struct archive_hash_entry *) NULL) 956 990 goto error_return; … … 1004 1038 1005 1039 /* Look for this symbol in the archive symbol map. */ 1006 arh = archive_hash_lookup (&arsym_hash, h->root.string, false, false);1040 arh = archive_hash_lookup (&arsym_hash, h->root.string, FALSE, FALSE); 1007 1041 if (arh == (struct archive_hash_entry *) NULL) 1008 1042 { 1009 pundef = &(*pundef)->next; 1010 continue; 1043 /* If we haven't found the exact symbol we're looking for, 1044 let's look for its import thunk */ 1045 if (info->pei386_auto_import) 1046 { 1047 bfd_size_type amt = strlen (h->root.string) + 10; 1048 char *buf = (char *) bfd_malloc (amt); 1049 if (buf == NULL) 1050 return FALSE; 1051 1052 sprintf (buf, "__imp_%s", h->root.string); 1053 arh = archive_hash_lookup (&arsym_hash, buf, FALSE, FALSE); 1054 free(buf); 1055 } 1056 if (arh == (struct archive_hash_entry *) NULL) 1057 { 1058 pundef = &(*pundef)->next; 1059 continue; 1060 } 1011 1061 } 1012 1013 1062 /* Look at all the objects which define this symbol. */ 1014 1063 for (l = arh->defs; l != (struct archive_list *) NULL; l = l->next) 1015 1064 { 1016 1065 bfd *element; 1017 b oolean needed;1066 bfd_boolean needed; 1018 1067 1019 1068 /* If the symbol has gotten defined along the way, quit. */ … … 1064 1113 abfd->archive_pass = pass; 1065 1114 1066 return true;1115 return TRUE; 1067 1116 1068 1117 error_return: 1069 1118 archive_hash_table_free (&arsym_hash); 1070 return false;1119 return FALSE; 1071 1120 } 1072 1121 … … 1077 1126 for finding them. */ 1078 1127 1079 static b oolean1128 static bfd_boolean 1080 1129 generic_link_check_archive_element_no_collect (abfd, info, pneeded) 1081 1130 bfd *abfd; 1082 1131 struct bfd_link_info *info; 1083 b oolean *pneeded;1084 { 1085 return generic_link_check_archive_element (abfd, info, pneeded, false);1132 bfd_boolean *pneeded; 1133 { 1134 return generic_link_check_archive_element (abfd, info, pneeded, FALSE); 1086 1135 } 1087 1136 … … 1090 1139 symbol name, as collect2 does. */ 1091 1140 1092 static b oolean1141 static bfd_boolean 1093 1142 generic_link_check_archive_element_collect (abfd, info, pneeded) 1094 1143 bfd *abfd; 1095 1144 struct bfd_link_info *info; 1096 b oolean *pneeded;1097 { 1098 return generic_link_check_archive_element (abfd, info, pneeded, true);1145 bfd_boolean *pneeded; 1146 { 1147 return generic_link_check_archive_element (abfd, info, pneeded, TRUE); 1099 1148 } 1100 1149 … … 1102 1151 constructors. */ 1103 1152 1104 static b oolean1153 static bfd_boolean 1105 1154 generic_link_check_archive_element (abfd, info, pneeded, collect) 1106 1155 bfd *abfd; 1107 1156 struct bfd_link_info *info; 1108 b oolean *pneeded;1109 b oolean collect;1157 bfd_boolean *pneeded; 1158 bfd_boolean collect; 1110 1159 { 1111 1160 asymbol **pp, **ppend; 1112 1161 1113 *pneeded = false;1162 *pneeded = FALSE; 1114 1163 1115 1164 if (! generic_link_read_symbols (abfd)) 1116 return false;1165 return FALSE; 1117 1166 1118 1167 pp = _bfd_generic_link_get_symbols (abfd); … … 1135 1184 a reference when pulling files out of an archive. See the 1136 1185 SVR4 ABI, p. 4-27. */ 1137 h = bfd_link_hash_lookup (info->hash, bfd_asymbol_name (p), false,1138 false, true);1186 h = bfd_link_hash_lookup (info->hash, bfd_asymbol_name (p), FALSE, 1187 FALSE, TRUE); 1139 1188 if (h == (struct bfd_link_hash_entry *) NULL 1140 1189 || (h->type != bfd_link_hash_undefined … … 1152 1201 if (! (*info->callbacks->add_archive_element) (info, abfd, 1153 1202 bfd_asymbol_name (p))) 1154 return false;1203 return FALSE; 1155 1204 symcount = _bfd_generic_link_get_symcount (abfd); 1156 1205 symbols = _bfd_generic_link_get_symbols (abfd); 1157 1206 if (! generic_link_add_symbol_list (abfd, info, symcount, 1158 1207 symbols, collect)) 1159 return false;1160 *pneeded = true;1161 return true;1208 return FALSE; 1209 *pneeded = TRUE; 1210 return TRUE; 1162 1211 } 1163 1212 … … 1178 1227 if (! (*info->callbacks->add_archive_element) 1179 1228 (info, abfd, bfd_asymbol_name (p))) 1180 return false;1181 *pneeded = true;1182 return true;1229 return FALSE; 1230 *pneeded = TRUE; 1231 return TRUE; 1183 1232 } 1184 1233 … … 1196 1245 sizeof (struct bfd_link_hash_common_entry))); 1197 1246 if (h->u.c.p == NULL) 1198 return false;1247 return FALSE; 1199 1248 1200 1249 size = bfd_asymbol_value (p); … … 1225 1274 1226 1275 /* This archive element is not needed. */ 1227 return true;1276 return TRUE; 1228 1277 } 1229 1278 … … 1231 1280 is the object file. INFO is the linker information. SYMBOL_COUNT 1232 1281 is the number of symbols. SYMBOLS is the list of symbols. COLLECT 1233 is trueif constructors should be automatically collected by name1282 is TRUE if constructors should be automatically collected by name 1234 1283 as is done by collect2. */ 1235 1284 1236 static b oolean1285 static bfd_boolean 1237 1286 generic_link_add_symbol_list (abfd, info, symbol_count, symbols, collect) 1238 1287 bfd *abfd; … … 1240 1289 bfd_size_type symbol_count; 1241 1290 asymbol **symbols; 1242 b oolean collect;1291 bfd_boolean collect; 1243 1292 { 1244 1293 asymbol **pp, **ppend; … … 1264 1313 const char *string; 1265 1314 struct generic_link_hash_entry *h; 1315 struct bfd_link_hash_entry *bh; 1266 1316 1267 1317 name = bfd_asymbol_name (p); … … 1285 1335 string = NULL; 1286 1336 1287 h = NULL;1337 bh = NULL; 1288 1338 if (! (_bfd_generic_link_add_one_symbol 1289 1339 (info, abfd, name, p->flags, bfd_get_section (p), 1290 p->value, string, false, collect,1291 (struct bfd_link_hash_entry **) &h)))1292 return false;1340 p->value, string, FALSE, collect, &bh))) 1341 return FALSE; 1342 h = (struct generic_link_hash_entry *) bh; 1293 1343 1294 1344 /* If this is a constructor symbol, and the linker didn't do … … 1336 1386 } 1337 1387 1338 return true;1388 return TRUE; 1339 1389 } 1340 1390 … … 1401 1451 /* DEF_ROW */ {DEF, DEF, DEF, MDEF, DEF, CDEF, MDEF, CYCLE }, 1402 1452 /* DEFW_ROW */ {DEFW, DEFW, DEFW, NOACT, NOACT, NOACT, NOACT, CYCLE }, 1403 /* COMMON_ROW */ {COM, COM, COM, CREF, C REF,BIG, REFC, WARNC },1453 /* COMMON_ROW */ {COM, COM, COM, CREF, COM, BIG, REFC, WARNC }, 1404 1454 /* INDR_ROW */ {IND, IND, IND, MDEF, IND, CIND, MIND, CYCLE }, 1405 /* WARN_ROW */ {MWARN, WARN, WARN, CWARN, CWARN, WARN, CWARN, MWARN},1455 /* WARN_ROW */ {MWARN, WARN, WARN, CWARN, CWARN, WARN, CWARN, NOACT }, 1406 1456 /* SET_ROW */ {SET, SET, SET, SET, SET, SET, CYCLE, CYCLE } 1407 1457 }; … … 1464 1514 the name of the symbol to indirect to, or a warning symbol, in 1465 1515 which case it is the warning string. 1466 COPY is trueif NAME or STRING must be copied into locally1516 COPY is TRUE if NAME or STRING must be copied into locally 1467 1517 allocated memory if they need to be saved. 1468 COLLECT is trueif we should automatically collect gcc constructor1518 COLLECT is TRUE if we should automatically collect gcc constructor 1469 1519 or destructor names as collect2 does. 1470 1520 HASHP, if not NULL, is a place to store the created hash table … … 1472 1522 the hash table entry, and stored it in *HASHP. */ 1473 1523 1474 b oolean1524 bfd_boolean 1475 1525 _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, 1476 1526 string, copy, collect, hashp) … … 1482 1532 bfd_vma value; 1483 1533 const char *string; 1484 b oolean copy;1485 b oolean collect;1534 bfd_boolean copy; 1535 bfd_boolean collect; 1486 1536 struct bfd_link_hash_entry **hashp; 1487 1537 { 1488 1538 enum link_row row; 1489 1539 struct bfd_link_hash_entry *h; 1490 b oolean cycle;1540 bfd_boolean cycle; 1491 1541 1492 1542 if (bfd_is_ind_section (section) … … 1516 1566 { 1517 1567 if (row == UNDEF_ROW || row == UNDEFW_ROW) 1518 h = bfd_wrapped_link_hash_lookup (abfd, info, name, true, copy, false);1568 h = bfd_wrapped_link_hash_lookup (abfd, info, name, TRUE, copy, FALSE); 1519 1569 else 1520 h = bfd_link_hash_lookup (info->hash, name, true, copy, false);1570 h = bfd_link_hash_lookup (info->hash, name, TRUE, copy, FALSE); 1521 1571 if (h == NULL) 1522 1572 { 1523 1573 if (hashp != NULL) 1524 1574 *hashp = NULL; 1525 return false;1575 return FALSE; 1526 1576 } 1527 1577 } … … 1529 1579 if (info->notice_all 1530 1580 || (info->notice_hash != (struct bfd_hash_table *) NULL 1531 && (bfd_hash_lookup (info->notice_hash, name, false, false)1581 && (bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) 1532 1582 != (struct bfd_hash_entry *) NULL))) 1533 1583 { 1534 1584 if (! (*info->callbacks->notice) (info, h->root.string, abfd, section, 1535 1585 value)) 1536 return false;1586 return FALSE; 1537 1587 } 1538 1588 … … 1544 1594 enum link_action action; 1545 1595 1546 cycle = false;1596 cycle = FALSE; 1547 1597 action = link_action[(int) row][(int) h->type]; 1548 1598 switch (action) … … 1576 1626 h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size, 1577 1627 abfd, bfd_link_hash_defined, (bfd_vma) 0))) 1578 return false;1628 return FALSE; 1579 1629 /* Fall through. */ 1580 1630 case DEF: … … 1634 1684 1635 1685 if (! ((*info->callbacks->constructor) 1636 (info, 1637 c == 'I' ? true : false, 1686 (info, c == 'I', 1638 1687 h->root.string, abfd, section, value))) 1639 return false;1688 return FALSE; 1640 1689 } 1641 1690 } … … 1655 1704 sizeof (struct bfd_link_hash_common_entry))); 1656 1705 if (h->u.c.p == NULL) 1657 return false;1706 return FALSE; 1658 1707 1659 1708 h->u.c.size = value; … … 1704 1753 /* We have found a common definition for a symbol which 1705 1754 already had a common definition. Use the maximum of the 1706 two sizes . */1755 two sizes, and use the section required by the larger symbol. */ 1707 1756 BFD_ASSERT (h->type == bfd_link_hash_common); 1708 1757 if (! ((*info->callbacks->multiple_common) … … 1710 1759 h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size, 1711 1760 abfd, bfd_link_hash_common, value))) 1712 return false;1761 return FALSE; 1713 1762 if (value > h->u.c.size) 1714 1763 { … … 1723 1772 power = 4; 1724 1773 h->u.c.p->alignment_power = power; 1774 1775 /* Some systems have special treatment for small commons, 1776 hence we want to select the section used by the larger 1777 symbol. This makes sure the symbol does not go in a 1778 small common section if it is now too large. */ 1779 if (section == bfd_com_section_ptr) 1780 { 1781 h->u.c.p->section 1782 = bfd_make_section_old_way (abfd, "COMMON"); 1783 h->u.c.p->section->flags = SEC_ALLOC; 1784 } 1785 else if (section->owner != abfd) 1786 { 1787 h->u.c.p->section 1788 = bfd_make_section_old_way (abfd, section->name); 1789 h->u.c.p->section->flags = SEC_ALLOC; 1790 } 1791 else 1792 h->u.c.p->section = section; 1725 1793 } 1726 1794 break; … … 1742 1810 (info, h->root.string, obfd, h->type, (bfd_vma) 0, 1743 1811 abfd, bfd_link_hash_common, value))) 1744 return false;1812 return FALSE; 1745 1813 } 1746 1814 break; … … 1754 1822 case MDEF: 1755 1823 /* Handle a multiple definition. */ 1756 { 1757 asection *msec = NULL; 1758 bfd_vma mval = 0; 1759 1760 switch (h->type) 1761 { 1762 case bfd_link_hash_defined: 1763 msec = h->u.def.section; 1764 mval = h->u.def.value; 1824 if (!info->allow_multiple_definition) 1825 { 1826 asection *msec = NULL; 1827 bfd_vma mval = 0; 1828 1829 switch (h->type) 1830 { 1831 case bfd_link_hash_defined: 1832 msec = h->u.def.section; 1833 mval = h->u.def.value; 1834 break; 1835 case bfd_link_hash_indirect: 1836 msec = bfd_ind_section_ptr; 1837 mval = 0; 1838 break; 1839 default: 1840 abort (); 1841 } 1842 1843 /* Ignore a redefinition of an absolute symbol to the 1844 same value; it's harmless. */ 1845 if (h->type == bfd_link_hash_defined 1846 && bfd_is_abs_section (msec) 1847 && bfd_is_abs_section (section) 1848 && value == mval) 1765 1849 break; 1766 case bfd_link_hash_indirect: 1767 msec = bfd_ind_section_ptr; 1768 mval = 0; 1769 break; 1770 default: 1771 abort (); 1772 } 1773 1774 /* Ignore a redefinition of an absolute symbol to the same 1775 value; it's harmless. */ 1776 if (h->type == bfd_link_hash_defined 1777 && bfd_is_abs_section (msec) 1778 && bfd_is_abs_section (section) 1779 && value == mval) 1780 break; 1781 1782 if (! ((*info->callbacks->multiple_definition) 1783 (info, h->root.string, msec->owner, msec, mval, abfd, 1784 section, value))) 1785 return false; 1786 } 1850 1851 if (! ((*info->callbacks->multiple_definition) 1852 (info, h->root.string, msec->owner, msec, mval, 1853 abfd, section, value))) 1854 return FALSE; 1855 } 1787 1856 break; 1788 1857 … … 1794 1863 h->u.c.p->section->owner, bfd_link_hash_common, h->u.c.size, 1795 1864 abfd, bfd_link_hash_indirect, (bfd_vma) 0))) 1796 return false;1865 return FALSE; 1797 1866 /* Fall through. */ 1798 1867 case IND: … … 1803 1872 /* STRING is the name of the symbol we want to indirect 1804 1873 to. */ 1805 inh = bfd_wrapped_link_hash_lookup (abfd, info, string, true,1806 copy, false);1874 inh = bfd_wrapped_link_hash_lookup (abfd, info, string, TRUE, 1875 copy, FALSE); 1807 1876 if (inh == (struct bfd_link_hash_entry *) NULL) 1808 return false;1877 return FALSE; 1809 1878 if (inh->type == bfd_link_hash_indirect 1810 1879 && inh->u.i.link == h) 1811 1880 { 1812 1881 (*_bfd_error_handler) 1813 (_("%s: indirect symbol `%s' to `%s' is a loop"), 1814 bfd_ get_filename (abfd), name, string);1882 (_("%s: indirect symbol `%s' to `%s' is a loop"), 1883 bfd_archive_filename (abfd), name, string); 1815 1884 bfd_set_error (bfd_error_invalid_operation); 1816 return false;1885 return FALSE; 1817 1886 } 1818 1887 if (inh->type == bfd_link_hash_new) … … 1829 1898 { 1830 1899 row = UNDEF_ROW; 1831 cycle = true;1900 cycle = TRUE; 1832 1901 } 1833 1902 … … 1841 1910 if (! (*info->callbacks->add_to_set) (info, h, BFD_RELOC_CTOR, 1842 1911 abfd, section, value)) 1843 return false;1912 return FALSE; 1844 1913 break; 1845 1914 … … 1852 1921 (asection *) NULL, 1853 1922 (bfd_vma) 0)) 1854 return false;1923 return FALSE; 1855 1924 /* Only issue a warning once. */ 1856 1925 h->u.i.warning = NULL; … … 1860 1929 /* Try again with the referenced symbol. */ 1861 1930 h = h->u.i.link; 1862 cycle = true;1931 cycle = TRUE; 1863 1932 break; 1864 1933 … … 1868 1937 h->next = h; 1869 1938 h = h->u.i.link; 1870 cycle = true;1939 cycle = TRUE; 1871 1940 break; 1872 1941 … … 1876 1945 hash_entry_bfd (h), 1877 1946 (asection *) NULL, (bfd_vma) 0)) 1878 return false;1947 return FALSE; 1879 1948 break; 1880 1949 … … 1891 1960 (asection *) NULL, 1892 1961 (bfd_vma) 0)) 1893 return false;1962 return FALSE; 1894 1963 break; 1895 1964 } … … 1906 1975 h->root.string))); 1907 1976 if (sub == NULL) 1908 return false;1977 return FALSE; 1909 1978 *sub = *h; 1910 1979 sub->type = bfd_link_hash_warning; … … 1915 1984 { 1916 1985 char *w; 1917 1918 w = bfd_hash_allocate (&info->hash->table, 1919 strlen (string) + 1);1986 size_t len = strlen (string) + 1; 1987 1988 w = bfd_hash_allocate (&info->hash->table, len); 1920 1989 if (w == NULL) 1921 return false;1922 strcpy (w, string);1990 return FALSE; 1991 memcpy (w, string, len); 1923 1992 sub->u.i.warning = w; 1924 1993 } … … 1935 2004 while (cycle); 1936 2005 1937 return true;2006 return TRUE; 1938 2007 } 1939 2008 … … 1941 2010 /* Generic final link routine. */ 1942 2011 1943 b oolean2012 bfd_boolean 1944 2013 _bfd_generic_final_link (abfd, info) 1945 2014 bfd *abfd; … … 1960 2029 for (p = o->link_order_head; p != NULL; p = p->next) 1961 2030 if (p->type == bfd_indirect_link_order) 1962 p->u.indirect.section->linker_mark = true;2031 p->u.indirect.section->linker_mark = TRUE; 1963 2032 1964 2033 /* Build the output symbol table. */ 1965 2034 for (sub = info->input_bfds; sub != (bfd *) NULL; sub = sub->link_next) 1966 2035 if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc)) 1967 return false;2036 return FALSE; 1968 2037 1969 2038 /* Accumulate the global symbols. */ … … 1979 2048 code still expects one. */ 1980 2049 if (! generic_add_output_symbol (abfd, &outsymalloc, NULL)) 1981 return false;2050 return FALSE; 1982 2051 1983 2052 if (info->relocateable) … … 2010 2079 input_section); 2011 2080 if (relsize < 0) 2012 return false;2013 relocs = (arelent **) bfd_malloc (( size_t) relsize);2081 return FALSE; 2082 relocs = (arelent **) bfd_malloc ((bfd_size_type) relsize); 2014 2083 if (!relocs && relsize != 0) 2015 return false;2084 return FALSE; 2016 2085 symbols = _bfd_generic_link_get_symbols (input_bfd); 2017 2086 reloc_count = bfd_canonicalize_reloc (input_bfd, … … 2019 2088 relocs, 2020 2089 symbols); 2090 free (relocs); 2021 2091 if (reloc_count < 0) 2022 return false;2092 return FALSE; 2023 2093 BFD_ASSERT ((unsigned long) reloc_count 2024 2094 == input_section->reloc_count); 2025 2095 o->reloc_count += reloc_count; 2026 free (relocs);2027 2096 } 2028 2097 } 2029 2098 if (o->reloc_count > 0) 2030 2099 { 2031 o->orelocation = ((arelent **) 2032 bfd_alloc (abfd, 2033 (o->reloc_count 2034 * sizeof (arelent *)))); 2100 bfd_size_type amt; 2101 2102 amt = o->reloc_count; 2103 amt *= sizeof (arelent *); 2104 o->orelocation = (arelent **) bfd_alloc (abfd, amt); 2035 2105 if (!o->orelocation) 2036 return false;2106 return FALSE; 2037 2107 o->flags |= SEC_RELOC; 2038 2108 /* Reset the count so that it can be used as an index … … 2057 2127 case bfd_symbol_reloc_link_order: 2058 2128 if (! _bfd_generic_reloc_link_order (abfd, info, o, p)) 2059 return false;2129 return FALSE; 2060 2130 break; 2061 2131 case bfd_indirect_link_order: 2062 if (! default_indirect_link_order (abfd, info, o, p, true))2063 return false;2132 if (! default_indirect_link_order (abfd, info, o, p, TRUE)) 2133 return FALSE; 2064 2134 break; 2065 2135 default: 2066 2136 if (! _bfd_default_link_order (abfd, info, o, p)) 2067 return false;2137 return FALSE; 2068 2138 break; 2069 2139 } … … 2071 2141 } 2072 2142 2073 return true;2143 return TRUE; 2074 2144 } 2075 2145 2076 2146 /* Add an output symbol to the output BFD. */ 2077 2147 2078 static b oolean2148 static bfd_boolean 2079 2149 generic_add_output_symbol (output_bfd, psymalloc, sym) 2080 2150 bfd *output_bfd; … … 2085 2155 { 2086 2156 asymbol **newsyms; 2157 bfd_size_type amt; 2087 2158 2088 2159 if (*psymalloc == 0) … … 2090 2161 else 2091 2162 *psymalloc *= 2; 2092 newsyms = (asymbol **) bfd_realloc (bfd_get_outsymbols (output_bfd), 2093 *psymalloc * sizeof (asymbol *)); 2163 amt = *psymalloc; 2164 amt *= sizeof (asymbol *); 2165 newsyms = (asymbol **) bfd_realloc (bfd_get_outsymbols (output_bfd), amt); 2094 2166 if (newsyms == (asymbol **) NULL) 2095 return false;2167 return FALSE; 2096 2168 bfd_get_outsymbols (output_bfd) = newsyms; 2097 2169 } … … 2101 2173 ++ bfd_get_symcount (output_bfd); 2102 2174 2103 return true;2175 return TRUE; 2104 2176 } 2105 2177 2106 2178 /* Handle the symbols for an input BFD. */ 2107 2179 2108 b oolean2180 bfd_boolean 2109 2181 _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc) 2110 2182 bfd *output_bfd; … … 2117 2189 2118 2190 if (! generic_link_read_symbols (input_bfd)) 2119 return false;2191 return FALSE; 2120 2192 2121 2193 /* Create a filename symbol if we are supposed to. */ … … 2134 2206 newsym = bfd_make_empty_symbol (input_bfd); 2135 2207 if (!newsym) 2136 return false;2208 return FALSE; 2137 2209 newsym->name = input_bfd->filename; 2138 2210 newsym->value = 0; … … 2142 2214 if (! generic_add_output_symbol (output_bfd, psymalloc, 2143 2215 newsym)) 2144 return false;2216 return FALSE; 2145 2217 2146 2218 break; … … 2157 2229 asymbol *sym; 2158 2230 struct generic_link_hash_entry *h; 2159 b oolean output;2231 bfd_boolean output; 2160 2232 2161 2233 h = (struct generic_link_hash_entry *) NULL; … … 2188 2260 bfd_wrapped_link_hash_lookup (output_bfd, info, 2189 2261 bfd_asymbol_name (sym), 2190 false, false, true));2262 FALSE, FALSE, TRUE)); 2191 2263 else 2192 2264 h = _bfd_generic_link_hash_lookup (_bfd_generic_hash_table (info), 2193 2265 bfd_asymbol_name (sym), 2194 false, false, true);2266 FALSE, FALSE, TRUE); 2195 2267 2196 2268 if (h != (struct generic_link_hash_entry *) NULL) … … 2256 2328 || (info->strip == strip_some 2257 2329 && (bfd_hash_lookup (info->keep_hash, bfd_asymbol_name (sym), 2258 false, false)2330 FALSE, FALSE) 2259 2331 == (struct bfd_hash_entry *) NULL))) 2260 output = false;2332 output = FALSE; 2261 2333 else if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0) 2262 2334 { … … 2267 2339 if (bfd_asymbol_bfd (sym) == input_bfd 2268 2340 && (sym->flags & BSF_NOT_AT_END) != 0) 2269 output = true;2341 output = TRUE; 2270 2342 else 2271 output = false;2343 output = FALSE; 2272 2344 } 2273 2345 else if (bfd_is_ind_section (sym->section)) 2274 output = false;2346 output = FALSE; 2275 2347 else if ((sym->flags & BSF_DEBUGGING) != 0) 2276 2348 { 2277 2349 if (info->strip == strip_none) 2278 output = true;2350 output = TRUE; 2279 2351 else 2280 output = false;2352 output = FALSE; 2281 2353 } 2282 2354 else if (bfd_is_und_section (sym->section) 2283 2355 || bfd_is_com_section (sym->section)) 2284 output = false;2356 output = FALSE; 2285 2357 else if ((sym->flags & BSF_LOCAL) != 0) 2286 2358 { 2287 2359 if ((sym->flags & BSF_WARNING) != 0) 2288 output = false;2360 output = FALSE; 2289 2361 else 2290 2362 { … … 2293 2365 default: 2294 2366 case discard_all: 2295 output = false;2367 output = FALSE; 2296 2368 break; 2369 case discard_sec_merge: 2370 output = TRUE; 2371 if (info->relocateable 2372 || ! (sym->section->flags & SEC_MERGE)) 2373 break; 2374 /* FALLTHROUGH */ 2297 2375 case discard_l: 2298 2376 if (bfd_is_local_label (input_bfd, sym)) 2299 output = false;2377 output = FALSE; 2300 2378 else 2301 output = true;2379 output = TRUE; 2302 2380 break; 2303 2381 case discard_none: 2304 output = true;2382 output = TRUE; 2305 2383 break; 2306 2384 } … … 2310 2388 { 2311 2389 if (info->strip != strip_all) 2312 output = true;2390 output = TRUE; 2313 2391 else 2314 output = false;2392 output = FALSE; 2315 2393 } 2316 2394 else … … 2323 2401 field set. */ 2324 2402 if ((sym->section->flags & SEC_HAS_CONTENTS) != 0 2325 && sym->section->linker_mark == false)2326 output = false;2403 && ! sym->section->linker_mark) 2404 output = FALSE; 2327 2405 2328 2406 if (output) 2329 2407 { 2330 2408 if (! generic_add_output_symbol (output_bfd, psymalloc, sym)) 2331 return false;2409 return FALSE; 2332 2410 if (h != (struct generic_link_hash_entry *) NULL) 2333 h->written = true;2411 h->written = TRUE; 2334 2412 } 2335 2413 } 2336 2414 2337 return true;2415 return TRUE; 2338 2416 } 2339 2417 … … 2404 2482 This is called for each symbol in the hash table. */ 2405 2483 2406 b oolean2484 bfd_boolean 2407 2485 _bfd_generic_link_write_global_symbol (h, data) 2408 2486 struct generic_link_hash_entry *h; … … 2413 2491 asymbol *sym; 2414 2492 2493 if (h->root.type == bfd_link_hash_warning) 2494 h = (struct generic_link_hash_entry *) h->root.u.i.link; 2495 2415 2496 if (h->written) 2416 return true;2417 2418 h->written = true;2497 return TRUE; 2498 2499 h->written = TRUE; 2419 2500 2420 2501 if (wginfo->info->strip == strip_all 2421 2502 || (wginfo->info->strip == strip_some 2422 2503 && bfd_hash_lookup (wginfo->info->keep_hash, h->root.root.string, 2423 false, false) == NULL))2424 return true;2504 FALSE, FALSE) == NULL)) 2505 return TRUE; 2425 2506 2426 2507 if (h->sym != (asymbol *) NULL) … … 2430 2511 sym = bfd_make_empty_symbol (wginfo->output_bfd); 2431 2512 if (!sym) 2432 return false;2513 return FALSE; 2433 2514 sym->name = h->root.root.string; 2434 2515 sym->flags = 0; … … 2446 2527 } 2447 2528 2448 return true;2529 return TRUE; 2449 2530 } 2450 2531 2451 2532 /* Create a relocation. */ 2452 2533 2453 b oolean2534 bfd_boolean 2454 2535 _bfd_generic_reloc_link_order (abfd, info, sec, link_order) 2455 2536 bfd *abfd; … … 2465 2546 abort (); 2466 2547 2467 r = (arelent *) bfd_alloc (abfd, sizeof (arelent));2548 r = (arelent *) bfd_alloc (abfd, (bfd_size_type) sizeof (arelent)); 2468 2549 if (r == (arelent *) NULL) 2469 return false;2550 return FALSE; 2470 2551 2471 2552 r->address = link_order->offset; … … 2474 2555 { 2475 2556 bfd_set_error (bfd_error_bad_value); 2476 return false;2557 return FALSE; 2477 2558 } 2478 2559 … … 2487 2568 bfd_wrapped_link_hash_lookup (abfd, info, 2488 2569 link_order->u.reloc.p->u.name, 2489 false, false, true));2570 FALSE, FALSE, TRUE)); 2490 2571 if (h == (struct generic_link_hash_entry *) NULL 2491 2572 || ! h->written) … … 2494 2575 (info, link_order->u.reloc.p->u.name, 2495 2576 (bfd *) NULL, (asection *) NULL, (bfd_vma) 0))) 2496 return false;2577 return FALSE; 2497 2578 bfd_set_error (bfd_error_bad_value); 2498 return false;2579 return FALSE; 2499 2580 } 2500 2581 r->sym_ptr_ptr = &h->sym; … … 2510 2591 bfd_reloc_status_type rstat; 2511 2592 bfd_byte *buf; 2512 boolean ok; 2593 bfd_boolean ok; 2594 file_ptr loc; 2513 2595 2514 2596 size = bfd_get_reloc_size (r->howto); 2515 2597 buf = (bfd_byte *) bfd_zmalloc (size); 2516 2598 if (buf == (bfd_byte *) NULL) 2517 return false;2599 return FALSE; 2518 2600 rstat = _bfd_relocate_contents (r->howto, abfd, 2519 link_order->u.reloc.p->addend, buf); 2601 (bfd_vma) link_order->u.reloc.p->addend, 2602 buf); 2520 2603 switch (rstat) 2521 2604 { … … 2535 2618 { 2536 2619 free (buf); 2537 return false;2620 return FALSE; 2538 2621 } 2539 2622 break; 2540 2623 } 2541 ok = bfd_set_section_contents (abfd, sec, (PTR) buf, 2542 (file_ptr) 2543 (link_order->offset * 2544 bfd_octets_per_byte (abfd)), size); 2624 loc = link_order->offset * bfd_octets_per_byte (abfd); 2625 ok = bfd_set_section_contents (abfd, sec, (PTR) buf, loc, 2626 (bfd_size_type) size); 2545 2627 free (buf); 2546 2628 if (! ok) 2547 return false;2629 return FALSE; 2548 2630 2549 2631 r->addend = 0; … … 2553 2635 ++sec->reloc_count; 2554 2636 2555 return true;2637 return TRUE; 2556 2638 } 2557 2639 … … 2564 2646 asection *section; 2565 2647 { 2648 bfd_size_type amt = sizeof (struct bfd_link_order); 2566 2649 struct bfd_link_order *new; 2567 2650 2568 new = ((struct bfd_link_order *) 2569 bfd_alloc (abfd, sizeof (struct bfd_link_order))); 2651 new = (struct bfd_link_order *) bfd_zalloc (abfd, amt); 2570 2652 if (!new) 2571 2653 return NULL; 2572 2654 2573 2655 new->type = bfd_undefined_link_order; 2574 new->offset = 0;2575 new->size = 0;2576 new->next = (struct bfd_link_order *) NULL;2577 2656 2578 2657 if (section->link_order_tail != (struct bfd_link_order *) NULL) … … 2589 2668 of how the particular backends generates relocs. */ 2590 2669 2591 b oolean2670 bfd_boolean 2592 2671 _bfd_default_link_order (abfd, info, sec, link_order) 2593 2672 bfd *abfd; … … 2605 2684 case bfd_indirect_link_order: 2606 2685 return default_indirect_link_order (abfd, info, sec, link_order, 2607 false); 2608 case bfd_fill_link_order: 2609 return default_fill_link_order (abfd, info, sec, link_order); 2686 FALSE); 2610 2687 case bfd_data_link_order: 2611 return bfd_set_section_contents (abfd, sec, 2612 (PTR) link_order->u.data.contents, 2613 (file_ptr) 2614 (link_order->offset * 2615 bfd_octets_per_byte (abfd)), 2616 link_order->size); 2617 } 2618 } 2619 2620 /* Default routine to handle a bfd_fill_link_order. */ 2621 2622 static boolean 2623 default_fill_link_order (abfd, info, sec, link_order) 2688 return default_data_link_order (abfd, info, sec, link_order); 2689 } 2690 } 2691 2692 /* Default routine to handle a bfd_data_link_order. */ 2693 2694 static bfd_boolean 2695 default_data_link_order (abfd, info, sec, link_order) 2624 2696 bfd *abfd; 2625 2697 struct bfd_link_info *info ATTRIBUTE_UNUSED; … … 2627 2699 struct bfd_link_order *link_order; 2628 2700 { 2629 size_tsize;2630 char *space;2631 size_t i;2632 int fill;2633 b oolean result;2701 bfd_size_type size; 2702 size_t fill_size; 2703 bfd_byte *fill; 2704 file_ptr loc; 2705 bfd_boolean result; 2634 2706 2635 2707 BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0); 2636 2708 2637 size = (size_t) link_order->size; 2638 space = (char *) bfd_malloc (size); 2639 if (space == NULL && size != 0) 2640 return false; 2641 2642 fill = link_order->u.fill.value; 2643 for (i = 0; i < size; i += 2) 2644 space[i] = fill >> 8; 2645 for (i = 1; i < size; i += 2) 2646 space[i] = fill; 2647 result = bfd_set_section_contents (abfd, sec, space, 2648 (file_ptr) 2649 (link_order->offset * 2650 bfd_octets_per_byte (abfd)), 2651 link_order->size); 2652 free (space); 2709 size = link_order->size; 2710 if (size == 0) 2711 return TRUE; 2712 2713 fill = link_order->u.data.contents; 2714 fill_size = link_order->u.data.size; 2715 if (fill_size != 0 && fill_size < size) 2716 { 2717 bfd_byte *p; 2718 fill = (bfd_byte *) bfd_malloc (size); 2719 if (fill == NULL) 2720 return FALSE; 2721 p = fill; 2722 if (fill_size == 1) 2723 memset (p, (int) link_order->u.data.contents[0], (size_t) size); 2724 else 2725 { 2726 do 2727 { 2728 memcpy (p, link_order->u.data.contents, fill_size); 2729 p += fill_size; 2730 size -= fill_size; 2731 } 2732 while (size >= fill_size); 2733 if (size != 0) 2734 memcpy (p, link_order->u.data.contents, (size_t) size); 2735 size = link_order->size; 2736 } 2737 } 2738 2739 loc = link_order->offset * bfd_octets_per_byte (abfd); 2740 result = bfd_set_section_contents (abfd, sec, fill, loc, size); 2741 2742 if (fill != link_order->u.data.contents) 2743 free (fill); 2653 2744 return result; 2654 2745 } … … 2656 2747 /* Default routine to handle a bfd_indirect_link_order. */ 2657 2748 2658 static b oolean2749 static bfd_boolean 2659 2750 default_indirect_link_order (output_bfd, info, output_section, link_order, 2660 2751 generic_linker) … … 2663 2754 asection *output_section; 2664 2755 struct bfd_link_order *link_order; 2665 b oolean generic_linker;2756 bfd_boolean generic_linker; 2666 2757 { 2667 2758 asection *input_section; … … 2669 2760 bfd_byte *contents = NULL; 2670 2761 bfd_byte *new_contents; 2762 bfd_size_type sec_size; 2763 file_ptr loc; 2671 2764 2672 2765 BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0); 2673 2766 2674 2767 if (link_order->size == 0) 2675 return true;2768 return TRUE; 2676 2769 2677 2770 input_section = link_order->u.indirect.section; … … 2695 2788 bfd_get_target (input_bfd), bfd_get_target (output_bfd)); 2696 2789 bfd_set_error (bfd_error_wrong_format); 2697 return false;2790 return FALSE; 2698 2791 } 2699 2792 … … 2708 2801 different types of object files together. */ 2709 2802 if (! generic_link_read_symbols (input_bfd)) 2710 return false;2803 return FALSE; 2711 2804 2712 2805 /* Since we have been called by a specific linker, rather than … … 2740 2833 h = bfd_wrapped_link_hash_lookup (output_bfd, info, 2741 2834 bfd_asymbol_name (sym), 2742 false, false, true);2835 FALSE, FALSE, TRUE); 2743 2836 else 2744 2837 h = bfd_link_hash_lookup (info->hash, 2745 2838 bfd_asymbol_name (sym), 2746 false, false, true);2839 FALSE, FALSE, TRUE); 2747 2840 if (h != NULL) 2748 2841 set_symbol_from_hash (sym, h); … … 2752 2845 2753 2846 /* Get and relocate the section contents. */ 2754 contents = ((bfd_byte *)2755 bfd_malloc (bfd_section_size (input_bfd, input_section)));2756 if (contents == NULL && bfd_section_size (input_bfd, input_section)!= 0)2847 sec_size = bfd_section_size (input_bfd, input_section); 2848 contents = ((bfd_byte *) bfd_malloc (sec_size)); 2849 if (contents == NULL && sec_size != 0) 2757 2850 goto error_return; 2758 2851 new_contents = (bfd_get_relocated_section_contents … … 2763 2856 2764 2857 /* Output the section contents. */ 2858 loc = link_order->offset * bfd_octets_per_byte (output_bfd); 2765 2859 if (! bfd_set_section_contents (output_bfd, output_section, 2766 (PTR) new_contents, 2767 (file_ptr) 2768 (link_order->offset * 2769 bfd_octets_per_byte (output_bfd)), 2770 link_order->size)) 2860 (PTR) new_contents, loc, link_order->size)) 2771 2861 goto error_return; 2772 2862 2773 2863 if (contents != NULL) 2774 2864 free (contents); 2775 return true;2865 return TRUE; 2776 2866 2777 2867 error_return: 2778 2868 if (contents != NULL) 2779 2869 free (contents); 2780 return false;2870 return FALSE; 2781 2871 } 2782 2872 … … 2807 2897 2808 2898 SYNOPSIS 2809 b oolean bfd_link_split_section(bfd *abfd, asection *sec);2899 bfd_boolean bfd_link_split_section(bfd *abfd, asection *sec); 2810 2900 2811 2901 DESCRIPTION … … 2819 2909 */ 2820 2910 2821 b oolean2911 bfd_boolean 2822 2912 _bfd_generic_link_split_section (abfd, sec) 2823 2913 bfd *abfd ATTRIBUTE_UNUSED; 2824 2914 asection *sec ATTRIBUTE_UNUSED; 2825 2915 { 2826 return false;2827 } 2916 return FALSE; 2917 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.