aboutsummaryrefslogtreecommitdiff
path: root/gas/read.c
diff options
context:
space:
mode:
Diffstat (limited to 'gas/read.c')
-rw-r--r--gas/read.c174
1 files changed, 97 insertions, 77 deletions
diff --git a/gas/read.c b/gas/read.c
index 7fee241..886c028 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -89,6 +89,10 @@ die horribly;
#define LEX_QM 0
#endif
+#ifndef LEX_HASH
+#define LEX_HASH 0
+#endif
+
#ifndef LEX_DOLLAR
/* The a29k assembler does not permits labels to start with $. */
#define LEX_DOLLAR 3
@@ -104,7 +108,7 @@ char lex_type[256] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
- 0, 0, 0, 0, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
+ 0, 0, 0, LEX_HASH, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM, /* 0123456789:;<=>? */
LEX_AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 3, /* PQRSTUVWXYZ[\]^_ */
@@ -208,10 +212,18 @@ static int dwarf_file_string;
#endif
static void cons_worker PARAMS ((int, int));
-static int scrub_from_string PARAMS ((char **));
+static int scrub_from_string PARAMS ((char *, int));
static void do_align PARAMS ((int, char *, int, int));
static void s_align PARAMS ((int, int));
+static void s_lcomm_internal PARAMS ((int, int));
static int hex_float PARAMS ((int, char *));
+static inline int sizeof_sleb128 PARAMS ((offsetT));
+static inline int sizeof_uleb128 PARAMS ((valueT));
+static inline int output_sleb128 PARAMS ((char *, offsetT));
+static inline int output_uleb128 PARAMS ((char *, valueT));
+static inline int output_big_sleb128 PARAMS ((char *, LITTLENUM_TYPE *, int));
+static inline int output_big_uleb128 PARAMS ((char *, LITTLENUM_TYPE *, int));
+static int output_big_leb128 PARAMS ((char *, LITTLENUM_TYPE *, int, int));
static void do_org PARAMS ((segT, expressionS *, int));
char *demand_copy_string PARAMS ((int *lenP));
static segT get_segmented_expression PARAMS ((expressionS *expP));
@@ -407,7 +419,7 @@ static const pseudo_typeS potable[] =
{"xstabs", s_xstab, 's'},
{"word", cons, 2},
{"zero", s_space, 0},
- {NULL} /* end sentinel */
+ {NULL, NULL, 0} /* end sentinel */
};
static int pop_override_ok = 0;
@@ -472,15 +484,18 @@ static char *scrub_string;
static char *scrub_string_end;
static int
-scrub_from_string (from)
- char **from;
+scrub_from_string (buf, buflen)
+ char *buf;
+ int buflen;
{
- int size;
-
- *from = scrub_string;
- size = scrub_string_end - scrub_string;
- scrub_string = scrub_string_end;
- return size;
+ int copy;
+
+ copy = scrub_string_end - scrub_string;
+ if (copy > buflen)
+ copy = buflen;
+ memcpy (buf, scrub_string, copy);
+ scrub_string += copy;
+ return copy;
}
/* read_a_source_file()
@@ -780,7 +795,7 @@ read_a_source_file (name)
mri_pending_align = 0;
if (line_label != NULL)
{
- line_label->sy_frag = frag_now;
+ symbol_set_frag (line_label, frag_now);
S_SET_VALUE (line_label, frag_now_fix ());
}
}
@@ -815,6 +830,9 @@ read_a_source_file (name)
else
{
int inquote = 0;
+#ifdef QUOTES_IN_INSN
+ int inescape = 0;
+#endif
/* WARNING: c has char, which may be end-of-line. */
/* Also: input_line_pointer->`\0` where c was. */
@@ -828,6 +846,14 @@ read_a_source_file (name)
{
if (flag_m68k_mri && *input_line_pointer == '\'')
inquote = ! inquote;
+#ifdef QUOTES_IN_INSN
+ if (inescape)
+ inescape = 0;
+ else if (*input_line_pointer == '"')
+ inquote = ! inquote;
+ else if (*input_line_pointer == '\\')
+ inescape = 1;
+#endif
input_line_pointer++;
}
@@ -861,7 +887,7 @@ read_a_source_file (name)
mri_pending_align = 0;
if (line_label != NULL)
{
- line_label->sy_frag = frag_now;
+ symbol_set_frag (line_label, frag_now);
S_SET_VALUE (line_label, frag_now_fix ());
}
}
@@ -1121,7 +1147,7 @@ mri_comment_end (stop, stopc)
void
s_abort (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
as_fatal (_(".abort detected. Abandoning ship."));
}
@@ -1147,21 +1173,7 @@ do_align (n, fill, len, max)
if (fill == NULL)
{
- int maybe_text;
-
-#ifdef BFD_ASSEMBLER
- if ((bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0)
- maybe_text = 1;
- else
- maybe_text = 0;
-#else
- if (now_seg != data_section && now_seg != bss_section)
- maybe_text = 1;
- else
- maybe_text = 0;
-#endif
-
- if (maybe_text)
+ if (subseg_text_p (now_seg))
default_fill = NOP_OPCODE;
else
default_fill = 0;
@@ -1325,7 +1337,7 @@ s_align_ptwo (arg)
void
s_comm (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
register char *name;
register char c;
@@ -1407,7 +1419,7 @@ s_comm (ignore)
void
s_mri_common (small)
- int small;
+ int small ATTRIBUTE_UNUSED;
{
char *name;
char c;
@@ -1481,10 +1493,12 @@ s_mri_common (small)
if (line_label != NULL)
{
- line_label->sy_value.X_op = O_symbol;
- line_label->sy_value.X_add_symbol = sym;
- line_label->sy_value.X_add_number = S_GET_VALUE (sym);
- line_label->sy_frag = &zero_address_frag;
+ expressionS exp;
+ exp.X_op = O_symbol;
+ exp.X_add_symbol = sym;
+ exp.X_add_number = 0;
+ symbol_set_value_expression (line_label, &exp);
+ symbol_set_frag (line_label, &zero_address_frag);
S_SET_SEGMENT (line_label, expr_section);
}
@@ -1504,7 +1518,7 @@ s_mri_common (small)
void
s_data (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
segT section;
register int temp;
@@ -1578,7 +1592,7 @@ s_app_file (appfile)
void
s_app_line (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
int l;
@@ -1604,7 +1618,7 @@ s_app_line (ignore)
void
s_end (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
if (flag_mri)
{
@@ -1622,7 +1636,7 @@ s_end (ignore)
void
s_err (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
as_bad (_(".err encountered"));
demand_empty_rest_of_line ();
@@ -1632,7 +1646,7 @@ s_err (ignore)
void
s_fail (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
offsetT temp;
char *stop = NULL;
@@ -1655,7 +1669,7 @@ s_fail (ignore)
void
s_fill (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
expressionS rep_exp;
long size = 1;
@@ -1752,7 +1766,7 @@ s_fill (ignore)
void
s_globl (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
char *name;
int c;
@@ -1768,9 +1782,11 @@ s_globl (ignore)
name = input_line_pointer;
c = get_symbol_end ();
symbolP = symbol_find_or_make (name);
+ S_SET_EXTERNAL (symbolP);
+
*input_line_pointer = c;
SKIP_WHITESPACE ();
- S_SET_EXTERNAL (symbolP);
+ c = *input_line_pointer;
if (c == ',')
{
input_line_pointer++;
@@ -1825,7 +1841,7 @@ s_irp (irpc)
void
s_linkonce (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
enum linkonce_type type;
@@ -2056,9 +2072,9 @@ s_lcomm_internal (needs_align, bytes_p)
frag_align (align, 0, 0);
/* detach from old frag */
if (S_GET_SEGMENT (symbolP) == bss_seg)
- symbolP->sy_frag->fr_symbol = NULL;
+ symbol_get_frag (symbolP)->fr_symbol = NULL;
- symbolP->sy_frag = frag_now;
+ symbol_set_frag (symbolP, frag_now);
pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
(offsetT) temp, (char *) 0);
*pfrag = 0;
@@ -2103,7 +2119,7 @@ void s_lcomm_bytes (needs_align)
void
s_lsym (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
register char *name;
register char c;
@@ -2225,7 +2241,7 @@ get_line_sb (line)
void
s_macro (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
char *file;
unsigned int line;
@@ -2253,7 +2269,7 @@ s_macro (ignore)
{
S_SET_SEGMENT (line_label, undefined_section);
S_SET_VALUE (line_label, 0);
- line_label->sy_frag = &zero_address_frag;
+ symbol_set_frag (line_label, &zero_address_frag);
}
if (((flag_m68k_mri
@@ -2277,7 +2293,7 @@ s_macro (ignore)
void
s_mexit (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
cond_exit_macro (macro_nest);
buffer_limit = input_scrub_next_buffer (&input_line_pointer);
@@ -2287,7 +2303,7 @@ s_mexit (ignore)
void
s_mri (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
int on, old_flag;
@@ -2355,7 +2371,7 @@ do_org (segment, exp, fill)
void
s_org (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
register segT segment;
expressionS exp;
@@ -2411,7 +2427,7 @@ s_org (ignore)
void
s_mri_sect (type)
- char *type;
+ char *type ATTRIBUTE_UNUSED;
{
#ifdef TC_M68K
@@ -2575,7 +2591,7 @@ s_mri_sect (type)
void
s_print (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
char *s;
int len;
@@ -2589,7 +2605,7 @@ s_print (ignore)
void
s_purgem (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
if (is_it_end_of_statement ())
{
@@ -2619,7 +2635,7 @@ s_purgem (ignore)
void
s_rept (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
int count;
sb one;
@@ -2775,9 +2791,12 @@ s_space (mult)
S_SET_VALUE (mri_common_symbol, val + 1);
if (line_label != NULL)
{
- know (line_label->sy_value.X_op == O_symbol);
- know (line_label->sy_value.X_add_symbol == mri_common_symbol);
- line_label->sy_value.X_add_number += 1;
+ expressionS *symexp;
+
+ symexp = symbol_get_value_expression (line_label);
+ know (symexp->X_op == O_symbol);
+ know (symexp->X_add_symbol == mri_common_symbol);
+ symexp->X_add_number += 1;
}
}
}
@@ -2786,7 +2805,7 @@ s_space (mult)
do_align (1, (char *) NULL, 0, 0);
if (line_label != NULL)
{
- line_label->sy_frag = frag_now;
+ symbol_set_frag (line_label, frag_now);
S_SET_VALUE (line_label, frag_now_fix ());
}
}
@@ -2988,7 +3007,7 @@ s_float_space (float_type)
void
s_struct (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
char *stop = NULL;
char stopc;
@@ -3004,7 +3023,7 @@ s_struct (ignore)
void
s_text (ignore)
- int ignore;
+ int ignore ATTRIBUTE_UNUSED;
{
register int temp;
@@ -3106,7 +3125,8 @@ pseudo_set (symbolP)
&& (S_GET_SEGMENT (exp.X_add_symbol)
== S_GET_SEGMENT (exp.X_op_symbol))
&& SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
- && exp.X_add_symbol->sy_frag == exp.X_op_symbol->sy_frag)
+ && (symbol_get_frag (exp.X_add_symbol)
+ == symbol_get_frag (exp.X_op_symbol)))
{
exp.X_op = O_constant;
exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol)
@@ -3130,19 +3150,19 @@ pseudo_set (symbolP)
#endif /* OBJ_AOUT or OBJ_BOUT */
S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
if (exp.X_op != O_constant)
- symbolP->sy_frag = &zero_address_frag;
+ symbol_set_frag (symbolP, &zero_address_frag);
break;
case O_register:
S_SET_SEGMENT (symbolP, reg_section);
S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
- symbolP->sy_frag = &zero_address_frag;
+ symbol_set_frag (symbolP, &zero_address_frag);
break;
case O_symbol:
if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section
|| exp.X_add_number != 0)
- symbolP->sy_value = exp;
+ symbol_set_value_expression (symbolP, &exp);
else
{
symbolS *s = exp.X_add_symbol;
@@ -3156,7 +3176,7 @@ pseudo_set (symbolP)
#endif /* OBJ_AOUT or OBJ_BOUT */
S_SET_VALUE (symbolP,
exp.X_add_number + S_GET_VALUE (s));
- symbolP->sy_frag = s->sy_frag;
+ symbol_set_frag (symbolP, symbol_get_frag (s));
copy_symbol_attributes (symbolP, s);
}
break;
@@ -3164,7 +3184,7 @@ pseudo_set (symbolP)
default:
/* The value is some complex expression.
FIXME: Should we set the segment to anything? */
- symbolP->sy_value = exp;
+ symbol_set_value_expression (symbolP, &exp);
break;
}
}
@@ -3393,13 +3413,13 @@ emit_expr (exp, nbytes)
/* Handle a negative bignum. */
if (op == O_uminus
&& exp->X_add_number == 0
- && exp->X_add_symbol->sy_value.X_op == O_big
- && exp->X_add_symbol->sy_value.X_add_number > 0)
+ && symbol_get_value_expression (exp->X_add_symbol)->X_op == O_big
+ && symbol_get_value_expression (exp->X_add_symbol)->X_add_number > 0)
{
int i;
unsigned long carry;
- exp = &exp->X_add_symbol->sy_value;
+ exp = symbol_get_value_expression (exp->X_add_symbol);
/* Negate the bignum: one's complement each digit and add 1. */
carry = 1;
@@ -4207,7 +4227,7 @@ output_leb128 (p, value, sign)
we don't output for NULL values of P. It isn't really as critical as
for "normal" values that this be streamlined. */
-static int
+static inline int
output_big_sleb128 (p, bignum, size)
char *p;
LITTLENUM_TYPE *bignum;
@@ -4253,7 +4273,7 @@ output_big_sleb128 (p, bignum, size)
return p - orig;
}
-static int
+static inline int
output_big_uleb128 (p, bignum, size)
char *p;
LITTLENUM_TYPE *bignum;
@@ -4295,7 +4315,7 @@ output_big_uleb128 (p, bignum, size)
return p - orig;
}
-static inline int
+static int
output_big_leb128 (p, bignum, size, sign)
char *p;
LITTLENUM_TYPE *bignum;
@@ -4388,7 +4408,7 @@ s_leb128 (sign)
/*
* stringer()
*
- * We read 0 or more ',' seperated, double-quoted strings.
+ * We read 0 or more ',' separated, double-quoted strings.
*
* Caller should have checked need_pass_2 is FALSE because we don't check it.
*/
@@ -4812,7 +4832,7 @@ equals (sym_name, reassign)
/* ARGSUSED */
void
s_include (arg)
- int arg;
+ int arg ATTRIBUTE_UNUSED;
{
char *newbuf;
char *filename;
@@ -5034,7 +5054,7 @@ do_s_func (end_p, default_prefix)
void
s_ignore (arg)
- int arg;
+ int arg ATTRIBUTE_UNUSED;
{
while (!is_end_of_line[(unsigned char) *input_line_pointer])
{