From: "Fāng-ruì Sòng" <maskray@google.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Fangrui Song via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Set the retain attribute on _elf_set_element if CC supports [BZ #27492]
Date: Mon, 15 Mar 2021 00:45:23 -0700 [thread overview]
Message-ID: <CAFP8O3LMfkUS0M_pAkr2822SJ2gStWSThQsdNeLEeb8a2h7vSA@mail.gmail.com> (raw)
In-Reply-To: <878s6ozxil.fsf@oldenburg.str.redhat.com>
On Mon, Mar 15, 2021 at 12:28 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Fangrui Song via Libc-alpha:
>
> > So that text_set_element/data_set_element/bss_set_element defined
> > variables will be retained by the linker.
> >
> > Note: 'used' and 'retain' are orthogonal: 'used' makes sure the variable
> > will not be optimized out; 'retain' prevents section garbage collection
> > if the linker support SHF_GNU_RETAIN.
>
> This needs recent-ish GCC 11, see commit 6347f4a0904fce17e ("Add retain
> attribute to place symbols in SHF_GNU_RETAIN section).
>
> > +#ifdef __has_attribute
> > +#if __has_attribute (retain)
> > +# ifdef SHARED
>
> Indentation is off there.
OK. I can increase the level of indentation...
> It's probably simpler to define a new macro, like
> ELEMENT_SECTION_ATTRIBUTES, and use that unconditionally, perhaps like
> this?
>
> #ifndef __ASSEMBLER__
> # if defined (__has_attribute) && __has_attribute (retain)
> # define ELEMENT_SECTION_ATTRIBUTES used, retain
> # else
> # define ELEMENT_SECTION_ATTRIBUTES used
> # endif
> #endif
`#ifdef __has_attribute` should be fine without #ifndef __ASSEMBLER__ ?
> Have you checked that __has_attribute (retain) is only true on GCC if
> the underlying linker has retain support and the attribute does not
> produce a warning?
There is a GCC bug. I've reported
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587
>
> Thanks,
> Florian
>
next prev parent reply other threads:[~2021-03-15 7:45 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 1:10 Fangrui Song
2021-03-15 7:28 ` Florian Weimer
2021-03-15 7:45 ` Fāng-ruì Sòng [this message]
2021-03-15 8:13 ` Florian Weimer
2021-03-22 4:00 ` [PATCH v2] " Fangrui Song
2021-03-22 4:24 ` H.J. Lu
2021-03-22 4:40 ` Fangrui Song
2021-03-22 20:28 ` H.J. Lu
2021-03-23 4:14 ` Fangrui Song
2021-03-29 23:11 ` H.J. Lu
2021-03-29 23:24 ` [PATCH v3] " Fangrui Song
2021-03-30 18:17 ` H.J. Lu
2021-03-30 19:17 ` Fāng-ruì Sòng
2021-03-30 19:30 ` H.J. Lu
2021-03-31 4:34 ` Fāng-ruì Sòng
2021-03-31 16:17 ` H.J. Lu
2021-03-31 18:09 ` Fāng-ruì Sòng
2021-03-31 18:57 ` H.J. Lu
2021-03-31 19:39 ` [PATCH v4] " Fangrui Song
2021-03-31 23:38 ` H.J. Lu
2021-04-01 0:02 ` Fangrui Song
2021-04-01 1:00 ` H.J. Lu
2021-04-01 1:06 ` [PATCH v5] " Fangrui Song
2021-04-01 12:52 ` H.J. Lu
2021-04-02 3:23 ` Fangrui Song
2021-04-02 14:14 ` H.J. Lu
2021-04-02 17:09 ` Fangrui Song
2021-04-02 17:33 ` H.J. Lu
2021-04-03 18:02 ` Fangrui Song
2021-04-03 20:47 ` H.J. Lu
2021-04-03 21:57 ` Fangrui Song
2021-04-05 1:55 ` H.J. Lu
2021-04-05 18:17 ` Fangrui Song
2021-04-05 20:35 ` H.J. Lu
2021-04-05 21:03 ` Fangrui Song
2021-04-05 21:58 ` H.J. Lu
2021-04-06 21:46 ` Fangrui Song
2021-04-09 22:36 ` Fāng-ruì Sòng
2021-04-16 3:51 ` Fāng-ruì Sòng
2021-04-16 13:00 ` H.J. Lu
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=CAFP8O3LMfkUS0M_pAkr2822SJ2gStWSThQsdNeLEeb8a2h7vSA@mail.gmail.com \
--to=maskray@google.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@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).