Merge pull request #8 from biergaizi/upstream
[darwin-xtools.git] / cctools / as / symbols.c
blobe5d76b5cd4ec63f058572a8557eac606a3f31d26
1 /* symbols.c -symbol table-
2 Copyright (C) 1987 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
9 any later version.
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 #include <stdlib.h>
21 #include <string.h>
22 #include <ctype.h>
23 #include "as.h"
24 #include "hash.h"
25 #include "obstack.h" /* For "symbols.h" */
26 #include "struc-symbol.h"
27 #include "symbols.h"
28 #include "frags.h"
29 #include "expr.h"
30 #include "sections.h"
31 #include "read.h"
32 #include "xmalloc.h"
33 #include "messages.h"
34 #include "fixes.h"
35 #include "input-scrub.h"
36 #include "dwarf2dbg.h"
38 /* symbol-name => struct symbol pointer */
39 struct hash_control *sy_hash = NULL;
41 /* FixS & symbols live here */
42 struct obstack notes = { 0 };
44 /* all the symbol nodes */
45 symbolS *symbol_rootP = NULL;
46 /* last struct symbol we made, or NULL */
47 symbolS *symbol_lastP = NULL;
48 /* The last symbol we assigned an index to. */
49 symbolS *symbol_lastIndexedP = NULL;
51 symbolS abs_symbol = { {{0}} };
54 * Un*x idea of local labels. They are made by "n:" where n
55 * is any decimal digit. Refer to them with
56 * "nb" for previous (backward) n:
57 * or "nf" for next (forward) n:.
59 * Like Un*x AS, we have one set of local label counters for entire assembly,
60 * not one set per (sub)segment like in most assemblers. This implies that
61 * one can refer to a label in another segment, and indeed some crufty
62 * compilers have done just that.
64 * I document the symbol names here to save duplicating words elsewhere.
65 * The mth occurence of label n: is turned into the symbol "Ln^Am" where
66 * n is a digit and m is a decimal number. "L" makes it a label discarded
67 * unless debugging and "^A"('\1') ensures no ordinary symbol SHOULD get the
68 * same name as a local label symbol. The first "4:" is "L4^A1" - the m
69 * numbers begin at 1.
72 typedef short unsigned int local_label_countT;
74 static void make_stab_for_symbol(
75 symbolS *symbolP);
77 static void make_subprogram_for_symbol(
78 symbolS *symbolP);
80 static void fb_label_init(void);
83 void
84 symbol_begin(
85 void)
87 symbol_lastP = NULL;
88 symbol_rootP = NULL; /* In case we have 0 symbols (!!) */
89 sy_hash = hash_new();
90 memset((char *)(&abs_symbol), '\0', sizeof(abs_symbol));
91 abs_symbol.sy_type = N_ABS; /* Can't initialise a union. Sigh. */
92 fb_label_init ();
96 /* Somebody else's idea of local labels. They are made by "n:" where n
97 is any decimal digit. Refer to them with
98 "nb" for previous (backward) n:
99 or "nf" for next (forward) n:.
101 We do a little better and let n be any number, not just a single digit, but
102 since the other guy's assembler only does ten, we treat the first ten
103 specially.
105 Like someone else's assembler, we have one set of local label counters for
106 entire assembly, not one set per (sub)segment like in most assemblers. This
107 implies that one can refer to a label in another segment, and indeed some
108 crufty compilers have done just that.
110 Since there could be a LOT of these things, treat them as a sparse
111 array. */
113 #define LOCAL_LABEL_CHAR '\002'
114 #define FB_LABEL_SPECIAL (10)
116 static int32_t fb_low_counter[FB_LABEL_SPECIAL];
117 static int32_t *fb_labels;
118 static int32_t *fb_label_instances;
119 static int32_t fb_label_count;
120 static int32_t fb_label_max;
122 /* This must be more than FB_LABEL_SPECIAL. */
123 #define FB_LABEL_BUMP_BY (FB_LABEL_SPECIAL + 6)
125 static void
126 fb_label_init (void)
128 memset ((void *) fb_low_counter, '\0', sizeof (fb_low_counter));
131 /* Add one to the instance number of this fb label. */
133 void
134 fb_label_instance_inc (int32_t label)
136 int32_t *i;
138 if (label < FB_LABEL_SPECIAL)
140 ++fb_low_counter[label];
141 return;
144 if (fb_labels != NULL)
146 for (i = fb_labels + FB_LABEL_SPECIAL;
147 i < fb_labels + fb_label_count; ++i)
149 if (*i == label)
151 ++fb_label_instances[i - fb_labels];
152 return;
153 } /* if we find it */
154 } /* for each existing label */
157 /* If we get to here, we don't have label listed yet. */
159 if (fb_labels == NULL)
161 fb_labels = (int32_t *) xmalloc (FB_LABEL_BUMP_BY * sizeof (int32_t));
162 fb_label_instances = (int32_t *) xmalloc (FB_LABEL_BUMP_BY * sizeof (int32_t));
163 fb_label_max = FB_LABEL_BUMP_BY;
164 fb_label_count = FB_LABEL_SPECIAL;
167 else if (fb_label_count == fb_label_max)
169 fb_label_max += FB_LABEL_BUMP_BY;
170 fb_labels = (int32_t *) xrealloc ((char *) fb_labels,
171 fb_label_max * sizeof (int32_t));
172 fb_label_instances = (int32_t *) xrealloc ((char *) fb_label_instances,
173 fb_label_max * sizeof (int32_t));
174 } /* if we needed to grow */
176 fb_labels[fb_label_count] = label;
177 fb_label_instances[fb_label_count] = 1;
178 ++fb_label_count;
181 static int32_t
182 fb_label_instance (int32_t label)
184 int32_t *i;
186 if (label < FB_LABEL_SPECIAL)
188 return (fb_low_counter[label]);
191 if (fb_labels != NULL)
193 for (i = fb_labels + FB_LABEL_SPECIAL;
194 i < fb_labels + fb_label_count; ++i)
196 if (*i == label)
198 return (fb_label_instances[i - fb_labels]);
199 } /* if we find it */
200 } /* for each existing label */
203 /* We didn't find the label, so this must be a reference to the
204 first instance. */
205 return 0;
208 /* Caller must copy returned name: we re-use the area for the next name.
210 The mth occurence of label n: is turned into the symbol "Ln^Bm"
211 where n is the label number and m is the instance number. "L" makes
212 it a label discarded unless debugging and "^B"('\2') ensures no
213 ordinary symbol SHOULD get the same name as a local label
214 symbol. The first "4:" is "L4^B1" - the m numbers begin at 1. */
216 char * /* Return local label name. */
217 fb_label_name (int32_t n, /* We just saw "n:", "nf" or "nb" : n a number. */
218 int32_t augend /* 0 for nb, 1 for n:, nf. */)
220 int32_t i;
221 /* Returned to caller, then copied. Used for created names ("4f"). */
222 static char symbol_name_build[24];
223 register char *p;
224 register char *q;
225 char symbol_name_temporary[20]; /* Build up a number, BACKWARDS. */
227 know (n >= 0);
228 #ifdef TC_MMIX
229 know ((uint32_t) augend <= 2 /* See mmix_fb_label. */);
230 #else
231 know ((uint32_t) augend <= 1);
232 #endif
233 p = symbol_name_build;
234 #ifdef LOCAL_LABEL_PREFIX
235 *p++ = LOCAL_LABEL_PREFIX;
236 #endif
237 *p++ = 'L';
239 /* Next code just does sprintf( {}, "%d", n); */
240 /* Label number. */
241 q = symbol_name_temporary;
242 for (*q++ = 0, i = n; i; ++q)
244 *q = i % 10 + '0';
245 i /= 10;
247 while ((*p = *--q) != '\0')
248 ++p;
250 *p++ = LOCAL_LABEL_CHAR; /* ^B */
252 /* Instance number. */
253 q = symbol_name_temporary;
254 for (*q++ = 0, i = fb_label_instance (n) + augend; i; ++q)
256 *q = i % 10 + '0';
257 i /= 10;
259 while ((*p++ = *--q) != '\0');
261 /* The label, as a '\0' ended string, starts at symbol_name_build. */
262 return (symbol_name_build);
265 /* Decode name that may have been generated by foo_label_name() above.
266 If the name wasn't generated by foo_label_name(), then return it
267 unaltered. This is used for error messages. */
269 char *
270 decode_local_label_name (char *s)
272 char *p;
273 char *symbol_decode;
274 int label_number;
275 int instance_number;
276 char *type;
277 int index = 0;
279 #ifdef LOCAL_LABEL_PREFIX
280 if (s[index] == LOCAL_LABEL_PREFIX)
281 ++index;
282 #endif
284 if (s[index] != 'L')
285 return s;
287 for (label_number = 0, p = s + index + 1; isdigit (*p); ++p)
288 label_number = (10 * label_number) + *p - '0';
290 if (*p == LOCAL_LABEL_CHAR)
291 type = "fb";
292 else
293 return s;
295 for (instance_number = 0, p++; isdigit (*p); ++p)
296 instance_number = (10 * instance_number) + *p - '0';
298 #define MESSAGE_FORMAT "\"%d\" (instance number %d of a %s label)"
299 symbol_decode = obstack_alloc (&notes, strlen (MESSAGE_FORMAT) + 30);
300 sprintf (symbol_decode, MESSAGE_FORMAT, label_number, instance_number, type);
302 return symbol_decode;
305 void
306 local_colon(
307 int n) /* just saw "n:" */
309 fb_label_instance_inc (n);
310 colon (fb_label_name (n, 0), 1);
314 * symbol_new()
316 * Return a pointer to a new symbol.
317 * Die if we can't make a new symbol.
318 * Fill in the symbol's values.
319 * Add symbol to end of symbol chain.
322 * Please always call this to create a new symbol.
324 * Changes since 1985: Symbol names may not contain '\0'. Sigh.
326 symbolS *
327 symbol_new(
328 char *name, /* We copy this: OK to alter your copy. */
329 unsigned char type, /* As in <nlist.h>. */
330 char other, /* As in <nlist.h>. */
331 short desc, /* As in <nlist.h>. */
332 valueT value, /* As in <nlist.h>, often an address. */
333 /* Often used as offset from frag address. */
334 struct frag *frag) /* For sy_frag. */
336 register symbolS * symbolP;
337 register char * preserved_copy_of_name;
338 register unsigned int name_length;
339 char * p;
341 name_length = strlen(name) + 1;
342 obstack_grow(&notes,name,name_length);
343 p=obstack_finish(&notes);
344 /* obstack_1done( &notes, name, name_length, &p ); */
345 preserved_copy_of_name = p;
346 p=obstack_alloc(&notes,sizeof(struct symbol));
347 /* obstack_1blank( &notes, sizeof(struct symbol), &p ); */
348 symbolP = (symbolS *) p;
349 symbolP -> sy_name = preserved_copy_of_name;
350 symbolP -> sy_type = type;
351 symbolP -> sy_other = other;
352 symbolP -> sy_desc = desc;
353 symbolP -> sy_value = value;
354 symbolP -> sy_frag = frag;
355 symbolP -> sy_prev_by_index = NULL; /* Don't know what this is yet. */
356 symbolP -> sy_has_been_resolved = 0;
357 symbolP -> sy_next = NULL; /* End of chain. */
358 symbolP -> sy_forward = NULL; /* JF */
359 symbolP -> expression = NULL;
360 #ifdef SUSPECT
361 symbolP -> sy_name_offset = ~ 0; /* Impossible offset catches errors. */
362 symbolP -> sy_number = ~ 0; /* Ditto. */
363 #endif
365 * Link to end of symbol chain.
367 if (symbol_lastP)
369 symbol_lastP -> sy_next = symbolP;
371 else
373 symbol_rootP = symbolP;
375 symbol_lastP = symbolP;
377 return (symbolP);
380 /* FROM line 136 */
381 symbolS *
382 symbol_create (const char *name, /* It is copied, the caller can destroy/modify. */
383 segT segment, /* Segment identifier (SEG_<something>). */
384 valueT valu, /* Symbol value. */
385 fragS *frag /* Associated fragment. */)
387 /* FIXME */
388 return symbol_new ((char *)name, 0, segment, 0, valu, frag);
392 * symbol_assign_index()
394 * Assigns the next index to the given symbol.
396 * Asserts that the symbol has not been assigned an index yet.
399 void
400 symbol_assign_index(
401 struct symbol *symbolP)
403 if (symbolP->sy_prev_by_index != NULL)
405 as_fatal("symbol %s already has an index", symbolP->sy_name);
407 symbolP->sy_prev_by_index = symbol_lastIndexedP;
408 symbol_lastIndexedP = symbolP;
412 * colon()
414 * We have just seen "<name>:".
415 * Creates a struct symbol unless it already exists.
417 * Gripes if we are redefining a symbol incompatibly (and ignores it).
420 /* This is used to work around compiler optimizer bug #50416 */
421 static volatile unsigned int temp;
423 void
424 colon( /* just seen "x:" - rattle symbols & frags */
425 char *sym_name, /* symbol name, as a cannonical string */
426 /* We copy this string: OK to alter later. */
427 int local_colon)/* non-zero if called from local_colon() */
429 register struct symbol * symbolP; /* symbol we are working with */
431 if (frchain_now == NULL)
433 know(flagseen['n']);
434 as_fatal("with -n a section directive must be seen before assembly "
435 "can begin");
437 if (inlineasm_checks && local_colon == 0)
439 if (inlineasm_file_name)
440 as_warn_where_with_column(inlineasm_file_name, inlineasm_line_number,
441 inlineasm_column_number, "label definition in inlineasm");
442 else
443 as_bad("label definition in inlineasm");
445 if ((symbolP = symbol_table_lookup( sym_name )))
448 * Now check for undefined symbols
450 if ((symbolP -> sy_type & N_TYPE) == N_UNDF)
452 temp = symbolP->sy_desc;
453 if( symbolP -> sy_other == 0
454 /* bug #50416 -O causes this not to work for:
455 && ((symbolP->sy_desc) & (~REFERENCE_TYPE)) == 0
457 && (temp & (~(REFERENCE_TYPE | N_WEAK_REF | N_WEAK_DEF |
458 N_ARM_THUMB_DEF | N_SYMBOL_RESOLVER |
459 N_NO_DEAD_STRIP | REFERENCED_DYNAMICALLY))) == 0
460 && symbolP -> sy_value == 0)
462 symbolP -> sy_frag = frag_now;
463 symbolP -> sy_value = obstack_next_free(& frags) - frag_now -> fr_literal;
464 know( N_UNDF == 0 );
465 symbolP -> sy_type |= N_SECT; /* keep N_EXT bit */
466 symbolP -> sy_other = frchain_now->frch_nsect;
467 symbolP -> sy_desc &= ~REFERENCE_TYPE;
468 symbolP -> sy_desc &= ~(N_WEAK_REF & N_WEAK_DEF);
469 symbol_assign_index(symbolP);
470 #ifdef NeXT_MOD /* generate stabs for debugging assembly code */
471 if(flagseen['g'])
472 make_stab_for_symbol(symbolP);
473 #endif
474 if(debug_type == DEBUG_DWARF2)
475 make_subprogram_for_symbol(symbolP);
477 else
479 as_fatal( "Symbol \"%s\" is already defined as \"%s\"/%d.%d."
480 TA_DFMT ".",
481 sym_name,
482 seg_name [(int) N_TYPE_seg [symbolP -> sy_type & N_TYPE]],
483 symbolP -> sy_other, symbolP -> sy_desc,
484 symbolP -> sy_value);
487 else
489 as_fatal("Symbol %s already defined.",sym_name);
492 else
494 symbolP = symbol_new (sym_name,
495 N_SECT,
496 frchain_now->frch_nsect,
498 (valueT)(obstack_next_free(&frags)-frag_now->fr_literal),
499 frag_now);
500 symbol_table_insert (symbolP);
501 symbol_assign_index (symbolP);
502 #ifdef NeXT_MOD /* generate stabs for debugging assembly code */
503 if(flagseen['g'])
504 make_stab_for_symbol(symbolP);
505 #endif
506 if(debug_type == DEBUG_DWARF2)
507 make_subprogram_for_symbol(symbolP);
509 #ifdef tc_frob_label
510 tc_frob_label(symbolP);
511 #endif
516 * symbol_table_insert()
518 * Die if we can't insert the symbol.
521 void
522 symbol_table_insert(
523 struct symbol *symbolP)
525 const char * error_string;
527 know( symbolP );
528 know( symbolP -> sy_name );
529 error_string = hash_jam (sy_hash, symbolP -> sy_name, (char *)symbolP);
530 if (error_string != NULL && error_string[0] != '\0')
532 as_fatal( "Inserting \"%s\" into symbol table failed: %s",
533 symbolP -> sy_name, error_string);
538 * symbol_find_or_make()
540 * If a symbol name does not exist, create it as undefined, and insert
541 * it into the symbol table. Return a pointer to it.
543 symbolS *
544 symbol_find_or_make(
545 char *name)
547 register symbolS * symbolP;
549 symbolP = symbol_table_lookup (name);
550 if (symbolP == NULL)
552 symbolP = symbol_new (name, N_UNDF, 0, 0, 0, & zero_address_frag);
553 symbol_table_insert (symbolP);
555 return (symbolP);
559 * symbol_find()
561 * Implement symbol table lookup.
562 * In: A symbol's name as a string: '\0' can't be part of a symbol name.
563 * Out: NULL if the name was not in the symbol table, else the address
564 * of a struct symbol associated with that name.
566 symbolS *
567 symbol_find(
568 char *name)
570 return ( (symbolS *) hash_find( sy_hash, name ));
574 * symbol_table_lookup()
576 * Same as symbol_find() except assumes the symbol is being looked up and is
577 * a non-lazy symbol reference.
579 symbolS *
580 symbol_table_lookup(
581 char *name)
583 register symbolS * symbolP;
585 symbolP = (symbolS *) hash_find( sy_hash, name );
586 if(symbolP != NULL)
587 symbolP->sy_desc &= ~REFERENCE_FLAG_UNDEFINED_LAZY;
588 return(symbolP);
591 #ifdef NeXT_MOD /* generate stabs for debugging assembly code */
593 * make_stab_for_symbol() is called when -g is present for a label that is
594 * being defined. If the label is a text label and in the (__TEXT,__text)
595 * section and not a local label create a stab for it.
597 * See the detailed comments about stabs in read_a_source_file() for a
598 * description of what is going on here.
600 static
601 void
602 make_stab_for_symbol(
603 symbolS *symbolP)
605 symbolS *stab;
606 int stabnamelen;
607 char *stabname;
609 if(symbolP->sy_name[0] == 'L')
610 return;
611 if((symbolP->sy_type & N_TYPE) != N_SECT)
612 return;
613 if(symbolP->sy_other != text_nsect)
614 return;
616 stabnamelen = strlen(symbolP->sy_name) + sizeof(":f3");
617 stabname = xmalloc(stabnamelen);
618 strcpy(stabname, symbolP->sy_name);
619 if(symbolP->sy_type & N_EXT)
620 strcat(stabname, ":F3");
621 else
622 strcat(stabname, ":f3");
624 stab = symbol_new(
625 stabname,
626 36, /* N_FUN */
627 text_nsect, /* n_sect */
628 logical_input_line, /* n_desc, line number */
629 symbolP->sy_value,
630 symbolP->sy_frag);
631 free(stabname);
633 #endif /* NeXT generate stabs for debugging assembly code */
636 * make_subprogram_for_symbol() gathers the info that is needed for each
637 * symbol that will have a dwarf2_subprogram when generating dwarf debugging
638 * info for assembly files.
640 static
641 void
642 make_subprogram_for_symbol(
643 symbolS *symbolP)
645 struct dwarf2_subprogram_info *i;
646 static struct dwarf2_subprogram_info *last_dwarf2_subprogram_info = NULL;
648 if(symbolP->sy_name[0] == 'L')
649 return;
650 if((symbolP->sy_type & N_TYPE) != N_SECT)
651 return;
652 if(symbolP->sy_other != text_nsect)
653 return;
655 i = xmalloc(sizeof(struct dwarf2_subprogram_info));
656 i->name = symbolP->sy_name;
657 if(i->name[0] == '_')
658 i->name++;
659 i->file_number = dwarf2_file_number;
660 i->line_number = logical_input_line;
662 * We can't used the symbolP directly as it may have the N_ARM_THUMB_DEF
663 * bit set. And that will cause the AT_high_pc and AT_low_pc values to
664 * have the low bit set after relocation producing bad dwarf. So we
665 * create a temporary symbol that will not have the N_ARM_THUMB_DEF bit
666 * set.
668 i->symbol = symbol_temp_new(symbolP->sy_other, symbolP->sy_value,
669 symbolP->sy_frag);
670 i->next = NULL;
671 if(dwarf2_subprograms_info == NULL){
672 dwarf2_subprograms_info = i;
673 last_dwarf2_subprogram_info = i;
675 else{
676 last_dwarf2_subprogram_info->next = i;
677 last_dwarf2_subprogram_info = i;
682 * indirect_symbol_new()
684 * Return a pointer to a new indirect_symbol.
685 * Die if we can't make a new indirect_symbol.
686 * Fill in the indirect_symbol's values.
687 * Add symbol to end of section's indirect symbol chain.
689 isymbolS *
690 indirect_symbol_new(
691 char *name, /* We copy this: OK to alter your copy. */
692 struct frag *frag, /* For sy_frag. */
693 uint32_t offset) /* Offset from frag address. */
695 isymbolS *isymbolP;
696 char *preserved_copy_of_name;
697 uint32_t name_length;
698 char *p;
699 struct frag *fr_next;
700 symbolS *symbolP;
701 #ifdef CHECK_INDIRECTS
702 uint32_t stride, fr_fix;
703 #endif
706 * First see if the last frag recorded for an indirect symbol turned
707 * out to be zero sized then changed that recorded frag to the next
708 * non-zero frag in the list. I think this happens because we record
709 * the frag before we fill it and if we run out of space that frag gets
710 * a zero size and a new one is created.
712 if(frchain_now->frch_isym_last != NULL &&
713 frchain_now->frch_isym_last->isy_frag->fr_fix == 0){
714 if(frchain_now->frch_isym_last->isy_frag->fr_next != NULL){
715 fr_next = frchain_now->frch_isym_last->isy_frag->fr_next;
716 while(fr_next->fr_fix == 0 &&
717 fr_next->fr_type == rs_fill &&
718 fr_next->fr_next != NULL)
719 fr_next = fr_next->fr_next;
720 frchain_now->frch_isym_last->isy_frag = fr_next;
724 name_length = strlen(name) + 1;
725 obstack_grow(&notes, name, name_length);
726 p = obstack_finish(&notes);
727 preserved_copy_of_name = p;
728 p = obstack_alloc(&notes, sizeof(struct indirect_symbol));
729 isymbolP = (isymbolS *)p;
730 isymbolP->isy_name = preserved_copy_of_name;
731 isymbolP->isy_offset = offset;
732 isymbolP->isy_frag = frag;
733 isymbolP->isy_next = NULL; /* End of chain. */
734 isymbolP->isy_symbol = NULL;
737 * Link to end of indirect symbol chain and check for missing indirect
738 * symbols.
740 if(frchain_now->frch_isym_root == NULL){
741 #ifdef CHECK_INDIRECTS
742 if(offset != 0)
743 as_bad("missing or bad indirect symbol for section (%s,%s)",
744 frchain_now->frch_section.segname,
745 frchain_now->frch_section.sectname);
746 #endif
747 frchain_now->frch_isym_root = isymbolP;
748 frchain_now->frch_isym_last = isymbolP;
750 else{
751 #ifdef CHECK_INDIRECTS
752 if((frchain_now->frch_section.flags & SECTION_TYPE) ==
753 S_SYMBOL_STUBS)
754 stride = frchain_now->frch_section.reserved2;
755 else
756 stride = sizeof(uint32_t);
757 if(frag == frchain_now->frch_isym_last->isy_frag){
758 if(offset - frchain_now->frch_isym_last->isy_offset != stride)
759 as_bad("missing or bad indirect symbol for section "
760 "(%s,%s)", frchain_now->frch_section.segname,
761 frchain_now->frch_section.sectname);
763 else{
764 if(frchain_now->frch_isym_last->isy_frag->fr_fix < stride){
765 fr_fix = 0;
766 fr_next = frchain_now->frch_isym_last->isy_frag;
767 while(fr_fix + fr_next->fr_fix < stride &&
768 fr_next->fr_type == rs_fill &&
769 fr_next->fr_next != NULL){
770 fr_fix += fr_next->fr_fix;
771 fr_next = fr_next->fr_next;
773 if(frag != fr_next->fr_next ||
774 fr_fix + fr_next->fr_fix != stride ||
775 offset != 0)
776 as_bad("missing or bad indirect symbol for section "
777 "(%s,%s)", frchain_now->frch_section.segname,
778 frchain_now->frch_section.sectname);
780 else{
781 fr_next = frchain_now->frch_isym_last->isy_frag->fr_next;
783 * Because of section changes there maybe some zero length
784 * frags after the last one that passed through here. So
785 * skip them and get to the last real one.
787 while(fr_next->fr_fix == 0 &&
788 fr_next->fr_type == rs_fill &&
789 fr_next->fr_next != NULL)
790 fr_next = fr_next->fr_next;
791 if(frag != fr_next || offset != 0)
792 as_bad("missing or bad indirect symbol for section "
793 "(%s,%s)", frchain_now->frch_section.segname,
794 frchain_now->frch_section.sectname);
797 #endif
798 frchain_now->frch_isym_last->isy_next = isymbolP;
799 frchain_now->frch_isym_last = isymbolP;
801 if((frchain_now->frch_section.flags & SECTION_TYPE) ==
802 S_NON_LAZY_SYMBOL_POINTERS){
803 symbolP = (symbolS *)hash_find(sy_hash, name);
804 if(symbolP != NULL)
805 symbolP->sy_desc &= ~REFERENCE_FLAG_UNDEFINED_LAZY;
807 return(isymbolP);
810 const char *
811 S_GET_NAME (symbolS *s)
813 return s->sy_name;
817 S_IS_DEFINED (symbolS *s)
819 return (s->sy_type & N_TYPE) != N_UNDF;
822 /* FROM line 2317 */
823 #ifdef TC_SYMFIELD_TYPE
825 /* Get a pointer to the processor information for a symbol. */
827 TC_SYMFIELD_TYPE *
828 symbol_get_tc (symbolS *s)
830 return &s->sy_tc;
833 /* Set the processor information for a symbol. */
835 void
836 symbol_set_tc (symbolS *s, TC_SYMFIELD_TYPE *o)
838 s->sy_tc = *o;
841 #endif /* TC_SYMFIELD_TYPE */
844 S_IS_LOCAL (symbolS *s)
846 const char *name;
848 name = S_GET_NAME (s);
849 if(name == NULL)
850 return(1);
852 if(name[0] == 'L' && flagseen['L'] == FALSE)
853 return(1);
854 else
855 return(0);
858 fragS *
859 symbol_get_frag (symbolS *s)
861 return(s->sy_frag);
865 * symbol_temp_new(), symbol_temp_new_now() are used by dwarf2dbg.c to make
866 * symbols in dwarf sections. symbol_temp_make() is used to make an undefined
867 * symbol that its values are later set by symbol_set_value_now() to the current
868 * address in a dwarf section.
870 * These are used in expressions, so the expression values can be put out in
871 * dwarf section contents.
873 symbolS *
874 symbol_temp_new(
875 segT nsect,
876 valueT value,
877 struct frag *frag)
879 return(symbol_new(FAKE_LABEL_NAME, N_SECT, nsect, 0, value, frag));
882 symbolS *
883 symbol_temp_new_now(void)
885 return(symbol_temp_new(now_seg, frag_now_fix(), frag_now));
888 symbolS *
889 symbol_temp_make(void)
891 return(symbol_new(FAKE_LABEL_NAME, N_UNDF, 0, 0, 0, & zero_address_frag));
894 /* Set the value of SYM to the current position in the current segment. */
895 void
896 symbol_set_value_now(
897 symbolS *sym)
899 sym->sy_type = N_SECT;
900 sym->sy_other = now_seg;
901 sym->sy_value = frag_now_fix();
902 sym->sy_frag = frag_now;
905 /* end: symbols.c */