public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <i@maskray.me>
To: binutils@sourceware.org
Subject: Re: [PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag
Date: Mon, 28 Sep 2020 21:43:53 -0700	[thread overview]
Message-ID: <20200929044353.vx26ypc2oioqbmfb@gmail.com> (raw)
In-Reply-To: <20200928132613.btkqaoomv4fdnupn@jozef-acer-manjaro>

On 2020-09-28, Jozef Lawrynowicz wrote:
>The attached patch is version 2 of the SHF_GNU_RETAIN patch that was
>previously discussed here:
>https://sourceware.org/pipermail/binutils/2020-September/113406.html
>
>The following changes have been made:
>- Removed the .retain directive
>- The assembler will create different input sections for sections with
>  the same name but SHF_GNU_RETAIN set/unset (thanks to H.J. for that).
>  This means the linker will be able to do a better job garbage
>  collecting input sections, as the "retain" attribute applied to a
>  symbol declaration in the source code will not cause other parts of
>  the program that are not required, but are in the same section, to be
>  unnecessarily retained.
>- Added GNU OSABI handling (also thanks to H.J.).

My point from https://sourceware.org/pipermail/binutils/2020-September/113466.html stands.
Section flags are a bit cumbersome. If the following 

   // a.h
   __attribute__((section("sec")))
   inline void bar() { ... }
   // a.c
   #include "a.h"
   
   __attribute__((section("sec"), retain))
   void foo() {
   }

compiles to

   .section sec,"a",@progbits
   ...
   .section sec,"aR",@progbits
   ...

You will get a gas error for changing section flags
(https://sourceware.org/pipermail/binutils/2020-February/109945.html)

.reloc is really convenience in this case. You can add as many .reloc
directives as you like, each contributing one R_*_NONE to the object
file but zero cost to the linked image.

  reply	other threads:[~2020-09-29  4:43 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 [this message]
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

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=20200929044353.vx26ypc2oioqbmfb@gmail.com \
    --to=i@maskray.me \
    --cc=binutils@sourceware.org \
    /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).