* as.c: Include write.h.
(common_emul_init): Use FAKE_LABEL_NAME.
* ecoff.c (add_file, ecoff_directive_end, ecoff_directive_loc):
Likewise.
(ecoff_build_symbols): Use FAKE_LABEL_CHAR.
* expr.c (get_symbol_name): Use FAKE_LABEL_CHAR. Accept only if
input_from_string is TRUE.
* read.c (input_from_string): New.
(read_symbol_name): Use FAKE_LABEL_CHAR. Accept only if
input_from_string is TRUE.
(temp_ilp): Set input_from_string to TRUE.
(restore_ilp): Set input_from_string to FALSE.
* read.h (input_from_string): Declare.
* symbols.c: Include write.h
(S_IS_LOCAL): Check for FAKE_LABEL_CHAR.
(symbol_relc_make_sym): Fix comment refering to default fake label
string.
* write.h (FAKE_LABEL_CHAR): New.
* config/tc-riscv.h (FAKE_LABEL_CHAR): Define.
* testsuite/gas/all/err-fakelabel.s: New.
2017-11-22 Jim Wilson <jimw@sifive.com>
+ * as.c: Include write.h.
+ (common_emul_init): Use FAKE_LABEL_NAME.
+ * ecoff.c (add_file, ecoff_directive_end, ecoff_directive_loc):
+ Likewise.
+ (ecoff_build_symbols): Use FAKE_LABEL_CHAR.
+ * expr.c (get_symbol_name): Use FAKE_LABEL_CHAR. Accept only if
+ input_from_string is TRUE.
+ * read.c (input_from_string): New.
+ (read_symbol_name): Use FAKE_LABEL_CHAR. Accept only if
+ input_from_string is TRUE.
+ (temp_ilp): Set input_from_string to TRUE.
+ (restore_ilp): Set input_from_string to FALSE.
+ * read.h (input_from_string): Declare.
+ * symbols.c: Include write.h
+ (S_IS_LOCAL): Check for FAKE_LABEL_CHAR.
+ (symbol_relc_make_sym): Fix comment refering to default fake label
+ string.
+ * write.h (FAKE_LABEL_CHAR): New.
+ * config/tc-riscv.h (FAKE_LABEL_CHAR): Define.
+ * testsuite/gas/all/err-fakelabel.s: New.
+
* doc/as.texinfo (.align): Change some to most for text nop fill.
(.balign, .p2align): Likewise.
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#include "bfdver.h"
+#include "write.h"
#ifdef HAVE_ITBL_CPU
#include "itbl-ops.h"
if (this_emulation->fake_label_name == 0)
{
if (this_emulation->leading_underscore)
- this_emulation->fake_label_name = "L0\001";
+ this_emulation->fake_label_name = FAKE_LABEL_NAME;
else
/* What other parameters should we test? */
- this_emulation->fake_label_name = ".L0\001";
+ this_emulation->fake_label_name = "." FAKE_LABEL_NAME;
}
}
#endif
sure FAKE_LABEL_NAME is printable. It still must be distinct from any
real label name. So, append a space, which other labels can't contain. */
#define FAKE_LABEL_NAME ".L0 "
+/* Changing the special character in FAKE_LABEL_NAME requires changing
+ FAKE_LABEL_CHAR too. */
+#define FAKE_LABEL_CHAR ' '
#define md_relax_frag(segment, fragp, stretch) \
riscv_relax_frag (segment, fragp, stretch)
if (stabs_seen)
{
(void) add_ecoff_symbol (file_name, st_Nil, sc_Nil,
- symbol_new ("L0\001", now_seg,
+ symbol_new (FAKE_LABEL_NAME, now_seg,
(valueT) frag_now_fix (),
frag_now),
(bfd_vma) 0, 0, ECOFF_MARK_STAB (N_SOL));
as_warn (_(".end directive names unknown symbol"));
else
(void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text,
- symbol_new ("L0\001", now_seg,
+ symbol_new (FAKE_LABEL_NAME, now_seg,
(valueT) frag_now_fix (),
frag_now),
(bfd_vma) 0, (symint_t) 0, (symint_t) 0);
if (stabs_seen)
{
(void) add_ecoff_symbol ((char *) NULL, st_Label, sc_Text,
- symbol_new ("L0\001", now_seg,
+ symbol_new (FAKE_LABEL_NAME, now_seg,
(valueT) frag_now_fix (),
frag_now),
(bfd_vma) 0, 0, lineno);
/* If an st_end symbol has an associated gas
symbol, then it is a local label created for
a .bend or .end directive. Stabs line
- numbers will have \001 in the names. */
+ numbers will have FAKE_LABEL_CHAR in the names. */
if (local
&& sym_ptr->ecoff_sym.asym.st != st_End
- && strchr (sym_ptr->name, '\001') == 0)
+ && strchr (sym_ptr->name, FAKE_LABEL_CHAR) == 0)
sym_ptr->ecoff_sym.asym.iss =
add_string (&fil_ptr->strings,
fil_ptr->str_hash,
char c;
* ilp_return = input_line_pointer;
- /* We accept \001 in a name in case this is being called with a
+ /* We accept FAKE_LABEL_CHAR in a name in case this is being called with a
constructed string. */
- if (is_name_beginner (c = *input_line_pointer++) || c == '\001')
+ if (is_name_beginner (c = *input_line_pointer++)
+ || (input_from_string && c == FAKE_LABEL_CHAR))
{
while (is_part_of_name (c = *input_line_pointer++)
- || c == '\001')
+ || (input_from_string && c == FAKE_LABEL_CHAR))
;
if (is_name_ender (c))
c = *input_line_pointer++;
#endif
char *input_line_pointer; /*->next char of source file to parse. */
+bfd_boolean input_from_string = FALSE;
#if BITS_PER_CHAR != 8
/* The following table is indexed by[(char)] and will break if
if (mbstowcs (NULL, name, len) == (size_t) -1)
as_warn (_("symbol name not recognised in the current locale"));
}
- else if (is_name_beginner (c) || c == '\001')
+ else if (is_name_beginner (c) || (input_from_string && c == FAKE_LABEL_CHAR))
{
ptrdiff_t len;
name = input_line_pointer - 1;
- /* We accept \001 in a name in case this is
+ /* We accept FAKE_LABEL_CHAR in a name in case this is
being called with a constructed string. */
while (is_part_of_name (c = *input_line_pointer++)
- || c == '\001')
+ || (input_from_string && c == FAKE_LABEL_CHAR))
;
len = (input_line_pointer - name) - 1;
input_line_pointer = buf;
buffer_limit = buf + strlen (buf);
+ input_from_string = TRUE;
}
/* Restore a saved input line pointer. */
input_line_pointer = saved_ilp;
buffer_limit = saved_limit;
+ input_from_string = FALSE;
saved_ilp = NULL;
}
02110-1301, USA. */
extern char *input_line_pointer; /* -> char we are parsing now. */
+extern bfd_boolean input_from_string;
/* Define to make whitespace be allowed in many syntactically
unnecessary places. Normally undefined. For compatibility with
#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. */
&& ! 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 (".");
--- /dev/null
+;# Test that fake labels aren't accepted.
+;# { dg-do assemble }
+label\ 1: ;# { dg-error "Error: " }
#define FAKE_LABEL_NAME "L0\001"
#endif
+/* This is the special character used to indicate a fake symbol. Must be
+ present in FAKE_LABEL_NAME. */
+#ifndef FAKE_LABEL_CHAR
+#define FAKE_LABEL_CHAR '\001'
+#endif
+
#include "bit_fix.h"
/*