From e7e6e437daf42e323ba981ef53fbb3e5362d4a3f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 4 Dec 2002 04:20:07 +0000 Subject: [PATCH] 2002-12-03 Roland McGrath * sysdeps/generic/libc-tls.c (__libc_setup_tls): Include static TLS area surplus in calculation for sbrk call. --- sysdeps/generic/libc-tls.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sysdeps/generic/libc-tls.c b/sysdeps/generic/libc-tls.c index a403e95..a6a0504 100644 --- a/sysdeps/generic/libc-tls.c +++ b/sysdeps/generic/libc-tls.c @@ -106,15 +106,22 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign) /* We do not need a TLS block and no thread descriptor. */ return; + /* We have to set up the TCB block which also (possibly) contains 'errno'. Therefore we avoid 'malloc' which might touch 'errno'. Instead we use 'sbrk' which would only uses 'errno' if it fails. In this case we are right away out of memory and the user gets - what she/he deserves. */ + what she/he deserves. + + The initialized value of _dl_tls_static_size is provided by dl-open.c + to request some surplus that permits dynamic loading of modules with + IE-model TLS. */ # if TLS_TCB_AT_TP - tlsblock = __sbrk (roundup (memsz, tcbalign) + tcbsize + max_align); + tlsblock = __sbrk (roundup (memsz, tcbalign) + tcbsize + max_align + + GL(dl_tls_static_size)); # elif TLS_DTV_AT_TP - tlsblock = __sbrk (roundup (tcbsize, align) + memsz + max_align); + tlsblock = __sbrk (roundup (tcbsize, align) + memsz + max_align + + GL(dl_tls_static_size)); # else /* In case a model with a different layout for the TCB and DTV is defined add another #elif here and in the following #ifs. */ -- 2.7.4