diff mbox series

[RFC,v12,7/8] Restore separate libc loading for the TLS/namespace storage test

Message ID 20210708163255.812-8-vivek@collabora.com
State New
Headers show
Series Implementation of RTLD_SHARED for dlmopen | expand

Commit Message

Vivek Dasmohapatra July 8, 2021, 4:32 p.m. UTC
tst-tls-ie-dlmopen checks to see that new namespaces consume
TLS memory as expected: This does not happen when new namespaces
share the same libc instance (since TLS is allocated only when
a new libc instance insitialises its threading infrastructure).

Adding RTLD_ISOLATE to the dlmopen flags in the test restores
the old behaviour which allows the test to check what it
actually needs to.
---
 elf/tst-tls-ie-dlmopen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Adhemerval Zanella Aug. 9, 2021, 7:08 p.m. UTC | #1
On 08/07/2021 13:32, Vivek Das Mohapatra via Libc-alpha wrote:
> tst-tls-ie-dlmopen checks to see that new namespaces consume
> TLS memory as expected: This does not happen when new namespaces
> share the same libc instance (since TLS is allocated only when
> a new libc instance insitialises its threading infrastructure).
> 
> Adding RTLD_ISOLATE to the dlmopen flags in the test restores
> the old behaviour which allows the test to check what it
> actually needs to.

LGTM, but this patch should be merged with the
'Implement dlmopen RTLD_SHARED flag (bug 22745)' one to be logically
consistent.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  elf/tst-tls-ie-dlmopen.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/elf/tst-tls-ie-dlmopen.c b/elf/tst-tls-ie-dlmopen.c
> index a579d72d2d..e67017db2d 100644
> --- a/elf/tst-tls-ie-dlmopen.c
> +++ b/elf/tst-tls-ie-dlmopen.c
> @@ -53,7 +53,7 @@ static void *
>  load_and_access (Lmid_t lmid, const char *mod, const char *func)
>  {
>    /* Load module with TLS.  */
> -  void *p = xdlmopen (lmid, mod, RTLD_NOW);
> +  void *p = xdlmopen (lmid, mod, RTLD_NOW|RTLD_ISOLATE);
>    /* Access the TLS variable to ensure it is allocated.  */
>    void (*f) (void) = (void (*) (void))xdlsym (p, func);
>    f ();
> @@ -95,7 +95,7 @@ do_test (void)
>       than 1024 bytes are available (exact number depends on TLS optimizations
>       and the libc TLS use).  */
>    printf ("The next dlmopen should fail...\n");
> -  void *p = dlmopen (LM_ID_BASE, "tst-tls-ie-mod4.so", RTLD_NOW);
> +  void *p = dlmopen (LM_ID_BASE, "tst-tls-ie-mod4.so", RTLD_NOW|RTLD_ISOLATE);
>    if (p != NULL)
>      FAIL_EXIT1 ("error: expected dlmopen to fail because there is "
>  		"not enough surplus static TLS.\n");
>
diff mbox series

Patch

diff --git a/elf/tst-tls-ie-dlmopen.c b/elf/tst-tls-ie-dlmopen.c
index a579d72d2d..e67017db2d 100644
--- a/elf/tst-tls-ie-dlmopen.c
+++ b/elf/tst-tls-ie-dlmopen.c
@@ -53,7 +53,7 @@  static void *
 load_and_access (Lmid_t lmid, const char *mod, const char *func)
 {
   /* Load module with TLS.  */
-  void *p = xdlmopen (lmid, mod, RTLD_NOW);
+  void *p = xdlmopen (lmid, mod, RTLD_NOW|RTLD_ISOLATE);
   /* Access the TLS variable to ensure it is allocated.  */
   void (*f) (void) = (void (*) (void))xdlsym (p, func);
   f ();
@@ -95,7 +95,7 @@  do_test (void)
      than 1024 bytes are available (exact number depends on TLS optimizations
      and the libc TLS use).  */
   printf ("The next dlmopen should fail...\n");
-  void *p = dlmopen (LM_ID_BASE, "tst-tls-ie-mod4.so", RTLD_NOW);
+  void *p = dlmopen (LM_ID_BASE, "tst-tls-ie-mod4.so", RTLD_NOW|RTLD_ISOLATE);
   if (p != NULL)
     FAIL_EXIT1 ("error: expected dlmopen to fail because there is "
 		"not enough surplus static TLS.\n");