* sysdeps/generic/libc-tls.c (__libc_setup_tls): Make the phdr loop

actually iterate over the elements.  Fix typo p_type -> p_vaddr.

	* include/pthread.h: Don't declare __pthread_initialize_minimal as
	weak here; we declare it weak or strong in the one place we use it.
	* sysdeps/generic/libc-start.c: ... which is here.
	Don't make the decl weak if [USE_TLS], since static programs need TLS
	setup even when single-threaded.
This commit is contained in:
Roland McGrath 2002-08-05 06:38:00 +00:00
parent 2a185b31a8
commit a162642d80
4 changed files with 20 additions and 10 deletions

View File

@ -1,5 +1,14 @@
2002-08-04 Roland McGrath <roland@redhat.com> 2002-08-04 Roland McGrath <roland@redhat.com>
* sysdeps/generic/libc-tls.c (__libc_setup_tls): Make the phdr loop
actually iterate over the elements. Fix typo p_type -> p_vaddr.
* include/pthread.h: Don't declare __pthread_initialize_minimal as
weak here; we declare it weak or strong in the one place we use it.
* sysdeps/generic/libc-start.c: ... which is here.
Don't make the decl weak if [USE_TLS], since static programs need TLS
setup even when single-threaded.
* stdlib/isomac.c (fmt): Add -DNOT_IN_libc to the compiler command. * stdlib/isomac.c (fmt): Add -DNOT_IN_libc to the compiler command.
* elf/Makefile (test-srcs): Add $(modules-names) to it. * elf/Makefile (test-srcs): Add $(modules-names) to it.

View File

@ -2,5 +2,3 @@
/* This function is called to initialize the pthread library. */ /* This function is called to initialize the pthread library. */
extern void __pthread_initialize (void) __attribute__ ((weak)); extern void __pthread_initialize (void) __attribute__ ((weak));
extern void __pthread_initialize_minimal (void) __attribute__ ((weak));

View File

@ -30,7 +30,12 @@ extern int __libc_multiple_libcs;
extern void *__libc_stack_end; extern void *__libc_stack_end;
#ifndef SHARED #ifndef SHARED
extern void __pthread_initialize_minimal (void) __attribute__ ((weak)); # include <tls.h>
extern void __pthread_initialize_minimal (void)
# if !(USE_TLS - 0)
__attribute__ ((weak))
# endif
;
#endif #endif
@ -91,7 +96,7 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
we need to setup errno. If there is no thread library and we we need to setup errno. If there is no thread library and we
handle TLS the function is defined in the libc to initialized the handle TLS the function is defined in the libc to initialized the
TLS handling. */ TLS handling. */
# ifndef TLS # if !(USE_TLS - 0)
if (__pthread_initialize_minimal) if (__pthread_initialize_minimal)
# endif # endif
__pthread_initialize_minimal (); __pthread_initialize_minimal ();

View File

@ -57,14 +57,12 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
size_t max_align = tcbalign; size_t max_align = tcbalign;
size_t loadaddr = ~0ul; size_t loadaddr = ~0ul;
size_t tcb_offset; size_t tcb_offset;
ElfW(Phdr) *phdr;
/* Look through the TLS segment if there is any. */ /* Look through the TLS segment if there is any. */
if (_dl_phdr != NULL) if (_dl_phdr != NULL)
for (phdr = _dl_phdr; phdr < &_dl_phdr[_dl_phnum]; ++phdr)
{ {
ElfW(Phdr) *phdr = _dl_phdr;
size_t phnum = _dl_phnum;
while (phnum-- > 0)
if (phdr->p_type == PT_TLS) if (phdr->p_type == PT_TLS)
{ {
/* Remember the values we need. */ /* Remember the values we need. */
@ -80,7 +78,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
/* We have to find the load address which is not easy. /* We have to find the load address which is not easy.
Look for the load segment with the lowest address. */ Look for the load segment with the lowest address. */
if (phdr->p_vaddr < loadaddr) if (phdr->p_vaddr < loadaddr)
loadaddr = phdr->p_type; loadaddr = phdr->p_vaddr;
} }
} }