aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2024-08-01 23:31:23 +0200
committerFlorian Weimer <fweimer@redhat.com>2024-09-09 21:15:23 +0200
commite3d5d2d3508faeb8545f871a419f4ac46fa16df2 (patch)
treefeeed949e4e584459da3da63e9d8431e0c79926f /elf
parent28c4f32f71c4cdd8549842c646819538206ba3a6 (diff)
downloadglibc-e3d5d2d3508faeb8545f871a419f4ac46fa16df2.zip
glibc-e3d5d2d3508faeb8545f871a419f4ac46fa16df2.tar.gz
glibc-e3d5d2d3508faeb8545f871a419f4ac46fa16df2.tar.bz2
elf: Clarify and invert second argument of _dl_allocate_tls_init
Also remove an outdated comment: _dl_allocate_tls_init is called as part of pthread_create. Reviewed-by: Carlos O'Donell <carlos@redhat.com> (cherry picked from commit fe06fb313bddf7e4530056897d4a706606e49377)
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-tls.c13
-rw-r--r--elf/rtld.c2
2 files changed, 10 insertions, 5 deletions
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 3d22127..ecb966d 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -552,9 +552,14 @@ _dl_resize_dtv (dtv_t *dtv, size_t max_modid)
/* Allocate initial TLS. RESULT should be a non-NULL pointer to storage
for the TLS space. The DTV may be resized, and so this function may
call malloc to allocate that space. The loader's GL(dl_load_tls_lock)
- is taken when manipulating global TLS-related data in the loader. */
+ is taken when manipulating global TLS-related data in the loader.
+
+ If MAIN_THREAD, this is the first call during process
+ initialization. In this case, TLS initialization for secondary
+ (audit) namespaces is skipped because that has already been handled
+ by dlopen. */
void *
-_dl_allocate_tls_init (void *result, bool init_tls)
+_dl_allocate_tls_init (void *result, bool main_thread)
{
if (result == NULL)
/* The memory allocation failed. */
@@ -633,7 +638,7 @@ _dl_allocate_tls_init (void *result, bool init_tls)
because it would already be set by the audit setup. However,
subsequent thread creation would need to follow the default
behaviour. */
- if (map->l_ns != LM_ID_BASE && !init_tls)
+ if (map->l_ns != LM_ID_BASE && main_thread)
continue;
memset (__mempcpy (dest, map->l_tls_initimage,
map->l_tls_initimage_size), '\0',
@@ -661,7 +666,7 @@ _dl_allocate_tls (void *mem)
{
return _dl_allocate_tls_init (mem == NULL
? _dl_allocate_tls_storage ()
- : allocate_dtv (mem), true);
+ : allocate_dtv (mem), false);
}
rtld_hidden_def (_dl_allocate_tls)
diff --git a/elf/rtld.c b/elf/rtld.c
index 4b01e93..3ca9a11 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -2337,7 +2337,7 @@ dl_main (const ElfW(Phdr) *phdr,
into the main thread's TLS area, which we allocated above.
Note: thread-local variables must only be accessed after completing
the next step. */
- _dl_allocate_tls_init (tcbp, false);
+ _dl_allocate_tls_init (tcbp, true);
/* And finally install it for the main thread. */
if (! __rtld_tls_init_tp_called)