summaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-10-29 22:03:29 +0000
committerJakub Jelinek <jakub@redhat.com>2006-10-29 22:03:29 +0000
commit8dd5fcaca8ce7e43ed49879235f08d45d2a4a2e5 (patch)
tree196eec145dc3a6fb925a5b07d831b21d761d7c20 /elf
parent48b752c9f6499f0de89766c94b3b1bedbfd6476e (diff)
downloadglibc-8dd5fcaca8ce7e43ed49879235f08d45d2a4a2e5.tar.gz
Updated to fedora-glibc-20061029T2155cvs/fedora-glibc-2_5_90-3
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile18
-rw-r--r--elf/dl-addr.c4
-rw-r--r--elf/dl-cache.c6
-rw-r--r--elf/dl-close.c74
-rw-r--r--elf/dl-iteratephdr.c2
-rw-r--r--elf/dl-load.c13
-rw-r--r--elf/dl-lookup.c2
-rw-r--r--elf/dl-object.c2
-rw-r--r--elf/dl-open.c16
-rw-r--r--elf/dl-reloc.c24
-rw-r--r--elf/dl-runtime.c8
-rw-r--r--elf/dl-support.c4
-rw-r--r--elf/dl-sym.c10
-rw-r--r--elf/dl-sysdep.c32
-rw-r--r--elf/dl-tls.c79
-rw-r--r--elf/ldconfig.c2
-rw-r--r--elf/rtld.c53
-rw-r--r--elf/tst-thrlock.c59
-rw-r--r--elf/tst-tls-dlinfo.c4
-rw-r--r--elf/tst-tls1.c8
-rw-r--r--elf/tst-tls10.h3
-rw-r--r--elf/tst-tls14.c8
-rw-r--r--elf/tst-tls2.c8
-rw-r--r--elf/tst-tls3.c8
-rw-r--r--elf/tst-tls4.c4
-rw-r--r--elf/tst-tls5.c4
-rw-r--r--elf/tst-tls6.c4
-rw-r--r--elf/tst-tls7.c4
-rw-r--r--elf/tst-tls8.c4
-rw-r--r--elf/tst-tls9.c4
-rw-r--r--elf/tst-tlsmod1.c4
-rw-r--r--elf/tst-tlsmod13.c3
-rw-r--r--elf/tst-tlsmod13a.c3
-rw-r--r--elf/tst-tlsmod14a.c10
-rw-r--r--elf/tst-tlsmod2.c2
-rw-r--r--elf/tst-tlsmod3.c4
-rw-r--r--elf/tst-tlsmod4.c4
-rw-r--r--elf/tst-tlsmod5.c2
-rw-r--r--elf/tst-tlsmod6.c2
39 files changed, 203 insertions, 302 deletions
diff --git a/elf/Makefile b/elf/Makefile
index b1a9bab022..afebaec1ec 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -159,8 +159,8 @@ endif
ifeq (yes,$(build-shared))
tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
constload1 order $(tests-vis-$(have-protected)) noload filter unload \
- reldep reldep2 reldep3 reldep4 $(tests-nodelete-$(have-z-nodelete)) \
- $(tests-nodlopen-$(have-z-nodlopen)) neededtest neededtest2 \
+ reldep reldep2 reldep3 reldep4 nodelete nodelete2 \
+ nodlopen nodlopen2 neededtest neededtest2 \
neededtest3 neededtest4 unload2 lateglobal initfirst global \
restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \
circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \
@@ -171,12 +171,10 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
unload3 unload4 unload5 unload6 unload7 tst-global1 order2 \
tst-audit1 tst-audit2 \
- tst-stackguard1 tst-addr1
+ tst-stackguard1 tst-addr1 tst-thrlock
# reldep9
test-srcs = tst-pathopt
tests-vis-yes = vismain
-tests-nodelete-yes = nodelete nodelete2
-tests-nodlopen-yes = nodlopen nodlopen2
tests-execstack-yes = tst-execstack tst-execstack-needed tst-execstack-prog
endif
ifeq (yesyes,$(have-fpie)$(build-shared))
@@ -186,8 +184,9 @@ tests: $(objpfx)tst-leaks1-mem
modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
testobj1_1 failobj constload2 constload3 unloadmod \
dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \
- $(modules-nodelete-$(have-z-nodelete)) \
- $(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \
+ nodelmod1 nodelmod2 nodelmod3 nodelmod4 \
+ nodel2mod1 nodel2mod2 nodel2mod3 \
+ nodlopenmod nodlopenmod2 filtmod1 filtmod2 \
reldepmod1 reldepmod2 reldepmod3 reldepmod4 nextmod1 nextmod2 \
reldep4mod1 reldep4mod2 reldep4mod3 reldep4mod4 \
neededobj1 neededobj2 neededobj3 neededobj4 \
@@ -221,9 +220,6 @@ ifeq (yesyes,$(have-fpie)$(build-shared))
modules-names += tst-piemod1
endif
modules-vis-yes = vismod1 vismod2 vismod3
-modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4 \
- nodel2mod1 nodel2mod2 nodel2mod3
-modules-nodlopen-yes = nodlopenmod nodlopenmod2
modules-execstack-yes = tst-execstack-mod
extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
# We need this variable to be sure the test modules get the right CPPFLAGS.
@@ -916,3 +912,5 @@ $(objpfx)tst-leaks1-mem: $(objpfx)tst-leaks1.out
tst-leaks1-ENV = MALLOC_TRACE=$(objpfx)tst-leaks1.mtrace
$(objpfx)tst-addr1: $(libdl)
+
+$(objpfx)tst-thrlock: $(libdl) $(shared-thread-library)
diff --git a/elf/dl-addr.c b/elf/dl-addr.c
index 720b24d04b..e55dc4b46f 100644
--- a/elf/dl-addr.c
+++ b/elf/dl-addr.c
@@ -93,9 +93,7 @@ _dl_addr (const void *address, Dl_info *info,
so we can omit that test here. */
if ((symtab[symndx].st_shndx != SHN_UNDEF
|| symtab[symndx].st_value != 0)
-#ifdef USE_TLS
&& ELFW(ST_TYPE) (symtab[symndx].st_info) != STT_TLS
-#endif
&& DL_ADDR_SYM_MATCH (match, &symtab[symndx],
matchsym, addr)
&& symtab[symndx].st_name < strtabsize)
@@ -123,9 +121,7 @@ _dl_addr (const void *address, Dl_info *info,
for (; (void *) symtab < (void *) symtabend; ++symtab)
if ((ELFW(ST_BIND) (symtab->st_info) == STB_GLOBAL
|| ELFW(ST_BIND) (symtab->st_info) == STB_WEAK)
-#ifdef USE_TLS
&& ELFW(ST_TYPE) (symtab->st_info) != STT_TLS
-#endif
&& (symtab->st_shndx != SHN_UNDEF
|| symtab->st_value != 0)
&& DL_ADDR_SYM_MATCH (match, symtab, matchsym, addr)
diff --git a/elf/dl-cache.c b/elf/dl-cache.c
index fc7d9916c6..bbeba77e4a 100644
--- a/elf/dl-cache.c
+++ b/elf/dl-cache.c
@@ -256,11 +256,7 @@ _dl_load_cache_lookup (const char *name)
platform = 1ULL << platform;
/* Only accept hwcap if it's for the right platform. */
-#ifdef USE_TLS
-# define _DL_HWCAP_TLS_MASK (1LL << 63)
-#else
-# define _DL_HWCAP_TLS_MASK 0
-#endif
+#define _DL_HWCAP_TLS_MASK (1LL << 63)
#define HWCAP_CHECK \
if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) \
continue; \
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 31bc80b935..df968fe649 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -41,7 +41,6 @@ typedef void (*fini_t) (void);
#define IDX_STILL_USED -1
-#ifdef USE_TLS
/* Returns true we an non-empty was found. */
static bool
remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp,
@@ -103,26 +102,12 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp,
/* No non-entry in this list element. */
return false;
}
-#endif
void
-_dl_close (void *_map)
+_dl_close_worker (struct link_map *map)
{
- struct link_map *map = _map;
Lmid_t ns = map->l_ns;
- unsigned int i;
- /* First see whether we can remove the object at all. */
- if (__builtin_expect (map->l_flags_1 & DF_1_NODELETE, 0)
- && map->l_init_called)
- /* Nope. Do nothing. */
- return;
-
- if (__builtin_expect (map->l_direct_opencount, 1) == 0)
- GLRO(dl_signal_error) (0, map->l_name, NULL, N_("shared object not open"));
-
- /* Acquire the lock. */
- __rtld_lock_lock_recursive (GL(dl_load_lock));
/* One less direct use. */
--map->l_direct_opencount;
@@ -143,16 +128,13 @@ _dl_close (void *_map)
_dl_debug_printf ("\nclosing file=%s; direct_opencount=%u\n",
map->l_name, map->l_direct_opencount);
- __rtld_lock_unlock_recursive (GL(dl_load_lock));
return;
}
retry:
dl_close_state = pending;
-#ifdef USE_TLS
bool any_tls = false;
-#endif
const unsigned int nloaded = GL(dl_ns)[ns]._ns_nloaded;
char used[nloaded];
char done[nloaded];
@@ -246,7 +228,7 @@ _dl_close (void *_map)
#endif
bool unload_any = false;
unsigned int first_loaded = ~0;
- for (i = 0; i < nloaded; ++i)
+ for (unsigned int i = 0; i < nloaded; ++i)
{
struct link_map *imap = maps[i];
@@ -417,7 +399,7 @@ _dl_close (void *_map)
struct r_scope_elem **old = imap->l_scope;
- if (SINGLE_THREAD_P)
+ if (RTLD_SINGLE_THREAD_P)
imap->l_scope = newp;
else
{
@@ -474,15 +456,13 @@ _dl_close (void *_map)
r->r_state = RT_DELETE;
_dl_debug_state ();
-#ifdef USE_TLS
size_t tls_free_start;
size_t tls_free_end;
tls_free_start = tls_free_end = NO_TLS_OFFSET;
-#endif
/* Check each element of the search list to see if all references to
it are gone. */
- for (i = first_loaded; i < nloaded; ++i)
+ for (unsigned int i = first_loaded; i < nloaded; ++i)
{
struct link_map *imap = maps[i];
if (!used[i])
@@ -509,7 +489,6 @@ _dl_close (void *_map)
--GL(dl_ns)[ns]._ns_main_searchlist->r_nlist;
}
-#ifdef USE_TLS
/* Remove the object from the dtv slotinfo array if it uses TLS. */
if (__builtin_expect (imap->l_tls_blocksize > 0, 0))
{
@@ -528,7 +507,7 @@ _dl_close (void *_map)
this search list, going in either direction. When the
whole chunk is at the end of the used area then we can
reclaim it. */
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
if (tls_free_start == NO_TLS_OFFSET
|| (size_t) imap->l_tls_offset == tls_free_start)
{
@@ -568,7 +547,7 @@ _dl_close (void *_map)
= tls_free_end - imap->l_tls_blocksize;
}
}
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
if ((size_t) imap->l_tls_offset == tls_free_end)
/* Extend the contiguous chunk being reclaimed. */
tls_free_end -= imap->l_tls_blocksize;
@@ -585,12 +564,11 @@ _dl_close (void *_map)
tls_free_start = imap->l_tls_offset;
tls_free_end = tls_free_start + imap->l_tls_blocksize;
}
-# else
-# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
-# endif
+#else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+#endif
}
}
-#endif
/* We can unmap all the maps at once. We determined the
start address and length when we loaded the object and
@@ -656,7 +634,6 @@ _dl_close (void *_map)
}
}
-#ifdef USE_TLS
/* If we removed any object which uses TLS bump the generation counter. */
if (any_tls)
{
@@ -666,7 +643,6 @@ _dl_close (void *_map)
if (tls_free_end == GL(dl_tls_static_used))
GL(dl_tls_static_used) = tls_free_start;
}
-#endif
#ifdef SHARED
/* Auditing checkpoint: we have deleted all objects. */
@@ -698,11 +674,34 @@ _dl_close (void *_map)
goto retry;
dl_close_state = not_pending;
+}
+
+
+void
+_dl_close (void *_map)
+{
+ struct link_map *map = _map;
+
+ /* First see whether we can remove the object at all. */
+ if (__builtin_expect (map->l_flags_1 & DF_1_NODELETE, 0))
+ {
+ assert (map->l_init_called);
+ /* Nope. Do nothing. */
+ return;
+ }
+
+ if (__builtin_expect (map->l_direct_opencount, 1) == 0)
+ GLRO(dl_signal_error) (0, map->l_name, NULL, N_("shared object not open"));
+
+ /* Acquire the lock. */
+ __rtld_lock_lock_recursive (GL(dl_load_lock));
+
+ _dl_close_worker (map);
+
__rtld_lock_unlock_recursive (GL(dl_load_lock));
}
-#ifdef USE_TLS
static bool __libc_freeres_fn_section
free_slotinfo (struct dtv_slotinfo_list **elemp)
{
@@ -729,7 +728,6 @@ free_slotinfo (struct dtv_slotinfo_list **elemp)
return true;
}
-#endif
libc_freeres_fn (free_mem)
@@ -755,22 +753,20 @@ libc_freeres_fn (free_mem)
free (old);
}
-#ifdef USE_TLS
if (USE___THREAD || GL(dl_tls_dtv_slotinfo_list) != NULL)
{
/* Free the memory allocated for the dtv slotinfo array. We can do
this only if all modules which used this memory are unloaded. */
-# ifdef SHARED
+#ifdef SHARED
if (GL(dl_initial_dtv) == NULL)
/* There was no initial TLS setup, it was set up later when
it used the normal malloc. */
free_slotinfo (&GL(dl_tls_dtv_slotinfo_list));
else
-# endif
+#endif
/* The first element of the list does not have to be deallocated.
It was allocated in the dynamic linker (i.e., with a different
malloc), and in the static library it's in .bss space. */
free_slotinfo (&GL(dl_tls_dtv_slotinfo_list)->next);
}
-#endif
}
diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index 52a114421d..d03d8b6daf 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -70,11 +70,9 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
info.dlpi_subs = GL(dl_load_adds) - nloaded;
info.dlpi_tls_modid = 0;
info.dlpi_tls_data = NULL;
-#ifdef USE_TLS
info.dlpi_tls_modid = l->l_tls_modid;
if (info.dlpi_tls_modid != 0)
info.dlpi_tls_data = _dl_tls_get_addr_soft (l);
-#endif
ret = callback (&info, sizeof (struct dl_phdr_info), data);
if (ret)
break;
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 36dc123c01..ccbbf4fdd2 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1085,7 +1085,6 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
break;
case PT_TLS:
-#ifdef USE_TLS
if (ph->p_memsz == 0)
/* Nothing to do for an empty segment. */
break;
@@ -1113,7 +1112,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
break;
}
-# ifdef SHARED
+#ifdef SHARED
if (l->l_prev == NULL || (mode & __RTLD_AUDIT) != 0)
/* We are loading the executable itself when the dynamic linker
was executed directly. The setup will happen later. */
@@ -1122,7 +1121,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
/* In a static binary there is no way to tell if we dynamically
loaded libpthread. */
if (GL(dl_error_catch_tsd) == &_dl_initial_error_catch_tsd)
-# endif
+#endif
{
/* We have not yet loaded libpthread.
We can do the TLS setup right now! */
@@ -1155,7 +1154,6 @@ cannot allocate TLS data structures for initial thread");
_dl_deallocate_tls (tcb, 1);
goto call_lose;
}
-#endif
/* Uh-oh, the binary expects TLS support but we cannot
provide it. */
@@ -1394,7 +1392,7 @@ cannot allocate TLS data structures for initial thread");
requires that it be executable. We must change the
protection of the variable which contains the flags used in
the mprotect calls. */
-#if defined HAVE_Z_RELRO && defined SHARED
+#ifdef SHARED
if ((mode & (__RTLD_DLOPEN | __RTLD_AUDIT)) == __RTLD_DLOPEN)
{
const uintptr_t p = (uintptr_t) &__stack_prot & -GLRO(dl_pagesize);
@@ -1431,11 +1429,9 @@ cannot enable executable stack as shared object requires");
}
}
-#ifdef USE_TLS
/* Adjust the address of the TLS initialization image. */
if (l->l_tls_initimage != NULL)
l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
-#endif
/* We are done mapping in the file. We no longer need the descriptor. */
if (__builtin_expect (__close (fd) != 0, 0))
@@ -1939,11 +1935,10 @@ open_path (const char *name, size_t namelen, int preloaded,
must not be freed using the general free() in libc. */
if (sps->malloced)
free (sps->dirs);
-#ifdef HAVE_Z_RELRO
+
/* rtld_search_dirs is attribute_relro, therefore avoid writing
into it. */
if (sps != &rtld_search_dirs)
-#endif
sps->dirs = (void *) -1;
}
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 29a52165ce..019278c9b0 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -449,12 +449,10 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map,
conflict = 1;
}
-# ifdef USE_TLS
if (value->s
&& (__builtin_expect (ELFW(ST_TYPE) (value->s->st_info)
== STT_TLS, 0)))
type_class = 4;
-# endif
if (conflict
|| GLRO(dl_trace_prelink_map) == undef_map
diff --git a/elf/dl-object.c b/elf/dl-object.c
index 29f44bfd55..33ee860e59 100644
--- a/elf/dl-object.c
+++ b/elf/dl-object.c
@@ -64,7 +64,7 @@ _dl_new_object (char *realname, const char *libname, int type,
new->l_name = realname;
new->l_type = type;
new->l_loader = loader;
-#if defined USE_TLS && NO_TLS_OFFSET != 0
+#if NO_TLS_OFFSET != 0
new->l_tls_offset = NO_TLS_OFFSET;
#endif
new->l_ns = nsid;
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 2a891f244d..c997521126 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -164,9 +164,7 @@ dl_open_worker (void *a)
struct link_map *new, *l;
int lazy;
unsigned int i;
-#ifdef USE_TLS
bool any_tls = false;
-#endif
struct link_map *call_map = NULL;
/* Check whether _dl_open() has been called from a valid DSO. */
@@ -419,7 +417,7 @@ dl_open_worker (void *a)
memcpy (newp, imap->l_scope, cnt * sizeof (imap->l_scope[0]));
struct r_scope_elem **old = imap->l_scope;
- if (SINGLE_THREAD_P)
+ if (RTLD_SINGLE_THREAD_P)
imap->l_scope = newp;
else
{
@@ -441,7 +439,6 @@ dl_open_worker (void *a)
atomic_write_barrier ();
imap->l_scope[cnt] = &new->l_searchlist;
}
-#if USE_TLS
/* Only add TLS memory if this object is loaded now and
therefore is not yet initialized. */
else if (! imap->l_init_called
@@ -456,11 +453,11 @@ dl_open_worker (void *a)
if (imap->l_need_tls_init)
{
imap->l_need_tls_init = 0;
-# ifdef SHARED
+#ifdef SHARED
/* Update the slot information data for at least the
generation of the DSO we are allocating data for. */
_dl_update_slotinfo (imap->l_tls_modid);
-# endif
+#endif
GL(dl_init_static_tls) (imap);
assert (imap->l_need_tls_init == 0);
@@ -469,15 +466,12 @@ dl_open_worker (void *a)
/* We have to bump the generation counter. */
any_tls = true;
}
-#endif
}
-#if USE_TLS
/* Bump the generation number if necessary. */
if (any_tls && __builtin_expect (++GL(dl_tls_generation) == 0, 0))
_dl_fatal_printf (N_("\
TLS generation counter wrapped! Please report this."));
-#endif
/* Run the initializer functions of new objects. */
_dl_init (new, args->argc, args->argv, args->env);
@@ -574,7 +568,6 @@ no more namespaces available for dlmopen()"));
state if relocation failed, for example. */
if (args.map)
{
-#ifdef USE_TLS
/* Maybe some of the modules which were loaded use TLS.
Since it will be removed in the following _dl_close call
we have to mark the dtv array as having gaps to fill the
@@ -584,9 +577,8 @@ no more namespaces available for dlmopen()"));
up. */
if ((mode & __RTLD_AUDIT) == 0)
GL(dl_tls_dtv_gaps) = true;
-#endif
- _dl_close (args.map);
+ _dl_close_worker (args.map);
}
assert (_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT);
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index 117410e924..c315b5d972 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -1,5 +1,5 @@
/* Relocate a shared object and resolve its references to other loaded objects.
- Copyright (C) 1995-2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1995-2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -35,7 +35,6 @@
#endif
-#ifdef USE_TLS
/* We are trying to perform a static TLS relocation in MAP, but it was
dynamically loaded. This can only work if there is enough surplus in
the static TLS area already allocated for each running thread. If this
@@ -56,7 +55,7 @@ _dl_allocate_static_tls (struct link_map *map)
cannot allocate memory in static TLS block"));
}
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
size_t freebytes;
size_t n;
size_t blsize;
@@ -73,7 +72,7 @@ cannot allocate memory in static TLS block"));
- map->l_tls_firstbyte_offset);
map->l_tls_offset = GL(dl_tls_static_used) = offset;
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
size_t used;
size_t check;
@@ -87,9 +86,9 @@ cannot allocate memory in static TLS block"));
map->l_tls_offset = offset;
GL(dl_tls_static_used) = used;
-# else
-# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
-# endif
+#else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+#endif
/* If the object is not yet relocated we cannot initialize the
static TLS region. Delay it. */
@@ -115,13 +114,13 @@ cannot allocate memory in static TLS block"));
void
_dl_nothread_init_static_tls (struct link_map *map)
{
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
void *dest = (char *) THREAD_SELF - map->l_tls_offset;
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
void *dest = (char *) THREAD_SELF + map->l_tls_offset + TLS_PRE_TCB_SIZE;
-# else
-# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
-# endif
+#else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+#endif
/* Fill in the DTV slot so that a later LD/GD access will find it. */
dtv_t *dtv = THREAD_DTV ();
@@ -133,7 +132,6 @@ _dl_nothread_init_static_tls (struct link_map *map)
memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size),
'\0', map->l_tls_blocksize - map->l_tls_initimage_size);
}
-#endif
void
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index 0488fab8d0..afc99f6150 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -93,14 +93,14 @@ _dl_fixup (
version = NULL;
}
- if (l->l_type == lt_loaded && !SINGLE_THREAD_P)
+ if (l->l_type == lt_loaded && !RTLD_SINGLE_THREAD_P)
__rtld_mrlock_lock (l->l_scope_lock);
result = _dl_lookup_symbol_x (strtab + sym->st_name, l, &sym,
l->l_scope, version, ELF_RTYPE_CLASS_PLT,
DL_LOOKUP_ADD_DEPENDENCY, NULL);
- if (l->l_type == lt_loaded && !SINGLE_THREAD_P)
+ if (l->l_type == lt_loaded && !RTLD_SINGLE_THREAD_P)
__rtld_mrlock_unlock (l->l_scope_lock);
/* Currently result contains the base load address (or link map)
@@ -181,7 +181,7 @@ _dl_profile_fixup (
version = NULL;
}
- if (l->l_type == lt_loaded && !SINGLE_THREAD_P)
+ if (l->l_type == lt_loaded && !RTLD_SINGLE_THREAD_P)
__rtld_mrlock_lock (l->l_scope_lock);
result = _dl_lookup_symbol_x (strtab + refsym->st_name, l, &defsym,
@@ -189,7 +189,7 @@ _dl_profile_fixup (
ELF_RTYPE_CLASS_PLT,
DL_LOOKUP_ADD_DEPENDENCY, NULL);
- if (l->l_type == lt_loaded && !SINGLE_THREAD_P)
+ if (l->l_type == lt_loaded && !RTLD_SINGLE_THREAD_P)
__rtld_mrlock_unlock (l->l_scope_lock);
/* Currently result contains the base load address (or link map)
diff --git a/elf/dl-support.c b/elf/dl-support.c
index c3b6350ed3..fe8c68c9e4 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -1,5 +1,5 @@
/* Support for dynamic linking code in static libc.
- Copyright (C) 1996-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1996-2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -97,9 +97,7 @@ int _dl_starting_up = 1;
hp_timing_t _dl_cpuclock_offset;
#endif
-#ifdef USE_TLS
void (*_dl_init_static_tls) (struct link_map *) = &_dl_nothread_init_static_tls;
-#endif
size_t _dl_pagesize;
diff --git a/elf/dl-sym.c b/elf/dl-sym.c
index 8bb564c2fe..88a5adb0d5 100644
--- a/elf/dl-sym.c
+++ b/elf/dl-sym.c
@@ -26,12 +26,10 @@
#include <ldsodefs.h>
#include <dl-hash.h>
#include <sysdep-cancel.h>
-#ifdef USE_TLS
-# include <dl-tls.h>
-#endif
+#include <dl-tls.h>
-#if defined USE_TLS && defined SHARED
+#ifdef SHARED
/* Systems which do not have tls_index also probably have to define
DONT_USE_TLS_INDEX. */
@@ -115,7 +113,7 @@ do_sym (void *handle, const char *name, void *who,
the initial binary. And then the more complex part
where the object is dynamically loaded and the scope
array can change. */
- if (match->l_type != lt_loaded || SINGLE_THREAD_P)
+ if (match->l_type != lt_loaded || RTLD_SINGLE_THREAD_P)
result = GLRO(dl_lookup_symbol_x) (name, match, &ref,
match->l_scope, vers, 0,
flags | DL_LOOKUP_ADD_DEPENDENCY,
@@ -184,7 +182,7 @@ RTLD_NEXT used in code not dynamically loaded"));
{
void *value;
-#if defined USE_TLS && defined SHARED
+#ifdef SHARED
if (ELFW(ST_TYPE) (ref->st_info) == STT_TLS)
/* The found symbol is a thread-local storage variable.
Return the address for to the current thread. */
diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index 985e2b8f77..d06ce1754e 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -1,5 +1,5 @@
/* Operating system support for run-time dynamic linker. Generic Unix version.
- Copyright (C) 1995-1998, 2000-2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000-2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -405,25 +405,8 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
}
#endif
-#ifdef USE_TLS
/* For TLS enabled builds always add 'tls'. */
++cnt;
-#else
- if (cnt == 0)
- {
- /* If we no have platform name and no important capability we only
- have the base directory to search. */
- result = (struct r_strlenpair *) malloc (sizeof (*result));
- if (result == NULL)
- goto no_memory;
-
- result[0].str = (char *) result; /* Does not really matter. */
- result[0].len = 0;
-
- *sz = 1;
- return result;
- }
-#endif
/* Create temporary data structure to generate result table. */
temp = (struct r_strlenpair *) alloca (cnt * sizeof (*temp));
@@ -465,11 +448,11 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
temp[m].len = platform_len;
++m;
}
-#ifdef USE_TLS
+
temp[m].str = "tls";
temp[m].len = 3;
++m;
-#endif
+
assert (m == cnt);
/* Determine the total size of all strings together. */
@@ -487,13 +470,8 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
*sz = 1 << cnt;
result = (struct r_strlenpair *) malloc (*sz * sizeof (*result) + total);
if (result == NULL)
- {
-#ifndef USE_TLS
- no_memory:
-#endif
- _dl_signal_error (ENOMEM, NULL, NULL,
- N_("cannot create capability list"));
- }
+ _dl_signal_error (ENOMEM, NULL, NULL,
+ N_("cannot create capability list"));
if (cnt == 1)
{
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index a0f4f77ffa..d5865ab409 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -26,30 +26,26 @@
#include <sys/param.h>
#include <tls.h>
-
-/* We don't need any of this if TLS is not supported. */
-#ifdef USE_TLS
-
-# include <dl-tls.h>
-# include <ldsodefs.h>
+#include <dl-tls.h>
+#include <ldsodefs.h>
/* Amount of excess space to allocate in the static TLS area
to allow dynamic loading of modules defining IE-model TLS data. */
-# define TLS_STATIC_SURPLUS 64 + DL_NNS * 100
+#define TLS_STATIC_SURPLUS 64 + DL_NNS * 100
/* Value used for dtv entries for which the allocation is delayed. */
-# define TLS_DTV_UNALLOCATED ((void *) -1l)
+#define TLS_DTV_UNALLOCATED ((void *) -1l)
/* Out-of-memory handler. */
-# ifdef SHARED
+#ifdef SHARED
static void
__attribute__ ((__noreturn__))
oom (void)
{
_dl_fatal_printf ("cannot allocate memory for thread-local data: ABORT\n");
}
-# endif
+#endif
size_t
@@ -113,7 +109,7 @@ _dl_next_tls_modid (void)
}
-# ifdef SHARED
+#ifdef SHARED
void
internal_function
_dl_determine_tlsoffset (void)
@@ -158,7 +154,7 @@ _dl_determine_tlsoffset (void)
memory requirement for the next TLS block is smaller than the
gap. */
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
/* We simply start with zero. */
size_t offset = 0;
@@ -205,7 +201,7 @@ _dl_determine_tlsoffset (void)
GL(dl_tls_static_used) = offset;
GL(dl_tls_static_size) = (roundup (offset + TLS_STATIC_SURPLUS, max_align)
+ TLS_TCB_SIZE);
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
/* The TLS blocks start right after the TCB. */
size_t offset = TLS_TCB_SIZE;
@@ -249,9 +245,9 @@ _dl_determine_tlsoffset (void)
GL(dl_tls_static_used) = offset;
GL(dl_tls_static_size) = roundup (offset + TLS_STATIC_SURPLUS,
TLS_TCB_ALIGN);
-# else
-# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
-# endif
+#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;
@@ -288,7 +284,7 @@ _dl_tls_setup (void)
return 0;
}
rtld_hidden_def (_dl_tls_setup)
-# endif
+#endif
static void *
internal_function
@@ -337,13 +333,13 @@ _dl_allocate_tls_storage (void)
void *result;
size_t size = GL(dl_tls_static_size);
-# if TLS_DTV_AT_TP
+#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
+#endif
/* Allocate a correctly aligned chunk of memory. */
result = __libc_memalign (GL(dl_tls_static_align), size);
@@ -352,14 +348,14 @@ _dl_allocate_tls_storage (void)
/* Allocate the DTV. */
void *allocated = result;
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
/* The TCB follows the TLS blocks. */
result = (char *) result + size - TLS_TCB_SIZE;
/* 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. */
memset (result, '\0', TLS_TCB_SIZE);
-# elif TLS_DTV_AT_TP
+#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.
@@ -367,7 +363,7 @@ _dl_allocate_tls_storage (void)
initialize the DTV et al. */
memset ((char *) result - TLS_PRE_TCB_SIZE, '\0',
TLS_PRE_TCB_SIZE + TLS_TCB_SIZE);
-# endif
+#endif
result = allocate_dtv (result);
if (result == NULL)
@@ -428,14 +424,14 @@ _dl_allocate_tls_init (void *result)
assert (map->l_tls_modid == cnt);
assert (map->l_tls_blocksize >= map->l_tls_initimage_size);
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
assert ((size_t) map->l_tls_offset >= map->l_tls_blocksize);
dest = (char *) result - map->l_tls_offset;
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
dest = (char *) result + map->l_tls_offset;
-# else
-# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
-# endif
+#else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+#endif
/* Copy the initialization image and clear the BSS part. */
dtv[map->l_tls_modid].pointer.val = dest;
@@ -491,21 +487,21 @@ _dl_deallocate_tls (void *tcb, bool dealloc_tcb)
if (dealloc_tcb)
{
-# if TLS_TCB_AT_TP
+#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;
-# elif TLS_DTV_AT_TP
+#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);
-# endif
+#endif
free (tcb);
}
}
rtld_hidden_def (_dl_deallocate_tls)
-# ifdef SHARED
+#ifdef SHARED
/* 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
@@ -513,15 +509,15 @@ rtld_hidden_def (_dl_deallocate_tls)
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. */
-# 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
+# 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 *
@@ -732,7 +728,7 @@ __tls_get_addr (GET_ADDR_ARGS)
return (char *) p + GET_ADDR_OFFSET;
}
-# endif
+#endif
/* Look up the module's TLS block as for __tls_get_addr,
@@ -840,4 +836,3 @@ cannot create TLS data structures"));
listp->slotinfo[idx].map = l;
listp->slotinfo[idx].gen = GL(dl_tls_generation) + 1;
}
-#endif /* use TLS */
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 6800272ac7..0716a2acb8 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -1196,9 +1196,7 @@ main (int argc, char **argv)
add_dir (argv[i]);
}
-#ifdef USE_TLS
hwcap_extra[63 - _DL_FIRST_EXTRA] = "tls";
-#endif
set_hwcap ();
diff --git a/elf/rtld.c b/elf/rtld.c
index 8f0b0703a7..5e6ee51603 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1,5 +1,5 @@
/* Run time dynamic linker.
- Copyright (C) 1995-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1995-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -207,8 +207,7 @@ DL_SYSINFO_IMPLEMENTATION
is fine, too. The latter is important here. We can avoid setting
up a temporary link map for ld.so if we can mark _rtld_global as
hidden. */
-#if defined PI_STATIC_AND_HIDDEN && defined HAVE_HIDDEN \
- && defined HAVE_VISIBILITY_ATTRIBUTE
+#ifdef PI_STATIC_AND_HIDDEN
# define DONT_USE_BOOTSTRAP_MAP 1
#endif
@@ -292,7 +291,7 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
GL(dl_rtld_map).l_map_end = (ElfW(Addr)) _end;
GL(dl_rtld_map).l_text_end = (ElfW(Addr)) _etext;
/* Copy the TLS related data if necessary. */
-#if USE_TLS && !defined DONT_USE_BOOTSTRAP_MAP
+#ifndef DONT_USE_BOOTSTRAP_MAP
# if USE___THREAD
assert (info->l.l_tls_modid != 0);
GL(dl_rtld_map).l_tls_blocksize = info->l.l_tls_blocksize;
@@ -400,7 +399,7 @@ _dl_start (void *arg)
bootstrap_map.l_ld = (void *) bootstrap_map.l_addr + elf_machine_dynamic ();
elf_get_dynamic_info (&bootstrap_map, NULL);
-#if defined USE_TLS && NO_TLS_OFFSET != 0
+#if NO_TLS_OFFSET != 0
bootstrap_map.l_tls_offset = NO_TLS_OFFSET;
#endif
@@ -701,7 +700,6 @@ match_version (const char *string, struct link_map *map)
return 0;
}
-#ifdef USE_TLS
static bool tls_init_tp_called;
static void *
@@ -773,7 +771,6 @@ cannot allocate TLS data structures for initial thread");
return tcbp;
}
-#endif
#ifdef _LIBC_REENTRANT
/* _dl_error_catch_tsd points to this for the single-threaded case.
@@ -861,18 +858,14 @@ dl_main (const ElfW(Phdr) *phdr,
hp_timing_t stop;
hp_timing_t diff;
#endif
-#ifdef USE_TLS
void *tcbp = NULL;
-#endif
#ifdef _LIBC_REENTRANT
/* Explicit initialization since the reloc would just be more work. */
GL(dl_error_catch_tsd) = &_dl_initial_error_catch_tsd;
#endif
-#ifdef USE_TLS
GL(dl_init_static_tls) = &_dl_nothread_init_static_tls;
-#endif
#if defined SHARED && defined _LIBC_REENTRANT \
&& defined __rtld_lock_default_lock_recursive
@@ -1157,7 +1150,6 @@ of this helper program; chances are you did not intend to run this program.\n\
break;
case PT_TLS:
-#ifdef USE_TLS
if (ph->p_memsz > 0)
{
/* Note that in the case the dynamic linker we duplicate work
@@ -1177,10 +1169,6 @@ of this helper program; chances are you did not intend to run this program.\n\
/* This image gets the ID one. */
GL(dl_tls_max_dtv_idx) = main_map->l_tls_modid = 1;
}
-#else
- _dl_fatal_printf ("\
-ld.so does not support TLS, but program uses it!\n");
-#endif
break;
case PT_GNU_STACK:
@@ -1192,13 +1180,12 @@ ld.so does not support TLS, but program uses it!\n");
main_map->l_relro_size = ph->p_memsz;
break;
}
-#ifdef USE_TLS
- /* Adjust the address of the TLS initialization image in case
- the executable is actually an ET_DYN object. */
- if (main_map->l_tls_initimage != NULL)
- main_map->l_tls_initimage
- = (char *) main_map->l_tls_initimage + main_map->l_addr;
-#endif
+
+ /* Adjust the address of the TLS initialization image in case
+ the executable is actually an ET_DYN object. */
+ if (main_map->l_tls_initimage != NULL)
+ main_map->l_tls_initimage
+ = (char *) main_map->l_tls_initimage + main_map->l_addr;
if (! main_map->l_map_end)
main_map->l_map_end = ~0;
if (! main_map->l_text_end)
@@ -1401,12 +1388,10 @@ ld.so does not support TLS, but program uses it!\n");
break;
}
-#ifdef USE_TLS
/* Add the dynamic linker to the TLS list if it also uses TLS. */
if (GL(dl_rtld_map).l_tls_blocksize != 0)
/* Assign a module ID. Do this before loading any audit modules. */
GL(dl_rtld_map).l_tls_modid = _dl_next_tls_modid ();
-#endif
/* If we have auditing DSOs to load, do it now. */
if (__builtin_expect (audit_list != NULL, 0))
@@ -1416,7 +1401,6 @@ ld.so does not support TLS, but program uses it!\n");
struct audit_list *al = audit_list->next;
do
{
-#ifdef USE_TLS
int tls_idx = GL(dl_tls_max_dtv_idx);
/* Now it is time to determine the layout of the static TLS
@@ -1428,7 +1412,7 @@ ld.so does not support TLS, but program uses it!\n");
/* Since we start using the auditing DSOs right away we need to
initialize the data structures now. */
tcbp = init_tls ();
-#endif
+
struct dlmopen_args dlmargs;
dlmargs.fname = al->name;
dlmargs.map = NULL;
@@ -1543,9 +1527,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
assert (GL(dl_ns)[ns]._ns_loaded == NULL);
assert (GL(dl_ns)[ns]._ns_nloaded == 0);
-#ifdef USE_TLS
GL(dl_tls_max_dtv_idx) = tls_idx;
-#endif
goto not_loaded;
}
}
@@ -1821,7 +1803,6 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
_dl_receive_error (print_missing_version, version_check_doit, &args);
}
-#ifdef USE_TLS
/* We do not initialize any of the TLS functionality unless any of the
initial modules uses TLS. This makes dynamic loading of modules with
TLS impossible, but to support it requires either eagerly doing setup
@@ -1832,7 +1813,6 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
bool was_tls_init_tp_called = tls_init_tp_called;
if (tcbp == NULL)
tcbp = init_tls ();
-#endif
/* Set up the stack checker's canary. */
uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard ();
@@ -1889,13 +1869,12 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
(size_t) l->l_map_start,
(int) sizeof l->l_addr * 2,
(size_t) l->l_addr);
-#ifdef USE_TLS
+
if (l->l_tls_modid)
_dl_printf (" TLS(0x%Zx, 0x%0*Zx)\n", l->l_tls_modid,
(int) sizeof l->l_tls_offset * 2,
(size_t) l->l_tls_offset);
else
-#endif
_dl_printf ("\n");
}
}
@@ -2178,11 +2157,9 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
if (l->l_relro_size)
_dl_protect_relro (l);
-#ifdef USE_TLS
/* Add object to slot information data if necessasy. */
if (l->l_tls_blocksize != 0 && tls_init_tp_called)
_dl_add_to_slotinfo (l);
-#endif
}
_dl_sysdep_start_cleanup ();
@@ -2229,11 +2206,9 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
_dl_relocate_object (l, l->l_scope, GLRO(dl_lazy),
consider_profiling);
-#ifdef USE_TLS
/* Add object to slot information data if necessasy. */
if (l->l_tls_blocksize != 0 && tls_init_tp_called)
_dl_add_to_slotinfo (l);
-#endif
l = l->l_prev;
}
@@ -2262,7 +2237,6 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
# define NONTLS_INIT_TP do { } while (0)
#endif
-#ifdef USE_TLS
if (!was_tls_init_tp_called && GL(dl_tls_max_dtv_idx) > 0)
++GL(dl_tls_generation);
@@ -2280,9 +2254,6 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
_dl_fatal_printf ("cannot set up thread-local storage: %s\n",
lossage);
}
-#else
- NONTLS_INIT_TP;
-#endif
if (! prelinked && rtld_multiple_ref)
{
diff --git a/elf/tst-thrlock.c b/elf/tst-thrlock.c
new file mode 100644
index 0000000000..fe72eba141
--- /dev/null
+++ b/elf/tst-thrlock.c
@@ -0,0 +1,59 @@
+#include <dlfcn.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gnu/lib-names.h>
+
+static void *
+tf (void *arg)
+{
+ void *h = dlopen (LIBM_SO, RTLD_LAZY);
+ if (h == NULL)
+ {
+ printf ("dlopen failed: %s\n", dlerror ());
+ exit (1);
+ }
+ if (dlsym (h, "sin") == NULL)
+ {
+ printf ("dlsym failed: %s\n", dlerror ());
+ exit (1);
+ }
+ if (dlclose (h) != 0)
+ {
+ printf ("dlclose failed: %s\n", dlerror ());
+ exit (1);
+ }
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+#define N 10
+ pthread_t th[N];
+ for (int i = 0; i < N; ++i)
+ {
+ int e = pthread_create (&th[i], NULL, tf, NULL);
+ if (e != 0)
+ {
+ printf ("pthread_create failed with %d (%s)\n", e, strerror (e));
+ return 1;
+ }
+ }
+ for (int i = 0; i < N; ++i)
+ {
+ void *res;
+ int e = pthread_join (th[i], &res);
+ if (e != 0 || res != NULL)
+ {
+ puts ("thread failed");
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/elf/tst-tls-dlinfo.c b/elf/tst-tls-dlinfo.c
index e97b5081fd..26c2811178 100644
--- a/elf/tst-tls-dlinfo.c
+++ b/elf/tst-tls-dlinfo.c
@@ -9,7 +9,6 @@
static int
do_test (void)
{
-#ifdef USE_TLS
static const char modname[] = "tst-tlsmod2.so";
int result = 0;
int *foop;
@@ -83,9 +82,6 @@ do_test (void)
dlclose (h);
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tls1.c b/elf/tst-tls1.c
index 478f5bbdcd..3b9b10f9aa 100644
--- a/elf/tst-tls1.c
+++ b/elf/tst-tls1.c
@@ -3,21 +3,18 @@
#include <tls.h>
-#ifdef USE_TLS
-# include "tls-macros.h"
+#include "tls-macros.h"
/* Two common 'int' variables in TLS. */
COMMON_INT_DEF(foo);
COMMON_INT_DEF(bar);
-#endif
#define TEST_FUNCTION do_test ()
static int
do_test (void)
{
-#ifdef USE_TLS
int result = 0;
int *ap, *bp;
@@ -82,9 +79,6 @@ do_test (void)
}
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tls10.h b/elf/tst-tls10.h
index 1be6adc293..bffc332a0a 100644
--- a/elf/tst-tls10.h
+++ b/elf/tst-tls10.h
@@ -1,8 +1,7 @@
#include <tls.h>
#include <stdlib.h>
-#if defined USE_TLS && defined HAVE___THREAD \
- && defined HAVE_TLS_MODEL_ATTRIBUTE
+#if defined HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
# define USE_TLS__THREAD
struct A
diff --git a/elf/tst-tls14.c b/elf/tst-tls14.c
index 428fd5293e..c1e6ba7e2c 100644
--- a/elf/tst-tls14.c
+++ b/elf/tst-tls14.c
@@ -6,9 +6,9 @@
#include <tls.h>
-#if USE_TLS && HAVE___THREAD
+#if HAVE___THREAD
-#define AL 4096
+# define AL 4096
struct foo
{
int i;
@@ -55,11 +55,11 @@ do_test (void)
return result;
}
-#define TEST_FUNCTION do_test ()
+# define TEST_FUNCTION do_test ()
#else
-#define TEST_FUNCTION 0
+# define TEST_FUNCTION 0
#endif
diff --git a/elf/tst-tls2.c b/elf/tst-tls2.c
index 417489968e..3d13272c08 100644
--- a/elf/tst-tls2.c
+++ b/elf/tst-tls2.c
@@ -3,21 +3,18 @@
#include <tls.h>
-#ifdef USE_TLS
-# include "tls-macros.h"
+#include "tls-macros.h"
/* Two 'int' variables in TLS. */
VAR_INT_DEF(foo);
VAR_INT_DEF(bar);
-#endif
#define TEST_FUNCTION do_test ()
static int
do_test (void)
{
-#ifdef USE_TLS
int result = 0;
int *ap, *bp;
@@ -82,9 +79,6 @@ do_test (void)
}
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tls3.c b/elf/tst-tls3.c
index 84be43575b..c5e501eb4e 100644
--- a/elf/tst-tls3.c
+++ b/elf/tst-tls3.c
@@ -3,15 +3,13 @@
#include <tls.h>
-#ifdef USE_TLS
-# include "tls-macros.h"
+#include "tls-macros.h"
/* One define int variable, two externs. */
COMMON_INT_DECL(foo);
VAR_INT_DECL(bar);
VAR_INT_DEF(baz);
-#endif
extern int in_dso (void);
@@ -21,7 +19,6 @@ extern int in_dso (void);
static int
do_test (void)
{
-#ifdef USE_TLS
int result = 0;
int *ap, *bp, *cp;
@@ -67,9 +64,6 @@ do_test (void)
result |= in_dso ();
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tls4.c b/elf/tst-tls4.c
index f92ee53ce5..4ae33db24d 100644
--- a/elf/tst-tls4.c
+++ b/elf/tst-tls4.c
@@ -9,7 +9,6 @@
static int
do_test (void)
{
-#ifdef USE_TLS
static const char modname[] = "tst-tlsmod2.so";
int result = 0;
int *foop;
@@ -47,9 +46,6 @@ do_test (void)
dlclose (h);
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tls5.c b/elf/tst-tls5.c
index a571d2cd3f..27b18294fb 100644
--- a/elf/tst-tls5.c
+++ b/elf/tst-tls5.c
@@ -9,7 +9,6 @@
static int
do_test (void)
{
-#ifdef USE_TLS
static const char modname[] = "tst-tlsmod2.so";
int result = 0;
int *foop;
@@ -63,9 +62,6 @@ do_test (void)
dlclose (h);
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tls6.c b/elf/tst-tls6.c
index 68d706538f..021622d9c7 100644
--- a/elf/tst-tls6.c
+++ b/elf/tst-tls6.c
@@ -10,7 +10,6 @@
static int
do_test (void)
{
-#ifdef USE_TLS
static const char modname[] = "tst-tlsmod2.so";
int result = 0;
int *foop;
@@ -81,9 +80,6 @@ do_test (void)
}
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tls7.c b/elf/tst-tls7.c
index 37f1a63e16..1edc2b6356 100644
--- a/elf/tst-tls7.c
+++ b/elf/tst-tls7.c
@@ -10,7 +10,6 @@
static int
do_test (void)
{
-#ifdef USE_TLS
static const char modname[] = "tst-tlsmod3.so";
int result = 0;
int (*fp) (void);
@@ -52,9 +51,6 @@ do_test (void)
}
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tls8.c b/elf/tst-tls8.c
index ccc4e9f6fa..36b1baca63 100644
--- a/elf/tst-tls8.c
+++ b/elf/tst-tls8.c
@@ -10,7 +10,6 @@
static int
do_test (void)
{
-#ifdef USE_TLS
static const char modname1[] = "$ORIGIN/tst-tlsmod3.so";
static const char modname2[] = "$ORIGIN/tst-tlsmod4.so";
int result = 0;
@@ -165,9 +164,6 @@ do_test (void)
}
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tls9.c b/elf/tst-tls9.c
index e317696dfc..12078518fa 100644
--- a/elf/tst-tls9.c
+++ b/elf/tst-tls9.c
@@ -9,7 +9,6 @@
static int
do_test (void)
{
-#ifdef USE_TLS
static const char modname1[] = "tst-tlsmod5.so";
static const char modname2[] = "tst-tlsmod6.so";
int result = 0;
@@ -33,9 +32,6 @@ do_test (void)
dlclose (h2);
return result;
-#else
- return 0;
-#endif
}
diff --git a/elf/tst-tlsmod1.c b/elf/tst-tlsmod1.c
index c74a617b77..4d966c9472 100644
--- a/elf/tst-tlsmod1.c
+++ b/elf/tst-tlsmod1.c
@@ -2,7 +2,6 @@
#include <tls.h>
-#ifdef USE_TLS
#include "tls-macros.h"
@@ -10,7 +9,6 @@
COMMON_INT_DEF(foo);
VAR_INT_DEF(bar);
VAR_INT_DECL(baz);
-#endif
extern int in_dso (void);
@@ -18,7 +16,6 @@ int
in_dso (void)
{
int result = 0;
-#ifdef USE_TLS
int *ap, *bp, *cp;
/* Get variables using initial exec model. */
@@ -62,7 +59,6 @@ in_dso (void)
printf ("baz = %d\n", *cp);
result = 1;
}
-#endif
return result;
}
diff --git a/elf/tst-tlsmod13.c b/elf/tst-tlsmod13.c
index beca89f6fe..e4e23af2d8 100644
--- a/elf/tst-tlsmod13.c
+++ b/elf/tst-tlsmod13.c
@@ -1,7 +1,6 @@
#include <tls.h>
-#if defined USE_TLS && defined HAVE___THREAD \
- && defined HAVE_TLS_MODEL_ATTRIBUTE
+#if defined HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
__thread int a[2] __attribute__ ((tls_model ("initial-exec")));
#else
int a[2];
diff --git a/elf/tst-tlsmod13a.c b/elf/tst-tlsmod13a.c
index 14b12b032b..70a02131ee 100644
--- a/elf/tst-tlsmod13a.c
+++ b/elf/tst-tlsmod13a.c
@@ -1,7 +1,6 @@
#include <tls.h>
-#if defined USE_TLS && defined HAVE___THREAD \
- && defined HAVE_TLS_MODEL_ATTRIBUTE
+#if defined HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
__thread int b[2] __attribute__ ((tls_model ("initial-exec")));
#else
int b[2];
diff --git a/elf/tst-tlsmod14a.c b/elf/tst-tlsmod14a.c
index 0bb393d9c5..ad1d179aac 100644
--- a/elf/tst-tlsmod14a.c
+++ b/elf/tst-tlsmod14a.c
@@ -3,9 +3,9 @@
#include <tls.h>
-#if USE_TLS && HAVE___THREAD
+#if HAVE___THREAD
-#define AL 4096
+# define AL 4096
struct foo
{
int i;
@@ -15,9 +15,9 @@ static __thread struct foo f;
static struct foo g;
-#ifndef FCT
-# define FCT in_dso1
-#endif
+# ifndef FCT
+# define FCT in_dso1
+# endif
int
diff --git a/elf/tst-tlsmod2.c b/elf/tst-tlsmod2.c
index 98d9d3e518..981923313c 100644
--- a/elf/tst-tlsmod2.c
+++ b/elf/tst-tlsmod2.c
@@ -2,7 +2,6 @@
#include <tls.h>
-#ifdef USE_TLS
#include "tls-macros.h"
@@ -35,4 +34,3 @@ in_dso (int n, int *caller_foop)
return result;
}
-#endif
diff --git a/elf/tst-tlsmod3.c b/elf/tst-tlsmod3.c
index 4a8aad659f..5c456ee2da 100644
--- a/elf/tst-tlsmod3.c
+++ b/elf/tst-tlsmod3.c
@@ -2,8 +2,7 @@
#include <tls.h>
-#ifdef USE_TLS
-# include "tls-macros.h"
+#include "tls-macros.h"
extern int in_dso (int n, int *caller_foop);
@@ -38,4 +37,3 @@ in_dso2 (void)
return result;
}
-#endif
diff --git a/elf/tst-tlsmod4.c b/elf/tst-tlsmod4.c
index 5285e821b0..dd95486618 100644
--- a/elf/tst-tlsmod4.c
+++ b/elf/tst-tlsmod4.c
@@ -2,8 +2,7 @@
#include <tls.h>
-#ifdef USE_TLS
-# include "tls-macros.h"
+#include "tls-macros.h"
COMMON_INT_DEF(baz);
@@ -35,4 +34,3 @@ in_dso (int n, int *caller_bazp)
return result;
}
-#endif
diff --git a/elf/tst-tlsmod5.c b/elf/tst-tlsmod5.c
index 2ec69e13b3..00d3a9d920 100644
--- a/elf/tst-tlsmod5.c
+++ b/elf/tst-tlsmod5.c
@@ -1,7 +1,5 @@
#include <tls.h>
-#ifdef USE_TLS
#include "tls-macros.h"
COMMON_INT_DEF(foo);
-#endif
diff --git a/elf/tst-tlsmod6.c b/elf/tst-tlsmod6.c
index 0fda51b226..244d9ae485 100644
--- a/elf/tst-tlsmod6.c
+++ b/elf/tst-tlsmod6.c
@@ -1,7 +1,5 @@
#include <tls.h>
-#ifdef USE_TLS
#include "tls-macros.h"
COMMON_INT_DEF(bar);
-#endif