aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-01-13 17:58:02 +1030
committerAlan Modra <amodra@gmail.com>2020-01-13 18:43:34 +1030
commit90dee485e5a5cf5eb51491feb8ebea1fcbf5d4cc (patch)
tree552006ee4e73a489fd5647151b5956c1f5fca8e1 /opcodes
parentfebda64f152972d8edf0147fb29f89b02f6a4cf9 (diff)
downloadgdb-90dee485e5a5cf5eb51491feb8ebea1fcbf5d4cc.zip
gdb-90dee485e5a5cf5eb51491feb8ebea1fcbf5d4cc.tar.gz
gdb-90dee485e5a5cf5eb51491feb8ebea1fcbf5d4cc.tar.bz2
asan: ns32k: wild memory write
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.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog5
-rw-r--r--opcodes/ns32k-dis.c11
2 files changed, 10 insertions, 6 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 4584331..e74ff05 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,10 @@
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
result of wasm_read_leb128 in a uint64_t and check that bits
are not lost when copying to other locals. Use uint32_t for
diff --git a/opcodes/ns32k-dis.c b/opcodes/ns32k-dis.c
index 51b3926..d505edd 100644
--- a/opcodes/ns32k-dis.c
+++ b/opcodes/ns32k-dis.c
@@ -347,9 +347,7 @@ flip_bytes (char *ptr, int count)
}
/* 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);