From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Cc: "H.J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH 3/3] x86: limit data passed to i386_dis_printf()
Date: Mon, 24 Apr 2023 09:35:28 +0200 [thread overview]
Message-ID: <b3511736-584c-6c99-9046-331a18c60417@suse.com> (raw)
In-Reply-To: <61597ebf-cc5e-2029-6520-31f7adfeea68@suse.com>
The function doesn't use "ins" for other than retrieving "info". Remove
a thus pointless level of indirection.
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -114,7 +114,7 @@ static bool MOVSXD_Fixup (instr_info *,
static bool DistinctDest_Fixup (instr_info *, int, int);
static bool PREFETCHI_Fixup (instr_info *, int, int);
-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 *, ...);
@@ -359,12 +359,12 @@ fetch_error (const instr_info *ins)
name = prefix_name (ins->address_mode, priv->the_buffer[0],
priv->orig_sizeflag);
if (name != 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]);
}
@@ -9528,7 +9528,7 @@ oappend_register (instr_info *ins, const
used in the next fprintf_styled_func call. */
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 style,
const char *fmt, ...)
{
va_list ap;
@@ -9569,9 +9569,8 @@ i386_dis_printf (const instr_info *ins,
{
/* Output content between our START position and CURR. */
int len = curr - start;
- int n = (*ins->info->fprintf_styled_func) (ins->info->stream,
- curr_style,
- "%.*s", len, start);
+ int n = (*info->fprintf_styled_func) (info->stream, curr_style,
+ "%.*s", len, start);
if (n < 0)
break;
@@ -9722,7 +9721,7 @@ print_insn (bfd_vma pc, disassemble_info
if (ins.address_mode == 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;
}
@@ -9767,7 +9766,7 @@ print_insn (bfd_vma pc, disassemble_info
for (i = 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 == 0 ? "" : " "),
prefix_name (ins.address_mode, ins.all_prefixes[i],
sizeflag));
@@ -9790,10 +9789,10 @@ print_insn (bfd_vma pc, disassemble_info
/* Handle ins.prefixes before fwait. */
for (i = 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");
return i + 1;
}
@@ -9939,14 +9938,14 @@ print_insn (bfd_vma pc, disassemble_info
are all 0s in inverted form. */
if (ins.need_vex && ins.vex.register_specifier != 0)
{
- i386_dis_printf (&ins, dis_style_text, "(bad)");
+ i386_dis_printf (info, dis_style_text, "(bad)");
return ins.end_codep - priv.the_buffer;
}
/* If EVEX.z is set, there must be an actual mask register in use. */
if (ins.vex.zeroing && ins.vex.mask_register_specifier == 0)
{
- i386_dis_printf (&ins, dis_style_text, "(bad)");
+ i386_dis_printf (info, dis_style_text, "(bad)");
return ins.end_codep - priv.the_buffer;
}
@@ -9957,7 +9956,7 @@ print_insn (bfd_vma pc, disassemble_info
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)");
return ins.end_codep - priv.the_buffer;
}
ins.used_prefixes |= PREFIX_DATA;
@@ -9984,7 +9983,7 @@ print_insn (bfd_vma pc, disassemble_info
|| (ins.vex.evex && dp->prefix_requirement != PREFIX_DATA
&& !ins.vex.w != !(ins.used_prefixes & PREFIX_DATA)))
{
- i386_dis_printf (&ins, dis_style_text, "(bad)");
+ i386_dis_printf (info, dis_style_text, "(bad)");
return ins.end_codep - priv.the_buffer;
}
break;
@@ -10035,13 +10034,13 @@ print_insn (bfd_vma pc, disassemble_info
if (name == NULL)
abort ();
prefix_length += strlen (name) + 1;
- i386_dis_printf (&ins, dis_style_mnemonic, "%s ", name);
+ i386_dis_printf (info, dis_style_mnemonic, "%s ", name);
}
/* 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)");
return MAX_CODE_LENGTH;
}
@@ -10065,7 +10064,7 @@ print_insn (bfd_vma pc, disassemble_info
i = 0;
/* 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, "");
/* The enter and bound instructions are printed with operands in the same
order as the intel book; everything else is printed in reverse order. */
@@ -10120,7 +10119,7 @@ print_insn (bfd_vma pc, disassemble_info
break;
}
if (needcomma)
- i386_dis_printf (&ins, dis_style_text, ",");
+ i386_dis_printf (info, dis_style_text, ",");
if (ins.op_index[i] != -1 && !ins.op_riprel[i])
{
bfd_vma target = (bfd_vma) ins.op_address[ins.op_index[i]];
@@ -10136,14 +10135,14 @@ print_insn (bfd_vma pc, disassemble_info
(*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 = 1;
}
for (i = 0; i < MAX_OPERANDS; i++)
if (ins.op_index[i] != -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]]),
prev parent reply other threads:[~2023-04-24 7:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 7:33 [PATCH 0/3] x86: further disassembler tweaks Jan Beulich
2023-04-24 7:34 ` [PATCH 1/3] x86: work around compiler diagnosing dangling pointer Jan Beulich
2023-04-24 10:24 ` Alan Modra
2023-04-24 10:35 ` Jan Beulich
2023-04-24 7:35 ` [PATCH 2/3] x86: limit data passed to prefix_name() Jan Beulich
2023-04-24 7:35 ` Jan Beulich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b3511736-584c-6c99-9046-331a18c60417@suse.com \
--to=jbeulich@suse.com \
--cc=binutils@sourceware.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).