From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Subject: [PATCH 3/4] x86: avoid string copy when swapping Vex.W controlled operands
Date: Fri, 10 Jun 2022 15:35:52 +0200 [thread overview]
Message-ID: <c34029b6-a66e-8dab-1b42-87ee8da91af8@suse.com> (raw)
In-Reply-To: <6fd28ca0-2af4-7335-18d3-31036dea7a4f@suse.com>
Now that op_out[] is an array of pointers, there's no need anymore to
copy strings. Simply swap the pointers.
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -13473,9 +13473,10 @@ OP_VexW (instr_info *ins, int bytemode,
if (ins->vex.w)
{
/* Swap 2nd and 3rd operands. */
- strcpy (ins->scratchbuf, ins->op_out[2]);
- strcpy (ins->op_out[2], ins->op_out[1]);
- strcpy (ins->op_out[1], ins->scratchbuf);
+ char *tmp = ins->op_out[2];
+
+ ins->op_out[2] = ins->op_out[1];
+ ins->op_out[1] = tmp;
}
}
@@ -13503,9 +13504,10 @@ OP_REG_VexI4 (instr_info *ins, int bytem
if (ins->vex.w)
{
/* Swap 3rd and 4th operands. */
- strcpy (ins->scratchbuf, ins->op_out[3]);
- strcpy (ins->op_out[3], ins->op_out[2]);
- strcpy (ins->op_out[2], ins->scratchbuf);
+ char *tmp = ins->op_out[3];
+
+ ins->op_out[3] = ins->op_out[2];
+ ins->op_out[2] = tmp;
}
}
next prev parent reply other threads:[~2022-06-10 13:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 13:33 [PATCH 0/4] x86: follow-on to making disassembler thread-safe Jan Beulich
2022-06-10 13:35 ` [PATCH 1/4] x86: properly initialize struct instr_info instance(s) Jan Beulich
2022-06-10 13:35 ` [PATCH 2/4] x86: shrink prefix related disassembler state fields Jan Beulich
2022-06-10 13:35 ` Jan Beulich [this message]
2022-06-10 13:36 ` [PATCH 4/4] x86: replace global scratch buffer Jan Beulich
2022-06-13 13:59 ` H.J. Lu
2022-06-13 14:55 ` Jan Beulich
2022-06-13 20:58 ` H.J. Lu
2022-06-10 19:43 ` [PATCH 0/4] x86: follow-on to making disassembler thread-safe H.J. Lu
2022-06-13 7:54 ` Jan Beulich
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=c34029b6-a66e-8dab-1b42-87ee8da91af8@suse.com \
--to=jbeulich@suse.com \
--cc=binutils@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).