From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 11/23] elf: Move static TLS size and alignment into _rtld_global_ro
Date: Wed, 12 May 2021 18:58:10 +0200 [thread overview]
Message-ID: <310d3f42a889e5fd9651cd1be3917f490666630c.1620838411.git.fweimer@redhat.com> (raw)
In-Reply-To: <cover.1620838411.git.fweimer@redhat.com>
This helps to clarify that the caching of these fields in libpthread
(in __static_tls_size, __static_tls_align_m1) is unnecessary.
---
elf/dl-reloc.c | 6 +++---
elf/dl-tls.c | 22 +++++++++++-----------
elf/rtld_static_init.c | 6 ++++++
sysdeps/generic/ldsodefs.h | 10 ++++++----
4 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index bb9ca1a101..e13a672ade 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -53,14 +53,14 @@ _dl_try_allocate_static_tls (struct link_map *map, bool optional)
/* If we've already used the variable with dynamic access, or if the
alignment requirements are too high, fail. */
if (map->l_tls_offset == FORCED_DYNAMIC_TLS_OFFSET
- || map->l_tls_align > GL(dl_tls_static_align))
+ || map->l_tls_align > GLRO (dl_tls_static_align))
{
fail:
return -1;
}
#if TLS_TCB_AT_TP
- size_t freebytes = GL(dl_tls_static_size) - GL(dl_tls_static_used);
+ size_t freebytes = GLRO (dl_tls_static_size) - GL(dl_tls_static_used);
if (freebytes < TLS_TCB_SIZE)
goto fail;
freebytes -= TLS_TCB_SIZE;
@@ -89,7 +89,7 @@ _dl_try_allocate_static_tls (struct link_map *map, bool optional)
+ map->l_tls_firstbyte_offset);
size_t used = offset + map->l_tls_blocksize;
- if (used > GL(dl_tls_static_size))
+ if (used > GLRO (dl_tls_static_size))
goto fail;
/* Account optional static TLS surplus usage. */
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 67781bc108..91031c2b72 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -300,9 +300,9 @@ _dl_determine_tlsoffset (void)
}
GL(dl_tls_static_used) = offset;
- GL(dl_tls_static_size) = (roundup (offset + GLRO(dl_tls_static_surplus),
- max_align)
- + TLS_TCB_SIZE);
+ GLRO (dl_tls_static_size) = (roundup (offset + GLRO(dl_tls_static_surplus),
+ max_align)
+ + TLS_TCB_SIZE);
#elif TLS_DTV_AT_TP
/* The TLS blocks start right after the TCB. */
size_t offset = TLS_TCB_SIZE;
@@ -345,14 +345,14 @@ _dl_determine_tlsoffset (void)
}
GL(dl_tls_static_used) = offset;
- GL(dl_tls_static_size) = roundup (offset + GLRO(dl_tls_static_surplus),
- TLS_TCB_ALIGN);
+ GLRO (dl_tls_static_size) = roundup (offset + GLRO(dl_tls_static_surplus),
+ TLS_TCB_ALIGN);
#else
# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
#endif
/* The alignment requirement for the static TLS block. */
- GL(dl_tls_static_align) = max_align;
+ GLRO (dl_tls_static_align) = max_align;
}
#endif /* SHARED */
@@ -391,8 +391,8 @@ allocate_dtv (void *result)
void
_dl_get_tls_static_info (size_t *sizep, size_t *alignp)
{
- *sizep = GL(dl_tls_static_size);
- *alignp = GL(dl_tls_static_align);
+ *sizep = GLRO (dl_tls_static_size);
+ *alignp = GLRO (dl_tls_static_align);
}
/* Derive the location of the pointer to the start of the original
@@ -416,7 +416,7 @@ void *
_dl_allocate_tls_storage (void)
{
void *result;
- size_t size = GL(dl_tls_static_size);
+ size_t size = GLRO (dl_tls_static_size);
#if TLS_DTV_AT_TP
/* Memory layout is:
@@ -427,7 +427,7 @@ _dl_allocate_tls_storage (void)
/* Perform the allocation. Reserve space for the required alignment
and the pointer to the original allocation. */
- size_t alignment = GL(dl_tls_static_align);
+ size_t alignment = GLRO (dl_tls_static_align);
void *allocated = malloc (size + alignment + sizeof (void *));
if (__glibc_unlikely (allocated == NULL))
return NULL;
@@ -436,7 +436,7 @@ _dl_allocate_tls_storage (void)
#if TLS_TCB_AT_TP
/* The TCB follows the TLS blocks, which determine the alignment.
(TCB alignment requirements have been taken into account when
- calculating GL(dl_tls_static_align).) */
+ calculating GLRO (dl_tls_static_align).) */
void *aligned = (void *) roundup ((uintptr_t) allocated, alignment);
result = aligned + size - TLS_TCB_SIZE;
diff --git a/elf/rtld_static_init.c b/elf/rtld_static_init.c
index cd823096d6..bded6bd2d4 100644
--- a/elf/rtld_static_init.c
+++ b/elf/rtld_static_init.c
@@ -51,6 +51,12 @@ __rtld_static_init (struct link_map *map)
dl->_dl_hwcap2 = _dl_hwcap2;
extern __typeof (dl->_dl_pagesize) _dl_pagesize attribute_hidden;
dl->_dl_pagesize = _dl_pagesize;
+ extern __typeof (dl->_dl_tls_static_align) _dl_tls_static_align
+ attribute_hidden;
+ dl->_dl_tls_static_align = _dl_tls_static_align;
+ extern __typeof (dl->_dl_tls_static_size) _dl_tls_static_size
+ attribute_hidden;
+ dl->_dl_tls_static_size = _dl_tls_static_size;
__rtld_static_init_arch (map, dl);
}
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index c288f3a2a1..e383aa1dc3 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -437,12 +437,8 @@ struct rtld_global
} *_dl_tls_dtv_slotinfo_list;
/* Number of modules in the static TLS block. */
EXTERN size_t _dl_tls_static_nelem;
- /* Size of the static TLS block. */
- EXTERN size_t _dl_tls_static_size;
/* Size actually allocated in the static TLS block. */
EXTERN size_t _dl_tls_static_used;
- /* Alignment requirement of the static TLS block. */
- EXTERN size_t _dl_tls_static_align;
/* Remaining amount of static TLS that may be used for optimizing
dynamic TLS access (e.g. with TLSDESC). */
EXTERN size_t _dl_tls_static_optional;
@@ -610,6 +606,12 @@ struct rtld_global_ro
binaries, don't honor for PIEs). */
EXTERN ElfW(Addr) _dl_use_load_bias;
+ /* Size of the static TLS block. */
+ EXTERN size_t _dl_tls_static_size;
+
+ /* Alignment requirement of the static TLS block. */
+ EXTERN size_t _dl_tls_static_align;
+
/* Size of surplus space in the static TLS area for dynamically
loaded modules with IE-model TLS or for TLSDESC optimization.
See comments in elf/dl-tls.c where it is initialized. */
--
2.31.1
next prev parent reply other threads:[~2021-05-12 16:58 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 16:57 [PATCH 00/23] nptl: Move almost all remaining functions into libc Florian Weimer
2021-05-12 16:57 ` [PATCH 01/23] nptl: Move __nptl_initial_report_events into ld.so/startup code Florian Weimer
2021-05-13 17:51 ` Adhemerval Zanella
2021-05-17 8:06 ` Florian Weimer
2021-05-18 17:28 ` Adhemerval Zanella
2021-05-12 16:57 ` [PATCH 02/23] nptl: Move __nptl_create_event, __nptl_death_event into libc Florian Weimer
2021-05-13 18:04 ` Adhemerval Zanella
2021-05-12 16:57 ` [PATCH 03/23] elf: Partially initialize ld.so after static dlopen (bug 20802) Florian Weimer
2021-05-13 19:35 ` Adhemerval Zanella
2021-05-13 20:09 ` Florian Weimer
2021-05-13 20:11 ` Adhemerval Zanella
2021-05-13 20:44 ` Florian Weimer
2021-05-12 16:57 ` [PATCH 04/23] aarch64: Remove _dl_var_init Florian Weimer
2021-05-13 19:36 ` Adhemerval Zanella
2021-05-12 16:57 ` [PATCH 05/23] arc: " Florian Weimer
2021-05-13 19:36 ` Adhemerval Zanella
2021-05-12 16:57 ` [PATCH 06/23] ia64: " Florian Weimer
2021-05-13 19:37 ` Adhemerval Zanella
2021-05-12 16:57 ` [PATCH 07/23] m68k: " Florian Weimer
2021-05-13 19:37 ` Adhemerval Zanella
2021-05-12 16:57 ` [PATCH 08/23] mips: " Florian Weimer
2021-05-13 19:37 ` Adhemerval Zanella
2021-05-12 16:58 ` [PATCH 09/23] powerpc: " Florian Weimer
2021-05-13 19:38 ` Adhemerval Zanella
2021-05-12 16:58 ` [PATCH 10/23] elf: Remove DL_STATIC_INIT Florian Weimer
2021-05-13 19:38 ` Adhemerval Zanella
2021-05-12 16:58 ` Florian Weimer [this message]
2021-05-13 19:45 ` [PATCH 11/23] elf: Move static TLS size and alignment into _rtld_global_ro Adhemerval Zanella
2021-05-12 16:58 ` [PATCH 12/23] nptl: Introduce __nptl_deferred_init Florian Weimer
2021-05-13 20:20 ` Adhemerval Zanella
2021-05-13 20:51 ` Florian Weimer
2021-05-14 11:57 ` Adhemerval Zanella
2021-05-14 12:22 ` Florian Weimer
2021-05-14 13:29 ` Adhemerval Zanella
2021-05-14 19:16 ` Carlos O'Donell
2021-05-14 19:27 ` Florian Weimer
2021-05-15 2:02 ` Carlos O'Donell
2021-05-18 17:29 ` Adhemerval Zanella
2021-05-12 16:58 ` [PATCH 13/23] nptl: Eliminate the __static_tls_size, __static_tls_align_m1 variables Florian Weimer
2021-05-14 12:40 ` Adhemerval Zanella
2021-05-17 8:14 ` Florian Weimer
2021-05-18 17:33 ` Adhemerval Zanella
2021-05-12 16:58 ` [PATCH 14/23] nptl: Move pthread_getattr_default_np into libc Florian Weimer
2021-05-14 14:00 ` Adhemerval Zanella
2021-05-12 16:58 ` [PATCH 15/23] nptl: Remove unused nptl/pthread_getcpuclockid.c implementation Florian Weimer
2021-05-13 20:22 ` Adhemerval Zanella
2021-05-12 16:58 ` [PATCH 16/23] Linux: Move implementation of pthread_getcpuclockid to nptl directory Florian Weimer
2021-05-13 20:23 ` Adhemerval Zanella
2021-05-12 16:58 ` [PATCH 17/23] nptl: Move pthread_getcpuclockid into libc Florian Weimer
2021-05-14 14:05 ` Adhemerval Zanella
2021-05-12 16:58 ` [PATCH 18/23] nptl: Move pthread_getname_np " Florian Weimer
2021-05-14 14:44 ` Adhemerval Zanella
2021-05-12 16:59 ` [PATCH 19/23] nptl: Move pthread_setaffinity_np " Florian Weimer
2021-05-14 14:45 ` Adhemerval Zanella
2021-05-12 16:59 ` [PATCH 20/23] nptl: Move pthread_setname_np " Florian Weimer
2021-05-14 14:46 ` Adhemerval Zanella
2021-05-12 16:59 ` [PATCH 21/23] nptl: Move pthread_setschedprio " Florian Weimer
2021-05-14 14:47 ` Adhemerval Zanella
2021-05-12 16:59 ` [PATCH 22/23] nptl: Move pthread_sigqueue " Florian Weimer
2021-05-14 14:48 ` Adhemerval Zanella
2021-05-12 16:59 ` [PATCH 23/23] nptl: Move semi-public __pthread_get_minstack symbol " Florian Weimer
2021-05-14 14:50 ` Adhemerval Zanella
2021-05-17 9:12 ` [PATCH 00/23] nptl: Move almost all remaining functions " 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=310d3f42a889e5fd9651cd1be3917f490666630c.1620838411.git.fweimer@redhat.com \
--to=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).