diff options
author | Nick Clifton <nickc@redhat.com> | 2015-08-21 16:42:14 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2015-08-21 16:42:14 +0100 |
commit | d02603dc201f80cd9d2a1f4b1a16110b1e04222b (patch) | |
tree | b55476923d8bde556b6b3421345bde8e4562ad97 /gas/config/tc-ppc.c | |
parent | 40045d91812b25c88c8275b8c08d27c234b68ba8 (diff) | |
download | gdb-d02603dc201f80cd9d2a1f4b1a16110b1e04222b.zip gdb-d02603dc201f80cd9d2a1f4b1a16110b1e04222b.tar.gz gdb-d02603dc201f80cd9d2a1f4b1a16110b1e04222b.tar.bz2 |
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.
Diffstat (limited to 'gas/config/tc-ppc.c')
-rw-r--r-- | gas/config/tc-ppc.c | 126 |
1 files changed, 49 insertions, 77 deletions
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index 8cff4dc..6e48f7a 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -860,7 +860,7 @@ register_name (expressionS *expressionP) else if (!reg_names_p || !ISALPHA (name[0])) return FALSE; - c = get_symbol_end (); + c = get_symbol_name (&name); reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT, name); /* Put back the delimiting char. */ @@ -2142,13 +2142,12 @@ ppc_elf_lcomm (int xxx ATTRIBUTE_UNUSED) char *pfrag; int align2; - name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&name); - /* just after name is now '\0'. */ + /* Just after name is now '\0'. */ p = input_line_pointer; *p = c; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); if (*input_line_pointer != ',') { as_bad (_("expected comma after symbol-name: rest of line ignored.")); @@ -2238,8 +2237,8 @@ ppc_elf_lcomm (int xxx ATTRIBUTE_UNUSED) static void ppc_elf_localentry (int ignore ATTRIBUTE_UNUSED) { - char *name = input_line_pointer; - char c = get_symbol_end (); + char *name; + char c = get_symbol_name (&name); char *p; expressionS exp; symbolS *sym; @@ -2248,7 +2247,7 @@ ppc_elf_localentry (int ignore ATTRIBUTE_UNUSED) p = input_line_pointer; *p = c; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); if (*input_line_pointer != ',') { *p = 0; @@ -2491,8 +2490,7 @@ parse_toc_entry (enum toc_size_qualifier *toc_kind) SKIP_WHITESPACE (); /* Find the spelling of the operand. */ - toc_spec = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&toc_spec); if (strcmp (toc_spec, "toc") == 0) { @@ -2521,7 +2519,7 @@ parse_toc_entry (enum toc_size_qualifier *toc_kind) /* Now find the ']'. */ *input_line_pointer = c; - SKIP_WHITESPACE (); /* leading whitespace could be there. */ + SKIP_WHITESPACE_AFTER_NAME (); /* leading whitespace could be there. */ c = *input_line_pointer++; /* input_line_pointer->past char in c. */ if (c != ']') @@ -3630,10 +3628,9 @@ ppc_comm (int lcomm) symbolS *sym; char *pfrag; - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); end_name = input_line_pointer; - *end_name = endc; + (void) restore_line_pointer (endc); if (*input_line_pointer != ',') { @@ -3684,12 +3681,11 @@ ppc_comm (int lcomm) } ++input_line_pointer; - lcomm_name = input_line_pointer; - lcomm_endc = get_symbol_end (); + lcomm_endc = get_symbol_name (&lcomm_name); lcomm_sym = symbol_find_or_make (lcomm_name); - *input_line_pointer = lcomm_endc; + (void) restore_line_pointer (lcomm_endc); /* The fourth argument to .lcomm is the alignment. */ if (*input_line_pointer != ',') @@ -3792,12 +3788,11 @@ ppc_csect (int ignore ATTRIBUTE_UNUSED) symbolS *sym; offsetT align; - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); sym = symbol_find_or_make (name); - *input_line_pointer = endc; + (void) restore_line_pointer (endc); if (S_GET_NAME (sym)[0] == '\0') { @@ -3965,15 +3960,14 @@ ppc_dwsect (int ignore ATTRIBUTE_UNUSED) /* Parse opt-label. */ if (*input_line_pointer == ',') { - const char *label; + char *label; char c; ++input_line_pointer; - label = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&label); opt_label = symbol_find_or_make (label); - *input_line_pointer = c; + (void) restore_line_pointer (c); } else opt_label = NULL; @@ -4103,8 +4097,7 @@ ppc_named_section (int ignore ATTRIBUTE_UNUSED) char c; symbolS *sym; - user_name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&user_name); if (strcmp (user_name, ".text") == 0) real_name = ".text[PR]"; @@ -4113,12 +4106,12 @@ ppc_named_section (int ignore ATTRIBUTE_UNUSED) else { as_bad (_("the XCOFF file format does not support arbitrary sections")); - *input_line_pointer = c; + (void) restore_line_pointer (c); ignore_rest_of_line (); return; } - *input_line_pointer = c; + (void) restore_line_pointer (c); sym = symbol_find_or_make (real_name); @@ -4135,12 +4128,11 @@ ppc_extern (int ignore ATTRIBUTE_UNUSED) char *name; char endc; - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); (void) symbol_find_or_make (name); - *input_line_pointer = endc; + (void) restore_line_pointer (endc); demand_empty_rest_of_line (); } @@ -4154,12 +4146,11 @@ ppc_lglobl (int ignore ATTRIBUTE_UNUSED) char endc; symbolS *sym; - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); sym = symbol_find_or_make (name); - *input_line_pointer = endc; + (void) restore_line_pointer (endc); symbol_get_tc (sym)->output = 1; @@ -4192,14 +4183,13 @@ ppc_ref (int ignore ATTRIBUTE_UNUSED) do { - name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&name); fix_at_start (symbol_get_frag (ppc_current_csect), 0, symbol_find_or_make (name), 0, FALSE, BFD_RELOC_NONE); *input_line_pointer = c; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); c = *input_line_pointer; if (c == ',') { @@ -4229,12 +4219,11 @@ ppc_rename (int ignore ATTRIBUTE_UNUSED) symbolS *sym; int len; - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); sym = symbol_find_or_make (name); - *input_line_pointer = endc; + (void) restore_line_pointer (endc); if (*input_line_pointer != ',') { @@ -4393,8 +4382,7 @@ ppc_function (int ignore ATTRIBUTE_UNUSED) symbolS *ext_sym; symbolS *lab_sym; - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); /* Ignore any [PR] suffix. */ name = ppc_canonicalize_symbol_name (name); @@ -4405,7 +4393,7 @@ ppc_function (int ignore ATTRIBUTE_UNUSED) ext_sym = symbol_find_or_make (name); - *input_line_pointer = endc; + (void) restore_line_pointer (endc); if (*input_line_pointer != ',') { @@ -4415,12 +4403,11 @@ ppc_function (int ignore ATTRIBUTE_UNUSED) } ++input_line_pointer; - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); lab_sym = symbol_find_or_make (name); - *input_line_pointer = endc; + (void) restore_line_pointer (endc); if (ext_sym != lab_sym) { @@ -4599,12 +4586,11 @@ ppc_bs (int ignore ATTRIBUTE_UNUSED) if (ppc_current_block != NULL) as_bad (_("nested .bs blocks")); - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); csect = symbol_find_or_make (name); - *input_line_pointer = endc; + (void) restore_line_pointer (endc); sym = symbol_make (".bs"); S_SET_SEGMENT (sym, now_seg); @@ -4881,12 +4867,11 @@ ppc_tc (int ignore ATTRIBUTE_UNUSED) return; } - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); sym = symbol_find_or_make (name); - *input_line_pointer = endc; + (void) restore_line_pointer (endc); if (S_IS_DEFINED (sym)) { @@ -4952,6 +4937,7 @@ ppc_tc (int ignore ATTRIBUTE_UNUSED) static void ppc_machine (int ignore ATTRIBUTE_UNUSED) { + char c; char *cpu_string; #define MAX_HISTORY 100 static ppc_cpu_t *cpu_history; @@ -4959,19 +4945,9 @@ ppc_machine (int ignore ATTRIBUTE_UNUSED) SKIP_WHITESPACE (); - if (*input_line_pointer == '"') - { - int len; - cpu_string = demand_copy_C_string (&len); - } - else - { - char c; - cpu_string = input_line_pointer; - c = get_symbol_end (); - cpu_string = xstrdup (cpu_string); - *input_line_pointer = c; - } + c = get_symbol_name (&cpu_string); + cpu_string = xstrdup (cpu_string); + (void) restore_line_pointer (c); if (cpu_string != NULL) { @@ -5210,8 +5186,7 @@ ppc_znop (int ignore ATTRIBUTE_UNUSED) char *name; /* Strip out the symbol name. */ - symbol_name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&symbol_name); name = xmalloc (input_line_pointer - symbol_name + 1); strcpy (name, symbol_name); @@ -5220,7 +5195,7 @@ ppc_znop (int ignore ATTRIBUTE_UNUSED) *input_line_pointer = c; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); /* Look up the opcode in the hash table. */ opcode = (const struct powerpc_opcode *) hash_find (ppc_hash, "nop"); @@ -5256,13 +5231,12 @@ ppc_pe_comm (int lcomm) symbolS *symbolP; offsetT align; - name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&name); /* just after name is now '\0'. */ p = input_line_pointer; *p = c; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); if (*input_line_pointer != ',') { as_bad (_("expected comma after symbol-name: rest of line ignored.")); @@ -5387,15 +5361,14 @@ ppc_pe_section (int ignore ATTRIBUTE_UNUSED) segT sec; int align; - section_name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (§ion_name); name = xmalloc (input_line_pointer - section_name + 1); strcpy (name, section_name); *input_line_pointer = c; - SKIP_WHITESPACE (); + SKIP_WHITESPACE_AFTER_NAME (); exp = 0; flags = SEC_NO_FLAGS; @@ -5543,12 +5516,11 @@ ppc_pe_function (int ignore ATTRIBUTE_UNUSED) char endc; symbolS *ext_sym; - name = input_line_pointer; - endc = get_symbol_end (); + endc = get_symbol_name (&name); ext_sym = symbol_find_or_make (name); - *input_line_pointer = endc; + (void) restore_line_pointer (endc); S_SET_DATA_TYPE (ext_sym, DT_FCN << N_BTSHFT); SF_SET_FUNCTION (ext_sym); |