diff options
author | Ian Lance Taylor <ian@airs.com> | 1995-09-07 01:17:16 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1995-09-07 01:17:16 +0000 |
commit | 86038ada178e4cf8f3a541f2720b26761901e769 (patch) | |
tree | 18df56d5a8bc0f1649c6429f0c3d68a3c8c3aef6 /gas/read.c | |
parent | fca4042a3a74ccc2974d28bbde58e79915799494 (diff) | |
download | gdb-86038ada178e4cf8f3a541f2720b26761901e769.zip gdb-86038ada178e4cf8f3a541f2720b26761901e769.tar.gz gdb-86038ada178e4cf8f3a541f2720b26761901e769.tar.bz2 |
* app.c (do_scrub_chars): In MRI mode, silently end quoted strings
at newline characters. In MRI mode, always keep spaces in the
operands field. In MRI mode, treat a line comment character as a
regular comment character following a space.
* cond.c (ignore_input): Use strncasecmp rather than strncmp when
looking for special pseudo-ops.
* read.c (cons_worker): In MRI mode, the expressions stop at the
first unquoted space.
(equals): Likewise.
Diffstat (limited to 'gas/read.c')
-rw-r--r-- | gas/read.c | 172 |
1 files changed, 144 insertions, 28 deletions
@@ -191,6 +191,7 @@ symbolS *mri_common_symbol; may be needed. */ static int mri_pending_align; +static int scrub_from_string PARAMS ((char **)); static void do_align PARAMS ((int, char *)); static int hex_float PARAMS ((int, char *)); static void do_org PARAMS ((segT, expressionS *, int)); @@ -330,6 +331,7 @@ static const pseudo_typeS potable[] = /* print */ {"quad", cons, 8}, {"rept", s_rept, 0}, + {"rva", s_rva, 4}, {"sbttl", listing_title, 1}, /* Subtitle of listing */ /* scl */ /* sect */ @@ -425,6 +427,24 @@ pobegin () } +/* This function is used when scrubbing the characters between #APP + and #NO_APP. */ + +static char *scrub_string; +static char *scrub_string_end; + +static int +scrub_from_string (from) + char **from; +{ + int size; + + *from = scrub_string; + size = scrub_string_end - scrub_string; + scrub_string = scrub_string_end; + return size; +} + /* read_a_source_file() * * We read the file, putting things into a web that @@ -810,7 +830,6 @@ read_a_source_file (name) char *new_tmp; unsigned int new_length; char *tmp_buf = 0; - extern char *scrub_string, *scrub_last_string; bump_line_counters (); s = input_line_pointer; @@ -862,26 +881,30 @@ read_a_source_file (name) { input_line_pointer = ends + 8; } - new_buf = xmalloc (100); - new_length = 100; - new_tmp = new_buf; scrub_string = s; - scrub_last_string = ends; + scrub_string_end = ends; + + new_length = ends - s; + new_buf = (char *) xmalloc (new_length); + new_tmp = new_buf; for (;;) { - int ch; + int space; + int size; - ch = do_scrub_next_char (scrub_from_string, scrub_to_string); - if (ch == EOF) - break; - *new_tmp++ = ch; - if (new_tmp == new_buf + new_length) + space = (new_buf + new_length) - new_tmp; + size = do_scrub_chars (scrub_from_string, new_tmp, space); + + if (size < space) { - new_buf = xrealloc (new_buf, new_length + 100); - new_tmp = new_buf + new_length; - new_length += 100; + new_tmp += size; + break; } + + new_buf = xrealloc (new_buf, new_length + 100); + new_tmp = new_buf + new_length; + new_length += 100; } if (tmp_buf) @@ -908,6 +931,7 @@ read_a_source_file (name) if (old_buffer) { + free (buffer); bump_line_counters (); if (old_input != 0) { @@ -1224,11 +1248,11 @@ s_data (ignore) } /* Handle the .appfile pseudo-op. This is automatically generated by - do_scrub_next_char when a preprocessor # line comment is seen with - a file name. This default definition may be overridden by the - object or CPU specific pseudo-ops. This function is also the - default definition for .file; the APPFILE argument is 1 for - .appfile, 0 for .file. */ + do_scrub_chars when a preprocessor # line comment is seen with a + file name. This default definition may be overridden by the object + or CPU specific pseudo-ops. This function is also the default + definition for .file; the APPFILE argument is 1 for .appfile, 0 for + .file. */ void s_app_file (appfile) @@ -1256,9 +1280,9 @@ s_app_file (appfile) } /* Handle the .appline pseudo-op. This is automatically generated by - do_scrub_next_char when a preprocessor # line comment is seen. - This default definition may be overridden by the object or CPU - specific pseudo-ops. */ + do_scrub_chars when a preprocessor # line comment is seen. This + default definition may be overridden by the object or CPU specific + pseudo-ops. */ void s_app_line (ignore) @@ -2362,12 +2386,14 @@ parse_repeat_cons PARAMS ((expressionS *exp, unsigned int nbytes)); /* worker to do .byte etc statements */ /* clobbers input_line_pointer, checks */ /* end-of-line. */ -void -cons (nbytes) +static void +cons_worker (nbytes, rva) register int nbytes; /* 1=.byte, 2=.word, 4=.long */ + int rva; { int c; expressionS exp; + char *stop = NULL; #ifdef md_flush_pending_output md_flush_pending_output (); @@ -2379,17 +2405,54 @@ cons (nbytes) return; } + /* In MRI mode, the operands end at the first unquoted space. */ + if (flag_mri) + { + char *s; + int inquote = 0; + + for (s = input_line_pointer; + ((! is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t') + || inquote); + s++) + { + if (*s == '\'') + inquote = ! inquote; + } + stop = s; + } + c = 0; do { + if (rva) + { + /* If this is an .rva pseudoop then stick + an extra reloc in for this word. */ + int reloc; + char *p = frag_more (0); + exp.X_op = O_absent; + +#ifdef BFD_ASSEMBLER + reloc = BFD_RELOC_RVA; +#elif defined(TC_RVA_RELOC) + reloc = TC_RVA_RELOC; +#else + abort(); +#endif + fix_new_exp (frag_now, p - frag_now->fr_literal, + nbytes, &exp, 0, reloc); + + } if (flag_mri) parse_mri_cons (&exp, (unsigned int) nbytes); else TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes); - emit_expr (&exp, (unsigned int) nbytes); + emit_expr (&exp, (unsigned int) nbytes); ++c; } - while (*input_line_pointer++ == ','); + while (*input_line_pointer++ == ',' + && (! flag_mri || input_line_pointer < stop)); /* In MRI mode, after an odd number of bytes, we must align to an even word boundary, unless the next instruction is a dc.b, ds.b @@ -2398,9 +2461,33 @@ cons (nbytes) mri_pending_align = 1; input_line_pointer--; /* Put terminator back into stream. */ + + if (flag_mri) + { + input_line_pointer = stop; + while (! is_end_of_line[(unsigned char) *input_line_pointer]) + ++input_line_pointer; + } + demand_empty_rest_of_line (); } + +void +cons (size) + int size; +{ + cons_worker (size, 0); +} + +void +s_rva (size) + int size; +{ + cons_worker (size, 1); +} + + /* Put the contents of expression EXP into the object file using NBYTES bytes. If need_pass_2 is 1, this does nothing. */ @@ -2625,8 +2712,8 @@ emit_expr (exp, nbytes) fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0, /* @@ Should look at CPU word size. */ nbytes == 2 ? BFD_RELOC_16 - : nbytes == 8 ? BFD_RELOC_64 - : BFD_RELOC_32); + : nbytes == 8 ? BFD_RELOC_64 + : BFD_RELOC_32); #endif #else #ifdef TC_CONS_FIX_NEW @@ -3435,6 +3522,8 @@ equals (sym_name) char *sym_name; { register symbolS *symbolP; /* symbol we are working with */ + char *stop; + int stopc; input_line_pointer++; if (*input_line_pointer == '=') @@ -3443,6 +3532,25 @@ equals (sym_name) while (*input_line_pointer == ' ' || *input_line_pointer == '\t') input_line_pointer++; + /* In MRI mode, the operands end at the first unquoted space. */ + if (flag_mri) + { + char *s; + int inquote = 0; + + for (s = input_line_pointer; + ((! is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t') + || inquote); + s++) + { + if (*s == '\'') + inquote = ! inquote; + } + stop = s; + stopc = *stop; + *stop = '\0'; + } + if (sym_name[0] == '.' && sym_name[1] == '\0') { /* Turn '. = mumble' into a .org mumble */ @@ -3458,6 +3566,14 @@ equals (sym_name) symbolP = symbol_find_or_make (sym_name); pseudo_set (symbolP); } + + if (flag_mri) + { + input_line_pointer = stop; + *stop = stopc; + while (! is_end_of_line[(unsigned char) *input_line_pointer]) + ++input_line_pointer; + } } /* equals() */ /* .include -- include a file at this point. */ |