/* symbols.c -symbol table-
Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001
+ 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#ifdef BFD_ASSEMBLER
if (OUTPUT_FLAVOR == bfd_target_aout_flavour)
#endif
- sprintf(od_buf, "%d.%d.",
- S_GET_OTHER (symbolP),
- S_GET_DESC (symbolP));
+ sprintf (od_buf, "%d.%d.",
+ S_GET_OTHER (symbolP),
+ S_GET_DESC (symbolP));
#endif
as_bad (_("symbol `%s' is already defined as \"%s\"/%s%ld"),
sym_name,
symbolS *
symbol_make (name)
- CONST char *name;
+ const char *name;
{
symbolS *symbolP;
symbolS *
symbol_find (name)
- CONST char *name;
+ const char *name;
{
#ifdef STRIP_UNDERSCORE
return (symbol_find_base (name, 1));
#endif /* STRIP_UNDERSCORE */
}
+symbolS *
+symbol_find_exact (name)
+ const char *name;
+{
+#ifdef BFD_ASSEMBLER
+ {
+ struct local_symbol *locsym;
+
+ locsym = (struct local_symbol *) hash_find (local_hash, name);
+ if (locsym != NULL)
+ return (symbolS *) locsym;
+ }
+#endif
+
+ return ((symbolS *) hash_find (sy_hash, name));
+}
+
symbolS *
symbol_find_base (name, strip_underscore)
- CONST char *name;
+ const char *name;
int strip_underscore;
{
if (strip_underscore && *name == '_')
*copy = '\0';
}
-#ifdef BFD_ASSEMBLER
- {
- struct local_symbol *locsym;
-
- locsym = (struct local_symbol *) hash_find (local_hash, name);
- if (locsym != NULL)
- return (symbolS *) locsym;
- }
-#endif
-
- return ((symbolS *) hash_find (sy_hash, name));
+ return symbol_find_exact (name);
}
/* Once upon a time, symbols were kept in a singly linked list. At
case O_bit_not:
case O_logical_not:
left = resolve_symbol_value (add_symbol);
+ seg_left = S_GET_SEGMENT (add_symbol);
if (op == O_uminus)
left = -left;
final_val += left + symp->sy_frag->fr_address;
if (final_seg == expr_section || final_seg == undefined_section)
- final_seg = absolute_section;
+ final_seg = seg_left;
resolved = symbol_resolved_p (add_symbol);
break;
Don't emit messages unless we're finalizing the symbol value,
otherwise we may get the same message multiple times. */
- if (op != O_eq && op != O_ne
- && (seg_left != absolute_section
- || seg_right != absolute_section)
- && ((op != O_subtract
- && op != O_lt && op != O_le && op != O_ge && op != O_gt)
- || seg_left != seg_right
- || (seg_left == undefined_section
- && add_symbol != op_symbol))
- && finalize_syms)
+ if ((op == O_eq || op == O_ne)
+ || ((op == O_subtract
+ || op == O_lt || op == O_le || op == O_ge || op == O_gt)
+ && seg_left == seg_right
+ && (seg_left != undefined_section
+ || add_symbol == op_symbol))
+ || (seg_left == absolute_section
+ && seg_right == absolute_section))
+ {
+ if (final_seg == expr_section || final_seg == undefined_section)
+ final_seg = absolute_section;
+ }
+ else if (finalize_syms)
{
char *file;
unsigned int line;
as_bad (_("invalid section for operation setting `%s'"),
S_GET_NAME (symp));
}
+ /* Prevent the error propagating. */
+ if (final_seg == expr_section || final_seg == undefined_section)
+ final_seg = absolute_section;
}
/* Check for division by zero. */
final_val += symp->sy_frag->fr_address + left;
if (final_seg == expr_section || final_seg == undefined_section)
- final_seg = absolute_section;
+ {
+ if (seg_left == undefined_section
+ || seg_right == undefined_section)
+ final_seg = undefined_section;
+ else if (seg_left == absolute_section)
+ final_seg = seg_right;
+ else
+ final_seg = seg_left;
+ }
resolved = (symbol_resolved_p (add_symbol)
&& symbol_resolved_p (op_symbol));
break;
return S_GET_NAME (s) == 0;
}
-CONST char *
+const char *
S_GET_NAME (s)
symbolS *s;
{
{
char * file;
unsigned int line;
-
+
/* Do not reassign section symbols. */
as_where (& file, & line);
as_warn_where (file, line,
segT s = S_GET_SEGMENT (sym);
if (s != undefined_section
- && s != expr_section)
+ && s != expr_section)
fprintf (file, " %lx", (long) S_GET_VALUE (sym));
}
else if (indent_level < max_indent_level