From aoliva@redhat.com Mon Feb 7 08:37:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Mon, 07 Feb 2005 08:37:00 -0000 Subject: getting glibc to compile with GCC CVS mainline Message-ID: Here are patches to fix incompatibilities with the current CVS version of GCC. The first addresses a problem that causes GCC to reject auto nested functions that are declared but not defined. The second addresses a problem of trying to construct array types of incomplete types. Although this is well-formed C++, it's ill-formed C, even if the type would decay to pointer to incomplete type, which is well-formed in both languages. There were two occurrences of this error in glibc. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-unused-nested-auto.patch Type: text/x-patch Size: 1833 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-array-incomplete-type.patch Type: text/x-patch Size: 2028 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Mon Feb 7 08:39:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Mon, 07 Feb 2005 08:39:00 -0000 Subject: add manual/dir-add.texi to .cvsignore Message-ID: It's a bit annoying that, after a glibc build, you end up with a file in the build tree that is marked as unknown by CVS. This patch fixes this. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-manual-ignore-dir-add.patch Type: text/x-patch Size: 472 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Mon Feb 7 08:46:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Mon, 07 Feb 2005 08:46:00 -0000 Subject: __librt_multiple_threads for nptl? Message-ID: No current ports need this (not even the FR-V port, that has recently been converted to use info from the TCB instead of relying on this global var), but it was surprising to me that any DTV_AT_TP port is now required to use this trick. It sure is a tiny little bit more efficient for uses within librt, but what if it required an ABI change? I was a bit concerned about breaking ABI compatibility changing FR-V to use multiple_threads in the TCB, as opposed to using this variable, but I'm now convinced it's not an issue. Am I mistake? Anyhow, how about installing this patch, or at least enabling a port to define some macro to get this variable defined in librt? Some mq functions definitely need it. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-nptl-librt-multiple-threads.patch Type: text/x-patch Size: 1298 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Mon Feb 7 09:15:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Mon, 07 Feb 2005 09:15:00 -0000 Subject: Fujitsu FR-V port (linuxthreads and nptl included) In-Reply-To: References: Message-ID: On Feb 3, 2005, Alexandre Oliva wrote: > This patch is a first cut at contributing the glibc port to the > Fujitsu FR-V architecture. Support has been recently contributed to > GCC, binutils and Linux. > One of the distinguishing features of this port is that different > sections of executables (and shared libraries) can be loaded anywhere > in the address space. The ABI was originally designed for uCLinux, > where being able to relocate text and data segments by different > amounts was essential to enable sharing of text segments among > multiple processes. The kernel passes to the executable's entry point > a load map that maps vaddrs from the executable to memory addresses > where they were mapped. Ditto for an interpreter, if there is one. > As a result, the concept of a base load address doesn't make sense, > and an operation more complex than a simple addition is necessary to > map a vaddr to a memory address. > Although MMU Linux doesn't need the ability to relocate segments by > different amounts to enable sharing of read-only segments, we figured > FR-V already had a sufficient number of ABIs, and it made little sense > to design yet another ABI for the Linux port, and being able to share > some object code between frv-uclinux and frv-linux-gnu was certainly a > plus. Unfortunately, this means we had to turn a number of cases that > relied on the existence of a single base load address per module into > use of macros that, on all other ports, would still perform just an > addition, but on frv-linux-gnu, would perform the more complex > operation, even though all ld.so-loaded modules are guaranteed to be > laid out in such a way that a regular base load address would do, and > even kernel-loaded binaries are also very likely to be laid out in the > traditional way. We went for ABI compliance over efficiency in this > case. Too bad. > The TLS ABI extension also has some novelties that required a bit of > changes in common code. One of the novelties is that __tls_get_addr() > needs not be exported: instead of calling this function directly, code > that may require dynamic TLS resolution loads the address of the > function to call directly from the TLS descriptor. This in turn > enables load-time short-circuiting of potentially-expensive calls to > __tls_get_addr() for variables that turn out to be in static TLS, > enabling run-time optimization of the General Dynamic model to > something pretty close to Initial Exec. It also enables lazy handling > of General Dynamic relocations referencing TLS variables, but this was > not implemented yet. > The other novelty is that the offset from the (biased) TLS pointer to > the TLS block for the main executable, if there is one, is fixed by > the ABI, which makes the Local Exec model extremely efficient. This last bit, in turn, required a change to the TLS offset assignment that can benefit other ports. The existing TLS offset assignment code assigns all offsets starting at zero, with the maximum alignment required by the static TLS blocks. Only then does it take TLS_PRE_TCB_SIZE into account, rounding it up to the alignment of the static TLS block, leaving whatever padding required by this operation unused. The change introduced to enable the offset from the TCB to the executable TLS block to be constant enabled the pre-tcb size and alignment requirements to be taken into account early, such that we can use whatever padding they might require for TLS blocks. This is particularly useful in case some TLS segment has a very large alignment requirement. Also, if a TLS segment has alignment requirements no stricter than those of the TCB, and the pre-TCB block has wider alignment requirements than the TCB, the current code will not obtain the correct alignment for the pre-TCB block. This actually hits in current code, because the TCB often has 16-byte alignment, and the pre-TCB block is declared as requiring 32-byte alignment. The change to implement this fix was implemented by adding an argument to a function exported by ld.so to libpthread.so. I'm not sure this is regarded as an ABI break, since it's an internal function. It would be simple enough to introduce a separate entry point to obtain the same information, or version the function so as to make incompatibilities explicit. Opinions? The first patch below contains only the changes to generic code required by the FR-V port. Unfortunately a lot of recent code was added without thought regarding ports maintained in the ports tree. The pltenter/pltexit changes were particularly unfortunate in this regard, and it would surely be possible to have introduced them in such a way that a port would have to introduce a single header file containing a few more macro definitions. Oh, well... The second patch below is for the ports/ tree, containing all the changes to support frv-linux-gnu that didn't have to be made to generic code. Roland, may I check it in? I'm a bit concerned that some of the changes to generic code (e.g., link.h, DL_RELOC_ADDR and the other macros required by the aggregate type for l_addr) may face significant resistance to get in the tree, so I'm trying to think of some way to include the patches for the generic code required by FR-V in the ports/ tree, such that someone who got ports/ could apply teh patch and then build the port. Thoughts? -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-frv-20050206.patch.bz2 Type: application/x-bzip2 Size: 15264 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-frv-20050206-port.patch.bz2 Type: application/x-bzip2 Size: 44941 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From jakub@redhat.com Mon Feb 7 10:17:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 07 Feb 2005 10:17:00 -0000 Subject: [PATCH] Fix pthread_key_destroy before first pthread_create Message-ID: <20050207101722.GZ4777@sunsite.mff.cuni.cz> Hi! linuxthreads fails nptl/tst-tsd1.c and it appears to be a regression from the 2.2.4 days introduced by the 2001-11-28 bugfix, so something that we should IMHO fix. 2005-02-07 Jakub Jelinek * specific.c (pthread_key_delete): If pthread_create has not been called yet, clear p_specific for the current thread. * Makefile (tests): Add tst-tsd1. * tst-tsd1.c: New test. --- libc/linuxthreads/specific.c.jj 2004-05-07 14:32:11.000000000 +0200 +++ libc/linuxthreads/specific.c 2005-02-07 10:47:37.998832101 +0100 @@ -104,15 +104,16 @@ int pthread_key_delete(pthread_key_t key that if the key is reallocated later by pthread_key_create, its associated values will be NULL in all threads. - Do nothing if no threads have been created yet. */ + If no threads have been created yet, clear it just in the + current thread. */ + struct pthread_key_delete_helper_args args; + args.idx1st = key / PTHREAD_KEY_2NDLEVEL_SIZE; + args.idx2nd = key % PTHREAD_KEY_2NDLEVEL_SIZE; if (__pthread_manager_request != -1) { - struct pthread_key_delete_helper_args args; struct pthread_request request; - args.idx1st = key / PTHREAD_KEY_2NDLEVEL_SIZE; - args.idx2nd = key % PTHREAD_KEY_2NDLEVEL_SIZE; args.self = 0; request.req_thread = self; @@ -124,6 +125,11 @@ int pthread_key_delete(pthread_key_t key (char *) &request, sizeof(request))); suspend(self); } + else + { + if (self->p_specific[args.idx1st] != NULL) + self->p_specific[args.idx1st][args.idx2nd] = NULL; + } pthread_mutex_unlock(&pthread_keys_mutex); return 0; --- libc/linuxthreads/Makefile.jj 2005-01-08 16:50:22.000000000 +0100 +++ libc/linuxthreads/Makefile 2005-02-07 10:53:30.469967029 +0100 @@ -1,4 +1,4 @@ -# Copyright (C) 1996-2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 1996-2003, 2004, 2005 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 @@ -111,7 +111,7 @@ tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex17 ex18 tst-cancel tst-context bug-sleep \ tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \ tst-cancel6 tst-cancel7 tst-cancel8 tst-popen tst-popen2 tst-attr1 \ - tst-stack1 tst-align + tst-stack1 tst-align tst-tsd1 test-srcs = tst-signal # These tests are linked with libc before libpthread tests-reverse += tst-cancel5 --- libc/linuxthreads/tst-tsd1.c.jj 2005-02-07 10:52:59.181622245 +0100 +++ libc/linuxthreads/tst-tsd1.c 2005-02-07 10:53:06.166359576 +0100 @@ -0,0 +1,118 @@ +/* Copyright (C) 2002, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + 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 + + +static int +do_test (void) +{ + pthread_key_t key1; + pthread_key_t key2; + void *value; + int result = 0; + int err; + + err = pthread_key_create (&key1, NULL); + if (err != 0) + { + printf ("1st key_create failed: %s\n", strerror (err)); + return 1; + } + + /* Initial value must be NULL. */ + value = pthread_getspecific (key1); + if (value != NULL) + { + puts ("1st getspecific != NULL"); + result = 1; + } + + err = pthread_setspecific (key1, (void *) -2l); + if (err != 0) + { + printf ("1st setspecific failed: %s\n", strerror (err)); + return 1; + } + + value = pthread_getspecific (key1); + if (value == NULL) + { + puts ("2nd getspecific == NULL\n"); + result = 1; + } + else if (value != (void *) -2l) + { + puts ("2nd getspecific != -2l\n"); + result = 1; + } + + err = pthread_setspecific (key1, (void *) -3l); + if (err != 0) + { + printf ("2nd setspecific failed: %s\n", strerror (err)); + return 1; + } + + value = pthread_getspecific (key1); + if (value == NULL) + { + puts ("3rd getspecific == NULL\n"); + result = 1; + } + else if (value != (void *) -3l) + { + puts ("3rd getspecific != -2l\n"); + result = 1; + } + + err = pthread_key_delete (key1); + if (err != 0) + { + printf ("key_delete failed: %s\n", strerror (err)); + result = 1; + } + + + err = pthread_key_create (&key2, NULL); + if (err != 0) + { + printf ("2nd key_create failed: %s\n", strerror (err)); + return 1; + } + + if (key1 != key2) + puts ("key1 != key2; no more tests performed"); + else + { + value = pthread_getspecific (key2); + if (value != NULL) + { + puts ("4th getspecific != NULL"); + result = 1; + } + } + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" Jakub From jakub@redhat.com Mon Feb 7 10:49:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 07 Feb 2005 10:49:00 -0000 Subject: [PATCH] Fix segfault in open_path Message-ID: <20050207104949.GA4777@sunsite.mff.cuni.cz> Hi! Running: #include #include int main (void) { chroot ("/tmp/foobar"); dlopen ("libnss_compat.so.2", RTLD_LAZY); } as root after rm -rf /tmp/foobar; mkdir /tmp/foobar results in a segfault. The problem is that rtld_search_dirs are attribute_relro, but open_path if it doesn't find any of the standard search directories wants to clear it. One solution would be to remove attribute_relro from rtld_search_dirs, but that's a variable that IMHO should be protected from changing, so this patch just avoids writing into it instead. Because standard search paths are almost always present and only in very rare situations like this chroot testcase none of them is, I think letting ld.so in this case cycle through open_path and see that all dirs in it are nonexisting is not a big deal. rtld_search_dirs.malloced is 0, so it is not freed either. 2005-01-07 Jakub Jelinek * elf/dl-load.c (open_path): If rtld_search_dirs is in RELRO segment, avoid writing to it if none of the standard search directories exist. --- libc/elf/dl-load.c.jj 2005-01-19 14:12:38.000000000 +0100 +++ libc/elf/dl-load.c 2005-02-07 11:24:58.611074914 +0100 @@ -1876,7 +1876,12 @@ open_path (const char *name, size_t name must not be freed using the general free() in libc. */ if (sps->malloced) free (sps->dirs); - sps->dirs = (void *) -1; +#ifdef HAVE_Z_RELRO + /* rtld_search_dirs is attribute_relro, therefore avoid writing + into it. */ + if (sps != &rtld_search_dirs) +#endif + sps->dirs = (void *) -1; } return -1; Jakub From jakub@redhat.com Mon Feb 7 13:18:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 07 Feb 2005 13:18:00 -0000 Subject: [PATCH] Fix __nscd_get{grouplist,ai} Message-ID: <20050207131828.GB4777@sunsite.mff.cuni.cz> Hi! If nscd is running, but enable-cache group no then initgroups will set just the group passed to it as second argument and not the other ones. I guess when host caching is disabled and getaddrinfo is used, the result will be similar. Furthermore, running nscd -d with one of the 3 caches disabled and Ctrl-Cing it results in a segfault, also fixed by the patch below. 2005-02-07 Jakub Jelinek * nscd/nscd.c (termination_handler): Avoid segfault if some database is not enabled. * nscd/nscd_getai.c (__nscd_getai): If ai_resp->found == -1, set __nss_not_use_nscd_hosts and return -1. * nscd/nscd_initgroups.c (__nscd_getgrouplist): If initgr_resp->found == -1, set __nss_not_use_nscd_group and return -1. Avoid leaking sockets. --- libc/nscd/nscd.c.jj 2005-01-19 14:12:59.000000000 +0100 +++ libc/nscd/nscd.c 2005-02-07 13:31:03.554553157 +0100 @@ -442,6 +442,9 @@ termination_handler (int signum) /* Synchronize memory. */ for (int cnt = 0; cnt < lastdb; ++cnt) { + if (!dbs[cnt].enabled) + continue; + /* Make sure nobody keeps using the database. */ dbs[cnt].head->timestamp = 0; --- libc/nscd/nscd_initgroups.c.jj 2004-11-10 10:30:32.000000000 +0100 +++ libc/nscd/nscd_initgroups.c 2005-02-07 14:01:57.271312190 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2004. @@ -75,7 +75,7 @@ __nscd_getgrouplist (const char *user, g sizeof (initgr_resp_mem)); if (sock == -1) { - /* nscd not running or wrong version or hosts caching disabled. */ + /* nscd not running or wrong version. */ __nss_not_use_nscd_group = 1; goto out; } @@ -101,7 +101,7 @@ __nscd_getgrouplist (const char *user, g (initgr_resp->ngrps + 1) * sizeof (gid_t)); if (newp == NULL) /* We cannot increase the buffer size. */ - goto out; + goto out_close; *groupsp = newp; *size = initgr_resp->ngrps + 1; @@ -125,6 +125,13 @@ __nscd_getgrouplist (const char *user, g } else { + if (__builtin_expect (initgr_resp->found == -1, 0)) + { + /* The daemon does not cache this database. */ + __nss_not_use_nscd_group = 1; + goto out_close; + } + /* No group found yet. */ retval = 0; @@ -143,6 +150,7 @@ __nscd_getgrouplist (const char *user, g (*groupsp)[retval++] = group; } + out_close: if (sock != -1) close_not_cancel_no_status (sock); out: --- libc/nscd/nscd_getai.c.jj 2004-11-25 14:35:57.000000000 +0100 +++ libc/nscd/nscd_getai.c 2005-02-07 14:02:38.952871053 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2004. @@ -78,7 +78,7 @@ __nscd_getai (const char *key, struct ns sizeof (ai_resp_mem)); if (sock == -1) { - /* nscd not running or wrong version or hosts caching disabled. */ + /* nscd not running or wrong version. */ __nss_not_use_nscd_hosts = 1; goto out; } @@ -151,6 +151,13 @@ __nscd_getai (const char *key, struct ns } else { + if (__builtin_expect (ai_resp->found == -1, 0)) + { + /* The daemon does not cache this database. */ + __nss_not_use_nscd_hosts = 1; + goto out_close; + } + /* Store the error number. */ *h_errnop = ai_resp->error; Jakub From jakub@redhat.com Mon Feb 7 18:36:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 07 Feb 2005 18:36:00 -0000 Subject: [PATCH] Cosmetic fix for nscd.init Message-ID: <20050207183633.GC4777@sunsite.mff.cuni.cz> Hi! service nscd reload doesn't print what it is actually doing, just [ OK ] or [ FAILED ] etc. and doesn't print a newline after that status string. Fixed thusly: 2005-02-07 Jakub Jelinek * nscd/nscd.init (reload): Print Reloading nscd: before and a newline after the status string printed by killproc. --- libc/nscd/nscd.init.jj 2004-10-18 10:20:55.000000000 +0200 +++ libc/nscd/nscd.init 2005-02-07 19:32:46.000000000 +0100 @@ -88,9 +88,9 @@ case "$1" in RETVAL=$? ;; status) - status nscd + status nscd RETVAL=$? - ;; + ;; restart) restart RETVAL=$? @@ -100,9 +100,11 @@ case "$1" in RETVAL=$? ;; reload) - killproc /usr/sbin/nscd -HUP + echo -n $"Reloading $prog: " + killproc /usr/sbin/nscd -HUP RETVAL=$? - ;; + echo + ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" RETVAL=1 Jakub From roland@redhat.com Mon Feb 7 19:32:00 2005 From: roland@redhat.com (Roland McGrath) Date: Mon, 07 Feb 2005 19:32:00 -0000 Subject: __librt_multiple_threads for nptl? In-Reply-To: Alexandre Oliva's message of , 7 February 2005 06:45:52 -0200 Message-ID: <200502071932.j17JW0F2026628@magilla.sf.frob.com> > I was a bit concerned about breaking ABI compatibility changing FR-V > to use multiple_threads in the TCB, as opposed to using this > variable, but I'm now convinced it's not an issue. Am I mistake? You are talking about the private TCB contents. That is not part of any ABI except the GLIBC_PRIVATE interface between libc/ld.so/librt. We don't consider that an ABI change. From roland@redhat.com Mon Feb 7 19:37:00 2005 From: roland@redhat.com (Roland McGrath) Date: Mon, 07 Feb 2005 19:37:00 -0000 Subject: Fujitsu FR-V port (linuxthreads and nptl included) In-Reply-To: Alexandre Oliva's message of , 7 February 2005 07:15:20 -0200 Message-ID: <200502071936.j17Jaica026647@magilla.sf.frob.com> > The second patch below is for the ports/ tree, containing all the > changes to support frv-linux-gnu that didn't have to be made to > generic code. Roland, may I check it in? For additions of new port-specific files to the ports repository, we don't really have hard approval rules beyond the copyright assignment status. You are on the ACL for the whole ports repository. But, my opinion is that we shouldn't put a port in there when there is no branch in the main repository against which you can build it. i.e., let's get any generic changes worked out first. From drepper@redhat.com Mon Feb 7 22:55:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 07 Feb 2005 22:55:00 -0000 Subject: [PATCH] Fix __nscd_get{grouplist,ai} In-Reply-To: <20050207131828.GB4777@sunsite.mff.cuni.cz> References: <20050207131828.GB4777@sunsite.mff.cuni.cz> Message-ID: <4207F14C.3020102@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From kkojima@rr.iij4u.or.jp Tue Feb 8 04:34:00 2005 From: kkojima@rr.iij4u.or.jp (Kaz Kojima) Date: Tue, 08 Feb 2005 04:34:00 -0000 Subject: [PATCH] SH: Remove RESOLVE from dl-machine.h Message-ID: <20050208.133441.88023607.kkojima@rr.iij4u.or.jp> Hi, The appended patch removes RESOLVE from sh/dl-machine.h. Regards, kaz -- 2005-02-08 Kaz Kojima * sysdeps/sh/dl-machine.h (elf_machine_rela): Remove code using RESOLVE. diff -uprN ORIG/libc/sysdeps/sh/dl-machine.h LOCAL/libc/sysdeps/sh/dl-machine.h --- ORIG/libc/sysdeps/sh/dl-machine.h 2005-01-12 12:35:28.000000000 +0900 +++ LOCAL/libc/sysdeps/sh/dl-machine.h 2005-02-08 12:24:02.000000000 +0900 @@ -323,15 +323,9 @@ elf_machine_rela (struct link_map *map, else { const Elf32_Sym *const refsym = sym; -#ifndef RTLD_BOOTSTRAP struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type); - value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value; -#else - - value = RESOLVE (&sym, version, r_type); - value += sym->st_value; -#endif + value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value; value += reloc->r_addend; switch (r_type) From drepper@redhat.com Tue Feb 8 08:28:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 08 Feb 2005 08:28:00 -0000 Subject: [PATCH] SH: Remove RESOLVE from dl-machine.h In-Reply-To: <20050208.133441.88023607.kkojima@rr.iij4u.or.jp> References: <20050208.133441.88023607.kkojima@rr.iij4u.or.jp> Message-ID: <42087769.1070701@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From jakub@redhat.com Tue Feb 8 18:03:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 08 Feb 2005 18:03:00 -0000 Subject: [PATCH] Fix dl-load.c typo Message-ID: <20050208180324.GD4777@sunsite.mff.cuni.cz> Hi! Following typo seems to be the cause of: Didn't expect signal from child: got `Segmentation fault' make[2]: *** [/usr/src/libc/objl/elf/tst-tls9.out] Error 1 Didn't expect signal from child: got `Segmentation fault' make[2]: *** [/usr/src/libc/objl/elf/tst-tls4.out] Error 1 Didn't expect signal from child: got `Segmentation fault' make[2]: *** [/usr/src/libc/objl/elf/tst-tls5.out] Error 1 Didn't expect signal from child: got `Segmentation fault' make[2]: *** [/usr/src/libc/objl/elf/tst-tls7.out] Error 1 Didn't expect signal from child: got `Segmentation fault' Didn't expect signal from child: got `Segmentation fault' make[2]: *** [/usr/src/libc/objl/elf/tst-tls6.out] Error 1 make[2]: *** [/usr/src/libc/objl/elf/tst-tls8.out] Error 1 in linuxthreads build. The result is that _dl_tls_setup () is not called although it should. 2005-02-08 Jakub Jelinek * elf/dl-load.c (_dl_map_object_from_fd): Fix a typo. --- libc/elf/dl-load.c.jj 2005-02-08 17:24:04.000000000 +0100 +++ libc/elf/dl-load.c 2005-02-08 18:58:05.584415097 +0100 @@ -1084,7 +1084,7 @@ _dl_map_object_from_fd (const char *name } # ifdef SHARED - if (l->l_prev == NULL || (mode && __RTLD_AUDIT) != 0) + if (l->l_prev == NULL || (mode & __RTLD_AUDIT) != 0) /* We are loading the executable itself when the dynamic linker was executed directly. The setup will happen later. */ break; Jakub From drepper@redhat.com Tue Feb 8 21:40:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 08 Feb 2005 21:40:00 -0000 Subject: [PATCH] Fix dl-load.c typo In-Reply-To: <20050208180324.GD4777@sunsite.mff.cuni.cz> References: <20050208180324.GD4777@sunsite.mff.cuni.cz> Message-ID: <42093176.6070907@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From aoliva@redhat.com Wed Feb 9 09:38:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 09:38:00 -0000 Subject: elf.h changes for FR-V FDPIC and TLS In-Reply-To: References: Message-ID: Roland asked me to break the patch up into smaller pieces. Here goes the first one, that doesn't depend on any other patches. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-frv-elf-h.patch Type: text/x-patch Size: 1565 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Wed Feb 9 09:48:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 09:48:00 -0000 Subject: Fujitsu FR-V port (linuxthreads and nptl included) In-Reply-To: References: Message-ID: Since GCC 3.4 is the first release to support shared libs for FR-V, the symbols exported by libgcc are marked as GCC_3.4. Since glibc brings them into libc.so, we have to export them. It might be worth noting that the FR-V ABI specifies different names for the functions traditionally exported by libgcc, and GCC actually emits references to these alternate names, that are thus brought into libc.so from libgcc.a. I couldn't find any way to introduce this as part of the ports infrastructure, unfortunately. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-frv-versions-def.patch Type: text/x-patch Size: 343 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Wed Feb 9 09:57:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 09:57:00 -0000 Subject: Introduce TRY_STATIC_TLS macro, used in FR-V In-Reply-To: References: Message-ID: This patch introduces TRY_STATIC_TLS, a macro that can be used to test whether a module's TLS block is in the static TLS block, or can be assigned there. If you use a sufficiently-recent version of GCC and never call TRY_STATIC_TLS, the new static intermediate function will be fully inlined into the single caller, without any performance hit whatsoever. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-try-allocate-static-tls.patch Type: text/x-patch Size: 1746 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From drepper@redhat.com Wed Feb 9 09:57:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 09 Feb 2005 09:57:00 -0000 Subject: Fujitsu FR-V port (linuxthreads and nptl included) In-Reply-To: References: Message-ID: <4209DE56.1020204@redhat.com> No way. I'm not willing to be the slave of these embedded idiots with their gazillion ports. This data must be part of the add-ons. If the support does not exist, write it. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From aoliva@redhat.com Wed Feb 9 10:08:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 10:08:00 -0000 Subject: FR-V TLS macros In-Reply-To: References: Message-ID: No need to explain this one, I think. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-frv-tls-macros.patch Type: text/x-patch Size: 2217 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From drepper@redhat.com Wed Feb 9 10:10:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 09 Feb 2005 10:10:00 -0000 Subject: Introduce TRY_STATIC_TLS macro, used in FR-V In-Reply-To: References: Message-ID: <4209E170.6010705@redhat.com> No. No changes like this to generic code. There is no need whatsoever. If some moron "designed" TLS on an arch incorrectly, add an _dl_catch_error block to catch the _dl_signal_error call and handle it. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From drepper@redhat.com Wed Feb 9 10:13:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 09 Feb 2005 10:13:00 -0000 Subject: FR-V TLS macros In-Reply-To: References: Message-ID: <4209E1F8.6010107@redhat.com> And once again, no. We are not going to add endless streams of #if blocks. Develop a generic method for add-ons and use it. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From aoliva@redhat.com Wed Feb 9 11:01:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 11:01:00 -0000 Subject: FR-V PLT audit In-Reply-To: References: Message-ID: The FR-V port doesn't support profiling (yet?), and so we never actually lay out the structure that pltenter/exit functions rely on, but it looks like we must define them anyway. Here are the definitions. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-frv-plt-audit.patch Type: text/x-patch Size: 1754 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Wed Feb 9 11:02:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 11:02:00 -0000 Subject: FR-V set_tid_address syscall number In-Reply-To: References: Message-ID: This is defined in kernel headers, but since other ports define this, I thought I would too... -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-frv-set-tid-address.patch Type: text/x-patch Size: 480 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Wed Feb 9 11:02:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 11:02:00 -0000 Subject: using pre-TCB padding for static TLS In-Reply-To: References: Message-ID: On Feb 7, 2005, Alexandre Oliva wrote: >> The other novelty is that the offset from the (biased) TLS pointer to >> the TLS block for the main executable, if there is one, is fixed by >> the ABI, which makes the Local Exec model extremely efficient. > This last bit, in turn, required a change to the TLS offset assignment > that can benefit other ports. The existing TLS offset assignment code > assigns all offsets starting at zero, with the maximum alignment > required by the static TLS blocks. Only then does it take > TLS_PRE_TCB_SIZE into account, rounding it up to the alignment of the > static TLS block, leaving whatever padding required by this operation > unused. > The change introduced to enable the offset from the TCB to the > executable TLS block to be constant enabled the pre-tcb size and > alignment requirements to be taken into account early, such that we > can use whatever padding they might require for TLS blocks. This is > particularly useful in case some TLS segment has a very large > alignment requirement. > Also, if a TLS segment has alignment requirements no stricter than > those of the TCB, and the pre-TCB block has wider alignment > requirements than the TCB, the current code will not obtain the > correct alignment for the pre-TCB block. This actually hits in > current code, because the TCB often has 16-byte alignment, and the > pre-TCB block is declared as requiring 32-byte alignment. > The change to implement this fix was implemented by adding an argument > to a function exported by ld.so to libpthread.so. I'm not sure this > is regarded as an ABI break, since it's an internal function. It > would be simple enough to introduce a separate entry point to obtain > the same information, or version the function so as to make > incompatibilities explicit. Opinions? This patch has the changes described above. It introduces two new macros to control the behavior of dl-tls: TLS_PRE_TCB_ALIGN (that should probably be set for all DTV_AT_TP ports) and TLS_FIXED_EXEC_TCB_OFFSET_P (that is only used on FR-V). I could probably split these out into a separate patch, but they're so small and entangled with the current patch that I didn't think it was worth the trouble. It also introduces TLS_STATIC_RESERVED_SIZE, defined as an alias to TLS_PRE_TCB_SIZE unless TLS_FIXED_EXEC_TCB_OFFSET_P, in which case the offset may have to vary, and is thus defined as a macro. _dl_get_tls_static_info() gets a new argument that libc uses to communicate the amount of space reserved for the pre-tcb block, such that nptl can take it into account when allocating space for the TLS block. I have a few backward-compatibility concerns regarding this change, but since it's an internal function, I thought this might be ok. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibc-use-pre-tcb-padding.patch Type: text/x-patch Size: 11004 bytes Desc: not available URL: -------------- next part -------------- -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Wed Feb 9 11:07:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 11:07:00 -0000 Subject: Introduce TRY_STATIC_TLS macro, used in FR-V In-Reply-To: <4209E170.6010705@redhat.com> References: <4209E170.6010705@redhat.com> Message-ID: On Feb 9, 2005, Ulrich Drepper wrote: > No. No changes like this to generic code. There is no need whatsoever. > If some moron "designed" TLS on an arch incorrectly, add an > _dl_catch_error block to catch the _dl_signal_error call and handle it. Just because another moron couldn't think of a better way to design it? How stupid is this going to get? -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From drepper@redhat.com Wed Feb 9 11:11:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 09 Feb 2005 11:11:00 -0000 Subject: FR-V set_tid_address syscall number In-Reply-To: References: Message-ID: <4209EF8D.1060205@redhat.com> No. These were added just for the time when the kernel feature was too new. The #ifs must simply go. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From drepper@redhat.com Wed Feb 9 11:14:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 09 Feb 2005 11:14:00 -0000 Subject: using pre-TCB padding for static TLS In-Reply-To: References: Message-ID: <4209EFD8.7080902@redhat.com> > > * sysdeps/generic/dl-tls.c (_dl_determine_tlsoffset): Update > executable sanity check in fixed exec tcb offset mode. What part of "ports use their own sysdeps tree" don't you understand? Define your own dl-tls.c file for this moronic port which cannot follow common practice. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From drepper@redhat.com Wed Feb 9 11:15:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 09 Feb 2005 11:15:00 -0000 Subject: FR-V PLT audit In-Reply-To: References: Message-ID: <4209F002.30001@redhat.com> And again, define something to move this into the port. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From aoliva@redhat.com Wed Feb 9 11:15:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 11:15:00 -0000 Subject: FR-V TLS macros In-Reply-To: <4209E1F8.6010107@redhat.com> References: <4209E1F8.6010107@redhat.com> Message-ID: On Feb 9, 2005, Ulrich Drepper wrote: > And once again, no. We are not going to add endless streams of #if > blocks. Then why did you add them in the first place? > Develop a generic method for add-ons and use it. It looks like you're going to reject anything I come up with on grounds of prejudice. I don't feel like wasting my time trying to figure out some way to fix stuff you broke just to have you reject it with a stupid reason. Here's my design suggestion: include a sysdeps header file any time you find yourself adding streams of machine-specific defines. Then port maintainers will even get saner build errors. If I make such a change to this file and to that oh-so-beautiful stream of multiple ifdefs you ``designed?? to introduce plt audit, what reason are you going to use to reject it? -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Wed Feb 9 11:30:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 11:30:00 -0000 Subject: Fujitsu FR-V port (linuxthreads and nptl included) In-Reply-To: <4209DE56.1020204@redhat.com> References: <4209DE56.1020204@redhat.com> Message-ID: On Feb 9, 2005, Ulrich Drepper wrote: > No way. I'm not willing to be the slave of these embedded idiots with > their gazillion ports. This data must be part of the add-ons. If the > support does not exist, write it. So, I can add an entry to ports/Versions.def and it will just work. However, I'd like to make it specific to the FR-V port if possible. Unfortunately, Versions.v is preprocessed with -undef, so __FRV_FDPIC__ isn't defined. Any chance we could take out this -undef, or must I come up with some more convoluted solution? Or can I just keep GCC_3.4 unconditional in ports/Versions.def, such that any other ports willing to use them can without further hassle can, and those that don't won't be affected in any way AFAICT? I.e., does this patch actually impact negatively any other port, or are you just going on your crusade against new ports and being a pain as usual? -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Wed Feb 9 11:35:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 11:35:00 -0000 Subject: using pre-TCB padding for static TLS In-Reply-To: <4209EFD8.7080902@redhat.com> References: <4209EFD8.7080902@redhat.com> Message-ID: On Feb 9, 2005, Ulrich Drepper wrote: >> >> * sysdeps/generic/dl-tls.c (_dl_determine_tlsoffset): Update >> executable sanity check in fixed exec tcb offset mode. > What part of "ports use their own sysdeps tree" don't you understand? What part of `all DTV_AT_TP ports are broken, and could also reduce static TLS wastage' don't you understand? The machine-specific portion of this change is just a few lines, that other ports could and should take advantage of. Keeping them hidden elsewhere will do nobody any good. > Define your own dl-tls.c file for this moronic port which cannot follow > common practice. How painful can it be to watch someone else improve on a poor design of yours and regret not having thought of it? It's almost funny to watch you promoting new and better ways to do things when you come up with them, and then classify as moronic the better ways to do things that you didn't think of. You should be ashamed. -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From aoliva@redhat.com Wed Feb 9 11:36:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Wed, 09 Feb 2005 11:36:00 -0000 Subject: FR-V set_tid_address syscall number In-Reply-To: <4209EF8D.1060205@redhat.com> References: <4209EF8D.1060205@redhat.com> Message-ID: On Feb 9, 2005, Ulrich Drepper wrote: > No. These were added just for the time when the kernel feature was too > new. The #ifs must simply go. Sounds good to me, patch withdrawn. Should I even bother to post a patch to remove the others? -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From jakub@redhat.com Wed Feb 9 20:40:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 09 Feb 2005 20:40:00 -0000 Subject: [PATCH] Fix initstate{,_r} (BZ #710) Message-ID: <20050209204045.GG4777@sunsite.mff.cuni.cz> Hi! initstate{,_r} fails to save old state, although the comment above it states: Note: The first thing we do is save the current state, if any, just like setstate so that it doesn't matter when initstate is called. The patch below does just that, using the same code setstate uses. I've checked FreeBSD random.c and it behaves similarly (well, it is initstate not initstate_r there) and run the testcase on Solaris, where it passed (unlike on unpatched glibc). 2005-02-09 Jakub Jelinek [BZ #710] * stdlib/random_r.c (__initstate_r): Save old state. * stdlib/Makefile (tests): Add tst-random2. * stdlib/tst-random2.c: New test. Reported by Peter Bergner . --- libc/stdlib/random_r.c.jj 2002-07-06 08:35:55.000000000 +0200 +++ libc/stdlib/random_r.c 2005-02-09 21:22:34.700318767 +0100 @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation + Copyright (C) 1995, 2005 Free Software Foundation The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -240,10 +240,19 @@ __initstate_r (seed, arg_state, n, buf) int degree; int separation; int32_t *state; + int old_type; + int32_t *old_state; if (buf == NULL) goto fail; + old_type = buf->rand_type; + old_state = buf->state; + if (old_type == TYPE_0) + old_state[-1] = TYPE_0; + else + old_state[-1] = (MAX_TYPES * (buf->rptr - old_state)) + old_type; + if (n >= BREAK_3) type = n < BREAK_4 ? TYPE_3 : TYPE_4; else if (n < BREAK_1) --- libc/stdlib/Makefile.jj 2005-01-26 18:22:23.000000000 +0100 +++ libc/stdlib/Makefile 2005-02-09 21:19:00.689543768 +0100 @@ -61,9 +61,9 @@ distribute := exit.h grouping.h abort-in test-srcs := tst-fmtmsg tests := tst-strtol tst-strtod testmb testrand testsort testdiv \ test-canon test-canon2 tst-strtoll tst-environ \ - tst-xpg-basename tst-random tst-bsearch tst-limits \ - tst-rand48 bug-strtod tst-setcontext test-a64l tst-qsort \ - tst-system testmb2 + tst-xpg-basename tst-random tst-random2 tst-bsearch \ + tst-limits tst-rand48 bug-strtod tst-setcontext \ + test-a64l tst-qsort tst-system testmb2 include ../Makeconfig --- libc/stdlib/tst-random2.c.jj 2005-02-09 21:05:16.972676949 +0100 +++ libc/stdlib/tst-random2.c 2005-02-09 21:14:39.892126585 +0100 @@ -0,0 +1,58 @@ +/* Copyright (C) 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2005. + + 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 + +int +main (void) +{ + int pass; + int ret = 0; + long int r[2]; + + for (pass = 0; pass < 2; pass++) + { + srandom (0x12344321); + + int j; + for (j = 0; j < 3; ++j) + random (); + if (pass == 1) + { + char state[128]; + char *ostate = initstate (0x34562101, state, 128); + if (setstate (ostate) != state) + { + puts ("setstate (ostate) != state"); + ret = 1; + } + } + + random (); + r[pass] = random (); + } + + if (r[0] != r[1]) + { + printf ("%ld != %ld\n", r[0], r[1]); + ret = 1; + } + return ret; +} Jakub From jakub@redhat.com Wed Feb 9 21:35:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 09 Feb 2005 21:35:00 -0000 Subject: [PATCH] Define CMSPAR to bits/termios.h Message-ID: <20050209213522.GH4777@sunsite.mff.cuni.cz> Hi! https://bugzilla.redhat.com/beta/show_bug.cgi?id=147533 complains about missing CMSPAR definitions (in all bits/termios.h's but sparc one). While adding that, I have noticed alpha/powerpc/sparc termios.h's lack many feature set macro guards that the generic linux bits/termios.h has. Assuming the generic one is correct, I have added them to those 3 headers as well. 2005-02-09 Jakub Jelinek * sysdeps/unix/sysv/linux/bits/termios.h (CMSPAR): Define. * sysdeps/unix/sysv/linux/alpha/bits/termios.h: Add __USE_MISC and __USE_XOPEN guards to match linux/bits/termios.h. (CMSPAR): Define. * sysdeps/unix/sysv/linux/powerpc/bits/termios.h: Add __USE_MISC and __USE_XOPEN guards to match linux/bits/termios.h. (CMSPAR): Define. * sysdeps/unix/sysv/linux/sparc/bits/termios.h: Add __USE_MISC and __USE_XOPEN guards to match linux/bits/termios.h. --- libc/sysdeps/unix/sysv/linux/bits/termios.h.jj 2004-04-13 10:42:55.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/bits/termios.h 2005-02-09 22:00:10.488446408 +0100 @@ -1,5 +1,5 @@ /* termios type and macro definitions. Linux version. - Copyright (C) 1993,1994,1995,1996,1997,1998,1999,2003 + Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -172,6 +172,7 @@ struct termios #define __MAX_BAUD B4000000 #ifdef __USE_MISC # define CIBAUD 002003600000 /* input baud rate (not used) */ +# define CMSPAR 010000000000 /* mark or space (stick) parity */ # define CRTSCTS 020000000000 /* flow control */ #endif --- libc/sysdeps/unix/sysv/linux/alpha/bits/termios.h.jj 2004-04-13 10:42:55.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/alpha/bits/termios.h 2005-02-09 22:25:27.015715773 +0100 @@ -1,5 +1,5 @@ /* termios type and macro definitions. Linux version. - Copyright (C) 1993,1994,1995,1996,1997,1999,2003 + Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -91,34 +91,42 @@ struct termios #define OFILL 00000100 #define OFDEL 00000200 -#define NLDLY 00001400 -#define NL0 00000000 -#define NL1 00000400 -#define NL2 00001000 -#define NL3 00001400 -#define TABDLY 00006000 -#define TAB0 00000000 -#define TAB1 00002000 -#define TAB2 00004000 -#define TAB3 00006000 -#define CRDLY 00030000 -#define CR0 00000000 -#define CR1 00010000 -#define CR2 00020000 -#define CR3 00030000 -#define FFDLY 00040000 -#define FF0 00000000 -#define FF1 00040000 -#define BSDLY 00100000 -#define BS0 00000000 -#define BS1 00100000 +#if defined __USE_MISC || defined __USE_XOPEN +# define NLDLY 00001400 +# define NL0 00000000 +# define NL1 00000400 +# define NL2 00001000 +# define NL3 00001400 +# define TABDLY 00006000 +# define TAB0 00000000 +# define TAB1 00002000 +# define TAB2 00004000 +# define TAB3 00006000 +# define CRDLY 00030000 +# define CR0 00000000 +# define CR1 00010000 +# define CR2 00020000 +# define CR3 00030000 +# define FFDLY 00040000 +# define FF0 00000000 +# define FF1 00040000 +# define BSDLY 00100000 +# define BS0 00000000 +# define BS1 00100000 +#endif + #define VTDLY 00200000 #define VT0 00000000 #define VT1 00200000 -#define XTABS 01000000 /* Hmm.. Linux/i386 considers this part of TABDLY.. */ + +#ifdef __USE_MISC +# define XTABS 01000000 /* Hmm.. Linux/i386 considers this part of TABDLY.. */ +#endif /* c_cflag bit meaning */ -#define CBAUD 0000037 +#ifdef __USE_MISC +# define CBAUD 0000037 +#endif #define B0 0000000 /* hang up */ #define B50 0000001 #define B75 0000002 @@ -135,9 +143,11 @@ struct termios #define B9600 0000015 #define B19200 0000016 #define B38400 0000017 -#define EXTA B19200 -#define EXTB B38400 -#define CBAUDEX 0000000 +#ifdef __USE_MISC +# define EXTA B19200 +# define EXTB B38400 +# define CBAUDEX 0000000 +#endif #define B57600 00020 #define B115200 00021 #define B230400 00022 @@ -169,23 +179,30 @@ struct termios #define HUPCL 00040000 #define CLOCAL 00100000 -#define CRTSCTS 020000000000 /* flow control */ +#ifdef __USE_MISC +# define CMSPAR 010000000000 /* mark or space (stick) parity */ +# define CRTSCTS 020000000000 /* flow control */ +#endif /* c_lflag bits */ #define ISIG 0x00000080 #define ICANON 0x00000100 -#define XCASE 0x00004000 +#if defined __USE_MISC || defined __USE_XOPEN +# define XCASE 0x00004000 +#endif #define ECHO 0x00000008 #define ECHOE 0x00000002 #define ECHOK 0x00000004 #define ECHONL 0x00000010 #define NOFLSH 0x80000000 #define TOSTOP 0x00400000 -#define ECHOCTL 0x00000040 -#define ECHOPRT 0x00000020 -#define ECHOKE 0x00000001 -#define FLUSHO 0x00800000 -#define PENDIN 0x20000000 +#ifdef __USE_MISC +# define ECHOCTL 0x00000040 +# define ECHOPRT 0x00000020 +# define ECHOKE 0x00000001 +# define FLUSHO 0x00800000 +# define PENDIN 0x20000000 +#endif #define IEXTEN 0x00000400 /* Values for the ACTION argument to `tcflow'. */ --- libc/sysdeps/unix/sysv/linux/powerpc/bits/termios.h.jj 2004-05-18 10:52:28.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/powerpc/bits/termios.h 2005-02-09 22:25:12.952226345 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1999,2001,2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1997,1999,2001,2003,2004,2005 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 @@ -92,34 +92,41 @@ struct termios { #define OFILL 00000100 #define OFDEL 00000200 -#define NLDLY 00001400 -#define NL0 00000000 -#define NL1 00000400 -#define NL2 00001000 -#define NL3 00001400 -#define TABDLY 00006000 -#define TAB0 00000000 -#define TAB1 00002000 -#define TAB2 00004000 -#define TAB3 00006000 -#define XTABS 00006000 /* Required by POSIX to be == TAB3. */ -#define CRDLY 00030000 -#define CR0 00000000 -#define CR1 00010000 -#define CR2 00020000 -#define CR3 00030000 -#define FFDLY 00040000 -#define FF0 00000000 -#define FF1 00040000 -#define BSDLY 00100000 -#define BS0 00000000 -#define BS1 00100000 +#if defined __USE_MISC || defined __USE_XOPEN +# define NLDLY 00001400 +# define NL0 00000000 +# define NL1 00000400 +# define NL2 00001000 +# define NL3 00001400 +# define TABDLY 00006000 +# define TAB0 00000000 +# define TAB1 00002000 +# define TAB2 00004000 +# define TAB3 00006000 +# define CRDLY 00030000 +# define CR0 00000000 +# define CR1 00010000 +# define CR2 00020000 +# define CR3 00030000 +# define FFDLY 00040000 +# define FF0 00000000 +# define FF1 00040000 +# define BSDLY 00100000 +# define BS0 00000000 +# define BS1 00100000 +#endif #define VTDLY 00200000 #define VT0 00000000 #define VT1 00200000 +#ifdef __USE_MISC +# define XTABS 00006000 +#endif + /* c_cflag bit meaning */ -#define CBAUD 0000377 +#ifdef __USE_MISC +# define CBAUD 0000377 +#endif #define B0 0000000 /* hang up */ #define B50 0000001 #define B75 0000002 @@ -136,9 +143,11 @@ struct termios { #define B9600 0000015 #define B19200 0000016 #define B38400 0000017 -#define EXTA B19200 -#define EXTB B38400 -#define CBAUDEX 0000020 +#ifdef __USE_MISC +# define EXTA B19200 +# define EXTB B38400 +# define CBAUDEX 0000020 +#endif #define B57600 00020 #define B115200 00021 #define B230400 00022 @@ -169,23 +178,30 @@ struct termios { #define HUPCL 00040000 #define CLOCAL 00100000 -#define CRTSCTS 020000000000 /* flow control */ +#ifdef __USE_MISC +# define CMSPAR 010000000000 /* mark or space (stick) parity */ +# define CRTSCTS 020000000000 /* flow control */ +#endif /* c_lflag bits */ #define ISIG 0x00000080 #define ICANON 0x00000100 -#define XCASE 0x00004000 +#if defined __USE_MISC || defined __USE_XOPEN +# define XCASE 0x00004000 +#endif #define ECHO 0x00000008 #define ECHOE 0x00000002 #define ECHOK 0x00000004 #define ECHONL 0x00000010 #define NOFLSH 0x80000000 #define TOSTOP 0x00400000 -#define ECHOCTL 0x00000040 -#define ECHOPRT 0x00000020 -#define ECHOKE 0x00000001 -#define FLUSHO 0x00800000 -#define PENDIN 0x20000000 +#ifdef __USE_MISC +# define ECHOCTL 0x00000040 +# define ECHOPRT 0x00000020 +# define ECHOKE 0x00000001 +# define FLUSHO 0x00800000 +# define PENDIN 0x20000000 +#endif #define IEXTEN 0x00000400 /* Values for the ACTION argument to `tcflow'. */ --- libc/sysdeps/unix/sysv/linux/sparc/bits/termios.h.jj 2004-04-13 10:42:55.000000000 +0200 +++ libc/sysdeps/unix/sysv/linux/sparc/bits/termios.h 2005-02-09 22:30:13.565561763 +0100 @@ -1,5 +1,6 @@ /* termios type and macro definitions. Linux/SPARC version. - Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. + Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2005 + 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,34 +85,41 @@ struct termios #define ONLRET 0x00000020 #define OFILL 0x00000040 #define OFDEL 0x00000080 -#define NLDLY 0x00000100 -#define NL0 0x00000000 -#define NL1 0x00000100 -#define CRDLY 0x00000600 -#define CR0 0x00000000 -#define CR1 0x00000200 -#define CR2 0x00000400 -#define CR3 0x00000600 -#define TABDLY 0x00001800 -#define TAB0 0x00000000 -#define TAB1 0x00000800 -#define TAB2 0x00001000 -#define TAB3 0x00001800 -#define XTABS 0x00001800 -#define BSDLY 0x00002000 -#define BS0 0x00000000 -#define BS1 0x00002000 -#define VTDLY 0x00004000 -#define VT0 0x00000000 -#define VT1 0x00004000 +#if defined __USE_MISC || defined __USE_XOPEN +# define NLDLY 0x00000100 +# define NL0 0x00000000 +# define NL1 0x00000100 +# define CRDLY 0x00000600 +# define CR0 0x00000000 +# define CR1 0x00000200 +# define CR2 0x00000400 +# define CR3 0x00000600 +# define TABDLY 0x00001800 +# define TAB0 0x00000000 +# define TAB1 0x00000800 +# define TAB2 0x00001000 +# define TAB3 0x00001800 +# define BSDLY 0x00002000 +# define BS0 0x00000000 +# define BS1 0x00002000 #define FFDLY 0x00008000 #define FF0 0x00000000 #define FF1 0x00008000 +#endif +#define VTDLY 0x00004000 +#define VT0 0x00000000 +#define VT1 0x00004000 #define PAGEOUT 0x00010000 /* SUNOS specific */ #define WRAP 0x00020000 /* SUNOS specific */ +#ifdef __USE_MISC +# define XTABS 0x00001800 +#endif + /* c_cflag bit meaning */ -#define CBAUD 0x0000100f +#ifdef __USE_MISC +# define CBAUD 0x0000100f +#endif #define B0 0x00000000 /* hang up */ #define B50 0x00000001 #define B75 0x00000002 @@ -128,8 +136,10 @@ struct termios #define B9600 0x0000000d #define B19200 0x0000000e #define B38400 0x0000000f -#define EXTA B19200 -#define EXTB B38400 +#ifdef __USE_MISC +# define EXTA B19200 +# define EXTB B38400 +#endif #define CSIZE 0x00000030 #define CS5 0x00000000 #define CS6 0x00000010 @@ -141,7 +151,9 @@ struct termios #define PARODD 0x00000200 #define HUPCL 0x00000400 #define CLOCAL 0x00000800 -#define CBAUDEX 0x00001000 +#ifdef __USE_MISC +# define CBAUDEX 0x00001000 +#endif #define B57600 0x00001001 #define B115200 0x00001002 #define B230400 0x00001003 @@ -159,26 +171,32 @@ struct termios #define B2000000 0x0000100f #define __MAX_BAUD B2000000 -#define CIBAUD 0x100f0000 /* input baud rate (not used) */ -#define CMSPAR 0x40000000 /* mark or space (stick) parity */ -#define CRTSCTS 0x80000000 /* flow control */ +#ifdef __USE_MISC +# define CIBAUD 0x100f0000 /* input baud rate (not used) */ +# define CMSPAR 0x40000000 /* mark or space (stick) parity */ +# define CRTSCTS 0x80000000 /* flow control */ +#endif /* c_lflag bits */ #define ISIG 0x00000001 #define ICANON 0x00000002 -#define XCASE 0x00000004 +#if defined __USE_MISC || defined __USE_XOPEN +# define XCASE 0x00000004 +#endif #define ECHO 0x00000008 #define ECHOE 0x00000010 #define ECHOK 0x00000020 #define ECHONL 0x00000040 #define NOFLSH 0x00000080 #define TOSTOP 0x00000100 -#define ECHOCTL 0x00000200 -#define ECHOPRT 0x00000400 -#define ECHOKE 0x00000800 -#define DEFECHO 0x00001000 /* SUNOS thing, what is it? */ -#define FLUSHO 0x00002000 -#define PENDIN 0x00004000 +#ifdef __USE_MISC +# define ECHOCTL 0x00000200 +# define ECHOPRT 0x00000400 +# define ECHOKE 0x00000800 +# define DEFECHO 0x00001000 /* SUNOS thing, what is it? */ +# define FLUSHO 0x00002000 +# define PENDIN 0x00004000 +#endif #define IEXTEN 0x00008000 /* modem lines */ Jakub From rth@twiddle.net Thu Feb 10 05:16:00 2005 From: rth@twiddle.net (Richard Henderson) Date: Thu, 10 Feb 2005 05:16:00 -0000 Subject: FR-V PLT audit In-Reply-To: <4209F002.30001@redhat.com> References: <4209F002.30001@redhat.com> Message-ID: <20050210051559.GA3978@twiddle.net> On Wed, Feb 09, 2005 at 03:12:02AM -0800, Ulrich Drepper wrote: > And again, define something to move this into the port. You must admit that this part is exceedingly ugly to begin with. I think you're being unfair to Alex making him cleanup your mess. r~ From roland@redhat.com Thu Feb 10 06:43:00 2005 From: roland@redhat.com (Roland McGrath) Date: Thu, 10 Feb 2005 06:43:00 -0000 Subject: FR-V PLT audit In-Reply-To: Richard Henderson's message of Wednesday, 9 February 2005 21:15:59 -0800 <20050210051559.GA3978@twiddle.net> Message-ID: <200502100643.j1A6hmek021559@magilla.sf.frob.com> Indeed, what is the motivation for using an anonymous union rather than each sysdeps/CPU/ldsodefs.h defining a macro for the appropriate thing? From rth@twiddle.net Thu Feb 10 07:06:00 2005 From: rth@twiddle.net (Richard Henderson) Date: Thu, 10 Feb 2005 07:06:00 -0000 Subject: FR-V PLT audit In-Reply-To: <200502100643.j1A6hmek021559@magilla.sf.frob.com> References: <20050210051559.GA3978@twiddle.net> <200502100643.j1A6hmek021559@magilla.sf.frob.com> Message-ID: <20050210070648.GA4296@twiddle.net> On Wed, Feb 09, 2005 at 10:43:48PM -0800, Roland McGrath wrote: > Indeed, what is the motivation for using an anonymous union rather than > each sysdeps/CPU/ldsodefs.h defining a macro for the appropriate thing? Or any macros at all? What's so special about the argument and result registers that require structure names to differ by target? We don't do that for sigcontext, or jmp_buf. r~ From roland@redhat.com Thu Feb 10 07:19:00 2005 From: roland@redhat.com (Roland McGrath) Date: Thu, 10 Feb 2005 07:19:00 -0000 Subject: FR-V PLT audit In-Reply-To: Richard Henderson's message of Wednesday, 9 February 2005 23:06:48 -0800 <20050210070648.GA4296@twiddle.net> Message-ID: <200502100719.j1A7JQRn009078@magilla.sf.frob.com> > On Wed, Feb 09, 2005 at 10:43:48PM -0800, Roland McGrath wrote: > > Indeed, what is the motivation for using an anonymous union rather than > > each sysdeps/CPU/ldsodefs.h defining a macro for the appropriate thing? > > Or any macros at all? What's so special about the argument and result > registers that require structure names to differ by target? We don't > do that for sigcontext, or jmp_buf. I think the intent there was just that the structure member names match the names of the entry point symbols in the audit library. The reason the API for those functions uses a different name for each CPU is that the signature and what you need to know to implement it also differ for each CPU. It is not something that is ever used generically like sigcontext and jmp_buf are. From aoliva@redhat.com Thu Feb 10 07:35:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Thu, 10 Feb 2005 07:35:00 -0000 Subject: apology for the tone Message-ID: I'm writing this e-mail to apologize to all of you who have watched my yesterday's e-mail exchange with Uli. It must be sad to watch two grown-ups behave like that. This discussion brought out the worst in me. I should be sorry and ashamed, and I am. You all who didn't deserve the tone of my postings, please accept my apologies. I wish I could promise it won't happen again, but all I can promise with some hope of living up to is to try. Thanks for your understanding. -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From rth@twiddle.net Thu Feb 10 07:51:00 2005 From: rth@twiddle.net (Richard Henderson) Date: Thu, 10 Feb 2005 07:51:00 -0000 Subject: FR-V PLT audit In-Reply-To: <200502100719.j1A7JQRn009078@magilla.sf.frob.com> References: <20050210070648.GA4296@twiddle.net> <200502100719.j1A7JQRn009078@magilla.sf.frob.com> Message-ID: <20050210075139.GD4296@twiddle.net> On Wed, Feb 09, 2005 at 11:19:26PM -0800, Roland McGrath wrote: > I think the intent there was just that the structure member names match the > names of the entry point symbols in the audit library. The reason the API > for those functions uses a different name for each CPU is that the > signature and what you need to know to implement it also differ for each > CPU. It is not something that is ever used generically like sigcontext and > jmp_buf are. Possibly, but in practice it seems like you'll wind up with a lot of commonality in the actual implementations, and thence a lot of macro hackery to try to cope with the gratuitous name changes. It's not like you'll have mips and i386 versions in the same binary in the first place, and therefore no need to make sure that the two are in separate namespaces. r~ From roland@redhat.com Thu Feb 10 09:03:00 2005 From: roland@redhat.com (Roland McGrath) Date: Thu, 10 Feb 2005 09:03:00 -0000 Subject: FR-V PLT audit In-Reply-To: Richard Henderson's message of Wednesday, 9 February 2005 23:51:39 -0800 <20050210075139.GD4296@twiddle.net> Message-ID: <200502100903.j1A93Mos031618@magilla.sf.frob.com> > It's not like you'll have mips and i386 versions in the same binary > in the first place, and therefore no need to make sure that the two > are in separate namespaces. That's not the concern. The concern is that one could try to compile an audit library on a different platform and have it seem like it's ok because the signature happens to match, but in fact the audit library's pltenter/pltexit functions have not been ported properly to the machine you are compiling for. Since those implementations are always machine-specific, having the API distinguish the machine in the names makes sure you have considered the target machine specifically. From paolo.bonzini@lu.unisi.ch Thu Feb 10 09:33:00 2005 From: paolo.bonzini@lu.unisi.ch (Paolo Bonzini) Date: Thu, 10 Feb 2005 09:33:00 -0000 Subject: [PATCH] fix crash for sed "script" /\(\)/x Message-ID: <420B2A82.6000606@lu.unisi.ch> An empty subexpression in the presence of REG_NOSUB may cause a CONCAT node to have a NULL children, and this would crash in calc_first. The attached patch cures it by not optimizing the empty subexpression in the first place. It ought not to be very common, so we do not lose much. Paolo -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: regex-fix-crash.patch URL: From jakub@redhat.com Thu Feb 10 09:57:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 10 Feb 2005 09:57:00 -0000 Subject: [PATCH] Fix ppc bits/link.h Message-ID: <20050210095742.GI4777@sunsite.mff.cuni.cz> Hi! On ppc (as well as sparc, s390 etc.), unlike i386, installed headers should be usable both for -m3{2,1} and -m64 compilations. 2005-02-10 Jakub Jelinek * sysdeps/powerpc/powerpc32/bits/link.h: Removed. * sysdeps/powerpc/powerpc64/bits/link.h: Moved to... * sysdeps/powerpc/bits/link.h: ... here. New file. --- libc/sysdeps/powerpc/powerpc64/bits/link.h.jj 2005-01-08 08:08:24.000000000 +0100 +++ libc/sysdeps/powerpc/powerpc64/bits/link.h 2005-02-10 10:41:37.252735416 +0100 @@ -1,109 +0,0 @@ -/* Copyright (C) 2004, 2005 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. */ - -#ifndef _LINK_H -# error "Never include directly; use instead." -#endif - - -#if __ELF_NATIVE_CLASS == 32 - -/* Registers for entry into PLT on PPC32. */ -typedef struct La_ppc32_regs -{ - uint32_t lr_reg[8]; - double lr_fp[8]; - uint32_t lr_vreg[12][4]; - uint32_t lr_r1; - uint32_t lr_lr; -} La_ppc32_regs; - -/* Return values for calls from PLT on PPC32. */ -typedef struct La_ppc32_retval -{ - uint32_t lrv_r3; - uint32_t lrv_r4; - double lrv_fp[8]; - uint32_t lrv_v2[4]; -} La_ppc32_retval; - - -__BEGIN_DECLS - -extern Elf32_Addr la_ppc32_gnu_pltenter (Elf32_Sym *__sym, - unsigned int __ndx, - uintptr_t *__refcook, - uintptr_t *__defcook, - La_ppc32_regs *__regs, - unsigned int *__flags, - const char *__symname, - long int *__framesizep); -extern unsigned int la_ppc32_gnu_pltexit (Elf32_Sym *__sym, - unsigned int __ndx, - uintptr_t *__refcook, - uintptr_t *__defcook, - const La_ppc32_regs *__inregs, - La_ppc32_retval *__outregs, - const char *symname); - -__END_DECLS - -#else - -/* Registers for entry into PLT on PPC64. */ -typedef struct La_ppc64_regs -{ - uint64_t lr_reg[8]; - double lr_fp[13]; - uint64_t __padding; - uint32_t lr_vreg[12][4]; - uint64_t lr_r1; - uint64_t lr_lr; -} La_ppc64_regs; - -/* Return values for calls from PLT on PPC64. */ -typedef struct La_ppc64_retval -{ - uint64_t lrv_r3; - uint64_t lrv_r4; - double lrv_fp[8]; - uint32_t lrv_v2[4]; -} La_ppc64_retval; - - -__BEGIN_DECLS - -extern Elf64_Addr la_ppc64_gnu_pltenter (Elf64_Sym *__sym, - unsigned int __ndx, - uintptr_t *__refcook, - uintptr_t *__defcook, - La_ppc64_regs *__regs, - unsigned int *__flags, - const char *__symname, - long int *__framesizep); -extern unsigned int la_ppc64_gnu_pltexit (Elf64_Sym *__sym, - unsigned int __ndx, - uintptr_t *__refcook, - uintptr_t *__defcook, - const La_ppc64_regs *__inregs, - La_ppc64_retval *__outregs, - const char *symname); - -__END_DECLS - -#endif --- libc/sysdeps/powerpc/powerpc32/bits/link.h.jj 2005-01-08 06:45:39.000000000 +0100 +++ libc/sysdeps/powerpc/powerpc32/bits/link.h 2005-02-10 10:41:26.042737767 +0100 @@ -1,62 +0,0 @@ -/* Copyright (C) 2004, 2005 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. */ - -#ifndef _LINK_H -# error "Never include directly; use instead." -#endif - - -/* Registers for entry into PLT on PPC32. */ -typedef struct La_ppc32_regs -{ - uint32_t lr_reg[8]; - double lr_fp[8]; - uint32_t lr_vreg[12][4]; - uint32_t lr_r1; - uint32_t lr_lr; -} La_ppc32_regs; - -/* Return values for calls from PLT on PPC32. */ -typedef struct La_ppc32_retval -{ - uint32_t lrv_r3; - uint32_t lrv_r4; - double lrv_fp[8]; - uint32_t lrv_v2[4]; -} La_ppc32_retval; - - -__BEGIN_DECLS - -extern Elf32_Addr la_ppc32_gnu_pltenter (Elf32_Sym *__sym, - unsigned int __ndx, - uintptr_t *__refcook, - uintptr_t *__defcook, - La_ppc32_regs *__regs, - unsigned int *__flags, - const char *__symname, - long int *__framesizep); -extern unsigned int la_ppc32_gnu_pltexit (Elf32_Sym *__sym, - unsigned int __ndx, - uintptr_t *__refcook, - uintptr_t *__defcook, - const La_ppc32_regs *__inregs, - La_ppc32_retval *__outregs, - const char *symname); - -__END_DECLS --- libc/sysdeps/powerpc/bits/link.h.jj 2005-02-10 10:39:55.485913268 +0100 +++ libc/sysdeps/powerpc/bits/link.h 2005-01-08 08:08:24.000000000 +0100 @@ -0,0 +1,109 @@ +/* Copyright (C) 2004, 2005 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. */ + +#ifndef _LINK_H +# error "Never include directly; use instead." +#endif + + +#if __ELF_NATIVE_CLASS == 32 + +/* Registers for entry into PLT on PPC32. */ +typedef struct La_ppc32_regs +{ + uint32_t lr_reg[8]; + double lr_fp[8]; + uint32_t lr_vreg[12][4]; + uint32_t lr_r1; + uint32_t lr_lr; +} La_ppc32_regs; + +/* Return values for calls from PLT on PPC32. */ +typedef struct La_ppc32_retval +{ + uint32_t lrv_r3; + uint32_t lrv_r4; + double lrv_fp[8]; + uint32_t lrv_v2[4]; +} La_ppc32_retval; + + +__BEGIN_DECLS + +extern Elf32_Addr la_ppc32_gnu_pltenter (Elf32_Sym *__sym, + unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + La_ppc32_regs *__regs, + unsigned int *__flags, + const char *__symname, + long int *__framesizep); +extern unsigned int la_ppc32_gnu_pltexit (Elf32_Sym *__sym, + unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + const La_ppc32_regs *__inregs, + La_ppc32_retval *__outregs, + const char *symname); + +__END_DECLS + +#else + +/* Registers for entry into PLT on PPC64. */ +typedef struct La_ppc64_regs +{ + uint64_t lr_reg[8]; + double lr_fp[13]; + uint64_t __padding; + uint32_t lr_vreg[12][4]; + uint64_t lr_r1; + uint64_t lr_lr; +} La_ppc64_regs; + +/* Return values for calls from PLT on PPC64. */ +typedef struct La_ppc64_retval +{ + uint64_t lrv_r3; + uint64_t lrv_r4; + double lrv_fp[8]; + uint32_t lrv_v2[4]; +} La_ppc64_retval; + + +__BEGIN_DECLS + +extern Elf64_Addr la_ppc64_gnu_pltenter (Elf64_Sym *__sym, + unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + La_ppc64_regs *__regs, + unsigned int *__flags, + const char *__symname, + long int *__framesizep); +extern unsigned int la_ppc64_gnu_pltexit (Elf64_Sym *__sym, + unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + const La_ppc64_regs *__inregs, + La_ppc64_retval *__outregs, + const char *symname); + +__END_DECLS + +#endif Jakub From rth@twiddle.net Thu Feb 10 16:51:00 2005 From: rth@twiddle.net (Richard Henderson) Date: Thu, 10 Feb 2005 16:51:00 -0000 Subject: FR-V PLT audit In-Reply-To: <200502100903.j1A93Mos031618@magilla.sf.frob.com> References: <20050210075139.GD4296@twiddle.net> <200502100903.j1A93Mos031618@magilla.sf.frob.com> Message-ID: <20050210164941.GA6437@twiddle.net> On Thu, Feb 10, 2005 at 01:03:22AM -0800, Roland McGrath wrote: > That's not the concern. The concern is that one could try to compile an > audit library on a different platform and have it seem like it's ok because > the signature happens to match, but in fact the audit library's > pltenter/pltexit functions have not been ported properly to the machine you > are compiling for. Since those implementations are always > machine-specific, having the API distinguish the machine in the names makes > sure you have considered the target machine specifically. Given that any non-trivial audit library will be looking at the arguments, and the structure member names are different for each platform, what do you think the odds are that the library will compile when configured incorrectly? I'm thinking pretty low, myself. r~ From jakub@redhat.com Fri Feb 11 14:55:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 11 Feb 2005 14:55:00 -0000 Subject: [PATCH] Fix soversions.awk Message-ID: <20050211145533.GJ4777@sunsite.mff.cuni.cz> Hi! Current CVS doesn't build e.g. on ppc64. The problem is that powerpc64-redhat-linux-gnu is matched by both: powerpc64-.*-.* WORDSIZE32 powerpc-@VENDOR@-@OS@ powerpc.*-.*-.* WORDSIZE64 powerpc64-@VENDOR@-@OS@ so we end up with only WORDSIZE{32,64} keywords in first column of soversions.i and thus e.g. Versions.all generation that looks for DEFAULT keywords is broken. The following patch considers only the first matching WORDSIZE32 resp. WORDSIZE64. 2005-02-11 Jakub Jelinek * scripts/soversions.awk: Only record first WORDSIZE{32,64} matching line. --- libc/scripts/soversions.awk.jj 2005-02-11 14:22:01.000000000 +0100 +++ libc/scripts/soversions.awk 2005-02-11 15:01:26.824281128 +0100 @@ -8,7 +8,7 @@ BEGIN { { thiscf = $1 } $2 ~ /WORDSIZE[3264]/ { - if (config ~ thiscf) { + if ((config ~ thiscf) && !othercf) { othercf = $3; sub(/@CPU@/, cpu, othercf); sub(/@VENDOR@/, vendor, othercf); Jakub From jakub@redhat.com Sat Feb 12 22:26:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 12 Feb 2005 22:26:00 -0000 Subject: [PATCH] Fix assertion failures in ld.so with prelinked ld.so Message-ID: <20050212222602.GK4777@sunsite.mff.cuni.cz> Hi! Prelinked ld.so is already relocated by prelink... 2005-02-11 Jakub Jelinek * elf/rtld.c (_dl_start): Set bootstrap_map.l_relocated even for already prelinked ld.so. --- libc/elf/rtld.c.jj 2005-01-26 18:22:16.000000000 +0100 +++ libc/elf/rtld.c 2005-02-11 15:22:21.467797051 +0100 @@ -509,8 +509,8 @@ _dl_start (void *arg) data access using the global offset table. */ ELF_DYNAMIC_RELOCATE (&bootstrap_map, 0, 0); - bootstrap_map.l_relocated = 1; } + bootstrap_map.l_relocated = 1; /* Please note that we don't allow profiling of this object and therefore need not test whether we have to allocate the array Jakub From jakub@redhat.com Sat Feb 12 22:28:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 12 Feb 2005 22:28:00 -0000 Subject: [PATCH] Fix LD_TRACE_PRELINKING Message-ID: <20050212222824.GL4777@sunsite.mff.cuni.cz> Hi! Without this patch LD_TRACE_PRELINKING doesn't report conflicts caused by ld.so relocations (malloc, free, etc.). This causes that prelinked binaries use ld.so's own malloc/free, which is in itself bad, but especially bad when e.g. ld.so malloces something and libc.so attempts to free it or the other way around. 2005-02-12 Jakub Jelinek * elf/rtld.c (dlmain): If LD_TRACE_PRELINKING, clear l_relocated flag before relocating ld.so again. --- libc/elf/rtld.c.jj 2005-02-11 15:22:21.000000000 +0100 +++ libc/elf/rtld.c 2005-02-12 10:50:50.000000000 +0100 @@ -1919,10 +1919,13 @@ ERROR: ld.so: object '%s' from %s cannot if ((GLRO(dl_debug_mask) & DL_DEBUG_PRELINK) && GL(dl_rtld_map).l_opencount > 1) - _dl_relocate_object (&GL(dl_rtld_map), main_map->l_scope, - 0, 0); - } - + { + /* Mark the link map as not yet relocated again. */ + GL(dl_rtld_map).l_relocated = 0; + _dl_relocate_object (&GL(dl_rtld_map), main_map->l_scope, + 0, 0); + } + } #define VERNEEDTAG (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (DT_VERNEED)) if (version_info) { Jakub From jakub@redhat.com Sat Feb 12 22:29:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 12 Feb 2005 22:29:00 -0000 Subject: [PATCH] Warning fix for __chk_fail Message-ID: <20050212222936.GM4777@sunsite.mff.cuni.cz> Hi! As __chk_fail is noreturn, but __libc_message is not (depending on arguments, it either returns or does not), we need this trick to shut GCC up. __libc_fatal already uses the same. 2005-02-11 Jakub Jelinek * debug/chk_fail.c (__chk_fail): Add a while (1) loop around __libc_message to kill GCC warning about noreturn function returning. --- libc/debug/chk_fail.c.jj 2005-02-07 10:20:54.000000000 +0100 +++ libc/debug/chk_fail.c 2005-02-11 16:03:47.271886099 +0100 @@ -26,7 +26,9 @@ void __attribute__ ((noreturn)) __chk_fail (void) { - __libc_message (1, "*** buffer overflow detected ***: %s terminated\n", - __libc_argv[0] ?: ""); + /* The loop is added only to keep gcc happy. */ + while (1) + __libc_message (1, "*** buffer overflow detected ***: %s terminated\n", + __libc_argv[0] ?: ""); } libc_hidden_def (__chk_fail) Jakub From schwab@suse.de Mon Feb 14 22:11:00 2005 From: schwab@suse.de (Andreas Schwab) Date: Mon, 14 Feb 2005 22:11:00 -0000 Subject: Doc fix for telldir/seekdir Message-ID: The file positions that telldir and seekdir operate on are of type long, not off_t. Andreas. 2005-02-14 Andreas Schwab * manual/filesys.texi (Random Access Directory): Fix type of file position value for telldir and seekdir. (Attribute Meanings): Fix typo. --- manual/filesys.texi.~1.96.~ 2003-11-10 09:58:21.000000000 +0100 +++ manual/filesys.texi 2005-02-14 23:03:15.326678928 +0100 @@ -531,7 +531,7 @@ added or removed since you last called @ @comment dirent.h @comment BSD -@deftypefun off_t telldir (DIR *@var{dirstream}) +@deftypefun long int telldir (DIR *@var{dirstream}) The @code{telldir} function returns the file position of the directory stream @var{dirstream}. You can use this value with @code{seekdir} to restore the directory stream to that position. @@ -539,7 +539,7 @@ restore the directory stream to that pos @comment dirent.h @comment BSD -@deftypefun void seekdir (DIR *@var{dirstream}, off_t @var{pos}) +@deftypefun void seekdir (DIR *@var{dirstream}, long int @var{pos}) The @code{seekdir} function sets the file position of the directory stream @var{dirstream} to @var{pos}. The value @var{pos} must be the result of a previous call to @code{telldir} on this particular stream; @@ -1740,7 +1740,7 @@ is transparently replaced by @code{ino64 @deftp {Data Type} ino64_t This is an arithmetic data type used to represent file serial numbers for the use in LFS. In the GNU system, this type is equivalent to -@code{unsigned long longint}. +@code{unsigned long long int}. When compiling with @code{_FILE_OFFSET_BITS == 64} this type is available under the name @code{ino_t}. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstra??e 5, 90409 N??rnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From aj@suse.de Tue Feb 15 19:55:00 2005 From: aj@suse.de (Andreas Jaeger) Date: Tue, 15 Feb 2005 19:55:00 -0000 Subject: getting glibc to compile with GCC CVS mainline In-Reply-To: (Alexandre Oliva's message of "07 Feb 2005 06:37:25 -0200") References: Message-ID: Alexandre Oliva writes: > Here are patches to fix incompatibilities with the current CVS version > of GCC. > > The first addresses a problem that causes GCC to reject auto nested > functions that are declared but not defined. The actual error message is: dl-reloc.c: In function ?_dl_relocate_object?: dynamic-link.h:44: error: nested function ?elf_machine_rel_relative? declared but never defined dynamic-link.h:37: error: nested function ?elf_machine_rel? declared but never defined > The second addresses a problem of trying to construct array types of > incomplete types. Although this is well-formed C++, it's ill-formed > C, even if the type would decay to pointer to incomplete type, which > is well-formed in both languages. There were two occurrences of this > error in glibc. Shall I commit these patches? Andreas > > Index: ChangeLog > 2005-02-03 Alexandre Oliva > > * elf/dynamic-link.h: Don't declare nested auto functions that are > not going to be defined. > > --- elf/dynamic-link.h 2005-01-22 16:18:28.000000000 -0200 > +++ elf/dynamic-link.h 2005-02-07 06:20:18.000000000 -0200 > @@ -1,5 +1,5 @@ > /* Inline functions for dynamic linking. > - Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc. > + Copyright (C) 1995-2002, 2003, 2004, 2005 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 > @@ -31,20 +31,24 @@ > optimizing away alignment tests or using word instructions for > copying memory, breaking the very code written to handle the > unaligned cases. */ > +# if ! ELF_MACHINE_NO_REL > auto void __attribute__((always_inline)) > elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc, > const ElfW(Sym) *sym, const struct r_found_version *version, > void *const reloc_addr); > auto void __attribute__((always_inline)) > +elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc, > + void *const reloc_addr); > +# endif > +# if ! ELF_MACHINE_NO_RELA > +auto void __attribute__((always_inline)) > elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, > const ElfW(Sym) *sym, const struct r_found_version *version, > void *const reloc_addr); > auto void __attribute__((always_inline)) > -elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc, > - void *const reloc_addr); > -auto void __attribute__((always_inline)) > elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc, > void *const reloc_addr); > +# endif > # if ELF_MACHINE_NO_RELA || defined ELF_MACHINE_PLT_REL > auto void __attribute__((always_inline)) > elf_machine_lazy_rel (struct link_map *map, > > Index: ChangeLog > 2005-02-02 Alexandre Oliva > > * iconvdata/jis0208.h (struct jisx0208_ucs_idx): Move declaration > before use. Fix typo in comment. > > Index: nptl/ChangeLog > 2005-02-02 Alexandre Oliva > > * sysdeps/pthread/pthread.h (__sigsetjmp): Don't declare __env > argument as array, GCC 4 doesn't like it. > > Index: iconvdata/jis0208.h > --- iconvdata/jis0208.h 2003-06-11 18:40:42.000000000 -0300 > +++ iconvdata/jis0208.h 2005-02-02 05:57:39.000000000 -0200 > @@ -27,13 +27,7 @@ > /* Conversion table. */ > extern const uint16_t __jis0208_to_ucs[]; > > -extern const char __jisx0208_from_ucs4_lat1[256][2]; > -extern const char __jisx0208_from_ucs4_greek[0xc1][2]; > -extern const struct jisx0208_ucs_idx __jisx0208_from_ucs_idx[]; > -extern const char __jisx0208_from_ucs_tab[][2]; > - > - > -/* Struct for table with indeces in UCS mapping table. */ > +/* Struct for table with indexes in UCS mapping table. */ > struct jisx0208_ucs_idx > { > uint16_t start; > @@ -41,6 +35,11 @@ > uint16_t idx; > }; > > +extern const char __jisx0208_from_ucs4_lat1[256][2]; > +extern const char __jisx0208_from_ucs4_greek[0xc1][2]; > +extern const struct jisx0208_ucs_idx __jisx0208_from_ucs_idx[]; > +extern const char __jisx0208_from_ucs_tab[][2]; > + > > static inline uint32_t > __attribute ((always_inline)) > Index: nptl/sysdeps/pthread/pthread.h > --- nptl/sysdeps/pthread/pthread.h 2004-12-05 00:18:43.000000000 -0200 > +++ nptl/sysdeps/pthread/pthread.h 2005-02-02 08:21:16.000000000 -0200 > @@ -1,4 +1,4 @@ > -/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. > +/* Copyright (C) 2002, 2003, 2004, 2005 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 > @@ -661,7 +661,7 @@ > > /* Function used in the macros. */ > struct __jmp_buf_tag; > -extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROW; > +extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROW; > > > /* Mutex handling. */ Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SUSE Linux Products GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 188 bytes Desc: not available URL: From aoliva@redhat.com Tue Feb 15 21:30:00 2005 From: aoliva@redhat.com (Alexandre Oliva) Date: Tue, 15 Feb 2005 21:30:00 -0000 Subject: getting glibc to compile with GCC CVS mainline In-Reply-To: References: Message-ID: On Feb 15, 2005, Andreas Jaeger wrote: > Alexandre Oliva writes: >> Here are patches to fix incompatibilities with the current CVS version >> of GCC. >> >> The first addresses a problem that causes GCC to reject auto nested >> functions that are declared but not defined. > The actual error message is: > dl-reloc.c: In function ?_dl_relocate_object?: > dynamic-link.h:44: error: nested function ?elf_machine_rel_relative? declared but never defined > dynamic-link.h:37: error: nested function ?elf_machine_rel? declared but never defined >> The second addresses a problem of trying to construct array types of >> incomplete types. Although this is well-formed C++, it's ill-formed >> C, even if the type would decay to pointer to incomplete type, which >> is well-formed in both languages. There were two occurrences of this >> error in glibc. > Shall I commit these patches? The latter is already in, RTH beat me to posting it. I'm told by Matthew Burgess that the former doesn't fix the problem on i*86-linux-gnu, although it does fix it on frv-linux-gnu. It seems that dl-machine.h, that defines these macros, is only included after the ELF_MACHINE_NO_REL* macros are tested for. Maybe they should be defined elsewhere? Matthew agreed to file a bug report on this problem. I figured it didn't make sense for me to waste time trying to implement a patch that wouldn't even be looked at :-/ -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org} Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org} From jakub@redhat.com Mon Feb 21 10:12:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 21 Feb 2005 10:12:00 -0000 Subject: [PATCH] Fix MALLOC_CHECK_={5,7} Message-ID: <20050221101236.GU4777@sunsite.mff.cuni.cz> Hi! Since the Jan, 7th, malloc.c change malloc_printerr will print just the program name instead of the error message, which isn't very helpful. 2005-02-21 Jakub Jelinek * malloc/malloc.c (malloc_printerr): If MALLOC_CHECK_={5,7}, print the error message rather than program name. --- libc/malloc/malloc.c.jj 2005-01-08 16:50:22.000000000 +0100 +++ libc/malloc/malloc.c 2005-02-21 10:58:05.269061553 +0100 @@ -5513,7 +5513,9 @@ extern char **__libc_argv attribute_hidd static void malloc_printerr(int action, const char *str, void *ptr) { - if (action & 1) + if ((action & 5) == 5) + __libc_message (action & 2, "%s\n", str); + else if (action & 1) { char buf[2 * sizeof (uintptr_t) + 1]; @@ -5523,8 +5525,7 @@ malloc_printerr(int action, const char * *--cp = '0'; __libc_message (action & 2, - action & 4 - ? "%s\n" : "*** glibc detected *** %s: %s: 0x%s ***\n", + "*** glibc detected *** %s: %s: 0x%s ***\n", __libc_argv[0] ?: "", str, cp); } else if (action & 2) Jakub From drepper@redhat.com Mon Feb 21 19:45:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 21 Feb 2005 19:45:00 -0000 Subject: [PATCH] Fix MALLOC_CHECK_={5,7} In-Reply-To: <20050221101236.GU4777@sunsite.mff.cuni.cz> References: <20050221101236.GU4777@sunsite.mff.cuni.cz> Message-ID: <421A39B4.4050904@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From jakub@redhat.com Mon Feb 21 21:02:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 21 Feb 2005 21:02:00 -0000 Subject: [PATCH] Fix gethostbyname when using nscd Message-ID: <20050221210207.GV4777@sunsite.mff.cuni.cz> Hi! The first hunk is the most important. Fixes a bug where e.g. with overly long /etc/hosts entries gethostbyname etc. work only when nscd is turned off but fail when it is running. The problem is that if h_errno is not set to NETDB_INTERNAL, the non-_r functions don't consider ERANGE as being because the buffer was too small and don't retry with a larger size. The rest of the changes is just something I have noticed during the debugging - there were a few places which grew the buffer sizes linearly, which is really slow for very big answers. The other places have been fixed before already to DTRT. 2005-02-21 Jakub Jelinek * nscd/nscd_gethst_r.c (nscd_gethst_r): Set *h_errnop to NETDB_INTERNAL if buffer is too small. * nscd/hstcache.c (INCR): Remove. (addhstbyX): Double buflen in each iteration rather than add INCR. * nscd/grpcache.c (INCR): Remove. (addgrbyX): Double buflen in each iteration rather than add INCR. * nscd/pwdcache.c (INCR): Remove. (addpwbyX): Double buflen in each iteration rather than add INCR. --- libc/nscd/nscd_gethst_r.c.jj 2004-11-10 10:30:32.000000000 +0100 +++ libc/nscd/nscd_gethst_r.c 2005-02-21 21:34:28.644218762 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1998-2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1998. @@ -218,6 +218,7 @@ nscd_gethst_r (const char *key, size_t k ? INADDRSZ : IN6ADDRSZ))) { no_room: + *h_errnop = NETDB_INTERNAL; __set_errno (ERANGE); retval = ERANGE; goto out_close; --- libc/nscd/hstcache.c.jj 2005-01-26 18:36:40.000000000 +0100 +++ libc/nscd/hstcache.c 2005-02-21 21:28:50.806168914 +0100 @@ -1,5 +1,5 @@ /* Cache handling for host lookup. - Copyright (C) 1998-2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1998. @@ -453,11 +453,10 @@ addhstbyX (struct database_dyn *db, int { char *old_buffer = buffer; errno = 0; -#define INCR 1024 if (__builtin_expect (buflen > 32768, 0)) { - buflen += INCR; + buflen *= 2; buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen); if (buffer == NULL) { @@ -478,7 +477,7 @@ addhstbyX (struct database_dyn *db, int else /* Allocate a new buffer on the stack. If possible combine it with the previously allocated buffer. */ - buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR); + buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen); } #if 0 --- libc/nscd/grpcache.c.jj 2005-01-26 18:36:40.000000000 +0100 +++ libc/nscd/grpcache.c 2005-02-21 21:30:49.876047695 +0100 @@ -1,5 +1,5 @@ /* Cache handling for group lookup. - Copyright (C) 1998-2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1998. @@ -429,11 +429,10 @@ addgrbyX (struct database_dyn *db, int f { char *old_buffer = buffer; errno = 0; -#define INCR 1024 if (__builtin_expect (buflen > 32768, 0)) { - buflen += INCR; + buflen *= 2; buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen); if (buffer == NULL) { @@ -454,7 +453,7 @@ addgrbyX (struct database_dyn *db, int f else /* Allocate a new buffer on the stack. If possible combine it with the previously allocated buffer. */ - buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR); + buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen); } #if 0 --- libc/nscd/pwdcache.c.jj 2005-01-26 18:36:40.000000000 +0100 +++ libc/nscd/pwdcache.c 2005-02-21 21:31:14.872612500 +0100 @@ -1,5 +1,5 @@ /* Cache handling for passwd lookup. - Copyright (C) 1998-2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1998. @@ -425,11 +425,10 @@ addpwbyX (struct database_dyn *db, int f { char *old_buffer = buffer; errno = 0; -#define INCR 1024 if (__builtin_expect (buflen > 32768, 0)) { - buflen += INCR; + buflen *= 2; buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen); if (buffer == NULL) { @@ -450,7 +449,7 @@ addpwbyX (struct database_dyn *db, int f else /* Allocate a new buffer on the stack. If possible combine it with the previously allocated buffer. */ - buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR); + buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen); } #if 0 Jakub From drepper@redhat.com Mon Feb 21 23:55:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 21 Feb 2005 23:55:00 -0000 Subject: [PATCH] Fix gethostbyname when using nscd In-Reply-To: <20050221210207.GV4777@sunsite.mff.cuni.cz> References: <20050221210207.GV4777@sunsite.mff.cuni.cz> Message-ID: <421A74FB.3080002@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From drepper@redhat.com Tue Feb 22 05:07:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 22 Feb 2005 05:07:00 -0000 Subject: [PATCH] fix crash for sed "script" /\(\)/x In-Reply-To: <420B2A82.6000606@lu.unisi.ch> References: <420B2A82.6000606@lu.unisi.ch> Message-ID: <421ABDEC.2000708@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From jakub@redhat.com Tue Feb 22 09:41:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 22 Feb 2005 09:41:00 -0000 Subject: [PATCH] Build libmcheck.a and librpcsvc.a with -fPIC Message-ID: <20050222094055.GW4777@sunsite.mff.cuni.cz> Hi! These libraries have no .so counterpart. By building them with -fPIC, one can link them into PIEs and DSOs as well. 2005-02-22 Jakub Jelinek * malloc/Makefile (CFLAGS-mcheck-init.c): Add. * sunrpc/Makefile: Add $(PIC-ccflag) to CFLAGS-x* for librpcsvc.a objects. --- libc/malloc/Makefile.jj 2004-12-21 14:33:27.000000000 +0100 +++ libc/malloc/Makefile 2005-02-22 10:31:53.542037756 +0100 @@ -101,6 +101,8 @@ $(objpfx)memusagestat: $(memusagestat-mo include ../Rules +CFLAGS-mcheck-init.c = $(PIC-ccflag) + $(objpfx)libmcheck.a: $(objpfx)mcheck-init.o -rm -f $@ $(patsubst %/,cd % &&,$(objpfx)) \ --- libc/sunrpc/Makefile.jj 2004-09-29 10:25:39.000000000 +0200 +++ libc/sunrpc/Makefile 2005-02-22 10:33:48.531584027 +0100 @@ -107,19 +107,19 @@ librpcsvc-inhibit-o = .os # Build no sha omit-deps = $(librpcsvc-routines) endif -CFLAGS-xbootparam_prot.c = -Wno-unused -CFLAGS-xnlm_prot.c = -Wno-unused -CFLAGS-xrstat.c = -Wno-unused -CFLAGS-xyppasswd.c = -Wno-unused -CFLAGS-xklm_prot.c = -Wno-unused -CFLAGS-xrex.c = -Wno-unused -CFLAGS-xsm_inter.c = -Wno-unused -CFLAGS-xmount.c = -Wno-unused -CFLAGS-xrusers.c = -Wno-unused -CFLAGS-xspray.c = -Wno-unused -CFLAGS-xnfs_prot.c = -Wno-unused -CFLAGS-xrquota.c = -Wno-unused -CFLAGS-xkey_prot.c = -Wno-unused +CFLAGS-xbootparam_prot.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xnlm_prot.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xrstat.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xyppasswd.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xklm_prot.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xrex.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xsm_inter.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xmount.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xrusers.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xspray.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xnfs_prot.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xrquota.c = -Wno-unused $(PIC-ccflag) +CFLAGS-xkey_prot.c = -Wno-unused $(PIC-ccflag) CFLAGS-auth_unix.c = -fexceptions CFLAGS-key_call.c = -fexceptions CFLAGS-pmap_rmt.c = -fexceptions Jakub From drepper@redhat.com Tue Feb 22 09:53:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 22 Feb 2005 09:53:00 -0000 Subject: [PATCH] Build libmcheck.a and librpcsvc.a with -fPIC In-Reply-To: <20050222094055.GW4777@sunsite.mff.cuni.cz> References: <20050222094055.GW4777@sunsite.mff.cuni.cz> Message-ID: <421B00EA.2090108@redhat.com> Applied. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From schwab@suse.de Tue Feb 22 14:38:00 2005 From: schwab@suse.de (Andreas Schwab) Date: Tue, 22 Feb 2005 14:38:00 -0000 Subject: Fix invalid free Message-ID: This is broken both in HEAD and in 2.3 branch. Andreas. 2005-02-22 Andreas Schwab * posix/execvp.c (execvp): Fix invalid free. --- posix/execvp.c.~1.23.~ 2005-01-29 01:31:23.000000000 +0100 +++ posix/execvp.c 2005-02-22 13:59:32.000000000 +0100 @@ -189,7 +189,7 @@ execvp (file, argv) __set_errno (EACCES); free (script_argv); - free (name); + free (name - pathlen); if (path_malloc) free (path); } -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstra??e 5, 90409 N??rnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From jakub@redhat.com Tue Feb 22 20:14:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 22 Feb 2005 20:14:00 -0000 Subject: [PATCH] Handle large requests in nscd Message-ID: <20050222201408.GX4777@sunsite.mff.cuni.cz> Hi! If nscd is supposed to serve very big requests (e.g. a group with around 7k members), nscd or the client (or both) can fail to DTRT. The problem is that nscd in many places doesn't count with partial reads/writes in read, readv or write. The following patch introduces __writeall function for the server and __readall plus __readvall functions that wrap write, __read and __readv respectively and attempt to read (resp. write) as many bytes as possible and only stop on failures, EOF condition or when the whole requested size has been read (resp. written). 2005-02-22 Jakub Jelinek * nscd/nscd-client.h: Include sys/uio.h. (__readall, __readvall, __writeall): New prototypes. * nscd/connections.c (__writeall): New function. (handle_request): Use it. * nscd/aicache.c (addhstaiX): Likewise. * nscd/initgrcache.c (addinitgroupsX): Likewise. * nscd/hstcache.c (cache_addhst): Likewise. * nscd/grpcache.c (cache_addgr): Likewise. * nscd/pwdcache.c (cache_addpw): Likewise. * nscd/nscd_helper.c (__readall, __readvall): New functions. * nscd/nscd_getai.c (__nscd_getai): Use them. * nscd/nscd_getpw_r.c (__nscd_getpw_r): Likewise. * nscd/nscd_getgr_r.c (__nscd_getgr_r): Likewise. * nscd/nscd_gethst_r.c (__nscd_gethst_r): Likewise. * nscd/nscd_initgroups.c (__nscd_getgrouplist): Likewise. --- libc/nscd/initgrcache.c.jj 2005-01-26 18:36:40.000000000 +0100 +++ libc/nscd/initgrcache.c 2005-02-22 18:39:04.774959626 +0100 @@ -1,5 +1,5 @@ /* Cache handling for host lookup. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2004. @@ -343,7 +343,7 @@ addinitgroupsX (struct database_dyn *db, unnecessarily let the receiver wait. */ assert (fd != -1); - written = TEMP_FAILURE_RETRY (write (fd, &dataset->resp, total)); + written = __writeall (fd, &dataset->resp, total); } --- libc/nscd/hstcache.c.jj 2005-02-22 10:02:31.000000000 +0100 +++ libc/nscd/hstcache.c 2005-02-22 18:30:26.680010234 +0100 @@ -327,7 +327,7 @@ cache_addhst (struct database_dyn *db, i unnecessarily keep the receiver waiting. */ assert (fd != -1); - written = TEMP_FAILURE_RETRY (write (fd, &dataset->resp, total)); + written = __writeall (fd, &dataset->resp, total); } /* Add the record to the database. But only if it has not been --- libc/nscd/grpcache.c.jj 2005-02-22 10:02:30.000000000 +0100 +++ libc/nscd/grpcache.c 2005-02-22 18:29:21.543582609 +0100 @@ -292,7 +292,7 @@ cache_addgr (struct database_dyn *db, in unnecessarily let the receiver wait. */ assert (fd != -1); - written = TEMP_FAILURE_RETRY (write (fd, &dataset->resp, total)); + written = __writeall (fd, &dataset->resp, total); } /* Add the record to the database. But only if it has not been --- libc/nscd/nscd_getgr_r.c.jj 2004-11-10 10:30:32.000000000 +0100 +++ libc/nscd/nscd_getgr_r.c 2005-02-22 18:15:07.008525858 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004 +/* Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1998. @@ -202,7 +202,7 @@ nscd_getgr_r (const char *key, size_t ke total_len = vec[0].iov_len + vec[1].iov_len; /* Get this data. */ - size_t n = TEMP_FAILURE_RETRY (__readv (sock, vec, 2)); + size_t n = __readvall (sock, vec, 2); if (__builtin_expect (n != total_len, 0)) goto out_close; } @@ -232,8 +232,7 @@ nscd_getgr_r (const char *key, size_t ke retval = 0; if (gr_name == NULL) { - size_t n = TEMP_FAILURE_RETRY (__read (sock, resultbuf->gr_mem[0], - total_len)); + size_t n = __readall (sock, resultbuf->gr_mem[0], total_len); if (__builtin_expect (n != total_len, 0)) { /* The `errno' to some value != ERANGE. */ --- libc/nscd/aicache.c.jj 2005-01-26 18:36:39.000000000 +0100 +++ libc/nscd/aicache.c 2005-02-22 18:28:55.104279879 +0100 @@ -1,5 +1,5 @@ /* Cache handling for host lookup. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2004. @@ -365,7 +365,7 @@ addhstaiX (struct database_dyn *db, int wait. */ assert (fd != -1); - TEMP_FAILURE_RETRY (write (fd, &dataset->resp, total)); + __writeall (fd, &dataset->resp, total); } goto out; --- libc/nscd/nscd_gethst_r.c.jj 2005-02-22 10:02:36.000000000 +0100 +++ libc/nscd/nscd_gethst_r.c 2005-02-22 18:16:03.525475243 +0100 @@ -299,8 +299,7 @@ nscd_gethst_r (const char *key, size_t k ++n; } - if ((size_t) TEMP_FAILURE_RETRY (__readv (sock, vec, n)) - != total_len) + if ((size_t) __readvall (sock, vec, n) != total_len) goto out_close; } else @@ -329,9 +328,8 @@ nscd_gethst_r (const char *key, size_t k /* And finally read the aliases. */ if (addr_list == NULL) { - if ((size_t) TEMP_FAILURE_RETRY (__read (sock, - resultbuf->h_aliases[0], - total_len)) == total_len) + if ((size_t) __readall (sock, resultbuf->h_aliases[0], total_len) + == total_len) { retval = 0; *result = resultbuf; --- libc/nscd/nscd_helper.c.jj 2005-02-07 10:21:15.000000000 +0100 +++ libc/nscd/nscd_helper.c 2005-02-22 18:36:13.605372284 +0100 @@ -34,6 +34,64 @@ #include "nscd-client.h" +ssize_t +__readall (int fd, void *buf, size_t len) +{ + size_t n = len; + ssize_t ret; + do + { + ret = TEMP_FAILURE_RETRY (__read (fd, buf, n)); + if (ret <= 0) + break; + buf = (char *) buf + ret; + n -= ret; + } + while (n); + return ret < 0 ? ret : len - n; +} + + +ssize_t +__readvall (int fd, const struct iovec *iov, int iovcnt) +{ + ssize_t ret = TEMP_FAILURE_RETRY (__readv (fd, iov, iovcnt)); + if (ret <= 0) + return ret; + + size_t total = 0; + int i; + for (i = 0; i < iovcnt; ++i) + total += iov[i].iov_len; + + if (ret < total) + { + struct iovec iov_buf[iovcnt], *iovp; + ssize_t r = ret; + iovp = memcpy (iov_buf, iov, iovcnt * sizeof (*iov)); + do + { + while (iovp->iov_len <= r) + { + r -= iovp->iov_len; + --iovcnt; + ++iovp; + } + iovp->iov_base = (char *) iovp->iov_base + r; + iovp->iov_len -= r; + r = TEMP_FAILURE_RETRY (__readv (fd, iovp, iovcnt)); + if (r <= 0) + break; + ret += r; + } + while (ret < total); + if (r < 0) + ret = r; + } + return ret; +} + + static int open_socket (void) { --- libc/nscd/nscd_getpw_r.c.jj 2004-11-10 10:30:32.000000000 +0100 +++ libc/nscd/nscd_getpw_r.c 2005-02-22 18:16:55.661203796 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1998. @@ -172,7 +172,7 @@ nscd_getpw_r (const char *key, size_t ke retval = 0; if (pw_name == NULL) { - ssize_t nbytes = TEMP_FAILURE_RETRY (__read (sock, buffer, total)); + ssize_t nbytes = __readall (sock, buffer, total); if (__builtin_expect (nbytes != total, 0)) { --- libc/nscd/nscd-client.h.jj 2004-11-10 10:30:32.000000000 +0100 +++ libc/nscd/nscd-client.h 2005-02-22 18:39:34.808623306 +0100 @@ -1,4 +1,5 @@ -/* Copyright (c) 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (c) 1998, 1999, 2000, 2003, 2004, 2005 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1998. @@ -28,6 +29,7 @@ #include #include #include +#include /* Version number of the daemon interface */ @@ -309,4 +311,13 @@ extern const struct datahead *__nscd_cac size_t keylen, const struct mapped_database *mapped); +/* Wrappers around read, readv and write that only read/write less than LEN + bytes on error or EOF. */ +extern ssize_t __readall (int fd, void *buf, size_t len) + attribute_hidden; +extern ssize_t __readvall (int fd, const struct iovec *iov, int iovcnt) + attribute_hidden; +extern ssize_t __writeall (int fd, const void *buf, size_t len) + attribute_hidden; + #endif /* nscd.h */ --- libc/nscd/pwdcache.c.jj 2005-02-22 10:02:40.000000000 +0100 +++ libc/nscd/pwdcache.c 2005-02-22 18:27:40.291571183 +0100 @@ -287,7 +287,7 @@ cache_addpw (struct database_dyn *db, in unnecessarily let the receiver wait. */ assert (fd != -1); - written = TEMP_FAILURE_RETRY (write (fd, &dataset->resp, total)); + written = __writeall (fd, &dataset->resp, total); } --- libc/nscd/nscd_initgroups.c.jj 2005-02-08 17:17:18.000000000 +0100 +++ libc/nscd/nscd_initgroups.c 2005-02-22 18:17:38.709548411 +0100 @@ -110,9 +110,8 @@ __nscd_getgrouplist (const char *user, g if (respdata == NULL) { /* Read the data from the socket. */ - if ((size_t) TEMP_FAILURE_RETRY (__read (sock, *groupsp, - initgr_resp->ngrps - * sizeof (gid_t))) + if ((size_t) __readall (sock, *groupsp, initgr_resp->ngrps + * sizeof (gid_t)) == initgr_resp->ngrps * sizeof (gid_t)) retval = initgr_resp->ngrps; } --- libc/nscd/nscd_getai.c.jj 2005-02-08 17:17:18.000000000 +0100 +++ libc/nscd/nscd_getai.c 2005-02-22 18:09:44.607856677 +0100 @@ -119,8 +119,7 @@ __nscd_getai (const char *key, struct ns if (respdata == NULL) { /* Read the data from the socket. */ - if ((size_t) TEMP_FAILURE_RETRY (__read (sock, resultbuf + 1, - datalen)) == datalen) + if ((size_t) __readall (sock, resultbuf + 1, datalen) == datalen) { retval = 0; *result = resultbuf; --- libc/nscd/connections.c.jj 2005-02-07 10:21:15.000000000 +0100 +++ libc/nscd/connections.c 2005-02-22 18:34:29.444878715 +0100 @@ -181,6 +181,24 @@ static int sock; unsigned long int client_queued; +ssize_t +__writeall (int fd, const void *buf, size_t len) +{ + size_t n = len; + ssize_t ret; + do + { + ret = TEMP_FAILURE_RETRY (write (fd, buf, n)); + if (ret <= 0) + break; + buf = (const char *) buf + ret; + n -= ret; + } + while (n); + return ret < 0 ? ret : len - n; +} + + /* Initialize database information structures. */ void nscd_init (void) @@ -691,7 +709,7 @@ cannot handle old request version %d; cu if (cached != NULL) { /* Hurray it's in the cache. */ - if (TEMP_FAILURE_RETRY (write (fd, cached->data, cached->recsize)) + if (__writeall (fd, cached->data, cached->recsize) != cached->recsize && __builtin_expect (debug_level, 0) > 0) { Jakub From drepper@redhat.com Tue Feb 22 22:56:00 2005 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 22 Feb 2005 22:56:00 -0000 Subject: [PATCH] Handle large requests in nscd In-Reply-To: <20050222201408.GX4777@sunsite.mff.cuni.cz> References: <20050222201408.GX4777@sunsite.mff.cuni.cz> Message-ID: <421BB872.80807@redhat.com> Applied. Although I changed __writeall to writeall. It's all in nscd itself. -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From roland@redhat.com Fri Feb 25 02:47:00 2005 From: roland@redhat.com (Roland McGrath) Date: Fri, 25 Feb 2005 02:47:00 -0000 Subject: symbol bloat for fortify warnings Message-ID: <200502250246.j1P2kw0J026108@magilla.sf.frob.com> I really dislike the addition of symbols in the dynamic symbol table, and in the ABI we will maintain permanently, just as a kludge for emitting link-time warnings. We can get the warnings done just with stuff in libc_nonshared.a, and not suffer this bloat. I propose the following approach instead. This works now to produce linker warnings. When gcc is hopefully soon extended to support an attribute like `deprecated' but with supplied message text, it can be: #define __warndecl(name, msg) \ static __inline__ __attribute__ ((__always_inline__, __warning__ (msg))) \ void name (void) { } to get better warnings at compile-time and produce no run-time overhead at all. Ok? Thanks, Roland 2005-02-24 Roland McGrath * debug/Versions (libc: GLIBC_2.4): Remove __memset_zero_constant_len_parameter. * sysdeps/generic/memset_chk.c: Remove alias and warning. * misc/sys/cdefs.h (__warndecl): New macro. * debug/warning-nop.c: New file. * string/bits/string3.h (memset): Call __warn_memset_zero_len with no arguments, instead of calling __memset_zero_constant_len_parameter. Use __warndecl for __warn_memset_zero_len. * debug/Makefile (routines): Add $(static-only-routines). (static-only-routines): New variable. Index: misc/sys/cdefs.h =================================================================== RCS file: /cvs/glibc/libc/misc/sys/cdefs.h,v retrieving revision 1.61 diff -B -b -p -u -r1.61 cdefs.h --- misc/sys/cdefs.h 7 Jan 2005 19:39:28 -0000 1.61 +++ misc/sys/cdefs.h 25 Feb 2005 02:46:07 -0000 @@ -130,6 +130,7 @@ /* Fortify support. */ #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) #define __bos0(ptr) __builtin_object_size (ptr, 0) +#define __warndecl(name, msg) extern void name (void) /* Support for flexible arrays. */ Index: string/bits/string3.h =================================================================== RCS file: /cvs/glibc/libc/string/bits/string3.h,v retrieving revision 1.2 diff -B -b -p -u -r1.2 string3.h --- string/bits/string3.h 21 Feb 2005 23:04:07 -0000 1.2 +++ string/bits/string3.h 25 Feb 2005 02:46:07 -0000 @@ -85,11 +85,11 @@ __mempcpy_ichk (void *__restrict __dest, especially problematic if the intended fill value is zero. In this case no work is done at all. We detect these problems by referring non-existing functions. */ -extern char *__memset_zero_constant_len_parameter (void *, int, size_t, - size_t); +__warndecl (__warn_memset_zero_len, + "memset used with constant zero length parameter; this could be due to transposed parameters"); #define memset(dest, ch, len) \ (__builtin_constant_p (len) && (len) == 0 \ - ? __memset_zero_constant_len_parameter (dest, ch, len, 0) \ + ? (__warn_memset_zero_len (), (void) (ch), (void) (len), (void *) (dest)) \ : ((__bos0 (dest) != (size_t) -1) \ ? __builtin___memset_chk (dest, ch, len, __bos0 (dest)) \ : __memset_ichk (dest, ch, len))) Index: debug/warning-nop.c =================================================================== RCS file: debug/warning-nop.c diff -N debug/warning-nop.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ debug/warning-nop.c 25 Feb 2005 02:46:07 -0000 @@ -0,0 +1,38 @@ +/* Dummy nop functions to elicit link-time warnings. + Copyright (C) 2005 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 + +void __nop (void) +{ +} + +/* Don't insert any other #include's before this #undef! */ + +#undef __warndecl +#define __warndecl(name, msg) \ + strong_alias (__nop, name) link_warning (name, msg) + +#undef __USE_FORTIFY_LEVEL +#define __USE_FORTIFY_LEVEL 99 + +/* Following here we need an #include for each public header file + that uses __warndecl. */ + +#include Index: debug/Makefile =================================================================== RCS file: /cvs/glibc/libc/debug/Makefile,v retrieving revision 1.23 diff -B -b -p -u -r1.23 Makefile --- debug/Makefile 21 Feb 2005 23:08:04 -0000 1.23 +++ debug/Makefile 25 Feb 2005 02:46:07 -0000 @@ -24,14 +24,16 @@ subdir := debug headers := execinfo.h distribute = sigcontextinfo.h register-dump.h frame.h -routines := backtrace backtracesyms backtracesymsfd noophooks \ +routines = backtrace backtracesyms backtracesymsfd noophooks \ memcpy_chk memmove_chk mempcpy_chk memset_chk stpcpy_chk \ strcat_chk strcpy_chk strncat_chk strncpy_chk \ sprintf_chk vsprintf_chk snprintf_chk vsnprintf_chk \ printf_chk fprintf_chk vprintf_chk vfprintf_chk \ gets_chk chk_fail readonly-area fgets_chk fgets_u_chk \ read_chk pread_chk pread64_chk recv_chk recvfrom_chk \ - readlink_chk getwd_chk getcwd_chk + readlink_chk getwd_chk getcwd_chk \ + $(static-only-routines) +static-only-routines := warning-nop CFLAGS-backtrace.c = -fno-omit-frame-pointer CFLAGS-sprintf_chk.c = -D_IO_MTSAFE_IO Index: debug/Versions =================================================================== RCS file: /cvs/glibc/libc/debug/Versions,v retrieving revision 1.5 diff -B -b -p -u -r1.5 Versions --- debug/Versions 21 Feb 2005 23:06:50 -0000 1.5 +++ debug/Versions 25 Feb 2005 02:46:07 -0000 @@ -22,7 +22,6 @@ libc { __fgets_chk; __fgets_unlocked_chk; __read_chk; __pread_chk; __pread64_chk; __readlink_chk; __getcwd_chk; __getwd_chk; - __memset_zero_constant_len_parameter; __recv_chk; __recvfrom_chk; } } Index: sysdeps/generic/memset_chk.c =================================================================== RCS file: /cvs/glibc/libc/sysdeps/generic/memset_chk.c,v retrieving revision 1.2 diff -B -b -p -u -r1.2 memset_chk.c --- sysdeps/generic/memset_chk.c 21 Feb 2005 23:05:43 -0000 1.2 +++ sysdeps/generic/memset_chk.c 25 Feb 2005 02:46:07 -0000 @@ -90,7 +90,3 @@ __memset_chk (dstpp, c, len, dstlen) return dstpp; } -strong_alias (__memset_chk, __memset_zero_constant_len_parameter) - -link_warning (__memset_zero_constant_len_parameter, - "memset used with constant zero length parameter; this could be due to transposed parameters") From jakub@redhat.com Fri Feb 25 17:28:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 25 Feb 2005 17:28:00 -0000 Subject: New read etc. checking macros Message-ID: <20050225172817.GB4777@sunsite.mff.cuni.cz> Hi! As shown on the testcase below, we generate __read_chk calls unnecessarily and the currently implemented -DA variant generates largest and slowest code. One alternative (-DB) is to only call __read_chk if we don't know if the buffer is big enough, but know the size. Another, which has the advantage that no new @GLIBC_2.4 entrypoints are needed, does the checking in the caller, either at compile time if the compiler can optimize it at compile time, or at runtime if not. #include #undef read extern void __chk_fail (void) __attribute__((noreturn)); #ifdef A extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes, size_t __buflen) __wur; #define read(fd, buf, nbytes) \ (__bos (buf) != (size_t) -1 \ ? __read_chk (fd, buf, nbytes, __bos (buf)) \ : read (fd, buf, nbytes)) #elif defined B extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes, size_t __buflen) __wur; #define read(fd, buf, nbytes) \ (__bos (buf) != (size_t) -1 \ && (!__builtin_constant_p (nbytes) || nbytes > __bos (buf)) \ ? __read_chk (fd, buf, nbytes, __bos (buf)) \ : read (fd, buf, nbytes)) #else #define read(fd, buf, nbytes) \ ({ size_t __nbytes = (nbytes); \ if (__bos (buf) != (size_t) -1 && __nbytes > __bos (buf)) \ __chk_fail (); \ read (fd, buf, __nbytes); }) #endif size_t n = 4; int main (void) { char buf[4]; volatile ssize_t ret; ret = read (0, buf, sizeof (buf)); ret = read (0, buf, 2); ret = read (0, buf, n++); ret = read (0, buf, n); ret = read (0, buf, 5); return 0; } Jakub From roland@redhat.com Fri Feb 25 23:30:00 2005 From: roland@redhat.com (Roland McGrath) Date: Fri, 25 Feb 2005 23:30:00 -0000 Subject: New read etc. checking macros In-Reply-To: Jakub Jelinek's message of Friday, 25 February 2005 18:28:17 +0100 <20050225172817.GB4777@sunsite.mff.cuni.cz> Message-ID: <200502252329.j1PNTwda032230@magilla.sf.frob.com> > Another, which has the advantage that no new @GLIBC_2.4 entrypoints are > needed, does the checking in the caller, either at compile time if the > compiler can optimize it at compile time, or at runtime if not. The recent *_chk additions that Ulrich implemented have different semantics than this. I wonder which is really preferable. What is in now for e.g. {p,f,}read_chk does the most conservative checking. That is, it does not fail unless the buffer would actually have been overrun by the read. This obviously avoids breaking anything that would not already have been biting in test cases already tried. But to me, that conservatism is more of a detriment than an advantage. This conservative approach also requires more intricate implementation work than does what you've suggested, as well as introducing many new ABI symbols. Currently, a program can do: char buf[10]; ssize_t n = read(0, buf, 20); and get no failures as long as the input available to be read happens to be no more than 10 bytes. So, the program gets __chk_fail instead of clobbering. But there is nothing here that helps a program notice early that it is vulnerable to that failure given some possible input. I would like to see this do the simple check that Jakub's third example does. If the NBYTES argument is larger than what BUF points to, it should fail immediately. In fact, when the compiler can detect this statically it might as well diagnose it directly, i.e. as if the prototype were: ssize_t read(int fd, char buf[nbytes], size_t nbytes); I can imagine reading POSIX to say that this is not in fact invoked undefined behavior when there is some external guarantee such as the program knowing that the file being read contains no more than 10 bytes. The standard C functions' specifications talk more explicitly about an array (for e.g. fgets and fread), so the strict reading might not be as permissive for those as for the POSIX functions like read. Regardless, this is desireable checking for the way people usually write their programs. Perhaps it should be done only at _FORTIFY_SOURCE >= 2. Thanks, Roland From jakub@redhat.com Sat Feb 26 00:08:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 26 Feb 2005 00:08:00 -0000 Subject: New read etc. checking macros In-Reply-To: <200502252329.j1PNTwda032230@magilla.sf.frob.com> References: <20050225172817.GB4777@sunsite.mff.cuni.cz> <200502252329.j1PNTwda032230@magilla.sf.frob.com> Message-ID: <20050226000812.GD4777@sunsite.mff.cuni.cz> On Fri, Feb 25, 2005 at 03:29:58PM -0800, Roland McGrath wrote: > I can imagine reading POSIX to say that this is not in fact invoked > undefined behavior when there is some external guarantee such as the > program knowing that the file being read contains no more than 10 bytes. > The standard C functions' specifications talk more explicitly about an > array (for e.g. fgets and fread), so the strict reading might not be as > permissive for those as for the POSIX functions like read. Regardless, > this is desireable checking for the way people usually write their programs. > Perhaps it should be done only at _FORTIFY_SOURCE >= 2. Yeah, I think we can only protect read etc. with _FORTIFY_SOURCE >= 2 which has some limitations against POSIX and not allowing bigger len than the buffer that is provided is reasonable limitation. Jakub From roland@redhat.com Sat Feb 26 00:46:00 2005 From: roland@redhat.com (Roland McGrath) Date: Sat, 26 Feb 2005 00:46:00 -0000 Subject: New read etc. checking macros In-Reply-To: Jakub Jelinek's message of Saturday, 26 February 2005 01:08:12 +0100 <20050226000812.GD4777@sunsite.mff.cuni.cz> Message-ID: <200502260046.j1Q0kgRI001009@magilla.sf.frob.com> > Yeah, I think we can only protect read etc. with _FORTIFY_SOURCE >= 2 > which has some limitations against POSIX and not allowing bigger len > than the buffer that is provided is reasonable limitation. Does the gcc magic handle cases like: struct { uint32_t magic; char foo[3]; char bar[27]; } record; if (read(fd, &record.magic, sizeof record.magic) == sizeof record.magic && record.magic == 0x1234567) n = read(fd, &record.foo, sizeof record - (&record.foo - (char*)&record)); i.e., so __bos yields 30 rather than 3? From jakub@redhat.com Sat Feb 26 00:50:00 2005 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 26 Feb 2005 00:50:00 -0000 Subject: New read etc. checking macros In-Reply-To: <200502260046.j1Q0kgRI001009@magilla.sf.frob.com> References: <20050226000812.GD4777@sunsite.mff.cuni.cz> <200502260046.j1Q0kgRI001009@magilla.sf.frob.com> Message-ID: <20050226005041.GE4777@sunsite.mff.cuni.cz> On Fri, Feb 25, 2005 at 04:46:42PM -0800, Roland McGrath wrote: > > Yeah, I think we can only protect read etc. with _FORTIFY_SOURCE >= 2 > > which has some limitations against POSIX and not allowing bigger len > > than the buffer that is provided is reasonable limitation. > > Does the gcc magic handle cases like: > > struct { > uint32_t magic; > char foo[3]; > char bar[27]; > } record; > > if (read(fd, &record.magic, sizeof record.magic) == sizeof record.magic && > record.magic == 0x1234567) > n = read(fd, &record.foo, sizeof record - (&record.foo - (char*)&record)); > > i.e., so __bos yields 30 rather than 3? __bos (&record.foo) is 3 for -D_FORTIFY_SOURCE=2, and 30 for -D_FORTIFY_SOURCE=1. So read etc. probably wants to use __bos0 (&record.foo) which is always 30. Jakub