public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] Make clone3 shared-only [BZ #31770]
Date: Tue, 21 May 2024 05:55:57 -0700	[thread overview]
Message-ID: <CAMe9rOqudu=TdHtv2E50c-fawVj8r5BWAi2QYFb-iwU1zZ+wpA@mail.gmail.com> (raw)
In-Reply-To: <7bf33c04-aca0-4f26-bcdd-3b23b901aaa6@linaro.org>

On Tue, May 21, 2024 at 5:50 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 20/05/24 23:31, H.J. Lu wrote:
> > clone3 isn't exported from libc.so.  Fix BZ #31770 by making clone3
> > shared-only.
> >
> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> > ---
> >  sysdeps/unix/sysv/linux/Makefile | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> > index 415aa1f14d..233db08be7 100644
> > --- a/sysdeps/unix/sysv/linux/Makefile
> > +++ b/sysdeps/unix/sysv/linux/Makefile
> > @@ -112,6 +112,7 @@ sysdep_routines += \
> >    xstat \
> >    xstat64 \
> >    # sysdep_routines
> > +shared-only-routines += clone3
> >
> >  CFLAGS-gethostid.c = -fexceptions
> >  CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
>
> We need __clone3 for posix_spawn and pthread_create, so making it shared-only
> is not correct.  Wit this patch applied:
>
> $ make test t=posix/tst-spawn-static run-built-tests=no
> x86_64-glibc-linux-gnu-gcc -o /home/azanella/Projects/glibc/build/x86_64-linux-gnu/posix/tst-spawn-static -nostdlib -nostartfiles -static -static-pie [...]
> /home/azanella/toolchain/install/compilers/14/x86_64-linux-gnu/bin/../lib/gcc/x86_64-glibc-linux-gnu/14.1.1/../../../../x86_64-glibc-linux-gnu/bin/ld: /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.a(spawni.o): in function `__spawnix':
> /home/azanella/Projects/glibc/glibc-git/posix/../sysdeps/unix/sysv/linux/spawni.c:417:(.text+0x231): undefined reference to `__clone3'
> /home/azanella/toolchain/install/compilers/14/x86_64-linux-gnu/bin/../lib/gcc/x86_64-glibc-linux-gnu/14.1.1/../../../../x86_64-glibc-linux-gnu/bin/ld: /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.a(clone-internal.o): in function `__clone3_internal':
> [...]
>
> The correct approach is to remove the __clone3 to clone3 alias in
> *all* clone3.S implementations:

Can you review

https://patchwork.sourceware.org/project/glibc/list/?series=34172

Thanks.

> diff --git a/sysdeps/unix/sysv/linux/x86_64/clone3.S b/sysdeps/unix/sysv/linux/x86_64/clone3.S
> index 5a2d42234e..4cc19e066c 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/clone3.S
> +++ b/sysdeps/unix/sysv/linux/x86_64/clone3.S
> @@ -86,4 +86,3 @@ L(thread_start):
>  PSEUDO_END (__clone3)
>
>  libc_hidden_def (__clone3)
> -weak_alias (__clone3, clone3)
>
> Which results in:
>
> x86_64-linux-gnu$ readelf -sW libc.a | grep clone3
>     19: 0000000000000000     0 NOTYPE  GLOBAL HIDDEN   UND __clone3
>      4: 0000000000000000     4 OBJECT  LOCAL  DEFAULT    3 clone3_supported.0
>     15: 0000000000000060   137 FUNC    GLOBAL HIDDEN     1 __clone3_internal
>     16: 0000000000000000     0 NOTYPE  GLOBAL HIDDEN   UND __clone3
> File: libc.a(clone3.o)
>      7: 0000000000000000    71 FUNC    GLOBAL DEFAULT    1 __clone3



-- 
H.J.

      reply	other threads:[~2024-05-21 12:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21  2:31 H.J. Lu
2024-05-21 12:50 ` Adhemerval Zanella Netto
2024-05-21 12:55   ` H.J. Lu [this message]

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='CAMe9rOqudu=TdHtv2E50c-fawVj8r5BWAi2QYFb-iwU1zZ+wpA@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --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).