diff options
-rw-r--r-- | include/link.h | 2 | ||||
-rw-r--r-- | ldso/include/dl-string.h | 7 | ||||
-rw-r--r-- | ldso/include/ldsodefs.h | 39 | ||||
-rw-r--r-- | ldso/ldso/Makefile | 13 | ||||
-rw-r--r-- | ldso/ldso/dl-debug.c | 5 | ||||
-rw-r--r-- | ldso/ldso/ldso.c | 5 | ||||
-rw-r--r-- | ldso/libdl/Makefile | 8 | ||||
-rw-r--r-- | libc/sysdeps/linux/alpha/Makefile | 9 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/Makefile | 4 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/alpha/dl-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/generic/dl-minimal.c | 129 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/generic/dl-tls.c | 69 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/generic/powerpc/libc-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/generic/sh/libc-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/generic/sparc/libc-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/i386/dl-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/i386/libc-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/mips/dl-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/powerpc/dl-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/sh/dl-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/sparc/dl-tls.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/x86_64/dl-tls.c | 1 |
22 files changed, 255 insertions, 46 deletions
diff --git a/include/link.h b/include/link.h index e50b8317a..be0b3b83b 100644 --- a/include/link.h +++ b/include/link.h @@ -25,7 +25,7 @@ #include <elf.h> #include <dlfcn.h> #include <sys/types.h> -#ifdef IS_IN_libpthread +#if defined(IS_IN_libpthread) || defined(IS_IN_rtld) #include <tls.h> /* Defines USE_TLS. */ #endif diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h index 8e35e6ad2..2e21a3dff 100644 --- a/ldso/include/dl-string.h +++ b/ldso/include/dl-string.h @@ -13,6 +13,7 @@ static char * _dl_strchr(const char * str,int c); static char *_dl_strrchr(const char *str, int c); static char *_dl_strstr(const char *s1, const char *s2); static void * _dl_memcpy(void * dst, const void * src, size_t len); +static void * _dl_mempcpy(void * dst, const void * src, size_t len); static int _dl_memcmp(const void * s1,const void * s2,size_t len); static void *_dl_memset(void * str,int c,size_t len); static char *_dl_get_last_path_component(char *path); @@ -146,6 +147,12 @@ static inline void * _dl_memcpy(void * dst, const void * src, size_t len) return dst; } +static inline void * _dl_mempcpy(void * dst, const void * src, size_t len) +{ + _dl_memcpy(dst, src, len); + return (void *)(((char *) dst) + len); +} + static __always_inline int _dl_memcmp(const void * s1,const void * s2,size_t len) { unsigned char *c1 = (unsigned char *)s1-1; diff --git a/ldso/include/ldsodefs.h b/ldso/include/ldsodefs.h index 833fe2c25..ce4c375da 100644 --- a/ldso/include/ldsodefs.h +++ b/ldso/include/ldsodefs.h @@ -4,11 +4,19 @@ #include <features.h> #include <tls.h> -/* - * NPTL - These are supposed to be from 'sysdeps/generic/ldsodefs.h' - * and used with the ld.so global structure. I am not sure how - * this fits into uClibc yet, so they are empty. - */ +#ifdef IS_IN_rtld +# define EXTERN +#else +# define EXTERN extern +#endif + +/* Non-shared code has no support for multiple namespaces. */ +#ifdef SHARED +# define DL_NNS 16 +#else +# define DL_NNS 1 +#endif + #define GL(x) _##x #define GLRO(x) _##x @@ -17,7 +25,6 @@ might use the variable which results in copy relocations on some platforms. But this does not matter, ld.so can always use the local copy. */ -//extern void *__libc_stack_end attribute_relro; extern void *__libc_stack_end; rtld_hidden_proto (__libc_stack_end) @@ -64,11 +71,11 @@ extern void _dl_nothread_init_static_tls (struct link_map *) attribute_hidden; 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; + 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; + EXTERN bool _dl_tls_dtv_gaps; /* Information about the dtv slots. */ - extern struct dtv_slotinfo_list + EXTERN struct dtv_slotinfo_list { size_t len; struct dtv_slotinfo_list *next; @@ -80,13 +87,13 @@ extern void _dl_nothread_init_static_tls (struct link_map *) attribute_hidden; } slotinfo[0]; } *_dl_tls_dtv_slotinfo_list; /* Number of modules in the static TLS block. */ - extern size_t _dl_tls_static_nelem; + EXTERN size_t _dl_tls_static_nelem; /* Size of the static TLS block. */ - extern size_t _dl_tls_static_size; + EXTERN size_t _dl_tls_static_size; /* Size actually allocated in the static TLS block. */ - extern size_t _dl_tls_static_used; + EXTERN size_t _dl_tls_static_used; /* Alignment requirement of the static TLS block. */ - extern size_t _dl_tls_static_align; + 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 @@ -97,11 +104,11 @@ extern void _dl_nothread_init_static_tls (struct link_map *) attribute_hidden; # define DTV_SURPLUS (14) /* Initial dtv of the main thread, not allocated with normal malloc. */ - extern void *_dl_initial_dtv; + EXTERN void *_dl_initial_dtv; /* Generation counter for the dtv. */ - extern size_t _dl_tls_generation; + EXTERN size_t _dl_tls_generation; - extern void (*_dl_init_static_tls) (struct link_map *); + EXTERN void (*_dl_init_static_tls) (struct link_map *); #endif #endif diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile index 78af3cb5f..9085254fb 100644 --- a/ldso/ldso/Makefile +++ b/ldso/ldso/Makefile @@ -43,7 +43,7 @@ endif ifeq ($(PTHREADS_NATIVE),y) XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) $(PICFLAG) \ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ - -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I. -I$(TOPDIR)include $(PTINC) + -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I. -I$(TOPDIR)include $(PTINC) -DSHARED -DIS_IN_rtld else XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) $(PICFLAG) \ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ @@ -59,7 +59,7 @@ ifeq ($(UCLIBC_BUILD_RELRO),y) LDFLAGS+=-z relro endif -CSRC= ldso.c +CSRC=ldso.c COBJS=$(patsubst %.c,%.o, $(CSRC)) ASRC=$(shell ls $(TARGET_ARCH)/*.S) AOBJS=$(patsubst %.S,%.o, $(ASRC)) @@ -82,7 +82,14 @@ XXFLAGS := $(XXFLAGS:-fomit-frame-pointer=) all: $(LDSO_FULLNAME) +ifeq ($(PTHREADS_NATIVE),y) +dl-tls.c dl-minimal.c: + $(LN) -sf $(TOPDIR)libpthread/nptl/sysdeps/generic/$@ $@ + +$(LDSO_FULLNAME): dl-tls.c dl-minimal.c $(OBJS) $(DLINK_OBJS) +else $(LDSO_FULLNAME): $(OBJS) $(DLINK_OBJS) +endif $(LD) $(LDFLAGS) -soname=$(UCLIBC_LDSO) \ -o $(LDSO_FULLNAME) $(OBJS) $(LIBGCC) $(INSTALL) -d $(TOPDIR)lib @@ -101,4 +108,4 @@ ldso.o: $(CSRC) dl-elf.c dl-hash.c dl-startup.c dl-debug.c \ $(TARGET_ARCH)/*.h $(TARGET_ARCH)/*.c $(TOPDIR)ldso/include/*.h clean: - $(RM) $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~ + $(RM) $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~ dl-tls.c dl-minimal.c diff --git a/ldso/ldso/dl-debug.c b/ldso/ldso/dl-debug.c index 7ce8bfbce..c105d89db 100644 --- a/ldso/ldso/dl-debug.c +++ b/ldso/ldso/dl-debug.c @@ -98,9 +98,14 @@ static void debug_reloc(ElfW(Sym) *symtab, char *strtab, ELF_RELOC *rpnt) _dl_dprintf(_dl_debug_file, "\n"); } +#define assert(expr) \ + if (!(expr)) \ + _dl_dprintf(_dl_debug_file, "Assert: %s(%d)\n", __FILE__, __LINE__); + #else #define debug_sym(symtab, strtab, symtab_index) #define debug_reloc(symtab, strtab, rpnt) +#define assert(expr) #endif /* __SUPPORT_LD_DEBUG__ */ diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 709d58d25..cfcf82b8c 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -69,6 +69,11 @@ unsigned long attribute_hidden _dl_skip_args = 0; /* Forward function declarations */ static int _dl_suid_ok(void); +#ifdef __PTHREADS_NATIVE__ +#include "dl-minimal.c" +#include "dl-tls.c" +#endif + /* * This stub function is used by some debuggers. The idea is that they * can set an internal breakpoint on it, so that we are notified when the diff --git a/ldso/libdl/Makefile b/ldso/libdl/Makefile index d4d54f911..ccf9d1b30 100644 --- a/ldso/libdl/Makefile +++ b/ldso/libdl/Makefile @@ -27,9 +27,15 @@ XXFLAGS+=-O0 -g3 else XXFLAGS+=$(OPTIMIZATION) endif +ifeq ($(PTHREADS_NATIVE),y) +XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) \ + -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ + -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I. -I$(TOPDIR)include $(PTINC) -DIS_IN_rtld +else XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) \ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I. -I$(TOPDIR)include +endif XXFLAGS+=-isystem $(shell $(CC) -print-file-name=include) XXFLAGS_NOPIC:=$(XXFLAGS) @@ -67,7 +73,7 @@ libdl.o: libdl.c $(TOPDIR)ldso/include/*.h $(STRIPTOOL) -x -R .note -R .comment $*.o libdl_pic.o: libdl.c $(TOPDIR)ldso/include/*.h - $(CC) $(XXFLAGS) -c libdl.c -o libdl_pic.o + $(CC) $(XXFLAGS) -DSHARED -c libdl.c -o libdl_pic.o $(STRIPTOOL) -x -R .note -R .comment $*.o shared: $(LIBDL_PIC) diff --git a/libc/sysdeps/linux/alpha/Makefile b/libc/sysdeps/linux/alpha/Makefile index c37858380..45e2ece62 100644 --- a/libc/sysdeps/linux/alpha/Makefile +++ b/libc/sysdeps/linux/alpha/Makefile @@ -32,6 +32,10 @@ COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(SOBJS) $(COBJS) +ifeq ($(PTHREADS_NATIVE),y) +COBJS += $(PTDIR)sysdeps/$(TARGET_ARCH)/libc-tls.o +endif + OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH) all: $(OBJ_LIST) @@ -76,6 +80,11 @@ $(TOPDIR)lib/crtn.o: $(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o endif +ifeq ($(PTHREADS_NATIVE),y) +$(PTDIR)sysdeps/$(TARGET_ARCH)/libc-tls.o: + $(MAKE) -C $(PTDIR)sysdeps/$(TARGET_ARCH) libc-tls.o +endif + headers: $(LN) -fs ../libc/sysdeps/linux/alpha/fpu_control.h $(TOPDIR)/include/ diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile index 84b29ac53..0ef5922eb 100644 --- a/libc/sysdeps/linux/common/Makefile +++ b/libc/sysdeps/linux/common/Makefile @@ -21,6 +21,10 @@ include $(TOPDIR)Rules.mak SRCS = $(wildcard *.c) +ifeq ($(strip $(PTHREADS_NATIVE)),y) +SRCS := $(filter-out fork.c,$(SRCS)) +endif + ifeq ($(strip $(EXCLUDE_BRK)),y) SRCS := $(filter-out sbrk.c,$(SRCS)) endif diff --git a/libpthread/nptl/sysdeps/alpha/dl-tls.c b/libpthread/nptl/sysdeps/alpha/dl-tls.c new file mode 100644 index 000000000..db50de8ab --- /dev/null +++ b/libpthread/nptl/sysdeps/alpha/dl-tls.c @@ -0,0 +1 @@ +#include <../generic/dl-tls.c> diff --git a/libpthread/nptl/sysdeps/generic/dl-minimal.c b/libpthread/nptl/sysdeps/generic/dl-minimal.c new file mode 100644 index 000000000..02968a91c --- /dev/null +++ b/libpthread/nptl/sysdeps/generic/dl-minimal.c @@ -0,0 +1,129 @@ +/* Minimal replacements for basic facilities used in the dynamic linker. + Copyright (C) 1995-1998,2000-2002,2004 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. */ + +//#include <errno.h> +#include <limits.h> +#include <string.h> +#include <tls.h> +//#include <unistd.h> +#include <sys/param.h> +#include <sys/types.h> +#include <ldsodefs.h> + +/* Minimal `malloc' allocator for use while loading shared libraries. + No block is ever freed. */ + +static void *alloc_ptr, *alloc_end, *alloc_last_block; + +/* Declarations of global functions. */ +extern void weak_function free (void *ptr); +extern void * weak_function realloc (void *ptr, size_t n); + +/* Allocate an aligned memory block. */ +void * weak_function +memalign (size_t align, size_t n) +{ +#ifdef MAP_ANON +#define _dl_zerofd (-1) +#else + extern int _dl_zerofd; + + if (_dl_zerofd == -1) + _dl_zerofd = _dl_sysdep_open_zero_fill (); +#define MAP_ANON 0 +#endif + + if (alloc_end == 0) + { + /* Consume any unused space in the last page of our data segment. */ + extern int _end attribute_hidden; + alloc_ptr = &_end; + alloc_end = (void *) 0 + (((alloc_ptr - (void *) 0) + + GLRO(dl_pagesize) - 1) + & ~(GLRO(dl_pagesize) - 1)); + } + + /* Make sure the allocation pointer is ideally aligned. */ + alloc_ptr = (void *) 0 + (((alloc_ptr - (void *) 0) + align - 1) + & ~(align - 1)); + + if (alloc_ptr + n >= alloc_end) + { + /* Insufficient space left; allocate another page. */ + caddr_t page; + size_t nup = (n + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1); + page = _dl_mmap (0, nup, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, _dl_zerofd, 0); + if (_dl_mmap_check_error(page)) + return -1; + if (page != alloc_end) + alloc_ptr = page; + alloc_end = page + nup; + } + + alloc_last_block = (void *) alloc_ptr; + alloc_ptr += n; + return alloc_last_block; +} + +void * weak_function +malloc (size_t n) +{ + return memalign (sizeof (double), n); +} + +/* We use this function occasionally since the real implementation may + be optimized when it can assume the memory it returns already is + set to NUL. */ +void * weak_function +calloc (size_t nmemb, size_t size) +{ + /* New memory from the trivial malloc above is always already cleared. + (We make sure that's true in the rare occasion it might not be, + by clearing memory in free, below.) */ + return malloc (nmemb * size); +} + +/* This will rarely be called. */ +void weak_function +free (void *ptr) +{ + /* We can free only the last block allocated. */ + if (ptr == alloc_last_block) + { + /* Since this is rare, we clear the freed block here + so that calloc can presume malloc returns cleared memory. */ + _dl_memset (alloc_last_block, '\0', alloc_ptr - alloc_last_block); + alloc_ptr = alloc_last_block; + } +} + +/* This is only called with the most recent block returned by malloc. */ +void * weak_function +realloc (void *ptr, size_t n) +{ + void *new; + if (ptr == NULL) + return malloc (n); + assert (ptr == alloc_last_block); + alloc_ptr = alloc_last_block; + new = malloc (n); + assert (new == ptr); + return new; +} diff --git a/libpthread/nptl/sysdeps/generic/dl-tls.c b/libpthread/nptl/sysdeps/generic/dl-tls.c index 4fed570d5..4c3a9db4b 100644 --- a/libpthread/nptl/sysdeps/generic/dl-tls.c +++ b/libpthread/nptl/sysdeps/generic/dl-tls.c @@ -1,4 +1,4 @@ -/* Thread-local storage handling in the ELF dynamic linker. Generic version. +/* tHREAD-local storage handling in the ELF dynamic linker. Generic version. Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -17,21 +17,27 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <assert.h> -#include <errno.h> #include <libintl.h> #include <signal.h> #include <stdlib.h> -#include <unistd.h> #include <sys/param.h> - #include <tls.h> +#include <dl-tls.h> +#include <ldsodefs.h> -/* We don't need any of this if TLS is not supported. */ -#ifdef USE_TLS +#ifndef IS_IN_rtld +#include <assert.h> +#include <link.h> +#include <string.h> +#include <unistd.h> -# include <dl-tls.h> -# include <ldsodefs.h> +#define _dl_malloc malloc +#define _dl_memset memset +#define _dl_mempcpy mempcpy +#define _dl_dprintf fprintf +#define _dl_debug_file stderr +#define _dl_exit exit +#endif /* Amount of excess space to allocate in the static TLS area to allow dynamic loading of modules defining IE-model TLS data. */ @@ -47,11 +53,20 @@ static void __attribute__ ((__noreturn__)) oom (void) { - _dl_fatal_printf ("cannot allocate memory for thread-local data: ABORT\n"); + do { + _dl_dprintf (_dl_debug_file, + "cannot allocate thread-local memory: ABORT\n"); + _dl_exit (127); + } while (1); } # endif +void *_dl_memalign(size_t alignment, size_t bytes) +{ + return _dl_malloc(bytes); +} + size_t internal_function _dl_next_tls_modid (void) @@ -208,8 +223,9 @@ _dl_determine_tlsoffset (void) # elif TLS_DTV_AT_TP /* The TLS blocks start right after the TCB. */ size_t offset = TLS_TCB_SIZE; + size_t cnt; - for (size_t cnt = 0; slotinfo[cnt].map != NULL; ++cnt) + for (cnt = 0; slotinfo[cnt].map != NULL; ++cnt) { assert (cnt < GL(dl_tls_dtv_slotinfo_list)->len); @@ -346,7 +362,7 @@ _dl_allocate_tls_storage (void) # endif /* Allocate a correctly aligned chunk of memory. */ - result = __libc_memalign (GL(dl_tls_static_align), size); + result = _dl_memalign (GL(dl_tls_static_align), size); if (__builtin_expect (result != NULL, 1)) { /* Allocate the DTV. */ @@ -358,14 +374,14 @@ _dl_allocate_tls_storage (void) /* Clear the TCB data structure. We can't ask the caller (i.e. libpthread) to do it, because we will initialize the DTV et al. */ - memset (result, '\0', TLS_TCB_SIZE); + _dl_memset (result, '\0', TLS_TCB_SIZE); # elif TLS_DTV_AT_TP result = (char *) result + size - GL(dl_tls_static_size); /* Clear the TCB data structure and TLS_PRE_TCB_SIZE bytes before it. We can't ask the caller (i.e. libpthread) to do it, because we will initialize the DTV et al. */ - memset ((char *) result - TLS_PRE_TCB_SIZE, '\0', + _dl_memset ((char *) result - TLS_PRE_TCB_SIZE, '\0', TLS_PRE_TCB_SIZE + TLS_TCB_SIZE); # endif @@ -440,7 +456,7 @@ _dl_allocate_tls_init (void *result) /* Copy the initialization image and clear the BSS part. */ dtv[map->l_tls_modid].pointer.val = dest; dtv[map->l_tls_modid].pointer.is_static = true; - memset (__mempcpy (dest, map->l_tls_initimage, + _dl_memset (_dl_mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size), '\0', map->l_tls_blocksize - map->l_tls_initimage_size); } @@ -476,9 +492,10 @@ internal_function _dl_deallocate_tls (void *tcb, bool dealloc_tcb) { dtv_t *dtv = GET_DTV (tcb); + size_t cnt; /* We need to free the memory allocated for non-static TLS. */ - for (size_t cnt = 0; cnt < dtv[-1].counter; ++cnt) + for (cnt = 0; cnt < dtv[-1].counter; ++cnt) if (! dtv[1 + cnt].pointer.is_static && dtv[1 + cnt].pointer.val != TLS_DTV_UNALLOCATED) free (dtv[1 + cnt].pointer.val); @@ -529,12 +546,12 @@ allocate_and_init (struct link_map *map) { void *newp; - newp = __libc_memalign (map->l_tls_align, map->l_tls_blocksize); + newp = _dl_memalign (map->l_tls_align, map->l_tls_blocksize); if (newp == NULL) oom (); /* Initialize the memory. */ - memset (__mempcpy (newp, map->l_tls_initimage, map->l_tls_initimage_size), + _dl_memset (_dl_mempcpy (newp, map->l_tls_initimage, map->l_tls_initimage_size), '\0', map->l_tls_blocksize - map->l_tls_initimage_size); return newp; @@ -584,7 +601,9 @@ _dl_update_slotinfo (unsigned long int req_modid) listp = GL(dl_tls_dtv_slotinfo_list); do { - for (size_t cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt) + size_t cnt; + + for (cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt) { size_t gen = listp->slotinfo[cnt].gen; @@ -637,7 +656,7 @@ _dl_update_slotinfo (unsigned long int req_modid) newp = malloc ((2 + newsize) * sizeof (dtv_t)); if (newp == NULL) oom (); - memcpy (newp, &dtv[-1], oldsize * sizeof (dtv_t)); + _dl_memcpy (newp, &dtv[-1], oldsize * sizeof (dtv_t)); } else { @@ -650,7 +669,7 @@ _dl_update_slotinfo (unsigned long int req_modid) newp[0].counter = newsize; /* Clear the newly allocated part. */ - memset (newp + 2 + oldsize, '\0', + _dl_memset (newp + 2 + oldsize, '\0', (newsize - oldsize) * sizeof (dtv_t)); /* Point dtv to the generation counter. */ @@ -782,13 +801,14 @@ _dl_add_to_slotinfo (struct link_map *l) generation. */ ++GL(dl_tls_generation); - _dl_signal_error (ENOMEM, "dlopen", NULL, N_("\ -cannot create TLS data structures")); + _dl_dprintf (_dl_debug_file, + "cannot create TLS data structures: ABORT\n"); + _dl_exit (127); } listp->len = TLS_SLOTINFO_SURPLUS; listp->next = NULL; - memset (listp->slotinfo, '\0', + _dl_memset (listp->slotinfo, '\0', TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo)); } @@ -796,4 +816,3 @@ cannot create TLS data structures")); listp->slotinfo[idx].map = l; listp->slotinfo[idx].gen = GL(dl_tls_generation) + 1; } -#endif /* use TLS */ diff --git a/libpthread/nptl/sysdeps/generic/powerpc/libc-tls.c b/libpthread/nptl/sysdeps/generic/powerpc/libc-tls.c new file mode 100644 index 000000000..4e726c14d --- /dev/null +++ b/libpthread/nptl/sysdeps/generic/powerpc/libc-tls.c @@ -0,0 +1 @@ +#include <../generic/libc-tls.c> diff --git a/libpthread/nptl/sysdeps/generic/sh/libc-tls.c b/libpthread/nptl/sysdeps/generic/sh/libc-tls.c new file mode 100644 index 000000000..4e726c14d --- /dev/null +++ b/libpthread/nptl/sysdeps/generic/sh/libc-tls.c @@ -0,0 +1 @@ +#include <../generic/libc-tls.c> diff --git a/libpthread/nptl/sysdeps/generic/sparc/libc-tls.c b/libpthread/nptl/sysdeps/generic/sparc/libc-tls.c new file mode 100644 index 000000000..4e726c14d --- /dev/null +++ b/libpthread/nptl/sysdeps/generic/sparc/libc-tls.c @@ -0,0 +1 @@ +#include <../generic/libc-tls.c> diff --git a/libpthread/nptl/sysdeps/i386/dl-tls.c b/libpthread/nptl/sysdeps/i386/dl-tls.c new file mode 100644 index 000000000..db50de8ab --- /dev/null +++ b/libpthread/nptl/sysdeps/i386/dl-tls.c @@ -0,0 +1 @@ +#include <../generic/dl-tls.c> diff --git a/libpthread/nptl/sysdeps/i386/libc-tls.c b/libpthread/nptl/sysdeps/i386/libc-tls.c new file mode 100644 index 000000000..4e726c14d --- /dev/null +++ b/libpthread/nptl/sysdeps/i386/libc-tls.c @@ -0,0 +1 @@ +#include <../generic/libc-tls.c> diff --git a/libpthread/nptl/sysdeps/mips/dl-tls.c b/libpthread/nptl/sysdeps/mips/dl-tls.c new file mode 100644 index 000000000..db50de8ab --- /dev/null +++ b/libpthread/nptl/sysdeps/mips/dl-tls.c @@ -0,0 +1 @@ +#include <../generic/dl-tls.c> diff --git a/libpthread/nptl/sysdeps/powerpc/dl-tls.c b/libpthread/nptl/sysdeps/powerpc/dl-tls.c new file mode 100644 index 000000000..db50de8ab --- /dev/null +++ b/libpthread/nptl/sysdeps/powerpc/dl-tls.c @@ -0,0 +1 @@ +#include <../generic/dl-tls.c> diff --git a/libpthread/nptl/sysdeps/sh/dl-tls.c b/libpthread/nptl/sysdeps/sh/dl-tls.c new file mode 100644 index 000000000..db50de8ab --- /dev/null +++ b/libpthread/nptl/sysdeps/sh/dl-tls.c @@ -0,0 +1 @@ +#include <../generic/dl-tls.c> diff --git a/libpthread/nptl/sysdeps/sparc/dl-tls.c b/libpthread/nptl/sysdeps/sparc/dl-tls.c new file mode 100644 index 000000000..db50de8ab --- /dev/null +++ b/libpthread/nptl/sysdeps/sparc/dl-tls.c @@ -0,0 +1 @@ +#include <../generic/dl-tls.c> diff --git a/libpthread/nptl/sysdeps/x86_64/dl-tls.c b/libpthread/nptl/sysdeps/x86_64/dl-tls.c new file mode 100644 index 000000000..db50de8ab --- /dev/null +++ b/libpthread/nptl/sysdeps/x86_64/dl-tls.c @@ -0,0 +1 @@ +#include <../generic/dl-tls.c> |