From jakub@redhat.com Thu Oct 2 14:55:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 02 Oct 2003 14:55:00 -0000 Subject: [PATCH] New regex testcases Message-ID: <20031002125225.GA12344@sunsite.ms.mff.cuni.cz> Hi! Current CVS fails tests 8 and 9 in bug-regex11 with the patch below, without the last posix/regcomp.c revert test 4 fails and all other succeed. Haven't tried latest Paolo's patch yet. 2003-10-02 Jakub Jelinek * posix/bug-regex11.c (tests): Add new tests. * posix/bug-regex12.c (tests): Add new test. --- libc/posix/bug-regex11.c.jj 2002-10-17 19:15:06.000000000 +0200 +++ libc/posix/bug-regex11.c 2003-10-02 16:33:38.000000000 +0200 @@ -1,5 +1,5 @@ /* Regular expression tests. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2002. @@ -41,7 +41,17 @@ struct { { 0, 21 }, { 8, 9 }, { 9, 10 } } }, { "^\\(a*\\)\\1\\{9\\}\\(a\\{0,9\\}\\)\\([0-9]*;.*[^a]\\2\\([0-9]\\)\\)", "a1;;0a1aa2aaa3aaaa4aaaaa5aaaaaa6aaaaaaa7aaaaaaaa8aaaaaaaaa9aa2aa1a0", 0, - 5, { { 0, 67 }, { 0, 0 }, { 0, 1 }, { 1, 67 }, { 66, 67 } } } + 5, { { 0, 67 }, { 0, 0 }, { 0, 1 }, { 1, 67 }, { 66, 67 } } }, + /* Test for BRE expression anchoring. POSIX says just that this may match; + in glibc regex it always matched, so avoid changing it. */ + { "\\(^\\|foo\\)bar", "bar", 0, 2, { { 0, 3 }, { -1, -1 } } }, + { "\\(foo\\|^\\)bar", "bar", 0, 2, { { 0, 3 }, { -1, -1 } } }, + /* In ERE this must be treated as an anchor. */ + { "(^|foo)bar", "bar", REG_EXTENDED, 2, { { 0, 3 }, { -1, -1 } } }, + { "(foo|^)bar", "bar", REG_EXTENDED, 2, { { 0, 3 }, { -1, -1 } } }, + /* Here ^ cannot be treated as an anchor according to POSIX. */ + { "(^|foo)bar", "(^|foo)bar", 0, 2, { { 0, 10 }, { -1, -1 } } }, + { "(foo|^)bar", "(foo|^)bar", 0, 2, { { 0, 10 }, { -1, -1 } } } }; int --- libc/posix/bug-regex12.c.jj 2002-09-30 09:47:16.000000000 +0200 +++ libc/posix/bug-regex12.c 2003-10-02 16:41:16.000000000 +0200 @@ -1,5 +1,5 @@ /* Regular expression tests. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2002. @@ -32,7 +32,9 @@ struct int flags, nmatch; } tests[] = { { "^<\\([^~]*\\)\\([^~]\\)[^~]*~\\1\\(.\\).*|=.*\\3.*\\2", - "<,.8~2,~so-|=-~.0,123456789<><", REG_NOSUB, 0, } + "<,.8~2,~so-|=-~.0,123456789<><", REG_NOSUB, 0 }, + /* In ERE, all carets must be treated as anchors. */ + { "a^b", "a^b", REG_EXTENDED, 0 } }; int Jakub From jakub@redhat.com Thu Oct 2 18:04:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 02 Oct 2003 18:04:00 -0000 Subject: [PATCH] New cancellation wrapper tests Message-ID: <20031002160125.GB12344@sunsite.ms.mff.cuni.cz> Hi! With linuxthreads (before latest changes) the testcase fails for 0 (pause) and 1 (close) arg syscalls in both attempts even when clobber_lots_of_args is not called, with NPTL (before latest changes) the testcase fails for 0 (pause) and 1 (close) arg only when clobber_lots_of_regs is called (otherwise, %ecx ends up magically with the right value and thus the bug doesn't show up). 2003-10-02 Jakub Jelinek nptl/ * Makefile (tests): Add tst-cancel19. * tst-cancel19.c: New test. linuxthreads/ * Makefile (tests): Add tst-cancel8. * tst-cancel8.c: New test. --- libc/nptl/tst-cancel19.c.jj 2003-10-02 19:45:12.000000000 +0200 +++ libc/nptl/tst-cancel19.c 2003-10-02 19:54:28.000000000 +0200 @@ -0,0 +1,287 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void * +tf (void *arg) +{ + return NULL; +} + +static void +handler (int sig) +{ +} + +static void __attribute__ ((noinline)) +clobber_lots_of_regs (void) +{ +#define X1(n) long r##n = 10##n; __asm __volatile ("" : "+r" (r##n)); +#define X2(n) X1(n##0) X1(n##1) X1(n##2) X1(n##3) X1(n##4) +#define X3(n) X2(n##0) X2(n##1) X2(n##2) X2(n##3) X2(n##4) + X3(0) X3(1) X3(2) X3(3) X3(4) +#undef X1 +#define X1(n) __asm __volatile ("" : : "r" (r##n)); + X3(0) X3(1) X3(2) X3(3) X3(4) +#undef X1 +#undef X2 +#undef X3 +} + +static int +do_test (void) +{ + pthread_t th; + int old, rc; + int ret = 0; + int fd[2]; + + rc = pipe (fd); + if (rc < 0) + error (EXIT_FAILURE, errno, "couldn't create pipe"); + + rc = pthread_create (&th, NULL, tf, NULL); + if (rc) + error (EXIT_FAILURE, rc, "couldn't create thread"); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "1st pthread_setcanceltype failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED && old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "1st pthread_setcanceltype returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + close (fd[0]); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after close failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after close returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + close (fd[1]); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd close failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd close returned invalid value %d", + old); + ret = 1; + } + + struct sigaction sa = { .sa_handler = handler, .sa_flags = 0 }; + sigemptyset (&sa.sa_mask); + sigaction (SIGALRM, &sa, NULL); + + struct itimerval it; + it.it_value.tv_sec = 1; + it.it_value.tv_usec = 0; + it.it_interval = it.it_value; + setitimer (ITIMER_REAL, &it, NULL); + + clobber_lots_of_regs (); + pause (); + + memset (&it, 0, sizeof (it)); + setitimer (ITIMER_REAL, &it, NULL); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after pause failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after pause returned invalid value %d", + old); + ret = 1; + } + + it.it_value.tv_sec = 1; + it.it_value.tv_usec = 0; + it.it_interval = it.it_value; + setitimer (ITIMER_REAL, &it, NULL); + + clobber_lots_of_regs (); + pause (); + + memset (&it, 0, sizeof (it)); + setitimer (ITIMER_REAL, &it, NULL); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd pause failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd pause returned invalid value %d", + old); + ret = 1; + } + + char fname[] = "/tmp/tst-cancel19-dir-XXXXXX\0foo/bar"; + char *enddir = strchr (fname, '\0'); + if (mkdtemp (fname) == NULL) + { + error (0, errno, "mkdtemp failed"); + ret = 1; + } + *enddir = '/'; + + clobber_lots_of_regs (); + creat (fname, 0400); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after creat failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after creat returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + creat (fname, 0400); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd creat failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd creat returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + open (fname, O_CREAT, 0400); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after open failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after open returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + open (fname, O_CREAT, 0400); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd open failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd open returned invalid value %d", + old); + ret = 1; + } + + *enddir = '\0'; + rmdir (fname); + + clobber_lots_of_regs (); + select (-1, NULL, NULL, NULL, NULL); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after select failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after select returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + select (-1, NULL, NULL, NULL, NULL); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd select failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd select returned invalid value %d", + old); + ret = 1; + } + + pthread_join (th, NULL); + + return ret; +} + +#define TIMEOUT 20 +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" --- libc/nptl/Makefile.jj 2003-09-24 11:38:19.000000000 +0200 +++ libc/nptl/Makefile 2003-10-02 19:56:09.000000000 +0200 @@ -215,7 +215,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 \ tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \ tst-cancel6 tst-cancel7 tst-cancel8 tst-cancel9 tst-cancel10 \ tst-cancel11 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 \ - tst-cancel16 tst-cancel17 tst-cancel18 \ + tst-cancel16 tst-cancel17 tst-cancel18 tst-cancel19 \ tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 \ tst-flock1 tst-flock2 \ tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \ --- libc/linuxthreads/tst-cancel8.c.jj 2003-10-02 19:56:32.000000000 +0200 +++ libc/linuxthreads/tst-cancel8.c 2003-10-02 19:56:50.000000000 +0200 @@ -0,0 +1,287 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void * +tf (void *arg) +{ + return NULL; +} + +static void +handler (int sig) +{ +} + +static void __attribute__ ((noinline)) +clobber_lots_of_regs (void) +{ +#define X1(n) long r##n = 10##n; __asm __volatile ("" : "+r" (r##n)); +#define X2(n) X1(n##0) X1(n##1) X1(n##2) X1(n##3) X1(n##4) +#define X3(n) X2(n##0) X2(n##1) X2(n##2) X2(n##3) X2(n##4) + X3(0) X3(1) X3(2) X3(3) X3(4) +#undef X1 +#define X1(n) __asm __volatile ("" : : "r" (r##n)); + X3(0) X3(1) X3(2) X3(3) X3(4) +#undef X1 +#undef X2 +#undef X3 +} + +static int +do_test (void) +{ + pthread_t th; + int old, rc; + int ret = 0; + int fd[2]; + + rc = pipe (fd); + if (rc < 0) + error (EXIT_FAILURE, errno, "couldn't create pipe"); + + rc = pthread_create (&th, NULL, tf, NULL); + if (rc) + error (EXIT_FAILURE, rc, "couldn't create thread"); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "1st pthread_setcanceltype failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED && old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "1st pthread_setcanceltype returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + close (fd[0]); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after close failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after close returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + close (fd[1]); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd close failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd close returned invalid value %d", + old); + ret = 1; + } + + struct sigaction sa = { .sa_handler = handler, .sa_flags = 0 }; + sigemptyset (&sa.sa_mask); + sigaction (SIGALRM, &sa, NULL); + + struct itimerval it; + it.it_value.tv_sec = 1; + it.it_value.tv_usec = 0; + it.it_interval = it.it_value; + setitimer (ITIMER_REAL, &it, NULL); + + clobber_lots_of_regs (); + pause (); + + memset (&it, 0, sizeof (it)); + setitimer (ITIMER_REAL, &it, NULL); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after pause failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after pause returned invalid value %d", + old); + ret = 1; + } + + it.it_value.tv_sec = 1; + it.it_value.tv_usec = 0; + it.it_interval = it.it_value; + setitimer (ITIMER_REAL, &it, NULL); + + clobber_lots_of_regs (); + pause (); + + memset (&it, 0, sizeof (it)); + setitimer (ITIMER_REAL, &it, NULL); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd pause failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd pause returned invalid value %d", + old); + ret = 1; + } + + char fname[] = "/tmp/tst-lt-cancel8-dir-XXXXXX\0foo/bar"; + char *enddir = strchr (fname, '\0'); + if (mkdtemp (fname) == NULL) + { + error (0, errno, "mkdtemp failed"); + ret = 1; + } + *enddir = '/'; + + clobber_lots_of_regs (); + creat (fname, 0400); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after creat failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after creat returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + creat (fname, 0400); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd creat failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd creat returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + open (fname, O_CREAT, 0400); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after open failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after open returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + open (fname, O_CREAT, 0400); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd open failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd open returned invalid value %d", + old); + ret = 1; + } + + *enddir = '\0'; + rmdir (fname); + + clobber_lots_of_regs (); + select (-1, NULL, NULL, NULL, NULL); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after select failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_DEFERRED) + { + error (0, 0, "pthread_setcanceltype after select returned invalid value %d", + old); + ret = 1; + } + + clobber_lots_of_regs (); + select (-1, NULL, NULL, NULL, NULL); + + rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old); + if (rc) + { + error (0, rc, "pthread_setcanceltype after 2nd select failed"); + ret = 1; + } + if (old != PTHREAD_CANCEL_ASYNCHRONOUS) + { + error (0, 0, "pthread_setcanceltype after 2nd select returned invalid value %d", + old); + ret = 1; + } + + pthread_join (th, NULL); + + return ret; +} + +#define TIMEOUT 20 +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" --- libc/linuxthreads/Makefile.jj 2003-09-22 17:35:40.000000000 +0200 +++ libc/linuxthreads/Makefile 2003-10-02 19:57:18.000000000 +0200 @@ -109,7 +109,7 @@ tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \ ex17 ex18 tst-cancel tst-context bug-sleep \ tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \ - tst-cancel6 tst-cancel7 tst-popen tst-popen2 tst-attr1 + tst-cancel6 tst-cancel7 tst-cancel8 tst-popen tst-popen2 tst-attr1 test-srcs = tst-signal # These tests are linked with libc before libpthread tests-reverse += tst-cancel5 Jakub From drepper@redhat.com Thu Oct 2 18:49:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 02 Oct 2003 18:49:00 -0000 Subject: [PATCH] New cancellation wrapper tests In-Reply-To: <20031002160125.GB12344@sunsite.ms.mff.cuni.cz> References: <20031002160125.GB12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F7C7339.6020008@redhat.com> Thanks, I've applied the patch. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jakub@redhat.com Fri Oct 3 13:18:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 03 Oct 2003 13:18:00 -0000 Subject: [PATCH] Support backtrace () on IA-64, make it work even with -fomit-frame-pointer on AMD64 Message-ID: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> Hi! sysdeps/generic/backtrace.c doesn't work on IA-64 and with -fomit-frame-pointer doesn't work on AMD64. But all IA-64 code has .IA_64.unwind* and AMD64 uses -fasynchronous-unwind-tables by default. The following patch uses unwind info for backtrace instead of stack frame walking by hand on these arches. segfault.c will need similar treatment, but I don't think it is good idea to duplicate the whole file. Either the portion which records backtrace needs to be macroized, such that sysdeps/ia64/segfault.c can use its own version, or we could change backtrace's API such that e.g. backtrace (NULL, size) would return number of frames which would return the same value as backtrace (array, size), but without storing anything into array, then segfault.c could do: int cnt = backtrace (NULL, 65536); arr = alloca (cnt * sizeof (void *)); cnt = backtrace (arr, cnt); (or even INT_MAX instead of 65536, though limiting the backtrace size IMHO makes sense). 2003-10-03 Jakub Jelinek * sysdeps/ia64/backtrace.c: New file. * sysdeps/x86_64/backtrace.c: New file. --- libc/sysdeps/ia64/backtrace.c.jj 2003-10-03 14:36:36.000000000 +0200 +++ libc/sysdeps/ia64/backtrace.c 2003-10-03 14:52:09.000000000 +0200 @@ -0,0 +1,79 @@ +/* Return backtrace of current program state. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include + +struct trace_arg +{ + void **array; + int cnt, size; +}; + +static _Unwind_Reason_Code +backtrace_helper (struct _Unwind_Context *ctx, void *a) +{ + struct trace_arg *arg = a; + + /* We are first called with address in the __backtrace function. + Skip it. */ + if (arg->cnt != -1) + arg->array[arg->cnt] = (void *) _Unwind_GetIP (ctx); + if (++arg->cnt == arg->size) + return _URC_END_OF_STACK; + return _URC_NO_REASON; +} + +int +__backtrace (array, size) + void **array; + int size; +{ + struct trace_arg arg = { .array = array, .size = size, .cnt = -1 }; + static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *); + + if (unwind_backtrace == NULL) + { + void *handle = __libc_dlopen ("libgcc_s.so.1"); + _Unwind_Reason_Code (*fn) (_Unwind_Trace_Fn, void *); + + if (handle == NULL) + return 0; + + fn = __libc_dlsym (handle, "_Unwind_Backtrace"); + if (fn == NULL) + fn = (void *) -1; + unwind_backtrace = fn; + } + if (unwind_backtrace == (void *) -1) + return 0; + + if (size >= 1) + unwind_backtrace (backtrace_helper, &arg); + + /* _Unwind_Backtrace on IA-64 seems to put NULL address above + _start. Fix it up here. */ + if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL) + --arg.cnt; + return arg.cnt != -1 ? arg.cnt : 0; +} +weak_alias (__backtrace, backtrace) --- libc/sysdeps/x86_64/backtrace.c.jj 2003-10-03 15:02:54.000000000 +0200 +++ libc/sysdeps/x86_64/backtrace.c 2003-10-03 15:02:49.000000000 +0200 @@ -0,0 +1 @@ +#include "../ia64/backtrace.c" Jakub From drepper@redhat.com Sat Oct 4 21:16:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 04 Oct 2003 21:16:00 -0000 Subject: [PATCH] Support backtrace () on IA-64, make it work even with -fomit-frame-pointer on AMD64 In-Reply-To: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> References: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F7F3882.7080106@redhat.com> Jakub Jelinek wrote: > 2003-10-03 Jakub Jelinek > > * sysdeps/ia64/backtrace.c: New file. > * sysdeps/x86_64/backtrace.c: New file. Doesn't work for me on ia64 with gcc 3.2. At link time libgcc_eh.a and the unwind functions in libc collide. To make things compile in the first place I had to extend unwind.h with at least the type definition of _Unwind_Trace_Fn. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From jakub@redhat.com Sun Oct 5 09:57:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 05 Oct 2003 09:57:00 -0000 Subject: [PATCH] Support backtrace () on IA-64, make it work even with -fomit-frame-pointer on AMD64 In-Reply-To: <3F7F3882.7080106@redhat.com> References: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> <3F7F3882.7080106@redhat.com> Message-ID: <20031005075459.GJ12344@sunsite.ms.mff.cuni.cz> On Sat, Oct 04, 2003 at 02:15:46PM -0700, Ulrich Drepper wrote: > Jakub Jelinek wrote: > > > > 2003-10-03 Jakub Jelinek > > > > * sysdeps/ia64/backtrace.c: New file. > > * sysdeps/x86_64/backtrace.c: New file. > > Doesn't work for me on ia64 with gcc 3.2. At link time libgcc_eh.a and > the unwind functions in libc collide. > > To make things compile in the first place I had to extend unwind.h with > at least the type definition of _Unwind_Trace_Fn. Sorry, I only compiled it outside of glibc and there it worked. Here is a better patch (built on amd64, passed make check, checked output of a few sample proglets): 2003-10-05 Jakub Jelinek * sysdeps/ia64/backtrace.c: New file. * sysdeps/x86_64/backtrace.c: New file. * sysdeps/generic/unwind.h (_Unwind_Trace_Fn): New type. (_Unwind_Backtrace): New prototype. --- libc/sysdeps/ia64/backtrace.c.jj 2003-10-03 14:36:36.000000000 +0200 +++ libc/sysdeps/ia64/backtrace.c 2003-10-05 11:41:34.000000000 +0200 @@ -0,0 +1,85 @@ +/* Return backtrace of current program state. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include + +struct trace_arg +{ + void **array; + int cnt, size; +}; + +static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *); +static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *); + +static void +init (void) +{ + void *handle = __libc_dlopen ("libgcc_s.so.1"); + + if (handle == NULL) + return; + + unwind_backtrace = __libc_dlsym (handle, "_Unwind_Backtrace"); + unwind_getip = __libc_dlsym (handle, "_Unwind_GetIP"); + if (unwind_getip == NULL) + unwind_backtrace = NULL; +} + +static _Unwind_Reason_Code +backtrace_helper (struct _Unwind_Context *ctx, void *a) +{ + struct trace_arg *arg = a; + + /* We are first called with address in the __backtrace function. + Skip it. */ + if (arg->cnt != -1) + arg->array[arg->cnt] = (void *) unwind_getip (ctx); + if (++arg->cnt == arg->size) + return _URC_END_OF_STACK; + return _URC_NO_REASON; +} + +int +__backtrace (array, size) + void **array; + int size; +{ + struct trace_arg arg = { .array = array, .size = size, .cnt = -1 }; + __libc_once_define (static, once); + + __libc_once (once, init); + if (unwind_backtrace == NULL) + return 0; + + if (size >= 1) + unwind_backtrace (backtrace_helper, &arg); + + /* _Unwind_Backtrace on IA-64 seems to put NULL address above + _start. Fix it up here. */ + if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL) + --arg.cnt; + return arg.cnt != -1 ? arg.cnt : 0; +} +weak_alias (__backtrace, backtrace) --- libc/sysdeps/x86_64/backtrace.c.jj 2003-10-03 15:02:54.000000000 +0200 +++ libc/sysdeps/x86_64/backtrace.c 2003-10-03 15:02:49.000000000 +0200 @@ -0,0 +1 @@ +#include "../ia64/backtrace.c" --- libc/sysdeps/generic/unwind.h.jj Thu Sep 4 03:45:02 2003 +++ libc/sysdeps/generic/unwind.h Sat Oct 4 08:59:35 2003 @@ -130,6 +130,14 @@ extern void _Unwind_DeleteException (str e.g. executing cleanup code, and not to implement rethrowing. */ extern void _Unwind_Resume (struct _Unwind_Exception *); +/* @@@ Use unwind data to perform a stack backtrace. The trace callback + is called for every stack frame in the call chain, but no cleanup + actions are performed. */ +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) + (struct _Unwind_Context *, void *); + +extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *); + /* These functions are used for communicating information about the unwind context (i.e. the unwind descriptors and the user register state) between the unwind library and the personality routine and landing pad. Only Jakub From drepper@redhat.com Sun Oct 5 19:32:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 05 Oct 2003 19:32:00 -0000 Subject: [PATCH] Support backtrace () on IA-64, make it work even with -fomit-frame-pointer on AMD64 In-Reply-To: <20031005075459.GJ12344@sunsite.ms.mff.cuni.cz> References: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> <3F7F3882.7080106@redhat.com> <20031005075459.GJ12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F8071BA.1060409@redhat.com> Jakub Jelinek wrote: > 2003-10-05 Jakub Jelinek > > * sysdeps/ia64/backtrace.c: New file. > * sysdeps/x86_64/backtrace.c: New file. > * sysdeps/generic/unwind.h (_Unwind_Trace_Fn): New type. > (_Unwind_Backtrace): New prototype. Applied, thanks. -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- From davidm@napali.hpl.hp.com Wed Oct 8 21:42:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Wed, 08 Oct 2003 21:42:00 -0000 Subject: support INLINE_SYSCALL & INTERNAL_SYSCALL via new ia64 syscall stub In-Reply-To: <3F7A1874.5020609@redhat.com> References: <200309270421.h8R4LTKs031759@napali.hpl.hp.com> <3F7A1874.5020609@redhat.com> Message-ID: <16260.33959.742372.309581@napali.hpl.hp.com> >>>>> On Tue, 30 Sep 2003 16:57:40 -0700, Ulrich Drepper said: Uli> David Mosberger wrote: >> The patch below is relative to the CVS sysdep.h and adds support for >> doing INLINE_SYSCALL and INTERNAL_SYSCALL via the new ia64 syscall >> stubs Uli> No, it doesn't. The patch is very incomplete. Try again, Uli> after testing. Perhaps I wasn't clear enough: yes, the patch was for sysdep.h ONLY. Everything else remained unchanged w.r.t. to my earlier new-syscall stub support patch. My patch wasn't meant for acceptance into libc, since (as I understand it), things aren't totally settled yet in regards to new-syscall-stub support. Instead, my patch was meant to show how to do inline-syscalls on ia64 with the new syscall stubs. Sorry if the patch caused confusion. I do hope it's useful to folks interested in adding new-syscall-stub support to glibc. --david From schwab@suse.de Thu Oct 9 12:47:00 2003 From: schwab@suse.de (Andreas Schwab) Date: Thu, 09 Oct 2003 12:47:00 -0000 Subject: [PATCH] Support backtrace () on IA-64, make it work even with -fomit-frame-pointer on AMD64 In-Reply-To: <20031005075459.GJ12344@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Sun, 5 Oct 2003 09:54:59 +0200") References: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> <3F7F3882.7080106@redhat.com> <20031005075459.GJ12344@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Sorry, I only compiled it outside of glibc and there it worked. > Here is a better patch (built on amd64, passed make check, checked output > of a few sample proglets): Doesn't seem to work on ia64, though. $ gdb ../cc/debug/backtrace-tst GNU gdb 6.0 Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "ia64-suse-linux"... (gdb) r Starting program: /usr/src/packages/BUILD/glibc-2.3/cc/debug/backtrace-tst Program received signal SIGABRT, Aborted. 0x200000000009cca2 in kill () from /usr/src/packages/BUILD/glibc-2.3/cc/libc.so.6.1 (gdb) bt #0 0x200000000009cca2 in kill () from /usr/src/packages/BUILD/glibc-2.3/cc/libc.so.6.1 #1 0x200000000009c990 in *__GI_raise (sig=6) at ../linuxthreads/sysdeps/unix/sysv/linux/raise.c:33 #2 0x200000000009f340 in *__GI_abort () at ../sysdeps/generic/abort.c:50 #3 0x20000000002c9de0 in uw_update_reg_address () from /lib/libgcc_s.so.1 #4 0x20000000002ca2a0 in uw_update_context () from /lib/libgcc_s.so.1 #5 0x20000000002cbf30 in _Unwind_Backtrace () from /lib/libgcc_s.so.1 #6 0x2000000000220dc0 in __backtrace (array=0x20000000002b64e8, size=20) at ../sysdeps/ia64/backtrace.c:77 #7 0x4000000000000a00 in compare (p1=0x60000fffffffaad0, p2=0x60000fffffffaad4) at backtrace-tst.c:11 #8 0x20000000000a0020 in msort_with_tmp (b=0x60000fffffffaad0, n=2, s=4, cmp=@0x4000000000000f20: 0x40000000000009d0 , t=0x60000fffffffaa70 "") at msort.c:34 #9 0x200000000009fef0 in msort_with_tmp (b=0x60000fffffffaad0, n=5, s=4, cmp=@0x4000000000000f20: 0x40000000000009d0 , t=0x60000fffffffaa70 "") at msort.c:47 Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N??rnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From jakub@redhat.com Thu Oct 9 13:06:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 09 Oct 2003 13:06:00 -0000 Subject: [PATCH] Support backtrace () on IA-64, make it work even with -fomit-frame-pointer on AMD64 In-Reply-To: References: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> <3F7F3882.7080106@redhat.com> <20031005075459.GJ12344@sunsite.ms.mff.cuni.cz> Message-ID: <20031009110337.GR12344@sunsite.ms.mff.cuni.cz> On Thu, Oct 09, 2003 at 02:47:53PM +0200, Andreas Schwab wrote: > Jakub Jelinek writes: > > > Sorry, I only compiled it outside of glibc and there it worked. > > Here is a better patch (built on amd64, passed make check, checked output > > of a few sample proglets): > > Doesn't seem to work on ia64, though. Works for me just fine (gcc-3_3-rhl-branch libgcc_s.so.1), with various CFLAGS used for backtrace-tst (-O2, -O0, with or without -Wl,--export-dynamic, etc.). What kind of libgcc you're using? Jakub From schwab@suse.de Thu Oct 9 14:04:00 2003 From: schwab@suse.de (Andreas Schwab) Date: Thu, 09 Oct 2003 14:04:00 -0000 Subject: [PATCH] Support backtrace () on IA-64, make it work even with -fomit-frame-pointer on AMD64 In-Reply-To: <20031009110337.GR12344@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Thu, 9 Oct 2003 13:03:37 +0200") References: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> <3F7F3882.7080106@redhat.com> <20031005075459.GJ12344@sunsite.ms.mff.cuni.cz> <20031009110337.GR12344@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Thu, Oct 09, 2003 at 02:47:53PM +0200, Andreas Schwab wrote: >> Jakub Jelinek writes: >> >> > Sorry, I only compiled it outside of glibc and there it worked. >> > Here is a better patch (built on amd64, passed make check, checked output >> > of a few sample proglets): >> >> Doesn't seem to work on ia64, though. > > Works for me just fine (gcc-3_3-rhl-branch libgcc_s.so.1), > with various CFLAGS used for backtrace-tst (-O2, -O0, with or without > -Wl,--export-dynamic, etc.). > What kind of libgcc you're using? Just the one that comes with gcc 3.3.1. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N??rnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From jakub@redhat.com Thu Oct 9 14:15:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 09 Oct 2003 14:15:00 -0000 Subject: [PATCH] Support backtrace () on IA-64, make it work even with -fomit-frame-pointer on AMD64 In-Reply-To: References: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> <3F7F3882.7080106@redhat.com> <20031005075459.GJ12344@sunsite.ms.mff.cuni.cz> <20031009110337.GR12344@sunsite.ms.mff.cuni.cz> Message-ID: <20031009121244.GT12344@sunsite.ms.mff.cuni.cz> On Thu, Oct 09, 2003 at 04:04:42PM +0200, Andreas Schwab wrote: > Jakub Jelinek writes: > > > On Thu, Oct 09, 2003 at 02:47:53PM +0200, Andreas Schwab wrote: > >> Jakub Jelinek writes: > >> > >> > Sorry, I only compiled it outside of glibc and there it worked. > >> > Here is a better patch (built on amd64, passed make check, checked output > >> > of a few sample proglets): > >> > >> Doesn't seem to work on ia64, though. > > > > Works for me just fine (gcc-3_3-rhl-branch libgcc_s.so.1), > > with various CFLAGS used for backtrace-tst (-O2, -O0, with or without > > -Wl,--export-dynamic, etc.). > > What kind of libgcc you're using? > > Just the one that comes with gcc 3.3.1. Diffing gcc-3_3{,-rhl}-branch, I think just 2003-05-16 Jakub Jelinek * config/ia64/unwind-ia64.c (uw_update_reg_address): Handle .save XX, r0. might be the difference which matters. This patch is on the trunk, gcc-3_3-rhl-branch and gcc-3_2-rhl8-branch, but not on gcc-3_3-branch. Might ask Mark if he allows that for 3.3.2... Certainly, without that not just backtrace, but lots of other things (like NPTL) don't work properly. Jakub From sjmunroe@us.ibm.com Thu Oct 9 21:08:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Thu, 09 Oct 2003 21:08:00 -0000 Subject: [PATCH] add c++types check for PPC and PPC64 Message-ID: <3F85CECC.5090209@us.ibm.com> Added c++-types checking for powerpc and powerpc64. The current Makefile does not allow multiple "config-machine"s that require difference types under a single "base-machine" (like powerpc32 and powerpc64). So I patch Makefile to check using the "config-machine" first then check for the "base-machine" in the else leg. 2003-10-09 Steven Munroe * Makecheck: Allow for c++-types-$(config-machine)-$(config-os).data in addition to c++-types-$(base-machine)-$(config-os).data. * scripts/data/c++-types-powerpc-linux-gnu.data: New file. * scripts/data/c++-types-powerpc64-linux-gnu.data: New file. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ppc-c++-types-20031006.patch URL: From schwab@suse.de Fri Oct 10 08:33:00 2003 From: schwab@suse.de (Andreas Schwab) Date: Fri, 10 Oct 2003 08:33:00 -0000 Subject: [PATCH] Support backtrace () on IA-64, make it work even with -fomit-frame-pointer on AMD64 In-Reply-To: <20031009121244.GT12344@sunsite.ms.mff.cuni.cz> (Jakub Jelinek's message of "Thu, 9 Oct 2003 14:12:44 +0200") References: <20031003111537.GD12344@sunsite.ms.mff.cuni.cz> <3F7F3882.7080106@redhat.com> <20031005075459.GJ12344@sunsite.ms.mff.cuni.cz> <20031009110337.GR12344@sunsite.ms.mff.cuni.cz> <20031009121244.GT12344@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > On Thu, Oct 09, 2003 at 04:04:42PM +0200, Andreas Schwab wrote: >> Jakub Jelinek writes: >> >> > On Thu, Oct 09, 2003 at 02:47:53PM +0200, Andreas Schwab wrote: >> >> Jakub Jelinek writes: >> >> >> >> > Sorry, I only compiled it outside of glibc and there it worked. >> >> > Here is a better patch (built on amd64, passed make check, checked output >> >> > of a few sample proglets): >> >> >> >> Doesn't seem to work on ia64, though. >> > >> > Works for me just fine (gcc-3_3-rhl-branch libgcc_s.so.1), >> > with various CFLAGS used for backtrace-tst (-O2, -O0, with or without >> > -Wl,--export-dynamic, etc.). >> > What kind of libgcc you're using? >> >> Just the one that comes with gcc 3.3.1. > > Diffing gcc-3_3{,-rhl}-branch, I think just > 2003-05-16 Jakub Jelinek > > * config/ia64/unwind-ia64.c (uw_update_reg_address): Handle > .save XX, r0. > might be the difference which matters. Thanks, that did it. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N??rnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From kkojima@rr.iij4u.or.jp Tue Oct 14 02:31:00 2003 From: kkojima@rr.iij4u.or.jp (kaz Kojima) Date: Tue, 14 Oct 2003 02:31:00 -0000 Subject: [PATCH] SH: Add pad instructions after trapa instruction Message-ID: <20031014.113110.56040264.kkojima@rr.iij4u.or.jp> Hi, The attached patch adds pad instructions to avoid the SH-4 core bug for the trapa instruction in DO_CALL macro. Regards, kaz -- 2003-10-13 Kaz Kojima (DO_CALL): Add SYSCALL_INST_PAD after trapa instruction. diff -u3prN ORIG/libc/sysdeps/unix/sysv/linux/sh/sysdep.h LOCAL/libc/sysdeps/unix/sysv/linux/sh/sysdep.h --- ORIG/libc/sysdeps/unix/sysv/linux/sh/sysdep.h Sun Sep 21 20:59:10 2003 +++ LOCAL/libc/sysdeps/unix/sysv/linux/sh/sysdep.h Tue Oct 14 10:15:48 2003 @@ -183,6 +183,13 @@ # endif /* _LIBC_REENTRANT */ #endif /* PIC */ +# ifdef NEED_SYSCALL_INST_PAD +# define SYSCALL_INST_PAD \ + or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0 +# else +# define SYSCALL_INST_PAD +# endif + #define SYSCALL_INST0 trapa #0x10 #define SYSCALL_INST1 trapa #0x11 #define SYSCALL_INST2 trapa #0x12 @@ -195,18 +202,12 @@ #define DO_CALL(syscall_name, args) \ mov.l 1f,r3; \ SYSCALL_INST##args; \ + SYSCALL_INST_PAD; \ bra 2f; \ nop; \ .align 2; \ 1: .long SYS_ify (syscall_name); \ 2: - -# ifdef NEED_SYSCALL_INST_PAD -# define SYSCALL_INST_PAD \ - or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0 -# else -# define SYSCALL_INST_PAD -# endif #else /* not __ASSEMBLER__ */ From jakub@redhat.com Tue Oct 14 23:35:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 14 Oct 2003 23:35:00 -0000 Subject: [PATCH] Print number of relative relocations in LD_DEBUG=statistics output Message-ID: <20031014213157.GD12344@sunsite.ms.mff.cuni.cz> Hi! I think this is useful (although it is possible to dig it through readelf on all of used libraries plus ldd (or LD_TRACE_PRELINKING) to see what libraries are mapped at their desired locations). Adds 160 bytes to ld.so's .text section and 64 bytes to .rodata in my i686 build. 2003-10-15 Jakub Jelinek * elf/rtld.c (print_statistics): Print also number of relative relocations. --- libc/elf/rtld.c.jj 2003-10-02 21:51:05.000000000 +0200 +++ libc/elf/rtld.c 2003-10-15 00:57:09.000000000 +0200 @@ -2118,10 +2118,30 @@ print_statistics (void) buf, pbuf); } #endif + + unsigned long int num_relative_relocations = 0; + struct r_scope_elem *scope = &GL(dl_loaded)->l_searchlist; + unsigned int i; + + for (i = 0; i < scope->r_nlist; i++) + { + struct link_map *l = scope->r_list [i]; + + if (!l->l_addr) + continue; + + if (l->l_info[VERSYMIDX (DT_RELCOUNT)]) + num_relative_relocations += l->l_info[VERSYMIDX (DT_RELCOUNT)]->d_un.d_val; + if (l->l_info[VERSYMIDX (DT_RELACOUNT)]) + num_relative_relocations += l->l_info[VERSYMIDX (DT_RELACOUNT)]->d_un.d_val; + } + INTUSE(_dl_debug_printf) (" number of relocations: %lu\n", GL(dl_num_relocations)); INTUSE(_dl_debug_printf) (" number of relocations from cache: %lu\n", GL(dl_num_cache_relocations)); + INTUSE(_dl_debug_printf) (" number of relative relocations: %lu\n", + num_relative_relocations); #ifndef HP_TIMING_NONAVAIL /* Time spend while loading the object and the dependencies. */ Jakub From drepper@redhat.com Wed Oct 15 04:37:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 15 Oct 2003 04:37:00 -0000 Subject: [PATCH] SH: Add pad instructions after trapa instruction In-Reply-To: <20031014.113110.56040264.kkojima@rr.iij4u.or.jp> References: <20031014.113110.56040264.kkojima@rr.iij4u.or.jp> Message-ID: <3F8CCED5.8050605@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 kaz Kojima wrote: > The attached patch adds pad instructions to avoid the SH-4 > core bug for the trapa instruction in DO_CALL macro. Applied. Thanks, - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/jM7V2ijCOnn/RHQRAhn1AJ4yhKCwocXkAVxRK1teKMFqolTiJwCghPmI H0/ZNkZcX8NLsUVHRemXFt8= =VB9Q -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Fri Oct 17 20:47:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Fri, 17 Oct 2003 20:47:00 -0000 Subject: Versioning longjmp etc. Message-ID: We are looking at integrating Vector Extensions (AKA Altivec or VMX) into glibc for PPC32/PPC64. This will change the size of __jmp_buf and sigcontext/ucontext and requires versioning of the corresponding functions (setjmp/longjmp etc). I assume this includes the complete function stack, for example [siglongjmp | longjmp] -> [__libc_siglongjmp | __libc_longjmp] -> __longjmp. But looking at linuxthreads/ptlongjmp.c and nptl/pt-longjmp.c I don't understand why we need the siglongjmp()/longjmp() stubs. They add path-length without adding any function (at least in the current implementation). So could these stubs be eliminated and replaced with aliases? If they are required where should I move ptlongjmp.c to (sysdeps/pthreads, sysdeps/generic, ...) so I can override it for powerpc[32 | 64]? Or should the siglongjmp()/longjmp() stubs be split out of ptlongjmp.c? From drepper@redhat.com Fri Oct 17 20:56:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 17 Oct 2003 20:56:00 -0000 Subject: Versioning longjmp etc. In-Reply-To: References: Message-ID: <3F905758.2050200@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Steve Munroe wrote: > We are looking at integrating Vector Extensions (AKA Altivec or VMX) into > glibc for PPC32/PPC64. Why should this be necessary? It makes almost no sense at all to include the content of these registers in the state. setjmp/longjmp are probably never used in the middle of computations in which vector registers are used. And if they are, this can be documented as the users problem. Saving and restoring makes setjmp/longjmp much more expensive and for absolutely no gain. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/kFdY2ijCOnn/RHQRAvV1AKCG60+FQvvHO8T+jlwlp/yQW9dCzQCeJgl+ b4S4ltS4kRTD203GeFs/Fc4= =Zk67 -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Fri Oct 17 21:12:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Fri, 17 Oct 2003 21:12:00 -0000 Subject: Versioning longjmp etc. Message-ID: Ulrich Drepper writes: > Why should this be necessary? It makes almost no sense at all to > include the content of these registers in the state. setjmp/longjmp are > probably never used in the middle of computations in which vector > registers are used. For the future when gcc supports autovectorization. I want to make VMX as usable as possible, without undefined behaviors or undocumented restrictions. How about get/set/make/swapcontext? The size of ucontext will change as a result of VMX state in sigcontext. This requires versioning. From drepper@redhat.com Fri Oct 17 21:27:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 17 Oct 2003 21:27:00 -0000 Subject: Versioning longjmp etc. In-Reply-To: References: Message-ID: <3F905E8B.7080002@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Steve Munroe wrote: > I want to make VMX as usable as possible, without undefined behaviors or > undocumented restrictions. The compiler knows about setjmp/longjmp. It will store the register content in memory around these calls. > How about get/set/make/swapcontext? The size of ucontext will change as a > result of VMX state in sigcontext. This requires versioning. Hasn't it already changed? If not, yes, ppc sucks again and requires versioning. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/kF6L2ijCOnn/RHQRAlHdAJ9A4RH/jAwsJhXqmE8bVm7D0ifjRQCgl/D1 Gzu0qB0CeOXCVzzmw4ejziA= =qnEi -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Fri Oct 17 22:27:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Fri, 17 Oct 2003 22:27:00 -0000 Subject: Versioning longjmp etc. Message-ID: Ulrich Drepper writes: > > How about get/set/make/swapcontext? The size of ucontext will change as a > > result of VMX state in sigcontext. This requires versioning. > > Hasn't it already changed? If not, yes, ppc sucks again and requires > versioning. Paul MacKerras submitted patches for PPC32 last month, PPC32 chips have had VMX (AKA Altivec) for a while now. But the first PPC64 chips with VMX have just started shipping (in the Apple G5) so this is a new issue for PPC64. I've been waiting for the kernel headers (sigcontext) to settle. BTW any man who thinks ppc sucks does not own a G5! ;) From jakub@redhat.com Thu Oct 23 19:49:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 23 Oct 2003 19:49:00 -0000 Subject: [PATCH] Fix locale printing on 64-bit big-endian arches Message-ID: <20031023174620.GM12344@sunsite.ms.mff.cuni.cz> Hi! 2003-10-23 Jakub Jelinek * locale/programs/locale.c (show_info): Fix printing word values on 64-bit big-endian architectures. --- libc/locale/programs/locale.c.jj 2003-05-22 02:40:45.000000000 +0200 +++ libc/locale/programs/locale.c 2003-10-23 21:46:06.000000000 +0200 @@ -893,12 +893,12 @@ show_info (const char *name) break; case word: { - unsigned int val = - (unsigned int) (unsigned long int) nl_langinfo (item->item_id); + union { unsigned int word; char *string; } val; + val.string = nl_langinfo (item->item_id); if (show_keyword_name) printf ("%s=", item->name); - printf ("%d\n", val); + printf ("%d\n", val.word); } break; case wstring: Jakub From drepper@redhat.com Fri Oct 24 03:23:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 24 Oct 2003 03:23:00 -0000 Subject: [PATCH] Fix locale printing on 64-bit big-endian arches In-Reply-To: <20031023174620.GM12344@sunsite.ms.mff.cuni.cz> References: <20031023174620.GM12344@sunsite.ms.mff.cuni.cz> Message-ID: <3F989B42.5030302@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jakub Jelinek wrote: > 2003-10-23 Jakub Jelinek > > * locale/programs/locale.c (show_info): Fix printing word values on > 64-bit big-endian architectures. Applied. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/mJtD2ijCOnn/RHQRAtVmAKC6dSU11cMq5xOCv6eNPVHcVOuytQCfao6i VlwxA5loxnNgWl1xlk7E58A= =TTnG -----END PGP SIGNATURE----- From sjmunroe@us.ibm.com Fri Oct 24 22:57:00 2003 From: sjmunroe@us.ibm.com (Steve Munroe) Date: Fri, 24 Oct 2003 22:57:00 -0000 Subject: Versioning longjmp etc. Message-ID: Need start over on this ... Ulrich Drepper writes: > Steve Munroe wrote: > > We are looking at integrating Vector Extensions (AKA Altivec or VMX) into > > glibc for PPC32/PPC64. > > Why should this be necessary? It makes almost no sense at all to > include the content of these registers in the state. ... Because the ABI requires it. VMX is treated like any other (GPRs, FPRs) register file. The ABI specifies volatile and nonvolatile registers. Volatile registers are saved by the caller (if it needs to preserve them) and nonvolatile registers are "callee saved". With this definition setjmp/longjmp need to save and restore the nonvolatile registers, including the nonvolatile vector registers (v20-v31 and vrsave). VMX state is included only if indicated in the AT_HWCAP. This will be handled similar the way AT_DCACHEBSIZE was interrogated for powerpc memset. > ... setjmp/longjmp are > probably never used in the middle of computations in which vector > registers are used. That is difficult to enforce in the general case. As applications get larger and more complex a single application may use a mixture of VMX and non-VMX aware libraries. With call-backs the stack can easily include non-VMX aware functions sandwiched between VMX aware layers. If this middle(ware) layer gets control as the result of a signal and longjmp, the VMX state must be restored before it returns to the initial VMX-aware layer. Since the compiler (and code generated by it) was not VMX-aware, we must depend on the runtime code (setjmp/longjmp). Steven J. Munroe Power Linux Toolchain Architect IBM Corporation, Linux Technology Center From davidm@napali.hpl.hp.com Wed Oct 29 04:26:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Wed, 29 Oct 2003 04:26:00 -0000 Subject: new syscall stub support for ia64 libc Message-ID: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> Now that NPTL etc. have settled, I'd like to renew the effort in getting the new system call stubs supported on ia64. As you may recall, the new syscall stubs are designed to support light-weight system calls (by taking advantage of the EPC instruction). The light-weight syscalls can yield huge performance improvements. For example, gettimeofday() and sigprocmask() run about 3 times faster as lightweight syscalls. What I'd like to see is something that makes it possible for non-threaded and NPTL apps to take advantage of the new syscall stubs. If LinuxThreads apps don't get the benefit, that's OK, I suppose. Does this sound reasonable? If so, how should I go about this? Should I re-send the (forward-ported) version of the original patch that I did so you can see what's involved? Any other suggestions? Thanks, --david From jakub@redhat.com Wed Oct 29 09:51:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 29 Oct 2003 09:51:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> Message-ID: <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> On Tue, Oct 28, 2003 at 08:26:09PM -0800, David Mosberger wrote: > Now that NPTL etc. have settled, I'd like to renew the effort in > getting the new system call stubs supported on ia64. As you may > recall, the new syscall stubs are designed to support light-weight > system calls (by taking advantage of the EPC instruction). The > light-weight syscalls can yield huge performance improvements. For > example, gettimeofday() and sigprocmask() run about 3 times faster as > lightweight syscalls. > > What I'd like to see is something that makes it possible for > non-threaded and NPTL apps to take advantage of the new syscall stubs. > If LinuxThreads apps don't get the benefit, that's OK, I suppose. > > Does this sound reasonable? If so, how should I go about this? > Should I re-send the (forward-ported) version of the original patch > that I did so you can see what's involved? Any other suggestions? Yes, please post a forward ported complete tested patch (the last version of the patch I and Ulrich saw was incomplete (but lead to discovery of a linker bug)). NPTL is now in sources CVS, so things are way easier for diffing... Thanks. Jakub From drepper@redhat.com Wed Oct 29 17:54:00 2003 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 29 Oct 2003 17:54:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> Message-ID: <3F9FFC7E.7040407@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 David Mosberger wrote: > What I'd like to see is something that makes it possible for > non-threaded and NPTL apps to take advantage of the new syscall stubs. We do this for x86 as well. The thread register is simply set up for every program, not only threaded programs. And this is done on x86 inside ld.so. I assume you want something like this. Otherwise I don't understand the reference to NPTL. > If LinuxThreads apps don't get the benefit, that's OK, I suppose. I couldn't care less about LT. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/n/x+2ijCOnn/RHQRAtWwAJ4iDxQLUMtvG4Cy3R21WVlMtLhebwCfSG+a ReLQtGHhwQ2UUmWPYvz7yOc= =WXO7 -----END PGP SIGNATURE----- From davidm@napali.hpl.hp.com Thu Oct 30 08:04:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Thu, 30 Oct 2003 08:04:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> Message-ID: <16288.50694.36460.339805@napali.hpl.hp.com> Hi Jakub, >>>>> On Wed, 29 Oct 2003 08:44:36 +0100, Jakub Jelinek said: Jakub> Yes, please post a forward ported complete tested patch (the last Jakub> version of the patch I and Ulrich saw was incomplete (but lead to Jakub> discovery of a linker bug)). Jakub> NPTL is now in sources CVS, so things are way easier for diffing... OK, here is a preliminary patch. Some comments: - The "assert (ph->p_vaddr == GL(dl_sysinfo_dso)" check in elf/rtld.c is too strict. On ia64, we have two LOAD segments, so the check can't possibly succeed: $ readelf -l arch/ia64/kernel/gate.so |grep LOAD LOAD 0x0000000000000000 0xa000000000010000 0xa000000000010000 LOAD 0x0000000000000000 0xa000000000020000 0xa000000000020000 The patch below simply #if's out the code, but perhaps a better fix would be to check ph->p_vaddr only for the first LOAD segment? - The changes to linuxthreads/{manager,pthread}.c are almost certainly wrong, but I'm not sure I understand how you want things set up to ensure that single-threaded apps use the new stub but linuxthread apps use the old one. - The ia64-specific vfork.S for now are done via old-style stub. I'm not sure whether this is still necessary and will look into it. - The libc-start.c change is also "wrong" but since DL_SYSDEP_OSCHECK() may do syscalls, it is necessary to do __pthread_initialize_minimal() first, as otherwise the minimal thread descriptor isn't setup. The rest should be good. With the patch applied, "make check" gets through all the tests except the linuxthread ones. I wasn't sure whether it's worth tracking those down, since the linuxthreads part is likely to change anyhow. --david Index: elf/rtld.c =================================================================== RCS file: /cvs/glibc/libc/elf/rtld.c,v retrieving revision 1.299 diff -u -r1.299 rtld.c --- elf/rtld.c 27 Oct 2003 20:08:32 -0000 1.299 +++ elf/rtld.c 30 Oct 2003 07:55:02 -0000 @@ -1169,8 +1169,10 @@ l->l_ldnum = ph->p_memsz / sizeof (ElfW(Dyn)); break; } +#if 0 if (ph->p_type == PT_LOAD) assert ((void *) ph->p_vaddr == GL(dl_sysinfo_dso)); +#endif } elf_get_dynamic_info (l, dyn_temp); _dl_setup_hash (l); Index: linuxthreads/descr.h =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/descr.h,v retrieving revision 1.14 diff -u -r1.14 descr.h --- linuxthreads/descr.h 17 Sep 2003 09:39:00 -0000 1.14 +++ linuxthreads/descr.h 30 Oct 2003 07:55:02 -0000 @@ -189,7 +189,23 @@ #endif size_t p_alloca_cutoff; /* Maximum size which should be allocated using alloca() instead of malloc(). */ +#if TLS_TCB_AT_TP /* New elements must be added at the end. */ +#else + union { + struct { + void *reserved[11]; /* reserve for future use */ + void *tcb; /* XXX do we really need this? */ + union dtv *dtvp; /* XXX do we really need this? */ + pthread_descr self; /* XXX do we really need this? */ + int multiple_threads; +#ifdef NEED_DL_SYSINFO + uintptr_t sysinfo; +#endif + } data; + void *__padding[16]; + } p_header __attribute__ ((aligned(32))); +#endif } __attribute__ ((aligned(32))); /* We need to align the structure so that doubles are aligned properly. This is 8 bytes on MIPS and 16 bytes on MIPS64. Index: linuxthreads/manager.c =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/manager.c,v retrieving revision 1.96 diff -u -r1.96 manager.c --- linuxthreads/manager.c 15 Oct 2003 05:53:06 -0000 1.96 +++ linuxthreads/manager.c 30 Oct 2003 07:55:02 -0000 @@ -650,6 +650,10 @@ #if !defined USE_TLS || !TLS_DTV_AT_TP new_thread->p_header.data.tcb = new_thread; new_thread->p_header.data.self = new_thread; +# if 1 + /* XXX why isn't this done already??? */ + new_thread->p_header.data.sysinfo = GL(dl_sysinfo); +# endif #endif #if TLS_MULTIPLE_THREADS_IN_TCB || !defined USE_TLS || !TLS_DTV_AT_TP new_thread->p_multiple_threads = 1; Index: linuxthreads/pthread.c =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/pthread.c,v retrieving revision 1.132 diff -u -r1.132 pthread.c --- linuxthreads/pthread.c 15 Oct 2003 05:53:44 -0000 1.132 +++ linuxthreads/pthread.c 30 Oct 2003 07:55:02 -0000 @@ -357,6 +357,11 @@ self = THREAD_SELF; +#if 1 + /* XXX why isn't this done already??? */ + self->p_header.data.sysinfo = GL(dl_sysinfo); +#endif + /* The memory for the thread descriptor was allocated elsewhere as part of the TLS allocation. We have to initialize the data structure by hand. This initialization must mirror the struct @@ -676,6 +681,10 @@ mgr->p_header.data.tcb = tcbp; mgr->p_header.data.self = mgr; mgr->p_header.data.multiple_threads = 1; +# if 1 + /* XXX why isn't this done already??? */ + mgr->p_header.data.sysinfo = GL(dl_sysinfo); +# endif #elif TLS_MULTIPLE_THREADS_IN_TCB mgr->p_multiple_threads = 1; #endif Index: linuxthreads/sysdeps/ia64/tcb-offsets.sym =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/ia64/tcb-offsets.sym,v retrieving revision 1.6 diff -u -r1.6 tcb-offsets.sym --- linuxthreads/sysdeps/ia64/tcb-offsets.sym 25 Apr 2003 22:04:27 -0000 1.6 +++ linuxthreads/sysdeps/ia64/tcb-offsets.sym 30 Oct 2003 07:55:02 -0000 @@ -4,6 +4,7 @@ -- #ifdef USE_TLS MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads) - sizeof (struct _pthread_descr_struct) +SYSINFO_OFFSET offsetof (struct _pthread_descr_struct, p_header.data.sysinfo) - sizeof (struct _pthread_descr_struct) #else MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads) #endif Index: linuxthreads/sysdeps/ia64/tls.h =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/ia64/tls.h,v retrieving revision 1.6 diff -u -r1.6 tls.h --- linuxthreads/sysdeps/ia64/tls.h 31 Jul 2003 19:16:34 -0000 1.6 +++ linuxthreads/sysdeps/ia64/tls.h 30 Oct 2003 07:55:02 -0000 @@ -20,10 +20,13 @@ #ifndef _TLS_H #define _TLS_H +#include + #ifndef __ASSEMBLER__ # include # include +# include /* Type for the dtv. */ typedef union dtv @@ -83,8 +86,10 @@ /* Code to initially initialize the thread pointer. This might need special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ -# define TLS_INIT_TP(tcbp, secondcall) \ - (__thread_self = (__typeof (__thread_self)) (tcbp), NULL) +# define TLS_INIT_TP(tcbp, secondcall) \ + (__thread_self = (__typeof (__thread_self)) (tcbp), \ + THREAD_SELF->p_header.data.sysinfo = GL(dl_sysinfo), \ + NULL) /* Return the address of the dtv for the current thread. */ # define THREAD_DTV() \ Index: linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S,v retrieving revision 1.4 diff -u -r1.4 vfork.S --- linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S 11 Feb 2003 06:27:53 -0000 1.4 +++ linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S 30 Oct 2003 07:55:02 -0000 @@ -43,9 +43,13 @@ mov out0=CLONE_VM+CLONE_VFORK+SIGCHLD mov out1=0 /* Standard sp value. */ ;; +#if 0 DO_CALL (SYS_ify (clone)) +#else + mov r15=SYS_ify(clone) + break __BREAK_SYSCALL +#endif cmp.eq p6,p0=-1,r10 - ;; (p6) br.cond.spnt.few __syscall_error ret PSEUDO_END(__vfork) Index: sysdeps/generic/libc-start.c =================================================================== RCS file: /cvs/glibc/libc/sysdeps/generic/libc-start.c,v retrieving revision 1.46 diff -u -r1.46 libc-start.c --- sysdeps/generic/libc-start.c 31 Jul 2003 19:20:39 -0000 1.46 +++ sysdeps/generic/libc-start.c 30 Oct 2003 07:55:04 -0000 @@ -123,14 +123,6 @@ # endif _dl_aux_init (auxvec); # endif -# ifdef DL_SYSDEP_OSCHECK - if (!__libc_multiple_libcs) - { - /* This needs to run to initiliaze _dl_osversion before TLS - setup might check it. */ - DL_SYSDEP_OSCHECK (__libc_fatal); - } -# endif /* Initialize the thread library at least a bit since the libgcc functions are using thread functions if these are available and @@ -142,6 +134,15 @@ # endif __pthread_initialize_minimal (); #endif + +# ifdef DL_SYSDEP_OSCHECK + if (!__libc_multiple_libcs) + { + /* This needs to run to initiliaze _dl_osversion before TLS + setup might check it. */ + DL_SYSDEP_OSCHECK (__libc_fatal); + } +# endif /* Register the destructor of the dynamic linker if there is any. */ if (__builtin_expect (rtld_fini != NULL, 1)) Index: sysdeps/unix/sysv/linux/ia64/clone2.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/ia64/clone2.S,v retrieving revision 1.7 diff -u -r1.7 clone2.S --- sysdeps/unix/sysv/linux/ia64/clone2.S 13 Mar 2003 04:36:59 -0000 1.7 +++ sysdeps/unix/sysv/linux/ia64/clone2.S 30 Oct 2003 07:55:07 -0000 @@ -25,49 +25,56 @@ /* size_t child_stack_size, int flags, void *arg, */ /* pid_t *parent_tid, void *tls, pid_t *child_tid) */ +#define CHILD p8 +#define PARENT p9 + ENTRY(__clone2) - alloc r2=ar.pfs,8,2,6,0 + .prologue + alloc r2=ar.pfs,8,0,6,0 cmp.eq p6,p0=0,in0 mov r8=EINVAL -(p6) br.cond.spnt.few __syscall_error - ;; - flushrs /* This is necessary, since the child */ - /* will be running with the same */ - /* register backing store for a few */ - /* instructions. We need to ensure */ - /* that it will not read or write the */ - /* backing store. */ - mov loc0=in0 /* save fn */ - mov loc1=in4 /* save arg */ mov out0=in3 /* Flags are first syscall argument. */ mov out1=in1 /* Stack address. */ +(p6) br.cond.spnt.many __syscall_error + ;; mov out2=in2 /* Stack size. */ mov out3=in5 /* Parent TID Pointer */ mov out4=in7 /* Child TID Pointer */ mov out5=in6 /* TLS pointer */ - DO_CALL (SYS_ify (clone2)) + /* + * clone2() is special: the child cannot execute br.ret right + * after the system call returns, because it starts out + * executing on an empty stack. Because of this, we can't use + * the new (lightweight) syscall convention here. Instead, we + * just fall back on always using "break". + * + * Furthermore, since the child starts with an empty stack, we + * need to avoid unwinding past invalid memory. To that end, + * we'll pretend now that __clone2() is the end of the + * call-chain. This is wrong for the parent, but only until + * it returns from clone2() but it's better than the + * alternative. + */ + mov r15=SYS_ify (clone2) + .save rp, r0 + break __BREAK_SYSCALL + .body cmp.eq p6,p0=-1,r10 + cmp.eq CHILD,PARENT=0,r8 /* Are we the child? */ +(p6) br.cond.spnt.many __syscall_error ;; -(p6) br.cond.spnt.few __syscall_error - -# define CHILD p6 -# define PARENT p7 - cmp.eq CHILD,PARENT=0,r8 /* Are we the child? */ - ;; -(CHILD) ld8 out1=[loc0],8 /* Retrieve code pointer. */ -(CHILD) mov out0=loc1 /* Pass proper argument to fn */ +(CHILD) ld8 out1=[in0],8 /* Retrieve code pointer. */ +(CHILD) mov out0=in4 /* Pass proper argument to fn */ (PARENT) ret ;; - ld8 gp=[loc0] /* Load function gp. */ + ld8 gp=[in0] /* Load function gp. */ mov b6=out1 - ;; - br.call.dptk.few rp=b6 /* Call fn(arg) in the child */ + br.call.dptk.many rp=b6 /* Call fn(arg) in the child */ ;; mov out0=r8 /* Argument to _exit */ .globl _exit - br.call.dpnt.few rp=_exit /* call _exit with result from fn. */ + br.call.dpnt.many rp=_exit /* call _exit with result from fn. */ ret /* Not reached. */ - PSEUDO_END(__clone2) /* For now we leave __clone undefined. This is unlikely to be a */ Index: sysdeps/unix/sysv/linux/ia64/sysdep.h =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/ia64/sysdep.h,v retrieving revision 1.17 diff -u -r1.17 sysdep.h --- sysdeps/unix/sysv/linux/ia64/sysdep.h 16 Aug 2003 08:00:24 -0000 1.17 +++ sysdeps/unix/sysv/linux/ia64/sysdep.h 30 Oct 2003 07:55:08 -0000 @@ -23,6 +23,7 @@ #include #include +#include /* For Linux we can use the system call table in the header file /usr/include/asm/unistd.h @@ -95,9 +96,32 @@ cmp.eq p6,p0=-1,r10; \ (p6) br.cond.spnt.few __syscall_error; -#define DO_CALL(num) \ +#define DO_CALL_VIA_BREAK(num) \ mov r15=num; \ - break __BREAK_SYSCALL; + break __BREAK_SYSCALL + +#if defined HAVE_TLS_SUPPORT && (!defined NOT_IN_libc || defined IS_IN_libpthread) + +/* Use the lightweight stub only if (a) we have a suitably modern + thread-control block (HAVE_TLS_SUPPORT) and (b) we're not compiling + the runtime loader (which might do syscalls before being fully + relocated). */ + +#define DO_CALL(num) \ + .prologue; \ + adds r2 = SYSINFO_OFFSET, r13;; \ + ld8 r2 = [r2]; \ + .save ar.pfs, r11; \ + mov r11 = ar.pfs;; \ + .body; \ + mov r15 = num; \ + mov b7 = r2; \ + br.call.sptk.many b6 = b7;; \ + .restore sp; \ + mov ar.pfs = r11 +#else +#define DO_CALL(num) DO_CALL_VIA_BREAK(num) +#endif #undef PSEUDO_END #define PSEUDO_END(name) .endp C_SYMBOL_NAME(name); @@ -144,6 +168,47 @@ (non-negative) errno on error or the return value on success. */ #undef INLINE_SYSCALL +#undef INTERNAL_SYSCALL +#if defined HAVE_TLS_SUPPORT && (!defined NOT_IN_libc || defined IS_IN_libpthread) + +#define DO_INLINE_SYSCALL(name, nr, args...) \ + register long _r8 __asm ("r8"); \ + register long _r10 __asm ("r10"); \ + register long _r15 __asm ("r15") = __NR_##name; \ + long _retval; \ + LOAD_ARGS_##nr (args); \ + /* \ + * Don't specify any unwind info here. We mark ar.pfs as clobbered. This will force \ + * the compiler to save ar.pfs somewhere and emit appropriate unwind info for that \ + * save. \ + */ \ + __asm __volatile ("adds r2 = -8, r13;;\n" \ + "ld8 r2 = [r2];;\n" \ + "mov b7=r2;\n" \ + "br.call.sptk.many b6=b7;;\n" \ + : "=r" (_r8), "=r" (_r10), "=r" (_r15) ASM_OUTARGS_##nr \ + : "2" (_r15) ASM_ARGS_##nr \ + : "memory", "ar.pfs" ASM_CLOBBERS_##nr); \ + _retval = _r8; + +#define INLINE_SYSCALL(name, nr, args...) \ + ({ \ + DO_INLINE_SYSCALL(name, nr, args) \ + if (_r10 == -1) \ + { \ + __set_errno (_retval); \ + _retval = -1; \ + } \ + _retval; }) + +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + ({ \ + DO_INLINE_SYSCALL(name, nr, args) \ + err = _r10; \ + _retval; }) + +#else /* !new syscall-stub */ + #define INLINE_SYSCALL(name, nr, args...) \ ({ \ register long _r8 asm ("r8"); \ @@ -164,10 +229,6 @@ } \ _retval; }) -#undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) long int err - -#undef INTERNAL_SYSCALL #define INTERNAL_SYSCALL(name, err, nr, args...) \ ({ \ register long _r8 asm ("r8"); \ @@ -183,6 +244,11 @@ _retval = _r8; \ err = _r10; \ _retval; }) + +#endif /* !new syscall-stub */ + +#undef INTERNAL_SYSCALL_DECL +#define INTERNAL_SYSCALL_DECL(err) long int err #undef INTERNAL_SYSCALL_ERROR_P #define INTERNAL_SYSCALL_ERROR_P(val, err) (err == -1) Index: sysdeps/unix/sysv/linux/ia64/vfork.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/ia64/vfork.S,v retrieving revision 1.4 diff -u -r1.4 vfork.S --- sysdeps/unix/sysv/linux/ia64/vfork.S 31 Dec 2002 20:37:30 -0000 1.4 +++ sysdeps/unix/sysv/linux/ia64/vfork.S 30 Oct 2003 07:55:08 -0000 @@ -34,9 +34,13 @@ mov out0=CLONE_VM+CLONE_VFORK+SIGCHLD mov out1=0 /* Standard sp value. */ ;; +#if 0 DO_CALL (SYS_ify (clone)) +#else + mov r15=SYS_ify(clone) + break __BREAK_SYSCALL +#endif cmp.eq p6,p0=-1,r10 - ;; (p6) br.cond.spnt.few __syscall_error ret PSEUDO_END(__vfork) From jakub@redhat.com Thu Oct 30 09:09:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 30 Oct 2003 09:09:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <16288.50694.36460.339805@napali.hpl.hp.com> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> Message-ID: <20031030070302.GS12344@sunsite.ms.mff.cuni.cz> On Thu, Oct 30, 2003 at 12:04:22AM -0800, David Mosberger wrote: > Hi Jakub, > > >>>>> On Wed, 29 Oct 2003 08:44:36 +0100, Jakub Jelinek said: > > Jakub> Yes, please post a forward ported complete tested patch (the last > Jakub> version of the patch I and Ulrich saw was incomplete (but lead to > Jakub> discovery of a linker bug)). > Jakub> NPTL is now in sources CVS, so things are way easier for diffing... > > OK, here is a preliminary patch. Some comments: > > - The "assert (ph->p_vaddr == GL(dl_sysinfo_dso)" check in elf/rtld.c > is too strict. On ia64, we have two LOAD segments, so the check > can't possibly succeed: > > $ readelf -l arch/ia64/kernel/gate.so |grep LOAD > LOAD 0x0000000000000000 0xa000000000010000 0xa000000000010000 > LOAD 0x0000000000000000 0xa000000000020000 0xa000000000020000 Can you readelf -Wl arch/ia64/kernel/gate.so |grep LOAD (or grep -A1 LOAD instead), or better yet readelf -Wa arch/ia64/kernel/gate.so ? I'd like to understand why you need the second LOAD segment, what stuff has it in etc. > The patch below simply #if's out the code, but perhaps a better > fix would be to check ph->p_vaddr only for the first LOAD segment? Yeah, that's doable, add some variable #ifndef NDEBUG, increment it for each PT_LOAD and use it in the assert. > - The changes to linuxthreads/{manager,pthread}.c are almost certainly > wrong, but I'm not sure I understand how you want things set up to > ensure that single-threaded apps use the new stub but linuxthread > apps use the old one. IMHO NEED_DL_SYSINFO should be defined in both NPTL and Linuxthread ia64/dl-sysdep.h, while USE_DL_SYSINFO only in NPTL. And sysdep.h should use sysinfo only if USE_DL_SYSINFO is defined. Then linuxthreads will work just fine (use break always, who cares) and NPTL will use VDSO. > - The libc-start.c change is also "wrong" but since DL_SYSDEP_OSCHECK() > may do syscalls, it is necessary to do __pthread_initialize_minimal() > first, as otherwise the minimal thread descriptor isn't setup. This is handled on IA-32 by providing DL_SYSINFO_DEFAULT (and defining USE_DL_SYSINFO). This means the few syscalls in DL_SYSDEP_OSCHECK will use the break insn and the rest will use VDSO if available. Jakub From roland@redhat.com Thu Oct 30 19:38:00 2003 From: roland@redhat.com (Roland McGrath) Date: Thu, 30 Oct 2003 19:38:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: Jakub Jelinek's message of Thursday, 30 October 2003 08:03:02 +0100 <20031030070302.GS12344@sunsite.ms.mff.cuni.cz> Message-ID: <200310301937.h9UJbu8N017565@magilla.sf.frob.com> > Can you readelf -Wl arch/ia64/kernel/gate.so |grep LOAD (or grep -A1 LOAD > instead), or better yet readelf -Wa arch/ia64/kernel/gate.so ? I'd like > to understand why you need the second LOAD segment, what stuff has it in > etc. There are two LOAD segments for the same one page of file data mapped into two consecutive pages with different permissions. The first segment is read-only and the second is execute-only. The execute-only permission (cannot be read by user mode) is required for the magic EPC instruction. Hence we need two mappings to see the DSO info and to execute. > IMHO NEED_DL_SYSINFO should be defined in both NPTL and > Linuxthread ia64/dl-sysdep.h, while USE_DL_SYSINFO only in NPTL. > And sysdep.h should use sysinfo only if USE_DL_SYSINFO is defined. > Then linuxthreads will work just fine (use break always, who cares) > and NPTL will use VDSO. Agreed. THis is what i386 does. From davidm@napali.hpl.hp.com Thu Oct 30 19:59:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Thu, 30 Oct 2003 19:59:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <20031030070302.GS12344@sunsite.ms.mff.cuni.cz> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> <20031030070302.GS12344@sunsite.ms.mff.cuni.cz> Message-ID: <16289.28064.354214.335234@napali.hpl.hp.com> >>>>> On Thu, 30 Oct 2003 08:03:02 +0100, Jakub Jelinek said: >> - The "assert (ph->p_vaddr == GL(dl_sysinfo_dso)" check in >> elf/rtld.c is too strict. On ia64, we have two LOAD segments, so >> the check can't possibly succeed: >> $ readelf -l arch/ia64/kernel/gate.so |grep LOAD LOAD >> 0x0000000000000000 0xa000000000010000 0xa000000000010000 LOAD >> 0x0000000000000000 0xa000000000020000 0xa000000000020000 Jakub> Can you readelf -Wl arch/ia64/kernel/gate.so |grep LOAD (or Jakub> grep -A1 LOAD instead), or better yet readelf -Wa Jakub> arch/ia64/kernel/gate.so ? I'd like to understand why you Jakub> need the second LOAD segment, what stuff has it in etc. How about I try to explain? The reason there are two segments is that the privilege-promote page used to enter the kernel is executable only at the user-level. To export the DSO headers etc., we thus create a second, read-only mapping. Here is the expanded readelf output: $ readelf -Wl arch/ia64/kernel/gate.so |grep LOAD LOAD 0x000000 0xa000000000010000 0xa000000000010000 0x000628 0x000628 R 0x10000 LOAD 0x000000 0xa000000000020000 0xa000000000020000 0x0009e0 0x0009e0 E 0x10000 >> - The changes to linuxthreads/{manager,pthread}.c are almost >> certainly wrong, but I'm not sure I understand how you want >> things set up to ensure that single-threaded apps use the new >> stub but linuxthread apps use the old one. Jakub> IMHO NEED_DL_SYSINFO should be defined in both NPTL and Jakub> Linuxthread ia64/dl-sysdep.h, while USE_DL_SYSINFO only in Jakub> NPTL. And sysdep.h should use sysinfo only if USE_DL_SYSINFO is Jakub> defined. Then linuxthreads will work just fine (use break Jakub> always, who cares) and NPTL will use VDSO. But wouldn't this imply that non-threaded apps won't use the new stubs? I'm probably missing something here. >> - The libc-start.c change is also "wrong" but since >> DL_SYSDEP_OSCHECK() may do syscalls, it is necessary to do >> __pthread_initialize_minimal() first, as otherwise the minimal >> thread descriptor isn't setup. Jakub> This is handled on IA-32 by providing DL_SYSINFO_DEFAULT (and Jakub> defining USE_DL_SYSINFO). This means the few syscalls in Jakub> DL_SYSDEP_OSCHECK will use the break insn and the rest will Jakub> use VDSO if available. OK, that behavior should be fine (especially if the DL_SYSDEP_OSCHECK can go away completely with the right libc config option). --david From jakub@redhat.com Thu Oct 30 20:23:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 30 Oct 2003 20:23:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <16289.28064.354214.335234@napali.hpl.hp.com> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> <20031030070302.GS12344@sunsite.ms.mff.cuni.cz> <16289.28064.354214.335234@napali.hpl.hp.com> Message-ID: <20031030181725.GU12344@sunsite.ms.mff.cuni.cz> On Thu, Oct 30, 2003 at 11:59:28AM -0800, David Mosberger wrote: > Jakub> IMHO NEED_DL_SYSINFO should be defined in both NPTL and > Jakub> Linuxthread ia64/dl-sysdep.h, while USE_DL_SYSINFO only in > Jakub> NPTL. And sysdep.h should use sysinfo only if USE_DL_SYSINFO is > Jakub> defined. Then linuxthreads will work just fine (use break > Jakub> always, who cares) and NPTL will use VDSO. > > But wouldn't this imply that non-threaded apps won't use the new > stubs? I'm probably missing something here. No. In recent glibc's, you always have to use matching libc.so+libpthread.so+librt.so, so you either use libc.so+libpthread.so+librt.so from NPTL build, or from Linuxthreads build. In Linuxthreads build non-threaded nor threaded apps won't use the new stubs, just the dynamic linker will have support for them (but won't use them). That is so that ld.so from Linuxthreads build can load NPTL libc.so+libpthread.so+librt.so. In NPTL build, both non-threaded and threaded apps will use the new stubs after TLS is set up. > Jakub> This is handled on IA-32 by providing DL_SYSINFO_DEFAULT (and > Jakub> defining USE_DL_SYSINFO). This means the few syscalls in > Jakub> DL_SYSDEP_OSCHECK will use the break insn and the rest will > Jakub> use VDSO if available. > > OK, that behavior should be fine (especially if the DL_SYSDEP_OSCHECK > can go away completely with the right libc config option). DL_SYSDEP_OSCHECK is going away only if you configure glibc without --enable-kernel=x.y.z. Which is something you almost never want to do in NPTL build. Jakub From davidm@napali.hpl.hp.com Thu Oct 30 22:35:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Thu, 30 Oct 2003 22:35:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <20031030181725.GU12344@sunsite.ms.mff.cuni.cz> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> <20031030070302.GS12344@sunsite.ms.mff.cuni.cz> <16289.28064.354214.335234@napali.hpl.hp.com> <20031030181725.GU12344@sunsite.ms.mff.cuni.cz> Message-ID: <16289.37435.952062.757104@napali.hpl.hp.com> >>>>> On Thu, 30 Oct 2003 19:17:25 +0100, Jakub Jelinek said: >> But wouldn't this imply that non-threaded apps won't use the new >> stubs? I'm probably missing something here. Jakub> No. In recent glibc's, you always have to use matching Jakub> libc.so+libpthread.so+librt.so, so you either use Jakub> libc.so+libpthread.so+librt.so from NPTL build, or from Linuxthreads Jakub> build. Oh, thanks for explaining that. Yes, then things should be fine. Let me see if I can come up with an updated patch. --david From rth@twiddle.net Fri Oct 31 08:45:00 2003 From: rth@twiddle.net (Richard Henderson) Date: Fri, 31 Oct 2003 08:45:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <16288.50694.36460.339805@napali.hpl.hp.com> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> Message-ID: <20031031084249.GA30446@twiddle.net> On Thu, Oct 30, 2003 at 12:04:22AM -0800, David Mosberger wrote: > + __asm __volatile ("adds r2 = -8, r13;;\n" > + "ld8 r2 = [r2];;\n" > + "mov b7=r2;\n" > + "br.call.sptk.many b6=b7;;\n" > + : "=r" (_r8), "=r" (_r10), > + "=r" (_r15) ASM_OUTARGS_##nr > + : "2" (_r15) ASM_ARGS_##nr > + : "memory", "ar.pfs" ASM_CLOBBERS_##nr); Any particular reason why you're managing the memory load from assembly? Seems to me you could do __asm __volatile ("br.call.sptk.many b6=%0" : ... : "b" (__thread_self->whatever) : ...); Anyway, the magic -8 there certainly looks dangerous. r~ From jakub@redhat.com Fri Oct 31 09:07:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 31 Oct 2003 09:07:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <20031031084249.GA30446@twiddle.net> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> <20031031084249.GA30446@twiddle.net> Message-ID: <20031031070114.GV12344@sunsite.ms.mff.cuni.cz> On Fri, Oct 31, 2003 at 12:42:49AM -0800, Richard Henderson wrote: > On Thu, Oct 30, 2003 at 12:04:22AM -0800, David Mosberger wrote: > > + __asm __volatile ("adds r2 = -8, r13;;\n" > > + "ld8 r2 = [r2];;\n" > > + "mov b7=r2;\n" > > + "br.call.sptk.many b6=b7;;\n" > > + : "=r" (_r8), "=r" (_r10), > > + "=r" (_r15) ASM_OUTARGS_##nr > > + : "2" (_r15) ASM_ARGS_##nr > > + : "memory", "ar.pfs" ASM_CLOBBERS_##nr); > > Any particular reason why you're managing the memory load > from assembly? Seems to me you could do > > __asm __volatile ("br.call.sptk.many b6=%0" > : ... > : "b" (__thread_self->whatever) Cannot tcbhead_t's private field be reused for the sysinfo pointer actually on IA-64? That way 32 bytes wouldn't have to be wasted at end of struct pthread, it would be at the same location in linuxthreads as well as NPTL build (so that linuxthreads ld.so can load NPTL libc/libpthread). It would need some small changes in generic code, particularly macroizing sysinfo access. On IA-32 this could be: #define THREAD_SELF_SYSINFO THREAD_GETMEM (THREAD_SELF, header.sysinfo) #define THREAD_SYSINFO(pd) ((pd)->header.sysinfo) and on IA-64: #define THREAD_SELF_SYSINFO (((tcbhead_t) __thread_self)->private) #define THREAD_SYSINFO(pd) (((tcbhead_t) ((pd) + 1))->private) Jakub From davidm@napali.hpl.hp.com Fri Oct 31 16:43:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Fri, 31 Oct 2003 16:43:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <20031031084249.GA30446@twiddle.net> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> <20031031084249.GA30446@twiddle.net> Message-ID: <16290.37157.387367.684587@napali.hpl.hp.com> >>>>> On Fri, 31 Oct 2003 00:42:49 -0800, Richard Henderson said: Richard> On Thu, Oct 30, 2003 at 12:04:22AM -0800, David Mosberger wrote: >> + __asm __volatile ("adds r2 = -8, r13;;\n" >> + "ld8 r2 = [r2];;\n" >> + "mov b7=r2;\n" >> + "br.call.sptk.many b6=b7;;\n" >> + : "=r" (_r8), "=r" (_r10), >> + "=r" (_r15) ASM_OUTARGS_##nr >> + : "2" (_r15) ASM_ARGS_##nr >> + : "memory", "ar.pfs" ASM_CLOBBERS_##nr); Richard> Any particular reason why you're managing the memory load Richard> from assembly? Seems to me you could do Richard> __asm __volatile ("br.call.sptk.many b6=%0" Richard> : ... Richard> : "b" (__thread_self->whatever) Richard> : ...); That's probably worth trying. Richard> Anyway, the magic -8 there certainly looks dangerous. Not really. The offset must be architected (effectively, it's part of the ia64 linux abi), because otherwise you can't use the new syscall stubs outside of the C library. But I agree it would be cleaner to use the offset macro in this particular case (for consistency); I just didn't want to sort out the include file dependency mess that made this difficult at the time. Regardless, we should probably add an assertion somewhere that SYSINFO_OFFSET == -8. --david From davidm@napali.hpl.hp.com Fri Oct 31 16:45:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Fri, 31 Oct 2003 16:45:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <20031031070114.GV12344@sunsite.ms.mff.cuni.cz> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> <20031031084249.GA30446@twiddle.net> <20031031070114.GV12344@sunsite.ms.mff.cuni.cz> Message-ID: <16290.37282.439025.287911@napali.hpl.hp.com> >>>>> On Fri, 31 Oct 2003 08:01:14 +0100, Jakub Jelinek said: Jakub> Cannot tcbhead_t's private field be reused for the sysinfo pointer Jakub> actually on IA-64? As long as we can make it appear at offsets -8, that would be OK. Jakub> That way 32 bytes wouldn't have to be wasted at end of struct Jakub> pthread, it would be at the same location in linuxthreads as Jakub> well as NPTL build That's not sufficient. The offset must be the same across _all_ libcs, so that non-libc code can use the new syscall stubs as well. --david From jakub@redhat.com Fri Oct 31 16:54:00 2003 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 31 Oct 2003 16:54:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <16290.37282.439025.287911@napali.hpl.hp.com> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> <20031031084249.GA30446@twiddle.net> <20031031070114.GV12344@sunsite.ms.mff.cuni.cz> <16290.37282.439025.287911@napali.hpl.hp.com> Message-ID: <20031031144724.GY12344@sunsite.ms.mff.cuni.cz> On Fri, Oct 31, 2003 at 08:45:22AM -0800, David Mosberger wrote: > >>>>> On Fri, 31 Oct 2003 08:01:14 +0100, Jakub Jelinek said: > > Jakub> Cannot tcbhead_t's private field be reused for the sysinfo pointer > Jakub> actually on IA-64? > > As long as we can make it appear at offsets -8, that would be OK. It would be offset 8, not -8 actually. > Jakub> That way 32 bytes wouldn't have to be wasted at end of struct > Jakub> pthread, it would be at the same location in linuxthreads as > Jakub> well as NPTL build > > That's not sufficient. The offset must be the same across _all_ libcs, > so that non-libc code can use the new syscall stubs as well. I don't think it is a good idea to give access to glibc internals (which these are) to outside code. There is syscall(3) function for a reason. Also, derefencing r13[-8] (or r13[8]) in various syscall stub macros is not going to work if you run the program then against older glibc and there won't be any symbol versioning which would catch it up. Jakub From davidm@napali.hpl.hp.com Fri Oct 31 18:29:00 2003 From: davidm@napali.hpl.hp.com (David Mosberger) Date: Fri, 31 Oct 2003 18:29:00 -0000 Subject: new syscall stub support for ia64 libc In-Reply-To: <20031031144724.GY12344@sunsite.ms.mff.cuni.cz> References: <200310290426.h9T4Q9pw014305@napali.hpl.hp.com> <20031029074436.GR12344@sunsite.ms.mff.cuni.cz> <16288.50694.36460.339805@napali.hpl.hp.com> <20031031084249.GA30446@twiddle.net> <20031031070114.GV12344@sunsite.ms.mff.cuni.cz> <16290.37282.439025.287911@napali.hpl.hp.com> <20031031144724.GY12344@sunsite.ms.mff.cuni.cz> Message-ID: <16290.43497.682724.236106@napali.hpl.hp.com> >>>>> On Fri, 31 Oct 2003 15:47:24 +0100, Jakub Jelinek said: Jakub> On Fri, Oct 31, 2003 at 08:45:22AM -0800, David Mosberger wrote: >> >>>>> On Fri, 31 Oct 2003 08:01:14 +0100, Jakub Jelinek said: Jakub> Cannot tcbhead_t's private field be reused for the sysinfo pointer Jakub> actually on IA-64? >> As long as we can make it appear at offsets -8, that would be OK. Jakub> It would be offset 8, not -8 actually. Ah, you mean _that_ one. It's defined by the psABI and since the new syscall stub was defined much later, I considered it off limits. I'd hate to change the offset now, many months after an open discussion on this topic. On the other hand, if we do want to change it, now is probably the last chance. Jakub> That way 32 bytes wouldn't have to be wasted at end of struct Jakub> pthread, it would be at the same location in linuxthreads as Jakub> well as NPTL build I don't think you have to waste 32 bytes. You could do something like: struct pthread { : long reserved; }; and then access sys_info via ((long *) tcb_pointer)[-1]. That way, no matter what the alignment, you'll always access the right word and will only use up an extra 8 bytes. >> That's not sufficient. The offset must be the same across _all_ libcs, >> so that non-libc code can use the new syscall stubs as well. Jakub> I don't think it is a good idea to give access to glibc Jakub> internals (which these are) to outside code. There is Jakub> syscall(3) function for a reason. It's not glibc internals, it's ia64 linux abi. I certainly do not encourage the use of handcrafted syscall stubs, but sometimes, they're needed. Jakub> Also, derefencing r13[-8] (or r13[8]) in various syscall stub Jakub> macros is not going to work if you run the program then Jakub> against older glibc and there won't be any symbol versioning Jakub> which would catch it up. If someone chooses to use the new syscall stubs, they'll have to live with that. --david