public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v4 1/3] ld.so: Export tls_init_tp_called as __rtld_tls_init_tp_called
Date: Wed, 26 Oct 2022 16:34:34 -0400	[thread overview]
Message-ID: <25e120b4-2141-cef7-d721-93cf3c8c9672@gotplt.org> (raw)
In-Reply-To: <08163a7b1e71d42325dfa3baeec3193268729771.1661775887.git.fweimer@redhat.com>



On 2022-08-29 08:26, Florian Weimer via Libc-alpha wrote:
> This allows the rest of dynamic loader to check whether the TCB
> has been set up (and THREAD_GETMEM and THREAD_SETMEM will work).
> ---
>   elf/rtld.c                 | 10 +++++-----
>   sysdeps/generic/ldsodefs.h |  3 +++
>   2 files changed, 8 insertions(+), 5 deletions(-)

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@gotplt.org>

> 
> diff --git a/elf/rtld.c b/elf/rtld.c
> index cbbaf4a331..714434b21d 100644
> --- a/elf/rtld.c
> +++ b/elf/rtld.c
> @@ -730,7 +730,7 @@ match_version (const char *string, struct link_map *map)
>     return 0;
>   }
>   
> -static bool tls_init_tp_called;
> +bool __rtld_tls_init_tp_called;
>   
>   static void *
>   init_tls (size_t naudit)
> @@ -800,7 +800,7 @@ cannot allocate TLS data structures for initial thread\n");
>     if (__glibc_unlikely (lossage != NULL))
>       _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage);
>     __tls_init_tp ();
> -  tls_init_tp_called = true;
> +  __rtld_tls_init_tp_called = true;
>   
>     return tcbp;
>   }
> @@ -2050,7 +2050,7 @@ dl_main (const ElfW(Phdr) *phdr,
>        an old kernel that can't perform TLS_INIT_TP, even if no TLS is ever
>        used.  Trying to do it lazily is too hairy to try when there could be
>        multiple threads (from a non-TLS-using libpthread).  */
> -  bool was_tls_init_tp_called = tls_init_tp_called;
> +  bool was_tls_init_tp_called = __rtld_tls_init_tp_called;
>     if (tcbp == NULL)
>       tcbp = init_tls (0);
>   
> @@ -2315,7 +2315,7 @@ dl_main (const ElfW(Phdr) *phdr,
>   			       consider_profiling);
>   
>   	/* Add object to slot information data if necessasy.  */
> -	if (l->l_tls_blocksize != 0 && tls_init_tp_called)
> +	if (l->l_tls_blocksize != 0 && __rtld_tls_init_tp_called)
>   	  _dl_add_to_slotinfo (l, true);
>         }
>     }
> @@ -2341,7 +2341,7 @@ dl_main (const ElfW(Phdr) *phdr,
>     _dl_allocate_tls_init (tcbp, false);
>   
>     /* And finally install it for the main thread.  */
> -  if (! tls_init_tp_called)
> +  if (! __rtld_tls_init_tp_called)
>       {
>         const char *lossage = TLS_INIT_TP (tcbp);
>         if (__glibc_unlikely (lossage != NULL))
> diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
> index 050a3032de..fc81affed0 100644
> --- a/sysdeps/generic/ldsodefs.h
> +++ b/sysdeps/generic/ldsodefs.h
> @@ -1217,6 +1217,9 @@ extern void *_dl_allocate_tls_storage (void) attribute_hidden;
>   extern void *_dl_allocate_tls_init (void *, bool);
>   rtld_hidden_proto (_dl_allocate_tls_init)
>   
> +/* True if the TCB has been set up.  */
> +extern bool __rtld_tls_init_tp_called attribute_hidden;
> +
>   /* Deallocate memory allocated with _dl_allocate_tls.  */
>   extern void _dl_deallocate_tls (void *tcb, bool dealloc_tcb);
>   rtld_hidden_proto (_dl_deallocate_tls)

  reply	other threads:[~2022-10-26 20:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 12:26 [PATCH v4 0/3] Rework exception handling in the dynamic loader [BZ #25486] Florian Weimer
2022-08-29 12:26 ` [PATCH v4 1/3] ld.so: Export tls_init_tp_called as __rtld_tls_init_tp_called Florian Weimer
2022-10-26 20:34   ` Siddhesh Poyarekar [this message]
2022-08-29 12:26 ` [PATCH v4 2/3] scripts/localplt.awk: Handle DT_JMPREL with empty PLT (for C-SKY) Florian Weimer
2022-10-26 20:34   ` Siddhesh Poyarekar
2022-08-29 12:27 ` [PATCH v4 3/3] elf: Rework exception handling in the dynamic loader [BZ #25486] Florian Weimer
2022-10-26 20:34   ` Siddhesh Poyarekar
2022-10-27  9:46     ` Florian Weimer

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=25e120b4-2141-cef7-d721-93cf3c8c9672@gotplt.org \
    --to=siddhesh@gotplt.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).