aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-02-22 03:51:38 +0000
committerUlrich Drepper <drepper@redhat.com>2005-02-22 03:51:38 +0000
commite13e33e279e193191e06811cb7ae3518d7acad1a (patch)
treeaf79ff3fe269f056259402f256fdd3f0d78aab6e /elf
parentaf272d4fa88306ec6a9c112cae6ebbb45f0b296e (diff)
downloadglibc-e13e33e279e193191e06811cb7ae3518d7acad1a.tar
glibc-e13e33e279e193191e06811cb7ae3518d7acad1a.tar.gz
glibc-e13e33e279e193191e06811cb7ae3518d7acad1a.tar.bz2
glibc-e13e33e279e193191e06811cb7ae3518d7acad1a.zip
2005-02-21 Alan Modra <amodra@bigpond.net.au>
* elf/dl-reloc.c (_dl_nothread_init_static_tls): Assert that dtv array index is within bounds. * elf/dl-load.c: Do not allow PT_TLS in modules loaded in statically linked code. * sysdeps/generic/dl-tls.c [!SHARED]: Don't build _dl_next_tls_modid. * elf/Makefile: Remove rules to build and run tst-tls9-static.
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile7
-rw-r--r--elf/dl-load.c9
-rw-r--r--elf/dl-reloc.c2
3 files changed, 10 insertions, 8 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 6c34d8ab44..e7c16f44df 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -139,12 +139,7 @@ endif
ifeq (yes,$(build-static))
tests-static = tst-tls1-static tst-tls2-static
ifeq (yes,$(have-initfini-array))
-tests-static += tst-array1-static
-endif
-ifeq (yesyesyes,$(build-static)$(build-shared)$(elf))
-tests-static += tst-tls9-static
-tst-tls9-static-ENV = \
- LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
+tests-static += tst-array1-static
endif
tests += $(tests-static)
endif
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 088b2224e2..5c562471c9 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1056,6 +1056,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
case PT_TLS:
#ifdef USE_TLS
+# ifdef SHARED
if (ph->p_memsz == 0)
/* Nothing to do for an empty segment. */
break;
@@ -1083,7 +1084,6 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
break;
}
-# 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. */
@@ -1092,7 +1092,6 @@ _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
{
/* We have not yet loaded libpthread.
We can do the TLS setup right now! */
@@ -1125,6 +1124,12 @@ cannot allocate TLS data structures for initial thread");
_dl_deallocate_tls (tcb, 1);
goto call_lose;
}
+# else
+ errval = EINVAL;
+ errstring = N_("\
+statically linked code cannot load module with TLS");
+ goto call_lose;
+# endif
#endif
/* Uh-oh, the binary expects TLS support but we cannot
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index c3a58dd921..140093c6ce 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -125,6 +125,8 @@ _dl_nothread_init_static_tls (struct link_map *map)
/* Fill in the DTV slot so that a later LD/GD access will find it. */
dtv_t *dtv = THREAD_DTV ();
+ _dl_printf("modid=%u, counter=%u\n", map->l_tls_modid, dtv[-1].counter);
+ assert (map->l_tls_modid <= dtv[-1].counter);
dtv[map->l_tls_modid].pointer.val = dest;
dtv[map->l_tls_modid].pointer.is_static = true;