Improve error reporting for PR14724

This commit is contained in:
Nick Clifton
1998-02-02 23:44:42 +00:00
parent e8f2efef4d
commit 6d0b44264f

View File

@ -1,5 +1,5 @@
/* tc-v850.c -- Assembler code for the NEC V850 /* tc-v850.c -- Assembler code for the NEC V850
Copyright (C) 1996, 1997 Free Software Foundation. Copyright (C) 1996, 1997, 1998 Free Software Foundation.
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.
@ -681,7 +681,8 @@ register_name (expressionP)
c = get_symbol_end (); c = get_symbol_end ();
reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT, name, FALSE); reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT,
name, FALSE);
* input_line_pointer = c; /* put back the delimiting char */ * input_line_pointer = c; /* put back the delimiting char */
@ -743,7 +744,8 @@ system_register_name (expressionP, accept_numbers
start = name = input_line_pointer; start = name = input_line_pointer;
c = get_symbol_end (); c = get_symbol_end ();
reg_number = reg_name_search (system_registers, SYSREG_NAME_CNT, name, accept_numbers); reg_number = reg_name_search (system_registers, SYSREG_NAME_CNT, name,
accept_numbers);
* input_line_pointer = c; /* put back the delimiting char */ * input_line_pointer = c; /* put back the delimiting char */
@ -772,7 +774,8 @@ system_register_name (expressionP, accept_numbers
else if (accept_list_names) else if (accept_list_names)
{ {
c = get_symbol_end (); c = get_symbol_end ();
reg_number = reg_name_search (system_list_registers, SYSREGLIST_NAME_CNT, name, FALSE); reg_number = reg_name_search (system_list_registers,
SYSREGLIST_NAME_CNT, name, FALSE);
* input_line_pointer = c; /* put back the delimiting char */ * input_line_pointer = c; /* put back the delimiting char */
} }
@ -979,14 +982,16 @@ parse_register_list
input_line_pointer ++; input_line_pointer ++;
/* Parse the register list until a terminator (closing curly brace or new-line) is found. */ /* Parse the register list until a terminator (closing curly brace or
new-line) is found. */
for (;;) for (;;)
{ {
if (register_name (& exp)) if (register_name (& exp))
{ {
int i; int i;
/* Locate the given register in the list, and if it is there, insert the corresponding bit into the instruction. */ /* Locate the given register in the list, and if it is there,
insert the corresponding bit into the instruction. */
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
{ {
if (regs[ i ] == exp.X_add_number) if (regs[ i ] == exp.X_add_number)
@ -1050,7 +1055,8 @@ parse_register_list
{ {
int i; int i;
/* Locate the given register in the list, and if it is there, insert the corresponding bit into the instruction. */ /* Locate the given register in the list, and if it is there,
insert the corresponding bit into the instruction. */
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
{ {
if (regs[ i ] == j) if (regs[ i ] == j)
@ -1231,7 +1237,8 @@ md_convert_frag (abfd, sec, fragP)
target. */ target. */
md_number_to_chars (buffer + 2, 0x00000780, 4); md_number_to_chars (buffer + 2, 0x00000780, 4);
fix_new (fragP, fragP->fr_fix + 2, 4, fragP->fr_symbol, fix_new (fragP, fragP->fr_fix + 2, 4, fragP->fr_symbol,
fragP->fr_offset, 1, BFD_RELOC_UNUSED + (int)fragP->fr_opcode + 1); fragP->fr_offset, 1, BFD_RELOC_UNUSED + (int) fragP->fr_opcode
+ 1);
fragP->fr_var = 0; fragP->fr_var = 0;
fragP->fr_fix += 6; fragP->fr_fix += 6;
} }
@ -1240,7 +1247,8 @@ md_convert_frag (abfd, sec, fragP)
{ {
md_number_to_chars (fragP->fr_fix + fragP->fr_literal, 0x00000780, 4); md_number_to_chars (fragP->fr_fix + fragP->fr_literal, 0x00000780, 4);
fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
fragP->fr_offset, 1, BFD_RELOC_UNUSED + (int)fragP->fr_opcode + 1); fragP->fr_offset, 1, BFD_RELOC_UNUSED + (int) fragP->fr_opcode
+ 1);
fragP->fr_var = 0; fragP->fr_var = 0;
fragP->fr_fix += 4; fragP->fr_fix += 4;
} }
@ -1562,7 +1570,8 @@ v850_insert_operand (insn, operand, val, file, line, str)
char buf[100]; char buf[100];
/* Restore min and mix to expected values for decimal ranges. */ /* Restore min and mix to expected values for decimal ranges. */
if ((operand->flags & V850_OPERAND_SIGNED) && ! warn_signed_overflows) if ((operand->flags & V850_OPERAND_SIGNED)
&& ! warn_signed_overflows)
max = (1 << (operand->bits - 1)) - 1; max = (1 << (operand->bits - 1)) - 1;
if (! (operand->flags & V850_OPERAND_SIGNED) if (! (operand->flags & V850_OPERAND_SIGNED)
@ -1694,7 +1703,8 @@ md_assemble (str)
/* lo(), hi(), hi0(), etc... */ /* lo(), hi(), hi0(), etc... */
if ((reloc = v850_reloc_prefix (operand)) != BFD_RELOC_UNUSED) if ((reloc = v850_reloc_prefix (operand)) != BFD_RELOC_UNUSED)
{ {
if (reloc == BFD_RELOC_64) /* This is a fake reloc, used to indicate an error condition. */ /* This is a fake reloc, used to indicate an error condition. */
if (reloc == BFD_RELOC_64)
{ {
match = 1; match = 1;
goto error; goto error;
@ -1707,7 +1717,8 @@ md_assemble (str)
switch (reloc) switch (reloc)
{ {
case BFD_RELOC_V850_ZDA_16_16_OFFSET: case BFD_RELOC_V850_ZDA_16_16_OFFSET:
/* To cope with "not1 7, zdaoff(0xfffff006)[r0]" and the like. */ /* To cope with "not1 7, zdaoff(0xfffff006)[r0]"
and the like. */
/* Fall through. */ /* Fall through. */
case BFD_RELOC_LO16: case BFD_RELOC_LO16:
@ -1757,7 +1768,8 @@ md_assemble (str)
} }
insn = v850_insert_operand (insn, operand, ex.X_add_number, insn = v850_insert_operand (insn, operand, ex.X_add_number,
(char *) NULL, 0, copy_of_instruction); (char *) NULL, 0,
copy_of_instruction);
} }
else else
{ {
@ -1795,8 +1807,7 @@ md_assemble (str)
{ {
errmsg = "invalid register name"; errmsg = "invalid register name";
} }
else if ((operand->flags & V850_NOT_R0)
if ((operand->flags & V850_NOT_R0)
&& ex.X_add_number == 0) && ex.X_add_number == 0)
{ {
errmsg = "register r0 cannot be used here"; errmsg = "register r0 cannot be used here";
@ -1805,9 +1816,6 @@ md_assemble (str)
skipping over any following potential matches skipping over any following potential matches
for this opcode. */ for this opcode. */
opcode += 3; opcode += 3;
if (* input_line_pointer == ']')
++ input_line_pointer;
} }
} }
else if ((operand->flags & V850_OPERAND_SRG) != 0) else if ((operand->flags & V850_OPERAND_SRG) != 0)
@ -1839,7 +1847,8 @@ md_assemble (str)
str = input_line_pointer; str = input_line_pointer;
input_line_pointer = hold; input_line_pointer = hold;
while (*str == ' ' || *str == ',' || *str == '[' || *str == ']') while ( *str == ' ' || *str == ',' || *str == '['
|| *str == ']')
++ str; ++ str;
continue; continue;
} }
@ -1855,7 +1864,8 @@ md_assemble (str)
{ {
errmsg = parse_register_list (& insn, operand); errmsg = parse_register_list (& insn, operand);
/* The parse_register_list() function has already done everything, so fake a dummy expression. */ /* The parse_register_list() function has already done
everything, so fake a dummy expression. */
ex.X_op = O_constant; ex.X_op = O_constant;
ex.X_add_number = 0; ex.X_add_number = 0;
} }
@ -1908,8 +1918,17 @@ md_assemble (str)
expression (& ex); expression (& ex);
if (ex.X_op != O_constant) if (ex.X_op != O_constant)
{
/* If this register is actually occuring too early on
the parsing of the instruction, (because another
field is missing) then report this. */
if (opindex_ptr[1] != 0
&& (v850_operands [opindex_ptr [1]].flags & V850_OPERAND_REG))
errmsg = "syntax error: value is missing before the register name";
else
errmsg = "syntax error: register not expected"; errmsg = "syntax error: register not expected";
} }
}
else if (system_register_name (& ex, false else if (system_register_name (& ex, false
/* start-sanitize-v850e */ /* start-sanitize-v850e */
, false , false
@ -1930,14 +1949,15 @@ md_assemble (str)
/* start-sanitize-v850e */ /* start-sanitize-v850e */
/* Special case: /* Special case:
If we are assembling a MOV instruction (or a CALLT.... :-) If we are assembling a MOV instruction (or a CALLT.... :-)
and the immediate value does not fit into the bits available and the immediate value does not fit into the bits
then create a fake error so that the next MOV instruction available then create a fake error so that the next MOV
will be selected. This one has a 32 bit immediate field. */ instruction will be selected. This one has a 32 bit
immediate field. */
if (((insn & 0x07e0) == 0x0200) if (((insn & 0x07e0) == 0x0200)
&& ex.X_op == O_constant && ex.X_op == O_constant
&& (ex.X_add_number < (- (1 << (operand->bits - 1))) || ex.X_add_number > ((1 << operand->bits) - 1))) && (ex.X_add_number < (- (1 << (operand->bits - 1))) || ex.X_add_number > ((1 << operand->bits) - 1)))
errmsg = "immediate constant is too large"; errmsg = "immediate operand is too large";
/* end-sanitize-v850e */ /* end-sanitize-v850e */
} }
@ -1961,12 +1981,14 @@ md_assemble (str)
goto error; goto error;
} }
insn = v850_insert_operand (insn, operand, ex.X_add_number, insn = v850_insert_operand (insn, operand, ex.X_add_number,
(char *) NULL, 0, copy_of_instruction); (char *) NULL, 0,
copy_of_instruction);
break; break;
case O_constant: case O_constant:
insn = v850_insert_operand (insn, operand, ex.X_add_number, insn = v850_insert_operand (insn, operand, ex.X_add_number,
(char *) NULL, 0, copy_of_instruction); (char *) NULL, 0,
copy_of_instruction);
break; break;
default: default:
@ -1995,13 +2017,24 @@ md_assemble (str)
if (match == 0) if (match == 0)
{ {
next_opcode = opcode + 1; next_opcode = opcode + 1;
if (next_opcode->name != NULL && strcmp (next_opcode->name, opcode->name) == 0) if (next_opcode->name != NULL
&& strcmp (next_opcode->name, opcode->name) == 0)
{ {
opcode = next_opcode; opcode = next_opcode;
/* Skip versions that are not supported by the target
processor. */
if ((opcode->processors & processor_mask) == 0)
goto error;
continue; continue;
} }
as_bad (errmsg); as_bad ("%s: %s", copy_of_instruction, errmsg);
if (* input_line_pointer == ']')
++ input_line_pointer;
ignore_rest_of_line (); ignore_rest_of_line ();
input_line_pointer = saved_input_line_pointer; input_line_pointer = saved_input_line_pointer;
return; return;
@ -2088,7 +2121,8 @@ md_assemble (str)
if (reloc != BFD_RELOC_UNUSED) if (reloc != BFD_RELOC_UNUSED)
{ {
reloc_howto_type * reloc_howto = bfd_reloc_type_lookup (stdoutput, reloc); reloc_howto_type * reloc_howto = bfd_reloc_type_lookup (stdoutput,
reloc);
int size; int size;
int address; int address;
fixS * fixP; fixS * fixP;
@ -2098,7 +2132,9 @@ md_assemble (str)
size = bfd_get_reloc_size (reloc_howto); size = bfd_get_reloc_size (reloc_howto);
if (size != 2 && size != 4) /* XXX this will abort on an R_V850_8 reloc - is this reloc actually used ? */ /* XXX This will abort on an R_V850_8 reloc -
is this reloc actually used ? */
if (size != 2 && size != 4)
abort(); abort();
address = (f - frag_now->fr_literal) + insn_size - size; address = (f - frag_now->fr_literal) + insn_size - size;
@ -2129,7 +2165,8 @@ md_assemble (str)
f - frag_now->fr_literal, 4, f - frag_now->fr_literal, 4,
& fixups[i].exp, & fixups[i].exp,
1 /* FIXME: V850_OPERAND_RELATIVE ??? */, 1 /* FIXME: V850_OPERAND_RELATIVE ??? */,
(bfd_reloc_code_real_type) (fixups[i].opindex + (int) BFD_RELOC_UNUSED) (bfd_reloc_code_real_type) (fixups[i].opindex
+ (int) BFD_RELOC_UNUSED)
); );
} }
} }
@ -2156,7 +2193,8 @@ tc_gen_reloc (seg, fixp)
if (reloc->howto == (reloc_howto_type *) NULL) if (reloc->howto == (reloc_howto_type *) NULL)
{ {
as_bad_where (fixp->fx_file, fixp->fx_line, as_bad_where (fixp->fx_file, fixp->fx_line,
"reloc %d not supported by object file format", (int)fixp->fx_r_type); "reloc %d not supported by object file format",
(int)fixp->fx_r_type);
xfree (reloc); xfree (reloc);