diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-02-05 00:57:29 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-02-05 00:57:29 +0000 |
commit | 535b764df5ca722066c2db615190e6a70688c6a6 (patch) | |
tree | 06f6ba9853ac4e8f698fc1e3b0b4cb80ffd06bae /sysdeps | |
parent | 67ddea92542c12f2099a89dbc58a045a65bb7771 (diff) | |
download | glibc-535b764df5ca722066c2db615190e6a70688c6a6.tar.gz glibc-535b764df5ca722066c2db615190e6a70688c6a6.tar.xz glibc-535b764df5ca722066c2db615190e6a70688c6a6.zip |
Update.
* elf/rtld.c (_dl_start_final): Allocate TLS and initialize thread-pointer as soon as possible. * sysdeps/generic/ldsodefs.h: Include <tls.h>. Define first TLS elements in rtld_global. * sysdeps/generic/tls.h: New file. * elf/Makefile (distribute): Add tls.h. * sysdeps/i386/dl-machine.h (elf_machine_rel): Add support for TLS relocations. Not complete yet. * resolv/resolv.h: Allow user to define __need_res_state and only define __res_start structure then. * include/resolv.h: Only declare functions if _RESOLV_H_ is defined.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/generic/ldsodefs.h | 6 | ||||
-rw-r--r-- | sysdeps/generic/tls.h | 22 | ||||
-rw-r--r-- | sysdeps/i386/dl-machine.h | 39 | ||||
-rwxr-xr-x | sysdeps/i386/elf/configure | 6 |
4 files changed, 70 insertions, 3 deletions
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 0f63799524..08785a818e 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -35,6 +35,7 @@ #include <dl-lookupcfg.h> #include <bits/libc-lock.h> #include <hp-timing.h> +#include <tls.h> __BEGIN_DECLS @@ -286,6 +287,11 @@ struct rtld_global EXTERN hp_timing_t _dl_hp_timing_overhead; #endif +#ifdef USE_TLS + /* Offset of the TLS block for ld.so from the thread-pointer. */ + EXTERN size_t _rtld_tlsoffset; +#endif + /* Name of the shared object to be profiled (if any). */ EXTERN const char *_dl_profile; /* Map of shared object to be profiled. */ diff --git a/sysdeps/generic/tls.h b/sysdeps/generic/tls.h new file mode 100644 index 0000000000..3820162ae8 --- /dev/null +++ b/sysdeps/generic/tls.h @@ -0,0 +1,22 @@ +/* Definition for thread-local data handling. Generic version. + Copyright (C) 2002 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 + 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. */ + +/* By default no TLS support is available. This is signaled by the + absence of the symbol USE_TLS. */ +#undef USE_TLS diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 69a0c5550e..f791fa3ffa 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -342,7 +342,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, else #endif { -#ifdef RTLD_BOOTSTRAP +#if defined RTLD_BOOTSTRAP && !defined USE_TLS Elf32_Addr value; assert (r_type == R_386_GLOB_DAT || r_type == R_386_JMP_SLOT); @@ -352,7 +352,9 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, #else const Elf32_Sym *const refsym = sym; Elf32_Addr value = RESOLVE (&sym, version, r_type); +# ifndef RTLD_BOOTSTRAP if (sym) +# endif value += sym->st_value; switch (r_type) @@ -361,6 +363,40 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, case R_386_JMP_SLOT: *reloc_addr = value; break; + + /* XXX Remove TLS relocations which are not needed. */ + + case R_386_TLS_DTPMOD32: +# ifdef RTLD_BOOTSTRAP + /* During startup the dynamic linker is always the module + with index 1. + XXX If this relocation is necessary move before RESOLVE + call. */ + *reloc_addr = 1; +# else + /* XXX Implement. RESOLVE must return the map from which we + get the module ID. */ + _exit (99); +# endif + break; + case R_386_TLS_DTPOFF32: +# ifndef RTLD_BOOTSTRAP + /* During relocation all TLS symbols are defined and used. + Therefore the offset is already correct. */ + *reloc_addr = sym->st_value; +# endif + break; + case R_386_TLS_TPOFF32: + /* The offset is positive, backward from the thread pointer. */ +# ifdef RTLD_BOOTSTRAP + *reloc_addr = GL(rtld_tlsoffset) - sym->st_value; +# else + /* XXX Implement. */ + _exit (98); +# endif + break; + +# ifndef RTLD_BOOTSTRAP case R_386_32: *reloc_addr += value; break; @@ -390,6 +426,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, default: _dl_reloc_bad_type (map, r_type, 0); break; +# endif } #endif } diff --git a/sysdeps/i386/elf/configure b/sysdeps/i386/elf/configure index e12bf4a164..ca7f567bcb 100755 --- a/sysdeps/i386/elf/configure +++ b/sysdeps/i386/elf/configure @@ -9,16 +9,18 @@ if eval "test \"`echo '$''{'libc_cv_386_tls'+set}'`\" = set"; then else cat > conftest.s <<\EOF .section ".tdata", "awT", @progbits + .globl foo foo: .long 1 .section ".tbss", "awT", @nobits - .comm bar,4,4 + .globl bar +bar: .skip 4 .text baz: leal bar@TLSLDM(%ebx), %eax leal bar@DTPOFF(%eax), %edx subl foo@GOTTPOFF(%edx), %eax subl $bar@TPOFF, %eax EOF -if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:22: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then +if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:24: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_386_tls=yes else libc_cv_386_tls=no |