Allow symbol and label names to be enclosed in double quotes.

gas	PR gas/18581
	* expr.c (get_symbol_end): Rename to get_symbol_name.  Add a
	return parameter pointing to the start of the symbol.  Allow
	symbol names enclosed in double quotes.
	(restore_line_pointer): New function.  Replace the NUL character
	inserted into the input stream with the given character.  If the
	character was a double quote, advance the input pointer.
	* expr.h (get_symbol_end): Delete.
	(get_symbol_name): Add prototype.
	(restore_line_pointer): Prototype.
	* read.h (SKIP_WHITESPACE_AFTER_NAME): New macro.
	* doc/as.texinfo (Symbol Intro): Document that symbol names can
	now be enclosed in double quotes.
	* cond.c (s_ifdef): Replace get_symbol_end with get_symbol_name.
	Use restore_line_pointer to replace the NUL in the input stream.
	Use SKIP_WHITESPACE_AFTER_NAME to skip past the end of a symbol.
	Check for the use of double quoted symbol names.
	* expr.c: Likewise.
	* config/obj-aout.c: Likewise.
	* config/obj-coff-seh.c: Likewise.
	* config/obj-coff.c: Likewise.
	* config/obj-elf.c: Likewise.
	* config/obj-evax.c: Likewise.
	* config/obj-macho.c: Likewise.
	* config/obj-som.c: Likewise.
	* config/tc-alpha.c: Likewise.
	* config/tc-arc.c: Likewise.
	* config/tc-arm.c: Likewise.
	* config/tc-dlx.c: Likewise.
	* config/tc-h8300.c: Likewise.
	* config/tc-hppa.c: Likewise.
	* config/tc-i370.c: Likewise.
	* config/tc-i386-intel.c: Likewise.
	* config/tc-i386.c: Likewise.
	* config/tc-i960.c: Likewise.
	* config/tc-ia64.c: Likewise.
	* config/tc-iq2000.c: Likewise.
	* config/tc-m32r.c: Likewise.
	* config/tc-m68hc11.c: Likewise.
	* config/tc-m68k.c: Likewise.
	* config/tc-microblaze.c: Likewise.
	* config/tc-mips.c: Likewise.
	* config/tc-mmix.c: Likewise.
	* config/tc-mn10200.c: Likewise.
	* config/tc-mn10300.c: Likewise.
	* config/tc-nios2.c: Likewise.
	* config/tc-ppc.c: Likewise.
	* config/tc-s390.c: Likewise.
	* config/tc-score.c: Likewise.
	* config/tc-score7.c: Likewise.
	* config/tc-sparc.c: Likewise.
	* config/tc-tic4x.c: Likewise.
	* config/tc-tic54x.c: Likewise.
	* config/tc-tic6x.c: Likewise.
	* config/tc-tilegx.c: Likewise.
	* config/tc-tilepro.c: Likewise.
	* config/tc-v850.c: Likewise.
	* config/tc-xtensa.c: Likewise.
	* config/tc-z80.c: Likewise.
	* dw2gencfi.c: Likewise.
	* dwarf2dbgc.: Likewise.
	* ecoff.c: Likewise.
	* read.c: Likewise.
	* stabs.c: Likewise.

tests	PR gas/18581
	* gas/all/byte.d: Disable this test.  Quoted expressions
	are now allowed in .byte directives.
	* gas/all/quoted-sym-names.s: New test.
	* gas/all/quoted-sym-names.d: Expected output.
	* gas/all/gas.exp: Run the new test.
This commit is contained in:
Nick Clifton
2015-08-21 16:42:14 +01:00
parent 40045d9181
commit d02603dc20
59 changed files with 900 additions and 911 deletions

View File

@ -351,8 +351,8 @@ tic54x_asg (int x ATTRIBUTE_UNUSED)
return;
}
name = ++input_line_pointer;
c = get_symbol_end (); /* Get terminator. */
++input_line_pointer;
c = get_symbol_name (&name); /* Get terminator. */
if (!ISALPHA (*name))
{
as_bad (_("symbols assigned with .asg must begin with a letter"));
@ -367,7 +367,7 @@ tic54x_asg (int x ATTRIBUTE_UNUSED)
strcpy (tmp, name);
name = tmp;
subsym_create_or_replace (name, str);
*input_line_pointer = c;
(void) restore_line_pointer (c);
demand_empty_rest_of_line ();
}
@ -411,11 +411,10 @@ tic54x_eval (int x ATTRIBUTE_UNUSED)
ignore_rest_of_line ();
return;
}
name = input_line_pointer;
c = get_symbol_end (); /* Get terminator. */
c = get_symbol_name (&name); /* Get terminator. */
tmp = xmalloc (strlen (name) + 1);
name = strcpy (tmp, name);
*input_line_pointer = c;
(void) restore_line_pointer (c);
if (!ISALPHA (*name))
{
@ -471,8 +470,9 @@ tic54x_bss (int x ATTRIBUTE_UNUSED)
current_seg = now_seg; /* Save current seg. */
current_subseg = now_subseg; /* Save current subseg. */
name = input_line_pointer;
c = get_symbol_end (); /* Get terminator. */
c = get_symbol_name (&name); /* Get terminator. */
if (c == '"')
c = * ++ input_line_pointer;
if (c != ',')
{
as_bad (_(".bss size argument missing\n"));
@ -782,8 +782,8 @@ tic54x_endstruct (int is_union)
static void
tic54x_tag (int ignore ATTRIBUTE_UNUSED)
{
char *name = input_line_pointer;
int c = get_symbol_end ();
char *name;
int c = get_symbol_name (&name);
struct stag *stag = (struct stag *) hash_find (stag_hash, name);
if (!stag)
@ -829,7 +829,7 @@ tic54x_tag (int ignore ATTRIBUTE_UNUSED)
if (current_stag != NULL && !current_stag->is_union)
abs_section_offset += stag->size;
*input_line_pointer = c;
(void) restore_line_pointer (c);
demand_empty_rest_of_line ();
line_label = NULL;
}
@ -1109,11 +1109,10 @@ tic54x_global (int type)
do
{
name = input_line_pointer;
c = get_symbol_end ();
c = get_symbol_name (&name);
symbolP = symbol_find_or_make (name);
c = restore_line_pointer (c);
*input_line_pointer = c;
S_SET_STORAGE_CLASS (symbolP, C_EXT);
if (c == ',')
{
@ -1184,13 +1183,14 @@ tic54x_sect (int arg)
else
{
int c;
name = input_line_pointer;
c = get_symbol_end ();
c = get_symbol_name (&name);
len = strlen(name);
name = strcpy (xmalloc (len + 10), name);
*input_line_pointer = c;
(void) restore_line_pointer (c);
demand_empty_rest_of_line ();
}
/* Make sure all named initialized sections flagged properly. If we
encounter instructions, we'll flag it with SEC_CODE as well. */
strcat (name, ",\"w\"\n");
@ -1366,17 +1366,14 @@ tic54x_usect (int x ATTRIBUTE_UNUSED)
current_seg = now_seg; /* Save current seg. */
current_subseg = now_subseg; /* Save current subseg. */
if (*input_line_pointer == '"')
input_line_pointer++;
section_name = input_line_pointer;
c = get_symbol_end (); /* Get terminator. */
input_line_pointer++; /* Skip null symbol terminator. */
c = get_symbol_name (&section_name); /* Get terminator. */
name = xmalloc (input_line_pointer - section_name + 1);
strcpy (name, section_name);
if (*input_line_pointer == ',')
c = restore_line_pointer (c);
if (c == ',')
++input_line_pointer;
else if (c != ',')
else
{
as_bad (_("Missing size argument"));
ignore_rest_of_line ();
@ -2008,17 +2005,17 @@ tic54x_message (int type)
static void
tic54x_label (int ignored ATTRIBUTE_UNUSED)
{
char *name = input_line_pointer;
char *name;
symbolS *symbolP;
int c;
ILLEGAL_WITHIN_STRUCT ();
c = get_symbol_end ();
c = get_symbol_name (&name);
symbolP = colon (name);
S_SET_STORAGE_CLASS (symbolP, C_STATLAB);
*input_line_pointer = c;
(void) restore_line_pointer (c);
demand_empty_rest_of_line ();
}
@ -2141,12 +2138,12 @@ tic54x_sblock (int ignore ATTRIBUTE_UNUSED)
}
else
{
char *section_name = input_line_pointer;
char *section_name;
c = get_symbol_end ();
c = get_symbol_name (&section_name);
name = xmalloc (strlen (section_name) + 1);
strcpy (name, section_name);
*input_line_pointer = c;
(void) restore_line_pointer (c);
}
seg = bfd_get_section_by_name (stdoutput, name);
@ -2256,12 +2253,11 @@ tic54x_var (int ignore ATTRIBUTE_UNUSED)
ignore_rest_of_line ();
return;
}
name = input_line_pointer;
c = get_symbol_end ();
c = get_symbol_name (&name);
/* .var symbols start out with a null string. */
name = strcpy (xmalloc (strlen (name) + 1), name);
hash_insert (subsym_hash[macro_level], name, empty);
*input_line_pointer = c;
c = restore_line_pointer (c);
if (c == ',')
{
++input_line_pointer;
@ -4500,8 +4496,8 @@ subsym_substitute (char *line, int forced)
if (forced)
++ptr;
name = input_line_pointer = ptr;
c = get_symbol_end ();
input_line_pointer = ptr;
c = get_symbol_name (&name);
/* '?' is not normally part of a symbol, but it IS part of a local
label. */
if (c == '?')
@ -4846,7 +4842,7 @@ md_assemble (char *line)
int c;
input_line_pointer = line;
c = get_symbol_end ();
c = get_symbol_name (&line);
if (cpu == VNONE)
cpu = V542;