public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] x86: limit data passed to prefix_name()
Date: Fri, 28 Apr 2023 06:24:50 +0000 (GMT)	[thread overview]
Message-ID: <20230428062450.40BD53858D37@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ffe983ed7a93366a947f7cc9c569e85e63115fe9

commit ffe983ed7a93366a947f7cc9c569e85e63115fe9
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Apr 28 08:24:11 2023 +0200

    x86: limit data passed to prefix_name()
    
    Make apparent that neither what "ins" points to nor, in particular, that
    "ins->info->private_data" is actually used in the function.

Diff:
---
 opcodes/i386-dis.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 65a2abdd85e..8650e28267c 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -119,7 +119,6 @@ static bool PREFETCHI_Fixup (instr_info *, int, int);
 static void ATTRIBUTE_PRINTF_3 i386_dis_printf (const instr_info *,
 						enum disassembler_style,
 						const char *, ...);
-static const char *prefix_name (const instr_info *, int, int);
 
 /* This character is used to encode style information within the output
    buffers.  See oappend_insert_style for more details.  */
@@ -143,6 +142,8 @@ enum address_mode
   mode_64bit
 };
 
+static const char *prefix_name (enum address_mode, int, int);
+
 enum x86_64_isa
 {
   amd64 = 1,
@@ -351,7 +352,8 @@ fetch_error (const instr_info *ins)
     return -1;
 
   if (ins->prefixes || ins->fwait_prefix >= 0 || (ins->rex & REX_OPCODE))
-    name = prefix_name (ins, priv->the_buffer[0], priv->orig_sizeflag);
+    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);
   else
@@ -8924,7 +8926,7 @@ ckprefix (instr_info *ins)
    prefix byte.  */
 
 static const char *
-prefix_name (const instr_info *ins, int pref, int sizeflag)
+prefix_name (enum address_mode mode, int pref, int sizeflag)
 {
   static const char *rexes [16] =
     {
@@ -8987,7 +8989,7 @@ prefix_name (const instr_info *ins, int pref, int sizeflag)
     case 0x66:
       return (sizeflag & DFLAG) ? "data16" : "data32";
     case 0x67:
-      if (ins->address_mode == mode_64bit)
+      if (mode == mode_64bit)
 	return (sizeflag & AFLAG) ? "addr32" : "addr64";
       else
 	return (sizeflag & AFLAG) ? "addr16" : "addr32";
@@ -9764,7 +9766,8 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
 	   i++)
 	i386_dis_printf (&ins, dis_style_mnemonic, "%s%s",
 			 (i == 0 ? "" : " "),
-			 prefix_name (&ins, ins.all_prefixes[i], sizeflag));
+			 prefix_name (ins.address_mode, ins.all_prefixes[i],
+				      sizeflag));
       ret = i;
       goto out;
 
@@ -9791,7 +9794,8 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
       for (i = 0; i < ins.fwait_prefix && ins.all_prefixes[i];
 	   i++)
 	i386_dis_printf (&ins, dis_style_mnemonic, "%s ",
-			 prefix_name (&ins, ins.all_prefixes[i], sizeflag));
+			 prefix_name (ins.address_mode, ins.all_prefixes[i],
+				      sizeflag));
       i386_dis_printf (&ins, dis_style_mnemonic, "fwait");
       ret = i + 1;
       goto out;
@@ -10033,8 +10037,9 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
   for (i = 0; i < (int) ARRAY_SIZE (ins.all_prefixes); i++)
     if (ins.all_prefixes[i])
       {
-	const char *name;
-	name = prefix_name (&ins, ins.all_prefixes[i], orig_sizeflag);
+	const char *name = prefix_name (ins.address_mode, ins.all_prefixes[i],
+					orig_sizeflag);
+
 	if (name == NULL)
 	  abort ();
 	prefix_length += strlen (name) + 1;

                 reply	other threads:[~2023-04-28  6:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230428062450.40BD53858D37@sourceware.org \
    --to=jbeulich@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    /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).