| 1 | /* symbols.c -symbol table- | 
|---|
| 2 | Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, | 
|---|
| 3 | 1999, 2000, 2001, 2002, 2003 | 
|---|
| 4 | Free Software Foundation, Inc. | 
|---|
| 5 |  | 
|---|
| 6 | This file is part of GAS, the GNU Assembler. | 
|---|
| 7 |  | 
|---|
| 8 | GAS 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, or (at your option) | 
|---|
| 11 | any later version. | 
|---|
| 12 |  | 
|---|
| 13 | GAS 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 GAS; see the file COPYING.  If not, write to the Free | 
|---|
| 20 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | 
|---|
| 21 | 02111-1307, USA.  */ | 
|---|
| 22 |  | 
|---|
| 23 | /* #define DEBUG_SYMS / * to debug symbol list maintenance.  */ | 
|---|
| 24 |  | 
|---|
| 25 | #include "as.h" | 
|---|
| 26 |  | 
|---|
| 27 | #include "safe-ctype.h" | 
|---|
| 28 | #include "obstack.h"            /* For "symbols.h" */ | 
|---|
| 29 | #include "subsegs.h" | 
|---|
| 30 |  | 
|---|
| 31 | #include "struc-symbol.h" | 
|---|
| 32 |  | 
|---|
| 33 | /* This is non-zero if symbols are case sensitive, which is the | 
|---|
| 34 | default.  */ | 
|---|
| 35 | int symbols_case_sensitive = 1; | 
|---|
| 36 |  | 
|---|
| 37 | #ifndef WORKING_DOT_WORD | 
|---|
| 38 | extern int new_broken_words; | 
|---|
| 39 | #endif | 
|---|
| 40 |  | 
|---|
| 41 | /* symbol-name => struct symbol pointer */ | 
|---|
| 42 | static struct hash_control *sy_hash; | 
|---|
| 43 |  | 
|---|
| 44 | /* Table of local symbols.  */ | 
|---|
| 45 | static struct hash_control *local_hash; | 
|---|
| 46 |  | 
|---|
| 47 | /* Below are commented in "symbols.h".  */ | 
|---|
| 48 | symbolS *symbol_rootP; | 
|---|
| 49 | symbolS *symbol_lastP; | 
|---|
| 50 | symbolS abs_symbol; | 
|---|
| 51 |  | 
|---|
| 52 | #ifdef DEBUG_SYMS | 
|---|
| 53 | #define debug_verify_symchain verify_symbol_chain | 
|---|
| 54 | #else | 
|---|
| 55 | #define debug_verify_symchain(root, last) ((void) 0) | 
|---|
| 56 | #endif | 
|---|
| 57 |  | 
|---|
| 58 | #define DOLLAR_LABEL_CHAR       '\001' | 
|---|
| 59 | #define LOCAL_LABEL_CHAR        '\002' | 
|---|
| 60 |  | 
|---|
| 61 | struct obstack notes; | 
|---|
| 62 |  | 
|---|
| 63 | static char *save_symbol_name PARAMS ((const char *)); | 
|---|
| 64 | static void fb_label_init PARAMS ((void)); | 
|---|
| 65 | static long dollar_label_instance PARAMS ((long)); | 
|---|
| 66 | static long fb_label_instance PARAMS ((long)); | 
|---|
| 67 |  | 
|---|
| 68 | static void print_binary PARAMS ((FILE *, const char *, expressionS *)); | 
|---|
| 69 | static void report_op_error PARAMS ((symbolS *, symbolS *, symbolS *)); | 
|---|
| 70 |  | 
|---|
| 71 | /* Return a pointer to a new symbol.  Die if we can't make a new | 
|---|
| 72 | symbol.  Fill in the symbol's values.  Add symbol to end of symbol | 
|---|
| 73 | chain. | 
|---|
| 74 |  | 
|---|
| 75 | This function should be called in the general case of creating a | 
|---|
| 76 | symbol.  However, if the output file symbol table has already been | 
|---|
| 77 | set, and you are certain that this symbol won't be wanted in the | 
|---|
| 78 | output file, you can call symbol_create.  */ | 
|---|
| 79 |  | 
|---|
| 80 | symbolS * | 
|---|
| 81 | symbol_new (name, segment, valu, frag) | 
|---|
| 82 | const char *name; | 
|---|
| 83 | segT segment; | 
|---|
| 84 | valueT valu; | 
|---|
| 85 | fragS *frag; | 
|---|
| 86 | { | 
|---|
| 87 | symbolS *symbolP = symbol_create (name, segment, valu, frag); | 
|---|
| 88 |  | 
|---|
| 89 | /* Link to end of symbol chain.  */ | 
|---|
| 90 | #ifdef BFD_ASSEMBLER | 
|---|
| 91 | { | 
|---|
| 92 | extern int symbol_table_frozen; | 
|---|
| 93 | if (symbol_table_frozen) | 
|---|
| 94 | abort (); | 
|---|
| 95 | } | 
|---|
| 96 | #endif | 
|---|
| 97 | symbol_append (symbolP, symbol_lastP, &symbol_rootP, &symbol_lastP); | 
|---|
| 98 |  | 
|---|
| 99 | return symbolP; | 
|---|
| 100 | } | 
|---|
| 101 |  | 
|---|
| 102 | /* Save a symbol name on a permanent obstack, and convert it according | 
|---|
| 103 | to the object file format.  */ | 
|---|
| 104 |  | 
|---|
| 105 | static char * | 
|---|
| 106 | save_symbol_name (name) | 
|---|
| 107 | const char *name; | 
|---|
| 108 | { | 
|---|
| 109 | unsigned int name_length; | 
|---|
| 110 | char *ret; | 
|---|
| 111 |  | 
|---|
| 112 | name_length = strlen (name) + 1;      /* +1 for \0.  */ | 
|---|
| 113 | obstack_grow (¬es, name, name_length); | 
|---|
| 114 | ret = obstack_finish (¬es); | 
|---|
| 115 |  | 
|---|
| 116 | #ifdef STRIP_UNDERSCORE | 
|---|
| 117 | if (ret[0] == '_') | 
|---|
| 118 | ++ret; | 
|---|
| 119 | #endif | 
|---|
| 120 |  | 
|---|
| 121 | #ifdef tc_canonicalize_symbol_name | 
|---|
| 122 | ret = tc_canonicalize_symbol_name (ret); | 
|---|
| 123 | #endif | 
|---|
| 124 |  | 
|---|
| 125 | if (! symbols_case_sensitive) | 
|---|
| 126 | { | 
|---|
| 127 | char *s; | 
|---|
| 128 |  | 
|---|
| 129 | for (s = ret; *s != '\0'; s++) | 
|---|
| 130 | *s = TOUPPER (*s); | 
|---|
| 131 | } | 
|---|
| 132 |  | 
|---|
| 133 | return ret; | 
|---|
| 134 | } | 
|---|
| 135 |  | 
|---|
| 136 | symbolS * | 
|---|
| 137 | symbol_create (name, segment, valu, frag) | 
|---|
| 138 | const char *name;          /* It is copied, the caller can destroy/modify.  */ | 
|---|
| 139 | segT segment;              /* Segment identifier (SEG_<something>).  */ | 
|---|
| 140 | valueT valu;               /* Symbol value.  */ | 
|---|
| 141 | fragS *frag;               /* Associated fragment.  */ | 
|---|
| 142 | { | 
|---|
| 143 | char *preserved_copy_of_name; | 
|---|
| 144 | symbolS *symbolP; | 
|---|
| 145 |  | 
|---|
| 146 | preserved_copy_of_name = save_symbol_name (name); | 
|---|
| 147 |  | 
|---|
| 148 | symbolP = (symbolS *) obstack_alloc (¬es, sizeof (symbolS)); | 
|---|
| 149 |  | 
|---|
| 150 | /* symbol must be born in some fixed state.  This seems as good as any.  */ | 
|---|
| 151 | memset (symbolP, 0, sizeof (symbolS)); | 
|---|
| 152 |  | 
|---|
| 153 | #ifdef BFD_ASSEMBLER | 
|---|
| 154 | symbolP->bsym = bfd_make_empty_symbol (stdoutput); | 
|---|
| 155 | if (symbolP->bsym == NULL) | 
|---|
| 156 | as_perror ("%s", "bfd_make_empty_symbol"); | 
|---|
| 157 | symbolP->bsym->udata.p = (PTR) symbolP; | 
|---|
| 158 | #endif | 
|---|
| 159 | S_SET_NAME (symbolP, preserved_copy_of_name); | 
|---|
| 160 |  | 
|---|
| 161 | S_SET_SEGMENT (symbolP, segment); | 
|---|
| 162 | S_SET_VALUE (symbolP, valu); | 
|---|
| 163 | symbol_clear_list_pointers (symbolP); | 
|---|
| 164 |  | 
|---|
| 165 | symbolP->sy_frag = frag; | 
|---|
| 166 | #ifndef BFD_ASSEMBLER | 
|---|
| 167 | symbolP->sy_number = ~0; | 
|---|
| 168 | symbolP->sy_name_offset = (unsigned int) ~0; | 
|---|
| 169 | #endif | 
|---|
| 170 |  | 
|---|
| 171 | obj_symbol_new_hook (symbolP); | 
|---|
| 172 |  | 
|---|
| 173 | #ifdef tc_symbol_new_hook | 
|---|
| 174 | tc_symbol_new_hook (symbolP); | 
|---|
| 175 | #endif | 
|---|
| 176 |  | 
|---|
| 177 | return symbolP; | 
|---|
| 178 | } | 
|---|
| 179 |  | 
|---|
| 180 |  | 
|---|
| 181 | #ifdef BFD_ASSEMBLER | 
|---|
| 182 |  | 
|---|
| 183 | /* Local symbol support.  If we can get away with it, we keep only a | 
|---|
| 184 | small amount of information for local symbols.  */ | 
|---|
| 185 |  | 
|---|
| 186 | static struct local_symbol *local_symbol_make PARAMS ((const char *, segT, | 
|---|
| 187 | valueT, fragS *)); | 
|---|
| 188 | static symbolS *local_symbol_convert PARAMS ((struct local_symbol *)); | 
|---|
| 189 |  | 
|---|
| 190 | /* Used for statistics.  */ | 
|---|
| 191 |  | 
|---|
| 192 | static unsigned long local_symbol_count; | 
|---|
| 193 | static unsigned long local_symbol_conversion_count; | 
|---|
| 194 |  | 
|---|
| 195 | /* This macro is called with a symbol argument passed by reference. | 
|---|
| 196 | It returns whether this is a local symbol.  If necessary, it | 
|---|
| 197 | changes its argument to the real symbol.  */ | 
|---|
| 198 |  | 
|---|
| 199 | #define LOCAL_SYMBOL_CHECK(s)                                           \ | 
|---|
| 200 | (s->bsym == NULL                                                      \ | 
|---|
| 201 | ? (local_symbol_converted_p ((struct local_symbol *) s)              \ | 
|---|
| 202 | ? (s = local_symbol_get_real_symbol ((struct local_symbol *) s),  \ | 
|---|
| 203 | 0)                                                             \ | 
|---|
| 204 | : 1)                                                              \ | 
|---|
| 205 | : 0) | 
|---|
| 206 |  | 
|---|
| 207 | /* Create a local symbol and insert it into the local hash table.  */ | 
|---|
| 208 |  | 
|---|
| 209 | static struct local_symbol * | 
|---|
| 210 | local_symbol_make (name, section, value, frag) | 
|---|
| 211 | const char *name; | 
|---|
| 212 | segT section; | 
|---|
| 213 | valueT value; | 
|---|
| 214 | fragS *frag; | 
|---|
| 215 | { | 
|---|
| 216 | char *name_copy; | 
|---|
| 217 | struct local_symbol *ret; | 
|---|
| 218 |  | 
|---|
| 219 | ++local_symbol_count; | 
|---|
| 220 |  | 
|---|
| 221 | name_copy = save_symbol_name (name); | 
|---|
| 222 |  | 
|---|
| 223 | ret = (struct local_symbol *) obstack_alloc (¬es, sizeof *ret); | 
|---|
| 224 | ret->lsy_marker = NULL; | 
|---|
| 225 | ret->lsy_name = name_copy; | 
|---|
| 226 | ret->lsy_section = section; | 
|---|
| 227 | local_symbol_set_frag (ret, frag); | 
|---|
| 228 | ret->lsy_value = value; | 
|---|
| 229 |  | 
|---|
| 230 | hash_jam (local_hash, name_copy, (PTR) ret); | 
|---|
| 231 |  | 
|---|
| 232 | return ret; | 
|---|
| 233 | } | 
|---|
| 234 |  | 
|---|
| 235 | /* Convert a local symbol into a real symbol.  Note that we do not | 
|---|
| 236 | reclaim the space used by the local symbol.  */ | 
|---|
| 237 |  | 
|---|
| 238 | static symbolS * | 
|---|
| 239 | local_symbol_convert (locsym) | 
|---|
| 240 | struct local_symbol *locsym; | 
|---|
| 241 | { | 
|---|
| 242 | symbolS *ret; | 
|---|
| 243 |  | 
|---|
| 244 | assert (locsym->lsy_marker == NULL); | 
|---|
| 245 | if (local_symbol_converted_p (locsym)) | 
|---|
| 246 | return local_symbol_get_real_symbol (locsym); | 
|---|
| 247 |  | 
|---|
| 248 | ++local_symbol_conversion_count; | 
|---|
| 249 |  | 
|---|
| 250 | ret = symbol_new (locsym->lsy_name, locsym->lsy_section, locsym->lsy_value, | 
|---|
| 251 | local_symbol_get_frag (locsym)); | 
|---|
| 252 |  | 
|---|
| 253 | if (local_symbol_resolved_p (locsym)) | 
|---|
| 254 | ret->sy_resolved = 1; | 
|---|
| 255 |  | 
|---|
| 256 | /* Local symbols are always either defined or used.  */ | 
|---|
| 257 | ret->sy_used = 1; | 
|---|
| 258 |  | 
|---|
| 259 | #ifdef TC_LOCAL_SYMFIELD_CONVERT | 
|---|
| 260 | TC_LOCAL_SYMFIELD_CONVERT (locsym, ret); | 
|---|
| 261 | #endif | 
|---|
| 262 |  | 
|---|
| 263 | symbol_table_insert (ret); | 
|---|
| 264 |  | 
|---|
| 265 | local_symbol_mark_converted (locsym); | 
|---|
| 266 | local_symbol_set_real_symbol (locsym, ret); | 
|---|
| 267 |  | 
|---|
| 268 | hash_jam (local_hash, locsym->lsy_name, NULL); | 
|---|
| 269 |  | 
|---|
| 270 | return ret; | 
|---|
| 271 | } | 
|---|
| 272 |  | 
|---|
| 273 | #else /* ! BFD_ASSEMBLER */ | 
|---|
| 274 |  | 
|---|
| 275 | #define LOCAL_SYMBOL_CHECK(s) 0 | 
|---|
| 276 | #define local_symbol_convert(s) ((symbolS *) s) | 
|---|
| 277 |  | 
|---|
| 278 | #endif /* ! BFD_ASSEMBLER */ | 
|---|
| 279 |  | 
|---|
| 280 |  | 
|---|
| 281 | /* We have just seen "<name>:". | 
|---|
| 282 | Creates a struct symbol unless it already exists. | 
|---|
| 283 |  | 
|---|
| 284 | Gripes if we are redefining a symbol incompatibly (and ignores it).  */ | 
|---|
| 285 |  | 
|---|
| 286 | symbolS * | 
|---|
| 287 | colon (sym_name)                /* Just seen "x:" - rattle symbols & frags.  */ | 
|---|
| 288 | const char *sym_name;      /* Symbol name, as a cannonical string.  */ | 
|---|
| 289 | /* We copy this string: OK to alter later.  */ | 
|---|
| 290 | { | 
|---|
| 291 | register symbolS *symbolP;    /* Symbol we are working with.  */ | 
|---|
| 292 |  | 
|---|
| 293 | /* Sun local labels go out of scope whenever a non-local symbol is | 
|---|
| 294 | defined.  */ | 
|---|
| 295 | if (LOCAL_LABELS_DOLLAR) | 
|---|
| 296 | { | 
|---|
| 297 | int local; | 
|---|
| 298 |  | 
|---|
| 299 | #ifdef BFD_ASSEMBLER | 
|---|
| 300 | local = bfd_is_local_label_name (stdoutput, sym_name); | 
|---|
| 301 | #else | 
|---|
| 302 | local = LOCAL_LABEL (sym_name); | 
|---|
| 303 | #endif | 
|---|
| 304 |  | 
|---|
| 305 | if (! local) | 
|---|
| 306 | dollar_label_clear (); | 
|---|
| 307 | } | 
|---|
| 308 |  | 
|---|
| 309 | #ifndef WORKING_DOT_WORD | 
|---|
| 310 | if (new_broken_words) | 
|---|
| 311 | { | 
|---|
| 312 | struct broken_word *a; | 
|---|
| 313 | int possible_bytes; | 
|---|
| 314 | fragS *frag_tmp; | 
|---|
| 315 | char *frag_opcode; | 
|---|
| 316 |  | 
|---|
| 317 | extern const int md_short_jump_size; | 
|---|
| 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 |  | 
|---|
| 326 | possible_bytes = (md_short_jump_size | 
|---|
| 327 | + new_broken_words * md_long_jump_size); | 
|---|
| 328 |  | 
|---|
| 329 | frag_tmp = frag_now; | 
|---|
| 330 | frag_opcode = frag_var (rs_broken_word, | 
|---|
| 331 | possible_bytes, | 
|---|
| 332 | possible_bytes, | 
|---|
| 333 | (relax_substateT) 0, | 
|---|
| 334 | (symbolS *) broken_words, | 
|---|
| 335 | (offsetT) 0, | 
|---|
| 336 | NULL); | 
|---|
| 337 |  | 
|---|
| 338 | /* We want to store the pointer to where to insert the jump | 
|---|
| 339 | table in the fr_opcode of the rs_broken_word frag.  This | 
|---|
| 340 | requires a little hackery.  */ | 
|---|
| 341 | while (frag_tmp | 
|---|
| 342 | && (frag_tmp->fr_type != rs_broken_word | 
|---|
| 343 | || frag_tmp->fr_opcode)) | 
|---|
| 344 | frag_tmp = frag_tmp->fr_next; | 
|---|
| 345 | know (frag_tmp); | 
|---|
| 346 | frag_tmp->fr_opcode = frag_opcode; | 
|---|
| 347 | new_broken_words = 0; | 
|---|
| 348 |  | 
|---|
| 349 | for (a = broken_words; a && a->dispfrag == 0; a = a->next_broken_word) | 
|---|
| 350 | a->dispfrag = frag_tmp; | 
|---|
| 351 | } | 
|---|
| 352 | #endif /* WORKING_DOT_WORD */ | 
|---|
| 353 |  | 
|---|
| 354 | if ((symbolP = symbol_find (sym_name)) != 0) | 
|---|
| 355 | { | 
|---|
| 356 | #ifdef RESOLVE_SYMBOL_REDEFINITION | 
|---|
| 357 | if (RESOLVE_SYMBOL_REDEFINITION (symbolP)) | 
|---|
| 358 | return symbolP; | 
|---|
| 359 | #endif | 
|---|
| 360 | /* Now check for undefined symbols.  */ | 
|---|
| 361 | if (LOCAL_SYMBOL_CHECK (symbolP)) | 
|---|
| 362 | { | 
|---|
| 363 | #ifdef BFD_ASSEMBLER | 
|---|
| 364 | struct local_symbol *locsym = (struct local_symbol *) symbolP; | 
|---|
| 365 |  | 
|---|
| 366 | if (locsym->lsy_section != undefined_section | 
|---|
| 367 | && (local_symbol_get_frag (locsym) != frag_now | 
|---|
| 368 | || locsym->lsy_section != now_seg | 
|---|
| 369 | || locsym->lsy_value != frag_now_fix ())) | 
|---|
| 370 | { | 
|---|
| 371 | as_bad (_("symbol `%s' is already defined"), sym_name); | 
|---|
| 372 | return symbolP; | 
|---|
| 373 | } | 
|---|
| 374 |  | 
|---|
| 375 | locsym->lsy_section = now_seg; | 
|---|
| 376 | local_symbol_set_frag (locsym, frag_now); | 
|---|
| 377 | locsym->lsy_value = frag_now_fix (); | 
|---|
| 378 | #endif | 
|---|
| 379 | } | 
|---|
| 380 | else if (!S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP)) | 
|---|
| 381 | { | 
|---|
| 382 | if (S_GET_VALUE (symbolP) == 0) | 
|---|
| 383 | { | 
|---|
| 384 | symbolP->sy_frag = frag_now; | 
|---|
| 385 | #ifdef OBJ_VMS | 
|---|
| 386 | S_SET_OTHER (symbolP, const_flag); | 
|---|
| 387 | #endif | 
|---|
| 388 | S_SET_VALUE (symbolP, (valueT) frag_now_fix ()); | 
|---|
| 389 | S_SET_SEGMENT (symbolP, now_seg); | 
|---|
| 390 | #ifdef N_UNDF | 
|---|
| 391 | know (N_UNDF == 0); | 
|---|
| 392 | #endif /* if we have one, it better be zero.  */ | 
|---|
| 393 |  | 
|---|
| 394 | } | 
|---|
| 395 | else | 
|---|
| 396 | { | 
|---|
| 397 | /* There are still several cases to check: | 
|---|
| 398 |  | 
|---|
| 399 | A .comm/.lcomm symbol being redefined as initialized | 
|---|
| 400 | data is OK | 
|---|
| 401 |  | 
|---|
| 402 | A .comm/.lcomm symbol being redefined with a larger | 
|---|
| 403 | size is also OK | 
|---|
| 404 |  | 
|---|
| 405 | This only used to be allowed on VMS gas, but Sun cc | 
|---|
| 406 | on the sparc also depends on it.  */ | 
|---|
| 407 |  | 
|---|
| 408 | if (((!S_IS_DEBUG (symbolP) | 
|---|
| 409 | && (!S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP)) | 
|---|
| 410 | && S_IS_EXTERNAL (symbolP)) | 
|---|
| 411 | || S_GET_SEGMENT (symbolP) == bss_section) | 
|---|
| 412 | && (now_seg == data_section | 
|---|
| 413 | || now_seg == S_GET_SEGMENT (symbolP))) | 
|---|
| 414 | { | 
|---|
| 415 | /* Select which of the 2 cases this is.  */ | 
|---|
| 416 | if (now_seg != data_section) | 
|---|
| 417 | { | 
|---|
| 418 | /* New .comm for prev .comm symbol. | 
|---|
| 419 |  | 
|---|
| 420 | If the new size is larger we just change its | 
|---|
| 421 | value.  If the new size is smaller, we ignore | 
|---|
| 422 | this symbol.  */ | 
|---|
| 423 | if (S_GET_VALUE (symbolP) | 
|---|
| 424 | < ((unsigned) frag_now_fix ())) | 
|---|
| 425 | { | 
|---|
| 426 | S_SET_VALUE (symbolP, (valueT) frag_now_fix ()); | 
|---|
| 427 | } | 
|---|
| 428 | } | 
|---|
| 429 | else | 
|---|
| 430 | { | 
|---|
| 431 | /* It is a .comm/.lcomm being converted to initialized | 
|---|
| 432 | data.  */ | 
|---|
| 433 | symbolP->sy_frag = frag_now; | 
|---|
| 434 | #ifdef OBJ_VMS | 
|---|
| 435 | S_SET_OTHER (symbolP, const_flag); | 
|---|
| 436 | #endif | 
|---|
| 437 | S_SET_VALUE (symbolP, (valueT) frag_now_fix ()); | 
|---|
| 438 | S_SET_SEGMENT (symbolP, now_seg); /* Keep N_EXT bit.  */ | 
|---|
| 439 | } | 
|---|
| 440 | } | 
|---|
| 441 | else | 
|---|
| 442 | { | 
|---|
| 443 | #if (!defined (OBJ_AOUT) && !defined (OBJ_MAYBE_AOUT) \ | 
|---|
| 444 | && !defined (OBJ_BOUT) && !defined (OBJ_MAYBE_BOUT)) | 
|---|
| 445 | static const char *od_buf = ""; | 
|---|
| 446 | #else | 
|---|
| 447 | char od_buf[100]; | 
|---|
| 448 | od_buf[0] = '\0'; | 
|---|
| 449 | #ifdef BFD_ASSEMBLER | 
|---|
| 450 | if (OUTPUT_FLAVOR == bfd_target_aout_flavour) | 
|---|
| 451 | #endif | 
|---|
| 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"), | 
|---|
| 457 | sym_name, | 
|---|
| 458 | segment_name (S_GET_SEGMENT (symbolP)), | 
|---|
| 459 | od_buf, | 
|---|
| 460 | (long) S_GET_VALUE (symbolP)); | 
|---|
| 461 | } | 
|---|
| 462 | }                   /* if the undefined symbol has no value  */ | 
|---|
| 463 | } | 
|---|
| 464 | else | 
|---|
| 465 | { | 
|---|
| 466 | /* Don't blow up if the definition is the same.  */ | 
|---|
| 467 | if (!(frag_now == symbolP->sy_frag | 
|---|
| 468 | && S_GET_VALUE (symbolP) == frag_now_fix () | 
|---|
| 469 | && S_GET_SEGMENT (symbolP) == now_seg)) | 
|---|
| 470 | as_bad (_("symbol `%s' is already defined"), sym_name); | 
|---|
| 471 | } | 
|---|
| 472 |  | 
|---|
| 473 | } | 
|---|
| 474 | #ifdef BFD_ASSEMBLER | 
|---|
| 475 | else if (! flag_keep_locals && bfd_is_local_label_name (stdoutput, sym_name)) | 
|---|
| 476 | { | 
|---|
| 477 | symbolP = (symbolS *) local_symbol_make (sym_name, now_seg, | 
|---|
| 478 | (valueT) frag_now_fix (), | 
|---|
| 479 | frag_now); | 
|---|
| 480 | } | 
|---|
| 481 | #endif /* BFD_ASSEMBLER */ | 
|---|
| 482 | else | 
|---|
| 483 | { | 
|---|
| 484 | symbolP = symbol_new (sym_name, now_seg, (valueT) frag_now_fix (), | 
|---|
| 485 | frag_now); | 
|---|
| 486 | #ifdef OBJ_VMS | 
|---|
| 487 | S_SET_OTHER (symbolP, const_flag); | 
|---|
| 488 | #endif /* OBJ_VMS */ | 
|---|
| 489 |  | 
|---|
| 490 | symbol_table_insert (symbolP); | 
|---|
| 491 | } | 
|---|
| 492 |  | 
|---|
| 493 | if (mri_common_symbol != NULL) | 
|---|
| 494 | { | 
|---|
| 495 | /* This symbol is actually being defined within an MRI common | 
|---|
| 496 | section.  This requires special handling.  */ | 
|---|
| 497 | if (LOCAL_SYMBOL_CHECK (symbolP)) | 
|---|
| 498 | symbolP = local_symbol_convert ((struct local_symbol *) symbolP); | 
|---|
| 499 | symbolP->sy_value.X_op = O_symbol; | 
|---|
| 500 | symbolP->sy_value.X_add_symbol = mri_common_symbol; | 
|---|
| 501 | symbolP->sy_value.X_add_number = S_GET_VALUE (mri_common_symbol); | 
|---|
| 502 | symbolP->sy_frag = &zero_address_frag; | 
|---|
| 503 | S_SET_SEGMENT (symbolP, expr_section); | 
|---|
| 504 | symbolP->sy_mri_common = 1; | 
|---|
| 505 | } | 
|---|
| 506 |  | 
|---|
| 507 | #ifdef tc_frob_label | 
|---|
| 508 | tc_frob_label (symbolP); | 
|---|
| 509 | #endif | 
|---|
| 510 | #ifdef obj_frob_label | 
|---|
| 511 | obj_frob_label (symbolP); | 
|---|
| 512 | #endif | 
|---|
| 513 |  | 
|---|
| 514 | return symbolP; | 
|---|
| 515 | } | 
|---|
| 516 |  | 
|---|
| 517 |  | 
|---|
| 518 | /* Die if we can't insert the symbol.  */ | 
|---|
| 519 |  | 
|---|
| 520 | void | 
|---|
| 521 | symbol_table_insert (symbolP) | 
|---|
| 522 | symbolS *symbolP; | 
|---|
| 523 | { | 
|---|
| 524 | register const char *error_string; | 
|---|
| 525 |  | 
|---|
| 526 | know (symbolP); | 
|---|
| 527 | know (S_GET_NAME (symbolP)); | 
|---|
| 528 |  | 
|---|
| 529 | if (LOCAL_SYMBOL_CHECK (symbolP)) | 
|---|
| 530 | { | 
|---|
| 531 | error_string = hash_jam (local_hash, S_GET_NAME (symbolP), | 
|---|
| 532 | (PTR) symbolP); | 
|---|
| 533 | if (error_string != NULL) | 
|---|
| 534 | as_fatal (_("inserting \"%s\" into symbol table failed: %s"), | 
|---|
| 535 | S_GET_NAME (symbolP), error_string); | 
|---|
| 536 | return; | 
|---|
| 537 | } | 
|---|
| 538 |  | 
|---|
| 539 | if ((error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (PTR) symbolP))) | 
|---|
| 540 | { | 
|---|
| 541 | as_fatal (_("inserting \"%s\" into symbol table failed: %s"), | 
|---|
| 542 | S_GET_NAME (symbolP), error_string); | 
|---|
| 543 | }                           /* on error  */ | 
|---|
| 544 | } | 
|---|
| 545 |  | 
|---|
| 546 |  | 
|---|
| 547 | /* If a symbol name does not exist, create it as undefined, and insert | 
|---|
| 548 | it into the symbol table.  Return a pointer to it.  */ | 
|---|
| 549 |  | 
|---|
| 550 | symbolS * | 
|---|
| 551 | symbol_find_or_make (name) | 
|---|
| 552 | const char *name; | 
|---|
| 553 | { | 
|---|
| 554 | register symbolS *symbolP; | 
|---|
| 555 |  | 
|---|
| 556 | symbolP = symbol_find (name); | 
|---|
| 557 |  | 
|---|
| 558 | if (symbolP == NULL) | 
|---|
| 559 | { | 
|---|
| 560 | #ifdef BFD_ASSEMBLER | 
|---|
| 561 | if (! flag_keep_locals && bfd_is_local_label_name (stdoutput, name)) | 
|---|
| 562 | { | 
|---|
| 563 | symbolP = md_undefined_symbol ((char *) name); | 
|---|
| 564 | if (symbolP != NULL) | 
|---|
| 565 | return symbolP; | 
|---|
| 566 |  | 
|---|
| 567 | symbolP = (symbolS *) local_symbol_make (name, undefined_section, | 
|---|
| 568 | (valueT) 0, | 
|---|
| 569 | &zero_address_frag); | 
|---|
| 570 | return symbolP; | 
|---|
| 571 | } | 
|---|
| 572 | #endif | 
|---|
| 573 |  | 
|---|
| 574 | symbolP = symbol_make (name); | 
|---|
| 575 |  | 
|---|
| 576 | symbol_table_insert (symbolP); | 
|---|
| 577 | }                           /* if symbol wasn't found */ | 
|---|
| 578 |  | 
|---|
| 579 | return (symbolP); | 
|---|
| 580 | } | 
|---|
| 581 |  | 
|---|
| 582 | symbolS * | 
|---|
| 583 | symbol_make (name) | 
|---|
| 584 | const char *name; | 
|---|
| 585 | { | 
|---|
| 586 | symbolS *symbolP; | 
|---|
| 587 |  | 
|---|
| 588 | /* Let the machine description default it, e.g. for register names.  */ | 
|---|
| 589 | symbolP = md_undefined_symbol ((char *) name); | 
|---|
| 590 |  | 
|---|
| 591 | if (!symbolP) | 
|---|
| 592 | symbolP = symbol_new (name, undefined_section, (valueT) 0, &zero_address_frag); | 
|---|
| 593 |  | 
|---|
| 594 | return (symbolP); | 
|---|
| 595 | } | 
|---|
| 596 |  | 
|---|
| 597 | /* Implement symbol table lookup. | 
|---|
| 598 | In:  A symbol's name as a string: '\0' can't be part of a symbol name. | 
|---|
| 599 | Out: NULL if the name was not in the symbol table, else the address | 
|---|
| 600 | of a struct symbol associated with that name.  */ | 
|---|
| 601 |  | 
|---|
| 602 | symbolS * | 
|---|
| 603 | symbol_find (name) | 
|---|
| 604 | const char *name; | 
|---|
| 605 | { | 
|---|
| 606 | #ifdef STRIP_UNDERSCORE | 
|---|
| 607 | return (symbol_find_base (name, 1)); | 
|---|
| 608 | #else /* STRIP_UNDERSCORE */ | 
|---|
| 609 | return (symbol_find_base (name, 0)); | 
|---|
| 610 | #endif /* STRIP_UNDERSCORE */ | 
|---|
| 611 | } | 
|---|
| 612 |  | 
|---|
| 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 * | 
|---|
| 631 | symbol_find_base (name, strip_underscore) | 
|---|
| 632 | const char *name; | 
|---|
| 633 | int strip_underscore; | 
|---|
| 634 | { | 
|---|
| 635 | if (strip_underscore && *name == '_') | 
|---|
| 636 | name++; | 
|---|
| 637 |  | 
|---|
| 638 | #ifdef tc_canonicalize_symbol_name | 
|---|
| 639 | { | 
|---|
| 640 | char *copy; | 
|---|
| 641 | size_t len = strlen (name) + 1; | 
|---|
| 642 |  | 
|---|
| 643 | copy = (char *) alloca (len); | 
|---|
| 644 | memcpy (copy, name, len); | 
|---|
| 645 | name = tc_canonicalize_symbol_name (copy); | 
|---|
| 646 | } | 
|---|
| 647 | #endif | 
|---|
| 648 |  | 
|---|
| 649 | if (! symbols_case_sensitive) | 
|---|
| 650 | { | 
|---|
| 651 | char *copy; | 
|---|
| 652 | const char *orig; | 
|---|
| 653 | unsigned char c; | 
|---|
| 654 |  | 
|---|
| 655 | orig = name; | 
|---|
| 656 | name = copy = (char *) alloca (strlen (name) + 1); | 
|---|
| 657 |  | 
|---|
| 658 | while ((c = *orig++) != '\0') | 
|---|
| 659 | { | 
|---|
| 660 | *copy++ = TOUPPER (c); | 
|---|
| 661 | } | 
|---|
| 662 | *copy = '\0'; | 
|---|
| 663 | } | 
|---|
| 664 |  | 
|---|
| 665 | return symbol_find_exact (name); | 
|---|
| 666 | } | 
|---|
| 667 |  | 
|---|
| 668 | /* Once upon a time, symbols were kept in a singly linked list.  At | 
|---|
| 669 | least coff needs to be able to rearrange them from time to time, for | 
|---|
| 670 | which a doubly linked list is much more convenient.  Loic did these | 
|---|
| 671 | as macros which seemed dangerous to me so they're now functions. | 
|---|
| 672 | xoxorich.  */ | 
|---|
| 673 |  | 
|---|
| 674 | /* Link symbol ADDME after symbol TARGET in the chain.  */ | 
|---|
| 675 |  | 
|---|
| 676 | void | 
|---|
| 677 | symbol_append (addme, target, rootPP, lastPP) | 
|---|
| 678 | symbolS *addme; | 
|---|
| 679 | symbolS *target; | 
|---|
| 680 | symbolS **rootPP; | 
|---|
| 681 | symbolS **lastPP; | 
|---|
| 682 | { | 
|---|
| 683 | if (LOCAL_SYMBOL_CHECK (addme)) | 
|---|
| 684 | abort (); | 
|---|
| 685 | if (target != NULL && LOCAL_SYMBOL_CHECK (target)) | 
|---|
| 686 | abort (); | 
|---|
| 687 |  | 
|---|
| 688 | if (target == NULL) | 
|---|
| 689 | { | 
|---|
| 690 | know (*rootPP == NULL); | 
|---|
| 691 | know (*lastPP == NULL); | 
|---|
| 692 | addme->sy_next = NULL; | 
|---|
| 693 | #ifdef SYMBOLS_NEED_BACKPOINTERS | 
|---|
| 694 | addme->sy_previous = NULL; | 
|---|
| 695 | #endif | 
|---|
| 696 | *rootPP = addme; | 
|---|
| 697 | *lastPP = addme; | 
|---|
| 698 | return; | 
|---|
| 699 | }                           /* if the list is empty  */ | 
|---|
| 700 |  | 
|---|
| 701 | if (target->sy_next != NULL) | 
|---|
| 702 | { | 
|---|
| 703 | #ifdef SYMBOLS_NEED_BACKPOINTERS | 
|---|
| 704 | target->sy_next->sy_previous = addme; | 
|---|
| 705 | #endif /* SYMBOLS_NEED_BACKPOINTERS */ | 
|---|
| 706 | } | 
|---|
| 707 | else | 
|---|
| 708 | { | 
|---|
| 709 | know (*lastPP == target); | 
|---|
| 710 | *lastPP = addme; | 
|---|
| 711 | }                           /* if we have a next  */ | 
|---|
| 712 |  | 
|---|
| 713 | addme->sy_next = target->sy_next; | 
|---|
| 714 | target->sy_next = addme; | 
|---|
| 715 |  | 
|---|
| 716 | #ifdef SYMBOLS_NEED_BACKPOINTERS | 
|---|
| 717 | addme->sy_previous = target; | 
|---|
| 718 | #endif /* SYMBOLS_NEED_BACKPOINTERS */ | 
|---|
| 719 |  | 
|---|
| 720 | debug_verify_symchain (symbol_rootP, symbol_lastP); | 
|---|
| 721 | } | 
|---|
| 722 |  | 
|---|
| 723 | /* Set the chain pointers of SYMBOL to null.  */ | 
|---|
| 724 |  | 
|---|
| 725 | void | 
|---|
| 726 | symbol_clear_list_pointers (symbolP) | 
|---|
| 727 | symbolS *symbolP; | 
|---|
| 728 | { | 
|---|
| 729 | if (LOCAL_SYMBOL_CHECK (symbolP)) | 
|---|
| 730 | abort (); | 
|---|
| 731 | symbolP->sy_next = NULL; | 
|---|
| 732 | #ifdef SYMBOLS_NEED_BACKPOINTERS | 
|---|
| 733 | symbolP->sy_previous = NULL; | 
|---|
| 734 | #endif | 
|---|
| 735 | } | 
|---|
| 736 |  | 
|---|
| 737 | #ifdef SYMBOLS_NEED_BACKPOINTERS | 
|---|
| 738 | /* Remove SYMBOLP from the list.  */ | 
|---|
| 739 |  | 
|---|
| 740 | void | 
|---|
| 741 | symbol_remove (symbolP, rootPP, lastPP) | 
|---|
| 742 | symbolS *symbolP; | 
|---|
| 743 | symbolS **rootPP; | 
|---|
| 744 | symbolS **lastPP; | 
|---|
| 745 | { | 
|---|
| 746 | if (LOCAL_SYMBOL_CHECK (symbolP)) | 
|---|
| 747 | abort (); | 
|---|
| 748 |  | 
|---|
| 749 | if (symbolP == *rootPP) | 
|---|
| 750 | { | 
|---|
| 751 | *rootPP = symbolP->sy_next; | 
|---|
| 752 | }                           /* if it was the root  */ | 
|---|
| 753 |  | 
|---|
| 754 | if (symbolP == *lastPP) | 
|---|
| 755 | { | 
|---|
| 756 | *lastPP = symbolP->sy_previous; | 
|---|
| 757 | }                           /* if it was the tail  */ | 
|---|
| 758 |  | 
|---|
| 759 | if (symbolP->sy_next != NULL) | 
|---|
| 760 | { | 
|---|
| 761 | symbolP->sy_next->sy_previous = symbolP->sy_previous; | 
|---|
| 762 | }                           /* if not last  */ | 
|---|
| 763 |  | 
|---|
| 764 | if (symbolP->sy_previous != NULL) | 
|---|
| 765 | { | 
|---|
| 766 | symbolP->sy_previous->sy_next = symbolP->sy_next; | 
|---|
| 767 | }                           /* if not first  */ | 
|---|
| 768 |  | 
|---|
| 769 | debug_verify_symchain (*rootPP, *lastPP); | 
|---|
| 770 | } | 
|---|
| 771 |  | 
|---|
| 772 | /* Link symbol ADDME before symbol TARGET in the chain.  */ | 
|---|
| 773 |  | 
|---|
| 774 | void | 
|---|
| 775 | symbol_insert (addme, target, rootPP, lastPP) | 
|---|
| 776 | symbolS *addme; | 
|---|
| 777 | symbolS *target; | 
|---|
| 778 | symbolS **rootPP; | 
|---|
| 779 | symbolS **lastPP ATTRIBUTE_UNUSED; | 
|---|
| 780 | { | 
|---|
| 781 | if (LOCAL_SYMBOL_CHECK (addme)) | 
|---|
| 782 | abort (); | 
|---|
| 783 | if (LOCAL_SYMBOL_CHECK (target)) | 
|---|
| 784 | abort (); | 
|---|
| 785 |  | 
|---|
| 786 | if (target->sy_previous != NULL) | 
|---|
| 787 | { | 
|---|
| 788 | target->sy_previous->sy_next = addme; | 
|---|
| 789 | } | 
|---|
| 790 | else | 
|---|
| 791 | { | 
|---|
| 792 | know (*rootPP == target); | 
|---|
| 793 | *rootPP = addme; | 
|---|
| 794 | }                           /* if not first  */ | 
|---|
| 795 |  | 
|---|
| 796 | addme->sy_previous = target->sy_previous; | 
|---|
| 797 | target->sy_previous = addme; | 
|---|
| 798 | addme->sy_next = target; | 
|---|
| 799 |  | 
|---|
| 800 | debug_verify_symchain (*rootPP, *lastPP); | 
|---|
| 801 | } | 
|---|
| 802 |  | 
|---|
| 803 | #endif /* SYMBOLS_NEED_BACKPOINTERS */ | 
|---|
| 804 |  | 
|---|
| 805 | void | 
|---|
| 806 | verify_symbol_chain (rootP, lastP) | 
|---|
| 807 | symbolS *rootP; | 
|---|
| 808 | symbolS *lastP; | 
|---|
| 809 | { | 
|---|
| 810 | symbolS *symbolP = rootP; | 
|---|
| 811 |  | 
|---|
| 812 | if (symbolP == NULL) | 
|---|
| 813 | return; | 
|---|
| 814 |  | 
|---|
| 815 | for (; symbol_next (symbolP) != NULL; symbolP = symbol_next (symbolP)) | 
|---|
| 816 | { | 
|---|
| 817 | #ifdef BFD_ASSEMBLER | 
|---|
| 818 | assert (symbolP->bsym != NULL); | 
|---|
| 819 | #endif | 
|---|
| 820 | #ifdef SYMBOLS_NEED_BACKPOINTERS | 
|---|
| 821 | assert (symbolP->sy_next->sy_previous == symbolP); | 
|---|
| 822 | #else | 
|---|
| 823 | /* Walk the list anyways, to make sure pointers are still good.  */ | 
|---|
| 824 | ; | 
|---|
| 825 | #endif /* SYMBOLS_NEED_BACKPOINTERS */ | 
|---|
| 826 | } | 
|---|
| 827 |  | 
|---|
| 828 | assert (lastP == symbolP); | 
|---|
| 829 | } | 
|---|
| 830 |  | 
|---|
| 831 | void | 
|---|
| 832 | verify_symbol_chain_2 (sym) | 
|---|
| 833 | symbolS *sym; | 
|---|
| 834 | { | 
|---|
| 835 | symbolS *p = sym, *n = sym; | 
|---|
| 836 | #ifdef SYMBOLS_NEED_BACKPOINTERS | 
|---|
| 837 | while (symbol_previous (p)) | 
|---|
| 838 | p = symbol_previous (p); | 
|---|
| 839 | #endif | 
|---|
| 840 | while (symbol_next (n)) | 
|---|
| 841 | n = symbol_next (n); | 
|---|
| 842 | verify_symbol_chain (p, n); | 
|---|
| 843 | } | 
|---|
| 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 |  | 
|---|
| 902 | /* Resolve the value of a symbol.  This is called during the final | 
|---|
| 903 | pass over the symbol table to resolve any symbols with complex | 
|---|
| 904 | values.  */ | 
|---|
| 905 |  | 
|---|
| 906 | valueT | 
|---|
| 907 | resolve_symbol_value (symp) | 
|---|
| 908 | symbolS *symp; | 
|---|
| 909 | { | 
|---|
| 910 | int resolved; | 
|---|
| 911 | valueT final_val = 0; | 
|---|
| 912 | segT final_seg; | 
|---|
| 913 |  | 
|---|
| 914 | #ifdef BFD_ASSEMBLER | 
|---|
| 915 | if (LOCAL_SYMBOL_CHECK (symp)) | 
|---|
| 916 | { | 
|---|
| 917 | struct local_symbol *locsym = (struct local_symbol *) symp; | 
|---|
| 918 |  | 
|---|
| 919 | final_val = locsym->lsy_value; | 
|---|
| 920 | if (local_symbol_resolved_p (locsym)) | 
|---|
| 921 | return final_val; | 
|---|
| 922 |  | 
|---|
| 923 | final_val += local_symbol_get_frag (locsym)->fr_address / OCTETS_PER_BYTE; | 
|---|
| 924 |  | 
|---|
| 925 | if (finalize_syms) | 
|---|
| 926 | { | 
|---|
| 927 | locsym->lsy_value = final_val; | 
|---|
| 928 | local_symbol_mark_resolved (locsym); | 
|---|
| 929 | } | 
|---|
| 930 |  | 
|---|
| 931 | return final_val; | 
|---|
| 932 | } | 
|---|
| 933 | #endif | 
|---|
| 934 |  | 
|---|
| 935 | if (symp->sy_resolved) | 
|---|
| 936 | { | 
|---|
| 937 | if (symp->sy_value.X_op == O_constant) | 
|---|
| 938 | return (valueT) symp->sy_value.X_add_number; | 
|---|
| 939 | else | 
|---|
| 940 | return 0; | 
|---|
| 941 | } | 
|---|
| 942 |  | 
|---|
| 943 | resolved = 0; | 
|---|
| 944 | final_seg = S_GET_SEGMENT (symp); | 
|---|
| 945 |  | 
|---|
| 946 | if (symp->sy_resolving) | 
|---|
| 947 | { | 
|---|
| 948 | if (finalize_syms) | 
|---|
| 949 | as_bad (_("symbol definition loop encountered at `%s'"), | 
|---|
| 950 | S_GET_NAME (symp)); | 
|---|
| 951 | final_val = 0; | 
|---|
| 952 | resolved = 1; | 
|---|
| 953 | } | 
|---|
| 954 | else | 
|---|
| 955 | { | 
|---|
| 956 | symbolS *add_symbol, *op_symbol; | 
|---|
| 957 | offsetT left, right; | 
|---|
| 958 | segT seg_left, seg_right; | 
|---|
| 959 | operatorT op; | 
|---|
| 960 |  | 
|---|
| 961 | symp->sy_resolving = 1; | 
|---|
| 962 |  | 
|---|
| 963 | /* Help out with CSE.  */ | 
|---|
| 964 | add_symbol = symp->sy_value.X_add_symbol; | 
|---|
| 965 | op_symbol = symp->sy_value.X_op_symbol; | 
|---|
| 966 | final_val = symp->sy_value.X_add_number; | 
|---|
| 967 | op = symp->sy_value.X_op; | 
|---|
| 968 |  | 
|---|
| 969 | switch (op) | 
|---|
| 970 | { | 
|---|
| 971 | default: | 
|---|
| 972 | BAD_CASE (op); | 
|---|
| 973 | break; | 
|---|
| 974 |  | 
|---|
| 975 | case O_absent: | 
|---|
| 976 | final_val = 0; | 
|---|
| 977 | /* Fall through.  */ | 
|---|
| 978 |  | 
|---|
| 979 | case O_constant: | 
|---|
| 980 | final_val += symp->sy_frag->fr_address / OCTETS_PER_BYTE; | 
|---|
| 981 | if (final_seg == expr_section) | 
|---|
| 982 | final_seg = absolute_section; | 
|---|
| 983 | resolved = 1; | 
|---|
| 984 | break; | 
|---|
| 985 |  | 
|---|
| 986 | case O_symbol: | 
|---|
| 987 | case O_symbol_rva: | 
|---|
| 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 |  | 
|---|
| 993 | do_symbol: | 
|---|
| 994 | if (symp->sy_mri_common) | 
|---|
| 995 | { | 
|---|
| 996 | /* This is a symbol inside an MRI common section.  The | 
|---|
| 997 | relocation routines are going to handle it specially. | 
|---|
| 998 | Don't change the value.  */ | 
|---|
| 999 | resolved = symbol_resolved_p (add_symbol); | 
|---|
| 1000 | break; | 
|---|
| 1001 | } | 
|---|
| 1002 |  | 
|---|
| 1003 | if (finalize_syms && final_val == 0) | 
|---|
| 1004 | { | 
|---|
| 1005 | if (LOCAL_SYMBOL_CHECK (add_symbol)) | 
|---|
| 1006 | add_symbol = local_symbol_convert ((struct local_symbol *) | 
|---|
| 1007 | add_symbol); | 
|---|
| 1008 | copy_symbol_attributes (symp, add_symbol); | 
|---|
| 1009 | } | 
|---|
| 1010 |  | 
|---|
| 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.  */ | 
|---|
| 1017 | if (! S_IS_DEFINED (add_symbol) || S_IS_COMMON (add_symbol)) | 
|---|
| 1018 | { | 
|---|
| 1019 | if (finalize_syms) | 
|---|
| 1020 | { | 
|---|
| 1021 | symp->sy_value.X_op = O_symbol; | 
|---|
| 1022 | symp->sy_value.X_add_symbol = add_symbol; | 
|---|
| 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; | 
|---|
| 1027 | } | 
|---|
| 1028 | final_val = 0; | 
|---|
| 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; | 
|---|
| 1049 | goto exit_dont_set_value; | 
|---|
| 1050 | } | 
|---|
| 1051 | else | 
|---|
| 1052 | { | 
|---|
| 1053 | final_val += symp->sy_frag->fr_address + left; | 
|---|
| 1054 | if (final_seg == expr_section || final_seg == undefined_section) | 
|---|
| 1055 | final_seg = seg_left; | 
|---|
| 1056 | } | 
|---|
| 1057 |  | 
|---|
| 1058 | resolved = symbol_resolved_p (add_symbol); | 
|---|
| 1059 | break; | 
|---|
| 1060 |  | 
|---|
| 1061 | case O_uminus: | 
|---|
| 1062 | case O_bit_not: | 
|---|
| 1063 | case O_logical_not: | 
|---|
| 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; | 
|---|
| 1077 |  | 
|---|
| 1078 | if (op == O_uminus) | 
|---|
| 1079 | left = -left; | 
|---|
| 1080 | else if (op == O_logical_not) | 
|---|
| 1081 | left = !left; | 
|---|
| 1082 | else | 
|---|
| 1083 | left = ~left; | 
|---|
| 1084 |  | 
|---|
| 1085 | final_val += left + symp->sy_frag->fr_address; | 
|---|
| 1086 |  | 
|---|
| 1087 | resolved = symbol_resolved_p (add_symbol); | 
|---|
| 1088 | break; | 
|---|
| 1089 |  | 
|---|
| 1090 | case O_multiply: | 
|---|
| 1091 | case O_divide: | 
|---|
| 1092 | case O_modulus: | 
|---|
| 1093 | case O_left_shift: | 
|---|
| 1094 | case O_right_shift: | 
|---|
| 1095 | case O_bit_inclusive_or: | 
|---|
| 1096 | case O_bit_or_not: | 
|---|
| 1097 | case O_bit_exclusive_or: | 
|---|
| 1098 | case O_bit_and: | 
|---|
| 1099 | case O_add: | 
|---|
| 1100 | case O_subtract: | 
|---|
| 1101 | case O_eq: | 
|---|
| 1102 | case O_ne: | 
|---|
| 1103 | case O_lt: | 
|---|
| 1104 | case O_le: | 
|---|
| 1105 | case O_ge: | 
|---|
| 1106 | case O_gt: | 
|---|
| 1107 | case O_logical_and: | 
|---|
| 1108 | case O_logical_or: | 
|---|
| 1109 | left = resolve_symbol_value (add_symbol); | 
|---|
| 1110 | right = resolve_symbol_value (op_symbol); | 
|---|
| 1111 | seg_left = S_GET_SEGMENT (add_symbol); | 
|---|
| 1112 | seg_right = S_GET_SEGMENT (op_symbol); | 
|---|
| 1113 |  | 
|---|
| 1114 | /* Simplify addition or subtraction of a constant by folding the | 
|---|
| 1115 | constant into X_add_number.  */ | 
|---|
| 1116 | if (op == O_add) | 
|---|
| 1117 | { | 
|---|
| 1118 | if (seg_right == absolute_section) | 
|---|
| 1119 | { | 
|---|
| 1120 | final_val += right; | 
|---|
| 1121 | goto do_symbol; | 
|---|
| 1122 | } | 
|---|
| 1123 | else if (seg_left == absolute_section) | 
|---|
| 1124 | { | 
|---|
| 1125 | final_val += left; | 
|---|
| 1126 | add_symbol = op_symbol; | 
|---|
| 1127 | left = right; | 
|---|
| 1128 | seg_left = seg_right; | 
|---|
| 1129 | goto do_symbol; | 
|---|
| 1130 | } | 
|---|
| 1131 | } | 
|---|
| 1132 | else if (op == O_subtract) | 
|---|
| 1133 | { | 
|---|
| 1134 | if (seg_right == absolute_section) | 
|---|
| 1135 | { | 
|---|
| 1136 | final_val -= right; | 
|---|
| 1137 | goto do_symbol; | 
|---|
| 1138 | } | 
|---|
| 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; | 
|---|
| 1164 |  | 
|---|
| 1165 | /* Check for division by zero.  */ | 
|---|
| 1166 | if ((op == O_divide || op == O_modulus) && right == 0) | 
|---|
| 1167 | { | 
|---|
| 1168 | /* If seg_right is not absolute_section, then we've | 
|---|
| 1169 | already issued a warning about using a bad symbol.  */ | 
|---|
| 1170 | if (seg_right == absolute_section && finalize_syms) | 
|---|
| 1171 | { | 
|---|
| 1172 | char *file; | 
|---|
| 1173 | unsigned int line; | 
|---|
| 1174 |  | 
|---|
| 1175 | if (expr_symbol_where (symp, &file, &line)) | 
|---|
| 1176 | as_bad_where (file, line, _("division by zero")); | 
|---|
| 1177 | else | 
|---|
| 1178 | as_bad (_("division by zero when setting `%s'"), | 
|---|
| 1179 | S_GET_NAME (symp)); | 
|---|
| 1180 | } | 
|---|
| 1181 |  | 
|---|
| 1182 | right = 1; | 
|---|
| 1183 | } | 
|---|
| 1184 |  | 
|---|
| 1185 | switch (symp->sy_value.X_op) | 
|---|
| 1186 | { | 
|---|
| 1187 | case O_multiply:            left *= right; break; | 
|---|
| 1188 | case O_divide:              left /= right; break; | 
|---|
| 1189 | case O_modulus:             left %= right; break; | 
|---|
| 1190 | case O_left_shift:          left <<= right; break; | 
|---|
| 1191 | case O_right_shift:         left >>= right; break; | 
|---|
| 1192 | case O_bit_inclusive_or:    left |= right; break; | 
|---|
| 1193 | case O_bit_or_not:          left |= ~right; break; | 
|---|
| 1194 | case O_bit_exclusive_or:    left ^= right; break; | 
|---|
| 1195 | case O_bit_and:             left &= right; break; | 
|---|
| 1196 | case O_add:                 left += right; break; | 
|---|
| 1197 | case O_subtract:            left -= right; 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; | 
|---|
| 1207 | case O_lt:  left = left <  right ? ~ (offsetT) 0 : 0; break; | 
|---|
| 1208 | case O_le:  left = left <= right ? ~ (offsetT) 0 : 0; break; | 
|---|
| 1209 | case O_ge:  left = left >= right ? ~ (offsetT) 0 : 0; break; | 
|---|
| 1210 | case O_gt:  left = left >  right ? ~ (offsetT) 0 : 0; break; | 
|---|
| 1211 | case O_logical_and: left = left && right; break; | 
|---|
| 1212 | case O_logical_or:  left = left || right; break; | 
|---|
| 1213 | default:            abort (); | 
|---|
| 1214 | } | 
|---|
| 1215 |  | 
|---|
| 1216 | final_val += symp->sy_frag->fr_address + left; | 
|---|
| 1217 | if (final_seg == expr_section || final_seg == undefined_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 | } | 
|---|
| 1227 | resolved = (symbol_resolved_p (add_symbol) | 
|---|
| 1228 | && symbol_resolved_p (op_symbol)); | 
|---|
| 1229 | break; | 
|---|
| 1230 |  | 
|---|
| 1231 | case O_register: | 
|---|
| 1232 | case O_big: | 
|---|
| 1233 | case O_illegal: | 
|---|
| 1234 | /* Give an error (below) if not in expr_section.  We don't | 
|---|
| 1235 | want to worry about expr_section symbols, because they | 
|---|
| 1236 | are fictional (they are created as part of expression | 
|---|
| 1237 | resolution), and any problems may not actually mean | 
|---|
| 1238 | anything.  */ | 
|---|
| 1239 | break; | 
|---|
| 1240 | } | 
|---|
| 1241 |  | 
|---|
| 1242 | symp->sy_resolving = 0; | 
|---|
| 1243 | } | 
|---|
| 1244 |  | 
|---|
| 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.  */ | 
|---|
| 1251 | #if defined (OBJ_AOUT) && ! defined (BFD_ASSEMBLER) | 
|---|
| 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 |  | 
|---|
| 1258 | /* Don't worry if we can't resolve an expr_section symbol.  */ | 
|---|
| 1259 | if (finalize_syms) | 
|---|
| 1260 | { | 
|---|
| 1261 | if (resolved) | 
|---|
| 1262 | symp->sy_resolved = 1; | 
|---|
| 1263 | else if (S_GET_SEGMENT (symp) != expr_section) | 
|---|
| 1264 | { | 
|---|
| 1265 | as_bad (_("can't resolve value for symbol `%s'"), | 
|---|
| 1266 | S_GET_NAME (symp)); | 
|---|
| 1267 | symp->sy_resolved = 1; | 
|---|
| 1268 | } | 
|---|
| 1269 | } | 
|---|
| 1270 |  | 
|---|
| 1271 | return final_val; | 
|---|
| 1272 | } | 
|---|
| 1273 |  | 
|---|
| 1274 | #ifdef BFD_ASSEMBLER | 
|---|
| 1275 |  | 
|---|
| 1276 | static void resolve_local_symbol PARAMS ((const char *, PTR)); | 
|---|
| 1277 |  | 
|---|
| 1278 | /* A static function passed to hash_traverse.  */ | 
|---|
| 1279 |  | 
|---|
| 1280 | static void | 
|---|
| 1281 | resolve_local_symbol (key, value) | 
|---|
| 1282 | const char *key ATTRIBUTE_UNUSED; | 
|---|
| 1283 | PTR value; | 
|---|
| 1284 | { | 
|---|
| 1285 | if (value != NULL) | 
|---|
| 1286 | resolve_symbol_value (value); | 
|---|
| 1287 | } | 
|---|
| 1288 |  | 
|---|
| 1289 | #endif | 
|---|
| 1290 |  | 
|---|
| 1291 | /* Resolve all local symbols.  */ | 
|---|
| 1292 |  | 
|---|
| 1293 | void | 
|---|
| 1294 | resolve_local_symbol_values () | 
|---|
| 1295 | { | 
|---|
| 1296 | #ifdef BFD_ASSEMBLER | 
|---|
| 1297 | hash_traverse (local_hash, resolve_local_symbol); | 
|---|
| 1298 | #endif | 
|---|
| 1299 | } | 
|---|
| 1300 |  | 
|---|
| 1301 | /* Dollar labels look like a number followed by a dollar sign.  Eg, "42$". | 
|---|
| 1302 | They are *really* local.  That is, they go out of scope whenever we see a | 
|---|
| 1303 | label that isn't local.  Also, like fb labels, there can be multiple | 
|---|
| 1304 | instances of a dollar label.  Therefor, we name encode each instance with | 
|---|
| 1305 | the instance number, keep a list of defined symbols separate from the real | 
|---|
| 1306 | symbol table, and we treat these buggers as a sparse array.  */ | 
|---|
| 1307 |  | 
|---|
| 1308 | static long *dollar_labels; | 
|---|
| 1309 | static long *dollar_label_instances; | 
|---|
| 1310 | static char *dollar_label_defines; | 
|---|
| 1311 | static unsigned long dollar_label_count; | 
|---|
| 1312 | static unsigned long dollar_label_max; | 
|---|
| 1313 |  | 
|---|
| 1314 | int | 
|---|
| 1315 | dollar_label_defined (label) | 
|---|
| 1316 | long label; | 
|---|
| 1317 | { | 
|---|
| 1318 | long *i; | 
|---|
| 1319 |  | 
|---|
| 1320 | know ((dollar_labels != NULL) || (dollar_label_count == 0)); | 
|---|
| 1321 |  | 
|---|
| 1322 | for (i = dollar_labels; i < dollar_labels + dollar_label_count; ++i) | 
|---|
| 1323 | if (*i == label) | 
|---|
| 1324 | return dollar_label_defines[i - dollar_labels]; | 
|---|
| 1325 |  | 
|---|
| 1326 | /* If we get here, label isn't defined.  */ | 
|---|
| 1327 | return 0; | 
|---|
| 1328 | } | 
|---|
| 1329 |  | 
|---|
| 1330 | static long | 
|---|
| 1331 | dollar_label_instance (label) | 
|---|
| 1332 | long label; | 
|---|
| 1333 | { | 
|---|
| 1334 | long *i; | 
|---|
| 1335 |  | 
|---|
| 1336 | know ((dollar_labels != NULL) || (dollar_label_count == 0)); | 
|---|
| 1337 |  | 
|---|
| 1338 | for (i = dollar_labels; i < dollar_labels + dollar_label_count; ++i) | 
|---|
| 1339 | if (*i == label) | 
|---|
| 1340 | return (dollar_label_instances[i - dollar_labels]); | 
|---|
| 1341 |  | 
|---|
| 1342 | /* If we get here, we haven't seen the label before. | 
|---|
| 1343 | Therefore its instance count is zero.  */ | 
|---|
| 1344 | return 0; | 
|---|
| 1345 | } | 
|---|
| 1346 |  | 
|---|
| 1347 | void | 
|---|
| 1348 | dollar_label_clear () | 
|---|
| 1349 | { | 
|---|
| 1350 | memset (dollar_label_defines, '\0', (unsigned int) dollar_label_count); | 
|---|
| 1351 | } | 
|---|
| 1352 |  | 
|---|
| 1353 | #define DOLLAR_LABEL_BUMP_BY 10 | 
|---|
| 1354 |  | 
|---|
| 1355 | void | 
|---|
| 1356 | define_dollar_label (label) | 
|---|
| 1357 | long label; | 
|---|
| 1358 | { | 
|---|
| 1359 | long *i; | 
|---|
| 1360 |  | 
|---|
| 1361 | for (i = dollar_labels; i < dollar_labels + dollar_label_count; ++i) | 
|---|
| 1362 | if (*i == label) | 
|---|
| 1363 | { | 
|---|
| 1364 | ++dollar_label_instances[i - dollar_labels]; | 
|---|
| 1365 | dollar_label_defines[i - dollar_labels] = 1; | 
|---|
| 1366 | return; | 
|---|
| 1367 | } | 
|---|
| 1368 |  | 
|---|
| 1369 | /* If we get to here, we don't have label listed yet.  */ | 
|---|
| 1370 |  | 
|---|
| 1371 | if (dollar_labels == NULL) | 
|---|
| 1372 | { | 
|---|
| 1373 | dollar_labels = (long *) xmalloc (DOLLAR_LABEL_BUMP_BY * sizeof (long)); | 
|---|
| 1374 | dollar_label_instances = (long *) xmalloc (DOLLAR_LABEL_BUMP_BY * sizeof (long)); | 
|---|
| 1375 | dollar_label_defines = xmalloc (DOLLAR_LABEL_BUMP_BY); | 
|---|
| 1376 | dollar_label_max = DOLLAR_LABEL_BUMP_BY; | 
|---|
| 1377 | dollar_label_count = 0; | 
|---|
| 1378 | } | 
|---|
| 1379 | else if (dollar_label_count == dollar_label_max) | 
|---|
| 1380 | { | 
|---|
| 1381 | dollar_label_max += DOLLAR_LABEL_BUMP_BY; | 
|---|
| 1382 | dollar_labels = (long *) xrealloc ((char *) dollar_labels, | 
|---|
| 1383 | dollar_label_max * sizeof (long)); | 
|---|
| 1384 | dollar_label_instances = (long *) xrealloc ((char *) dollar_label_instances, | 
|---|
| 1385 | dollar_label_max * sizeof (long)); | 
|---|
| 1386 | dollar_label_defines = xrealloc (dollar_label_defines, dollar_label_max); | 
|---|
| 1387 | }                           /* if we needed to grow  */ | 
|---|
| 1388 |  | 
|---|
| 1389 | dollar_labels[dollar_label_count] = label; | 
|---|
| 1390 | dollar_label_instances[dollar_label_count] = 1; | 
|---|
| 1391 | dollar_label_defines[dollar_label_count] = 1; | 
|---|
| 1392 | ++dollar_label_count; | 
|---|
| 1393 | } | 
|---|
| 1394 |  | 
|---|
| 1395 | /* Caller must copy returned name: we re-use the area for the next name. | 
|---|
| 1396 |  | 
|---|
| 1397 | The mth occurence of label n: is turned into the symbol "Ln^Am" | 
|---|
| 1398 | where n is the label number and m is the instance number. "L" makes | 
|---|
| 1399 | it a label discarded unless debugging and "^A"('\1') ensures no | 
|---|
| 1400 | ordinary symbol SHOULD get the same name as a local label | 
|---|
| 1401 | symbol. The first "4:" is "L4^A1" - the m numbers begin at 1. | 
|---|
| 1402 |  | 
|---|
| 1403 | fb labels get the same treatment, except that ^B is used in place | 
|---|
| 1404 | of ^A.  */ | 
|---|
| 1405 |  | 
|---|
| 1406 | char *                          /* Return local label name.  */ | 
|---|
| 1407 | dollar_label_name (n, augend) | 
|---|
| 1408 | register long n;           /* we just saw "n$:" : n a number.  */ | 
|---|
| 1409 | register int augend;       /* 0 for current instance, 1 for new instance.  */ | 
|---|
| 1410 | { | 
|---|
| 1411 | long i; | 
|---|
| 1412 | /* Returned to caller, then copied.  Used for created names ("4f").  */ | 
|---|
| 1413 | static char symbol_name_build[24]; | 
|---|
| 1414 | register char *p; | 
|---|
| 1415 | register char *q; | 
|---|
| 1416 | char symbol_name_temporary[20];       /* Build up a number, BACKWARDS.  */ | 
|---|
| 1417 |  | 
|---|
| 1418 | know (n >= 0); | 
|---|
| 1419 | know (augend == 0 || augend == 1); | 
|---|
| 1420 | p = symbol_name_build; | 
|---|
| 1421 | #ifdef LOCAL_LABEL_PREFIX | 
|---|
| 1422 | *p++ = LOCAL_LABEL_PREFIX; | 
|---|
| 1423 | #endif | 
|---|
| 1424 | *p++ = 'L'; | 
|---|
| 1425 |  | 
|---|
| 1426 | /* Next code just does sprintf( {}, "%d", n);  */ | 
|---|
| 1427 | /* Label number.  */ | 
|---|
| 1428 | q = symbol_name_temporary; | 
|---|
| 1429 | for (*q++ = 0, i = n; i; ++q) | 
|---|
| 1430 | { | 
|---|
| 1431 | *q = i % 10 + '0'; | 
|---|
| 1432 | i /= 10; | 
|---|
| 1433 | } | 
|---|
| 1434 | while ((*p = *--q) != '\0') | 
|---|
| 1435 | ++p; | 
|---|
| 1436 |  | 
|---|
| 1437 | *p++ = DOLLAR_LABEL_CHAR;             /* ^A  */ | 
|---|
| 1438 |  | 
|---|
| 1439 | /* Instance number.  */ | 
|---|
| 1440 | q = symbol_name_temporary; | 
|---|
| 1441 | for (*q++ = 0, i = dollar_label_instance (n) + augend; i; ++q) | 
|---|
| 1442 | { | 
|---|
| 1443 | *q = i % 10 + '0'; | 
|---|
| 1444 | i /= 10; | 
|---|
| 1445 | } | 
|---|
| 1446 | while ((*p++ = *--q) != '\0');; | 
|---|
| 1447 |  | 
|---|
| 1448 | /* The label, as a '\0' ended string, starts at symbol_name_build.  */ | 
|---|
| 1449 | return symbol_name_build; | 
|---|
| 1450 | } | 
|---|
| 1451 |  | 
|---|
| 1452 | /* Sombody else's idea of local labels. They are made by "n:" where n | 
|---|
| 1453 | is any decimal digit. Refer to them with | 
|---|
| 1454 | "nb" for previous (backward) n: | 
|---|
| 1455 | or "nf" for next (forward) n:. | 
|---|
| 1456 |  | 
|---|
| 1457 | We do a little better and let n be any number, not just a single digit, but | 
|---|
| 1458 | since the other guy's assembler only does ten, we treat the first ten | 
|---|
| 1459 | specially. | 
|---|
| 1460 |  | 
|---|
| 1461 | Like someone else's assembler, we have one set of local label counters for | 
|---|
| 1462 | entire assembly, not one set per (sub)segment like in most assemblers. This | 
|---|
| 1463 | implies that one can refer to a label in another segment, and indeed some | 
|---|
| 1464 | crufty compilers have done just that. | 
|---|
| 1465 |  | 
|---|
| 1466 | Since there could be a LOT of these things, treat them as a sparse | 
|---|
| 1467 | array.  */ | 
|---|
| 1468 |  | 
|---|
| 1469 | #define FB_LABEL_SPECIAL (10) | 
|---|
| 1470 |  | 
|---|
| 1471 | static long fb_low_counter[FB_LABEL_SPECIAL]; | 
|---|
| 1472 | static long *fb_labels; | 
|---|
| 1473 | static long *fb_label_instances; | 
|---|
| 1474 | static long fb_label_count; | 
|---|
| 1475 | static long fb_label_max; | 
|---|
| 1476 |  | 
|---|
| 1477 | /* This must be more than FB_LABEL_SPECIAL.  */ | 
|---|
| 1478 | #define FB_LABEL_BUMP_BY (FB_LABEL_SPECIAL + 6) | 
|---|
| 1479 |  | 
|---|
| 1480 | static void | 
|---|
| 1481 | fb_label_init () | 
|---|
| 1482 | { | 
|---|
| 1483 | memset ((void *) fb_low_counter, '\0', sizeof (fb_low_counter)); | 
|---|
| 1484 | } | 
|---|
| 1485 |  | 
|---|
| 1486 | /* Add one to the instance number of this fb label.  */ | 
|---|
| 1487 |  | 
|---|
| 1488 | void | 
|---|
| 1489 | fb_label_instance_inc (label) | 
|---|
| 1490 | long label; | 
|---|
| 1491 | { | 
|---|
| 1492 | long *i; | 
|---|
| 1493 |  | 
|---|
| 1494 | if (label < FB_LABEL_SPECIAL) | 
|---|
| 1495 | { | 
|---|
| 1496 | ++fb_low_counter[label]; | 
|---|
| 1497 | return; | 
|---|
| 1498 | } | 
|---|
| 1499 |  | 
|---|
| 1500 | if (fb_labels != NULL) | 
|---|
| 1501 | { | 
|---|
| 1502 | for (i = fb_labels + FB_LABEL_SPECIAL; | 
|---|
| 1503 | i < fb_labels + fb_label_count; ++i) | 
|---|
| 1504 | { | 
|---|
| 1505 | if (*i == label) | 
|---|
| 1506 | { | 
|---|
| 1507 | ++fb_label_instances[i - fb_labels]; | 
|---|
| 1508 | return; | 
|---|
| 1509 | }                   /* if we find it  */ | 
|---|
| 1510 | }                       /* for each existing label  */ | 
|---|
| 1511 | } | 
|---|
| 1512 |  | 
|---|
| 1513 | /* If we get to here, we don't have label listed yet.  */ | 
|---|
| 1514 |  | 
|---|
| 1515 | if (fb_labels == NULL) | 
|---|
| 1516 | { | 
|---|
| 1517 | fb_labels = (long *) xmalloc (FB_LABEL_BUMP_BY * sizeof (long)); | 
|---|
| 1518 | fb_label_instances = (long *) xmalloc (FB_LABEL_BUMP_BY * sizeof (long)); | 
|---|
| 1519 | fb_label_max = FB_LABEL_BUMP_BY; | 
|---|
| 1520 | fb_label_count = FB_LABEL_SPECIAL; | 
|---|
| 1521 |  | 
|---|
| 1522 | } | 
|---|
| 1523 | else if (fb_label_count == fb_label_max) | 
|---|
| 1524 | { | 
|---|
| 1525 | fb_label_max += FB_LABEL_BUMP_BY; | 
|---|
| 1526 | fb_labels = (long *) xrealloc ((char *) fb_labels, | 
|---|
| 1527 | fb_label_max * sizeof (long)); | 
|---|
| 1528 | fb_label_instances = (long *) xrealloc ((char *) fb_label_instances, | 
|---|
| 1529 | fb_label_max * sizeof (long)); | 
|---|
| 1530 | }                           /* if we needed to grow  */ | 
|---|
| 1531 |  | 
|---|
| 1532 | fb_labels[fb_label_count] = label; | 
|---|
| 1533 | fb_label_instances[fb_label_count] = 1; | 
|---|
| 1534 | ++fb_label_count; | 
|---|
| 1535 | } | 
|---|
| 1536 |  | 
|---|
| 1537 | static long | 
|---|
| 1538 | fb_label_instance (label) | 
|---|
| 1539 | long label; | 
|---|
| 1540 | { | 
|---|
| 1541 | long *i; | 
|---|
| 1542 |  | 
|---|
| 1543 | if (label < FB_LABEL_SPECIAL) | 
|---|
| 1544 | { | 
|---|
| 1545 | return (fb_low_counter[label]); | 
|---|
| 1546 | } | 
|---|
| 1547 |  | 
|---|
| 1548 | if (fb_labels != NULL) | 
|---|
| 1549 | { | 
|---|
| 1550 | for (i = fb_labels + FB_LABEL_SPECIAL; | 
|---|
| 1551 | i < fb_labels + fb_label_count; ++i) | 
|---|
| 1552 | { | 
|---|
| 1553 | if (*i == label) | 
|---|
| 1554 | { | 
|---|
| 1555 | return (fb_label_instances[i - fb_labels]); | 
|---|
| 1556 | }                   /* if we find it  */ | 
|---|
| 1557 | }                       /* for each existing label  */ | 
|---|
| 1558 | } | 
|---|
| 1559 |  | 
|---|
| 1560 | /* We didn't find the label, so this must be a reference to the | 
|---|
| 1561 | first instance.  */ | 
|---|
| 1562 | return 0; | 
|---|
| 1563 | } | 
|---|
| 1564 |  | 
|---|
| 1565 | /* Caller must copy returned name: we re-use the area for the next name. | 
|---|
| 1566 |  | 
|---|
| 1567 | The mth occurence of label n: is turned into the symbol "Ln^Bm" | 
|---|
| 1568 | where n is the label number and m is the instance number. "L" makes | 
|---|
| 1569 | it a label discarded unless debugging and "^B"('\2') ensures no | 
|---|
| 1570 | ordinary symbol SHOULD get the same name as a local label | 
|---|
| 1571 | symbol. The first "4:" is "L4^B1" - the m numbers begin at 1. | 
|---|
| 1572 |  | 
|---|
| 1573 | dollar labels get the same treatment, except that ^A is used in | 
|---|
| 1574 | place of ^B.  */ | 
|---|
| 1575 |  | 
|---|
| 1576 | char *                          /* Return local label name.  */ | 
|---|
| 1577 | fb_label_name (n, augend) | 
|---|
| 1578 | long n;                    /* We just saw "n:", "nf" or "nb" : n a number.  */ | 
|---|
| 1579 | long augend;               /* 0 for nb, 1 for n:, nf.  */ | 
|---|
| 1580 | { | 
|---|
| 1581 | long i; | 
|---|
| 1582 | /* Returned to caller, then copied.  Used for created names ("4f").  */ | 
|---|
| 1583 | static char symbol_name_build[24]; | 
|---|
| 1584 | register char *p; | 
|---|
| 1585 | register char *q; | 
|---|
| 1586 | char symbol_name_temporary[20];       /* Build up a number, BACKWARDS.  */ | 
|---|
| 1587 |  | 
|---|
| 1588 | know (n >= 0); | 
|---|
| 1589 | know (augend == 0 || augend == 1); | 
|---|
| 1590 | p = symbol_name_build; | 
|---|
| 1591 | #ifdef LOCAL_LABEL_PREFIX | 
|---|
| 1592 | *p++ = LOCAL_LABEL_PREFIX; | 
|---|
| 1593 | #endif | 
|---|
| 1594 | *p++ = 'L'; | 
|---|
| 1595 |  | 
|---|
| 1596 | /* Next code just does sprintf( {}, "%d", n);  */ | 
|---|
| 1597 | /* Label number.  */ | 
|---|
| 1598 | q = symbol_name_temporary; | 
|---|
| 1599 | for (*q++ = 0, i = n; i; ++q) | 
|---|
| 1600 | { | 
|---|
| 1601 | *q = i % 10 + '0'; | 
|---|
| 1602 | i /= 10; | 
|---|
| 1603 | } | 
|---|
| 1604 | while ((*p = *--q) != '\0') | 
|---|
| 1605 | ++p; | 
|---|
| 1606 |  | 
|---|
| 1607 | *p++ = LOCAL_LABEL_CHAR;              /* ^B  */ | 
|---|
| 1608 |  | 
|---|
| 1609 | /* Instance number.  */ | 
|---|
| 1610 | q = symbol_name_temporary; | 
|---|
| 1611 | for (*q++ = 0, i = fb_label_instance (n) + augend; i; ++q) | 
|---|
| 1612 | { | 
|---|
| 1613 | *q = i % 10 + '0'; | 
|---|
| 1614 | i /= 10; | 
|---|
| 1615 | } | 
|---|
| 1616 | while ((*p++ = *--q) != '\0');; | 
|---|
| 1617 |  | 
|---|
| 1618 | /* The label, as a '\0' ended string, starts at symbol_name_build.  */ | 
|---|
| 1619 | return (symbol_name_build); | 
|---|
| 1620 | } | 
|---|
| 1621 |  | 
|---|
| 1622 | /* Decode name that may have been generated by foo_label_name() above. | 
|---|
| 1623 | If the name wasn't generated by foo_label_name(), then return it | 
|---|
| 1624 | unaltered.  This is used for error messages.  */ | 
|---|
| 1625 |  | 
|---|
| 1626 | char * | 
|---|
| 1627 | decode_local_label_name (s) | 
|---|
| 1628 | char *s; | 
|---|
| 1629 | { | 
|---|
| 1630 | char *p; | 
|---|
| 1631 | char *symbol_decode; | 
|---|
| 1632 | int label_number; | 
|---|
| 1633 | int instance_number; | 
|---|
| 1634 | char *type; | 
|---|
| 1635 | const char *message_format; | 
|---|
| 1636 | int index = 0; | 
|---|
| 1637 |  | 
|---|
| 1638 | #ifdef LOCAL_LABEL_PREFIX | 
|---|
| 1639 | if (s[index] == LOCAL_LABEL_PREFIX) | 
|---|
| 1640 | ++index; | 
|---|
| 1641 | #endif | 
|---|
| 1642 |  | 
|---|
| 1643 | if (s[index] != 'L') | 
|---|
| 1644 | return s; | 
|---|
| 1645 |  | 
|---|
| 1646 | for (label_number = 0, p = s + index + 1; ISDIGIT (*p); ++p) | 
|---|
| 1647 | label_number = (10 * label_number) + *p - '0'; | 
|---|
| 1648 |  | 
|---|
| 1649 | if (*p == DOLLAR_LABEL_CHAR) | 
|---|
| 1650 | type = "dollar"; | 
|---|
| 1651 | else if (*p == LOCAL_LABEL_CHAR) | 
|---|
| 1652 | type = "fb"; | 
|---|
| 1653 | else | 
|---|
| 1654 | return s; | 
|---|
| 1655 |  | 
|---|
| 1656 | for (instance_number = 0, p++; ISDIGIT (*p); ++p) | 
|---|
| 1657 | instance_number = (10 * instance_number) + *p - '0'; | 
|---|
| 1658 |  | 
|---|
| 1659 | message_format = _("\"%d\" (instance number %d of a %s label)"); | 
|---|
| 1660 | symbol_decode = obstack_alloc (¬es, strlen (message_format) + 30); | 
|---|
| 1661 | sprintf (symbol_decode, message_format, label_number, instance_number, type); | 
|---|
| 1662 |  | 
|---|
| 1663 | return symbol_decode; | 
|---|
| 1664 | } | 
|---|
| 1665 |  | 
|---|
| 1666 | /* Get the value of a symbol.  */ | 
|---|
| 1667 |  | 
|---|
| 1668 | valueT | 
|---|
| 1669 | S_GET_VALUE (s) | 
|---|
| 1670 | symbolS *s; | 
|---|
| 1671 | { | 
|---|
| 1672 | #ifdef BFD_ASSEMBLER | 
|---|
| 1673 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 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 | } | 
|---|
| 1683 | if (s->sy_value.X_op != O_constant) | 
|---|
| 1684 | { | 
|---|
| 1685 | static symbolS *recur; | 
|---|
| 1686 |  | 
|---|
| 1687 | /* FIXME: In non BFD assemblers, S_IS_DEFINED and S_IS_COMMON | 
|---|
| 1688 | may call S_GET_VALUE.  We use a static symbol to avoid the | 
|---|
| 1689 | immediate recursion.  */ | 
|---|
| 1690 | if (recur == s) | 
|---|
| 1691 | return (valueT) s->sy_value.X_add_number; | 
|---|
| 1692 | recur = s; | 
|---|
| 1693 | if (! s->sy_resolved | 
|---|
| 1694 | || s->sy_value.X_op != O_symbol | 
|---|
| 1695 | || (S_IS_DEFINED (s) && ! S_IS_COMMON (s))) | 
|---|
| 1696 | as_bad (_("attempt to get value of unresolved symbol `%s'"), | 
|---|
| 1697 | S_GET_NAME (s)); | 
|---|
| 1698 | recur = NULL; | 
|---|
| 1699 | } | 
|---|
| 1700 | return (valueT) s->sy_value.X_add_number; | 
|---|
| 1701 | } | 
|---|
| 1702 |  | 
|---|
| 1703 | /* Set the value of a symbol.  */ | 
|---|
| 1704 |  | 
|---|
| 1705 | void | 
|---|
| 1706 | S_SET_VALUE (s, val) | 
|---|
| 1707 | symbolS *s; | 
|---|
| 1708 | valueT val; | 
|---|
| 1709 | { | 
|---|
| 1710 | #ifdef BFD_ASSEMBLER | 
|---|
| 1711 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1712 | { | 
|---|
| 1713 | ((struct local_symbol *) s)->lsy_value = val; | 
|---|
| 1714 | return; | 
|---|
| 1715 | } | 
|---|
| 1716 | #endif | 
|---|
| 1717 |  | 
|---|
| 1718 | s->sy_value.X_op = O_constant; | 
|---|
| 1719 | s->sy_value.X_add_number = (offsetT) val; | 
|---|
| 1720 | s->sy_value.X_unsigned = 0; | 
|---|
| 1721 | } | 
|---|
| 1722 |  | 
|---|
| 1723 | void | 
|---|
| 1724 | copy_symbol_attributes (dest, src) | 
|---|
| 1725 | symbolS *dest, *src; | 
|---|
| 1726 | { | 
|---|
| 1727 | if (LOCAL_SYMBOL_CHECK (dest)) | 
|---|
| 1728 | dest = local_symbol_convert ((struct local_symbol *) dest); | 
|---|
| 1729 | if (LOCAL_SYMBOL_CHECK (src)) | 
|---|
| 1730 | src = local_symbol_convert ((struct local_symbol *) src); | 
|---|
| 1731 |  | 
|---|
| 1732 | #ifdef BFD_ASSEMBLER | 
|---|
| 1733 | /* In an expression, transfer the settings of these flags. | 
|---|
| 1734 | The user can override later, of course.  */ | 
|---|
| 1735 | #define COPIED_SYMFLAGS (BSF_FUNCTION | BSF_OBJECT) | 
|---|
| 1736 | dest->bsym->flags |= src->bsym->flags & COPIED_SYMFLAGS; | 
|---|
| 1737 | #endif | 
|---|
| 1738 |  | 
|---|
| 1739 | #ifdef OBJ_COPY_SYMBOL_ATTRIBUTES | 
|---|
| 1740 | OBJ_COPY_SYMBOL_ATTRIBUTES (dest, src); | 
|---|
| 1741 | #endif | 
|---|
| 1742 | } | 
|---|
| 1743 |  | 
|---|
| 1744 | #ifdef BFD_ASSEMBLER | 
|---|
| 1745 |  | 
|---|
| 1746 | int | 
|---|
| 1747 | S_IS_FUNCTION (s) | 
|---|
| 1748 | symbolS *s; | 
|---|
| 1749 | { | 
|---|
| 1750 | flagword flags; | 
|---|
| 1751 |  | 
|---|
| 1752 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1753 | return 0; | 
|---|
| 1754 |  | 
|---|
| 1755 | flags = s->bsym->flags; | 
|---|
| 1756 |  | 
|---|
| 1757 | return (flags & BSF_FUNCTION) != 0; | 
|---|
| 1758 | } | 
|---|
| 1759 |  | 
|---|
| 1760 | int | 
|---|
| 1761 | S_IS_EXTERNAL (s) | 
|---|
| 1762 | symbolS *s; | 
|---|
| 1763 | { | 
|---|
| 1764 | flagword flags; | 
|---|
| 1765 |  | 
|---|
| 1766 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1767 | return 0; | 
|---|
| 1768 |  | 
|---|
| 1769 | flags = s->bsym->flags; | 
|---|
| 1770 |  | 
|---|
| 1771 | /* Sanity check.  */ | 
|---|
| 1772 | if ((flags & BSF_LOCAL) && (flags & BSF_GLOBAL)) | 
|---|
| 1773 | abort (); | 
|---|
| 1774 |  | 
|---|
| 1775 | return (flags & BSF_GLOBAL) != 0; | 
|---|
| 1776 | } | 
|---|
| 1777 |  | 
|---|
| 1778 | int | 
|---|
| 1779 | S_IS_WEAK (s) | 
|---|
| 1780 | symbolS *s; | 
|---|
| 1781 | { | 
|---|
| 1782 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1783 | return 0; | 
|---|
| 1784 | return (s->bsym->flags & BSF_WEAK) != 0; | 
|---|
| 1785 | } | 
|---|
| 1786 |  | 
|---|
| 1787 | int | 
|---|
| 1788 | S_IS_COMMON (s) | 
|---|
| 1789 | symbolS *s; | 
|---|
| 1790 | { | 
|---|
| 1791 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1792 | return 0; | 
|---|
| 1793 | return bfd_is_com_section (s->bsym->section); | 
|---|
| 1794 | } | 
|---|
| 1795 |  | 
|---|
| 1796 | int | 
|---|
| 1797 | S_IS_DEFINED (s) | 
|---|
| 1798 | symbolS *s; | 
|---|
| 1799 | { | 
|---|
| 1800 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1801 | return ((struct local_symbol *) s)->lsy_section != undefined_section; | 
|---|
| 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)); | 
|---|
| 1827 | } | 
|---|
| 1828 |  | 
|---|
| 1829 | int | 
|---|
| 1830 | S_IS_DEBUG (s) | 
|---|
| 1831 | symbolS *s; | 
|---|
| 1832 | { | 
|---|
| 1833 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1834 | return 0; | 
|---|
| 1835 | if (s->bsym->flags & BSF_DEBUGGING) | 
|---|
| 1836 | return 1; | 
|---|
| 1837 | return 0; | 
|---|
| 1838 | } | 
|---|
| 1839 |  | 
|---|
| 1840 | int | 
|---|
| 1841 | S_IS_LOCAL (s) | 
|---|
| 1842 | symbolS *s; | 
|---|
| 1843 | { | 
|---|
| 1844 | flagword flags; | 
|---|
| 1845 | const char *name; | 
|---|
| 1846 |  | 
|---|
| 1847 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1848 | return 1; | 
|---|
| 1849 |  | 
|---|
| 1850 | flags = s->bsym->flags; | 
|---|
| 1851 |  | 
|---|
| 1852 | /* Sanity check.  */ | 
|---|
| 1853 | if ((flags & BSF_LOCAL) && (flags & BSF_GLOBAL)) | 
|---|
| 1854 | abort (); | 
|---|
| 1855 |  | 
|---|
| 1856 | if (bfd_get_section (s->bsym) == reg_section) | 
|---|
| 1857 | return 1; | 
|---|
| 1858 |  | 
|---|
| 1859 | if (flag_strip_local_absolute | 
|---|
| 1860 | && (flags & BSF_GLOBAL) == 0 | 
|---|
| 1861 | && bfd_get_section (s->bsym) == absolute_section) | 
|---|
| 1862 | return 1; | 
|---|
| 1863 |  | 
|---|
| 1864 | name = S_GET_NAME (s); | 
|---|
| 1865 | return (name != NULL | 
|---|
| 1866 | && ! S_IS_DEBUG (s) | 
|---|
| 1867 | && (strchr (name, DOLLAR_LABEL_CHAR) | 
|---|
| 1868 | || strchr (name, LOCAL_LABEL_CHAR) | 
|---|
| 1869 | || (! flag_keep_locals | 
|---|
| 1870 | && (bfd_is_local_label (stdoutput, s->bsym) | 
|---|
| 1871 | || (flag_mri | 
|---|
| 1872 | && name[0] == '?' | 
|---|
| 1873 | && name[1] == '?'))))); | 
|---|
| 1874 | } | 
|---|
| 1875 |  | 
|---|
| 1876 | int | 
|---|
| 1877 | S_IS_EXTERN (s) | 
|---|
| 1878 | symbolS *s; | 
|---|
| 1879 | { | 
|---|
| 1880 | return S_IS_EXTERNAL (s); | 
|---|
| 1881 | } | 
|---|
| 1882 |  | 
|---|
| 1883 | int | 
|---|
| 1884 | S_IS_STABD (s) | 
|---|
| 1885 | symbolS *s; | 
|---|
| 1886 | { | 
|---|
| 1887 | return S_GET_NAME (s) == 0; | 
|---|
| 1888 | } | 
|---|
| 1889 |  | 
|---|
| 1890 | const char * | 
|---|
| 1891 | S_GET_NAME (s) | 
|---|
| 1892 | symbolS *s; | 
|---|
| 1893 | { | 
|---|
| 1894 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1895 | return ((struct local_symbol *) s)->lsy_name; | 
|---|
| 1896 | return s->bsym->name; | 
|---|
| 1897 | } | 
|---|
| 1898 |  | 
|---|
| 1899 | segT | 
|---|
| 1900 | S_GET_SEGMENT (s) | 
|---|
| 1901 | symbolS *s; | 
|---|
| 1902 | { | 
|---|
| 1903 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1904 | return ((struct local_symbol *) s)->lsy_section; | 
|---|
| 1905 | return s->bsym->section; | 
|---|
| 1906 | } | 
|---|
| 1907 |  | 
|---|
| 1908 | void | 
|---|
| 1909 | S_SET_SEGMENT (s, seg) | 
|---|
| 1910 | symbolS *s; | 
|---|
| 1911 | segT seg; | 
|---|
| 1912 | { | 
|---|
| 1913 | /* Don't reassign section symbols.  The direct reason is to prevent seg | 
|---|
| 1914 | faults assigning back to const global symbols such as *ABS*, but it | 
|---|
| 1915 | shouldn't happen anyway.  */ | 
|---|
| 1916 |  | 
|---|
| 1917 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1918 | { | 
|---|
| 1919 | if (seg == reg_section) | 
|---|
| 1920 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 1921 | else | 
|---|
| 1922 | { | 
|---|
| 1923 | ((struct local_symbol *) s)->lsy_section = seg; | 
|---|
| 1924 | return; | 
|---|
| 1925 | } | 
|---|
| 1926 | } | 
|---|
| 1927 |  | 
|---|
| 1928 | if (s->bsym->flags & BSF_SECTION_SYM) | 
|---|
| 1929 | { | 
|---|
| 1930 | if (s->bsym->section != seg) | 
|---|
| 1931 | abort (); | 
|---|
| 1932 | } | 
|---|
| 1933 | else | 
|---|
| 1934 | s->bsym->section = seg; | 
|---|
| 1935 | } | 
|---|
| 1936 |  | 
|---|
| 1937 | void | 
|---|
| 1938 | S_SET_EXTERNAL (s) | 
|---|
| 1939 | symbolS *s; | 
|---|
| 1940 | { | 
|---|
| 1941 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1942 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 1943 | if ((s->bsym->flags & BSF_WEAK) != 0) | 
|---|
| 1944 | { | 
|---|
| 1945 | /* Let .weak override .global.  */ | 
|---|
| 1946 | return; | 
|---|
| 1947 | } | 
|---|
| 1948 | if (s->bsym->flags & BSF_SECTION_SYM) | 
|---|
| 1949 | { | 
|---|
| 1950 | char * file; | 
|---|
| 1951 | unsigned int line; | 
|---|
| 1952 |  | 
|---|
| 1953 | /* Do not reassign section symbols.  */ | 
|---|
| 1954 | as_where (& file, & line); | 
|---|
| 1955 | as_warn_where (file, line, | 
|---|
| 1956 | _("section symbols are already global")); | 
|---|
| 1957 | return; | 
|---|
| 1958 | } | 
|---|
| 1959 | s->bsym->flags |= BSF_GLOBAL; | 
|---|
| 1960 | s->bsym->flags &= ~(BSF_LOCAL | BSF_WEAK); | 
|---|
| 1961 | } | 
|---|
| 1962 |  | 
|---|
| 1963 | void | 
|---|
| 1964 | S_CLEAR_EXTERNAL (s) | 
|---|
| 1965 | symbolS *s; | 
|---|
| 1966 | { | 
|---|
| 1967 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1968 | return; | 
|---|
| 1969 | if ((s->bsym->flags & BSF_WEAK) != 0) | 
|---|
| 1970 | { | 
|---|
| 1971 | /* Let .weak override.  */ | 
|---|
| 1972 | return; | 
|---|
| 1973 | } | 
|---|
| 1974 | s->bsym->flags |= BSF_LOCAL; | 
|---|
| 1975 | s->bsym->flags &= ~(BSF_GLOBAL | BSF_WEAK); | 
|---|
| 1976 | } | 
|---|
| 1977 |  | 
|---|
| 1978 | void | 
|---|
| 1979 | S_SET_WEAK (s) | 
|---|
| 1980 | symbolS *s; | 
|---|
| 1981 | { | 
|---|
| 1982 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 1983 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 1984 | s->bsym->flags |= BSF_WEAK; | 
|---|
| 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)); | 
|---|
| 2005 | } | 
|---|
| 2006 |  | 
|---|
| 2007 | void | 
|---|
| 2008 | S_SET_NAME (s, name) | 
|---|
| 2009 | symbolS *s; | 
|---|
| 2010 | char *name; | 
|---|
| 2011 | { | 
|---|
| 2012 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2013 | { | 
|---|
| 2014 | ((struct local_symbol *) s)->lsy_name = name; | 
|---|
| 2015 | return; | 
|---|
| 2016 | } | 
|---|
| 2017 | s->bsym->name = name; | 
|---|
| 2018 | } | 
|---|
| 2019 | #endif /* BFD_ASSEMBLER */ | 
|---|
| 2020 |  | 
|---|
| 2021 | #ifdef SYMBOLS_NEED_BACKPOINTERS | 
|---|
| 2022 |  | 
|---|
| 2023 | /* Return the previous symbol in a chain.  */ | 
|---|
| 2024 |  | 
|---|
| 2025 | symbolS * | 
|---|
| 2026 | symbol_previous (s) | 
|---|
| 2027 | symbolS *s; | 
|---|
| 2028 | { | 
|---|
| 2029 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2030 | abort (); | 
|---|
| 2031 | return s->sy_previous; | 
|---|
| 2032 | } | 
|---|
| 2033 |  | 
|---|
| 2034 | #endif /* SYMBOLS_NEED_BACKPOINTERS */ | 
|---|
| 2035 |  | 
|---|
| 2036 | /* Return the next symbol in a chain.  */ | 
|---|
| 2037 |  | 
|---|
| 2038 | symbolS * | 
|---|
| 2039 | symbol_next (s) | 
|---|
| 2040 | symbolS *s; | 
|---|
| 2041 | { | 
|---|
| 2042 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2043 | abort (); | 
|---|
| 2044 | return s->sy_next; | 
|---|
| 2045 | } | 
|---|
| 2046 |  | 
|---|
| 2047 | /* Return a pointer to the value of a symbol as an expression.  */ | 
|---|
| 2048 |  | 
|---|
| 2049 | expressionS * | 
|---|
| 2050 | symbol_get_value_expression (s) | 
|---|
| 2051 | symbolS *s; | 
|---|
| 2052 | { | 
|---|
| 2053 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2054 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2055 | return &s->sy_value; | 
|---|
| 2056 | } | 
|---|
| 2057 |  | 
|---|
| 2058 | /* Set the value of a symbol to an expression.  */ | 
|---|
| 2059 |  | 
|---|
| 2060 | void | 
|---|
| 2061 | symbol_set_value_expression (s, exp) | 
|---|
| 2062 | symbolS *s; | 
|---|
| 2063 | const expressionS *exp; | 
|---|
| 2064 | { | 
|---|
| 2065 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2066 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2067 | s->sy_value = *exp; | 
|---|
| 2068 | } | 
|---|
| 2069 |  | 
|---|
| 2070 | /* Set the frag of a symbol.  */ | 
|---|
| 2071 |  | 
|---|
| 2072 | void | 
|---|
| 2073 | symbol_set_frag (s, f) | 
|---|
| 2074 | symbolS *s; | 
|---|
| 2075 | fragS *f; | 
|---|
| 2076 | { | 
|---|
| 2077 | #ifdef BFD_ASSEMBLER | 
|---|
| 2078 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2079 | { | 
|---|
| 2080 | local_symbol_set_frag ((struct local_symbol *) s, f); | 
|---|
| 2081 | return; | 
|---|
| 2082 | } | 
|---|
| 2083 | #endif | 
|---|
| 2084 | s->sy_frag = f; | 
|---|
| 2085 | } | 
|---|
| 2086 |  | 
|---|
| 2087 | /* Return the frag of a symbol.  */ | 
|---|
| 2088 |  | 
|---|
| 2089 | fragS * | 
|---|
| 2090 | symbol_get_frag (s) | 
|---|
| 2091 | symbolS *s; | 
|---|
| 2092 | { | 
|---|
| 2093 | #ifdef BFD_ASSEMBLER | 
|---|
| 2094 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2095 | return local_symbol_get_frag ((struct local_symbol *) s); | 
|---|
| 2096 | #endif | 
|---|
| 2097 | return s->sy_frag; | 
|---|
| 2098 | } | 
|---|
| 2099 |  | 
|---|
| 2100 | /* Mark a symbol as having been used.  */ | 
|---|
| 2101 |  | 
|---|
| 2102 | void | 
|---|
| 2103 | symbol_mark_used (s) | 
|---|
| 2104 | symbolS *s; | 
|---|
| 2105 | { | 
|---|
| 2106 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2107 | return; | 
|---|
| 2108 | s->sy_used = 1; | 
|---|
| 2109 | } | 
|---|
| 2110 |  | 
|---|
| 2111 | /* Clear the mark of whether a symbol has been used.  */ | 
|---|
| 2112 |  | 
|---|
| 2113 | void | 
|---|
| 2114 | symbol_clear_used (s) | 
|---|
| 2115 | symbolS *s; | 
|---|
| 2116 | { | 
|---|
| 2117 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2118 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2119 | s->sy_used = 0; | 
|---|
| 2120 | } | 
|---|
| 2121 |  | 
|---|
| 2122 | /* Return whether a symbol has been used.  */ | 
|---|
| 2123 |  | 
|---|
| 2124 | int | 
|---|
| 2125 | symbol_used_p (s) | 
|---|
| 2126 | symbolS *s; | 
|---|
| 2127 | { | 
|---|
| 2128 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2129 | return 1; | 
|---|
| 2130 | return s->sy_used; | 
|---|
| 2131 | } | 
|---|
| 2132 |  | 
|---|
| 2133 | /* Mark a symbol as having been used in a reloc.  */ | 
|---|
| 2134 |  | 
|---|
| 2135 | void | 
|---|
| 2136 | symbol_mark_used_in_reloc (s) | 
|---|
| 2137 | symbolS *s; | 
|---|
| 2138 | { | 
|---|
| 2139 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2140 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2141 | s->sy_used_in_reloc = 1; | 
|---|
| 2142 | } | 
|---|
| 2143 |  | 
|---|
| 2144 | /* Clear the mark of whether a symbol has been used in a reloc.  */ | 
|---|
| 2145 |  | 
|---|
| 2146 | void | 
|---|
| 2147 | symbol_clear_used_in_reloc (s) | 
|---|
| 2148 | symbolS *s; | 
|---|
| 2149 | { | 
|---|
| 2150 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2151 | return; | 
|---|
| 2152 | s->sy_used_in_reloc = 0; | 
|---|
| 2153 | } | 
|---|
| 2154 |  | 
|---|
| 2155 | /* Return whether a symbol has been used in a reloc.  */ | 
|---|
| 2156 |  | 
|---|
| 2157 | int | 
|---|
| 2158 | symbol_used_in_reloc_p (s) | 
|---|
| 2159 | symbolS *s; | 
|---|
| 2160 | { | 
|---|
| 2161 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2162 | return 0; | 
|---|
| 2163 | return s->sy_used_in_reloc; | 
|---|
| 2164 | } | 
|---|
| 2165 |  | 
|---|
| 2166 | /* Mark a symbol as an MRI common symbol.  */ | 
|---|
| 2167 |  | 
|---|
| 2168 | void | 
|---|
| 2169 | symbol_mark_mri_common (s) | 
|---|
| 2170 | symbolS *s; | 
|---|
| 2171 | { | 
|---|
| 2172 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2173 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2174 | s->sy_mri_common = 1; | 
|---|
| 2175 | } | 
|---|
| 2176 |  | 
|---|
| 2177 | /* Clear the mark of whether a symbol is an MRI common symbol.  */ | 
|---|
| 2178 |  | 
|---|
| 2179 | void | 
|---|
| 2180 | symbol_clear_mri_common (s) | 
|---|
| 2181 | symbolS *s; | 
|---|
| 2182 | { | 
|---|
| 2183 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2184 | return; | 
|---|
| 2185 | s->sy_mri_common = 0; | 
|---|
| 2186 | } | 
|---|
| 2187 |  | 
|---|
| 2188 | /* Return whether a symbol is an MRI common symbol.  */ | 
|---|
| 2189 |  | 
|---|
| 2190 | int | 
|---|
| 2191 | symbol_mri_common_p (s) | 
|---|
| 2192 | symbolS *s; | 
|---|
| 2193 | { | 
|---|
| 2194 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2195 | return 0; | 
|---|
| 2196 | return s->sy_mri_common; | 
|---|
| 2197 | } | 
|---|
| 2198 |  | 
|---|
| 2199 | /* Mark a symbol as having been written.  */ | 
|---|
| 2200 |  | 
|---|
| 2201 | void | 
|---|
| 2202 | symbol_mark_written (s) | 
|---|
| 2203 | symbolS *s; | 
|---|
| 2204 | { | 
|---|
| 2205 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2206 | return; | 
|---|
| 2207 | s->written = 1; | 
|---|
| 2208 | } | 
|---|
| 2209 |  | 
|---|
| 2210 | /* Clear the mark of whether a symbol has been written.  */ | 
|---|
| 2211 |  | 
|---|
| 2212 | void | 
|---|
| 2213 | symbol_clear_written (s) | 
|---|
| 2214 | symbolS *s; | 
|---|
| 2215 | { | 
|---|
| 2216 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2217 | return; | 
|---|
| 2218 | s->written = 0; | 
|---|
| 2219 | } | 
|---|
| 2220 |  | 
|---|
| 2221 | /* Return whether a symbol has been written.  */ | 
|---|
| 2222 |  | 
|---|
| 2223 | int | 
|---|
| 2224 | symbol_written_p (s) | 
|---|
| 2225 | symbolS *s; | 
|---|
| 2226 | { | 
|---|
| 2227 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2228 | return 0; | 
|---|
| 2229 | return s->written; | 
|---|
| 2230 | } | 
|---|
| 2231 |  | 
|---|
| 2232 | /* Mark a symbol has having been resolved.  */ | 
|---|
| 2233 |  | 
|---|
| 2234 | void | 
|---|
| 2235 | symbol_mark_resolved (s) | 
|---|
| 2236 | symbolS *s; | 
|---|
| 2237 | { | 
|---|
| 2238 | #ifdef BFD_ASSEMBLER | 
|---|
| 2239 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2240 | { | 
|---|
| 2241 | local_symbol_mark_resolved ((struct local_symbol *) s); | 
|---|
| 2242 | return; | 
|---|
| 2243 | } | 
|---|
| 2244 | #endif | 
|---|
| 2245 | s->sy_resolved = 1; | 
|---|
| 2246 | } | 
|---|
| 2247 |  | 
|---|
| 2248 | /* Return whether a symbol has been resolved.  */ | 
|---|
| 2249 |  | 
|---|
| 2250 | int | 
|---|
| 2251 | symbol_resolved_p (s) | 
|---|
| 2252 | symbolS *s; | 
|---|
| 2253 | { | 
|---|
| 2254 | #ifdef BFD_ASSEMBLER | 
|---|
| 2255 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2256 | return local_symbol_resolved_p ((struct local_symbol *) s); | 
|---|
| 2257 | #endif | 
|---|
| 2258 | return s->sy_resolved; | 
|---|
| 2259 | } | 
|---|
| 2260 |  | 
|---|
| 2261 | /* Return whether a symbol is a section symbol.  */ | 
|---|
| 2262 |  | 
|---|
| 2263 | int | 
|---|
| 2264 | symbol_section_p (s) | 
|---|
| 2265 | symbolS *s ATTRIBUTE_UNUSED; | 
|---|
| 2266 | { | 
|---|
| 2267 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2268 | return 0; | 
|---|
| 2269 | #ifdef BFD_ASSEMBLER | 
|---|
| 2270 | return (s->bsym->flags & BSF_SECTION_SYM) != 0; | 
|---|
| 2271 | #else | 
|---|
| 2272 | /* FIXME.  */ | 
|---|
| 2273 | return 0; | 
|---|
| 2274 | #endif | 
|---|
| 2275 | } | 
|---|
| 2276 |  | 
|---|
| 2277 | /* Return whether a symbol is equated to another symbol.  */ | 
|---|
| 2278 |  | 
|---|
| 2279 | int | 
|---|
| 2280 | symbol_equated_p (s) | 
|---|
| 2281 | symbolS *s; | 
|---|
| 2282 | { | 
|---|
| 2283 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2284 | return 0; | 
|---|
| 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))); | 
|---|
| 2304 | } | 
|---|
| 2305 |  | 
|---|
| 2306 | /* Return whether a symbol has a constant value.  */ | 
|---|
| 2307 |  | 
|---|
| 2308 | int | 
|---|
| 2309 | symbol_constant_p (s) | 
|---|
| 2310 | symbolS *s; | 
|---|
| 2311 | { | 
|---|
| 2312 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2313 | return 1; | 
|---|
| 2314 | return s->sy_value.X_op == O_constant; | 
|---|
| 2315 | } | 
|---|
| 2316 |  | 
|---|
| 2317 | #ifdef BFD_ASSEMBLER | 
|---|
| 2318 |  | 
|---|
| 2319 | /* Return the BFD symbol for a symbol.  */ | 
|---|
| 2320 |  | 
|---|
| 2321 | asymbol * | 
|---|
| 2322 | symbol_get_bfdsym (s) | 
|---|
| 2323 | symbolS *s; | 
|---|
| 2324 | { | 
|---|
| 2325 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2326 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2327 | return s->bsym; | 
|---|
| 2328 | } | 
|---|
| 2329 |  | 
|---|
| 2330 | /* Set the BFD symbol for a symbol.  */ | 
|---|
| 2331 |  | 
|---|
| 2332 | void | 
|---|
| 2333 | symbol_set_bfdsym (s, bsym) | 
|---|
| 2334 | symbolS *s; | 
|---|
| 2335 | asymbol *bsym; | 
|---|
| 2336 | { | 
|---|
| 2337 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2338 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2339 | s->bsym = bsym; | 
|---|
| 2340 | } | 
|---|
| 2341 |  | 
|---|
| 2342 | #endif /* BFD_ASSEMBLER */ | 
|---|
| 2343 |  | 
|---|
| 2344 | #ifdef OBJ_SYMFIELD_TYPE | 
|---|
| 2345 |  | 
|---|
| 2346 | /* Get a pointer to the object format information for a symbol.  */ | 
|---|
| 2347 |  | 
|---|
| 2348 | OBJ_SYMFIELD_TYPE * | 
|---|
| 2349 | symbol_get_obj (s) | 
|---|
| 2350 | symbolS *s; | 
|---|
| 2351 | { | 
|---|
| 2352 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2353 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2354 | return &s->sy_obj; | 
|---|
| 2355 | } | 
|---|
| 2356 |  | 
|---|
| 2357 | /* Set the object format information for a symbol.  */ | 
|---|
| 2358 |  | 
|---|
| 2359 | void | 
|---|
| 2360 | symbol_set_obj (s, o) | 
|---|
| 2361 | symbolS *s; | 
|---|
| 2362 | OBJ_SYMFIELD_TYPE *o; | 
|---|
| 2363 | { | 
|---|
| 2364 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2365 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2366 | s->sy_obj = *o; | 
|---|
| 2367 | } | 
|---|
| 2368 |  | 
|---|
| 2369 | #endif /* OBJ_SYMFIELD_TYPE */ | 
|---|
| 2370 |  | 
|---|
| 2371 | #ifdef TC_SYMFIELD_TYPE | 
|---|
| 2372 |  | 
|---|
| 2373 | /* Get a pointer to the processor information for a symbol.  */ | 
|---|
| 2374 |  | 
|---|
| 2375 | TC_SYMFIELD_TYPE * | 
|---|
| 2376 | symbol_get_tc (s) | 
|---|
| 2377 | symbolS *s; | 
|---|
| 2378 | { | 
|---|
| 2379 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2380 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2381 | return &s->sy_tc; | 
|---|
| 2382 | } | 
|---|
| 2383 |  | 
|---|
| 2384 | /* Set the processor information for a symbol.  */ | 
|---|
| 2385 |  | 
|---|
| 2386 | void | 
|---|
| 2387 | symbol_set_tc (s, o) | 
|---|
| 2388 | symbolS *s; | 
|---|
| 2389 | TC_SYMFIELD_TYPE *o; | 
|---|
| 2390 | { | 
|---|
| 2391 | if (LOCAL_SYMBOL_CHECK (s)) | 
|---|
| 2392 | s = local_symbol_convert ((struct local_symbol *) s); | 
|---|
| 2393 | s->sy_tc = *o; | 
|---|
| 2394 | } | 
|---|
| 2395 |  | 
|---|
| 2396 | #endif /* TC_SYMFIELD_TYPE */ | 
|---|
| 2397 |  | 
|---|
| 2398 | void | 
|---|
| 2399 | symbol_begin () | 
|---|
| 2400 | { | 
|---|
| 2401 | symbol_lastP = NULL; | 
|---|
| 2402 | symbol_rootP = NULL;          /* In case we have 0 symbols (!!)  */ | 
|---|
| 2403 | sy_hash = hash_new (); | 
|---|
| 2404 | #ifdef BFD_ASSEMBLER | 
|---|
| 2405 | local_hash = hash_new (); | 
|---|
| 2406 | #endif | 
|---|
| 2407 |  | 
|---|
| 2408 | memset ((char *) (&abs_symbol), '\0', sizeof (abs_symbol)); | 
|---|
| 2409 | #ifdef BFD_ASSEMBLER | 
|---|
| 2410 | #if defined (EMIT_SECTION_SYMBOLS) || !defined (RELOC_REQUIRES_SYMBOL) | 
|---|
| 2411 | abs_symbol.bsym = bfd_abs_section.symbol; | 
|---|
| 2412 | #endif | 
|---|
| 2413 | #else | 
|---|
| 2414 | /* Can't initialise a union. Sigh.  */ | 
|---|
| 2415 | S_SET_SEGMENT (&abs_symbol, absolute_section); | 
|---|
| 2416 | #endif | 
|---|
| 2417 | abs_symbol.sy_value.X_op = O_constant; | 
|---|
| 2418 | abs_symbol.sy_frag = &zero_address_frag; | 
|---|
| 2419 |  | 
|---|
| 2420 | if (LOCAL_LABELS_FB) | 
|---|
| 2421 | fb_label_init (); | 
|---|
| 2422 | } | 
|---|
| 2423 |  | 
|---|
| 2424 |  | 
|---|
| 2425 | int indent_level; | 
|---|
| 2426 |  | 
|---|
| 2427 | /* Maximum indent level. | 
|---|
| 2428 | Available for modification inside a gdb session.  */ | 
|---|
| 2429 | int max_indent_level = 8; | 
|---|
| 2430 |  | 
|---|
| 2431 | #if 0 | 
|---|
| 2432 |  | 
|---|
| 2433 | static void | 
|---|
| 2434 | indent () | 
|---|
| 2435 | { | 
|---|
| 2436 | printf ("%*s", indent_level * 4, ""); | 
|---|
| 2437 | } | 
|---|
| 2438 |  | 
|---|
| 2439 | #endif | 
|---|
| 2440 |  | 
|---|
| 2441 | void | 
|---|
| 2442 | print_symbol_value_1 (file, sym) | 
|---|
| 2443 | FILE *file; | 
|---|
| 2444 | symbolS *sym; | 
|---|
| 2445 | { | 
|---|
| 2446 | const char *name = S_GET_NAME (sym); | 
|---|
| 2447 | if (!name || !name[0]) | 
|---|
| 2448 | name = "(unnamed)"; | 
|---|
| 2449 | fprintf (file, "sym %lx %s", (unsigned long) sym, name); | 
|---|
| 2450 |  | 
|---|
| 2451 | if (LOCAL_SYMBOL_CHECK (sym)) | 
|---|
| 2452 | { | 
|---|
| 2453 | #ifdef BFD_ASSEMBLER | 
|---|
| 2454 | struct local_symbol *locsym = (struct local_symbol *) sym; | 
|---|
| 2455 | if (local_symbol_get_frag (locsym) != &zero_address_frag | 
|---|
| 2456 | && local_symbol_get_frag (locsym) != NULL) | 
|---|
| 2457 | fprintf (file, " frag %lx", (long) local_symbol_get_frag (locsym)); | 
|---|
| 2458 | if (local_symbol_resolved_p (locsym)) | 
|---|
| 2459 | fprintf (file, " resolved"); | 
|---|
| 2460 | fprintf (file, " local"); | 
|---|
| 2461 | #endif | 
|---|
| 2462 | } | 
|---|
| 2463 | else | 
|---|
| 2464 | { | 
|---|
| 2465 | if (sym->sy_frag != &zero_address_frag) | 
|---|
| 2466 | fprintf (file, " frag %lx", (long) sym->sy_frag); | 
|---|
| 2467 | if (sym->written) | 
|---|
| 2468 | fprintf (file, " written"); | 
|---|
| 2469 | if (sym->sy_resolved) | 
|---|
| 2470 | fprintf (file, " resolved"); | 
|---|
| 2471 | else if (sym->sy_resolving) | 
|---|
| 2472 | fprintf (file, " resolving"); | 
|---|
| 2473 | if (sym->sy_used_in_reloc) | 
|---|
| 2474 | fprintf (file, " used-in-reloc"); | 
|---|
| 2475 | if (sym->sy_used) | 
|---|
| 2476 | fprintf (file, " used"); | 
|---|
| 2477 | if (S_IS_LOCAL (sym)) | 
|---|
| 2478 | fprintf (file, " local"); | 
|---|
| 2479 | if (S_IS_EXTERN (sym)) | 
|---|
| 2480 | fprintf (file, " extern"); | 
|---|
| 2481 | if (S_IS_DEBUG (sym)) | 
|---|
| 2482 | fprintf (file, " debug"); | 
|---|
| 2483 | if (S_IS_DEFINED (sym)) | 
|---|
| 2484 | fprintf (file, " defined"); | 
|---|
| 2485 | } | 
|---|
| 2486 | fprintf (file, " %s", segment_name (S_GET_SEGMENT (sym))); | 
|---|
| 2487 | if (symbol_resolved_p (sym)) | 
|---|
| 2488 | { | 
|---|
| 2489 | segT s = S_GET_SEGMENT (sym); | 
|---|
| 2490 |  | 
|---|
| 2491 | if (s != undefined_section | 
|---|
| 2492 | && s != expr_section) | 
|---|
| 2493 | fprintf (file, " %lx", (long) S_GET_VALUE (sym)); | 
|---|
| 2494 | } | 
|---|
| 2495 | else if (indent_level < max_indent_level | 
|---|
| 2496 | && S_GET_SEGMENT (sym) != undefined_section) | 
|---|
| 2497 | { | 
|---|
| 2498 | indent_level++; | 
|---|
| 2499 | fprintf (file, "\n%*s<", indent_level * 4, ""); | 
|---|
| 2500 | #ifdef BFD_ASSEMBLER | 
|---|
| 2501 | if (LOCAL_SYMBOL_CHECK (sym)) | 
|---|
| 2502 | fprintf (file, "constant %lx", | 
|---|
| 2503 | (long) ((struct local_symbol *) sym)->lsy_value); | 
|---|
| 2504 | else | 
|---|
| 2505 | #endif | 
|---|
| 2506 | print_expr_1 (file, &sym->sy_value); | 
|---|
| 2507 | fprintf (file, ">"); | 
|---|
| 2508 | indent_level--; | 
|---|
| 2509 | } | 
|---|
| 2510 | fflush (file); | 
|---|
| 2511 | } | 
|---|
| 2512 |  | 
|---|
| 2513 | void | 
|---|
| 2514 | print_symbol_value (sym) | 
|---|
| 2515 | symbolS *sym; | 
|---|
| 2516 | { | 
|---|
| 2517 | indent_level = 0; | 
|---|
| 2518 | print_symbol_value_1 (stderr, sym); | 
|---|
| 2519 | fprintf (stderr, "\n"); | 
|---|
| 2520 | } | 
|---|
| 2521 |  | 
|---|
| 2522 | static void | 
|---|
| 2523 | print_binary (file, name, exp) | 
|---|
| 2524 | FILE *file; | 
|---|
| 2525 | const char *name; | 
|---|
| 2526 | expressionS *exp; | 
|---|
| 2527 | { | 
|---|
| 2528 | indent_level++; | 
|---|
| 2529 | fprintf (file, "%s\n%*s<", name, indent_level * 4, ""); | 
|---|
| 2530 | print_symbol_value_1 (file, exp->X_add_symbol); | 
|---|
| 2531 | fprintf (file, ">\n%*s<", indent_level * 4, ""); | 
|---|
| 2532 | print_symbol_value_1 (file, exp->X_op_symbol); | 
|---|
| 2533 | fprintf (file, ">"); | 
|---|
| 2534 | indent_level--; | 
|---|
| 2535 | } | 
|---|
| 2536 |  | 
|---|
| 2537 | void | 
|---|
| 2538 | print_expr_1 (file, exp) | 
|---|
| 2539 | FILE *file; | 
|---|
| 2540 | expressionS *exp; | 
|---|
| 2541 | { | 
|---|
| 2542 | fprintf (file, "expr %lx ", (long) exp); | 
|---|
| 2543 | switch (exp->X_op) | 
|---|
| 2544 | { | 
|---|
| 2545 | case O_illegal: | 
|---|
| 2546 | fprintf (file, "illegal"); | 
|---|
| 2547 | break; | 
|---|
| 2548 | case O_absent: | 
|---|
| 2549 | fprintf (file, "absent"); | 
|---|
| 2550 | break; | 
|---|
| 2551 | case O_constant: | 
|---|
| 2552 | fprintf (file, "constant %lx", (long) exp->X_add_number); | 
|---|
| 2553 | break; | 
|---|
| 2554 | case O_symbol: | 
|---|
| 2555 | indent_level++; | 
|---|
| 2556 | fprintf (file, "symbol\n%*s<", indent_level * 4, ""); | 
|---|
| 2557 | print_symbol_value_1 (file, exp->X_add_symbol); | 
|---|
| 2558 | fprintf (file, ">"); | 
|---|
| 2559 | maybe_print_addnum: | 
|---|
| 2560 | if (exp->X_add_number) | 
|---|
| 2561 | fprintf (file, "\n%*s%lx", indent_level * 4, "", | 
|---|
| 2562 | (long) exp->X_add_number); | 
|---|
| 2563 | indent_level--; | 
|---|
| 2564 | break; | 
|---|
| 2565 | case O_register: | 
|---|
| 2566 | fprintf (file, "register #%d", (int) exp->X_add_number); | 
|---|
| 2567 | break; | 
|---|
| 2568 | case O_big: | 
|---|
| 2569 | fprintf (file, "big"); | 
|---|
| 2570 | break; | 
|---|
| 2571 | case O_uminus: | 
|---|
| 2572 | fprintf (file, "uminus -<"); | 
|---|
| 2573 | indent_level++; | 
|---|
| 2574 | print_symbol_value_1 (file, exp->X_add_symbol); | 
|---|
| 2575 | fprintf (file, ">"); | 
|---|
| 2576 | goto maybe_print_addnum; | 
|---|
| 2577 | case O_bit_not: | 
|---|
| 2578 | fprintf (file, "bit_not"); | 
|---|
| 2579 | break; | 
|---|
| 2580 | case O_multiply: | 
|---|
| 2581 | print_binary (file, "multiply", exp); | 
|---|
| 2582 | break; | 
|---|
| 2583 | case O_divide: | 
|---|
| 2584 | print_binary (file, "divide", exp); | 
|---|
| 2585 | break; | 
|---|
| 2586 | case O_modulus: | 
|---|
| 2587 | print_binary (file, "modulus", exp); | 
|---|
| 2588 | break; | 
|---|
| 2589 | case O_left_shift: | 
|---|
| 2590 | print_binary (file, "lshift", exp); | 
|---|
| 2591 | break; | 
|---|
| 2592 | case O_right_shift: | 
|---|
| 2593 | print_binary (file, "rshift", exp); | 
|---|
| 2594 | break; | 
|---|
| 2595 | case O_bit_inclusive_or: | 
|---|
| 2596 | print_binary (file, "bit_ior", exp); | 
|---|
| 2597 | break; | 
|---|
| 2598 | case O_bit_exclusive_or: | 
|---|
| 2599 | print_binary (file, "bit_xor", exp); | 
|---|
| 2600 | break; | 
|---|
| 2601 | case O_bit_and: | 
|---|
| 2602 | print_binary (file, "bit_and", exp); | 
|---|
| 2603 | break; | 
|---|
| 2604 | case O_eq: | 
|---|
| 2605 | print_binary (file, "eq", exp); | 
|---|
| 2606 | break; | 
|---|
| 2607 | case O_ne: | 
|---|
| 2608 | print_binary (file, "ne", exp); | 
|---|
| 2609 | break; | 
|---|
| 2610 | case O_lt: | 
|---|
| 2611 | print_binary (file, "lt", exp); | 
|---|
| 2612 | break; | 
|---|
| 2613 | case O_le: | 
|---|
| 2614 | print_binary (file, "le", exp); | 
|---|
| 2615 | break; | 
|---|
| 2616 | case O_ge: | 
|---|
| 2617 | print_binary (file, "ge", exp); | 
|---|
| 2618 | break; | 
|---|
| 2619 | case O_gt: | 
|---|
| 2620 | print_binary (file, "gt", exp); | 
|---|
| 2621 | break; | 
|---|
| 2622 | case O_logical_and: | 
|---|
| 2623 | print_binary (file, "logical_and", exp); | 
|---|
| 2624 | break; | 
|---|
| 2625 | case O_logical_or: | 
|---|
| 2626 | print_binary (file, "logical_or", exp); | 
|---|
| 2627 | break; | 
|---|
| 2628 | case O_add: | 
|---|
| 2629 | indent_level++; | 
|---|
| 2630 | fprintf (file, "add\n%*s<", indent_level * 4, ""); | 
|---|
| 2631 | print_symbol_value_1 (file, exp->X_add_symbol); | 
|---|
| 2632 | fprintf (file, ">\n%*s<", indent_level * 4, ""); | 
|---|
| 2633 | print_symbol_value_1 (file, exp->X_op_symbol); | 
|---|
| 2634 | fprintf (file, ">"); | 
|---|
| 2635 | goto maybe_print_addnum; | 
|---|
| 2636 | case O_subtract: | 
|---|
| 2637 | indent_level++; | 
|---|
| 2638 | fprintf (file, "subtract\n%*s<", indent_level * 4, ""); | 
|---|
| 2639 | print_symbol_value_1 (file, exp->X_add_symbol); | 
|---|
| 2640 | fprintf (file, ">\n%*s<", indent_level * 4, ""); | 
|---|
| 2641 | print_symbol_value_1 (file, exp->X_op_symbol); | 
|---|
| 2642 | fprintf (file, ">"); | 
|---|
| 2643 | goto maybe_print_addnum; | 
|---|
| 2644 | default: | 
|---|
| 2645 | fprintf (file, "{unknown opcode %d}", (int) exp->X_op); | 
|---|
| 2646 | break; | 
|---|
| 2647 | } | 
|---|
| 2648 | fflush (stdout); | 
|---|
| 2649 | } | 
|---|
| 2650 |  | 
|---|
| 2651 | void | 
|---|
| 2652 | print_expr (exp) | 
|---|
| 2653 | expressionS *exp; | 
|---|
| 2654 | { | 
|---|
| 2655 | print_expr_1 (stderr, exp); | 
|---|
| 2656 | fprintf (stderr, "\n"); | 
|---|
| 2657 | } | 
|---|
| 2658 |  | 
|---|
| 2659 | void | 
|---|
| 2660 | symbol_print_statistics (file) | 
|---|
| 2661 | FILE *file; | 
|---|
| 2662 | { | 
|---|
| 2663 | hash_print_statistics (file, "symbol table", sy_hash); | 
|---|
| 2664 | #ifdef BFD_ASSEMBLER | 
|---|
| 2665 | hash_print_statistics (file, "mini local symbol table", local_hash); | 
|---|
| 2666 | fprintf (file, "%lu mini local symbols created, %lu converted\n", | 
|---|
| 2667 | local_symbol_count, local_symbol_conversion_count); | 
|---|
| 2668 | #endif | 
|---|
| 2669 | } | 
|---|