From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH 04/10] elf: Use custom NODELETE DSO for tst-dlopenfail, tst-dlopenfail-2
Date: Thu, 20 May 2021 17:36:49 -0300 [thread overview]
Message-ID: <7e610729-8695-974b-99a2-4ee2d8670611@linaro.org> (raw)
In-Reply-To: <7f53b7fc5e9cbc1bc6fdc15429d50e995e5fbb66.1621347402.git.fweimer@redhat.com>
On 18/05/2021 11:25, Florian Weimer via Libc-alpha wrote:
> Once libpthread is removed, it no longer can be used for testing.
Looks good in general, just some comments below regarding the test
change.
> ---
> elf/Makefile | 11 +++++++--
> elf/tst-dlopenfail-2.c | 5 +---
> elf/tst-dlopenfail.c | 44 ++++++++++++++----------------------
> elf/tst-dlopenfailmod2.c | 6 ++---
> elf/tst-dlopenfailnodelmod.c | 29 ++++++++++++++++++++++++
> 5 files changed, 59 insertions(+), 36 deletions(-)
> create mode 100644 elf/tst-dlopenfailnodelmod.c
>
> diff --git a/elf/Makefile b/elf/Makefile
> index 5e809dbfaa..834ec858a8 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -334,7 +334,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
> tst-auditmanymod7 tst-auditmanymod8 tst-auditmanymod9 \
> tst-initlazyfailmod tst-finilazyfailmod \
> tst-dlopenfailmod1 tst-dlopenfaillinkmod tst-dlopenfailmod2 \
> - tst-dlopenfailmod3 tst-ldconfig-ld-mod \
> + tst-dlopenfailmod3 tst-dlopenfailnodelmod tst-ldconfig-ld-mod \
> tst-filterobj-flt tst-filterobj-aux tst-filterobj-filtee \
> tst-auditlogmod-1 tst-auditlogmod-2 tst-auditlogmod-3 \
> tst-single_threaded-mod1 tst-single_threaded-mod2 \
> @@ -1733,11 +1733,18 @@ LDFLAGS-tst-dlopenfailmod1.so = -Wl,--no-as-needed
> $(objpfx)tst-dlopenfailmod1.so: \
> $(shared-thread-library) $(objpfx)tst-dlopenfaillinkmod.so
> LDFLAGS-tst-dlopenfaillinkmod.so = -Wl,-soname,tst-dlopenfail-missingmod.so
> -$(objpfx)tst-dlopenfailmod2.so: $(shared-thread-library)
> +$(objpfx)tst-dlopenfailmod2.so: $(objpfx)tst-dlopenfailnodelmod.so
> $(objpfx)tst-dlopenfail-2: $(libdl)
> $(objpfx)tst-dlopenfail-2.out: \
> $(objpfx)tst-dlopenfailmod1.so $(objpfx)tst-dlopenfailmod2.so \
> $(objpfx)tst-dlopenfailmod3.so
Ok.
> +# tst-dlopenfailnodelmod.so emulates how libpthread was linked.
> +$(objpfx)tst-dlopenfailnodelmod.so: $(libsupport)
> +LDFLAGS-tst-dlopenfailnodelmod.so = \
> + -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
> +# tst-dlopenfail should export the libsupport symbols, so that
> +# tst-dlopenfailnodelmod.so uses them for error reporting.
> +LDFLAGS-tst-dlopenfail = -Wl,-E
>
> $(objpfx)tst-dlopen-nodelete-reloc: $(libdl)
> $(objpfx)tst-dlopen-nodelete-reloc.out: \
Ok.
> diff --git a/elf/tst-dlopenfail-2.c b/elf/tst-dlopenfail-2.c
> index 50eed81cb0..168c4b2c7f 100644
> --- a/elf/tst-dlopenfail-2.c
> +++ b/elf/tst-dlopenfail-2.c
> @@ -28,10 +28,7 @@
> static int
> do_test (void)
> {
> - /* This test uses libpthread as the canonical NODELETE module. If
> - libpthread is no longer NODELETE because it has been merged into
> - libc, the test needs to be updated. */
> - TEST_VERIFY (dlsym (NULL, "pthread_create") == NULL);
> + TEST_VERIFY (dlsym (NULL, "no_delete_mod_function") == NULL);
>
> /* This is expected to fail because of the missing dependency. */
> puts ("info: attempting to load tst-dlopenfailmod1.so");
Ok.
> diff --git a/elf/tst-dlopenfail.c b/elf/tst-dlopenfail.c
> index db2b41f9b5..990e28dbce 100644
> --- a/elf/tst-dlopenfail.c
> +++ b/elf/tst-dlopenfail.c
> @@ -18,7 +18,6 @@
>
> #include <dlfcn.h>
> #include <errno.h>
> -#include <gnu/lib-names.h>
> #include <stddef.h>
> #include <stdio.h>
> #include <string.h>
> @@ -28,10 +27,7 @@
> static int
> do_test (void)
> {
> - /* This test uses libpthread as the canonical NODELETE module. If
> - libpthread is no longer NODELETE because it has been merged into
> - libc, the test needs to be updated. */
> - TEST_VERIFY (dlsym (NULL, "pthread_create") == NULL);
> + TEST_VERIFY (dlsym (NULL, "no_delete_mod_function") == NULL);
>
> /* This is expected to fail because of the missing dependency. */
> puts ("info: attempting to load tst-dlopenfailmod1.so");
Ok.
> @@ -42,36 +38,30 @@ do_test (void)
> " cannot open shared object file:"
> " No such file or directory");
>
> - /* Do not probe for the presence of libpthread at this point because
> - that might trigger relocation if bug 20839 is present, obscuring
> - a subsequent crash. */
> + /* Do not probe for the presence of the tst-dlopenfailnodelmod.so at
> + this point because that might trigger relocation if bug 20839 is
> + present, obscuring a subsequent crash. */
>
> /* This is expected to succeed. */
> puts ("info: loading tst-dlopenfailmod2.so");
> void *handle = xdlopen ("tst-dlopenfailmod2.so", RTLD_NOW);
> + xdlsym (handle, "no_delete_mod_function");
> xdlclose (handle);
>
> - /* libpthread should remain loaded. */
> - TEST_VERIFY (dlopen (LIBPTHREAD_SO, RTLD_LAZY | RTLD_NOLOAD) != NULL);
> - TEST_VERIFY (dlsym (NULL, "pthread_create") == NULL);
> + /* The NODELETE module should remain loaded. */
> + xdlopen ("tst-dlopenfailnodelmod.so", RTLD_LAZY | RTLD_NOLOAD);
> + /* But the symbol is not in the global scope. */
No sure if this is an improvement, the failure message will be triggered
in the libsupport not in the test itself.
> + TEST_VERIFY (dlsym (NULL, "no_delete_mod_function") == NULL);
>
> - /* We can make libpthread global, and then the symbol should become
> - available. */
> - TEST_VERIFY (dlopen (LIBPTHREAD_SO, RTLD_LAZY | RTLD_GLOBAL) != NULL);
> - TEST_VERIFY (dlsym (NULL, "pthread_create") != NULL);
> + /* We can make tst-dlopenfailnodelmod.so global, and then the symbol
> + should become available. */
> + xdlopen ("tst-dlopenfailnodelmod.so", RTLD_LAZY | RTLD_GLOBAL);
> + void (*no_delete_mod_function) (void)
> + = xdlsym (NULL, "no_delete_mod_function");
>
Same as before.
> - /* sem_open is sufficiently complex to depend on relocations. */
> - void *(*sem_open_ptr) (const char *, int flag, ...)
> - = dlsym (NULL, "sem_open");
> - if (sem_open_ptr == NULL)
> - /* Hurd does not implement sem_open. */
> - puts ("warning: sem_open not found, further testing not possible");
> - else
> - {
> - errno = 0;
> - TEST_VERIFY (sem_open_ptr ("/", 0) == NULL);
> - TEST_COMPARE (errno, EINVAL);
> - }
> + /* Hopefully, no_delete_mod_function is sufficiently complex to
> + depend on relocations. */
> + no_delete_mod_function ();
>
> return 0;
> }
Ok.
> diff --git a/elf/tst-dlopenfailmod2.c b/elf/tst-dlopenfailmod2.c
> index cd6f9cf56b..ed353f9a3c 100644
> --- a/elf/tst-dlopenfailmod2.c
> +++ b/elf/tst-dlopenfailmod2.c
> @@ -16,11 +16,11 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> -#include <pthread.h>
> #include <stdio.h>
>
> -/* Force linking against libpthread. */
> -void *pthread_create_reference = pthread_create;
> +/* Force linking against tst-dlopenfailnodelmod.so. */
> +void no_delete_mod_function (void);
> +void *function_reference = no_delete_mod_function;
>
> static void __attribute__ ((constructor))
> init (void)
Ok.
> diff --git a/elf/tst-dlopenfailnodelmod.c b/elf/tst-dlopenfailnodelmod.c
> new file mode 100644
> index 0000000000..c4347b7591
> --- /dev/null
> +++ b/elf/tst-dlopenfailnodelmod.c
> @@ -0,0 +1,29 @@
> +/* NODELETE module for tst-dlopenfail, tst-dlopenfail-2.
> + Copyright (C) 2021 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <support/check.h>
> +
> +/* Introduce some relocation dependencies. */
> +const char test_string[] = "test string";
> +const char *test_string_ptr = test_string;
> +
> +void
> +no_delete_mod_function (void)
> +{
> + TEST_COMPARE_STRING (test_string, test_string_ptr);
> +}
>
Ok.
next prev parent reply other threads:[~2021-05-20 20:36 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-18 14:24 [PATCH 00/10] nptl: Complete libpthread removal Florian Weimer
2021-05-18 14:24 ` [PATCH 01/10] nptl: Perform signal initialization upon pthread_create Florian Weimer
2021-05-20 19:15 ` Adhemerval Zanella
2021-05-20 19:41 ` Florian Weimer
2021-05-20 19:57 ` Adhemerval Zanella
2021-05-20 20:05 ` Florian Weimer
2021-05-20 20:32 ` Adhemerval Zanella
2021-05-21 9:58 ` Florian Weimer
2021-05-21 11:31 ` Adhemerval Zanella
2021-05-21 12:40 ` Adhemerval Zanella
2021-05-18 14:24 ` [PATCH 02/10] nptl: Eliminate the __static_tls_size, __static_tls_align_m1 variables Florian Weimer
2021-05-18 14:25 ` [PATCH 03/10] nptl: Move semi-public __pthread_get_minstack symbol into libc Florian Weimer
2021-05-18 14:25 ` [PATCH 04/10] elf: Use custom NODELETE DSO for tst-dlopenfail, tst-dlopenfail-2 Florian Weimer
2021-05-20 20:36 ` Adhemerval Zanella [this message]
2021-05-18 14:25 ` [PATCH 05/10] nptl: Move pthread_create, thrd_create into libc Florian Weimer
2021-05-20 20:44 ` Adhemerval Zanella
2021-05-18 14:25 ` [PATCH 06/10] nptl: Remove unused __libc_pthread_init function Florian Weimer
2021-05-18 14:49 ` Andreas Schwab
2021-05-18 14:25 ` [PATCH 07/10] nptl: Remove remaining code from libpthread Florian Weimer
2021-05-20 20:49 ` Adhemerval Zanella
2021-05-18 14:25 ` [PATCH 08/10] elf: Do not load libpthread for PTHREAD_IN_LIBC Florian Weimer
2021-05-20 20:53 ` Adhemerval Zanella
2021-05-21 19:15 ` Florian Weimer
2021-05-18 14:25 ` [PATCH 09/10] elf: Add facility to create stub DSOs in elf/stub-dsos Florian Weimer
2021-05-24 18:24 ` Adhemerval Zanella
2021-05-24 18:25 ` Adhemerval Zanella
2021-05-18 14:25 ` [PATCH 10/10] nptl: Stop building libpthread Florian Weimer
2021-05-18 14:56 ` [PATCH 00/10] nptl: Complete libpthread removal Andreas Schwab
2021-05-18 15:04 ` Florian Weimer
2021-05-18 15:26 ` Andreas Schwab
2021-05-18 15:51 ` Florian Weimer
2021-05-18 16:27 ` Andreas Schwab
2021-05-18 16:31 ` Florian Weimer
2021-05-18 16:47 ` Andreas Schwab
2021-05-20 13:27 ` Florian Weimer
2021-05-20 13:50 ` Andreas Schwab
2021-05-20 13:54 ` Florian Weimer
2021-05-20 14:01 ` Andreas Schwab
2021-05-20 15:09 ` H.J. Lu
2021-05-20 15:13 ` Florian Weimer
2021-05-20 15:17 ` Andreas Schwab
2021-05-20 15:35 ` H.J. Lu
2021-05-20 15:39 ` Florian Weimer
2021-05-20 15:57 ` H.J. Lu
2021-05-19 11:57 ` Szabolcs Nagy
2021-05-19 12:35 ` Florian Weimer
2021-05-19 13:14 ` Szabolcs Nagy
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=7e610729-8695-974b-99a2-4ee2d8670611@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.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).