/* read.c - read a source file -
Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
- 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
grow when we do 4361 style flonums. */
#define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
-/* Routines that read assembler source text to build spagetti in memory.
+/* Routines that read assembler source text to build spaghetti in memory.
Another group of these functions is in the expr.c module. */
#include "as.h"
#include "obstack.h"
#include "listing.h"
#include "ecoff.h"
+#include "dw2gencfi.h"
#ifndef TC_START_LABEL
#define TC_START_LABEL(x,y) (x == ':')
/* Set by the object-format or the target. */
#ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
-#define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
+#define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
do \
- { \
- if ((SIZE) >= 8) \
- (P2VAR) = 3; \
- else if ((SIZE) >= 4) \
- (P2VAR) = 2; \
- else if ((SIZE) >= 2) \
- (P2VAR) = 1; \
- else \
- (P2VAR) = 0; \
+ { \
+ if ((SIZE) >= 8) \
+ (P2VAR) = 3; \
+ else if ((SIZE) >= 4) \
+ (P2VAR) = 2; \
+ else if ((SIZE) >= 2) \
+ (P2VAR) = 1; \
+ else \
+ (P2VAR) = 0; \
} \
while (0)
#endif
internals manual. */
int target_big_endian = TARGET_BYTES_BIG_ENDIAN;
-static char *old_buffer; /* JF a hack. */
-static char *old_input;
-static char *old_limit;
-
/* Variables for handling include file directory table. */
/* Table of pointers to directories to search for .include's. */
#define obj_pop_insert() pop_insert(obj_pseudo_table)
#endif
+#ifndef cfi_pop_insert
+#define cfi_pop_insert() pop_insert(cfi_pseudo_table)
+#endif
+
static void
pobegin ()
{
/* Now portable ones. Skip any that we've seen already. */
pop_table_name = "standard";
pop_insert (potable);
+
+#ifdef TARGET_USE_CFIPOP
+ pop_table_name = "cfi";
+ pop_override_ok = 1;
+ cfi_pop_insert ();
+#endif
}
\f
#define HANDLE_CONDITIONAL_ASSEMBLY() \
while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
{ /* We have another line to parse. */
know (buffer_limit[-1] == '\n'); /* Must have a sentinel. */
- contin: /* JF this goto is my fault I admit it.
- Someone brave please re-write the whole
- input section here? Pleeze??? */
+
while (input_line_pointer < buffer_limit)
{
/* We have more of this buffer to parse. */
}
/* In MRI mode, we need to handle the MACRO
- pseudo-op specially: we don't want to put the
- symbol in the symbol table. */
+ pseudo-op specially: we don't want to put the
+ symbol in the symbol table. */
if (!mri_line_macro
#ifdef TC_START_LABEL_WITHOUT_COLON
&& TC_START_LABEL_WITHOUT_COLON(c,
}
}
- /* We are at the begining of a line, or similar place.
+ /* We are at the beginning of a line, or similar place.
We expect a well-formed assembler statement.
A "symbol-name:" is a statement.
c = get_symbol_end (); /* name's delimiter. */
/* C is character after symbol.
- That character's place in the input line is now '\0'.
- S points to the beginning of the symbol.
- [In case of pseudo-op, s->'.'.]
- Input_line_pointer->'\0' where c was. */
+ That character's place in the input line is now '\0'.
+ S points to the beginning of the symbol.
+ [In case of pseudo-op, s->'.'.]
+ Input_line_pointer->'\0' where c was. */
if (TC_START_LABEL (c, input_line_pointer))
{
if (flag_m68k_mri)
line_label = colon (s); /* User-defined label. */
/* Put ':' back for error messages' sake. */
*input_line_pointer++ = ':';
+#ifdef tc_check_label
+ tc_check_label (line_label);
+#endif
/* Input_line_pointer->after ':'. */
SKIP_WHITESPACE ();
}
if (NO_PSEUDO_DOT || flag_m68k_mri)
{
/* The MRI assembler and the m88k use pseudo-ops
- without a period. */
+ without a period. */
pop = (pseudo_typeS *) hash_find (po_hash, s);
if (pop != NULL && pop->poc_handler == NULL)
pop = NULL;
{
/* PSEUDO - OP.
- WARNING: c has next char, which may be end-of-line.
- We lookup the pseudo-op table with s+1 because we
- already know that the pseudo-op begins with a '.'. */
+ WARNING: c has next char, which may be end-of-line.
+ We lookup the pseudo-op table with s+1 because we
+ already know that the pseudo-op begins with a '.'. */
if (pop == NULL)
pop = (pseudo_typeS *) hash_find (po_hash, s + 1);
/* In MRI mode, we may need to insert an
- automatic alignment directive. What a hack
- this is. */
+ automatic alignment directive. What a hack
+ this is. */
if (mri_pending_align
&& (pop == NULL
|| !((pop->poc_handler == cons
input_line_pointer++;
/* Input_line is restored.
- Input_line_pointer->1st non-blank char
- after pseudo-operation. */
+ Input_line_pointer->1st non-blank char
+ after pseudo-operation. */
(*pop->poc_handler) (pop->poc_val);
/* If that was .end, just get out now. */
const char *err;
macro_entry *macro;
- if (check_macro (s, &out, '\0', &err, ¯o))
+ if (check_macro (s, &out, &err, ¯o))
{
if (err != NULL)
as_bad ("%s", err);
if (c && strchr (line_comment_chars, c))
{ /* Its a comment. Better say APP or NO_APP. */
+ sb sbuf;
char *ends;
char *new_buf;
char *new_tmp;
continue; /* We ignore it */
s += 4;
+ sb_new (&sbuf);
ends = strstr (s, "#NO_APP\n");
if (!ends)
/* The end of the #APP wasn't in this buffer. We
keep reading in buffers until we find the #NO_APP
that goes with this #APP There is one. The specs
- guarentee it... */
+ guarantee it... */
tmp_len = buffer_limit - s;
tmp_buf = xmalloc (tmp_len + 1);
memcpy (tmp_buf, s, tmp_len);
if (size < space)
{
- new_tmp += size;
+ new_tmp[size] = 0;
break;
}
if (tmp_buf)
free (tmp_buf);
- old_buffer = buffer;
- old_input = input_line_pointer;
- old_limit = buffer_limit;
- buffer = new_buf;
- input_line_pointer = new_buf;
- buffer_limit = new_tmp;
+ /* We've "scrubbed" input to the preferred format. In the
+ process we may have consumed the whole of the remaining
+ file (and included files). We handle this formatted
+ input similar to that of macro expansion, letting
+ actual macro expansion (possibly nested) and other
+ input expansion work. Beware that in messages, line
+ numbers and possibly file names will be incorrect. */
+ sb_add_string (&sbuf, new_buf);
+ input_scrub_include_sb (&sbuf, input_line_pointer, 0);
+ sb_kill (&sbuf);
+ buffer_limit = input_scrub_next_buffer (&input_line_pointer);
+ free (new_buf);
continue;
}
#ifdef md_after_pass_hook
md_after_pass_hook ();
#endif
-
- if (old_buffer)
- {
- free (buffer);
- bump_line_counters ();
- if (old_input != 0)
- {
- buffer = old_buffer;
- input_line_pointer = old_input;
- buffer_limit = old_limit;
- old_buffer = 0;
- goto contin;
- }
- }
}
quit:
}
#ifdef md_do_align
- just_record_alignment:
+ just_record_alignment: ATTRIBUTE_UNUSED_LABEL
#endif
record_alignment (now_seg, n - OCTETS_PER_BYTE_POWER);
if ((temp = get_absolute_expression ()) < 0)
{
- as_warn (_(".COMMon length (%ld) < 0 ignored"), (long) temp);
+ as_warn (_(".COMMon length (%lu) out of range ignored"),
+ (unsigned long) temp);
ignore_rest_of_line ();
if (flag_mri)
mri_comment_end (stop, stopc);
= (!new_logical_line (s, appfile ? -2 : -1) && appfile);
/* In MRI mode, the preprocessor may have inserted an extraneous
- backquote. */
+ backquote. */
if (flag_m68k_mri
&& *input_line_pointer == '\''
&& is_end_of_line[(unsigned char) input_line_pointer[1]])
if (flag_mri)
{
/* The MRI assembler permits the start symbol to follow .end,
- but we don't support that. */
+ but we don't support that. */
SKIP_WHITESPACE ();
if (!is_end_of_line[(unsigned char) *input_line_pointer]
&& *input_line_pointer != '*'
memset (p, 0, (unsigned int) size);
/* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
- flavoured AS. The following bizarre behaviour is to be
- compatible with above. I guess they tried to take up to 8
- bytes from a 4-byte expression and they forgot to sign
- extend. */
+ flavoured AS. The following bizarre behaviour is to be
+ compatible with above. I guess they tried to take up to 8
+ bytes from a 4-byte expression and they forgot to sign
+ extend. */
#define BSD_FILL_SIZE_CROCK_4 (4)
md_number_to_chars (p, (valueT) fill,
(size > BSD_FILL_SIZE_CROCK_4
? BSD_FILL_SIZE_CROCK_4
: (int) size));
/* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
- but emits no error message because it seems a legal thing to do.
- It is a degenerate case of .fill but could be emitted by a
+ but emits no error message because it seems a legal thing to do.
+ It is a degenerate case of .fill but could be emitted by a
compiler. */
}
demand_empty_rest_of_line ();
sb_new (&out);
- err = expand_irp (irpc, 0, &s, &out, get_line_sb, '\0');
+ err = expand_irp (irpc, 0, &s, &out, get_line_sb);
if (err != NULL)
as_bad_where (file, line, "%s", err);
#ifdef OBJ_COFF
/* The symbol may already have been created with a preceding
- ".globl" directive -- be careful not to step on storage class
- in that case. Otherwise, set it to static. */
+ ".globl" directive -- be careful not to step on storage class
+ in that case. Otherwise, set it to static. */
if (S_GET_STORAGE_CLASS (symbolP) != C_EXT)
{
S_SET_STORAGE_CLASS (symbolP, C_STAT);
demand_empty_rest_of_line ();
}
-/* Read a line into an sb. */
+/* Read a line into an sb. Returns the character that ended the line
+ or zero if there are no more lines. */
static int
get_line_sb (line)
sb *line;
{
char quote1, quote2, inquote;
+ unsigned char c;
if (input_line_pointer[-1] == '\n')
bump_line_counters ();
inquote = '\0';
- while (!is_end_of_line[(unsigned char) *input_line_pointer]
- || (inquote != '\0' && *input_line_pointer != '\n'))
+ while ((c = * input_line_pointer ++) != 0
+ && (!is_end_of_line[c]
+ || (inquote != '\0' && c != '\n')))
{
- if (inquote == *input_line_pointer)
+ if (inquote == c)
inquote = '\0';
else if (inquote == '\0')
{
- if (*input_line_pointer == quote1)
+ if (c == quote1)
inquote = quote1;
- else if (*input_line_pointer == quote2)
+ else if (c == quote2)
inquote = quote2;
}
- sb_add_char (line, *input_line_pointer++);
- }
-
- while (input_line_pointer < buffer_limit
- && is_end_of_line[(unsigned char) *input_line_pointer])
- {
- if (input_line_pointer[-1] == '\n')
- bump_line_counters ();
- ++input_line_pointer;
+ sb_add_char (line, c);
}
- return 1;
+ /* Don't skip multiple end-of-line characters, because that breaks support
+ for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
+ characters but isn't. Instead just skip one end of line character and
+ return the character skipped so that the caller can re-insert it if
+ necessary. */
+ return c;
}
-/* Define a macro. This is an interface to macro.c, which is shared
- between gas and gasp. */
+/* Define a macro. This is an interface to macro.c. */
void
s_macro (ignore)
int len;
s = demand_copy_C_string (&len);
- printf ("%s\n", s);
+ if (s != NULL)
+ printf ("%s\n", s);
demand_empty_rest_of_line ();
}
#ifndef NO_LISTING
/* When doing symbol listings, play games with dummy fragments living
outside the normal fragment chain to record the file and line info
- for this symbol. */
+ for this symbol. */
if (listing & LISTING_SYMBOLS)
{
extern struct list_info_struct *listing_tail;
}
/* In: Pointer to a symbol.
- Input_line_pointer->expression.
+ Input_line_pointer->expression.
Out: Input_line_pointer->just after any whitespace after expression.
- Tried to set symbol to value of expression.
- Will change symbols type, value, and frag; */
+ Tried to set symbol to value of expression.
+ Will change symbols type, value, and frag; */
void
pseudo_set (symbolP)
as_bad (_("floating point number invalid"));
}
else if (exp.X_op == O_subtract
- && (S_GET_SEGMENT (exp.X_add_symbol)
- == S_GET_SEGMENT (exp.X_op_symbol))
&& SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
&& (symbol_get_frag (exp.X_add_symbol)
== symbol_get_frag (exp.X_op_symbol)))
}
}
\f
-/* cons()
+/* cons()
CONStruct more frag of .bytes, or .words etc.
Should need_pass_2 be 1 then emit no frag(s).
#endif
#endif
+void
+do_parse_cons_expression (expressionS *exp,
+ int nbytes ATTRIBUTE_UNUSED)
+{
+ TC_PARSE_CONS_EXPRESSION (exp, nbytes);
+}
+
+
/* Worker to do .byte etc statements.
Clobbers input_line_pointer and checks end-of-line. */
if (need_pass_2)
return;
+ dot_value = frag_now_fix ();
+
#ifndef NO_LISTING
#ifdef OBJ_ELF
/* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
x->sub = exp->X_op_symbol;
x->addnum = exp->X_add_number;
x->added = 0;
+ x->use_jump = 0;
new_broken_words++;
return;
}
them in words, longs, etc. and we'll pack them in target byte order
for you.
- The rules are: pack least significat bit first, if a field doesn't
+ The rules are: pack least significant bit first, if a field doesn't
entirely fit, put it in the next unit. Overflowing the bitfield is
explicitly *not* even a warning. The bitwidth should be considered
a "mask".
return length;
}
-/* float_cons()
+/* float_cons()
CONStruct some more frag chars of .floats .ffloats etc.
Makes 0 or more new frags.
by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
reading, I decided to be incompatible. This always tries to give you
rounded bits to the precision of the pseudo-op. Former AS did premature
- truncatation, restored noisy bits instead of trailing 0s AND gave you
+ truncation, restored noisy bits instead of trailing 0s AND gave you
a choice of 2 flavours of noise according to which of 2 floating-point
scanners you directed AS to use.
SKIP_WHITESPACE ();
/* Skip any 0{letter} that may be present. Don't even check if the
- letter is legal. Someone may invent a "z" format and this routine
- has no use for such information. Lusers beware: you get
- diagnostics if your input is ill-conditioned. */
+ letter is legal. Someone may invent a "z" format and this routine
+ has no use for such information. Lusers beware: you get
+ diagnostics if your input is ill-conditioned. */
if (input_line_pointer[0] == '0'
&& ISALPHA (input_line_pointer[1]))
input_line_pointer += 2;
/* Accept :xxxx, where the x's are hex digits, for a floating
- point with the exact digits specified. */
+ point with the exact digits specified. */
if (input_line_pointer[0] == ':')
{
++input_line_pointer;
c = 0;
ignore_rest_of_line ();
}
-
+
while (c == ',' || c == '<' || c == '"')
{
SKIP_WHITESPACE ();
#ifndef NO_LISTING
#ifdef OBJ_ELF
/* In ELF, when gcc is emitting DWARF 1 debugging output, it
- will emit .string with a filename in the .debug section
- after a sequence of constants. See the comment in
- emit_expr for the sequence. emit_expr will set
- dwarf_file_string to non-zero if this string might be a
- source file name. */
+ will emit .string with a filename in the .debug section
+ after a sequence of constants. See the comment in
+ emit_expr for the sequence. emit_expr will set
+ dwarf_file_string to non-zero if this string might be a
+ source file name. */
if (strcmp (segment_name (now_seg), ".debug") != 0)
dwarf_file_string = 0;
else if (dwarf_file_string)
}
offsetT
-get_absolute_expression ()
+get_absolute_expr (exp)
+ expressionS *exp;
{
- expressionS exp;
-
- expression (&exp);
- if (exp.X_op != O_constant)
+ expression (exp);
+ if (exp->X_op != O_constant)
{
- if (exp.X_op != O_absent)
+ if (exp->X_op != O_absent)
as_bad (_("bad or irreducible absolute expression"));
- exp.X_add_number = 0;
+ exp->X_add_number = 0;
}
- return exp.X_add_number;
+ return exp->X_add_number;
+}
+
+offsetT
+get_absolute_expression ()
+{
+ expressionS exp;
+
+ return get_absolute_expr (&exp);
}
char /* Return terminator. */
if (filename == NULL)
{
/* demand_copy_string has already printed an error and
- called ignore_rest_of_line. */
+ called ignore_rest_of_line. */
return;
}
}
This call avoids macro/conditionals nesting checking, since the contents of
the line are assumed to replace the contents of a line already scanned.
- An appropriate use of this function would be substition of input lines when
+ An appropriate use of this function would be substitution of input lines when
called by md_start_line_hook(). The given line is assumed to already be
properly scrubbed. */