From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
To: Alan Modra <amodra@gmail.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>, Binutils <binutils@sourceware.org>
Subject: Re: [PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag
Date: Fri, 2 Oct 2020 16:45:13 +0100 [thread overview]
Message-ID: <20201002154513.jo6u6okjpxpvxvh3@jozef-acer-manjaro> (raw)
In-Reply-To: <20201002141110.GS15011@bubble.grove.modra.org>
On Fri, Oct 02, 2020 at 11:41:10PM +0930, Alan Modra via Binutils wrote:
> On Fri, Oct 02, 2020 at 01:30:23PM +0100, Jozef Lawrynowicz wrote:
> > On Thu, Oct 01, 2020 at 09:09:07PM +0930, Alan Modra via Binutils wrote:
> > > On Thu, Oct 01, 2020 at 11:50:33AM +0100, Jozef Lawrynowicz wrote:
> > > > --- a/bfd/elflink.c
> > > > +++ b/bfd/elflink.c
> > > > @@ -14102,7 +14102,8 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
> > > > || (elf_section_data (o)->this_hdr.sh_type
> > > > == SHT_FINI_ARRAY)))
> > > > || (elf_section_data (o)->this_hdr.sh_type == SHT_NOTE
> > > > - && elf_next_in_group (o) == NULL )))
> > > > + && elf_next_in_group (o) == NULL)
> > > > + || (elf_section_flags (o) & SHF_GNU_RETAIN)))
> > >
> > > Flag bits in SHF_MASKOS depend on OS, so this needs a test of OSABI.
> > > That can be done by checking elf_tdata (sub)->has_gnu_osabi for the
> > > appropriate bit.
> > >
> >
> > Fixed the two OSABI issues in the attached patch.
>
> I didn't mention it, but readelf has two occurrences of decoding
> SHF_GNU_UNIQUE. They both need fixing, not just the first one.
Well in fact, the part I added OSABI handling to already in readelf
wasn't correct anyway, those nested switch/if-else/switch statements
caught me out ;)
Cleaning that up is a task for some other time, however.
I started adding tests to validate the readelf output with/without "-N",
when the numeric values for SHF_GNU_{RETAIN,MBIND} are set, for targets
which neither error when these bits are set (ELFOSABI_STANDALONE) nor
handle them as their GNU OSABI values (ELFOSABI_{NONE,GNU,FREEBSD}).
However, hppa-unknown-elf is the only target I've been testing that
satisfies these constraints (ELFOSABI_HPUX), so I'm going to find some
others to validate the changes and finish this off next week.
>
> > > > +* Add support for the SHF_GNU_RETAIN ELF section flag.
> > > > + This flag specifies that the section should not be garbage collected by the
> > > > + linker if it is unused.
> > >
> > > I would drop "if it is unused". The phrase doesn't really add
> > > anything to a user's understanding.
> > >
> >
> > I don't really have a strong opinion either way, but I thought "if it is
> > unused" might be helpful to add to the description since "garbage
> > collection" is not precisely defined in ELF.
>
> The reason I don't particularly like "if it is unused" is that it
> sounds like something said by someone who doesn't really understand
> linker garbage collection. "used" and "referenced by a relocation
> from a kept section" are only loosely related. And indeed the whole
> purpose of SHF_GNU_RETAIN is surely to keep needed sections, ones that
> are used for some purpose.
Sounds fair to me. The precise ELF definition is targeting technical
users after all.
Thanks,
Jozef
>
> --
> Alan Modra
> Australia Development Lab, IBM
prev parent reply other threads:[~2020-10-02 15:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-28 13:26 Jozef Lawrynowicz
2020-09-29 4:43 ` Fangrui Song
2020-09-29 10:04 ` Jozef Lawrynowicz
2020-09-29 19:38 ` Fangrui Song
2020-09-29 19:54 ` H.J. Lu
2020-09-29 21:37 ` Jozef Lawrynowicz
2020-09-30 0:10 ` Roland McGrath
2020-09-30 10:18 ` Jozef Lawrynowicz
2020-09-30 14:01 ` H.J. Lu
2020-10-01 19:22 ` Fangrui Song
2020-10-01 19:53 ` H.J. Lu
2020-10-02 12:44 ` Jozef Lawrynowicz
2020-09-30 14:13 ` Michael Matz
2020-09-30 22:13 ` H.J. Lu
2020-10-01 10:50 ` Jozef Lawrynowicz
2020-10-01 11:39 ` Alan Modra
2020-10-02 12:30 ` Jozef Lawrynowicz
2020-10-02 12:33 ` H.J. Lu
2020-10-02 12:41 ` H.J. Lu
2020-10-02 12:53 ` Jozef Lawrynowicz
2020-10-02 14:11 ` Alan Modra
2020-10-02 15:45 ` Jozef Lawrynowicz [this message]
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=20201002154513.jo6u6okjpxpvxvh3@jozef-acer-manjaro \
--to=jozef.l@mittosystems.com \
--cc=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).