[PATCH] Use TLS initial-exec model for __libc_tsd_* thread variables

Jens Remus jremus@linux.ibm.com
Fri Jul 25 13:40:03 GMT 2025


Commit 10a66a8e421b ("Remove <libc-tsd.h>") removed the TLS initial-exec
(IE) model attribute from the __libc_tsd_* thread variable declarations
and definitions.  Commit a894f04d8776 ("Optimize __libc_tsd_* thread
variable access") restored it on declarations.

Restore the TLS initial-exec model attribute on __libc_tsd_* thread
variable definitions.

This resolves test tst-locale1 failure on s390 32-bit, when using a
GNU linker without the fix from GNU binutils commit aefebe82dc89
("IBM zSystems: Fix offset relative to static TLS").

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---

Notes:
    Even though compiler option -ftls-model=initial-exec is used, the
    explicit specification of __attribute__ ((tls_model ("initial-exec")))
    on thread variable definitions (not declarations) has an effect on the
    code emitted by GCC for s390 32-bit.

 ctype/ctype-info.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ctype/ctype-info.c b/ctype/ctype-info.c
index b7d3422726f5..fb5acf9419db 100644
--- a/ctype/ctype-info.c
+++ b/ctype/ctype-info.c
@@ -24,11 +24,11 @@
    __ctype_init before user code runs, but this does not happen for
    threads in secondary namespaces.  With the initializers, secondary
    namespaces at least get locale data from the C locale.  */
-__thread const uint16_t * __libc_tsd_CTYPE_B
+__thread const uint16_t * __libc_tsd_CTYPE_B attribute_tls_model_ie
   = (const uint16_t *) _nl_C_LC_CTYPE_class + 128;
-__thread const int32_t * __libc_tsd_CTYPE_TOLOWER
+__thread const int32_t * __libc_tsd_CTYPE_TOLOWER attribute_tls_model_ie
   = (const int32_t *) _nl_C_LC_CTYPE_tolower + 128;
-__thread const int32_t * __libc_tsd_CTYPE_TOUPPER
+__thread const int32_t * __libc_tsd_CTYPE_TOUPPER attribute_tls_model_ie
   = (const int32_t *) _nl_C_LC_CTYPE_toupper + 128;
 
 
-- 
2.48.1



More information about the Libc-alpha mailing list