aarch64: Fix segfault on unicode symbols
authorAlex Coplan <alex.coplan@arm.com>
Thu, 2 Jul 2020 12:53:07 +0000 (13:53 +0100)
committerAlex Coplan <alex.coplan@arm.com>
Thu, 2 Jul 2020 12:53:07 +0000 (13:53 +0100)
This patch fixes a segfault which occurs when the AArch64 backend parses
a symbol operand that begins with a register name and ends with a
unicode byte (byte value > 127).

For example, the following input causes the crash:

x0é: udf x0é

gas/ChangeLog:

2020-07-02  Alex Coplan  <alex.coplan@arm.com>

* config/tc-aarch64.c (reg_name_p): Fix cast so that we don't
segfault on negative chars.
* testsuite/gas/aarch64/reglike-label-unicode-segv.d: New test.
* testsuite/gas/aarch64/reglike-label-unicode-segv.s: Input.

gas/ChangeLog
gas/config/tc-aarch64.c
gas/testsuite/gas/aarch64/reglike-label-unicode-segv.d [new file with mode: 0644]
gas/testsuite/gas/aarch64/reglike-label-unicode-segv.s [new file with mode: 0644]

index 864c6cde220f494df659e5a0cdbbaeef0694912a..c4b04f02bdf841339efcbb044cddb4801824c959 100644 (file)
@@ -1,3 +1,10 @@
+2020-07-02  Alex Coplan  <alex.coplan@arm.com>
+
+       * config/tc-aarch64.c (reg_name_p): Fix cast so that we don't
+       segfault on negative chars.
+       * testsuite/gas/aarch64/reglike-label-unicode-segv.d: New test.
+       * testsuite/gas/aarch64/reglike-label-unicode-segv.s: Input.
+
 2020-07-02  Nick Clifton  <nickc@redhat.com>
 
        PR 26028
index 728fd10a4e2e246e4e8fd3f97c0a11a88e285641..ecb15d2343740426a4c867a9e1a03a3414fbbc45 100644 (file)
@@ -2190,7 +2190,7 @@ reg_name_p (char *str, aarch64_reg_type reg_type)
     return FALSE;
 
   skip_whitespace (str);
-  if (*str == ',' || is_end_of_line[(unsigned int) *str])
+  if (*str == ',' || is_end_of_line[(unsigned char) *str])
     return TRUE;
 
   return FALSE;
diff --git a/gas/testsuite/gas/aarch64/reglike-label-unicode-segv.d b/gas/testsuite/gas/aarch64/reglike-label-unicode-segv.d
new file mode 100644 (file)
index 0000000..f262e6f
--- /dev/null
@@ -0,0 +1,8 @@
+#objdump: -dr
+
+.*:     file format .*
+
+Disassembly of section \.text:
+
+0+ <x0é>:
+.*:    00000000        udf     #0
diff --git a/gas/testsuite/gas/aarch64/reglike-label-unicode-segv.s b/gas/testsuite/gas/aarch64/reglike-label-unicode-segv.s
new file mode 100644 (file)
index 0000000..18f1e92
--- /dev/null
@@ -0,0 +1,2 @@
+x0é:
+udf x0é