From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 524213858C1F; Fri, 28 Apr 2023 06:24:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 524213858C1F Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] x86: limit data passed to i386_dis_printf() X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: ffe983ed7a93366a947f7cc9c569e85e63115fe9 X-Git-Newrev: e4452aa670e5cec9c78b241d3572c91170598965 Message-Id: <20230428062455.524213858C1F@sourceware.org> Date: Fri, 28 Apr 2023 06:24:55 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Apr 2023 06:24:55 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De4452aa670e5= cec9c78b241d3572c91170598965 commit e4452aa670e5cec9c78b241d3572c91170598965 Author: Jan Beulich Date: Fri Apr 28 08:24:41 2023 +0200 x86: limit data passed to i386_dis_printf() =20 The function doesn't use "ins" for other than retrieving "info". Remove a thus pointless level of indirection. Diff: --- opcodes/i386-dis.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 8650e28267c..b529fe705bc 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -116,7 +116,7 @@ static bool MOVSXD_Fixup (instr_info *, int, int); static bool DistinctDest_Fixup (instr_info *, int, int); static bool PREFETCHI_Fixup (instr_info *, int, int); =20 -static void ATTRIBUTE_PRINTF_3 i386_dis_printf (const instr_info *, +static void ATTRIBUTE_PRINTF_3 i386_dis_printf (const disassemble_info *, enum disassembler_style, const char *, ...); =20 @@ -355,12 +355,12 @@ fetch_error (const instr_info *ins) name =3D prefix_name (ins->address_mode, priv->the_buffer[0], priv->orig_sizeflag); if (name !=3D NULL) - i386_dis_printf (ins, dis_style_mnemonic, "%s", name); + i386_dis_printf (ins->info, dis_style_mnemonic, "%s", name); else { /* Just print the first byte as a .byte instruction. */ - i386_dis_printf (ins, dis_style_assembler_directive, ".byte "); - i386_dis_printf (ins, dis_style_immediate, "%#x", + i386_dis_printf (ins->info, dis_style_assembler_directive, ".byte "); + i386_dis_printf (ins->info, dis_style_immediate, "%#x", (unsigned int) priv->the_buffer[0]); } =20 @@ -9524,7 +9524,7 @@ oappend_register (instr_info *ins, const char *s) used in the next fprintf_styled_func call. */ =20 static void ATTRIBUTE_PRINTF_3 -i386_dis_printf (const instr_info *ins, enum disassembler_style style, +i386_dis_printf (const disassemble_info *info, enum disassembler_style sty= le, const char *fmt, ...) { va_list ap; @@ -9565,9 +9565,8 @@ i386_dis_printf (const instr_info *ins, enum disassem= bler_style style, { /* Output content between our START position and CURR. */ int len =3D curr - start; - int n =3D (*ins->info->fprintf_styled_func) (ins->info->stream, - curr_style, - "%.*s", len, start); + int n =3D (*info->fprintf_styled_func) (info->stream, curr_style, + "%.*s", len, start); if (n < 0) break; =20 @@ -9719,7 +9718,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int i= ntel_syntax) =20 if (ins.address_mode =3D=3D mode_64bit && sizeof (bfd_vma) < 8) { - i386_dis_printf (&ins, dis_style_text, _("64-bit address is disabled= ")); + i386_dis_printf (info, dis_style_text, _("64-bit address is disabled= ")); return -1; } =20 @@ -9764,7 +9763,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int i= ntel_syntax) for (i =3D 0; i < (int) ARRAY_SIZE (ins.all_prefixes) && ins.all_prefixes[i]; i++) - i386_dis_printf (&ins, dis_style_mnemonic, "%s%s", + i386_dis_printf (info, dis_style_mnemonic, "%s%s", (i =3D=3D 0 ? "" : " "), prefix_name (ins.address_mode, ins.all_prefixes[i], sizeflag)); @@ -9793,10 +9792,10 @@ print_insn (bfd_vma pc, disassemble_info *info, int= intel_syntax) /* Handle ins.prefixes before fwait. */ for (i =3D 0; i < ins.fwait_prefix && ins.all_prefixes[i]; i++) - i386_dis_printf (&ins, dis_style_mnemonic, "%s ", + i386_dis_printf (info, dis_style_mnemonic, "%s ", prefix_name (ins.address_mode, ins.all_prefixes[i], sizeflag)); - i386_dis_printf (&ins, dis_style_mnemonic, "fwait"); + i386_dis_printf (info, dis_style_mnemonic, "fwait"); ret =3D i + 1; goto out; } @@ -9943,7 +9942,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int i= ntel_syntax) are all 0s in inverted form. */ if (ins.need_vex && ins.vex.register_specifier !=3D 0) { - i386_dis_printf (&ins, dis_style_text, "(bad)"); + i386_dis_printf (info, dis_style_text, "(bad)"); ret =3D ins.end_codep - priv.the_buffer; goto out; } @@ -9951,7 +9950,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int i= ntel_syntax) /* If EVEX.z is set, there must be an actual mask register in use. */ if (ins.vex.zeroing && ins.vex.mask_register_specifier =3D=3D 0) { - i386_dis_printf (&ins, dis_style_text, "(bad)"); + i386_dis_printf (info, dis_style_text, "(bad)"); ret =3D ins.end_codep - priv.the_buffer; goto out; } @@ -9963,7 +9962,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int i= ntel_syntax) the encoding invalid. Most other PREFIX_OPCODE rules still apply. */ if (ins.need_vex ? !ins.vex.prefix : !(ins.prefixes & PREFIX_DATA)) { - i386_dis_printf (&ins, dis_style_text, "(bad)"); + i386_dis_printf (info, dis_style_text, "(bad)"); ret =3D ins.end_codep - priv.the_buffer; goto out; } @@ -9991,7 +9990,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int i= ntel_syntax) || (ins.vex.evex && dp->prefix_requirement !=3D PREFIX_DATA && !ins.vex.w !=3D !(ins.used_prefixes & PREFIX_DATA))) { - i386_dis_printf (&ins, dis_style_text, "(bad)"); + i386_dis_printf (info, dis_style_text, "(bad)"); ret =3D ins.end_codep - priv.the_buffer; goto out; } @@ -10043,13 +10042,13 @@ print_insn (bfd_vma pc, disassemble_info *info, i= nt intel_syntax) if (name =3D=3D NULL) abort (); prefix_length +=3D strlen (name) + 1; - i386_dis_printf (&ins, dis_style_mnemonic, "%s ", name); + i386_dis_printf (info, dis_style_mnemonic, "%s ", name); } =20 /* Check maximum code length. */ if ((ins.codep - ins.start_codep) > MAX_CODE_LENGTH) { - i386_dis_printf (&ins, dis_style_text, "(bad)"); + i386_dis_printf (info, dis_style_text, "(bad)"); ret =3D MAX_CODE_LENGTH; goto out; } @@ -10074,7 +10073,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int= intel_syntax) i =3D 0; =20 /* Print the instruction mnemonic along with any trailing whitespace. */ - i386_dis_printf (&ins, dis_style_mnemonic, "%s%*s", ins.obuf, i, ""); + i386_dis_printf (info, dis_style_mnemonic, "%s%*s", ins.obuf, i, ""); =20 /* The enter and bound instructions are printed with operands in the same order as the intel book; everything else is printed in reverse order.= */ @@ -10129,7 +10128,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int= intel_syntax) break; } if (needcomma) - i386_dis_printf (&ins, dis_style_text, ","); + i386_dis_printf (info, dis_style_text, ","); if (ins.op_index[i] !=3D -1 && !ins.op_riprel[i]) { bfd_vma target =3D (bfd_vma) ins.op_address[ins.op_index[i]]; @@ -10145,14 +10144,14 @@ print_insn (bfd_vma pc, disassemble_info *info, i= nt intel_syntax) (*info->print_address_func) (target, info); } else - i386_dis_printf (&ins, dis_style_text, "%s", op_txt[i]); + i386_dis_printf (info, dis_style_text, "%s", op_txt[i]); needcomma =3D 1; } =20 for (i =3D 0; i < MAX_OPERANDS; i++) if (ins.op_index[i] !=3D -1 && ins.op_riprel[i]) { - i386_dis_printf (&ins, dis_style_comment_start, " # "); + i386_dis_printf (info, dis_style_comment_start, " # "); (*info->print_address_func) ((bfd_vma)(ins.start_pc + (ins.codep - ins.start_codep) + ins.op_address[ins.op_index[i]]),