From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v2] Handle private COMDAT function symbol reference in readonly data section
Date: Wed, 31 Jan 2024 09:39:12 -0800 [thread overview]
Message-ID: <CAMe9rOq+pme8tideBK7gDUg0KBYkvDuzAk83kL3dC3UtkhckJw@mail.gmail.com> (raw)
In-Reply-To: <Zbp+52AiNrQMgbpx@tucnak>
On Wed, Jan 31, 2024 at 9:10 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Wed, Jan 31, 2024 at 08:48:33AM -0800, H.J. Lu wrote:
> > Which function (target hook) can I use to generate
> >
> > .section .data.rel.ro.local,"awG",@progbits,_ZN1AIxE3fooExx,comdat
>
> Just
> if (decl)
> return get_section (reloc == 1
> ? ".data.rel.ro.local" : ".data.rel.ro",
> SECTION_WRITE | SECTION_RELRO | SECTION_LINKONCE,
> decl);
> for the first hunk and
> else if (decl)
> return get_section (".rodata", SECTION_LINKONCE, decl);
> in the second case?
>
> Haven't tried it though, maybe the get_section section conflict stuff
> isn't able to handle it (and perhaps that is the reason why we simply don't
> emit functions into
> .section .text,"axG",@progbits,whatever,comdat
> sections instead of
> .section .text.function_name,"axG",@progbits,whatever,comdat
GNU binutils has no issues with it:
[hjl@gnu-cfl-3 tmp]$ cat x.s
.section .text,"axG",@progbits,whatever,comdat
nop
.text
nop
[hjl@gnu-cfl-3 tmp]$ gcc -c x.s
[hjl@gnu-cfl-3 tmp]$ readelf -SW x.o | grep text
[ 2] .text PROGBITS 0000000000000000 000048
000001 00 AX 0 0 1
[ 5] .text PROGBITS 0000000000000000 000049
000001 00 AXG 0 0 1
[hjl@gnu-cfl-3 tmp]$
If it doesn't work for some targets, we can use
targetm.asm_out.function_rodata_section.
> In such case, we could append something to those section names,
> like const.pool (or whatever else that couldn't clash with function names,
> so needs probably a dot somewhere). Could be
> .data.rel.ro.local.const.pool
> .data.rel.ro.const.pool
> or
> .data.rel.ro.local..shared
> .data.rel.ro..shared
> or something similar, but .data.rel.ro.local.shared would not be ok,
> because it could clash with .data.rel.ro.local section for shared function.
>
> > > Another question is if we need to do anything about the
> > > DECL_COMDAT_GROUP (decl) && DECL_SECTION_NAME (decl)
> > > && startswith (DECL_SECTION_NAME (decl), ".gnu.linkonce.t.")
> > > case (older linkers) (i.e. when using years old GNU linkers).
> > >
> >
> > Should we support such targets? It is not easy for me to test it.
>
> Perhaps let's wait if somebody files an issue with such configuration.
>
> Jakub
>
--
H.J.
next prev parent reply other threads:[~2024-01-31 17:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 2:21 H.J. Lu
2024-01-31 16:30 ` Jakub Jelinek
2024-01-31 16:48 ` H.J. Lu
2024-01-31 17:09 ` Jakub Jelinek
2024-01-31 17:39 ` H.J. Lu [this message]
2024-01-31 18:11 ` Jakub Jelinek
2024-01-31 18:58 ` [PATCH] varasm, v3: Handle private COMDAT function symbol reference in readonly data section [PR113617] Jakub Jelinek
2024-02-01 8:23 ` Jakub Jelinek
2024-01-31 19:31 ` [PATCH v2] Handle private COMDAT function symbol reference in readonly data section 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=CAMe9rOq+pme8tideBK7gDUg0KBYkvDuzAk83kL3dC3UtkhckJw@mail.gmail.com \
--to=hjl.tools@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@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).