Changeset 609 for branches/GNU/src/binutils/gas/symbols.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/gas/symbols.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* symbols.c -symbol table- 2 2 Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3 1999, 2000, 2001 3 1999, 2000, 2001, 2002, 2003 4 4 Free Software Foundation, Inc. 5 5 … … 23 23 /* #define DEBUG_SYMS / * to debug symbol list maintenance. */ 24 24 25 #include <ctype.h>26 27 25 #include "as.h" 28 26 27 #include "safe-ctype.h" 29 28 #include "obstack.h" /* For "symbols.h" */ 30 29 #include "subsegs.h" … … 62 61 struct obstack notes; 63 62 63 static char *save_symbol_name PARAMS ((const char *)); 64 64 static void fb_label_init PARAMS ((void)); 65 65 static long dollar_label_instance PARAMS ((long)); … … 67 67 68 68 static void print_binary PARAMS ((FILE *, const char *, expressionS *)); 69 static void report_op_error PARAMS ((symbolS *, symbolS *, symbolS *)); 69 70 70 71 /* Return a pointer to a new symbol. Die if we can't make a new … … 124 125 if (! symbols_case_sensitive) 125 126 { 126 unsigned char *s; 127 128 for (s = (unsigned char *) ret; *s != '\0'; s++) 129 if (islower (*s)) 130 *s = toupper (*s); 127 char *s; 128 129 for (s = ret; *s != '\0'; s++) 130 *s = TOUPPER (*s); 131 131 } 132 132 … … 208 208 209 209 static struct local_symbol * 210 local_symbol_make (name, section, offset, frag)210 local_symbol_make (name, section, value, frag) 211 211 const char *name; 212 212 segT section; 213 valueT offset;213 valueT value; 214 214 fragS *frag; 215 215 { … … 226 226 ret->lsy_section = section; 227 227 local_symbol_set_frag (ret, frag); 228 ret->lsy_ offset = offset;228 ret->lsy_value = value; 229 229 230 230 hash_jam (local_hash, name_copy, (PTR) ret); … … 248 248 ++local_symbol_conversion_count; 249 249 250 ret = symbol_new (locsym->lsy_name, locsym->lsy_section, locsym->lsy_ offset,250 ret = symbol_new (locsym->lsy_name, locsym->lsy_section, locsym->lsy_value, 251 251 local_symbol_get_frag (locsym)); 252 252 … … 256 256 /* Local symbols are always either defined or used. */ 257 257 ret->sy_used = 1; 258 259 #ifdef TC_LOCAL_SYMFIELD_CONVERT 260 TC_LOCAL_SYMFIELD_CONVERT (locsym, ret); 261 #endif 258 262 259 263 symbol_table_insert (ret); … … 313 317 extern const int md_short_jump_size; 314 318 extern const int md_long_jump_size; 319 320 if (now_seg == absolute_section) 321 { 322 as_bad (_("cannot define symbol `%s' in absolute section"), sym_name); 323 return NULL; 324 } 325 315 326 possible_bytes = (md_short_jump_size 316 327 + new_broken_words * md_long_jump_size); … … 356 367 && (local_symbol_get_frag (locsym) != frag_now 357 368 || locsym->lsy_section != now_seg 358 || locsym->lsy_ offset!= frag_now_fix ()))369 || locsym->lsy_value != frag_now_fix ())) 359 370 { 360 as_bad (_(" Symbol %s already defined."), sym_name);371 as_bad (_("symbol `%s' is already defined"), sym_name); 361 372 return symbolP; 362 373 } … … 364 375 locsym->lsy_section = now_seg; 365 376 local_symbol_set_frag (locsym, frag_now); 366 locsym->lsy_ offset= frag_now_fix ();377 locsym->lsy_value = frag_now_fix (); 367 378 #endif 368 379 } … … 439 450 if (OUTPUT_FLAVOR == bfd_target_aout_flavour) 440 451 #endif 441 sprintf (od_buf, "%d.%d.",442 S_GET_OTHER (symbolP),443 S_GET_DESC (symbolP));444 #endif 445 as_bad (_(" Symbol \"%s\" is already defined as \"%s\"/%s%ld."),452 sprintf (od_buf, "%d.%d.", 453 S_GET_OTHER (symbolP), 454 S_GET_DESC (symbolP)); 455 #endif 456 as_bad (_("symbol `%s' is already defined as \"%s\"/%s%ld"), 446 457 sym_name, 447 458 segment_name (S_GET_SEGMENT (symbolP)), … … 457 468 && S_GET_VALUE (symbolP) == frag_now_fix () 458 469 && S_GET_SEGMENT (symbolP) == now_seg)) 459 as_bad (_(" Symbol %s already defined."), sym_name);470 as_bad (_("symbol `%s' is already defined"), sym_name); 460 471 } 461 472 … … 483 494 { 484 495 /* This symbol is actually being defined within an MRI common 485 496 section. This requires special handling. */ 486 497 if (LOCAL_SYMBOL_CHECK (symbolP)) 487 498 symbolP = local_symbol_convert ((struct local_symbol *) symbolP); … … 521 532 (PTR) symbolP); 522 533 if (error_string != NULL) 523 as_fatal (_(" Inserting \"%s\" into symbol table failed: %s"),534 as_fatal (_("inserting \"%s\" into symbol table failed: %s"), 524 535 S_GET_NAME (symbolP), error_string); 525 536 return; … … 528 539 if ((error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (PTR) symbolP))) 529 540 { 530 as_fatal (_(" Inserting \"%s\" into symbol table failed: %s"),541 as_fatal (_("inserting \"%s\" into symbol table failed: %s"), 531 542 S_GET_NAME (symbolP), error_string); 532 543 } /* on error */ … … 571 582 symbolS * 572 583 symbol_make (name) 573 CONSTchar *name;584 const char *name; 574 585 { 575 586 symbolS *symbolP; … … 591 602 symbolS * 592 603 symbol_find (name) 593 CONSTchar *name;604 const char *name; 594 605 { 595 606 #ifdef STRIP_UNDERSCORE … … 601 612 602 613 symbolS * 614 symbol_find_exact (name) 615 const char *name; 616 { 617 #ifdef BFD_ASSEMBLER 618 { 619 struct local_symbol *locsym; 620 621 locsym = (struct local_symbol *) hash_find (local_hash, name); 622 if (locsym != NULL) 623 return (symbolS *) locsym; 624 } 625 #endif 626 627 return ((symbolS *) hash_find (sy_hash, name)); 628 } 629 630 symbolS * 603 631 symbol_find_base (name, strip_underscore) 604 CONSTchar *name;632 const char *name; 605 633 int strip_underscore; 606 634 { … … 630 658 while ((c = *orig++) != '\0') 631 659 { 632 if (islower (c)) 633 c = toupper (c); 634 *copy++ = c; 660 *copy++ = TOUPPER (c); 635 661 } 636 662 *copy = '\0'; 637 663 } 638 664 639 #ifdef BFD_ASSEMBLER 640 { 641 struct local_symbol *locsym; 642 643 locsym = (struct local_symbol *) hash_find (local_hash, name); 644 if (locsym != NULL) 645 return (symbolS *) locsym; 646 } 647 #endif 648 649 return ((symbolS *) hash_find (sy_hash, name)); 665 return symbol_find_exact (name); 650 666 } 651 667 … … 827 843 } 828 844 845 static void 846 report_op_error (symp, left, right) 847 symbolS *symp; 848 symbolS *left, *right; 849 { 850 char *file; 851 unsigned int line; 852 segT seg_left = S_GET_SEGMENT (left); 853 segT seg_right = right ? S_GET_SEGMENT (right) : 0; 854 855 if (expr_symbol_where (symp, &file, &line)) 856 { 857 if (seg_left == undefined_section) 858 as_bad_where (file, line, 859 _("undefined symbol `%s' in operation"), 860 S_GET_NAME (left)); 861 if (seg_right == undefined_section) 862 as_bad_where (file, line, 863 _("undefined symbol `%s' in operation"), 864 S_GET_NAME (right)); 865 if (seg_left != undefined_section 866 && seg_right != undefined_section) 867 { 868 if (right) 869 as_bad_where (file, line, 870 _("invalid sections for operation on `%s' and `%s'"), 871 S_GET_NAME (left), S_GET_NAME (right)); 872 else 873 as_bad_where (file, line, 874 _("invalid section for operation on `%s'"), 875 S_GET_NAME (left)); 876 } 877 878 } 879 else 880 { 881 if (seg_left == undefined_section) 882 as_bad (_("undefined symbol `%s' in operation setting `%s'"), 883 S_GET_NAME (left), S_GET_NAME (symp)); 884 if (seg_right == undefined_section) 885 as_bad (_("undefined symbol `%s' in operation setting `%s'"), 886 S_GET_NAME (right), S_GET_NAME (symp)); 887 if (seg_left != undefined_section 888 && seg_right != undefined_section) 889 { 890 if (right) 891 as_bad_where (file, line, 892 _("invalid sections for operation on `%s' and `%s' setting `%s'"), 893 S_GET_NAME (left), S_GET_NAME (right), S_GET_NAME (symp)); 894 else 895 as_bad_where (file, line, 896 _("invalid section for operation on `%s' setting `%s'"), 897 S_GET_NAME (left), S_GET_NAME (symp)); 898 } 899 } 900 } 901 829 902 /* Resolve the value of a symbol. This is called during the final 830 903 pass over the symbol table to resolve any symbols with complex … … 832 905 833 906 valueT 834 resolve_symbol_value (symp , finalize)907 resolve_symbol_value (symp) 835 908 symbolS *symp; 836 int finalize;837 909 { 838 910 int resolved; 839 valueT final_val ;911 valueT final_val = 0; 840 912 segT final_seg; 841 913 … … 845 917 struct local_symbol *locsym = (struct local_symbol *) symp; 846 918 919 final_val = locsym->lsy_value; 847 920 if (local_symbol_resolved_p (locsym)) 848 return locsym->lsy_offset / bfd_octets_per_byte (stdoutput); 849 850 final_val = (local_symbol_get_frag (locsym)->fr_address 851 + locsym->lsy_offset) / bfd_octets_per_byte (stdoutput); 852 853 if (finalize) 921 return final_val; 922 923 final_val += local_symbol_get_frag (locsym)->fr_address / OCTETS_PER_BYTE; 924 925 if (finalize_syms) 854 926 { 855 locsym->lsy_ offset= final_val;927 locsym->lsy_value = final_val; 856 928 local_symbol_mark_resolved (locsym); 857 929 } … … 874 946 if (symp->sy_resolving) 875 947 { 876 if (finalize )877 as_bad (_(" Symbol definition loop encountered at %s"),948 if (finalize_syms) 949 as_bad (_("symbol definition loop encountered at `%s'"), 878 950 S_GET_NAME (symp)); 879 951 final_val = 0; … … 914 986 case O_symbol: 915 987 case O_symbol_rva: 916 left = resolve_symbol_value (add_symbol, finalize); 988 left = resolve_symbol_value (add_symbol); 989 seg_left = S_GET_SEGMENT (add_symbol); 990 if (finalize_syms) 991 symp->sy_value.X_op_symbol = NULL; 992 917 993 do_symbol: 918 919 994 if (symp->sy_mri_common) 920 995 { 921 996 /* This is a symbol inside an MRI common section. The 922 923 997 relocation routines are going to handle it specially. 998 Don't change the value. */ 924 999 resolved = symbol_resolved_p (add_symbol); 925 1000 break; 926 1001 } 927 1002 928 if (finalize && final_val == 0)1003 if (finalize_syms && final_val == 0) 929 1004 { 930 1005 if (LOCAL_SYMBOL_CHECK (add_symbol)) … … 934 1009 } 935 1010 936 /* If we have equated this symbol to an undefined symbol, we937 keep X_op set to O_symbol, and wedon't change938 939 940 941 1011 /* If we have equated this symbol to an undefined or common 1012 symbol, keep X_op set to O_symbol, and don't change 1013 X_add_number. This permits the routine which writes out 1014 relocation to detect this case, and convert the 1015 relocation to be against the symbol to which this symbol 1016 is equated. */ 942 1017 if (! S_IS_DEFINED (add_symbol) || S_IS_COMMON (add_symbol)) 943 1018 { 944 if (finalize )1019 if (finalize_syms) 945 1020 { 946 S_SET_SEGMENT (symp, S_GET_SEGMENT (add_symbol));947 1021 symp->sy_value.X_op = O_symbol; 948 1022 symp->sy_value.X_add_symbol = add_symbol; 949 1023 symp->sy_value.X_add_number = final_val; 1024 /* Use X_op_symbol as a flag. */ 1025 symp->sy_value.X_op_symbol = add_symbol; 1026 final_seg = seg_left; 950 1027 } 951 1028 final_val = 0; 952 1029 resolved = symbol_resolved_p (add_symbol); 1030 symp->sy_resolving = 0; 1031 goto exit_dont_set_value; 1032 } 1033 else if (finalize_syms && final_seg == expr_section 1034 && seg_left != expr_section) 1035 { 1036 /* If the symbol is an expression symbol, do similarly 1037 as for undefined and common syms above. Handles 1038 "sym +/- expr" where "expr" cannot be evaluated 1039 immediately, and we want relocations to be against 1040 "sym", eg. because it is weak. */ 1041 symp->sy_value.X_op = O_symbol; 1042 symp->sy_value.X_add_symbol = add_symbol; 1043 symp->sy_value.X_add_number = final_val; 1044 symp->sy_value.X_op_symbol = add_symbol; 1045 final_seg = seg_left; 1046 final_val += symp->sy_frag->fr_address + left; 1047 resolved = symbol_resolved_p (add_symbol); 1048 symp->sy_resolving = 0; 953 1049 goto exit_dont_set_value; 954 1050 } … … 957 1053 final_val += symp->sy_frag->fr_address + left; 958 1054 if (final_seg == expr_section || final_seg == undefined_section) 959 final_seg = S_GET_SEGMENT (add_symbol);1055 final_seg = seg_left; 960 1056 } 961 1057 … … 966 1062 case O_bit_not: 967 1063 case O_logical_not: 968 left = resolve_symbol_value (add_symbol, finalize); 1064 left = resolve_symbol_value (add_symbol); 1065 seg_left = S_GET_SEGMENT (add_symbol); 1066 1067 /* By reducing these to the relevant dyadic operator, we get 1068 !S -> S == 0 permitted on anything, 1069 -S -> 0 - S only permitted on absolute 1070 ~S -> S ^ ~0 only permitted on absolute */ 1071 if (op != O_logical_not && seg_left != absolute_section 1072 && finalize_syms) 1073 report_op_error (symp, add_symbol, NULL); 1074 1075 if (final_seg == expr_section || final_seg == undefined_section) 1076 final_seg = absolute_section; 969 1077 970 1078 if (op == O_uminus) … … 976 1084 977 1085 final_val += left + symp->sy_frag->fr_address; 978 if (final_seg == expr_section || final_seg == undefined_section)979 final_seg = absolute_section;980 1086 981 1087 resolved = symbol_resolved_p (add_symbol); … … 1001 1107 case O_logical_and: 1002 1108 case O_logical_or: 1003 left = resolve_symbol_value (add_symbol , finalize);1004 right = resolve_symbol_value (op_symbol , finalize);1109 left = resolve_symbol_value (add_symbol); 1110 right = resolve_symbol_value (op_symbol); 1005 1111 seg_left = S_GET_SEGMENT (add_symbol); 1006 1112 seg_right = S_GET_SEGMENT (op_symbol); … … 1008 1114 /* Simplify addition or subtraction of a constant by folding the 1009 1115 constant into X_add_number. */ 1010 if (op == O_add || op == O_subtract)1116 if (op == O_add) 1011 1117 { 1012 1118 if (seg_right == absolute_section) 1013 1119 { 1014 if (op == O_add) 1015 final_val += right; 1016 else 1017 final_val -= right; 1018 op = O_symbol; 1019 op_symbol = NULL; 1120 final_val += right; 1020 1121 goto do_symbol; 1021 1122 } 1022 else if (seg_left == absolute_section && op == O_add)1123 else if (seg_left == absolute_section) 1023 1124 { 1024 op = O_symbol;1025 1125 final_val += left; 1026 1126 add_symbol = op_symbol; 1027 1127 left = right; 1028 op_symbol = NULL;1128 seg_left = seg_right; 1029 1129 goto do_symbol; 1030 1130 } 1031 1131 } 1032 1033 /* Subtraction is permitted if both operands are in the same 1034 section. Otherwise, both operands must be absolute. We 1035 already handled the case of addition or subtraction of a 1036 constant above. This will probably need to be changed 1037 for an object file format which supports arbitrary 1038 expressions, such as IEEE-695. */ 1039 /* Don't emit messages unless we're finalizing the symbol value, 1040 otherwise we may get the same message multiple times. */ 1041 if ((seg_left != absolute_section 1042 || seg_right != absolute_section) 1043 && (op != O_subtract 1044 || seg_left != seg_right 1045 || seg_left == undefined_section) 1046 && finalize) 1132 else if (op == O_subtract) 1047 1133 { 1048 char *file; 1049 unsigned int line; 1050 1051 if (expr_symbol_where (symp, &file, &line)) 1134 if (seg_right == absolute_section) 1052 1135 { 1053 if (seg_left == undefined_section) 1054 as_bad_where (file, line, 1055 _("undefined symbol %s in operation"), 1056 S_GET_NAME (symp->sy_value.X_add_symbol)); 1057 if (seg_right == undefined_section) 1058 as_bad_where (file, line, 1059 _("undefined symbol %s in operation"), 1060 S_GET_NAME (symp->sy_value.X_op_symbol)); 1061 if (seg_left != undefined_section 1062 && seg_right != undefined_section) 1063 as_bad_where (file, line, 1064 _("invalid section for operation")); 1065 } 1066 else 1067 { 1068 if (seg_left == undefined_section) 1069 as_bad (_("undefined symbol %s in operation setting %s"), 1070 S_GET_NAME (symp->sy_value.X_add_symbol), 1071 S_GET_NAME (symp)); 1072 if (seg_right == undefined_section) 1073 as_bad (_("undefined symbol %s in operation setting %s"), 1074 S_GET_NAME (symp->sy_value.X_op_symbol), 1075 S_GET_NAME (symp)); 1076 if (seg_left != undefined_section 1077 && seg_right != undefined_section) 1078 as_bad (_("invalid section for operation setting %s"), 1079 S_GET_NAME (symp)); 1136 final_val -= right; 1137 goto do_symbol; 1080 1138 } 1081 1139 } 1140 1141 /* Equality and non-equality tests are permitted on anything. 1142 Subtraction, and other comparison operators are permitted if 1143 both operands are in the same section. Otherwise, both 1144 operands must be absolute. We already handled the case of 1145 addition or subtraction of a constant above. This will 1146 probably need to be changed for an object file format which 1147 supports arbitrary expressions, such as IEEE-695. 1148 1149 Don't emit messages unless we're finalizing the symbol value, 1150 otherwise we may get the same message multiple times. */ 1151 if (finalize_syms 1152 && !(seg_left == absolute_section 1153 && seg_right == absolute_section) 1154 && !(op == O_eq || op == O_ne) 1155 && !((op == O_subtract 1156 || op == O_lt || op == O_le || op == O_ge || op == O_gt) 1157 && seg_left == seg_right 1158 && (seg_left != undefined_section 1159 || add_symbol == op_symbol))) 1160 report_op_error (symp, add_symbol, op_symbol); 1161 1162 if (final_seg == expr_section || final_seg == undefined_section) 1163 final_seg = absolute_section; 1082 1164 1083 1165 /* Check for division by zero. */ … … 1085 1167 { 1086 1168 /* If seg_right is not absolute_section, then we've 1087 1088 if (seg_right == absolute_section && finalize )1169 already issued a warning about using a bad symbol. */ 1170 if (seg_right == absolute_section && finalize_syms) 1089 1171 { 1090 1172 char *file; … … 1094 1176 as_bad_where (file, line, _("division by zero")); 1095 1177 else 1096 as_bad (_("division by zero when setting %s"),1178 as_bad (_("division by zero when setting `%s'"), 1097 1179 S_GET_NAME (symp)); 1098 1180 } … … 1114 1196 case O_add: left += right; break; 1115 1197 case O_subtract: left -= right; break; 1116 case O_eq: left = left == right ? ~ (offsetT) 0 : 0; break; 1117 case O_ne: left = left != right ? ~ (offsetT) 0 : 0; break; 1198 case O_eq: 1199 case O_ne: 1200 left = (left == right && seg_left == seg_right 1201 && (seg_left != undefined_section 1202 || add_symbol == op_symbol) 1203 ? ~ (offsetT) 0 : 0); 1204 if (symp->sy_value.X_op == O_ne) 1205 left = ~left; 1206 break; 1118 1207 case O_lt: left = left < right ? ~ (offsetT) 0 : 0; break; 1119 1208 case O_le: left = left <= right ? ~ (offsetT) 0 : 0; break; … … 1127 1216 final_val += symp->sy_frag->fr_address + left; 1128 1217 if (final_seg == expr_section || final_seg == undefined_section) 1129 final_seg = absolute_section; 1218 { 1219 if (seg_left == undefined_section 1220 || seg_right == undefined_section) 1221 final_seg = undefined_section; 1222 else if (seg_left == absolute_section) 1223 final_seg = seg_right; 1224 else 1225 final_seg = seg_left; 1226 } 1130 1227 resolved = (symbol_resolved_p (add_symbol) 1131 1228 && symbol_resolved_p (op_symbol)); … … 1146 1243 } 1147 1244 1148 if (finalize) 1149 { 1150 S_SET_VALUE (symp, final_val); 1151 1245 if (finalize_syms) 1246 S_SET_VALUE (symp, final_val); 1247 1248 exit_dont_set_value: 1249 /* Always set the segment, even if not finalizing the value. 1250 The segment is used to determine whether a symbol is defined. */ 1152 1251 #if defined (OBJ_AOUT) && ! defined (BFD_ASSEMBLER) 1153 /* The old a.out backend does not handle S_SET_SEGMENT correctly 1154 for a stab symbol, so we use this bad hack. */ 1155 if (final_seg != S_GET_SEGMENT (symp)) 1156 #endif 1157 S_SET_SEGMENT (symp, final_seg); 1158 } 1159 1160 exit_dont_set_value: 1252 /* The old a.out backend does not handle S_SET_SEGMENT correctly 1253 for a stab symbol, so we use this bad hack. */ 1254 if (final_seg != S_GET_SEGMENT (symp)) 1255 #endif 1256 S_SET_SEGMENT (symp, final_seg); 1257 1161 1258 /* Don't worry if we can't resolve an expr_section symbol. */ 1162 if (finalize )1259 if (finalize_syms) 1163 1260 { 1164 1261 if (resolved) … … 1166 1263 else if (S_GET_SEGMENT (symp) != expr_section) 1167 1264 { 1168 as_bad (_("can't resolve value for symbol \"%s\""),1265 as_bad (_("can't resolve value for symbol `%s'"), 1169 1266 S_GET_NAME (symp)); 1170 1267 symp->sy_resolved = 1; … … 1187 1284 { 1188 1285 if (value != NULL) 1189 resolve_symbol_value (value , 1);1286 resolve_symbol_value (value); 1190 1287 } 1191 1288 … … 1547 1644 return s; 1548 1645 1549 for (label_number = 0, p = s + index + 1; isdigit ((unsigned char)*p); ++p)1646 for (label_number = 0, p = s + index + 1; ISDIGIT (*p); ++p) 1550 1647 label_number = (10 * label_number) + *p - '0'; 1551 1648 … … 1557 1654 return s; 1558 1655 1559 for (instance_number = 0, p++; isdigit ((unsigned char)*p); ++p)1656 for (instance_number = 0, p++; ISDIGIT (*p); ++p) 1560 1657 instance_number = (10 * instance_number) + *p - '0'; 1561 1658 … … 1575 1672 #ifdef BFD_ASSEMBLER 1576 1673 if (LOCAL_SYMBOL_CHECK (s)) 1577 return ((struct local_symbol *) s)->lsy_offset; 1578 #endif 1579 1580 if (!s->sy_resolved && s->sy_value.X_op != O_constant) 1581 resolve_symbol_value (s, 1); 1674 return resolve_symbol_value (s); 1675 #endif 1676 1677 if (!s->sy_resolved) 1678 { 1679 valueT val = resolve_symbol_value (s); 1680 if (!finalize_syms) 1681 return val; 1682 } 1582 1683 if (s->sy_value.X_op != O_constant) 1583 1684 { … … 1585 1686 1586 1687 /* FIXME: In non BFD assemblers, S_IS_DEFINED and S_IS_COMMON 1587 1588 1688 may call S_GET_VALUE. We use a static symbol to avoid the 1689 immediate recursion. */ 1589 1690 if (recur == s) 1590 1691 return (valueT) s->sy_value.X_add_number; … … 1593 1694 || s->sy_value.X_op != O_symbol 1594 1695 || (S_IS_DEFINED (s) && ! S_IS_COMMON (s))) 1595 as_bad (_(" Attempt to get value of unresolved symbol %s"),1696 as_bad (_("attempt to get value of unresolved symbol `%s'"), 1596 1697 S_GET_NAME (s)); 1597 1698 recur = NULL; … … 1610 1711 if (LOCAL_SYMBOL_CHECK (s)) 1611 1712 { 1612 ((struct local_symbol *) s)->lsy_ offset= val;1713 ((struct local_symbol *) s)->lsy_value = val; 1613 1714 return; 1614 1715 } … … 1700 1801 return ((struct local_symbol *) s)->lsy_section != undefined_section; 1701 1802 return s->bsym->section != undefined_section; 1803 } 1804 1805 1806 #ifndef EXTERN_FORCE_RELOC 1807 #define EXTERN_FORCE_RELOC IS_ELF 1808 #endif 1809 1810 /* Return true for symbols that should not be reduced to section 1811 symbols or eliminated from expressions, because they may be 1812 overridden by the linker. */ 1813 int 1814 S_FORCE_RELOC (s, strict) 1815 symbolS *s; 1816 int strict; 1817 { 1818 if (LOCAL_SYMBOL_CHECK (s)) 1819 return ((struct local_symbol *) s)->lsy_section == undefined_section; 1820 1821 return ((strict 1822 && ((s->bsym->flags & BSF_WEAK) != 0 1823 || (EXTERN_FORCE_RELOC 1824 && (s->bsym->flags & BSF_GLOBAL) != 0))) 1825 || s->bsym->section == undefined_section 1826 || bfd_is_com_section (s->bsym->section)); 1702 1827 } 1703 1828 … … 1763 1888 } 1764 1889 1765 CONSTchar *1890 const char * 1766 1891 S_GET_NAME (s) 1767 1892 symbolS *s; … … 1825 1950 char * file; 1826 1951 unsigned int line; 1827 1952 1828 1953 /* Do not reassign section symbols. */ 1829 1954 as_where (& file, & line); 1830 1955 as_warn_where (file, line, 1831 _(" Section symbols are already global"));1956 _("section symbols are already global")); 1832 1957 return; 1833 1958 } … … 1859 1984 s->bsym->flags |= BSF_WEAK; 1860 1985 s->bsym->flags &= ~(BSF_GLOBAL | BSF_LOCAL); 1986 } 1987 1988 void 1989 S_SET_THREAD_LOCAL (s) 1990 symbolS *s; 1991 { 1992 if (LOCAL_SYMBOL_CHECK (s)) 1993 s = local_symbol_convert ((struct local_symbol *) s); 1994 if (bfd_is_com_section (s->bsym->section) 1995 && (s->bsym->flags & BSF_THREAD_LOCAL) != 0) 1996 return; 1997 s->bsym->flags |= BSF_THREAD_LOCAL; 1998 if ((s->bsym->flags & BSF_FUNCTION) != 0) 1999 as_bad (_("Accessing function `%s' as thread-local object"), 2000 S_GET_NAME (s)); 2001 else if (! bfd_is_und_section (s->bsym->section) 2002 && (s->bsym->section->flags & SEC_THREAD_LOCAL) == 0) 2003 as_bad (_("Accessing `%s' as thread-local object"), 2004 S_GET_NAME (s)); 1861 2005 } 1862 2006 … … 2140 2284 return 0; 2141 2285 return s->sy_value.X_op == O_symbol; 2286 } 2287 2288 /* Return whether a symbol is equated to another symbol, and should be 2289 treated specially when writing out relocs. */ 2290 2291 int 2292 symbol_equated_reloc_p (s) 2293 symbolS *s; 2294 { 2295 if (LOCAL_SYMBOL_CHECK (s)) 2296 return 0; 2297 /* X_op_symbol, normally not used for O_symbol, is set by 2298 resolve_symbol_value to flag expression syms that have been 2299 equated. */ 2300 return (s->sy_value.X_op == O_symbol 2301 && ((s->sy_resolved && s->sy_value.X_op_symbol != NULL) 2302 || ! S_IS_DEFINED (s) 2303 || S_IS_COMMON (s))); 2142 2304 } 2143 2305 … … 2328 2490 2329 2491 if (s != undefined_section 2330 2492 && s != expr_section) 2331 2493 fprintf (file, " %lx", (long) S_GET_VALUE (sym)); 2332 2494 } … … 2339 2501 if (LOCAL_SYMBOL_CHECK (sym)) 2340 2502 fprintf (file, "constant %lx", 2341 (long) ((struct local_symbol *) sym)->lsy_ offset);2503 (long) ((struct local_symbol *) sym)->lsy_value); 2342 2504 else 2343 2505 #endif -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.