Commit e7b47f2e authored by John Darrington's avatar John Darrington
Browse files

S12Z: gas: Fix bug when a symbol name was the single letter 'c'.

The assembler incorrectly recognised "c" as a register name, and
refused to allow it where it expected a symbol/label.

gas/
	* config/tc-s12z.c (lex_reg_name): Compare the length of the strings
	before the contents.
	* testsuite/gas/s12z/labels.d: New file.
	* testsuite/gas/s12z/labels.s: New file.
	* testsuite/gas/s12z/s12z.exp: Add them.
parent 77fdb0e0
2019-01-16 John Darrington <john@darrington.wattle.id.au>
* config/tc-s12z.c (tfr): Change as_bad to as_warn.
* config/tc-s12z.c (lex_reg_name): Compare the length of the strings
before the contents.
* testsuite/gas/s12z/labels.d: New file.
* testsuite/gas/s12z/labels.s: New file.
* testsuite/gas/s12z/s12z.exp: Add them.
* config/tc-s12z.c (tfr): Change as_bad to as_warn.
Also fix message typo and semantics.
* config/tc-s12z.c (emit_opr): Emit BFD_RELOC_S12Z_OPR instead of
* config/tc-s12z.c (emit_opr): Emit BFD_RELOC_S12Z_OPR instead of
BFD_RELOC_24.
* testsuite/gas/s12z/opr-indirect-expr.d: Expect R_S12Z_OPR instead
of R_S12Z_EXT24.
......
......@@ -308,7 +308,7 @@ lex_reg_name (uint16_t which, int *reg)
p++;
}
int len = p - input_line_pointer;
size_t len = p - input_line_pointer;
if (len <= 0)
return 0;
......@@ -318,7 +318,8 @@ lex_reg_name (uint16_t which, int *reg)
{
gas_assert (registers[i].name);
if (0 == strncasecmp (registers[i].name, input_line_pointer, len))
if (len == strlen (registers[i].name)
&& 0 == strncasecmp (registers[i].name, input_line_pointer, len))
{
if ((0x1U << i) & which)
{
......
#objdump: -d -r
#name: check that certain symbol labels are correctly accepted.
#source: labels.s
.*: file format elf32-s12z
Disassembly of section .text:
00000000 <.text>:
0: c4 fa 00 00 st d0, 0
4: 00
2: R_S12Z_OPR c
5: c4 bd st d0, d1
7: c5 fa 00 00 st d1, 0
b: 00
9: R_S12Z_OPR xavier
st d0, c ; c is a valid label
st d0, d1 ; Move D0 into the memory at address D1
st d1, xavier ; This is a valid label
......@@ -119,6 +119,7 @@ run_dump_test bit-manip-invalid
run_dump_test opr-symbol
run_dump_test brclr-symbols
run_dump_test dbCC
run_dump_test labels
# Expression related tests
run_dump_test opr-expr
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment