+2015-08-27 Alan Modra <amodra@gmail.com>
+
+ PR gas/18581
+ * config/tc-aarch64.h (TC_START_LABEL): Redefine.
+ * config/tc-arm.c (tc_start_label_without_colon): Delete params.
+ Use input_line_pointer directly.
+ * config/tc-arm.h (TC_START_LABEL): Redefine.
+ (TC_START_LABEL_WITHOUT_COLON): Redefine.
+ (tc_start_label_without_colon): Update prototype.
+ * config/tc-bfin.c (bfin_start_label): Delete ptr param. Check
+ for NUL instead.
+ * config/tc-bfin.h (bfin_start_label): Update prototype.
+ (TC_START_LABEL): Redefine.
+ * config/tc-d30v.h (TC_START_LABEL): Redefine.
+ * config/tc-fr30.c (restore_colon): Rewrite.
+ (fr30_is_colon_insn): Add nul_char param. Return int. Bump
+ i_l_p over quote. Update restore_colon calls.
+ * config/tc-fr30.h (TC_START_LABEL): Redefine.
+ (fr30_is_colon_insn): Update prototype.
+ * config/tc-m32c.c (restore_colon, m32c_is_colon_insn): As above.
+ * config/tc-m32c.h (TC_START_LABEL): Redefine.
+ (m32c_is_colon_insn): Update prototype.
+ * config/tc-m32r.h (TC_START_LABEL): Redefine.
+ * config/tc-mep.h (TC_START_LABEL): Redefine.
+ * config/tc-nds32.h (TC_START_LABEL): Redefine.
+ * config/tc-tic54x.c (tic54x_start_label): Replace params with
+ nul_char and next_char. Step over trailing quote.
+ * config/tc-tic54x.h (TC_START_LABEL_WITHOUT_COLON): Redefine.
+ (tic54x_start_label): Update prototype.
+ * read.c (TC_START_LABEL): Redefine. Update invocation.
+ (TC_START_LABEL_WITHOUT_COLON): Update invocation.
+ * config/tc-nios2.c (s_nios2_set): Save initial input_line_pointer
+ and restore if calling s_set. Don't restore delim again.
+
2015-08-26 Alan Modra <amodra@gmail.com>
PR gas/18581
(aarch64_copy_symbol_attributes (DEST, SRC))
#endif
-#define TC_START_LABEL(C,S,STR) ((C) == ':' \
- || ((C) == '/' && aarch64_data_in_code ()))
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
+ (NEXT_CHAR == ':' || (NEXT_CHAR == '/' && aarch64_data_in_code ()))
#define tc_canonicalize_symbol_name(str) aarch64_canonicalize_symbol_name (str);
#define obj_adjust_symtab() aarch64_adjust_symtab ()
}
bfd_boolean
-tc_start_label_without_colon (char unused1 ATTRIBUTE_UNUSED, const char * rest)
+tc_start_label_without_colon (void)
{
bfd_boolean ret = TRUE;
if (codecomposer_syntax && asmfunc_state == WAITING_ASMFUNC_NAME)
{
- const char *label = rest;
+ const char *label = input_line_pointer;
while (!is_end_of_line[(int) label[-1]])
--label;
#define md_start_line_hook() arm_start_line_hook ()
-#define TC_START_LABEL_WITHOUT_COLON(c, l) tc_start_label_without_colon (c, l)
-extern bfd_boolean tc_start_label_without_colon (char, const char *);
+#define TC_START_LABEL_WITHOUT_COLON(NUL_CHAR, NEXT_CHAR) \
+ tc_start_label_without_colon ()
+extern bfd_boolean tc_start_label_without_colon (void);
#define tc_frob_label(S) arm_frob_label (S)
(arm_copy_symbol_attributes (DEST, SRC))
#endif
-#define TC_START_LABEL(C,S,STR) (C == ':' || (C == '/' && arm_data_in_code ()))
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
+ (NEXT_CHAR == ':' || (NEXT_CHAR == '/' && arm_data_in_code ()))
#define tc_canonicalize_symbol_name(str) arm_canonicalize_symbol_name (str);
#define obj_adjust_symtab() arm_adjust_symtab ()
}
bfd_boolean
-bfin_start_label (char *s, char *ptr)
+bfin_start_label (char *s)
{
- while (s != ptr)
+ while (*s != 0)
{
if (*s == '(' || *s == '[')
return FALSE;
#define WORKING_DOT_WORD
-extern bfd_boolean bfin_start_label (char *, char *);
+extern bfd_boolean bfin_start_label (char *);
#define md_number_to_chars number_to_chars_littleendian
#define md_convert_frag(b,s,f) as_fatal ("bfin convert_frag\n");
#define DOUBLESLASH_LINE_COMMENTS
-#define TC_START_LABEL(c, s, ptr) (c == ':' && bfin_start_label (s, ptr))
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
+ (NEXT_CHAR == ':' && bfin_start_label (STR))
#define tc_fix_adjustable(FIX) bfin_fix_adjustable (FIX)
extern bfd_boolean bfin_fix_adjustable (struct fix *);
int d30v_cleanup (int);
#define md_cleanup() d30v_cleanup (FALSE)
-#define TC_START_LABEL(ch, s, ptr) (ch == ':' && d30v_cleanup (FALSE))
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
+ (NEXT_CHAR == ':' && d30v_cleanup (FALSE))
void d30v_start_line (void);
#define md_start_line_hook() d30v_start_line ()
}
/* Worker function for fr30_is_colon_insn(). */
-static char
-restore_colon (int advance_i_l_p_by)
+static int
+restore_colon (char *next_i_l_p, char *nul_char)
{
- char c;
-
/* Restore the colon, and advance input_line_pointer to
the end of the new symbol. */
- * input_line_pointer = ':';
- input_line_pointer += advance_i_l_p_by;
- c = * input_line_pointer;
- * input_line_pointer = 0;
-
- return c;
+ *input_line_pointer = *nul_char;
+ input_line_pointer = next_i_l_p;
+ *nul_char = *next_i_l_p;
+ *next_i_l_p = 0;
+ return 1;
}
/* Determines if the symbol starting at START and ending in
(but which has now been replaced bu a NUL) is in fact an
LDI:8, LDI:20, LDI:32, CALL:D. JMP:D, RET:D or Bcc:D instruction.
If it is, then it restores the colon, advances INPUT_LINE_POINTER
- to the real end of the instruction/symbol, and returns the character
- that really terminated the symbol. Otherwise it returns 0. */
-char
-fr30_is_colon_insn (char * start)
+ to the real end of the instruction/symbol, saves the char there to
+ NUL_CHAR and pokes a NUL, and returns 1. Otherwise it returns 0. */
+int
+fr30_is_colon_insn (char *start, char *nul_char)
{
char * i_l_p = input_line_pointer;
+ if (*nul_char == '"')
+ ++i_l_p;
+
/* Check to see if the symbol parsed so far is 'ldi'. */
if ( (start[0] != 'l' && start[0] != 'L')
|| (start[1] != 'd' && start[1] != 'D')
break;
if (len == -1)
- return restore_colon (1);
+ return restore_colon (i_l_p + 1, nul_char);
}
}
/* Check to see if the text following the colon is '8'. */
if (i_l_p[1] == '8' && (i_l_p[2] == ' ' || i_l_p[2] == '\t'))
- return restore_colon (2);
+ return restore_colon (i_l_p + 2, nul_char);
/* Check to see if the text following the colon is '20'. */
- else if (i_l_p[1] == '2' && i_l_p[2] =='0' && (i_l_p[3] == ' ' || i_l_p[3] == '\t'))
- return restore_colon (3);
+ else if (i_l_p[1] == '2' && i_l_p[2] =='0'
+ && (i_l_p[3] == ' ' || i_l_p[3] == '\t'))
+ return restore_colon (i_l_p + 3, nul_char);
/* Check to see if the text following the colon is '32'. */
- else if (i_l_p[1] == '3' && i_l_p[2] =='2' && (i_l_p[3] == ' ' || i_l_p[3] == '\t'))
- return restore_colon (3);
+ else if (i_l_p[1] == '3' && i_l_p[2] =='2'
+ && (i_l_p[3] == ' ' || i_l_p[3] == '\t'))
+ return restore_colon (i_l_p + 3, nul_char);
return 0;
}
/* We need a special version of the TC_START_LABEL macro so that we
allow the LDI:8, LDI:20, LDI:32 and delay slot instructions to be
- parsed as such. We need to be able to change the contents of
- the local variable 'c' which is passed to this macro as 'character'. */
-#define TC_START_LABEL(character, s, i_l_p) \
- ((character) != ':' ? 0 : (character = fr30_is_colon_insn (s)) ? 0 : ((character = ':'), 1))
-extern char fr30_is_colon_insn (char *);
+ parsed as such. We need to be able to change the contents of the
+ var storing what was at the NUL delimiter. */
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
+ (NEXT_CHAR == ':' && !fr30_is_colon_insn (STR, &NUL_CHAR))
+extern int fr30_is_colon_insn (char *, char *);
}
/* Worker function for m32c_is_colon_insn(). */
-static char
-restore_colon (int advance_i_l_p_by)
+static int
+restore_colon (char *next_i_l_p, char *nul_char)
{
- char c;
-
/* Restore the colon, and advance input_line_pointer to
the end of the new symbol. */
- * input_line_pointer = ':';
- input_line_pointer += advance_i_l_p_by;
- c = * input_line_pointer;
- * input_line_pointer = 0;
-
- return c;
+ *input_line_pointer = *nul_char;
+ input_line_pointer = next_i_l_p;
+ *nul_char = *next_i_l_p;
+ *next_i_l_p = 0;
+ return 1;
}
/* Determines if the symbol starting at START and ending in
(but which has now been replaced bu a NUL) is in fact an
:Z, :S, :Q, or :G suffix.
If it is, then it restores the colon, advances INPUT_LINE_POINTER
- to the real end of the instruction/symbol, and returns the character
- that really terminated the symbol. Otherwise it returns 0. */
-char
-m32c_is_colon_insn (char *start ATTRIBUTE_UNUSED)
+ to the real end of the instruction/symbol, saves the char there to
+ NUL_CHAR and pokes a NUL, and returns 1. Otherwise it returns 0. */
+int
+m32c_is_colon_insn (char *start ATTRIBUTE_UNUSED, char *nul_char)
{
char * i_l_p = input_line_pointer;
+ if (*nul_char == '"')
+ ++i_l_p;
+
/* Check to see if the text following the colon is 'G' */
if (TOLOWER (i_l_p[1]) == 'g' && (i_l_p[2] == ' ' || i_l_p[2] == '\t'))
- return restore_colon (2);
+ return restore_colon (i_l_p + 2, nul_char);
/* Check to see if the text following the colon is 'Q' */
if (TOLOWER (i_l_p[1]) == 'q' && (i_l_p[2] == ' ' || i_l_p[2] == '\t'))
- return restore_colon (2);
+ return restore_colon (i_l_p + 2, nul_char);
/* Check to see if the text following the colon is 'S' */
if (TOLOWER (i_l_p[1]) == 's' && (i_l_p[2] == ' ' || i_l_p[2] == '\t'))
- return restore_colon (2);
+ return restore_colon (i_l_p + 2, nul_char);
/* Check to see if the text following the colon is 'Z' */
if (TOLOWER (i_l_p[1]) == 'z' && (i_l_p[2] == ' ' || i_l_p[2] == '\t'))
- return restore_colon (2);
+ return restore_colon (i_l_p + 2, nul_char);
return 0;
}
/* We need a special version of the TC_START_LABEL macro so that we
allow the :Z, :S, :Q and :G suffixes to be
- parsed as such. We need to be able to change the contents of
- the local variable 'c' which is passed to this macro as 'character'. */
-#define TC_START_LABEL(character, s, i_l_p) \
- ((character) != ':' ? 0 : (character = m32c_is_colon_insn (s)) ? 0 : ((character = ':'), 1))
-extern char m32c_is_colon_insn (char *);
+ parsed as such. We need to be able to change the contents of the
+ var storing what was at the NUL delimiter. */
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
+ (NEXT_CHAR == ':' && !m32c_is_colon_insn (STR, &NUL_CHAR))
+extern int m32c_is_colon_insn (char *, char *);
#define H_TICK_HEX 1
/* Ensure insns at labels are aligned to 32 bit boundaries. */
int m32r_fill_insn (int);
-#define TC_START_LABEL(ch, s, ptr) (ch == ':' && m32r_fill_insn (0))
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
+ (NEXT_CHAR == ':' && m32r_fill_insn (0))
#define md_cleanup() m32r_fill_insn (1)
#define md_elf_section_change_hook m32r_elf_section_change_hook
#define VTEXT_SECTION_NAME ".vtext"
/* Needed to process pending instructions when a label is encountered. */
-#define TC_START_LABEL(ch, s, ptr) ((ch == ':') && mep_flush_pending_output ())
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
+ (NEXT_CHAR == ':' && mep_flush_pending_output ())
#define tc_unrecognized_line(c) mep_unrecognized_line (c)
extern int mep_unrecognized_line (int);
#define md_macro_start() nds32_macro_start ()
#define md_macro_end() nds32_macro_end ()
#define md_macro_info(args) nds32_macro_info (args)
-#define TC_START_LABEL(C, S, STR) (C == ':' && nds32_start_label (0, 0))
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \
+ (NEXT_CHAR == ':' && nds32_start_label (0, 0))
#define tc_check_label(label) nds32_check_label (label)
#define tc_frob_label(label) nds32_frob_label (label)
#define md_end md_end
static void
s_nios2_set (int equiv)
{
+ char *save = input_line_pointer;
char *directive;
char delim = get_symbol_name (&directive);
char *endline = input_line_pointer;
/* If we fall through to here, either we have ".set XXX, YYY"
or we have ".set XXX" where XXX is unknown or we have
a syntax error. */
- input_line_pointer = directive;
- *endline = delim;
+ input_line_pointer = save;
s_set (equiv);
}
syntax puts the symbol *before* the pseudo (which is kinda like MRI syntax,
I guess, except I've never seen a definition of MRI syntax).
- C is the character that used to be at *REST, which points to the end of the
- label.
-
Don't allow labels to start with '.' */
int
-tic54x_start_label (int c, char *rest)
+tic54x_start_label (int nul_char, int next_char)
{
+ char *rest;
+
/* If within .struct/.union, no auto line labels, please. */
if (current_stag != NULL)
return 0;
/* Disallow labels starting with "." */
- if (c != ':')
+ if (next_char != ':')
{
- char *label = rest;
+ char *label = input_line_pointer;
while (!is_end_of_line[(int) label[-1]])
--label;
}
}
- if (is_end_of_line[(int) c])
+ if (is_end_of_line[(int) next_char])
return 1;
- if (ISSPACE (c))
- while (ISSPACE (c = *++rest))
- ;
- if (c == '.')
- {
- /* Don't let colon () define a label for any of these... */
- return (strncasecmp (rest, ".tag", 4) != 0 || !ISSPACE (rest[4]))
- && (strncasecmp (rest, ".struct", 7) != 0 || !ISSPACE (rest[7]))
- && (strncasecmp (rest, ".union", 6) != 0 || !ISSPACE (rest[6]))
- && (strncasecmp (rest, ".macro", 6) != 0 || !ISSPACE (rest[6]))
- && (strncasecmp (rest, ".set", 4) != 0 || !ISSPACE (rest[4]))
- && (strncasecmp (rest, ".equ", 4) != 0 || !ISSPACE (rest[4]));
- }
+ rest = input_line_pointer;
+ if (nul_char == '"')
+ ++rest;
+ while (ISSPACE (next_char))
+ next_char = *++rest;
+ if (next_char != '.')
+ return 1;
- return 1;
+ /* Don't let colon () define a label for any of these... */
+ return ((strncasecmp (rest, ".tag", 4) != 0 || !ISSPACE (rest[4]))
+ && (strncasecmp (rest, ".struct", 7) != 0 || !ISSPACE (rest[7]))
+ && (strncasecmp (rest, ".union", 6) != 0 || !ISSPACE (rest[6]))
+ && (strncasecmp (rest, ".macro", 6) != 0 || !ISSPACE (rest[6]))
+ && (strncasecmp (rest, ".set", 4) != 0 || !ISSPACE (rest[4]))
+ && (strncasecmp (rest, ".equ", 4) != 0 || !ISSPACE (rest[4])));
}
#define TC_FRAG_INIT(FRAGP) do {(FRAGP)->tc_frag_data = 0;}while (0)
/* tell GAS whether the given token is indeed a code label */
-#define TC_START_LABEL_WITHOUT_COLON(c,ptr) tic54x_start_label(c,ptr)
-extern int tic54x_start_label (int, char *);
+#define TC_START_LABEL_WITHOUT_COLON(NUL_CHAR, NEXT_CHAR) \
+ tic54x_start_label(NUL_CHAR, NEXT_CHAR)
+extern int tic54x_start_label (int, int);
/* custom handling for relocations in cons expressions */
#define TC_CONS_FIX_NEW(FRAG, OFF, LEN, EXP, RELOC) \
#include "wchar.h"
#ifndef TC_START_LABEL
-#define TC_START_LABEL(x,y,z) (x == ':')
+#define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) (NEXT_CHAR == ':')
#endif
/* Set by the object-format or the target. */
symbol in the symbol table. */
if (!mri_line_macro
#ifdef TC_START_LABEL_WITHOUT_COLON
- && TC_START_LABEL_WITHOUT_COLON (next_char,
- input_line_pointer)
+ && TC_START_LABEL_WITHOUT_COLON (nul_char, next_char)
#endif
)
line_label = colon (line_start);
S points to the beginning of the symbol.
[In case of pseudo-op, s->'.'.]
Input_line_pointer->'\0' where NUL_CHAR was. */
- if (TC_START_LABEL (next_char, s, input_line_pointer))
+ if (TC_START_LABEL (s, nul_char, next_char))
{
if (flag_m68k_mri)
{