diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2017-05-15 13:09:37 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@imgtec.com> | 2017-05-15 13:57:08 +0100 |
commit | e295202f606accec7623c961997a295a8e680247 (patch) | |
tree | 8b20ee6b5aaa943898b48fab2078fb74336480e6 | |
parent | c76081bc874d7d41eb6f41ea79a4ac0f906467d0 (diff) | |
download | gdb-e295202f606accec7623c961997a295a8e680247.zip gdb-e295202f606accec7623c961997a295a8e680247.tar.gz gdb-e295202f606accec7623c961997a295a8e680247.tar.bz2 |
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.
-rw-r--r-- | gas/ChangeLog | 9 | ||||
-rw-r--r-- | gas/config/tc-mips.c | 5 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips.exp | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-reloc-error.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-reloc-error.l | 28 | ||||
-rw-r--r-- | gas/testsuite/gas/mips/mips16-reloc-error.s | 52 |
6 files changed, 98 insertions, 1 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 4aca584..65a4577 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,14 @@ 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. * testsuite/gas/mips/lui-2.d: New test. * gas/testsuite/gas/mips/mips.exp: Fold corresponding list tests diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 27ce043..0932cea 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -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; diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index cdc39df..c0bdd77 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -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" diff --git a/gas/testsuite/gas/mips/mips16-reloc-error.d b/gas/testsuite/gas/mips/mips16-reloc-error.d new file mode 100644 index 0000000..1129a65 --- /dev/null +++ b/gas/testsuite/gas/mips/mips16-reloc-error.d @@ -0,0 +1,3 @@ +#name: MIPS16 relocation errors +#as: -32 -mips64r2 +#error-output: mips16-reloc-error.l diff --git a/gas/testsuite/gas/mips/mips16-reloc-error.l b/gas/testsuite/gas/mips/mips16-reloc-error.l new file mode 100644 index 0000000..a107604 --- /dev/null +++ b/gas/testsuite/gas/mips/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' diff --git a/gas/testsuite/gas/mips/mips16-reloc-error.s b/gas/testsuite/gas/mips/mips16-reloc-error.s new file mode 100644 index 0000000..f826682 --- /dev/null +++ b/gas/testsuite/gas/mips/mips16-reloc-error.s @@ -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 |