Browse Source

i386: Add MAX_OPERAND_BUFFER_SIZE

When displaying operands, invalid opcodes may overflow operand buffer
due to additional styling characters.  Each style is encoded with 3
bytes.  Define MAX_OPERAND_BUFFER_SIZE for operand buffer size and
increase it from 100 bytes to 128 bytes to accommodate 9 sets of styles
in an operand.

gas/

	PR binutils/29483
	* testsuite/gas/i386/i386.exp: Run pr29483.
	* testsuite/gas/i386/pr29483.d: New file.
	* testsuite/gas/i386/pr29483.s: Likewise.

opcodes/

	PR binutils/29483
	* i386-dis.c (MAX_OPERAND_BUFFER_SIZE): New.
	(obuf): Replace 100 with MAX_OPERAND_BUFFER_SIZE.
	(staging_area): Likewise.
	(op_out): Likewise.
users/aburgess/try-mips-disasm-styling
H.J. Lu 4 years ago
parent
commit
9096fc28c6
  1. 1
      gas/testsuite/gas/i386/i386.exp
  2. 10
      gas/testsuite/gas/i386/pr29483.d
  3. 3
      gas/testsuite/gas/i386/pr29483.s
  4. 9
      opcodes/i386-dis.c

1
gas/testsuite/gas/i386/i386.exp

@ -1346,6 +1346,7 @@ if [gas_64_check] then {
run_dump_test ehinterp
}
run_dump_test pr27198
run_dump_test pr29483
set ASFLAGS "$old_ASFLAGS --64"

10
gas/testsuite/gas/i386/pr29483.d

@ -0,0 +1,10 @@
#objdump: -dw
.*: +file format .*
Disassembly of section .text:
0+ <pr29483>:
+[a-f0-9]+: 65 62 62 7d 97 a0 94 ff 20 20 20 ae vpscatterdd %xmm26,%gs:-0x51dfdfe0\(%rdi,%xmm23,8\)\{bad\}\{%k7\}\{z\}/\(bad\)
#pass

3
gas/testsuite/gas/i386/pr29483.s

@ -0,0 +1,3 @@
.text
pr29483:
.byte 0x65,0x62,0x62,0x7d,0x97,0xa0,0x94,0xff,0x20,0x20,0x20,0xae

9
opcodes/i386-dis.c

@ -119,6 +119,9 @@ static void DistinctDest_Fixup (instr_info *, int, int);
buffers. See oappend_insert_style for more details. */
#define STYLE_MARKER_CHAR '\002'
/* The maximum operand buffer size. */
#define MAX_OPERAND_BUFFER_SIZE 128
struct dis_private {
/* Points to first byte not fetched. */
bfd_byte *max_fetched;
@ -165,7 +168,7 @@ struct instr_info
current instruction. */
int evex_used;
char obuf[100];
char obuf[MAX_OPERAND_BUFFER_SIZE];
char *obufp;
char *mnemonicendp;
unsigned char *start_codep;
@ -9275,7 +9278,7 @@ i386_dis_printf (instr_info *ins, enum disassembler_style style,
va_list ap;
enum disassembler_style curr_style = style;
char *start, *curr;
char staging_area[100];
char staging_area[MAX_OPERAND_BUFFER_SIZE];
int res;
va_start (ap, fmt);
@ -9377,7 +9380,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
.last_seg_prefix = -1,
.fwait_prefix = -1,
};
char op_out[MAX_OPERANDS][100];
char op_out[MAX_OPERANDS][MAX_OPERAND_BUFFER_SIZE];
priv.orig_sizeflag = AFLAG | DFLAG;
if ((info->mach & bfd_mach_i386_i386) != 0)

Loading…
Cancel
Save