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.
This commit is contained in:
Alan Modra
2020-01-13 17:58:02 +10:30
parent febda64f15
commit 90dee485e5
2 changed files with 10 additions and 6 deletions

View 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> 2020-01-13 Alan Modra <amodra@gmail.com>
* wasm32-dis.c (print_insn_wasm32): Localise variables. Store * wasm32-dis.c (print_insn_wasm32): Localise variables. Store

View File

@ -347,9 +347,7 @@ flip_bytes (char *ptr, int count)
} }
/* Given a character C, does it represent a general addressing mode? */ /* Given a character C, does it represent a general addressing mode? */
#define Is_gen(c) \ #define Is_gen(c) (strchr ("FLBWDAIZf", (c)) != NULL)
((c) == 'F' || (c) == 'L' || (c) == 'B' \
|| (c) == 'W' || (c) == 'D' || (c) == 'A' || (c) == 'I' || (c) == 'Z')
/* Adressing modes. */ /* Adressing modes. */
#define Adrmod_index_byte 0x1c #define Adrmod_index_byte 0x1c
@ -810,7 +808,8 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info)
of the addressing extension. */ 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)) if (Adrmod_is_index (addr_mode))
{ {