From: "H.J. Lu" <hjl.tools@gmail.com>
To: Alan Modra <amodra@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] x86-64: Allocate input section memory if needed
Date: Wed, 28 Dec 2022 15:44:55 -0800 [thread overview]
Message-ID: <CAMe9rOpXvqHkGY-0w4tGtP5SfeMbDukPnDYB8ZjpE8nReHLMXA@mail.gmail.com> (raw)
In-Reply-To: <Y6y+AkDrApGiOwwM@squeak.grove.modra.org>
On Wed, Dec 28, 2022 at 2:07 PM Alan Modra <amodra@gmail.com> wrote:
>
> 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
But elf_x86_size_or_finish_relative_reloc modifies the section
contents by storing r_addend in it.
> 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
--
H.J.
next prev parent reply other threads:[~2022-12-28 23:45 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
2022-12-28 23:44 ` H.J. Lu [this message]
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=CAMe9rOpXvqHkGY-0w4tGtP5SfeMbDukPnDYB8ZjpE8nReHLMXA@mail.gmail.com \
--to=hjl.tools@gmail.com \
--cc=amodra@gmail.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).