mirror of git://sourceware.org/git/glibc.git
* elf/dl-load.c (_dl_map_object_from_fd): Don't check DF_STATIC_TLS.
* elf/dl-reloc.c (_dl_relocate_object: CHECK_STATIC_TLS): New macro to signal error if an IE-model TLS reloc resolved to a dlopen'd module. * sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela): Call it after performing TPOFF relocs. * sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise. * sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise. * elf/dl-conflict.c (CHECK_STATIC_TLS): New macro (no-op). * elf/dl-close.c (remove_slotinfo): Change asserts so as not to crash when closing a partially-initialized object. * elf/dl-load.c (_dl_map_object_from_fd) [! USE_TLS]: Call lose instead of _dl_fatal_printf when we see PT_TLS.
This commit is contained in:
parent
d29724f870
commit
2430d57a13
15
ChangeLog
15
ChangeLog
|
@ -1,5 +1,20 @@
|
||||||
2002-10-17 Roland McGrath <roland@redhat.com>
|
2002-10-17 Roland McGrath <roland@redhat.com>
|
||||||
|
|
||||||
|
* elf/dl-load.c (_dl_map_object_from_fd): Don't check DF_STATIC_TLS.
|
||||||
|
* elf/dl-reloc.c (_dl_relocate_object: CHECK_STATIC_TLS): New macro
|
||||||
|
to signal error if an IE-model TLS reloc resolved to a dlopen'd module.
|
||||||
|
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela):
|
||||||
|
Call it after performing TPOFF relocs.
|
||||||
|
* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.
|
||||||
|
* sysdeps/sh/dl-machine.h (elf_machine_rela): Likewise.
|
||||||
|
* elf/dl-conflict.c (CHECK_STATIC_TLS): New macro (no-op).
|
||||||
|
|
||||||
|
* elf/dl-close.c (remove_slotinfo): Change asserts so as not to crash
|
||||||
|
when closing a partially-initialized object.
|
||||||
|
|
||||||
|
* elf/dl-load.c (_dl_map_object_from_fd) [! USE_TLS]: Call lose
|
||||||
|
instead of _dl_fatal_printf when we see PT_TLS.
|
||||||
|
|
||||||
* Makeconfig (CPPFLAGS): Fix last change to use $(libof-$(<F))
|
* Makeconfig (CPPFLAGS): Fix last change to use $(libof-$(<F))
|
||||||
instead of $(libof-$<).
|
instead of $(libof-$<).
|
||||||
|
|
||||||
|
|
|
@ -53,18 +53,22 @@ remove_slotinfo (size_t idx, struct dtv_slotinfo_list *listp, size_t disp)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct link_map *old_map = listp->slotinfo[idx - disp].map;
|
struct link_map *old_map = listp->slotinfo[idx - disp].map;
|
||||||
assert (old_map != NULL);
|
|
||||||
|
|
||||||
/* Mark the entry as unused. */
|
/* The entry might still be in its unused state if we are closing an
|
||||||
listp->slotinfo[idx - disp].gen = GL(dl_tls_generation) + 1;
|
object that wasn't fully set up. */
|
||||||
listp->slotinfo[idx - disp].map = NULL;
|
if (__builtin_expect (old_map != NULL, 1))
|
||||||
|
{
|
||||||
|
assert (old_map->l_tls_modid == idx);
|
||||||
|
|
||||||
|
/* Mark the entry as unused. */
|
||||||
|
listp->slotinfo[idx - disp].gen = GL(dl_tls_generation) + 1;
|
||||||
|
listp->slotinfo[idx - disp].map = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* If this is not the last currently used entry no need to look
|
/* If this is not the last currently used entry no need to look
|
||||||
further. */
|
further. */
|
||||||
if (old_map->l_tls_modid != GL(dl_tls_max_dtv_idx))
|
if (idx != GL(dl_tls_max_dtv_idx))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
assert (old_map->l_tls_modid == GL(dl_tls_max_dtv_idx));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (idx - disp > disp == 0 ? 1 + GL(dl_tls_static_nelem) : 0)
|
while (idx - disp > disp == 0 ? 1 + GL(dl_tls_static_nelem) : 0)
|
||||||
|
|
|
@ -44,6 +44,7 @@ _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict,
|
||||||
/* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */
|
/* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */
|
||||||
#define RESOLVE_MAP(ref, version, flags) (*ref = NULL, NULL)
|
#define RESOLVE_MAP(ref, version, flags) (*ref = NULL, NULL)
|
||||||
#define RESOLVE(ref, version, flags) (*ref = NULL, 0)
|
#define RESOLVE(ref, version, flags) (*ref = NULL, 0)
|
||||||
|
#define CHECK_STATIC_TLS(ref_map, sym_map) ((void) 0)
|
||||||
#define RESOLVE_CONFLICT_FIND_MAP(map, r_offset) \
|
#define RESOLVE_CONFLICT_FIND_MAP(map, r_offset) \
|
||||||
do { \
|
do { \
|
||||||
while ((resolve_conflict_map->l_map_end < (ElfW(Addr)) (r_offset)) \
|
while ((resolve_conflict_map->l_map_end < (ElfW(Addr)) (r_offset)) \
|
||||||
|
|
|
@ -957,7 +957,9 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
|
||||||
#else
|
#else
|
||||||
/* Uh-oh, the binary expects TLS support but we cannot
|
/* Uh-oh, the binary expects TLS support but we cannot
|
||||||
provide it. */
|
provide it. */
|
||||||
_dl_fatal_printf ("cannot handle file '%s' with TLS data\n", name);
|
errval = 0;
|
||||||
|
errstring = N_("cannot handle TLS data");
|
||||||
|
goto call_lose;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1173,11 +1175,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
|
||||||
|
|
||||||
/* Make sure we are not dlopen'ing an object
|
/* Make sure we are not dlopen'ing an object
|
||||||
that has the DF_1_NOOPEN flag set. */
|
that has the DF_1_NOOPEN flag set. */
|
||||||
if ((__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0)
|
if (__builtin_expect (l->l_flags_1 & DF_1_NOOPEN, 0)
|
||||||
#ifdef USE_TLS
|
|
||||||
|| __builtin_expect (l->l_flags & DF_STATIC_TLS, 0)
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
&& (mode & __RTLD_DLOPEN))
|
&& (mode & __RTLD_DLOPEN))
|
||||||
{
|
{
|
||||||
/* We are not supposed to load this object. Free all resources. */
|
/* We are not supposed to load this object. Free all resources. */
|
||||||
|
|
|
@ -159,6 +159,15 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
|
||||||
l->l_lookup_cache.value = _lr; })) \
|
l->l_lookup_cache.value = _lr; })) \
|
||||||
: l->l_addr)
|
: l->l_addr)
|
||||||
|
|
||||||
|
#define CHECK_STATIC_TLS(map, sym_map) \
|
||||||
|
do { \
|
||||||
|
if (__builtin_expect ((sym_map)->l_tls_offset == 0, 0)) \
|
||||||
|
{ \
|
||||||
|
errstring = N_("shared object cannot be dlopen()ed"); \
|
||||||
|
INTUSE(_dl_signal_error) (0, (map)->l_name, NULL, errstring); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#include "dynamic-link.h"
|
#include "dynamic-link.h"
|
||||||
|
|
||||||
ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling);
|
ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling);
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2002-10-17 Roland McGrath <roland@redhat.com>
|
||||||
|
|
||||||
|
* Makefile (unload): Don't link in libpthread.so.
|
||||||
|
($(objpfx)unload.out): Do depend on it.
|
||||||
|
* unload.c (main): Improve error reporting.
|
||||||
|
|
||||||
2002-10-09 Roland McGrath <roland@redhat.com>
|
2002-10-09 Roland McGrath <roland@redhat.com>
|
||||||
|
|
||||||
* sysdeps/pthread/bits/libc-lock.h (__libc_maybe_call): New macro.
|
* sysdeps/pthread/bits/libc-lock.h (__libc_maybe_call): New macro.
|
||||||
|
|
|
@ -98,10 +98,11 @@ $(objpfx)libpthread.so: $(common-objpfx)libc.so \
|
||||||
# Make sure we link with the thread library.
|
# Make sure we link with the thread library.
|
||||||
ifeq ($(build-shared),yes)
|
ifeq ($(build-shared),yes)
|
||||||
$(addprefix $(objpfx), \
|
$(addprefix $(objpfx), \
|
||||||
$(filter-out $(tests-static), \
|
$(filter-out $(tests-static) unload, \
|
||||||
$(tests) $(test-srcs))): $(objpfx)libpthread.so
|
$(tests) $(test-srcs))): $(objpfx)libpthread.so
|
||||||
$(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
|
$(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.so
|
||||||
$(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
|
$(objpfx)unload: $(common-objpfx)dlfcn/libdl.so
|
||||||
|
$(objpfx)unload.out: $(objpfx)libpthread.so
|
||||||
else
|
else
|
||||||
$(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
|
$(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
|
||||||
$(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.a
|
$(addprefix $(objpfx),$(librt-tests)): $(common-objpfx)rt/librt.a
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Tests for non-unloading of libpthread.
|
/* Tests for non-unloading of libpthread.
|
||||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
Copyright (C) 2000, 2002 Free Software Foundation, Inc.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
@ -29,13 +29,13 @@ main (void)
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
puts ("failed to load " LIBPTHREAD_SO);
|
printf ("failed to load %s: %s\n", LIBPTHREAD_SO, dlerror ());
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dlclose (p) != 0)
|
if (dlclose (p) != 0)
|
||||||
{
|
{
|
||||||
puts ("dlclose (" LIBPTHREAD_SO ") failed");
|
printf ("dlclose (%s) failed: %s\n", LIBPTHREAD_SO, dlerror ());
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -432,6 +432,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
|
||||||
Therefore the offset is already correct. */
|
Therefore the offset is already correct. */
|
||||||
if (sym != NULL)
|
if (sym != NULL)
|
||||||
*reloc_addr = sym->st_value;
|
*reloc_addr = sym->st_value;
|
||||||
|
CHECK_STATIC_TLS (map, sym_map);
|
||||||
# endif
|
# endif
|
||||||
break;
|
break;
|
||||||
case R_386_TLS_TPOFF32:
|
case R_386_TLS_TPOFF32:
|
||||||
|
@ -445,6 +446,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
|
||||||
block we subtract the offset from that of the TLS block. */
|
block we subtract the offset from that of the TLS block. */
|
||||||
if (sym != NULL)
|
if (sym != NULL)
|
||||||
*reloc_addr += sym_map->l_tls_offset - sym->st_value;
|
*reloc_addr += sym_map->l_tls_offset - sym->st_value;
|
||||||
|
CHECK_STATIC_TLS (map, sym_map);
|
||||||
# endif
|
# endif
|
||||||
break;
|
break;
|
||||||
case R_386_TLS_TPOFF:
|
case R_386_TLS_TPOFF:
|
||||||
|
@ -457,6 +459,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
|
||||||
thread pointer. */
|
thread pointer. */
|
||||||
if (sym != NULL)
|
if (sym != NULL)
|
||||||
*reloc_addr += sym->st_value - sym_map->l_tls_offset;
|
*reloc_addr += sym->st_value - sym_map->l_tls_offset;
|
||||||
|
CHECK_STATIC_TLS (map, sym_map);
|
||||||
# endif
|
# endif
|
||||||
break;
|
break;
|
||||||
#endif /* use TLS */
|
#endif /* use TLS */
|
||||||
|
@ -549,6 +552,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
|
||||||
*reloc_addr
|
*reloc_addr
|
||||||
= (sym == NULL ? 0 : sym_map->l_tls_offset - sym->st_value)
|
= (sym == NULL ? 0 : sym_map->l_tls_offset - sym->st_value)
|
||||||
+ reloc->r_addend;
|
+ reloc->r_addend;
|
||||||
|
CHECK_STATIC_TLS (map, sym_map);
|
||||||
break;
|
break;
|
||||||
case R_386_TLS_TPOFF:
|
case R_386_TLS_TPOFF:
|
||||||
/* The offset is negative, forward from the thread pointer. */
|
/* The offset is negative, forward from the thread pointer. */
|
||||||
|
@ -558,6 +562,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
|
||||||
*reloc_addr
|
*reloc_addr
|
||||||
= (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset)
|
= (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset)
|
||||||
+ reloc->r_addend;
|
+ reloc->r_addend;
|
||||||
|
CHECK_STATIC_TLS (map, sym_map);
|
||||||
break;
|
break;
|
||||||
#endif /* use TLS */
|
#endif /* use TLS */
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -582,6 +582,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
|
||||||
*reloc_addr
|
*reloc_addr
|
||||||
= ((sym == NULL ? 0 : sym_map->l_tls_offset + sym->st_value)
|
= ((sym == NULL ? 0 : sym_map->l_tls_offset + sym->st_value)
|
||||||
+ reloc->r_addend);
|
+ reloc->r_addend);
|
||||||
|
CHECK_STATIC_TLS (map, sym_map);
|
||||||
# endif
|
# endif
|
||||||
break;
|
break;
|
||||||
#endif /* use TLS */
|
#endif /* use TLS */
|
||||||
|
|
|
@ -428,11 +428,16 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
|
||||||
# ifndef RTLD_BOOTSTRAP
|
# ifndef RTLD_BOOTSTRAP
|
||||||
if (sym != NULL)
|
if (sym != NULL)
|
||||||
# endif
|
# endif
|
||||||
/* We know the offset of the object the symbol is contained in.
|
{
|
||||||
It is a negative value which will be added to the
|
/* We know the offset of the object the symbol is contained in.
|
||||||
thread pointer. */
|
It is a negative value which will be added to the
|
||||||
*reloc_addr = (sym->st_value + reloc->r_addend
|
thread pointer. */
|
||||||
- sym_map->l_tls_offset);
|
*reloc_addr = (sym->st_value + reloc->r_addend
|
||||||
|
- sym_map->l_tls_offset);
|
||||||
|
# ifndef RTLD_BOOTSTRAP
|
||||||
|
CHECK_STATIC_TLS (map, sym_map);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* use TLS */
|
#endif /* use TLS */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue