public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Hans-Peter Nilsson <hp@bitrange.com>,
	"H.J. Lu" <hjl.tools@gmail.com>, Fangrui Song <i@maskray.me>,
	Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] Support SHF_GNU_RETAIN ELF section flag
Date: Wed, 23 Sep 2020 06:39:25 -0700	[thread overview]
Message-ID: <CAMe9rOoFoirTkE16yYd=8FpCcfsW9C51LxtzhLbcfd5ug1b6Jw@mail.gmail.com> (raw)
In-Reply-To: <20200923095818.npbwybrm63vb4ejm@jozef-acer-manjaro>

On Wed, Sep 23, 2020 at 2:58 AM Jozef Lawrynowicz
<jozef.l@mittosystems.com> wrote:
>
> On Tue, Sep 22, 2020 at 07:24:01PM -0400, Hans-Peter Nilsson wrote:
> > On Tue, 22 Sep 2020, Jozef Lawrynowicz wrote:
> > > The new tests are passing for all targets except mmix-elf.
> >
> > There is no mmix-elf target: if it's buildable, that's a
> > mistake.  I'm not sure what kind of abomination results, if it's
> > a goldblum-fly or karloff-frankensteins. :)
> >
> > The target mmix a.k.a. mmix-knuth-mmixware assembles to ELF, but
> > links to MMO by use of the generic linker machinery.  You *can*
> > link to ELF by means of the linker option "-m elf64mmix".
> >
> > brgds, H-P
> >
>
> Ah, thanks for the info. I formed that list of targets by just
> extracting the CPU name from all the files in bfd/ with "elf" in the
> name.
>
> mmix-elf is buildable, and most tests pass, but it definitely appears
> that a lot is broken!
>
>   ==> mmix-elf/binutils.sum <==
>   # of expected passes            122
>   # of unexpected failures        38
>   ==> mmix-elf/gas.sum <==
>   # of expected passes            446
>   # of unexpected failures        68
>   ==> mmix-elf/ld.sum <==
>   # of expected passes            430
>   # of unexpected failures        158
>
> I'll remove any mmix-elf-specific XFAIL-ing from the patch.
>
> On Tue, Sep 22, 2020 at 04:58:23PM -0700, H.J. Lu via Binutils wrote:
> > On Tue, Sep 22, 2020 at 1:30 PM Jozef Lawrynowicz
> > <jozef.l@mittosystems.com> wrote:
> > >
> > +  /* A GNU extension for preventing linker garbage collection of sections.  */
> > +  {"retain", obj_elf_retain, 0},
> > +
> >
> > Why is this needed?  Isn't
> >
> > @@ -857,6 +861,9 @@ obj_elf_parse_section_letters (char *str, size_t len,
> >   case 'd':
> >    *gnu_attr |= SHF_GNU_MBIND;
> >    break;
> > + case 'R':
> > +  *gnu_attr |= SHF_GNU_RETAIN;
> > +  break;
> >   case '?':
> >    *is_clone = TRUE;
> >    break;
> >
> > enough?  The .section directive is used for all other SHF_XXX bits.   I don't
> > think we need a separate directive for SHF_GNU_RETAIN?
>
> GCC doesn't know if SHF_GNU_RETAIN is required when creating a section,
> since the "retain" attribute is applied to function and data
> declarations.
>
> So rather than emitting the section directive again, which could be
> confusing if there are two almost identical section declarations, the
> ".retain" directive describes the precise augmentation to make to the
> already-declared section.
>
> I think that:
>
> >  .section .text,"ax"
> >    ...
> >  foo:
> >    ...
> >  .retain
> >  retained_fn:
> >    ...
>
> is some nice syntactic sugar compared to:
>
> >  .section .text,"ax"
> >    ...
> >  foo:
> >    ...
> >  .section .text,"axR"
> >  retained_fn:
> >    ...
>
> It's also partly for convenience; we have other directives which are
> synonyms or short-hand for each other.
>

You don't need to keep the whole section when only one symbol should
be kept.  Please drop the .retain directive.  GCC, as and ld should do the
right thing with

.section .text,"ax"
   ...
foo:
  ...
 .section .text,"axR"

 retained_fn:

where foo can be dropped and retained_fn will be kept.

H.J.

  reply	other threads:[~2020-09-23 13:40 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 20:29 Jozef Lawrynowicz
2020-09-22 23:24 ` Hans-Peter Nilsson
2020-09-22 23:58 ` H.J. Lu
2020-09-23  1:09 ` Fangrui Song
2020-09-23  9:58   ` Jozef Lawrynowicz
2020-09-23 13:39     ` H.J. Lu [this message]
2020-09-23 13:51       ` Michael Matz
2020-09-23 16:52         ` Jozef Lawrynowicz
2020-09-23 17:13           ` H.J. Lu
2020-09-23 18:47             ` Jozef Lawrynowicz
2020-09-23 19:03               ` H.J. Lu
2020-09-23 20:04                 ` Jozef Lawrynowicz
2020-09-23 20:17                   ` H.J. Lu
2020-09-23 23:29                     ` Fangrui Song
2020-09-24 11:39                       ` Jozef Lawrynowicz
2020-09-24 19:06                         ` Fangrui Song
2020-09-24 13:27                       ` Michael Matz
2020-09-24 13:18                     ` H.J. Lu
2020-09-24 13:49                       ` Jozef Lawrynowicz
2020-09-24 13:59                         ` H.J. Lu
2020-09-24 16:56                           ` Jozef Lawrynowicz
2020-09-24 17:04                             ` H.J. Lu
2020-09-24 17:18                               ` Jozef Lawrynowicz
2020-09-24 17:37                                 ` H.J. Lu
2020-09-23 12:13 ` Jozef Lawrynowicz
2020-09-23 13:59   ` Alan Modra
2020-09-23 16:54     ` Jozef Lawrynowicz
2020-09-28 11:35 ` Pedro Alves
2020-09-28 12:28   ` Jozef Lawrynowicz
2020-09-28 14:46     ` Pedro Alves
2020-09-29 13:18       ` Michael Matz
2020-09-29 13:22         ` Jozef Lawrynowicz
2020-09-29 13:48         ` Pedro Alves
2020-09-29 13:55           ` Michael Matz
2020-09-29 14:04             ` Pedro Alves
2020-09-29 14:10               ` Michael Matz
2020-09-29 14:11                 ` Pedro Alves

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='CAMe9rOoFoirTkE16yYd=8FpCcfsW9C51LxtzhLbcfd5ug1b6Jw@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hp@bitrange.com \
    --cc=i@maskray.me \
    /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).