mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 13:56:22 +08:00
MIPS/GAS: Improve bignum operand error diagnostics
Improve bignum operand error diagnostics for cases where a constant would be accepted and report them as range errors, also indicating the offending operand and instruction, e.g.: $ cat bignum.s addiu $2, 0x10000000000000000 break 0x10000000000000000 $ as -o bignum.o bignum.s bignum.s:1: Error: bignum invalid bignum.s:2: Error: operand 1 must be constant `break 0x10000000000000000' $ now show as: $ as -o bignum.o bignum.s bignum.s:1: Error: operand 2 out of range `addiu $2,0x10000000000000000' bignum.s:2: Error: operand 1 out of range `break 0x10000000000000000' $ gas/ * config/tc-mips.c (match_const_int): Call `match_out_of_range' rather than `match_not_constant' for unrelocated operands retrieved as an `O_big' expression. (match_int_operand): Call `match_out_of_range' for relocatable operands retrieved as an `O_big' expression. (match_mips16_insn): Call `match_out_of_range' for relaxable operands retrieved as an `O_big' expression. * testsuite/gas/mips/addiu-error.d: New test. * testsuite/gas/mips/mips16@addiu-error.d: New test. * testsuite/gas/mips/micromips@addiu-error.d: New test. * testsuite/gas/mips/break-error.d: New test. * testsuite/gas/mips/lui-1.l: Adjust error message. * testsuite/gas/mips/addiu-error.l: New stderr output. * testsuite/gas/mips/mips16@addiu-error.l: New stderr output. * testsuite/gas/mips/micromips@addiu-error.l: New stderr output. * testsuite/gas/mips/break-error.l: New stderr output. * testsuite/gas/mips/addiu-error.s: New test source. * testsuite/gas/mips/break-error.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests.
This commit is contained in:
@ -1,3 +1,25 @@
|
|||||||
|
2017-05-15 Maciej W. Rozycki <macro@imgtec.com>
|
||||||
|
|
||||||
|
* config/tc-mips.c (match_const_int): Call `match_out_of_range'
|
||||||
|
rather than `match_not_constant' for unrelocated operands
|
||||||
|
retrieved as an `O_big' expression.
|
||||||
|
(match_int_operand): Call `match_out_of_range' for relocatable
|
||||||
|
operands retrieved as an `O_big' expression.
|
||||||
|
(match_mips16_insn): Call `match_out_of_range' for relaxable
|
||||||
|
operands retrieved as an `O_big' expression.
|
||||||
|
* testsuite/gas/mips/addiu-error.d: New test.
|
||||||
|
* testsuite/gas/mips/mips16@addiu-error.d: New test.
|
||||||
|
* testsuite/gas/mips/micromips@addiu-error.d: New test.
|
||||||
|
* testsuite/gas/mips/break-error.d: New test.
|
||||||
|
* testsuite/gas/mips/lui-1.l: Adjust error message.
|
||||||
|
* testsuite/gas/mips/addiu-error.l: New stderr output.
|
||||||
|
* testsuite/gas/mips/mips16@addiu-error.l: New stderr output.
|
||||||
|
* testsuite/gas/mips/micromips@addiu-error.l: New stderr output.
|
||||||
|
* testsuite/gas/mips/break-error.l: New stderr output.
|
||||||
|
* testsuite/gas/mips/addiu-error.s: New test source.
|
||||||
|
* testsuite/gas/mips/break-error.s: New test source.
|
||||||
|
* testsuite/gas/mips/mips.exp: Run the new tests.
|
||||||
|
|
||||||
2017-05-15 Maciej W. Rozycki <macro@imgtec.com>
|
2017-05-15 Maciej W. Rozycki <macro@imgtec.com>
|
||||||
|
|
||||||
* config/tc-mips.c (match_mips16_insn): Remove the explicit
|
* config/tc-mips.c (match_mips16_insn): Remove the explicit
|
||||||
|
@ -4856,7 +4856,10 @@ match_const_int (struct mips_arg_info *arg, offsetT *value)
|
|||||||
*value = ex.X_add_number;
|
*value = ex.X_add_number;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
match_not_constant (arg);
|
if (r[0] == BFD_RELOC_UNUSED && ex.X_op == O_big)
|
||||||
|
match_out_of_range (arg);
|
||||||
|
else
|
||||||
|
match_not_constant (arg);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -5062,6 +5065,12 @@ match_int_operand (struct mips_arg_info *arg,
|
|||||||
if (!match_expression (arg, &offset_expr, offset_reloc))
|
if (!match_expression (arg, &offset_expr, offset_reloc))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (offset_expr.X_op == O_big)
|
||||||
|
{
|
||||||
|
match_out_of_range (arg);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (offset_reloc[0] != BFD_RELOC_UNUSED)
|
if (offset_reloc[0] != BFD_RELOC_UNUSED)
|
||||||
/* Relocation operators were used. Accept the argument and
|
/* Relocation operators were used. Accept the argument and
|
||||||
leave the relocation value in offset_expr and offset_relocs
|
leave the relocation value in offset_expr and offset_relocs
|
||||||
@ -8261,6 +8270,12 @@ match_mips16_insn (struct mips_cl_insn *insn, const struct mips_opcode *opcode,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (offset_expr.X_op == O_big)
|
||||||
|
{
|
||||||
|
match_out_of_range (&arg);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
relax_char = c;
|
relax_char = c;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
3
gas/testsuite/gas/mips/addiu-error.d
Normal file
3
gas/testsuite/gas/mips/addiu-error.d
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#name: MIPS ADDIU errors
|
||||||
|
#as: -32
|
||||||
|
#error-output: addiu-error.l
|
8
gas/testsuite/gas/mips/addiu-error.l
Normal file
8
gas/testsuite/gas/mips/addiu-error.l
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.*: Assembler messages:
|
||||||
|
.*:5: Error: operand 2 out of range `addiu \$2,-32769'
|
||||||
|
.*:6: Error: operand 2 out of range `addiu \$2,65536'
|
||||||
|
.*:7: Error: operand 2 out of range `addiu \$2,0x10000000000000000'
|
||||||
|
.*:8: Error: operand 2 must be an immediate expression `addiu \$2,\$3'
|
||||||
|
.*:9: Error: invalid operands `addiu \$2,\(\$3\)'
|
||||||
|
.*:10: Error: register value used as expression `addiu \$2,0\+\$3'
|
||||||
|
.*:11: Error: register value used as expression `addiu \$2,\(\(\$3\)\)'
|
11
gas/testsuite/gas/mips/addiu-error.s
Normal file
11
gas/testsuite/gas/mips/addiu-error.s
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Source code used to test error diagnostics with the ADDIU instruction.
|
||||||
|
|
||||||
|
.text
|
||||||
|
foo:
|
||||||
|
addiu $2, -32769
|
||||||
|
addiu $2, 65536
|
||||||
|
addiu $2, 0x10000000000000000
|
||||||
|
addiu $2, $3
|
||||||
|
addiu $2, ($3)
|
||||||
|
addiu $2, 0+$3
|
||||||
|
addiu $2, (($3))
|
3
gas/testsuite/gas/mips/break-error.d
Normal file
3
gas/testsuite/gas/mips/break-error.d
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#name: MIPS BREAK errors
|
||||||
|
#as: -32
|
||||||
|
#error-output: break-error.l
|
8
gas/testsuite/gas/mips/break-error.l
Normal file
8
gas/testsuite/gas/mips/break-error.l
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.*: Assembler messages:
|
||||||
|
.*:5: Error: operand 1 out of range `break -1'
|
||||||
|
.*:6: Error: operand 1 out of range `break 65536'
|
||||||
|
.*:7: Error: operand 1 out of range `break 0x10000000000000000'
|
||||||
|
.*:8: Error: operand 1 must be an immediate expression `break \$3'
|
||||||
|
.*:9: Error: invalid operands `break \(\$3\)'
|
||||||
|
.*:10: Error: register value used as expression `break 0\+\$3'
|
||||||
|
.*:11: Error: register value used as expression `break \(\(\$3\)\)'
|
11
gas/testsuite/gas/mips/break-error.s
Normal file
11
gas/testsuite/gas/mips/break-error.s
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Source code used to test error diagnostics with the BREAK instruction.
|
||||||
|
|
||||||
|
.text
|
||||||
|
foo:
|
||||||
|
break -1
|
||||||
|
break 65536
|
||||||
|
break 0x10000000000000000
|
||||||
|
break $3
|
||||||
|
break ($3)
|
||||||
|
break 0+$3
|
||||||
|
break (($3))
|
@ -1,7 +1,7 @@
|
|||||||
.*\.s: Assembler messages:
|
.*\.s: Assembler messages:
|
||||||
.*\.s:5: Error: operand 2 out of range `lui \$2,-1'
|
.*\.s:5: Error: operand 2 out of range `lui \$2,-1'
|
||||||
.*\.s:6: Error: operand 2 out of range `lui \$2,65536'
|
.*\.s:6: Error: operand 2 out of range `lui \$2,65536'
|
||||||
.*\.s:7: Error: bignum invalid
|
.*\.s:7: Error: operand 2 out of range `lui \$2,0x10000000000000000'
|
||||||
.*\.s:8: Error: operand 2 must be an immediate expression `lui \$2,\$3'
|
.*\.s:8: Error: operand 2 must be an immediate expression `lui \$2,\$3'
|
||||||
.*\.s:9: Error: invalid operands `lui \$2,\(\$3\)'
|
.*\.s:9: Error: invalid operands `lui \$2,\(\$3\)'
|
||||||
.*\.s:10: Error: register value used as expression `lui \$2,0\+\$3'
|
.*\.s:10: Error: register value used as expression `lui \$2,0\+\$3'
|
||||||
|
4
gas/testsuite/gas/mips/micromips@addiu-error.d
Normal file
4
gas/testsuite/gas/mips/micromips@addiu-error.d
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#name: MIPS ADDIU errors
|
||||||
|
#as: -32
|
||||||
|
#error-output: micromips@addiu-error.l
|
||||||
|
#source: addiu-error.s
|
8
gas/testsuite/gas/mips/micromips@addiu-error.l
Normal file
8
gas/testsuite/gas/mips/micromips@addiu-error.l
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.*: Assembler messages:
|
||||||
|
.*:5: Error: operand 2 out of range `addiu \$2,-32769'
|
||||||
|
.*:6: Error: operand 2 out of range `addiu \$2,65536'
|
||||||
|
.*:7: Error: operand 2 out of range `addiu \$2,0x10000000000000000'
|
||||||
|
.*:8: Error: operand 2 must be an immediate expression `addiu \$2,\$3'
|
||||||
|
.*:9: Error: operand 2 out of range `addiu \$2,\(\$3\)'
|
||||||
|
.*:10: Error: register value used as expression `addiu \$2,0\+\$3'
|
||||||
|
.*:11: Error: register value used as expression `addiu \$2,\(\(\$3\)\)'
|
@ -1466,6 +1466,8 @@ if { [istarget mips*-*-vxworks*] } {
|
|||||||
run_dump_test_arches "lui" [mips_arch_list_matching mips1]
|
run_dump_test_arches "lui" [mips_arch_list_matching mips1]
|
||||||
run_dump_test_arches "lui-1" [mips_arch_list_matching mips1]
|
run_dump_test_arches "lui-1" [mips_arch_list_matching mips1]
|
||||||
run_dump_test_arches "lui-2" [mips_arch_list_matching mips1]
|
run_dump_test_arches "lui-2" [mips_arch_list_matching mips1]
|
||||||
|
run_dump_test_arches "addiu-error" [mips_arch_list_all]
|
||||||
|
run_dump_test_arches "break-error" [mips_arch_list_all]
|
||||||
|
|
||||||
run_dump_test "r5900"
|
run_dump_test "r5900"
|
||||||
run_dump_test "r5900-full"
|
run_dump_test "r5900-full"
|
||||||
|
4
gas/testsuite/gas/mips/mips16@addiu-error.d
Normal file
4
gas/testsuite/gas/mips/mips16@addiu-error.d
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#name: MIPS ADDIU errors
|
||||||
|
#as: -32
|
||||||
|
#error-output: mips16@addiu-error.l
|
||||||
|
#source: addiu-error.s
|
8
gas/testsuite/gas/mips/mips16@addiu-error.l
Normal file
8
gas/testsuite/gas/mips/mips16@addiu-error.l
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.*: Assembler messages:
|
||||||
|
.*:5: Error: operand value out of range for instruction
|
||||||
|
.*:6: Error: operand value out of range for instruction
|
||||||
|
.*:7: Error: operand 2 out of range `addiu \$2,0x10000000000000000'
|
||||||
|
.*:8: Error: operand 2 must be an immediate expression `addiu \$2,\$3'
|
||||||
|
.*:9: Error: invalid operands `addiu \$2,\(\$3\)'
|
||||||
|
.*:10: Error: register value used as expression `addiu \$2,0\+\$3'
|
||||||
|
.*:11: Error: register value used as expression `addiu \$2,\(\(\$3\)\)'
|
Reference in New Issue
Block a user