From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] x86-64: Allocate input section memory if needed
Date: Thu, 29 Dec 2022 08:36:58 +1030 [thread overview]
Message-ID: <Y6y+AkDrApGiOwwM@squeak.grove.modra.org> (raw)
In-Reply-To: <CAMe9rOogGfYV7QAfv4DgztDOxUzEL57W5yFoAzSyCFF439DNmA@mail.gmail.com>
On Wed, Dec 28, 2022 at 09:23:21AM -0800, H.J. Lu wrote:
> On Tue, Dec 27, 2022 at 5:16 PM Alan Modra <amodra@gmail.com> wrote:
> >
> > On Tue, Dec 27, 2022 at 11:47:56AM -0800, H.J. Lu via Binutils wrote:
> > > + /* Cache the section contents for
> > > + elf_link_input_bfd. */
> > > + elf_section_data (sec)->this_hdr.contents
> > > + = contents;
> >
> > You shouldn't really be caching unaltered section contents when
> > !info->keep_memory. I'm not saying the patch is wrong, but please fix
> > this when you have some time.
> >
> > --
> > Alan Modra
> > Australia Development Lab, IBM
>
> elf_x86_64_scan_relocs has
>
> if (elf_section_data (sec)->this_hdr.contents != contents)
> {
> if (!converted && !_bfd_link_keep_memory (info))
> free (contents);
> else
> {
> /* Cache the section contents for elf_link_input_bfd if any
> load is converted or --no-keep-memory isn't used. */
> elf_section_data (sec)->this_hdr.contents = contents;
> info->cache_size += sec->size;
> }
> }
>
> Are you suggesting that it should be
No, the code above is correct and how it should be in
elf_x86_size_or_finish_relative_reloc. Of course it is a little more
complicated there due to handling multiple sections.
>
> if (elf_section_data (sec)->this_hdr.contents != contents)
> {
> if (!converted)
> free (contents);
> else
> {
> /* Cache the section contents for elf_link_input_bfd if any
> load is converted. */
> elf_section_data (sec)->this_hdr.contents = contents;
> info->cache_size += sec->size;
> }
> }
This would be wrong as it ignores info->keep_memory.
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2022-12-28 22:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-27 19:47 H.J. Lu
2022-12-28 1:16 ` Alan Modra
2022-12-28 17:23 ` H.J. Lu
2022-12-28 22:06 ` Alan Modra [this message]
2022-12-28 23:44 ` H.J. Lu
2022-12-29 0:57 ` Alan Modra
2023-01-03 21:59 ` H.J. Lu
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=Y6y+AkDrApGiOwwM@squeak.grove.modra.org \
--to=amodra@gmail.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).