aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Darrington <john@darrington.wattle.id.au>2019-01-14 16:55:17 +0100
committerJohn Darrington <john@darrington.wattle.id.au>2019-01-16 19:35:05 +0100
commite7b47f2e68c6eaff916ea4d1202a77e15730f48f (patch)
treefd28ffb0f1b591cf32469b7959be0de03965d11f
parent77fdb0e00bd47c564c4e32726fc6020d9441d4a7 (diff)
downloadgdb-e7b47f2e68c6eaff916ea4d1202a77e15730f48f.zip
gdb-e7b47f2e68c6eaff916ea4d1202a77e15730f48f.tar.gz
gdb-e7b47f2e68c6eaff916ea4d1202a77e15730f48f.tar.bz2
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.
-rw-r--r--gas/ChangeLog9
-rw-r--r--gas/config/tc-s12z.c5
-rw-r--r--gas/testsuite/gas/s12z/labels.d18
-rw-r--r--gas/testsuite/gas/s12z/labels.s3
-rw-r--r--gas/testsuite/gas/s12z/s12z.exp1
5 files changed, 32 insertions, 4 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 6b852c2..2fd79ba 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,8 +1,13 @@
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.
diff --git a/gas/config/tc-s12z.c b/gas/config/tc-s12z.c
index f6c5889..e62f383 100644
--- a/gas/config/tc-s12z.c
+++ b/gas/config/tc-s12z.c
@@ -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)
{
diff --git a/gas/testsuite/gas/s12z/labels.d b/gas/testsuite/gas/s12z/labels.d
new file mode 100644
index 0000000..d00e756
--- /dev/null
+++ b/gas/testsuite/gas/s12z/labels.d
@@ -0,0 +1,18 @@
+#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
diff --git a/gas/testsuite/gas/s12z/labels.s b/gas/testsuite/gas/s12z/labels.s
new file mode 100644
index 0000000..9326262
--- /dev/null
+++ b/gas/testsuite/gas/s12z/labels.s
@@ -0,0 +1,3 @@
+ 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
diff --git a/gas/testsuite/gas/s12z/s12z.exp b/gas/testsuite/gas/s12z/s12z.exp
index 03baf90..76d0931 100644
--- a/gas/testsuite/gas/s12z/s12z.exp
+++ b/gas/testsuite/gas/s12z/s12z.exp
@@ -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