diff options
author | Roland McGrath <roland@gnu.org> | 2002-12-04 12:27:20 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2002-12-04 12:27:20 +0000 |
commit | 68dc80ca28a192d686b3190373df8468b4ce5cb8 (patch) | |
tree | 0d44f72655d3148c6f830f635f7b019368cc340b /sysdeps/generic | |
parent | 7a5cdb30e31c860ce0314393cc97f161258ff842 (diff) | |
download | glibc-68dc80ca28a192d686b3190373df8468b4ce5cb8.tar.gz glibc-68dc80ca28a192d686b3190373df8468b4ce5cb8.tar.xz glibc-68dc80ca28a192d686b3190373df8468b4ce5cb8.zip |
2002-12-04 Roland McGrath <roland@redhat.com>
* sysdeps/generic/ldsodefs.h (struct rtld_global): Move all [USE_TLS] members to the end, so a libpthread compiled with !USE_TLS will still find other members properly. * sysdeps/generic/dl-tls.c [SHARED] (_dl_tls_setup): New function. * sysdeps/generic/ldsodefs.h: Declare it. * elf/Versions (ld: GLIBC_PRIVATE): Add it. * sysdeps/generic/libc-tls.c (init_slotinfo): New static inline function, broken out of __libc_setup_tls. (init_static_tls): Likewise. (__libc_setup_tls): Call them. (_dl_tls_setup): New function, uses new subroutines. * sysdeps/generic/ldsodefs.h (_dl_next_tls_modid): Declare as hidden. (_dl_determine_tlsoffset): Likewise. * elf/rtld.c (_dl_initial_error_catch_tsd): Renamed from startup_error_tsd, made global. (dl_main): Update initialization. * elf/dl-tsd.c: Likewise. * sysdeps/generic/ldsodefs.h: Declare it.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/ldsodefs.h | 108 |
1 files changed, 63 insertions, 45 deletions
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 8321b96b5f..5e08844ce3 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -293,45 +293,6 @@ struct rtld_global EXTERN hp_timing_t _dl_hp_timing_overhead; #endif -#ifdef USE_TLS - /* Highest dtv index currently needed. */ - EXTERN size_t _dl_tls_max_dtv_idx; - /* Flag signalling whether there are gaps in the module ID allocation. */ - EXTERN bool _dl_tls_dtv_gaps; - /* Information about the dtv slots. */ - EXTERN struct dtv_slotinfo_list - { - size_t len; - struct dtv_slotinfo_list *next; - struct dtv_slotinfo - { - size_t gen; - struct link_map *map; - } slotinfo[0]; - } *_dl_tls_dtv_slotinfo_list; - /* Number of modules in the static TLS block. */ - EXTERN size_t _dl_tls_static_nelem; - /* Size of the static TLS block. */ - EXTERN size_t _dl_tls_static_size; - /* Size actually allocated in the static TLS block. */ - EXTERN size_t _dl_tls_static_used; - /* Alignment requirement of the static TLS block. */ - EXTERN size_t _dl_tls_static_align; - -/* Number of additional entries in the slotinfo array of each slotinfo - list element. A large number makes it almost certain take we never - have to iterate beyond the first element in the slotinfo list. */ -# define TLS_SLOTINFO_SURPLUS (62) - -/* Number of additional slots in the dtv allocated. */ -# define DTV_SURPLUS (14) - - /* Initial dtv of the main thread, not allocated with normal malloc. */ - EXTERN void *_dl_initial_dtv; - /* Generation counter for the dtv. */ - EXTERN size_t _dl_tls_generation; -#endif - /* Name of the shared object to be profiled (if any). */ EXTERN const char *_dl_profile; /* Map of shared object to be profiled. */ @@ -369,6 +330,10 @@ struct rtld_global /* File descriptor to write debug messages to. */ EXTERN int _dl_debug_fd; +#ifdef _LIBC_REENTRANT + EXTERN void **(*_dl_error_catch_tsd) (void) __attribute__ ((const)); +#endif + /* Get architecture specific definitions. */ #define PROCINFO_DECL #include <dl-procinfo.c> @@ -376,9 +341,49 @@ struct rtld_global /* Structure describing the dynamic linker itself. */ EXTERN struct link_map _dl_rtld_map; -#ifdef _LIBC_REENTRANT - EXTERN void **(*_dl_error_catch_tsd) (void) __attribute__ ((const)); + /* Keep the conditional TLS members at the end so the layout of the + structure used by !USE_TLS code matches the prefix of the layout in + the USE_TLS rtld. Note that `struct link_map' is conditionally + defined as well, so _dl_rtld_map needs to be last before this. */ +#ifdef USE_TLS + /* Highest dtv index currently needed. */ + EXTERN size_t _dl_tls_max_dtv_idx; + /* Flag signalling whether there are gaps in the module ID allocation. */ + EXTERN bool _dl_tls_dtv_gaps; + /* Information about the dtv slots. */ + EXTERN struct dtv_slotinfo_list + { + size_t len; + struct dtv_slotinfo_list *next; + struct dtv_slotinfo + { + size_t gen; + struct link_map *map; + } slotinfo[0]; + } *_dl_tls_dtv_slotinfo_list; + /* Number of modules in the static TLS block. */ + EXTERN size_t _dl_tls_static_nelem; + /* Size of the static TLS block. */ + EXTERN size_t _dl_tls_static_size; + /* Size actually allocated in the static TLS block. */ + EXTERN size_t _dl_tls_static_used; + /* Alignment requirement of the static TLS block. */ + EXTERN size_t _dl_tls_static_align; + +/* Number of additional entries in the slotinfo array of each slotinfo + list element. A large number makes it almost certain take we never + have to iterate beyond the first element in the slotinfo list. */ +# define TLS_SLOTINFO_SURPLUS (62) + +/* Number of additional slots in the dtv allocated. */ +# define DTV_SURPLUS (14) + + /* Initial dtv of the main thread, not allocated with normal malloc. */ + EXTERN void *_dl_initial_dtv; + /* Generation counter for the dtv. */ + EXTERN size_t _dl_tls_generation; #endif + #ifdef SHARED }; # define __rtld_global_attribute__ @@ -401,6 +406,13 @@ extern struct rtld_global _rtld_global __rtld_global_attribute__; #endif #undef EXTERN +#ifdef IS_IN_rtld +/* This is the initial value of GL(dl_error_catch_tsd). + A non-TLS libpthread will change it. */ +extern void **_dl_initial_error_catch_tsd (void) __attribute__ ((const)) + attribute_hidden; +#endif + /* Parameters passed to the dynamic linker. */ extern int _dl_argc attribute_hidden; extern char **_dl_argv; @@ -739,10 +751,16 @@ extern void _dl_sysdep_start_cleanup (void) /* Determine next available module ID. */ -extern size_t _dl_next_tls_modid (void) internal_function; +extern size_t _dl_next_tls_modid (void) internal_function attribute_hidden; /* Calculate offset of the TLS blocks in the static TLS block. */ -extern void _dl_determine_tlsoffset (void) internal_function; +extern void _dl_determine_tlsoffset (void) internal_function attribute_hidden; + +/* Set up the data structures for TLS, when they were not set up at startup. + Returns nonzero on malloc failure. + This is called from _dl_map_object_from_fd or by libpthread. */ +extern int _dl_tls_setup (void) internal_function; +rtld_hidden_proto (_dl_tls_setup) /* Allocate memory for static TLS block (unless MEM is nonzero) and dtv. */ extern void *_dl_allocate_tls (void *mem) internal_function; @@ -754,9 +772,9 @@ extern void _dl_get_tls_static_info (size_t *sizep, size_t *alignp) /* These are internal entry points to the two halves of _dl_allocate_tls, only used within rtld.c itself at startup time. */ extern void *_dl_allocate_tls_storage (void) - internal_function attribute_hidden; + internal_function attribute_hidden; extern void *_dl_allocate_tls_init (void *) internal_function; -rtld_hidden_proto (_dl_allocate_tls_init); +rtld_hidden_proto (_dl_allocate_tls_init) /* Deallocate memory allocated with _dl_allocate_tls. */ extern void _dl_deallocate_tls (void *tcb, bool dealloc_tcb) internal_function; |