From: "J.W. Jagersma" <jwjagersma@gmail.com>
To: binutils@sourceware.org
Cc: dj@delorie.com, nickc@redhat.com, "J.W. Jagersma" <jwjagersma@gmail.com>
Subject: [PATCH 4/3+] coff-go32-exe: avoid reallocating stub on copy
Date: Wed, 25 Mar 2020 18:54:39 +0100 [thread overview]
Message-ID: <20200325175438.11596-1-jwjagersma@gmail.com> (raw)
In-Reply-To: <20200319191923.34747-1-jwjagersma@gmail.com>
I'd like to make a small addition to this patch set:
When copying the stub from one bfd to another, there is no need to
reallocate if the destination already has a stub that is the same size
as the source. This will practically always be the case.
bfd/
2020-03-25 Jan W. Jagersma <jwjagersma@gmail.com>
* coff-stgo32.c (go32exe_copy_private_bfd_data): Avoid realloc
when possible.
---
bfd/coff-stgo32.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c
index 7239b34306..d1be578c6a 100644
--- a/bfd/coff-stgo32.c
+++ b/bfd/coff-stgo32.c
@@ -217,8 +217,9 @@ go32exe_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
/* Make sure we have a source stub. */
BFD_ASSERT (coff_data (ibfd)->stub != NULL);
- /* Allocate the output stub. */
- coff_data (obfd)->stub = bfd_alloc (obfd, coff_data (ibfd)->stub_size);
+ /* Reallocate the output stub if necessary. */
+ if (coff_data (ibfd)->stub_size > coff_data (obfd)->stub_size)
+ coff_data (obfd)->stub = bfd_alloc (obfd, coff_data (ibfd)->stub_size);
if (coff_data (obfd)->stub == NULL)
return FALSE;
--
2.25.2
next prev parent reply other threads:[~2020-03-25 17:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-19 19:19 [PATCH 0/3] coff-go32-exe: support variable-length stubs J.W. Jagersma
2020-03-19 19:19 ` [PATCH 1/3] always add base bfd->origin to file offset J.W. Jagersma
2020-03-19 19:19 ` [PATCH 2/3] coff-go32-exe: support variable-length stubs J.W. Jagersma
2020-03-19 19:19 ` [PATCH 3/3] normalize names in coff-stgo32.c J.W. Jagersma
2020-03-20 14:04 ` [PATCH 0/3] coff-go32-exe: support variable-length stubs Nick Clifton
2020-03-20 15:38 ` J.W. Jagersma
2020-03-20 19:42 ` DJ Delorie
2020-03-21 16:07 ` J.W. Jagersma
2020-04-01 16:45 ` J.W. Jagersma
2020-03-25 17:54 ` J.W. Jagersma [this message]
2020-04-02 13:34 ` Nick Clifton
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=20200325175438.11596-1-jwjagersma@gmail.com \
--to=jwjagersma@gmail.com \
--cc=binutils@sourceware.org \
--cc=dj@delorie.com \
--cc=nickc@redhat.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).