unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer via Libc-alpha <libc-alpha@sourceware.org>
To: "Fāng-ruì Sòng" <maskray@google.com>
Cc: Fangrui Song via Libc-alpha <libc-alpha@sourceware.org>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: PING^2: [PATCH] elf: Avoid nested functions in the loader (all ports) [BZ #27220]
Date: Fri, 24 Sep 2021 00:00:49 +0200	[thread overview]
Message-ID: <875yurlzou.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20210922194450.mqwskdcrjyxfpd6f@google.com> ("Fāng-ruì Sòng"'s message of "Wed, 22 Sep 2021 12:44:50 -0700")

* Fāng-ruì Sòng:

> For folks who don't know me, I have pushed many Clang fixes to make
> glibc builds better, e.g.
> (Some were from my observation that some
> https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/google/grte/v5-2.27/master
> commits could be avoided by fixing Clang instead)
>
> * https://reviews.llvm.org/rGc841b9abf039ec0457752cd96f7e4716c1c7a323 "[MC][ELF] Don't create relocations with section symbols for STB_LOCAL ifunc"
> * https://reviews.llvm.org/D64283 PowerPC64 -mabi=ieeelongdouble (the heavy lift work is on IBM's side)
> * https://reviews.llvm.org/rGf931290308abd0eebecae385cd32ca3a25ddd9be [PowerPC] Parse and ignore .machine
> * https://reviews.llvm.org/D88625 better support for asm("memcpy = __GI_memcpy");
> * https://reviews.llvm.org/D88712 respect asm label for built-in functions

I very much appreciate that you have fixed those minor Clang
incompatibility problems that have been in a WONTFIX state for so long
(especially the last change).

> However, for
>
> void bar();
> void foo() { bar(); }
> void bar() asm("bar1");
>
> GCC happily redirects the bar call to bar1.
> Clang rejects this x.c:5:6: error: cannot apply asm label to function
> after its first use
> void bar() asm("bar1");
>      ^         ~~~~~~
>
> The issue is really to fix on Clang's side.
> (I spent many hours in a weekend for investigation and made the
> conclusion. Basically Clang does "parse decl A; codegen decl A; parse
> decl B; codegen decl B; ..." When it sees the asm label, it is too late
> to change the previous codegen.)

I think GCC used to call this function-at-a-time mode.

> This just needs some declaration reordering (the number of lines doesn't
> even need to increase) which is probably not a big burden on glibc's
> side.

This is a bit unfortunate.  I want to rework how we deal with hidden
prototypes (for PLT/relocation avoidance), so that what glibc does
becomes much more contributor-friendly.  In part I want to to this to
offset some of the maintenance cost I added with the preprocessor goo
for the libpthread merge.  What I want to do is to parse the installed
headers and automatically generate the aliases in a consistent fashion.
With GCC, I could add the aliases in a separate (wrapper) header.  To
support Clang, it looks like I would have to rewrite the header instead
of merely parsing it, which hopefully won't be too bad.

Does Clang support #pragma redefine_extname?  And can that be applied
*before* the declaration?  (We can't do that with __asm__ because we
don't know the appropriate prototype at this point.)  If there's nothing
that speaks against using #pragma redefine_extname, it might provide a
way to avoid ordering issues.

Thanks,
Florian


  reply	other threads:[~2021-09-23 22:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23  4:36 [PATCH] elf: Avoid nested functions in the loader (all ports) [BZ #27220] Fangrui Song via Libc-alpha
2021-09-03  5:41 ` Fāng-ruì Sòng via Libc-alpha
2021-09-03 10:09 ` Florian Weimer via Libc-alpha
2021-09-04  3:52   ` Fangrui Song via Libc-alpha
2021-09-13 16:36     ` Fāng-ruì Sòng via Libc-alpha
2021-09-20 17:55       ` PING^2: " Fāng-ruì Sòng via Libc-alpha
2021-09-22 17:53         ` Carlos O'Donell via Libc-alpha
2021-09-22 18:09           ` Joseph Myers
2021-09-22 18:20             ` Carlos O'Donell via Libc-alpha
2021-09-22 18:40               ` Fāng-ruì Sòng via Libc-alpha
2021-09-22 19:21                 ` Joseph Myers
2021-09-22 19:44                   ` Fāng-ruì Sòng via Libc-alpha
2021-09-23 22:00                     ` Florian Weimer via Libc-alpha [this message]
2021-09-23 22:14                       ` Fāng-ruì Sòng via Libc-alpha

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

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yurlzou.fsf@oldenburg.str.redhat.com \
    --to=libc-alpha@sourceware.org \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=maskray@google.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).