2002-02-07 04:08:19 +00:00
|
|
|
/* Thread-local storage handling in the ELF dynamic linker. Generic version.
|
2005-01-06 22:40:27 +00:00
|
|
|
Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
2002-02-07 04:08:19 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
|
|
|
|
|
|
|
#include <assert.h>
|
2005-01-06 22:40:27 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <libintl.h>
|
2002-02-13 08:03:56 +00:00
|
|
|
#include <signal.h>
|
2002-02-09 01:41:44 +00:00
|
|
|
#include <stdlib.h>
|
2002-02-13 08:03:56 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/param.h>
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2002-02-07 17:54:45 +00:00
|
|
|
#include <tls.h>
|
2002-02-07 04:08:19 +00:00
|
|
|
|
|
|
|
/* We don't need any of this if TLS is not supported. */
|
|
|
|
#ifdef USE_TLS
|
|
|
|
|
2002-02-14 07:57:19 +00:00
|
|
|
# include <dl-tls.h>
|
|
|
|
# include <ldsodefs.h>
|
2002-02-07 17:29:14 +00:00
|
|
|
|
2002-11-05 03:01:37 +00:00
|
|
|
/* Amount of excess space to allocate in the static TLS area
|
|
|
|
to allow dynamic loading of modules defining IE-model TLS data. */
|
[BZ #77]
Update.
Add support for namespaces in the dynamic linker.
* dlfcn/Makefile (libdl-routines): Add dlmopen.
* dlfcn/Versions [libdl, GLIBC_2.3.4]: Add dlmopen.
* dlfcn/dlfcn.h: Define Lmid_t, LM_ID_BASE, and LM_ID_NEWLM.
Declare dlmopen. Document RTLD_DI_LMID.
* dlfcn/dlinfo.c: Handle RTLD_DI_LMID.
* dlfcn/dlmopen.c: New file.
* dlfcn/dlopen.c: Pass new parameter to _dl_open.
* dlfcn/dlopenold.c: Likewise.
* elf/dl-addr.c: Adjust for removal of GL(dl_loaded).
* elf/dl-caller.c: Likewise.
* elf/dl-close.c: Likewise.
* elf/dl-conflict.c: Likewise.
* elf/dl-debug.c: Likewise.
* elf/dl-lookup.c: Likewise.
* elf/dl-sym.c: Likewise.
* elf/dl-version.c: Likewise.
* elf/do-lookup.h: Likewise.
* elf/rtld.c: Likewise.
* sysdeps/unix/sysv/linux/i386/dl-librecon.h: Likewise.
* elf/dl-depsc: Likewise. Add new parameter to _dl_map_object.
* elf/dl-fini.c: Call destructors in all namespaces.
* elf/dl-iteratephdr.c: Compute total nloaded. Adjust for removal of
GL(dl_loaded).
* elf/dl-libc.c: Pass new parameter to _dl_open. Adjust for removal
of GL(dl_loaded).
* elf/dl-load.c (_dl_map_object_from_fd): Don't load ld.so a second
time. Reuse the one from the main namespace in all others.
Pass new parameter to _dl_new_object.
Adjust for removal of GL(dl_loaded).
* elf/dl-object.c: Take new parameter. Use it to initialize l_ns.
Adjust for removal of GL(dl_loaded).
* elf/dl-open.c (_dl_open): Take new parameter.
Adjust for removal of GL(dl_loaded).
* elf/dl-support.c: Replace global _dl_loaded etc variables with
_dl_ns variable.
* include/dlfcn.h: Adjust prototype of _dl_open.
Define __LM_ID_CALLER.
* include/link.h: Add l_real, l_ns, and l_direct_opencount elements.
* sysdeps/generic/dl-tls.c: Bump TLS_STATIC_SURPLUS. Since libc is
using TLS we need memory appropriate to the number of namespaces.
* sysdeps/generic/ldsodefs.h (struct rtld_global): Replace _dl_loaded,
_dl_nloaded, _dl_global_scope, _dl_main_searchlist, and
_dl_global_scope_alloc with _dl_ns element. Define DL_NNS.
Adjust prototypes of _dl_map_object and member in rtld_global_ro.
* malloc/malloc.c: Include <dlfcn.h>.
* malloc/arena.c (ptmalloc_init): If libc is not in primary namespace,
never use brk.
* elf/Makefile: Add rules to build and run tst-dlmopen1 and
tst-dlmopen2.
* elf/tst-dlmopen1.c: New file.
* elf/tst-dlmopen1mod.c: New file.
* elf/tst-dlmopen2.c: New file.
* elf/dl-close.c: Improve reference counting by tracking direct loads.
* elf/dl-lookup.c (add_dependency): Likewise.
* elf/dl-open.c (dl_open_worker): Likewise.
* elf/rtld.c (dl_main): Likewise.
2004-09-09 GOTO Masanori <gotom@debian.or.jp>
[BZ #77]
* elf/dl-close.c: Count down l_opencount to check not only for
l_reldeps, but also l_initfini.
2004-10-13 Ulrich Drepper <drepper@redhat.com>
2004-10-14 02:08:23 +00:00
|
|
|
# define TLS_STATIC_SURPLUS 64 + DL_NNS * 100
|
2002-11-05 03:01:37 +00:00
|
|
|
|
2002-02-07 04:08:19 +00:00
|
|
|
/* Value used for dtv entries for which the allocation is delayed. */
|
2002-02-13 08:03:56 +00:00
|
|
|
# define TLS_DTV_UNALLOCATED ((void *) -1l)
|
|
|
|
|
|
|
|
|
|
|
|
/* Out-of-memory handler. */
|
2002-02-14 07:57:19 +00:00
|
|
|
# ifdef SHARED
|
2002-02-13 08:03:56 +00:00
|
|
|
static void
|
|
|
|
__attribute__ ((__noreturn__))
|
|
|
|
oom (void)
|
|
|
|
{
|
2002-05-03 07:39:22 +00:00
|
|
|
_dl_fatal_printf ("cannot allocate memory for thread-local data: ABORT\n");
|
2002-02-13 08:03:56 +00:00
|
|
|
}
|
2005-02-23 06:19:23 +00:00
|
|
|
# endif
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
|
2002-02-07 04:08:19 +00:00
|
|
|
size_t
|
|
|
|
internal_function
|
|
|
|
_dl_next_tls_modid (void)
|
|
|
|
{
|
|
|
|
size_t result;
|
|
|
|
|
|
|
|
if (__builtin_expect (GL(dl_tls_dtv_gaps), false))
|
|
|
|
{
|
2002-02-13 08:03:56 +00:00
|
|
|
size_t disp = 0;
|
|
|
|
struct dtv_slotinfo_list *runp = GL(dl_tls_dtv_slotinfo_list);
|
|
|
|
|
|
|
|
/* Note that this branch will never be executed during program
|
|
|
|
start since there are no gaps at that time. Therefore it
|
|
|
|
does not matter that the dl_tls_dtv_slotinfo is not allocated
|
2005-01-10 11:10:54 +00:00
|
|
|
yet when the function is called for the first times.
|
|
|
|
|
|
|
|
NB: the offset +1 is due to the fact that DTV[0] is used
|
|
|
|
for something else. */
|
2007-07-12 18:26:36 +00:00
|
|
|
result = GL(dl_tls_static_nelem) + 1;
|
2005-03-20 22:25:59 +00:00
|
|
|
if (result <= GL(dl_tls_max_dtv_idx))
|
|
|
|
do
|
|
|
|
{
|
|
|
|
while (result - disp < runp->len)
|
|
|
|
{
|
|
|
|
if (runp->slotinfo[result - disp].map == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
++result;
|
|
|
|
assert (result <= GL(dl_tls_max_dtv_idx) + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result - disp < runp->len)
|
|
|
|
break;
|
|
|
|
|
|
|
|
disp += runp->len;
|
|
|
|
}
|
|
|
|
while ((runp = runp->next) != NULL);
|
2004-12-22 20:10:10 +00:00
|
|
|
|
2005-01-10 11:10:54 +00:00
|
|
|
if (result > GL(dl_tls_max_dtv_idx))
|
2002-02-13 08:03:56 +00:00
|
|
|
{
|
|
|
|
/* The new index must indeed be exactly one higher than the
|
|
|
|
previous high. */
|
2005-01-10 11:10:54 +00:00
|
|
|
assert (result == GL(dl_tls_max_dtv_idx) + 1);
|
2002-02-13 08:03:56 +00:00
|
|
|
/* There is no gap anymore. */
|
|
|
|
GL(dl_tls_dtv_gaps) = false;
|
|
|
|
|
|
|
|
goto nogaps;
|
|
|
|
}
|
2002-02-07 04:08:19 +00:00
|
|
|
}
|
|
|
|
else
|
2002-02-13 08:03:56 +00:00
|
|
|
{
|
|
|
|
/* No gaps, allocate a new entry. */
|
|
|
|
nogaps:
|
2005-02-23 06:19:23 +00:00
|
|
|
|
2002-02-13 08:03:56 +00:00
|
|
|
result = ++GL(dl_tls_max_dtv_idx);
|
|
|
|
}
|
2002-02-07 04:08:19 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-12-22 20:10:10 +00:00
|
|
|
|
2005-02-23 06:19:23 +00:00
|
|
|
# ifdef SHARED
|
2002-02-07 04:08:19 +00:00
|
|
|
void
|
|
|
|
internal_function
|
2002-02-13 08:03:56 +00:00
|
|
|
_dl_determine_tlsoffset (void)
|
2002-02-07 04:08:19 +00:00
|
|
|
{
|
2003-09-02 00:49:47 +00:00
|
|
|
size_t max_align = TLS_TCB_ALIGN;
|
2005-01-06 22:40:27 +00:00
|
|
|
size_t freetop = 0;
|
|
|
|
size_t freebottom = 0;
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2002-02-13 08:03:56 +00:00
|
|
|
/* The first element of the dtv slot info list is allocated. */
|
|
|
|
assert (GL(dl_tls_dtv_slotinfo_list) != NULL);
|
|
|
|
/* There is at this point only one element in the
|
|
|
|
dl_tls_dtv_slotinfo_list list. */
|
|
|
|
assert (GL(dl_tls_dtv_slotinfo_list)->next == NULL);
|
2002-02-09 01:41:44 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
struct dtv_slotinfo *slotinfo = GL(dl_tls_dtv_slotinfo_list)->slotinfo;
|
2003-09-02 00:49:47 +00:00
|
|
|
|
2003-07-24 20:07:00 +00:00
|
|
|
/* Determining the offset of the various parts of the static TLS
|
|
|
|
block has several dependencies. In addition we have to work
|
|
|
|
around bugs in some toolchains.
|
|
|
|
|
|
|
|
Each TLS block from the objects available at link time has a size
|
|
|
|
and an alignment requirement. The GNU ld computes the alignment
|
|
|
|
requirements for the data at the positions *in the file*, though.
|
|
|
|
I.e, it is not simply possible to allocate a block with the size
|
|
|
|
of the TLS program header entry. The data is layed out assuming
|
|
|
|
that the first byte of the TLS block fulfills
|
|
|
|
|
|
|
|
p_vaddr mod p_align == &TLS_BLOCK mod p_align
|
|
|
|
|
|
|
|
This means we have to add artificial padding at the beginning of
|
|
|
|
the TLS block. These bytes are never used for the TLS data in
|
|
|
|
this module but the first byte allocated must be aligned
|
|
|
|
according to mod p_align == 0 so that the first byte of the TLS
|
|
|
|
block is aligned according to p_vaddr mod p_align. This is ugly
|
|
|
|
and the linker can help by computing the offsets in the TLS block
|
|
|
|
assuming the first byte of the TLS block is aligned according to
|
|
|
|
p_align.
|
|
|
|
|
|
|
|
The extra space which might be allocated before the first byte of
|
|
|
|
the TLS block need not go unused. The code below tries to use
|
|
|
|
that memory for the next TLS block. This can work if the total
|
|
|
|
memory requirement for the next TLS block is smaller than the
|
|
|
|
gap. */
|
|
|
|
|
2002-02-07 04:08:19 +00:00
|
|
|
# if TLS_TCB_AT_TP
|
|
|
|
/* We simply start with zero. */
|
2005-01-06 22:40:27 +00:00
|
|
|
size_t offset = 0;
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
for (size_t cnt = 0; slotinfo[cnt].map != NULL; ++cnt)
|
2002-02-07 04:08:19 +00:00
|
|
|
{
|
2002-02-13 08:03:56 +00:00
|
|
|
assert (cnt < GL(dl_tls_dtv_slotinfo_list)->len);
|
|
|
|
|
2003-09-02 00:49:47 +00:00
|
|
|
size_t firstbyte = (-slotinfo[cnt].map->l_tls_firstbyte_offset
|
|
|
|
& (slotinfo[cnt].map->l_tls_align - 1));
|
|
|
|
size_t off;
|
|
|
|
max_align = MAX (max_align, slotinfo[cnt].map->l_tls_align);
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2003-09-02 00:49:47 +00:00
|
|
|
if (freebottom - freetop >= slotinfo[cnt].map->l_tls_blocksize)
|
2003-07-24 20:07:00 +00:00
|
|
|
{
|
2003-09-02 00:49:47 +00:00
|
|
|
off = roundup (freetop + slotinfo[cnt].map->l_tls_blocksize
|
|
|
|
- firstbyte, slotinfo[cnt].map->l_tls_align)
|
|
|
|
+ firstbyte;
|
|
|
|
if (off <= freebottom)
|
|
|
|
{
|
|
|
|
freetop = off;
|
|
|
|
|
|
|
|
/* XXX For some architectures we perhaps should store the
|
|
|
|
negative offset. */
|
|
|
|
slotinfo[cnt].map->l_tls_offset = off;
|
|
|
|
continue;
|
|
|
|
}
|
2003-07-24 20:07:00 +00:00
|
|
|
}
|
2003-09-02 00:49:47 +00:00
|
|
|
|
|
|
|
off = roundup (offset + slotinfo[cnt].map->l_tls_blocksize - firstbyte,
|
|
|
|
slotinfo[cnt].map->l_tls_align) + firstbyte;
|
|
|
|
if (off > offset + slotinfo[cnt].map->l_tls_blocksize
|
|
|
|
+ (freebottom - freetop))
|
2003-07-24 20:07:00 +00:00
|
|
|
{
|
2003-09-02 00:49:47 +00:00
|
|
|
freetop = offset;
|
|
|
|
freebottom = off - slotinfo[cnt].map->l_tls_blocksize;
|
2003-07-24 20:07:00 +00:00
|
|
|
}
|
2003-09-02 00:49:47 +00:00
|
|
|
offset = off;
|
2002-02-07 04:08:19 +00:00
|
|
|
|
|
|
|
/* XXX For some architectures we perhaps should store the
|
|
|
|
negative offset. */
|
2003-09-02 00:49:47 +00:00
|
|
|
slotinfo[cnt].map->l_tls_offset = off;
|
2002-02-07 04:08:19 +00:00
|
|
|
}
|
2002-02-07 06:38:57 +00:00
|
|
|
|
2002-11-05 03:01:37 +00:00
|
|
|
GL(dl_tls_static_used) = offset;
|
2003-09-02 00:49:47 +00:00
|
|
|
GL(dl_tls_static_size) = (roundup (offset + TLS_STATIC_SURPLUS, max_align)
|
2003-07-24 20:07:00 +00:00
|
|
|
+ TLS_TCB_SIZE);
|
2002-02-07 04:08:19 +00:00
|
|
|
# elif TLS_DTV_AT_TP
|
2002-02-13 08:03:56 +00:00
|
|
|
/* The TLS blocks start right after the TCB. */
|
2005-01-06 22:40:27 +00:00
|
|
|
size_t offset = TLS_TCB_SIZE;
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
for (size_t cnt = 0; slotinfo[cnt].map != NULL; ++cnt)
|
2002-02-07 04:08:19 +00:00
|
|
|
{
|
2003-09-02 00:49:47 +00:00
|
|
|
assert (cnt < GL(dl_tls_dtv_slotinfo_list)->len);
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2003-09-02 00:49:47 +00:00
|
|
|
size_t firstbyte = (-slotinfo[cnt].map->l_tls_firstbyte_offset
|
|
|
|
& (slotinfo[cnt].map->l_tls_align - 1));
|
|
|
|
size_t off;
|
|
|
|
max_align = MAX (max_align, slotinfo[cnt].map->l_tls_align);
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2004-11-23 22:57:42 +00:00
|
|
|
if (slotinfo[cnt].map->l_tls_blocksize <= freetop - freebottom)
|
2002-02-13 08:03:56 +00:00
|
|
|
{
|
2003-09-02 00:49:47 +00:00
|
|
|
off = roundup (freebottom, slotinfo[cnt].map->l_tls_align);
|
|
|
|
if (off - freebottom < firstbyte)
|
|
|
|
off += slotinfo[cnt].map->l_tls_align;
|
|
|
|
if (off + slotinfo[cnt].map->l_tls_blocksize - firstbyte <= freetop)
|
|
|
|
{
|
|
|
|
slotinfo[cnt].map->l_tls_offset = off - firstbyte;
|
2005-01-06 22:40:27 +00:00
|
|
|
freebottom = (off + slotinfo[cnt].map->l_tls_blocksize
|
|
|
|
- firstbyte);
|
2003-09-02 00:49:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2002-02-13 08:03:56 +00:00
|
|
|
|
2003-09-02 00:49:47 +00:00
|
|
|
off = roundup (offset, slotinfo[cnt].map->l_tls_align);
|
|
|
|
if (off - offset < firstbyte)
|
|
|
|
off += slotinfo[cnt].map->l_tls_align;
|
2002-02-13 08:03:56 +00:00
|
|
|
|
2003-09-02 00:49:47 +00:00
|
|
|
slotinfo[cnt].map->l_tls_offset = off - firstbyte;
|
|
|
|
if (off - firstbyte - offset > freetop - freebottom)
|
|
|
|
{
|
|
|
|
freebottom = offset;
|
|
|
|
freetop = off - firstbyte;
|
2002-02-13 08:03:56 +00:00
|
|
|
}
|
2002-02-07 08:44:37 +00:00
|
|
|
|
2003-09-02 00:49:47 +00:00
|
|
|
offset = off + slotinfo[cnt].map->l_tls_blocksize - firstbyte;
|
2002-02-07 04:08:19 +00:00
|
|
|
}
|
2002-02-07 08:44:37 +00:00
|
|
|
|
2002-11-05 03:01:37 +00:00
|
|
|
GL(dl_tls_static_used) = offset;
|
|
|
|
GL(dl_tls_static_size) = roundup (offset + TLS_STATIC_SURPLUS,
|
|
|
|
TLS_TCB_ALIGN);
|
2002-02-07 04:08:19 +00:00
|
|
|
# else
|
|
|
|
# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
|
|
|
|
# endif
|
2002-02-07 08:44:37 +00:00
|
|
|
|
|
|
|
/* The alignment requirement for the static TLS block. */
|
2003-07-24 20:07:00 +00:00
|
|
|
GL(dl_tls_static_align) = max_align;
|
2002-02-07 04:08:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-04 12:30:40 +00:00
|
|
|
/* This is called only when the data structure setup was skipped at startup,
|
|
|
|
when there was no need for it then. Now we have dynamically loaded
|
|
|
|
something needing TLS, or libpthread needs it. */
|
|
|
|
int
|
|
|
|
internal_function
|
|
|
|
_dl_tls_setup (void)
|
|
|
|
{
|
|
|
|
assert (GL(dl_tls_dtv_slotinfo_list) == NULL);
|
|
|
|
assert (GL(dl_tls_max_dtv_idx) == 0);
|
|
|
|
|
|
|
|
const size_t nelem = 2 + TLS_SLOTINFO_SURPLUS;
|
|
|
|
|
2002-12-06 11:15:07 +00:00
|
|
|
GL(dl_tls_dtv_slotinfo_list)
|
|
|
|
= calloc (1, (sizeof (struct dtv_slotinfo_list)
|
|
|
|
+ nelem * sizeof (struct dtv_slotinfo)));
|
2002-12-04 12:30:40 +00:00
|
|
|
if (GL(dl_tls_dtv_slotinfo_list) == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
GL(dl_tls_dtv_slotinfo_list)->len = nelem;
|
|
|
|
|
|
|
|
/* Number of elements in the static TLS block. It can't be zero
|
|
|
|
because of various assumptions. The one element is null. */
|
|
|
|
GL(dl_tls_static_nelem) = GL(dl_tls_max_dtv_idx) = 1;
|
|
|
|
|
|
|
|
/* This initializes more variables for us. */
|
|
|
|
_dl_determine_tlsoffset ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
rtld_hidden_def (_dl_tls_setup)
|
|
|
|
# endif
|
|
|
|
|
2002-08-20 07:22:11 +00:00
|
|
|
static void *
|
2002-02-09 01:41:44 +00:00
|
|
|
internal_function
|
2002-08-20 07:22:11 +00:00
|
|
|
allocate_dtv (void *result)
|
2002-02-09 01:41:44 +00:00
|
|
|
{
|
|
|
|
dtv_t *dtv;
|
2002-02-13 08:03:56 +00:00
|
|
|
size_t dtv_length;
|
2002-02-09 01:41:44 +00:00
|
|
|
|
2002-02-13 08:03:56 +00:00
|
|
|
/* We allocate a few more elements in the dtv than are needed for the
|
|
|
|
initial set of modules. This should avoid in most cases expansions
|
|
|
|
of the dtv. */
|
|
|
|
dtv_length = GL(dl_tls_max_dtv_idx) + DTV_SURPLUS;
|
2002-12-06 11:15:07 +00:00
|
|
|
dtv = calloc (dtv_length + 2, sizeof (dtv_t));
|
2002-08-05 01:28:17 +00:00
|
|
|
if (dtv != NULL)
|
2002-02-09 01:41:44 +00:00
|
|
|
{
|
2002-02-13 08:03:56 +00:00
|
|
|
/* This is the initial length of the dtv. */
|
|
|
|
dtv[0].counter = dtv_length;
|
2002-12-06 11:15:07 +00:00
|
|
|
|
|
|
|
/* The rest of the dtv (including the generation counter) is
|
|
|
|
Initialize with zero to indicate nothing there. */
|
2002-02-13 08:03:56 +00:00
|
|
|
|
2002-08-05 01:20:52 +00:00
|
|
|
/* Add the dtv to the thread data structures. */
|
|
|
|
INSTALL_DTV (result, dtv);
|
|
|
|
}
|
2002-08-05 01:28:17 +00:00
|
|
|
else
|
2002-08-20 07:22:11 +00:00
|
|
|
result = NULL;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Get size and alignment requirements of the static TLS block. */
|
|
|
|
void
|
|
|
|
internal_function
|
|
|
|
_dl_get_tls_static_info (size_t *sizep, size_t *alignp)
|
|
|
|
{
|
|
|
|
*sizep = GL(dl_tls_static_size);
|
|
|
|
*alignp = GL(dl_tls_static_align);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *
|
|
|
|
internal_function
|
|
|
|
_dl_allocate_tls_storage (void)
|
|
|
|
{
|
|
|
|
void *result;
|
Update.
2003-01-11 Jim Meyering <jim@meyering.net>
* io/ftw.c [HAVE_CONFIG_H]: Include <config.h>.
[HAVE_SYS_PARAM_H || _LIBC]: Guard inclusion of <sys/param.h>.
Include <sys/stat.h>, not <include/sys/stat.h>, if !_LIBC.
[!_LIBC] (__chdir, __closedir, __fchdir, __getcwd, __opendir): Define.
[!_LIBC] (__readdir64, __tdestroy, __tfind, __tsearch): Define.
[!_LIBC] (internal_function, dirent64, MAX): Define.
(__set_errno): Define if not already defined.
(open_dir_stream): When FTW_CHDIR is enabled, invoke opendir on
the basename, not the entire file name.
(process_entry): When FTW_CHDIR is enabled, invoke XSTAT or LXSTAT on
the basename, not the entire file name.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* string/tester.c (test_strcpy): Disable last added strcpy until
it is fixed.
2003-01-11 Philip Blundell <philb@gnu.org>
* sysdeps/unix/sysv/linux/arm/socket.S: Add cancellation support.
2003-01-11 Andreas Schwab <schwab@suse.de>
* Makerules: Add vpath for %.dynsym and %.so so that the
implicit rule chaining for check-abi works.
2003-01-11 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
Add non-PIC case.
2003-01-11 Jakub Jelinek <jakub@redhat.com>
* elf/tls-macros.h [__ia64__] (__TLS_CALL_CLOBBERS): Define.
[__ia64__] (TLS_LE, TLS_IE): Fix typos. Add ;; at start of asm if
gp is used early.
[__ia64__] (TLS_LD, TLS_GD): Likewise. Use __TLS_CALL_CLOBBERS.
* elf/Makefile ($(objpfx)tst-tlsmod5.so, $(objpfx)tst-tlsmod6.so):
Ensure libc.so in DT_NEEDED.
* sysdeps/alpha/dl-machine.h (elf_machine_rela): Move
CHECK_STATIC_TLS before l_tls_offset use.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela):
Likewise.
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage) [TLS_DTV_AT_TP]:
Allocate TLS_PRE_TCB_SIZE bytes below result.
(_dl_deallocate_tls) [TLS_DTV_AT_TP]: Adjust before freeing.
* sysdeps/generic/libc-tls.c (__libc_setup_tls): If
TLS_INIT_TP_EXPENSIVE is not defined, allocate even if no PT_TLS
segment has been found. If TLS_DTV_AT_TP, allocate TLS_PRE_TCB_SIZE
bytes below result and add tcb_offset to memsz.
* sysdeps/ia64/dl-tls.h (__tls_get_addr): New prototype.
* sysdeps/ia64/dl-machine.h: Include tls.h.
(elf_machine_type_class): Return ELF_RTYPE_CLASS_PLT for TLS relocs
too.
(elf_machine_rela): Assume if sym_map != NULL sym is non-NULL too.
Handle R_IA64_DTPMOD*, R_IA64_DTPREL* and R_IA64_TPREL* relocations.
* sysdeps/ia64/libc-tls.c: New file.
2003-01-10 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/powerpc64/sysdep.h (PSEUDO_RET): Add branch hit.
* sysdeps/unix/sysv/linux/powerpc/bits/stat.h (STAT_VER_LINUX):
Fix type. Move definition out of #if.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/ftruncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S: Add cancellation
support.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Remove
ftruncate64, pread64, pwrite64, truncate64 entries.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
(INLINE_SYSCALL): New version that supports function call like
syscalls. Add __builtin_expect.
(LOADARGS_n): Add argument size safety checks.
(INTERNAL_SYSCALL): New Macro.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/truncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h [__PPC_ELF_H]: Avoid
redefinition of elf_fpreg_t and elf_fpregset_t.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* elf/dl-close.c (_dl_close): Add several asserts. Correct and
simplify test for unloading. If loader of a DSO is unloaded do not
use its scope anymore. Fall back to own scope and adjust opencounts.
Fix several comments.
* elf/dl-deps.c (_dl_map_object_deps): Always allocate memory for
the l_searchlist, not only for l_initfini.
* elf/dl-lookup.c (add_dependencies): Avoid creating relocation
dependencies if objects cannot be removed. Remove object with the
definition as not unloadable if necessary.
* elf/reldep6.c: Create relocation dependency before closing the first
module.
2003-01-10 Guido Gnther <agx@sigxcpu.org>
* elf/Makefile: Add rules to build and run reldep9 test.
* elf/reldep9.c: New file.
* elf/reldep9mod1.c: New file.
* elf/reldep9mod2.c: New file.
* elf/reldep9mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile: Add rules to build and run nodelete2 test.
* elf/nodelete2.c: New file.
* elf/nodel2mod1.c: New file.
* elf/nodel2mod2.c: New file.
* elf/nodel2mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
2003-01-12 10:11:16 +00:00
|
|
|
size_t size = GL(dl_tls_static_size);
|
|
|
|
|
|
|
|
# if TLS_DTV_AT_TP
|
|
|
|
/* Memory layout is:
|
|
|
|
[ TLS_PRE_TCB_SIZE ] [ TLS_TCB_SIZE ] [ TLS blocks ]
|
|
|
|
^ This should be returned. */
|
|
|
|
size += (TLS_PRE_TCB_SIZE + GL(dl_tls_static_align) - 1)
|
|
|
|
& ~(GL(dl_tls_static_align) - 1);
|
|
|
|
# endif
|
2002-08-20 07:22:11 +00:00
|
|
|
|
|
|
|
/* Allocate a correctly aligned chunk of memory. */
|
Update.
2003-01-11 Jim Meyering <jim@meyering.net>
* io/ftw.c [HAVE_CONFIG_H]: Include <config.h>.
[HAVE_SYS_PARAM_H || _LIBC]: Guard inclusion of <sys/param.h>.
Include <sys/stat.h>, not <include/sys/stat.h>, if !_LIBC.
[!_LIBC] (__chdir, __closedir, __fchdir, __getcwd, __opendir): Define.
[!_LIBC] (__readdir64, __tdestroy, __tfind, __tsearch): Define.
[!_LIBC] (internal_function, dirent64, MAX): Define.
(__set_errno): Define if not already defined.
(open_dir_stream): When FTW_CHDIR is enabled, invoke opendir on
the basename, not the entire file name.
(process_entry): When FTW_CHDIR is enabled, invoke XSTAT or LXSTAT on
the basename, not the entire file name.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* string/tester.c (test_strcpy): Disable last added strcpy until
it is fixed.
2003-01-11 Philip Blundell <philb@gnu.org>
* sysdeps/unix/sysv/linux/arm/socket.S: Add cancellation support.
2003-01-11 Andreas Schwab <schwab@suse.de>
* Makerules: Add vpath for %.dynsym and %.so so that the
implicit rule chaining for check-abi works.
2003-01-11 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
Add non-PIC case.
2003-01-11 Jakub Jelinek <jakub@redhat.com>
* elf/tls-macros.h [__ia64__] (__TLS_CALL_CLOBBERS): Define.
[__ia64__] (TLS_LE, TLS_IE): Fix typos. Add ;; at start of asm if
gp is used early.
[__ia64__] (TLS_LD, TLS_GD): Likewise. Use __TLS_CALL_CLOBBERS.
* elf/Makefile ($(objpfx)tst-tlsmod5.so, $(objpfx)tst-tlsmod6.so):
Ensure libc.so in DT_NEEDED.
* sysdeps/alpha/dl-machine.h (elf_machine_rela): Move
CHECK_STATIC_TLS before l_tls_offset use.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela):
Likewise.
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage) [TLS_DTV_AT_TP]:
Allocate TLS_PRE_TCB_SIZE bytes below result.
(_dl_deallocate_tls) [TLS_DTV_AT_TP]: Adjust before freeing.
* sysdeps/generic/libc-tls.c (__libc_setup_tls): If
TLS_INIT_TP_EXPENSIVE is not defined, allocate even if no PT_TLS
segment has been found. If TLS_DTV_AT_TP, allocate TLS_PRE_TCB_SIZE
bytes below result and add tcb_offset to memsz.
* sysdeps/ia64/dl-tls.h (__tls_get_addr): New prototype.
* sysdeps/ia64/dl-machine.h: Include tls.h.
(elf_machine_type_class): Return ELF_RTYPE_CLASS_PLT for TLS relocs
too.
(elf_machine_rela): Assume if sym_map != NULL sym is non-NULL too.
Handle R_IA64_DTPMOD*, R_IA64_DTPREL* and R_IA64_TPREL* relocations.
* sysdeps/ia64/libc-tls.c: New file.
2003-01-10 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/powerpc64/sysdep.h (PSEUDO_RET): Add branch hit.
* sysdeps/unix/sysv/linux/powerpc/bits/stat.h (STAT_VER_LINUX):
Fix type. Move definition out of #if.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/ftruncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S: Add cancellation
support.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Remove
ftruncate64, pread64, pwrite64, truncate64 entries.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
(INLINE_SYSCALL): New version that supports function call like
syscalls. Add __builtin_expect.
(LOADARGS_n): Add argument size safety checks.
(INTERNAL_SYSCALL): New Macro.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/truncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h [__PPC_ELF_H]: Avoid
redefinition of elf_fpreg_t and elf_fpregset_t.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* elf/dl-close.c (_dl_close): Add several asserts. Correct and
simplify test for unloading. If loader of a DSO is unloaded do not
use its scope anymore. Fall back to own scope and adjust opencounts.
Fix several comments.
* elf/dl-deps.c (_dl_map_object_deps): Always allocate memory for
the l_searchlist, not only for l_initfini.
* elf/dl-lookup.c (add_dependencies): Avoid creating relocation
dependencies if objects cannot be removed. Remove object with the
definition as not unloadable if necessary.
* elf/reldep6.c: Create relocation dependency before closing the first
module.
2003-01-10 Guido Gnther <agx@sigxcpu.org>
* elf/Makefile: Add rules to build and run reldep9 test.
* elf/reldep9.c: New file.
* elf/reldep9mod1.c: New file.
* elf/reldep9mod2.c: New file.
* elf/reldep9mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile: Add rules to build and run nodelete2 test.
* elf/nodelete2.c: New file.
* elf/nodel2mod1.c: New file.
* elf/nodel2mod2.c: New file.
* elf/nodel2mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
2003-01-12 10:11:16 +00:00
|
|
|
result = __libc_memalign (GL(dl_tls_static_align), size);
|
2003-03-06 06:40:43 +00:00
|
|
|
if (__builtin_expect (result != NULL, 1))
|
2002-08-05 01:20:52 +00:00
|
|
|
{
|
2002-08-20 07:22:11 +00:00
|
|
|
/* Allocate the DTV. */
|
|
|
|
void *allocated = result;
|
|
|
|
|
|
|
|
# if TLS_TCB_AT_TP
|
|
|
|
/* The TCB follows the TLS blocks. */
|
Update.
2003-01-11 Jim Meyering <jim@meyering.net>
* io/ftw.c [HAVE_CONFIG_H]: Include <config.h>.
[HAVE_SYS_PARAM_H || _LIBC]: Guard inclusion of <sys/param.h>.
Include <sys/stat.h>, not <include/sys/stat.h>, if !_LIBC.
[!_LIBC] (__chdir, __closedir, __fchdir, __getcwd, __opendir): Define.
[!_LIBC] (__readdir64, __tdestroy, __tfind, __tsearch): Define.
[!_LIBC] (internal_function, dirent64, MAX): Define.
(__set_errno): Define if not already defined.
(open_dir_stream): When FTW_CHDIR is enabled, invoke opendir on
the basename, not the entire file name.
(process_entry): When FTW_CHDIR is enabled, invoke XSTAT or LXSTAT on
the basename, not the entire file name.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* string/tester.c (test_strcpy): Disable last added strcpy until
it is fixed.
2003-01-11 Philip Blundell <philb@gnu.org>
* sysdeps/unix/sysv/linux/arm/socket.S: Add cancellation support.
2003-01-11 Andreas Schwab <schwab@suse.de>
* Makerules: Add vpath for %.dynsym and %.so so that the
implicit rule chaining for check-abi works.
2003-01-11 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
Add non-PIC case.
2003-01-11 Jakub Jelinek <jakub@redhat.com>
* elf/tls-macros.h [__ia64__] (__TLS_CALL_CLOBBERS): Define.
[__ia64__] (TLS_LE, TLS_IE): Fix typos. Add ;; at start of asm if
gp is used early.
[__ia64__] (TLS_LD, TLS_GD): Likewise. Use __TLS_CALL_CLOBBERS.
* elf/Makefile ($(objpfx)tst-tlsmod5.so, $(objpfx)tst-tlsmod6.so):
Ensure libc.so in DT_NEEDED.
* sysdeps/alpha/dl-machine.h (elf_machine_rela): Move
CHECK_STATIC_TLS before l_tls_offset use.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela):
Likewise.
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage) [TLS_DTV_AT_TP]:
Allocate TLS_PRE_TCB_SIZE bytes below result.
(_dl_deallocate_tls) [TLS_DTV_AT_TP]: Adjust before freeing.
* sysdeps/generic/libc-tls.c (__libc_setup_tls): If
TLS_INIT_TP_EXPENSIVE is not defined, allocate even if no PT_TLS
segment has been found. If TLS_DTV_AT_TP, allocate TLS_PRE_TCB_SIZE
bytes below result and add tcb_offset to memsz.
* sysdeps/ia64/dl-tls.h (__tls_get_addr): New prototype.
* sysdeps/ia64/dl-machine.h: Include tls.h.
(elf_machine_type_class): Return ELF_RTYPE_CLASS_PLT for TLS relocs
too.
(elf_machine_rela): Assume if sym_map != NULL sym is non-NULL too.
Handle R_IA64_DTPMOD*, R_IA64_DTPREL* and R_IA64_TPREL* relocations.
* sysdeps/ia64/libc-tls.c: New file.
2003-01-10 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/powerpc64/sysdep.h (PSEUDO_RET): Add branch hit.
* sysdeps/unix/sysv/linux/powerpc/bits/stat.h (STAT_VER_LINUX):
Fix type. Move definition out of #if.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/ftruncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S: Add cancellation
support.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Remove
ftruncate64, pread64, pwrite64, truncate64 entries.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
(INLINE_SYSCALL): New version that supports function call like
syscalls. Add __builtin_expect.
(LOADARGS_n): Add argument size safety checks.
(INTERNAL_SYSCALL): New Macro.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/truncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h [__PPC_ELF_H]: Avoid
redefinition of elf_fpreg_t and elf_fpregset_t.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* elf/dl-close.c (_dl_close): Add several asserts. Correct and
simplify test for unloading. If loader of a DSO is unloaded do not
use its scope anymore. Fall back to own scope and adjust opencounts.
Fix several comments.
* elf/dl-deps.c (_dl_map_object_deps): Always allocate memory for
the l_searchlist, not only for l_initfini.
* elf/dl-lookup.c (add_dependencies): Avoid creating relocation
dependencies if objects cannot be removed. Remove object with the
definition as not unloadable if necessary.
* elf/reldep6.c: Create relocation dependency before closing the first
module.
2003-01-10 Guido Gnther <agx@sigxcpu.org>
* elf/Makefile: Add rules to build and run reldep9 test.
* elf/reldep9.c: New file.
* elf/reldep9mod1.c: New file.
* elf/reldep9mod2.c: New file.
* elf/reldep9mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile: Add rules to build and run nodelete2 test.
* elf/nodelete2.c: New file.
* elf/nodel2mod1.c: New file.
* elf/nodel2mod2.c: New file.
* elf/nodel2mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
2003-01-12 10:11:16 +00:00
|
|
|
result = (char *) result + size - TLS_TCB_SIZE;
|
2002-08-20 07:22:11 +00:00
|
|
|
|
2002-11-14 00:48:38 +00:00
|
|
|
/* Clear the TCB data structure. We can't ask the caller (i.e.
|
|
|
|
libpthread) to do it, because we will initialize the DTV et al. */
|
2005-01-06 22:40:27 +00:00
|
|
|
memset (result, '\0', TLS_TCB_SIZE);
|
Update.
2003-01-11 Jim Meyering <jim@meyering.net>
* io/ftw.c [HAVE_CONFIG_H]: Include <config.h>.
[HAVE_SYS_PARAM_H || _LIBC]: Guard inclusion of <sys/param.h>.
Include <sys/stat.h>, not <include/sys/stat.h>, if !_LIBC.
[!_LIBC] (__chdir, __closedir, __fchdir, __getcwd, __opendir): Define.
[!_LIBC] (__readdir64, __tdestroy, __tfind, __tsearch): Define.
[!_LIBC] (internal_function, dirent64, MAX): Define.
(__set_errno): Define if not already defined.
(open_dir_stream): When FTW_CHDIR is enabled, invoke opendir on
the basename, not the entire file name.
(process_entry): When FTW_CHDIR is enabled, invoke XSTAT or LXSTAT on
the basename, not the entire file name.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* string/tester.c (test_strcpy): Disable last added strcpy until
it is fixed.
2003-01-11 Philip Blundell <philb@gnu.org>
* sysdeps/unix/sysv/linux/arm/socket.S: Add cancellation support.
2003-01-11 Andreas Schwab <schwab@suse.de>
* Makerules: Add vpath for %.dynsym and %.so so that the
implicit rule chaining for check-abi works.
2003-01-11 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
Add non-PIC case.
2003-01-11 Jakub Jelinek <jakub@redhat.com>
* elf/tls-macros.h [__ia64__] (__TLS_CALL_CLOBBERS): Define.
[__ia64__] (TLS_LE, TLS_IE): Fix typos. Add ;; at start of asm if
gp is used early.
[__ia64__] (TLS_LD, TLS_GD): Likewise. Use __TLS_CALL_CLOBBERS.
* elf/Makefile ($(objpfx)tst-tlsmod5.so, $(objpfx)tst-tlsmod6.so):
Ensure libc.so in DT_NEEDED.
* sysdeps/alpha/dl-machine.h (elf_machine_rela): Move
CHECK_STATIC_TLS before l_tls_offset use.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela):
Likewise.
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage) [TLS_DTV_AT_TP]:
Allocate TLS_PRE_TCB_SIZE bytes below result.
(_dl_deallocate_tls) [TLS_DTV_AT_TP]: Adjust before freeing.
* sysdeps/generic/libc-tls.c (__libc_setup_tls): If
TLS_INIT_TP_EXPENSIVE is not defined, allocate even if no PT_TLS
segment has been found. If TLS_DTV_AT_TP, allocate TLS_PRE_TCB_SIZE
bytes below result and add tcb_offset to memsz.
* sysdeps/ia64/dl-tls.h (__tls_get_addr): New prototype.
* sysdeps/ia64/dl-machine.h: Include tls.h.
(elf_machine_type_class): Return ELF_RTYPE_CLASS_PLT for TLS relocs
too.
(elf_machine_rela): Assume if sym_map != NULL sym is non-NULL too.
Handle R_IA64_DTPMOD*, R_IA64_DTPREL* and R_IA64_TPREL* relocations.
* sysdeps/ia64/libc-tls.c: New file.
2003-01-10 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/powerpc64/sysdep.h (PSEUDO_RET): Add branch hit.
* sysdeps/unix/sysv/linux/powerpc/bits/stat.h (STAT_VER_LINUX):
Fix type. Move definition out of #if.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/ftruncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S: Add cancellation
support.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Remove
ftruncate64, pread64, pwrite64, truncate64 entries.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
(INLINE_SYSCALL): New version that supports function call like
syscalls. Add __builtin_expect.
(LOADARGS_n): Add argument size safety checks.
(INTERNAL_SYSCALL): New Macro.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/truncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h [__PPC_ELF_H]: Avoid
redefinition of elf_fpreg_t and elf_fpregset_t.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* elf/dl-close.c (_dl_close): Add several asserts. Correct and
simplify test for unloading. If loader of a DSO is unloaded do not
use its scope anymore. Fall back to own scope and adjust opencounts.
Fix several comments.
* elf/dl-deps.c (_dl_map_object_deps): Always allocate memory for
the l_searchlist, not only for l_initfini.
* elf/dl-lookup.c (add_dependencies): Avoid creating relocation
dependencies if objects cannot be removed. Remove object with the
definition as not unloadable if necessary.
* elf/reldep6.c: Create relocation dependency before closing the first
module.
2003-01-10 Guido Gnther <agx@sigxcpu.org>
* elf/Makefile: Add rules to build and run reldep9 test.
* elf/reldep9.c: New file.
* elf/reldep9mod1.c: New file.
* elf/reldep9mod2.c: New file.
* elf/reldep9mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile: Add rules to build and run nodelete2 test.
* elf/nodelete2.c: New file.
* elf/nodel2mod1.c: New file.
* elf/nodel2mod2.c: New file.
* elf/nodel2mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
2003-01-12 10:11:16 +00:00
|
|
|
# elif TLS_DTV_AT_TP
|
|
|
|
result = (char *) result + size - GL(dl_tls_static_size);
|
|
|
|
|
|
|
|
/* Clear the TCB data structure and TLS_PRE_TCB_SIZE bytes before it.
|
|
|
|
We can't ask the caller (i.e. libpthread) to do it, because we will
|
|
|
|
initialize the DTV et al. */
|
2005-01-06 22:40:27 +00:00
|
|
|
memset ((char *) result - TLS_PRE_TCB_SIZE, '\0',
|
Update.
2003-01-11 Jim Meyering <jim@meyering.net>
* io/ftw.c [HAVE_CONFIG_H]: Include <config.h>.
[HAVE_SYS_PARAM_H || _LIBC]: Guard inclusion of <sys/param.h>.
Include <sys/stat.h>, not <include/sys/stat.h>, if !_LIBC.
[!_LIBC] (__chdir, __closedir, __fchdir, __getcwd, __opendir): Define.
[!_LIBC] (__readdir64, __tdestroy, __tfind, __tsearch): Define.
[!_LIBC] (internal_function, dirent64, MAX): Define.
(__set_errno): Define if not already defined.
(open_dir_stream): When FTW_CHDIR is enabled, invoke opendir on
the basename, not the entire file name.
(process_entry): When FTW_CHDIR is enabled, invoke XSTAT or LXSTAT on
the basename, not the entire file name.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* string/tester.c (test_strcpy): Disable last added strcpy until
it is fixed.
2003-01-11 Philip Blundell <philb@gnu.org>
* sysdeps/unix/sysv/linux/arm/socket.S: Add cancellation support.
2003-01-11 Andreas Schwab <schwab@suse.de>
* Makerules: Add vpath for %.dynsym and %.so so that the
implicit rule chaining for check-abi works.
2003-01-11 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
Add non-PIC case.
2003-01-11 Jakub Jelinek <jakub@redhat.com>
* elf/tls-macros.h [__ia64__] (__TLS_CALL_CLOBBERS): Define.
[__ia64__] (TLS_LE, TLS_IE): Fix typos. Add ;; at start of asm if
gp is used early.
[__ia64__] (TLS_LD, TLS_GD): Likewise. Use __TLS_CALL_CLOBBERS.
* elf/Makefile ($(objpfx)tst-tlsmod5.so, $(objpfx)tst-tlsmod6.so):
Ensure libc.so in DT_NEEDED.
* sysdeps/alpha/dl-machine.h (elf_machine_rela): Move
CHECK_STATIC_TLS before l_tls_offset use.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela):
Likewise.
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage) [TLS_DTV_AT_TP]:
Allocate TLS_PRE_TCB_SIZE bytes below result.
(_dl_deallocate_tls) [TLS_DTV_AT_TP]: Adjust before freeing.
* sysdeps/generic/libc-tls.c (__libc_setup_tls): If
TLS_INIT_TP_EXPENSIVE is not defined, allocate even if no PT_TLS
segment has been found. If TLS_DTV_AT_TP, allocate TLS_PRE_TCB_SIZE
bytes below result and add tcb_offset to memsz.
* sysdeps/ia64/dl-tls.h (__tls_get_addr): New prototype.
* sysdeps/ia64/dl-machine.h: Include tls.h.
(elf_machine_type_class): Return ELF_RTYPE_CLASS_PLT for TLS relocs
too.
(elf_machine_rela): Assume if sym_map != NULL sym is non-NULL too.
Handle R_IA64_DTPMOD*, R_IA64_DTPREL* and R_IA64_TPREL* relocations.
* sysdeps/ia64/libc-tls.c: New file.
2003-01-10 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/powerpc64/sysdep.h (PSEUDO_RET): Add branch hit.
* sysdeps/unix/sysv/linux/powerpc/bits/stat.h (STAT_VER_LINUX):
Fix type. Move definition out of #if.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/ftruncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S: Add cancellation
support.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Remove
ftruncate64, pread64, pwrite64, truncate64 entries.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
(INLINE_SYSCALL): New version that supports function call like
syscalls. Add __builtin_expect.
(LOADARGS_n): Add argument size safety checks.
(INTERNAL_SYSCALL): New Macro.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/truncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h [__PPC_ELF_H]: Avoid
redefinition of elf_fpreg_t and elf_fpregset_t.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* elf/dl-close.c (_dl_close): Add several asserts. Correct and
simplify test for unloading. If loader of a DSO is unloaded do not
use its scope anymore. Fall back to own scope and adjust opencounts.
Fix several comments.
* elf/dl-deps.c (_dl_map_object_deps): Always allocate memory for
the l_searchlist, not only for l_initfini.
* elf/dl-lookup.c (add_dependencies): Avoid creating relocation
dependencies if objects cannot be removed. Remove object with the
definition as not unloadable if necessary.
* elf/reldep6.c: Create relocation dependency before closing the first
module.
2003-01-10 Guido Gnther <agx@sigxcpu.org>
* elf/Makefile: Add rules to build and run reldep9 test.
* elf/reldep9.c: New file.
* elf/reldep9mod1.c: New file.
* elf/reldep9mod2.c: New file.
* elf/reldep9mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile: Add rules to build and run nodelete2 test.
* elf/nodelete2.c: New file.
* elf/nodel2mod1.c: New file.
* elf/nodel2mod2.c: New file.
* elf/nodel2mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
2003-01-12 10:11:16 +00:00
|
|
|
TLS_PRE_TCB_SIZE + TLS_TCB_SIZE);
|
|
|
|
# endif
|
2002-11-14 00:48:38 +00:00
|
|
|
|
2002-08-20 07:22:11 +00:00
|
|
|
result = allocate_dtv (result);
|
|
|
|
if (result == NULL)
|
|
|
|
free (allocated);
|
2002-08-05 01:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2002-08-20 00:23:31 +00:00
|
|
|
|
2002-08-05 01:20:52 +00:00
|
|
|
|
|
|
|
void *
|
|
|
|
internal_function
|
|
|
|
_dl_allocate_tls_init (void *result)
|
|
|
|
{
|
2002-08-20 00:23:31 +00:00
|
|
|
if (result == NULL)
|
|
|
|
/* The memory allocation failed. */
|
|
|
|
return NULL;
|
|
|
|
|
2003-01-30 20:46:44 +00:00
|
|
|
dtv_t *dtv = GET_DTV (result);
|
|
|
|
struct dtv_slotinfo_list *listp;
|
|
|
|
size_t total = 0;
|
2005-01-06 22:40:27 +00:00
|
|
|
size_t maxgen = 0;
|
2003-01-30 20:46:44 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
/* We have to prepare the dtv for all currently loaded modules using
|
|
|
|
TLS. For those which are dynamically loaded we add the values
|
|
|
|
indicating deferred allocation. */
|
2002-08-05 01:20:52 +00:00
|
|
|
listp = GL(dl_tls_dtv_slotinfo_list);
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
size_t cnt;
|
|
|
|
|
2002-08-12 08:48:51 +00:00
|
|
|
for (cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
|
2002-02-09 01:41:44 +00:00
|
|
|
{
|
2002-08-05 01:20:52 +00:00
|
|
|
struct link_map *map;
|
|
|
|
void *dest;
|
2002-02-13 08:03:56 +00:00
|
|
|
|
2002-08-05 01:20:52 +00:00
|
|
|
/* Check for the total number of used slots. */
|
|
|
|
if (total + cnt > GL(dl_tls_max_dtv_idx))
|
|
|
|
break;
|
2002-02-13 08:03:56 +00:00
|
|
|
|
2002-08-05 01:20:52 +00:00
|
|
|
map = listp->slotinfo[cnt].map;
|
|
|
|
if (map == NULL)
|
|
|
|
/* Unused entry. */
|
|
|
|
continue;
|
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
/* Keep track of the maximum generation number. This might
|
|
|
|
not be the generation counter. */
|
|
|
|
maxgen = MAX (maxgen, listp->slotinfo[cnt].gen);
|
|
|
|
|
2003-04-25 09:12:43 +00:00
|
|
|
if (map->l_tls_offset == NO_TLS_OFFSET)
|
2002-08-05 01:20:52 +00:00
|
|
|
{
|
|
|
|
/* For dynamically loaded modules we simply store
|
|
|
|
the value indicating deferred allocation. */
|
2005-01-06 22:40:27 +00:00
|
|
|
dtv[map->l_tls_modid].pointer.val = TLS_DTV_UNALLOCATED;
|
|
|
|
dtv[map->l_tls_modid].pointer.is_static = false;
|
2002-08-05 01:20:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
2002-02-13 08:03:56 +00:00
|
|
|
|
2002-08-05 01:20:52 +00:00
|
|
|
assert (map->l_tls_modid == cnt);
|
|
|
|
assert (map->l_tls_blocksize >= map->l_tls_initimage_size);
|
2002-02-09 01:41:44 +00:00
|
|
|
# if TLS_TCB_AT_TP
|
2003-04-12 20:32:01 +00:00
|
|
|
assert ((size_t) map->l_tls_offset >= map->l_tls_blocksize);
|
2002-08-05 01:20:52 +00:00
|
|
|
dest = (char *) result - map->l_tls_offset;
|
2002-02-09 01:41:44 +00:00
|
|
|
# elif TLS_DTV_AT_TP
|
2002-08-05 01:20:52 +00:00
|
|
|
dest = (char *) result + map->l_tls_offset;
|
2002-02-09 01:41:44 +00:00
|
|
|
# else
|
|
|
|
# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
|
|
|
|
# endif
|
|
|
|
|
2002-08-06 00:51:51 +00:00
|
|
|
/* Copy the initialization image and clear the BSS part. */
|
2005-01-06 22:40:27 +00:00
|
|
|
dtv[map->l_tls_modid].pointer.val = dest;
|
|
|
|
dtv[map->l_tls_modid].pointer.is_static = true;
|
2002-08-06 00:51:51 +00:00
|
|
|
memset (__mempcpy (dest, map->l_tls_initimage,
|
|
|
|
map->l_tls_initimage_size), '\0',
|
|
|
|
map->l_tls_blocksize - map->l_tls_initimage_size);
|
2002-02-09 01:41:44 +00:00
|
|
|
}
|
|
|
|
|
2002-08-05 01:20:52 +00:00
|
|
|
total += cnt;
|
2002-08-12 08:48:51 +00:00
|
|
|
if (total >= GL(dl_tls_max_dtv_idx))
|
2002-08-05 01:20:52 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
listp = listp->next;
|
|
|
|
assert (listp != NULL);
|
2002-02-09 01:41:44 +00:00
|
|
|
}
|
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
/* The DTV version is up-to-date now. */
|
|
|
|
dtv[0].counter = maxgen;
|
|
|
|
|
2002-02-09 01:41:44 +00:00
|
|
|
return result;
|
|
|
|
}
|
2002-10-10 06:47:09 +00:00
|
|
|
rtld_hidden_def (_dl_allocate_tls_init)
|
2002-02-23 07:59:56 +00:00
|
|
|
|
2002-08-05 01:20:52 +00:00
|
|
|
void *
|
|
|
|
internal_function
|
2002-08-20 07:22:11 +00:00
|
|
|
_dl_allocate_tls (void *mem)
|
2002-08-05 01:20:52 +00:00
|
|
|
{
|
2002-08-20 07:22:11 +00:00
|
|
|
return _dl_allocate_tls_init (mem == NULL
|
|
|
|
? _dl_allocate_tls_storage ()
|
|
|
|
: allocate_dtv (mem));
|
2002-08-05 01:20:52 +00:00
|
|
|
}
|
2003-01-03 21:15:43 +00:00
|
|
|
rtld_hidden_def (_dl_allocate_tls)
|
2002-08-20 00:23:31 +00:00
|
|
|
|
2002-02-23 07:59:56 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
internal_function
|
2002-08-20 07:22:11 +00:00
|
|
|
_dl_deallocate_tls (void *tcb, bool dealloc_tcb)
|
2002-02-23 07:59:56 +00:00
|
|
|
{
|
|
|
|
dtv_t *dtv = GET_DTV (tcb);
|
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
/* We need to free the memory allocated for non-static TLS. */
|
|
|
|
for (size_t cnt = 0; cnt < dtv[-1].counter; ++cnt)
|
|
|
|
if (! dtv[1 + cnt].pointer.is_static
|
|
|
|
&& dtv[1 + cnt].pointer.val != TLS_DTV_UNALLOCATED)
|
|
|
|
free (dtv[1 + cnt].pointer.val);
|
|
|
|
|
2002-02-23 07:59:56 +00:00
|
|
|
/* The array starts with dtv[-1]. */
|
2003-03-03 18:36:14 +00:00
|
|
|
#ifdef SHARED
|
|
|
|
if (dtv != GL(dl_initial_dtv))
|
|
|
|
#endif
|
|
|
|
free (dtv - 1);
|
2002-02-23 07:59:56 +00:00
|
|
|
|
2002-08-20 07:22:11 +00:00
|
|
|
if (dealloc_tcb)
|
2002-10-15 08:38:53 +00:00
|
|
|
{
|
|
|
|
# if TLS_TCB_AT_TP
|
|
|
|
/* The TCB follows the TLS blocks. Back up to free the whole block. */
|
|
|
|
tcb -= GL(dl_tls_static_size) - TLS_TCB_SIZE;
|
Update.
2003-01-11 Jim Meyering <jim@meyering.net>
* io/ftw.c [HAVE_CONFIG_H]: Include <config.h>.
[HAVE_SYS_PARAM_H || _LIBC]: Guard inclusion of <sys/param.h>.
Include <sys/stat.h>, not <include/sys/stat.h>, if !_LIBC.
[!_LIBC] (__chdir, __closedir, __fchdir, __getcwd, __opendir): Define.
[!_LIBC] (__readdir64, __tdestroy, __tfind, __tsearch): Define.
[!_LIBC] (internal_function, dirent64, MAX): Define.
(__set_errno): Define if not already defined.
(open_dir_stream): When FTW_CHDIR is enabled, invoke opendir on
the basename, not the entire file name.
(process_entry): When FTW_CHDIR is enabled, invoke XSTAT or LXSTAT on
the basename, not the entire file name.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* string/tester.c (test_strcpy): Disable last added strcpy until
it is fixed.
2003-01-11 Philip Blundell <philb@gnu.org>
* sysdeps/unix/sysv/linux/arm/socket.S: Add cancellation support.
2003-01-11 Andreas Schwab <schwab@suse.de>
* Makerules: Add vpath for %.dynsym and %.so so that the
implicit rule chaining for check-abi works.
2003-01-11 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
Add non-PIC case.
2003-01-11 Jakub Jelinek <jakub@redhat.com>
* elf/tls-macros.h [__ia64__] (__TLS_CALL_CLOBBERS): Define.
[__ia64__] (TLS_LE, TLS_IE): Fix typos. Add ;; at start of asm if
gp is used early.
[__ia64__] (TLS_LD, TLS_GD): Likewise. Use __TLS_CALL_CLOBBERS.
* elf/Makefile ($(objpfx)tst-tlsmod5.so, $(objpfx)tst-tlsmod6.so):
Ensure libc.so in DT_NEEDED.
* sysdeps/alpha/dl-machine.h (elf_machine_rela): Move
CHECK_STATIC_TLS before l_tls_offset use.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela):
Likewise.
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage) [TLS_DTV_AT_TP]:
Allocate TLS_PRE_TCB_SIZE bytes below result.
(_dl_deallocate_tls) [TLS_DTV_AT_TP]: Adjust before freeing.
* sysdeps/generic/libc-tls.c (__libc_setup_tls): If
TLS_INIT_TP_EXPENSIVE is not defined, allocate even if no PT_TLS
segment has been found. If TLS_DTV_AT_TP, allocate TLS_PRE_TCB_SIZE
bytes below result and add tcb_offset to memsz.
* sysdeps/ia64/dl-tls.h (__tls_get_addr): New prototype.
* sysdeps/ia64/dl-machine.h: Include tls.h.
(elf_machine_type_class): Return ELF_RTYPE_CLASS_PLT for TLS relocs
too.
(elf_machine_rela): Assume if sym_map != NULL sym is non-NULL too.
Handle R_IA64_DTPMOD*, R_IA64_DTPREL* and R_IA64_TPREL* relocations.
* sysdeps/ia64/libc-tls.c: New file.
2003-01-10 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/powerpc64/sysdep.h (PSEUDO_RET): Add branch hit.
* sysdeps/unix/sysv/linux/powerpc/bits/stat.h (STAT_VER_LINUX):
Fix type. Move definition out of #if.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/ftruncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S: Add cancellation
support.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Remove
ftruncate64, pread64, pwrite64, truncate64 entries.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
(INLINE_SYSCALL): New version that supports function call like
syscalls. Add __builtin_expect.
(LOADARGS_n): Add argument size safety checks.
(INTERNAL_SYSCALL): New Macro.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/truncate64.c: New file.
* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h [__PPC_ELF_H]: Avoid
redefinition of elf_fpreg_t and elf_fpregset_t.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* elf/dl-close.c (_dl_close): Add several asserts. Correct and
simplify test for unloading. If loader of a DSO is unloaded do not
use its scope anymore. Fall back to own scope and adjust opencounts.
Fix several comments.
* elf/dl-deps.c (_dl_map_object_deps): Always allocate memory for
the l_searchlist, not only for l_initfini.
* elf/dl-lookup.c (add_dependencies): Avoid creating relocation
dependencies if objects cannot be removed. Remove object with the
definition as not unloadable if necessary.
* elf/reldep6.c: Create relocation dependency before closing the first
module.
2003-01-10 Guido Gnther <agx@sigxcpu.org>
* elf/Makefile: Add rules to build and run reldep9 test.
* elf/reldep9.c: New file.
* elf/reldep9mod1.c: New file.
* elf/reldep9mod2.c: New file.
* elf/reldep9mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile: Add rules to build and run nodelete2 test.
* elf/nodelete2.c: New file.
* elf/nodel2mod1.c: New file.
* elf/nodel2mod2.c: New file.
* elf/nodel2mod3.c: New file.
2003-01-09 Jakub Jelinek <jakub@redhat.com>
2003-01-12 10:11:16 +00:00
|
|
|
# elif TLS_DTV_AT_TP
|
|
|
|
/* Back up the TLS_PRE_TCB_SIZE bytes. */
|
|
|
|
tcb -= (TLS_PRE_TCB_SIZE + GL(dl_tls_static_align) - 1)
|
|
|
|
& ~(GL(dl_tls_static_align) - 1);
|
2002-10-15 08:38:53 +00:00
|
|
|
# endif
|
|
|
|
free (tcb);
|
|
|
|
}
|
2002-02-23 07:59:56 +00:00
|
|
|
}
|
2003-01-03 21:15:43 +00:00
|
|
|
rtld_hidden_def (_dl_deallocate_tls)
|
2002-02-09 01:41:44 +00:00
|
|
|
|
|
|
|
|
2002-02-13 08:03:56 +00:00
|
|
|
# ifdef SHARED
|
2002-02-07 04:08:19 +00:00
|
|
|
/* The __tls_get_addr function has two basic forms which differ in the
|
|
|
|
arguments. The IA-64 form takes two parameters, the module ID and
|
|
|
|
offset. The form used, among others, on IA-32 takes a reference to
|
|
|
|
a special structure which contain the same information. The second
|
|
|
|
form seems to be more often used (in the moment) so we default to
|
|
|
|
it. Users of the IA-64 form have to provide adequate definitions
|
|
|
|
of the following macros. */
|
2002-02-13 08:03:56 +00:00
|
|
|
# ifndef GET_ADDR_ARGS
|
|
|
|
# define GET_ADDR_ARGS tls_index *ti
|
|
|
|
# endif
|
|
|
|
# ifndef GET_ADDR_MODULE
|
|
|
|
# define GET_ADDR_MODULE ti->ti_module
|
|
|
|
# endif
|
|
|
|
# ifndef GET_ADDR_OFFSET
|
|
|
|
# define GET_ADDR_OFFSET ti->ti_offset
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
|
|
|
allocate_and_init (struct link_map *map)
|
|
|
|
{
|
|
|
|
void *newp;
|
|
|
|
|
|
|
|
newp = __libc_memalign (map->l_tls_align, map->l_tls_blocksize);
|
|
|
|
if (newp == NULL)
|
|
|
|
oom ();
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2002-02-13 08:03:56 +00:00
|
|
|
/* Initialize the memory. */
|
|
|
|
memset (__mempcpy (newp, map->l_tls_initimage, map->l_tls_initimage_size),
|
|
|
|
'\0', map->l_tls_blocksize - map->l_tls_initimage_size);
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2002-02-13 08:03:56 +00:00
|
|
|
return newp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
struct link_map *
|
|
|
|
_dl_update_slotinfo (unsigned long int req_modid)
|
2002-02-07 04:08:19 +00:00
|
|
|
{
|
2004-12-22 20:10:10 +00:00
|
|
|
struct link_map *the_map = NULL;
|
2005-01-06 22:40:27 +00:00
|
|
|
dtv_t *dtv = THREAD_DTV ();
|
2002-02-13 08:03:56 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
/* The global dl_tls_dtv_slotinfo array contains for each module
|
|
|
|
index the generation counter current when the entry was created.
|
|
|
|
This array never shrinks so that all module indices which were
|
|
|
|
valid at some time can be used to access it. Before the first
|
|
|
|
use of a new module index in this function the array was extended
|
|
|
|
appropriately. Access also does not have to be guarded against
|
|
|
|
modifications of the array. It is assumed that pointer-size
|
|
|
|
values can be read atomically even in SMP environments. It is
|
|
|
|
possible that other threads at the same time dynamically load
|
|
|
|
code and therefore add to the slotinfo list. This is a problem
|
|
|
|
since we must not pick up any information about incomplete work.
|
|
|
|
The solution to this is to ignore all dtv slots which were
|
|
|
|
created after the one we are currently interested. We know that
|
|
|
|
dynamic loading for this module is completed and this is the last
|
|
|
|
load operation we know finished. */
|
|
|
|
unsigned long int idx = req_modid;
|
|
|
|
struct dtv_slotinfo_list *listp = GL(dl_tls_dtv_slotinfo_list);
|
|
|
|
|
|
|
|
while (idx >= listp->len)
|
2002-02-13 08:03:56 +00:00
|
|
|
{
|
2005-01-06 22:40:27 +00:00
|
|
|
idx -= listp->len;
|
|
|
|
listp = listp->next;
|
|
|
|
}
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
if (dtv[0].counter < listp->slotinfo[idx].gen)
|
|
|
|
{
|
|
|
|
/* The generation counter for the slot is higher than what the
|
|
|
|
current dtv implements. We have to update the whole dtv but
|
|
|
|
only those entries with a generation counter <= the one for
|
|
|
|
the entry we need. */
|
|
|
|
size_t new_gen = listp->slotinfo[idx].gen;
|
|
|
|
size_t total = 0;
|
|
|
|
|
|
|
|
/* We have to look through the entire dtv slotinfo list. */
|
|
|
|
listp = GL(dl_tls_dtv_slotinfo_list);
|
|
|
|
do
|
2002-02-13 08:03:56 +00:00
|
|
|
{
|
2005-01-06 22:40:27 +00:00
|
|
|
for (size_t cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
|
2002-02-13 08:03:56 +00:00
|
|
|
{
|
2005-01-06 22:40:27 +00:00
|
|
|
size_t gen = listp->slotinfo[cnt].gen;
|
|
|
|
|
|
|
|
if (gen > new_gen)
|
|
|
|
/* This is a slot for a generation younger than the
|
|
|
|
one we are handling now. It might be incompletely
|
|
|
|
set up so ignore it. */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* If the entry is older than the current dtv layout we
|
|
|
|
know we don't have to handle it. */
|
|
|
|
if (gen <= dtv[0].counter)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* If there is no map this means the entry is empty. */
|
|
|
|
struct link_map *map = listp->slotinfo[cnt].map;
|
|
|
|
if (map == NULL)
|
2007-07-12 18:26:36 +00:00
|
|
|
{
|
2005-01-06 22:40:27 +00:00
|
|
|
/* If this modid was used at some point the memory
|
|
|
|
might still be allocated. */
|
|
|
|
if (! dtv[total + cnt].pointer.is_static
|
|
|
|
&& dtv[total + cnt].pointer.val != TLS_DTV_UNALLOCATED)
|
2002-02-13 08:03:56 +00:00
|
|
|
{
|
2005-01-06 22:40:27 +00:00
|
|
|
free (dtv[total + cnt].pointer.val);
|
|
|
|
dtv[total + cnt].pointer.val = TLS_DTV_UNALLOCATED;
|
2002-02-13 08:03:56 +00:00
|
|
|
}
|
2004-12-22 20:10:10 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check whether the current dtv array is large enough. */
|
|
|
|
size_t modid = map->l_tls_modid;
|
|
|
|
assert (total + cnt == modid);
|
|
|
|
if (dtv[-1].counter < modid)
|
|
|
|
{
|
|
|
|
/* Reallocate the dtv. */
|
|
|
|
dtv_t *newp;
|
|
|
|
size_t newsize = GL(dl_tls_max_dtv_idx) + DTV_SURPLUS;
|
|
|
|
size_t oldsize = dtv[-1].counter;
|
|
|
|
|
|
|
|
assert (map->l_tls_modid <= newsize);
|
|
|
|
|
|
|
|
if (dtv == GL(dl_initial_dtv))
|
2007-07-12 18:26:36 +00:00
|
|
|
{
|
2005-01-06 22:40:27 +00:00
|
|
|
/* This is the initial dtv that was allocated
|
|
|
|
during rtld startup using the dl-minimal.c
|
|
|
|
malloc instead of the real malloc. We can't
|
|
|
|
free it, we have to abandon the old storage. */
|
|
|
|
|
|
|
|
newp = malloc ((2 + newsize) * sizeof (dtv_t));
|
|
|
|
if (newp == NULL)
|
|
|
|
oom ();
|
|
|
|
memcpy (newp, &dtv[-1], oldsize * sizeof (dtv_t));
|
2007-07-12 18:26:36 +00:00
|
|
|
}
|
2005-01-06 22:40:27 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
newp = realloc (&dtv[-1],
|
|
|
|
(2 + newsize) * sizeof (dtv_t));
|
|
|
|
if (newp == NULL)
|
|
|
|
oom ();
|
|
|
|
}
|
|
|
|
|
|
|
|
newp[0].counter = newsize;
|
|
|
|
|
|
|
|
/* Clear the newly allocated part. */
|
|
|
|
memset (newp + 2 + oldsize, '\0',
|
|
|
|
(newsize - oldsize) * sizeof (dtv_t));
|
|
|
|
|
|
|
|
/* Point dtv to the generation counter. */
|
|
|
|
dtv = &newp[1];
|
2007-07-12 18:26:36 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
/* Install this new dtv in the thread data
|
|
|
|
structures. */
|
|
|
|
INSTALL_NEW_DTV (dtv);
|
2002-02-13 08:03:56 +00:00
|
|
|
}
|
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
/* If there is currently memory allocate for this
|
|
|
|
dtv entry free it. */
|
|
|
|
/* XXX Ideally we will at some point create a memory
|
|
|
|
pool. */
|
|
|
|
if (! dtv[modid].pointer.is_static
|
|
|
|
&& dtv[modid].pointer.val != TLS_DTV_UNALLOCATED)
|
|
|
|
/* Note that free is called for NULL is well. We
|
|
|
|
deallocate even if it is this dtv entry we are
|
|
|
|
supposed to load. The reason is that we call
|
|
|
|
memalign and not malloc. */
|
|
|
|
free (dtv[modid].pointer.val);
|
|
|
|
|
|
|
|
/* This module is loaded dynamically- We defer memory
|
|
|
|
allocation. */
|
|
|
|
dtv[modid].pointer.is_static = false;
|
|
|
|
dtv[modid].pointer.val = TLS_DTV_UNALLOCATED;
|
|
|
|
|
|
|
|
if (modid == req_modid)
|
|
|
|
the_map = map;
|
2002-02-13 08:03:56 +00:00
|
|
|
}
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
total += listp->len;
|
2002-02-13 08:03:56 +00:00
|
|
|
}
|
2005-01-06 22:40:27 +00:00
|
|
|
while ((listp = listp->next) != NULL);
|
|
|
|
|
|
|
|
/* This will be the new maximum generation counter. */
|
|
|
|
dtv[0].counter = new_gen;
|
2002-02-13 08:03:56 +00:00
|
|
|
}
|
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
return the_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* The generic dynamic and local dynamic model cannot be used in
|
|
|
|
statically linked applications. */
|
|
|
|
void *
|
|
|
|
__tls_get_addr (GET_ADDR_ARGS)
|
|
|
|
{
|
|
|
|
dtv_t *dtv = THREAD_DTV ();
|
|
|
|
struct link_map *the_map = NULL;
|
|
|
|
void *p;
|
|
|
|
|
|
|
|
if (__builtin_expect (dtv[0].counter != GL(dl_tls_generation), 0))
|
|
|
|
the_map = _dl_update_slotinfo (GET_ADDR_MODULE);
|
|
|
|
|
|
|
|
p = dtv[GET_ADDR_MODULE].pointer.val;
|
2002-02-13 08:03:56 +00:00
|
|
|
|
|
|
|
if (__builtin_expect (p == TLS_DTV_UNALLOCATED, 0))
|
|
|
|
{
|
|
|
|
/* The allocation was deferred. Do it now. */
|
|
|
|
if (the_map == NULL)
|
|
|
|
{
|
|
|
|
/* Find the link map for this module. */
|
|
|
|
size_t idx = GET_ADDR_MODULE;
|
|
|
|
struct dtv_slotinfo_list *listp = GL(dl_tls_dtv_slotinfo_list);
|
|
|
|
|
|
|
|
while (idx >= listp->len)
|
|
|
|
{
|
|
|
|
idx -= listp->len;
|
|
|
|
listp = listp->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
the_map = listp->slotinfo[idx].map;
|
|
|
|
}
|
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
p = dtv[GET_ADDR_MODULE].pointer.val = allocate_and_init (the_map);
|
|
|
|
dtv[GET_ADDR_MODULE].pointer.is_static = false;
|
2002-02-13 08:03:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (char *) p + GET_ADDR_OFFSET;
|
2002-02-07 04:08:19 +00:00
|
|
|
}
|
2002-02-13 08:03:56 +00:00
|
|
|
# endif
|
2002-02-07 04:08:19 +00:00
|
|
|
|
2005-01-06 22:40:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
_dl_add_to_slotinfo (struct link_map *l)
|
|
|
|
{
|
|
|
|
/* Now that we know the object is loaded successfully add
|
|
|
|
modules containing TLS data to the dtv info table. We
|
|
|
|
might have to increase its size. */
|
|
|
|
struct dtv_slotinfo_list *listp;
|
|
|
|
struct dtv_slotinfo_list *prevp;
|
|
|
|
size_t idx = l->l_tls_modid;
|
|
|
|
|
|
|
|
/* Find the place in the dtv slotinfo list. */
|
|
|
|
listp = GL(dl_tls_dtv_slotinfo_list);
|
|
|
|
prevp = NULL; /* Needed to shut up gcc. */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
/* Does it fit in the array of this list element? */
|
|
|
|
if (idx < listp->len)
|
|
|
|
break;
|
|
|
|
idx -= listp->len;
|
|
|
|
prevp = listp;
|
|
|
|
listp = listp->next;
|
|
|
|
}
|
|
|
|
while (listp != NULL);
|
|
|
|
|
|
|
|
if (listp == NULL)
|
|
|
|
{
|
|
|
|
/* When we come here it means we have to add a new element
|
|
|
|
to the slotinfo list. And the new module must be in
|
|
|
|
the first slot. */
|
|
|
|
assert (idx == 0);
|
|
|
|
|
|
|
|
listp = prevp->next = (struct dtv_slotinfo_list *)
|
|
|
|
malloc (sizeof (struct dtv_slotinfo_list)
|
|
|
|
+ TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
|
|
|
|
if (listp == NULL)
|
|
|
|
{
|
|
|
|
/* We ran out of memory. We will simply fail this
|
|
|
|
call but don't undo anything we did so far. The
|
|
|
|
application will crash or be terminated anyway very
|
|
|
|
soon. */
|
|
|
|
|
|
|
|
/* We have to do this since some entries in the dtv
|
|
|
|
slotinfo array might already point to this
|
|
|
|
generation. */
|
|
|
|
++GL(dl_tls_generation);
|
|
|
|
|
|
|
|
_dl_signal_error (ENOMEM, "dlopen", NULL, N_("\
|
|
|
|
cannot create TLS data structures"));
|
|
|
|
}
|
|
|
|
|
|
|
|
listp->len = TLS_SLOTINFO_SURPLUS;
|
|
|
|
listp->next = NULL;
|
|
|
|
memset (listp->slotinfo, '\0',
|
|
|
|
TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the information into the slotinfo data structure. */
|
|
|
|
listp->slotinfo[idx].map = l;
|
|
|
|
listp->slotinfo[idx].gen = GL(dl_tls_generation) + 1;
|
|
|
|
}
|
2002-02-07 04:08:19 +00:00
|
|
|
#endif /* use TLS */
|