public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <i@maskray.me>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Nick Clifton <nickc@redhat.com>, Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] elf: Also check linked-to section for SHT_NOTE section
Date: Wed, 30 Sep 2020 20:41:59 -0700	[thread overview]
Message-ID: <MWHPR12MB1456FF73D980368A3F822F31CB300@MWHPR12MB1456.namprd12.prod.outlook.com> (raw)
In-Reply-To: <CAMe9rOo-Nz6vt3ue2z0+iQNXCx6AkqyjSzN=ZghWCFdsTpPpEw@mail.gmail.com>

On Wed, Sep 30, 2020 at 7:03 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Wed, Sep 30, 2020 at 7:01 AM Nick Clifton <nickc@redhat.com> wrote:
> >
> > Hi H.J.
> >
> >   Thanks for taking an interest in this.
> >
> > > Please try this patch.
> >   It did not appear to make a difference. :-(
> >
> >   I am using an extended test case (attached) but the results are the
> >   same as before:
> >
> >   % as eliminate.s -o eliminate.o
> >   % ld -e 0 --gc-sections --print-gc-sections eliminate.o
> >   ld: removing unused section '.group' in file 'eliminate.o'
> >   ld: removing unused section '.group' in file 'eliminate.o'
> >   ld: removing unused section '.text' in file 'eliminate.o'
> >   ld: removing unused section '.unused1' in file 'eliminate.o'
> >   ld: removing unused section '.unused2[unused_group]' in file 'eliminate.o'
> >   ld: removing unused section '.unused3[unused_group2]' in file 'eliminate.o'
> >   ld: removing unused section '.gnu.note2[unused_group]' in file 'eliminate.o'
> >   ld: removing unused section '.gnu.note3[unused_group2]' in file 'eliminate.o'
> >   ld: a.out: sh_link of section `.gnu.note1' points to discarded section `.unused1' of `eliminate.o'
> >   ld: final link failed: bad value
> >
> > Cheers
> >   Nick
>
> Works for me:
>
> [hjl@gnu-cfl-2 ld]$ gcc -c eliminate.s
> [hjl@gnu-cfl-2 ld]$ ./ld-new -e 0 --gc-sections --print-gc-sections eliminate.o
> ./ld-new: removing unused section '.group' in file 'eliminate.o'
> ./ld-new: removing unused section '.group' in file 'eliminate.o'
> ./ld-new: removing unused section '.text' in file 'eliminate.o'
> ./ld-new: removing unused section '.unused1' in file 'eliminate.o'
> ./ld-new: removing unused section '.unused2[unused_group]' in file 'eliminate.o'
> ./ld-new: removing unused section '.unused3[unused_group2]' in file
> 'eliminate.o'
> ./ld-new: removing unused section '.gnu.note1' in file 'eliminate.o'
> ./ld-new: removing unused section '.gnu.note2[unused_group]' in file
> 'eliminate.o'
> ./ld-new: removing unused section '.gnu.note3[unused_group2]' in file
> 'eliminate.o'
> [hjl@gnu-cfl-2 ld]$
>
>
> --
> H.J.

Thanks HJ for the patch. The --gc-sections semantics I expect are
written down here:
https://sourceware.org/pipermail/binutils/2020-February/109851.html

(If SHF_GNU_RETAIN
(https://sourceware.org/pipermail/binutils/2020-September/113534.html)
is accepted, a SHF_GNU_RETAIN section will be added to the GC root
list.
I forwarded the progress to a few toolchain folks on LLVM side and
encouraged them to reply if they still have concerns.)

      reply	other threads:[~2020-10-01  3:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 15:12 RFC: New gas directive: .attach_to_group Nick Clifton
2020-09-29 16:53 ` Fangrui Song
2020-09-30  9:33   ` Nick Clifton
     [not found]   ` <3609c590-8750-a021-92fb-05ff0ba7ca7d@redhat.com>
2020-09-30 13:43     ` [PATCH] elf: Also check linked-to section for SHT_NOTE section H.J. Lu
2020-09-30 14:01       ` Nick Clifton
2020-09-30 14:03         ` H.J. Lu
2020-10-01  3:41           ` Fangrui Song [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=MWHPR12MB1456FF73D980368A3F822F31CB300@MWHPR12MB1456.namprd12.prod.outlook.com \
    --to=i@maskray.me \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=nickc@redhat.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).