From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: "H.J. Lu" <hjl.tools@gmail.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH] Make clone3 shared-only [BZ #31770]
Date: Tue, 21 May 2024 09:50:38 -0300 [thread overview]
Message-ID: <7bf33c04-aca0-4f26-bcdd-3b23b901aaa6@linaro.org> (raw)
In-Reply-To: <20240521023139.1670459-1-hjl.tools@gmail.com>
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:
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
next prev parent reply other threads:[~2024-05-21 12:50 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 [this message]
2024-05-21 12:55 ` 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=7bf33c04-aca0-4f26-bcdd-3b23b901aaa6@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=hjl.tools@gmail.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).