public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Nick Clifton <nickc@redhat.com>, Binutils <binutils@sourceware.org>
Subject: [PATCH] elf: Also check linked-to section for SHT_NOTE section
Date: Wed, 30 Sep 2020 06:43:03 -0700	[thread overview]
Message-ID: <CAMe9rOpZKx2tygA6_HTrcb44H=92mPNuuaq=6pBjRHBx3NHcZQ@mail.gmail.com> (raw)
In-Reply-To: <3609c590-8750-a021-92fb-05ff0ba7ca7d@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1842 bytes --]

On Wed, Sep 30, 2020 at 3:56 AM Nick Clifton <nickc@redhat.com> wrote:
>
> Hi Fangrui, Hi H.J.,
>
> > If the section group intention of .annobin.text is so that .annobin.text
> > can be discarded if the associated .text is discarded (--gc-sections),
> > an alternative is SHF_LINK_ORDER
>
>   Sorry to bother you with this, but I am having some troubles
>   getting to grip with using SHF_LINK_ORDER to eliminate unused
>   sections.  I create a small test file to compare using groups
>   and link_orders but it does not work as I would expect:
>
>   % cat eliminate.s
>         .text
>         .nop
>
>         .section .unused1, "ax", %progbits
>         .nop
>
>         .section .unused2, "axG", %progbits, unused_group
>         .nop
>
>         .section .gnu.note.text, "", %note
>         .word 1
>
>         .section .gnu.note1, "o", %note, .unused1
>         .word 2
>
>         .section .gnu.note2, "G", %note, unused_group
>         .word 3
>
>   % as eliminate.s -o elminate.o
>   % ld -e0 --gc-sections --print-gc-sections elminate.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 '.gnu.note2[unused_group]' 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
>
>   I thought that the sh_link from .gnu.note1 to .unused1 would mean that it
>   should be discarded when .unused1 is discarded.  But instead I get an
>   error.
>
>   I am probably doing something silly, but please could you point me in the
>   right direction ?
>

Please try this patch.

-- 
H.J.

[-- Attachment #2: 0001-elf-Also-check-linked-to-section-for-SHT_NOTE-sectio.patch --]
[-- Type: application/x-patch, Size: 2576 bytes --]

  parent reply	other threads:[~2020-09-30 13:43 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     ` H.J. Lu [this message]
2020-09-30 14:01       ` [PATCH] elf: Also check linked-to section for SHT_NOTE section Nick Clifton
2020-09-30 14:03         ` H.J. Lu
2020-10-01  3:41           ` Fangrui Song

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='CAMe9rOpZKx2tygA6_HTrcb44H=92mPNuuaq=6pBjRHBx3NHcZQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --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).