diff options
| author | joerg <joerg@NetBSD.org> | 2011-11-17 16:20:11 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2011-11-17 16:20:11 +0000 |
| commit | 3de82d2d274750ab7ec74b759ff8d9c2cd9b080e (patch) | |
| tree | 6c80c9eaff445830abb57fc53f99b17c5375b22b /libexec | |
| parent | 7960eefa9186d680656e8ca93b01cd6be8ea55da (diff) | |
FreeBSD bug report 161344: TLS area for the main thread is set up to
early, if e.g. pointers to functions are used as initializers.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/ld.elf_so/rtld.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libexec/ld.elf_so/rtld.c b/libexec/ld.elf_so/rtld.c index 0adc9b81e4f..c33bbcd90ce 100644 --- a/libexec/ld.elf_so/rtld.c +++ b/libexec/ld.elf_so/rtld.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtld.c,v 1.153 2011/10/23 21:06:07 christos Exp $ */ +/* $NetBSD: rtld.c,v 1.154 2011/11/17 16:20:11 joerg Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -40,7 +40,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: rtld.c,v 1.153 2011/10/23 21:06:07 christos Exp $"); +__RCSID("$NetBSD: rtld.c,v 1.154 2011/11/17 16:20:11 joerg Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -642,13 +642,12 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase) } #if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) - dbg(("initializing initial Thread Local Storage")); + dbg(("initializing initial Thread Local Storage offsets")); /* * All initial objects get the TLS space from the static block. */ for (obj = _rtld_objlist; obj != NULL; obj = obj->next) _rtld_tls_offset_allocate(obj); - _rtld_tls_initial_allocation(); #endif dbg(("relocating objects")); @@ -659,6 +658,16 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase) if (_rtld_do_copy_relocations(_rtld_objmain) == -1) _rtld_die(); +#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) + dbg(("initializing Thread Local Storage for main thread")); + /* + * Set up TLS area for the main thread. + * This has to be done after all relocations are processed, + * since .tdata may contain relocations. + */ + _rtld_tls_initial_allocation(); +#endif + /* * Set the __progname, environ and, __mainprog_obj before * calling anything that might use them. |
