From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>, Binutils <binutils@sourceware.org>
Subject: Re: [PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag
Date: Thu, 1 Oct 2020 21:09:07 +0930 [thread overview]
Message-ID: <20201001113907.GK15011@bubble.grove.modra.org> (raw)
In-Reply-To: <20201001105033.4eniyhry5o6epu4x@jozef-acer-manjaro>
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.
> {
> if (!_bfd_elf_gc_mark (info, o, gc_mark_hook))
> return FALSE;
> diff --git a/binutils/NEWS b/binutils/NEWS
> index c0dc73d7d8..6c7d3f3953 100644
> --- a/binutils/NEWS
> +++ b/binutils/NEWS
> @@ -4,6 +4,10 @@
> symbol names. In addition the --demangle=<style>, --no-demangle,
> --recurse-limit and --no-recurse-limit options are also now availale.
>
> +* 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.
> --- a/binutils/readelf.c
> +++ b/binutils/readelf.c
> @@ -6010,6 +6012,7 @@ get_elf_section_flags (Filedata * filedata, bfd_vma sh_flags)
> case SHF_EXCLUDE: sindex = 18; break;
> case SHF_COMPRESSED: sindex = 20; break;
> case SHF_GNU_MBIND: sindex = 24; break;
> + case SHF_GNU_RETAIN: sindex = 26; break;
Again, interpretation of the bit depends on e_ident[EI_OSABI].
SHF_GNU_RETAIN should only be printed for ELFOSABI_GNU and
ELFOSABI_FREEBSD.
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2020-10-01 11:39 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 [this message]
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
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=20201001113907.GK15011@bubble.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).