Fix bookkeeping of static TLS block for TLS_TCB_AT_TP architectures.

This commit is contained in:
Ulrich Drepper 2009-07-28 21:58:32 -07:00
parent b0948ffdcb
commit 9655389317
3 changed files with 18 additions and 5 deletions

View File

@ -1,3 +1,12 @@
2009-07-28 Ulrich Drepper <drepper@redhat.com>
* csu/libc-tls.c (__libc_setup_tls) [TLS_TCB_AT_TP]: Don't add TCB
size to memsz.
(init_static_tls) [TLS_TCB_AT_TP]: Add it to GL(dl_tls_static_size)
here.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Compute freebytes in
two steps to catch bugs.
2009-07-27 Ulrich Drepper <drepper@redhat.com> 2009-07-27 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/tst-xmmymm.sh: Refine testing. The script now * sysdeps/x86_64/tst-xmmymm.sh: Refine testing. The script now

View File

@ -1,5 +1,5 @@
/* Initialization code for TLS in statically linked application. /* Initialization code for TLS in statically linked application.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -99,6 +99,9 @@ init_static_tls (size_t memsz, size_t align)
surplus that permits dynamic loading of modules with IE-model TLS. */ surplus that permits dynamic loading of modules with IE-model TLS. */
GL(dl_tls_static_size) = roundup (memsz + GL(dl_tls_static_size), GL(dl_tls_static_size) = roundup (memsz + GL(dl_tls_static_size),
TLS_TCB_ALIGN); TLS_TCB_ALIGN);
#if TLS_TCB_AT_TP
GL(dl_tls_static_size) += TLS_TCB_SIZE;
#endif
GL(dl_tls_static_used) = memsz; GL(dl_tls_static_used) = memsz;
/* The alignment requirement for the static TLS block. */ /* The alignment requirement for the static TLS block. */
GL(dl_tls_static_align) = align; GL(dl_tls_static_align) = align;
@ -211,9 +214,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
memsz = roundup (memsz, align ?: 1); memsz = roundup (memsz, align ?: 1);
#if TLS_TCB_AT_TP #if TLS_DTV_AT_TP
memsz += tcbsize;
#elif TLS_DTV_AT_TP
memsz += tcb_offset; memsz += tcb_offset;
#endif #endif

View File

@ -61,7 +61,10 @@ _dl_try_allocate_static_tls (struct link_map *map)
size_t n; size_t n;
size_t blsize; size_t blsize;
freebytes = GL(dl_tls_static_size) - GL(dl_tls_static_used) - TLS_TCB_SIZE; freebytes = GL(dl_tls_static_size) - GL(dl_tls_static_used);
if (freebytes < TLS_TCB_SIZE)
goto fail;
freebytes -= TLS_TCB_SIZE;
blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset; blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset;
if (freebytes < blsize) if (freebytes < blsize)