along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* #define DEBUG_SYMS /* to debug symbol list maintenance */
+/* #define DEBUG_SYMS / * to debug symbol list maintenance */
#include <ctype.h>
symbolS *symbol_lastP;
symbolS abs_symbol;
-symbolS *dot_text_symbol;
-symbolS *dot_data_symbol;
-symbolS *dot_bss_symbol;
-
struct obstack notes;
static void fb_label_init PARAMS ((void));
-void
-symbol_begin ()
-{
- symbol_lastP = NULL;
- symbol_rootP = NULL; /* In case we have 0 symbols (!!) */
- sy_hash = hash_new ();
- memset ((char *) (&abs_symbol), '\0', sizeof (abs_symbol));
-#ifdef BFD_ASSEMBLER
- abs_symbol.bsym = bfd_abs_section.symbol;
-#else
- /* Can't initialise a union. Sigh. */
- S_SET_SEGMENT (&abs_symbol, absolute_section);
-#endif
-#ifdef LOCAL_LABELS_FB
- fb_label_init ();
-#endif /* LOCAL_LABELS_FB */
-}
-
/*
* symbol_new()
*
*/
symbolS *
-symbol_new (name, segment, value, frag)
+symbol_new (name, segment, valu, frag)
CONST char *name; /* It is copied, the caller can destroy/modify */
segT segment; /* Segment identifier (SEG_<something>) */
- valueT value; /* Symbol value */
+ valueT valu; /* Symbol value */
fragS *frag; /* Associated fragment */
{
unsigned int name_length;
S_SET_NAME (symbolP, preserved_copy_of_name);
S_SET_SEGMENT (symbolP, segment);
- S_SET_VALUE (symbolP, value);
+ S_SET_VALUE (symbolP, valu);
symbol_clear_list_pointers(symbolP);
symbolP->sy_frag = frag;
#ifndef BFD_ASSEMBLER
symbolP->sy_number = ~0;
- symbolP->sy_name_offset = ~0;
+ symbolP->sy_name_offset = (unsigned int) ~0;
#endif
/*
S_GET_OTHER (symbolP), S_GET_DESC (symbolP),
(long) S_GET_VALUE (symbolP));
#else
- as_fatal ("Symbol \"%s\" is already defined as \"%s\"/%d.",
+ as_fatal ("Symbol \"%s\" is already defined as \"%s\"/%ld.",
sym_name,
segment_name (S_GET_SEGMENT (symbolP)),
- S_GET_VALUE (symbolP));
+ (long) S_GET_VALUE (symbolP));
#endif
}
} /* if the undefined symbol has no value */
symbol_table_insert (symbolP)
symbolS *symbolP;
{
- register char *error_string;
+ register const char *error_string;
know (symbolP);
know (S_GET_NAME (symbolP));
- if (*(error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (char *) symbolP)))
+ if ((error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (PTR) symbolP)))
{
as_fatal ("Inserting \"%s\" into symbol table failed: %s",
S_GET_NAME (symbolP), error_string);
know (symbolP->sy_next->sy_previous == symbolP);
#else
/* Walk the list anyways, to make sure pointers are still good. */
- *symbolP;
+ ;
#endif /* SYMBOLS_NEED_BACKPOINTERS */
}
resolve_symbol_value (symp)
symbolS *symp;
{
+ int resolved;
+
if (symp->sy_resolved)
return;
+ resolved = 0;
+
if (symp->sy_resolving)
{
as_bad ("Symbol definition loop encountered at %s",
S_GET_NAME (symp));
S_SET_VALUE (symp, (valueT) 0);
+ resolved = 1;
}
else
{
S_SET_VALUE (symp, S_GET_VALUE (symp) + symp->sy_frag->fr_address);
if (S_GET_SEGMENT (symp) == expr_section)
S_SET_SEGMENT (symp, absolute_section);
+ resolved = 1;
break;
case O_symbol:
|| S_GET_SEGMENT (symp) == undefined_section)
S_SET_SEGMENT (symp,
S_GET_SEGMENT (symp->sy_value.X_add_symbol));
+
+ resolved = symp->sy_value.X_add_symbol->sy_resolved;
break;
case O_uminus:
if (S_GET_SEGMENT (symp) == expr_section
|| S_GET_SEGMENT (symp) == undefined_section)
S_SET_SEGMENT (symp, absolute_section);
+ resolved = symp->sy_value.X_add_symbol->sy_resolved;
break;
case O_multiply:
if (S_GET_SEGMENT (symp) == expr_section
|| S_GET_SEGMENT (symp) == undefined_section)
S_SET_SEGMENT (symp, absolute_section);
+ resolved = (symp->sy_value.X_add_symbol->sy_resolved
+ && symp->sy_value.X_op_symbol->sy_resolved);
break;
case O_register:
case O_big:
case O_illegal:
- as_bad ("bad value for symbol \"%s\"", S_GET_NAME (symp));
+ /* Give an error (below) if not in expr_section. We don't
+ want to worry about expr_section symbols, because they
+ are fictional (they are created as part of expression
+ resolution), and any problems may not actually mean
+ anything. */
break;
}
}
- symp->sy_resolved = 1;
+ /* Don't worry if we can't resolve an expr_section symbol. */
+ if (resolved)
+ symp->sy_resolved = 1;
+ else if (S_GET_SEGMENT (symp) != expr_section)
+ {
+ as_bad ("can't resolve value for symbol \"%s\"", S_GET_NAME (symp));
+ symp->sy_resolved = 1;
+ }
}
#ifdef LOCAL_LABELS_DOLLAR
static long *dollar_label_instances;
static char *dollar_label_defines;
static long dollar_label_count;
-static long dollar_label_max;
+static unsigned long dollar_label_max;
int
dollar_label_defined (label)
void
dollar_label_clear ()
{
- memset (dollar_label_defines, '\0', dollar_label_count);
+ memset (dollar_label_defines, '\0', (unsigned int) dollar_label_count);
}
#define DOLLAR_LABEL_BUMP_BY 10
static long fb_low_counter[FB_LABEL_SPECIAL];
static long *fb_labels;
static long *fb_label_instances;
-static long fb_label_count = 0;
-static long fb_label_max = 0;
+static long fb_label_count;
+static long fb_label_max;
/* this must be more than FB_LABEL_SPECIAL */
#define FB_LABEL_BUMP_BY (FB_LABEL_SPECIAL + 6)
{
s->sy_value.X_op = O_constant;
s->sy_value.X_add_number = (offsetT) val;
+ s->sy_value.X_unsigned = 0;
}
#ifdef BFD_ASSEMBLER
flagword flags = s->bsym->flags;
/* sanity check */
- if (flags & BSF_LOCAL && flags & (BSF_EXPORT | BSF_GLOBAL))
+ if (flags & BSF_LOCAL && flags & BSF_GLOBAL)
abort ();
- return (flags & (BSF_EXPORT | BSF_GLOBAL)) != 0;
+ return (flags & BSF_GLOBAL) != 0;
}
int
S_IS_COMMON (s)
symbolS *s;
{
- return s->bsym->section == &bfd_com_section;
+ return bfd_is_com_section (s->bsym->section);
}
int
flagword flags = s->bsym->flags;
/* sanity check */
- if (flags & BSF_LOCAL && flags & (BSF_EXPORT | BSF_GLOBAL))
+ if (flags & BSF_LOCAL && flags & BSF_GLOBAL)
abort ();
return (S_GET_NAME (s)
}
#endif /* BFD_ASSEMBLER */
+void
+symbol_begin ()
+{
+ symbol_lastP = NULL;
+ symbol_rootP = NULL; /* In case we have 0 symbols (!!) */
+ sy_hash = hash_new ();
+ memset ((char *) (&abs_symbol), '\0', sizeof (abs_symbol));
+#ifdef BFD_ASSEMBLER
+ abs_symbol.bsym = bfd_abs_section.symbol;
+#else
+ /* Can't initialise a union. Sigh. */
+ S_SET_SEGMENT (&abs_symbol, absolute_section);
+#endif
+#ifdef LOCAL_LABELS_FB
+ fb_label_init ();
+#endif /* LOCAL_LABELS_FB */
+}
+
/* end of symbols.c */