asan: ns32k: wild memory write
authorAlan Modra <amodra@gmail.com>
Mon, 13 Jan 2020 07:28:02 +0000 (17:58 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 13 Jan 2020 08:13:34 +0000 (18:43 +1030)
index_offset isn't set up for "sfsr", resulting in a random offset
being used when trying to disassemble the following.

 .byte 0x3e, 0xf7, 0x07, 0x00

* ns32k-dis.c (Is_gen): Use strchr, add 'f'.
(print_insn_ns32k): Adjust ioffset for 'f' index_offset.

opcodes/ChangeLog
opcodes/ns32k-dis.c

index 458433164f100cc595c32e42e3fbab16d481c1fc..e74ff054618d4c1d9ce61113e95b3c4d9fac7034 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-13  Alan Modra  <amodra@gmail.com>
+
+       * ns32k-dis.c (Is_gen): Use strchr, add 'f'.
+       (print_insn_ns32k): Adjust ioffset for 'f' index_offset.
+
 2020-01-13  Alan Modra  <amodra@gmail.com>
 
        * wasm32-dis.c (print_insn_wasm32): Localise variables.  Store
index 51b39260c4f68cb5efb854ce07fe950de521fbc0..d505edd774267d4c3f93200917a9296792bd4b31 100644 (file)
@@ -347,9 +347,7 @@ flip_bytes (char *ptr, int count)
 }
 \f
 /* Given a character C, does it represent a general addressing mode?  */
-#define Is_gen(c) \
-  ((c) == 'F' || (c) == 'L' || (c) == 'B' \
-   || (c) == 'W' || (c) == 'D' || (c) == 'A' || (c) == 'I' || (c) == 'Z')
+#define Is_gen(c) (strchr ("FLBWDAIZf", (c)) != NULL)
 
 /* Adressing modes.  */
 #define Adrmod_index_byte        0x1c
@@ -808,9 +806,10 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info)
         if we are using scaled indexed addressing mode, since the index
         bytes occur right after the basic instruction, not as part
         of the addressing extension.  */
-      if (Is_gen(d[1]))
+      if (Is_gen (d[1]))
        {
-         int addr_mode = bit_extract (buffer, ioffset - 5, 5);
+         int bitoff = d[1] == 'f' ? 10 : 5;
+         int addr_mode = bit_extract (buffer, ioffset - bitoff, 5);
 
          if (Adrmod_is_index (addr_mode))
            {
@@ -819,7 +818,7 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info)
            }
        }
 
-      if (d[2] && Is_gen(d[3]))
+      if (d[2] && Is_gen (d[3]))
        {
          int addr_mode = bit_extract (buffer, ioffset - 10, 5);
 
This page took 0.025021 seconds and 4 git commands to generate.