From cc49a5a8837be1f9307b167d9bf4399798a847c9 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 1 Nov 2009 07:27:00 -0800 Subject: [PATCH 01/29] Restore locking in free_check. This code is only used when MALLOC_CHECK_ is used. Then some bogus crashes and/or assert could result from the locking changes. The code ain't fast. --- ChangeLog | 5 +++++ malloc/hooks.c | 37 ++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a917dc1f4..a9f6357a69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-11-01 Ulrich Drepper + + * malloc/hooks.c (free_check): Restore locking and call _int_free + appropriately. + 2009-10-30 Ulrich Drepper * version.h (VERSION): Bump for 2.11 release. diff --git a/malloc/hooks.c b/malloc/hooks.c index 622a815f32..28845eeb49 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -162,8 +162,8 @@ mem2chunk_check(mem, magic_p) Void_t* mem; unsigned char **magic_p; ((char*)p + sz)>=(mp_.sbrk_base+main_arena.system_mem) )) || szprev_size&MALLOC_ALIGN_MASK || - (contig && (char*)prev_chunk(p)size & PREV_INUSE) || ( (((unsigned long)p - p->prev_size) & page_mask) != 0 ) || ( (sz = chunksize(p)), ((p->prev_size + sz) & page_mask) != 0 ) ) @@ -276,13 +276,17 @@ free_check(mem, caller) Void_t* mem; const Void_t *caller; mchunkptr p; if(!mem) return; + (void)mutex_lock(&main_arena.mutex); p = mem2chunk_check(mem, NULL); if(!p) { + (void)mutex_unlock(&main_arena.mutex); + malloc_printerr(check_action, "free(): invalid pointer", mem); return; } #if HAVE_MMAP if (chunk_is_mmapped(p)) { + (void)mutex_unlock(&main_arena.mutex); munmap_chunk(p); return; } @@ -291,12 +295,11 @@ free_check(mem, caller) Void_t* mem; const Void_t *caller; memset(mem, 0, chunksize(p) - (SIZE_SZ+1)); #endif #ifdef ATOMIC_FASTBINS - _int_free(&main_arena, p, 0); + _int_free(&main_arena, p, 1); #else - (void)mutex_lock(&main_arena.mutex); _int_free(&main_arena, p); - (void)mutex_unlock(&main_arena.mutex); #endif + (void)mutex_unlock(&main_arena.mutex); } static Void_t* @@ -345,13 +348,13 @@ realloc_check(oldmem, bytes, caller) if(oldsize - SIZE_SZ >= nb) newmem = oldmem; /* do nothing */ else { - /* Must alloc, copy, free. */ - if (top_check() >= 0) + /* Must alloc, copy, free. */ + if (top_check() >= 0) newmem = _int_malloc(&main_arena, bytes+1); - if (newmem) { - MALLOC_COPY(BOUNDED_N(newmem, bytes+1), oldmem, oldsize - 2*SIZE_SZ); - munmap_chunk(oldp); - } + if (newmem) { + MALLOC_COPY(BOUNDED_N(newmem, bytes+1), oldmem, oldsize - 2*SIZE_SZ); + munmap_chunk(oldp); + } } } } else { @@ -367,7 +370,7 @@ realloc_check(oldmem, bytes, caller) nb = chunksize(newp); if(oldp=chunk_at_offset(newp, nb)) { memset((char*)oldmem + 2*sizeof(mbinptr), 0, - oldsize - (2*sizeof(mbinptr)+2*SIZE_SZ+1)); + oldsize - (2*sizeof(mbinptr)+2*SIZE_SZ+1)); } else if(nb > oldsize+SIZE_SZ) { memset((char*)BOUNDED_N(chunk2mem(newp), bytes) + oldsize, 0, nb - (oldsize+SIZE_SZ)); @@ -626,7 +629,7 @@ public_sET_STATe(Void_t* msptr) mark_bin(&main_arena, i); } else { /* Oops, index computation from chunksize must have changed. - Link the whole list into unsorted_chunks. */ + Link the whole list into unsorted_chunks. */ first(b) = last(b) = b; b = unsorted_chunks(&main_arena); ms->av[2*i+2]->bk = b; @@ -667,7 +670,7 @@ public_sET_STATe(Void_t* msptr) /* Check whether it is safe to enable malloc checking, or whether it is necessary to disable it. */ if (ms->using_malloc_checking && !using_malloc_checking && - !disallow_malloc_check) + !disallow_malloc_check) __malloc_check_init (); else if (!ms->using_malloc_checking && using_malloc_checking) { __malloc_hook = NULL; From 13f6812ffb5b8ad8c343d49e0be7e5ae0d31dc8e Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 3 Nov 2009 23:52:01 +0100 Subject: [PATCH 02/29] Make name of libgcc_s library configurable --- ChangeLog | 6 ++++++ nptl/ChangeLog | 7 +++++++ nptl/sysdeps/pthread/unwind-forcedunwind.c | 5 +++-- nptl/sysdeps/pthread/unwind-resume.c | 5 +++-- sysdeps/generic/framestate.c | 3 ++- sysdeps/generic/libgcc_s.h | 2 ++ 6 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 sysdeps/generic/libgcc_s.h diff --git a/ChangeLog b/ChangeLog index a9f6357a69..e6efe933c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-11-03 Andreas Schwab + + [BZ #4457] + * sysdeps/generic/libgcc_s.h: New file. + * sysdeps/generic/framestate.c: Include it and use LIBGCC_S_SO. + 2009-11-01 Ulrich Drepper * malloc/hooks.c (free_check): Restore locking and call _int_free diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 52176fc10d..0aaaa3f7b9 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,10 @@ +2009-11-03 Andreas Schwab + + [BZ #4457] + * sysdeps/pthread/unwind-resume.c: Include and use + LIBGCC_S_SO. + * sysdeps/pthread/unwind-forcedunwind.c: Likewise. + 2009-10-30 Ulrich Drepper * tst-sem11.c (main): Rewrite to avoid aliasing problems. diff --git a/nptl/sysdeps/pthread/unwind-forcedunwind.c b/nptl/sysdeps/pthread/unwind-forcedunwind.c index 402591f6e4..ae43f335e7 100644 --- a/nptl/sysdeps/pthread/unwind-forcedunwind.c +++ b/nptl/sysdeps/pthread/unwind-forcedunwind.c @@ -22,6 +22,7 @@ #include #include #include +#include static void *libgcc_s_handle; static void (*libgcc_s_resume) (struct _Unwind_Exception *exc); @@ -49,7 +50,7 @@ pthread_cancel_init (void) return; } - handle = __libc_dlopen ("libgcc_s.so.1"); + handle = __libc_dlopen (LIBGCC_S_SO); if (handle == NULL || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL @@ -61,7 +62,7 @@ pthread_cancel_init (void) || ARCH_CANCEL_INIT (handle) #endif ) - __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n"); + __libc_fatal (LIBGCC_S_SO " must be installed for pthread_cancel to work\n"); PTR_MANGLE (resume); libgcc_s_resume = resume; diff --git a/nptl/sysdeps/pthread/unwind-resume.c b/nptl/sysdeps/pthread/unwind-resume.c index 088f4c6f6c..69f3e04c43 100644 --- a/nptl/sysdeps/pthread/unwind-resume.c +++ b/nptl/sysdeps/pthread/unwind-resume.c @@ -20,6 +20,7 @@ #include #include #include +#include static void (*libgcc_s_resume) (struct _Unwind_Exception *exc); static _Unwind_Reason_Code (*libgcc_s_personality) @@ -32,12 +33,12 @@ init (void) void *resume, *personality; void *handle; - handle = __libc_dlopen ("libgcc_s.so.1"); + handle = __libc_dlopen (LIBGCC_S_SO); if (handle == NULL || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL) - __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n"); + __libc_fatal (LIBGCC_S_SO " must be installed for pthread_cancel to work\n"); libgcc_s_resume = resume; libgcc_s_personality = personality; diff --git a/sysdeps/generic/framestate.c b/sysdeps/generic/framestate.c index a912a8c375..80375bba98 100644 --- a/sysdeps/generic/framestate.c +++ b/sysdeps/generic/framestate.c @@ -24,6 +24,7 @@ #define __frame_state_for fallback_frame_state_for #include #undef __frame_state_for +#include typedef struct frame_state * (*framesf)(void *pc, struct frame_state *); struct frame_state *__frame_state_for (void *pc, @@ -36,7 +37,7 @@ __frame_state_for (void *pc, struct frame_state *frame_state) if (frame_state_for == NULL) { - void *handle = __libc_dlopen ("libgcc_s.so.1"); + void *handle = __libc_dlopen (LIBGCC_S_SO); if (handle == NULL || (frame_state_for diff --git a/sysdeps/generic/libgcc_s.h b/sysdeps/generic/libgcc_s.h new file mode 100644 index 0000000000..e74a1034ca --- /dev/null +++ b/sysdeps/generic/libgcc_s.h @@ -0,0 +1,2 @@ +/* Name of libgcc_s library provided by gcc. */ +#define LIBGCC_S_SO "libgcc_s.so.1" From 34df851b3364e14133b865574dbc5f2a8b88874e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 6 Nov 2009 09:26:31 -0800 Subject: [PATCH 03/29] Fix preadv, pwritev and fallocate for -D_FILE_OFFSET_BITS=64. As reported in http://bugzilla.redhat.com/533063 , preadv/pwritev prototypes are wrong on 32-bit arches with -D_FILE_OFFSET_BITS=64 and as I've just found, fallocate is wrong too. The problem is that only off_t is remapped to the 64-bit type transparently, __off_t is not. --- ChangeLog | 14 ++++++++++++++ misc/sys/uio.h | 4 ++-- sysdeps/unix/sysv/linux/i386/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/ia64/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/s390/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/sh/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/sparc/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h | 4 ++-- 9 files changed, 30 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index e6efe933c7..5c4b5d497f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2009-11-04 Jakub Jelinek + + * misc/sys/uio.h (preadv, pwritev): Fix type of last argument + when -D_FILE_OFFSET_BITS=64. + + * sysdeps/unix/sysv/linux/ia64/bits/fcntl.h (fallocate): Fix types + of last two arguments when -D_FILE_OFFSET_BITS=64. + * sysdeps/unix/sysv/linux/i386/bits/fcntl.h (fallocate): Likewise. + * sysdeps/unix/sysv/linux/s390/bits/fcntl.h (fallocate): Likewise. + * sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h (fallocate): Likewise. + * sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h (fallocate): Likewise. + * sysdeps/unix/sysv/linux/sparc/bits/fcntl.h (fallocate): Likewise. + * sysdeps/unix/sysv/linux/sh/bits/fcntl.h (fallocate): Likewise. + 2009-11-03 Andreas Schwab [BZ #4457] diff --git a/misc/sys/uio.h b/misc/sys/uio.h index 05d956bfd3..a32b7ed8e5 100644 --- a/misc/sys/uio.h +++ b/misc/sys/uio.h @@ -80,10 +80,10 @@ extern ssize_t pwritev (int __fd, __const struct iovec *__iovec, int __count, # else # ifdef __REDIRECT extern ssize_t __REDIRECT (preadv, (int __fd, __const struct iovec *__iovec, - int __count, __off_t __offset), + int __count, __off64_t __offset), preadv64) __wur; extern ssize_t __REDIRECT (pwritev, (int __fd, __const struct iovec *__iovec, - int __count, __off_t __offset), + int __count, __off64_t __offset), pwritev64) __wur; # else # define preadv preadv64 diff --git a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h index 06b9e48acc..6a38dc03fe 100644 --- a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h @@ -259,8 +259,8 @@ extern ssize_t tee (int __fdin, int __fdout, size_t __len, extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else # ifdef __REDIRECT -extern int __REDIRECT (fallocate, (int __fd, int __mode, __off_t __offset, - __off_t __len), +extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, + __off64_t __len), fallocate64); # else # define fallocate fallocate64 diff --git a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h index 9677394773..9a0245a6c4 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h @@ -253,8 +253,8 @@ extern ssize_t tee (int __fdin, int __fdout, size_t __len, extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else # ifdef __REDIRECT -extern int __REDIRECT (fallocate, (int __fd, int __mode, __off_t __offset, - __off_t __len), +extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, + __off64_t __len), fallocate64); # else # define fallocate fallocate64 diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h index ea0ee6e551..6c4b66b7ac 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h @@ -259,8 +259,8 @@ extern ssize_t tee (int __fdin, int __fdout, size_t __len, extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else # ifdef __REDIRECT -extern int __REDIRECT (fallocate, (int __fd, int __mode, __off_t __offset, - __off_t __len), +extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, + __off64_t __len), fallocate64); # else # define fallocate fallocate64 diff --git a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h index 3a11c48e04..d3dddbc368 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h @@ -279,8 +279,8 @@ extern ssize_t tee (int __fdin, int __fdout, size_t __len, extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else # ifdef __REDIRECT -extern int __REDIRECT (fallocate, (int __fd, int __mode, __off_t __offset, - __off_t __len), +extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, + __off64_t __len), fallocate64); # else # define fallocate fallocate64 diff --git a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h index 03ecd72fea..d7a21ea2e2 100644 --- a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h @@ -259,8 +259,8 @@ extern ssize_t tee (int __fdin, int __fdout, size_t __len, extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else # ifdef __REDIRECT -extern int __REDIRECT (fallocate, (int __fd, int __mode, __off_t __offset, - __off_t __len), +extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, + __off64_t __len), fallocate64); # else # define fallocate fallocate64 diff --git a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h index 2b8c9bd102..dfa848a377 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h @@ -278,8 +278,8 @@ extern ssize_t tee (int __fdin, int __fdout, size_t __len, extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else # ifdef __REDIRECT -extern int __REDIRECT (fallocate, (int __fd, int __mode, __off_t __offset, - __off_t __len), +extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, + __off64_t __len), fallocate64); # else # define fallocate fallocate64 diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h index 29c956cdf8..c3eb859e7d 100644 --- a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h @@ -273,8 +273,8 @@ extern ssize_t tee (int __fdin, int __fdout, size_t __len, extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else # ifdef __REDIRECT -extern int __REDIRECT (fallocate, (int __fd, int __mode, __off_t __offset, - __off_t __len), +extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, + __off64_t __len), fallocate64); # else # define fallocate fallocate64 From 872873d48d5d96879a2dd8c249e688e73a5dd554 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 6 Nov 2009 09:27:41 -0800 Subject: [PATCH 04/29] Fix R_PPC64_{JMP_IREL,IRELATIVE} handling in dl-conflict.c. I've just committed STT_GNU_IFUNC ppc/ppc64 support into prelink, and this patch is needed on the glibc side. Without it ld.so segfaults, as in dl-conflict.c sym_map is always NULL. While dl-machine.h could use RESOLVE_CONFLICT_FIND_MAP macro to compute it, it doesn't make sense, because with prelink we know it is already properly relocated (all relative relocations are applied by prelink). --- ChangeLog | 5 +++++ sysdeps/powerpc/powerpc64/dl-machine.h | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c4b5d497f..1a44a6ba44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-11-03 Jakub Jelinek + + * sysdeps/powerpc/powerpc64/dl-machine.h (resolve_ifunc): Don't + relocate opd entry when resolving prelink conflicts. + 2009-11-04 Jakub Jelinek * misc/sys/uio.h (preadv, pwritev): Fix type of last argument diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h index 8a720ae9c2..00888587af 100644 --- a/sysdeps/powerpc/powerpc64/dl-machine.h +++ b/sysdeps/powerpc/powerpc64/dl-machine.h @@ -531,13 +531,14 @@ auto inline Elf64_Addr __attribute__ ((always_inline)) resolve_ifunc (Elf64_Addr value, const struct link_map *map, const struct link_map *sym_map) { +#ifndef RESOLVE_CONFLICT_FIND_MAP /* The function we are calling may not yet have its opd entry relocated. */ Elf64_FuncDesc opd; if (map != sym_map -#if !defined RTLD_BOOTSTRAP && defined SHARED +# if !defined RTLD_BOOTSTRAP && defined SHARED /* Bootstrap map doesn't have l_relocated set for it. */ && sym_map != &GL(dl_rtld_map) -#endif +# endif && !sym_map->l_relocated) { Elf64_FuncDesc *func = (Elf64_FuncDesc *) value; @@ -546,6 +547,7 @@ resolve_ifunc (Elf64_Addr value, opd.fd_aux = func->fd_aux; value = (Elf64_Addr) &opd; } +#endif return ((Elf64_Addr (*) (void)) value) (); } From 5b55d23611e939340d658f42212c474c8188053e Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Fri, 6 Nov 2009 09:29:24 -0800 Subject: [PATCH 05/29] Correct readahead syscall wrapper on powerpc32. Due to alignment of 64bit parameters there is a dummy second argument. But other than that the syscall arguments are directly mapped to the function arguments. --- ChangeLog | 5 +++++ sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list | 3 +++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1a44a6ba44..03efd6c504 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-11-03 Andreas Schwab + + * sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Add + readahead. + 2009-11-03 Jakub Jelinek * sysdeps/powerpc/powerpc64/dl-machine.h (resolve_ifunc): Don't diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list index 82025b4855..1233be671a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list @@ -3,3 +3,6 @@ # System calls with wrappers. oldgetrlimit EXTRA getrlimit i:ip __old_getrlimit getrlimit@GLIBC_2.0 oldsetrlimit EXTRA setrlimit i:ip __old_setrlimit setrlimit@GLIBC_2.0 + +# Due to 64bit alignment there is a dummy second parameter +readahead - readahead i:iiiii __readahead readahead From 8608ae1f7ba31f2149f9620a1339020339eac00d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 6 Nov 2009 09:30:56 -0800 Subject: [PATCH 06/29] Properly handle STT_GNU_IFUNC symbols in do_sym. do_sym should use DL_FIXUP_VALUE_XXX macros to call IFUNC function. Otherwise, it won't compile on ia64. This patch fixes it and adds a test. --- ChangeLog | 5 +++++ elf/dl-sym.c | 9 +++++++-- elf/ifuncmain3.c | 9 +++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03efd6c504..a555225823 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-11-01 H.J. Lu + + * elf/dl-sym.c (do_sym): Properly handle STT_GNU_IFUNC symbols. + * elf/ifuncmain3.c (main): Test dlopen STT_GNU_IFUNC symbol. + 2009-11-03 Andreas Schwab * sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Add diff --git a/elf/dl-sym.c b/elf/dl-sym.c index 459729f0f2..0fa3b3ae47 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -193,8 +193,13 @@ RTLD_NEXT used in code not dynamically loaded")); /* Resolve indirect function address. */ if (__builtin_expect (ELFW(ST_TYPE) (ref->st_info) == STT_GNU_IFUNC, 0)) - value - = ((DL_FIXUP_VALUE_TYPE (*) (void)) DL_FIXUP_VALUE_ADDR (value)) (); + { + DL_FIXUP_VALUE_TYPE fixup + = DL_FIXUP_MAKE_VALUE (result, (ElfW(Addr)) value); + fixup = + ((DL_FIXUP_VALUE_TYPE (*) (void)) DL_FIXUP_VALUE_ADDR (fixup)) (); + value = (void *) DL_FIXUP_VALUE_CODE_ADDR (fixup); + } #ifdef SHARED /* Auditing checkpoint: we have a new binding. Provide the diff --git a/elf/ifuncmain3.c b/elf/ifuncmain3.c index 5d067cced9..1574dd5cbe 100644 --- a/elf/ifuncmain3.c +++ b/elf/ifuncmain3.c @@ -46,6 +46,15 @@ main (void) return 1; } + p = dlsym (h, "foo"); + if (p == NULL) + { + printf ("symbol not found: %s\n", dlerror ()); + return 1; + } + if ((*p) () != -1) + abort (); + f = dlsym (h, "get_foo_p"); if (f == NULL) { From 685cb08356bb9408c50970711ba3f4726e95b638 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 6 Nov 2009 09:32:06 -0800 Subject: [PATCH 07/29] Fix spelling in memusagestat.c --- ChangeLog | 4 ++++ malloc/memusagestat.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a555225823..97bd4533b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-10-30 Holger Hans Peter Freyther + + * malloc/memusagestat.c (main): Fix spelling in an error message. + 2009-11-01 H.J. Lu * elf/dl-sym.c (do_sym): Properly handle STT_GNU_IFUNC symbols. diff --git a/malloc/memusagestat.c b/malloc/memusagestat.c index 4d57f2cc23..a5a315056b 100644 --- a/malloc/memusagestat.c +++ b/malloc/memusagestat.c @@ -181,7 +181,7 @@ main (int argc, char *argv[]) || st.st_size < 2 * sizeof (struct entry)) { close (fd); - error (EXIT_FAILURE, 0, "input file as incorrect size"); + error (EXIT_FAILURE, 0, "input file has incorrect size"); } /* Compute number of data entries. */ total = st.st_size / sizeof (struct entry) - 2; From 868f7a4053502783ab0348736230f093a78f3d46 Mon Sep 17 00:00:00 2001 From: Philippe De Muyter Date: Fri, 6 Nov 2009 09:33:27 -0800 Subject: [PATCH 08/29] Fix spelling of (Newton-)Raphson --- ChangeLog | 5 +++++ sysdeps/powerpc/fpu/e_sqrt.c | 6 +++--- sysdeps/powerpc/fpu/e_sqrtf.c | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97bd4533b3..705e83f4b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-11-04 Philippe De Muyter + + * sysdeps/powerpc/fpu/e_sqrt.c: Fix spelling of (Newton-)Raphson. + * sysdeps/powerpc/fpu/e_sqrtf.c: Likewise. + 2009-10-30 Holger Hans Peter Freyther * malloc/memusagestat.c (main): Fix spelling in an error message. diff --git a/sysdeps/powerpc/fpu/e_sqrt.c b/sysdeps/powerpc/fpu/e_sqrt.c index 24e0dd3523..e95b786a00 100644 --- a/sysdeps/powerpc/fpu/e_sqrt.c +++ b/sysdeps/powerpc/fpu/e_sqrt.c @@ -35,7 +35,7 @@ extern const float __t_sqrt[1024]; /* The method is based on a description in Computation of elementary functions on the IBM RISC System/6000 processor, P. W. Markstein, IBM J. Res. Develop, 34(1) 1990. - Basically, it consists of two interleaved Newton-Rhapson approximations, + Basically, it consists of two interleaved Newton-Raphson approximations, one to find the actual square root, and one to find its reciprocal without the expense of a division operation. The tricky bit here is the use of the POWER/PowerPC multiply-add operation to get the @@ -44,7 +44,7 @@ extern const float __t_sqrt[1024]; The argument reduction works by a combination of table lookup to obtain the initial guesses, and some careful modification of the generated guesses (which mostly runs on the integer unit, while the - Newton-Rhapson is running on the FPU). */ + Newton-Raphson is running on the FPU). */ #ifdef __STDC__ double @@ -102,7 +102,7 @@ __slow_ieee754_sqrt (x) /* complete the INSERT_WORDS (sx, sxi, xi1) operation. */ sx = iw_u.value; - /* Here we have three Newton-Rhapson iterations each of a + /* Here we have three Newton-Raphson iterations each of a division and a square root and the remainder of the argument reduction, all interleaved. */ sd = -(sg * sg - sx); diff --git a/sysdeps/powerpc/fpu/e_sqrtf.c b/sysdeps/powerpc/fpu/e_sqrtf.c index 8e8138a17d..ca44fac559 100644 --- a/sysdeps/powerpc/fpu/e_sqrtf.c +++ b/sysdeps/powerpc/fpu/e_sqrtf.c @@ -35,7 +35,7 @@ extern const float __t_sqrt[1024]; /* The method is based on a description in Computation of elementary functions on the IBM RISC System/6000 processor, P. W. Markstein, IBM J. Res. Develop, 34(1) 1990. - Basically, it consists of two interleaved Newton-Rhapson approximations, + Basically, it consists of two interleaved Newton-Raphson approximations, one to find the actual square root, and one to find its reciprocal without the expense of a division operation. The tricky bit here is the use of the POWER/PowerPC multiply-add operation to get the @@ -44,7 +44,7 @@ extern const float __t_sqrt[1024]; The argument reduction works by a combination of table lookup to obtain the initial guesses, and some careful modification of the generated guesses (which mostly runs on the integer unit, while the - Newton-Rhapson is running on the FPU). */ + Newton-Raphson is running on the FPU). */ #ifdef __STDC__ float @@ -90,7 +90,7 @@ __slow_ieee754_sqrtf (x) sg = t_sqrt[0]; sy = t_sqrt[1]; - /* Here we have three Newton-Rhapson iterations each of a + /* Here we have three Newton-Raphson iterations each of a division and a square root and the remainder of the argument reduction, all interleaved. */ sd = -(sg * sg - sx); From 639d6699e9943c393f5fb5a9b84ab24e20bb7a93 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 6 Nov 2009 09:34:23 -0800 Subject: [PATCH 09/29] Fix up whitespaces. --- elf/dl-sym.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elf/dl-sym.c b/elf/dl-sym.c index 0fa3b3ae47..4faf05c00b 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -196,7 +196,7 @@ RTLD_NEXT used in code not dynamically loaded")); { DL_FIXUP_VALUE_TYPE fixup = DL_FIXUP_MAKE_VALUE (result, (ElfW(Addr)) value); - fixup = + fixup = ((DL_FIXUP_VALUE_TYPE (*) (void)) DL_FIXUP_VALUE_ADDR (fixup)) (); value = (void *) DL_FIXUP_VALUE_CODE_ADDR (fixup); } From 6515a01fc1d35d329886d5a45435537ee9115bc4 Mon Sep 17 00:00:00 2001 From: Caolan McNamara Date: Tue, 10 Nov 2009 06:29:13 -0800 Subject: [PATCH 10/29] Avoid memset warning in one case. --- ChangeLog | 5 +++++ string/bits/string3.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 705e83f4b4..ac8baf13be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-11-10 Ulrich Drepper + + * string/bits/string3.h (memset): If the second parameter is constant + and zero there is likely no transposition. + 2009-11-04 Philippe De Muyter * sysdeps/powerpc/fpu/e_sqrt.c: Fix spelling of (Newton-)Raphson. diff --git a/string/bits/string3.h b/string/bits/string3.h index a5593e3b89..1d759f181b 100644 --- a/string/bits/string3.h +++ b/string/bits/string3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -77,7 +77,8 @@ __NTH (mempcpy (void *__restrict __dest, __const void *__restrict __src, __extern_always_inline void * __NTH (memset (void *__dest, int __ch, size_t __len)) { - if (__builtin_constant_p (__len) && __len == 0) + if (__builtin_constant_p (__len) && __len == 0 + && (!__builtin_constant_p (__ch) || __ch != 0)) { __warn_memset_zero_len (); return __dest; From 51e4196f16a2d98377e3c481a44e133369dc7669 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 10 Nov 2009 07:36:50 -0800 Subject: [PATCH 11/29] Handle running out of buffer space with IPv6 mapping enabled. With big DNS answers like the one you get for goodtimesdot.com you can get a truncated address list if IPv6 mapping is enabled. Instead tell the caller to resize the buffer. --- ChangeLog | 8 ++++++++ resolv/mapv4v6hostent.h | 12 +++++------- resolv/nss_dns/dns-host.c | 6 ++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac8baf13be..49c2e08a4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,15 @@ +2009-11-10 Andreas Schwab + + * resolv/mapv4v6hostent.h (map_v4v6_hostent): Return non-zero if + out of buffer space. + * resolv/nss_dns/dns-host.c (getanswer_r): Check for + map_v4v6_hostent running out of space. + 2009-11-10 Ulrich Drepper * string/bits/string3.h (memset): If the second parameter is constant and zero there is likely no transposition. + Patch by Caolan McNamara diff --git a/resolv/mapv4v6hostent.h b/resolv/mapv4v6hostent.h index 4151ce3639..c11038adf3 100644 --- a/resolv/mapv4v6hostent.h +++ b/resolv/mapv4v6hostent.h @@ -57,13 +57,13 @@ typedef union { char ac; } align; -static void +static int map_v4v6_hostent (struct hostent *hp, char **bpp, int *lenp) { char **ap; if (hp->h_addrtype != AF_INET || hp->h_length != INADDRSZ) - return; + return 0; hp->h_addrtype = AF_INET6; hp->h_length = IN6ADDRSZ; for (ap = hp->h_addr_list; *ap; ap++) @@ -71,11 +71,8 @@ map_v4v6_hostent (struct hostent *hp, char **bpp, int *lenp) int i = sizeof (align) - ((u_long) *bpp % sizeof (align)); if (*lenp < (i + IN6ADDRSZ)) - { - /* Out of memory. Truncate address list here. XXX */ - *ap = NULL; - return; - } + /* Out of memory. */ + return 1; *bpp += i; *lenp -= i; map_v4v6_address (*ap, *bpp); @@ -83,4 +80,5 @@ map_v4v6_hostent (struct hostent *hp, char **bpp, int *lenp) *bpp += IN6ADDRSZ; *lenp -= IN6ADDRSZ; } + return 0; } diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 62e67e8b01..818a40a898 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -878,7 +878,8 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, } bp += n; linebuflen -= n; - map_v4v6_hostent (result, &bp, &linebuflen); + if (map_v4v6_hostent (result, &bp, &linebuflen)) + goto too_small; } *h_errnop = NETDB_SUCCESS; return NSS_STATUS_SUCCESS; @@ -953,7 +954,8 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, } if (have_to_map) - map_v4v6_hostent (result, &bp, &linebuflen); + if (map_v4v6_hostent (result, &bp, &linebuflen)) + goto too_small; *h_errnop = NETDB_SUCCESS; return NSS_STATUS_SUCCESS; } From dc2d2c7e915b0add3755d41bcd0739ed0e69c5d3 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 14 Nov 2009 08:28:40 -0800 Subject: [PATCH 12/29] Fix F_SETOWN_EX and F_GETOWN_EX definitions. (cherry picked from commit 8964681064db9f13ee4ec7f46c53f04d66a04b99) --- ChangeLog | 11 +++++++++++ sysdeps/unix/sysv/linux/i386/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/ia64/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h | 8 ++++---- sysdeps/unix/sysv/linux/s390/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/sh/bits/fcntl.h | 8 ++++---- sysdeps/unix/sysv/linux/sparc/bits/fcntl.h | 4 ++-- sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h | 8 ++++---- 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49c2e08a4a..aaa46bee32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-11-14 Ulrich Drepper + + * sysdeps/unix/sysv/linux/sh/bits/fcntl.h: Update F_SETOWN_EX and + F_GETOWN_EX definitions according to corrected kernel definitions. + * sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/sparc/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/ia64/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/i386/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/s390/bits/fcntl.h: Likewise. + 2009-11-10 Andreas Schwab * resolv/mapv4v6hostent.h (map_v4v6_hostent): Return non-zero if diff --git a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h index 6a38dc03fe..a6db8a86b4 100644 --- a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h @@ -92,8 +92,8 @@ #ifdef __USE_GNU # define F_SETSIG 10 /* Set number of signal to be sent. */ # define F_GETSIG 11 /* Get number of signal to be sent. */ -# define F_SETOWN_EX 12 /* Get owner (thread receiving SIGIO). */ -# define F_GETOWN_EX 13 /* Set owner (thread receiving SIGIO). */ +# define F_SETOWN_EX 15 /* Get owner (thread receiving SIGIO). */ +# define F_GETOWN_EX 16 /* Set owner (thread receiving SIGIO). */ #endif #ifdef __USE_GNU diff --git a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h index 9a0245a6c4..51c5329ac2 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h @@ -88,8 +88,8 @@ #ifdef __USE_GNU # define F_SETSIG 10 /* Set number of signal to be sent. */ # define F_GETSIG 11 /* Get number of signal to be sent. */ -# define F_SETOWN_EX 12 /* Get owner (thread receiving SIGIO). */ -# define F_GETOWN_EX 13 /* Set owner (thread receiving SIGIO). */ +# define F_SETOWN_EX 15 /* Get owner (thread receiving SIGIO). */ +# define F_GETOWN_EX 16 /* Set owner (thread receiving SIGIO). */ #endif #ifdef __USE_GNU diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h index 6c4b66b7ac..4bdaf7bd04 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h @@ -85,15 +85,15 @@ #define F_SETLKW64 14 /* Set record locking info (blocking). */ #if defined __USE_BSD || defined __USE_UNIX98 -# define F_SETOWN 8 /* Get owner (process receiving of SIGIO). */ -# define F_GETOWN 9 /* Set owner (process receiving of SIGIO). */ +# define F_SETOWN 8 /* Get owner (process receiving SIGIO). */ +# define F_GETOWN 9 /* Set owner (process receiving SIGIO). */ #endif #ifdef __USE_GNU # define F_SETSIG 10 /* Set number of signal to be sent. */ # define F_GETSIG 11 /* Get number of signal to be sent. */ -# define F_SETOWN_EX 12 /* Get owner (thread receiving SIGIO). */ -# define F_GETOWN_EX 13 /* Set owner (thread receiving SIGIO). */ +# define F_SETOWN_EX 15 /* Get owner (thread receiving SIGIO). */ +# define F_GETOWN_EX 16 /* Set owner (thread receiving SIGIO). */ #endif #ifdef __USE_GNU diff --git a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h index d3dddbc368..0af0f93f1e 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h @@ -107,8 +107,8 @@ #ifdef __USE_GNU # define F_SETSIG 10 /* Set number of signal to be sent. */ # define F_GETSIG 11 /* Get number of signal to be sent. */ -# define F_SETOWN_EX 12 /* Get owner (thread receiving SIGIO). */ -# define F_GETOWN_EX 13 /* Set owner (thread receiving SIGIO). */ +# define F_SETOWN_EX 15 /* Get owner (thread receiving SIGIO). */ +# define F_GETOWN_EX 16 /* Set owner (thread receiving SIGIO). */ #endif #ifdef __USE_GNU diff --git a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h index d7a21ea2e2..a6db8a86b4 100644 --- a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h @@ -85,15 +85,15 @@ #define F_SETLKW64 14 /* Set record locking info (blocking). */ #if defined __USE_BSD || defined __USE_UNIX98 -# define F_SETOWN 8 /* Get owner (process receiving of SIGIO). */ -# define F_GETOWN 9 /* Set owner (process receiving of SIGIO). */ +# define F_SETOWN 8 /* Get owner (process receiving SIGIO). */ +# define F_GETOWN 9 /* Set owner (process receiving SIGIO). */ #endif #ifdef __USE_GNU # define F_SETSIG 10 /* Set number of signal to be sent. */ # define F_GETSIG 11 /* Get number of signal to be sent. */ -# define F_SETOWN_EX 12 /* Get owner (thread receiving of SIGIO). */ -# define F_GETOWN_EX 13 /* Set owner (thread receiving of SIGIO). */ +# define F_SETOWN_EX 15 /* Get owner (thread receiving SIGIO). */ +# define F_GETOWN_EX 16 /* Set owner (thread receiving SIGIO). */ #endif #ifdef __USE_GNU diff --git a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h index dfa848a377..ad4f48e673 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h @@ -99,8 +99,8 @@ #ifdef __USE_GNU # define F_SETSIG 10 /* Set number of signal to be sent. */ # define F_GETSIG 11 /* Get number of signal to be sent. */ -# define F_GETOWN_EX 12 /* Get owner (thread receiving SIGIO). */ -# define F_SETOWN_EX 13 /* Set owner (thread receiving SIGIO). */ +# define F_SETOWN_EX 15 /* Set owner (thread receiving SIGIO). */ +# define F_GETOWN_EX 16 /* Get owner (thread receiving SIGIO). */ #endif #ifdef __USE_GNU diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h index c3eb859e7d..6e96885d55 100644 --- a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h @@ -99,15 +99,15 @@ #endif #if defined __USE_BSD || defined __USE_UNIX98 -# define F_SETOWN 8 /* Get owner (process receiving of SIGIO). */ -# define F_GETOWN 9 /* Set owner (process receiving of SIGIO). */ +# define F_SETOWN 8 /* Get owner (process receiving SIGIO). */ +# define F_GETOWN 9 /* Set owner (process receiving SIGIO). */ #endif #ifdef __USE_GNU # define F_SETSIG 10 /* Set number of signal to be sent. */ # define F_GETSIG 11 /* Get number of signal to be sent. */ -# define F_SETOWN_EX 12 /* Get owner (thread receiving SIGIO). */ -# define F_GETOWN_EX 13 /* Set owner (thread receiving SIGIO). */ +# define F_SETOWN_EX 15 /* Get owner (thread receiving SIGIO). */ +# define F_GETOWN_EX 16 /* Set owner (thread receiving SIGIO). */ #endif #ifdef __USE_GNU From 3e224a852a7109e2efa1f07f15962235d12b7e63 Mon Sep 17 00:00:00 2001 From: Mike Frsyinger Date: Sat, 14 Nov 2009 19:11:44 -0800 Subject: [PATCH 13/29] Add missing stdio.h include. (cherry picked from commit 5ec794b4b537bc507010af28d2d93bb76d0972ac) --- ChangeLog | 4 ++++ posix/bug-regex29.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index aaa46bee32..57090cb2d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-11-06 Mike Frsyinger + + * posix/bug-regex29.c: Include stdio.h. + 2009-11-14 Ulrich Drepper * sysdeps/unix/sysv/linux/sh/bits/fcntl.h: Update F_SETOWN_EX and diff --git a/posix/bug-regex29.c b/posix/bug-regex29.c index bd796c6c2a..cfc9f99dbc 100644 --- a/posix/bug-regex29.c +++ b/posix/bug-regex29.c @@ -1,4 +1,5 @@ #include +#include static int do_test (void) From c78e33c312e16a4faccf07278d45538f0252058f Mon Sep 17 00:00:00 2001 From: Mike Frsyinger Date: Sat, 14 Nov 2009 19:16:01 -0800 Subject: [PATCH 14/29] Fix building on x86 with older kernel headers. Fix building on x86 when older linux headers lack __NR_fallocate define. (cherry picked from commit f9a7bd536e0b1693db32e1330bbd96108ca63c42) --- sysdeps/unix/sysv/linux/i386/fallocate.c | 6 ++++++ sysdeps/unix/sysv/linux/i386/fallocate64.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/sysdeps/unix/sysv/linux/i386/fallocate.c b/sysdeps/unix/sysv/linux/i386/fallocate.c index 7a943e44c0..14e788386c 100644 --- a/sysdeps/unix/sysv/linux/i386/fallocate.c +++ b/sysdeps/unix/sysv/linux/i386/fallocate.c @@ -16,6 +16,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include #include #include @@ -28,5 +29,10 @@ extern int __call_fallocate (int fd, int mode, __off64_t offset, __off64_t len) int fallocate (int fd, int mode, __off_t offset, __off_t len) { +#ifdef __NR_fallocate return __call_fallocate (fd, mode, offset, len); +#else + __set_errno (ENOSYS); + return -1; +#endif } diff --git a/sysdeps/unix/sysv/linux/i386/fallocate64.c b/sysdeps/unix/sysv/linux/i386/fallocate64.c index 4998f5e644..85f315c9b6 100644 --- a/sysdeps/unix/sysv/linux/i386/fallocate64.c +++ b/sysdeps/unix/sysv/linux/i386/fallocate64.c @@ -16,6 +16,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include #include #include @@ -28,5 +29,10 @@ extern int __call_fallocate (int fd, int mode, __off64_t offset, __off64_t len) int fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) { +#ifdef __NR_fallocate return __call_fallocate (fd, mode, offset, len); +#else + __set_errno (ENOSYS); + return -1; +#endif } From c0ca09284eedec057b9036eb319be7e30442df04 Mon Sep 17 00:00:00 2001 From: Mike Frsyinger Date: Sat, 14 Nov 2009 19:16:49 -0800 Subject: [PATCH 15/29] Missing CL. (cherry picked from commit fabe43aba8fb46614eb2a74b2916bfbbf8fec10e) --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 57090cb2d3..3a75f3571a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-11-09 Mike Frysinger + + * sysdeps/unix/sysv/linux/i386/fallocate.c: Include errno.h. + (fallocate): Return ENOSYS if __NR_fallocate is not defined. + * sysdeps/unix/sysv/linux/i386/fallocate64.c: Likewise. + 2009-11-06 Mike Frsyinger * posix/bug-regex29.c: Include stdio.h. From 22bdb3aa5b2cd760fd3bf1ee6c46c61e23457876 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 17 Nov 2009 06:43:39 -0800 Subject: [PATCH 16/29] Add missing Linux MADV_* definitions. (cherry picked from commit 2866eeb1b70c989591293d37ae292e71def16775) --- ChangeLog | 14 +++++++++++- sysdeps/unix/sysv/linux/i386/bits/mman.h | 21 ++++++++++-------- sysdeps/unix/sysv/linux/ia64/bits/mman.h | 22 +++++++++++-------- sysdeps/unix/sysv/linux/powerpc/bits/mman.h | 22 +++++++++++-------- sysdeps/unix/sysv/linux/s390/bits/mman.h | 21 ++++++++++-------- sysdeps/unix/sysv/linux/sh/bits/mman.h | 22 +++++++++++-------- sysdeps/unix/sysv/linux/sparc/bits/mman.h | 24 ++++++++++++--------- sysdeps/unix/sysv/linux/x86_64/bits/mman.h | 21 ++++++++++-------- 8 files changed, 102 insertions(+), 65 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a75f3571a..e73ee6a3e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,22 @@ +2009-11-17 Ulrich Drepper + + [BZ #10972] + * sysdeps/unix/sysv/linux/powerpc/bits/mman.h: Add new MADV_* + constants from recent kernels. + * sysdeps/unix/sysv/linux/i386/bits/mman.h: Likewise. + * sysdeps/unix/sysv/linux/x86_64/bits/mman.h: Likewise. + * sysdeps/unix/sysv/linux/s390/bits/mman.h: Likewise. + * sysdeps/unix/sysv/linux/sparc/bits/mman.h: Likewise. + * sysdeps/unix/sysv/linux/sh/bits/mman.h: Likewise. + * sysdeps/unix/sysv/linux/ia64/bits/mman.h: Likewise. + 2009-11-09 Mike Frysinger * sysdeps/unix/sysv/linux/i386/fallocate.c: Include errno.h. (fallocate): Return ENOSYS if __NR_fallocate is not defined. * sysdeps/unix/sysv/linux/i386/fallocate64.c: Likewise. -2009-11-06 Mike Frsyinger +2009-11-06 Mike Frysinger * posix/bug-regex29.c: Include stdio.h. diff --git a/sysdeps/unix/sysv/linux/i386/bits/mman.h b/sysdeps/unix/sysv/linux/i386/bits/mman.h index 2b90c8d7d5..22aa401e02 100644 --- a/sysdeps/unix/sysv/linux/i386/bits/mman.h +++ b/sysdeps/unix/sysv/linux/i386/bits/mman.h @@ -1,5 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/i386 version. - Copyright (C) 1997, 2000, 2003, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 1997,2000,2003,2005,2006,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -84,14 +84,17 @@ /* Advice to `madvise'. */ #ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_NORMAL 0 /* No further special treatment. */ +# define MADV_RANDOM 1 /* Expect random page references. */ +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define MADV_WILLNEED 3 /* Will need these pages. */ +# define MADV_DONTNEED 4 /* Don't need these pages. */ +# define MADV_REMOVE 9 /* Remove these pages and resources. */ +# define MADV_DONTFORK 10 /* Do not inherit across fork. */ +# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */ +# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */ +# define MADV_HWPOISON 100 /* Poison a page for testing. */ #endif /* The POSIX people had to invent similar names for the same things. */ diff --git a/sysdeps/unix/sysv/linux/ia64/bits/mman.h b/sysdeps/unix/sysv/linux/ia64/bits/mman.h index a27a30fc0c..1b278c79ee 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/mman.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/mman.h @@ -1,5 +1,6 @@ /* Definitions for POSIX memory map interface. Linux/ia64 version. - Copyright (C) 1997,1998,2000,2003,2005,2006 Free Software Foundation, Inc. + Copyright (C) 1997,1998,2000,2003,2005,2006,2009 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -84,14 +85,17 @@ /* Advice to `madvise'. */ #ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_NORMAL 0 /* No further special treatment. */ +# define MADV_RANDOM 1 /* Expect random page references. */ +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define MADV_WILLNEED 3 /* Will need these pages. */ +# define MADV_DONTNEED 4 /* Don't need these pages. */ +# define MADV_REMOVE 9 /* Remove these pages and resources. */ +# define MADV_DONTFORK 10 /* Do not inherit across fork. */ +# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */ +# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */ +# define MADV_HWPOISON 100 /* Poison a page for testing. */ #endif /* The POSIX people had to invent similar names for the same things. */ diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/mman.h b/sysdeps/unix/sysv/linux/powerpc/bits/mman.h index d5729a1f1c..e6580f8220 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/mman.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/mman.h @@ -1,5 +1,6 @@ /* Definitions for POSIX memory map interface. Linux/PowerPC version. - Copyright (C) 1997,2000,2003,2005,2006,2008 Free Software Foundation, Inc. + Copyright (C) 1997,2000,2003,2005,2006,2008,2009 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -85,14 +86,17 @@ /* Advice to `madvise'. */ #ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_NORMAL 0 /* No further special treatment. */ +# define MADV_RANDOM 1 /* Expect random page references. */ +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define MADV_WILLNEED 3 /* Will need these pages. */ +# define MADV_DONTNEED 4 /* Don't need these pages. */ +# define MADV_REMOVE 9 /* Remove these pages and resources. */ +# define MADV_DONTFORK 10 /* Do not inherit across fork. */ +# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */ +# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */ +# define MADV_HWPOISON 100 /* Poison a page for testing. */ #endif /* The POSIX people had to invent similar names for the same things. */ diff --git a/sysdeps/unix/sysv/linux/s390/bits/mman.h b/sysdeps/unix/sysv/linux/s390/bits/mman.h index d25531c282..daeafd48ff 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/mman.h +++ b/sysdeps/unix/sysv/linux/s390/bits/mman.h @@ -1,5 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/s390 version. - Copyright (C) 2000,2001,2002,2003,2005,2006 Free Software Foundation, Inc. + Copyright (C) 2000-2003,2005,2006,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -84,14 +84,17 @@ /* Advice to `madvise'. */ #ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_NORMAL 0 /* No further special treatment. */ +# define MADV_RANDOM 1 /* Expect random page references. */ +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define MADV_WILLNEED 3 /* Will need these pages. */ +# define MADV_DONTNEED 4 /* Don't need these pages. */ +# define MADV_REMOVE 9 /* Remove these pages and resources. */ +# define MADV_DONTFORK 10 /* Do not inherit across fork. */ +# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */ +# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */ +# define MADV_HWPOISON 100 /* Poison a page for testing. */ #endif /* The POSIX people had to invent similar names for the same things. */ diff --git a/sysdeps/unix/sysv/linux/sh/bits/mman.h b/sysdeps/unix/sysv/linux/sh/bits/mman.h index 7a6b572a4e..aee0011255 100644 --- a/sysdeps/unix/sysv/linux/sh/bits/mman.h +++ b/sysdeps/unix/sysv/linux/sh/bits/mman.h @@ -1,5 +1,6 @@ /* Definitions for POSIX memory map interface. Linux/SH version. - Copyright (C) 1997,1999,2000,2003,2005,2006 Free Software Foundation, Inc. + Copyright (C) 1997,1999,2000,2003,2005,2006,2009 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -83,14 +84,17 @@ /* Advice to `madvise'. */ #ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_NORMAL 0 /* No further special treatment. */ +# define MADV_RANDOM 1 /* Expect random page references. */ +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define MADV_WILLNEED 3 /* Will need these pages. */ +# define MADV_DONTNEED 4 /* Don't need these pages. */ +# define MADV_REMOVE 9 /* Remove these pages and resources. */ +# define MADV_DONTFORK 10 /* Do not inherit across fork. */ +# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */ +# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */ +# define MADV_HWPOISON 100 /* Poison a page for testing. */ #endif /* The POSIX people had to invent similar names for the same things. */ diff --git a/sysdeps/unix/sysv/linux/sparc/bits/mman.h b/sysdeps/unix/sysv/linux/sparc/bits/mman.h index be2b7eb280..71a3aa6a30 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/mman.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/mman.h @@ -1,5 +1,6 @@ /* Definitions for POSIX memory map interface. Linux/SPARC version. - Copyright (C) 1997,1999,2000,2003,2005,2006 Free Software Foundation, Inc. + Copyright (C) 1997,1999,2000,2003,2005,2006,2009 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -85,15 +86,18 @@ /* Advice to `madvise'. */ #ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_FREE 5 /* Content can be freed (Solaris). */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_NORMAL 0 /* No further special treatment. */ +# define MADV_RANDOM 1 /* Expect random page references. */ +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define MADV_WILLNEED 3 /* Will need these pages. */ +# define MADV_DONTNEED 4 /* Don't need these pages. */ +# define MADV_FREE 5 /* Content can be freed (Solaris). */ +# define MADV_REMOVE 9 /* Remove these pages and resources. */ +# define MADV_DONTFORK 10 /* Do not inherit across fork. */ +# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */ +# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */ +# define MADV_HWPOISON 100 /* Poison a page for testing. */ #endif /* The POSIX people had to invent similar names for the same things. */ diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/mman.h b/sysdeps/unix/sysv/linux/x86_64/bits/mman.h index 7810682536..3dcbf9c317 100644 --- a/sysdeps/unix/sysv/linux/x86_64/bits/mman.h +++ b/sysdeps/unix/sysv/linux/x86_64/bits/mman.h @@ -1,5 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/x86_64 version. - Copyright (C) 2001, 2003, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2005, 2006, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -85,14 +85,17 @@ /* Advice to `madvise'. */ #ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_NORMAL 0 /* No further special treatment. */ +# define MADV_RANDOM 1 /* Expect random page references. */ +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define MADV_WILLNEED 3 /* Will need these pages. */ +# define MADV_DONTNEED 4 /* Don't need these pages. */ +# define MADV_REMOVE 9 /* Remove these pages and resources. */ +# define MADV_DONTFORK 10 /* Do not inherit across fork. */ +# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */ +# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */ +# define MADV_HWPOISON 100 /* Poison a page for testing. */ #endif /* The POSIX people had to invent similar names for the same things. */ From c086031db01cc10bafe55864b1185c111a30198e Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 17 Nov 2009 09:18:11 -0800 Subject: [PATCH 17/29] Fix _NC_LOCALE_NAME definition. (cherry picked from commit 4fb9241e4edbe238de8ba251f4448e31e8b1baf4) --- ChangeLog | 6 ++++++ locale/Makefile | 6 +++--- locale/langinfo.h | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e73ee6a3e2..ccf46701cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-11-17 Ulrich Drepper + [BZ #10968] + * locale/langinfo.h (_NL_LOCALE_NAME): Correct definition. + Patch by Bruno Haible . + * locale/tst-locname.c: New file. + * locale/Makefile (tests): Add tst-locname. + [BZ #10972] * sysdeps/unix/sysv/linux/powerpc/bits/mman.h: Add new MADV_* constants from recent kernels. diff --git a/locale/Makefile b/locale/Makefile index d9ab1947e7..2d645daa2f 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991,1992,1995-2003,2005 Free Software Foundation, Inc. +# Copyright (C) 1991,1992,1995-2003,2005,2009 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -38,7 +38,7 @@ distribute = localeinfo.h categories.def iso-639.def iso-3166.def \ routines = setlocale findlocale loadlocale loadarchive \ localeconv nl_langinfo nl_langinfo_l mb_cur_max \ newlocale duplocale freelocale uselocale -tests = tst-C-locale +tests = tst-C-locale tst-locname categories = ctype messages monetary numeric time paper name \ address telephone measurement identification collate aux = $(categories:%=lc-%) $(categories:%=C-%) SYS_libc C_name \ @@ -104,7 +104,7 @@ CFLAGS-charmap-dir.c = -Wno-write-strings # This makes sure -DNOT_IN_libc is passed for all these modules. cpp-srcs-left := $(addsuffix .c,$(localedef-modules) $(localedef-aux) \ - $(locale-modules) $(lib-modules)) + $(locale-modules) $(lib-modules)) lib := nonlib include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) diff --git a/locale/langinfo.h b/locale/langinfo.h index c940c743aa..0a53365071 100644 --- a/locale/langinfo.h +++ b/locale/langinfo.h @@ -568,7 +568,8 @@ enum /* This macro produces an item you can pass to `nl_langinfo' or `nl_langinfo_l' to get the name of the locale in use for CATEGORY. */ -#define _NL_LOCALE_NAME(category) _NL_ITEM ((category), -1) +#define _NL_LOCALE_NAME(category) _NL_ITEM ((category), \ + _NL_ITEM_INDEX (-1)) #ifdef __USE_GNU # define NL_LOCALE_NAME(category) _NL_LOCALE_NAME (category) #endif From b39591e9c1c156a080563d60450d5fdb7971457c Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 17 Nov 2009 09:37:31 -0800 Subject: [PATCH 18/29] Handle LC_GLOBAL_LOCALE in duplocale. (cherry picked from commit 7443244740724babd575943ee33c45da326afbe7) --- ChangeLog | 5 +++++ locale/Makefile | 2 +- locale/duplocale.c | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ccf46701cc..d5194f890e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-11-17 Ulrich Drepper + [BZ #10969] + * locale/duplocale.c (__duplocale): Handle LC_GLOBAL_LOCALE special. + * locale/tst-duplocale.c: New file. + * locale/Makefile (tests): Add tst-duplocale. + [BZ #10968] * locale/langinfo.h (_NL_LOCALE_NAME): Correct definition. Patch by Bruno Haible . diff --git a/locale/Makefile b/locale/Makefile index 2d645daa2f..2dbd8dc6a5 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -38,7 +38,7 @@ distribute = localeinfo.h categories.def iso-639.def iso-3166.def \ routines = setlocale findlocale loadlocale loadarchive \ localeconv nl_langinfo nl_langinfo_l mb_cur_max \ newlocale duplocale freelocale uselocale -tests = tst-C-locale tst-locname +tests = tst-C-locale tst-locname tst-duplocale categories = ctype messages monetary numeric time paper name \ address telephone measurement identification collate aux = $(categories:%=lc-%) $(categories:%=C-%) SYS_libc C_name \ diff --git a/locale/duplocale.c b/locale/duplocale.c index 61782590d7..63513c539c 100644 --- a/locale/duplocale.c +++ b/locale/duplocale.c @@ -1,5 +1,5 @@ /* Duplicate handle for selection of locales. - Copyright (C) 1997,2000,2001,2002,2005,2008 Free Software Foundation, Inc. + Copyright (C) 1997,2000-2002,2005,2008,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -37,6 +37,10 @@ __duplocale (__locale_t dataset) if (dataset == _nl_C_locobj_ptr) return dataset; + /* Handle a special value. */ + if (dataset == LC_GLOBAL_LOCALE) + dataset = &_nl_global_locale; + __locale_t result; int cnt; size_t names_len = 0; From 1960ded78b85a1661d847c4b071c62915635a761 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 17 Nov 2009 16:23:24 -0800 Subject: [PATCH 19/29] Fix ranges with multibyte characters as endpoints. This is another bug in computing the fastmap. It was reported by a user of sed because it usually does not happen with !_LIBC. However, it is there in that case too. The bug is that whenever we have a range at the beginning of the regex, the regex must be tested on any possible multibyte character. The reason why _LIBC masks it, is that in general there is a collation symbol for each possible multibyte-character lead byte, so all the lead bytes are in general already part of the fastmap. The tests use cyrillic characters as an example. With _LIBC, they pass without the patch too, but you can make them fail by removing collation symbols handling. (cherry picked from commit 815d8147a3418334ffa91e2384c6e159f0809d65) --- ChangeLog | 8 ++++ posix/Makefile | 3 +- posix/bug-regex30.c | 103 ++++++++++++++++++++++++++++++++++++++++++++ posix/regcomp.c | 2 +- 4 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 posix/bug-regex30.c diff --git a/ChangeLog b/ChangeLog index d5194f890e..bbc9eb0b47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-11-17 Paolo Bonzini + + * posix/bug-regex30.c: New file. + * posix/Makefile: Add rules to build and run bug-regex30. + * posix/regcomp.c (re_compile_fastmap_iter): Add all multibyte + character lead bytes when there is a range in a COMPLEX_BRACKET. + Reported by Oleg Bylatov. + 2009-11-17 Ulrich Drepper [BZ #10969] diff --git a/posix/Makefile b/posix/Makefile index c9ce18b94e..2a467a8f7b 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -82,7 +82,7 @@ tests := tstgetopt testfnm runtests runptests \ bug-regex17 bug-regex18 bug-regex19 bug-regex20 \ bug-regex21 bug-regex22 bug-regex23 bug-regex24 \ bug-regex25 bug-regex26 bug-regex27 bug-regex28 \ - bug-regex29 \ + bug-regex29 bug-regex30 \ tst-nice tst-nanosleep tst-regex2 \ transbug tst-rxspencer tst-pcre tst-boost \ bug-ga1 tst-vfork1 tst-vfork2 tst-vfork3 tst-waitid \ @@ -195,6 +195,7 @@ bug-regex22-ENV = LOCPATH=$(common-objpfx)localedata bug-regex23-ENV = LOCPATH=$(common-objpfx)localedata bug-regex25-ENV = LOCPATH=$(common-objpfx)localedata bug-regex26-ENV = LOCPATH=$(common-objpfx)localedata +bug-regex30-ENV = LOCPATH=$(common-objpfx)localedata tst-rxspencer-ARGS = --utf8 rxspencer/tests tst-rxspencer-ENV = LOCPATH=$(common-objpfx)localedata tst-pcre-ARGS = PCRE.tests diff --git a/posix/bug-regex30.c b/posix/bug-regex30.c new file mode 100644 index 0000000000..ef2bd76eba --- /dev/null +++ b/posix/bug-regex30.c @@ -0,0 +1,103 @@ +/* Russian regular expression tests. + Copyright (C) 2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Paolo Bonzini , 2009. + + 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 +#include +#include +#include +#include + +/* Tests supposed to match. */ +struct +{ + const char *pattern; + const char *string; + int flags, nmatch; + regmatch_t rm[5]; +} tests[] = { + /* U+0413 \xd0\x93 CYRILLIC CAPITAL LETTER GHE + U+0420 \xd0\xa0 CYRILLIC CAPITAL LETTER ER + U+0430 \xd0\xb0 CYRILLIC SMALL LETTER A + U+0433 \xd0\xb3 CYRILLIC SMALL LETTER GHE + U+0440 \xd1\x80 CYRILLIC SMALL LETTER ER + U+044F \xd1\x8f CYRILLIC SMALL LETTER YA */ + { "[\xd0\xb0-\xd1\x8f]", "\xd0\xb3", 0, 1, + { { 0, 2 } } }, + { "[\xd0\xb0-\xd1\x8f]", "\xd0\x93", REG_ICASE, 1, + { { 0, 2 } } }, + { "[\xd1\x80-\xd1\x8f]", "\xd0\xa0", REG_ICASE, 1, + { { 0, 2 } } }, +}; + + +static int +do_test (void) +{ + if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL) + { + puts ("setlocale failed"); + return 1; + } + + int ret = 0; + + for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i) + { + regex_t re; + regmatch_t rm[5]; + int n = regcomp (&re, tests[i].pattern, tests[i].flags); + if (n != 0) + { + char buf[500]; + regerror (n, &re, buf, sizeof (buf)); + printf ("regcomp %zd failed: %s\n", i, buf); + ret = 1; + continue; + } + + if (regexec (&re, tests[i].string, tests[i].nmatch, rm, 0)) + { + printf ("regexec %zd failed\n", i); + ret = 1; + regfree (&re); + continue; + } + + for (n = 0; n < tests[i].nmatch; ++n) + if (rm[n].rm_so != tests[i].rm[n].rm_so + || rm[n].rm_eo != tests[i].rm[n].rm_eo) + { + if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1) + break; + printf ("regexec match failure rm[%d] %d..%d\n", + n, rm[n].rm_so, rm[n].rm_eo); + ret = 1; + break; + } + + regfree (&re); + } + + return ret; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/posix/regcomp.c b/posix/regcomp.c index 446fed5445..6966b5da3c 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -377,7 +377,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, applies to multibyte character sets; for single byte character sets, the SIMPLE_BRACKET again suffices. */ if (dfa->mb_cur_max > 1 - && (cset->nchar_classes || cset->non_match + && (cset->nchar_classes || cset->non_match || cset->nranges # ifdef _LIBC || cset->nequiv_classes # endif /* _LIBC */ From c35a44f325843a4b6fb3bc53526bcc1f741c8254 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 17 Nov 2009 16:23:57 -0800 Subject: [PATCH 20/29] Add missing test files. (cherry picked from commit 3a00b16da491d5c869795251e1ad4f43b3ba1469) --- locale/tst-duplocale.c | 14 ++++++++++++++ locale/tst-locname.c | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 locale/tst-duplocale.c create mode 100644 locale/tst-locname.c diff --git a/locale/tst-duplocale.c b/locale/tst-duplocale.c new file mode 100644 index 0000000000..53e5fbb8fe --- /dev/null +++ b/locale/tst-duplocale.c @@ -0,0 +1,14 @@ +#include +#include + +static int +do_test (void) +{ + locale_t d = duplocale (LC_GLOBAL_LOCALE); + if (d != (locale_t) 0) + freelocale (d); + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/locale/tst-locname.c b/locale/tst-locname.c new file mode 100644 index 0000000000..7eb71adfd8 --- /dev/null +++ b/locale/tst-locname.c @@ -0,0 +1,20 @@ +#include +#include +#include +#include + +static int +do_test (void) +{ + const char *s = nl_langinfo (_NL_LOCALE_NAME (LC_CTYPE)); + if (s == NULL || strcmp (s, "C") != 0) + { + printf ("incorrect locale name returned: %s, expected \"C\"\n", s); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" From b12103e146512f80531ccced34ec8f106d3cec66 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 17 Nov 2009 16:24:26 -0800 Subject: [PATCH 21/29] Whitespace fixes. (cherry picked from commit 3933378fd3cbe49c1e0ca42844f959eb12f05f60) --- posix/bug-regex30.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posix/bug-regex30.c b/posix/bug-regex30.c index ef2bd76eba..43df64d9d3 100644 --- a/posix/bug-regex30.c +++ b/posix/bug-regex30.c @@ -34,7 +34,7 @@ struct regmatch_t rm[5]; } tests[] = { /* U+0413 \xd0\x93 CYRILLIC CAPITAL LETTER GHE - U+0420 \xd0\xa0 CYRILLIC CAPITAL LETTER ER + U+0420 \xd0\xa0 CYRILLIC CAPITAL LETTER ER U+0430 \xd0\xb0 CYRILLIC SMALL LETTER A U+0433 \xd0\xb3 CYRILLIC SMALL LETTER GHE U+0440 \xd1\x80 CYRILLIC SMALL LETTER ER @@ -83,7 +83,7 @@ do_test (void) for (n = 0; n < tests[i].nmatch; ++n) if (rm[n].rm_so != tests[i].rm[n].rm_so - || rm[n].rm_eo != tests[i].rm[n].rm_eo) + || rm[n].rm_eo != tests[i].rm[n].rm_eo) { if (tests[i].rm[n].rm_so == -1 && tests[i].rm[n].rm_eo == -1) break; From 488e337a17866ebdb9ca6a07f91fc9fcf9f1c3db Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 19 Nov 2009 10:03:46 -0800 Subject: [PATCH 22/29] Avoid warnings in CPU_* macros when using const bitsets. (cherry picked from commit 03ebadd9eaa4663f58bd3fa6fe8283f255925632) --- ChangeLog | 8 ++++++++ sysdeps/unix/sysv/linux/bits/sched.h | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index bbc9eb0b47..34d486ae26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-11-19 Ulrich Drepper + + [BZ #10918] + * sysdeps/unix/sysv/linux/bits/sched.h (__CPU_ISSET_S): Use __const + in cast to not throw away const-ness of parameters. + (__CPU_EQUAL_S): Likewise. + (__CPU_OP_S): Likewise. + 2009-11-17 Paolo Bonzini * posix/bug-regex30.c: New file. diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h index 95d05b4ab2..18269a99b9 100644 --- a/sysdeps/unix/sysv/linux/bits/sched.h +++ b/sysdeps/unix/sysv/linux/bits/sched.h @@ -1,6 +1,6 @@ /* Definitions of constants and data structure for POSIX 1003.1b-1993 scheduling interface. - Copyright (C) 1996-1999,2001-2003,2005,2006,2007,2008 + Copyright (C) 1996-1999,2001-2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -154,7 +154,7 @@ typedef struct (__extension__ \ ({ size_t __cpu = (cpu); \ __cpu < 8 * (setsize) \ - ? ((((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \ + ? ((((__const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \ & __CPUMASK (__cpu))) != 0 \ : 0; })) @@ -167,8 +167,8 @@ typedef struct # else # define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \ (__extension__ \ - ({ __cpu_mask *__arr1 = (cpusetp1)->__bits; \ - __cpu_mask *__arr2 = (cpusetp2)->__bits; \ + ({ __const __cpu_mask *__arr1 = (cpusetp1)->__bits; \ + __const __cpu_mask *__arr2 = (cpusetp2)->__bits; \ size_t __imax = (setsize) / sizeof (__cpu_mask); \ size_t __i; \ for (__i = 0; __i < __imax; ++__i) \ @@ -180,8 +180,8 @@ typedef struct # define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \ (__extension__ \ ({ cpu_set_t *__dest = (destset); \ - __cpu_mask *__arr1 = (srcset1)->__bits; \ - __cpu_mask *__arr2 = (srcset2)->__bits; \ + __const __cpu_mask *__arr1 = (srcset1)->__bits; \ + __const __cpu_mask *__arr2 = (srcset2)->__bits; \ size_t __imax = (setsize) / sizeof (__cpu_mask); \ size_t __i; \ for (__i = 0; __i < __imax; ++__i) \ From 16b583ea7ec0b96c8908e6c5418836f74554329a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 19 Nov 2009 10:29:16 -0800 Subject: [PATCH 23/29] Fix getwc* and putwc* on non-wide streams. (cherry picked from commit df1934daa7788ca5f19d82efb02cdf9b9c495b1a) --- ChangeLog | 5 +++++ libio/libio.h | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34d486ae26..b6f77ff8ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-11-19 Ulrich Drepper + [BZ #10958] + * libio/libio.h (_IO_getwc_unlocked): Check for _wide_data being + initialized before using it. + (_IO_putwc_unlocked): Likewise. + [BZ #10918] * sysdeps/unix/sysv/linux/bits/sched.h (__CPU_ISSET_S): Use __const in cast to not throw away const-ness of parameters. diff --git a/libio/libio.h b/libio/libio.h index 643812f72b..3c9f2bd3e8 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1995,1997-2006,2007 Free Software Foundation, Inc. +/* Copyright (C) 1991-1995,1997-2006,2007,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Per Bothner . @@ -442,13 +442,15 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t); #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T # define _IO_getwc_unlocked(_fp) \ - (_IO_BE ((_fp)->_wide_data->_IO_read_ptr >= (_fp)->_wide_data->_IO_read_end,\ - 0) \ + (_IO_BE ((_fp)->_wide_data == NULL \ + || ((_fp)->_wide_data->_IO_read_ptr \ + >= (_fp)->_wide_data->_IO_read_end), 0) \ ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++) # define _IO_putwc_unlocked(_wch, _fp) \ - (_IO_BE ((_fp)->_wide_data->_IO_write_ptr \ - >= (_fp)->_wide_data->_IO_write_end, 0) \ - ? __woverflow (_fp, _wch) \ + (_IO_BE ((_fp)->_wide_data == NULL \ + || ((_fp)->_wide_data->_IO_write_ptr \ + >= (_fp)->_wide_data->_IO_write_end), 0) \ + ? __woverflow (_fp, _wch) \ : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch))) #endif From 1bc1954c735788ae9e7f954e18cf39a22f964d06 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 17 Nov 2009 18:04:51 -0800 Subject: [PATCH 24/29] Fix sync_file_range on ppc/ppc64. I've noticed that sync_file_range is a stub on ppc/ppc64. The kernel on these arches provides sync_file_range2 syscall with swapped parameters. The following completely untested patch ought to fix this. (cherry picked from commit 8ad81b316bc158746aee18aa7d7df44d3eb61871) --- ChangeLog | 8 ++++ .../linux/powerpc/powerpc64/sync_file_range.c | 44 +++++++++++++++++++ sysdeps/unix/sysv/linux/sync_file_range.c | 10 ++++- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/sync_file_range.c diff --git a/ChangeLog b/ChangeLog index b6f77ff8ed..34212ee6c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-11-16 Jakub Jelinek + + * sysdeps/unix/sysv/linux/sync_file_range.c (sync_file_range): + Implement using sync_file_range2 syscall if __NR_sync_file_range2 + is defined. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/sync_file_range.c: New + file. + 2009-11-19 Ulrich Drepper [BZ #10958] diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sync_file_range.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sync_file_range.c new file mode 100644 index 0000000000..1ca4ce66df --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sync_file_range.c @@ -0,0 +1,44 @@ +/* Selective file content synch'ing. + Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include +#include + + +#if defined __NR_sync_file_range2 +int +sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags) +{ + return INLINE_SYSCALL (sync_file_range2, 4, fd, flags, from, to); +} +#else +int +sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (sync_file_range) + +# include +#endif diff --git a/sysdeps/unix/sysv/linux/sync_file_range.c b/sysdeps/unix/sysv/linux/sync_file_range.c index 4e267a1602..41e08e0281 100644 --- a/sysdeps/unix/sysv/linux/sync_file_range.c +++ b/sysdeps/unix/sysv/linux/sync_file_range.c @@ -1,5 +1,5 @@ /* Selective file content synch'ing. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -34,6 +34,14 @@ sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags) __LONG_LONG_PAIR ((long) (to >> 32), (long) to), flags); } +#elif defined __NR_sync_file_range2 +int +sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags) +{ + return INLINE_SYSCALL (sync_file_range2, 6, fd, flags, + __LONG_LONG_PAIR ((long) (from >> 32), (long) from), + __LONG_LONG_PAIR ((long) (to >> 32), (long) to)); +} #else int sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags) From 8d7c09b162cd1687e21549f9aaaa3d4a9b39735c Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 20 Nov 2009 08:30:20 -0800 Subject: [PATCH 25/29] Properly recover from shorter read. (cherry picked from commit 66221417957963c1d2df8d79f43573e328df2275) --- ChangeLog | 6 ++++++ sysdeps/ia64/memchr.S | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 34212ee6c8..e0fd11c15e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-11-18 H.J. Lu + + [BZ #10162] + * sysdeps/ia64/memchr.S: Don't use a simple loop on data shorter + than software pipeline. Properly recover from shorter read. + 2009-11-16 Jakub Jelinek * sysdeps/unix/sysv/linux/sync_file_range.c (sync_file_range): diff --git a/sysdeps/ia64/memchr.S b/sysdeps/ia64/memchr.S index cd062b2dd5..cdd71ca5a5 100644 --- a/sysdeps/ia64/memchr.S +++ b/sysdeps/ia64/memchr.S @@ -126,7 +126,16 @@ ENTRY(__memchr) br.ret.sptk.many b0 .recovery: - adds ret0 = -((MEMLAT + 1) * 8), ret0;; +#if MEMLAT != 6 +# error "MEMLAT must be 6!" +#endif +(p[MEMLAT-6]) add ret0 = -8, ret0;; +(p[MEMLAT-5]) add ret0 = -8, ret0;; +(p[MEMLAT-4]) add ret0 = -8, ret0;; +(p[MEMLAT-3]) add ret0 = -8, ret0;; +(p[MEMLAT-2]) add ret0 = -8, ret0;; +(p[MEMLAT-1]) add ret0 = -8, ret0;; +(p[MEMLAT]) add ret0 = -8, ret0;; (p[MEMLAT+1]) add ret0 = -8, ret0;; (p[MEMLAT+2]) add ret0 = -8, ret0;; .l4: From 8757dec424e2fc887623104565243bdd66cd609b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 24 Nov 2009 11:17:06 -0800 Subject: [PATCH 26/29] Fix startup to security-relevant statically linked binaries. Before the change they crash on startup. Perform IREL relocations earlier to prevent this. (cherry picked from commit 1c3c269b55c84c29ec1e2c70f122c5e33fef4257) --- ChangeLog | 7 +++++++ csu/elf-init.c | 21 +++++++++++++++------ csu/libc-start.c | 6 ++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0fd11c15e..3cae5d1cf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-11-24 Ulrich Drepper + + * csu/elf-init.c (__libc_csu_irel): New function. Code to perform + irel relocations split out from... + (__libc_csu_init): ...here. + * csu/libc-start.c [!SHARED]: Call __libc_csu_irel early. + 2009-11-18 H.J. Lu [BZ #10162] diff --git a/csu/elf-init.c b/csu/elf-init.c index 1d2df62ca3..1e3d6d6cd8 100644 --- a/csu/elf-init.c +++ b/csu/elf-init.c @@ -72,15 +72,14 @@ extern void _fini (void); /* These functions are passed to __libc_start_main by the startup code. These get statically linked into each program. For dynamically linked programs, this module will come from libc_nonshared.a and differs from - the libc.a module in that it doesn't call the preinit array. */ + the libc.a module in that it doesn't call the preinit array and performs + explicit IREL{,A} relocations. */ -void -__libc_csu_init (int argc, char **argv, char **envp) -{ - /* For dynamically linked executables the preinit array is executed by - the dynamic linker (before initializing any shared object. */ #ifndef LIBC_NONSHARED +void +__libc_csu_irel (void) +{ # ifdef USE_MULTIARCH # ifdef ELF_MACHINE_IRELA { @@ -98,7 +97,17 @@ __libc_csu_init (int argc, char **argv, char **envp) } # endif # endif +} +#endif + +void +__libc_csu_init (int argc, char **argv, char **envp) +{ + /* For dynamically linked executables the preinit array is executed by + the dynamic linker (before initializing any shared object. */ + +#ifndef LIBC_NONSHARED /* For static executables, preinit happens right before init. */ { const size_t size = __preinit_array_end - __preinit_array_start; diff --git a/csu/libc-start.c b/csu/libc-start.c index 80b672f88d..dc7ca55f09 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -24,6 +24,9 @@ #include extern void __libc_init_first (int argc, char **argv, char **envp); +#ifndef SHARED +extern void __libc_csu_irel (void); +#endif extern int __libc_multiple_libcs; @@ -134,6 +137,9 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), } # endif + /* Performe IREL{,A} relocations. */ + __libc_csu_irel (); + /* Initialize the thread library at least a bit since the libgcc functions are using thread functions if these are available and we need to setup errno. */ From f3a93a0820949f67c95eda882e4f4331ad26accd Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 25 Nov 2009 14:04:18 +0100 Subject: [PATCH 27/29] Prevent unintended file desriptor leak in grantpt. The pt_chown program is completely transparently called. It might not be able to live with the various file descriptors the program has open at the time of the call (e.g., under SELinux). Close all but the needed descriptor and connect stdin, stdout, and stderr with /dev/null. pt_chown shouldn't print anything when called to do real work. (cherry picked from commit 139ee080b6b428240bf49f3e6361f3ac729f891a) --- ChangeLog | 6 +++++ login/programs/pt_chown.c | 5 ++-- sysdeps/unix/grantpt.c | 4 +++ sysdeps/unix/sysv/linux/grantpt.c | 42 +++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/grantpt.c diff --git a/ChangeLog b/ChangeLog index 3cae5d1cf1..93c511c3f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-11-24 Ulrich Drepper + * sysdeps/unix/grantpt.c (grantpt): Use CLOSE_ALL_FDS is available + before the exec. + * sysdeps/unix/sysv/linux/grantpt.c: New file. + * login/programs/pt_chown.c (main): Don't print message on errors + when doing real work. + * csu/elf-init.c (__libc_csu_irel): New function. Code to perform irel relocations split out from... (__libc_csu_init): ...here. diff --git a/login/programs/pt_chown.c b/login/programs/pt_chown.c index 7e279a5f3b..4c36f2ceac 100644 --- a/login/programs/pt_chown.c +++ b/login/programs/pt_chown.c @@ -154,8 +154,7 @@ main (int argc, char *argv[]) # define ncap_list (sizeof (cap_list) / sizeof (cap_list[0])) cap_t caps = cap_init (); if (caps == NULL) - error (FAIL_ENOMEM, errno, - _("Failed to initialize drop of capabilities")); + return FAIL_ENOMEM; /* There is no reason why these should not work. */ cap_set_flag (caps, CAP_PERMITTED, ncap_list, cap_list, CAP_SET); @@ -166,7 +165,7 @@ main (int argc, char *argv[]) cap_free (caps); if (__builtin_expect (res != 0, 0)) - error (FAIL_EXEC, errno, _("cap_set_proc failed")); + return FAIL_EXEC; } #endif diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c index 8c299e9147..b02bf7cccf 100644 --- a/sysdeps/unix/grantpt.c +++ b/sysdeps/unix/grantpt.c @@ -190,6 +190,10 @@ grantpt (int fd) if (__dup2 (fd, PTY_FILENO) < 0) _exit (FAIL_EBADF); +#ifdef CLOSE_ALL_FDS + CLOSE_ALL_FDS (); +#endif + execle (_PATH_PT_CHOWN, basename (_PATH_PT_CHOWN), NULL, NULL); _exit (FAIL_EXEC); } diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c new file mode 100644 index 0000000000..6305ed4944 --- /dev/null +++ b/sysdeps/unix/sysv/linux/grantpt.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "not-cancel.h" +#include "pty-private.h" + + +/* Close all file descriptors except the one specified. */ +static void +close_all_fds (void) +{ + DIR *dir = opendir ("/proc/self/fd"); + if (dir != NULL) + { + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (isdigit (d->d_name[0])) + { + char *endp; + long int fd = strtol (d->d_name, &endp, 10); + if (*endp == '\0' && fd != PTY_FILENO && fd != dirfd (dir)) + close_not_cancel_no_status (fd); + } + + closedir (dir); + + int nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_RDONLY); + assert (nullfd == STDIN_FILENO); + nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_WRONLY); + assert (nullfd == STDOUT_FILENO); + __dup2 (STDOUT_FILENO, STDERR_FILENO); + } +} +#define CLOSE_ALL_FDS() close_all_fds() + +#include From 64d61e9dc302aaa22000f9b03cce86d11a5e910d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 24 Nov 2009 18:47:26 -0800 Subject: [PATCH 28/29] Avoid local PLTs. (cherry picked from commit 0f622686af3ae5a8f03dae886b08c260b38bda16) --- sysdeps/unix/sysv/linux/grantpt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c index 6305ed4944..f2fc60f83a 100644 --- a/sysdeps/unix/sysv/linux/grantpt.c +++ b/sysdeps/unix/sysv/linux/grantpt.c @@ -15,11 +15,11 @@ static void close_all_fds (void) { - DIR *dir = opendir ("/proc/self/fd"); + DIR *dir = __opendir ("/proc/self/fd"); if (dir != NULL) { struct dirent64 *d; - while ((d = readdir64 (dir)) != NULL) + while ((d = __readdir64 (dir)) != NULL) if (isdigit (d->d_name[0])) { char *endp; @@ -28,7 +28,7 @@ close_all_fds (void) close_not_cancel_no_status (fd); } - closedir (dir); + __closedir (dir); int nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_RDONLY); assert (nullfd == STDIN_FILENO); From 20af204581e1ba42738c1bfb69cc2f5350f4ffa4 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Fri, 27 Nov 2009 21:37:30 -0800 Subject: [PATCH 29/29] Fix infloop in __pthread_disable_asynccancel on x86_64 (cherry picked from commit b55ec98c6490b944593243c7da54dda1796e3f84) --- nptl/ChangeLog | 5 +++++ nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 0aaaa3f7b9..08a55ee5c8 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,8 @@ +2009-11-27 Andreas Schwab + + * sysdeps/unix/sysv/linux/x86_64/cancellation.S: Reload + THREAD_SELF->cancelhandling after returning from futex call. + 2009-11-03 Andreas Schwab [BZ #4457] diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S index 0d48ec6fcd..680696200a 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S @@ -96,8 +96,8 @@ ENTRY(__pthread_disable_asynccancel) cmpxchgl %r11d, %fs:CANCELHANDLING jnz 2b -3: movl %r11d, %eax - andl $(TCB_CANCELING_BITMASK|TCB_CANCELED_BITMASK), %eax + movl %r11d, %eax +3: andl $(TCB_CANCELING_BITMASK|TCB_CANCELED_BITMASK), %eax cmpl $TCB_CANCELING_BITMASK, %eax je 4f 1: ret @@ -111,5 +111,6 @@ ENTRY(__pthread_disable_asynccancel) addq $CANCELHANDLING, %rdi LOAD_PRIVATE_FUTEX_WAIT (%esi) syscall + movl %fs:CANCELHANDLING, %eax jmp 3b END(__pthread_disable_asynccancel)