/* symbols.c -symbol table-
- Copyright (C) 1987-2016 Free Software Foundation, Inc.
+ Copyright (C) 1987-2018 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#include "obstack.h" /* For "symbols.h" */
#include "subsegs.h"
#include "struc-symbol.h"
+#include "write.h"
/* This is non-zero if symbols are case sensitive, which is the
default. */
}
else
{
-#if (!defined (OBJ_AOUT) && !defined (OBJ_MAYBE_AOUT) \
- && !defined (OBJ_BOUT) && !defined (OBJ_MAYBE_BOUT))
+#if (!defined (OBJ_AOUT) && !defined (OBJ_MAYBE_AOUT))
static const char *od_buf = "";
#else
char od_buf[100];
operands must be absolute. We already handled the case of
addition or subtraction of a constant above. This will
probably need to be changed for an object file format which
- supports arbitrary expressions, such as IEEE-695. */
+ supports arbitrary expressions. */
if (!(seg_left == absolute_section
&& seg_right == absolute_section)
&& !(op == O_eq || op == O_ne)
}
*symbolPP = symbolP;
- *valueP = exp.X_add_number;
- *segP = symbolP->bsym->section;
- *fragPP = symbolP->sy_frag;
+
+ /* A bogus input file can result in resolve_expression()
+ generating a local symbol, so we have to check again. */
+ if (LOCAL_SYMBOL_CHECK (symbolP))
+ {
+ struct local_symbol *locsym = (struct local_symbol *) symbolP;
+
+ *valueP = locsym->lsy_value;
+ *segP = locsym->lsy_section;
+ *fragPP = local_symbol_get_frag (locsym);
+ }
+ else
+ {
+ *valueP = exp.X_add_number;
+ *segP = symbolP->bsym->section;
+ *fragPP = symbolP->sy_frag;
+ }
if (*segP == expr_section)
switch (exp.X_op)
int
S_FORCE_RELOC (symbolS *s, int strict)
{
+ segT sec;
if (LOCAL_SYMBOL_CHECK (s))
- return ((struct local_symbol *) s)->lsy_section == undefined_section;
-
- return ((strict
+ sec = ((struct local_symbol *) s)->lsy_section;
+ else
+ {
+ if ((strict
&& ((s->bsym->flags & BSF_WEAK) != 0
|| (EXTERN_FORCE_RELOC
&& (s->bsym->flags & BSF_GLOBAL) != 0)))
- || (s->bsym->flags & BSF_GNU_INDIRECT_FUNCTION) != 0
- || s->bsym->section == undefined_section
- || bfd_is_com_section (s->bsym->section));
+ || (s->bsym->flags & BSF_GNU_INDIRECT_FUNCTION) != 0)
+ return TRUE;
+ sec = s->bsym->section;
+ }
+ return bfd_is_und_section (sec) || bfd_is_com_section (sec);
}
int
&& ! S_IS_DEBUG (s)
&& (strchr (name, DOLLAR_LABEL_CHAR)
|| strchr (name, LOCAL_LABEL_CHAR)
+#if FAKE_LABEL_CHAR != DOLLAR_LABEL_CHAR
+ || strchr (name, FAKE_LABEL_CHAR)
+#endif
|| TC_LABEL_IS_LOCAL (name)
|| (! flag_keep_locals
&& (bfd_is_local_label (stdoutput, s->bsym)
|| S_GET_SEGMENT (sym) == absolute_section)
return symbol_relc_make_expr (& sym->sy_value);
- /* This may be a "fake symbol" L0\001, referring to ".".
+ /* This may be a "fake symbol", referring to ".".
Write out a special null symbol to refer to this position. */
if (! strcmp (S_GET_NAME (sym), FAKE_LABEL_NAME))
return xstrdup (".");