From vda at uclibc.org Mon Dec 3 00:59:14 2007 From: vda at uclibc.org (vda at uclibc.org) Date: Mon, 3 Dec 2007 00:59:14 -0800 (PST) Subject: svn commit: trunk/uClibc/libc/stdlib Message-ID: <20071203085914.866F8128030@busybox.net> Author: vda Date: 2007-12-03 00:59:12 -0800 (Mon, 03 Dec 2007) New Revision: 20609 Log: realpath: reduce stack usage from 3*PATH_MAX (12k) to 1*PATH_MAX (4k). reduction is achieved by direct use of user-supplied PATH_MAX sized buffer for result (without intermediate copy) and changes in copy_buf[] usage - now it is used for both "source" pathname and link name (it works because they have to be less than PATH_MAX combined, otherwise we return NULL). Modified: trunk/uClibc/libc/stdlib/realpath.c Changeset: Modified: trunk/uClibc/libc/stdlib/realpath.c =================================================================== --- trunk/uClibc/libc/stdlib/realpath.c 2007-12-02 08:56:53 UTC (rev 20608) +++ trunk/uClibc/libc/stdlib/realpath.c 2007-12-03 08:59:12 UTC (rev 20609) @@ -43,20 +43,23 @@ #define MAX_READLINKS 32 #ifdef __STDC__ -char *realpath(const char *path, char resolved_path[]) +char *realpath(const char *path, char got_path[]) #else -char *realpath(path, resolved_path) +char *realpath(path, got_path) const char *path; -char resolved_path[]; +char got_path[]; #endif { char copy_path[PATH_MAX]; - char link_path[PATH_MAX]; - char got_path[PATH_MAX]; - char *new_path = got_path; + /* use user supplied buffer directly - reduces stack usage */ + /* char got_path[PATH_MAX]; */ char *max_path; + char *new_path; + size_t path_len; int readlinks = 0; - int n; +#ifdef S_IFLNK + int link_len; +#endif if (path == NULL) { __set_errno(EINVAL); @@ -67,17 +70,20 @@ return NULL; } /* Make a copy of the source path since we may need to modify it. */ - if (strlen(path) >= PATH_MAX - 2) { + path_len = strlen(path); + if (path_len >= PATH_MAX - 2) { __set_errno(ENAMETOOLONG); return NULL; } - strcpy(copy_path, path); - path = copy_path; - max_path = copy_path + PATH_MAX - 2; - /* If it's a relative pathname use getcwd for starters. */ + /* Copy so that path is at the end of copy_path[] */ + strcpy(copy_path + (PATH_MAX-1) - path_len, path); + path = copy_path + (PATH_MAX-1) - path_len; + max_path = got_path + PATH_MAX - 2; /* points to last non-NUL char */ + new_path = got_path; if (*path != '/') { - /* Ohoo... */ - getcwd(new_path, PATH_MAX - 1); + /* If it's a relative pathname use getcwd for starters. */ + if (!getcwd(new_path, PATH_MAX - 1)) + return NULL; new_path += strlen(new_path); if (new_path[-1] != '/') *new_path++ = '/'; @@ -112,7 +118,7 @@ } /* Safely copy the next pathname component. */ while (*path != '\0' && *path != '/') { - if (path > max_path) { + if (new_path > max_path) { __set_errno(ENAMETOOLONG); return NULL; } @@ -124,35 +130,32 @@ __set_errno(ELOOP); return NULL; } - /* See if latest pathname component is a symlink. */ + path_len = strlen(path); + /* See if last (so far) pathname component is a symlink. */ *new_path = '\0'; - n = readlink(got_path, link_path, PATH_MAX - 1); - if (n < 0) { + link_len = readlink(got_path, copy_path, PATH_MAX - 1); + if (link_len < 0) { /* EINVAL means the file exists but isn't a symlink. */ if (errno != EINVAL) { - /* Make sure it's null terminated. */ - *new_path = '\0'; - strcpy(resolved_path, got_path); return NULL; } } else { + /* Safe sex check. */ + if (path_len + link_len >= PATH_MAX - 2) { + __set_errno(ENAMETOOLONG); + return NULL; + } /* Note: readlink doesn't add the null byte. */ - link_path[n] = '\0'; - if (*link_path == '/') + /* copy_path[link_len] = '\0'; - we don't need it too */ + if (*copy_path == '/') /* Start over for an absolute symlink. */ new_path = got_path; else /* Otherwise back up over this component. */ while (*(--new_path) != '/'); - /* Safe sex check. */ - if (strlen(path) + n >= PATH_MAX - 2) { - __set_errno(ENAMETOOLONG); - return NULL; - } - /* Insert symlink contents into path. */ - strcat(link_path, path); - strcpy(copy_path, link_path); - path = copy_path; + /* Prepend symlink contents to path. */ + memmove(copy_path + (PATH_MAX-1) - link_len - path_len, copy_path, link_len); + path = copy_path + (PATH_MAX-1) - link_len - path_len; } #endif /* S_IFLNK */ *new_path++ = '/'; @@ -162,6 +165,5 @@ new_path--; /* Make sure it's null terminated. */ *new_path = '\0'; - strcpy(resolved_path, got_path); - return resolved_path; + return got_path; } From carmelo at uclibc.org Mon Dec 3 12:58:34 2007 From: carmelo at uclibc.org (carmelo at uclibc.org) Date: Mon, 3 Dec 2007 12:58:34 -0800 (PST) Subject: svn commit: trunk/uClibc/ldso/include Message-ID: <20071203205834.209C312802A@busybox.net> Author: carmelo Date: 2007-12-03 12:58:30 -0800 (Mon, 03 Dec 2007) New Revision: 20611 Log: Some versions of gcc consider inline merely a hint. AVR32 depends on the system calls actually being inlined, so AVR32 needs to use __always_inline instead of just inline. The attached patch changes this for the system calls. Signed-off-by: Hans-Christian Egtvedt Modified: trunk/uClibc/ldso/include/dl-syscall.h Changeset: Modified: trunk/uClibc/ldso/include/dl-syscall.h =================================================================== --- trunk/uClibc/ldso/include/dl-syscall.h 2007-12-03 10:45:14 UTC (rev 20610) +++ trunk/uClibc/ldso/include/dl-syscall.h 2007-12-03 20:58:30 UTC (rev 20611) @@ -59,69 +59,69 @@ dynamic linking at all, so we cannot return any error codes. We just punt if there is an error. */ #define __NR__dl_exit __NR_exit -static inline _syscall1(void, _dl_exit, int, status); +static __always_inline _syscall1(void, _dl_exit, int, status); #define __NR__dl_close __NR_close -static inline _syscall1(int, _dl_close, int, fd); +static __always_inline _syscall1(int, _dl_close, int, fd); #define __NR__dl_open __NR_open -static inline _syscall3(int, _dl_open, const char *, fn, int, flags, +static __always_inline _syscall3(int, _dl_open, const char *, fn, int, flags, __kernel_mode_t, mode); #define __NR__dl_write __NR_write -static inline _syscall3(unsigned long, _dl_write, int, fd, +static __always_inline _syscall3(unsigned long, _dl_write, int, fd, const void *, buf, unsigned long, count); #define __NR__dl_read __NR_read -static inline _syscall3(unsigned long, _dl_read, int, fd, +static __always_inline _syscall3(unsigned long, _dl_read, int, fd, const void *, buf, unsigned long, count); #define __NR__dl_mprotect __NR_mprotect -static inline _syscall3(int, _dl_mprotect, const void *, addr, +static __always_inline _syscall3(int, _dl_mprotect, const void *, addr, unsigned long, len, int, prot); #define __NR__dl_stat __NR_stat -static inline _syscall2(int, _dl_stat, const char *, file_name, +static __always_inline _syscall2(int, _dl_stat, const char *, file_name, struct stat *, buf); #define __NR__dl_fstat __NR_fstat -static inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf); +static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf); #define __NR__dl_munmap __NR_munmap -static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length); +static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length); #ifdef __NR_getxuid # define __NR_getuid __NR_getxuid #endif #define __NR__dl_getuid __NR_getuid -static inline _syscall0(uid_t, _dl_getuid); +static __always_inline _syscall0(uid_t, _dl_getuid); #ifndef __NR_geteuid # define __NR_geteuid __NR_getuid #endif #define __NR__dl_geteuid __NR_geteuid -static inline _syscall0(uid_t, _dl_geteuid); +static __always_inline _syscall0(uid_t, _dl_geteuid); #ifdef __NR_getxgid # define __NR_getgid __NR_getxgid #endif #define __NR__dl_getgid __NR_getgid -static inline _syscall0(gid_t, _dl_getgid); +static __always_inline _syscall0(gid_t, _dl_getgid); #ifndef __NR_getegid # define __NR_getegid __NR_getgid #endif #define __NR__dl_getegid __NR_getegid -static inline _syscall0(gid_t, _dl_getegid); +static __always_inline _syscall0(gid_t, _dl_getegid); #ifdef __NR_getxpid # define __NR_getpid __NR_getxpid #endif #define __NR__dl_getpid __NR_getpid -static inline _syscall0(gid_t, _dl_getpid); +static __always_inline _syscall0(gid_t, _dl_getpid); #define __NR__dl_readlink __NR_readlink -static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf, +static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf, size_t, bufsiz); #ifdef __UCLIBC_HAS_SSP__ @@ -150,14 +150,14 @@ #if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap) # define __NR__dl_mmap __NR_mmap -static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length, +static __always_inline _syscall6(void *, _dl_mmap, void *, start, size_t, length, int, prot, int, flags, int, fd, off_t, offset); /* then try mmap2() */ #elif defined(__NR_mmap2) # define __NR___syscall_mmap2 __NR_mmap2 -static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len, +static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len, int, prot, int, flags, int, fd, off_t, offset); /* Some architectures always use 12 as page shift for mmap2() eventhough the @@ -168,7 +168,7 @@ # define MMAP2_PAGE_SHIFT 12 #endif -static inline void * _dl_mmap(void * addr, unsigned long size, int prot, +static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot, int flags, int fd, unsigned long offset) { if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) @@ -181,8 +181,8 @@ #elif defined(__NR_mmap) # define __NR__dl_mmap_real __NR_mmap -static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer); -static inline void * _dl_mmap(void * addr, unsigned long size, int prot, +static __always_inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer); +static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot, int flags, int fd, unsigned long offset) { unsigned long buffer[6]; From bernds at uclibc.org Mon Dec 3 14:41:40 2007 From: bernds at uclibc.org (bernds at uclibc.org) Date: Mon, 3 Dec 2007 14:41:40 -0800 (PST) Subject: svn commit: trunk/uClibc/ldso: include ldso libdl Message-ID: <20071203224140.67EA512802B@busybox.net> Author: bernds Date: 2007-12-03 14:41:36 -0800 (Mon, 03 Dec 2007) New Revision: 20612 Log: Blackfin FD-PIC patch 1/6. Add a new function _dl_free. In _dl_malloc, ensure we always get back a full page from mmap. Reset _dl_malloc_function and _dl_free_function when libdl is initialized. Modified: trunk/uClibc/ldso/include/ldso.h trunk/uClibc/ldso/ldso/ldso.c trunk/uClibc/ldso/libdl/libdl.c Changeset: Modified: trunk/uClibc/ldso/include/ldso.h =================================================================== --- trunk/uClibc/ldso/include/ldso.h 2007-12-03 20:58:30 UTC (rev 20611) +++ trunk/uClibc/ldso/include/ldso.h 2007-12-03 22:41:36 UTC (rev 20612) @@ -99,7 +99,8 @@ #define NULL ((void *) 0) #endif -extern void *_dl_malloc(int size); +extern void *_dl_malloc(size_t size); +extern void _dl_free(void *); extern char *_dl_getenv(const char *symbol, char **envp); extern void _dl_unsetenv(const char *symbol, char **envp); extern char *_dl_strdup(const char *string); Modified: trunk/uClibc/ldso/ldso/ldso.c =================================================================== --- trunk/uClibc/ldso/ldso/ldso.c 2007-12-03 20:58:30 UTC (rev 20611) +++ trunk/uClibc/ldso/ldso/ldso.c 2007-12-03 22:41:36 UTC (rev 20612) @@ -50,6 +50,7 @@ size_t _dl_pagesize = 0; /* Store the page size for use later */ struct r_debug *_dl_debug_addr = NULL; /* Used to communicate with the gdb debugger */ void *(*_dl_malloc_function) (size_t size) = NULL; +void (*_dl_free_function) (void *p) = NULL; #ifdef __SUPPORT_LD_DEBUG__ char *_dl_debug = 0; @@ -884,7 +885,7 @@ return 0; } -void *_dl_malloc(int size) +void *_dl_malloc(size_t size) { void *retval; @@ -895,9 +896,26 @@ if (_dl_malloc_function) return (*_dl_malloc_function) (size); - if (_dl_malloc_addr - _dl_mmap_zero + (unsigned)size > _dl_pagesize) { + if (_dl_malloc_addr - _dl_mmap_zero + size > _dl_pagesize) { + size_t rounded_size; + + /* Since the above assumes we get a full page even if + we request less than that, make sure we request a + full page, since uClinux may give us less than than + a full page. We might round even + larger-than-a-page sizes, but we end up never + reusing _dl_mmap_zero/_dl_malloc_addr in that case, + so we don't do it. + + The actual page size doesn't really matter; as long + as we're self-consistent here, we're safe. */ + if (size < _dl_pagesize) + rounded_size = (size + _dl_pagesize - 1) & _dl_pagesize; + else + rounded_size = size; + _dl_debug_early("mmapping more memory\n"); - _dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, size, + _dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, rounded_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (_dl_mmap_check_error(_dl_mmap_zero)) { _dl_dprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname); @@ -916,5 +934,11 @@ return retval; } +void _dl_free (void *p) +{ + if (_dl_free_function) + (*_dl_free_function) (p); +} + #include "dl-hash.c" #include "dl-elf.c" Modified: trunk/uClibc/ldso/libdl/libdl.c =================================================================== --- trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 20:58:30 UTC (rev 20611) +++ trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 22:41:36 UTC (rev 20612) @@ -32,6 +32,7 @@ #include #include +#include #ifdef SHARED @@ -51,6 +52,7 @@ extern struct r_debug *_dl_debug_addr; extern unsigned long _dl_error_number; extern void *(*_dl_malloc_function)(size_t); +extern void (*_dl_free_function) (void *p); extern void _dl_run_init_array(struct elf_resolve *); extern void _dl_run_fini_array(struct elf_resolve *); #ifdef __LDSO_CACHE_SUPPORT__ @@ -67,6 +69,9 @@ #else /* SHARED */ +#define _dl_malloc malloc +#define _dl_free free + /* When libdl is linked as a static library, we need to replace all * the symbols that otherwise would have been loaded in from ldso... */ @@ -83,13 +88,15 @@ int _dl_debug_file = 2; #endif const char *_dl_progname = ""; /* Program name */ +void *(*_dl_malloc_function)(size_t); +void (*_dl_free_function) (void *p); char *_dl_library_path = 0; /* Where we look for libraries */ char *_dl_ldsopath = 0; /* Location of the shared lib loader */ int _dl_errno = 0; /* We can't use the real errno in ldso */ size_t _dl_pagesize = PAGE_SIZE; /* Store the page size for use later */ /* This global variable is also to communicate with debuggers such as gdb. */ struct r_debug *_dl_debug_addr = NULL; -#define _dl_malloc malloc + #include "../ldso/dl-array.c" #include "../ldso/dl-debug.c" #include LDSO_ELFINTERP @@ -157,6 +164,7 @@ struct init_fini_list *tmp, *runp, *runp2, *dep_list; unsigned int nlist, i; struct elf_resolve **init_fini_list; + static int _dl_init = 0; /* A bit of sanity checking... */ if (!(flag & (RTLD_LAZY|RTLD_NOW))) { @@ -166,6 +174,11 @@ from = (ElfW(Addr)) __builtin_return_address(0); + if (!_dl_init) { + _dl_init++; + _dl_malloc_function = malloc; + _dl_free_function = free; + } /* Cover the trivial case first */ if (!libname) return _dl_symbol_tables; From bernds at uclibc.org Mon Dec 3 14:46:56 2007 From: bernds at uclibc.org (bernds at uclibc.org) Date: Mon, 3 Dec 2007 14:46:56 -0800 (PST) Subject: svn commit: trunk/uClibc/ldso: include ldso libdl Message-ID: <20071203224656.A34AD12802B@busybox.net> Author: bernds Date: 2007-12-03 14:46:53 -0800 (Mon, 03 Dec 2007) New Revision: 20613 Log: Blackfin FD-PIC patch 2/6. Add the necessary changes in ld.so and libdl to deal with targets that prepend an underscore to symbol names. Modified: trunk/uClibc/ldso/include/dl-defs.h trunk/uClibc/ldso/ldso/ldso.c trunk/uClibc/ldso/libdl/libdl.c Changeset: Modified: trunk/uClibc/ldso/include/dl-defs.h =================================================================== --- trunk/uClibc/ldso/include/dl-defs.h 2007-12-03 22:41:36 UTC (rev 20612) +++ trunk/uClibc/ldso/include/dl-defs.h 2007-12-03 22:46:53 UTC (rev 20613) @@ -175,4 +175,10 @@ # define DL_MALLOC_ALIGN (__WORDSIZE / 8) #endif +#ifdef __UCLIBC_NO_UNDERSCORES__ +#define __C_SYMBOL_PREFIX__ "" +#else +#define __C_SYMBOL_PREFIX__ "_" +#endif + #endif /* _LD_DEFS_H */ Modified: trunk/uClibc/ldso/ldso/ldso.c =================================================================== --- trunk/uClibc/ldso/ldso/ldso.c 2007-12-03 22:41:36 UTC (rev 20612) +++ trunk/uClibc/ldso/ldso/ldso.c 2007-12-03 22:46:53 UTC (rev 20613) @@ -773,7 +773,7 @@ * ld.so.1, so we have to look up each symbol individually. */ - _dl_envp = (unsigned long *) (intptr_t) _dl_find_hash("__environ", _dl_symbol_tables, NULL, 0); + _dl_envp = (unsigned long *) (intptr_t) _dl_find_hash(__C_SYMBOL_PREFIX__ "__environ", _dl_symbol_tables, NULL, 0); if (_dl_envp) *_dl_envp = (unsigned long) envp; @@ -828,8 +828,8 @@ } /* Find the real malloc function and make ldso functions use that from now on */ - _dl_malloc_function = (void* (*)(size_t)) (intptr_t) _dl_find_hash("malloc", - _dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT); + _dl_malloc_function = (void* (*)(size_t)) (intptr_t) _dl_find_hash(__C_SYMBOL_PREFIX__ "malloc", + _dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT); /* Notify the debugger that all objects are now mapped in. */ _dl_debug_addr->r_state = RT_CONSISTENT; Modified: trunk/uClibc/ldso/libdl/libdl.c =================================================================== --- trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 22:41:36 UTC (rev 20612) +++ trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 22:46:53 UTC (rev 20613) @@ -446,7 +446,22 @@ ElfW(Addr) from; struct dyn_elf *rpnt; void *ret; - + /* Nastiness to support underscore prefixes. */ + char tmp_buf[80]; +#ifndef __UCLIBC_NO_UNDERSCORES__ + char *name2 = tmp_buf; + size_t nlen = strlen (name) + 1; + if (nlen + 1 > sizeof (tmp_buf)) + name2 = malloc (nlen + 1); + if (name2 == 0) { + _dl_error_number = LD_ERROR_MMAP_FAILED; + return 0; + } + name2[0] = '_'; + memcpy (name2 + 1, name, nlen); +#else + const char *name2 = name; +#endif handle = (struct dyn_elf *) vhandle; /* First of all verify that we have a real handle @@ -460,7 +475,8 @@ break; if (!rpnt) { _dl_error_number = LD_BAD_HANDLE; - return NULL; + ret = NULL; + goto out; } } else if (handle == RTLD_NEXT) { /* @@ -484,13 +500,18 @@ tpnt = NULL; if (handle == _dl_symbol_tables) tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */ - ret = _dl_find_hash((char*)name, handle, tpnt, 0); + ret = _dl_find_hash(name2, handle, tpnt, 0); /* * Nothing found. */ if (!ret) _dl_error_number = LD_NO_SYMBOL; +out: +#ifndef __UCLIBC_NO_UNDERSCORES__ + if (name2 != tmp_buf) + free (name2); +#endif return ret; } From bernds at uclibc.org Mon Dec 3 14:54:19 2007 From: bernds at uclibc.org (bernds at uclibc.org) Date: Mon, 3 Dec 2007 14:54:19 -0800 (PST) Subject: svn commit: trunk/uClibc/ldso: include ldso ldso/bfin libdl Message-ID: <20071203225419.E6E8C12802B@busybox.net> Author: bernds Date: 2007-12-03 14:54:16 -0800 (Mon, 03 Dec 2007) New Revision: 20614 Log: Blackfin FD-PIC patch 3/6. Change _dl_find_hash to _dl_lookup_hash, as on the NPTL branch. _dl_find_hash is now a wrapper function around it; unlike on the NPTL branch, it retains the old interface so that not all callers need to be changed. _dl_lookup_hash can optionally give its caller a pointer to the module where the symbol was found. Introduce ELF_RTYPE_CLASS_DLSYM for lookups from libdl. Spelling fixes in the Blackfin port, since Alex Oliva's original version of these patches used _dl_find_hash_mod as the name of the function rather than _dl_lookup_hash. Modified: trunk/uClibc/ldso/include/dl-defs.h trunk/uClibc/ldso/include/dl-elf.h trunk/uClibc/ldso/include/dl-hash.h trunk/uClibc/ldso/ldso/bfin/elfinterp.c trunk/uClibc/ldso/ldso/dl-hash.c trunk/uClibc/ldso/libdl/libdl.c Changeset: Modified: trunk/uClibc/ldso/include/dl-defs.h =================================================================== --- trunk/uClibc/ldso/include/dl-defs.h 2007-12-03 22:46:53 UTC (rev 20613) +++ trunk/uClibc/ldso/include/dl-defs.h 2007-12-03 22:54:16 UTC (rev 20614) @@ -181,4 +181,11 @@ #define __C_SYMBOL_PREFIX__ "_" #endif +/* Define this if you want to modify the VALUE returned by + _dl_find_hash for this reloc TYPE. TPNT is the module in which the + matching SYM was found. */ +#ifndef DL_FIND_HASH_VALUE +# define DL_FIND_HASH_VALUE(TPNT, TYPE, SYM) (DL_RELOC_ADDR ((SYM)->st_value, (TPNT)->loadaddr)) +#endif + #endif /* _LD_DEFS_H */ Modified: trunk/uClibc/ldso/include/dl-elf.h =================================================================== --- trunk/uClibc/ldso/include/dl-elf.h 2007-12-03 22:46:53 UTC (rev 20613) +++ trunk/uClibc/ldso/include/dl-elf.h 2007-12-03 22:54:16 UTC (rev 20614) @@ -183,7 +183,12 @@ #endif #define ELF_RTYPE_CLASS_PLT (0x1) +/* dlsym() calls _dl_find_hash with this value, that enables + DL_FIND_HASH_VALUE to return something different than the symbol + itself, e.g., a function descriptor. */ +#define ELF_RTYPE_CLASS_DLSYM 0x80000000 + /* Convert between the Linux flags for page protections and the ones specified in the ELF standard. */ #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \ Modified: trunk/uClibc/ldso/include/dl-hash.h =================================================================== --- trunk/uClibc/ldso/include/dl-hash.h 2007-12-03 22:46:53 UTC (rev 20613) +++ trunk/uClibc/ldso/include/dl-hash.h 2007-12-03 22:54:16 UTC (rev 20614) @@ -105,9 +105,23 @@ DL_LOADADDR_TYPE loadaddr, unsigned long * dynamic_info, unsigned long dynamic_addr, unsigned long dynamic_size); -extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1, - struct elf_resolve *mytpnt, int type_class); +extern char * _dl_lookup_hash(const char * name, struct dyn_elf * rpnt, + struct elf_resolve *mytpnt, int type_class +#ifdef __FDPIC__ + , struct elf_resolve **tpntp +#endif + ); +static __always_inline char *_dl_find_hash(const char *name, struct dyn_elf *rpnt, + struct elf_resolve *mytpnt, int type_class) +{ +#ifdef __FDPIC__ + return _dl_lookup_hash(name, rpnt, mytpnt, type_class, NULL); +#else + return _dl_lookup_hash(name, rpnt, mytpnt, type_class); +#endif +} + extern int _dl_linux_dynamic_link(void); extern char * _dl_library_path; Modified: trunk/uClibc/ldso/ldso/bfin/elfinterp.c =================================================================== --- trunk/uClibc/ldso/ldso/bfin/elfinterp.c 2007-12-03 22:46:53 UTC (rev 20613) +++ trunk/uClibc/ldso/ldso/bfin/elfinterp.c 2007-12-03 22:54:16 UTC (rev 20614) @@ -72,11 +72,9 @@ got_entry = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset); /* Get the address to be used to fill in the GOT entry. */ - new_addr = _dl_find_hash_mod(symname, tpnt->symbol_scope, NULL, 0, - &new_tpnt); + new_addr = _dl_lookup_hash(symname, tpnt->symbol_scope, NULL, 0, &new_tpnt); if (!new_addr) { - new_addr = _dl_find_hash_mod(symname, NULL, NULL, 0, - &new_tpnt); + new_addr = _dl_lookup_hash(symname, NULL, NULL, 0, &new_tpnt); if (!new_addr) { _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname); @@ -188,7 +186,7 @@ } else { symbol_addr = (unsigned long) - _dl_find_hash_mod(symname, scope, NULL, 0, &symbol_tpnt); + _dl_lookup_hash(symname, scope, NULL, 0, &symbol_tpnt); /* * We want to allow undefined references to weak symbols - this might Modified: trunk/uClibc/ldso/ldso/dl-hash.c =================================================================== --- trunk/uClibc/ldso/ldso/dl-hash.c 2007-12-03 22:46:53 UTC (rev 20613) +++ trunk/uClibc/ldso/ldso/dl-hash.c 2007-12-03 22:54:16 UTC (rev 20614) @@ -257,7 +257,12 @@ * This function resolves externals, and this is either called when we process * relocations or when we call an entry in the PLT table for the first time. */ -char *_dl_find_hash(const char *name, struct dyn_elf *rpnt, struct elf_resolve *mytpnt, int type_class) +char *_dl_lookup_hash(const char *name, struct dyn_elf *rpnt, + struct elf_resolve *mytpnt, int type_class +#ifdef __FDPIC__ + , struct elf_resolve **tpntp +#endif + ) { struct elf_resolve *tpnt = NULL; ElfW(Sym) *symtab; @@ -265,7 +270,8 @@ unsigned long elf_hash_number = 0xffffffff; const ElfW(Sym) *sym = NULL; - char *weak_result = NULL; + const ElfW(Sym) *weak_sym = 0; + struct elf_resolve *weak_tpnt = 0; #ifdef __LDSO_GNU_HASH_SUPPORT__ unsigned long gnu_hash_number = _dl_gnu_hash((const unsigned char *)name); @@ -326,15 +332,32 @@ #if 0 /* Perhaps we should support old style weak symbol handling * per what glibc does when you export LD_DYNAMIC_WEAK */ - if (!weak_result) - weak_result = (char *) DL_RELOC_ADDR(tpnt->loadaddr, sym->st_value); + if (!weak_sym) { + weak_tpnt = tpnt; + weak_sym = sym; + } break; #endif case STB_GLOBAL: - return (char*) DL_RELOC_ADDR(tpnt->loadaddr, sym->st_value); +#ifdef __FDPIC__ + if (tpntp) + *tpntp = tpnt; +#endif + return DL_FIND_HASH_VALUE (tpnt, type_class, sym); default: /* Local symbols not handled here */ break; } } - return weak_result; + if (weak_sym) { +#ifdef __FDPIC__ + if (tpntp) + *tpntp = weak_tpnt; +#endif + return DL_FIND_HASH_VALUE (weak_tpnt, type_class, weak_sym); + } +#ifdef __FDPIC__ + if (tpntp) + *tpntp = NULL; +#endif + return NULL; } Modified: trunk/uClibc/ldso/libdl/libdl.c =================================================================== --- trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 22:46:53 UTC (rev 20613) +++ trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 22:54:16 UTC (rev 20614) @@ -500,7 +500,7 @@ tpnt = NULL; if (handle == _dl_symbol_tables) tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */ - ret = _dl_find_hash(name2, handle, tpnt, 0); + ret = _dl_find_hash(name2, handle, tpnt, ELF_RTYPE_CLASS_DLSYM); /* * Nothing found. From bernds at uclibc.org Mon Dec 3 15:01:57 2007 From: bernds at uclibc.org (bernds at uclibc.org) Date: Mon, 3 Dec 2007 15:01:57 -0800 (PST) Subject: svn commit: trunk/uClibc/ldso/include Message-ID: <20071203230157.206D912850D@busybox.net> Author: bernds Date: 2007-12-03 15:01:56 -0800 (Mon, 03 Dec 2007) New Revision: 20615 Log: Blackfin FD-PIC patch 4/6. Add a hash table for function descriptors on FD-PIC targets. Modified: trunk/uClibc/ldso/include/dl-hash.h Changeset: Modified: trunk/uClibc/ldso/include/dl-hash.h =================================================================== --- trunk/uClibc/ldso/include/dl-hash.h 2007-12-03 22:54:16 UTC (rev 20614) +++ trunk/uClibc/ldso/include/dl-hash.h 2007-12-03 23:01:56 UTC (rev 20615) @@ -89,6 +89,13 @@ * we don't have to calculate it every time, which requires a divide */ unsigned long data_words; #endif + +#ifdef __FDPIC__ + /* Every loaded module holds a hashtable of function descriptors of + functions defined in it, such that it's easy to release the + memory when the module is dlclose()d. */ + struct funcdesc_ht *funcdesc_ht; +#endif }; #define RELOCS_DONE 0x000001 From bernds at uclibc.org Mon Dec 3 15:10:17 2007 From: bernds at uclibc.org (bernds at uclibc.org) Date: Mon, 3 Dec 2007 15:10:17 -0800 (PST) Subject: svn commit: trunk/uClibc/ldso: include ldso Message-ID: <20071203231017.CD133128559@busybox.net> Author: bernds Date: 2007-12-03 15:10:14 -0800 (Mon, 03 Dec 2007) New Revision: 20616 Log: Blackfin FD-PIC patches 5/6. A couple more target macros for ld.so to deal with FD-PIC support. We need special code to compute the initial got and dpnt, and we need to pass extra arguments to _dl_get_ready_to_run. Modified: trunk/uClibc/ldso/include/dl-defs.h trunk/uClibc/ldso/include/ldso.h trunk/uClibc/ldso/ldso/dl-startup.c trunk/uClibc/ldso/ldso/ldso.c Changeset: Modified: trunk/uClibc/ldso/include/dl-defs.h =================================================================== --- trunk/uClibc/ldso/include/dl-defs.h 2007-12-03 23:01:56 UTC (rev 20615) +++ trunk/uClibc/ldso/include/dl-defs.h 2007-12-03 23:10:14 UTC (rev 20616) @@ -95,6 +95,20 @@ ((LOADADDR) + (ADDR)) #endif +/* Initialize the location of the dynamic addr. This is only called + * from DL_START, so additional arguments passed to it may be referenced. */ +#ifndef DL_BOOT_COMPUTE_DYN +#define DL_BOOT_COMPUTE_DYN(DPNT, GOT, LOAD_ADDR) \ + ((DPNT) = ((ElfW(Dyn) *) DL_RELOC_ADDR(load_addr, got))) +#endif + +/* Initialize the location of the global offset table. This is only called + * from DL_START, so additional arguments passed to it may be referenced. */ +#ifndef DL_BOOT_COMPUTE_GOT +#define DL_BOOT_COMPUTE_GOT(GOT) \ + ((GOT) = elf_machine_dynamic()) +#endif + /* Initialize a LOADADDR representing the loader itself. It's only * called from DL_BOOT, so additional arguments passed to it may be * referenced. Modified: trunk/uClibc/ldso/include/ldso.h =================================================================== --- trunk/uClibc/ldso/include/ldso.h 2007-12-03 23:01:56 UTC (rev 20615) +++ trunk/uClibc/ldso/include/ldso.h 2007-12-03 23:10:14 UTC (rev 20616) @@ -106,7 +106,15 @@ extern char *_dl_strdup(const char *string); extern void _dl_dprintf(int, const char *, ...); +#ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS +# define DL_GET_READY_TO_RUN_EXTRA_PARMS +#endif +#ifndef DL_GET_READY_TO_RUN_EXTRA_ARGS +# define DL_GET_READY_TO_RUN_EXTRA_ARGS +#endif + extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr, - ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv); + ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv + DL_GET_READY_TO_RUN_EXTRA_PARMS); #endif /* _LDSO_H_ */ Modified: trunk/uClibc/ldso/ldso/dl-startup.c =================================================================== --- trunk/uClibc/ldso/ldso/dl-startup.c 2007-12-03 23:01:56 UTC (rev 20615) +++ trunk/uClibc/ldso/ldso/dl-startup.c 2007-12-03 23:10:14 UTC (rev 20616) @@ -192,8 +192,11 @@ * we can take advantage of the magic offset register, if we * happen to know what that is for this architecture. If not, * we can always read stuff out of the ELF file to find it... */ - got = elf_machine_dynamic(); - dpnt = (ElfW(Dyn) *) DL_RELOC_ADDR(load_addr, got); + DL_BOOT_COMPUTE_GOT(got); + + /* Now, finally, fix up the location of the dynamic stuff */ + DL_BOOT_COMPUTE_DYN (dpnt, got, load_addr); + SEND_EARLY_STDERR_DEBUG("First Dynamic section entry="); SEND_ADDRESS_STDERR_DEBUG(dpnt, 1); _dl_memset(tpnt, 0, sizeof(struct elf_resolve)); @@ -304,7 +307,8 @@ __rtld_stack_end = (void *)(argv - 1); - _dl_get_ready_to_run(tpnt, load_addr, auxvt, envp, argv); + _dl_get_ready_to_run(tpnt, load_addr, auxvt, envp, argv + DL_GET_READY_TO_RUN_EXTRA_ARGS); /* Transfer control to the application. */ Modified: trunk/uClibc/ldso/ldso/ldso.c =================================================================== --- trunk/uClibc/ldso/ldso/ldso.c 2007-12-03 23:01:56 UTC (rev 20615) +++ trunk/uClibc/ldso/ldso/ldso.c 2007-12-03 23:10:14 UTC (rev 20616) @@ -131,8 +131,9 @@ } void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr, - ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, - char **argv) + ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, + char **argv + DL_GET_READY_TO_RUN_EXTRA_PARMS) { ElfW(Phdr) *ppnt; ElfW(Dyn) *dpnt; @@ -313,7 +314,7 @@ /* OK, we have what we need - slip this one into the list. */ app_tpnt = _dl_add_elf_hash_table(_dl_progname, app_tpnt->loadaddr, app_tpnt->dynamic_info, - DL_RELOC_ADDR(app_tpnt->loadaddr, ppnt->p_vaddr), + (unsigned long) DL_RELOC_ADDR(app_tpnt->loadaddr, ppnt->p_vaddr), ppnt->p_filesz); _dl_loaded_modules->libtype = elf_executable; _dl_loaded_modules->ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_val; @@ -345,7 +346,7 @@ if (ptmp != _dl_ldsopath) *ptmp = '\0'; - _dl_debug_early("Lib Loader: (%x) %s\n", DL_LOADADDR_BASE(tpnt->loadaddr), tpnt->libname); + _dl_debug_early("Lib Loader: (%x) %s\n", (unsigned) DL_LOADADDR_BASE(tpnt->loadaddr), tpnt->libname); } } app_tpnt->relro_addr = relro_addr; From bernds at uclibc.org Mon Dec 3 15:13:11 2007 From: bernds at uclibc.org (bernds at uclibc.org) Date: Mon, 3 Dec 2007 15:13:11 -0800 (PST) Subject: svn commit: trunk/uClibc/ldso: ldso libdl Message-ID: <20071203231311.AD8DA12C3D2@busybox.net> Author: bernds Date: 2007-12-03 15:13:10 -0800 (Mon, 03 Dec 2007) New Revision: 20617 Log: Fix a few warnings introduced by my previous commits. Modified: trunk/uClibc/ldso/ldso/dl-hash.c trunk/uClibc/ldso/libdl/libdl.c Changeset: Modified: trunk/uClibc/ldso/ldso/dl-hash.c =================================================================== --- trunk/uClibc/ldso/ldso/dl-hash.c 2007-12-03 23:10:14 UTC (rev 20616) +++ trunk/uClibc/ldso/ldso/dl-hash.c 2007-12-03 23:13:10 UTC (rev 20617) @@ -343,7 +343,7 @@ if (tpntp) *tpntp = tpnt; #endif - return DL_FIND_HASH_VALUE (tpnt, type_class, sym); + return (char *) DL_FIND_HASH_VALUE (tpnt, type_class, sym); default: /* Local symbols not handled here */ break; } @@ -353,7 +353,7 @@ if (tpntp) *tpntp = weak_tpnt; #endif - return DL_FIND_HASH_VALUE (weak_tpnt, type_class, weak_sym); + return (char *) DL_FIND_HASH_VALUE (weak_tpnt, type_class, weak_sym); } #ifdef __FDPIC__ if (tpntp) Modified: trunk/uClibc/ldso/libdl/libdl.c =================================================================== --- trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 23:10:14 UTC (rev 20616) +++ trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 23:13:10 UTC (rev 20617) @@ -447,8 +447,8 @@ struct dyn_elf *rpnt; void *ret; /* Nastiness to support underscore prefixes. */ +#ifndef __UCLIBC_NO_UNDERSCORES__ char tmp_buf[80]; -#ifndef __UCLIBC_NO_UNDERSCORES__ char *name2 = tmp_buf; size_t nlen = strlen (name) + 1; if (nlen + 1 > sizeof (tmp_buf)) From bernds at uclibc.org Mon Dec 3 18:14:44 2007 From: bernds at uclibc.org (bernds at uclibc.org) Date: Mon, 3 Dec 2007 18:14:44 -0800 (PST) Subject: svn commit: trunk/uClibc/ldso: include ldso libdl Message-ID: <20071204021444.4AF9B12802D@busybox.net> Author: bernds Date: 2007-12-03 18:14:39 -0800 (Mon, 03 Dec 2007) New Revision: 20618 Log: Blackfin FD-PIC patch 6/6. These are mostly the changes necessary to deal with loading the libraries into memory. A couple new target macros are defined for this purpose, and the code in dl-elf.c is modified to deal with nommu systems. Modified: trunk/uClibc/ldso/include/dl-defs.h trunk/uClibc/ldso/ldso/dl-elf.c trunk/uClibc/ldso/libdl/libdl.c Changeset: Modified: trunk/uClibc/ldso/include/dl-defs.h =================================================================== --- trunk/uClibc/ldso/include/dl-defs.h 2007-12-03 23:13:10 UTC (rev 20617) +++ trunk/uClibc/ldso/include/dl-defs.h 2007-12-04 02:14:39 UTC (rev 20618) @@ -110,7 +110,7 @@ #endif /* Initialize a LOADADDR representing the loader itself. It's only - * called from DL_BOOT, so additional arguments passed to it may be + * called from DL_START, so additional arguments passed to it may be * referenced. */ #ifndef DL_INIT_LOADADDR_BOOT @@ -144,6 +144,12 @@ ((LOADADDR) = (DL_LOADADDR_TYPE)(BASEADDR)) #endif +/* Update LOADADDR with information about PHDR, just mapped to the + given ADDR. */ +#ifndef DL_INIT_LOADADDR_HDR +# define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) /* Do nothing. */ +#endif + /* Convert a DL_LOADADDR_TYPE to an identifying pointer. Used mostly * for debugging. */ @@ -166,6 +172,13 @@ && (!(TFROM) || (TFROM)->loadaddr < (TPNT)->loadaddr)) #endif +/* This is called from dladdr() to give targets that use function descriptors + * a chance to map a function descriptor's address to the function's entry + * point before trying to find in which library it's defined. */ +#ifndef DL_LOOKUP_ADDRESS +#define DL_LOOKUP_ADDRESS(ADDRESS) (ADDRESS) +#endif + /* Use this macro to convert a pointer to a function's entry point to * a pointer to function. The pointer is assumed to have already been * relocated. LOADADDR is passed because it may contain additional @@ -202,4 +215,40 @@ # define DL_FIND_HASH_VALUE(TPNT, TYPE, SYM) (DL_RELOC_ADDR ((SYM)->st_value, (TPNT)->loadaddr)) #endif +/* Unmap all previously-mapped segments accumulated in LOADADDR. + Generally used when an error occurs during loading. */ +#ifndef DL_LOADADDR_UNMAP +# define DL_LOADADDR_UNMAP(LOADADDR, LEN) \ + _dl_munmap((char *) (LOADADDR), (LEN)) +#endif + +/* Similar to DL_LOADADDR_UNMAP, but used for libraries that have been + dlopen()ed successfully, when they're dlclose()d. */ +#ifndef DL_LIB_UNMAP +# define DL_LIB_UNMAP(LIB, LEN) (DL_LOADADDR_UNMAP ((LIB)->loadaddr, (LEN))) +#endif + +/* Define this to verify that a library named LIBNAME, whose ELF + headers are pointed to by EPNT, is suitable for dynamic linking. + If it is not, print an error message (optional) and return NULL. + If the library can have its segments relocated independently, + arrange for PICLIB to be set to 2. If all segments have to be + relocated by the same amount, set it to 1. If it has to be loaded + at physical addresses as specified in the program headers, set it + to 0. A reasonable (?) guess for PICLIB will already be in place, + so it is safe to do nothing here. */ +#ifndef DL_CHECK_LIB_TYPE +# define DL_CHECK_LIB_TYPE(EPNT, PICLIB, PROGNAME, LIBNAME) (void)0 +#endif + +/* Define this if you have special segment. */ +#ifndef DL_IS_SPECIAL_SEGMENT +# define DL_IS_SPECIAL_SEGMENT(EPNT, PPNT) 0 +#endif + +/* Define this if you want to use special method to map the segment. */ +#ifndef DL_MAP_SEGMENT +# define DL_MAP_SEGMENT(EPNT, PPNT, INFILE, FLAGS) 0 +#endif + #endif /* _LD_DEFS_H */ Modified: trunk/uClibc/ldso/ldso/dl-elf.c =================================================================== --- trunk/uClibc/ldso/ldso/dl-elf.c 2007-12-03 23:13:10 UTC (rev 20617) +++ trunk/uClibc/ldso/ldso/dl-elf.c 2007-12-04 02:14:39 UTC (rev 20618) @@ -354,6 +354,7 @@ DL_LOADADDR_TYPE lib_loadaddr; DL_INIT_LOADADDR_EXTRA_DECLS + libaddr = 0; infile = _dl_open(libname, O_RDONLY, 0); if (infile < 0) { _dl_internal_error_number = LD_ERROR_NOFILE; @@ -449,6 +450,8 @@ ppnt++; } + DL_CHECK_LIB_TYPE (epnt, piclib, _dl_progname, libname); + maxvma = (maxvma + ADDR_ALIGN) & ~ADDR_ALIGN; minvma = minvma & ~0xffffU; @@ -456,17 +459,19 @@ if (!piclib) flags |= MAP_FIXED; - status = (char *) _dl_mmap((char *) (piclib ? 0 : minvma), - maxvma - minvma, PROT_NONE, flags | MAP_ANONYMOUS, -1, 0); - if (_dl_mmap_check_error(status)) { - _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname); - _dl_internal_error_number = LD_ERROR_MMAP_FAILED; - _dl_close(infile); - _dl_munmap(header, _dl_pagesize); - return NULL; + if (piclib == 0 || piclib == 1) { + status = (char *) _dl_mmap((char *) (piclib ? 0 : minvma), + maxvma - minvma, PROT_NONE, flags | MAP_ANONYMOUS, -1, 0); + if (_dl_mmap_check_error(status)) { + _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname); + _dl_internal_error_number = LD_ERROR_MMAP_FAILED; + _dl_close(infile); + _dl_munmap(header, _dl_pagesize); + return NULL; + } + libaddr = (unsigned long) status; + flags |= MAP_FIXED; } - libaddr = (unsigned long) status; - flags |= MAP_FIXED; /* Get the memory to store the library */ ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff]; @@ -474,11 +479,24 @@ DL_INIT_LOADADDR(lib_loadaddr, libaddr, ppnt, epnt->e_phnum); for (i = 0; i < epnt->e_phnum; i++) { + if (DL_IS_SPECIAL_SEGMENT (epnt, ppnt)) { + char *addr; + + addr = DL_MAP_SEGMENT (epnt, ppnt, infile, flags); + if (addr == NULL) + goto cant_map; + + DL_INIT_LOADADDR_HDR (lib_loadaddr, addr, ppnt); + ppnt++; + continue; + } if (ppnt->p_type == PT_GNU_RELRO) { relro_addr = ppnt->p_vaddr; relro_size = ppnt->p_memsz; } if (ppnt->p_type == PT_LOAD) { + char *tryaddr; + ssize_t size; /* See if this is a PIC library. */ if (i == 0 && ppnt->p_vaddr > 0x1000000) { @@ -489,53 +507,155 @@ if (ppnt->p_flags & PF_W) { unsigned long map_size; char *cpnt; + char *piclib2map = 0; - status = (char *) _dl_mmap((char *) ((piclib ? libaddr : 0) + - (ppnt->p_vaddr & PAGE_ALIGN)), (ppnt->p_vaddr & ADDR_ALIGN) - + ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags, infile, - ppnt->p_offset & OFFS_ALIGN); + if (piclib == 2 && + /* We might be able to avoid this + call if memsz doesn't require + an additional page, but this + would require mmap to always + return page-aligned addresses + and a whole number of pages + allocated. Unfortunately on + uClinux may return misaligned + addresses and may allocate + partial pages, so we may end up + doing unnecessary mmap calls. - if (_dl_mmap_check_error(status)) { + This is what we could do if we + knew mmap would always return + aligned pages: + + ((ppnt->p_vaddr + ppnt->p_filesz + + ADDR_ALIGN) + & PAGE_ALIGN) + < ppnt->p_vaddr + ppnt->p_memsz) + + Instead, we have to do this: */ + ppnt->p_filesz < ppnt->p_memsz) + { + piclib2map = (char *) + _dl_mmap(0, (ppnt->p_vaddr & ADDR_ALIGN) + + ppnt->p_memsz, + LXFLAGS(ppnt->p_flags), + flags | MAP_ANONYMOUS, -1, 0); + if (_dl_mmap_check_error(piclib2map)) + goto cant_map; + DL_INIT_LOADADDR_HDR + (lib_loadaddr, piclib2map + + (ppnt->p_vaddr & ADDR_ALIGN), ppnt); + } + + tryaddr = piclib == 2 ? piclib2map + : ((char*) (piclib ? libaddr : 0) + + (ppnt->p_vaddr & PAGE_ALIGN)); + + size = (ppnt->p_vaddr & ADDR_ALIGN) + + ppnt->p_filesz; + + /* For !MMU, mmap to fixed address will fail. + So instead of desperately call mmap and fail, + we set status to MAP_FAILED to save a call + to mmap (). */ +#ifndef __ARCH_USE_MMU__ + if (piclib2map == 0) +#endif + status = (char *) _dl_mmap + (tryaddr, size, LXFLAGS(ppnt->p_flags), + flags | (piclib2map ? MAP_FIXED : 0), + infile, ppnt->p_offset & OFFS_ALIGN); +#ifndef __ARCH_USE_MMU__ + else + status = MAP_FAILED; +#endif +#ifdef _DL_PREAD + if (_dl_mmap_check_error(status) && piclib2map + && (_DL_PREAD (infile, tryaddr, size, + ppnt->p_offset & OFFS_ALIGN) + == size)) + status = tryaddr; +#endif + if (_dl_mmap_check_error(status) + || (tryaddr && tryaddr != status)) { + cant_map: _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname); _dl_internal_error_number = LD_ERROR_MMAP_FAILED; - _dl_munmap((char *) libaddr, maxvma - minvma); + DL_LOADADDR_UNMAP (lib_loadaddr, maxvma - minvma); _dl_close(infile); _dl_munmap(header, _dl_pagesize); return NULL; } - /* Pad the last page with zeroes. */ - cpnt = (char *) (status + (ppnt->p_vaddr & ADDR_ALIGN) + - ppnt->p_filesz); - while (((unsigned long) cpnt) & ADDR_ALIGN) - *cpnt++ = 0; + if (! piclib2map) + DL_INIT_LOADADDR_HDR + (lib_loadaddr, status + + (ppnt->p_vaddr & ADDR_ALIGN), ppnt); - /* I am not quite sure if this is completely - * correct to do or not, but the basic way that - * we handle bss segments is that we mmap - * /dev/zero if there are any pages left over - * that are not mapped as part of the file */ + /* Now we want to allocate and + zero-out any data from the end of + the region we mapped in from the + file (filesz) to the end of the + loadable segment (memsz). We may + need additional pages for memsz, + that we map in below, and we can + count on the kernel to zero them + out, but we have to zero out stuff + in the last page that we mapped in + from the file. However, we can't + assume to have actually obtained + full pages from the kernel, since + we didn't ask for them, and uClibc + may not give us full pages for + small allocations. So only zero + out up to memsz or the end of the + page, whichever comes first. */ - map_size = (ppnt->p_vaddr + ppnt->p_filesz + ADDR_ALIGN) & PAGE_ALIGN; + /* CPNT is the beginning of the memsz + portion not backed by filesz. */ + cpnt = (char *) (status + size); - if (map_size < ppnt->p_vaddr + ppnt->p_memsz) - status = (char *) _dl_mmap((char *) map_size + - (piclib ? libaddr : 0), - ppnt->p_vaddr + ppnt->p_memsz - map_size, - LXFLAGS(ppnt->p_flags), flags | MAP_ANONYMOUS, -1, 0); - } else - status = (char *) _dl_mmap((char *) (ppnt->p_vaddr & PAGE_ALIGN) - + (piclib ? libaddr : 0), (ppnt->p_vaddr & ADDR_ALIGN) + - ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags, - infile, ppnt->p_offset & OFFS_ALIGN); - if (_dl_mmap_check_error(status)) { - _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname); - _dl_internal_error_number = LD_ERROR_MMAP_FAILED; - _dl_munmap((char *) libaddr, maxvma - minvma); - _dl_close(infile); - _dl_munmap(header, _dl_pagesize); - return NULL; + /* MAP_SIZE is the address of the + beginning of the next page. */ + map_size = (ppnt->p_vaddr + ppnt->p_filesz + + ADDR_ALIGN) & PAGE_ALIGN; + +#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + _dl_memset (cpnt, 0, + MIN (map_size + - (ppnt->p_vaddr + + ppnt->p_filesz), + ppnt->p_memsz + - ppnt->p_filesz)); + + if (map_size < ppnt->p_vaddr + ppnt->p_memsz + && !piclib2map) { + tryaddr = map_size + (char*)(piclib ? libaddr : 0); + status = (char *) _dl_mmap(tryaddr, + ppnt->p_vaddr + ppnt->p_memsz - map_size, + LXFLAGS(ppnt->p_flags), flags | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + if (_dl_mmap_check_error(status) + || tryaddr != status) + goto cant_map; + } + } else { + tryaddr = (piclib == 2 ? 0 + : (char *) (ppnt->p_vaddr & PAGE_ALIGN) + + (piclib ? libaddr : 0)); + size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz; + status = (char *) _dl_mmap + (tryaddr, size, LXFLAGS(ppnt->p_flags), + flags | (piclib == 2 ? MAP_EXECUTABLE + | MAP_DENYWRITE : 0), + infile, ppnt->p_offset & OFFS_ALIGN); + if (_dl_mmap_check_error(status) + || (tryaddr && tryaddr != status)) + goto cant_map; + DL_INIT_LOADADDR_HDR + (lib_loadaddr, status + + (ppnt->p_vaddr & ADDR_ALIGN), ppnt); } /* if (libaddr == 0 && piclib) { Modified: trunk/uClibc/ldso/libdl/libdl.c =================================================================== --- trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 23:13:10 UTC (rev 20617) +++ trunk/uClibc/ldso/libdl/libdl.c 2007-12-04 02:14:39 UTC (rev 20618) @@ -587,7 +587,7 @@ if (end < ppnt->p_vaddr + ppnt->p_memsz) end = ppnt->p_vaddr + ppnt->p_memsz; } - _dl_munmap((void*)tpnt->loadaddr, end); + DL_LIB_UNMAP (tpnt, end); /* Free elements in RTLD_LOCAL scope list */ for (runp = tpnt->rtld_local; runp; runp = tmp) { tmp = runp->next; @@ -713,6 +713,8 @@ _dl_if_debug_print("__address: %p __info: %p\n", __address, __info); + __address = DL_LOOKUP_ADDRESS (__address); + for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next) { struct elf_resolve *tpnt; From carmelo.amoroso at st.com Tue Dec 4 00:39:00 2007 From: carmelo.amoroso at st.com (Carmelo AMOROSO) Date: Tue, 04 Dec 2007 09:39:00 +0100 Subject: svn commit: trunk/uClibc/ldso: include ldso ldso/bfin libdl In-Reply-To: <20071203225419.E6E8C12802B@busybox.net> References: <20071203225419.E6E8C12802B@busybox.net> Message-ID: <47551224.2040400@st.com> bernds at uclibc.org wrote: > Author: bernds > Date: 2007-12-03 14:54:16 -0800 (Mon, 03 Dec 2007) > New Revision: 20614 > > Log: > Blackfin FD-PIC patch 3/6. > Change _dl_find_hash to _dl_lookup_hash, as on the NPTL branch. > _dl_find_hash is now a wrapper function around it; unlike on the NPTL branch, > it retains the old interface so that not all callers need to be changed. > > _dl_lookup_hash can optionally give its caller a pointer to the module where > the symbol was found. > > Introduce ELF_RTYPE_CLASS_DLSYM for lookups from libdl. > > Spelling fixes in the Blackfin port, since Alex Oliva's original version of > these patches used _dl_find_hash_mod as the name of the function rather than > _dl_lookup_hash. > > > Modified: > trunk/uClibc/ldso/include/dl-defs.h > trunk/uClibc/ldso/include/dl-elf.h > trunk/uClibc/ldso/include/dl-hash.h > trunk/uClibc/ldso/ldso/bfin/elfinterp.c > trunk/uClibc/ldso/ldso/dl-hash.c > trunk/uClibc/ldso/libdl/libdl.c > > > [SNIP] > > Modified: trunk/uClibc/ldso/include/dl-hash.h > =================================================================== > --- trunk/uClibc/ldso/include/dl-hash.h 2007-12-03 22:46:53 UTC (rev 20613) > +++ trunk/uClibc/ldso/include/dl-hash.h 2007-12-03 22:54:16 UTC (rev 20614) > @@ -105,9 +105,23 @@ > DL_LOADADDR_TYPE loadaddr, unsigned long * dynamic_info, > unsigned long dynamic_addr, unsigned long dynamic_size); > > -extern char * _dl_find_hash(const char * name, struct dyn_elf * rpnt1, > - struct elf_resolve *mytpnt, int type_class); > +extern char * _dl_lookup_hash(const char * name, struct dyn_elf * rpnt, > + struct elf_resolve *mytpnt, int type_class > +#ifdef __FDPIC__ > + , struct elf_resolve **tpntp > +#endif > + ); > > +static __always_inline char *_dl_find_hash(const char *name, struct dyn_elf *rpnt, > + struct elf_resolve *mytpnt, int type_class) > +{ > +#ifdef __FDPIC__ > + return _dl_lookup_hash(name, rpnt, mytpnt, type_class, NULL); > +#else > + return _dl_lookup_hash(name, rpnt, mytpnt, type_class); > +#endif > +} > + > extern int _dl_linux_dynamic_link(void); > > extern char * _dl_library_path; > I think that when nptl merge will be completed, we could use something like that: #if defined USE_TLS || defined __FDPIC__ #define HASH_EXTRA_TPNT #else #undef HASH_EXTRA_TPNT #endif and use it in _dl_find_hash wrapper. I've understood that you are keeping _dl_find_hash just the same to not break all other arch, right? > Modified: trunk/uClibc/ldso/ldso/bfin/elfinterp.c > =================================================================== > --- trunk/uClibc/ldso/ldso/bfin/elfinterp.c 2007-12-03 22:46:53 UTC (rev 20613) > +++ trunk/uClibc/ldso/ldso/bfin/elfinterp.c 2007-12-03 22:54:16 UTC (rev 20614) > @@ -72,11 +72,9 @@ > got_entry = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset); > > /* Get the address to be used to fill in the GOT entry. */ > - new_addr = _dl_find_hash_mod(symname, tpnt->symbol_scope, NULL, 0, > - &new_tpnt); > + new_addr = _dl_lookup_hash(symname, tpnt->symbol_scope, NULL, 0, &new_tpnt); > if (!new_addr) { > - new_addr = _dl_find_hash_mod(symname, NULL, NULL, 0, > - &new_tpnt); > + new_addr = _dl_lookup_hash(symname, NULL, NULL, 0, &new_tpnt); > if (!new_addr) { > _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", > _dl_progname, symname); > @@ -188,7 +186,7 @@ > } else { > > symbol_addr = (unsigned long) > - _dl_find_hash_mod(symname, scope, NULL, 0, &symbol_tpnt); > + _dl_lookup_hash(symname, scope, NULL, 0, &symbol_tpnt); > > /* > * We want to allow undefined references to weak symbols - this might > I expect to see, after nptl merge, all elfinterp.c calling always _dl_find_hash with the extra parameter passed: it will be NULL, if not used (not fdpic or not tls), not NULL otherwise. I think that mixing _dl_lookup_hash and _dl_find_hash invocation could create confusion. > Modified: trunk/uClibc/ldso/ldso/dl-hash.c > =================================================================== > --- trunk/uClibc/ldso/ldso/dl-hash.c 2007-12-03 22:46:53 UTC (rev 20613) > +++ trunk/uClibc/ldso/ldso/dl-hash.c 2007-12-03 22:54:16 UTC (rev 20614) > @@ -257,7 +257,12 @@ > * This function resolves externals, and this is either called when we process > * relocations or when we call an entry in the PLT table for the first time. > */ > -char *_dl_find_hash(const char *name, struct dyn_elf *rpnt, struct elf_resolve *mytpnt, int type_class) > +char *_dl_lookup_hash(const char *name, struct dyn_elf *rpnt, > + struct elf_resolve *mytpnt, int type_class > +#ifdef __FDPIC__ > + , struct elf_resolve **tpntp > +#endif > + ) > { > comment as above on HASH_EXTRA_TPNT > struct elf_resolve *tpnt = NULL; > ElfW(Sym) *symtab; > @@ -265,7 +270,8 @@ > unsigned long elf_hash_number = 0xffffffff; > const ElfW(Sym) *sym = NULL; > > - char *weak_result = NULL; > + const ElfW(Sym) *weak_sym = 0; > + struct elf_resolve *weak_tpnt = 0; > > #ifdef __LDSO_GNU_HASH_SUPPORT__ > unsigned long gnu_hash_number = _dl_gnu_hash((const unsigned char *)name); > @@ -326,15 +332,32 @@ > #if 0 > /* Perhaps we should support old style weak symbol handling > * per what glibc does when you export LD_DYNAMIC_WEAK */ > - if (!weak_result) > - weak_result = (char *) DL_RELOC_ADDR(tpnt->loadaddr, sym->st_value); > + if (!weak_sym) { > + weak_tpnt = tpnt; > + weak_sym = sym; > + } > break; > #endif > case STB_GLOBAL: > - return (char*) DL_RELOC_ADDR(tpnt->loadaddr, sym->st_value); > +#ifdef __FDPIC__ > + if (tpntp) > + *tpntp = tpnt; > +#endif > comment as above on HASH_EXTRA_TPNT > + return DL_FIND_HASH_VALUE (tpnt, type_class, sym); > default: /* Local symbols not handled here */ > break; > } > } > - return weak_result; > + if (weak_sym) { > +#ifdef __FDPIC__ > + if (tpntp) > + *tpntp = weak_tpnt; > +#endif > + return DL_FIND_HASH_VALUE (weak_tpnt, type_class, weak_sym); > + } > +#ifdef __FDPIC__ > + if (tpntp) > + *tpntp = NULL; > +#endif > + return NULL; > } > > same > Modified: trunk/uClibc/ldso/libdl/libdl.c > =================================================================== > --- trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 22:46:53 UTC (rev 20613) > +++ trunk/uClibc/ldso/libdl/libdl.c 2007-12-03 22:54:16 UTC (rev 20614) > @@ -500,7 +500,7 @@ > tpnt = NULL; > if (handle == _dl_symbol_tables) > tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */ > - ret = _dl_find_hash(name2, handle, tpnt, 0); > + ret = _dl_find_hash(name2, handle, tpnt, ELF_RTYPE_CLASS_DLSYM); > > /* > * Nothing found. > > I've not seen how ELF_RTYPE_CLASS_DLSYM is used... have I missed something? Cheers, Carmelo > _______________________________________________ > uClibc-cvs mailing list > uClibc-cvs at uclibc.org > http://busybox.net/cgi-bin/mailman/listinfo/uclibc-cvs > > From carmelo at uclibc.org Wed Dec 5 09:14:13 2007 From: carmelo at uclibc.org (carmelo at uclibc.org) Date: Wed, 5 Dec 2007 09:14:13 -0800 (PST) Subject: svn commit: branches/uClibc-nptl/libc/stdio Message-ID: <20071205171413.37DB212C3EC@busybox.net> Author: carmelo Date: 2007-12-05 09:14:10 -0800 (Wed, 05 Dec 2007) New Revision: 20624 Log: Fix typo in ifdef directive Modified: branches/uClibc-nptl/libc/stdio/_stdio.h Changeset: Modified: branches/uClibc-nptl/libc/stdio/_stdio.h =================================================================== --- branches/uClibc-nptl/libc/stdio/_stdio.h 2007-12-04 21:44:52 UTC (rev 20623) +++ branches/uClibc-nptl/libc/stdio/_stdio.h 2007-12-05 17:14:10 UTC (rev 20624) @@ -23,7 +23,7 @@ #ifdef __UCLIBC_HAS_THREADS__ #include -#ifdef __USE_STDIO_FUTEXES___ +#ifdef __USE_STDIO_FUTEXES__ #define __STDIO_THREADLOCK_OPENLIST \ _IO_lock_lock(_stdio_openlist_lock) From carmelo at uclibc.org Wed Dec 5 09:25:04 2007 From: carmelo at uclibc.org (carmelo at uclibc.org) Date: Wed, 5 Dec 2007 09:25:04 -0800 (PST) Subject: svn commit: trunk/uClibc/libc/misc/dirent Message-ID: <20071205172504.ACD5212802A@busybox.net> Author: carmelo Date: 2007-12-05 09:25:04 -0800 (Wed, 05 Dec 2007) New Revision: 20625 Log: Fix opendir problem when statically linked due to a missing initialization of the mutex field within DIR struct. When linked dynamically instead, __pthread_mutex_init will initialize the mutex itself. Without this fix, any call to readdir will stuck forever trying to acquire the mutex. Signed-off-by: Carmelo Amoroso Modified: trunk/uClibc/libc/misc/dirent/opendir.c Changeset: Modified: trunk/uClibc/libc/misc/dirent/opendir.c =================================================================== --- trunk/uClibc/libc/misc/dirent/opendir.c 2007-12-05 17:14:10 UTC (rev 20624) +++ trunk/uClibc/libc/misc/dirent/opendir.c 2007-12-05 17:25:04 UTC (rev 20625) @@ -64,6 +64,7 @@ if (!(ptr = malloc(sizeof(*ptr)))) goto nomem_close_and_ret; + memset(ptr, '\0', sizeof(DIR)); ptr->dd_fd = fd; ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0; From carmelo at uclibc.org Wed Dec 5 09:25:09 2007 From: carmelo at uclibc.org (carmelo at uclibc.org) Date: Wed, 5 Dec 2007 09:25:09 -0800 (PST) Subject: svn commit: branches/uClibc-nptl/libc/misc/dirent Message-ID: <20071205172509.21874128569@busybox.net> Author: carmelo Date: 2007-12-05 09:25:08 -0800 (Wed, 05 Dec 2007) New Revision: 20626 Log: Fix opendir problem when statically linked due to a missing initialization of the mutex field within DIR struct. When linked dynamically instead, __pthread_mutex_init will initialize the mutex itself. Without this fix, any call to readdir will stuck forever trying to acquire the mutex. Signed-off-by: Carmelo Amoroso Modified: branches/uClibc-nptl/libc/misc/dirent/opendir.c Changeset: Modified: branches/uClibc-nptl/libc/misc/dirent/opendir.c =================================================================== --- branches/uClibc-nptl/libc/misc/dirent/opendir.c 2007-12-05 17:25:04 UTC (rev 20625) +++ branches/uClibc-nptl/libc/misc/dirent/opendir.c 2007-12-05 17:25:08 UTC (rev 20626) @@ -75,6 +75,7 @@ if (!(ptr = malloc(sizeof(*ptr)))) goto nomem_close_and_ret; + memset(ptr, '\0', sizeof(DIR)); ptr->dd_fd = fd; ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0; From carmelo at uclibc.org Fri Dec 7 06:24:10 2007 From: carmelo at uclibc.org (carmelo at uclibc.org) Date: Fri, 7 Dec 2007 06:24:10 -0800 (PST) Subject: svn commit: trunk/uClibc/libc/sysdeps/linux/avr32 Message-ID: <20071207142410.53CA112802F@busybox.net> Author: carmelo Date: 2007-12-07 06:24:06 -0800 (Fri, 07 Dec 2007) New Revision: 20627 Log: I don't remember exactly why we decided to pick the caller's value of sa_restorer when SA_ONSTACK is set, but it seems to break LTP's sigaltstack testcase. Some users have reported problems with sigaltstack as well; hopefully this will fix it. Signed-off-by: Haavard Skinnemoen Modified: trunk/uClibc/libc/sysdeps/linux/avr32/sigaction.c Changeset: Modified: trunk/uClibc/libc/sysdeps/linux/avr32/sigaction.c =================================================================== --- trunk/uClibc/libc/sysdeps/linux/avr32/sigaction.c 2007-12-05 17:25:08 UTC (rev 20626) +++ trunk/uClibc/libc/sysdeps/linux/avr32/sigaction.c 2007-12-07 14:24:06 UTC (rev 20627) @@ -30,7 +30,7 @@ kact.k_sa_handler = act->sa_handler; memcpy(&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask)); kact.sa_flags = act->sa_flags; - if (kact.sa_flags & (SA_RESTORER | SA_ONSTACK)) + if (kact.sa_flags & SA_RESTORER) kact.sa_restorer = act->sa_restorer; else kact.sa_restorer = __default_rt_sa_restorer; From carmelo at uclibc.org Fri Dec 7 06:42:08 2007 From: carmelo at uclibc.org (carmelo at uclibc.org) Date: Fri, 7 Dec 2007 06:42:08 -0800 (PST) Subject: svn commit: trunk/uClibc/libc/misc/dirent Message-ID: <20071207144208.AA26912857F@busybox.net> Author: carmelo Date: 2007-12-07 06:42:06 -0800 (Fri, 07 Dec 2007) New Revision: 20628 Log: Removed pointless initialization to 0 of DIR fields after having added memset. Thanks to Peter Mazinger for pointing this out. Signed-off-by: Carmelo Amoroso Modified: trunk/uClibc/libc/misc/dirent/opendir.c Changeset: Modified: trunk/uClibc/libc/misc/dirent/opendir.c =================================================================== --- trunk/uClibc/libc/misc/dirent/opendir.c 2007-12-07 14:24:06 UTC (rev 20627) +++ trunk/uClibc/libc/misc/dirent/opendir.c 2007-12-07 14:42:06 UTC (rev 20628) @@ -66,7 +66,6 @@ memset(ptr, '\0', sizeof(DIR)); ptr->dd_fd = fd; - ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0; ptr->dd_max = statbuf.st_blksize; if (ptr->dd_max < 512) From vapier at uclibc.org Fri Dec 7 16:59:12 2007 From: vapier at uclibc.org (vapier at uclibc.org) Date: Fri, 7 Dec 2007 16:59:12 -0800 (PST) Subject: svn commit: trunk/uClibc/libm Message-ID: <20071208005912.AF44112850D@busybox.net> Author: vapier Date: 2007-12-07 16:59:10 -0800 (Fri, 07 Dec 2007) New Revision: 20629 Log: import trunc()/truncf() for ISO C requirements, otherwise fortran can hit infinite loops when it generates builtins+trunc() substitutes Added: trunk/uClibc/libm/s_trunc.c Modified: trunk/uClibc/libm/Makefile.in trunk/uClibc/libm/float_wrappers.c Changeset: Modified: trunk/uClibc/libm/Makefile.in =================================================================== --- trunk/uClibc/libm/Makefile.in 2007-12-07 14:42:06 UTC (rev 20628) +++ trunk/uClibc/libm/Makefile.in 2007-12-08 00:59:10 UTC (rev 20629) @@ -68,8 +68,8 @@ s_ilogb.c s_ldexp.c s_lib_version.c s_lrint.c s_lround.c s_llround.c \ s_log1p.c s_logb.c s_matherr.c s_modf.c s_nextafter.c s_round.c \ s_rint.c s_scalbn.c s_signgam.c s_significand.c s_sin.c s_tan.c \ - s_tanh.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c w_cabs.c \ - w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c \ + s_tanh.c s_trunc.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c \ + w_cabs.c w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c \ w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \ w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \ w_sqrt.c fpmacros.c nan.c carg.c s_llrint.c Modified: trunk/uClibc/libm/float_wrappers.c =================================================================== --- trunk/uClibc/libm/float_wrappers.c 2007-12-07 14:42:06 UTC (rev 20628) +++ trunk/uClibc/libm/float_wrappers.c 2007-12-08 00:59:10 UTC (rev 20629) @@ -26,7 +26,6 @@ #undef L_remquof /*float remquof(float, float, int *);*/ #undef L_scalblnf /*float scalblnf(float, long);*/ #undef L_tgammaf /*float tgammaf(float);*/ -#undef L_truncf /*float truncf(float);*/ /* Implement the following, as defined by SuSv3 */ #if 0 Added: trunk/uClibc/libm/s_trunc.c =================================================================== --- trunk/uClibc/libm/s_trunc.c (rev 0) +++ trunk/uClibc/libm/s_trunc.c 2007-12-08 00:59:10 UTC (rev 20629) @@ -0,0 +1,58 @@ +/* Truncate argument to nearest integral value not larger than the argument. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + 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 + +#include "math_private.h" + + +libm_hidden_proto(trunc) +double +trunc (double x) +{ + int32_t i0, j0; + u_int32_t i1; + int sx; + + EXTRACT_WORDS (i0, i1, x); + sx = i0 & 0x80000000; + j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + if (j0 < 20) + { + if (j0 < 0) + /* The magnitude of the number is < 1 so the result is +-0. */ + INSERT_WORDS (x, sx, 0); + else + INSERT_WORDS (x, sx | (i0 & ~(0x000fffff >> j0)), 0); + } + else if (j0 > 51) + { + if (j0 == 0x400) + /* x is inf or NaN. */ + return x + x; + } + else + { + INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (j0 - 20))); + } + + return x; +} +libm_hidden_def(trunc) From carmelo at uclibc.org Sun Dec 9 06:22:16 2007 From: carmelo at uclibc.org (carmelo at uclibc.org) Date: Sun, 9 Dec 2007 06:22:16 -0800 (PST) Subject: svn commit: branches/uClibc-nptl/libc/misc/dirent Message-ID: <20071209142216.C233612857B@busybox.net> Author: carmelo Date: 2007-12-09 06:22:14 -0800 (Sun, 09 Dec 2007) New Revision: 20633 Log: Remove pointless initialisation to 0 of some DIR's fields having called memset on whole DIR structure (and synch with trunk). Pointed out by Peter Mazinger Signed-off-by: Carmelo Amoroso Modified: branches/uClibc-nptl/libc/misc/dirent/opendir.c Changeset: Modified: branches/uClibc-nptl/libc/misc/dirent/opendir.c =================================================================== --- branches/uClibc-nptl/libc/misc/dirent/opendir.c 2007-12-09 10:07:39 UTC (rev 20632) +++ branches/uClibc-nptl/libc/misc/dirent/opendir.c 2007-12-09 14:22:14 UTC (rev 20633) @@ -77,7 +77,6 @@ memset(ptr, '\0', sizeof(DIR)); ptr->dd_fd = fd; - ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0; ptr->dd_max = statbuf.st_blksize; if (ptr->dd_max < 512) From vapier at uclibc.org Fri Dec 21 22:23:18 2007 From: vapier at uclibc.org (vapier at uclibc.org) Date: Fri, 21 Dec 2007 22:23:18 -0800 (PST) Subject: svn commit: trunk/uClibc/libc/unistd Message-ID: <20071222062318.2D18A1200F4@busybox.net> Author: vapier Date: 2007-12-21 22:23:15 -0800 (Fri, 21 Dec 2007) New Revision: 20663 Log: add hidden defs for execv/execlp for completeness Modified: trunk/uClibc/libc/unistd/exec.c Changeset: Modified: trunk/uClibc/libc/unistd/exec.c =================================================================== --- trunk/uClibc/libc/unistd/exec.c 2007-12-21 22:18:16 UTC (rev 20662) +++ trunk/uClibc/libc/unistd/exec.c 2007-12-22 06:23:15 UTC (rev 20663) @@ -29,6 +29,8 @@ libc_hidden_proto(execl) libc_hidden_proto(execle) +libc_hidden_proto(execlp) +libc_hidden_proto(execv) libc_hidden_proto(execvp) libc_hidden_proto(memcpy) @@ -129,6 +131,7 @@ { return execve(path, argv, __environ); } +libc_hidden_def(execv) #endif /**********************************************************************/ @@ -204,6 +207,7 @@ return n; } +libc_hidden_def(execlp) #endif /**********************************************************************/ From vapier at uclibc.org Fri Dec 21 22:28:24 2007 From: vapier at uclibc.org (vapier at uclibc.org) Date: Fri, 21 Dec 2007 22:28:24 -0800 (PST) Subject: svn commit: trunk/uClibc/libc/string: bfin generic Message-ID: <20071222062824.DF6941200F4@busybox.net> Author: vapier Date: 2007-12-21 22:28:23 -0800 (Fri, 21 Dec 2007) New Revision: 20664 Log: mark a bunch of public mem/str functions as weak so that people who insist on their own local copies while static linking dont hit link failures when other uClibc code force the libc.a objects to be pulled in via the hidden alias symbols Modified: trunk/uClibc/libc/string/bfin/memchr.S trunk/uClibc/libc/string/bfin/memcmp.S trunk/uClibc/libc/string/bfin/memcpy.S trunk/uClibc/libc/string/bfin/memmove.S trunk/uClibc/libc/string/bfin/memset.S trunk/uClibc/libc/string/bfin/strcmp.S trunk/uClibc/libc/string/generic/memchr.c trunk/uClibc/libc/string/generic/memcmp.c trunk/uClibc/libc/string/generic/memcpy.c trunk/uClibc/libc/string/generic/memmove.c trunk/uClibc/libc/string/generic/mempcpy.c trunk/uClibc/libc/string/generic/memset.c trunk/uClibc/libc/string/generic/strchr.c trunk/uClibc/libc/string/generic/strcmp.c trunk/uClibc/libc/string/generic/strlen.c trunk/uClibc/libc/string/generic/strrchr.c trunk/uClibc/libc/string/mempcpy.c trunk/uClibc/libc/string/strchr.c trunk/uClibc/libc/string/strdup.c trunk/uClibc/libc/string/strlen.c trunk/uClibc/libc/string/strrchr.c Changeset: Modified: trunk/uClibc/libc/string/bfin/memchr.S =================================================================== --- trunk/uClibc/libc/string/bfin/memchr.S 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/bfin/memchr.S 2007-12-22 06:28:23 UTC (rev 20664) @@ -23,6 +23,7 @@ .align 2 +.weak _memchr ENTRY(_memchr) P0 = R0; // P0 = address P2 = R2; // P2 = count Modified: trunk/uClibc/libc/string/bfin/memcmp.S =================================================================== --- trunk/uClibc/libc/string/bfin/memcmp.S 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/bfin/memcmp.S 2007-12-22 06:28:23 UTC (rev 20664) @@ -23,6 +23,7 @@ .align 2 +.weak _memcmp ENTRY(_memcmp) I1 = P3; P0 = R0; /* P0 = s1 address */ @@ -99,5 +100,5 @@ libc_hidden_def (memcmp) #ifdef __UCLIBC_SUSV3_LEGACY__ -strong_alias (memcmp,bcmp) +weak_alias (memcmp,bcmp) #endif Modified: trunk/uClibc/libc/string/bfin/memcpy.S =================================================================== --- trunk/uClibc/libc/string/bfin/memcpy.S 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/bfin/memcpy.S 2007-12-22 06:28:23 UTC (rev 20664) @@ -23,12 +23,8 @@ .align 2 -/* We have to bypass the libc-symbols.h machinery to make sure we get - * a weak symbol for memcpy (some crummy gcc tests want to redefine it). - */ -.global ___GI_memcpy -.type ___GI_memcpy, STT_FUNC -___GI_memcpy: +.weak _memcpy +ENTRY(_memcpy) [--SP] = P3; P0 = R0; /* P0 = To address */ P3 = R1; /* P3 = From Address */ @@ -75,8 +71,7 @@ P3 = [SP++]; RTS; -.size ___GI_memcpy,.-___GI_memcpy -.hidden ___GI_memcpy -.weak _memcpy -.set _memcpy,___GI_memcpy +.size _memcpy,.-_memcpy + +libc_hidden_def (memcpy) Modified: trunk/uClibc/libc/string/bfin/memmove.S =================================================================== --- trunk/uClibc/libc/string/bfin/memmove.S 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/bfin/memmove.S 2007-12-22 06:28:23 UTC (rev 20664) @@ -23,12 +23,8 @@ .align 2 - /* We have to bypass the libc-symbols.h machinery to make sure we get - a weak symbol for memcpy (some crummy gcc tests want to redefine - it). */ -.global ___GI_memmove -.type ___GI_memmove, STT_FUNC -___GI_memmove: +.weak _memmove +ENTRY(_memmove) I1 = P3; P0 = R0; /* P0 = To address */ P3 = R1; /* P3 = From Address */ @@ -99,8 +95,6 @@ P3 = I1; RTS; -.size ___GI_memmove,.-___GI_memmove +.size _memmove,.-_memmove -.hidden ___GI_memmove -.weak _memmove -.set _memmove,___GI_memmove +libc_hidden_def (memmove) Modified: trunk/uClibc/libc/string/bfin/memset.S =================================================================== --- trunk/uClibc/libc/string/bfin/memset.S 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/bfin/memset.S 2007-12-22 06:28:23 UTC (rev 20664) @@ -23,12 +23,8 @@ .align 2 -/* We have to bypass the libc-symbols.h machinery to make sure we get - * a weak symbol for memcpy (some crummy gcc tests want to redefine it). - */ -.global ___GI_memset -.type ___GI_memset, STT_FUNC -___GI_memset: +.weak _memset +ENTRY(_memset) P0 = R0 ; /* P0 = address */ P2 = R2 ; /* P2 = count */ R3 = R0 + R2; /* end */ @@ -89,8 +85,6 @@ B[P0++] = R1; JUMP .Laligned; -.size ___GI_memset,.-___GI_memset +.size _memset,.-_memset -.hidden ___GI_memset -.weak _memset -.set _memset,___GI_memset +libc_hidden_def (memset) Modified: trunk/uClibc/libc/string/bfin/strcmp.S =================================================================== --- trunk/uClibc/libc/string/bfin/strcmp.S 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/bfin/strcmp.S 2007-12-22 06:28:23 UTC (rev 20664) @@ -23,6 +23,7 @@ .align 2 +.weak _strcmp ENTRY(_strcmp) [--sp] = (R7:4); p1 = r0; @@ -116,6 +117,6 @@ libc_hidden_def (strcmp) #ifndef __UCLIBC_HAS_LOCALE__ -strong_alias (strcmp,strcoll) +weak_alias (strcmp,strcoll) libc_hidden_def (strcoll) #endif Modified: trunk/uClibc/libc/string/generic/memchr.c =================================================================== --- trunk/uClibc/libc/string/generic/memchr.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/memchr.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -174,4 +174,4 @@ return 0; } -libc_hidden_def(memchr) +libc_hidden_weak(memchr) Modified: trunk/uClibc/libc/string/generic/memcmp.c =================================================================== --- trunk/uClibc/libc/string/generic/memcmp.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/memcmp.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -330,7 +330,7 @@ return 0; } -libc_hidden_def(memcmp) +libc_hidden_weak(memcmp) #ifdef __UCLIBC_SUSV3_LEGACY__ strong_alias(memcmp,bcmp) #endif Modified: trunk/uClibc/libc/string/generic/memcpy.c =================================================================== --- trunk/uClibc/libc/string/generic/memcpy.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/memcpy.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -244,4 +244,4 @@ return dstpp; } -libc_hidden_def(memcpy) +libc_hidden_weak(memcpy) Modified: trunk/uClibc/libc/string/generic/memmove.c =================================================================== --- trunk/uClibc/libc/string/generic/memmove.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/memmove.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -279,4 +279,4 @@ return (dest); } -libc_hidden_def(memmove) +libc_hidden_weak(memmove) Modified: trunk/uClibc/libc/string/generic/mempcpy.c =================================================================== --- trunk/uClibc/libc/string/generic/mempcpy.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/mempcpy.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -16,5 +16,5 @@ memcpy(dstpp, srcpp, len); return (void *)(((char *)dstpp) + len); } -libc_hidden_def(mempcpy) +libc_hidden_weak(mempcpy) #endif Modified: trunk/uClibc/libc/string/generic/memset.c =================================================================== --- trunk/uClibc/libc/string/generic/memset.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/memset.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -83,4 +83,4 @@ return dstpp; } -libc_hidden_def(memset) +libc_hidden_weak(memset) Modified: trunk/uClibc/libc/string/generic/strchr.c =================================================================== --- trunk/uClibc/libc/string/generic/strchr.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/strchr.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -181,7 +181,7 @@ return NULL; } -libc_hidden_def(strchr) +libc_hidden_weak(strchr) #ifdef __UCLIBC_SUSV3_LEGACY__ -strong_alias(strchr,index) +weak_alias(strchr,index) #endif Modified: trunk/uClibc/libc/string/generic/strcmp.c =================================================================== --- trunk/uClibc/libc/string/generic/strcmp.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/strcmp.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -41,7 +41,7 @@ return c1 - c2; } -libc_hidden_def(strcmp) +libc_hidden_weak(strcmp) #ifndef __UCLIBC_HAS_LOCALE__ libc_hidden_proto(strcoll) Modified: trunk/uClibc/libc/string/generic/strlen.c =================================================================== --- trunk/uClibc/libc/string/generic/strlen.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/strlen.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -149,4 +149,4 @@ } } } -libc_hidden_def(strlen) +libc_hidden_weak(strlen) Modified: trunk/uClibc/libc/string/generic/strrchr.c =================================================================== --- trunk/uClibc/libc/string/generic/strrchr.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/generic/strrchr.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -42,7 +42,7 @@ return (char *) found; } -libc_hidden_def(strrchr) +libc_hidden_weak(strrchr) #ifdef __UCLIBC_SUSV3_LEGACY__ -strong_alias(strrchr,rindex) +weak_alias(strrchr,rindex) #endif Modified: trunk/uClibc/libc/string/mempcpy.c =================================================================== --- trunk/uClibc/libc/string/mempcpy.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/mempcpy.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -36,5 +36,5 @@ return r1; } -libc_hidden_def(Wmempcpy) +libc_hidden_weak(Wmempcpy) #endif Modified: trunk/uClibc/libc/string/strchr.c =================================================================== --- trunk/uClibc/libc/string/strchr.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/strchr.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -28,5 +28,5 @@ libc_hidden_def(Wstrchr) #if !defined WANT_WIDE && defined __UCLIBC_SUSV3_LEGACY__ -strong_alias(strchr,index) +weak_alias(strchr,index) #endif Modified: trunk/uClibc/libc/string/strdup.c =================================================================== --- trunk/uClibc/libc/string/strdup.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/strdup.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -33,5 +33,5 @@ } #ifndef WANT_WIDE -libc_hidden_def(strdup) +libc_hidden_weak(strdup) #endif Modified: trunk/uClibc/libc/string/strlen.c =================================================================== --- trunk/uClibc/libc/string/strlen.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/strlen.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -23,4 +23,4 @@ return p - s; } -libc_hidden_def(Wstrlen) +libc_hidden_weak(Wstrlen) Modified: trunk/uClibc/libc/string/strrchr.c =================================================================== --- trunk/uClibc/libc/string/strrchr.c 2007-12-22 06:23:15 UTC (rev 20663) +++ trunk/uClibc/libc/string/strrchr.c 2007-12-22 06:28:23 UTC (rev 20664) @@ -28,8 +28,8 @@ return (Wchar *) p; /* silence the warning */ } #ifndef WANT_WIDE -libc_hidden_def(strrchr) +libc_hidden_weak(strrchr) # ifdef __UCLIBC_SUSV3_LEGACY__ -strong_alias(strrchr,rindex) +weak_alias(strrchr,rindex) # endif #endif From vapier at uclibc.org Sat Dec 22 04:18:46 2007 From: vapier at uclibc.org (vapier at uclibc.org) Date: Sat, 22 Dec 2007 04:18:46 -0800 (PST) Subject: svn commit: trunk/uClibc/libc/unistd Message-ID: <20071222121846.82A281200F5@busybox.net> Author: vapier Date: 2007-12-22 04:18:44 -0800 (Sat, 22 Dec 2007) New Revision: 20665 Log: plug a memory leak when using execl* functions on no-mmu Modified: trunk/uClibc/libc/unistd/exec.c Changeset: Modified: trunk/uClibc/libc/unistd/exec.c =================================================================== --- trunk/uClibc/libc/unistd/exec.c 2007-12-22 06:28:23 UTC (rev 20664) +++ trunk/uClibc/libc/unistd/exec.c 2007-12-22 12:18:44 UTC (rev 20665) @@ -56,7 +56,9 @@ /* We do not have an MMU, so using alloca() is not an option. * Less obviously, using malloc() is not an option either since * malloc()ed memory can leak in a vfork() and exec*() situation. - * Therefore, we must use mmap() and unmap() directly. + * Therefore, we must use mmap() and unmap() directly, caching + * the result as we go. This way we minimize the leak to 1 + * allocation. */ # define EXEC_ALLOC_SIZE(VAR) size_t VAR; /* Semicolon included! */ @@ -68,22 +70,28 @@ # ifdef L___exec_alloc +void attribute_hidden __exec_free(void *ptr, size_t size) +{ + if (ptr) + munmap(ptr, size); +} + void attribute_hidden *__exec_alloc(size_t size) { - void *p; + static void *p; + static size_t old_size; + if (old_size >= size) + return p; + else + __exec_free(p, old_size); + + old_size = size; p = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); return (p != MAP_FAILED) ? p : NULL; } -void attribute_hidden __exec_free(void *ptr, size_t size) -{ - if (ptr) { - munmap(ptr, size); - } -} - # endif #endif From bugs at busybox.net Wed Dec 26 10:26:25 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 26 Dec 2007 10:26:25 -0800 Subject: [uClibc 0001814]: Statically linked programs crash Message-ID: <08d1a1cad9c26dc39a1b14ae22fc354e@bugs.uclibc.org> The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=1814 ====================================================================== Reported By: ashes Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 1814 Category: Other Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 12-26-2007 10:26 PST Last Modified: 12-26-2007 10:26 PST ====================================================================== Summary: Statically linked programs crash Description: To reproduce: Configure buildroot, choose uClibc library version, GCC version, and choose to install the native toolchain in the target filesystem. Build and chroot into the project root. Build "main(){return 0;}" with the native toolchain, link it statically, and run the ./a.out. My a.out's segmentation fault. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 12-26-07 10:26 ashes New Issue 12-26-07 10:26 ashes Status new => assigned 12-26-07 10:26 ashes Assigned To => uClibc ====================================================================== From bugs at busybox.net Sun Dec 30 12:22:09 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 30 Dec 2007 12:22:09 -0800 Subject: [uClibc 0001551]: Poll with zero or negative timeout Message-ID: The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1551 ====================================================================== Reported By: jcdr Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 1551 Category: Standards Compliance Reproducibility: always Severity: block Priority: normal Status: closed Resolution: fixed Fixed in Version: ====================================================================== Date Submitted: 10-23-2007 00:18 PDT Last Modified: 12-30-2007 12:22 PST ====================================================================== Summary: Poll with zero or negative timeout Description: Hello, I tried to use the bug tracking system, but the "Report Issue" page never go after the "Select Project" form. So I post this patch here. The attached patch solve an issue I faced while using the libdbus-glib waiting for a D-Bus message or the end of a glib timer at the same time. This specific case of use generate a poll call with a zero timeout. On platformes with the glibc a zero timeout poll return immetiately even if there is no file descriptor event. But on platformes with uClibc a zero timeout poll block until a file descriptor event occurs. I found that the file libc/sysdeps/linux/common/poll.c only take care of positive timeout and pass a null pointer in case of a zero or negative timeout, making the zero and negative the same case: blocking. The patch alway pass a valid structure for the timeout of poll and assign acceptable timeout values for the zero and negative case by avoiding the math needed for positive timeout value. This has been tested on a Blackfin BF533 processor. Have a good day, -- Jean-Christian de Rivaz ====================================================================== ---------------------------------------------------------------------- jcdr - 10-23-07 04:07 ---------------------------------------------------------------------- Joakim Tjernlund a ---------------------------------------------------------------------- jocke - 10-23-07 11:07 ---------------------------------------------------------------------- fixed in uClibc trunk Issue History Date Modified Username Field Change ====================================================================== 10-23-07 00:18 jcdr New Issue 10-23-07 00:18 jcdr Status new => assigned 10-23-07 00:18 jcdr Assigned To => uClibc 10-23-07 00:18 jcdr File Added: poll-zero-or-negative-timeout.txt 10-23-07 00:49 jcdr Issue Monitored: jcdr 10-23-07 04:06 jcdr File Added: poll-zero-timeout.txt 10-23-07 04:07 jcdr Note Added: 0002858 10-23-07 11:07 jocke Status assigned => resolved 10-23-07 11:07 jocke Resolution open => fixed 10-23-07 11:07 jocke Note Added: 0002859 12-30-07 12:22 vapier Status resolved => closed ====================================================================== From bugs at busybox.net Sun Dec 30 12:23:24 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 30 Dec 2007 12:23:24 -0800 Subject: [uClibc 0001484]: compilation errors on uboot using uclibc toolchain. Message-ID: The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1484 ====================================================================== Reported By: rk_appan Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 1484 Category: Architecture Specific Reproducibility: have not tried Severity: minor Priority: normal Status: closed Resolution: no change required Fixed in Version: ====================================================================== Date Submitted: 09-04-2007 07:16 PDT Last Modified: 12-30-2007 12:23 PST ====================================================================== Summary: compilation errors on uboot using uclibc toolchain. Description: I am using uclib0.9.28. When I am trying to build uboot, I am getting the following error: /home/kans/buildroot/toolchain_build_arm/gcc-4.2.0/gcc/config/arm/lib1funcs.asm:1000:undefined reference to `raise' I have enabled generic-arm and EABI option. Also, I there are warnings like warning: target CPU does not support interworking. I am getting strange errors like undefined reference to `getenv_IPaddr' and some other functions. The u-boot version what I am using is working fine with glibc toolchain. can anybody help to solve this problem. ====================================================================== ---------------------------------------------------------------------- vapier - 12-30-07 12:23 ---------------------------------------------------------------------- your uClibc is out of date ... this has been fixed already in 0.9.29+ Issue History Date Modified Username Field Change ====================================================================== 09-04-07 07:16 rk_appan New Issue 09-04-07 07:16 rk_appan Status new => assigned 09-04-07 07:16 rk_appan Assigned To => uClibc 12-30-07 12:23 vapier Note Added: 0003309 12-30-07 12:23 vapier Status assigned => closed 12-30-07 12:23 vapier Resolution open => no change required ====================================================================== From bugs at busybox.net Sun Dec 30 12:25:36 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 30 Dec 2007 12:25:36 -0800 Subject: [uClibc 0001547]: popen(3) allows "rw" to be specified Message-ID: The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1547 ====================================================================== Reported By: chmeee Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 1547 Category: Standards Compliance Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: no change required Fixed in Version: ====================================================================== Date Submitted: 10-22-2007 08:01 PDT Last Modified: 12-30-2007 12:25 PST ====================================================================== Summary: popen(3) allows "rw" to be specified Description: Specifying "rw" as the mode to popen(3) succeeds, giving read access, but should fail, as only one mode is permitted by the standard. The attached patch fixes this. ====================================================================== ---------------------------------------------------------------------- vapier - 12-30-07 12:25 ---------------------------------------------------------------------- the standard does not require it to fail. please refer to: http://www.opengroup.org/onlinepubs/009695399/functions/popen.html 1. If mode is r, ...... 2. If mode is w, ...... 3. If mode is any other value, the result is undefined. sounds like we're compliant ;) Issue History Date Modified Username Field Change ====================================================================== 10-22-07 08:01 chmeee New Issue 10-22-07 08:01 chmeee Status new => assigned 10-22-07 08:01 chmeee Assigned To => uClibc 10-22-07 08:01 chmeee File Added: popen.diff 12-30-07 12:25 vapier Note Added: 0003314 12-30-07 12:25 vapier Status assigned => closed 12-30-07 12:25 vapier Resolution open => no change required ====================================================================== From bugs at busybox.net Sun Dec 30 12:27:23 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 30 Dec 2007 12:27:23 -0800 Subject: [buildroot 0001501]: cross-compile bash does not support "set -o pipefail" or $PIPESTATUS builtin variable Message-ID: <2a2e913c8f4405e0951e8f9940480988@bugs.busybox.net> The following issue has been UPDATED. ====================================================================== http://busybox.net/bugs/view.php?id=1501 ====================================================================== Reported By: murphy666 Assigned To: uClibc ====================================================================== Project: buildroot Issue ID: 1501 Category: Architecture Specific Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 09-13-2007 11:24 PDT Last Modified: 12-30-2007 12:27 PST ====================================================================== Summary: cross-compile bash does not support "set -o pipefail" or $PIPESTATUS builtin variable Description: When building BASH (3.2 or 3.1 with latest patch) using buildroot & uClibc (tested uClibc 0.9.29,0.9.28.3) I'm unable to use PIPEFAIL or PIPESTATUS. PIPESTATUS Description : http://tldp.org/LDP/abs/html/internalvariables.html pipefail script example : set -o pipefail cat /tmp/anynotfound | tee -a /tmp/test will always return 0 has exit code. with the pipefail mode, the exit code should be the last non zero exit code (in this example cat /tmp/anynotfound fail so it should return 1) PIPESTATUS exmaple : exit 1 | exit 2 | exit 3 echo ${PIPESTATUS[@]} PIPESTATUS should return string "1 2 3" but always return "0" ====================================================================== ---------------------------------------------------------------------- vapier - 12-30-07 12:27 ---------------------------------------------------------------------- i doubt this is a uClibc problem. bash is known to have problems when cross-compiling. build it natively and i imagine it'll start to magically work. Issue History Date Modified Username Field Change ====================================================================== 09-13-07 11:24 murphy666 New Issue 09-13-07 11:24 murphy666 Status new => assigned 09-13-07 11:24 murphy666 Assigned To => uClibc 12-30-07 12:26 vapier Project uClibc => buildroot 12-30-07 12:27 vapier Note Added: 0003319 12-30-07 12:27 vapier Summary BASH built with uClibc does not support "set -o pipefail" or $PIPESTATUS builtin variable => cross-compile bash does not support "set -o pipefail" or $PIPESTATUS builtin variable 12-30-07 12:27 vapier Additional Information Updated ====================================================================== From bugs at busybox.net Sun Dec 30 12:28:33 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 30 Dec 2007 12:28:33 -0800 Subject: [uClibc 0001814]: Statically linked programs crash Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1814 ====================================================================== Reported By: ashes Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 1814 Category: Other Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 12-26-2007 10:26 PST Last Modified: 12-30-2007 12:28 PST ====================================================================== Summary: Statically linked programs crash Description: To reproduce: Configure buildroot, choose uClibc library version, GCC version, and choose to install the native toolchain in the target filesystem. Build and chroot into the project root. Build "main(){return 0;}" with the native toolchain, link it statically, and run the ./a.out. My a.out's segmentation fault. ====================================================================== ---------------------------------------------------------------------- vapier - 12-30-07 12:28 ---------------------------------------------------------------------- you need to actually describe your system. what kernel version ? what architecture ? Issue History Date Modified Username Field Change ====================================================================== 12-26-07 10:26 ashes New Issue 12-26-07 10:26 ashes Status new => assigned 12-26-07 10:26 ashes Assigned To => uClibc 12-30-07 12:28 vapier Note Added: 0003324 ====================================================================== From bugs at busybox.net Sun Dec 30 12:29:14 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 30 Dec 2007 12:29:14 -0800 Subject: [uClibc 0001476]: Weird linking behaviour Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1476 ====================================================================== Reported By: sors Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 1476 Category: Posix Threads Reproducibility: always Severity: block Priority: normal Status: assigned ====================================================================== Date Submitted: 08-27-2007 02:46 PDT Last Modified: 12-30-2007 12:29 PST ====================================================================== Summary: Weird linking behaviour Description: I have an application that is linked dynamically to a shared lib, which itself uses pthreads and is dynamically linked to the pthreads lib. When a worker thread is created and started, the thread function is called. But the main thread (which created the worker thread) never is scheduled/run again! If the worker thread contains an infinitive loop, it runs forever. If it exits (by using return) the whole process doesn't do anything anymore.. It is blocked. IF I link the pthreads lib to the application as well, the same code works fine. The main thread and the worker thread are both scheduled as expected. ====================================================================== ---------------------------------------------------------------------- vapier - 12-30-07 12:29 ---------------------------------------------------------------------- please post a small example application that exhibits the issue Issue History Date Modified Username Field Change ====================================================================== 08-27-07 02:46 sors New Issue 08-27-07 02:46 sors Status new => assigned 08-27-07 02:46 sors Assigned To => uClibc 08-27-07 07:03 sors Issue Monitored: sors 10-05-07 04:04 sors Issue End Monitor: sors 12-30-07 12:29 vapier Note Added: 0003329 ====================================================================== From bugs at busybox.net Sun Dec 30 12:34:30 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 30 Dec 2007 12:34:30 -0800 Subject: [uClibc 0001493]: fopen(, "a") or "w" causes crash. The gdb data follows: Message-ID: <7b6e9593051b54ce2a5552c39d741200@bugs.busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1493 ====================================================================== Reported By: akennedy Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 1493 Category: Other Reproducibility: always Severity: crash Priority: normal Status: closed Resolution: unable to reproduce Fixed in Version: ====================================================================== Date Submitted: 09-06-2007 18:44 PDT Last Modified: 12-30-2007 12:34 PST ====================================================================== Summary: fopen(, "a") or "w" causes crash. The gdb data follows: Description: http://busybox.net/bugs/view.php?id=0 0x0805d17f in __malloc_consolidate () (gdb) backtrace http://busybox.net/bugs/view.php?id=0 0x0805d17f in __malloc_consolidate () http://busybox.net/bugs/view.php?id=1 0x0805c65d in malloc () http://busybox.net/bugs/view.php?id=2 0x0805a98f in _stdio_fopen () http://busybox.net/bugs/view.php?id=3 0x0805a61e in fopen () ====================================================================== ---------------------------------------------------------------------- akennedy - 09-07-07 07:36 ---------------------------------------------------------------------- This error seems to be only in the file: libc/stdlib/malloc-standard/free.c because when I changed to the simple-malloc, I no longer get the segfault. ---------------------------------------------------------------------- vapier - 12-30-07 12:34 ---------------------------------------------------------------------- you'll need to actually describe your setup. what uClibc version ? what architecture ? you should also post a small test case that exhibits the problem. if fopen() was as broken as you describe, i imagine a lot more people would notice. Issue History Date Modified Username Field Change ====================================================================== 09-06-07 18:44 akennedy New Issue 09-06-07 18:44 akennedy Status new => assigned 09-06-07 18:44 akennedy Assigned To => uClibc 09-06-07 19:07 akennedy Issue Monitored: akennedy 09-07-07 07:36 akennedy Note Added: 0002726 12-30-07 12:34 vapier Note Added: 0003339 12-30-07 12:34 vapier Status assigned => closed 12-30-07 12:34 vapier Resolution open => unable to reproduce ====================================================================== From bugs at busybox.net Sun Dec 30 13:08:19 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sun, 30 Dec 2007 13:08:19 -0800 Subject: [uClibc 0001814]: Statically linked programs crash Message-ID: <5a52ca0d817290b3ceb6f82240adb70f@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1814 ====================================================================== Reported By: ashes Assigned To: uClibc ====================================================================== Project: uClibc Issue ID: 1814 Category: Other Reproducibility: always Severity: major Priority: normal Status: assigned ====================================================================== Date Submitted: 12-26-2007 10:26 PST Last Modified: 12-30-2007 13:08 PST ====================================================================== Summary: Statically linked programs crash Description: To reproduce: Configure buildroot, choose uClibc library version, GCC version, and choose to install the native toolchain in the target filesystem. Build and chroot into the project root. Build "main(){return 0;}" with the native toolchain, link it statically, and run the ./a.out. My a.out's segmentation fault. ====================================================================== ---------------------------------------------------------------------- vapier - 12-30-07 12:28 ---------------------------------------------------------------------- you need to actually describe your system. what kernel version ? what architecture ? ---------------------------------------------------------------------- ashes - 12-30-07 13:08 ---------------------------------------------------------------------- Linux-2.6.23.12, i386 Pentium4. Issue History Date Modified Username Field Change ====================================================================== 12-26-07 10:26 ashes New Issue 12-26-07 10:26 ashes Status new => assigned 12-26-07 10:26 ashes Assigned To => uClibc 12-30-07 12:28 vapier Note Added: 0003324 12-30-07 13:08 ashes Note Added: 0003344 ======================================================================