unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Fāng-ruì Sòng via Libc-alpha" <libc-alpha@sourceware.org>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	Fangrui Song via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: PING^2: [PATCH] elf: Avoid nested functions in the loader (all ports) [BZ #27220]
Date: Wed, 22 Sep 2021 12:44:50 -0700	[thread overview]
Message-ID: <20210922194450.mqwskdcrjyxfpd6f@google.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2109221918010.37774@digraph.polyomino.org.uk>

On 2021-09-22, Joseph Myers wrote:
>On Wed, 22 Sep 2021, Fāng-ruì Sòng via Libc-alpha wrote:
>
>> I went ahead and filed https://sourceware.org/bugzilla/show_bug.cgi?id=28376
>> "[meta] Build glibc with Clang"
>> to collect miscellaneous small fixes.
>
>Note also that issues regarding use of glibc installed headers should
>probably be handled separately (with a separate meta-bug to depend on
>them; we already have a few such bugs open, e.g. 26287).  The key
>difference there is that installed headers should support a wide range of
>compilers, including old versions.  Whereas for issues building glibc, the
>conclusion in some cases may well be that a change should be made to
>Clang, and only new versions with that fix supported, rather than working
>around a limitation in existing Clang versions.

Sure! Changes need to be assessed where they belong to, Clang or glibc.

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

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.)

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.

I hope glibc can be lenient in such a situation where Clang fixes may
not be feasible.

>> About the global variables (cur_*): they are in elf/dl-reloc.c
>>
>> -    /* String table object symbols.  */
>> -    const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
>> +    cur_l = l;
>> +    cur_scope = scope;
>> +    cur_strtab = (const void *) D_PTR (cur_l, l_info[DT_STRTAB]);
>>
>> removing them requires more parameters to ELF_DYNAMIC_RELOCATE and
>> RESOLVE_MAP.
>> Is that the direction you are imagining?
>
>Yes.  Explicit parameters (whether individual parameters or in a struct)
>seems cleaner than using global state to pass parameters.

Thanks for the confirmation. I will take a stab.

  reply	other threads:[~2021-09-22 19:45 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 [this message]
2021-09-23 22:00                     ` Florian Weimer via Libc-alpha
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=20210922194450.mqwskdcrjyxfpd6f@google.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).