MIPS16/GAS: Improve disallowed relocation operand error diagnostics
Improve disallowed relocation operand error diagnostics for MIPS16 code and make it match corresponding regular MIPS and microMIPS handling, e.g: $ cat sltu.s sltu $2, %lo(foo) $ as -o sltu.o sltu.s sltu.s: Assembler messages: sltu.s:1: Error: operand 2 must be constant `sltu $2,%lo(foo)' $ as -mips16 -o sltu.o sltu.s sltu.s: Assembler messages: sltu.s:1: Error: invalid operands `sltu $2,%lo(foo)' $ To do so call `match_not_constant' from `match_mips16_insn' whenever a disallowed relocation operation has been noticed, like `match_const_int' does, making reporting consistent: $ as -mips16 -o sltu.o sltu.s sltu.s: Assembler messages: sltu.s:1: Error: operand 2 must be constant `sltu $2,%lo(foo)' $ gas/ * config/tc-mips.c (match_mips16_insn): Call `match_not_constant' for a disallowed relocation operation. * testsuite/gas/mips/mips16-reloc-error.d: New test. * testsuite/gas/mips/mips16-reloc-error.l: New stderr output. * testsuite/gas/mips/mips16-reloc-error.s: New test source. * testsuite/gas/mips/mips.exp: Run the new test.
This commit is contained in:
parent
c76081bc87
commit
e295202f60
|
@ -1,3 +1,12 @@
|
|||
2017-05-15 Maciej W. Rozycki <macro@imgtec.com>
|
||||
|
||||
* config/tc-mips.c (match_mips16_insn): Call
|
||||
`match_not_constant' for a disallowed relocation operation.
|
||||
* testsuite/gas/mips/mips16-reloc-error.d: New test.
|
||||
* testsuite/gas/mips/mips16-reloc-error.l: New stderr output.
|
||||
* testsuite/gas/mips/mips16-reloc-error.s: New test source.
|
||||
* testsuite/gas/mips/mips.exp: Run the new test.
|
||||
|
||||
2017-05-15 Maciej W. Rozycki <macro@imgtec.com>
|
||||
|
||||
* testsuite/gas/mips/lui-1.d: New test.
|
||||
|
|
|
@ -8259,7 +8259,10 @@ match_mips16_insn (struct mips_cl_insn *insn, const struct mips_opcode *opcode,
|
|||
been allowed to take relocation operators. */
|
||||
if (offset_reloc[0] != BFD_RELOC_UNUSED
|
||||
&& (ext_operand->size != 16 || c == '8'))
|
||||
return FALSE;
|
||||
{
|
||||
match_not_constant (&arg);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
relax_char = c;
|
||||
continue;
|
||||
|
|
|
@ -967,6 +967,8 @@ if { [istarget mips*-*-vxworks*] } {
|
|||
run_dump_test "mips16-hilo-n32"
|
||||
}
|
||||
run_dump_test "mips16-hilo-match"
|
||||
run_dump_test "mips16-reloc-error"
|
||||
|
||||
run_dump_test "delay"
|
||||
run_dump_test "nodelay"
|
||||
run_dump_test "mips4010"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#name: MIPS16 relocation errors
|
||||
#as: -32 -mips64r2
|
||||
#error-output: mips16-reloc-error.l
|
|
@ -0,0 +1,28 @@
|
|||
.*: Assembler messages:
|
||||
.*:11: Error: operand 3 must be constant `addiu \$3,\$2,%lo\(bar\)'
|
||||
.*:12: Error: operand 3 must be constant `daddiu \$3,\$2,%lo\(bar\)'
|
||||
.*:14: Error: operand 2 must be constant `slti \$3,%lo\(bar\)'
|
||||
.*:15: Error: operand 2 must be constant `sltiu \$3,%lo\(bar\)'
|
||||
.*:17: Error: operand 3 must be constant `sll \$3,\$2,%lo\(bar\)'
|
||||
.*:18: Error: operand 3 must be constant `sra \$3,\$2,%lo\(bar\)'
|
||||
.*:19: Error: operand 3 must be constant `srl \$3,\$2,%lo\(bar\)'
|
||||
.*:20: Error: operand 3 must be constant `dsll \$3,\$2,%lo\(bar\)'
|
||||
.*:21: Error: operand 2 must be constant `dsra \$3,%lo\(bar\)'
|
||||
.*:22: Error: operand 2 must be constant `dsrl \$3,%lo\(bar\)'
|
||||
.*:24: Error: operand 1 must be constant `break %lo\(bar\)'
|
||||
.*:25: Error: operand 1 must be constant `sdbbp %lo\(bar\)'
|
||||
.*:27: Error: invalid operands `b %lo\(bar\)'
|
||||
.*:28: Error: invalid operands `beqz \$3,%lo\(bar\)'
|
||||
.*:29: Error: invalid operands `bnez \$3,%lo\(bar\)'
|
||||
.*:30: Error: invalid operands `bteqz %lo\(bar\)'
|
||||
.*:31: Error: invalid operands `btnez %lo\(bar\)'
|
||||
.*:33: Error: invalid operands `jal %lo\(bar\)'
|
||||
.*:34: Error: invalid operands `jalx %lo\(bar\)'
|
||||
.*:36: Error: operand 3 must be constant `save \$31,\$16,%lo\(bar\)'
|
||||
.*:37: Error: operand 3 must be constant `restore \$31,\$16,%lo\(bar\)'
|
||||
.*:39: Error: operand 6 must be constant `asmacro 0,0,0,0,0,%lo\(bar\)'
|
||||
.*:40: Error: operand 5 must be constant `asmacro 0,0,0,0,%lo\(bar\),0'
|
||||
.*:41: Error: operand 4 must be constant `asmacro 0,0,0,%lo\(bar\),0,0'
|
||||
.*:42: Error: operand 3 must be constant `asmacro 0,0,%lo\(bar\),0,0,0'
|
||||
.*:43: Error: operand 2 must be constant `asmacro 0,%lo\(bar\),0,0,0,0'
|
||||
.*:44: Error: operand 1 must be constant `asmacro %lo\(bar\),0,0,0,0,0'
|
|
@ -0,0 +1,52 @@
|
|||
.text
|
||||
|
||||
.set bar, 8
|
||||
|
||||
.ent foo
|
||||
.set mips16
|
||||
foo:
|
||||
li $2, %hi(bar)
|
||||
sll $2, $2, 16
|
||||
|
||||
addiu $3, $2, %lo(bar)
|
||||
daddiu $3, $2, %lo(bar)
|
||||
|
||||
slti $3, %lo(bar)
|
||||
sltiu $3, %lo(bar)
|
||||
|
||||
sll $3, $2, %lo(bar)
|
||||
sra $3, $2, %lo(bar)
|
||||
srl $3, $2, %lo(bar)
|
||||
dsll $3, $2, %lo(bar)
|
||||
dsra $3, %lo(bar)
|
||||
dsrl $3, %lo(bar)
|
||||
|
||||
break %lo(bar)
|
||||
sdbbp %lo(bar)
|
||||
|
||||
b %lo(bar)
|
||||
beqz $3, %lo(bar)
|
||||
bnez $3, %lo(bar)
|
||||
bteqz %lo(bar)
|
||||
btnez %lo(bar)
|
||||
|
||||
jal %lo(bar)
|
||||
jalx %lo(bar)
|
||||
|
||||
save $31, $16, %lo(bar)
|
||||
restore $31, $16, %lo(bar)
|
||||
|
||||
asmacro 0, 0, 0, 0, 0, %lo(bar)
|
||||
asmacro 0, 0, 0, 0, %lo(bar), 0
|
||||
asmacro 0, 0, 0, %lo(bar), 0, 0
|
||||
asmacro 0, 0, %lo(bar), 0, 0, 0
|
||||
asmacro 0, %lo(bar), 0, 0, 0, 0
|
||||
asmacro %lo(bar), 0, 0, 0, 0, 0
|
||||
|
||||
nop
|
||||
.set nomips16
|
||||
.end foo
|
||||
|
||||
# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
|
||||
.align 4, 0
|
||||
.space 16
|
Loading…
Reference in New Issue