From aj@suse.de Tue May 2 11:16:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Tue, 02 May 2000 11:16:00 -0000 Subject: Patch for conform Message-ID: Hi Uli, here's a patch for conformtest. Now you can say: macro-str STRING "123" (testing the value of a string) constant VALUE >= 10 (testing that the value is >= 10 - in fact you can use any combination of <=> - as long as it's valid C code) For further examples check my other two patches. I'm not sure where which preprocessor macro should be used in limits.h - please fix this. Andreas 2000-05-02 Andreas Jaeger * conform/conformtest.pl: Test for macros with string constants, check for minimum and maximum values. Add limits.h to headers. * conform/data/cpio.h-data: Test for value of MAGIC. * conform/data/limits.h-data: New file. ============================================================ Index: conform/conformtest.pl --- conform/conformtest.pl 2000/04/30 03:26:44 1.11 +++ conform/conformtest.pl 2000/05/02 18:12:05 @@ -5,22 +5,24 @@ # List of the headers we are testing. @headers = ("wordexp.h", "wctype.h", "wchar.h", "varargs.h", "utmpx.h", - "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "time.h", - "termios.h", "tar.h", "sys/wait.h", "sys/utsname.h", "sys/un.h", - "sys/uio.h", "sys/types.h", "sys/times.h", "sys/timeb.h", - "sys/time.h", "sys/statvfs.h", "sys/stat.h", "sys/socket.h", - "sys/shm.h", "sys/sem.h", "sys/resource.h", "sys/msg.h", - "sys/mman.h", "sys/ipc.h", "syslog.h", "stropts.h", "strings.h", - "string.h", "stdlib.h", "stdio.h", "stddef.h", "stdarg.h", - "spawn.h", "signal.h", "setjmp.h", "semaphore.h", - "search.h", "sched.h", "regex.h", "pwd.h", "pthread.h", - "poll.h", "nl_types.h", "netinet/tcp.h", "netinet/in.h", - "net/if.h", "netdb.h", "ndbm.h", "mqueue.h", "monetary.h", - "math.h", "locale.h", "libgen.h", "langinfo.h", "iso646.h", - "inttypes.h", "iconv.h", "grp.h", "glob.h", "ftw.h", "fnmatch.h", - "fmtmsg.h", "float.h", "fcntl.h", "errno.h", "dlfcn.h", "dirent.h", - "ctype.h", "cpio.h", "assert.h", "arpa/inet.h", "aio.h"); + "utime.h", "unistd.h", "ulimit.h", "ucontext.h", "time.h", + "termios.h", "tar.h", "sys/wait.h", "sys/utsname.h", "sys/un.h", + "sys/uio.h", "sys/types.h", "sys/times.h", "sys/timeb.h", + "sys/time.h", "sys/statvfs.h", "sys/stat.h", "sys/socket.h", + "sys/shm.h", "sys/sem.h", "sys/resource.h", "sys/msg.h", + "sys/mman.h", "sys/ipc.h", "syslog.h", "stropts.h", "strings.h", + "string.h", "stdlib.h", "stdio.h", "stddef.h", "stdarg.h", + "spawn.h", "signal.h", "setjmp.h", "semaphore.h", + "search.h", "sched.h", "regex.h", "pwd.h", "pthread.h", + "poll.h", "nl_types.h", "netinet/tcp.h", "netinet/in.h", + "net/if.h", "netdb.h", "ndbm.h", "mqueue.h", "monetary.h", + "math.h", "locale.h", "libgen.h", "limits.h", "langinfo.h", + "iso646.h", "inttypes.h", "iconv.h", "grp.h", "glob.h", "ftw.h", + "fnmatch.h", "fmtmsg.h", "float.h", "fcntl.h", "errno.h", + "dlfcn.h", "dirent.h", "ctype.h", "cpio.h", "assert.h", + "arpa/inet.h", "aio.h"); + # These are the ISO C99 keywords. @keywords = ('auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', @@ -307,6 +309,79 @@ compiletest ($fnamebase, "Testing for type of member $member", "Member \"$member\" does not have the correct type.", $res); + } elsif (/^constant *([a-zA-Z0-9_]*) ([>=<]+) ([A-Za-z0-9_]*)/) { + my($const) = $1; + my($op) = $2; + my($value) = $3; + my($res) = $missing; + + # Remember that this name is allowed. + push @allow, $const; + + # Generate a program to test for the availability of this constant. + open (TESTFILE, ">$fnamebase.c"); + print TESTFILE "$prepend"; + print TESTFILE "#include <$h>\n"; + print TESTFILE "__typeof__ ($const) a = $const;\n"; + close (TESTFILE); + + $res = compiletest ($fnamebase, "Testing for constant $const", + "Constant \"$const\" not available.", $res); + + if ($value ne "") { + # Generate a program to test for the value of this constant. + open (TESTFILE, ">$fnamebase.c"); + print TESTFILE "$prepend"; + print TESTFILE "#include <$h>\n"; + # Negate the value since 0 means ok + print TESTFILE "int main (void) { return !($const $op $value); }\n"; + close (TESTFILE); + + $res = runtest ($fnamebase, "Testing for value of constant $const", + "Constant \"$const\" has not the right value.", $res); + } + } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*)?/) { + my($const) = $1; + my($type) = "$3$4"; + my($value) = $5; + my($res) = $missing; + + # Remember that this name is allowed. + push @allow, $const; + + # Generate a program to test for the availability of this constant. + open (TESTFILE, ">$fnamebase.c"); + print TESTFILE "$prepend"; + print TESTFILE "#include <$h>\n"; + print TESTFILE "__typeof__ ($const) a = $const;\n"; + close (TESTFILE); + + $res = compiletest ($fnamebase, "Testing for constant $const", + "Constant \"$const\" not available.", $res); + + # Test the types of the members. + open (TESTFILE, ">$fnamebase.c"); + print TESTFILE "$prepend"; + print TESTFILE "#include <$h>\n"; + print TESTFILE "__typeof__ (($type) 0) a;\n"; + print TESTFILE "extern __typeof__ ($const) a;\n"; + close (TESTFILE); + + compiletest ($fnamebase, "Testing for type of constant $const", + "Constant \"$const\" does not have the correct type.", + $res); + + if ($value ne "") { + # Generate a program to test for the value of this constant. + open (TESTFILE, ">$fnamebase.c"); + print TESTFILE "$prepend"; + print TESTFILE "#include <$h>\n"; + print TESTFILE "int main (void) { return $const != $value; }\n"; + close (TESTFILE); + + $res = runtest ($fnamebase, "Testing for value of constant $const", + "Constant \"$const\" has not the right value.", $res); + } } elsif (/^constant *([a-zA-Z0-9_]*) *([A-Za-z0-9_]*)?/) { my($const) = $1; my($value) = $2; @@ -526,6 +601,38 @@ compiletest ($fnamebase, "Test for type of function $fname", "Function \"$fname\" has incorrect type.", $res); + } elsif (/^macro-str *([^ ]*)\s*(\".*\")/) { + # The above regex doesn't handle a \" in a string. + my($macro) = "$1"; + my($string) = "$2"; + my($res) = $missing; + + # Remember that this name is allowed. + push @allow, $macro; + + # Generate a program to test for availability of this macro. + open (TESTFILE, ">$fnamebase.c"); + print TESTFILE "$prepend"; + print TESTFILE "#include <$h>\n"; + print TESTFILE "#ifndef $macro\n"; + print TESTFILE "# error \"Macro $macro not defined\"\n"; + print TESTFILE "#endif\n"; + close (TESTFILE); + + compiletest ($fnamebase, "Test availability of macro $macro", + "Macro \"$macro\" is not available.", $missing); + + # Generate a program to test for the value of this macro. + open (TESTFILE, ">$fnamebase.c"); + print TESTFILE "$prepend"; + print TESTFILE "#include <$h>\n"; + # We can't include here. + print TESTFILE "extern int (strcmp)(const char *, const char *);\n"; + print TESTFILE "int main (void) { return strcmp ($macro, $string) != 0;}\n"; + close (TESTFILE); + + $res = runtest ($fnamebase, "Testing for value of macro $macro", + "Macro \"$macro\" has not the right value.", $res); } elsif (/^macro *([^ ]*)/) { my($macro) = "$1"; ============================================================ Index: conform/data/cpio.h-data --- conform/data/cpio.h-data 1999/08/24 20:34:18 1.2 +++ conform/data/cpio.h-data 2000/05/02 18:12:05 @@ -19,8 +19,8 @@ constant C_ISCTG 0110000 constant C_ISLNK 0120000 constant C_ISSOCK 0140000 -# XXX We should be able to test a constant string content here. -constant MAGIC + +macro-str MAGIC "070707" allow *_t #endif ============================================================ Index: conform/data/limits.h-data --- conform/data/limits.h-data created +++ conform/data/limits.h-data Tue May 2 20:03:30 2000 1.1 @@ -0,0 +1,129 @@ +// if these values exist, we should check the minimal value +allow AIO_LIST_MAX +allow AIO_MAX +allow AIO_PRIO_DELTA_MAX +allow ARG_MAX +allow ATEXT_MAX +allow CHILD_MAX +allow DELAYTIMER_MAX +allow IOV_MAX +allow LOGIN_NAME_MAX +allow MQ_OPEN_MAX +allow OPEN_MAX +allow PAGESIZE +allow PAGE_SIZE +allow PTHREAD_DESTRUCTOR_ITERATIONS +allow PTHREAD_KEYS_MAX +allow PTHREAD_STACK_MIN +allow PTHREAD_THREADS_MAX +allow RE_DUP_MAX +allow RTSIG_MAX +allow SEM_NSEMS_MAX +allow SEM_VALUE_MAX +allow SIGQUEUE_MAX +allow SS_REPL_MAX +allow STREAM_MAX +allow SYMLOOP_MAX +allow TIMER_MAX +allow TTY_NAME_MAX +allow TZNAME_MAX + +allow FILESIZEBITS +allow LINK_MAX +allow MAX_CANON +allow MAX_INPUT +allow NAME_MAX +allow PATH_MAX +allow PIPE_BUF +allow POSIX_ALLOC_SIZE_MIN +allow POSIX_REC_INCR_XFER_SIZE +allow POSIX_REC_MAX_XFER_SIZE +allow POSIX_REC_XFER_ALIGN +allow SYMLINK_MAX + +macro BC_BASE_MAX +macro BC_DIM_MAX +macro BC_SCALE_MAX +macro BC_STRING_MAX +macro CHARCLASS_NAME_MAX +macro COLL_WEIGHTS_MAX +macro EXPR_NEST_MAX +macro LINE_MAX +constant NGROUPS_MAX >= 8 +macro RE_DUP_MAX + +constant _POSIX_CLOCKRES_MIN <= 20000000 + +constant _POSIX_AIO_LISTIO_MAX 2 +constant _POSIX_AIO_MAX 1 +constant _POSIX_ARG_MAX 4096 +constant _POSIX_CHILD_MAX 6 +constant _POSIX_DELAYTIMER_MAX 32 +constant _POSIX_LINK_MAX 8 +constant _POSIX_LOGIN_NAME_MAX 9 +constant _POSIX_MAX_CANON 255 +constant _POSIX_MAX_INPUT 255 +constant _POSIX_MQ_OPEN_MAX 8 +constant _POSIX_MQ_PRIO_MAX 32 +constant _POSIX_NAME_MAX 14 +constant _POSIX_NGROUPS_MAX 0 +constant _POSIX_OPEN_MAX 16 +constant _POSIX_PATH_MAX 256 +constant _POSIX_PIPE_BUF 512 +constant _POSIX_RE_DUP_MAX 255 +constant _POSIX_RTSIG_MAX 8 +constant _POSIX_SEM_NSEMS_MAX 256 +constant _POSIX_SEM_VALUE_MAX 32767 +constant _POSIX_SIGQUEUE_MAX 32 +constant _POSIX_SSIZE_MAX 32767 +constant _POSIX_STREAM_MAX 8 +constant _POSIX_SS_REPL_MAX 4 +constant _POSIX_SYMLINK_MAX 255 +constant _POSIX_SYMLOOP_MAX 8 +constant _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 +constant _POSIX_THREAD_KEYS_MAX 128 +constant _POSIX_THREAD_THREADS_MAX 64 +constant _POSIX_TIMER_MAX 32 +constant _POSIX_TTY_NAME_MAX 9 +constant _POSIX_TZNAME_MAX 6 +constant _POSIX2_BC_BASE_MAX 99 +constant _POSIX2_BC_DIM_MAX 2048 +constant _POSIX2_BC_SCALE_MAX 99 +constant _POSIX2_BC_STRING_MAX 1000 +constant _POSIX2_CHARCLASS_NAME_MAX 14 +constant _POSIX2_COLL_WEIGHTS_MAX 2 +constant _POSIX2_EXPR_NEST_MAX 32 +constant _POSIX2_LINE_MAX 2048 +constant _POSIX2_RE_DUP_MAX 255 +constant _XOPEN_IOV_MAX 16 + +constant CHAR_BIT >= 8 +constant CHAR_MAX +constant INT_MAX >= 2147483647 +constant LONG_BIT >= 32 +constant MB_LEN_MAX >= 1 +constant LONG_MAX >= 2147483647 +constant SCHAR_MAX >= 127 +constant SHRT_MAX >= 32767 +constant SSIZE_MAX +constant UCHAR_MAX >= 255 +constant UINT_MAX >= 4294967295 +constant ULONG_MAX >= 4294967295 +constant USHRT_MAX >= 65535 +constant WORD_BIT >= 16 +constant CHAR_MIN +constant INT_MIN <= 2147483647 +constant LONG_MIN <= 2147483647 +constant SCHAR_MIN <= -127 +constant SHRT_MIN <= -32767 + +constant CHARCLASS_NAME_MAX >= 14 +constant NL_ARGMAX >= 9 +constant NL_LANGMAX >= 14 +constant NL_MSGMAX >= 32767 +constant NL_NMAX +constant NL_SETMAX >= 255 +constant NL_TEXTMAX +constant NZERO >= 20 +constant TMP_MAX >= 10000 + -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From jakub@redhat.com Wed May 3 01:57:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 03 May 2000 01:57:00 -0000 Subject: [PATCH] res_querydomain fix Message-ID: <20000503110157.U540@sunsite.ms.mff.cuni.cz> Hi! glibc 2.1.x export symbol res_querydomain, that's what resolv/Versions in 2.1.90 export as well, but due to the unconditional redefinition (have no idea why it is there) __res_querydomain is not exported at all and res_querydomain does not exist at all. So programs wanting to use res_querydomain loose. BTW: _res_resultcodes and __p_rr used to be exported as well in glibc 2.1.x and are still mentioned in the Versions file, but they are no longer present. Should we add those for binary compatibility? I know _res_resultcodes has been moved to some other array with different structure, but even if some app used it and was recompiled, that new array is not exported at all. 2000-03-05 Jakub Jelinek * resolv/resolv.h (res_querydomain): Remove redefinition to __res_querydomain (reported by Owen Taylor ). --- resolv/resolv.h.jj Mon Jan 3 07:35:03 2000 +++ resolv/resolv.h Wed May 3 10:32:57 2000 @@ -266,7 +266,6 @@ extern struct __res_state _res; #define p_query __p_query #define res_close __res_close #define res_isourserver __res_isourserver -#define res_querydomain __res_querydomain #define res_send __res_send __BEGIN_DECLS Jakub From drepper@redhat.com Wed May 3 19:31:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 03 May 2000 19:31:00 -0000 Subject: [PATCH] res_querydomain fix References: <20000503110157.U540@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > glibc 2.1.x export symbol res_querydomain, that's what resolv/Versions in > 2.1.90 export as well, but due to the unconditional redefinition (have no > idea why it is there) __res_querydomain is not exported at all and > res_querydomain does not exist at all. So programs wanting to use > res_querydomain loose. OK, I've applied the patch. Thanks. > BTW: _res_resultcodes and __p_rr used to be exported as well in glibc 2.1.x > and are still mentioned in the Versions file, but they are no longer > present. Should we add those for binary compatibility? Yep, we probably should do this. Any volunteer? -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed May 3 21:47:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 03 May 2000 21:47:00 -0000 Subject: advance warning Message-ID: I'll be traveling again, starting next Monday for almost two weeks. I'll most probably have mail access most of the time but probably no bandwidth to work in CVS. I'll also have no possibility to compile. Therefore, please don't check in big changes or anything but bug fixes without a mail from me saying so. I feel very uncomfortable with seeing the tree changing much while I cannot see what's going on. It is bad enough that I'll have to make sure that gcc can be used again afterwards. I would appreciate if somebody could compile the mainline gcc every day and try it on glibc. (E.g., gcc is broken in the moment, for three days; this should be reported and I'll do it as soon as I know what's broken.) Not reporting problems immediately can lead to long periods of unusability. Anyway, there are several people here who have write access and I have no problem with bug fixes going in. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From jakub@redhat.com Wed May 3 22:42:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 03 May 2000 22:42:00 -0000 Subject: advance warning References: Message-ID: <20000504074721.J540@sunsite.ms.mff.cuni.cz> On Wed, May 03, 2000 at 09:44:59PM -0700, Ulrich Drepper wrote: > gcc every day and try it on glibc. (E.g., gcc is broken in the > moment, for three days; this should be reported and I'll do it as soon > as I know what's broken.) Not reporting problems immediately can lead > to long periods of unusability. I'm doing this now on an about weekly basis. This morning gcc did not bootstrap at all, so I'll have to fix that up first. A week ago everything worked just fine (well, I have tons of gcc patches in the tree which were submitted and not okayed yet). Jakub From aj@suse.de Thu May 4 05:06:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Thu, 04 May 2000 05:06:00 -0000 Subject: Question + Patch for i386/getcpuclockid Message-ID: With the current CVS version I get this warning: ../linuxthreads/sysdeps/unix/sysv/linux/i386/getcpuclockid.c:30: warning: comparison of distinct pointer types lacks a cast gcc complains about this test: /* We don't allow any process ID but our own. */ if (thread_handle (thread_id) != thread_self ()) return EPERM; The types used here are: static inline pthread_handle thread_handle(pthread_t id) static inline pthread_descr thread_self (void) __attribute__ ((const)); Is this really correct? The types are different and I don't see directly how the contents can be the same. I propose the appended patch to fix this, Andreas 2000-05-04 Andreas Jaeger * sysdeps/unix/sysv/linux/i386/getcpuclockid.c (pthread_getcpuclockid): Correct test for ourselves. ============================================================ Index: linuxthreads/sysdeps/unix/sysv/linux/i386/getcpuclockid.c --- linuxthreads/sysdeps/unix/sysv/linux/i386/getcpuclockid.c 2000/04/18 06:35:42 1.3 +++ linuxthreads/sysdeps/unix/sysv/linux/i386/getcpuclockid.c 2000/05/04 12:06:02 @@ -27,7 +27,7 @@ pthread_getcpuclockid (pthread_t thread_id, clockid_t *clock_id) { /* We don't allow any process ID but our own. */ - if (thread_handle (thread_id) != thread_self ()) + if (thread_handle (thread_id)->h_descr != thread_self ()) return EPERM; /* Store the number. */ -- Andreas Jaeger SuSE Labs aj@suse.de From aj@suse.de Thu May 4 07:26:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Thu, 04 May 2000 07:26:00 -0000 Subject: Patch for 2.1.3 Message-ID: Can we add Jakub's patch to 2.1.3? It's needed for newer make versions. Andreas 2000-04-26 Jakub Jelinek * Makeconfig (full_config_sysdirs): Renamed from full-config-sysdirs. * Makerules (full_config_sysdirs): Likewise. * MakeTAGS (full_config_sysdirs): Likewise. -- Andreas Jaeger SuSE Labs aj@suse.de From jakub@redhat.com Thu May 4 09:31:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 04 May 2000 09:31:00 -0000 Subject: [PATCH] Kill warnings in gconv.h Message-ID: <20000504183712.A540@sunsite.ms.mff.cuni.cz> Hi! Including gconv.h when gcc -pedantic spits out unneeded warnings. This patch kills them. 2000-05-04 Jakub Jelinek * iconv/gconv.h (__gconv_t): Add __extension__ to make gcc -pedantic happy. --- libc/iconv/gconv.h.jj Thu Apr 13 09:25:30 2000 +++ libc/iconv/gconv.h Thu May 4 18:17:30 2000 @@ -124,7 +124,7 @@ typedef struct __gconv_info { size_t __nsteps; struct __gconv_step *__steps; - struct __gconv_step_data __data[0]; + __extension__ struct __gconv_step_data __data[0]; } *__gconv_t; #endif /* gconv.h */ Jakub From aj@suse.de Thu May 4 09:48:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Thu, 04 May 2000 09:48:00 -0000 Subject: [PATCH] Kill warnings in gconv.h References: <20000504183712.A540@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > Including gconv.h when gcc -pedantic spits out unneeded warnings. IMHO -pedantic makes only sense if you also specify -ansi - and since gconv.h is not part of ISO C, we don't really need to care. Andreas > This patch kills them. > 2000-05-04 Jakub Jelinek > * iconv/gconv.h (__gconv_t): Add __extension__ to make gcc -pedantic > happy. > --- libc/iconv/gconv.h.jj Thu Apr 13 09:25:30 2000 > +++ libc/iconv/gconv.h Thu May 4 18:17:30 2000 > @@ -124,7 +124,7 @@ typedef struct __gconv_info > { > size_t __nsteps; > struct __gconv_step *__steps; > - struct __gconv_step_data __data[0]; > + __extension__ struct __gconv_step_data __data[0]; > } *__gconv_t; > #endif /* gconv.h */ > Jakub -- Andreas Jaeger SuSE Labs aj@suse.de From jakub@redhat.com Thu May 4 11:56:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 04 May 2000 11:56:00 -0000 Subject: [PATCH] Kill warnings in gconv.h References: <20000504183712.A540@sunsite.ms.mff.cuni.cz> Message-ID: <20000504210145.B540@sunsite.ms.mff.cuni.cz> On Thu, May 04, 2000 at 06:43:43PM +0200, Andreas Jaeger wrote: > >>>>> Jakub Jelinek writes: > > > Hi! > > Including gconv.h when gcc -pedantic spits out unneeded warnings. > > IMHO -pedantic makes only sense if you also specify -ansi - and since > gconv.h is not part of ISO C, we don't really need to care. gconv.h is included indirectly from , and even if you use -pedantic -ansi, you'll get the warning. ANSI C89 does not allow zero-sized arrays. There is a bunch of projects which use -pedantic at the moment, e.g. XFree86 4.0 or from yesterday gcc as well and IMHO the __extension__ will not hurt and will kill a warning on about every file in projects using -pedantic. Here is another -pedantic patch (again, included from stdio.h): 2000-05-04 Jakub Jelinek * sysdeps/generic/bits/confname.h (_SC* enum): Avoid comma at the end of enum. --- libc/sysdeps/generic/bits/confname.h.jj Thu May 4 20:33:16 2000 +++ libc/sysdeps/generic/bits/confname.h Thu May 4 20:34:12 2000 @@ -420,7 +420,7 @@ enum #define _SC_PBS_MESSAGE _SC_PBS_MESSAGE _SC_PBS_TRACK, #define _SC_PBS_TRACK _SC_PBS_TRACK - _SC_SYMLOOP, + _SC_SYMLOOP #define _SC_SYMLOOP _SC_SYMLOOP }; Jakub From kettenis@wins.uva.nl Thu May 4 15:44:00 2000 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Thu, 04 May 2000 15:44:00 -0000 Subject: Spin locks Message-ID: <200005042244.e44Mi9c23527@delius.kettenis.local> Hi, Here's a quick note to let people know that I'm working on implementing the POSIX spin locks that are in the current IEEE Std. 1003.1-200X draft. I'm trying to get things integrated with the existing Mach/Hurd spin lock implementation that's already present in glibc (I'm recycling some of the Hurd code in the POSIX spin locks, and will reimplement the Mach spin locks on top of the POSIX spin locks. There's on thing that I'd like your opinion on: The current spin lock implementation is based on a simple test-and-set operation, and is aggressively inlined. I think the idea is to avoid function calls when there is no lock contention (note that the origional CMU Mach cthreads code does the same thing). However, by inlining we expose the internal implementation, and this somewhat reduces the flexability to change the implementation in the future. It also makes it hard to provide an implementation that does additional sanity checking (locking a lock that's already held by a thread, deadlocks etc.). Personaly I think that's not what we should worry about. Spin locks should be fast and simple. Mark From drepper@redhat.com Thu May 4 16:00:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 04 May 2000 16:00:00 -0000 Subject: Spin locks References: <200005042244.e44Mi9c23527@delius.kettenis.local> Message-ID: Mark Kettenis writes: > Here's a quick note to let people know that I'm working on > implementing the POSIX spin locks that are in the current IEEE > Std. 1003.1-200X draft. For Hurd this is, I assume. I've committed the Linux implementation some time ago. > Spin locks should be fast and simple. Well, make it an option. Note that you are always exposing a part of the interface: the pthread_spinlock_t type. If you change this you'll have problem anyhow. If you keep the same structure you'll use the same algorithms as well (most probably). There are some more advantage in using inlined versions (such as avoiding the lock prefix on x86 if you know the application runs on single processor machines). Anyhow, there definitely should be an option to turn the inlining off. Or better, there should be a flag to turn it on. The extra sanity checks are sometimes really useful. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Thu May 4 22:35:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 04 May 2000 22:35:00 -0000 Subject: [PATCH] Kill warnings in gconv.h References: <20000504183712.A540@sunsite.ms.mff.cuni.cz> <20000504210145.B540@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > 2000-05-04 Jakub Jelinek > > * sysdeps/generic/bits/confname.h (_SC* enum): Avoid comma at the > end of enum. I've applied both patches. Thanks, -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Fri May 5 01:14:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 May 2000 01:14:00 -0000 Subject: twp bigger changes Message-ID: You might have noticed this from the CVS update and the checkin but I still want to announce two bigger changes: - I've added Jes's first IA-64 changes. These are the changes to ld.so. This was the part of all the changes which I had the most problems with. The new code looks partly a bit more ugly but these changes were necessary to not penalize all architectures but IA-64 for the latter's weird requirements. - I've changed the internal thread descriptor of the thread library a bit. This will have no visible changes for the user. The only possible problem could be gdb if the old thread debugging mechanism is used. But since gdb now uses libthread_db this shouldn't be a problem. libthread_db is there for just these cases. The change is necessary since there are changes coming down the road which will depend on the free room at the beginning of the structure. These changes are mainly dealing with thread-local data which is handled by the compiler. We are currently defining an appropriate ABI in the IA-64 working groups and I'm making sure the same mechanisms can be used for other architectures which have a thread-local register (or a relative wasy way to get it, like the Alpha). Since it is impractical to customize the compiler to look at the end of the internal structure it is better to have a fixed offset. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Fri May 5 02:10:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 05 May 2000 02:10:00 -0000 Subject: Patch for hwcaps Message-ID: Here's a first patch for the new ldconfig with hwcaps. This adds a conversion from strings to indices which I need. Uli, can I commit this? Andreas 2000-05-05 Andreas Jaeger * sysdeps/generic/dl-procinfo.h (_DL_HWCAP_COUNT): New. (_dl_string_hwcap): New, does nothing. * sysdeps/unix/sysv/linux/i386/dl-procinfo.h (_DL_HWCAP_COUNT): New. (_dl_procinfo): Use _DL_HWCAP_COUNT instead of a constant. (_dl_string_hwcap): New function, converts from string to hwcap encoding. * sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.h (_DL_HWCAP_COUNT): New. (_dl_procinfo): Use _DL_HWCAP_COUNT instead of a constant. (_dl_string_hwcap): New function, converts from string to hwcap encoding. * sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.h (_DL_HWCAP_COUNT): New. (_dl_procinfo): Use _DL_HWCAP_COUNT instead of a constant. (_dl_string_hwcap): New function, converts from string to hwcap encoding. ============================================================ Index: sysdeps/generic/dl-procinfo.h --- sysdeps/generic/dl-procinfo.h 1998/04/03 11:08:28 1.3 +++ sysdeps/generic/dl-procinfo.h 2000/05/05 09:07:58 @@ -1,5 +1,5 @@ /* Stub version of processor capability information handling macros. - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1998. @@ -29,5 +29,10 @@ /* By default there is no important hardware capability. */ #define HWCAP_IMPORTANT (0) + +/* We don't have any hardware capabilities. */ +#define _DL_HWCAP_COUNT 0 + +#define _dl_string_hwcap(str) (-1) #endif /* dl-procinfo.h */ ============================================================ Index: sysdeps/unix/sysv/linux/i386/dl-procinfo.h --- sysdeps/unix/sysv/linux/i386/dl-procinfo.h 1999/04/28 23:06:40 1.5 +++ sysdeps/unix/sysv/linux/i386/dl-procinfo.h 2000/05/05 09:07:58 @@ -1,5 +1,5 @@ /* Linux/i386 version of processor capability information handling macros. - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1998. @@ -30,6 +30,7 @@ "pat", "pse36", "18", "19", "20", "21", "22", "mmx", "osfxsr", "25", "26", "27", "28", "29", "30", "amd3d" }; +#define _DL_HWCAP_COUNT 32 static inline int __attribute__ ((unused)) @@ -41,7 +42,7 @@ _dl_sysdep_message ("AT_HWCAP: ", NULL); - for (i = 0; i < 32; ++i) + for (i = 0; i < _DL_HWCAP_COUNT; ++i) if (word & (1 << i)) _dl_sysdep_message (" ", x86_cap_flags[i], NULL); @@ -81,6 +82,20 @@ /* XXX Which others to add here? */ HWCAP_IMPORTANT = (HWCAP_I386_MMX) +}; + +static inline int +__attribute__ ((unused)) +_dl_string_hwcap (const char *str) +{ + int i; + + for (i = 0; i < _DL_HWCAP_COUNT; i++) + { + if (strcmp (str, x86_cap_flags[i]) == 0) + return i; + } + return -1; }; #endif /* dl-procinfo.h */ ============================================================ Index: sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.h --- sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.h 1999/04/14 15:48:06 1.1 +++ sysdeps/unix/sysv/linux/sparc/sparc32/dl-procinfo.h 2000/05/05 09:07:58 @@ -1,5 +1,5 @@ /* Linux/sparc32 version of processor capability information handling macros. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 1999. @@ -27,6 +27,7 @@ { "flush", "stbar", "swap", "muldiv", "v9" }; +#define _DL_HWCAP_COUNT 5 static inline int __attribute__ ((unused)) @@ -36,7 +37,7 @@ _dl_sysdep_message ("AT_HWCAP: ", NULL); - for (i = 0; i < 5; ++i) + for (i = 0; i < _DL_HWCAP_COUNT; ++i) if (word & (1 << i)) _dl_sysdep_message (" ", sparc32_cap_flags[i], NULL); @@ -50,6 +51,19 @@ _dl_hwcap_string (int idx) { return sparc32_cap_flags[idx]; +}; + +static inline int +__attribute__ ((unused)) +_dl_string_hwcap (const char *str) +{ + int i; + for (i = 0; i < _DL_HWCAP_COUNT; i++) + { + if (strcmp (str, sparc32_cap_flags [i]) == 0) + return i; + } + return -1; }; #define HWCAP_IMPORTANT (HWCAP_SPARC_V9) ============================================================ Index: sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.h --- sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.h 1999/04/14 15:48:06 1.1 +++ sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.h 2000/05/05 09:07:58 @@ -1,5 +1,5 @@ /* Linux/sparc64 version of processor capability information handling macros. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 1999. @@ -27,6 +27,7 @@ { "flush", "stbar", "swap", "muldiv", "v9" }; +#define _DL_HWCAP_COUNT 5 static inline int __attribute__ ((unused)) @@ -36,7 +37,7 @@ _dl_sysdep_message ("AT_HWCAP: ", NULL); - for (i = 0; i < 5; ++i) + for (i = 0; i < _DL_HWCAP_COUNT; ++i) if (word & (1 << i)) _dl_sysdep_message (" ", sparc64_cap_flags[i], NULL); @@ -50,6 +51,20 @@ _dl_hwcap_string (int idx) { return sparc64_cap_flags[idx]; +}; + + +static inline int +__attribute__ ((unused)) +_dl_string_hwcap (const char *str) +{ + int i; + for (i = 0; i < _DL_HWCAP_COUNT; i++) + { + if (strcmp (str, sparc64_cap_flags [i]) == 0) + return i; + } + return -1; }; #define HWCAP_IMPORTANT (0) -- Andreas Jaeger SuSE Labs aj@suse.de From aj@suse.de Fri May 5 02:46:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 05 May 2000 02:46:00 -0000 Subject: Move some cache definitions around Message-ID: To avoid duplication in glibc, I'm moving some definitions from dl-cache.c to dl-cache.h. This way I can include "dl-cache.h" in ldconfig without duplication. I'm working currently on enhancing ldconfig to support hwcaps and like to present the smaller patches separatly if possible. A patch for ldconfig which uses this will come later. Can I commit this, Uli? Andreas 2000-05-05 Andreas Jaeger * sysdeps/generic/dl-cache.c (_dl_cache_libcmp): Moved from here... * sysdeps/generic/dl-cache.h (_dl_cache_libcmp): ...to here. * sysdeps/generic/dl-cache.c (LD_SO_CACHE): Moved from here... * sysdeps/generic/dl-cache.h (LD_SO_CACHE): ...to here. * sysdeps/generic/dl-cache.c (CACHEMAGIC): Moved from here... * sysdeps/generic/dl-cache.h (CACHEMAGIC): ...to here. ============================================================ Index: sysdeps/generic/dl-cache.h --- sysdeps/generic/dl-cache.h 1999/06/09 11:41:38 1.1 +++ sysdeps/generic/dl-cache.h 2000/05/05 09:44:30 @@ -1,5 +1,5 @@ /* Support for reading /etc/ld.so.cache files written by Linux ldconfig. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 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 @@ -21,3 +21,48 @@ #define _dl_cache_check_flags(flags) \ ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID) + + +#ifndef LD_SO_CACHE +# define LD_SO_CACHE "/etc/ld.so.cache" +#endif + +#define CACHEMAGIC "ld.so-1.7.0" + +static int +_dl_cache_libcmp (const char *p1, const char *p2) +{ + while (*p1 != '\0') + { + if (*p1 >= '0' && *p1 <= '9') + { + if (*p2 >= '0' && *p2 <= '9') + { + /* Must compare this numerically. */ + int val1; + int val2; + + val1 = *p1++ - '0'; + val2 = *p2++ - '0'; + while (*p1 >= '0' && *p1 <= '9') + val1 = val1 * 10 + *p1++ - '0'; + while (*p2 >= '0' && *p2 <= '9') + val2 = val2 * 10 + *p2++ - '0'; + if (val1 != val2) + return val1 - val2; + } + else + return 1; + } + else if (*p2 >= '0' && *p2 <= '9') + return -1; + else if (*p1 != *p2) + return *p1 - *p2; + else + { + ++p1; + ++p2; + } + } + return *p1 - *p2; +} ============================================================ Index: sysdeps/generic/dl-cache.c --- sysdeps/generic/dl-cache.c 2000/03/23 20:28:06 1.20 +++ sysdeps/generic/dl-cache.c 2000/05/05 09:44:30 @@ -28,12 +28,6 @@ size_t *filesize_ptr, int mmap_prot); -#ifndef LD_SO_CACHE -# define LD_SO_CACHE "/etc/ld.so.cache" -#endif - -#define CACHEMAGIC "ld.so-1.7.0" - struct cache_file { char magic[sizeof CACHEMAGIC - 1]; @@ -55,46 +49,6 @@ /* This is the cache ID we expect. Normally it is 3 for glibc linked binaries. */ int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID; - -/* Helper function which must match the one in ldconfig, so that - we rely on the same sort order. */ -static int -_dl_cache_libcmp (const char *p1, const char *p2) -{ - while (*p1 != '\0') - { - if (*p1 >= '0' && *p1 <= '9') - { - if (*p2 >= '0' && *p2 <= '9') - { - /* Must compare this numerically. */ - int val1; - int val2; - - val1 = *p1++ - '0'; - val2 = *p2++ - '0'; - while (*p1 >= '0' && *p1 <= '9') - val1 = val1 * 10 + *p1++ - '0'; - while (*p2 >= '0' && *p2 <= '9') - val2 = val2 * 10 + *p2++ - '0'; - if (val1 != val2) - return val1 - val2; - } - else - return 1; - } - else if (*p2 >= '0' && *p2 <= '9') - return -1; - else if (*p1 != *p2) - return *p1 - *p2; - else - { - ++p1; - ++p2; - } - } - return *p1 - *p2; -} /* Look up NAME in ld.so.cache and return the file name stored there, -- Andreas Jaeger SuSE Labs aj@suse.de From aj@suse.de Fri May 5 06:49:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 05 May 2000 06:49:00 -0000 Subject: ldconfig hwcap rewrite Message-ID: I'm appending a patch so that ldconfig writes the hwcap information to ld.so.cache. This is done in a compatible way with the old format, the new array is hidden in the strings table (Thanks Ulrich for the hint!). I've also changed dl-cache.c so that it reads the new format. I've moved some definitions around to avoid duplication. dl-cache.h is now included by both ldconfig and dl-cache.c and contains the common interface. In fact we now support three formats - ldconfig creates any of these and ld.so reads all of them: - the old libc5/glibc 2.0/2.1 format (ldconfig -c old) - the old format with the new array hidden in it (that's the default format created by ldconfig) - the new format - without the old libc5/glibc 2.0/2.1 format (ldconfig -c new). This format can not be used with libc5! My patch contains my last patch (moving around of cache stuff or so) and needs the dl-procinfo.h patch. I've tested it with a few examples and it works for me: gromit:/usr/src/build-glibc/ldconfig.new:[1]$ LD_DEBUG=libs elf/ld.so /bin/ls 08783: find library=libc.so.6; searching 08783: search cache=/etc/ld.so.cache 08783: trying file=/lib/mmx/libc.so.6 08783: 08783: 08783: calling init: /lib/mmx/libc.so.6 [...] gromit:/usr/src/build-glibc/ldconfig.new:[0]$ elf/ldconfig -p |grep libc.so libc.so.6 (libc6, hwcap: 0x800000) => /lib/mmx/libc.so.6 libc.so.6 (libc6) => /lib/libc.so.6 libc.so.5 (libc5) => /usr/i486-linux-libc5/lib/libc.so.5 libc.so.4 (libc4) => /lib/libc.so.4 libc.so.1 (libc5) => /usr/i486-linux-libc5/lib/libc.so.1 libc.so (libc5) => /usr/i486-linux-libc5/lib/libc.so The format should be easy to extend. If you feel more confident with adding some unused entries to struct file_entry_new, go ahead. But I don't think that's necessary since cache_file_new contains four unused entries and has all the information we need to enhance it. Andreas 2000-05-05 Andreas Jaeger * sysdeps/generic/dl-cache.h (struct file_entry_new): New. (struct cache_file_new): New. (struct file_entry): New (moved from cache.c). (struct cache_file): New (moved from cache.c). * sysdeps/generic/dl-cache.c (SEARCH_CACHE): New macro, broken out from _dl_load_cache_lookup. (_dl_load_cache_lookup): Move search to SEARCH_CACHE macro, handle the different cache formats. New variable cache_new for new format. * elf/ldconfig.h: Change according to changes in cache.c and ldconfig.c; remove cache_libcmp; add opt_format. * elf/ldconfig.c: Include "dl-cache.h" and "dl-procinfo.h"; remove stuff that's defined in those headers. Add hwcap to struct lib_entry. (opt_format): New variable to select cache format. (options): Add format parameter. (is_hwcap): New function. (path_hwcap): New function. (parse_opt): Handle new format parameter. (search_dir): Handle hwcap, search also subdirectories with hwcap. * elf/cache.c (_GNU_SOURCE): Removed. Not needed anymore since ldconfig is part of glibc. Include dl-cache.h and remove stuff that's defined there. (struct cache_entry): Add new member hwcap. (print_entry): Print hwcap, cleanup a bit. (print_cache): Print new and old formats. (compare): Use _dl_cache_libcmp from dl-cache.h; handle hwcap. (save_cache): Save new and old formats. (add_to_cache): Handle hwcap. * sysdeps/generic/dl-cache.c (_dl_cache_libcmp): Moved from here... * sysdeps/generic/dl-cache.h (_dl_cache_libcmp): ...to here. * sysdeps/generic/dl-cache.c (LD_SO_CACHE): Moved from here... * sysdeps/generic/dl-cache.h (LD_SO_CACHE): ...to here. * sysdeps/generic/dl-cache.c (CACHEMAGIC): Moved from here... * sysdeps/generic/dl-cache.h (CACHEMAGIC): ...to here. ============================================================ Index: sysdeps/generic/dl-cache.h --- sysdeps/generic/dl-cache.h 1999/06/09 11:41:38 1.1 +++ sysdeps/generic/dl-cache.h 2000/05/05 13:40:20 @@ -1,5 +1,5 @@ /* Support for reading /etc/ld.so.cache files written by Linux ldconfig. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 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 @@ -21,3 +21,101 @@ #define _dl_cache_check_flags(flags) \ ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID) + + +#ifndef LD_SO_CACHE +# define LD_SO_CACHE "/etc/ld.so.cache" +#endif + +#define CACHEMAGIC "ld.so-1.7.0" + +/* libc5 and glibc 2.0/2.1 use the same format. For glibc 2.2 another + format has been added in a compatible way: + The beginning of the string table is used for the new table: + old_magic + nlibs + libs[0] + ... + libs[nlibs-1] + new magic + newnlibs + ... + newlibs[0] + ... + newlibs[newnlibs-1] + string 1 + string 2 + ... +*/ +struct file_entry +{ + int flags; /* This is 1 for an ELF library. */ + unsigned int key, value; /* String table indices. */ +}; + +struct cache_file +{ + char magic[sizeof CACHEMAGIC - 1]; + unsigned int nlibs; + struct file_entry libs[0]; +}; + +#define CACHEMAGIC_NEW "glibc-ld.so.cache" +#define CACHE_VERSION "1.0" + + +struct file_entry_new +{ + int flags; /* This is 1 for an ELF library. */ + unsigned int key, value; /* String table indices. */ + unsigned long hwcap; /* Hwcap entry. */ +}; + +struct cache_file_new +{ + char magic[sizeof CACHEMAGIC_NEW - 1]; + char version[sizeof CACHE_VERSION - 1]; + unsigned int nlibs; /* Number of entries. */ + unsigned int len_strings; /* Size of string table. */ + unsigned int unused[4]; /* Leave space for future extensions. */ + struct file_entry_new libs[0]; /* Entries describing libraries. */ + /* After this the string table of size len_strings is found. */ +}; + +static int +_dl_cache_libcmp (const char *p1, const char *p2) +{ + while (*p1 != '\0') + { + if (*p1 >= '0' && *p1 <= '9') + { + if (*p2 >= '0' && *p2 <= '9') + { + /* Must compare this numerically. */ + int val1; + int val2; + + val1 = *p1++ - '0'; + val2 = *p2++ - '0'; + while (*p1 >= '0' && *p1 <= '9') + val1 = val1 * 10 + *p1++ - '0'; + while (*p2 >= '0' && *p2 <= '9') + val2 = val2 * 10 + *p2++ - '0'; + if (val1 != val2) + return val1 - val2; + } + else + return 1; + } + else if (*p2 >= '0' && *p2 <= '9') + return -1; + else if (*p1 != *p2) + return *p1 - *p2; + else + { + ++p1; + ++p2; + } + } + return *p1 - *p2; +} ============================================================ Index: sysdeps/generic/dl-cache.c --- sysdeps/generic/dl-cache.c 2000/03/23 20:28:06 1.20 +++ sysdeps/generic/dl-cache.c 2000/05/05 13:40:20 @@ -22,31 +22,16 @@ #include #include + /* System-dependent function to read a file's whole contents in the most convenient manner available. */ extern void *_dl_sysdep_read_whole_file (const char *filename, size_t *filesize_ptr, int mmap_prot); -#ifndef LD_SO_CACHE -# define LD_SO_CACHE "/etc/ld.so.cache" -#endif - -#define CACHEMAGIC "ld.so-1.7.0" - -struct cache_file - { - char magic[sizeof CACHEMAGIC - 1]; - unsigned int nlibs; - struct - { - int flags; /* This is 1 for an ELF library. */ - unsigned int key, value; /* String table indices. */ - } libs[0]; - }; - /* This is the starting address and the size of the mmap()ed file. */ static struct cache_file *cache; +static struct cache_file_new *cache_new; static size_t cachesize; /* 1 if cache_data + PTR points into the cache. */ @@ -56,45 +41,94 @@ binaries. */ int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID; -/* Helper function which must match the one in ldconfig, so that - we rely on the same sort order. */ -static int -_dl_cache_libcmp (const char *p1, const char *p2) -{ - while (*p1 != '\0') - { - if (*p1 >= '0' && *p1 <= '9') - { - if (*p2 >= '0' && *p2 <= '9') - { - /* Must compare this numerically. */ - int val1; - int val2; - - val1 = *p1++ - '0'; - val2 = *p2++ - '0'; - while (*p1 >= '0' && *p1 <= '9') - val1 = val1 * 10 + *p1++ - '0'; - while (*p2 >= '0' && *p2 <= '9') - val2 = val2 * 10 + *p2++ - '0'; - if (val1 != val2) - return val1 - val2; - } - else - return 1; - } - else if (*p2 >= '0' && *p2 <= '9') - return -1; - else if (*p1 != *p2) - return *p1 - *p2; - else - { - ++p1; - ++p2; - } - } - return *p1 - *p2; -} +#define SEARCH_CACHE(cache) \ + /* We use binary search since the table is sorted in the cache file. \ + It is important to use the same algorithm as used while generating \ + the cache file. */ \ + do \ + { \ + left = 0; \ + right = cache->nlibs - 1; \ + middle = (left + right) / 2; \ + cmpres = 1; \ + \ + while (left <= right) \ + { \ + /* Make sure string table indices are not bogus before using them. */ \ + if (! _dl_cache_verify_ptr (cache->libs[middle].key)) \ + { \ + cmpres = 1; \ + break; \ + } \ + \ + /* Actually compare the entry with the key. */ \ + cmpres = _dl_cache_libcmp (name, cache_data + cache->libs[middle].key); \ + if (cmpres == 0) \ + /* Found it. */ \ + break; \ + \ + if (cmpres < 0) \ + left = middle + 1; \ + else \ + right = middle - 1; \ + \ + middle = (left + right) / 2; \ + } \ + \ + if (cmpres == 0) \ + { \ + /* LEFT now marks the last entry for which we know the name is \ + correct. */ \ + left = middle; \ + \ + /* There might be entries with this name before the one we \ + found. So we have to find the beginning. */ \ + while (middle > 0 \ + /* Make sure string table indices are not bogus before \ + using them. */ \ + && _dl_cache_verify_ptr (cache->libs[middle - 1].key) \ + /* Actually compare the entry. */ \ + && (_dl_cache_libcmp (name, \ + cache_data + cache->libs[middle - 1].key) \ + == 0)) \ + --middle; \ + \ + do \ + { \ + int flags; \ + \ + /* Only perform the name test if necessary. */ \ + if (middle > left \ + /* We haven't seen this string so far. Test whether the \ + index is ok and whether the name matches. Otherwise \ + we are done. */ \ + && (! _dl_cache_verify_ptr (cache->libs[middle].key) \ + || (_dl_cache_libcmp (name, \ + cache_data + cache->libs[middle].key) \ + != 0))) \ + break; \ + \ + flags = cache->libs[middle].flags; \ + if (_dl_cache_check_flags (flags) \ + && _dl_cache_verify_ptr (cache->libs[middle].value)) \ + { \ + if (best == NULL || flags == _dl_correct_cache_id) \ + { \ + HWCAP_CHECK; \ + best = cache_data + cache->libs[middle].value; \ + \ + if (flags == _dl_correct_cache_id) \ + /* We've found an exact match for the shared \ + object and no general `ELF' release. Stop \ + searching. */ \ + break; \ + } \ + } \ + } \ + while (++middle <= right); \ + } \ + } while (0) + /* Look up NAME in ld.so.cache and return the file name stored there, @@ -117,10 +151,38 @@ /* Read the contents of the file. */ void *file = _dl_sysdep_read_whole_file (LD_SO_CACHE, &cachesize, PROT_READ); + + /* We can handle three different cache file formats here: + - the old libc5/glibc2.0/2.1 format + - the old format with the new format in it + - only the new format + The following checks if the cache contains any of these formats. */ if (file && cachesize > sizeof *cache && !memcmp (file, CACHEMAGIC, sizeof CACHEMAGIC - 1)) - /* Looks ok. */ - cache = file; + { + /* Looks ok. */ + cache = file; + + /* Check for new version. */ + cache_new = (struct cache_file_new *) &cache->libs[cache->nlibs]; + if (cachesize < + (sizeof (struct cache_file) + cache->nlibs * sizeof (struct file_entry) + + sizeof (struct cache_file_new)) + || memcmp (cache_new->magic, CACHEMAGIC_NEW, + sizeof CACHEMAGIC_NEW - 1) + || memcmp (cache_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1)) + cache_new = (void *) -1; + } + else if (file && cachesize > sizeof *cache_new) + { + cache_new = (struct cache_file_new *) file; + if (memcmp (cache_new->magic, CACHEMAGIC_NEW, + sizeof CACHEMAGIC_NEW - 1) + || memcmp (cache_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1)) + cache_new = (void *) -1; + } else { if (file) @@ -138,89 +200,24 @@ cache_data = (const char *) &cache->libs[cache->nlibs]; best = NULL; - - /* We use binary search since the table is sorted in the cache file. - It is important to use the same algorithm as used while generating - the cache file. */ - left = 0; - right = cache->nlibs - 1; - middle = (left + right) / 2; - cmpres = 1; - while (left <= right) + if (cache_new != (void *) -1) { - /* Make sure string table indices are not bogus before using them. */ - if (! _dl_cache_verify_ptr (cache->libs[middle].key)) - { - cmpres = 1; - break; - } - - /* Actually compare the entry with the key. */ - cmpres = _dl_cache_libcmp (name, cache_data + cache->libs[middle].key); - if (cmpres == 0) - /* Found it. */ - break; - - if (cmpres < 0) - left = middle + 1; - else - right = middle - 1; - - middle = (left + right) / 2; - } - - if (cmpres == 0) - { - /* LEFT now marks the last entry for which we know the name is - correct. */ - left = middle; - - /* There might be entries with this name before the one we - found. So we have to find the beginning. */ - while (middle > 0 - /* Make sure string table indices are not bogus before - using them. */ - && _dl_cache_verify_ptr (cache->libs[middle - 1].key) - /* Actually compare the entry. */ - && (_dl_cache_libcmp (name, - cache_data + cache->libs[middle - 1].key) - == 0)) - --middle; - - do - { - int flags; - - /* Only perform the name test if necessary. */ - if (middle > left - /* We haven't seen this string so far. Test whether the - index is ok and whether the name matches. Otherwise - we are done. */ - && (! _dl_cache_verify_ptr (cache->libs[middle].key) - || (_dl_cache_libcmp (name, - cache_data + cache->libs[middle].key) - != 0))) - break; - - flags = cache->libs[middle].flags; - if (_dl_cache_check_flags (flags) - && _dl_cache_verify_ptr (cache->libs[middle].value)) - { - if (best == NULL || flags == _dl_correct_cache_id) - { - best = cache_data + cache->libs[middle].value; - - if (flags == _dl_correct_cache_id) - /* We've found an exact match for the shared - object and no general `ELF' release. Stop - searching. */ - break; - } - } - } - while (++middle <= right); + /* This file ends in static libraries where we don't have a hwcap. */ + unsigned long int *hwcap; + weak_extern (_dl_hwcap); + + hwcap = &_dl_hwcap; + +#define HWCAP_CHECK \ + if (*hwcap && (cache_new->libs[middle].hwcap & *hwcap) > _dl_hwcap) \ + continue + SEARCH_CACHE (cache_new); } + else +#undef HWCAP_CHECK +#define HWCAP_CHECK do {} while (0) + SEARCH_CACHE (cache); /* Print our result if wanted. */ if (_dl_debug_libs && best != NULL) ============================================================ Index: elf/ldconfig.h --- elf/ldconfig.h 2000/04/04 05:27:55 1.2 +++ elf/ldconfig.h 2000/05/05 13:40:20 @@ -1,4 +1,4 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 1999. @@ -37,11 +37,9 @@ extern void save_cache (const char *cache_name); -extern void add_to_cache (const char *path, const char *lib, int flags); +extern void add_to_cache (const char *path, const char *lib, int flags, + unsigned long int hwcap); -extern int cache_libcmp (const char *p1, const char *p2); - - /* Declared in readlib.c. */ extern int process_file (const char *file_name, const char *lib, int *flag, char **soname, int is_link); @@ -54,6 +52,8 @@ /* Declared in ldconfig.c. */ extern int opt_verbose; +extern int opt_format; + /* Prototypes for a few program-wide used functions. */ extern void *xmalloc (size_t __n); extern void *xcalloc (size_t __n, size_t __size); @@ -61,4 +61,3 @@ extern char *xstrdup (const char *__str); #endif /* ! _LDCONFIG_H */ - ============================================================ Index: elf/ldconfig.c --- elf/ldconfig.c 1999/12/18 19:16:26 1.2 +++ elf/ldconfig.c 2000/05/05 13:40:21 @@ -1,4 +1,4 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 1999. @@ -32,10 +32,12 @@ #include #include "ldconfig.h" +#include "dl-cache.h" -#ifndef LD_SO_CACHE -# define LD_SO_CACHE "/etc/ld.so.cache" -#endif +/* We don't need this here - silence the compiler. */ +#define _dl_sysdep_message(string, args...) do {} while (0); + +#include "dl-procinfo.h" #ifndef LD_SO_CONF # define LD_SO_CONF "/etc/ld.so.conf" @@ -49,6 +51,7 @@ struct lib_entry { int flags; + unsigned long int hwcap; char *lib; char *path; }; @@ -63,7 +66,7 @@ {"libc5", FLAG_ELF_LIBC5}, {"libc6", FLAG_ELF_LIBC6}, {"glibc2", FLAG_ELF_LIBC6} -}; +}; /* List of directories to handle. */ @@ -85,6 +88,10 @@ /* Be verbose. */ int opt_verbose = 0; +/* Format to support. */ +/* 0: only libc5/glibc2; 1: both; 2: only glibc 2.2. */ +int opt_format = 1; + /* Build cache. */ static int opt_build_cache = 1; @@ -123,6 +130,7 @@ { NULL, 'f', "CONF", 0, N_("Use CONF as configuration file"), 0}, { NULL, 'n', NULL, 0, N_("Only process directories specified on the command line. Don't build cache."), 0}, { NULL, 'l', NULL, 0, N_("Manually link individual libraries."), 0}, + { "format", 'c', "FORMAT", 0, N_("Format to use: new, old or compat (default)"), 0}, { NULL, 0, NULL, 0, NULL, 0 } }; @@ -138,8 +146,52 @@ options, parse_opt, NULL, doc, NULL, NULL, NULL }; +/* Check if string corresponds to a hardware capability. */ +static int +is_hwcap (const char *name) +{ + if (_dl_string_hwcap (name) != -1) + return 1; + return 0; +} + +/* Get hwcap encoding of path. */ +static unsigned long int +path_hwcap (const char *path) +{ + char *str = xstrdup (path); + char *ptr; + unsigned long int hwcap = 0; + unsigned long int h; + + size_t len; + + len = strlen (str); + if (str[len] == '/') + str[len] = '\0'; + /* Search pathname from the end and check for hwcap strings. */ + for (;;) + { + ptr = strrchr (str, '/'); + if (ptr == NULL) + break; + + h = _dl_string_hwcap (ptr+1); + + if (h == -1) + break; + hwcap += 1 << h; + + /* Search the next part of the path. */ + *ptr = '\0'; + } + + free (str); + return hwcap; +} + /* Handle program arguments. */ static error_t parse_opt (int key, char *arg, struct argp_state *state) @@ -174,6 +226,14 @@ case 'X': opt_link = 0; break; + case 'c': + if (strcmp (arg, "old") == 0) + opt_format = 0; + else if (strcmp (arg, "compat") == 0) + opt_format = 1; + else if (strcmp (arg, "new") == 0) + opt_format = 2; + break; default: return ARGP_ERR_UNKNOWN; } @@ -190,7 +250,7 @@ Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "1999"); +"), "2000"); fprintf (stream, gettext ("Written by %s.\n"), "Andreas Jaeger"); } @@ -202,10 +262,10 @@ char *equal_sign; struct dir_entry *entry, *ptr, *prev; unsigned int i; - + entry = xmalloc (sizeof (struct dir_entry)); entry->next = NULL; - + /* Search for an '=' sign. */ entry->path = xstrdup (line); equal_sign = strchr (entry->path, '='); @@ -235,7 +295,7 @@ entry->path [i] = '\0'; --i; } - + ptr = dir_entries; prev = ptr; while (ptr != NULL) @@ -270,7 +330,7 @@ int do_link = 1; int do_remove = 1; /* XXX: The logics in this function should be simplified. */ - + /* Get complete path. */ snprintf (full_libname, sizeof full_libname, "%s/%s", path, libname); snprintf (full_soname, sizeof full_soname, "%s/%s", path, soname); @@ -405,7 +465,7 @@ - create symbolic links to the soname for each library This has to be done separatly for each directory. - + To keep track of which libraries to add to the cache and which links to create, we save a list of all libraries. @@ -416,7 +476,7 @@ if new library is newer, replace entry otherwise ignore this library otherwise add library to list - + For example, if the two libraries libxy.so.1.1 and libxy.so.1.2 exist and both have the same soname, e.g. libxy.so, a symbolic link is created from libxy.so.1.2 (the newer one) to libxy.so. @@ -424,7 +484,7 @@ libxy.so.1.1. */ /* Information for one library. */ -struct dlib_entry +struct dlib_entry { char *name; char *soname; @@ -446,12 +506,18 @@ int nchars; struct stat stat_buf; int is_link; - + unsigned long int hwcap = path_hwcap (entry->path); + dlibs = NULL; if (opt_verbose) - printf ("%s:\n", entry->path); - + { + if (hwcap != 0) + printf ("%s: (hwcap: 0x%lx)\n", entry->path, hwcap); + else + printf ("%s:\n", entry->path); + } + dir = opendir (entry->path); if (dir == NULL) { @@ -459,7 +525,7 @@ error (0, errno, _("Can't open directory %s"), entry->path); return; } - + while ((direntry = readdir (dir)) != NULL) { @@ -468,15 +534,17 @@ /* We only look at links and regular files. */ if (direntry->d_type != DT_UNKNOWN && direntry->d_type != DT_LNK - && direntry->d_type != DT_REG) + && direntry->d_type != DT_REG + && direntry->d_type != DT_DIR) continue; #endif /* _DIRENT_HAVE_D_TYPE */ - - /* Does this file look like a shared library? The dynamic - linker is also considered as shared library. */ - if ((strncmp (direntry->d_name, "lib", 3) != 0 - && strncmp (direntry->d_name, "ld-", 3) != 0) - || strstr (direntry->d_name, ".so") == NULL) + /* Does this file look like a shared library or is it a hwcap + subdirectory? The dynamic linker is also considered as + shared library. */ + if (((strncmp (direntry->d_name, "lib", 3) != 0 + && strncmp (direntry->d_name, "ld-", 3) != 0) + || strstr (direntry->d_name, ".so") == NULL) + && !is_hwcap (direntry->d_name)) continue; nchars = snprintf (buf, sizeof (buf), "%s/%s", entry->path, direntry->d_name); @@ -492,6 +560,16 @@ error (0, errno, _("Can't lstat %s"), buf); continue; } + else if (S_ISDIR (stat_buf.st_mode) && is_hwcap (direntry->d_name)) + { + /* Handle subdirectory also, make a recursive call. */ + struct dir_entry new_entry; + new_entry.path = buf; + new_entry.flag = entry->flag; + new_entry.next = NULL; + search_dir (&new_entry); + continue; + } else if (!S_ISREG (stat_buf.st_mode) && !S_ISLNK (stat_buf.st_mode)) continue; @@ -506,7 +584,7 @@ free (soname); soname = xstrdup (direntry->d_name); } - + if (flag == FLAG_ELF && (entry->flag == FLAG_ELF_LIBC5 || entry->flag == FLAG_ELF_LIBC6)) @@ -524,7 +602,7 @@ && entry->flag != FLAG_ANY) error (0, 0, _("libc4 library %s in wrong directory"), buf); } - + /* Add library to list. */ for (dlib_ptr = dlibs; dlib_ptr != NULL; dlib_ptr = dlib_ptr->next) { @@ -535,7 +613,7 @@ is newer. */ if ((!is_link && dlib_ptr->is_link) || (is_link == dlib_ptr->is_link - && cache_libcmp (dlib_ptr->name, direntry->d_name) < 0)) + && _dl_cache_libcmp (dlib_ptr->name, direntry->d_name) < 0)) { /* It's newer - add it. */ /* Flag should be the same - sanity check. */ @@ -586,11 +664,11 @@ if (dlib_ptr->is_link == 0) create_links (entry->path, dlib_ptr->name, dlib_ptr->soname); if (opt_build_cache) - add_to_cache (entry->path, dlib_ptr->soname, dlib_ptr->flag); + add_to_cache (entry->path, dlib_ptr->soname, dlib_ptr->flag, hwcap); } /* Free all resources. */ - while (dlibs) + while (dlibs) { dlib_ptr = dlibs; free (dlib_ptr->soname); @@ -627,7 +705,7 @@ FILE *file; char *line = NULL; size_t len = 0; - + file = fopen (filename, "r"); if (file == NULL) @@ -667,7 +745,7 @@ main (int argc, char **argv) { int remaining; - + /* Parse and process arguments. */ argp_parse (&argp, argc, argv, 0, &remaining, NULL); @@ -685,7 +763,7 @@ if (config_file == NULL) config_file = LD_SO_CONF; - + /* Chroot first. */ if (opt_chroot) { @@ -713,8 +791,8 @@ exit (0); } - - + + if (opt_build_cache) init_cache (); @@ -726,7 +804,7 @@ parse_conf (config_file); } - + search_dirs (); if (opt_build_cache) ============================================================ Index: elf/cache.c --- elf/cache.c 2000/04/10 16:22:16 1.3 +++ elf/cache.c 2000/05/05 13:40:21 @@ -17,8 +17,6 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define _GNU_SOURCE 1 - #include #include #include @@ -34,32 +32,17 @@ #include #include "ldconfig.h" - -#define CACHEMAGIC "ld.so-1.7.0" +#include "dl-cache.h" struct cache_entry { char *lib; char *path; int flags; + unsigned long int hwcap; struct cache_entry *next; }; -struct file_entry -{ - int flags; /* This is 1 for an ELF library. */ - unsigned int key, value; /* String table indices. */ -}; - - -struct cache_file -{ - char magic[sizeof CACHEMAGIC - 1]; - unsigned int nlibs; - struct file_entry libs[0]; -}; - - /* List of all cache entries. */ static struct cache_entry *entries; @@ -69,7 +52,7 @@ /* Print a single entry. */ static void -print_entry (const char *lib, int flag, const char *key) +print_entry (const char *lib, int flag, unsigned long int hwcap, const char *key) { printf ("\t%s (", lib); switch (flag & FLAG_TYPE_MASK) @@ -93,14 +76,17 @@ case 0: break; default: - fprintf (stdout, ",%d", flag & FLAG_REQUIRED_MASK); + printf (",%d", flag & FLAG_REQUIRED_MASK); break; } + if (hwcap != 0) + printf (", hwcap: 0x%lx", hwcap); printf (") => %s\n", key); } -/* Print the whole cache file. */ +/* Print the whole cache file, if a file contains the new cache format + hidden in the old one, print the contents of the new format. */ void print_cache (const char *cache_name) { @@ -109,7 +95,9 @@ int fd; unsigned int i; struct cache_file *cache; + struct cache_file_new *cache_new = NULL; const char *cache_data; + int format = 0; fd = open (cache_name, O_RDONLY); if (fd < 0) @@ -128,20 +116,63 @@ error (EXIT_FAILURE, errno, _("mmap of cache file failed.\n")); cache_size = st.st_size; - if (cache_size < sizeof (struct cache_file) - || memcmp (cache->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1)) - return; - /* This is where the strings start. */ - cache_data = (const char *) &cache->libs[cache->nlibs]; - - printf (_("%d libs found in cache `%s'\n"), cache->nlibs, cache_name); - - /* Print everything. */ - for (i = 0; i < cache->nlibs; i++) - print_entry (cache_data + cache->libs[i].key, - cache->libs[i].flags, - cache_data + cache->libs[i].value); + if (cache_size < sizeof (struct cache_file)) + error (EXIT_FAILURE, 0, _("File is not a cache file.\n")); + if (memcmp (cache->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1)) + { + /* This can only be the new format without the old one. */ + cache_new = (struct cache_file_new *) cache; + + if (memcmp (cache_new->magic, CACHEMAGIC_NEW, sizeof CACHEMAGIC_NEW - 1) + || memcmp (cache_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1)) + error (EXIT_FAILURE, 0, _("File is not a cache file.\n")); + format = 1; + /* This is where the strings start. */ + cache_data = (const char *) cache; + } + else + { + /* This is where the strings start. */ + cache_data = (const char *) &cache->libs[cache->nlibs]; + + /* Check for a new cache embedded in the old format. */ + if (cache_size > + (sizeof (struct cache_file) + + cache->nlibs * sizeof (struct file_entry) + + sizeof (struct cache_file_new))) + { + cache_new = (struct cache_file_new *) cache_data; + + if (!memcmp (cache_new->magic, CACHEMAGIC_NEW, sizeof CACHEMAGIC_NEW - 1) + && !memcmp (cache_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1)) + format = 1; + } + } + + if (format == 0) + { + printf (_("%d libs found in cache `%s'\n"), cache->nlibs, cache_name); + + /* Print everything. */ + for (i = 0; i < cache->nlibs; i++) + print_entry (cache_data + cache->libs[i].key, + cache->libs[i].flags, 0, + cache_data + cache->libs[i].value); + } + else if (format == 1) + { + printf (_("%d libs found in cache `%s'\n"), cache_new->nlibs, cache_name); + + /* Print everything. */ + for (i = 0; i < cache_new->nlibs; i++) + print_entry (cache_data + cache_new->libs[i].key, + cache_new->libs[i].flags, + cache_new->libs[i].hwcap, + cache_data + cache_new->libs[i].value); + } /* Cleanup. */ munmap (cache, cache_size); close (fd); @@ -155,45 +186,6 @@ } -/* Helper function which must match the one in the dynamic linker, so that - we rely on the same sort order. */ -int -cache_libcmp (const char *p1, const char *p2) -{ - while (*p1 != '\0') - { - if (*p1 >= '0' && *p1 <= '9') - { - if (*p2 >= '0' && *p2 <= '9') - { - /* Must compare this numerically. */ - int val1; - int val2; - - val1 = *p1++ - '0'; - val2 = *p2++ - '0'; - while (*p1 >= '0' && *p1 <= '9') - val1 = val1 * 10 + *p1++ - '0'; - while (*p2 >= '0' && *p2 <= '9') - val2 = val2 * 10 + *p2++ - '0'; - if (val1 != val2) - return val1 - val2; - } - else - return 1; - } - else if (*p2 >= '0' && *p2 <= '9') - return -1; - else if (*p1 != *p2) - return *p1 - *p2; - else - { - ++p1; - ++p2; - } - } - return *p1 - *p2; -} static int compare (const struct cache_entry *e1, const struct cache_entry *e2) @@ -201,80 +193,135 @@ int res; /* We need to swap entries here to get the correct sort order. */ - res = cache_libcmp (e2->lib, e1->lib); + res = _dl_cache_libcmp (e2->lib, e1->lib); if (res == 0) { if (e1->flags < e2->flags) return 1; else if (e1->flags > e2->flags) return -1; + else if (e2->hwcap > e1->hwcap) + return 1; + else if (e2->hwcap < e1->hwcap) + return -1; } return res; } - /* Save the contents of the cache. */ void save_cache (const char *cache_name) { struct cache_entry *entry; - int i, fd; + int fd, idx_old, idx_new; size_t total_strlen, len; char *strings, *str, *temp_name; - struct cache_file *file_entries; - size_t file_entries_size; + struct cache_file *file_entries = NULL; + struct cache_file_new *file_entries_new = NULL; + size_t file_entries_size = 0; + size_t file_entries_new_size = 0; unsigned int str_offset; /* Number of cache entries. */ int cache_entry_count = 0; + /* Number of normal cache entries. */ + int cache_entry_old_count = 0; /* The cache entries are sorted already, save them in this order. */ /* Count the length of all strings. */ + /* The old format doesn't contain hwcap entries and doesn't contain + libraries in subdirectories with hwcaps entries. Count therefore + also all entries with hwcap == 0. */ total_strlen = 0; for (entry = entries; entry != NULL; entry = entry->next) { /* Account the final NULs. */ total_strlen += strlen (entry->lib) + strlen (entry->path) + 2; ++cache_entry_count; + if (entry->hwcap == 0) + ++cache_entry_old_count; } /* Create the on disk cache structure. */ /* First an array for all strings. */ strings = (char *)xmalloc (total_strlen + 1); + + if (opt_format != 2) + { + /* And the list of all entries in the old format. */ + file_entries_size = sizeof (struct cache_file) + + cache_entry_old_count * sizeof (struct file_entry); + file_entries = (struct cache_file *) xmalloc (file_entries_size); + + /* Fill in the header. */ + memset (file_entries, 0, sizeof (struct cache_file)); + memcpy (file_entries->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1); + + file_entries->nlibs = cache_entry_old_count; + } - /* And the list of all entries. */ - file_entries_size = sizeof (struct cache_file) - + cache_entry_count * sizeof (struct file_entry); - file_entries = (struct cache_file *) xmalloc (file_entries_size); - - /* Fill in the header. */ - memset (file_entries, 0, sizeof (struct cache_file)); - memcpy (file_entries->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1); + if (opt_format != 0) + { + /* And the list of all entries in the new format. */ + file_entries_new_size = sizeof (struct cache_file_new) + + cache_entry_count * sizeof (struct file_entry_new); + file_entries_new = (struct cache_file_new *) xmalloc (file_entries_new_size); + + /* Fill in the header. */ + memset (file_entries_new, 0, sizeof (struct cache_file_new)); + memcpy (file_entries_new->magic, CACHEMAGIC_NEW, sizeof CACHEMAGIC_NEW - 1); + memcpy (file_entries_new->version, CACHE_VERSION, sizeof CACHE_VERSION - 1); + + file_entries_new->nlibs = cache_entry_count; + /* XXX why + 1 */ + file_entries_new->len_strings = total_strlen + 1; + } - file_entries->nlibs = cache_entry_count; + /* If we have both formats, we hide the new format in the strings + table, we have to adjust all string indices for this so that + old libc5/glibc 2 dynamic linkers just ignore them. */ + if (opt_format == 1) + str_offset = file_entries_new_size; + else + str_offset = 0; - str_offset = 0; str = strings; - for (i = 0, entry = entries; entry != NULL; entry = entry->next, ++i) + for (idx_old = 0, idx_new = 0, entry = entries; entry != NULL; + entry = entry->next, ++idx_new) { - file_entries->libs[i].flags = entry->flags; /* First the library. */ - /* XXX: Actually we can optimize here and remove duplicates. */ - file_entries->libs[i].key = str_offset; + if (opt_format != 2) + { + file_entries->libs[idx_old].flags = entry->flags; + /* XXX: Actually we can optimize here and remove duplicates. */ + file_entries->libs[idx_old].key = str_offset; + } + if (opt_format != 0) + { + /* XXX: Should we subtract file_entries_new_size from str_offset? */ + file_entries_new->libs[idx_new].flags = entry->flags; + file_entries_new->libs[idx_new].hwcap = entry->hwcap; + file_entries_new->libs[idx_new].key = str_offset; + } len = strlen (entry->lib); str = stpcpy (str, entry->lib); /* Account the final NUL. */ ++str; str_offset += len + 1; /* Then the path. */ - file_entries->libs[i].value = str_offset; + if (opt_format != 2) + file_entries->libs[idx_old].value = str_offset; + if (opt_format != 0) + file_entries_new->libs[idx_new].value = str_offset; len = strlen (entry->path); str = stpcpy (str, entry->path); /* Account the final NUL. */ ++str; str_offset += len + 1; + /* Ignore entries with hwcap for old format. */ + if (entry->hwcap == 0) + ++idx_old; } - assert (str_offset == total_strlen); /* Write out the cache. */ @@ -293,8 +340,17 @@ temp_name); /* Write contents. */ - if (write (fd, file_entries, file_entries_size) != (ssize_t)file_entries_size) - error (EXIT_FAILURE, errno, _("Writing of cache data failed")); + if (opt_format != 2) + { + if (write (fd, file_entries, file_entries_size) != (ssize_t)file_entries_size) + error (EXIT_FAILURE, errno, _("Writing of cache data failed")); + } + if (opt_format != 0) + { + if (write (fd, file_entries_new, file_entries_new_size) + != (ssize_t)file_entries_new_size) + error (EXIT_FAILURE, errno, _("Writing of cache data failed")); + } if (write (fd, strings, total_strlen) != (ssize_t)total_strlen) error (EXIT_FAILURE, errno, _("Writing of cache data failed.")); @@ -325,9 +381,11 @@ } } + /* Add one library to the cache. */ void -add_to_cache (const char *path, const char *lib, int flags) +add_to_cache (const char *path, const char *lib, int flags, + unsigned long int hwcap) { struct cache_entry *new_entry, *ptr, *prev; char *full_path; @@ -343,6 +401,7 @@ new_entry->lib = xstrdup (lib); new_entry->path = full_path; new_entry->flags = flags; + new_entry->hwcap = hwcap; /* Keep the list sorted - search for right place to insert. */ ptr = entries; -- Andreas Jaeger SuSE Labs aj@suse.de From hjl@lucon.org Fri May 5 08:09:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Fri, 05 May 2000 08:09:00 -0000 Subject: binutils 2.9.5.0.41 is released. Message-ID: <20000505080932.B2897@lucon.org> On Fri, May 05, 2000 at 10:10:20AM +0200, Martin v. Loewis wrote: > > Thanks for the tips. Actually, before attempting to get the latest > > GCC snapshot, I installed the latest binutils from HJ Lu > > (2.9.5.0.37). I'm not sure where they stand with respect to > > "today's CVS binutils"... Maybe HJ could comment on this... > > I really meant "today's"; the relevant patch was checked in on > Wednesday, I believe. > binutils 2.9.5.0.41 has Martin's patch. Let me know if anything is wrong on Linux. H.J. --- This is the beta release of binutils 2.9.5.0.41 for Linux, which is based on binutils 2000 0502 plus various changes. It is purely for Linux, although it has been tested on Solaris/Sparc and Solaris/x86 from time to time. I am planning to make the public release soon. Please test it as much as you can. Please report any bugs related to binutils 2.9.5.0.41 to hjl@lucon.org. For arm-linux targets, there are some important differences in behaviour between these tools and binutils 2.9.1.0.x. The linker emulation name has changed from elf32arm{26} to armelf_linux{26}. Also, the "-p" flag must be passed with the linker when working with object files (or static libraries) created using older versions of the assembler. If this flag is omitted the linker will silently generate bad output when given old input files. To get the correct behaviour from gcc, amend the *link section of your specs file as follows: *link: %{h*} %{version:-v} %{b} %{Wl,*:%*} %{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} %{rdynamic:-export-dynamic} %{!dynamic-linker: -dynamic-linker /lib/ld-linux.so.2} -X %{mbig-endian:-EB} %{mapcs-26:-m armelf_linux26} %{!mapcs-26:-m armelf_linux} -p Changes from binutils 2.9.5.0.37: 1. Update from binutils 2000 0502. 2. Support STV_HIDDEN and STV_INTERNAL. Changes from binutils 2.9.5.0.35: 1. Update from binutils 2000 0418. 2. Fix an ld demangle style option bug. Changes from binutils 2.9.5.0.34: 1. Update from binutils 2000 0412. Fix a relocation bug which affects the Linux kernel compilation. 2. An ELF/PPC linker script update. Changes from binutils 2.9.5.0.33: 1. Update from binutils 2000 0404. Fix the bug report bug. Changes from binutils 2.9.5.0.32: 1. Update from binutils 2000 0403. Fix the 16bit ia32 assembler bug. Changes from binutils 2.9.5.0.31: 1. Update from binutils 2000 0331. Fix the Linux/ARM assembler bug. 2. Fix a Debian assembler security bug. Changes from binutils 2.9.5.0.29: 1. Update from binutils 2000 0319. 2. An ELF/alpha bug is fixed. Changes from binutils 2.9.5.0.27: 1. Update from binutils 2000 0301. 2. A demangler bug is fixed. 3. A better fix for undefined symbols with -Bsymbolic when building shared library. Changes from binutils 2.9.5.0.24: 1. Update from binutils 2000 0204. 2. Added -taso to linker on alpha. 3. Fixed a -shared -Bsymbolic bug when PIC is not used. Changes from binutils 2.9.5.0.22: 1. Update from binutils 2000 0113. 2. A symbol version bug is fixed. 3. A -Bsymbolic bug is fixed. Changes from binutils 2.9.5.0.21: 1. Update from binutils 1999 1202. 2. Remove a MIPS/ELF change. 3. Enable SOM for HPPA. Changes from binutils 2.9.5.0.19: 1. Update from binutils 1999 1122. An ia32 gas bug is fixed. Changes from binutils 2.9.5.0.16: 1. Update from binutils 1999 1104. 2. i370 is changed to use EM_S370 and ELFOSABI_LINUX. Update readelf. 3. Fix Compaq's demangler support. Changes from binutils 2.9.5.0.14: 1. Update from binutils 1999 1012. A gas bug which affects Linux 2.3.21 is fixed. 2. i370 update. 3. The new demangler code. You should use "--style=xxx" to select the demnangle style instead of "--lang=xxx". Changes from binutils 2.9.5.0.13: 1. Update from binutils 1999 0925. 2. Fix a -s and linker script bug. Changes from binutils 2.9.5.0.12: 1. Update from binutils 1999 0922. 2. i370 update. Changes from binutils 2.9.5.0.11: 1. Update from binutils 1999 0910. It fixed a PIC linker bug on ix86 and sparc introduced in the last release. 2. i370 update. Changes from binutils 2.9.5.0.10: 1. Update from binutils 1999 0906. It fixed a PIC linker bug on ix86 and sparc. 2. Remove elf/hppa since it is WIP. Changes from binutils 2.9.5.0.8: 1. Update from binutils 1999 0831. It allows spaces around '(' and ')' in x86 FP register names. Changes from binutils 2.9.5.0.7: 1. Update from binutils 1999 0821. 2. Some MIPS changes. Changes from binutils 2.9.5.0.6: 1. Update from binutils 1999 0813. 2. i370 update. Changes from binutils 2.9.5.0.5: 1. Update from binutils 1999 0809. An ELF/Sparc ld bug is fixed. Changes from binutils 2.9.5.0.4: 1. Update from binutils 1999 0806. A Solaris/Sparc gas bug is fixed. 2. Remove mips gas patches from binutils 2.9.1.0.25. Changes from binutils 2.9.5.0.3: 1. Update from binutils 1999 0801. 2. Support for real mode x86 gcc. Changes from binutils 2.9.4.0.8: 1. Update from binutils 1999 0719. A libc 5 related bug fix. 2. Fix a typo in mips gas. Changes from binutils 2.9.4.0.7: 1. Update from binutils 1999 0710. A weak symbol bug http://egcs.cygnus.com/ml/egcs-bugs/1999-07/msg00129.html is fixed. Changes from binutils 2.9.4.0.6: 1. Update from binutils 1999 0626. Changes from binutils 2.9.4.0.5: 1. Update from binutils 1999 0620. 2. Remove my fwait fix and use the one in cvs. 3. Use "--only-section=section" instead of "--extract-section=section". for objcopy. Changes from binutils 2.9.4.0.4: 1. Update from binutils 1999 0612. 2. Remove various temporary fixes of mine since those bugs are fixed now. Changes from binutils 2.9.4.0.3: 1. Update from binutils 1999 0611. 2. Remove my ELF/Alpha bfd changes. 3. Use the local symbol copy fix in binutils 1999 0611. Changes from binutils 2.9.4.0.2: 1. Update from binutils 1999 0607. 2. Remove my Sparc hacks. 3. Fix local symbol copy. Changes from binutils 2.9.4.0.1: 1. Update from binutils 1999 0606. 2. Restore relocation overflow checking in binutils 2.9.1.0.25 so that Linux kernel can build. 3. Fix i370 for the new gas. Changes from binutils 1999 0605: 1. Fix a -Bsymbolic bug for Linux/alpha. 2. Add ELF/i370. 3. Fix 8/16-bit relocations for i386. 4. Add --redefine-sym=old_form=new_form to objcopy. 5. Add "-j section" for objcopy. 6. Fix i386 disassembler for fwait. 7. Fix a Sparc asm bug. 8. Add Ada demangle support. 9. Fix MIPS/ELF bugs. 10. Add some vxworks suppport. 11. Fix a.out assembler. The file list: 1. binutils-2.9.5.0.41.tar.gz. Source code. 2. binutils-2.9.5.0.37-2.9.5.0.41.diff.gz. Patch against the previous beta source code. 3. binutils-2.9.5.0.41-1.i386.rpm. IA-32 binary RPM for RedHat 6.2. There is no separate source rpm. You can do # rpm -ta binutils-2.9.5.0.41.tar.gz to create both binary and source rpms. The primary ftp sites for the beta Linux binutils are: 1. ftp://ftp.valinux.com/pub/support/hjl/binutils Thanks. H.J. Lu hjl@lucon.org 05/05/2000 From drepper@redhat.com Fri May 5 08:14:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 May 2000 08:14:00 -0000 Subject: Patch for hwcaps References: Message-ID: Andreas Jaeger writes: > Uli, can I commit this? Yep, go on. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Fri May 5 08:15:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 May 2000 08:15:00 -0000 Subject: Move some cache definitions around References: Message-ID: Andreas Jaeger writes: > Can I commit this, Uli? If you say you need the definitions elsewhere it's OK. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Fri May 5 08:34:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 May 2000 08:34:00 -0000 Subject: ldconfig hwcap rewrite References: Message-ID: It looks OK but there are a few problems. > +#define HWCAP_CHECK \ > + if (*hwcap && (cache_new->libs[middle].hwcap & *hwcap) > _dl_hwcap) \ > + continue > + SEARCH_CACHE (cache_new); > } > + else The first test certainly must be "if (hwcap", i.e., no dereferencing. Second, related to this, if you are using binary sort for the extended table, how do you make sure you see all the entries with a given name but different hwcaps? It seems you are stumbling accross one and then us the existence of the hwcap field to single step to the next entry. But what if the first entry with a matching name is not the one with the most specific hwcap? What I think is necessary is that either - there is exactly one of the hwcap entries actually in the table and by some the different hwcap entries can be by some other mean - add an explicit index to the first hwcap entry with the matching hwcap. The algorithm would look like this: find idx with matching file name if hwcap in entry[idx] is zero found entry idx else idx = entry[idx].first_hwcap while ((entry[idx].hwcap & _dl_hwcap) > _dl_hwcap) // Probably need to handle case here where no lib with hwcap // zero is available ++idx; found entry idx If you have already done something like this I missed it in my brief look over the code. It should be carefully documented in any case. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Fri May 5 08:35:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 05 May 2000 08:35:00 -0000 Subject: Move some cache definitions around References: Message-ID: >>>>> Ulrich Drepper writes: Uli> Andreas Jaeger writes: >> Can I commit this, Uli? Uli> If you say you need the definitions elsewhere it's OK. I need them, see my last patch. That patch also contains this one, so I'm not commiting it now and instead wait until you checked in my ldconfig hwcap enhancements - or told me to do it myself. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de From drepper@redhat.com Fri May 5 08:47:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 May 2000 08:47:00 -0000 Subject: Spin locks References: <200005042244.e44Mi9c23527@delius.kettenis.local> Message-ID: tb@MIT.EDU (Thomas Bushnell, BSG) writes: > For things like this, my preference is to just key on __OPTIMIZE__. > We shouldn't burden the users with a gajillion optimization options. Well, normally this is a good thing but not here I'd say. gcc generates really lousy code when not optimizing, especially the dead code analysis is missing. Now you suspect a problem with the spinlocks. Your only alternative would be to recompile everything without optimization. Yuck. Instead it should be possible to prevent the inling during debugging (to get the extra checks) and still have the dead code being removed. But since it's hurd I let you guys make the decision. I think this feature is important enough having used it on Linux (for mutexes) several times in the past. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@valinux.com Fri May 5 09:01:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Fri, 05 May 2000 09:01:00 -0000 Subject: [ia64-tools] generic glibc bug References: Message-ID: <20000505082525.B9881@valinux.com> On Fri, May 05, 2000 at 04:13:10PM +0200, Dan Pop wrote: > > Hi, > > This is probably not the best place to report this bug, but I'm sure > that the "right" eyes will see it. > > The memccpy() implementation in glibc (both 2.1 and 2.2) is broken. > The code looks like this: > > void * > __memccpy (dest, src, c, n) > void *dest; const void *src; > int c; size_t n; > { > register const char *s = src; > register char *d = dest; > register const reg_char x = (unsigned char) c; > register size_t i = n; > > while (i-- > 0) > if ((*d++ = *s++) == x) > return d; > > return NULL; > } > > If x is greater than 127 and plain char is signed, the match will never > be found, because d is a pointer to char and not to unsigned char, as it > should be. Instead of stopping after copying the target byte and returning > the address of the next byte in dest, the function will copy all n bytes and > return NULL. > It looks like a real bug. We should change "char *" to "unsigned char *". -- H.J. Lu (hjl@gnu.org) From kettenis@wins.uva.nl Fri May 5 09:52:00 2000 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Fri, 05 May 2000 09:52:00 -0000 Subject: Spin locks References: <200005042244.e44Mi9c23527@delius.kettenis.local> Message-ID: <200005051652.e45GqPO00433@delius.kettenis.local> From: Ulrich Drepper Date: 04 May 2000 16:00:35 -0700 Mark Kettenis writes: > Here's a quick note to let people know that I'm working on > implementing the POSIX spin locks that are in the current IEEE > Std. 1003.1-200X draft. For Hurd this is, I assume. I've committed the Linux implementation some time ago. Oops, seems I was fooled by LinuxThreads having its own ChangeLog entry :-(. My intention was to provide a spin lock implementation for all platforms. But since you already implemented them for Linux, I'll not try to push it :-) Anyway, I've taken a look at the code in linuxthreads/spinlock.c, but it looks to me as if your implementation is more like a fast and simple mutex than a spin lock. In fact the only different between a spin lock and a PTHREAD_MUTEX_FAST_NP mutex, is that you avoid the check of the mutex type. My understanding of what a spin lock does is: 1. Try to get the lock using some atomic operation. 2. If the lock couldn't be obtained, "spin" that is repeat step 1 for say N times, that is, keep actively polling for a while. 3. If the lock is still held by another thread, yield the processor. The idea is that you use spin locks around operations that would only take a few cycles. That means that if you're running on a multiprocessor machine and find that the lock is held by another thread, chances are high that the lock will become in the next few cycles and it is advantagous to actively wait to avoid step 3, which typically involves one or more system calls. Of course on a single processor machine you would set N = 0, since spinning is probably pointless there. I don't know the LinuxThreads implementation too well, but I believe step 3 is terribly expensive on Linux (involving several system calls). But there may be reasons why spinning is pointless on SMP Linux. Anyway, you're welcome to use the Hurd's spin lock implementation if you like :-). > Spin locks should be fast and simple. Well, make it an option. Note that you are always exposing a part of the interface: the pthread_spinlock_t type. If you change this you'll have problem anyhow. If you keep the same structure you'll use the same algorithms as well (most probably). There are some more advantage in using inlined versions (such as avoiding the lock prefix on x86 if you know the application runs on single processor machines). Hmm, I don't think I completely understand you here. First, the specification makes it possible to implement spin locks without exposing anything about the internals (in contrast to mutexes and condition varibles). Simply make pthread_spinlock_t a pointer and let pthread_spin_init allocate the data that's necessary. That wouldn't be a terrible smart thing to do I think, which is probably why you didn't consider it. Second, I don't see why using inlines helps to avoid using a lock prefix. Not inlining would make it possible to compile an optimized libc for uni-processors. Inlining would force me to use a lock prefix if I want to make sure the same binary will work on both single and multi processor machines. This issue isn't really relevant since I'm using xchgl wich doesn't need a lock prefix since the locking id done implicitly. It's probably possible to make use btsl like the Linux kernel does, and drop the lock prefix if we somehow know we're on a uniprocessor. But I'm not sure if that would really improve preformance. Anyhow, there definitely should be an option to turn the inlining off. Or better, there should be a flag to turn it on. The extra sanity checks are sometimes really useful. I think a compile-time flag to choose an alternative spin lock implementation that does additional sanity checks (and therefore doesn't do any inlining) would be a good idea, but not a priority (the LinuxThreads implementation doesn't do it either :-)). I even think this could implemented on top of the same pthread_spinlock_t type in a way that would more-or-less work even if not all code is compiled with that particular flag. Mark From drepper@redhat.com Fri May 5 09:59:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 May 2000 09:59:00 -0000 Subject: Spin locks References: <200005042244.e44Mi9c23527@delius.kettenis.local> <200005051652.e45GqPO00433@delius.kettenis.local> Message-ID: Mark Kettenis writes: > Anyway, I've taken a look at the code in linuxthreads/spinlock.c, but > it looks to me as if your implementation is more like a fast and > simple mutex than a spin lock. In fact the only different between a > spin lock and a PTHREAD_MUTEX_FAST_NP mutex, is that you avoid the > check of the mutex type. Well, this is the only way to avoid priority inversion. If you know nothing abou the other thread contesting for the spinlock you will run into these problems. My understanding is the priority iversions must be handled gracefully. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From kettenis@wins.uva.nl Fri May 5 10:17:00 2000 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Fri, 05 May 2000 10:17:00 -0000 Subject: twp bigger changes References: Message-ID: <200005051717.e45HH1h00449@delius.kettenis.local> From: Ulrich Drepper Date: 05 May 2000 01:14:32 -0700 - I've changed the internal thread descriptor of the thread library a bit. This will have no visible changes for the user. The only possible problem could be gdb if the old thread debugging mechanism is used. But since gdb now uses libthread_db this shouldn't be a problem. libthread_db is there for just these cases. GDB 5.0 will indeed use libthread_db if it is available. However, I suspect people will be somewhat dissappointed when they learn that it has some annoying limitations, like terminating the program when one of its threads terminate, and not being able to handle more than 30 thread creations. I've sent fixes for this problem to Michael Snyder, but since they're rather big, they'll probably not make the 5.0 release. Moreover, to make it work in a reliable way, I need the thread death events notifications and those don't work with the glibc 2.1.3 libthread_db. So perhaps it would be a good idea to release a glibc 2.1.4 with my libthread_db fixes. That would make it possible for the GDB folks to tell people to upgrade to 2.1.4 if they want to debug threads under Linux. The change is necessary since there are changes coming down the road which will depend on the free room at the beginning of the structure. These changes are mainly dealing with thread-local data which is handled by the compiler. We are currently defining an appropriate ABI in the IA-64 working groups and I'm making sure the same mechanisms can be used for other architectures which have a thread-local register (or a relative wasy way to get it, like the Alpha). Since it is impractical to customize the compiler to look at the end of the internal structure it is better to have a fixed offset. I don't think it would be very smart to make the compiler dependent on the internals of the threads implementation. I assume that the proposal is some abstract ABI definition like: "On the x86 %gs shall point to a thread-local data structure with the following layout: ..." But if not, I would like to express my serious concerns. Also note that, if you actually any of the segment registers to point at such a data structure, the number of entries in a LDT is limited, and that some OS'es have a per-process (i.e. per-VM space) LDT instead of a per-thread LDT. I sincerely hope that there would be a public discussion before things would be decided for existing widely deployed architectures, and that it will not happen behind closed doors as much of this IA-64 stuff seems to be done. Mark From kettenis@wins.uva.nl Fri May 5 10:25:00 2000 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Fri, 05 May 2000 10:25:00 -0000 Subject: Spin locks References: <200005042244.e44Mi9c23527@delius.kettenis.local> <200005051652.e45GqPO00433@delius.kettenis.local> Message-ID: <200005051724.e45HOw600459@delius.kettenis.local> From: Ulrich Drepper Date: 05 May 2000 09:59:49 -0700 Mark Kettenis writes: > Anyway, I've taken a look at the code in linuxthreads/spinlock.c, but > it looks to me as if your implementation is more like a fast and > simple mutex than a spin lock. In fact the only different between a > spin lock and a PTHREAD_MUTEX_FAST_NP mutex, is that you avoid the > check of the mutex type. Well, this is the only way to avoid priority inversion. If you know nothing abou the other thread contesting for the spinlock you will run into these problems. My understanding is the priority iversions must be handled gracefully. Version 3 of the Austin draft says on the page for pthread_spin_lock(): APPLICATION USAGE Applications using this function may be subject to priority inversion, as discussed in the System Interface Definitions volume of IEEE Std. 1003.1-200x, Section 3.290, Priority Inversion. So this seems to be not the case. Mark From drepper@redhat.com Fri May 5 10:41:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 May 2000 10:41:00 -0000 Subject: twp bigger changes References: <200005051717.e45HH1h00449@delius.kettenis.local> Message-ID: Mark Kettenis writes: > So perhaps it would be a good idea to release a glibc 2.1.4 with my > libthread_db fixes. That would make it possible for the GDB folks > to tell people to upgrade to 2.1.4 if they want to debug threads > under Linux. This is not motivation enough. The changes can be made available separetly. > I don't think it would be very smart to make the compiler dependent on > the internals of the threads implementation. I assume that the > proposal is some abstract ABI definition like: Whether you think it's smart or not, something like this has to be there. Not that there is only one field defined, the rest is left to the implementation. The one field at offset 0 is special and is needed in some situations and the compiler has to know about it. Just think for a second about passing a pointer to a thread-local variable to a normal function. How would you do this without this information? In short, we are not as stupid as you think we are. > Also note that, if you actually any of the segment registers to point > at such a data structure, the number of entries in a LDT is limited, > and that some OS'es have a per-process (i.e. per-VM space) LDT instead > of a per-thread LDT. Yes, and? There is always a fallback mechanism (using the POSIX thread-local data interface). We have to implement this anyway (e.g., for m68k). It will be a system specific thing which does not mean we must not take advantage of the possibilities available on some platforms. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Fri May 5 14:22:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 05 May 2000 14:22:00 -0000 Subject: ldconfig hwcap rewrite References: Message-ID: >>>>> Ulrich Drepper writes: Uli> It looks OK but there are a few problems. >> +#define HWCAP_CHECK \ >> + if (*hwcap && (cache_new->libs[middle].hwcap & *hwcap) > _dl_hwcap) \ >> + continue >> + SEARCH_CACHE (cache_new); >> } >> + else Uli> The first test certainly must be "if (hwcap", i.e., no dereferencing. Thanks, I've fixed this. Uli> Second, related to this, if you are using binary sort for the extended Uli> table, how do you make sure you see all the entries with a given name Uli> but different hwcaps? It seems you are stumbling accross one and then Uli> us the existence of the hwcap field to single step to the next entry. Uli> But what if the first entry with a matching name is not the one with Uli> the most specific hwcap? I've sorted them - but this sorting is not optimal. Uli> What I think is necessary is that either Uli> - there is exactly one of the hwcap entries actually in the table and Uli> by some the different hwcap entries can be by some other mean Uli> - add an explicit index to the first hwcap entry with the matching hwcap. Uli> The algorithm would look like this: Uli> find idx with matching file name Uli> if hwcap in entry[idx] is zero Uli> found entry idx Uli> else Uli> idx = entry[idx].first_hwcap Uli> while ((entry[idx].hwcap & _dl_hwcap) > _dl_hwcap) Uli> // Probably need to handle case here where no lib with hwcap Uli> // zero is available Uli> ++idx; Uli> found entry idx Uli> If you have already done something like this I missed it in my brief Uli> look over the code. It should be carefully documented in any case. I'll tomorrow again over the code - and either fix or document it. What's the best way to check for hwcaps? The current way which isn't either clever nor very good is to use: if ((entry[idx].hwcap & _dl_hwcap) > _dl_hwcap) for stepping over libraries and using the first one that fits. But there might be a number of libraries which fit. Is there a way to order them? Currently thw hwcaps are ordered to their numerical value. I'll also try to use HWCAP_IMPORTANT. Currently I sort two entries e1, e2 in ldconfig with: res = _dl_cache_libcmp (e2->lib, e1->lib); if (res == 0) { if (e1->flags < e2->flags) return 1; else if (e1->flags > e2->flags) return -1; else if (e2->hwcap > e1->hwcap) return 1; else if (e2->hwcap < e1->hwcap) return -1; } return res; Better seems to be (using HWCAP_IMPORTANT): res = _dl_cache_libcmp (e2->lib, e1->lib); if (res == 0) { if (e1->flags < e2->flags) return 1; else if (e1->flags > e2->flags) return -1; /* First use the important bits. */ else if ((e2->hwcap & HWCAP_IMPORTANT) > (e1->hwcap & HWCAP_IMPORTANT)) return 1; else if ((e2->hwcap & HWCAP_IMPORTANT) < (e1->hwcap & HWCAP_IMPORTANT)) return -1; else if (e2->hwcap > e1->hwcap) return 1; else if (e2->hwcap < e1->hwcap) return -1; } return res; Even better seems to be to count the number of set bits in hwcap (like it's done in sysdeps/generic/dl-sysdeps.c) - and order by this one after looking at HWCAP_IMPORTANT. This way the most specific ones are first. Should I look at hwcaps beside HWCAP_IMPORTANT at all (I do currently)? Does it make sense to handle others? I don't think and will change the functions accordingly. What do you think? I'll call it a day now and will look into these issues tomorrow again when time permits. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de From drepper@redhat.com Fri May 5 14:39:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 May 2000 14:39:00 -0000 Subject: ldconfig hwcap rewrite References: Message-ID: Andreas Jaeger writes: > What's the best way to check for hwcaps? The current way which isn't > either clever nor very good is to use: > if ((entry[idx].hwcap & _dl_hwcap) > _dl_hwcap) > for stepping over libraries and using the first one that fits. But > there might be a number of libraries which fit. Is there a way to > order them? Currently thw hwcaps are ordered to their numerical value. > I'll also try to use HWCAP_IMPORTANT. I think if you look at HWCAP_IMPORTANT and then at the numerical values, that's enough. The user has still the option to remove one of the objects. I'm still not sure whether you understood the potential I'm seeing. Look at this example: lib1 lib2 lib3 hwcap=7 lib3 hwcap=6 lib3 hwcap=4 lib3 hwcap=3 lib3 hwcap=2 You are searching for lib3 and hwcap is 7. Searching will immediately find the entry "lib3 hwcap=6" and starts searching from there. The entry with hwcap=7 is not found. There are many related problem which all involve the that you cannot be sure that an entry matching exactly the search criteria is available. I think the data structure must be something like this: [0] lib1 [0] [1] lib2 [1] [2] lib3 hwcap=7 [2] [3] lib3 hwcap=6 [2] [4] lib3 hwcap=4 [2] [5] lib3 hwcap=3 [2] [6] lib3 hwcap=2 [2] The first column is the inde of the entry in the table and does not have to be stored. The new last column specifies the first entry with the same name. Then you can simply start seaching incrementally there. Again, I'm not sure whether this is really a problem with your code. I just have seen binary search and without such helper structures it cannot be used. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Sat May 6 01:00:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Sat, 06 May 2000 01:00:00 -0000 Subject: -ffast-math and mathinlines.h References: Message-ID: >>>>> Andreas Jaeger writes: >>>>> Andreas Jaeger writes: AJ> Here's a patch for mathinline and the documentation. AJ> Jakub, could you check whether sysdeps/sparc/fpu/bits/mathinline also AJ> needs some #ifdef __FAST_MATH__ ? Andreas> The testsuite doesn't pass the math inline tests anymore with this Andreas> patch. I don't know what's going on and will check it later. I've commited this patch for now. There're more updates needed but gcc miscompiles glibc with them. I'll try to investigate and get gcc fixed before I submit the rest. An update for the manual is also coming later. Andreas 2000-05-06 Andreas Jaeger * sysdeps/i386/fpu/bits/mathinline.h: Disable some inline functions unless -ffast-math is given to gcc. ============================================================ Index: sysdeps/i386/fpu/bits/mathinline.h --- sysdeps/i386/fpu/bits/mathinline.h 2000/03/29 03:45:53 1.38 +++ sysdeps/i386/fpu/bits/mathinline.h 2000/05/06 07:41:12 @@ -604,7 +604,9 @@ #endif #ifdef __USE_ISOC99 +#ifdef __FAST_MATH__ __inline_mathop_declNP (log2, "fld1; fxch; fyl2x", "0" (__x) : "st(1)") +#endif /* __FAST_MATH__ */ __MATH_INLINE float ldexpf (float __x, int __y) @@ -618,9 +620,11 @@ __ldexp_code; } +#ifdef __FAST_MATH__ __inline_mathcodeNP3 (fma, __x, __y, __z, return (__x * __y) + __z) __inline_mathopNP (rint, "frndint") +#endif /* __FAST_MATH__ */ #define __lrint_code \ long int __lrintres; \ @@ -695,7 +699,7 @@ } /* Miscellaneous functions */ - +#ifdef __FAST_MATH__ __inline_mathcode (__coshm1, __x, \ register long double __exm1 = __expm1l (__fabsl (__x)); \ return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1) @@ -703,6 +707,7 @@ __inline_mathcode (__acosh1p, __x, \ return log1pl (__x + __sqrtl (__x) * __sqrtl (__x + 2.0))) +#endif /* __FAST_MATH__ */ #endif /* __USE_MISC */ /* Undefine some of the large macros which are not used anymore. */ -- Andreas Jaeger SuSE Labs aj@suse.de From aj@suse.de Sat May 6 06:59:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Sat, 06 May 2000 06:59:00 -0000 Subject: ldconfig hwcap rewrite References: Message-ID: >>>>> Ulrich Drepper writes: Uli> Andreas Jaeger writes: >> What's the best way to check for hwcaps? The current way which isn't >> either clever nor very good is to use: >> if ((entry[idx].hwcap & _dl_hwcap) > _dl_hwcap) >> for stepping over libraries and using the first one that fits. But >> there might be a number of libraries which fit. Is there a way to >> order them? Currently thw hwcaps are ordered to their numerical value. >> I'll also try to use HWCAP_IMPORTANT. Uli> I think if you look at HWCAP_IMPORTANT and then at the numerical Uli> values, that's enough. The user has still the option to remove one of Uli> the objects. I've had a look at the code in dl-sysdeps.c and will try to handle it in a similar way. ldconfig will only look at HWCAP_IMPORTANT and ignore all other hwcaps. Uli> I'm still not sure whether you understood the potential I'm seeing. Uli> Look at this example: Uli> lib1 Uli> lib2 Uli> lib3 hwcap=7 Uli> lib3 hwcap=6 Uli> lib3 hwcap=4 Uli> lib3 hwcap=3 Uli> lib3 hwcap=2 Uli> You are searching for lib3 and hwcap is 7. Searching will immediately Uli> find the entry "lib3 hwcap=6" and starts searching from there. The Uli> entry with hwcap=7 is not found. There are many related problem which It is found, there's this piece of code in dl-cache.c: /* There might be entries with this name before the one we \ found. So we have to find the beginning. */ \ while (middle > 0 \ /* Make sure string table indices are not bogus before \ using them. */ \ && _dl_cache_verify_ptr (cache->libs[middle - 1].key) \ /* Actually compare the entry. */ \ && (_dl_cache_libcmp (name, \ cache_data + cache->libs[middle - 1].key) \ == 0)) \ --middle; \ Therefore we should always find the first entry (this is old code, nothing I've added, I just reused it). Uli> all involve the that you cannot be sure that an entry matching exactly Uli> the search criteria is available. I think the data structure must be Uli> something like this: Uli> [0] lib1 [0] Uli> [1] lib2 [1] Uli> [2] lib3 hwcap=7 [2] Uli> [3] lib3 hwcap=6 [2] Uli> [4] lib3 hwcap=4 [2] Uli> [5] lib3 hwcap=3 [2] Uli> [6] lib3 hwcap=2 [2] Uli> The first column is the inde of the entry in the table and does not Uli> have to be stored. The new last column specifies the first entry with Uli> the same name. Then you can simply start seaching incrementally there. I could easily add this as an optimization Uli> Again, I'm not sure whether this is really a problem with your code. Uli> I just have seen binary search and without such helper structures it Uli> cannot be used. Thanks for the long explanation. Now I do know what you're after - and I'm convinced the code is fine;-). I'll document this a bit better. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de From kettenis@wins.uva.nl Sat May 6 07:07:00 2000 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Sat, 06 May 2000 07:07:00 -0000 Subject: GCC 2.8.1 Message-ID: <200005061406.e46E6xf29987@delius.kettenis.local> Just a quick note. I've switched my Linux -> Hurd cross-compiler to GCC 2.95.2. This probably means that nobody regularly build (parts of glibc) using GCC 2.8.1 anymore. I suggest we disallow GCC 2.8.1 to build glibc 2.2 as soon as someone reports a build problem that mentions GCC 2.8.1. Mark From aj@suse.de Sat May 6 09:09:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Sat, 06 May 2000 09:09:00 -0000 Subject: ldconfig hwcap rewrite References: Message-ID: >>>>> Ulrich Drepper writes: Ulrich> You are searching for lib3 and hwcap is 7. Searching will immediately Ulrich> find the entry "lib3 hwcap=6" and starts searching from there. The Ulrich> entry with hwcap=7 is not found. There are many related problem which Ulrich> all involve the that you cannot be sure that an entry matching exactly Ulrich> the search criteria is available. I think the data structure must be Ulrich> something like this: Ulrich> [0] lib1 [0] Ulrich> [1] lib2 [1] Ulrich> [2] lib3 hwcap=7 [2] Ulrich> [3] lib3 hwcap=6 [2] Ulrich> [4] lib3 hwcap=4 [2] Ulrich> [5] lib3 hwcap=3 [2] Ulrich> [6] lib3 hwcap=2 [2] Here's a new patch - I haven't added this kind of information since I do think it's not necessary (see my other email). Andreas 2000-05-06 Andreas Jaeger * sysdeps/generic/dl-cache.h (struct file_entry_new): New. (struct cache_file_new): New. (struct file_entry): New (moved from cache.c). (struct cache_file): New (moved from cache.c). * sysdeps/generic/dl-cache.c (SEARCH_CACHE): New macro, broken out from _dl_load_cache_lookup. (_dl_load_cache_lookup): Move search to SEARCH_CACHE macro, handle the different cache formats. New variable cache_new for new format. * elf/ldconfig.h: Change according to changes in cache.c and ldconfig.c; remove cache_libcmp; add opt_format. * elf/ldconfig.c: Include "dl-cache.h" and "dl-procinfo.h"; remove stuff that's defined in those headers. Add hwcap to struct lib_entry. (opt_format): New variable to select cache format. (options): Add format parameter. (is_hwcap): New function. (path_hwcap): New function. (parse_opt): Handle new format parameter. (search_dir): Handle hwcap, search also subdirectories with hwcap. * elf/cache.c (_GNU_SOURCE): Removed. Not needed anymore since ldconfig is part of glibc. Include dl-cache.h and remove stuff that's defined there. (struct cache_entry): Add new member hwcap. (print_entry): Print hwcap, cleanup a bit. (print_cache): Print new and old formats. (compare): Use _dl_cache_libcmp from dl-cache.h; handle hwcap. (save_cache): Save new and old formats. (add_to_cache): Handle hwcap. * sysdeps/generic/dl-cache.c (_dl_cache_libcmp): Moved from here... * sysdeps/generic/dl-cache.h (_dl_cache_libcmp): ...to here. * sysdeps/generic/dl-cache.c (LD_SO_CACHE): Moved from here... * sysdeps/generic/dl-cache.h (LD_SO_CACHE): ...to here. * sysdeps/generic/dl-cache.c (CACHEMAGIC): Moved from here... * sysdeps/generic/dl-cache.h (CACHEMAGIC): ...to here. ============================================================ Index: sysdeps/generic/dl-cache.h --- sysdeps/generic/dl-cache.h 1999/06/09 11:41:38 1.1 +++ sysdeps/generic/dl-cache.h 2000/05/06 15:55:47 @@ -1,5 +1,5 @@ /* Support for reading /etc/ld.so.cache files written by Linux ldconfig. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 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 @@ -21,3 +21,101 @@ #define _dl_cache_check_flags(flags) \ ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID) + + +#ifndef LD_SO_CACHE +# define LD_SO_CACHE "/etc/ld.so.cache" +#endif + +#define CACHEMAGIC "ld.so-1.7.0" + +/* libc5 and glibc 2.0/2.1 use the same format. For glibc 2.2 another + format has been added in a compatible way: + The beginning of the string table is used for the new table: + old_magic + nlibs + libs[0] + ... + libs[nlibs-1] + new magic + newnlibs + ... + newlibs[0] + ... + newlibs[newnlibs-1] + string 1 + string 2 + ... +*/ +struct file_entry +{ + int flags; /* This is 1 for an ELF library. */ + unsigned int key, value; /* String table indices. */ +}; + +struct cache_file +{ + char magic[sizeof CACHEMAGIC - 1]; + unsigned int nlibs; + struct file_entry libs[0]; +}; + +#define CACHEMAGIC_NEW "glibc-ld.so.cache" +#define CACHE_VERSION "1.0" + + +struct file_entry_new +{ + int flags; /* This is 1 for an ELF library. */ + unsigned int key, value; /* String table indices. */ + unsigned long hwcap; /* Hwcap entry. */ +}; + +struct cache_file_new +{ + char magic[sizeof CACHEMAGIC_NEW - 1]; + char version[sizeof CACHE_VERSION - 1]; + unsigned int nlibs; /* Number of entries. */ + unsigned int len_strings; /* Size of string table. */ + unsigned int unused[4]; /* Leave space for future extensions. */ + struct file_entry_new libs[0]; /* Entries describing libraries. */ + /* After this the string table of size len_strings is found. */ +}; + +static int +_dl_cache_libcmp (const char *p1, const char *p2) +{ + while (*p1 != '\0') + { + if (*p1 >= '0' && *p1 <= '9') + { + if (*p2 >= '0' && *p2 <= '9') + { + /* Must compare this numerically. */ + int val1; + int val2; + + val1 = *p1++ - '0'; + val2 = *p2++ - '0'; + while (*p1 >= '0' && *p1 <= '9') + val1 = val1 * 10 + *p1++ - '0'; + while (*p2 >= '0' && *p2 <= '9') + val2 = val2 * 10 + *p2++ - '0'; + if (val1 != val2) + return val1 - val2; + } + else + return 1; + } + else if (*p2 >= '0' && *p2 <= '9') + return -1; + else if (*p1 != *p2) + return *p1 - *p2; + else + { + ++p1; + ++p2; + } + } + return *p1 - *p2; +} ============================================================ Index: sysdeps/generic/dl-cache.c --- sysdeps/generic/dl-cache.c 2000/03/23 20:28:06 1.20 +++ sysdeps/generic/dl-cache.c 2000/05/06 15:55:47 @@ -22,31 +22,16 @@ #include #include + /* System-dependent function to read a file's whole contents in the most convenient manner available. */ extern void *_dl_sysdep_read_whole_file (const char *filename, size_t *filesize_ptr, int mmap_prot); -#ifndef LD_SO_CACHE -# define LD_SO_CACHE "/etc/ld.so.cache" -#endif - -#define CACHEMAGIC "ld.so-1.7.0" - -struct cache_file - { - char magic[sizeof CACHEMAGIC - 1]; - unsigned int nlibs; - struct - { - int flags; /* This is 1 for an ELF library. */ - unsigned int key, value; /* String table indices. */ - } libs[0]; - }; - /* This is the starting address and the size of the mmap()ed file. */ static struct cache_file *cache; +static struct cache_file_new *cache_new; static size_t cachesize; /* 1 if cache_data + PTR points into the cache. */ @@ -56,47 +41,102 @@ binaries. */ int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID; -/* Helper function which must match the one in ldconfig, so that - we rely on the same sort order. */ -static int -_dl_cache_libcmp (const char *p1, const char *p2) -{ - while (*p1 != '\0') - { - if (*p1 >= '0' && *p1 <= '9') - { - if (*p2 >= '0' && *p2 <= '9') - { - /* Must compare this numerically. */ - int val1; - int val2; - - val1 = *p1++ - '0'; - val2 = *p2++ - '0'; - while (*p1 >= '0' && *p1 <= '9') - val1 = val1 * 10 + *p1++ - '0'; - while (*p2 >= '0' && *p2 <= '9') - val2 = val2 * 10 + *p2++ - '0'; - if (val1 != val2) - return val1 - val2; - } - else - return 1; - } - else if (*p2 >= '0' && *p2 <= '9') - return -1; - else if (*p1 != *p2) - return *p1 - *p2; - else - { - ++p1; - ++p2; - } - } - return *p1 - *p2; -} +#define SEARCH_CACHE(cache) \ +/* We use binary search since the table is sorted in the cache file. \ + The first matching entry in the table is returned. \ + It is important to use the same algorithm as used while generating \ + the cache file. */ \ +do \ + { \ + left = 0; \ + right = cache->nlibs - 1; \ + middle = (left + right) / 2; \ + cmpres = 1; \ + \ + while (left <= right) \ + { \ + /* Make sure string table indices are not bogus before using \ + them. */ \ + if (! _dl_cache_verify_ptr (cache->libs[middle].key)) \ + { \ + cmpres = 1; \ + break; \ + } \ + \ + /* Actually compare the entry with the key. */ \ + cmpres = _dl_cache_libcmp (name, \ + cache_data + cache->libs[middle].key); \ + if (cmpres == 0) \ + /* Found it. */ \ + break; \ + \ + if (cmpres < 0) \ + left = middle + 1; \ + else \ + right = middle - 1; \ + \ + middle = (left + right) / 2; \ + } \ + \ + if (cmpres == 0) \ + { \ + /* LEFT now marks the last entry for which we know the name is \ + correct. */ \ + left = middle; \ + \ + /* There might be entries with this name before the one we \ + found. So we have to find the beginning. */ \ + while (middle > 0 \ + /* Make sure string table indices are not bogus before \ + using them. */ \ + && _dl_cache_verify_ptr (cache->libs[middle - 1].key) \ + /* Actually compare the entry. */ \ + && (_dl_cache_libcmp (name, \ + cache_data \ + + cache->libs[middle - 1].key) \ + == 0)) \ + --middle; \ + \ + do \ + { \ + int flags; \ + \ + /* Only perform the name test if necessary. */ \ + if (middle > left \ + /* We haven't seen this string so far. Test whether the \ + index is ok and whether the name matches. Otherwise \ + we are done. */ \ + && (! _dl_cache_verify_ptr (cache->libs[middle].key) \ + || (_dl_cache_libcmp (name, \ + cache_data \ + + cache->libs[middle].key) \ + != 0))) \ + break; \ + \ + flags = cache->libs[middle].flags; \ + if (_dl_cache_check_flags (flags) \ + && _dl_cache_verify_ptr (cache->libs[middle].value)) \ + { \ + if (best == NULL || flags == _dl_correct_cache_id) \ + { \ + HWCAP_CHECK; \ + best = cache_data + cache->libs[middle].value; \ + \ + if (flags == _dl_correct_cache_id) \ + /* We've found an exact match for the shared \ + object and no general `ELF' release. Stop \ + searching. */ \ + break; \ + } \ + } \ + } \ + while (++middle <= right); \ + } \ + } \ +while (0) + /* Look up NAME in ld.so.cache and return the file name stored there, or null if none is found. */ @@ -117,10 +157,38 @@ /* Read the contents of the file. */ void *file = _dl_sysdep_read_whole_file (LD_SO_CACHE, &cachesize, PROT_READ); + + /* We can handle three different cache file formats here: + - the old libc5/glibc2.0/2.1 format + - the old format with the new format in it + - only the new format + The following checks if the cache contains any of these formats. */ if (file && cachesize > sizeof *cache && !memcmp (file, CACHEMAGIC, sizeof CACHEMAGIC - 1)) - /* Looks ok. */ - cache = file; + { + /* Looks ok. */ + cache = file; + + /* Check for new version. */ + cache_new = (struct cache_file_new *) &cache->libs[cache->nlibs]; + if (cachesize < + (sizeof (struct cache_file) + cache->nlibs * sizeof (struct file_entry) + + sizeof (struct cache_file_new)) + || memcmp (cache_new->magic, CACHEMAGIC_NEW, + sizeof CACHEMAGIC_NEW - 1) + || memcmp (cache_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1)) + cache_new = (void *) -1; + } + else if (file && cachesize > sizeof *cache_new) + { + cache_new = (struct cache_file_new *) file; + if (memcmp (cache_new->magic, CACHEMAGIC_NEW, + sizeof CACHEMAGIC_NEW - 1) + || memcmp (cache_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1)) + cache_new = (void *) -1; + } else { if (file) @@ -139,88 +207,23 @@ best = NULL; - /* We use binary search since the table is sorted in the cache file. - It is important to use the same algorithm as used while generating - the cache file. */ - left = 0; - right = cache->nlibs - 1; - middle = (left + right) / 2; - cmpres = 1; - - while (left <= right) - { - /* Make sure string table indices are not bogus before using them. */ - if (! _dl_cache_verify_ptr (cache->libs[middle].key)) - { - cmpres = 1; - break; - } - - /* Actually compare the entry with the key. */ - cmpres = _dl_cache_libcmp (name, cache_data + cache->libs[middle].key); - if (cmpres == 0) - /* Found it. */ - break; - - if (cmpres < 0) - left = middle + 1; - else - right = middle - 1; - - middle = (left + right) / 2; - } - - if (cmpres == 0) + if (cache_new != (void *) -1) { - /* LEFT now marks the last entry for which we know the name is - correct. */ - left = middle; - - /* There might be entries with this name before the one we - found. So we have to find the beginning. */ - while (middle > 0 - /* Make sure string table indices are not bogus before - using them. */ - && _dl_cache_verify_ptr (cache->libs[middle - 1].key) - /* Actually compare the entry. */ - && (_dl_cache_libcmp (name, - cache_data + cache->libs[middle - 1].key) - == 0)) - --middle; - - do - { - int flags; - - /* Only perform the name test if necessary. */ - if (middle > left - /* We haven't seen this string so far. Test whether the - index is ok and whether the name matches. Otherwise - we are done. */ - && (! _dl_cache_verify_ptr (cache->libs[middle].key) - || (_dl_cache_libcmp (name, - cache_data + cache->libs[middle].key) - != 0))) - break; - - flags = cache->libs[middle].flags; - if (_dl_cache_check_flags (flags) - && _dl_cache_verify_ptr (cache->libs[middle].value)) - { - if (best == NULL || flags == _dl_correct_cache_id) - { - best = cache_data + cache->libs[middle].value; - - if (flags == _dl_correct_cache_id) - /* We've found an exact match for the shared - object and no general `ELF' release. Stop - searching. */ - break; - } - } - } - while (++middle <= right); + /* This file ends in static libraries where we don't have a hwcap. */ + unsigned long int *hwcap; + weak_extern (_dl_hwcap); + + hwcap = &_dl_hwcap; + +#define HWCAP_CHECK \ + if (hwcap && (cache_new->libs[middle].hwcap & *hwcap) > _dl_hwcap) \ + continue + SEARCH_CACHE (cache_new); } + else +#undef HWCAP_CHECK +#define HWCAP_CHECK do {} while (0) + SEARCH_CACHE (cache); /* Print our result if wanted. */ if (_dl_debug_libs && best != NULL) ============================================================ Index: elf/ldconfig.h --- elf/ldconfig.h 2000/04/04 05:27:55 1.2 +++ elf/ldconfig.h 2000/05/06 15:55:48 @@ -1,4 +1,4 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 1999. @@ -37,11 +37,9 @@ extern void save_cache (const char *cache_name); -extern void add_to_cache (const char *path, const char *lib, int flags); +extern void add_to_cache (const char *path, const char *lib, int flags, + unsigned long int hwcap); -extern int cache_libcmp (const char *p1, const char *p2); - - /* Declared in readlib.c. */ extern int process_file (const char *file_name, const char *lib, int *flag, char **soname, int is_link); @@ -54,6 +52,8 @@ /* Declared in ldconfig.c. */ extern int opt_verbose; +extern int opt_format; + /* Prototypes for a few program-wide used functions. */ extern void *xmalloc (size_t __n); extern void *xcalloc (size_t __n, size_t __size); @@ -61,4 +61,3 @@ extern char *xstrdup (const char *__str); #endif /* ! _LDCONFIG_H */ - ============================================================ Index: elf/ldconfig.c --- elf/ldconfig.c 1999/12/18 19:16:26 1.2 +++ elf/ldconfig.c 2000/05/06 15:55:48 @@ -1,4 +1,4 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 1999. @@ -32,10 +32,12 @@ #include #include "ldconfig.h" +#include "dl-cache.h" -#ifndef LD_SO_CACHE -# define LD_SO_CACHE "/etc/ld.so.cache" -#endif +/* We don't need this here - silence the compiler. */ +#define _dl_sysdep_message(string, args...) do {} while (0); + +#include "dl-procinfo.h" #ifndef LD_SO_CONF # define LD_SO_CONF "/etc/ld.so.conf" @@ -49,6 +51,7 @@ struct lib_entry { int flags; + unsigned long int hwcap; char *lib; char *path; }; @@ -63,7 +66,7 @@ {"libc5", FLAG_ELF_LIBC5}, {"libc6", FLAG_ELF_LIBC6}, {"glibc2", FLAG_ELF_LIBC6} -}; +}; /* List of directories to handle. */ @@ -85,6 +88,10 @@ /* Be verbose. */ int opt_verbose = 0; +/* Format to support. */ +/* 0: only libc5/glibc2; 1: both; 2: only glibc 2.2. */ +int opt_format = 1; + /* Build cache. */ static int opt_build_cache = 1; @@ -123,6 +130,7 @@ { NULL, 'f', "CONF", 0, N_("Use CONF as configuration file"), 0}, { NULL, 'n', NULL, 0, N_("Only process directories specified on the command line. Don't build cache."), 0}, { NULL, 'l', NULL, 0, N_("Manually link individual libraries."), 0}, + { "format", 'c', "FORMAT", 0, N_("Format to use: new, old or compat (default)"), 0}, { NULL, 0, NULL, 0, NULL, 0 } }; @@ -138,7 +146,53 @@ options, parse_opt, NULL, doc, NULL, NULL, NULL }; +/* Check if string corresponds to an important hardware capability. */ +static int +is_hwcap (const char *name) +{ + int hwcap_idx = _dl_string_hwcap (name); + + if (hwcap_idx != -1 && ((1 << hwcap_idx) & HWCAP_IMPORTANT)) + return 1; + return 0; +} + +/* Get hwcap encoding of path. */ +static unsigned long int +path_hwcap (const char *path) +{ + char *str = xstrdup (path); + char *ptr; + unsigned long int hwcap = 0; + unsigned long int h; + + size_t len; + + len = strlen (str); + if (str[len] == '/') + str[len] = '\0'; + + /* Search pathname from the end and check for hwcap strings. */ + for (;;) + { + ptr = strrchr (str, '/'); + + if (ptr == NULL) + break; + + h = _dl_string_hwcap (ptr+1); + + if (h == -1) + break; + hwcap += 1 << h; + /* Search the next part of the path. */ + *ptr = '\0'; + } + + free (str); + return hwcap; +} /* Handle program arguments. */ static error_t @@ -174,6 +228,14 @@ case 'X': opt_link = 0; break; + case 'c': + if (strcmp (arg, "old") == 0) + opt_format = 0; + else if (strcmp (arg, "compat") == 0) + opt_format = 1; + else if (strcmp (arg, "new") == 0) + opt_format = 2; + break; default: return ARGP_ERR_UNKNOWN; } @@ -190,7 +252,7 @@ Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "1999"); +"), "2000"); fprintf (stream, gettext ("Written by %s.\n"), "Andreas Jaeger"); } @@ -202,10 +264,10 @@ char *equal_sign; struct dir_entry *entry, *ptr, *prev; unsigned int i; - + entry = xmalloc (sizeof (struct dir_entry)); entry->next = NULL; - + /* Search for an '=' sign. */ entry->path = xstrdup (line); equal_sign = strchr (entry->path, '='); @@ -235,7 +297,7 @@ entry->path [i] = '\0'; --i; } - + ptr = dir_entries; prev = ptr; while (ptr != NULL) @@ -270,7 +332,7 @@ int do_link = 1; int do_remove = 1; /* XXX: The logics in this function should be simplified. */ - + /* Get complete path. */ snprintf (full_libname, sizeof full_libname, "%s/%s", path, libname); snprintf (full_soname, sizeof full_soname, "%s/%s", path, soname); @@ -405,7 +467,7 @@ - create symbolic links to the soname for each library This has to be done separatly for each directory. - + To keep track of which libraries to add to the cache and which links to create, we save a list of all libraries. @@ -416,7 +478,7 @@ if new library is newer, replace entry otherwise ignore this library otherwise add library to list - + For example, if the two libraries libxy.so.1.1 and libxy.so.1.2 exist and both have the same soname, e.g. libxy.so, a symbolic link is created from libxy.so.1.2 (the newer one) to libxy.so. @@ -424,7 +486,7 @@ libxy.so.1.1. */ /* Information for one library. */ -struct dlib_entry +struct dlib_entry { char *name; char *soname; @@ -446,12 +508,18 @@ int nchars; struct stat stat_buf; int is_link; - + unsigned long int hwcap = path_hwcap (entry->path); + dlibs = NULL; if (opt_verbose) - printf ("%s:\n", entry->path); - + { + if (hwcap != 0) + printf ("%s: (hwcap: 0x%lx)\n", entry->path, hwcap); + else + printf ("%s:\n", entry->path); + } + dir = opendir (entry->path); if (dir == NULL) { @@ -459,7 +527,7 @@ error (0, errno, _("Can't open directory %s"), entry->path); return; } - + while ((direntry = readdir (dir)) != NULL) { @@ -468,15 +536,17 @@ /* We only look at links and regular files. */ if (direntry->d_type != DT_UNKNOWN && direntry->d_type != DT_LNK - && direntry->d_type != DT_REG) + && direntry->d_type != DT_REG + && direntry->d_type != DT_DIR) continue; #endif /* _DIRENT_HAVE_D_TYPE */ - - /* Does this file look like a shared library? The dynamic - linker is also considered as shared library. */ - if ((strncmp (direntry->d_name, "lib", 3) != 0 - && strncmp (direntry->d_name, "ld-", 3) != 0) - || strstr (direntry->d_name, ".so") == NULL) + /* Does this file look like a shared library or is it a hwcap + subdirectory? The dynamic linker is also considered as + shared library. */ + if (((strncmp (direntry->d_name, "lib", 3) != 0 + && strncmp (direntry->d_name, "ld-", 3) != 0) + || strstr (direntry->d_name, ".so") == NULL) + && !is_hwcap (direntry->d_name)) continue; nchars = snprintf (buf, sizeof (buf), "%s/%s", entry->path, direntry->d_name); @@ -492,6 +562,16 @@ error (0, errno, _("Can't lstat %s"), buf); continue; } + else if (S_ISDIR (stat_buf.st_mode) && is_hwcap (direntry->d_name)) + { + /* Handle subdirectory also, make a recursive call. */ + struct dir_entry new_entry; + new_entry.path = buf; + new_entry.flag = entry->flag; + new_entry.next = NULL; + search_dir (&new_entry); + continue; + } else if (!S_ISREG (stat_buf.st_mode) && !S_ISLNK (stat_buf.st_mode)) continue; @@ -506,7 +586,7 @@ free (soname); soname = xstrdup (direntry->d_name); } - + if (flag == FLAG_ELF && (entry->flag == FLAG_ELF_LIBC5 || entry->flag == FLAG_ELF_LIBC6)) @@ -524,7 +604,7 @@ && entry->flag != FLAG_ANY) error (0, 0, _("libc4 library %s in wrong directory"), buf); } - + /* Add library to list. */ for (dlib_ptr = dlibs; dlib_ptr != NULL; dlib_ptr = dlib_ptr->next) { @@ -535,7 +615,7 @@ is newer. */ if ((!is_link && dlib_ptr->is_link) || (is_link == dlib_ptr->is_link - && cache_libcmp (dlib_ptr->name, direntry->d_name) < 0)) + && _dl_cache_libcmp (dlib_ptr->name, direntry->d_name) < 0)) { /* It's newer - add it. */ /* Flag should be the same - sanity check. */ @@ -586,11 +666,11 @@ if (dlib_ptr->is_link == 0) create_links (entry->path, dlib_ptr->name, dlib_ptr->soname); if (opt_build_cache) - add_to_cache (entry->path, dlib_ptr->soname, dlib_ptr->flag); + add_to_cache (entry->path, dlib_ptr->soname, dlib_ptr->flag, hwcap); } /* Free all resources. */ - while (dlibs) + while (dlibs) { dlib_ptr = dlibs; free (dlib_ptr->soname); @@ -627,7 +707,7 @@ FILE *file; char *line = NULL; size_t len = 0; - + file = fopen (filename, "r"); if (file == NULL) @@ -667,7 +747,7 @@ main (int argc, char **argv) { int remaining; - + /* Parse and process arguments. */ argp_parse (&argp, argc, argv, 0, &remaining, NULL); @@ -685,7 +765,7 @@ if (config_file == NULL) config_file = LD_SO_CONF; - + /* Chroot first. */ if (opt_chroot) { @@ -713,8 +793,8 @@ exit (0); } - - + + if (opt_build_cache) init_cache (); @@ -726,7 +806,7 @@ parse_conf (config_file); } - + search_dirs (); if (opt_build_cache) ============================================================ Index: elf/cache.c --- elf/cache.c 2000/04/10 16:22:16 1.3 +++ elf/cache.c 2000/05/06 15:55:49 @@ -17,9 +17,6 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define _GNU_SOURCE 1 - -#include #include #include #include @@ -34,32 +31,18 @@ #include #include "ldconfig.h" - -#define CACHEMAGIC "ld.so-1.7.0" +#include "dl-cache.h" struct cache_entry -{ - char *lib; - char *path; - int flags; - struct cache_entry *next; -}; - -struct file_entry -{ - int flags; /* This is 1 for an ELF library. */ - unsigned int key, value; /* String table indices. */ -}; - - -struct cache_file { - char magic[sizeof CACHEMAGIC - 1]; - unsigned int nlibs; - struct file_entry libs[0]; + char *lib; /* Library name. */ + char *path; /* Path to find library. */ + int flags; /* Flags to indicate kind of library. */ + unsigned long int hwcap; /* Important hardware capabilities. */ + int bits_hwcap; /* Number of bits set in hwcap. */ + struct cache_entry *next; /* Next entry in list. */ }; - /* List of all cache entries. */ static struct cache_entry *entries; @@ -69,7 +52,7 @@ /* Print a single entry. */ static void -print_entry (const char *lib, int flag, const char *key) +print_entry (const char *lib, int flag, unsigned long int hwcap, const char *key) { printf ("\t%s (", lib); switch (flag & FLAG_TYPE_MASK) @@ -93,14 +76,17 @@ case 0: break; default: - fprintf (stdout, ",%d", flag & FLAG_REQUIRED_MASK); + printf (",%d", flag & FLAG_REQUIRED_MASK); break; } + if (hwcap != 0) + printf (", hwcap: 0x%lx", hwcap); printf (") => %s\n", key); } -/* Print the whole cache file. */ +/* Print the whole cache file, if a file contains the new cache format + hidden in the old one, print the contents of the new format. */ void print_cache (const char *cache_name) { @@ -109,7 +95,9 @@ int fd; unsigned int i; struct cache_file *cache; + struct cache_file_new *cache_new = NULL; const char *cache_data; + int format = 0; fd = open (cache_name, O_RDONLY); if (fd < 0) @@ -128,20 +116,63 @@ error (EXIT_FAILURE, errno, _("mmap of cache file failed.\n")); cache_size = st.st_size; - if (cache_size < sizeof (struct cache_file) - || memcmp (cache->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1)) - return; - /* This is where the strings start. */ - cache_data = (const char *) &cache->libs[cache->nlibs]; - - printf (_("%d libs found in cache `%s'\n"), cache->nlibs, cache_name); - - /* Print everything. */ - for (i = 0; i < cache->nlibs; i++) - print_entry (cache_data + cache->libs[i].key, - cache->libs[i].flags, - cache_data + cache->libs[i].value); + if (cache_size < sizeof (struct cache_file)) + error (EXIT_FAILURE, 0, _("File is not a cache file.\n")); + if (memcmp (cache->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1)) + { + /* This can only be the new format without the old one. */ + cache_new = (struct cache_file_new *) cache; + + if (memcmp (cache_new->magic, CACHEMAGIC_NEW, sizeof CACHEMAGIC_NEW - 1) + || memcmp (cache_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1)) + error (EXIT_FAILURE, 0, _("File is not a cache file.\n")); + format = 1; + /* This is where the strings start. */ + cache_data = (const char *) cache; + } + else + { + /* This is where the strings start. */ + cache_data = (const char *) &cache->libs[cache->nlibs]; + + /* Check for a new cache embedded in the old format. */ + if (cache_size > + (sizeof (struct cache_file) + + cache->nlibs * sizeof (struct file_entry) + + sizeof (struct cache_file_new))) + { + cache_new = (struct cache_file_new *) cache_data; + + if (!memcmp (cache_new->magic, CACHEMAGIC_NEW, sizeof CACHEMAGIC_NEW - 1) + && !memcmp (cache_new->version, CACHE_VERSION, + sizeof CACHE_VERSION - 1)) + format = 1; + } + } + + if (format == 0) + { + printf (_("%d libs found in cache `%s'\n"), cache->nlibs, cache_name); + + /* Print everything. */ + for (i = 0; i < cache->nlibs; i++) + print_entry (cache_data + cache->libs[i].key, + cache->libs[i].flags, 0, + cache_data + cache->libs[i].value); + } + else if (format == 1) + { + printf (_("%d libs found in cache `%s'\n"), cache_new->nlibs, cache_name); + + /* Print everything. */ + for (i = 0; i < cache_new->nlibs; i++) + print_entry (cache_data + cache_new->libs[i].key, + cache_new->libs[i].flags, + cache_new->libs[i].hwcap, + cache_data + cache_new->libs[i].value); + } /* Cleanup. */ munmap (cache, cache_size); close (fd); @@ -155,45 +186,6 @@ } -/* Helper function which must match the one in the dynamic linker, so that - we rely on the same sort order. */ -int -cache_libcmp (const char *p1, const char *p2) -{ - while (*p1 != '\0') - { - if (*p1 >= '0' && *p1 <= '9') - { - if (*p2 >= '0' && *p2 <= '9') - { - /* Must compare this numerically. */ - int val1; - int val2; - - val1 = *p1++ - '0'; - val2 = *p2++ - '0'; - while (*p1 >= '0' && *p1 <= '9') - val1 = val1 * 10 + *p1++ - '0'; - while (*p2 >= '0' && *p2 <= '9') - val2 = val2 * 10 + *p2++ - '0'; - if (val1 != val2) - return val1 - val2; - } - else - return 1; - } - else if (*p2 >= '0' && *p2 <= '9') - return -1; - else if (*p1 != *p2) - return *p1 - *p2; - else - { - ++p1; - ++p2; - } - } - return *p1 - *p2; -} static int compare (const struct cache_entry *e1, const struct cache_entry *e2) @@ -201,80 +193,142 @@ int res; /* We need to swap entries here to get the correct sort order. */ - res = cache_libcmp (e2->lib, e1->lib); + res = _dl_cache_libcmp (e2->lib, e1->lib); if (res == 0) { if (e1->flags < e2->flags) return 1; else if (e1->flags > e2->flags) return -1; + /* Sort by most specific hwcap. */ + else if (e2->bits_hwcap > e1->bits_hwcap) + return 1; + else if (e2->bits_hwcap < e1->bits_hwcap) + return -1; + else if (e2->hwcap > e1->hwcap) + return 1; + else if (e2->hwcap < e1->hwcap) + return -1; } return res; } - /* Save the contents of the cache. */ void save_cache (const char *cache_name) { struct cache_entry *entry; - int i, fd; + int fd, idx_old, idx_new; size_t total_strlen, len; char *strings, *str, *temp_name; - struct cache_file *file_entries; - size_t file_entries_size; + struct cache_file *file_entries = NULL; + struct cache_file_new *file_entries_new = NULL; + size_t file_entries_size = 0; + size_t file_entries_new_size = 0; unsigned int str_offset; /* Number of cache entries. */ int cache_entry_count = 0; + /* Number of normal cache entries. */ + int cache_entry_old_count = 0; /* The cache entries are sorted already, save them in this order. */ /* Count the length of all strings. */ + /* The old format doesn't contain hwcap entries and doesn't contain + libraries in subdirectories with hwcaps entries. Count therefore + also all entries with hwcap == 0. */ total_strlen = 0; for (entry = entries; entry != NULL; entry = entry->next) { /* Account the final NULs. */ total_strlen += strlen (entry->lib) + strlen (entry->path) + 2; ++cache_entry_count; + if (entry->hwcap == 0) + ++cache_entry_old_count; } /* Create the on disk cache structure. */ /* First an array for all strings. */ - strings = (char *)xmalloc (total_strlen + 1); + strings = (char *)xmalloc (total_strlen); - /* And the list of all entries. */ - file_entries_size = sizeof (struct cache_file) - + cache_entry_count * sizeof (struct file_entry); - file_entries = (struct cache_file *) xmalloc (file_entries_size); + if (opt_format != 2) + { + /* And the list of all entries in the old format. */ + file_entries_size = sizeof (struct cache_file) + + cache_entry_old_count * sizeof (struct file_entry); + file_entries = (struct cache_file *) xmalloc (file_entries_size); + + /* Fill in the header. */ + memset (file_entries, 0, sizeof (struct cache_file)); + memcpy (file_entries->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1); - /* Fill in the header. */ - memset (file_entries, 0, sizeof (struct cache_file)); - memcpy (file_entries->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1); + file_entries->nlibs = cache_entry_old_count; + } - file_entries->nlibs = cache_entry_count; + if (opt_format != 0) + { + /* And the list of all entries in the new format. */ + file_entries_new_size = sizeof (struct cache_file_new) + + cache_entry_count * sizeof (struct file_entry_new); + file_entries_new = (struct cache_file_new *) xmalloc (file_entries_new_size); + + /* Fill in the header. */ + memset (file_entries_new, 0, sizeof (struct cache_file_new)); + memcpy (file_entries_new->magic, CACHEMAGIC_NEW, sizeof CACHEMAGIC_NEW - 1); + memcpy (file_entries_new->version, CACHE_VERSION, sizeof CACHE_VERSION - 1); - str_offset = 0; + file_entries_new->nlibs = cache_entry_count; + file_entries_new->len_strings = total_strlen; + } + + /* If we have both formats, we hide the new format in the strings + table, we have to adjust all string indices for this so that + old libc5/glibc 2 dynamic linkers just ignore them. */ + if (opt_format == 1) + str_offset = file_entries_new_size; + else + str_offset = 0; + str = strings; - for (i = 0, entry = entries; entry != NULL; entry = entry->next, ++i) + for (idx_old = 0, idx_new = 0, entry = entries; entry != NULL; + entry = entry->next, ++idx_new) { - file_entries->libs[i].flags = entry->flags; /* First the library. */ - /* XXX: Actually we can optimize here and remove duplicates. */ - file_entries->libs[i].key = str_offset; + if (opt_format != 2) + { + file_entries->libs[idx_old].flags = entry->flags; + /* XXX: Actually we can optimize here and remove duplicates. */ + file_entries->libs[idx_old].key = str_offset; + } + if (opt_format != 0) + { + /* We could subtract file_entries_new_size from str_offset - + not doing so makes the code easier, the string table + always begins at the beginning of the the new cache + struct. */ + file_entries_new->libs[idx_new].flags = entry->flags; + file_entries_new->libs[idx_new].hwcap = entry->hwcap; + file_entries_new->libs[idx_new].key = str_offset; + } len = strlen (entry->lib); str = stpcpy (str, entry->lib); /* Account the final NUL. */ ++str; str_offset += len + 1; /* Then the path. */ - file_entries->libs[i].value = str_offset; + if (opt_format != 2) + file_entries->libs[idx_old].value = str_offset; + if (opt_format != 0) + file_entries_new->libs[idx_new].value = str_offset; len = strlen (entry->path); str = stpcpy (str, entry->path); /* Account the final NUL. */ ++str; str_offset += len + 1; + /* Ignore entries with hwcap for old format. */ + if (entry->hwcap == 0) + ++idx_old; } - assert (str_offset == total_strlen); /* Write out the cache. */ @@ -293,8 +347,17 @@ temp_name); /* Write contents. */ - if (write (fd, file_entries, file_entries_size) != (ssize_t)file_entries_size) - error (EXIT_FAILURE, errno, _("Writing of cache data failed")); + if (opt_format != 2) + { + if (write (fd, file_entries, file_entries_size) != (ssize_t)file_entries_size) + error (EXIT_FAILURE, errno, _("Writing of cache data failed")); + } + if (opt_format != 0) + { + if (write (fd, file_entries_new, file_entries_new_size) + != (ssize_t)file_entries_new_size) + error (EXIT_FAILURE, errno, _("Writing of cache data failed")); + } if (write (fd, strings, total_strlen) != (ssize_t)total_strlen) error (EXIT_FAILURE, errno, _("Writing of cache data failed.")); @@ -325,13 +388,15 @@ } } + /* Add one library to the cache. */ void -add_to_cache (const char *path, const char *lib, int flags) +add_to_cache (const char *path, const char *lib, int flags, + unsigned long int hwcap) { struct cache_entry *new_entry, *ptr, *prev; char *full_path; - int len; + int len, i; new_entry = (struct cache_entry *) xmalloc (sizeof (struct cache_entry)); @@ -343,6 +408,14 @@ new_entry->lib = xstrdup (lib); new_entry->path = full_path; new_entry->flags = flags; + new_entry->hwcap = hwcap; + new_entry->bits_hwcap = 0; + + /* Count the number of bits set in the masked value. */ + for (i = 0; (~((1UL << i) - 1) & hwcap) != 0; ++i) + if ((hwcap & (1UL << i)) != 0) + ++new_entry->bits_hwcap; + /* Keep the list sorted - search for right place to insert. */ ptr = entries; -- Andreas Jaeger SuSE Labs aj@suse.de From kettenis@wins.uva.nl Sun May 7 11:27:00 2000 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Sun, 07 May 2000 11:27:00 -0000 Subject: everything is broken Message-ID: <200005071827.e47IRht00876@delius.kettenis.local> [ reviving an old thread :-) ] As I already said on libc-hacker in relation with the nss_db troubles, Ulrichs changes to run destructors in the order specified by the new ELF specs breaks calling dlclose() from within a destructor. The problem manifests itself with the nss_db module. If the nss_db module is loaded it dlopens the Berkeley DB library. Right now the nss_db module contains a destructor (nss/nss_db/db-open.c:unload_db()) that dlcloses() the DB library (apparently it does this to free the resources that otherwise might be reported by the mtrace facility). Now what happens is that if mtrace() isn't used, the load_db destructor function is run by _dl_fini(). Before running any destructors, _dl_fini() creates an array with all modules, and puts them in the right order. Now when unload_db() dlcloses the DB library, it removes the link map from the normal lists, and frees its storage. However the array used by _dl_fini() isn't changed accordingly (which admittedly would be a bit difficult). So when _dl_init() tries to run the destructors for the DB library it first uses memory that we just freed (but which is still partly intact), and then tries to call the destructor for the DB library. Since the DB library is no longer mapped into memory, this results in a bus error/segmentation fault. I'm not sure what the solution is. Perhaps one should simply not call dlclose() from a destructor? Otherwise we could add an extra reference to the modules in the array created by _dl_fini() such that any dlclose() calls in destructors won't actually close the libraries. Mark From hjl@valinux.com Sun May 7 12:13:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Sun, 07 May 2000 12:13:00 -0000 Subject: A csu/initfini.c patch for glibc 2.2. Message-ID: <20000507121310.A20989@valinux.com> Due to the circumstances under ia64, we have to use an initfini.c written by hand. This patch will support the platform dependent initfini.c. Thanks. -- H.J. Lu (hjl@gnu.org) -- 2000-05-07 H.J. Lu * csu/initfini.c: Moved to .... * sysdeps/generic/initfini.c: Here. * csu/Makefile (initfini.c): Set vpath to $(full-config-sysdirs). --- /dev/null Tue May 5 13:32:27 1998 +++ sysdeps/generic/initfini.c Thu Nov 4 08:52:51 1999 @@ -0,0 +1,136 @@ +/* Special .init and .fini section support. + Copyright (C) 1995, 1996, 1997 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 Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Library General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The Library General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + 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 Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This file is compiled into assembly code which is then munged by a sed + script into two files: crti.s and crtn.s. + + * crti.s puts a function prologue at the beginning of the + .init and .fini sections and defines global symbols for + those addresses, so they can be called as functions. + + * crtn.s puts the corresponding function epilogues + in the .init and .fini sections. */ + +/* We use embedded asm for .section unconditionally, as this makes it + easier to insert the necessary directives into crtn.S. */ +#define SECTION(x) asm (".section " x ); + +/* Embed an #include to pull in the alignment and .end directives. */ +asm ("\n#include \"defs.h\""); + +/* The initial common code ends here. */ +asm ("\n/*@HEADER_ENDS*/"); + +/* To determine whether we need .end and .align: */ +asm ("\n/*@TESTS_BEGIN*/"); +void +dummy (void (*foo) (void)) +{ + if (foo) + (*foo) (); +} +asm ("\n/*@TESTS_END*/"); + +/* The beginning of _init: */ +asm ("\n/*@_init_PROLOG_BEGINS*/"); + +SECTION (".init") +void +_init (void) +{ + /* We cannot use the normal constructor mechanism in gcrt1.o because it + appears before crtbegin.o in the link, so the header elt of .ctors + would come after the elt for __gmon_start__. One approach is for + gcrt1.o to reference a symbol which would be defined by some library + module which has a constructor; but then user code's constructors + would come first, and not be profiled. */ + extern void __gmon_start__ (void) __attribute__ ((weak)); /*weak_extern (__gmon_start__);*/ + +#ifndef WEAK_GMON_START + __gmon_start__ (); +#else + if (__gmon_start__) + __gmon_start__ (); +#endif + + asm ("ALIGN"); + asm("END_INIT"); + /* Now the epilog. */ + asm ("\n/*@_init_PROLOG_ENDS*/"); + asm ("\n/*@_init_EPILOG_BEGINS*/"); + SECTION(".init"); +} +asm ("END_INIT"); +#ifndef WEAK_GMON_START +SECTION(".text"); + +/* This version of __gmon_start__ is used if no other is found. By providing + a default function we avoid the need to test whether the pointer is NULL, + which can be painful on some machines. */ + +void __attribute__ ((weak)) +__gmon_start__ (void) +{ + /* do nothing */ +} +#endif + +/* End of the _init epilog, beginning of the _fini prolog. */ +asm ("\n/*@_init_EPILOG_ENDS*/"); +asm ("\n/*@_fini_PROLOG_BEGINS*/"); + +SECTION (".fini") +void +_fini (void) +{ + + /* End of the _fini prolog. */ + asm ("ALIGN"); + asm ("END_FINI"); + asm ("\n/*@_fini_PROLOG_ENDS*/"); + + { + /* Let GCC know that _fini is not a leaf function by having a dummy + function call here. We arrange for this call to be omitted from + either crt file. */ + extern void i_am_not_a_leaf (void); + i_am_not_a_leaf (); + } + + /* Beginning of the _fini epilog. */ + asm ("\n/*@_fini_EPILOG_BEGINS*/"); + SECTION (".fini"); +} +asm ("END_FINI"); + +/* End of the _fini epilog. Any further generated assembly (e.g. .ident) + is shared between both crt files. */ +asm ("\n/*@_fini_EPILOG_ENDS*/"); +asm ("\n/*@TRAILER_BEGINS*/"); + +/* End of file. */ --- /work/gnu/import/glibc-2.1/libc/csu/Makefile Sat Apr 10 05:43:02 1999 +++ csu/Makefile Wed Jan 12 07:54:26 2000 @@ -85,6 +85,8 @@ $(objpfx)crt%.o: $(objpfx)crt%.S $(objpf CFLAGS-initfini.s = -g0 -fPIC -fno-inline-functions +vpath initfini.c $(full-config-sysdirs) + $(objpfx)initfini.s: initfini.c $(compile.c) -S $(CFLAGS-initfini.s) -finhibit-size-directive \ $(no-exceptions) -o $@ From drepper@redhat.com Sun May 7 15:34:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 07 May 2000 15:34:00 -0000 Subject: ldconfig hwcap rewrite References: Message-ID: Andreas Jaeger writes: > Here's a new patch - I haven't added this kind of information since I > do think it's not necessary (see my other email). OK, I've applied the patch now. We'll see what happens when people start testing it. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Sun May 7 17:03:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 07 May 2000 17:03:00 -0000 Subject: A csu/initfini.c patch for glibc 2.2. References: <20000507121310.A20989@valinux.com> Message-ID: "H . J . Lu" writes: > Due to the circumstances under ia64, we have to use an initfini.c > written by hand. This patch will support the platform dependent > initfini.c. I've added the patch now. Thanks, -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@valinux.com Sun May 7 17:13:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Sun, 07 May 2000 17:13:00 -0000 Subject: A csu/initfini.c patch for glibc 2.2. References: <20000507121310.A20989@valinux.com> Message-ID: <20000507171248.A8623@valinux.com> On Sun, May 07, 2000 at 05:02:46PM -0700, Ulrich Drepper wrote: > "H . J . Lu" writes: > > > Due to the circumstances under ia64, we have to use an initfini.c > > written by hand. This patch will support the platform dependent > > initfini.c. > > I've added the patch now. Thanks, > Could you please also apply this? I am enclosing the diff between sysdeps/generic/abi-note.S and sysdeps/ia64/elf/abi-note.S here. H.J. ---- 2000-05-07 H.J. Lu * csu/abi-note.S: Moved to ... * sysdeps/generic/abi-note.S: Here. --- sysdeps/generic/abi-note.S Wed Nov 3 16:54:16 1999 +++ sysdeps/ia64/elf/abi-note.S Wed Nov 3 16:54:20 1999 @@ -60,6 +60,10 @@ offset length contents name begins with `.note' and creates a PT_NOTE program header entry pointing at it. */ + .psr abi64 + .psr lsb + .lsb + .section ".note.ABI-tag", "a" .align 4 .long 1f - 0f /* name length */ From drepper@redhat.com Sun May 7 17:38:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 07 May 2000 17:38:00 -0000 Subject: A csu/initfini.c patch for glibc 2.2. References: <20000507121310.A20989@valinux.com> <20000507171248.A8623@valinux.com> Message-ID: "H . J . Lu" writes: > Could you please also apply this? I am enclosing the diff between > sysdeps/generic/abi-note.S and sysdeps/ia64/elf/abi-note.S here. I haven't seen the IA-64 version. Why should it be necessary to have a different version? -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@valinux.com Sun May 7 17:54:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Sun, 07 May 2000 17:54:00 -0000 Subject: A csu/initfini.c patch for glibc 2.2. References: <20000507121310.A20989@valinux.com> <20000507171248.A8623@valinux.com> Message-ID: <20000507174427.A19408@valinux.com> On Sun, May 07, 2000 at 05:38:12PM -0700, Ulrich Drepper wrote: > "H . J . Lu" writes: > > > Could you please also apply this? I am enclosing the diff between > > sysdeps/generic/abi-note.S and sysdeps/ia64/elf/abi-note.S here. > > I haven't seen the IA-64 version. Why should it be necessary to have > a different version? > I am enclosing the IA-64 version here. The difference is .psr abi64 .psr lsb .lsb David may know more about it. -- H.J. Lu (hjl@gnu.org) --- /* Special .init and .fini section support. Copyright (C) 1997 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 Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. In addition to the permissions in the GNU Library General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file with other programs, and to distribute those programs without any restriction coming from the use of this file. (The Library General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into another program.) 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Define an ELF note identifying the operating-system ABI that the executable was created for. The ELF note information identifies a particular OS or coordinated development effort within which the ELF header's e_machine value plus (for dynamically linked programs) the PT_INTERP dynamic linker name and DT_NEEDED shared library names fully identify the runtime environment required by an executable. The general format of ELF notes is as follows. Offsets and lengths are bytes or (parenthetical references) to the values in other fields. offset length contents 0 4 length of name 4 4 length of data 8 4 note type 12 (0) vendor name - null-terminated ASCII string, padded to 4-byte alignment 12+(0) (4) note data, The GNU project and cooperating development efforts (including the Linux community) use note type 1 and a vendor name string of "GNU" for a note descriptor that indicates ABI requirements. The note data is four 32-bit words. The first of these is an operating system number (0=Hurd, 1=Linux, 2=Solaris, ...) and the remaining three identify the earliest release of that OS that supports this ABI. See abi-tags (top level) for details. */ #include /* OS-specific ABI tag value */ /* The linker (GNU ld 2.8 and later) recognizes an allocated section whose name begins with `.note' and creates a PT_NOTE program header entry pointing at it. */ .psr abi64 .psr lsb .lsb .section ".note.ABI-tag", "a" .align 4 .long 1f - 0f /* name length */ .long 3f - 2f /* data length */ .long 1 /* note type */ 0: .asciz "GNU" /* vendor name */ 1: .align 4 2: .long ABI_TAG /* note data: the ABI tag */ 3: .align 4 /* pad out section */ From drepper@redhat.com Sun May 7 19:23:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 07 May 2000 19:23:00 -0000 Subject: A csu/initfini.c patch for glibc 2.2. References: <20000507121310.A20989@valinux.com> <20000507171248.A8623@valinux.com> <20000507174427.A19408@valinux.com> Message-ID: "H . J . Lu" writes: > I am enclosing the IA-64 version here. The difference is > > .psr abi64 > .psr lsb > .lsb I don't know what this is. If it is necessary then this should be handled differently. Define a macro which expands to this value in a IA-64 specific header. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@valinux.com Sun May 7 19:53:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Sun, 07 May 2000 19:53:00 -0000 Subject: A csu/initfini.c patch for glibc 2.2. References: <20000507121310.A20989@valinux.com> <20000507171248.A8623@valinux.com> <20000507174427.A19408@valinux.com> Message-ID: <20000507195342.A27637@valinux.com> On Sun, May 07, 2000 at 07:22:58PM -0700, Ulrich Drepper wrote: > "H . J . Lu" writes: > > > I am enclosing the IA-64 version here. The difference is > > > > .psr abi64 > > .psr lsb > > .lsb > > I don't know what this is. If it is necessary then this should be > handled differently. Define a macro which expands to this value in a > IA-64 specific header. > That will work. Which file should the new macro go to? abi-note.S only include abi-tag.h which is a generated file. -- H.J. Lu (hjl@gnu.org) From drepper@redhat.com Sun May 7 20:46:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 07 May 2000 20:46:00 -0000 Subject: A csu/initfini.c patch for glibc 2.2. References: <20000507121310.A20989@valinux.com> <20000507171248.A8623@valinux.com> <20000507174427.A19408@valinux.com> <20000507195342.A27637@valinux.com> Message-ID: "H . J . Lu" writes: > That will work. Which file should the new macro go to? abi-note.S > only include abi-tag.h which is a generated file. We'll see. First I have to see a justification for this change. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From jakub@redhat.com Mon May 8 02:58:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 08 May 2000 02:58:00 -0000 Subject: everything is broken References: <200005071827.e47IRht00876@delius.kettenis.local> Message-ID: <20000508120032.C583@sunsite.ms.mff.cuni.cz> On Sun, May 07, 2000 at 08:27:43PM +0200, Mark Kettenis wrote: > [ reviving an old thread :-) ] > > As I already said on libc-hacker in relation with the nss_db troubles, > Ulrichs changes to run destructors in the order specified by the new > ELF specs breaks calling dlclose() from within a destructor. > > The problem manifests itself with the nss_db module. If the nss_db > module is loaded it dlopens the Berkeley DB library. Right now the > nss_db module contains a destructor (nss/nss_db/db-open.c:unload_db()) > that dlcloses() the DB library (apparently it does this to free the > resources that otherwise might be reported by the mtrace facility). > > Now what happens is that if mtrace() isn't used, the load_db > destructor function is run by _dl_fini(). Before running any > destructors, _dl_fini() creates an array with all modules, and puts > them in the right order. Now when unload_db() dlcloses the DB library, > it removes the link map from the normal lists, and frees its storage. > However the array used by _dl_fini() isn't changed accordingly (which > admittedly would be a bit difficult). So when _dl_init() tries to run > the destructors for the DB library it first uses memory that we just > freed (but which is still partly intact), and then tries to call the > destructor for the DB library. Since the DB library is no longer > mapped into memory, this results in a bus error/segmentation fault. > > I'm not sure what the solution is. Perhaps one should simply not call > dlclose() from a destructor? Otherwise we could add an extra > reference to the modules in the array created by _dl_fini() such that > any dlclose() calls in destructors won't actually close the libraries. Following patch fixes this issue for me: I'm not sure whether anything looks at l_opencount after _dl_fini is called, if yes, then we should decrease the count after we're done with it. I think dl-close might need something similar, though it could get a little bit more hairy (as unlike _dl_fini we are not closing all libraries). 2000-05-08 Jakub Jelinek * elf/dl-fini.c (_dl_fini): Bump l_opencount of all objects so that they are not dlclose'd from underneath us. --- libc/elf/dl-fini.c.jj Tue Apr 18 11:13:43 2000 +++ libc/elf/dl-fini.c Mon May 8 09:02:11 2000 @@ -58,7 +58,10 @@ _dl_fini (void) the pointers in. */ maps = (struct link_map **) alloca (nloaded * sizeof (struct link_map *)); for (l = _dl_loaded, nloaded = 0; l != NULL; l = l->l_next) - maps[nloaded++] = l; + { + maps[nloaded++] = l; + ++l->l_opencount; + } /* Now we have to do the sorting. */ for (l = _dl_loaded->l_next; l != NULL; l = l->l_next) Jakub From jakub@redhat.com Mon May 8 05:36:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 08 May 2000 05:36:00 -0000 Subject: [PATCH] dl-lookup.c fix Message-ID: <20000508143813.G583@sunsite.ms.mff.cuni.cz> Hi! We used to write in memory we did not own :(. I'll see if some other memory problems are not pending... 2000-05-08 Jakub Jelinek * elf/dl-lookup.c (add_dependency): Reallocate l_reldeps in sizeof(struct link_map *) chunks, not in bytes. --- libc/elf/dl-lookup.c.jj Mon May 8 08:22:14 2000 +++ libc/elf/dl-lookup.c Mon May 8 14:24:09 2000 @@ -137,7 +137,8 @@ add_dependency (struct link_map *undef_m undef_map->l_reldepsmax += 5; newp = realloc (undef_map->l_reldeps, - undef_map->l_reldepsmax); + undef_map->l_reldepsmax + * sizeof(struct link_map *)); if (__builtin_expect (newp != NULL, 1)) undef_map->l_reldeps = (struct link_map **) newp; Jakub From aj@suse.de Mon May 8 06:14:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 08 May 2000 06:14:00 -0000 Subject: [PATCH] dl-lookup.c fix References: <20000508143813.G583@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > We used to write in memory we did not own :(. > I'll see if some other memory problems are not pending... > 2000-05-08 Jakub Jelinek > * elf/dl-lookup.c (add_dependency): Reallocate l_reldeps in > sizeof(struct link_map *) chunks, not in bytes. Looks fine, I've applied the patch now. Thanks, Andreas -- Andreas Jaeger SuSE Labs aj@suse.de From schwab@suse.de Mon May 8 06:33:00 2000 From: schwab@suse.de (Andreas Schwab) Date: Mon, 08 May 2000 06:33:00 -0000 Subject: execle Message-ID: <200005081333.PAA30410@hawking.suse.de> This fixes a bug in execle. Andreas. 2000-05-08 Andreas Schwab * posix/execle.c: Fix size parameter of memcpy. Index: posix/execle.c =================================================================== RCS file: /cvs/glibc/libc/posix/execle.c,v retrieving revision 1.6 diff -u -a -u -r1.6 posix/execle.c --- posix/execle.c 1999/04/28 22:14:28 1.6 +++ posix/execle.c 2000/05/08 13:32:22 @@ -48,7 +48,8 @@ if ((char *) nptr + argv_max == (char *) argv) { /* Stack grows down. */ - argv = (const char **) memcpy (nptr, argv, i); + argv = (const char **) memcpy (nptr, argv, + i * sizeof (const char *)); argv_max += i; } else @@ -60,7 +61,8 @@ else #endif /* We have a hole in the stack. */ - argv = (const char **) memcpy (nptr, argv, i); + argv = (const char **) memcpy (nptr, argv, + i * sizeof (const char *)); } argv[i] = va_arg (args, const char *); -- Andreas Schwab "And now for something SuSE Labs completely different." Andreas.Schwab@suse.de SuSE GmbH, Schanz????ckerstr. 10, D-90443 N????rnberg From aj@suse.de Mon May 8 07:02:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 08 May 2000 07:02:00 -0000 Subject: lockf64 Patch Message-ID: I've just committed the appended patch to glibc 2.2 and 2.1. Andreas 2000-05-08 Andreas Jaeger * sysdeps/generic/lockf64.c (lockf64): Return -1 for overflow and set errno. ============================================================ Index: sysdeps/generic/lockf64.c --- sysdeps/generic/lockf64.c 1999/02/18 09:09:58 1.1 +++ sysdeps/generic/lockf64.c 2000/05/08 14:00:54 @@ -1,4 +1,4 @@ -/* Copyright (C) 1994, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1994,96,97,98,99,2000 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,8 +31,11 @@ off_t len = (off_t) len64; if (len64 != (off64_t) len) - /* We can't represent the length. */ - return EOVERFLOW; + { + /* We can't represent the length. */ + __set_errno (EOVERFLOW); + return -1; + } memset ((char *) &fl, '\0', sizeof (fl)); -- Andreas Jaeger SuSE Labs aj@suse.de From jakub@redhat.com Mon May 8 07:53:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 08 May 2000 07:53:00 -0000 Subject: [PATCH] dl-machine.h alpha/sparc fixes Message-ID: <20000508165447.A485@sunsite.ms.mff.cuni.cz> Hi! Callers of elf_machine_fixup_plt were not updated :(. 2000-05-08 Jakub Jelinek * sysdeps/alpha/dl-machine.h (elf_machine_rela): Fix arguments in call to elf_machine_fixup_plt. * sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela): Likewise. * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Likewise. --- libc/sysdeps/alpha/dl-machine.h.jj Mon May 8 14:30:46 2000 +++ libc/sysdeps/alpha/dl-machine.h Mon May 8 16:40:01 2000 @@ -497,7 +497,7 @@ elf_machine_rela (struct link_map *map, if (r_type == R_ALPHA_GLOB_DAT) *reloc_addr = sym_value; else if (r_type == R_ALPHA_JMP_SLOT) - elf_machine_fixup_plt (map, reloc, reloc_addr, sym_value); + elf_machine_fixup_plt (map, NULL, reloc, reloc_addr, sym_value); else if (r_type == R_ALPHA_REFQUAD) { sym_value += *reloc_addr; --- libc/sysdeps/sparc/sparc32/dl-machine.h.jj Mon May 8 14:30:55 2000 +++ libc/sysdeps/sparc/sparc32/dl-machine.h Mon May 8 16:33:26 2000 @@ -396,7 +396,7 @@ elf_machine_rela (struct link_map *map, *reloc_addr = value; break; case R_SPARC_JMP_SLOT: - elf_machine_fixup_plt(map, reloc, reloc_addr, value); + elf_machine_fixup_plt(map, NULL, reloc, reloc_addr, value); break; case R_SPARC_8: *(char *) reloc_addr = value; --- libc/sysdeps/sparc/sparc64/dl-machine.h.jj Mon May 8 14:30:55 2000 +++ libc/sysdeps/sparc/sparc64/dl-machine.h Mon May 8 16:34:07 2000 @@ -313,7 +313,7 @@ elf_machine_rela (struct link_map *map, break; case R_SPARC_JMP_SLOT: - elf_machine_fixup_plt(map, reloc, reloc_addr, value); + elf_machine_fixup_plt(map, NULL, reloc, reloc_addr, value); break; default: Jakub From drepper@redhat.com Mon May 8 08:22:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 08 May 2000 08:22:00 -0000 Subject: execle References: <200005081333.PAA30410@hawking.suse.de> Message-ID: Andreas Schwab writes: > This fixes a bug in execle. Thanks, I've checked in the patch. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Mon May 8 08:33:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 08 May 2000 08:33:00 -0000 Subject: everything is broken References: <200005071827.e47IRht00876@delius.kettenis.local> <20000508120032.C583@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > 2000-05-08 Jakub Jelinek > > * elf/dl-fini.c (_dl_fini): Bump l_opencount of all objects so that > they are not dlclose'd from underneath us. Well, this does not solve all the problems but it's better then the current situation so I checked the patch in. I'll try working on a better solution though I don't see, in the moment how this is possible. The problem I'm having is that the dependency between the object calling dlopen() and the opened object is not recorded and therefore not taken into account when computing the dependencies. But if we now sort the dlopen()ed object before the one which opened it, the dlclose call in the latter will work on a defunct descriptor. Maybe even worse now since the opencount is bumped and the descriptor seems to be intact. I'll have a few hours of flight ahead of me when I can think about this. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Mon May 8 08:42:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 08 May 2000 08:42:00 -0000 Subject: [PATCH] dl-machine.h alpha/sparc fixes References: <20000508165447.A485@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > Callers of elf_machine_fixup_plt were not updated :(. I've commited this now, Thanks, Andreas -- Andreas Jaeger SuSE Labs aj@suse.de From aj@suse.de Mon May 8 10:31:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 08 May 2000 10:31:00 -0000 Subject: struct flock with fcntl and _FILE_OFFSET_BITS=64 is broken Message-ID: struct flock is defined with different sizes if you compile with -D_FILE_OFFSET_BITS=64. The following example will break in this case since the kernel expects a struct with a different size: struct flock fl; fcntl (fd, F_GETLK, &fl); What can we do? I see two alternatives: A) Use in : #ifndef __USE_FILE_OFFSET64 #define F_GETLK 5 /* Get record locking info. */ #define F_SETLK 6 /* Set record locking info (non-blocking). */ #define F_SETLKW 7 /* Set record locking info (blocking). */ #else #define F_GETLK F_GETLK64 /* Get record locking info. */ #define F_SETLK F_SETLK64 /* Set record locking info (non-blocking). */ #define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */ #endif B) The other alternative is to add fcntl64 and handle it the usual way: # ifndef __USE_FILE_OFFSET64 extern int fcntl (... # else # ifdef __REDIRECT extern int __REDIRECT (fcntl, ..., fcntl64); # else # define fcntl fcntl64 # endif # endif What do you think? Which alternative is better - or does it work already without problems? Andreas -- Andreas Jaeger SuSE Labs aj@suse.de From jakub@redhat.com Mon May 8 12:24:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 08 May 2000 12:24:00 -0000 Subject: [PATCH] dl-deps.c fix Message-ID: <20000508212644.E485@sunsite.ms.mff.cuni.cz> Hi! L->l_initfini is sometimes created zero terminated, sometimes not. This can cause accessing l_initfini beyond the end of the allocated string (seen in _dl_fini) and things then depend on the stage of the noon and program may crash (seen as well). 2000-05-08 Jakub Jelinek * elf/dl-deps.c (_dl_map_object_deps): Zero terminate L->l_initfini always. --- libc/elf/dl-deps.c.jj Tue Apr 18 08:13:12 2000 +++ libc/elf/dl-deps.c Mon May 8 21:01:53 2000 @@ -465,7 +465,7 @@ _dl_map_object_deps (struct link_map *ma /* Store the search list we built in the object. It will be used for searches in the scope of this object. */ - map->l_searchlist.r_list = malloc ((2 * nlist + map->l_searchlist.r_list = malloc ((2 * nlist + 1 + (nlist == nduplist ? 0 : nduplist)) * sizeof (struct link_map *)); if (map->l_searchlist.r_list == NULL) @@ -549,4 +549,6 @@ _dl_map_object_deps (struct link_map *ma } } } + /* Terminate the list of dependencies */ + map->l_initfini[nlist] = NULL; } Jakub From jakub@redhat.com Tue May 9 03:23:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 09 May 2000 03:23:00 -0000 Subject: [PATCH] _dl_{,v}sym fix Message-ID: <20000509122501.B474@sunsite.ms.mff.cuni.cz> Hi! Following patch fixes the following testcase: === #include #include int main() { void *sym; void *handle = dlopen (NULL, RTLD_LAZY); if (!handle) { printf ("%s\n", dlerror()); return 1; } sym = dlsym (handle, "main"); if (!sym) { printf ("%s\n", dlerror()); return 1; } dlclose (handle); return 0; } === It matches the common usage of _dl_lookup* functions where the symbol is checked for non-zero, not the return value because it may be 0. 2000-05-09 Jakub Jelinek * elf/dl-sym.c (_dl_sym): Test ref not result for non-zero. (_dl_vsym): Likewise. Reported by Owen Taylor . --- libc/elf/dl-sym.c.jj Mon May 8 21:28:14 2000 +++ libc/elf/dl-sym.c Tue May 9 12:08:23 2000 @@ -74,7 +74,7 @@ RTLD_NEXT used in code not dynamically l } } - if (result) + if (ref) return DL_SYMBOL_ADDRESS (result, ref); return NULL; @@ -130,7 +130,7 @@ RTLD_NEXT used in code not dynamically l map->l_local_scope, &vers, 0); } - if (result) + if (ref) return DL_SYMBOL_ADDRESS (result, ref); return NULL; } Jakub From jakub@redhat.com Tue May 9 08:03:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 09 May 2000 08:03:00 -0000 Subject: [PATCH] ldconfig fix Message-ID: <20000509170458.J474@sunsite.ms.mff.cuni.cz> Hi! dl-procinfo.h expects elf.h to be included (previously it was only included in dl-sysdep.c which did that). The solution can be either to edit all relevant dl-procinfo.h headers to include , or include it in ldconfig. Without either build fails on sparc32 and sparc64. 2000-05-09 Jakub Jelinek * elf/ldconfig.c: Include elf.h. --- libc/elf/ldconfig.c.jj Mon May 8 08:22:14 2000 +++ libc/elf/ldconfig.c Tue May 9 16:52:19 2000 @@ -19,6 +19,7 @@ #include #include +#include #include #include #include Jakub From hjl@lucon.org Tue May 9 12:05:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Tue, 09 May 2000 12:05:00 -0000 Subject: Bug report: objc classes linked in wrong order References: Message-ID: <20000509120515.A18429@lucon.org> On Mon, May 08, 2000 at 05:01:06PM +0100, nicola@brainstorm.co.uk wrote: > Hi - I have a bug report. > > The problem description is as follows: > > (*) [standard behaviour] if I have two libraries implementing the same > function, say > > void hello (void); > > and I link an executable with the two libraries, the `hello` from the > first library given on the command line gets used. This happens with both > static and shared library. > > (*) if I do the same with an Objective-C class, i.e. I have two libraries > implementing the same method of the same class, what happens is: > > [standard behaviour] if I link an executable with the two libraries, the > method of the class from the first library on the command line gets used > when the two libraries are static. > > [the problem] The weird thing is when I link dynamically the two libraries > in: then - consistently - the class from the second library on the > command line gets used instead of the first as it should have. > > I was able to isolate the problem and to create a complete test showing > the problem, which I enclose in attach. > > Please notice that I am willing to actively help to fix the bug - only I > am not a linker/compiler expert, so I'm pretty stuck and don't know what > to look at. But it is quite important to me that the bug gets fixed. > > -- > > I am using binutils-2.9.1.0.23 and almost everything which comes with > RedHat 6.1. I have the bug with both the old and the latest CVS egcs > compiler. > > Thank you for any help. It is a very interesting problem. I know very little about Objective-C. >From the asm output, I have an impression that the Objective-C class implemenation is registered via the .ctors section. When you link with # cc -I./ -L/user/hjl/bugs/objc/shared/bug.report/install -o test-shared test.o -ltest1 -ltest2 -lobjc -lpthread "-ltest1 -ltest2 -lobjc -lpthread -lgcc -lc -lgcc" is passed to the linker. The dynamic linker in glibc 2.1 will process the .ctors section in the reverse order. That is 11951: calling init: /lib/libc.so.6 11951: calling init: /lib/libpthread.so.0 11951: calling init: ./install/libtest2.so.0 11951: calling init: ./install/libtest1.so.0 As the result, the implemenation in libtest2 gets register first. For the static link, libtest2.a is not even used at all. I don't know for sure what the right answer for it is. BTW, it may have an impact when libgcc.so is introduced. It will be interesting to see the order of calling init if it will make a difference. H.J. From hjl@lucon.org Tue May 9 12:07:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Tue, 09 May 2000 12:07:00 -0000 Subject: Bug report: objc classes linked in wrong order References: <20000509120515.A18429@lucon.org> Message-ID: <20000509120730.A18480@lucon.org> On Tue, May 09, 2000 at 12:05:15PM -0700, H . J . Lu wrote: > On Mon, May 08, 2000 at 05:01:06PM +0100, nicola@brainstorm.co.uk wrote: > > Hi - I have a bug report. > > > > The problem description is as follows: > > > > (*) [standard behaviour] if I have two libraries implementing the same > > function, say > > > > void hello (void); > > > > and I link an executable with the two libraries, the `hello` from the > > first library given on the command line gets used. This happens with both > > static and shared library. > > > > (*) if I do the same with an Objective-C class, i.e. I have two libraries > > implementing the same method of the same class, what happens is: > > > > [standard behaviour] if I link an executable with the two libraries, the > > method of the class from the first library on the command line gets used > > when the two libraries are static. > > > > [the problem] The weird thing is when I link dynamically the two libraries > > in: then - consistently - the class from the second library on the > > command line gets used instead of the first as it should have. > > > > I was able to isolate the problem and to create a complete test showing > > the problem, which I enclose in attach. > > > > Please notice that I am willing to actively help to fix the bug - only I > > am not a linker/compiler expert, so I'm pretty stuck and don't know what > > to look at. But it is quite important to me that the bug gets fixed. > > > > -- > > > > I am using binutils-2.9.1.0.23 and almost everything which comes with > > RedHat 6.1. I have the bug with both the old and the latest CVS egcs > > compiler. > > > > Thank you for any help. > > It is a very interesting problem. I know very little about Objective-C. > From the asm output, I have an impression that the Objective-C class > implemenation is registered via the .ctors section. When you link with > > # cc -I./ -L/user/hjl/bugs/objc/shared/bug.report/install -o test-shared test.o -ltest1 -ltest2 -lobjc -lpthread > > "-ltest1 -ltest2 -lobjc -lpthread -lgcc -lc -lgcc" is passed to the > linker. The dynamic linker in glibc 2.1 will process the .ctors section > in the reverse order. That is > > 11951: calling init: /lib/libc.so.6 > 11951: calling init: /lib/libpthread.so.0 > 11951: calling init: ./install/libtest2.so.0 > 11951: calling init: ./install/libtest1.so.0 > > As the result, the implemenation in libtest2 gets register first. For > the static link, libtest2.a is not even used at all. I don't know for > sure what the right answer for it is. > > BTW, it may have an impact when libgcc.so is introduced. It will be > interesting to see the order of calling init if it will make a > difference. > > > H.J. I forget to include the testcase. H.J. From drepper@redhat.com Tue May 9 19:22:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 09 May 2000 19:22:00 -0000 Subject: struct flock with fcntl and _FILE_OFFSET_BITS=64 is broken References: Message-ID: Andreas Jaeger writes: > B) The other alternative is to add fcntl64 and handle it the usual > way: This one. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Tue May 9 23:39:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 09 May 2000 23:39:00 -0000 Subject: [PATCH] dl-deps.c fix References: <20000508212644.E485@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > L->l_initfini is sometimes created zero terminated, sometimes not. > This can cause accessing l_initfini beyond the end of the allocated string > (seen in _dl_fini) and things then depend on the stage of the noon and > program may crash (seen as well). This patch is OK. Somebody please check this in. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Tue May 9 23:41:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 09 May 2000 23:41:00 -0000 Subject: [PATCH] _dl_{,v}sym fix References: <20000509122501.B474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > * elf/dl-sym.c (_dl_sym): Test ref not result for non-zero. > (_dl_vsym): Likewise. This is OK as well. Somebody please check this in. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Wed May 10 01:09:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 10 May 2000 01:09:00 -0000 Subject: struct flock with fcntl and _FILE_OFFSET_BITS=64 is broken References: Message-ID: >>>>> Ulrich Drepper writes: > Andreas Jaeger writes: >> B) The other alternative is to add fcntl64 and handle it the usual >> way: > This one. I don't like this solution anymore. It would mean we would have a fcntl64 call which does basically: int fcntl64 (int fd, int cmd, ...) { .... switch (cmd) { case F_SETLK: cmd = F_SETLK64; break; case F_SETLKW: cmd = F_SETLKW64; break; case F_GETLK: cmd = F_GETLK; break; default: break; } return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg); } Solution a) would involve fcntl64 just as a normal syscall - without any conversion we need to do. Another problem is that we need to convert betweeen struct flock64 and struct flock if fcntl64 is not available. Solution b) would mean we have to do this in fcntl *and* fcntl64. With solution a) there's only a possible conversion in fcntl. Have a look at the appended patch which implements solution a) and requires Andrea's LFS locking patch for Linux 2.3.99. Could you please consider this again? Thanks, Andreas ============================================================ Index: sysdeps/unix/sysv/linux/i386/bits/fcntl.h --- sysdeps/unix/sysv/linux/i386/bits/fcntl.h 1998/10/25 09:09:23 1.3 +++ sysdeps/unix/sysv/linux/i386/bits/fcntl.h 2000/05/09 15:02:02 @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 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 @@ -69,10 +69,15 @@ #define F_SETLK 6 /* Set record locking info (non-blocking). */ #define F_SETLKW 7 /* Set record locking info (blocking). */ -/* XXX missing */ -#define F_GETLK64 5 /* Get record locking info. */ -#define F_SETLK64 6 /* Set record locking info (non-blocking). */ -#define F_SETLKW64 7 /* Set record locking info (blocking). */ +#ifndef __USE_FILE_OFFSET64 +# define F_GETLK64 12 /* Get record locking info. */ +# define F_SETLK64 13 /* Set record locking info (non-blocking). */ +# define F_SETLKW64 14 /* Set record locking info (blocking). */ +#else +# define F_GETLK64 F_GETLK /* Get record locking info. */ +# define F_SETLK64 F_SETLK /* Set record locking info (non-blocking). */ +# define F_SETLKW64 F_SETLKW /* Set record locking info (blocking). */ +#endif #ifdef __USE_BSD # define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */ ============================================================ Index: sysdeps/unix/sysv/linux/sparc/bits/fcntl.h --- sysdeps/unix/sysv/linux/sparc/bits/fcntl.h 2000/01/04 19:55:10 1.6.2.2 +++ sysdeps/unix/sysv/linux/sparc/bits/fcntl.h 2000/05/09 15:02:02 @@ -79,10 +79,15 @@ # define F_GETSIG 11 /* Get number of signal to be sent. */ #endif -/* XXX missing */ -#define F_GETLK64 7 /* Get record locking info. */ -#define F_SETLK64 8 /* Set record locking info (non-blocking). */ -#define F_SETLKW64 9 /* Set record locking info (blocking). */ +#ifndef __USE_FILE_OFFSET64 +# define F_GETLK64 12 /* Get record locking info. */ +# define F_SETLK64 13 /* Set record locking info (non-blocking). */ +# define F_SETLKW64 14 /* Set record locking info (blocking). */ +#else +# define F_GETLK64 F_GETLK /* Get record locking info. */ +# define F_SETLK64 F_SETLK /* Set record locking info (non-blocking). */ +# define F_SETLKW64 F_SETLKW /* Set record locking info (blocking). */ +#endif /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ ============================================================ Index: sysdeps/unix/sysv/linux/alpha/bits/fcntl.h --- sysdeps/unix/sysv/linux/alpha/bits/fcntl.h 1999/08/05 17:40:36 1.7.2.1 +++ sysdeps/unix/sysv/linux/alpha/bits/fcntl.h 2000/05/09 15:02:02 @@ -72,10 +72,9 @@ #define F_SETLK 8 /* Set record locking info (non-blocking). */ #define F_SETLKW 9 /* Set record locking info (blocking). */ -/* XXX missing */ -#define F_GETLK64 7 /* Get record locking info. */ -#define F_SETLK64 8 /* Set record locking info (non-blocking). */ -#define F_SETLKW64 9 /* Set record locking info (blocking). */ +#define F_GETLK64 F_GETLK /* Get record locking info. */ +#define F_SETLK64 F_SETLK /* Set record locking info (non-blocking). */ +#define F_SETLKW64 F_SETLKW /* Set record locking info (blocking). */ #ifdef __USE_BSD # define F_SETOWN 5 /* Get owner of socket (receiver of SIGIO). */ ============================================================ Index: sysdeps/unix/sysv/linux/i386/lockf64.c --- sysdeps/unix/sysv/linux/i386/lockf64.c created +++ sysdeps/unix/sysv/linux/i386/lockf64.c Tue May 9 11:06:57 2000 1.1 @@ -0,0 +1,157 @@ +/* Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. 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 + +/* lockf is a simplified interface to fcntl's locking facilities. */ + +#ifdef __NR_fcntl64 +extern int __syscall_fcntl64 (int __fd, int __cmd, ...); + +/* This is declared in fcntl.c. */ +extern int __have_no_fcntl64; +#endif + +int +lockf64 (int fd, int cmd, off64_t len64) +{ + struct flock fl; +#ifdef __NR_fcntl64 + struct flock64 fl64; + int cmd64; +#endif + off_t len = (off_t) len64; + + memset ((char *) &fl, '\0', sizeof (fl)); + + /* lockf is always relative to the current file position. */ + fl.l_whence = SEEK_CUR; + fl.l_start = 0; + fl.l_len = len; + +#ifdef __NR_fcntl64 + if (!__have_no_fcntl64) + { + memset ((char *) &fl64, '\0', sizeof (fl64)); + fl64.l_whence = SEEK_CUR; + fl64.l_start = 0; + fl64.l_len = len64; + } +#endif + +#ifndef __NR_fcntl64 + if (len64 != (off64_t) len) + { + /* We can't represent the length. */ + __set_errno (EOVERFLOW); + return -1; + } +#endif + + switch (cmd) + { + case F_TEST: + /* Test the lock: return 0 if FD is unlocked or locked by this process; + return -1, set errno to EACCES, if another process holds the lock. */ +#ifdef __NR_fcntl64 + if (!__have_no_fcntl64) + { + int res = INLINE_SYSCALL (fcntl64, 3, fd, F_GETLK64, &fl64); + + /* If errno == ENOSYS try the 32bit interface if len64 can + be represented with 32 bits. */ + + if (res == 0) + { + if (fl64.l_type == F_UNLCK || fl64.l_pid == __getpid ()) + return 0; + __set_errno (EACCES); + return -1; + } + else if (errno == ENOSYS) + __have_no_fcntl64 = 1; + else + /* res < 0 && errno != ENOSYS. */ + return -1; + if (len64 != (off64_t) len) + { + /* We can't represent the length. */ + __set_errno (EOVERFLOW); + return -1; + } + } +#endif + if (__fcntl (fd, F_GETLK, &fl) < 0) + return -1; + if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ()) + return 0; + __set_errno (EACCES); + return -1; + case F_ULOCK: + fl.l_type = F_UNLCK; + cmd = F_SETLK; +#ifdef __NR_fcntl64 + cmd64 = F_SETLK64; +#endif + break; + case F_LOCK: + fl.l_type = F_WRLCK; + cmd = F_SETLKW; +#ifdef __NR_fcntl64 + cmd64 = F_SETLKW64; +#endif + break; + case F_TLOCK: + fl.l_type = F_WRLCK; + cmd = F_SETLK; +#ifdef __NR_fcntl64 + cmd64 = F_SETLK64; +#endif + break; + + default: + __set_errno (EINVAL); + return -1; + } +#ifdef __NR_fcntl64 + if (!__have_no_fcntl64) + { + int res = INLINE_SYSCALL (fcntl64, 3, fd, cmd64, &fl64); + + /* If errno == ENOSYS try the 32bit interface if len64 can + be represented with 32 bits. */ + if (res == 0 || errno != ENOSYS) + return res; + + __have_no_fcntl64 = 1; + + if (len64 != (off64_t) len) + { + /* We can't represent the length. */ + __set_errno (EOVERFLOW); + return -1; + } + } +#endif + return __fcntl (fd, cmd, &fl); +} ============================================================ Index: sysdeps/unix/sysv/linux/i386/fcntl.c --- sysdeps/unix/sysv/linux/i386/fcntl.c created +++ sysdeps/unix/sysv/linux/i386/fcntl.c Tue May 9 11:47:12 2000 1.1 @@ -0,0 +1,124 @@ +/* Copyright (C) 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + +#include + +/* lockf is a simplified interface to fcntl's locking facilities. */ + +#ifdef __NR_fcntl64 +extern int __syscall_fcntl64 (int __fd, int __cmd, ...); + +int __have_no_fcntl64; +#endif + +int +__libc_fcntl (int fd, int cmd, ...) +{ + void *arg; + va_list ap; + + /* XXX: Shall we do this only for F_GETLK, F_SETLK, F_SETLK64? */ + va_start (ap, cmd); + arg = va_arg (ap, void *); + +#ifdef __NR_fcntl64 + if (! __have_no_fcntl64) + { + int result = INLINE_SYSCALL (fcntl64, fd, cmd, arg); + if (result >= 0 || errno != ENOSYS) + return result; + + __have_no_fcntl64 = 1; + } +#endif + switch (cmd) + { + case F_GETLK64: + /* Convert arg from flock64 to flock and back. */ + { + struct flock fl; + struct flock64 *fl64 = arg; + int res; + + fl.l_start = (off_t)fl64->l_start; + /* Check if we can represent the values with the smaller type. */ + if ((off64_t)fl.l_start != fl64->l_start) + { + __set_errno (EOVERFLOW); + return -1; + } + fl.l_len = (off_t)fl64->l_len; + /* Check if we can represent the values with the smaller type. */ + if ((off64_t)fl.l_len != fl64->l_len) + { + __set_errno (EOVERFLOW); + return -1; + } + fl.l_type = fl64->l_type; + fl.l_whence = fl64->l_whence; + fl.l_pid = fl64->l_pid; + + res = INLINE_SYSCALL (fcntl, 3, fd, cmd, &fl); + if (res != 0) + return res; + /* Everything ok, convert back. */ + fl64->l_type = fl.l_type; + fl64->l_whence = fl.l_whence; + fl64->l_start = fl.l_start; + fl64->l_len = fl.l_len; + fl64->l_pid = fl.l_pid; + + return 0; + } + case F_SETLK64: + case F_SETLKW64: + /* Try to convert arg from flock64 to flock. */ + { + struct flock fl; + struct flock64 *fl64 = arg; + fl.l_start = (off_t)fl64->l_start; + /* Check if we can represent the values with the smaller type. */ + if ((off64_t)fl.l_start != fl64->l_start) + { + __set_errno (EOVERFLOW); + return -1; + } + fl.l_len = (off_t)fl64->l_len; + /* Check if we can represent the values with the smaller type. */ + if ((off64_t)fl.l_len != fl64->l_len) + { + __set_errno (EOVERFLOW); + return -1; + } + fl.l_type = fl64->l_type; + fl.l_whence = fl64->l_whence; + fl.l_pid = fl64->l_pid; + return INLINE_SYSCALL (fcntl, 3, fd, cmd, &fl); + } + default: + return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg); + } + return -1; +} +strong_alias (__libc_fcntl, __fcntl) +weak_alias (__libc_fcntl, fcntl) ============================================================ Index: sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c --- sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c created +++ sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c Tue May 9 16:50:51 2000 1.1 @@ -0,0 +1 @@ +#include ============================================================ Index: sysdeps/unix/sysv/linux/sparc/sparc32/lockf64.c --- sysdeps/unix/sysv/linux/sparc/sparc32/lockf64.c created +++ sysdeps/unix/sysv/linux/sparc/sparc32/lockf64.c Tue May 9 16:51:16 2000 1.1 @@ -0,0 +1 @@ +#include -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From aj@suse.de Wed May 10 02:07:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 10 May 2000 02:07:00 -0000 Subject: [PATCH] _dl_{,v}sym fix References: <20000509122501.B474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Ulrich Drepper writes: Ulrich> Jakub Jelinek writes: >> * elf/dl-sym.c (_dl_sym): Test ref not result for non-zero. >> (_dl_vsym): Likewise. Ulrich> This is OK as well. Somebody please check this in. I've checked both patches in. Jakub, can you make a test case from your example? Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From aj@suse.de Wed May 10 02:14:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 10 May 2000 02:14:00 -0000 Subject: [PATCH] ldconfig fix References: <20000509170458.J474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > dl-procinfo.h expects elf.h to be included (previously it was only included > in dl-sysdep.c which did that). > The solution can be either to edit all relevant dl-procinfo.h headers to > include , or include it in ldconfig. > Without either build fails on sparc32 and sparc64. Thanks, I'm adding this patch now to CVS. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From jakub@redhat.com Wed May 10 03:01:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 10 May 2000 03:01:00 -0000 Subject: [PATCH] Fix _dl_reloc_bad_type Message-ID: <20000510120345.O474@sunsite.ms.mff.cuni.cz> Hi! sizeof msg is including the terminating '\0', so we used to put the digits at a wrong place. Now have to find out what reloc ld.so is not happy about in libstdc++... 2000-05-10 Jakub Jelinek * elf/dl-reloc.c (_dl_reloc_bad_type): Write type into the message at proper place. --- libc/elf/dl-reloc.c.jj Mon May 8 08:22:14 2000 +++ libc/elf/dl-reloc.c Wed May 10 11:50:58 2000 @@ -158,15 +158,15 @@ _dl_reloc_bad_type (struct link_map *map if (plt) { char msg[] = "unexpected reloc type 0x??"; - msg[sizeof msg - 2] = DIGIT(type >> 8); - msg[sizeof msg - 1] = DIGIT(type); + msg[sizeof msg - 3] = DIGIT(type >> 8); + msg[sizeof msg - 2] = DIGIT(type); _dl_signal_error (0, map->l_name, msg); } else { char msg[] = "unexpected PLT reloc type 0x??"; - msg[sizeof msg - 2] = DIGIT(type >> 8); - msg[sizeof msg - 1] = DIGIT(type); + msg[sizeof msg - 3] = DIGIT(type >> 8); + msg[sizeof msg - 2] = DIGIT(type); _dl_signal_error (0, map->l_name, msg); } } Jakub From jakub@redhat.com Wed May 10 03:15:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 10 May 2000 03:15:00 -0000 Subject: [PATCH] Fix _dl_reloc_bad_type, take 2 Message-ID: <20000510121711.P474@sunsite.ms.mff.cuni.cz> Hi! Forget the last patch and take this one instead. There was one more bug. 2000-05-10 Jakub Jelinek * elf/dl-reloc.c (_dl_reloc_bad_type): Write type into the message at proper place. Compute the high nibble correctly. --- libc/elf/dl-reloc.c.jj Mon May 8 08:22:14 2000 +++ libc/elf/dl-reloc.c Wed May 10 11:50:58 2000 @@ -158,15 +158,15 @@ _dl_reloc_bad_type (struct link_map *map if (plt) { char msg[] = "unexpected reloc type 0x??"; - msg[sizeof msg - 2] = DIGIT(type >> 8); - msg[sizeof msg - 1] = DIGIT(type); + msg[sizeof msg - 3] = DIGIT(type >> 4); + msg[sizeof msg - 2] = DIGIT(type); _dl_signal_error (0, map->l_name, msg); } else { char msg[] = "unexpected PLT reloc type 0x??"; - msg[sizeof msg - 2] = DIGIT(type >> 8); - msg[sizeof msg - 1] = DIGIT(type); + msg[sizeof msg - 3] = DIGIT(type >> 4); + msg[sizeof msg - 2] = DIGIT(type); _dl_signal_error (0, map->l_name, msg); } } Jakub From aj@suse.de Wed May 10 03:16:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 10 May 2000 03:16:00 -0000 Subject: [PATCH] Fix _dl_reloc_bad_type References: <20000510120345.O474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > sizeof msg is including the terminating '\0', so we used to put the digits > at a wrong place. > Now have to find out what reloc ld.so is not happy about in libstdc++... Good bughunting! > 2000-05-10 Jakub Jelinek > * elf/dl-reloc.c (_dl_reloc_bad_type): Write type into the message > at proper place. I've commited this, Thanks, Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From aj@suse.de Wed May 10 03:19:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 10 May 2000 03:19:00 -0000 Subject: [PATCH] Fix _dl_reloc_bad_type, take 2 References: <20000510121711.P474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > Forget the last patch and take this one instead. There was one more bug. I've been too fast. ;-) Ok, I've added this one now. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From jakub@redhat.com Wed May 10 07:14:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 10 May 2000 07:14:00 -0000 Subject: [PATCH] sparc64 fixes Message-ID: <20000510161656.R474@sunsite.ms.mff.cuni.cz> Hi! Below is an implementation of R_SPARC_UA64 reloc in sparc64 ld.so (it is present in .eh_frame because it aligns to 4 only), added sparc64-linux time.c (it is defined in unistd.h due to sparc32 but the kernel implementation is not 64bit clean) and, shame on me for not finding all at once, I found one more bug in _dl_reloc_bad_type. 2000-05-10 Jakub Jelinek * elf/dl-reloc.c (_dl_reloc_bad_type): Sync messages with plt argument. * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Handle R_SPARC_UA64. * sysdeps/unix/sysv/linux/sparc/sparc64/time.c: New file. --- libc/elf/dl-reloc.c.jj Wed May 10 12:04:54 2000 +++ libc/elf/dl-reloc.c Wed May 10 13:36:41 2000 @@ -157,14 +157,14 @@ _dl_reloc_bad_type (struct link_map *map extern const char _itoa_lower_digits[]; if (plt) { - char msg[] = "unexpected reloc type 0x??"; + char msg[] = "unexpected PLT reloc type 0x??"; msg[sizeof msg - 3] = DIGIT(type >> 4); msg[sizeof msg - 2] = DIGIT(type); _dl_signal_error (0, map->l_name, msg); } else { - char msg[] = "unexpected PLT reloc type 0x??"; + char msg[] = "unexpected reloc type 0x??"; msg[sizeof msg - 3] = DIGIT(type >> 4); msg[sizeof msg - 2] = DIGIT(type); _dl_signal_error (0, map->l_name, msg); --- libc/sysdeps/sparc/sparc64/dl-machine.h.jj Mon May 8 14:30:55 2000 +++ libc/sysdeps/sparc/sparc64/dl-machine.h Wed May 10 13:34:53 2000 @@ -316,6 +316,24 @@ elf_machine_rela (struct link_map *map, elf_machine_fixup_plt(map, reloc, reloc_addr, value); break; + case R_SPARC_UA64: + if (! ((long) reloc_addr & 3)) + { + /* Common in .eh_frame */ + ((unsigned int *) reloc_addr) [0] = value >> 32; + ((unsigned int *) reloc_addr) [1] = value; + break; + } + ((unsigned char *) reloc_addr) [0] = value >> 56; + ((unsigned char *) reloc_addr) [1] = value >> 48; + ((unsigned char *) reloc_addr) [2] = value >> 40; + ((unsigned char *) reloc_addr) [3] = value >> 32; + ((unsigned char *) reloc_addr) [4] = value >> 24; + ((unsigned char *) reloc_addr) [5] = value >> 16; + ((unsigned char *) reloc_addr) [6] = value >> 8; + ((unsigned char *) reloc_addr) [7] = value; + break; + default: _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 0); break; --- libc/sysdeps/unix/sysv/linux/sparc/sparc64/time.c.jj Wed May 10 15:56:28 2000 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/time.c Wed May 10 15:56:35 2000 @@ -0,0 +1 @@ +#include Jakub From aj@suse.de Wed May 10 08:57:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 10 May 2000 08:57:00 -0000 Subject: [PATCH] sparc64 fixes References: <20000510161656.R474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > Below is an implementation of R_SPARC_UA64 reloc in sparc64 ld.so (it is > present in .eh_frame because it aligns to 4 only), added sparc64-linux > time.c (it is defined in unistd.h due to sparc32 but the kernel > implementation is not 64bit clean) and, shame on me for not finding all at > once, I found one more bug in _dl_reloc_bad_type. > 2000-05-10 Jakub Jelinek > * elf/dl-reloc.c (_dl_reloc_bad_type): Sync messages with plt > argument. > * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Handle > R_SPARC_UA64. > * sysdeps/unix/sysv/linux/sparc/sparc64/time.c: New file. Added. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From gkm@eng.ascend.com Wed May 10 09:31:00 2000 From: gkm@eng.ascend.com (Greg McGary) Date: Wed, 10 May 2000 09:31:00 -0000 Subject: sysdeps/powerpc/*.S, BPs and registers Message-ID: <200005101631.JAA12000@gkm-dsl-194.ascend.com> The way gcc passes structs by value for PPC (and presumably any RISC) is hardly optimal. Since BPs don't exactly fit a machine mode, they aren't passed in registers. Rather, the address of an in-memory copy is passed. When everything is basically working on PPC & MIPS, I will work on making gcc pass BPs in registers. There are implications for the assembler stuff I wish to discuss now. The current pass-by-value convention for BPs allows low-impact changes to the assembler code since BPs don't alter the register assignments for arguments (a bounded pointer arg still occupies a single register). However, when things change so that BPs occupy three registers, register assignments for later args will be bumped. IMO, a good way to handle this is to move from numeric to symbolic register names. E.g., instead of writing strcmp in terms of r3 and r4, do this: #define rSTR1 r3 #define rSTR2 r4 ... and write the body in terms of rSTR1 & rSTR2. When BPs are passed in registers, it will need to change the definitions like so: #if __BOUNDED_POINTERS__ # define rSTR1 r3 # define rSTR1_b r4 # define rSTR1_e r5 # define rSTR2 r6 # define rSTR2_b r7 # define rSTR2_e r8 #else # define rSTR1 r3 # define rSTR2 r4 #endif All temporary register variables will also need symbolic names. There should be relatively little register pressure with BPs since at least the base check will occur in the prologue so the base register can be immediately recycled as a temp variable. Only when the extent check happens in the epilogue will we need to preserve the r*_e registers and there are most often only one or two of these. I'd like to handle this in three phases: 1) rename numeric registers as symbolic 2) add BP checks for current in-memory pass-by-value 3) revise BP checks for register pass-by-value Even though BP checks can be added with relatively low impact, they would still benefit from symbolic register naming. Therefore, I'd like to do the register renaming first. Correctness for the register renaming pass should be easy to verify, since there should be no object-code changes. Even the pre-processed assembler should remain unchanged modulo some whitespace differences. What do you think? May I proceed with renaming registers? Greg From aj@suse.de Fri May 12 06:39:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 12 May 2000 06:39:00 -0000 Subject: [tmoestl@gmx.net] libc/1732: Using IN6_ARE_ADDR_EQUAL as defined in netinet/in.h Message-ID: FYI, I'm committing the appended patch for both branches. Andreas 2000-05-12 Andreas Jaeger * inet/netinet/in.h (IN6_ARE_ADDR_EQUAL): Correct indices. Reported by tmoestl@gmx.net, closes PR libc/1732. From hjl@lucon.org Fri May 12 14:48:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Fri, 12 May 2000 14:48:00 -0000 Subject: [hjl@lucon.org: binutils 2.9.5.0.42 is released.] Message-ID: <20000512144825.A31250@lucon.org> This is the beta release of binutils 2.9.5.0.42 for Linux, which is based on binutils 2000 0512 plus various changes. It is purely for Linux, although it has been tested on Solaris/Sparc and Solaris/x86 from time to time. I am planning to make the public release soon. Please test it as much as you can. Please report any bugs related to binutils 2.9.5.0.42 to hjl@lucon.org. For arm-linux targets, there are some important differences in behaviour between these tools and binutils 2.9.1.0.x. The linker emulation name has changed from elf32arm{26} to armelf_linux{26}. Also, the "-p" flag must be passed with the linker when working with object files (or static libraries) created using older versions of the assembler. If this flag is omitted the linker will silently generate bad output when given old input files. To get the correct behaviour from gcc, amend the *link section of your specs file as follows: *link: %{h*} %{version:-v} %{b} %{Wl,*:%*} %{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} %{rdynamic:-export-dynamic} %{!dynamic-linker: -dynamic-linker /lib/ld-linux.so.2} -X %{mbig-endian:-EB} %{mapcs-26:-m armelf_linux26} %{!mapcs-26:-m armelf_linux} -p Changes from binutils 2.9.5.0.41: 1. Update from binutils 2000 0512. 2. Add testsuite for ELF visibility. Changes from binutils 2.9.5.0.37: 1. Update from binutils 2000 0502. 2. Support STV_HIDDEN and STV_INTERNAL. Changes from binutils 2.9.5.0.35: 1. Update from binutils 2000 0418. 2. Fix an ld demangle style option bug. Changes from binutils 2.9.5.0.34: 1. Update from binutils 2000 0412. Fix a relocation bug which affects the Linux kernel compilation. 2. An ELF/PPC linker script update. Changes from binutils 2.9.5.0.33: 1. Update from binutils 2000 0404. Fix the bug report bug. Changes from binutils 2.9.5.0.32: 1. Update from binutils 2000 0403. Fix the 16bit ia32 assembler bug. Changes from binutils 2.9.5.0.31: 1. Update from binutils 2000 0331. Fix the Linux/ARM assembler bug. 2. Fix a Debian assembler security bug. Changes from binutils 2.9.5.0.29: 1. Update from binutils 2000 0319. 2. An ELF/alpha bug is fixed. Changes from binutils 2.9.5.0.27: 1. Update from binutils 2000 0301. 2. A demangler bug is fixed. 3. A better fix for undefined symbols with -Bsymbolic when building shared library. Changes from binutils 2.9.5.0.24: 1. Update from binutils 2000 0204. 2. Added -taso to linker on alpha. 3. Fixed a -shared -Bsymbolic bug when PIC is not used. Changes from binutils 2.9.5.0.22: 1. Update from binutils 2000 0113. 2. A symbol version bug is fixed. 3. A -Bsymbolic bug is fixed. Changes from binutils 2.9.5.0.21: 1. Update from binutils 1999 1202. 2. Remove a MIPS/ELF change. 3. Enable SOM for HPPA. Changes from binutils 2.9.5.0.19: 1. Update from binutils 1999 1122. An ia32 gas bug is fixed. Changes from binutils 2.9.5.0.16: 1. Update from binutils 1999 1104. 2. i370 is changed to use EM_S370 and ELFOSABI_LINUX. Update readelf. 3. Fix Compaq's demangler support. Changes from binutils 2.9.5.0.14: 1. Update from binutils 1999 1012. A gas bug which affects Linux 2.3.21 is fixed. 2. i370 update. 3. The new demangler code. You should use "--style=xxx" to select the demnangle style instead of "--lang=xxx". Changes from binutils 2.9.5.0.13: 1. Update from binutils 1999 0925. 2. Fix a -s and linker script bug. Changes from binutils 2.9.5.0.12: 1. Update from binutils 1999 0922. 2. i370 update. Changes from binutils 2.9.5.0.11: 1. Update from binutils 1999 0910. It fixed a PIC linker bug on ix86 and sparc introduced in the last release. 2. i370 update. Changes from binutils 2.9.5.0.10: 1. Update from binutils 1999 0906. It fixed a PIC linker bug on ix86 and sparc. 2. Remove elf/hppa since it is WIP. Changes from binutils 2.9.5.0.8: 1. Update from binutils 1999 0831. It allows spaces around '(' and ')' in x86 FP register names. Changes from binutils 2.9.5.0.7: 1. Update from binutils 1999 0821. 2. Some MIPS changes. Changes from binutils 2.9.5.0.6: 1. Update from binutils 1999 0813. 2. i370 update. Changes from binutils 2.9.5.0.5: 1. Update from binutils 1999 0809. An ELF/Sparc ld bug is fixed. Changes from binutils 2.9.5.0.4: 1. Update from binutils 1999 0806. A Solaris/Sparc gas bug is fixed. 2. Remove mips gas patches from binutils 2.9.1.0.25. Changes from binutils 2.9.5.0.3: 1. Update from binutils 1999 0801. 2. Support for real mode x86 gcc. Changes from binutils 2.9.4.0.8: 1. Update from binutils 1999 0719. A libc 5 related bug fix. 2. Fix a typo in mips gas. Changes from binutils 2.9.4.0.7: 1. Update from binutils 1999 0710. A weak symbol bug http://egcs.cygnus.com/ml/egcs-bugs/1999-07/msg00129.html is fixed. Changes from binutils 2.9.4.0.6: 1. Update from binutils 1999 0626. Changes from binutils 2.9.4.0.5: 1. Update from binutils 1999 0620. 2. Remove my fwait fix and use the one in cvs. 3. Use "--only-section=section" instead of "--extract-section=section". for objcopy. Changes from binutils 2.9.4.0.4: 1. Update from binutils 1999 0612. 2. Remove various temporary fixes of mine since those bugs are fixed now. Changes from binutils 2.9.4.0.3: 1. Update from binutils 1999 0611. 2. Remove my ELF/Alpha bfd changes. 3. Use the local symbol copy fix in binutils 1999 0611. Changes from binutils 2.9.4.0.2: 1. Update from binutils 1999 0607. 2. Remove my Sparc hacks. 3. Fix local symbol copy. Changes from binutils 2.9.4.0.1: 1. Update from binutils 1999 0606. 2. Restore relocation overflow checking in binutils 2.9.1.0.25 so that Linux kernel can build. 3. Fix i370 for the new gas. Changes from binutils 1999 0605: 1. Fix a -Bsymbolic bug for Linux/alpha. 2. Add ELF/i370. 3. Fix 8/16-bit relocations for i386. 4. Add --redefine-sym=old_form=new_form to objcopy. 5. Add "-j section" for objcopy. 6. Fix i386 disassembler for fwait. 7. Fix a Sparc asm bug. 8. Add Ada demangle support. 9. Fix MIPS/ELF bugs. 10. Add some vxworks suppport. 11. Fix a.out assembler. The file list: 1. binutils-2.9.5.0.42.tar.gz. Source code. 2. binutils-2.9.5.0.41-2.9.5.0.42.diff.gz. Patch against the previous beta source code. 3. binutils-2.9.5.0.42-1.i386.rpm. IA-32 binary RPM for RedHat 6.2. There is no separate source rpm. You can do # rpm -ta binutils-2.9.5.0.42.tar.gz to create both binary and source rpms. The primary ftp sites for the beta Linux binutils are: 1. ftp://ftp.valinux.com/pub/support/hjl/binutils Thanks. H.J. Lu hjl@lucon.org 05/12/2000 From aj@suse.de Sat May 13 11:25:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Sat, 13 May 2000 11:25:00 -0000 Subject: PF_PPOX added Message-ID: I've added the appended patch to synch with Linux 2.3.99pre7 to CVS. Andreas 2000-05-13 Andreas Jaeger * sysdeps/unix/sysv/linux/bits/socket.h (PF_PPPOX): New, from Linux 2.3.99pre7. (AF_PPPOX): Likewise. * sysdeps/unix/sysv/linux/mips/bits/socket.h (PF_PPPOX): Likewise. (AF_PPPOX): Likewise. ============================================================ Index: sysdeps/unix/sysv/linux/bits/socket.h --- sysdeps/unix/sysv/linux/bits/socket.h 2000/04/02 08:01:20 1.36 +++ sysdeps/unix/sysv/linux/bits/socket.h 2000/05/13 18:16:40 @@ -85,7 +85,8 @@ #define PF_ECONET 19 /* Acorn Econet. */ #define PF_ATMSVC 20 /* ATM SVCs. */ #define PF_SNA 22 /* Linux SNA Project */ -#define PF_IRDA 23 /* IRDA sockets. */ +#define PF_IRDA 23 /* IRDA sockets. */ +#define PF_PPPOX 24 /* PPPoX sockets. */ #define PF_MAX 32 /* For now.. */ /* Address families. */ @@ -114,7 +115,8 @@ #define AF_ECONET PF_ECONET #define AF_ATMSVC PF_ATMSVC #define AF_SNA PF_SNA -#define AF_IRDA PF_IRDA +#define AF_IRDA PF_IRDA +#define AF_PPPOX PF_PPPOX #define AF_MAX PF_MAX /* Socket level values. Others are defined in the appropriate headers. ============================================================ Index: sysdeps/unix/sysv/linux/mips/bits/socket.h --- sysdeps/unix/sysv/linux/mips/bits/socket.h 2000/04/02 08:01:25 1.12 +++ sysdeps/unix/sysv/linux/mips/bits/socket.h 2000/05/13 18:16:40 @@ -85,7 +85,8 @@ #define PF_ECONET 19 /* Acorn Econet. */ #define PF_ATMSVC 20 /* ATM SVCs. */ #define PF_SNA 22 /* Linux SNA Project */ -#define PF_IRDA 23 /* IRDA sockets. */ +#define PF_IRDA 23 /* IRDA sockets. */ +#define PF_PPPOX 24 /* PPPoX sockets. */ #define PF_MAX 32 /* For now.. */ /* Address families. */ @@ -114,7 +115,8 @@ #define AF_ECONET PF_ECONET #define AF_ATMSVC PF_ATMSVC #define AF_SNA PF_SNA -#define AF_IRDA PF_IRDA +#define AF_IRDA PF_IRDA +#define AF_PPPOX PF_PPPOX #define AF_MAX PF_MAX /* Socket level values. Others are defined in the appropriate headers. -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From jakub@redhat.com Sat May 13 14:46:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 13 May 2000 14:46:00 -0000 Subject: [PATCH] resolver fix Message-ID: <20000513234951.I474@sunsite.ms.mff.cuni.cz> Hi! This patch fixes resolver segfaults when linked with -lpthread. The issue is that the new resolver defines #define _res (*__res_state()) so when pthread.c sets the initial resp pointer to &_res, it sets it to NULL. Also, __pthread_initialize_minimal was called from within HAVE_DWARF2_* defines which is very wrong - if the system does not have DWARF2 eh, then it looses because pthread_initialize_minimal will be never called. And last, one minor optimization, like errno_location, __res_state is a good candidate for __attribute__((const)) IMHO, because it will not change during lifetime of any thread. 2000-05-13 Jakub Jelinek * elf/soinit.c (__libc_global_ctors): Move __pthread_initialize_minimal call out of HAVE_DWARF2_* defines. * resolv/resolv.h (__res_state): Added __attribute__((const)). (_res): If __RES_PTHREAD_INTERNAL is defined, declare it as variable, don't define it to __res_state call. * internals.h (__RES_PTHREAD_INTERNAL): Define. --- libc/elf/soinit.c.jj Sat May 13 21:43:33 2000 +++ libc/elf/soinit.c Sat May 13 21:45:22 2000 @@ -49,13 +49,14 @@ __libc_global_ctors (void) { /* Call constructor functions. */ run_hooks (__CTOR_LIST__); -#ifdef HAVE_DWARF2_UNWIND_INFO -# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC + /* Initialize the thread library at least a bit since the libgcc functions are using thread functions if these are available. */ if (__pthread_initialize_minimal) __pthread_initialize_minimal (); +#ifdef HAVE_DWARF2_UNWIND_INFO +# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC { static struct object ob; __register_frame_info (__EH_FRAME_BEGIN__, &ob); --- libc/linuxthreads/internals.h.jj Mon May 8 14:30:44 2000 +++ libc/linuxthreads/internals.h Sat May 13 22:01:09 2000 @@ -26,6 +26,7 @@ #include #include /* for _LIBC_TSD_KEY_N */ +#define __RES_PTHREAD_INTERNAL #include /* for per-thread resolver context */ --- libc/resolv/resolv.h.jj Mon May 8 14:30:46 2000 +++ libc/resolv/resolv.h Sat May 13 22:13:17 2000 @@ -254,8 +254,12 @@ typedef struct __res_state *res_state; /* Things involving an internal (static) resolver context. */ #if defined _REENTRANT || defined _LIBC_REENTRANT -extern struct __res_state *__res_state(void); +extern struct __res_state *__res_state(void) __attribute__ ((__const__)); +#if defined __RES_PTHREAD_INTERNAL +extern struct __res_state _res; +#else #define _res (*__res_state()) +#endif #else extern struct __res_state _res; #endif Jakub From aj@suse.de Mon May 15 00:14:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 15 May 2000 00:14:00 -0000 Subject: [PATCH] resolver fix References: <20000513234951.I474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > This patch fixes resolver segfaults when linked with -lpthread. > The issue is that the new resolver defines > #define _res (*__res_state()) > so when pthread.c sets the initial resp pointer to &_res, it sets it to > NULL. > Also, __pthread_initialize_minimal was called from within HAVE_DWARF2_* > defines which is very wrong - if the system does not have DWARF2 eh, then it > looses because pthread_initialize_minimal will be never called. > And last, one minor optimization, like errno_location, __res_state is a good > candidate for __attribute__((const)) IMHO, because it will not change during > lifetime of any thread. Thanks for the patch, Jakub. I've applied it with some indentation changes for resolv.h. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Tue May 16 02:34:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Tue, 16 May 2000 02:34:00 -0000 Subject: mathinline problem Message-ID: If I add this small patch for mathinline: Index: sysdeps/i386/fpu/bits/mathinline.h =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/fpu/bits/mathinline.h,v retrieving revision 1.39 diff -u -r1.39 mathinline.h --- mathinline.h 2000/05/06 07:46:06 1.39 +++ mathinline.h 2000/05/16 09:27:50 @@ -494,8 +494,10 @@ __inline_mathop_declNP (log, "fldln2; fxch; fyl2x", "0" (__x) : "st(1)") __inline_mathop_declNP (log10, "fldlg2; fxch; fyl2x", "0" (__x) : "st(1)") +#ifdef __FAST_MATH__ __inline_mathcodeNP (asin, __x, return __atan2l (__x, __sqrtl (1.0 - __x * __x))) __inline_mathcodeNP (acos, __x, return __atan2l (__sqrtl (1.0 - __x * __x), __x)) +#endif __inline_mathcode_ (long double, __sgn1l, __x, \ union { long double __xld; unsigned int __xi[3]; } __n = { __xld: __x }; \ =================================================================== I get a segementation fault when running the testsuite. For example I get for test-idouble -v3: [...] Test: acos (0) == pi/2 Result: is: 1.57079632679489655800e+00 0x1.921fb54442d1800000000000000000000p+0 Segmentation fault This happens with gcc 2.95.2 - it doesn't happen with the current gcc 2.96 CVS version. So what's the right thing to do? We do want to add some more __FAST_MATH__ #ifdefs to mathinline.h but adding more leads to segmentation faults in the testsuite (and therefore most probably also in user space programs). What should we do? Require gcc 2.96 for a correct compilation? Or ignore fast-math for now? I'd appreciate if somebody else could look into this. Thanks, Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From hjl@lucon.org Tue May 16 17:24:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Tue, 16 May 2000 17:24:00 -0000 Subject: NL_TEXTMAX == INT_MAX? Message-ID: <20000516172423.A17960@lucon.org> In glibc 2.1.3, we have /* Maximum number of bytes in a message. We have no limit. */ #define NL_TEXTMAX INT_MAX in . I don't think it makes any senses. A program I am working on has char msg [NL_TEXTMAX]; You can guess what happens. On Solaris 2.7/ia32, it is defined as 2048. If glibc does support long messages, 4096k should be more than enough. I'd like to see a more reasonable number. H.J. From roland@frob.com Tue May 16 17:37:00 2000 From: roland@frob.com (Roland McGrath) Date: Tue, 16 May 2000 17:37:00 -0000 Subject: NL_TEXTMAX == INT_MAX? References: <20000516172423.A17960@lucon.org> Message-ID: <200005170037.UAA00867@neuralgia.linnaean.org> Programs ought not assume there are arbitrary limits on everything. From kettenis@wins.uva.nl Tue May 16 17:53:00 2000 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Tue, 16 May 2000 17:53:00 -0000 Subject: NL_TEXTMAX == INT_MAX? References: <20000516172423.A17960@lucon.org> Message-ID: <200005170053.e4H0r8t00636@delius.kettenis.local> Date: Tue, 16 May 2000 17:24:23 -0700 From: "H . J . Lu" In glibc 2.1.3, we have /* Maximum number of bytes in a message. We have no limit. */ #define NL_TEXTMAX INT_MAX in . I don't think it makes any senses. A program I am working on has char msg [NL_TEXTMAX]; You can guess what happens. On Solaris 2.7/ia32, it is defined as 2048. If glibc does support long messages, 4096k should be more than enough. I'd like to see a more reasonable number. INT_MAX is the only reasonable number. The X/Open standard only specifies a minimum value. The GNU coding standards clearly state that arbitrary limits should be avoided. The program you're working on has a bug. The fix should be obvious :-). Mark From hjl@lucon.org Tue May 16 18:02:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Tue, 16 May 2000 18:02:00 -0000 Subject: NL_TEXTMAX == INT_MAX? References: <20000516172423.A17960@lucon.org> <200005170053.e4H0r8t00636@delius.kettenis.local> Message-ID: <20000516180221.A18099@lucon.org> On Wed, May 17, 2000 at 02:53:08AM +0200, Mark Kettenis wrote: > Date: Tue, 16 May 2000 17:24:23 -0700 > From: "H . J . Lu" > > In glibc 2.1.3, we have > > /* Maximum number of bytes in a message. We have no limit. */ > #define NL_TEXTMAX INT_MAX > > in . I don't think it makes any senses. A program > I am working on has > > char msg [NL_TEXTMAX]; > > You can guess what happens. On Solaris 2.7/ia32, it is defined as 2048. > If glibc does support long messages, 4096k should be more than enough. > I'd like to see a more reasonable number. > > INT_MAX is the only reasonable number. The X/Open standard only > specifies a minimum value. The GNU coding standards clearly state > that arbitrary limits should be avoided. The program you're working > on has a bug. The fix should be obvious :-). I won't buy you can create a message with INT_MAX bytes. H.J. From hjl@lucon.org Tue May 16 20:18:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Tue, 16 May 2000 20:18:00 -0000 Subject: NL_TEXTMAX == INT_MAX? References: <20000516172423.A17960@lucon.org> <200005170310.UAA01284@localhost.cygnus.com> Message-ID: <20000516201813.A18508@lucon.org> On Tue, May 16, 2000 at 08:10:57PM -0700, Geoff Keating wrote: > > Date: Tue, 16 May 2000 17:24:23 -0700 > > From: "H . J . Lu" > > > char msg [NL_TEXTMAX]; > > Such programs are broken. It's just like the same thing with > PATH_MAX. With PATH_MAX, I would expect I could create a pathname length up to PATH_MAX. > > > I won't buy you can create a message with INT_MAX bytes. > > I expect on an Alpha you can... and will it really help if NL_TEXTMAX > is, say, (1 << 30)? Yes, it may be reasonable, which I doubt, for 64bit machines if you have enough memory and/or swap space. But I won't call it reasonable for 32bit machines. If you think it is reasonable, try to generate such a message on both 64bit and 32bit machines. H.J. From hjl@lucon.org Tue May 16 21:40:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Tue, 16 May 2000 21:40:00 -0000 Subject: NL_TEXTMAX == INT_MAX? References: <20000516172423.A17960@lucon.org> <200005170310.UAA01284@localhost.cygnus.com> <20000516201813.A18508@lucon.org> <200005170359.UAA01309@localhost.cygnus.com> Message-ID: <20000516214054.A18727@lucon.org> On Tue, May 16, 2000 at 08:59:32PM -0700, Geoff Keating wrote: > > > Yes, it may be reasonable, which I doubt, for 64bit machines if you > > have enough memory and/or swap space. But I won't call it reasonable > > for 32bit machines. If you think it is reasonable, try to generate such > > a message on both 64bit and 32bit machines. > > So you think that NL_TEXTMAX should be modified at runtime to the > amount of free VM on the machine? I don't care as long as I could create a message of NL_TEXTMAX byte long. H.J. From aj@suse.de Tue May 16 23:51:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Tue, 16 May 2000 23:51:00 -0000 Subject: config.guess, config.sub, texinfo.tex updated Message-ID: I've updated config.guess, config.sub, texinfo.tex from their upstream versions. config.* adds support for e.g. alphaev6[78] and s390; texinfo.tex contains only a fix for \deftypeivarheader. I've only added this to glibc 2.2 for now, Andreas 2000-05-17 Andreas Jaeger * scripts/config.sub: New version. * scripts/config.guess: Likewise. * manual/texinfo.tex: Likewise. -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From jakub@redhat.com Wed May 17 02:04:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 17 May 2000 02:04:00 -0000 Subject: [PATCH] Fix dl-cache breakage on sparc64 Message-ID: <20000517110828.O474@sunsite.ms.mff.cuni.cz> Hi! This patch fixes breakage introduced by generic/dl-cache.h changes (several things were put into that file without updating sparc64/dl-cache.h as well). 2000-05-17 Jakub Jelinek * sysdeps/generic/dl-cache.h (_DL_CACHE_DEFAULT_ID): Only define if not yet defined. (_dl_cache_check_flags): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/dl-cache.h: include_next dl-cache.h. --- libc/sysdeps/generic/dl-cache.h.jj Tue May 9 13:48:11 2000 +++ libc/sysdeps/generic/dl-cache.h Wed May 17 06:56:58 2000 @@ -17,11 +17,14 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef _DL_CACHE_DEFAULT_ID #define _DL_CACHE_DEFAULT_ID 3 +#endif +#ifndef _dl_cache_check_flags #define _dl_cache_check_flags(flags) \ ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID) - +#endif #ifndef LD_SO_CACHE # define LD_SO_CACHE "/etc/ld.so.cache" --- libc/sysdeps/unix/sysv/linux/sparc/sparc64/dl-cache.h.jj Tue Jan 4 17:12:06 2000 +++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/dl-cache.h Wed May 17 06:55:56 2000 @@ -1,5 +1,5 @@ /* Support for reading /etc/ld.so.cache files written by Linux ldconfig. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 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 @@ -21,3 +21,5 @@ #define _dl_cache_check_flags(flags) \ ((flags) == _DL_CACHE_DEFAULT_ID) + +#include_next Jakub From jakub@redhat.com Wed May 17 02:05:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 17 May 2000 02:05:00 -0000 Subject: [PATCH] Fix math.h with -pedantic Message-ID: <20000517110948.P474@sunsite.ms.mff.cuni.cz> Hi! If math.h is included in some file which is compiled with -pedantic by gcc 2.95+, one gets an error. __extension__ helps here. 2000-05-17 Jakub Jelinek * sysdeps/arm/bits/huge_val.h (HUGE_VAL, HUGE_VALF): Add __extension__ to hexadecimal floating constant notation. * sysdeps/i386/bits/huge_val.h (HUGE_VAL, HUGE_VALF, HUGE_VALL): Likewise. * sysdeps/ieee754/bits/huge_val.h (HUGE_VAL, HUGE_VALF): Likewise. * sysdeps/m68k/bits/huge_val.h (HUGE_VAL, HUGE_VALF, HUGE_VALL): Likewise. * sysdeps/sparc/sparc64/bits/huge_val.h (HUGE_VAL, HUGE_VALF, HUGE_VALL): Likewise. * sysdeps/sparc/sparc32/bits/huge_val.h (HUGE_VAL, HUGE_VALF, HUGE_VALL): Likewise. (HUGE_VALL): Set to HUGE_VAL on sparc32. --- libc/sysdeps/arm/bits/huge_val.h.jj Tue Jan 4 17:11:54 2000 +++ libc/sysdeps/arm/bits/huge_val.h Wed May 17 10:43:47 2000 @@ -1,7 +1,7 @@ /* `HUGE_VAL' constants for IEEE 754 machines (where it is infinity). Used by and functions for overflow. ARM version. - Copyright (C) 1992, 95, 96, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1992, 95, 96, 97, 98, 99, 2000 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,7 +31,7 @@ # if __GNUC_PREREQ(2,95) -# define HUGE_VAL (0x1.0p2047) +# define HUGE_VAL (__extension__ 0x1.0p2047) # else @@ -69,7 +69,7 @@ static __huge_val_t __huge_val = { __HUG # if __GNUC_PREREQ(2,95) -# define HUGE_VALF (0x1.0p255f) +# define HUGE_VALF (__extension__ 0x1.0p255f) # else --- libc/sysdeps/i386/bits/huge_val.h.jj Tue Jan 4 17:11:55 2000 +++ libc/sysdeps/i386/bits/huge_val.h Wed May 17 10:44:03 2000 @@ -1,6 +1,6 @@ /* `HUGE_VAL' constants for ix86 (where it is infinity). Used by and functions for overflow. - Copyright (C) 1992, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 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 @@ -27,7 +27,7 @@ /* IEEE positive infinity (-HUGE_VAL is negative infinity). */ #if __GNUC_PREREQ(2,95) -# define HUGE_VAL (0x1.0p2047) +# define HUGE_VAL (__extension__ 0x1.0p2047) #else # define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } @@ -48,8 +48,8 @@ static __huge_val_t __huge_val = { __HUG # if __GNUC_PREREQ(2,95) -# define HUGE_VALF (0x1.0p255f) -# define HUGE_VALL (0x1.0p32767L) +# define HUGE_VALF (__extension__ 0x1.0p255f) +# define HUGE_VALL (__extension__ 0x1.0p32767L) # else --- libc/sysdeps/ieee754/bits/huge_val.h.jj Tue Jan 4 17:11:56 2000 +++ libc/sysdeps/ieee754/bits/huge_val.h Wed May 17 10:44:25 2000 @@ -1,6 +1,6 @@ /* `HUGE_VAL' constants for IEEE 754 machines (where it is infinity). Used by and functions for overflow. - Copyright (C) 1992, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 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 @@ -30,7 +30,7 @@ # if __GNUC_PREREQ(2,95) -# define HUGE_VAL (0x1.0p2047) +# define HUGE_VAL (__extension__ 0x1.0p2047) # else @@ -68,7 +68,7 @@ static __huge_val_t __huge_val = { __HUG # if __GNUC_PREREQ(2,95) -# define HUGE_VALF (0x1.0p255f) +# define HUGE_VALF (__extension__ 0x1.0p255f) # else --- libc/sysdeps/m68k/bits/huge_val.h.jj Tue Jan 4 17:11:56 2000 +++ libc/sysdeps/m68k/bits/huge_val.h Wed May 17 10:44:52 2000 @@ -1,6 +1,6 @@ /* `HUGE_VAL' constants for m68k (where it is infinity). Used by and functions for overflow. - Copyright (C) 1992, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 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 @@ -32,7 +32,7 @@ # if __GNUC_PREREQ(2,95) -# define HUGE_VAL (0x1.0p2047) +# define HUGE_VAL (__extension__ 0x1.0p2047) # else @@ -58,8 +58,8 @@ static union { unsigned char __c[8]; dou # if __GNUC_PREREQ(2,95) -# define HUGE_VALF (0x1.0p255f) -# define HUGE_VALL (0x1.0p32767L) +# define HUGE_VALF (__extension__ 0x1.0p255f) +# define HUGE_VALL (__extension__ 0x1.0p32767L) # else --- libc/sysdeps/sparc/sparc32/fpu/bits/huge_val.h.jj Tue Jan 4 17:11:59 2000 +++ libc/sysdeps/sparc/sparc32/fpu/bits/huge_val.h Wed May 17 10:42:51 2000 @@ -1,6 +1,6 @@ /* `HUGE_VAL' constants for IEEE 754 machines (where it is infinity). Used by and functions for overflow. - Copyright (C) 1992, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 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,7 +31,7 @@ # if __GNUC_PREREQ(2,95) -# define HUGE_VAL (0x1.0p2047) +# define HUGE_VAL (__extension__ 0x1.0p2047) # else @@ -60,8 +60,13 @@ static __huge_val_t __huge_val = { __HUG # if __GNUC_PREREQ(2,95) -# define HUGE_VALF (0x1.0p255) -# define HUGE_VALL (0x1.0p32767) +# define HUGE_VALF (__extension__ 0x1.0p255f) +# if __WORDSIZE == 32 +# define HUGE_VALL HUGE_VAL +# else +/* Sparc64 uses IEEE 754 128bit long double */ +# define HUGE_VALL (__extension__ 0x1.0p32767L) +# endif # else --- libc/sysdeps/sparc/sparc64/fpu/bits/huge_val.h.jj Tue Jan 4 17:11:59 2000 +++ libc/sysdeps/sparc/sparc64/fpu/bits/huge_val.h Wed May 17 10:42:51 2000 @@ -1,6 +1,6 @@ /* `HUGE_VAL' constants for IEEE 754 machines (where it is infinity). Used by and functions for overflow. - Copyright (C) 1992, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 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,7 +31,7 @@ # if __GNUC_PREREQ(2,95) -# define HUGE_VAL (0x1.0p2047) +# define HUGE_VAL (__extension__ 0x1.0p2047) # else @@ -60,12 +60,12 @@ static __huge_val_t __huge_val = { __HUG # if __GNUC_PREREQ(2,95) -# define HUGE_VALF (0x1.0p255f) +# define HUGE_VALF (__extension__ 0x1.0p255f) # if __WORDSIZE == 32 # define HUGE_VALL HUGE_VAL # else /* Sparc64 uses IEEE 754 128bit long double */ -# define HUGE_VALL (0x1.0p32767L) +# define HUGE_VALL (__extension__ 0x1.0p32767L) # endif # else Jakub From aj@suse.de Wed May 17 02:40:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 17 May 2000 02:40:00 -0000 Subject: [PATCH] Fix dl-cache breakage on sparc64 References: <20000517110828.O474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > This patch fixes breakage introduced by generic/dl-cache.h changes (several > things were put into that file without updating sparc64/dl-cache.h as well). Sorry about the breakage and thanks for fixing it. I'll submit your patch together with my other dl-cache/ldconfig patches later. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From jakub@redhat.com Wed May 17 03:55:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 17 May 2000 03:55:00 -0000 Subject: rcmd in glibc 2.1.90 Message-ID: <20000517125905.Q474@sunsite.ms.mff.cuni.cz> Hi! When I try with glibc 2.1.90 rlogin foobar I get rcmd: getaddrinfo: Name or service not known error message printed on the screen. IMHO glibc 2.1.x error message was much better: foobar: Unknown host This patch changes this, alternatively we could just kill the rcmd: getaddrinfo: and replace it with %s: (*ahost). Also, I've noticed that if the local domain is not specified in search in /etc/resolv.conf, then getaddrinfo does not resolve dotless names while it did in glibc 2.1. Say I'm on foo.mydomain.cz my /etc/resolv.conf does not contain any search line. With glibc 2.1 rlogin bar works (provided bar.mydomain.cz exists), while with 2.2 it fails. Is that desired behaviour or just a bug? 2000-05-17 Jakub Jelinek * inet/rcmd.c (rcmd_af): If *ahost cannot be resolved, include unresolved hostname in the message. --- libc/inet/rcmd.c.jj Tue May 9 13:47:33 2000 +++ libc/inet/rcmd.c Wed May 17 12:35:11 2000 @@ -134,9 +134,12 @@ rcmd_af(ahost, rport, locuser, remuser, (void)snprintf(num, sizeof(num), "%d", ntohs(rport)); error = getaddrinfo(*ahost, num, &hints, &res); if (error) { - fprintf(stderr, "rcmd: getaddrinfo: %s\n", - gai_strerror(error)); - return (-1); + if (error == EAI_NONAME && *ahost != NULL) + fprintf(stderr, "%s: Unknown host\n", *ahost); + else + fprintf(stderr, "rcmd: getaddrinfo: %s\n", + gai_strerror(error)); + return (-1); } pfd[0].events = POLLIN; Jakub From aj@suse.de Wed May 17 05:18:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 17 May 2000 05:18:00 -0000 Subject: Some pure/const attributes added Message-ID: FYI: I've commited the following patch. Btw. crypt.h doesn't have use any attributes at all. Any volunteer to add __THROW and other attributes? Andreas 2000-05-17 Andreas Jaeger * string/envz.h: Add pure attributes if possible. * string/argz.h: argz_count is a pure function. * string/strings.h: Add pure and const attributes if possible. ============================================================ Index: string/envz.h --- string/envz.h 1999/10/09 21:24:43 1.12 +++ string/envz.h 2000/05/17 11:41:03 @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated environment vectors - Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1995, 96, 98, 99, 2000 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -31,12 +31,14 @@ /* Returns a pointer to the entry in ENVZ for NAME, or 0 if there is none. */ extern char *envz_entry (__const char *__restrict __envz, size_t __envz_len, - __const char *__restrict __name) __THROW; + __const char *__restrict __name) + __THROW __attribute_pure__; /* Returns a pointer to the value portion of the entry in ENVZ for NAME, or 0 if there is none. */ extern char *envz_get (__const char *__restrict __envz, size_t __envz_len, - __const char *__restrict __name) __THROW; + __const char *__restrict __name) + __THROW __attribute_pure__; /* Adds an entry for NAME with value VALUE to ENVZ & ENVZ_LEN. If an entry with the same name already exists in ENVZ, it is removed. If VALUE is ============================================================ Index: string/strings.h --- string/strings.h 1999/10/09 21:24:53 1.9 +++ string/strings.h 2000/05/17 11:41:03 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1996, 1997, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,96,97,99,2000 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 @@ -30,7 +30,8 @@ __BEGIN_DECLS /* Compare N bytes of S1 and S2 (same as memcmp). */ -extern int bcmp (__const void *__s1, __const void *__s2, size_t __n) __THROW; +extern int bcmp (__const void *__s1, __const void *__s2, size_t __n) + __THROW __attribute_pure__; /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ extern void bcopy (__const void *__src, void *__dest, size_t __n) __THROW; @@ -40,20 +41,21 @@ /* Return the position of the first bit set in I, or 0 if none are set. The least-significant bit is position 1, the most-significant 32. */ -extern int ffs (int __i) __THROW; +extern int ffs (int __i) __THROW __attribute__ ((const)); /* Find the first occurrence of C in S (same as strchr). */ -extern char *index (__const char *__s, int __c) __THROW; +extern char *index (__const char *__s, int __c) __THROW __attribute_pure__; /* Find the last occurrence of C in S (same as strrchr). */ -extern char *rindex (__const char *__s, int __c) __THROW; +extern char *rindex (__const char *__s, int __c) __THROW __attribute_pure__; /* Compare S1 and S2, ignoring case. */ -extern int strcasecmp (__const char *__s1, __const char *__s2) __THROW; +extern int strcasecmp (__const char *__s1, __const char *__s2) + __THROW __attribute_pure__; /* Compare no more than N chars of S1 and S2, ignoring case. */ extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n) - __THROW; + __THROW __attribute_pure__; __END_DECLS -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Wed May 17 10:40:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 17 May 2000 10:40:00 -0000 Subject: [PATCH] Fix math.h with -pedantic References: <20000517110948.P474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Ulrich Drepper writes: > Jakub Jelinek writes: >> If math.h is included in some file which is compiled with -pedantic by gcc >> 2.95+, one gets an error. >> __extension__ helps here. > That's fine. Can get checked in. Done. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From greg@mcgary.org Wed May 17 18:21:00 2000 From: greg@mcgary.org (Greg McGary) Date: Wed, 17 May 2000 18:21:00 -0000 Subject: small powerpc/brk.S fix Message-ID: <200005180121.SAA18663@mcgary.org> 2000-05-17 Greg McGary * sysdeps/unix/sysv/linux/powerpc/brk.S [!PIC]: Get low part of &__curbrk with @l. Index: brk.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/brk.S,v retrieving revision 1.3 diff -u -p -r1.3 brk.S --- brk.S 2000/01/27 23:40:48 1.3 +++ brk.S 2000/05/18 01:14:41 @@ -37,7 +37,7 @@ ENTRY(__brk) stw r3,0(r5) #else lis r4,__curbrk@ha - stw r3,__curbrk@sdarel(r4) + stw r3,__curbrk@l(r4) #endif cmplw r6,r3 addi r1,r1,16 From jakub@redhat.com Thu May 18 02:20:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 18 May 2000 02:20:00 -0000 Subject: [PATCH] fopencookie binary compatibility Message-ID: <20000518112440.C474@sunsite.ms.mff.cuni.cz> Hi! cookie_seek_function_t type changed between 2.0 and 2.2, which causes binary incompatibility between programs using fopencookie compiled with glibc up to 2.1.x and glibc 2.2. This patch should add fopencookie@@GLIBC_2.2 and fopencookie@GLIBC_2.0, so that old programs can continue to work. 2000-05-18 Jakub Jelinek * libio/iofopncook.c (_IO_fopencookie): Renamed from fopencookie. (fopencookie@@GLIBC_2.2): New. (_IO_old_cookie_seek, _IO_old_fopencookie, _IO_old_cookie_jumps): New. (fopencookie@GLIBC_2.0): New. * libio/Versions: Add fopencookie to GLIBC_2.2. --- libc/libio/iofopncook.c.jj Tue Apr 4 01:32:57 2000 +++ libc/libio/iofopncook.c Thu May 18 10:40:38 2000 @@ -26,7 +26,7 @@ #include #include #include - +#include /* Prototyped for local functions. */ static _IO_ssize_t _IO_cookie_read (register _IO_FILE* fp, void* buf, @@ -35,7 +35,8 @@ static _IO_ssize_t _IO_cookie_write (reg const void* buf, _IO_ssize_t size); static _IO_off64_t _IO_cookie_seek (_IO_FILE *fp, _IO_off64_t offset, int dir); static int _IO_cookie_close (_IO_FILE* fp); - +_IO_FILE * _IO_fopencookie (void *cookie, const char *mode, + _IO_cookie_io_functions_t io_functions); static _IO_ssize_t _IO_cookie_read (fp, buf, size) @@ -140,7 +141,7 @@ _IO_cookie_init (struct _IO_cookie_file _IO_FILE * -fopencookie (cookie, mode, io_functions) +_IO_fopencookie (cookie, mode, io_functions) void *cookie; const char *mode; _IO_cookie_io_functions_t io_functions; @@ -182,3 +183,75 @@ fopencookie (cookie, mode, io_functions) return &new_f->cfile.__file; } + +versioned_symbol (libc, _IO_fopencookie, fopencookie, GLIBC_2_2); + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) + +static _IO_off64_t _IO_old_cookie_seek (_IO_FILE *fp, _IO_off64_t offset, + int dir); +_IO_FILE * _IO_old_fopencookie (void *cookie, const char *mode, + _IO_cookie_io_functions_t io_functions); + +static _IO_off64_t +_IO_old_cookie_seek (fp, offset, dir) + _IO_FILE *fp; + _IO_off64_t offset; + int dir; +{ + struct _IO_cookie_file *cfile = (struct _IO_cookie_file *) fp; + int (*seek) (_IO_FILE *, _IO_off_t, int); + int ret; + + seek = (int (*)(_IO_FILE *, _IO_off_t, int)) cfile->__io_functions.seek; + if (seek == NULL) + return _IO_pos_BAD; + + ret = seek (cfile->__cookie, offset, dir); + + return (ret == -1) ? _IO_pos_BAD : ret; +} + +static struct _IO_jump_t _IO_old_cookie_jumps = { + JUMP_INIT_DUMMY, + JUMP_INIT(finish, _IO_file_finish), + JUMP_INIT(overflow, _IO_file_overflow), + JUMP_INIT(underflow, _IO_file_underflow), + JUMP_INIT(uflow, _IO_default_uflow), + JUMP_INIT(pbackfail, _IO_default_pbackfail), + JUMP_INIT(xsputn, _IO_file_xsputn), + JUMP_INIT(xsgetn, _IO_default_xsgetn), + JUMP_INIT(seekoff, _IO_file_seekoff), + JUMP_INIT(seekpos, _IO_default_seekpos), + JUMP_INIT(setbuf, _IO_file_setbuf), + JUMP_INIT(sync, _IO_file_sync), + JUMP_INIT(doallocate, _IO_file_doallocate), + JUMP_INIT(read, _IO_cookie_read), + JUMP_INIT(write, _IO_cookie_write), + JUMP_INIT(seek, _IO_old_cookie_seek), + JUMP_INIT(close, _IO_cookie_close), + JUMP_INIT(stat, _IO_default_stat), + JUMP_INIT(showmanyc, _IO_default_showmanyc), + JUMP_INIT(imbue, _IO_default_imbue), +}; + +_IO_FILE * +_IO_old_fopencookie (cookie, mode, io_functions) + void *cookie; + const char *mode; + _IO_cookie_io_functions_t io_functions; +{ + _IO_FILE *ret; + + ret = _IO_fopencookie (cookie, mode, io_functions); + if (ret != NULL) + _IO_JUMPS (ret) = &_IO_old_cookie_jumps; + + return ret; +} + +#ifdef weak_alias +compat_symbol (libc, _IO_old_fopencookie, fopencookie, GLIBC_2_0); +#endif + +#endif --- libc/libio/Versions.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/Versions Thu May 18 10:14:35 2000 @@ -107,7 +107,7 @@ libc { # f* fgetpos; fgetpos64; fgetwc; fgetwc_unlocked; fgetws; fgetws_unlocked; fputwc; fputwc_unlocked; fputws; fputws_unlocked; fsetpos; fsetpos64; - fwide; fwprintf; fwscanf; + fwide; fwprintf; fwscanf; fopencookie; # g* getwc; getwc_unlocked; getwchar; getwchar_unlocked; Jakub From aj@suse.de Thu May 18 03:50:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Thu, 18 May 2000 03:50:00 -0000 Subject: [PATCH] fopencookie binary compatibility References: <20000518112440.C474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > cookie_seek_function_t type changed between 2.0 and 2.2, which causes binary > incompatibility between programs using fopencookie compiled with glibc up to > 2.1.x and glibc 2.2. > This patch should add fopencookie@@GLIBC_2.2 and fopencookie@GLIBC_2.0, so > that old programs can continue to work. > +#ifdef weak_alias > +compat_symbol (libc, _IO_old_fopencookie, fopencookie, GLIBC_2_0); > +#endif Is the #ifdef really needed? I don't think so. I'll check the patch in without this if this is ok. Uli, what do you think? Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From jakub@redhat.com Thu May 18 03:57:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 18 May 2000 03:57:00 -0000 Subject: [PATCH] fopencookie binary compatibility References: <20000518112440.C474@sunsite.ms.mff.cuni.cz> Message-ID: <20000518130136.E474@sunsite.ms.mff.cuni.cz> On Thu, May 18, 2000 at 12:49:10PM +0200, Andreas Jaeger wrote: > >>>>> Jakub Jelinek writes: > > > Hi! > > cookie_seek_function_t type changed between 2.0 and 2.2, which causes binary > > incompatibility between programs using fopencookie compiled with glibc up to > > 2.1.x and glibc 2.2. > > This patch should add fopencookie@@GLIBC_2.2 and fopencookie@GLIBC_2.0, so > > that old programs can continue to work. > > +#ifdef weak_alias > > +compat_symbol (libc, _IO_old_fopencookie, fopencookie, GLIBC_2_0); > > +#endif > Is the #ifdef really needed? I don't think so. > > I'll check the patch in without this if this is ok. Uli, what do you > think? That was cut'n'paste from oldiof[gs]etpos*, so if it is not needed here, it is not needed there either (and I assume it is not needed because e.g. oldiofclose.c does not have it). Jakub From aj@suse.de Thu May 18 04:27:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Thu, 18 May 2000 04:27:00 -0000 Subject: [PATCH] fopencookie binary compatibility References: <20000518112440.C474@sunsite.ms.mff.cuni.cz> <20000518130136.E474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: Jakub> On Thu, May 18, 2000 at 12:49:10PM +0200, Andreas Jaeger wrote: >> >>>>> Jakub Jelinek writes: >> >> > Hi! >> > cookie_seek_function_t type changed between 2.0 and 2.2, which causes binary >> > incompatibility between programs using fopencookie compiled with glibc up to >> > 2.1.x and glibc 2.2. >> > This patch should add fopencookie@@GLIBC_2.2 and fopencookie@GLIBC_2.0, so >> > that old programs can continue to work. >> > +#ifdef weak_alias >> > +compat_symbol (libc, _IO_old_fopencookie, fopencookie, GLIBC_2_0); >> > +#endif >> Is the #ifdef really needed? I don't think so. >> >> I'll check the patch in without this if this is ok. Uli, what do you >> think? Jakub> That was cut'n'paste from oldiof[gs]etpos*, so if it is not needed here, it Jakub> is not needed there either (and I assume it is not needed because e.g. Jakub> oldiofclose.c does not have it). It should not be needed because of the definition of weak_alias in include/libc-symbols.h. It's either a weak alias or a strong_alias. I think the #ifdef can also be removed from oldiof[gs]etpos*. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Fri May 19 09:55:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 19 May 2000 09:55:00 -0000 Subject: Problem with i386/i686/sysdep.h (includes patch) Message-ID: Compiling without linuxthreads on i686 I got: /builds/glibc/test-disable-linuxthreads/libc.so.6: undefined reference to `__syscall_error' I've removed the syscall_error declaration from sysdep.h. Why was it needed at all? Did I miss anything or is this the right fix? At least I can run make;make check now. Andreas 2000-05-19 Andreas Jaeger * sysdeps/unix/sysv/linux/i386/i686/sysdep.h (SYSCALL_ERROR_HANDLER): Remove unneeded syscall_error which breaks compilation without linuxthreads. ============================================================ Index: sysdeps/unix/sysv/linux/i386/i686/sysdep.h --- sysdeps/unix/sysv/linux/i386/i686/sysdep.h 1998/08/23 18:22:44 1.3 +++ sysdeps/unix/sysv/linux/i386/i686/sysdep.h 2000/05/19 16:32:28 @@ -49,7 +49,6 @@ not modify the stack! */ # else # define SYSCALL_ERROR_HANDLER \ - .type syscall_error,@function; \ 1:movl (%esp),%ecx; \ ret; \ 0:call 1b; \ -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From hjl@valinux.com Fri May 19 10:39:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Fri, 19 May 2000 10:39:00 -0000 Subject: ELF visibility support in glibc 2.2 Message-ID: <20000519103655.A5444@valinux.com> I checked in some testcases for ELF visibility in binutils. Under glibc 2.1, STV_PROTECTED is not supported. So there are 5 expected failures because of it. However, under glibc 2.2, in addition to those 5 expected STV_PROTECTED failures, I got FAIL: visibility (hidden_normal) (non PIC) FAIL: visibility (hidden_normal) (non PIC, load offset) FAIL: visibility (hidden_normal) FAIL: visibility (hidden_normal) (PIC main, non PIC so) FAIL: visibility (hidden_normal) (PIC main) FAIL: visibility (normal) (non PIC) FAIL: visibility (normal) (non PIC, load offset) FAIL: visibility (normal) FAIL: visibility (normal) (PIC main, non PIC so) FAIL: visibility (normal) (PIC main) They are all passed under glibc 2.1. Something is wrong here. I don't know what it is. I suspect ELF visibility support in glibc 2.2 is not working right. -- H.J. Lu (hjl@gnu.org) From hjl@lucon.org Fri May 19 11:03:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Fri, 19 May 2000 11:03:00 -0000 Subject: ST_VISIBILITY is broken in glibc 2.2 Message-ID: <20000519110346.A29403@lucon.org> ST_VISIBILITY is broken in glibc 2.2. STV_HIDDEN is supported by the static linker. STV_PROTECTED needs support from both the static linker and dynamic linker. The static linker has the STV_PROTECTED support. We just need to add the STV_PROTECTED support to the dynamic linker. As for STV_INTERNAL, it is treated as STV_HIDDEN for most cases. H.J. From greg@mcgary.org Fri May 19 12:20:00 2000 From: greg@mcgary.org (Greg McGary) Date: Fri, 19 May 2000 12:20:00 -0000 Subject: [PATCH] small powerpc/brk.S fix Message-ID: This is a repost. This patch completes Geoff's incomplete fix to convert addressing of __curbrk from GP-relative to absolute. 2000-05-17 Greg McGary * sysdeps/unix/sysv/linux/powerpc/brk.S [!PIC]: Get low part of &__curbrk with @l. Index: brk.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/brk.S,v retrieving revision 1.3 diff -u -p -r1.3 brk.S --- brk.S 2000/01/27 23:40:48 1.3 +++ brk.S 2000/05/18 01:14:41 @@ -37,7 +37,7 @@ ENTRY(__brk) stw r3,0(r5) #else lis r4,__curbrk@ha - stw r3,__curbrk@sdarel(r4) + stw r3,__curbrk@l(r4) #endif cmplw r6,r3 addi r1,r1,16 From aj@suse.de Fri May 19 13:10:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 19 May 2000 13:10:00 -0000 Subject: [PATCH] small powerpc/brk.S fix References: Message-ID: >>>>> Greg McGary writes: > This is a repost. > This patch completes Geoff's incomplete fix to convert > addressing of __curbrk from GP-relative to absolute. Geoff, what do you think about this? Shall I commit it? Andreas > 2000-05-17 Greg McGary > * sysdeps/unix/sysv/linux/powerpc/brk.S [!PIC]: > Get low part of &__curbrk with @l. > Index: brk.S > =================================================================== > RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/brk.S,v > retrieving revision 1.3 > diff -u -p -r1.3 brk.S > --- brk.S 2000/01/27 23:40:48 1.3 > +++ brk.S 2000/05/18 01:14:41 > @@ -37,7 +37,7 @@ ENTRY(__brk) > stw r3,0(r5) > #else > lis r4,__curbrk@ha > - stw r3,__curbrk@sdarel(r4) > + stw r3,__curbrk@l(r4) > #endif > cmplw r6,r3 > addi r1,r1,16 -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From hjl@lucon.org Sat May 20 16:46:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Sat, 20 May 2000 16:46:00 -0000 Subject: Bugs in glibc 2.2 Message-ID: <20000520164618.A840@lucon.org> Hi, I am working on several bugs in glibc 2.2. I had an impression that glibc 2.2 was very unstable. I was wondering how many people were using glibc 2.2. To start, There are struct __res_state _res; and void res_close(void) { res_nclose(&_res); } void res_nclose(res_state statp) { if (statp->_sock >= 0) { (void) close(statp->_sock); statp->_sock = -1; statp->_flags &= ~(RES_F_VC | RES_F_CONN); } } since _res._sock is 0, close (0) is called. It is very bad when 0 may be a valid fd for something else. There are other bugs I am trying to do down. For example, # man read no longer works. H.J. From jakub@redhat.com Sat May 20 21:29:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 20 May 2000 21:29:00 -0000 Subject: Bugs in glibc 2.2 References: <20000520164618.A840@lucon.org> Message-ID: <20000521063407.V474@sunsite.ms.mff.cuni.cz> > when 0 may be a valid fd for something else. There are other > bugs I am trying to do down. For example, > > # man read > > no longer works. I'm working on a fix for this now if it is groff segfaulting. > > H.J. Jakub From jakub@redhat.com Sat May 20 21:38:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 20 May 2000 21:38:00 -0000 Subject: [PATCH] Another huge_val.h fix Message-ID: <20000521064332.W474@sunsite.ms.mff.cuni.cz> Hi! Sadly it turns out that eventhough gcc 2.95 handles hex floating constants just fine (with __extension__ for -pedantic), g++ 2.95 does not, so everyone now gets a fatal error including math.h in a C++ program. Fortunately g++ 2.96 does (ObjC did already in 2.95), so IMHO we have three choices: - simply prereq 2.96 like done with this patch - use # if __GNUC_PREREQ(2,96) || (__GNUC_PREREQ(2,95) && !defined(__cplusplus)) - kill the hex floating consts bits from huge_val.h 2000-05-21 Jakub Jelinek * sysdeps/arm/bits/huge_val.h: Prereq gcc 2.96+, not 2.95. * sysdeps/i386/bits/huge_val.h: Likewise. * sysdeps/ieee754/bits/huge_val.h: Likewise. * sysdeps/m68k/bits/huge_val.h: Likewise. * sysdeps/sparc/sparc32/bits/huge_val.h: Likewise. * sysdeps/sparc/sparc64/bits/huge_val.h: Likewise. --- libc/sysdeps/arm/bits/huge_val.h.jj Thu May 18 14:49:54 2000 +++ libc/sysdeps/arm/bits/huge_val.h Sun May 21 06:23:09 2000 @@ -29,7 +29,7 @@ #ifdef __GNUC__ -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VAL (__extension__ 0x1.0p2047) @@ -67,7 +67,7 @@ static __huge_val_t __huge_val = { __HUG # ifdef __GNUC__ -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VALF (__extension__ 0x1.0p255f) --- libc/sysdeps/i386/bits/huge_val.h.jj Thu May 18 14:50:03 2000 +++ libc/sysdeps/i386/bits/huge_val.h Sun May 21 06:23:09 2000 @@ -26,7 +26,7 @@ /* IEEE positive infinity (-HUGE_VAL is negative infinity). */ -#if __GNUC_PREREQ(2,95) +#if __GNUC_PREREQ(2,96) # define HUGE_VAL (__extension__ 0x1.0p2047) #else # define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } @@ -46,7 +46,7 @@ static __huge_val_t __huge_val = { __HUG #ifdef __USE_ISOC99 -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VALF (__extension__ 0x1.0p255f) # define HUGE_VALL (__extension__ 0x1.0p32767L) --- libc/sysdeps/ieee754/bits/huge_val.h.jj Thu May 18 14:50:05 2000 +++ libc/sysdeps/ieee754/bits/huge_val.h Sun May 21 06:23:09 2000 @@ -28,7 +28,7 @@ #ifdef __GNUC__ -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VAL (__extension__ 0x1.0p2047) @@ -66,7 +66,7 @@ static __huge_val_t __huge_val = { __HUG # ifdef __GNUC__ -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VALF (__extension__ 0x1.0p255f) --- libc/sysdeps/m68k/bits/huge_val.h.jj Thu May 18 14:50:07 2000 +++ libc/sysdeps/m68k/bits/huge_val.h Sun May 21 06:23:09 2000 @@ -30,7 +30,7 @@ #ifdef __GNUC__ -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VAL (__extension__ 0x1.0p2047) @@ -56,7 +56,7 @@ static union { unsigned char __c[8]; dou #ifdef __USE_ISOC99 -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VALF (__extension__ 0x1.0p255f) # define HUGE_VALL (__extension__ 0x1.0p32767L) --- libc/sysdeps/sparc/sparc32/fpu/bits/huge_val.h.jj Thu May 18 14:50:19 2000 +++ libc/sysdeps/sparc/sparc32/fpu/bits/huge_val.h Sun May 21 06:23:09 2000 @@ -29,7 +29,7 @@ #ifdef __GNUC__ -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VAL (__extension__ 0x1.0p2047) @@ -58,7 +58,7 @@ static __huge_val_t __huge_val = { __HUG #ifdef __USE_ISOC99 -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VALF (__extension__ 0x1.0p255f) # if __WORDSIZE == 32 --- libc/sysdeps/sparc/sparc64/fpu/bits/huge_val.h.jj Thu May 18 14:50:21 2000 +++ libc/sysdeps/sparc/sparc64/fpu/bits/huge_val.h Sun May 21 06:23:09 2000 @@ -29,7 +29,7 @@ #ifdef __GNUC__ -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VAL (__extension__ 0x1.0p2047) @@ -58,7 +58,7 @@ static __huge_val_t __huge_val = { __HUG #ifdef __USE_ISOC99 -# if __GNUC_PREREQ(2,95) +# if __GNUC_PREREQ(2,96) # define HUGE_VALF (__extension__ 0x1.0p255f) # if __WORDSIZE == 32 Jakub From hjl@lucon.org Sat May 20 22:16:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Sat, 20 May 2000 22:16:00 -0000 Subject: Bugs in glibc 2.2 References: <20000520164618.A840@lucon.org> <20000521063407.V474@sunsite.ms.mff.cuni.cz> Message-ID: <20000520221616.A1857@lucon.org> On Sun, May 21, 2000 at 06:34:07AM +0200, Jakub Jelinek wrote: > > when 0 may be a valid fd for something else. There are other > > bugs I am trying to do down. For example, > > > > # man read > > > > no longer works. > > I'm working on a fix for this now if it is groff segfaulting. It seems like the groff bug. But I can be wrong. BTW, I put glibc 2.2 on RedHat 6.2. It doesn't work every well. I will try to fix the resolver bug. H.J. From hjl@lucon.org Sat May 20 22:29:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Sat, 20 May 2000 22:29:00 -0000 Subject: Bugs in glibc 2.2 References: <20000520164618.A840@lucon.org> Message-ID: <20000520222900.A1904@lucon.org> On Sat, May 20, 2000 at 04:46:18PM -0700, H . J . Lu wrote: > Hi, > > I am working on several bugs in glibc 2.2. I had an impression that > glibc 2.2 was very unstable. I was wondering how many people were > using glibc 2.2. To start, > > There are > > struct __res_state _res; > > and > > void > res_close(void) { > res_nclose(&_res); > } > > void > res_nclose(res_state statp) { > if (statp->_sock >= 0) { > (void) close(statp->_sock); > statp->_sock = -1; > statp->_flags &= ~(RES_F_VC | RES_F_CONN); > } > } > > since _res._sock is 0, close (0) is called. It is very bad > when 0 may be a valid fd for something else. There are other Here is the patch. H.J. --- 2000-05-20 2000 H.J. Lu * resolv/res_libc.c (_res): Initialize _sock to -1. Index: resolv/res_libc.c =================================================================== RCS file: /work/cvs/gnu/glibc/resolv/res_libc.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 res_libc.c --- resolv/res_libc.c 2000/04/29 18:47:48 1.1.1.1 +++ resolv/res_libc.c 2000/05/21 05:22:40 @@ -89,7 +89,7 @@ res_init(void) { #undef _res -struct __res_state _res; +struct __res_state _res = { _sock : -1 }; struct __res_state * From jakub@redhat.com Sun May 21 05:20:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 21 May 2000 05:20:00 -0000 Subject: [PATCH] Re: Bugs in glibc 2.2 References: <20000520164618.A840@lucon.org> <20000520222900.A1904@lucon.org> Message-ID: <20000521142536.X474@sunsite.ms.mff.cuni.cz> > 2000-05-20 2000 H.J. Lu > > * resolv/res_libc.c (_res): Initialize _sock to -1. > This is ok but not sufficient: 2000-05-21 Jakub Jelinek * manager.c (pthread_handle_create): Initialize p_res._sock to -1. --- libc/linuxthreads/manager.c.jj Tue May 9 13:47:36 2000 +++ libc/linuxthreads/manager.c Sun May 21 13:21:59 2000 @@ -395,6 +395,7 @@ static int pthread_handle_create(pthread new_thread->p_canceltype = PTHREAD_CANCEL_DEFERRED; new_thread->p_errnop = &new_thread->p_errno; new_thread->p_h_errnop = &new_thread->p_h_errno; + new_thread->p_res._sock = -1; new_thread->p_resp = &new_thread->p_res; new_thread->p_guardaddr = guardaddr; new_thread->p_guardsize = guardsize; Jakub From jakub@redhat.com Sun May 21 05:35:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 21 May 2000 05:35:00 -0000 Subject: [PATCH] libio fixes for glibc 2.1.90 Message-ID: <20000521144037.Y474@sunsite.ms.mff.cuni.cz> Hi! The following patch makes groff and a bunch of other programs work with glibc 2.1.90. The issue is that libstdc++'s libio declares its own stdin/stdout/stderr which lacks the _wide_data stuff and several pieces of glibc just trustfully dereference _wide_data member of _IO_FILE. IMHO even if libstdc++'s libio is changed so that for *-libc6.2-* libstdc++ (or always) puts the _wide_data stuff in, we need to maintain backward compatibility with older libstdc++'s. The following patch attempts to do so, by checking if _wide_data is non-NULL on entry to each routine which accesses _wide_data and it is not yet clear whether _wide_data is actually non-NULL (e.g. if a routine is always called from some wide jump table, _wide_data must be non-NULL, which means most routines should be safe). Besides this, I've changed _IO_setbuffer/_IO_setvbuf to call _IO_WSETBUF even for _mode 1. If there is some reason why it is called for _mode 0 only, then please let me know and revert those two hunks. man now works just fine with this. 2000-05-21 Jakub Jelinek * libio/libioP.h (_IO_CHECK_WIDE): Define. * libio/iosetbuffer.c (_IO_setbuffer): Use it. Call _IO_WSETBUF even for _mode 1. * libio/iosetvbuf.c (_IO_setvbuf): Likewise. * libio/wgenops.c (_IO_sputbackwc): If _IO_CHECK_WIDE fails, return WEOF. * libio/getwc.c (_IO_getwc): Likewise. * libio/putwc.c (putwc): Likewise. * libio/fputwc.c (fputwc): Likewise. * libio/getwc_u.c: Include wchar.h. (__getwc_unlocked): If _IO_CHECK_WIDE fails, return WEOF. * libio/fputwc_u.c (fputwc_unlocked): Check whether _IO_fwide really succeeded in setting to wide mode. * libio/fileops.c (_IO_new_file_fopen): Return NULL if _IO_CHECK_WIDE fails. * libio/iofwide.c (_IO_fwide): Don't change the mode if _IO_CHECK_WIDE fails. * libio/iogetwline (_IO_getwline_info): If _IO_CHECK_WIDE fails, return 0 and WEOF if eof != NULL. --- libc/libio/bits/stdio.h.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/bits/stdio.h Sun May 21 06:16:03 2000 @@ -1,5 +1,5 @@ /* Optimizing macros and inline functions for stdio functions. - Copyright (C) 198 Free Software Foundation, Inc. + Copyright (C) 1998 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as --- libc/libio/iosetbuffer.c.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/iosetbuffer.c Sun May 21 13:44:43 2000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 95, 96, 97, 98, 99 Free Software Foundation, Inc. +/* Copyright (C) 1993, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -38,7 +38,7 @@ _IO_setbuffer (fp, buf, size) if (!buf) size = 0; (void) _IO_SETBUF (fp, buf, size); - if (fp->_vtable_offset == 0 && fp->_mode == 0) + if (fp->_vtable_offset == 0 && fp->_mode >= 0 && ! _IO_CHECK_WIDE (fp)) /* We also have to set the buffer using the wide char function. */ (void) _IO_WSETBUF (fp, buf, size); _IO_funlockfile (fp); --- libc/libio/wgenops.c.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/wgenops.c Sun May 21 13:47:56 2000 @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 1995, 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1997, 1998, 1999, 2000 + Free Software Foundation, Inc. This file is part of the GNU IO Library. Written by Ulrich Drepper . Based on the single byte version by Per Bothner . @@ -607,6 +608,9 @@ _IO_sputbackwc (fp, c) { wint_t result; + if (_IO_CHECK_WIDE (fp)) + return WEOF; + if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base && (wchar_t)fp->_wide_data->_IO_read_ptr[-1] == (wchar_t) c) { --- libc/libio/iosetvbuf.c.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/iosetvbuf.c Sun May 21 13:45:35 2000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1993,1996,1997,1998,1999,2000 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -90,7 +90,8 @@ _IO_setvbuf (fp, buf, mode, size) goto unlock_return; } result = _IO_SETBUF (fp, buf, size) == NULL ? EOF : 0; - if (result == 0 && fp->_vtable_offset == 0 && fp->_mode == 0) + if (result == 0 && fp->_vtable_offset == 0 && fp->_mode >= 0 + && ! _IO_CHECK_WIDE (fp)) /* We also have to set the buffer using the wide char function. */ result = _IO_WSETBUF (fp, buf, size) == NULL ? EOF : 0; --- libc/libio/getwc.c.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/getwc.c Sun May 21 13:39:12 2000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 95, 96, 97, 98, 99 Free Software Foundation, Inc. +/* Copyright (C) 1993, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -34,6 +34,8 @@ _IO_getwc (fp) { wint_t result; CHECK_FILE (fp, WEOF); + if (_IO_CHECK_WIDE (fp)) + return WEOF; _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); result = _IO_getwc_unlocked (fp); --- libc/libio/fileops.c.jj Wed Mar 22 22:36:05 2000 +++ libc/libio/fileops.c Sun May 21 13:37:53 2000 @@ -278,9 +278,9 @@ _IO_new_file_fopen (fp, filename, mode, /* Yep. Load the appropriate conversions and set the orientation to wide. */ struct gconv_fcts fcts; - struct _IO_codecvt *cc = &fp->_wide_data->_codecvt; + struct _IO_codecvt *cc; - if (__wcsmbs_named_conv (&fcts, cs + 5) != 0) + if (_IO_CHECK_WIDE(fp) || __wcsmbs_named_conv (&fcts, cs + 5) != 0) { /* Something went wrong, we cannot load the conversion modules. This means we cannot proceed since the user explicitly asked @@ -288,6 +288,8 @@ _IO_new_file_fopen (fp, filename, mode, _IO_new_fclose (result); return NULL; } + + cc = &fp->_wide_data->_codecvt; /* The functions are always the same. */ *cc = __libio_codecvt; --- libc/libio/iofwide.c.jj Thu Apr 13 10:57:48 2000 +++ libc/libio/iofwide.c Sun May 21 13:40:13 2000 @@ -86,7 +86,7 @@ _IO_fwide (fp, mode) /* Normalize the value. */ mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1); - if (mode == 0 || fp->_mode != 0) + if (mode == 0 || fp->_mode != 0 || _IO_CHECK_WIDE (fp)) /* The caller simply wants to know about the current orientation or the orientation already has been determined. */ return fp->_mode; --- libc/libio/getwc_u.c.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/getwc_u.c Sun May 21 13:39:41 2000 @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1996, 1997, 1999, 2000 + Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -25,6 +26,7 @@ #include "libioP.h" #include "stdio.h" +#include #undef getwc_unlocked @@ -32,6 +34,8 @@ wint_t __getwc_unlocked (FILE *fp) { CHECK_FILE (fp, EOF); + if (_IO_CHECK_WIDE (fp)) + return WEOF; return _IO_getwc_unlocked (fp); } --- libc/libio/iogetwline.c.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/iogetwline.c Sun May 21 13:41:01 2000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -60,6 +60,12 @@ _IO_getwline_info (fp, buf, n, delim, ex wchar_t *ptr = buf; if (eof != NULL) *eof = 0; + if (_IO_CHECK_WIDE (fp)) + { + if (eof != NULL) + *eof = WEOF; + return 0; + } while (n != 0) { _IO_ssize_t len = (fp->_wide_data->_IO_read_end --- libc/libio/fputwc.c.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/fputwc.c Sun May 21 13:38:20 2000 @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000 + Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -33,6 +34,8 @@ fputwc (wc, fp) { int result; CHECK_FILE (fp, EOF); + if (_IO_CHECK_WIDE (fp)) + return WEOF; _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); if (_IO_fwide (fp, 1) < 0) --- libc/libio/fputwc_u.c.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/fputwc_u.c Sun May 21 13:38:37 2000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1996, 1997, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or @@ -34,7 +34,7 @@ fputwc_unlocked (wc, fp) _IO_FILE *fp; { CHECK_FILE (fp, EOF); - if (_IO_fwide (fp, 1) < 0) + if (_IO_fwide (fp, 1) != 1) return WEOF; return _IO_putwc_unlocked (wc, fp); } --- libc/libio/putwc.c.jj Tue Jan 4 17:11:50 2000 +++ libc/libio/putwc.c Sun May 21 13:46:33 2000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 95, 96, 97, 98, 99 Free Software Foundation, Inc. +/* Copyright (C) 1991, 95, 96, 97, 98, 99, 2000 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 @@ -26,6 +26,8 @@ putwc (wc, fp) { wint_t result; CHECK_FILE (fp, WEOF); + if (_IO_CHECK_WIDE (fp)) + return WEOF; _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); result = _IO_putwc_unlocked (wc, fp); --- libc/libio/libioP.h.jj Wed Mar 22 22:36:05 2000 +++ libc/libio/libioP.h Sun May 21 13:37:00 2000 @@ -71,6 +71,9 @@ extern "C" { #define _IO_JUMPS(THIS) ((struct _IO_FILE_plus *) (THIS))->vtable #define _IO_WIDE_JUMPS(THIS) ((struct _IO_FILE *) (THIS))->_wide_data->_wide_vtable + +#define _IO_CHECK_WIDE(THIS) (((struct _IO_FILE *) (THIS))->_wide_data == NULL) + #if _IO_JUMPS_OFFSET # define _IO_JUMPS_FUNC(THIS) \ (*(struct _IO_jump_t **) ((void *) &((struct _IO_FILE_plus *) (THIS))->vtable\ Jakub From jakub@redhat.com Sun May 21 05:39:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 21 May 2000 05:39:00 -0000 Subject: Bugs in glibc 2.2 References: <20000520164618.A840@lucon.org> <20000521063407.V474@sunsite.ms.mff.cuni.cz> <20000520221616.A1857@lucon.org> Message-ID: <20000521144441.Z474@sunsite.ms.mff.cuni.cz> On Sat, May 20, 2000 at 10:16:16PM -0700, H . J . Lu wrote: > On Sun, May 21, 2000 at 06:34:07AM +0200, Jakub Jelinek wrote: > > > when 0 may be a valid fd for something else. There are other > > > bugs I am trying to do down. For example, > > > > > > # man read > > > > > > no longer works. > > > > I'm working on a fix for this now if it is groff segfaulting. > > It seems like the groff bug. But I can be wrong. See my other mail. > BTW, I put > glibc 2.2 on RedHat 6.2. It doesn't work every well. I will > try to fix the resolver bug. What other issues do you see? I'm aware at the moment only about some rcmd issues and different resolver behaviour (need to investigate this still). Jakub From hjl@lucon.org Sun May 21 07:57:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Sun, 21 May 2000 07:57:00 -0000 Subject: Bugs in glibc 2.2 References: <20000520164618.A840@lucon.org> <20000521063407.V474@sunsite.ms.mff.cuni.cz> <20000520221616.A1857@lucon.org> <20000521144441.Z474@sunsite.ms.mff.cuni.cz> Message-ID: <20000521075726.A7606@lucon.org> On Sun, May 21, 2000 at 02:44:41PM +0200, Jakub Jelinek wrote: > > What other issues do you see? > I'm aware at the moment only about some rcmd issues and > different resolver behaviour (need to investigate this still). The dynamic linker is very strange. It failed the ELF visibility tests in the latest binutils where glibc 2.1 passes. I am looking into it now. H.J. From aj@suse.de Sun May 21 08:36:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Sun, 21 May 2000 08:36:00 -0000 Subject: [PATCH] Another huge_val.h fix References: <20000521064332.W474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: > Hi! > Sadly it turns out that eventhough gcc 2.95 handles hex floating constants > just fine (with __extension__ for -pedantic), g++ 2.95 does not, so everyone > now gets a fatal error including math.h in a C++ program. > Fortunately g++ 2.96 does (ObjC did already in 2.95), so IMHO we have three > choices: > - simply prereq 2.96 like done with this patch > - use # if __GNUC_PREREQ(2,96) || (__GNUC_PREREQ(2,95) && !defined(__cplusplus)) > - kill the hex floating consts bits from huge_val.h HUGE_VAL is required by some standards. IMO we can't just disable it for gcc <= 2.95, especially since 2.96 is not released yet. The only practical solution I see is to leave it the way it is and condem -pedantic. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Sun May 21 08:39:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Sun, 21 May 2000 08:39:00 -0000 Subject: [PATCH] fopencookie binary compatibility References: <20000518112440.C474@sunsite.ms.mff.cuni.cz> Message-ID: Hi Jakub, I'm commiting your patch now without the #ifdef weak as mentioned already. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Sun May 21 08:39:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Sun, 21 May 2000 08:39:00 -0000 Subject: [PATCH] Re: Bugs in glibc 2.2 References: <20000520164618.A840@lucon.org> <20000520222900.A1904@lucon.org> <20000521142536.X474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: >> 2000-05-20 2000 H.J. Lu >> >> * resolv/res_libc.c (_res): Initialize _sock to -1. >> Jakub> This is ok but not sufficient: Jakub> 2000-05-21 Jakub Jelinek Jakub> * manager.c (pthread_handle_create): Initialize p_res._sock to -1. I'm commiting HJ's and Jakub's patches for this problem now. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From jakub@redhat.com Sun May 21 11:57:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 21 May 2000 11:57:00 -0000 Subject: [PATCH] Another huge_val.h fix References: <20000521064332.W474@sunsite.ms.mff.cuni.cz> Message-ID: <20000521210303.A474@sunsite.ms.mff.cuni.cz> > > Fortunately g++ 2.96 does (ObjC did already in 2.95), so IMHO we have three > > choices: > > - simply prereq 2.96 like done with this patch > > - use # if __GNUC_PREREQ(2,96) || (__GNUC_PREREQ(2,95) && !defined(__cplusplus)) > > - kill the hex floating consts bits from huge_val.h > > HUGE_VAL is required by some standards. IMO we can't just disable it for > gcc <= 2.95, especially since 2.96 is not released yet. > > The only practical solution I see is to leave it the way it is and > condem -pedantic. #if __GNUC_PREREQ(2,96) does not disable it for gcc <= 2.95, see huge_val.h, it is just a nicer way of specifying that constant. For older gcc (to which by this patch is added gcc 2.95 due to g++), it uses the other definition, e.g.: #ifdef __GNUC__ # if __GNUC_PREREQ(2,96) # define HUGE_VAL (0x1.0p2047) # else # define HUGE_VAL \ (__extension__ \ ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ { __l: 0x7ff0000000000000ULL }).__d) # endif #else Lame definition for non-gcc compilers #endif Jakub From jakub@redhat.com Sun May 21 13:40:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 21 May 2000 13:40:00 -0000 Subject: [PATCH] Fix scsi/sg.h Message-ID: <20000521224548.C474@sunsite.ms.mff.cuni.cz> Hi! Minor bug fix. 2000-05-21 Jakub Jelinek * sysdeps/unix/sysv/linux/scsi/sg.h (sg_io_hdr_t): Remove duplicate dxfer_direction. --- libc/sysdeps/unix/sysv/linux/scsi/sg.h.jj Wed Mar 15 02:18:52 2000 +++ libc/sysdeps/unix/sysv/linux/scsi/sg.h Sun May 21 16:30:31 2000 @@ -46,7 +46,6 @@ typedef struct sg_io_hdr int dxfer_direction; /* [i] data transfer direction */ unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */ unsigned char mx_sb_len; /* [i] max length to write to sbp */ - int dxfer_direction; /* [i] data transfer direction */ unsigned short int iovec_count; /* [i] 0 implies no scatter gather */ unsigned int dxfer_len; /* [i] byte count of data transfer */ void * dxferp; /* [i], [*io] points to data transfer memory Jakub From drepper@redhat.com Sun May 21 13:59:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 21 May 2000 13:59:00 -0000 Subject: I'm back Message-ID: As some of you might have seen, I'm checking changes in the archive which means I'm back. Thanks for keeping the sources in good shape. It still compiles, even (again) with the mainline egcs. Last week I was at the POSIX/Unix standard group meeting. This provided the possibility to chat a bit about some future development. The main things of interest here are: - the pthread_spinlock_* functions were introduced by the SMP people in the .1c group. I.e., *not* by the RT guys. This means that an implementation which is not save of priority-inversion is explicitly wanted, not only allowed. Therefore I'll take Mark's proposal and change the implementation in LinuxThreads. - the getipnodeby*() functions are going away. Yeah, they had a short life. The reason is that they are useless. The user cannot fill in all the fields of the sockaddr_in6 struct even with these functions since neither sin6_flowinfo and (especially) sin6_scope are available. The getnameinfo() functions etc will be the only interface. The problem is that this is not yet in any official document. - The changes to use socklen_t in several of the socket-related interfaces are correct. The RFC 2553 will be superceded sometime soon by a new version which has these changes included. - I had to change the iconv() prototype. This follows a discussion we had in the Austin Group a long time ago (and for which Andreas J. filed a aardvark against the draft 3). Both, with and without const, was correct for the current version of the standard. The confusion got introduced by the header and the function definition having different signatures in old versions of the Unix standard. This is now changed. Loosing the const is not a real problem and it was more or less a coin-toss decision (in 1998!). - The next revision of Unix/POSIX will be aligned with ISO C99. I.e., all the new ISO C99 functionality will be in the standard as well as changes to align old code. This mainly means using restrict in function declarations but also has effects on some of the other parts (e.g., libm). This work is not yet finished but will be for the next draft. A consequence of this is that all POSIX systems will have the incompatibilities introduced by the ISO C99 changes. This includes the strtod() changes, `struct lconv' additions, and some other things. I'm sure there are a few more things but I cannot remember in the moment. In general I managed to get the changes through which would have prevented glibc/Linux from being Unix compliant. If you have the possibility look at the next draft (#4) when it becomes available. I'll announce it here. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Sun May 21 14:01:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 21 May 2000 14:01:00 -0000 Subject: [PATCH] Fix scsi/sg.h References: <20000521224548.C474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Minor bug fix. Thanks, I've added the patch. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Sun May 21 16:51:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 21 May 2000 16:51:00 -0000 Subject: mathinline problem References: Message-ID: Andreas Jaeger writes: > I get a segementation fault when running the testsuite. For example > I get for test-idouble -v3: That seems to be a bug in gcc. If you don't use -freorder-blocks you'll get two errors in the test suite (which is correct). -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@valinux.com Sun May 21 16:52:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Sun, 21 May 2000 16:52:00 -0000 Subject: Does make localedata/install-locales work? Message-ID: <20000521165245.A8297@valinux.com> With # make localedata/install-locales I got so many No definition for LC_PAPER category found No definition for LC_NAME category found No definition for LC_ADDRESS category found No definition for LC_TELEPHONE category found No definition for LC_MEASUREMENT category found No definition for LC_IDENTIFICATION category found and locales/uk_UA:2821: LC_COLLATE: syntax error locales/uk_UA:2822: LC_COLLATE: syntax error locales/uk_UA:2823: LC_COLLATE: syntax error locales/uk_UA:2824: LC_COLLATE: syntax error locales/uk_UA:2825: LC_COLLATE: syntax error locales/uk_UA:2826: LC_COLLATE: syntax error locales/uk_UA:2827: LC_COLLATE: syntax error locales/uk_UA:2828: LC_COLLATE: syntax error Has anyone tried it recently? H.J. -- H.J. Lu (hjl@gnu.org) From hjl@valinux.com Sun May 21 17:16:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Sun, 21 May 2000 17:16:00 -0000 Subject: A patch for STV_PROTECTED Message-ID: <20000521171657.A8394@valinux.com> This patch may not be 100% correct. But it passed all the visibility tests in today's binutils from CVS. -- H.J. Lu (hjl@gnu.org) -- 2000-05-21 2000 H.J. Lu * elf/do-lookup.h (do_lookup_protected_versioned): New. Used by the STV_PROTECTED support. (do_lookup_protected): Likewise. * elf/dl-lookup.c (_dl_lookup_symbol): Support STV_PROTECTED. (_dl_lookup_symbol_skip): Likewise. (_dl_lookup_versioned_symbol): Likewise. (_dl_lookup_versioned_symbol_skip): Likewise. * elf/dl-reloc.c (RESOLVE): Check STB_LOCAL instead of ST_VISIBILITY. * elf/dl-runtime.c (profile_fixup): Fix a typo in comment. Index: elf/dl-lookup.c =================================================================== RCS file: /work/cvs/gnu/glibc/elf/dl-lookup.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 dl-lookup.c --- elf/dl-lookup.c 2000/05/21 21:10:57 1.1.1.1 +++ elf/dl-lookup.c 2000/05/21 21:41:28 @@ -75,9 +75,19 @@ __libc_lock_define (extern, _dl_load_loc without versioning. gcc is not able to optimize a single function definition serving for both purposes so we define two functions. */ #define VERSIONED 0 +#define PROTECTED 0 #include "do-lookup.h" +#define VERSIONED 0 +#define PROTECTED 1 +#include "do-lookup.h" + +#define VERSIONED 1 +#define PROTECTED 0 +#include "do-lookup.h" + #define VERSIONED 1 +#define PROTECTED 1 #include "do-lookup.h" @@ -194,6 +204,7 @@ _dl_lookup_symbol (const char *undef_nam const unsigned long int hash = _dl_elf_hash (undef_name); struct sym_val current_value = { NULL, NULL }; struct r_scope_elem **scope; + int protected; ++_dl_num_relocations; @@ -232,6 +243,8 @@ _dl_lookup_symbol (const char *undef_nam return 0; } + protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) + == STV_PROTECTED; if (__builtin_expect (_dl_debug_bindings, 0)) _dl_debug_message (1, "binding file ", (reference_name && reference_name[0] @@ -239,10 +252,34 @@ _dl_lookup_symbol (const char *undef_nam : (_dl_argv[0] ?: "
")), " to ", current_value.m->l_name[0] ? current_value.m->l_name : _dl_argv[0], - ": symbol `", undef_name, "'\n", NULL); + ": ", protected ? "protected" : "normal", + " symbol `", undef_name, "'\n", NULL); + + if (__builtin_expect (protected == 0, 1)) + { + *ref = current_value.s; + return LOOKUP_VALUE (current_value.m); + } + else + { + /* It is very tricky. We need to figure out what value to + return for the protected symbol */ + struct sym_val protected_value = { NULL, NULL }; + + for (scope = symbol_scope; *scope; ++scope) + if (do_lookup_protected (undef_name, undef_map, hash, *ref, + &protected_value, *scope, 0, NULL, + reloc_type)) + break; - *ref = current_value.s; - return LOOKUP_VALUE (current_value.m); + if (protected_value.s == NULL || protected_value.m == undef_map) + { + *ref = current_value.s; + return LOOKUP_VALUE (current_value.m); + } + else + return LOOKUP_VALUE (undef_map); + } } @@ -263,6 +300,7 @@ _dl_lookup_symbol_skip (const char *unde struct sym_val current_value = { NULL, NULL }; struct r_scope_elem **scope; size_t i; + int protected; ++_dl_num_relocations; @@ -319,6 +357,8 @@ _dl_lookup_symbol_skip (const char *unde return 0; } + protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) + == STV_PROTECTED; if (__builtin_expect (_dl_debug_bindings, 0)) _dl_debug_message (1, "binding file ", (reference_name && reference_name[0] @@ -326,10 +366,38 @@ _dl_lookup_symbol_skip (const char *unde : (_dl_argv[0] ?: "
")), " to ", current_value.m->l_name[0] ? current_value.m->l_name : _dl_argv[0], - ": symbol `", undef_name, "' (skip)\n", NULL); + ": ", protected ? "protected" : "normal", + " symbol `", undef_name, "'\n", NULL); + + if (__builtin_expect (protected == 0, 1)) + { + *ref = current_value.s; + return LOOKUP_VALUE (current_value.m); + } + else + { + /* It is very tricky. We need to figure out what value to + return for the protected symbol */ + struct sym_val protected_value = { NULL, NULL }; + + if (i >= (*scope)->r_nlist + || !do_lookup_protected (undef_name, undef_map, hash, *ref, + &protected_value, *scope, i, + skip_map, 0)) + while (*++scope) + if (do_lookup_protected (undef_name, undef_map, hash, *ref, + &protected_value, *scope, 0, + skip_map, 0)) + break; - *ref = current_value.s; - return LOOKUP_VALUE (current_value.m); + if (protected_value.s == NULL || protected_value.m == undef_map) + { + *ref = current_value.s; + return LOOKUP_VALUE (current_value.m); + } + else + return LOOKUP_VALUE (undef_map); + } } @@ -350,6 +418,7 @@ _dl_lookup_versioned_symbol (const char const unsigned long int hash = _dl_elf_hash (undef_name); struct sym_val current_value = { NULL, NULL }; struct r_scope_elem **scope; + int protected; ++_dl_num_relocations; @@ -412,6 +481,8 @@ _dl_lookup_versioned_symbol (const char return 0; } + protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) + == STV_PROTECTED; if (__builtin_expect (_dl_debug_bindings, 0)) _dl_debug_message (1, "binding file ", (reference_name && reference_name[0] @@ -419,11 +490,36 @@ _dl_lookup_versioned_symbol (const char : (_dl_argv[0] ?: "
")), " to ", current_value.m->l_name[0] ? current_value.m->l_name : _dl_argv[0], - ": symbol `", undef_name, "' [", version->name, + ": ", protected ? "protected" : "normal", + " symbol `", undef_name, "' [", version->name, "]\n", NULL); + + if (__builtin_expect (protected == 0, 1)) + { + *ref = current_value.s; + return LOOKUP_VALUE (current_value.m); + } + else + { + /* It is very tricky. We need to figure out what value to + return for the protected symbol */ + struct sym_val protected_value = { NULL, NULL }; + + for (scope = symbol_scope; *scope; ++scope) + if (do_lookup_protected_versioned (undef_name, undef_map, hash, + *ref, &protected_value, + *scope, 0, version, NULL, + reloc_type)) + break; - *ref = current_value.s; - return LOOKUP_VALUE (current_value.m); + if (protected_value.s == NULL || protected_value.m == undef_map) + { + *ref = current_value.s; + return LOOKUP_VALUE (current_value.m); + } + else + return LOOKUP_VALUE (undef_map); + } } @@ -443,6 +539,7 @@ _dl_lookup_versioned_symbol_skip (const struct sym_val current_value = { NULL, NULL }; struct r_scope_elem **scope; size_t i; + int protected; ++_dl_num_relocations; @@ -512,19 +609,50 @@ _dl_lookup_versioned_symbol_skip (const return 0; } + protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) + == STV_PROTECTED; if (__builtin_expect (_dl_debug_bindings, 0)) _dl_debug_message (1, "binding file ", (reference_name && reference_name[0] ? reference_name : (_dl_argv[0] ?: "
")), - " to ", - current_value.m->l_name[0] + " to ", current_value.m->l_name[0] ? current_value.m->l_name : _dl_argv[0], - ": symbol `", undef_name, "' [", version->name, - "] (skip)\n", NULL); + ": ", protected ? "protected" : "normal", + " symbol `", undef_name, "' [", version->name, + "]\n", NULL); + + if (__builtin_expect (protected == 0, 1)) + { + *ref = current_value.s; + return LOOKUP_VALUE (current_value.m); + } + else + { + /* It is very tricky. We need to figure out what value to + return for the protected symbol */ + struct sym_val protected_value = { NULL, NULL }; + + if (i >= (*scope)->r_nlist + || !do_lookup_protected_versioned (undef_name, undef_map, + hash, *ref, + &protected_value, *scope, + i, version, skip_map, 0)) + while (*++scope) + if (do_lookup_protected_versioned (undef_name, undef_map, + hash, *ref, + &protected_value, *scope, + 0, version, skip_map, 0)) + break; - *ref = current_value.s; - return LOOKUP_VALUE (current_value.m); + if (protected_value.s == NULL || protected_value.m == undef_map) + { + *ref = current_value.s; + return LOOKUP_VALUE (current_value.m); + } + else + return LOOKUP_VALUE (undef_map); + } } Index: elf/dl-reloc.c =================================================================== RCS file: /work/cvs/gnu/glibc/elf/dl-reloc.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 dl-reloc.c --- elf/dl-reloc.c 2000/05/21 21:10:57 1.1.1.1 +++ elf/dl-reloc.c 2000/05/21 21:35:12 @@ -79,7 +79,7 @@ _dl_relocate_object (struct link_map *l, (flags))) \ : l) #define RESOLVE(ref, version, flags) \ - (__builtin_expect (ELFW(ST_VISIBILITY) ((*ref)->st_other), 0) == 0 \ + (ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL \ ? ((version) != NULL && (version)->hash != 0 \ ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, l, (ref), \ scope, (version), (flags)) \ Index: elf/dl-runtime.c =================================================================== RCS file: /work/cvs/gnu/glibc/elf/dl-runtime.c,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 dl-runtime.c --- elf/dl-runtime.c 2000/05/21 21:10:57 1.1.1.1 +++ elf/dl-runtime.c 2000/05/21 21:36:44 @@ -158,7 +158,7 @@ profile_fixup ( /* Sanity check that we're really looking at a PLT relocation. */ assert (ELFW(R_TYPE)(reloc->r_info) == ELF_MACHINE_JMP_SLOT); - /* Look up the target symbol. If the symbol is marked STV_PROTEXTED + /* Look up the target symbol. If the symbol is marked STV_PROTECTED don't look in the global scope. */ if (__builtin_expect (ELFW(ST_VISIBILITY) (sym->st_other), 0) == 0) { Index: elf/do-lookup.h =================================================================== RCS file: /work/cvs/gnu/glibc/elf/do-lookup.h,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 do-lookup.h --- elf/do-lookup.h 2000/05/21 21:10:58 1.1.1.1 +++ elf/do-lookup.h 2000/05/21 21:26:35 @@ -18,10 +18,18 @@ Boston, MA 02111-1307, USA. */ #if VERSIONED -# define FCT do_lookup_versioned +# if PROTECTED +# define FCT do_lookup_protected_versioned +# else +# define FCT do_lookup_versioned +# endif # define ARG const struct r_found_version *const version, #else -# define FCT do_lookup +# if PROTECTED +# define FCT do_lookup_protected +# else +# define FCT do_lookup +# endif # define ARG #endif @@ -56,10 +64,12 @@ FCT (const char *undef_name, struct link if (skip != NULL && map == skip) continue; +#if !PROTECTED /* Don't search the executable when resolving a copy reloc. */ if (elf_machine_lookup_noexec_p (reloc_type) && map->l_type == lt_executable) continue; +#endif /* Print some debugging info if wanted. */ if (_dl_debug_symbols) @@ -80,8 +90,13 @@ FCT (const char *undef_name, struct link sym = &symtab[symidx]; if (sym->st_value == 0 || /* No value. */ +#if PROTECTED + sym->st_shndx == SHN_UNDEF +#else (elf_machine_lookup_noplt_p (reloc_type) /* Reject PLT entry. */ - && sym->st_shndx == SHN_UNDEF)) + && sym->st_shndx == SHN_UNDEF) +#endif + ) continue; if (ELFW(ST_TYPE) (sym->st_info) > STT_FUNC) @@ -154,12 +169,7 @@ FCT (const char *undef_name, struct link sym = num_versions == 1 ? versioned_sym : NULL; #endif - if (sym != NULL - /* Don't allow binding if the symbol is hidden. When processor - specific definitions for STV_INTERNAL are defined we might - have to extend this conditional. */ - && (ELFW(ST_VISIBILITY) (sym->st_other) != STV_HIDDEN - || map == undef_map)) + if (sym != NULL) { found_it: switch (ELFW(ST_BIND) (sym->st_info)) @@ -199,4 +209,5 @@ FCT (const char *undef_name, struct link #undef FCT #undef ARG +#undef PROTECTED #undef VERSIONED From drepper@redhat.com Sun May 21 17:25:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 21 May 2000 17:25:00 -0000 Subject: Does make localedata/install-locales work? References: <20000521165245.A8297@valinux.com> Message-ID: "H . J . Lu" writes: > Has anyone tried it recently? All the localedata files are in the old format. Read the TODO list. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Sun May 21 17:29:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 21 May 2000 17:29:00 -0000 Subject: A patch for STV_PROTECTED References: <20000521171657.A8394@valinux.com> Message-ID: "H . J . Lu" writes: > This patch may not be 100% correct. But it passed all the visibility > tests in today's binutils from CVS. Why do you assume the binutils tests are correct? Send me a test case and I'll take a look. I have no time looking at the binutils test suite. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@valinux.com Sun May 21 17:43:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Sun, 21 May 2000 17:43:00 -0000 Subject: A patch for STV_PROTECTED References: <20000521171657.A8394@valinux.com> Message-ID: <20000521174334.A8645@valinux.com> On Sun, May 21, 2000 at 04:57:30PM -0700, Ulrich Drepper wrote: > "H . J . Lu" writes: > > > This patch may not be 100% correct. But it passed all the visibility > > tests in today's binutils from CVS. > > Why do you assume the binutils tests are correct? Send me a test case > and I'll take a look. I have no time looking at the binutils test > suite. > This is the first testcase. H.J. ---- #!/bin/sh # This is a shell archive (produced by GNU sharutils 4.2.1). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 2000-05-01 17:18 PDT by . # Source directory was `/home/hjl/bugs/gas/protected'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 58 -rw-r--r-- bar.c # 244 -rw-r--r-- foo.c # 124 -rw-r--r-- main.c # 712 -rw-r--r-- Makefile # save_IFS="${IFS}" IFS="${IFS}:" gettext_dir=FAILED locale_dir=FAILED first_param="$1" for dir in $PATH do if test "$gettext_dir" = FAILED && test -f $dir/gettext \ && ($dir/gettext --version >/dev/null 2>&1) then set `$dir/gettext --version 2>&1` if test "$3" = GNU then gettext_dir=$dir fi fi if test "$locale_dir" = FAILED && test -f $dir/shar \ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1) then locale_dir=`$dir/shar --print-text-domain-dir` fi done IFS="$save_IFS" if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED then echo=echo else TEXTDOMAINDIR=$locale_dir export TEXTDOMAINDIR TEXTDOMAIN=sharutils export TEXTDOMAIN echo="$gettext_dir/gettext -s" fi if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"' elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"' elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$2 "$8"' else shar_touch=: echo $echo 'WARNING: not restoring timestamps. Consider getting and' $echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch # if mkdir _sh21312; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' exit 1 fi # ============= bar.c ============== if test -f 'bar.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'bar.c' '(file already exists)' else $echo 'x -' extracting 'bar.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'bar.c' && void bar () { X printf ("Hello from bar.c: %p\n", bar); } SHAR_EOF (set 20 00 05 01 16 39 54 'bar.c'; eval "$shar_touch") && chmod 0644 'bar.c' || $echo 'restore of' 'bar.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'bar.c:' 'MD5 check failed' f0ddc307a39012f21670d47f36f60b06 bar.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'bar.c'`" test 58 -eq "$shar_count" || $echo 'bar.c:' 'original size' '58,' 'current size' "$shar_count!" fi fi # ============= foo.c ============== if test -f 'foo.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'foo.c' '(file already exists)' else $echo 'x -' extracting 'foo.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'foo.c' && static int called = 0; X void bar () { X called = 1; X printf ("Hello from foo.c: %p\n", bar); } X void * foo () { X void (*b) () = bar; X (*b) (); X if (!called) X { X printf ("Wrong function calld\n"); X abort (); X } X return b; } SHAR_EOF (set 20 00 05 01 16 57 41 'foo.c'; eval "$shar_touch") && chmod 0644 'foo.c' || $echo 'restore of' 'foo.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'foo.c:' 'MD5 check failed' 6755f30cd08d8e3e9966374be816b0e4 foo.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'foo.c'`" test 244 -eq "$shar_count" || $echo 'foo.c:' 'original size' '244,' 'current size' "$shar_count!" fi fi # ============= main.c ============== if test -f 'main.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'main.c' '(file already exists)' else $echo 'x -' extracting 'main.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'main.c' && #include X void * foo (); void bar (); X int main () { X bar (); X if (bar != foo ()) X abort (); X X return 0; } SHAR_EOF (set 20 00 05 01 16 39 20 'main.c'; eval "$shar_touch") && chmod 0644 'main.c' || $echo 'restore of' 'main.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'main.c:' 'MD5 check failed' 2c6acd8d5b43c31c3253598eb079a63f main.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'main.c'`" test 124 -eq "$shar_count" || $echo 'main.c:' 'original size' '124,' 'current size' "$shar_count!" fi fi # ============= Makefile ============== if test -f 'Makefile' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'Makefile' '(file already exists)' else $echo 'x -' extracting 'Makefile' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'Makefile' && CFLAGS=-O -B./ #LDFLAGS=-Wl,-Bsymbolic X PROGS= foo bar foobar X all: $(PROGS) X for f in $(PROGS); do echo "Running: $$f"; ./$$f; \ X if [ $$? != 0 ]; then echo Failed; fi; done X foo: libfoo.so main.c X $(CC) -o $@ $(CFLAGS) $^ -Wl,-rpath,. X foobar: libbar.so bar.c main.c X $(CC) -o $@ $(CFLAGS) $^ -Wl,-rpath,. X bar: libbar.so main.c X $(CC) -o $@ $(CFLAGS) $^ -Wl,-rpath,. X libfoo.so: foo.o X $(CC) -shared -o $@ $(CFLAGS) $^ X libbar.so: bar.o X $(CC) $(LDFLAGS) -shared -o $@ $(CFLAGS) $^ X libfoo.so: foo.o X foo.o: foo.c X $(CC) -c $^ X bar.o: bar.s X $(CC) -c $^ X bar.s: foo.c X $(CC) -S -o $@ -fPIC $(CFLAGS) $^ X echo ".protected bar" >> $@ X clean: X rm -f $(PROGS) *.so *.o *.s X X shar: X shar *.c Makefile > bug.shar SHAR_EOF (set 20 00 05 01 16 38 23 'Makefile'; eval "$shar_touch") && chmod 0644 'Makefile' || $echo 'restore of' 'Makefile' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'Makefile:' 'MD5 check failed' e817a28777472bb0c9fa1f1c28061386 Makefile SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'Makefile'`" test 712 -eq "$shar_count" || $echo 'Makefile:' 'original size' '712,' 'current size' "$shar_count!" fi fi rm -fr _sh21312 exit 0 From hjl@valinux.com Sun May 21 17:44:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Sun, 21 May 2000 17:44:00 -0000 Subject: A patch for STV_PROTECTED References: <20000521171657.A8394@valinux.com> Message-ID: <20000521174414.A8654@valinux.com> On Sun, May 21, 2000 at 04:57:30PM -0700, Ulrich Drepper wrote: > "H . J . Lu" writes: > > > This patch may not be 100% correct. But it passed all the visibility > > tests in today's binutils from CVS. > > Why do you assume the binutils tests are correct? Send me a test case > and I'll take a look. I have no time looking at the binutils test > suite. > This is the second testcase. H.J. --- #!/bin/sh # This is a shell archive (produced by GNU sharutils 4.2.1). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 2000-05-21 17:41 PDT by . # Source directory was `/home/hjl/bugs/gas/protected1'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 41 -rw-r--r-- bar.c # 83 -rw-r--r-- foo.c # 292 -rw-r--r-- main.c # 752 -rw-r--r-- Makefile # save_IFS="${IFS}" IFS="${IFS}:" gettext_dir=FAILED locale_dir=FAILED first_param="$1" for dir in $PATH do if test "$gettext_dir" = FAILED && test -f $dir/gettext \ && ($dir/gettext --version >/dev/null 2>&1) then set `$dir/gettext --version 2>&1` if test "$3" = GNU then gettext_dir=$dir fi fi if test "$locale_dir" = FAILED && test -f $dir/shar \ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1) then locale_dir=`$dir/shar --print-text-domain-dir` fi done IFS="$save_IFS" if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED then echo=echo else TEXTDOMAINDIR=$locale_dir export TEXTDOMAINDIR TEXTDOMAIN=sharutils export TEXTDOMAIN echo="$gettext_dir/gettext -s" fi if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"' elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"' elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then shar_touch='touch -am $3$4$5$6$2 "$8"' else shar_touch=: echo $echo 'WARNING: not restoring timestamps. Consider getting and' $echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch # if mkdir _sh08576; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' exit 1 fi # ============= bar.c ============== if test -f 'bar.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'bar.c' '(file already exists)' else $echo 'x -' extracting 'bar.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'bar.c' && const char *barxxx = "Hello from bar.c"; SHAR_EOF (set 20 00 05 19 14 55 08 'bar.c'; eval "$shar_touch") && chmod 0644 'bar.c' || $echo 'restore of' 'bar.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'bar.c:' 'MD5 check failed' 99220857605ca400feea0345d7362b1d bar.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'bar.c'`" test 41 -eq "$shar_count" || $echo 'bar.c:' 'original size' '41,' 'current size' "$shar_count!" fi fi # ============= foo.c ============== if test -f 'foo.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'foo.c' '(file already exists)' else $echo 'x -' extracting 'foo.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'foo.c' && const char *barxxx = "Hello from foo.c"; X const char * foo () { X return barxxx; } SHAR_EOF (set 20 00 05 19 14 53 51 'foo.c'; eval "$shar_touch") && chmod 0644 'foo.c' || $echo 'restore of' 'foo.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'foo.c:' 'MD5 check failed' 532d006c190a316a72de8b57b1046665 foo.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'foo.c'`" test 83 -eq "$shar_count" || $echo 'foo.c:' 'original size' '83,' 'current size' "$shar_count!" fi fi # ============= main.c ============== if test -f 'main.c' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'main.c' '(file already exists)' else $echo 'x -' extracting 'main.c' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'main.c' && #include #include X const char * foo (); const char * barxxx; X int main () { X printf ("bar: %p, %s\n", barxxx, barxxx); X printf ("foo (): %p, %s\n", foo (), foo ()); #ifdef FOOBAR X if (barxxx == foo ()) #else X if (barxxx != foo ()) #endif X abort (); X X return 0; } SHAR_EOF (set 20 00 05 19 17 37 24 'main.c'; eval "$shar_touch") && chmod 0644 'main.c' || $echo 'restore of' 'main.c' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'main.c:' 'MD5 check failed' 50e570d3a4243ffa51e919055dcdd6a2 main.c SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'main.c'`" test 292 -eq "$shar_count" || $echo 'main.c:' 'original size' '292,' 'current size' "$shar_count!" fi fi # ============= Makefile ============== if test -f 'Makefile' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'Makefile' '(file already exists)' else $echo 'x -' extracting 'Makefile' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'Makefile' && CFLAGS=-O -B./ PIC=-fPIC #LDFLAGS=-Wl,-Bsymbolic X PROGS= foo bar foobar X all: $(PROGS) X for f in $(PROGS); do echo "Running: $$f"; ./$$f; \ X if [ $$? != 0 ]; then echo Failed; fi; done X foo: libfoo.so main.c X $(CC) -o $@ $(CFLAGS) $^ -Wl,-rpath,. X foobar: libbar.so bar.c main.c X $(CC) -o $@ -DFOOBAR $(CFLAGS) $^ -Wl,-rpath,. X bar: libbar.so main.c X $(CC) -o $@ $(CFLAGS) $^ -Wl,-rpath,. X libfoo.so: foo.o X $(CC) -shared -o $@ $(CFLAGS) $^ X libbar.so: bar.o X $(CC) $(LDFLAGS) -shared -o $@ $(CFLAGS) $^ X libfoo.so: foo.o X foo.o: foo.c X $(CC) -c $^ $(PIC) $(CFLAGS) X bar.o: bar.s X $(CC) -c $^ X bar.s: foo.c X $(CC) -S -o $@ $(PIC) $(CFLAGS) $^ X echo ".protected barxxx" >> $@ X clean: X rm -f $(PROGS) *.so *.o *.s X X shar: X shar *.c Makefile > bug.shar SHAR_EOF (set 20 00 05 19 20 25 10 'Makefile'; eval "$shar_touch") && chmod 0644 'Makefile' || $echo 'restore of' 'Makefile' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'Makefile:' 'MD5 check failed' 1f142648e9dbd93eeda8e647d770e158 Makefile SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'Makefile'`" test 752 -eq "$shar_count" || $echo 'Makefile:' 'original size' '752,' 'current size' "$shar_count!" fi fi rm -fr _sh08576 exit 0 From hjl@valinux.com Sun May 21 17:46:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Sun, 21 May 2000 17:46:00 -0000 Subject: A patch for STV_PROTECTED References: <20000521171657.A8394@valinux.com> Message-ID: <20000521174601.B8654@valinux.com> On Sun, May 21, 2000 at 04:57:30PM -0700, Ulrich Drepper wrote: > "H . J . Lu" writes: > > > This patch may not be 100% correct. But it passed all the visibility > > tests in today's binutils from CVS. > > Why do you assume the binutils tests are correct? Send me a test case > and I'll take a look. I have no time looking at the binutils test > suite. > You may also need this patch against binutils in CVS to get it to work. I am waiting for feedbacks before I check it in. H.J. ----- 2000-05-20 H.J. Lu * elflink.h (elf_link_output_extsym): Clear the visibility field for symbols not defined locally. Thu Jan 13 13:29:40 2000 H.J. Lu * configure.in (AC_OUTPUT): Add ../binutils.spec. Index: bfd/elflink.h =================================================================== RCS file: /work/cvs/gnu/binutils/bfd/elflink.h,v retrieving revision 1.26 diff -u -p -r1.26 elflink.h --- bfd/elflink.h 2000/05/18 22:10:35 1.26 +++ bfd/elflink.h 2000/05/21 20:33:46 @@ -5089,6 +5089,11 @@ elf_link_output_extsym (h, data) sym.st_info = ELF_ST_INFO (bindtype, ELF_ST_TYPE (sym.st_info)); } + /* If a symbol is not defined locally, we clear the visibility + field. */ + if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) + sym.st_other &= ~ELF_ST_VISIBILITY(sym.st_other); + /* If this symbol should be put in the .dynsym section, then put it there now. We have already know the symbol index. We also fill in the entry in the .hash section. */ From drepper@redhat.com Sun May 21 18:05:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 21 May 2000 18:05:00 -0000 Subject: Problem with i386/i686/sysdep.h (includes patch) References: Message-ID: Andreas Jaeger writes: > I've removed the syscall_error declaration from sysdep.h. Why was it > needed at all? Did I miss anything or is this the right fix? I don't know why it was there but the patch is OK. I checked it in. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Mon May 22 00:10:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 22 May 2000 00:10:00 -0000 Subject: A patch for STV_PROTECTED References: <20000521171657.A8394@valinux.com> <20000521174601.B8654@valinux.com> Message-ID: "H . J . Lu" writes: > You may also need this patch against binutils in CVS to get it > to work. I am waiting for feedbacks before I check it in. A patch like this is necessary in any case. I would write it like this: /* If a symbol is not defined locally, we clear the visibility field. */ if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) sym.st_other ^= ELF_ST_VISIBILITY (sym.st_other); Saves an instructions or two. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Mon May 22 00:50:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 22 May 2000 00:50:00 -0000 Subject: [PATCH] Another huge_val.h fix References: <20000521064332.W474@sunsite.ms.mff.cuni.cz> <20000521210303.A474@sunsite.ms.mff.cuni.cz> Message-ID: >>>>> Jakub Jelinek writes: >> > Fortunately g++ 2.96 does (ObjC did already in 2.95), so IMHO we have three >> > choices: >> > - simply prereq 2.96 like done with this patch >> > - use # if __GNUC_PREREQ(2,96) || (__GNUC_PREREQ(2,95) && !defined(__cplusplus)) >> > - kill the hex floating consts bits from huge_val.h >> >> HUGE_VAL is required by some standards. IMO we can't just disable it for >> gcc <= 2.95, especially since 2.96 is not released yet. >> >> The only practical solution I see is to leave it the way it is and >> condem -pedantic. Jakub> #if __GNUC_PREREQ(2,96) Jakub> does not disable it for gcc <= 2.95, see huge_val.h, it is just a nicer way Jakub> of specifying that constant. Thanks Jakub, your patch looks fine. I didn't look at the patch and only read your explanation and misunderstood it :-(. Uli, Jakub's patch looks ok. I'd like to add it, is this ok? Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Mon May 22 02:01:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 22 May 2000 02:01:00 -0000 Subject: Patch for tst-iconv1.c Message-ID: The appended patch fixes this new compiler warning: tst-iconv1.c:37: warning: passing arg 2 of `iconv' from incompatible pointer type I've commited the patch already. Andreas 2000-05-22 Andreas Jaeger * iconv/tst-iconv1.c (main): Remove const from inbuf to follow change in iconv.h. ============================================================ Index: iconv/tst-iconv1.c --- iconv/tst-iconv1.c 2000/05/07 21:56:53 1.1 +++ iconv/tst-iconv1.c 2000/05/22 07:54:01 @@ -10,7 +10,7 @@ char utf8[5]; wchar_t ucs4[5]; iconv_t cd; - const char *inbuf; + char *inbuf; char *outbuf; size_t inbytes; size_t outbytes; -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From drepper@redhat.com Mon May 22 02:12:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 22 May 2000 02:12:00 -0000 Subject: [PATCH] Another huge_val.h fix References: <20000521064332.W474@sunsite.ms.mff.cuni.cz> <20000521210303.A474@sunsite.ms.mff.cuni.cz> Message-ID: Andreas Jaeger writes: > Uli, Jakub's patch looks ok. I'd like to add it, is this ok? OK. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From jakub@redhat.com Mon May 22 03:15:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 22 May 2000 03:15:00 -0000 Subject: [PATCH] Fix *scanf's character range Message-ID: <20000522122028.H474@sunsite.ms.mff.cuni.cz> Hi! This patch removes a bogus test which prevents e.g. %9[0-9] from working. Actually, I have no idea why the test was added there even if it was e.g. f - 1 or whatever, because if the test wants to guard against f[-2] being after the opening [, then this is already guaranteed. And at least if the *scanf character range is at least a little bit similar to shell patterns, then %[]-_] should match ], ^, _ characters and similarly with %[--/]. 2000-05-22 Jakub Jelinek * stdio-common/vfscanf.c (__vfscanf): Remove bogus check if '-' is not the second character in the range. * stdio-common/tstscanf.c (main): Add testcase for the above. (Reported by jik@kamens.brookline.ma.us). --- libc/stdio-common/vfscanf.c.jj Wed Mar 22 22:36:09 2000 +++ libc/stdio-common/vfscanf.c Mon May 22 11:18:55 2000 @@ -1657,9 +1657,8 @@ __vfscanf (FILE *s, const char *format, ++f; } - tw = (char *) f; while ((fc = *f++) != '\0' && fc != ']') - if (fc == '-' && *f != '\0' && *f != ']' && f - 2 != tw + if (fc == '-' && *f != '\0' && *f != ']' && (unsigned char) f[-2] <= (unsigned char) *f) { /* Add all characters from the one before the '-' --- libc/stdio-common/tstscanf.c.jj Tue Jan 4 17:11:53 2000 +++ libc/stdio-common/tstscanf.c Mon May 22 11:24:03 2000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 96, 97, 98, 99 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -34,6 +34,13 @@ main (int argc, char **argv) int result = 0; if (sscanf ("0", "%d", &x) != 1) + { + fputs ("test failed!\n", stdout); + result = 1; + } + + if (sscanf ("08905x", "%9[0-9]", buf) != 1 + || strcmp (buf, "08905") != 0) { fputs ("test failed!\n", stdout); result = 1; Jakub From jakub@redhat.com Mon May 22 05:49:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 22 May 2000 05:49:00 -0000 Subject: [PATCH] Fix *scanf's character range References: <20000522122028.H474@sunsite.ms.mff.cuni.cz> <200005221153.e4MBr8C17728@jik.kamens.brookline.ma.us> Message-ID: <20000522145439.J474@sunsite.ms.mff.cuni.cz> On Mon, May 22, 2000 at 07:53:08AM -0400, Jonathan Kamens wrote: > > Date: Mon, 22 May 2000 12:20:28 +0200 > > From: Jakub Jelinek > > > > Actually, I have no idea why the test was added there even if it was e.g. f > > - 1 or whatever, because if the test wants to guard against f[-2] being > > after the opening [, then this is already guaranteed. > > No, it isn't. When the "tw = (char *) f" executes, "f" points at the > first character after the opening '[', unless that character was ']' > or '-'. Therefore, "tw" points at the first character after the '[' > too. That means that the first time through the loop, "fc" is set to > that first character and "f" is pointing at the second character. > Therefore, "f - 2" points at the opening "[", which we most certainly > do not want. > > I believe that the fix which I submitted to bugzilla is correct and > yours is now -- the test you removed should not be removed, it should > just be changed from "f - 2" to "f - 1". > > I believe that your fix will cause the scanf format string "%10[--/]", > which should imply a character range from hyphen to slash, to behave > incorrectly. > > Mind you, I'm not certain about all of this, since the code is > somewhat complex and it is difficult to dream up good test cases for > it, but I've read over the code several times and I think I'm right. No, ']' and '-' after the opening '[' are handled separately before the loop: fc = *f; if (fc == ']' || fc == '-') { /* If ] or - appears before any char in the set, it is not the terminator or separator, but the first char in the set. */ wp[fc] = 1; ++f; } so even if fc is '-' in the first while cycle (e.g. for [--/]), then it will be the second -, fc will be '-', f will point to "/]" and f-2 will be "--/]". So I'm pretty sure f-2 never points to the opening '[' or before it in the while loop if fc == '-'. This programs works correctly with my patch btw: bash$ cat /tmp/v.c #include main() { char buf[10] = {}; int num; num = sscanf("-...-/X", "%9[--/]", buf); printf("num=%d, buf=\"%s\"\n", num, buf); } bash$ /tmp/v num=1, buf="-...-/" Jakub From jakub@redhat.com Mon May 22 06:07:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 22 May 2000 06:07:00 -0000 Subject: [PATCH] Fix rtld segfault in SUID/SGID binaries Message-ID: <20000522151312.K474@sunsite.ms.mff.cuni.cz> Hi! If a user runs a suid/sgid program with LD_LIBRARY_PATH set, so that all fields of it go away because they are insecure, open_path segfaults because it does not expect the path list to be empty. We can either fix open_path to use a while () {} loop instead of do {} while (), or make sure env_path_list is killed if it has 0 list. I don't think RPATH/RUNPATH can have 0 elements, so IMHO it is better not to slow down things for all 3 cases but only for LD_LIBRARY_PATH. 2000-05-22 Jakub Jelinek * elf/dl-load.c (_dl_init_paths): If env_path_list has 0 elements, free it and set to (void *) -1. --- libc/elf/dl-load.c.jj Tue May 9 13:47:25 2000 +++ libc/elf/dl-load.c Mon May 22 14:43:19 2000 @@ -636,6 +636,11 @@ _dl_init_paths (const char *llp) (void) fillin_rpath (local_strdup (llp), env_path_list, ":;", __libc_enable_secure, "LD_LIBRARY_PATH", NULL); + if (env_path_list[0] == NULL) + { + free (env_path_list); + env_path_list = (void *) -1; + } } else env_path_list = (void *) -1; Jakub From jakub@redhat.com Mon May 22 07:45:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 22 May 2000 07:45:00 -0000 Subject: [PATCH] Fix i386 bits/mathinline.h with -ansi -pedantic Message-ID: <20000522165035.T474@sunsite.ms.mff.cuni.cz> Hi! Without this, programs including math.h compiled with -ansi -pedantic don't compile (?: with omitted middle part gives a warning, while the latter construct results in error). 2000-05-22 Jakub Jelinek * sysdeps/i386/fpu/bits/mathinline.h (__expm1_code): Avoid using ?: with omitted middle operand. (__sgn1l): Add __extension__. --- libc/sysdeps/i386/fpu/bits/mathinline.h.jj Tue May 9 13:48:18 2000 +++ libc/sysdeps/i386/fpu/bits/mathinline.h Mon May 22 16:28:00 2000 @@ -367,7 +367,8 @@ __sincosl (long double __x, long double ("fscale # 2^int(x * log2(e))\n\t" \ : "=t" (__temp) : "0" (1.0), "u" (__exponent)); \ __temp -= 1.0; \ - return __temp + __value ?: __x + __temp += __value; \ + return __temp ? __temp : __x __inline_mathcodeNP_ (long double, __expm1l, __x, __expm1_code) @@ -498,7 +499,8 @@ __inline_mathcodeNP (asin, __x, return _ __inline_mathcodeNP (acos, __x, return __atan2l (__sqrtl (1.0 - __x * __x), __x)) __inline_mathcode_ (long double, __sgn1l, __x, \ - union { long double __xld; unsigned int __xi[3]; } __n = { __xld: __x }; \ + __extension__ \ + union { long double __xld; unsigned int __xi[3]; } __n = { __xld: __x }; \ __n.__xi[2] = (__n.__xi[2] & 0x8000) | 0x3fff; \ __n.__xi[1] = 0x80000000; \ __n.__xi[0] = 0; \ Jakub From drepper@redhat.com Mon May 22 08:02:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 22 May 2000 08:02:00 -0000 Subject: [PATCH] Fix i386 bits/mathinline.h with -ansi -pedantic References: <20000522165035.T474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > +++ libc/sysdeps/i386/fpu/bits/mathinline.h Mon May 22 16:28:00 2000 > @@ -367,7 +367,8 @@ __sincosl (long double __x, long double > ("fscale # 2^int(x * log2(e))\n\t" \ > : "=t" (__temp) : "0" (1.0), "u" (__exponent)); \ > __temp -= 1.0; \ > - return __temp + __value ?: __x > + __temp += __value; \ > + return __temp ? __temp : __x > __inline_mathcodeNP_ (long double, __expm1l, __x, __expm1_code) Your change is not preserving the semantics. Once you corrected this make sure the generated code is the same. There is no reason at all to make the generated worse code. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Mon May 22 09:35:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 22 May 2000 09:35:00 -0000 Subject: A patch for STV_PROTECTED References: <20000521171657.A8394@valinux.com> Message-ID: "H . J . Lu" writes: > This patch may not be 100% correct. But it passed all the visibility > tests in today's binutils from CVS. I'm still not sure whether this patch is correct. Still I've checked in a modified version of this patch. I'll have to think more about it and, especially, add lots of test cases to the test suite. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Mon May 22 09:42:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 22 May 2000 09:42:00 -0000 Subject: [PATCH] Fix *scanf's character range References: <20000522122028.H474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > This patch removes a bogus test which prevents e.g. %9[0-9] from working. Thanks, I've applied the patch. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Mon May 22 09:46:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 22 May 2000 09:46:00 -0000 Subject: [PATCH] Fix rtld segfault in SUID/SGID binaries References: <20000522151312.K474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > 2000-05-22 Jakub Jelinek > > * elf/dl-load.c (_dl_init_paths): If env_path_list has 0 elements, > free it and set to (void *) -1. I've checked in this patch. Thanks, -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@valinux.com Mon May 22 09:53:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Mon, 22 May 2000 09:53:00 -0000 Subject: A patch for STV_PROTECTED References: <20000521171657.A8394@valinux.com> Message-ID: <20000522095250.C23948@valinux.com> On Mon, May 22, 2000 at 09:03:04AM -0700, Ulrich Drepper wrote: > "H . J . Lu" writes: > > > This patch may not be 100% correct. But it passed all the visibility > > tests in today's binutils from CVS. > > I'm still not sure whether this patch is correct. Still I've checked > in a modified version of this patch. I'll have to think more about it > and, especially, add lots of test cases to the test suite. > Yes, we need lots of test cases. I will try to add more test cases into binutils also. -- H.J. Lu (hjl@gnu.org) From jakub@redhat.com Mon May 22 10:08:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 22 May 2000 10:08:00 -0000 Subject: [PATCH] Fix i386 bits/mathinline.h with -ansi -pedantic References: <20000522165035.T474@sunsite.ms.mff.cuni.cz> Message-ID: <20000522191325.W474@sunsite.ms.mff.cuni.cz> On Mon, May 22, 2000 at 07:30:14AM -0700, Ulrich Drepper wrote: > Jakub Jelinek writes: > > > +++ libc/sysdeps/i386/fpu/bits/mathinline.h Mon May 22 16:28:00 2000 > > @@ -367,7 +367,8 @@ __sincosl (long double __x, long double > > ("fscale # 2^int(x * log2(e))\n\t" \ > > : "=t" (__temp) : "0" (1.0), "u" (__exponent)); \ > > __temp -= 1.0; \ > > - return __temp + __value ?: __x > > + __temp += __value; \ > > + return __temp ? __temp : __x > > __inline_mathcodeNP_ (long double, __expm1l, __x, __expm1_code) > > Your change is not preserving the semantics. Once you corrected this > make sure the generated code is the same. There is no reason at all > to make the generated worse code. How does it change semantics? #include long double a, b, c; void foo(void) { a = __expm1l(b); } generates identical output with -O2 with unpatched and patched bits/mathinline.h (and similarly with -O2 -ansi -pedantic, though the output is different from plain -O2). Jakub From aj@suse.de Mon May 22 10:16:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 22 May 2000 10:16:00 -0000 Subject: Testcases for %a Message-ID: The problem I reported with mathinline seems to be a bug in printf. Looking into this I noticed that we don't test %a anywhere. Here're two small testcases - now the testsuite fails in tfformat with gcc 2.95.2 for me (2.96 CVS current is fine). Ulrich, is it ok to commit this? Andreas 2000-05-22 Andreas Jaeger * stdio-common/tfformat.c (sprint_doubles): Add testcase for %a. ============================================================ Index: stdio-common/tfformat.c --- stdio-common/tfformat.c 1997/08/04 14:22:43 1.4 +++ stdio-common/tfformat.c 2000/05/22 17:13:58 @@ -4009,6 +4009,8 @@ {__LINE__, 11.25, "11.2", "%.1f"}, {__LINE__, 1.75, "1.8", "%.1f"}, {__LINE__, 11.75, "11.8", "%.1f"}, + {__LINE__, 16, "0x1.0p+4", "%.1a"}, + {__LINE__, 16, "0x1.00000000000000000000p+4", "%.20a"}, {0 } -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Mon May 22 11:47:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 22 May 2000 11:47:00 -0000 Subject: Updated mathinline.h patch Message-ID: Here's an updated patch for -ffast-math and mathinline.h. I'd like to test all inline functions. We could either add -ffast-math or -D__FAST_MATH__ for the inline test files. I've tried first -ffast-math and seemed to got an endless loop with the long double functions and therefore added __FAST_MATH__ to enable all functions. glibc passes the testsuite with gcc 2.96 CVS current on i686. I was also successful with gcc 2.95.2. The testsuite passed - but if you run the tests with -v3, you get the segmentation fault I reported today in printf. Jakub, could you add some #ifdef __FAST_MATH__ to the sparc mathinline files, please? It seems that the sqrt functions need it. Uli, is it ok to install this? Andreas 2000-05-22 Andreas Jaeger * math/Makefile: Add -D__FAST_MATH__ to CFLAGS-test-ifloat.c, CFLAGS-test-idouble.c, CFLAGS-test-ildoubl.c. * manual/math.texi (FP Function Optimizations): Document gcc -ffast-math behaviour with mathinlines. * sysdeps/i386/fpu/bits/mathinline.h: Only use save inline functions unless -ffast-math is given to gcc. ============================================================ Index: manual/math.texi --- manual/math.texi 2000/04/24 01:36:42 1.60 +++ manual/math.texi 2000/05/22 18:18:17 @@ -1770,9 +1770,11 @@ can increase the speed of generated code significantly. The drawback is that code size will increase, and the increase is not always negligible. -The speed increase has one drawback: the inline functions might not set -@code{errno} and might not have the same precission as the library -functions. +There are two kind of inline functions: Those that give the same result +as the library functions and others that might not set @code{errno} and +might have a reduced precision and/or argument range in comparison with +the library functions. The latter inline functions are only available +if the flag @code{-ffast-math} is given to GNU CC. In cases where the inline functions and macros are not wanted the symbol @code{__NO_MATH_INLINES} should be defined before any system header is ============================================================ Index: sysdeps/i386/fpu/bits/mathinline.h --- sysdeps/i386/fpu/bits/mathinline.h 2000/05/06 07:46:06 1.39 +++ sysdeps/i386/fpu/bits/mathinline.h 2000/05/22 18:18:18 @@ -281,6 +281,8 @@ __inline_mathcode (__sgn, __x, \ return __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0)) +/* __FAST_MATH__ is defined by gcc -ffast-math. */ +#ifdef __FAST_MATH__ __inline_mathcode (__pow2, __x, \ register long double __value; \ register long double __exponent; \ @@ -474,6 +476,7 @@ __inline_mathopNP (sqrt, "fsqrt") __inline_mathopNP_ (long double, __sqrtl, "fsqrt") +#endif /* __FAST_MATH__ */ #if __GNUC_PREREQ (2, 8) __inline_mathcodeNP_ (double, fabs, __x, return __builtin_fabs (__x)) @@ -485,6 +488,7 @@ __inline_mathop_ (long double, __fabsl, "fabs") #endif +#ifdef __FAST_MATH__ /* The argument range of this inline version is reduced. */ __inline_mathopNP (sin, "fsin") /* The argument range of this inline version is reduced. */ @@ -517,6 +521,7 @@ __inline_mathcodeNP (tanh, __x, \ register long double __exm1 = __expm1l (-__fabsl (__x + __x)); \ return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x)) +#endif /* __FAST_MATH__ */ __inline_mathcodeNP (floor, __x, \ @@ -558,6 +563,7 @@ /* Optimized versions for some non-standardized functions. */ #if defined __USE_ISOC99 || defined __USE_MISC +#ifdef __FAST_MATH__ __inline_mathcodeNP (expm1, __x, __expm1_code) /* We cannot rely on M_SQRT being defined. So we do it for ourself @@ -601,6 +607,7 @@ : "=t" (__junk), "=u" (__value) : "0" (__x)); \ return __value) +#endif /* __FAST_MATH__ */ #endif #ifdef __USE_ISOC99 @@ -711,10 +718,12 @@ #endif /* __USE_MISC */ /* Undefine some of the large macros which are not used anymore. */ -#undef __expm1_code -#undef __exp_code -#undef __atan2_code -#undef __sincos_code +#ifdef __FAST_MATH__ +# undef __expm1_code +# undef __exp_code +# undef __atan2_code +# undef __sincos_code +#endif /* __FAST_MATH__ */ #endif /* __NO_MATH_INLINES */ ============================================================ Index: math/Makefile --- math/Makefile 2000/05/02 13:52:36 1.95 +++ math/Makefile 2000/05/22 18:18:18 @@ -116,9 +116,9 @@ CFLAGS-test-float.c = -fno-inline -ffloat-store CFLAGS-test-double.c = -fno-inline -ffloat-store CFLAGS-test-ldouble.c = -fno-inline -ffloat-store -CFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES -CFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES -CFLAGS-test-ildoubl.c = -U__LIBC_INTERNAL_MATH_INLINES +CFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ +CFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ +CFLAGS-test-ildoubl.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ LDLIBS-test-ifloat = math/libm LDLIBS-test-idouble = math/libm LDLIBS-test-ildoubl = math/libm -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From drepper@redhat.com Mon May 22 13:24:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 22 May 2000 13:24:00 -0000 Subject: [PATCH] Fix i386 bits/mathinline.h with -ansi -pedantic References: <20000522165035.T474@sunsite.ms.mff.cuni.cz> <20000522191325.W474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > How does it change semantics? My fault, ignore it. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@valinux.com Mon May 22 16:39:00 2000 From: hjl@valinux.com (H . J . Lu) Date: Mon, 22 May 2000 16:39:00 -0000 Subject: A glibc 2.1 patch for STB_LOCAL Message-ID: <20000522163849.A517@valinux.com> I sent in a binutils patch to implement undefined symbols with non-default visibility attributes. As the result, there may be entries in dynamic relocation record for local symbols. glibc 2.2 has no problems. Glibc 2.1 needs the following patch to work. BTW, I don't think gcc is using undefined symbols with non-default visibility attributes. It only uses defined symbols with non-default visibility attributes. -- H.J. Lu (hjl@gnu.org) --- 2000-05-22 H.J. Lu * elf/dl-reloc.c (RESOLVE): Short circuit STB_LOCAL. Index: elf/dl-reloc.c =================================================================== RCS file: /work/cvs/gnu/glibc-2.1/elf/dl-reloc.c,v retrieving revision 1.1.1.16 diff -u -p -r1.1.1.16 dl-reloc.c --- elf/dl-reloc.c 2000/01/12 16:45:39 1.1.1.16 +++ elf/dl-reloc.c 2000/05/22 23:16:34 @@ -71,11 +71,13 @@ _dl_relocate_object (struct link_map *l, /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */ #define RESOLVE(ref, version, flags) \ - ((version) != NULL && (version)->hash != 0 \ - ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, (ref), scope, \ - l->l_name, (version), (flags)) \ - : _dl_lookup_symbol (strtab + (*ref)->st_name, (ref), scope, \ - l->l_name, (flags))) + (ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL \ + ? ((version) != NULL && (version)->hash != 0 \ + ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, (ref), \ + scope, l->l_name, (version), (flags)) \ + : _dl_lookup_symbol (strtab + (*ref)->st_name, (ref), scope, \ + l->l_name, (flags))) \ + : l->l_addr) #include "dynamic-link.h" ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling); From aj@suse.de Tue May 23 01:10:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Tue, 23 May 2000 01:10:00 -0000 Subject: K&R Cleanup patch Message-ID: FYI: I'm going to commit the following patch later today. Andreas 2000-05-23 Andreas Jaeger * csu/munch-tmpl.c (__libc_init): Remove K&R support. * dirent/scandir64.c: Likewise. * pwd/getpw.c: Likewise. * stdlib/bsearch.c (bsearch): Likewise. * stdlib/tst-strtoll.c: Likewise. * localedata/collate-test.c: Likewise. * localedata/xfrm-test.c: Likewise. * posix/bsd-getpgrp.c: Likewise. * sysdeps/alpha/fpu/bits/fenv.h: Likewise. * sysdeps/generic/bits/siginfo.h: Likewise. * sysdeps/generic/bits/sockaddr.h: Likewise. * sysdeps/generic/sys/swap.h: Likewise. * sysdeps/generic/sys/sysinfo.h: Likewise. * sysdeps/generic/vfork.c: Likewise. * sysdeps/m68k/fpu/switch/68881-sw.h: Likewise. * sysdeps/mach/hurd/fdopen.c: Likewise. * sysdeps/unix/sysv/linux/alpha/sys/acct.h: Likewise. * sysdeps/unix/sysv/linux/poll.c: Likewise. * sysdeps/unix/sysv/linux/readv.c: Likewise. * sysdeps/unix/sysv/linux/writev.c: Likewise. * sysdeps/unix/sysv/linux/i386/setgroups.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/sigaction.h: Likewise. * misc/tst-dirname.c: Remove K&R support, use ANSI C prototypes. * shadow/lckpwdf.c: Likewise. * stdlib/tst-strtol.c: Likewise. * sysdeps/generic/tcsetattr.c: Likewise. * sysdeps/unix/sysv/linux/ttyname.c: Likewise. * sysdeps/unix/sysv/linux/ttyname_r.c: Likewise. ============================================================ Index: csu/munch-tmpl.c --- csu/munch-tmpl.c 1998/05/08 20:39:40 1.1 +++ csu/munch-tmpl.c 2000/05/23 07:41:07 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1995, 1997, 2000 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 @@ -30,7 +30,7 @@ { /* These functions are defined in crti.o to run the .init and .fini sections, which are used for initializers and finalizers. */ - extern void _init __P ((void)), _fini __P ((void)); + extern void _init (void), _fini (void); atexit (&_fini); /* Arrange for _fini to run at exit. */ _init (); } ============================================================ Index: dirent/scandir64.c --- dirent/scandir64.c 1998/07/16 10:28:49 1.2 +++ dirent/scandir64.c 2000/05/23 07:41:07 @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. +/* Copyright (C) 1992,93,94,95,96,97,98,2000 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 @@ -25,8 +25,8 @@ scandir64 (dir, namelist, select, cmp) const char *dir; struct dirent64 ***namelist; - int (*select) __P ((const struct dirent64 *)); - int (*cmp) __P ((const void *, const void *)); + int (*select) (const struct dirent64 *); + int (*cmp) (const void *, const void *); { DIR *dp = __opendir (dir); struct dirent64 **v = NULL; ============================================================ Index: pwd/getpw.c --- pwd/getpw.c 1999/06/30 17:11:04 1.12 +++ pwd/getpw.c 2000/05/23 07:41:07 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1996, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,96,98,99,2000 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 @@ -27,7 +27,7 @@ in the given buffer. This knows the format that the caller will expect, but this need not be the format of the password file. */ -int __getpw __P ((__uid_t uid, char *buf)); +int __getpw (__uid_t uid, char *buf); int __getpw (uid, buf) ============================================================ Index: stdlib/bsearch.c --- stdlib/bsearch.c 1997/02/10 03:18:45 1.4 +++ stdlib/bsearch.c 2000/05/23 07:41:07 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1997, 2000 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 @@ -23,7 +23,7 @@ of SIZE bytes each. The comparisons are done by (*COMPAR)(). */ void * bsearch (const void *key, const void *base, size_t nmemb, size_t size, - int (*compar) __P ((const void *, const void *))) + int (*compar) (const void *, const void *)) { size_t l, u, idx; const void *p; ============================================================ Index: stdlib/tst-strtoll.c --- stdlib/tst-strtoll.c 1999/06/21 13:35:52 1.2 +++ stdlib/tst-strtoll.c 2000/05/23 07:41:07 @@ -80,10 +80,11 @@ {NULL, 0, 0, 0, 0}, }; -static void expand __P ((char *dst, int c)); +/* Prototypes for local functions. */ +static void expand (char *dst, int c); int -main (int argc, char ** argv) +main (void) { register const struct ltest *lt; char *ep; ============================================================ Index: stdlib/tst-strtol.c --- stdlib/tst-strtol.c 1998/09/20 18:10:03 1.17 +++ stdlib/tst-strtol.c 2000/05/23 07:41:07 @@ -92,10 +92,11 @@ {NULL, 0, 0, 0, 0}, }; -static void expand __P ((char *dst, int c)); +/* Prototypes for local functions. */ +static void expand (char *dst, int c); int -main (int argc, char ** argv) +main (void) { register const struct ltest *lt; char *ep; ============================================================ Index: localedata/collate-test.c --- localedata/collate-test.c 1999/12/26 09:06:56 1.2 +++ localedata/collate-test.c 2000/05/23 07:41:07 @@ -1,5 +1,5 @@ /* Test collation function using real data. - Copyright (C) 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -31,7 +31,7 @@ const char *line; }; -static int xstrcoll __P ((const void *, const void *)); +static int xstrcoll (const void *, const void *); int main (int argc, char *argv[]) ============================================================ Index: localedata/xfrm-test.c --- localedata/xfrm-test.c 1998/02/13 17:42:44 1.2 +++ localedata/xfrm-test.c 2000/05/23 07:41:07 @@ -1,5 +1,5 @@ /* Test collation function via transformation using real data. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -31,7 +31,7 @@ const char *line; }; -static int xstrcmp __P ((const void *, const void *)); +static int xstrcmp (const void *, const void *); int main (int argc, char *argv[]) ============================================================ Index: posix/bsd-getpgrp.c --- posix/bsd-getpgrp.c 1997/03/16 18:21:26 1.1 +++ posix/bsd-getpgrp.c 2000/05/23 07:41:07 @@ -1,5 +1,5 @@ /* BSD-compatible versions of getpgrp function. - Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. + Copyright (C) 1991, 92, 94, 95, 96, 97, 2000 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 @@ -21,7 +21,7 @@ /* Don't include unistd.h because it declares a conflicting prototype for the POSIX.1 `getpgrp' function. */ -extern pid_t __getpgid __P ((pid_t)); +extern pid_t __getpgid (pid_t); pid_t __bsd_getpgrp (pid_t pid) ============================================================ Index: sysdeps/alpha/fpu/bits/fenv.h --- sysdeps/alpha/fpu/bits/fenv.h 1999/05/23 10:11:27 1.4 +++ sysdeps/alpha/fpu/bits/fenv.h 2000/05/23 07:41:08 @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 1999, 2000 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 @@ -99,5 +99,5 @@ #endif /* The system calls to talk to the kernel's FP code. */ -extern unsigned long int __ieee_get_fp_control __P ((void)); -extern void __ieee_set_fp_control __P ((unsigned long int __value)); +extern unsigned long int __ieee_get_fp_control (void) __THROW; +extern void __ieee_set_fp_control (unsigned long int __value) __THROW; ============================================================ Index: sysdeps/generic/bits/siginfo.h --- sysdeps/generic/bits/siginfo.h 1998/10/23 13:37:17 1.3 +++ sysdeps/generic/bits/siginfo.h 2000/05/23 07:41:08 @@ -1,5 +1,5 @@ /* siginfo_t, sigevent and constants. Stub version. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2000 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 @@ -185,7 +185,7 @@ sigval_t sigev_value; int sigev_signo; int sigev_notify; - void (*sigev_notify_function) __PMT ((sigval_t)); /* Function to start. */ + void (*sigev_notify_function) (sigval_t); /* Function to start. */ void *sigev_notify_attributes; /* Really pthread_attr_t.*/ } sigevent_t; ============================================================ Index: sysdeps/generic/bits/sockaddr.h --- sysdeps/generic/bits/sockaddr.h 1998/04/07 09:06:08 1.2 +++ sysdeps/generic/bits/sockaddr.h 2000/05/23 07:41:08 @@ -1,5 +1,5 @@ /* Definition of `struct sockaddr_*' common members. Generic/4.2 BSD version. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 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 @@ -39,6 +39,6 @@ /* Return the length of a `sockaddr' structure. */ #define SA_LEN(_x) __libc_sa_len((_x)->sa_family) -extern int __libc_sa_len __P ((sa_family_t __af)); +extern int __libc_sa_len (sa_family_t __af) __THROW; #endif /* bits/sockaddr.h */ ============================================================ Index: sysdeps/generic/sys/swap.h --- sysdeps/generic/sys/swap.h 1997/06/23 21:51:54 1.2 +++ sysdeps/generic/sys/swap.h 2000/05/23 07:41:08 @@ -1,5 +1,5 @@ /* Calls to enable and disable swapping on specified locations. Unix version. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 2000 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 @@ -25,9 +25,9 @@ /* Make the block special device PATH available to the system for swapping. This call is restricted to the super-user. */ -extern int swapon __P ((__const char *__path)); +extern int swapon (__const char *__path) __THROW; /* Stop using block special device PATH for swapping. */ -extern int swapoff __P ((__const char *__path)); +extern int swapoff (__const char *__path) __THROW; #endif /* sys/swap.h */ ============================================================ Index: sysdeps/generic/sys/sysinfo.h --- sysdeps/generic/sys/sysinfo.h 1999/07/31 06:08:39 1.4 +++ sysdeps/generic/sys/sysinfo.h 2000/05/23 07:41:08 @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1999, 2000 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 @@ -22,16 +22,16 @@ #include /* Return number of configured processors. */ -extern int get_nprocs_conf __P ((void)); +extern int get_nprocs_conf (void) __THROW; /* Return number of available processors. */ -extern int get_nprocs __P ((void)); +extern int get_nprocs (void) __THROW; /* Return number of physical pages of memory in the system. */ -extern int get_phys_pages __P ((void)); +extern int get_phys_pages (void) __THROW; /* Return number of available physical pages of memory in the system. */ -extern int get_avphys_pages __P ((void)); +extern int get_avphys_pages (void) __THROW; #endif /* sys/sysinfo.h */ ============================================================ Index: sysdeps/generic/vfork.c --- sysdeps/generic/vfork.c 1997/05/26 22:21:20 1.5 +++ sysdeps/generic/vfork.c 2000/05/23 07:41:08 @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1995, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995, 1997, 2000 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 @@ -22,7 +22,7 @@ /* If we don't have vfork, fork is close enough. */ __pid_t -__vfork __P ((void)) +__vfork (void) { return __fork (); } ============================================================ Index: sysdeps/generic/tcsetattr.c --- sysdeps/generic/tcsetattr.c 1997/10/13 03:52:41 1.1 +++ sysdeps/generic/tcsetattr.c 2000/05/23 07:41:08 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1995, 1996, 2000 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 @@ -20,14 +20,11 @@ #include #include -static int bad_speed __P ((speed_t speed)); +static int bad_speed (speed_t speed); /* Set the state of FD to *TERMIOS_P. */ int -tcsetattr (fd, optional_actions, termios_p) - int fd; - int optional_actions; - const struct termios *termios_p; +tcsetattr (int fd, int optional_actions, const struct termios *termios_p) { if (fd < 0) { @@ -65,8 +62,7 @@ /* Strychnine checking. */ static int -bad_speed (speed) - speed_t speed; +bad_speed (speed_t speed) { switch (speed) { ============================================================ Index: sysdeps/m68k/fpu/switch/68881-sw.h --- sysdeps/m68k/fpu/switch/68881-sw.h 1997/01/20 02:49:02 1.3 +++ sysdeps/m68k/fpu/switch/68881-sw.h 2000/05/23 07:41:08 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1997, 2000 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 @@ -33,9 +33,9 @@ struct switch_caller { unsigned short int insn; /* The `jsr' or `jmp' instruction. */ - __ptr_t target; /* The target of the instruction. */ - __ptr_t soft; /* The address of the soft function. */ - __ptr_t fpu; /* The address of the 68881 function. */ + void *target; /* The target of the instruction. */ + void *soft; /* The address of the soft function. */ + void *fpu; /* The address of the 68881 function. */ }; /* These are opcodes (values for `insn', above) for `jmp' and `jsr' @@ -47,12 +47,12 @@ /* Function to determine whether or not a 68881 is available, and modify its caller (which must be a `struct switch_caller', above, in data space) to use the appropriate version. */ -extern void __68881_switch __P ((int __dummy)); +extern void __68881_switch (int __dummy) __THROW; /* Define FUNCTION as a `struct switch_caller' which will call `__FUNCTION_68881' if a 68881 is present, and `__FUNCTION_soft' if not. -#define switching_function(FUNCTION) \ +#define switching_function(FUNCTION) \ struct switch_caller FUNCTION = \ { \ JSR, (__ptr_t) __68881_switch, \ ============================================================ Index: sysdeps/mach/hurd/fdopen.c --- sysdeps/mach/hurd/fdopen.c 1998/08/08 19:54:12 1.9 +++ sysdeps/mach/hurd/fdopen.c 2000/05/23 07:41:08 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1994, 1995, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994, 1995, 1997, 2000 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 @@ -23,7 +23,7 @@ #include /* Defined in fopen.c. */ -extern int __getmode __P ((const char *mode, __io_mode *mptr)); +extern int __getmode (const char *mode, __io_mode *mptr); /* Open a new stream on a given system file descriptor. */ FILE * ============================================================ Index: sysdeps/unix/sysv/linux/poll.c --- sysdeps/unix/sysv/linux/poll.c 1999/05/26 23:33:27 1.11 +++ sysdeps/unix/sysv/linux/poll.c 2000/05/23 07:41:08 @@ -1,5 +1,5 @@ /* Poll system call, with emulation if it is not available. - Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000 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 @@ -27,12 +27,12 @@ #if defined __NR_poll || __ASSUME_POLL_SYSCALL > 0 -extern int __syscall_poll __P ((struct pollfd *fds, unsigned int nfds, - int timeout)); +extern int __syscall_poll (struct pollfd *fds, unsigned int nfds, + int timeout); # if __ASSUME_POLL_SYSCALL == 0 -static int __emulate_poll __P ((struct pollfd *fds, unsigned long int nfds, - int timeout)) internal_function; +static int __emulate_poll (struct pollfd *fds, unsigned long int nfds, + int timeout) internal_function; # endif /* The real implementation. */ ============================================================ Index: sysdeps/unix/sysv/linux/readv.c --- sysdeps/unix/sysv/linux/readv.c 1998/10/21 15:11:06 1.8 +++ sysdeps/unix/sysv/linux/readv.c 2000/05/23 07:41:08 @@ -1,5 +1,5 @@ /* readv supports all Linux kernels >= 2.0. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2000 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 @@ -25,9 +25,9 @@ #include #include -extern ssize_t __syscall_readv __P ((int, __const struct iovec *, int)); -static ssize_t __atomic_readv_replacement __P ((int, __const struct iovec *, - int)) internal_function; +extern ssize_t __syscall_readv (int, __const struct iovec *, int); +static ssize_t __atomic_readv_replacement (int, __const struct iovec *, + int) internal_function; /* Not all versions of the kernel support the large number of records. */ ============================================================ Index: sysdeps/unix/sysv/linux/writev.c --- sysdeps/unix/sysv/linux/writev.c 1998/10/21 15:11:20 1.8 +++ sysdeps/unix/sysv/linux/writev.c 2000/05/23 07:41:08 @@ -1,5 +1,5 @@ /* writev supports all Linux kernels >= 2.0. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2000 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 @@ -25,9 +25,9 @@ #include #include -extern ssize_t __syscall_writev __P ((int, const struct iovec *, int)); -static ssize_t __atomic_writev_replacement __P ((int, const struct iovec *, - int)) internal_function; +extern ssize_t __syscall_writev (int, const struct iovec *, int); +static ssize_t __atomic_writev_replacement (int, const struct iovec *, + int) internal_function; /* Not all versions of the kernel support the large number of records. */ ============================================================ Index: sysdeps/unix/sysv/linux/ttyname.c --- sysdeps/unix/sysv/linux/ttyname.c 1999/04/28 23:05:51 1.10 +++ sysdeps/unix/sysv/linux/ttyname.c 2000/05/23 07:41:09 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 96, 97, 98, 99 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,96,97,98,99,2000 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 @@ -30,18 +30,13 @@ char *__ttyname; -static char * getttyname __P ((const char *dev, dev_t mydev, - ino_t myino, int save, int *dostat)) +static char * getttyname (const char *dev, dev_t mydev, + ino_t myino, int save, int *dostat) internal_function; static char * internal_function -getttyname (dev, mydev, myino, save, dostat) - const char *dev; - dev_t mydev; - ino_t myino; - int save; - int *dostat; +getttyname (const char *dev, dev_t mydev, ino_t myino, int save, int *dostat) { static char *name; static size_t namelen; @@ -102,8 +97,7 @@ /* Return the pathname of the terminal FD is open on, or NULL on errors. The returned storage is good only until the next call to this function. */ char * -ttyname (fd) - int fd; +ttyname (int fd) { static char *buf; static size_t buflen; ============================================================ Index: sysdeps/unix/sysv/linux/ttyname_r.c --- sysdeps/unix/sysv/linux/ttyname_r.c 1999/04/01 09:32:17 1.10 +++ sysdeps/unix/sysv/linux/ttyname_r.c 2000/05/23 07:41:09 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,95,96,97,98,99 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,95,96,97,98,99,2000 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 @@ -28,19 +28,14 @@ #include -static int getttyname_r __P ((char *buf, size_t buflen, - dev_t mydev, ino_t myino, int save, - int *dostat)) internal_function; +static int getttyname_r (char *buf, size_t buflen, + dev_t mydev, ino_t myino, int save, + int *dostat) internal_function; static int internal_function -getttyname_r (buf, buflen, mydev, myino, save, dostat) - char *buf; - size_t buflen; - dev_t mydev; - ino_t myino; - int save; - int *dostat; +getttyname_r (char *buf, size_t buflen, dev_t mydev, ino_t myino, + int save, int *dostat) { struct stat st; DIR *dirstream; @@ -98,10 +93,7 @@ /* Store at most BUFLEN character of the pathname of the terminal FD is open on in BUF. Return 0 on success, otherwise an error number. */ int -__ttyname_r (fd, buf, buflen) - int fd; - char *buf; - size_t buflen; +__ttyname_r (int fd, char *buf, size_t buflen) { char procname[30]; struct stat st, st1; ============================================================ Index: sysdeps/unix/sysv/linux/i386/setgroups.c --- sysdeps/unix/sysv/linux/i386/setgroups.c 2000/02/11 19:42:14 1.9 +++ sysdeps/unix/sysv/linux/i386/setgroups.c 2000/05/23 07:41:09 @@ -30,7 +30,7 @@ extern int __syscall_setgroups (int, const __kernel_gid_t *); #ifdef __NR_setgroups32 -extern int __syscall_setgroups32 __P ((int, const __kernel_gid32_t *)); +extern int __syscall_setgroups32 (int, const __kernel_gid32_t *); # if __ASSUME_32BITUIDS == 0 /* This variable is shared with all files that need to check for 32bit uids. */ ============================================================ Index: sysdeps/unix/sysv/linux/powerpc/bits/ipc.h --- sysdeps/unix/sysv/linux/powerpc/bits/ipc.h 2000/02/25 08:56:35 1.3 +++ sysdeps/unix/sysv/linux/powerpc/bits/ipc.h 2000/05/23 07:41:09 @@ -55,8 +55,8 @@ __BEGIN_DECLS /* The actual system call: all functions are multiplexed by this. */ -extern int __ipc __P ((int __call, int __first, int __second, int __third, - void *__ptr)); +extern int __ipc (int __call, int __first, int __second, int __third, + void *__ptr) __THROW; __END_DECLS ============================================================ Index: sysdeps/unix/sysv/linux/sparc/bits/sigaction.h --- sysdeps/unix/sysv/linux/sparc/bits/sigaction.h 2000/02/23 05:59:15 1.8 +++ sysdeps/unix/sysv/linux/sparc/bits/sigaction.h 2000/05/23 07:41:09 @@ -47,7 +47,7 @@ unsigned long sa_flags; /* Not used by Linux/Sparc yet. */ - void (*sa_restorer) __PMT ((void)); + void (*sa_restorer) (void); }; ============================================================ Index: misc/tst-dirname.c --- misc/tst-dirname.c 1996/12/22 00:32:05 1.3 +++ misc/tst-dirname.c 2000/05/23 07:41:09 @@ -1,5 +1,5 @@ /* Test program for dirname function a la XPG. - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -24,12 +24,8 @@ #include -extern int test __P ((const char *input, const char *result)); - int -test (input, result) - const char *input; - const char *result; +test (const char *input, const char *result) { int retval; char *cp; @@ -42,11 +38,8 @@ return retval; } -int main __P ((int argc, char *argv[])); int -main (argc, argv) - int argc; - char *argv[]; +main (void) { int result = 0; ============================================================ Index: shadow/lckpwdf.c --- shadow/lckpwdf.c 1998/07/16 11:20:45 1.7 +++ shadow/lckpwdf.c 2000/05/23 07:41:10 @@ -1,5 +1,5 @@ /* Handle locking of password file. - Copyright (C) 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -43,7 +43,7 @@ /* Prototypes for local functions. */ -static void noop_handler __P ((int __sig)); +static void noop_handler (int __sig); /* We cannot simply return in error cases. We have to close the file @@ -79,7 +79,7 @@ int -__lckpwdf () +__lckpwdf (void) { int flags; sigset_t saved_set; /* Saved set of caught signals. */ @@ -151,7 +151,7 @@ int -__ulckpwdf () +__ulckpwdf (void) { int result; @@ -178,8 +178,7 @@ static void -noop_handler (sig) - int sig; +noop_handler (int sig) { /* We simply return which makes the `fcntl' call return with an error. */ } -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From jakub@redhat.com Tue May 23 08:36:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 23 May 2000 08:36:00 -0000 Subject: [PATCH] Fix i386 mathinline.h Message-ID: <20000523174207.I474@sunsite.ms.mff.cuni.cz> Hi! sincos* is protected by __USE_GNU in mathcalls.h, so without this __sincos* lack prototypes (and -Wmissing-prototypes does not like that). Alternatively, we can provide the prototypes in mathinline.h for #ifndef __USE_GNU. Both patches are attached to this mail, please pick one. Jakub From aj@suse.de Tue May 23 09:53:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Tue, 23 May 2000 09:53:00 -0000 Subject: LDT use in LinuxThreads References: Message-ID: >>>>> Ulrich Drepper writes: Uli> I've enabled the use of the LDT-based thread descriptor for Liunx on Uli> i686 by default now. It works for me now and I've worked around the Uli> problem in libgcc (they are using thread functions far too early) by Uli> some special hack. Uli> If it does not work for you please let me know about the kernel Uli> version you are using. In this case you can safely compile glibc for Uli> everything below i686 since it won't use the new code. Hi Uli, it doesn't work for me with 2.3.48. What shall we do? Are you adding a run time test to disable LDT for older kernels? Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From drepper@redhat.com Tue May 23 10:05:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 23 May 2000 10:05:00 -0000 Subject: LDT use in LinuxThreads References: Message-ID: Andreas Jaeger writes: > it doesn't work for me with 2.3.48. What shall we do? Are you adding > a run time test to disable LDT for older kernels? We probably should use the kernel-features.h file to describe the kernel version for which it works and include useldt.h only if a high enough kernel version is assumed. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@lucon.org Tue May 23 10:23:00 2000 From: hjl@lucon.org (H . J . Lu) Date: Tue, 23 May 2000 10:23:00 -0000 Subject: LDT use in LinuxThreads References: Message-ID: <20000523102325.A8153@lucon.org> On Tue, May 23, 2000 at 09:33:49AM -0700, Ulrich Drepper wrote: > Andreas Jaeger writes: > > > it doesn't work for me with 2.3.48. What shall we do? Are you adding > > a run time test to disable LDT for older kernels? > > We probably should use the kernel-features.h file to describe the > kernel version for which it works and include useldt.h only if a high Shouldn't that be checked at the run-time? H.J. From drepper@redhat.com Tue May 23 10:43:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 23 May 2000 10:43:00 -0000 Subject: LDT use in LinuxThreads References: <20000523102325.A8153@lucon.org> Message-ID: "H . J . Lu" writes: > Shouldn't that be checked at the run-time? That's too much of an overhead. The use of the LDT is there to speed things up. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Tue May 23 20:07:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 23 May 2000 20:07:00 -0000 Subject: LDT use in LinuxThreads References: <20000523102325.A8153@lucon.org> Message-ID: tb@MIT.EDU (Thomas Bushnell, BSG) writes: > > That's too much of an overhead. The use of the LDT is there to speed > > things up. > > This is just too likely to break distributions. We should avoid this > kind of thing. Is at all possible to check a single global variable? What are you talking about? This will not break anything since there is a test for the kernel version at the beginning of the program execution. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Tue May 23 20:21:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 23 May 2000 20:21:00 -0000 Subject: LDT use in LinuxThreads References: <20000523102325.A8153@lucon.org> Message-ID: tb@MIT.EDU (Thomas Bushnell, BSG) writes: > That's fine; I thought you were talking about checking a compile-time > constant. At compile time you provide configure with the minimal supported kernel version and this will be enforced at runtime. With Andreas' information we can restrict the use of LDT on kernel 2.3.49 and later and enable the feature only if such a kernel is the minimum requirement. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Tue May 23 22:29:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Tue, 23 May 2000 22:29:00 -0000 Subject: LDT use in LinuxThreads References: <20000523102325.A8153@lucon.org> Message-ID: >>>>> Ulrich Drepper writes: Uli> tb@MIT.EDU (Thomas Bushnell, BSG) writes: >> That's fine; I thought you were talking about checking a compile-time >> constant. Uli> At compile time you provide configure with the minimal supported Uli> kernel version and this will be enforced at runtime. With Andreas' Uli> information we can restrict the use of LDT on kernel 2.3.49 and later Uli> and enable the feature only if such a kernel is the minimum Uli> requirement. Not on 2.3.49 - on something > 2.3.48 and < 2.3.99. Let's go for 2.3.99 to be on the save side. Btw. the kernel check is not working (Here's my email from some weeks ago again): If I compile the current glibc 2.2 CVS version with --enable-kernel=2.3.48 and try to run it on a Linux 2.2.14 system, I get the following error: $ elf/ld.so --library-path . /bin/ls /bin/ls: error while loading shared libraries: /bin/ls: cannot stat shared object: Error 38 strace reveals that fstat64 is called: open("/bin/ls", O_RDONLY) = 3 SYS_197(0x3, 0xbffff0ec, 0x8, 0x8, 0x3) = -1 ENOSYS (Function not implemented) close(3) = 0 write(2, "/bin/ls", 7/bin/ls) = 7 fstat64 seems to be called via the fstat call in sysdeps/unix/sysv/linux/i386/fstat.c from the dynamic linker. sysdeps/unix/sysv/linux/init-first.c has a check for the kernel version and reports "too old kernel" - but this check happens too late. Is there any chance to move this earlier? Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From drepper@redhat.com Tue May 23 22:59:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 23 May 2000 22:59:00 -0000 Subject: LDT use in LinuxThreads References: <20000523102325.A8153@lucon.org> Message-ID: Andreas Jaeger writes: > Btw. the kernel check is not working (Here's my email from some weeks > ago again): There were a few kernel versions where it didn't work. It does work with 2.3.99-pre8 (and -pre6 as well if I remember correctly). It's not important, people will find out easily. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Wed May 24 00:13:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 24 May 2000 00:13:00 -0000 Subject: LDT use in LinuxThreads References: <20000523102325.A8153@lucon.org> Message-ID: >>>>> Ulrich Drepper writes: > tb@MIT.EDU (Thomas Bushnell, BSG) writes: >> That's fine; I thought you were talking about checking a compile-time >> constant. > At compile time you provide configure with the minimal supported > kernel version and this will be enforced at runtime. With Andreas' > information we can restrict the use of LDT on kernel 2.3.49 and later > and enable the feature only if such a kernel is the minimum > requirement. Here's a patch to do so. Shall I commit it? Andreas For linuxthreads: 2000-05-24 Andreas Jaeger * sysdeps/i386/i686/pt-machine.h: Only use LDT on newer kernels. Normal ChangeLog: 2000-05-24 Andreas Jaeger * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_LDT_WORKS): Define it for newer kernels. ============================================================ Index: linuxthreads/sysdeps/i386/i686/pt-machine.h --- linuxthreads/sysdeps/i386/i686/pt-machine.h 2000/04/27 20:16:31 1.10 +++ linuxthreads/sysdeps/i386/i686/pt-machine.h 2000/05/24 06:47:04 @@ -22,8 +22,8 @@ #ifndef PT_EI # define PT_EI extern inline #endif +#include "kernel-features.h" - /* Get some notion of the current stack. Need not be exactly the top of the stack, just something somewhere in the current frame. */ #define CURRENT_STACK_FRAME stack_pointer @@ -61,6 +61,7 @@ : "memory"); return ret; } - +#if __ASSUME_LDT_WORKS > 0 #include "../useldt.h" +#endif ============================================================ Index: sysdeps/unix/sysv/linux/kernel-features.h --- sysdeps/unix/sysv/linux/kernel-features.h 2000/01/27 23:40:47 1.11 +++ sysdeps/unix/sysv/linux/kernel-features.h 2000/05/24 06:47:04 @@ -117,3 +117,14 @@ # define __ASSUME_SETRESUID_SYSCALL 1 # endif #endif + +/* We can use the LDTs for threading with Linux 2.3.99 and newer. */ +#if __LINUX_KERNEL_VERSION >= 131939 +# define __ASSUME_LDT_WORKS 1 +#endif -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Wed May 24 00:28:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 24 May 2000 00:28:00 -0000 Subject: Endless? loop in vismain test Message-ID: With binutils 2.9.5.0.24 and gcc 2.96 CVS current on i686 I seem to get an endless loop with the new vismain test. Running the test by hand with LD_DEBUG=all shows: [...] $ LD_DEBUG=all LD_PRELOAD=/builds/glibc/20000515-main/elf/vismod3.so /builds/glibc/20000515-main/elf/ld-linux.so.2 --library-path /builds/glibc/20000515-main:/builds/glibc/20000515-main/math:/builds/glibc/20000515-main/elf:/builds/glibc/20000515-main/dlfcn:/builds/glibc/20000515-main/nss:/builds/glibc/20000515-main/nis:/builds/glibc/20000515-main/rt:/builds/glibc/20000515-main/resolv:/builds/glibc/20000515-main/crypt:/builds/glibc/20000515-main/linuxthreads /builds/glibc/20000515-main/elf/vismain 22119: binding file /builds/glibc/20000515-main/libc.so.6 to /builds/glibc/20000515-main/libc.so.6: normal symbol `__write' [GLIBC_2.0] `.protected' seems to be handled correctly, good! 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/vismain 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/vismod3.so 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/vismod1.so 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/vismod2.so 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/libc.so.6 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/ld-linux.so.2 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/vismain 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/vismod3.so 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/vismod1.so 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/vismod2.so 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/libc.so.6 22119: symbol=_IO_funlockfile; lookup in file=/builds/glibc/20000515-main/elf/ld-linux.so.2 22119: binding file /builds/glibc/20000515-main/libc.so.6 to /builds/glibc/20000515-main/libc.so.6: normal symbol `_IO_funlockfile' [GLIBC_2.0] 22119: symbol=getlocal1; lookup in file=/builds/glibc/20000515-main/elf/vismain 22119: symbol=getlocal1; lookup in file=/builds/glibc/20000515-main/elf/vismod3.so 22119: symbol=getlocal1; lookup in file=/builds/glibc/20000515-main/elf/vismod1.so 22119: binding file /builds/glibc/20000515-main/elf/vismain to /builds/glibc/20000515-main/elf/vismod1.so: normal symbol `getlocal1' 22119: symbol=getlocal2; lookup in file=/builds/glibc/20000515-main/elf/vismain 22119: symbol=getlocal2; lookup in file=/builds/glibc/20000515-main/elf/vismod3.so 22119: symbol=getlocal2; lookup in file=/builds/glibc/20000515-main/elf/vismod1.so 22119: symbol=getlocal2; lookup in file=/builds/glibc/20000515-main/elf/vismod2.so 22119: binding file /builds/glibc/20000515-main/elf/vismain to /builds/glibc/20000515-main/elf/vismod2.so: normal symbol `getlocal2' 22119: symbol=getinmod1; lookup in file=/builds/glibc/20000515-main/elf/vismain 22119: symbol=getinmod1; lookup in file=/builds/glibc/20000515-main/elf/vismod3.so 22119: symbol=getinmod1; lookup in file=/builds/glibc/20000515-main/elf/vismod1.so 22119: binding file /builds/glibc/20000515-main/elf/vismain to /builds/glibc/20000515-main/elf/vismod1.so: normal symbol `getinmod1' 22119: symbol=getinmod2; lookup in file=/builds/glibc/20000515-main/elf/vismain 22119: symbol=getinmod2; lookup in file=/builds/glibc/20000515-main/elf/vismod3.so 22119: symbol=getinmod2; lookup in file=/builds/glibc/20000515-main/elf/vismod1.so 22119: symbol=getinmod2; lookup in file=/builds/glibc/20000515-main/elf/vismod2.so 22119: binding file /builds/glibc/20000515-main/elf/vismain to /builds/glibc/20000515-main/elf/vismod2.so: normal symbol `getinmod2' And here it stops and does nothing anymore (at least for the last one and a half minute, I didn't wait much longer) :-(. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Wed May 24 02:32:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 24 May 2000 02:32:00 -0000 Subject: gettext-test shouldn't run if !msgfmt Message-ID: On a machine without msgfmt I got the following error running the testsuite: [...] bin/sh -e tst-gettext.sh /var/home/aj/build-glibc/20000523/ /var/home/aj/build-glibc/20000523/intl/ tst-gettext.sh: msgfmt: command not found make[2]: *** [do-gettext-test] Error 127 make[2]: Leaving directory `/var/home/aj/libc/intl' make[1]: *** [intl/tests] Error 2 make[1]: Leaving directory `/var/home/aj/libc' make: *** [check] Error 2 [mq:ttyp0] /var/home/aj/build-glibc/20000523 $ grep -i msgfmt config.make MSGFMT = : FYI: I've committed the appended patch. Andreas 2000-05-24 Andreas Jaeger * intl/Makefile: Run gettext-test only if msgfmt is available. ============================================================ Index: intl/Makefile --- intl/Makefile 2000/04/09 22:50:08 1.23 +++ intl/Makefile 2000/05/24 09:30:52 @@ -46,10 +46,12 @@ ifeq (no,$(cross-compiling)) ifeq (yes,$(build-shared)) +ifneq ($(strip $(MSGFMT)),:) .PHONY: do-gettext-test tests: do-gettext-test do-gettext-test: tst-gettext.sh $(objpfx)tst-gettext $(SHELL) -e $< $(common-objpfx) $(objpfx) +endif endif endif -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From jakub@redhat.com Wed May 24 06:46:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 24 May 2000 06:46:00 -0000 Subject: sunrpc binary incompatibility with glibc 2.1.x Message-ID: <20000524155235.S474@sunsite.ms.mff.cuni.cz> Hi! Changing type of xp_raddr field in SVCXPRT (rpc/svc.h) from sockaddr_in to sockaddr_storage breaks binary compatibility on 64bit hosts (sockaddr_storage is aligned to 64 bits while sockaddr_in to 32bits only, so there is 4 bytes padding before sockaddr_storage while it is not present for sockaddr_in). Any ideas what to do with it? Versioning almost the whole sunrpc/ does not seem like a good idea to me, so perhaps cannot we have (on 64bit arches only): int xp_addrlen; /* length of remote address */ struct sockaddr_in xp_raddr; /* remote address */ struct sockaddr_storage xp_rnaddr; /* new remote address */ struct opaque_auth xp_verf; /* raw response verifier */ caddr_t xp_p1; /* private */ caddr_t xp_p2; /* private */ int xp_p3; /* private */ char xp_pad [256]; /* padding, internal use */ where svc_getcaller would be: #define svc_getcaller(x) \ ({ SVCXPRT *__svcxprt = (SVCXPRT *)(x); \ __svcxprt->xp_p3 ? \ (void *)&__svcxprt->xp_rnaddr : \ (void *)&__svcxprt->xp_raddr; \ }) Jakub From kukuk@suse.de Wed May 24 06:53:00 2000 From: kukuk@suse.de (Thorsten Kukuk) Date: Wed, 24 May 2000 06:53:00 -0000 Subject: sunrpc binary incompatibility with glibc 2.1.x References: <20000524155235.S474@sunsite.ms.mff.cuni.cz> Message-ID: <20000524155327.A27846@suse.de> Hi, On Wed, May 24, Jakub Jelinek wrote: > Hi! > > Changing type of xp_raddr field in SVCXPRT (rpc/svc.h) from sockaddr_in to > sockaddr_storage breaks binary compatibility on 64bit hosts > (sockaddr_storage is aligned to 64 bits while sockaddr_in to 32bits only, so > there is 4 bytes padding before sockaddr_storage while it is not present for > sockaddr_in). > Any ideas what to do with it? This is old and was already discussed here, without result. And it doesn't break binary compatibility only on 64bit hosts, 32bit hosts have also problems (the size of the struct changed, too). Our IPv6 implementation is not compatible with Solaris8 and it seems with *BSD, too. So I would like to remove the complete IPv6 code and wait for an "official" solution. In the moment the protocol is not compatible (you cannot comunicate with a Solaris8 RPC daemon over IPv6) and the interface, too. I would like to see a port of the new TI-RPC code Sun releases with Solaris8. Alexey Kuznetsov has already written a socket interface for it for an older Version. But I don't know who could do that. Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE GmbH Schanzaeckerstr. 10 90443 Nuernberg Linux is like a Vorlon. It is incredibly powerful, gives terse, cryptic answers and has a lot of things going on in the background. From drepper@redhat.com Wed May 24 08:05:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 May 2000 08:05:00 -0000 Subject: LDT use in LinuxThreads References: <20000523102325.A8153@lucon.org> Message-ID: Andreas Jaeger writes: > Here's a patch to do so. Shall I commit it? Yep. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed May 24 08:17:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 May 2000 08:17:00 -0000 Subject: sunrpc binary incompatibility with glibc 2.1.x References: <20000524155235.S474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Any ideas what to do with it? We wanted to rearrange the struct. It's a known problem but nonbody tackled it so far. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From kukuk@suse.de Wed May 24 09:16:00 2000 From: kukuk@suse.de (Thorsten Kukuk) Date: Wed, 24 May 2000 09:16:00 -0000 Subject: sunrpc binary incompatibility with glibc 2.1.x References: <20000524155235.S474@sunsite.ms.mff.cuni.cz> <20000524155327.A27846@suse.de> Message-ID: <20000524181653.C23443@suse.de> On Wed, May 24, Philip Blundell wrote: > In message < 20000524155327.A27846@suse.de >, Thorsten Kukuk writes: > >Our IPv6 implementation is not compatible with Solaris8 and it seems with > >*BSD, too. So I would like to remove the complete IPv6 code and wait for > >an "official" solution. > > I don't have any objection to this, so long as an `official' solution is > likely to be forthcoming. Are there specifications for the interfaces and > protocols used by the Sun and BSD implementations? Sun uses TI-RPC, not SunRPC. You don't need to make any changes on the interface. The problem is, that Solaris8 will not answer to SunRPC requests on a IPv6 address, only on a IPv4 address. I read something about a BSD implementation, but they haven't released the source. They have the problem with the incompatibility to Solaris8, too. Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE GmbH Schanzaeckerstr. 10 90443 Nuernberg Linux is like a Vorlon. It is incredibly powerful, gives terse, cryptic answers and has a lot of things going on in the background. From kukuk@suse.de Wed May 24 09:20:00 2000 From: kukuk@suse.de (Thorsten Kukuk) Date: Wed, 24 May 2000 09:20:00 -0000 Subject: sunrpc binary incompatibility with glibc 2.1.x References: <20000524155235.S474@sunsite.ms.mff.cuni.cz> Message-ID: <20000524182053.A24984@suse.de> Hi, On Wed, May 24, Ulrich Drepper wrote: > Jakub Jelinek writes: > > > Any ideas what to do with it? > > We wanted to rearrange the struct. It's a known problem but nonbody > tackled it so far. Yes, we spoke about this. But I also said that I don't like the idea, because the current implementation is incompatible to all other. Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE GmbH Schanzaeckerstr. 10 90443 Nuernberg Linux is like a Vorlon. It is incredibly powerful, gives terse, cryptic answers and has a lot of things going on in the background. From drepper@redhat.com Wed May 24 13:22:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 May 2000 13:22:00 -0000 Subject: fnmatch change Message-ID: I just checked in a change to fnamtch which changes its behaviour wrt to ranges. Currently you are surprised if you do something like rm [a-c]* if the locale != C. In some locales this will remove also the files beginning with uppercase characters. The problem was that strcoll() was used. This seemed correct since the standard mentioned collation sequence order decides about the range. But the problem is the collation sequence order is not collation order. I talked with the original designer of the POSIX i18n interfaces two weeks ago and he explained it. They realized at that time that the collation order is not suitable. Therefore they are using collation sequence order. The problem is they are not defining this. >From the talks with the guy I learned that the collation sequence order is the order of the collation definitions in the source file. It's a nice way out and I have implemented this now. One problem remains: the locale definitions must now be corrected. Currently the definitions look like this: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;;;IGNORE ;;;IGNORE <-a> ;;<-a>;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ What has to happen is that upper- and lower-case character must be defined in separate blocks. This has no effect on the collation order, but it ensures that [a-b] does not match A or B since the lines with A or B in the locale source file are not between the lines with the definitions for a or b. I'm a bit reluctant to spend much time on the old locale descriptions. Instead I'll check in in a few moments a ISO 14651 collation description which already pays attention to this. With the rewrite of the locale data to the new format we can also switch over to using this data. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed May 24 23:16:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 May 2000 23:16:00 -0000 Subject: [PATCH] Fix i386 mathinline.h References: <20000523174207.I474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > sincos* is protected by __USE_GNU in mathcalls.h, so without this > __sincos* lack prototypes (and -Wmissing-prototypes does not like that). I've applied the first patch. Thanks, -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed May 24 23:28:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 May 2000 23:28:00 -0000 Subject: Updated mathinline.h patch References: Message-ID: Andreas Jaeger writes: > Uli, is it ok to install this? I installed the patch now. Slightly modified. There were a functions used conditionally although the version in libc and the inlined version should produce the same code. Thanks, -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From kkojima@rr.iij4u.or.jp Thu May 25 04:28:00 2000 From: kkojima@rr.iij4u.or.jp (kaz Kojima) Date: Thu, 25 May 2000 04:28:00 -0000 Subject: Adding SH support to glibc-2.1.3 Message-ID: <200005251128.UAA14744@rr.iij4u.or.jp> Hi, Here's a patch for glibc-2.1.3 to support new sh-linux-gnu target for Linux on Hitachi SH processors. We've already done the paper work for copyright assignment, and got back the copy from FSF. Patch consists of two parts. One is for changes of generic part, and another is SH specific part. For the changes of generic part, there are four diffs. First three diffs are trivial, just add sh[34] support. We need the 4-th diff for csu/Makefile to get cststuff routines directly. This is needed because we couldn't use generated files. The constant (for label) is emitted far away than expected by the generation, after the function epilogue. Sorry for this long patch. Any comments are appreciated. Thanks, -- 2000-05-25 Kazumoto Kojima Yutaka Niibe * configure.in: Add machine sh3, sh4. * configure: Likewise * scripts/config.sub: Likewise. * csu/Makefile: Add new variable crts-predefined whose non-zero value means to generate crt[in].o from system dependent predefined crt[in].S instead of initfini.c. * elf/elf.h: Add SH specific declarations of relocations. * sysdeps/sh/Dist: New file. * sysdeps/sh/Implies: New file. * sysdeps/sh/gmp-mparam.h: New file for SH specific definitions for GNU MP library. * sysdeps/sh/machine-gmon.h: New file for SH specific definitions for profiling support. * sysdeps/sh/memcpy.S: New file for memcpy function written in assembler. * sysdeps/sh/memset.S: Likewise for memset. * sysdeps/sh/strlen.S: Likewise for strlen. * sysdeps/sh/sysdep.h: New file for SH specific assembler macros. * sysdeps/sh/sh3/__longjmp.S: New file for SH-3 specific __longjmp function written in assembler. * sysdeps/sh/sh3/bits/endian.h: New file for SH-3 specific definitions for endian. * sysdeps/sh/sh3/bits/huge_val.h: New file for SH-3 specific definitions for HUGE_VAL constant. * sysdeps/sh/sh3/bits/setjmp.h: New file for SH-3 specific definitions for jmp_buf. * sysdeps/sh/sh3/bsd-_setjmp.S: New file for SH-3 specific BSD _setjmp function written in assembler. * sysdeps/sh/sh3/bsd-setjmp.S: Likewise for setjmp. * sysdeps/sh/sh3/dl-machine.h: New file for SH-3 specific ELF dynamic location inline functions. * sysdeps/sh/sh3/elf/crti.S: Likewise for _init and _fini function prologue. * sysdeps/sh/sh3/elf/crti.S: Likewise for their epilogue and __gmon_start__ function. * sysdeps/sh/sh3/elf/start.S: New file for the startup code for SH-3 in ELF. * sysdeps/sh/sh3/setjmp.S: New file for SH specific __setjmp and __sigsetjmp functions written in assembler. * sysdeps/sh/sh3/sys/ucontext.h: New file for SH-3 specific definitions for user context. * sysdeps/sh/sh4/__longjmp.S: New file for SH-4 specific __longjmp function written in assembler. * sysdeps/sh/sh4/bits/endian.h: New file for SH-4 specific definitions for endian. * sysdeps/sh/sh4/bits/huge_val.h: New file for SH-4 specific definitions for HUGE_VAL constant. * sysdeps/sh/sh4/bits/setjmp.h: New file for SH-4 specific definitions for jmp_buf. * sysdeps/sh/sh4/bsd-_setjmp.S: New file for SH-4 specific BSD _setjmp function written in assembler. * sysdeps/sh/sh4/bsd-setjmp.S: Likewise for setjmp. * sysdeps/sh/sh4/dl-machine.h: New file for SH-4 specific ELF dynamic location inline functions. * sysdeps/sh/sh4/elf/crti.S: Likewise for _init and _fini function prologue. * sysdeps/sh/sh4/elf/crti.S: Likewise for their epilogue and __gmon_start__ function. * sysdeps/sh/sh4/elf/start.S: New file for the startup code for SH-4 in ELF. * sysdeps/sh/sh4/setjmp.S: New file for SH specific __setjmp and __sigsetjmp functions written in assembler. * sysdeps/sh/sh4/sys/ucontext.h: New file for SH-4 specific definitions for user context. * sysdeps/sh/sh4/fpu/bits/fenv.h: New file for SH-4 specific definitions for FPU. * sysdeps/sh/sh4/fpu/fclrexcpt.c: New file for SH-4 specific feclearexcept function. * sysdeps/sh/sh4/fpu/fegetenv.c: Likewise for fegetenv. * sysdeps/sh/sh4/fpu/fegetround.c: Likewise for fegetround. * sysdeps/sh/sh4/fpu/feholdexcpt.c: Likewise for feholdexcept. * sysdeps/sh/sh4/fpu/fesetenv.c: Likewise for fesetenv. * sysdeps/sh/sh4/fpu/fesetround.c: Likewise for fesetround. * sysdeps/sh/sh4/fpu/fraiseexcpt.c: Likewise for feraiseexcept. * sysdeps/sh/sh4/fpu/fsetexcptflg.c: Likewise for fesetexceptflag. * sysdeps/sh/sh4/fpu/ftestexcept.c: Likewise for fetestexcept. * sysdeps/sh/sh4/fpu/fpu_control.h: New file for SH-4 specific FPU control word definitions. * sysdeps/unix/sh/sysdep.S: New file for SH specific __syscall_error function in unix. * /sysdeps/unix/sh/sysdep.h: New file for SH specific miscellaneous definitions in unix. * sysdeps/unix/sysv/linux/sh/Dist: New file. * sysdeps/unix/sysv/linux/sh/Makefile: Likewise. * sysdeps/unix/sysv/linux/sh/Versions: Likewise. * sysdeps/unix/sysv/linux/sh/bits/mman.h: New file for Linux/SH specific definitions for mmap interface. * sysdeps/unix/sysv/linux/sh/sysdep.S: New files for Linux/SH specific definitions for system call and errno. * sysdeps/unix/sysv/linux/sh/brk.c: New file for Linux/SH specific definitions for brk function. * sysdeps/unix/sysv/linux/sh/clone.S: Likewise for clone. * sysdeps/unix/sysv/linux/sh/pipe.S: Likewise for pipe. * sysdeps/unix/sysv/linux/sh/socket.S: Likewise for socket. * sysdeps/unix/sysv/linux/sh/vfork.S: Likewise for vfork. * sysdeps/unix/sysv/linux/sh/sigrestorer.S: Likewise for signal restorers. * sysdeps/unix/sysv/linux/sh/getgroups.c: Likewise for getgroups. * sysdeps/unix/sysv/linux/sh/pread.c: Likewise for pread. * sysdeps/unix/sysv/linux/sh/pread64.c: Likewise for pread64. * sysdeps/unix/sysv/linux/sh/pwrite.c: Likewise for pwrite. * sysdeps/unix/sysv/linux/sh/pwrite64.c: Likewise for pwrite64. * sysdeps/unix/sysv/linux/sh/setgid.c: Likewise for setgid. * sysdeps/unix/sysv/linux/sh/seteuid.c: Likewise for seteuid. * sysdeps/unix/sysv/linux/sh/setfsgid.c: Likewise for setfsgid. * sysdeps/unix/sysv/linux/sh/setfsuid.c: Likewise for setfsuid. * sysdeps/unix/sysv/linux/sh/setgid.c: Likewise for setgid. * sysdeps/unix/sysv/linux/sh/setgroups.c: Likewise for setgroups. * sysdeps/unix/sysv/linux/sh/setregid.c: Likewise for setregid. * sysdeps/unix/sysv/linux/sh/setresgid.c: Likewise for setresgid. * sysdeps/unix/sysv/linux/sh/setresuid.c: Likewise for setresuid. * sysdeps/unix/sysv/linux/sh/setreuid.c: Likewise for setreuid. * sysdeps/unix/sysv/linux/sh/setuid.c: Likewise for setuid. * sysdeps/unix/sysv/linux/sh/errlist.c: New file for Linux/SH specific definitions for errlist. * sysdeps/unix/sysv/linux/sh/errlist.c: Likewise for siglist. * sysdeps/unix/sysv/linux/sh/sigaction.c: New file for Linux/SH specific definitions for sigaction. * /sysdeps/unix/sysv/linux/sh/init-first.h: New file for Linux/SH specific definitions for library initialization. * sysdeps/unix/sysv/linux/sh/profil-counter.h: New file for Linux/SH specific definitions for profiling support. * sysdeps/unix/sysv/linux/sh/register-dump.h: New file for Linux/SH specific definitions for register dump. * sysdeps/unix/sysv/linux/sh/sigcontextinfo.h: New file for Linux/SH specific definitions for signal context. * sysdeps/unix/sysv/linux/sh/sys/io.h: New file for Linux/SH specific definitions for low level I/O. * sysdeps/unix/sysv/linux/sh/sys/user.h: New file for Linux/SH specific definitions for low level user context. * sysdeps/unix/sysv/linux/sh/syscalls.list: New file for Linux/SH specific system call list. * linuxthreads/sysdeps/sh/pt-machine.h: New file for SH specific definitions in linuxthreads. diff -u -r -N glibc-2.1.3-original/configure glibc-2.1.3/configure --- glibc-2.1.3-original/configure Tue Oct 5 09:56:26 1999 +++ glibc-2.1.3/configure Wed May 24 04:38:56 2000 @@ -903,6 +903,8 @@ IP22) machine=mips/mips3 ;; *) machine=mips/$machine ;; esac ;; +sh3*) base_machine=sh machine=sh/sh3 ;; +sh4*) base_machine=sh machine=sh/sh4 ;; sparc | sparcv[67]) base_machine=sparc machine=sparc/sparc32 ;; sparcv8 | supersparc | hypersparc) diff -u -r -N glibc-2.1.3-original/configure.in glibc-2.1.3/configure.in --- glibc-2.1.3-original/configure.in Tue Oct 5 09:55:45 1999 +++ glibc-2.1.3/configure.in Wed May 24 04:37:59 2000 @@ -219,6 +219,8 @@ IP22) machine=mips/mips3 ;; *) machine=mips/$machine ;; esac ;; +sh3*) base_machine=sh machine=sh/sh3 ;; +sh4*) base_machine=sh machine=sh/sh4 ;; sparc | sparcv[67]) base_machine=sparc machine=sparc/sparc32 ;; sparcv8 | supersparc | hypersparc) diff -u -r -N glibc-2.1.3-original/csu/Makefile glibc-2.1.3/csu/Makefile --- glibc-2.1.3-original/csu/Makefile Sat Apr 10 21:43:02 1999 +++ glibc-2.1.3/csu/Makefile Thu May 25 17:08:11 2000 @@ -76,12 +76,19 @@ install-lib += $(crtstuff:=.o) extra-objs += $(crtstuff:=.o) +ifneq (yes,$(crts-predefined)) generated += $(crtstuff:=.S) initfini.s defs.h omit-deps += $(crtstuff) # Special rules for the building of crti.o and crtn.o $(objpfx)crt%.o: $(objpfx)crt%.S $(objpfx)defs.h $(compile.S) -g0 $(ASFLAGS-.os) -o $@ +else +generated += initfini.s defs.h + +$(objpfx)crti.o: $(objpfx)defs.h +$(objpfx)crtn.o: $(objpfx)defs.h +endif CFLAGS-initfini.s = -g0 -fPIC -fno-inline-functions @@ -91,6 +98,7 @@ # We only have one kind of startup code files. Static binaries and # shared libraries are build using the PIC version. +ifneq (yes,$(crts-predefined)) $(objpfx)crti.S: $(objpfx)initfini.s sed -n -e '1,/@HEADER_ENDS/p' \ -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \ @@ -100,6 +108,7 @@ sed -n -e '1,/@HEADER_ENDS/p' \ -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \ -e '/@TRAILER_BEGINS/,$$p' $< > $@ +endif $(objpfx)defs.h: $(objpfx)initfini.s sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \ diff -u -r -N glibc-2.1.3-original/elf/elf.h glibc-2.1.3/elf/elf.h --- glibc-2.1.3-original/elf/elf.h Wed Feb 23 16:02:47 2000 +++ glibc-2.1.3/elf/elf.h Sun Mar 12 04:09:08 2000 @@ -1580,6 +1580,41 @@ /* Keep this the last entry. */ #define R_ARM_NUM 256 +/* SH specific declarations */ + +/* SH relocs. */ +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 +/* Keep this the last entry. */ +#define R_SH_NUM 256 + __END_DECLS #endif /* elf.h */ diff -u -r -N glibc-2.1.3-original/linuxthreads/sysdeps/sh/pt-machine.h glibc-2.1.3/linuxthreads/sysdeps/sh/pt-machine.h --- glibc-2.1.3-original/linuxthreads/sysdeps/sh/pt-machine.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/linuxthreads/sysdeps/sh/pt-machine.h Sun Mar 12 07:54:45 2000 @@ -0,0 +1,46 @@ +/* Machine-dependent pthreads configuration and inline functions. + SuperH version. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Niibe Yutaka . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef PT_EI +# define PT_EI extern inline +#endif + +/* Spinlock implementation; required. */ +PT_EI int +testandset (int *spinlock) +{ + int ret; + + __asm__ __volatile__( + "tas.b %1\n\t" + "movt %0" + : "=z" (ret), "=m" (*spinlock) + : /* "1" (*spinlock) */ + : "memory", "cc"); + + return ret; +} + + +/* Get some notion of the current stack. Need not be exactly the top + of the stack, just something somewhere in the current frame. */ +#define CURRENT_STACK_FRAME stack_pointer +register char * stack_pointer __asm__ ("r15"); diff -u -r -N glibc-2.1.3-original/scripts/config.sub glibc-2.1.3/scripts/config.sub --- glibc-2.1.3-original/scripts/config.sub Tue Oct 26 05:23:27 1999 +++ glibc-2.1.3/scripts/config.sub Thu May 25 17:06:42 2000 @@ -171,7 +171,7 @@ | 580 | i960 | h8300 \ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ | alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \ - | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \ + | we32k | ns16k | clipper | i370 | sh | sh[34] | powerpc | powerpcle \ | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \ | mips64orion | mips64orionel | mipstx39 | mipstx39el \ | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ @@ -837,6 +837,9 @@ ;; we32k) basic_machine=we32k-att + ;; + sh3 | sh4 | sh3-unknown | sh4-unknown) + base_machine=sh ;; sparc | sparcv9) basic_machine=sparc-sun diff -u -r -N glibc-2.1.3-original/sysdeps/generic/bits/libc-lock.h glibc-2.1.3/sysdeps/generic/bits/libc-lock.h --- glibc-2.1.3-original/sysdeps/generic/bits/libc-lock.h Mon Oct 13 12:53:17 1997 +++ glibc-2.1.3/sysdeps/generic/bits/libc-lock.h Sun Mar 12 18:21:12 2000 @@ -90,7 +90,9 @@ /* End critical region with cleanup. */ #define __libc_cleanup_region_end(DOIT) - +/* Sometimes we have to exit the block in the middle. */ +#define __libc_cleanup_end(DOIT) + /* We need portable names for some of the functions. */ #define __libc_mutex_unlock diff -u -r -N glibc-2.1.3-original/sysdeps/sh/Dist glibc-2.1.3/sysdeps/sh/Dist --- glibc-2.1.3-original/sysdeps/sh/Dist Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/Dist Sun Mar 12 04:09:09 2000 @@ -0,0 +1 @@ +ieee754.h diff -u -r -N glibc-2.1.3-original/sysdeps/sh/Implies glibc-2.1.3/sysdeps/sh/Implies --- glibc-2.1.3-original/sysdeps/sh/Implies Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/Implies Sun Mar 12 04:15:28 2000 @@ -0,0 +1,2 @@ +wordsize-32 +ieee754 diff -u -r -N glibc-2.1.3-original/sysdeps/sh/bits/string.h glibc-2.1.3/sysdeps/sh/bits/string.h --- glibc-2.1.3-original/sysdeps/sh/bits/string.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/bits/string.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,22 @@ +/* SH specific definitions for string functions. + Copyright (C) 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#define _HAVE_STRING_ARCH_strcpy 1 +#define _HAVE_STRING_ARCH_stpcpy 1 +#define _HAVE_STRING_ARCH_mempcpy 1 diff -u -r -N glibc-2.1.3-original/sysdeps/sh/gmp-mparam.h glibc-2.1.3/sysdeps/sh/gmp-mparam.h --- glibc-2.1.3-original/sysdeps/sh/gmp-mparam.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/gmp-mparam.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,30 @@ +/* gmp-mparam.h -- Compiler/machine parameter header file. + +Copyright (C) 1991, 1993, 1994, 1995, 2000 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at your +option) any later version. + +The GNU MP 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 Library General Public +License for more details. + +You should have received a copy of the GNU Library General Public License +along with the GNU MP Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#define BITS_PER_MP_LIMB 32 +#define BYTES_PER_MP_LIMB 4 +#define BITS_PER_LONGINT 32 +#define BITS_PER_INT 32 +#define BITS_PER_SHORTINT 16 +#define BITS_PER_CHAR 8 + +#define IEEE_DOUBLE_BIG_ENDIAN 0 +#define IEEE_DOUBLE_MIXED_ENDIAN 1 diff -u -r -N glibc-2.1.3-original/sysdeps/sh/machine-gmon.h glibc-2.1.3/sysdeps/sh/machine-gmon.h --- glibc-2.1.3-original/sysdeps/sh/machine-gmon.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/machine-gmon.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,34 @@ +/* Machine-dependent definitions for profiling support. SH version. + Copyright (C) 1996, 1997, 1998, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* NOTYET */ + +/* We must not pollute the global namespace. */ +#define mcount_internal __mcount_internal + +void mcount_internal (u_long frompc, u_long selfpc); + +#define _MCOUNT_DECL(frompc, selfpc) \ +void mcount_internal (u_long frompc, u_long selfpc) + + +/* Define MCOUNT as empty since we have the implementation in another + file. */ +#define MCOUNT + diff -u -r -N glibc-2.1.3-original/sysdeps/sh/memcpy.S glibc-2.1.3/sysdeps/sh/memcpy.S --- glibc-2.1.3-original/sysdeps/sh/memcpy.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/memcpy.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,231 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +/* + * void *memcpy(void *dst, const void *src, size_t n); + * No overlap between the memory of DST and of SRC are assumed. + */ + +ENTRY(memcpy) + tst r6,r6 + bt/s 1f + mov r4,r0 + mov #12,r1 + cmp/gt r6,r1 + bf 2f +0: + mov.b @r5+,r1 + dt r6 + mov.b r1,@r4 + bf/s 0b + add #1,r4 +1: + rts + nop +2: + mov.l r8,@-r15 + mov.l r9,@-r15 + mov r6,r2 + mov.l r10,@-r15 + mov.l r11,@-r15 + mov.l r14,@-r15 + mov r4,r11 + mov r15,r14 + mov r5,r0 + and #1,r0 + tst r0,r0 + bt/s .L42 + mov r5,r0 + mov.b @r5+,r1 + add #-1,r2 + add #1,r4 + mov.b r1,@r11 + mov r5,r0 +.L42: + and #2,r0 + tst r0,r0 + bt/s .L43 + mov r4,r0 + mov.b @r5+,r1 + mov.b r1,@r4 + mov.b @r5+,r1 + add #1,r4 + add #-2,r2 + mov.b r1,@r4 + add #1,r4 + mov r4,r0 +.L43: + and #1,r0 + tst r0,r0 + bf/s .L38 + mov r4,r0 + and #2,r0 + tst r0,r0 + bf/s .L7 + mov r2,r0 + shlr2 r0 + and #3,r0 + cmp/eq #2,r0 + bt/s .L10 + mov #2,r1 + cmp/gt r1,r0 + bt/s .L14 + cmp/eq #3,r0 + cmp/eq #1,r0 + bt/s .L11 + mov r0,r1 + bra .L44 + shll2 r1 + .align 5 +.L14: + bf .L8 + mov.l @(8,r5),r1 + mov.l r1,@(8,r4) +.L10: + mov.l @(4,r5),r1 + mov.l r1,@(4,r4) +.L11: + mov.l @r5,r1 + mov.l r1,@r4 +.L8: + mov r0,r1 + shll2 r1 +.L44: + add r1,r4 + add r1,r5 + mov r2,r0 + mov #-4,r1 + shad r1,r0 + mov #3,r6 + bra .L37 + and r2,r6 + .align 5 +.L18: + mov.l @r5+,r1 + mov.l @r5+,r2 + mov.l @r5+,r3 + mov.l @r5+,r7 + mov.l r1,@r4 + mov.l r2,@(4,r4) + mov.l r3,@(8,r4) + mov.l r7,@(12,r4) + add #16,r4 +.L37: + cmp/pl r0 + bt/s .L18 + add #-1,r0 + mov r6,r2 +.L38: + bra .L40 + mov r2,r0 + .align 5 +.L7: + shar r0 + and #3,r0 + cmp/eq #2,r0 + bt/s .L23 + mov #2,r1 + cmp/gt r1,r0 + bt/s .L27 + cmp/eq #3,r0 + cmp/eq #1,r0 + bt/s .L24 + mov r0,r1 + bra .L45 + add r0,r1 + .align 5 +.L27: + bf .L21 + add #4,r5 + mov.w @r5,r1 + add #4,r4 + mov.w r1,@r4 + add #-4,r5 + add #-4,r4 +.L23: + add #2,r5 + mov.w @r5,r1 + add #2,r4 + mov.w r1,@r4 + add #-2,r5 + add #-2,r4 +.L24: + mov.w @r5,r1 + mov.w r1,@r4 +.L21: + mov r0,r1 + add r0,r1 +.L45: + add r1,r4 + add r1,r5 + mov r2,r0 + mov #-3,r1 + shad r1,r0 + mov #1,r10 + mov r0,r1 + and r2,r10 + cmp/pl r1 + bf/s .L29 + add #-1,r0 + mov r4,r9 + mov r4,r8 + add #4,r9 + mov r4,r6 + add #6,r8 + add #2,r6 +.L31: + mov.w @r5+,r1 + mov.w @r5+,r2 + mov.w @r5+,r3 + mov.w @r5+,r7 + mov.w r1,@r4 + mov.w r2,@r6 + add #8,r4 + mov r0,r1 + add #8,r6 + mov.w r3,@r9 + add #-1,r0 + add #8,r9 + mov.w r7,@r8 + cmp/pl r1 + bt/s .L31 + add #8,r8 +.L29: + mov r10,r2 + mov r2,r0 +.L40: + cmp/pl r0 + bf .L34 +.L35: + mov.b @r5+,r1 + dt r2 + mov.b r1,@r4 + bf/s .L35 + add #1,r4 +.L34: + mov r11,r0 + mov r14,r15 + mov.l @r15+,r14 + mov.l @r15+,r11 + mov.l @r15+,r10 + mov.l @r15+,r9 + rts + mov.l @r15+,r8 diff -u -r -N glibc-2.1.3-original/sysdeps/sh/memprof.h glibc-2.1.3/sysdeps/sh/memprof.h --- glibc-2.1.3-original/sysdeps/sh/memprof.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/memprof.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,21 @@ +/* Copyright (C) 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#define GETSP() ({ register uintptr_t stack_ptr asm ("%r15"); stack_ptr; }) + +#include diff -u -r -N glibc-2.1.3-original/sysdeps/sh/memset.S glibc-2.1.3/sysdeps/sh/memset.S --- glibc-2.1.3-original/sysdeps/sh/memset.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/memset.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,79 @@ +/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Kazumoto Kojima + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +/* void *memset (t, c, len) */ + +ENTRY(memset) + tst r6, r6 + bt/s end + mov r4, r3 + mov #3, r0 + cmp/hs r6, r0 + bt/s 2f + and r4, r0 + tst r0, r0 + bt/s 1f + add r0, r6 + add #-1, r0 + shll2 r0 + braf r0 + add #-4, r6 + + mov.b r5, @r4 + add #1, r4 + mov.b r5, @r4 + add #1, r4 + mov.b r5, @r4 + add #1, r4 +1: + extu.b r5, r0 + shll8 r5 + or r5, r0 + extu.w r0, r0 + mov r0, r5 + swap.w r5, r5 + or r0, r5 + +2: + add #-4, r6 + cmp/pz r6 + bf afew + mov.l r5, @r4 + bra 2b + add #4, r4 + +afew: + mov #-1, r0 + sub r6, r0 + shll2 r0 + braf r0 + nop + + mov.b r5, @r4 + add #1, r4 + mov.b r5, @r4 + add #1, r4 + mov.b r5, @r4 + add #1, r4 +end: + rts + mov r3, r0 +END(memset) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/__longjmp.S glibc-2.1.3/sysdeps/sh/sh3/__longjmp.S --- glibc-2.1.3-original/sysdeps/sh/sh3/__longjmp.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/__longjmp.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,44 @@ +/* longjmp for SH. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#define _SETJMP_H +#define _ASM +#include + +/* __longjmp(jmpbuf, val) */ + +ENTRY (__longjmp) + mov.l @r4+, r8 + mov.l @r4+, r9 + mov.l @r4+, r10 + mov.l @r4+, r11 + mov.l @r4+, r12 + mov.l @r4+, r13 + mov.l @r4+, r14 + mov.l @r4+, r15 + mov r5, r0 /* get the return value in place */ + tst r0, r0 + bf.s 1f + lds.l @r4+, pr + mov #1,r0 /* can't let setjmp() return zero! */ +1: + rts + ldc.l @r4+, gbr +END (__longjmp) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/bits/endian.h glibc-2.1.3/sysdeps/sh/sh3/bits/endian.h --- glibc-2.1.3-original/sysdeps/sh/sh3/bits/endian.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/bits/endian.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,13 @@ +/* SH is bi-endian but with a big-endian FPU. */ + +#ifndef _ENDIAN_H +# error "Never use directly; include instead." +#endif + +#ifdef __LITTLE_ENDIAN__ +#define __BYTE_ORDER __LITTLE_ENDIAN +#define __FLOAT_WORD_ORDER __LITTLE_ENDIAN +#else +#define __BYTE_ORDER __BIG_ENDIAN +#define __FLOAT_WORD_ORDER __BIG_ENDIAN +#endif diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/bits/huge_val.h glibc-2.1.3/sysdeps/sh/sh3/bits/huge_val.h --- glibc-2.1.3-original/sysdeps/sh/sh3/bits/huge_val.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/bits/huge_val.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,88 @@ +/* `HUGE_VAL' constants for IEEE 754 machines (where it is infinity). + Used by and functions for overflow. + SH version. + Copyright (C) 1992, 95, 96, 97, 98, 99, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +#include + +/* IEEE positive infinity (-HUGE_VAL is negative infinity). */ + +#ifdef __GNUC__ + +# define HUGE_VAL \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ + { __l: 0x000000007ff00000ULL }).__d) + +#else /* not GCC */ + +# include + +typedef union { unsigned char __c[8]; double __d; } __huge_val_t; + +# if __BYTE_ORDER == __BIG_ENDIAN +# define __HUGE_VAL_bytes { 0, 0, 0, 0, 0x7f, 0xf0, 0, 0 } +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __HUGE_VAL_bytes { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } +# endif + +static __huge_val_t __huge_val = { __HUGE_VAL_bytes }; +# define HUGE_VAL (__huge_val.__d) + +#endif /* GCC. */ + + +/* ISO C 9X extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */ + +#ifdef __USE_ISOC9X + +# ifdef __GNUC__ + +# define HUGE_VALF \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \ + { __l: 0x7f800000UL }).__d) + +# else /* not GCC */ + +typedef union { unsigned char __c[4]; float __f; } __huge_valf_t; + +# if __BYTE_ORDER == __BIG_ENDIAN +# define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 } +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f } +# endif + +static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; +# define HUGE_VALF (__huge_valf.__f) + +# endif /* GCC. */ + + +/* Generally there is no separate `long double' format and it is the + same as `double'. */ +# define HUGE_VALL HUGE_VAL + +#endif /* __USE_ISOC9X. */ diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/bits/setjmp.h glibc-2.1.3/sysdeps/sh/sh3/bits/setjmp.h --- glibc-2.1.3-original/sysdeps/sh/sh3/bits/setjmp.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/bits/setjmp.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,45 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Define the machine-dependent type `jmp_buf'. SH version. */ + +#ifndef _SETJMP_H +# error "Never include directly; use instead." +#endif + +#ifndef _ASM +typedef struct + { + /* Callee-saved registers r8 through r15. */ + int __regs[8]; + + /* Program counter. */ + __ptr_t __pc; + + /* The global pointer. */ + __ptr_t __gbr; + + } __jmp_buf[1]; +#endif + +#define JB_SIZE (4 * 10) + +/* Test if longjmp to JMPBUF would unwind the frame + containing a local variable at ADDRESS. */ +#define _JMPBUF_UNWINDS(jmpbuf, address) \ + ((__ptr_t) (address) < &(jmpbuf)[0].__regs[7]) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/bsd-_setjmp.S glibc-2.1.3/sysdeps/sh/sh3/bsd-_setjmp.S --- glibc-2.1.3-original/sysdeps/sh/sh3/bsd-_setjmp.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/bsd-_setjmp.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,51 @@ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. SH version. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This just does a tail-call to `__sigsetjmp (ARG, 0)'. + We cannot do it in C because it must be a tail-call, so frame-unwinding + in setjmp doesn't clobber the state restored by longjmp. */ + +#include + +ENTRY (_setjmp) +#ifdef PIC + mova 1f, r0 + mov.l 1f, r1 + bra 2f + add r1, r0 + .align 2 +1: + .long _GLOBAL_OFFSET_TABLE_ +2: + mov.l 3f, r1 + mov.l @(r0,r1), r1 + jmp @r1 + mov #0, r0 + .align 2 +3: + .long C_SYMBOL_NAME(__sigsetjmp@GOT) +#else + mov.l 1f, r1 + jmp @r1 + mov #0, r0 + .align 2 +1: + .long C_SYMBOL_NAME(__sigsetjmp) +#endif +END (_setjmp) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/bsd-setjmp.S glibc-2.1.3/sysdeps/sh/sh3/bsd-setjmp.S --- glibc-2.1.3-original/sysdeps/sh/sh3/bsd-setjmp.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/bsd-setjmp.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,51 @@ +/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. SH version. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This just does a tail-call to `__sigsetjmp (ARG, 1)'. + We cannot do it in C because it must be a tail-call, so frame-unwinding + in setjmp doesn't clobber the state restored by longjmp. */ + +#include + +ENTRY (setjmp) +#ifdef PIC + mova 1f, r0 + mov.l 1f, r1 + bra 2f + add r1, r0 + .align 2 +1: + .long _GLOBAL_OFFSET_TABLE_ +2: + mov.l 3f, r1 + mov.l @(r0,r1), r1 + jmp @r1 + mov #1, r0 + .align 2 +3: + .long C_SYMBOL_NAME(__sigsetjmp@GOT) +#else + mov.l 1f, r1 + jmp @r1 + mov #1, r0 + .align 2 +1: + .long C_SYMBOL_NAME(__sigsetjmp) +#endif +END (setjmp) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/dl-machine.h glibc-2.1.3/sysdeps/sh/sh3/dl-machine.h --- glibc-2.1.3-original/sysdeps/sh/sh3/dl-machine.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/dl-machine.h Sun Mar 12 16:02:39 2000 @@ -0,0 +1,523 @@ +/* Machine-dependent ELF dynamic relocation inline functions. SH-3 version. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef dl_machine_h +#define dl_machine_h + +/* Only dummy. This doesn't work. */ + +#define ELF_MACHINE_NAME "SH" + +#include + +#include + +/* Return nonzero iff E_MACHINE is compatible with the running host. */ +static inline int __attribute__ ((unused)) +elf_machine_matches_host (Elf32_Half e_machine) +{ + switch (e_machine) + { + case EM_SH: + return 1; + default: + return 0; + } +} + + +/* Return the link-time address of _DYNAMIC. Conveniently, this is the + first element of the GOT. This must be inlined in a function which + uses global data. */ +static inline Elf32_Addr __attribute__ ((unused)) +elf_machine_dynamic (void) +{ + register Elf32_Addr *got; + asm ("mov r12,%0" :"=r" (got)); + return *got; +} + + +/* Return the run-time load address of the shared object. */ +static inline Elf32_Addr __attribute__ ((unused)) +elf_machine_load_address (void) +{ + Elf32_Addr addr; + asm ("mov.l .L1,r0 + mov.l .L3,r2 + add r12,r2 + mov.l @(r0,r12),r0 + bra .L2 + sub r0,r2 + .align 2 + .L1: .long _dl_start@GOT + .L3: .long _dl_start@GOTOFF + .L2: mov r2,%0" + : "=r" (addr) : : "r0", "r1", "r2"); + return addr; +} + + +/* Set up the loaded object described by L so its unrelocated PLT + entries will jump to the on-demand fixup code in dl-runtime.c. */ + +static inline int __attribute__ ((unused)) +elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) +{ + Elf32_Addr *got; + extern void _dl_runtime_resolve (Elf32_Word); + extern void _dl_runtime_profile (Elf32_Word); + + if (l->l_info[DT_JMPREL] && lazy) + { + /* The GOT entries for functions in the PLT have not yet been filled + in. Their initial contents will arrange when called to load an + offset into the .rela.plt section and _GLOBAL_OFFSET_TABLE_[1], + and then jump to _GLOBAL_OFFSET_TABLE[2]. */ + got = (Elf32_Addr *) l->l_info[DT_PLTGOT]->d_un.d_ptr; + got[1] = (Elf32_Addr) l; /* Identify this shared object. */ + + /* The got[2] entry contains the address of a function which gets + called to get the address of a so far unresolved function and + jump to it. The profiling extension of the dynamic linker allows + to intercept the calls to collect information. In this case we + don't store the address in the GOT so that all future calls also + end in this function. */ + if (profile) + { + got[2] = (Elf32_Addr) &_dl_runtime_profile; + /* Say that we really want profiling and the timers are started. */ + _dl_profile_map = l; + } + else + /* This function will get called to fix up the GOT entry indicated by + the offset on the stack, and then jump to the resolved address. */ + got[2] = (Elf32_Addr) &_dl_runtime_resolve; + } + return lazy; +} + +/* This code is used in dl-runtime.c to call the `fixup' function + and then redirect to the address it returns. */ + +#define ELF_MACHINE_RUNTIME_FIXUP_ARGS int plt_type + +#ifdef PIC +#define FUN_ADDR "\ + mov.l 1f,r2 + mova 1f,r0 + bra 2f + add r0,r2 ! Get GOT address in r2 +0: .align 2 +1: .long _GLOBAL_OFFSET_TABLE_ +2: mov.l 3f,r0 + add r2,r0" +#define GOTJMP(x) #x "@GOTOFF" +#else +#define FUN_ADDR "\ + mov.l 3f,r0" +#define GOTJMP(x) #x +#endif + +#if defined (KERNEL_MATH_EMULATION) +#define FGR_SAVE "\ + sts.l fpscr, @-r15 + mov #8,r3 + swap.w r3, r3 + lds r3, fpscr + fmov.s fr11, @-r15 + fmov.s fr10, @-r15 + fmov.s fr9, @-r15 + fmov.s fr8, @-r15 + fmov.s fr7, @-r15 + fmov.s fr6, @-r15 + fmov.s fr5, @-r15 + fmov.s fr4, @-r15" +#define FGR_LOAD "\ + fmov.s @r15+, fr4 + fmov.s @r15+, fr5 + fmov.s @r15+, fr6 + fmov.s @r15+, fr7 + fmov.s @r15+, fr8 + fmov.s @r15+, fr9 + fmov.s @r15+, fr10 + fmov.s @r15+, fr11 + lds.l @r15+, fpscr" +#else +#define FGR_SAVE "" +#define FGR_LOAD "" +#endif + +#ifndef PROF +# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ + .text + .globl _dl_runtime_resolve + .type _dl_runtime_resolve, @function + .align 5 +_dl_runtime_resolve: + mov.l r3,@-r15 + mov.l r4,@-r15 + mov.l r5,@-r15 + mov.l r6,@-r15 + mov.l r7,@-r15 + mov.l r12,@-r15 + movt r3 ! Save T flag. + mov.l r3,@-r15 + " FGR_SAVE " + sts.l pr,@-r15 + mov r0,r4 ! PLT type + mov r2,r5 ! link map address + " FUN_ADDR " + jsr @r0 ! Call resolver. + mov r1,r6 ! reloc offset + lds.l @r15+,pr ! Get register content back. + " FGR_LOAD " + mov.l @r15+,r3 + shal r3 ! Lode T flag. + mov.l @r15+,r12 + mov.l @r15+,r7 + mov.l @r15+,r6 + mov.l @r15+,r5 + mov.l @r15+,r4 + jmp @r0 ! Jump to function address. + mov.l @r15+,r3 + .align 2 +3: + .long " GOTJMP (fixup) " + .size _dl_runtime_resolve, .-_dl_runtime_resolve + + .globl _dl_runtime_profile + .type _dl_runtime_profile, @function + .align 5 +_dl_runtime_profile: + mov.l r3,@-r15 + mov.l r4,@-r15 + mov.l r5,@-r15 + mov.l r6,@-r15 + mov.l r7,@-r15 + mov.l r12,@-r15 + movt r3 ! Save T flag. + mov.l r3,@-r15 + " FGR_SAVE " + sts.l pr,@-r15 + mov r0,r4 ! PLT type + mov r2,r5 ! link map address + sts pr,r7 ! return address + " FUN_ADDR " + jsr @r0 ! Call resolver. + mov r1,r6 ! reloc offset + lds.l @r15+,pr ! Get register content back. + " FGR_LOAD " + mov.l @r15+,r3 + shal r3 ! Lode T flag. + mov.l @r15+,r12 + mov.l @r15+,r7 + mov.l @r15+,r6 + mov.l @r15+,r5 + mov.l @r15+,r4 + jmp @r0 ! Jump to function address. + mov.l @r15+,r3 + .align 2 +3: + .long " GOTJMP (profile_fixup) " + .size _dl_runtime_profile, .-_dl_runtime_profile + .previous +"); +#else +# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ + .text + .globl _dl_runtime_resolve + .globl _dl_runtime_profile + .type _dl_runtime_resolve, @function + .type _dl_runtime_profile, @function + .align 5 +_dl_runtime_resolve: +_dl_runtime_profile: + mov.l r3,@-r15 + mov.l r4,@-r15 + mov.l r5,@-r15 + mov.l r6,@-r15 + mov.l r7,@-r15 + mov.l r12,@-r15 + movt r3 ! Save T flag. + mov.l r3,@-r15 + " FGR_SAVE " + sts.l pr,@-r15 + mov r0,r4 ! PLT type + mov r2,r5 ! link map address + sts pr,r7 ! return address + " FUN_ADDR " + jsr @r0 ! Call resolver. + mov r1,r6 ! reloc offset + lds.l @r15+,pr ! Get register content back. + " FGR_LOAD " + mov.l @r15+,r3 + shal r3 ! Lode T flag. + mov.l @r15+,r12 + mov.l @r15+,r7 + mov.l @r15+,r6 + mov.l @r15+,r5 + mov.l @r15+,r4 + jmp @r0 ! Jump to function address. + mov.l @r15+,r3 + .align 2 +3: + .long " GOTJMP (fixup) " + .size _dl_runtime_resolve, .-_dl_runtime_resolve + .size _dl_runtime_profile, .-_dl_runtime_profile + .previous +"); +#endif + +/* Mask identifying addresses reserved for the user program, + where the dynamic linker should not map anything. */ +#define ELF_MACHINE_USER_ADDRESS_MASK 0x80000000UL + +/* Initial entry point code for the dynamic linker. + The C function `_dl_start' is the real entry point; + its return value is the user program's entry point. */ + +#define RTLD_START asm ("\ +.text\n\ +.globl _start\n\ +.globl _dl_start_user\n\ +_start:\n\ + mov r15,r4\n\ + mov.l .L_dl_start,r1\n\ + mova .L_dl_start,r0\n\ + add r1,r0\n\ + jsr @r0\n\ + nop\n\ +_dl_start_user:\n\ + ! Save the user entry point address in r8.\n\ + mov r0,r8\n\ + ! Point r12 at the GOT.\n\ + mov.l 1f,r12\n\ + mova 1f,r0\n\ + bra 2f\n\ + add r0,r12\n\ + .align 2\n\ +1: .long _GLOBAL_OFFSET_TABLE_\n\ +2: ! Store the highest stack address\n\ + mov.l .L_stack_end,r0\n\ + mov.l @(r0,r12),r0\n\ + mov.l r15,@r0\n\ + ! See if we were run as a command with the executable file\n\ + ! name as an extra leading argument.\n\ + mov.l .L_dl_skip_args,r0\n\ + mov.l @(r0,r12),r0\n\ + mov.l @r0,r0\n\ + ! Get the original argument count.\n\ + mov.l @r15,r2\n\ + ! Subtract _dl_skip_args from it.\n\ + sub r0,r2\n\ + ! Adjust the stack pointer to skip _dl_skip_args words.\n\ + shll2 r0\n\ + add r0,r15\n\ + ! Store back the modified argument count.\n\ + mov.l r2,@r15\n\ + ! Push the searchlist of the main object as argument in\n\ + ! _dl_init_next call below.\n\ + mov.l .L_dl_main_searchlist,r0\n\ + mov.l @(r0,r12),r0\n\ + mov.l @r0,r9\n\ +0: mov r9,r4\n\ + ! Call _dl_init_next to return the address of an initializer\n\ + ! function to run.\n\ + mov.l .L_dl_init_next,r1\n\ + mova .L_dl_init_next,r0\n\ + add r1,r0\n\ + jsr @r0\n\ + nop\n\ + ! Check for zero return, when out of initializers.\n\ + tst r0,r0\n\ + bt 1f\n\ + ! Call the shared object initializer function.\n\ + jsr @r0\n\ + nop\n\ + ! Loop to call _dl_init_next for the next initializer.\n\ + bra 0b\n\ + nop\n\ +1: ! Clear the startup flag.\n\ + mov.l .L_dl_starting_up,r0\n\ + mov.l @(r0,r12),r0\n\ + mov #0,r2\n\ + mov.l r2,@r0\n\ + ! Pass our finalizer function to the user in r4, as per ELF ABI.\n\ + mov.l .L_dl_fini,r0\n\ + mov.l @(r0,r12),r4\n\ + ! Jump to the user's entry point.\n\ + jmp @r8\n\ + nop\n\ + .align 2\n\ +.L_dl_start:\n\ + .long _dl_start@PLT\n\ +.L_stack_end:\n\ + .long __libc_stack_end@GOT\n\ +.L_dl_skip_args:\n\ + .long _dl_skip_args@GOT\n\ +.L_dl_main_searchlist:\n\ + .long _dl_main_searchlist@GOT\n\ +.L_dl_init_next:\n\ + .long _dl_init_next@PLT\n\ +.L_dl_starting_up:\n\ + .long _dl_starting_up@GOT\n\ +.L_dl_fini:\n\ + .long _dl_fini@GOT\n\ +.previous\n\ +"); + +/* Nonzero iff TYPE should not be allowed to resolve to one of + the main executable's symbols, as for a COPY reloc. */ +#define elf_machine_lookup_noexec_p(type) ((type) == R_SH_COPY) + +/* Nonzero iff TYPE describes relocation of a PLT entry, so + PLT entries should not be allowed to define the value. */ +#define elf_machine_lookup_noplt_p(type) ((type) == R_SH_JMP_SLOT) + +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ +#define ELF_MACHINE_JMP_SLOT R_SH_JMP_SLOT + +/* We define an initialization functions. This is called very early in + _dl_sysdep_start. */ +#define DL_PLATFORM_INIT dl_platform_init () + +extern const char *_dl_platform; + +static inline void __attribute__ ((unused)) +dl_platform_init (void) +{ + if (_dl_platform != NULL && *_dl_platform == '\0') + /* Avoid an empty string which would disturb us. */ + _dl_platform = NULL; +} + +static inline void +elf_machine_fixup_plt (struct link_map *map, const Elf32_Rela *reloc, + Elf32_Addr *reloc_addr, Elf32_Addr value) +{ + *reloc_addr = value; +} + +/* Return the final value of a plt relocation. */ +static inline Elf32_Addr +elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, + Elf32_Addr value) +{ + return value + reloc->r_addend; +} + +#endif /* !dl_machine_h */ + +#ifdef RESOLVE + +/* SH never uses Elf32_Rel relocations. */ +#define ELF_MACHINE_NO_REL 1 + +extern char **_dl_argv; + +/* Perform the relocation specified by RELOC and SYM (which is fully resolved). + MAP is the object containing the reloc. */ + +static inline void +elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, + const Elf32_Sym *sym, const struct r_found_version *version, + Elf32_Addr *const reloc_addr) +{ + if (ELF32_R_TYPE (reloc->r_info) == R_SH_RELATIVE) + { +#ifndef RTLD_BOOTSTRAP + if (map != &_dl_rtld_map) /* Already done in rtld itself. */ +#endif + *reloc_addr = map->l_addr + reloc->r_addend; + } + else if (ELF32_R_TYPE (reloc->r_info) != R_SH_NONE) + { + const Elf32_Sym *const refsym = sym; + Elf32_Addr value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info)); + if (sym) + value += sym->st_value; + value += reloc->r_addend; + + switch (ELF32_R_TYPE (reloc->r_info)) + { + case R_SH_COPY: + if (sym == NULL) + /* This can happen in trace mode if an object could not be + found. */ + break; + if (sym->st_size > refsym->st_size + || (sym->st_size < refsym->st_size && _dl_verbose)) + { + const char *strtab; + + strtab = (const char *) map->l_info[DT_STRTAB]->d_un.d_ptr; + _dl_sysdep_error (_dl_argv[0] ?: "", + ": Symbol `", strtab + refsym->st_name, + "' has different size in shared object, " + "consider re-linking\n", NULL); + } + memcpy (reloc_addr, (void *) value, MIN (sym->st_size, + refsym->st_size)); + break; + case R_SH_GLOB_DAT: + case R_SH_JMP_SLOT: + *reloc_addr = value; + break; + case R_SH_DIR32: + { +#ifndef RTLD_BOOTSTRAP + /* This is defined in rtld.c, but nowhere in the static + libc.a; make the reference weak so static programs can + still link. This declaration cannot be done when + compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because + rtld.c contains the common defn for _dl_rtld_map, which + is incompatible with a weak decl in the same file. */ + weak_extern (_dl_rtld_map); + if (map == &_dl_rtld_map) + /* Undo the relocation done here during bootstrapping. + Now we will relocate it anew, possibly using a + binding found in the user program or a loaded library + rather than the dynamic linker's built-in definitions + used while loading those libraries. */ + value -= map->l_addr + refsym->st_value + reloc->r_addend; +#endif + *reloc_addr = value; + break; + } + case R_SH_REL32: + *reloc_addr = (value - (Elf32_Addr) reloc_addr); + break; + default: + assert (! "unexpected dynamic reloc type"); + break; + } + } +} + +static inline void +elf_machine_lazy_rel (Elf32_Addr l_addr, const Elf32_Rela *reloc) +{ + Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); + /* Check for unexpected PLT reloc type. */ + assert (ELF32_R_TYPE (reloc->r_info) == R_SH_JMP_SLOT); + *reloc_addr += l_addr; /* + reloc->r_addend; */ +} + +#endif /* RESOLVE */ diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/elf/crti.S glibc-2.1.3/sysdeps/sh/sh3/elf/crti.S --- glibc-2.1.3-original/sysdeps/sh/sh3/elf/crti.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/elf/crti.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,94 @@ + .file "initfini.c" +gcc2_compiled.: + +#include "defs.h" +#define PIC + +/*@HEADER_ENDS*/ +/*@_init_PROLOG_BEGINS*/ + .section .init + .align 5 + .global _init + .type _init,@function +_init: + mov.l r12,@-r15 + mov.l r14,@-r15 + sts.l pr,@-r15 +#ifdef PIC + mova .L22,r0 + mov.l .L22,r12 + add r0,r12 + mova .L23,r0 + mov.l .L23,r1 + add r0,r1 +#else + mov.l .L23,r1 +#endif + jsr @r1 + mov r15,r14 +#ifdef KERNEL_MATH_EMULATION +#ifdef PIC + mova .L24,r0 + mov.l .L24,r1 + add r0,r1 +#else + mov.l .L24,r1 +#endif + mov #8,r4 + jsr @r1 + swap.w r4,r4 +#endif + bra 1f + nop + .align 2 +#ifdef PIC +.L22: + .long _GLOBAL_OFFSET_TABLE_ +.L23: + .long __gmon_start__@PLT +#else +.L23: + .long __gmon_start__ +#endif +#ifdef KERNEL_MATH_EMULATION +.L24: +#ifdef PIC + .long __set_fpscr@PLT +#else + .long __set_fpscr +#endif +#endif +1: + ALIGN + END_INIT + + +/*@_init_PROLOG_ENDS*/ +/*@_fini_PROLOG_BEGINS*/ + .section .fini + .align 5 + .global _fini + .type _fini,@function +_fini: + mov.l r12,@-$r15 + mov.l r14,@-r15 + sts.l pr,@-r15 +#ifdef PIC + mova .L27,r0 + mov.l .L27,r12 + add r0,r12 +#endif + mov r15,r14 + ALIGN + END_FINI +#ifdef PIC + bra 1f + nop + .align 2 +.L27: + .long _GLOBAL_OFFSET_TABLE_ +#endif +1: +/*@_fini_PROLOG_ENDS*/ +/*@TRAILER_BEGINS*/ + .ident "GCC: (GNU) 2.95.1 19990816 (release)" diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/elf/crtn.S glibc-2.1.3/sysdeps/sh/sh3/elf/crtn.S --- glibc-2.1.3-original/sysdeps/sh/sh3/elf/crtn.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/elf/crtn.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,40 @@ + .file "initfini.c" +gcc2_compiled.: + +#include "defs.h" +#define PIC + +/*@HEADER_ENDS*/ +/*@_init_EPILOG_BEGINS*/ + .section .init + mov r14,r15 + lds.l @r15+,pr + mov.l @r15+,r14 + rts + mov.l @r15+,r12 + END_INIT + .section .text + .align 5 + .weak __gmon_start__ + .type __gmon_start__,@function +__gmon_start__: + mov.l r14,@-r15 + mov r15,r14 + mov r14,r15 + rts + mov.l @r15+,r14 + +/*@_init_EPILOG_ENDS*/ +/*@_fini_EPILOG_BEGINS*/ + .section .fini + mov r14,r15 + lds.l @r15+,pr + mov.l @r15+,r14 + rts + mov.l @r15+,r12 + + END_FINI + +/*@_fini_EPILOG_ENDS*/ +/*@TRAILER_BEGINS*/ + .ident "GCC: (GNU) 2.95.1 19990816 (release)" diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/elf/start.S glibc-2.1.3/sysdeps/sh/sh3/elf/start.S --- glibc-2.1.3-original/sysdeps/sh/sh3/elf/start.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/elf/start.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,90 @@ +/* Startup code for SH & ELF + Copyright (C) 1999 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This is the canonical entry point, usually the first thing in the text + segment. + + Note that the code in the .init section has already been run. + This includes _init and _libc_init + + + At this entry point, most registers' values are unspecified, except: + + r4 Contains a function pointer to be registered with `atexit'. + This is how the dynamic linker arranges to have DT_FINI + functions called for shared libraries that have been loaded + before this code runs. + + sp The stack contains the arguments and environment: + 0(sp) argc + 4(sp) argv[0] + ... + (4*argc)(sp) NULL + (4*(argc+1))(sp) envp[0] + ... + NULL +*/ + + .text + .globl _start +_start: + /* Clear the frame pointer since this is the outermost frame. */ + mov #0, r14 + + /* Pop argc off the stack and save a pointer to argv */ + mov.l @r15+,r5 + mov r15, r6 + + /* Push the last arguments to main() onto the stack */ + mov.l r4,@-r15 + mov.l L_fini,r0 + mov.l r0,@-r15 + + /* Set up the other arguments for main() that go in registers */ + mov.l L_main,r4 + mov.l L_init,r7 + + /* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */ + + /* Let the libc call main and exit with its return code. */ + mov.l L_libc_start_main,r1 + jsr @r1 + nop + /* should never get here....*/ + mov.l L_abort,r1 + jsr @r1 + nop + .align 2 +L_main: + .long main +L_init: + .long _init +L_fini: + .long _fini +L_libc_start_main: + .long __libc_start_main +L_abort: + .long abort +/* Define a symbol for the first piece of initialized data. */ + .data + .globl __data_start +__data_start: + .long 0 + .weak data_start + data_start = __data_start diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/setjmp.S glibc-2.1.3/sysdeps/sh/sh3/setjmp.S --- glibc-2.1.3-original/sysdeps/sh/sh3/setjmp.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/setjmp.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,67 @@ +/* setjmp for SH4. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#define _SETJMP_H +#define _ASM +#include + + /* Binary compatibility entry point. */ +ENTRY (__setjmp) + mov #0, r5 +ENTRY (__sigsetjmp) + /* Save registers */ + add #JB_SIZE, r4 + stc.l gbr, @-r4 + sts.l pr, @-r4 + mov.l r15, @-r4 + mov.l r14, @-r4 + mov.l r13, @-r4 + mov.l r12, @-r4 + mov.l r11, @-r4 + mov.l r10, @-r4 + mov.l r9, @-r4 + mov.l r8, @-r4 + + /* Make a tail call to __sigjmp_save; it takes the same args. */ +#ifdef PIC + mov.l 1f, r1 + mova 1f, r0 + bra 2f + add r1, r0 + .align 2 +1: + .long _GLOBAL_OFFSET_TABLE_ +2: + mov.l .L1, r1 + mov.l @(r0,r1), r1 + jmp @r1 + nop + .align 2 +.L1: + .long C_SYMBOL_NAME(__sigjmp_save@GOT) +#else + mov.l .L1, r1 + jmp @r1 + nop + .align 2 +.L1: + .long C_SYMBOL_NAME(__sigjmp_save) +#endif +END (__setjmp) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/sys/ucontext.h glibc-2.1.3/sysdeps/sh/sh3/sys/ucontext.h --- glibc-2.1.3-original/sysdeps/sh/sh3/sys/ucontext.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh3/sys/ucontext.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,99 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Where is System V/SH ABI? */ + +#ifndef _SYS_UCONTEXT_H +#define _SYS_UCONTEXT_H 1 + +#include +#include + +typedef int greg_t; + +/* Number of general registers. */ +#define NGREG 16 + +/* Container for all general registers. */ +typedef greg_t gregset_t[NGREG]; + +/* Number of each register is the `gregset_t' array. */ +enum +{ + R0 = 0, +#define R0 R0 + R1 = 1, +#define R1 R1 + R2 = 2, +#define R2 R2 + R3 = 3, +#define R3 R3 + R4 = 4, +#define R4 R4 + R5 = 5, +#define R5 R5 + R6 = 6, +#define R6 R6 + R7 = 7, +#define R7 R7 + R8 = 8, +#define R8 R8 + R9 = 9, +#define R9 R9 + R10 = 10, +#define R10 R10 + R11 = 11, +#define R11 R11 + R12 = 12, +#define R12 R12 + R13 = 13, +#define R13 R13 + R14 = 14, +#define R14 R14 + R15 = 15, +#define R15 R15 +}; + +typedef int freg_t; + +/* Number of FPU registers. */ +#define NFREG 16 + +/* Structure to describe FPU registers. */ +typedef freg_t fpregset_t[NFREG]; + +/* Context to describe whole processor state. */ +typedef struct + { + gregset_t gregs; + fpregset_t fpregs; + fpregset_t xfpregs; + } mcontext_t; + +/* Userlevel context. */ +typedef struct ucontext + { + unsigned long int uc_flags; + struct ucontext *uc_link; + __sigset_t uc_sigmask; + stack_t uc_stack; + mcontext_t uc_mcontext; + long int uc_filler[5]; + } ucontext_t; + +#endif /* sys/ucontext.h */ diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/__longjmp.S glibc-2.1.3/sysdeps/sh/sh4/__longjmp.S --- glibc-2.1.3-original/sysdeps/sh/sh4/__longjmp.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/__longjmp.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,49 @@ +/* longjmp for SH. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#define _SETJMP_H +#define _ASM +#include + +/* __longjmp(jmpbuf, val) */ + +ENTRY (__longjmp) + mov.l @r4+, r8 + mov.l @r4+, r9 + mov.l @r4+, r10 + mov.l @r4+, r11 + mov.l @r4+, r12 + mov.l @r4+, r13 + mov.l @r4+, r14 + mov.l @r4+, r15 + mov r5, r0 /* get the return value in place */ + tst r0, r0 + bf.s 1f + lds.l @r4+, pr + mov #1,r0 /* can't let setjmp() return zero! */ +1: + ldc.l @r4+, gbr + lds.l @r4+, fpscr + fmov.s @r4+, fr12 + fmov.s @r4+, fr13 + fmov.s @r4+, fr14 + rts + fmov.s @r4+, fr15 +END (__longjmp) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/bits/endian.h glibc-2.1.3/sysdeps/sh/sh4/bits/endian.h --- glibc-2.1.3-original/sysdeps/sh/sh4/bits/endian.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/bits/endian.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,13 @@ +/* SH is bi-endian but with a big-endian FPU. */ + +#ifndef _ENDIAN_H +# error "Never use directly; include instead." +#endif + +#ifdef __LITTLE_ENDIAN__ +#define __BYTE_ORDER __LITTLE_ENDIAN +#define __FLOAT_WORD_ORDER __LITTLE_ENDIAN +#else +#define __BYTE_ORDER __BIG_ENDIAN +#define __FLOAT_WORD_ORDER __BIG_ENDIAN +#endif diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/bits/huge_val.h glibc-2.1.3/sysdeps/sh/sh4/bits/huge_val.h --- glibc-2.1.3-original/sysdeps/sh/sh4/bits/huge_val.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/bits/huge_val.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,88 @@ +/* `HUGE_VAL' constants for IEEE 754 machines (where it is infinity). + Used by and functions for overflow. + SH version. + Copyright (C) 1992, 95, 96, 97, 98, 99, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +#include + +/* IEEE positive infinity (-HUGE_VAL is negative infinity). */ + +#ifdef __GNUC__ + +# define HUGE_VAL \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ + { __l: 0x000000007ff00000ULL }).__d) + +#else /* not GCC */ + +# include + +typedef union { unsigned char __c[8]; double __d; } __huge_val_t; + +# if __BYTE_ORDER == __BIG_ENDIAN +# define __HUGE_VAL_bytes { 0, 0, 0, 0, 0x7f, 0xf0, 0, 0 } +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __HUGE_VAL_bytes { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } +# endif + +static __huge_val_t __huge_val = { __HUGE_VAL_bytes }; +# define HUGE_VAL (__huge_val.__d) + +#endif /* GCC. */ + + +/* ISO C 9X extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */ + +#ifdef __USE_ISOC9X + +# ifdef __GNUC__ + +# define HUGE_VALF \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \ + { __l: 0x7f800000UL }).__d) + +# else /* not GCC */ + +typedef union { unsigned char __c[4]; float __f; } __huge_valf_t; + +# if __BYTE_ORDER == __BIG_ENDIAN +# define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 } +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f } +# endif + +static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; +# define HUGE_VALF (__huge_valf.__f) + +# endif /* GCC. */ + + +/* Generally there is no separate `long double' format and it is the + same as `double'. */ +# define HUGE_VALL HUGE_VAL + +#endif /* __USE_ISOC9X. */ diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/bits/setjmp.h glibc-2.1.3/sysdeps/sh/sh4/bits/setjmp.h --- glibc-2.1.3-original/sysdeps/sh/sh4/bits/setjmp.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/bits/setjmp.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,50 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Define the machine-dependent type `jmp_buf'. SH version. */ + +#ifndef _SETJMP_H +# error "Never include directly; use instead." +#endif + +#ifndef _ASM +typedef struct + { + /* Callee-saved registers r8 through r15. */ + int __regs[8]; + + /* Program counter. */ + __ptr_t __pc; + + /* The global pointer. */ + __ptr_t __gbr; + + /* Floating point status register. */ + int __fpscr; + + /* Callee-saved floating point registers fr12 through fr15. */ + int __fpregs[4]; + } __jmp_buf[1]; +#endif + +#define JB_SIZE (4 * 15) + +/* Test if longjmp to JMPBUF would unwind the frame + containing a local variable at ADDRESS. */ +#define _JMPBUF_UNWINDS(jmpbuf, address) \ + ((__ptr_t) (address) < &(jmpbuf)[0].__regs[7]) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/bsd-_setjmp.S glibc-2.1.3/sysdeps/sh/sh4/bsd-_setjmp.S --- glibc-2.1.3-original/sysdeps/sh/sh4/bsd-_setjmp.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/bsd-_setjmp.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,50 @@ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. SH version. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This just does a tail-call to `__sigsetjmp (ARG, 0)'. + We cannot do it in C because it must be a tail-call, so frame-unwinding + in setjmp doesn't clobber the state restored by longjmp. */ + +#include + +ENTRY (_setjmp) +#ifdef PIC + mova 1f, r0 + mov.l 1f, r1 + bra 2f + add r1, r0 + .align 2 +1: + .long _GLOBAL_OFFSET_TABLE_ +2: + mov.l 3f, r1 + mov.l @(r0,r1), r1 + jmp @r1 + mov #0, r0 +3: + .long C_SYMBOL_NAME(__sigsetjmp@GOT) +#else + mov.l 1f, r1 + jmp @r1 + mov #0, r0 + .align 2 +1: + .long C_SYMBOL_NAME(__sigsetjmp) +#endif +END (_setjmp) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/bsd-setjmp.S glibc-2.1.3/sysdeps/sh/sh4/bsd-setjmp.S --- glibc-2.1.3-original/sysdeps/sh/sh4/bsd-setjmp.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/bsd-setjmp.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,50 @@ +/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. SH version. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This just does a tail-call to `__sigsetjmp (ARG, 1)'. + We cannot do it in C because it must be a tail-call, so frame-unwinding + in setjmp doesn't clobber the state restored by longjmp. */ + +#include + +ENTRY (setjmp) +#ifdef PIC + mova 1f, r0 + mov.l 1f, r1 + bra 2f + add r1, r0 + .align 2 +1: + .long _GLOBAL_OFFSET_TABLE_ +2: + mov.l 3f, r1 + mov.l @(r0,r1), r1 + jmp @r1 + mov #1, r0 +3: + .long C_SYMBOL_NAME(__sigsetjmp@GOT) +#else + mov.l 1f, r1 + jmp @r1 + mov #1, r0 + .align 2 +1: + .long C_SYMBOL_NAME(__sigsetjmp) +#endif +END (setjmp) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/dl-machine.h glibc-2.1.3/sysdeps/sh/sh4/dl-machine.h --- glibc-2.1.3-original/sysdeps/sh/sh4/dl-machine.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/dl-machine.h Sun Mar 12 16:02:25 2000 @@ -0,0 +1,518 @@ +/* Machine-dependent ELF dynamic relocation inline functions. SH-4 version. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef dl_machine_h +#define dl_machine_h + +/* Only dummy. This doesn't work. */ + +#define ELF_MACHINE_NAME "SH" + +#include + +#include + +/* Return nonzero iff E_MACHINE is compatible with the running host. */ +static inline int __attribute__ ((unused)) +elf_machine_matches_host (Elf32_Half e_machine) +{ + switch (e_machine) + { + case EM_SH: + return 1; + default: + return 0; + } +} + + +/* Return the link-time address of _DYNAMIC. Conveniently, this is the + first element of the GOT. This must be inlined in a function which + uses global data. */ +static inline Elf32_Addr __attribute__ ((unused)) +elf_machine_dynamic (void) +{ + register Elf32_Addr *got; + asm ("mov r12,%0" :"=r" (got)); + return *got; +} + + +/* Return the run-time load address of the shared object. */ +static inline Elf32_Addr __attribute__ ((unused)) +elf_machine_load_address (void) +{ + Elf32_Addr addr; + asm ("mov.l .L1,r0 + mov.l .L3,r2 + add r12,r2 + mov.l @(r0,r12),r0 + bra .L2 + sub r0,r2 + .align 2 + .L1: .long _dl_start@GOT + .L3: .long _dl_start@GOTOFF + .L2: mov r2,%0" + : "=r" (addr) : : "r0", "r1", "r2"); + return addr; +} + + +/* Set up the loaded object described by L so its unrelocated PLT + entries will jump to the on-demand fixup code in dl-runtime.c. */ + +static inline int __attribute__ ((unused)) +elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) +{ + Elf32_Addr *got; + extern void _dl_runtime_resolve (Elf32_Word); + extern void _dl_runtime_profile (Elf32_Word); + + if (l->l_info[DT_JMPREL] && lazy) + { + /* The GOT entries for functions in the PLT have not yet been filled + in. Their initial contents will arrange when called to load an + offset into the .rela.plt section and _GLOBAL_OFFSET_TABLE_[1], + and then jump to _GLOBAL_OFFSET_TABLE[2]. */ + got = (Elf32_Addr *) l->l_info[DT_PLTGOT]->d_un.d_ptr; + got[1] = (Elf32_Addr) l; /* Identify this shared object. */ + + /* The got[2] entry contains the address of a function which gets + called to get the address of a so far unresolved function and + jump to it. The profiling extension of the dynamic linker allows + to intercept the calls to collect information. In this case we + don't store the address in the GOT so that all future calls also + end in this function. */ + if (profile) + { + got[2] = (Elf32_Addr) &_dl_runtime_profile; + /* Say that we really want profiling and the timers are started. */ + _dl_profile_map = l; + } + else + /* This function will get called to fix up the GOT entry indicated by + the offset on the stack, and then jump to the resolved address. */ + got[2] = (Elf32_Addr) &_dl_runtime_resolve; + } + return lazy; +} + +/* This code is used in dl-runtime.c to call the `fixup' function + and then redirect to the address it returns. */ + +#define ELF_MACHINE_RUNTIME_FIXUP_ARGS int plt_type + +#ifdef PIC +#define FUN_ADDR "\ + mov.l 1f,r2 + mova 1f,r0 + bra 2f + add r0,r2 ! Get GOT address in r2 +0: .align 2 +1: .long _GLOBAL_OFFSET_TABLE_ +2: mov.l 3f,r0 + add r2,r0" +#define GOTJMP(x) #x "@GOTOFF" +#else +#define FUN_ADDR "\ + mov.l 3f,r0" +#define GOTJMP(x) #x +#endif + +#define FGR_SAVE "\ + sts.l fpscr, @-r15 + mov #8,r3 + swap.w r3, r3 + lds r3, fpscr + fmov.s fr11, @-r15 + fmov.s fr10, @-r15 + fmov.s fr9, @-r15 + fmov.s fr8, @-r15 + fmov.s fr7, @-r15 + fmov.s fr6, @-r15 + fmov.s fr5, @-r15 + fmov.s fr4, @-r15" +#define FGR_LOAD "\ + fmov.s @r15+, fr4 + fmov.s @r15+, fr5 + fmov.s @r15+, fr6 + fmov.s @r15+, fr7 + fmov.s @r15+, fr8 + fmov.s @r15+, fr9 + fmov.s @r15+, fr10 + fmov.s @r15+, fr11 + lds.l @r15+, fpscr" + +#ifndef PROF +# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ + .text + .globl _dl_runtime_resolve + .type _dl_runtime_resolve, @function + .align 5 +_dl_runtime_resolve: + mov.l r3,@-r15 + mov.l r4,@-r15 + mov.l r5,@-r15 + mov.l r6,@-r15 + mov.l r7,@-r15 + mov.l r12,@-r15 + movt r3 ! Save T flag. + mov.l r3,@-r15 + " FGR_SAVE " + sts.l pr,@-r15 + mov r0,r4 ! PLT type + mov r2,r5 ! link map address + " FUN_ADDR " + jsr @r0 ! Call resolver. + mov r1,r6 ! reloc offset + lds.l @r15+,pr ! Get register content back. + " FGR_LOAD " + mov.l @r15+,r3 + shal r3 ! Lode T flag. + mov.l @r15+,r12 + mov.l @r15+,r7 + mov.l @r15+,r6 + mov.l @r15+,r5 + mov.l @r15+,r4 + jmp @r0 ! Jump to function address. + mov.l @r15+,r3 + .align 2 +3: + .long " GOTJMP (fixup) " + .size _dl_runtime_resolve, .-_dl_runtime_resolve + + .globl _dl_runtime_profile + .type _dl_runtime_profile, @function + .align 5 +_dl_runtime_profile: + mov.l r3,@-r15 + mov.l r4,@-r15 + mov.l r5,@-r15 + mov.l r6,@-r15 + mov.l r7,@-r15 + mov.l r12,@-r15 + movt r3 ! Save T flag. + mov.l r3,@-r15 + " FGR_SAVE " + sts.l pr,@-r15 + mov r0,r4 ! PLT type + mov r2,r5 ! link map address + sts pr,r7 ! return address + " FUN_ADDR " + jsr @r0 ! Call resolver. + mov r1,r6 ! reloc offset + lds.l @r15+,pr ! Get register content back. + " FGR_LOAD " + mov.l @r15+,r3 + shal r3 ! Lode T flag. + mov.l @r15+,r12 + mov.l @r15+,r7 + mov.l @r15+,r6 + mov.l @r15+,r5 + mov.l @r15+,r4 + jmp @r0 ! Jump to function address. + mov.l @r15+,r3 + .align 2 +3: + .long " GOTJMP (profile_fixup) " + .size _dl_runtime_profile, .-_dl_runtime_profile + .previous +"); +#else +# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ + .text + .globl _dl_runtime_resolve + .globl _dl_runtime_profile + .type _dl_runtime_resolve, @function + .type _dl_runtime_profile, @function + .align 5 +_dl_runtime_resolve: +_dl_runtime_profile: + mov.l r3,@-r15 + mov.l r4,@-r15 + mov.l r5,@-r15 + mov.l r6,@-r15 + mov.l r7,@-r15 + mov.l r12,@-r15 + movt r3 ! Save T flag. + mov.l r3,@-r15 + " FGR_SAVE " + sts.l pr,@-r15 + mov r0,r4 ! PLT type + mov r2,r5 ! link map address + sts pr,r7 ! return address + " FUN_ADDR " + jsr @r0 ! Call resolver. + mov r1,r6 ! reloc offset + lds.l @r15+,pr ! Get register content back. + " FGR_LOAD " + mov.l @r15+,r3 + shal r3 ! Lode T flag. + mov.l @r15+,r12 + mov.l @r15+,r7 + mov.l @r15+,r6 + mov.l @r15+,r5 + mov.l @r15+,r4 + jmp @r0 ! Jump to function address. + mov.l @r15+,r3 + .align 2 +3: + .long " GOTJMP (fixup) " + .size _dl_runtime_resolve, .-_dl_runtime_resolve + .size _dl_runtime_profile, .-_dl_runtime_profile + .previous +"); +#endif + +/* Mask identifying addresses reserved for the user program, + where the dynamic linker should not map anything. */ +#define ELF_MACHINE_USER_ADDRESS_MASK 0x80000000UL + +/* Initial entry point code for the dynamic linker. + The C function `_dl_start' is the real entry point; + its return value is the user program's entry point. */ + +#define RTLD_START asm ("\ +.text\n\ +.globl _start\n\ +.globl _dl_start_user\n\ +_start:\n\ + mov r15,r4\n\ + mov.l .L_dl_start,r1\n\ + mova .L_dl_start,r0\n\ + add r1,r0\n\ + jsr @r0\n\ + nop\n\ +_dl_start_user:\n\ + ! Save the user entry point address in r8.\n\ + mov r0,r8\n\ + ! Point r12 at the GOT.\n\ + mov.l 1f,r12\n\ + mova 1f,r0\n\ + bra 2f\n\ + add r0,r12\n\ + .align 2\n\ +1: .long _GLOBAL_OFFSET_TABLE_\n\ +2: ! Store the highest stack address\n\ + mov.l .L_stack_end,r0\n\ + mov.l @(r0,r12),r0\n\ + mov.l r15,@r0\n\ + ! See if we were run as a command with the executable file\n\ + ! name as an extra leading argument.\n\ + mov.l .L_dl_skip_args,r0\n\ + mov.l @(r0,r12),r0\n\ + mov.l @r0,r0\n\ + ! Get the original argument count.\n\ + mov.l @r15,r2\n\ + ! Subtract _dl_skip_args from it.\n\ + sub r0,r2\n\ + ! Adjust the stack pointer to skip _dl_skip_args words.\n\ + shll2 r0\n\ + add r0,r15\n\ + ! Store back the modified argument count.\n\ + mov.l r2,@r15\n\ + ! Push the searchlist of the main object as argument in\n\ + ! _dl_init_next call below.\n\ + mov.l .L_dl_main_searchlist,r0\n\ + mov.l @(r0,r12),r0\n\ + mov.l @r0,r9\n\ +0: mov r9,r4\n\ + ! Call _dl_init_next to return the address of an initializer\n\ + ! function to run.\n\ + mov.l .L_dl_init_next,r1\n\ + mova .L_dl_init_next,r0\n\ + add r1,r0\n\ + jsr @r0\n\ + nop\n\ + ! Check for zero return, when out of initializers.\n\ + tst r0,r0\n\ + bt 1f\n\ + ! Call the shared object initializer function.\n\ + jsr @r0\n\ + nop\n\ + ! Loop to call _dl_init_next for the next initializer.\n\ + bra 0b\n\ + nop\n\ +1: ! Clear the startup flag.\n\ + mov.l .L_dl_starting_up,r0\n\ + mov.l @(r0,r12),r0\n\ + mov #0,r2\n\ + mov.l r2,@r0\n\ + ! Pass our finalizer function to the user in r4, as per ELF ABI.\n\ + mov.l .L_dl_fini,r0\n\ + mov.l @(r0,r12),r4\n\ + ! Jump to the user's entry point.\n\ + jmp @r8\n\ + nop\n\ + .align 2\n\ +.L_dl_start:\n\ + .long _dl_start@PLT\n\ +.L_stack_end:\n\ + .long __libc_stack_end@GOT\n\ +.L_dl_skip_args:\n\ + .long _dl_skip_args@GOT\n\ +.L_dl_main_searchlist:\n\ + .long _dl_main_searchlist@GOT\n\ +.L_dl_init_next:\n\ + .long _dl_init_next@PLT\n\ +.L_dl_starting_up:\n\ + .long _dl_starting_up@GOT\n\ +.L_dl_fini:\n\ + .long _dl_fini@GOT\n\ +.previous\n\ +"); + +/* Nonzero iff TYPE should not be allowed to resolve to one of + the main executable's symbols, as for a COPY reloc. */ +#define elf_machine_lookup_noexec_p(type) ((type) == R_SH_COPY) + +/* Nonzero iff TYPE describes relocation of a PLT entry, so + PLT entries should not be allowed to define the value. */ +#define elf_machine_lookup_noplt_p(type) ((type) == R_SH_JMP_SLOT) + +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ +#define ELF_MACHINE_JMP_SLOT R_SH_JMP_SLOT + +/* We define an initialization functions. This is called very early in + _dl_sysdep_start. */ +#define DL_PLATFORM_INIT dl_platform_init () + +extern const char *_dl_platform; + +static inline void __attribute__ ((unused)) +dl_platform_init (void) +{ + if (_dl_platform != NULL && *_dl_platform == '\0') + /* Avoid an empty string which would disturb us. */ + _dl_platform = NULL; +} + +static inline void +elf_machine_fixup_plt (struct link_map *map, const Elf32_Rela *reloc, + Elf32_Addr *reloc_addr, Elf32_Addr value) +{ + *reloc_addr = value; +} + +/* Return the final value of a plt relocation. */ +static inline Elf32_Addr +elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, + Elf32_Addr value) +{ + return value + reloc->r_addend; +} + +#endif /* !dl_machine_h */ + +#ifdef RESOLVE + +/* SH never uses Elf32_Rel relocations. */ +#define ELF_MACHINE_NO_REL 1 + +extern char **_dl_argv; + +/* Perform the relocation specified by RELOC and SYM (which is fully resolved). + MAP is the object containing the reloc. */ + +static inline void +elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, + const Elf32_Sym *sym, const struct r_found_version *version, + Elf32_Addr *const reloc_addr) +{ + if (ELF32_R_TYPE (reloc->r_info) == R_SH_RELATIVE) + { +#ifndef RTLD_BOOTSTRAP + if (map != &_dl_rtld_map) /* Already done in rtld itself. */ +#endif + *reloc_addr = map->l_addr + reloc->r_addend; + } + else if (ELF32_R_TYPE (reloc->r_info) != R_SH_NONE) + { + const Elf32_Sym *const refsym = sym; + Elf32_Addr value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info)); + if (sym) + value += sym->st_value; + value += reloc->r_addend; + + switch (ELF32_R_TYPE (reloc->r_info)) + { + case R_SH_COPY: + if (sym == NULL) + /* This can happen in trace mode if an object could not be + found. */ + break; + if (sym->st_size > refsym->st_size + || (sym->st_size < refsym->st_size && _dl_verbose)) + { + const char *strtab; + + strtab = (const char *) map->l_info[DT_STRTAB]->d_un.d_ptr; + _dl_sysdep_error (_dl_argv[0] ?: "", + ": Symbol `", strtab + refsym->st_name, + "' has different size in shared object, " + "consider re-linking\n", NULL); + } + memcpy (reloc_addr, (void *) value, MIN (sym->st_size, + refsym->st_size)); + break; + case R_SH_GLOB_DAT: + case R_SH_JMP_SLOT: + *reloc_addr = value; + break; + case R_SH_DIR32: + { +#ifndef RTLD_BOOTSTRAP + /* This is defined in rtld.c, but nowhere in the static + libc.a; make the reference weak so static programs can + still link. This declaration cannot be done when + compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because + rtld.c contains the common defn for _dl_rtld_map, which + is incompatible with a weak decl in the same file. */ + weak_extern (_dl_rtld_map); + if (map == &_dl_rtld_map) + /* Undo the relocation done here during bootstrapping. + Now we will relocate it anew, possibly using a + binding found in the user program or a loaded library + rather than the dynamic linker's built-in definitions + used while loading those libraries. */ + value -= map->l_addr + refsym->st_value + reloc->r_addend; +#endif + *reloc_addr = value; + break; + } + case R_SH_REL32: + *reloc_addr = (value - (Elf32_Addr) reloc_addr); + break; + default: + assert (! "unexpected dynamic reloc type"); + break; + } + } +} + +static inline void +elf_machine_lazy_rel (Elf32_Addr l_addr, const Elf32_Rela *reloc) +{ + Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); + /* Check for unexpected PLT reloc type. */ + assert (ELF32_R_TYPE (reloc->r_info) == R_SH_JMP_SLOT); + *reloc_addr += l_addr; /* + reloc->r_addend; */ +} + +#endif /* RESOLVE */ diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/elf/crti.S glibc-2.1.3/sysdeps/sh/sh4/elf/crti.S --- glibc-2.1.3-original/sysdeps/sh/sh4/elf/crti.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/elf/crti.S Wed May 24 07:44:54 2000 @@ -0,0 +1,74 @@ + .file "initfini.c" +gcc2_compiled.: + +#include "defs.h" +#define PIC + +/*@HEADER_ENDS*/ +/*@_init_PROLOG_BEGINS*/ + .section .init + .align 5 + .global _init + .type _init,@function +_init: + mov.l r12,@-r15 + mov.l r14,@-r15 + sts.l pr,@-r15 +#ifdef PIC + mova .L22,r0 + mov.l .L22,r12 + add r0,r12 + mova .L23,r0 + mov.l .L23,r1 + add r0,r1 +#else + mov.l .L23,r1 +#endif + jsr @r1 + mov r15,r14 + bra 1f + nop + .align 2 +#ifdef PIC +.L22: + .long _GLOBAL_OFFSET_TABLE_ +.L23: + .long __gmon_start__@PLT +#else +.L23: + .long __gmon_start__ +#endif +1: + ALIGN + END_INIT + + +/*@_init_PROLOG_ENDS*/ +/*@_fini_PROLOG_BEGINS*/ + .section .fini + .align 5 + .global _fini + .type _fini,@function +_fini: + mov.l r12,@-$r15 + mov.l r14,@-r15 + sts.l pr,@-r15 +#ifdef PIC + mova .L27,r0 + mov.l .L27,r12 + add r0,r12 +#endif + mov r15,r14 + ALIGN + END_FINI +#ifdef PIC + bra 1f + nop + .align 2 +.L27: + .long _GLOBAL_OFFSET_TABLE_ +#endif +1: +/*@_fini_PROLOG_ENDS*/ +/*@TRAILER_BEGINS*/ + .ident "GCC: (GNU) 2.95.1 19990816 (release)" diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/elf/crtn.S glibc-2.1.3/sysdeps/sh/sh4/elf/crtn.S --- glibc-2.1.3-original/sysdeps/sh/sh4/elf/crtn.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/elf/crtn.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,40 @@ + .file "initfini.c" +gcc2_compiled.: + +#include "defs.h" +#define PIC + +/*@HEADER_ENDS*/ +/*@_init_EPILOG_BEGINS*/ + .section .init + mov r14,r15 + lds.l @r15+,pr + mov.l @r15+,r14 + rts + mov.l @r15+,r12 + END_INIT + .section .text + .align 5 + .weak __gmon_start__ + .type __gmon_start__,@function +__gmon_start__: + mov.l r14,@-r15 + mov r15,r14 + mov r14,r15 + rts + mov.l @r15+,r14 + +/*@_init_EPILOG_ENDS*/ +/*@_fini_EPILOG_BEGINS*/ + .section .fini + mov r14,r15 + lds.l @r15+,pr + mov.l @r15+,r14 + rts + mov.l @r15+,r12 + + END_FINI + +/*@_fini_EPILOG_ENDS*/ +/*@TRAILER_BEGINS*/ + .ident "GCC: (GNU) 2.95.1 19990816 (release)" diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/elf/start.S glibc-2.1.3/sysdeps/sh/sh4/elf/start.S --- glibc-2.1.3-original/sysdeps/sh/sh4/elf/start.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/elf/start.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,90 @@ +/* Startup code for SH & ELF + Copyright (C) 1999 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This is the canonical entry point, usually the first thing in the text + segment. + + Note that the code in the .init section has already been run. + This includes _init and _libc_init + + + At this entry point, most registers' values are unspecified, except: + + r4 Contains a function pointer to be registered with `atexit'. + This is how the dynamic linker arranges to have DT_FINI + functions called for shared libraries that have been loaded + before this code runs. + + sp The stack contains the arguments and environment: + 0(sp) argc + 4(sp) argv[0] + ... + (4*argc)(sp) NULL + (4*(argc+1))(sp) envp[0] + ... + NULL +*/ + + .text + .globl _start +_start: + /* Clear the frame pointer since this is the outermost frame. */ + mov #0, r14 + + /* Pop argc off the stack and save a pointer to argv */ + mov.l @r15+,r5 + mov r15, r6 + + /* Push the last arguments to main() onto the stack */ + mov.l r4,@-r15 + mov.l L_fini,r0 + mov.l r0,@-r15 + + /* Set up the other arguments for main() that go in registers */ + mov.l L_main,r4 + mov.l L_init,r7 + + /* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */ + + /* Let the libc call main and exit with its return code. */ + mov.l L_libc_start_main,r1 + jsr @r1 + nop + /* should never get here....*/ + mov.l L_abort,r1 + jsr @r1 + nop + .align 2 +L_main: + .long main +L_init: + .long _init +L_fini: + .long _fini +L_libc_start_main: + .long __libc_start_main +L_abort: + .long abort +/* Define a symbol for the first piece of initialized data. */ + .data + .globl __data_start +__data_start: + .long 0 + .weak data_start + data_start = __data_start diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/bits/fenv.h glibc-2.1.3/sysdeps/sh/sh4/fpu/bits/fenv.h --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/bits/fenv.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/bits/fenv.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,72 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _FENV_H +# error "Never use directly; include instead." +#endif + + +/* Define bits representing the exception. We use the bit positions + of the appropriate bits in the FPU control word. */ +enum + { + FE_INEXACT = 0x04, +#define FE_INEXACT FE_INEXACT + FE_UNDERFLOW = 0x08, +#define FE_UNDERFLOW FE_UNDERFLOW + FE_OVERFLOW = 0x10, +#define FE_OVERFLOW FE_OVERFLOW + FE_DIVBYZERO = 0x20, +#define FE_DIVBYZERO FE_DIVBYZERO + FE_INVALID = 0x40, +#define FE_INVALID FE_INVALID + }; + +#define FE_ALL_EXCEPT \ + (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) + +/* The SH FPU supports all of the four defined rounding modes. We + use again the bit positions in the FPU control word as the values + for the appropriate macros. */ +enum + { + FE_TONEAREST = 0x0, +#define FE_TONEAREST FE_TONEAREST + FE_TOWARDZERO = 0x1, +#define FE_TOWARDZERO FE_TOWARDZERO + FE_UPWARD = 0x2, +#define FE_UPWARD FE_UPWARD + FE_DOWNWARD = 0x3 +#define FE_DOWNWARD FE_DOWNWARD + }; + + +/* Type representing exception flags. */ +typedef unsigned short int fexcept_t; + + +/* Type representing floating-point environment. This function corresponds + to the layout of the block written by the `fstenv'. */ +typedef struct + { + unsigned int __fpscr; + } +fenv_t; + +/* If the default argument is used we use this value. */ +#define FE_DFL_ENV ((fenv_t *) -1) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fclrexcpt.c glibc-2.1.3/sysdeps/sh/sh4/fpu/fclrexcpt.c --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fclrexcpt.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/fclrexcpt.c Sun Mar 12 21:13:05 2000 @@ -0,0 +1,40 @@ +/* Clear given exceptions in current floating-point environment. + Copyright (C) 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Jaeger , 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +void +feclearexcept (int excepts) +{ + int cw; + + /* Mask out unsupported bits/exceptions. */ + excepts &= FE_ALL_EXCEPT; + + /* Read the complete control word. */ + _FPU_GETCW (cw); + + /* Clear exception bits. */ + cw &= ~excepts; + + /* Put the new data in effect. */ + _FPU_SETCW (cw); +} diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fegetenv.c glibc-2.1.3/sysdeps/sh/sh4/fpu/fegetenv.c --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fegetenv.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/fegetenv.c Sun Mar 12 21:13:05 2000 @@ -0,0 +1,29 @@ +/* Store current floating-point environment. + Copyright (C) 1997, 1998, 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +void +fegetenv (fenv_t *envp) +{ + unsigned long int temp; + _FPU_GETCW(temp); + envp->__fpscr = temp; +} diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fegetround.c glibc-2.1.3/sysdeps/sh/sh4/fpu/fegetround.c --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fegetround.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/fegetround.c Sun Mar 12 21:13:05 2000 @@ -0,0 +1,33 @@ +/* Return current rounding direction. + Copyright (C) 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Jaeger , 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +int +fegetround (void) +{ + int cw; + + /* Get control word. */ + _FPU_GETCW (cw); + + return cw & 0x3; +} diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/feholdexcpt.c glibc-2.1.3/sysdeps/sh/sh4/fpu/feholdexcpt.c --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/feholdexcpt.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/feholdexcpt.c Sun Mar 12 21:13:05 2000 @@ -0,0 +1,37 @@ +/* Store current floating-point environment and clear exceptions. + Copyright (C) 1997, 1998, 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +int +feholdexcept (fenv_t *envp) +{ + unsigned long int temp; + + /* Store the environment. */ + _FPU_GETCW(temp); + envp->__fpscr = temp; + + /* Now set all exceptions to non-stop. */ + temp &= ~FE_ALL_EXCEPT; + _FPU_SETCW(temp); + + return 1; +} diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fesetenv.c glibc-2.1.3/sysdeps/sh/sh4/fpu/fesetenv.c --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fesetenv.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/fesetenv.c Sun Mar 12 21:13:05 2000 @@ -0,0 +1,33 @@ +/* Install given floating-point environment. + Copyright (C) 1997, 1998, 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +void +fesetenv (const fenv_t *envp) +{ + if (envp == FE_DFL_ENV) + _FPU_SETCW(_FPU_DEFAULT); + else + { + unsigned long temp = envp->__fpscr; + _FPU_SETCW(temp); + } +} diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fesetround.c glibc-2.1.3/sysdeps/sh/sh4/fpu/fesetround.c --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fesetround.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/fesetround.c Sun Mar 12 21:13:05 2000 @@ -0,0 +1,43 @@ +/* Set current rounding direction. + Copyright (C) 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Jaeger , 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +int +fesetround (int round) +{ + unsigned int cw; + + if ((round & ~0x3) != 0) + /* ROUND is no valid rounding mode. */ + return 0; + + /* Get current state. */ + _FPU_GETCW (cw); + + /* Set rounding bits. */ + cw &= ~0x3; + cw |= round; + /* Set new state. */ + _FPU_SETCW (cw); + + return 1; +} diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fpu_control.h glibc-2.1.3/sysdeps/sh/sh4/fpu/fpu_control.h --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fpu_control.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/fpu_control.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,55 @@ +/* FPU control word definitions. SH version. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _FPU_CONTROL_H +#define _FPU_CONTROL_H + +/* masking of interrupts */ +#define _FPU_MASK_V 0x0800 /* Invalid operation */ +#define _FPU_MASK_Z 0x0400 /* Division by zero */ +#define _FPU_MASK_O 0x0200 /* Overflow */ +#define _FPU_MASK_U 0x0100 /* Underflow */ +#define _FPU_MASK_I 0x0080 /* Inexact operation */ + +/* rounding control */ +#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */ +#define _FPU_RC_ZERO 0x1 + +#define _FPU_RESERVED 0xffc00000 /* These bits are reserved. */ + +/* The fdlibm code requires strict IEEE double precision arithmetic, + and no interrupts for exceptions, rounding to nearest. */ +#define _FPU_DEFAULT 0x00080000 /* Default value. */ + +/* Type of the control word. */ +typedef unsigned int fpu_control_t; + +/* Macros for accessing the hardware control word. */ +#define _FPU_GETCW(cw) __asm__ ("sts fpscr,%0" : "=r" (cw)) + +#if defined __GNUC__ +#define _FPU_SETCW(cw) __set_fpscr ((cw)) +#else +#define _FPU_SETCW(cw) __asm__ ("lds %0,fpscr" : : "r" (cw)) +#endif + +/* Default control word set at startup. */ +extern fpu_control_t __fpu_control; + +#endif /* _FPU_CONTROL_H */ diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fraiseexcpt.c glibc-2.1.3/sysdeps/sh/sh4/fpu/fraiseexcpt.c --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fraiseexcpt.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/fraiseexcpt.c Sun Mar 12 21:13:05 2000 @@ -0,0 +1,33 @@ +/* Raise given exceptions. + Copyright (C) 1997, 1998, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +void +feraiseexcept (int excepts) +{ + /* Raise exceptions represented by EXPECTS. */ + fexcept_t temp; + _FPU_GETCW(temp); + temp |= (excepts & FE_ALL_EXCEPT); + temp |= (excepts & FE_ALL_EXCEPT) << 5; + _FPU_SETCW(temp); +} diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fsetexcptflg.c glibc-2.1.3/sysdeps/sh/sh4/fpu/fsetexcptflg.c --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fsetexcptflg.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/fsetexcptflg.c Sun Mar 12 21:13:05 2000 @@ -0,0 +1,38 @@ +/* Set floating-point environment exception handling. + Copyright (C) 1997, 1998, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +void +fesetexceptflag (const fexcept_t *flagp, int excepts) +{ + fexcept_t temp; + + /* Get the current environment. */ + _FPU_GETCW(temp); + + /* Set the desired exception mask. */ + temp &= ~(excepts & FE_ALL_EXCEPT); + temp |= (*flagp & excepts & FE_ALL_EXCEPT); + + /* Save state back to the FPU. */ + _FPU_SETCW(temp); +} diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/ftestexcept.c glibc-2.1.3/sysdeps/sh/sh4/fpu/ftestexcept.c --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/ftestexcept.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/ftestexcept.c Sun Mar 12 21:13:05 2000 @@ -0,0 +1,32 @@ +/* Test exception in current environment. + Copyright (C) 1997, 1998, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +int +fetestexcept (int excepts) +{ + fexcept_t temp; + + /* Get current exceptions. */ + _FPU_GETCW(temp); + + return temp & excepts & FE_ALL_EXCEPT; +} diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/setjmp.S glibc-2.1.3/sysdeps/sh/sh4/setjmp.S --- glibc-2.1.3-original/sysdeps/sh/sh4/setjmp.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/setjmp.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,72 @@ +/* setjmp for SH4. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#define _SETJMP_H +#define _ASM +#include + + /* Binary compatibility entry point. */ +ENTRY (__setjmp) + mov #0, r5 +ENTRY (__sigsetjmp) + /* Save registers */ + add #JB_SIZE, r4 + fmov.s fr15, @-r4 + fmov.s fr14, @-r4 + fmov.s fr13, @-r4 + fmov.s fr12, @-r4 + sts.l fpscr, @-r4 + stc.l gbr, @-r4 + sts.l pr, @-r4 + mov.l r15, @-r4 + mov.l r14, @-r4 + mov.l r13, @-r4 + mov.l r12, @-r4 + mov.l r11, @-r4 + mov.l r10, @-r4 + mov.l r9, @-r4 + mov.l r8, @-r4 + + /* Make a tail call to __sigjmp_save; it takes the same args. */ +#ifdef PIC + mov.l 1f, r1 + mova 1f, r0 + bra 2f + add r1, r0 + .align 2 +1: + .long _GLOBAL_OFFSET_TABLE_ +2: + mov.l .L1, r1 + mov.l @(r0,r1), r1 + jmp @r1 + nop + .align 2 +.L1: + .long C_SYMBOL_NAME(__sigjmp_save@GOT) +#else + mov.l .L1, r1 + jmp @r1 + nop + .align 2 +.L1: + .long C_SYMBOL_NAME(__sigjmp_save) +#endif +END (__setjmp) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/sys/ucontext.h glibc-2.1.3/sysdeps/sh/sh4/sys/ucontext.h --- glibc-2.1.3-original/sysdeps/sh/sh4/sys/ucontext.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sh4/sys/ucontext.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,99 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Where is System V/SH ABI? */ + +#ifndef _SYS_UCONTEXT_H +#define _SYS_UCONTEXT_H 1 + +#include +#include + +typedef int greg_t; + +/* Number of general registers. */ +#define NGREG 16 + +/* Container for all general registers. */ +typedef greg_t gregset_t[NGREG]; + +/* Number of each register is the `gregset_t' array. */ +enum +{ + R0 = 0, +#define R0 R0 + R1 = 1, +#define R1 R1 + R2 = 2, +#define R2 R2 + R3 = 3, +#define R3 R3 + R4 = 4, +#define R4 R4 + R5 = 5, +#define R5 R5 + R6 = 6, +#define R6 R6 + R7 = 7, +#define R7 R7 + R8 = 8, +#define R8 R8 + R9 = 9, +#define R9 R9 + R10 = 10, +#define R10 R10 + R11 = 11, +#define R11 R11 + R12 = 12, +#define R12 R12 + R13 = 13, +#define R13 R13 + R14 = 14, +#define R14 R14 + R15 = 15, +#define R15 R15 +}; + +typedef int freg_t; + +/* Number of FPU registers. */ +#define NFREG 16 + +/* Structure to describe FPU registers. */ +typedef freg_t fpregset_t[NFREG]; + +/* Context to describe whole processor state. */ +typedef struct + { + gregset_t gregs; + fpregset_t fpregs; + fpregset_t xfpregs; + } mcontext_t; + +/* Userlevel context. */ +typedef struct ucontext + { + unsigned long int uc_flags; + struct ucontext *uc_link; + __sigset_t uc_sigmask; + stack_t uc_stack; + mcontext_t uc_mcontext; + long int uc_filler[5]; + } ucontext_t; + +#endif /* sys/ucontext.h */ diff -u -r -N glibc-2.1.3-original/sysdeps/sh/strlen.S glibc-2.1.3/sysdeps/sh/strlen.S --- glibc-2.1.3-original/sysdeps/sh/strlen.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/strlen.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,84 @@ +/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Kazumoto Kojima + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +/* size_t strlen (const char *s) */ + +ENTRY(strlen) + mov r4, r0 + and #3, r0 + tst r0, r0 + bt/s 1f + mov #0, r2 + + add #-1, r0 + shll2 r0 + shll r0 + braf r0 + nop + + mov.b @r4+, r1 + tst r1, r1 + bt 8f + add #1, r2 + + mov.b @r4+, r1 + tst r1, r1 + bt 8f + add #1, r2 + + mov.b @r4+, r1 + tst r1, r1 + bt 8f + add #1, r2 + +1: + mov #0, r3 +2: + mov.l @r4+, r1 + cmp/str r3, r1 + bf/s 2b + add #4, r2 + + add #-4, r2 +#if __BYTE_ORDER == __BIG_ENDIAN + swap.b r1, r1 + swap.w r1, r1 + swap.b r1, r1 +#endif + extu.b r1, r0 + tst r0, r0 + bt/s 8f + shlr8 r1 + add #1, r2 + extu.b r1, r0 + tst r0, r0 + bt/s 8f + shlr8 r1 + add #1, r2 + extu.b r1, r0 + tst r0, r0 + bt 8f + add #1, r2 +8: + rts + mov r2, r0 +END(strlen) diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sysdep.h glibc-2.1.3/sysdeps/sh/sysdep.h --- glibc-2.1.3-original/sysdeps/sh/sysdep.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/sh/sysdep.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,76 @@ +/* Assembler macros for SH. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +#ifdef __ASSEMBLER__ + +/* Syntactic details of assembler. */ + +#ifdef HAVE_ELF + +#define ALIGNARG(log2) log2 +/* For ELF we need the `.type' directive to make shared libs work right. */ +#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,@##typearg; +#define ASM_SIZE_DIRECTIVE(name) .size name,.-name + +#ifdef PIC +#define PLTJMP(_x) _x##@PLT +#else +#define PLTJMP(_x) _x +#endif + +#else + +#define ALIGNARG(log2) log2 +#define ASM_TYPE_DIRECTIVE(name,type) /* Nothing is specified. */ +#define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified. */ + +#define PLTJMP(_x) _x + +#endif + +/* Define an entry point visible from C. */ +#define ENTRY(name) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ + ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function) \ + .align ALIGNARG(5); \ + C_LABEL(name) \ + CALL_MCOUNT + +#undef END +#define END(name) \ + ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(name)) + +/* If compiled for profiling, call `mcount' at the start of each function. */ +#ifdef PROF +#define CALL_MCOUNT /* NOTYET */ +#else +#define CALL_MCOUNT /* Do nothing. */ +#endif + +#ifdef NO_UNDERSCORES +/* Since C identifiers are not normally prefixed with an underscore + on this system, the asm identifier `syscall_error' intrudes on the + C name space. Make sure we use an innocuous name. */ +#define syscall_error __syscall_error +#define mcount _mcount +#endif + +#endif /* __ASSEMBLER__ */ diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sh/sysdep.S glibc-2.1.3/sysdeps/unix/sh/sysdep.S --- glibc-2.1.3-original/sysdeps/unix/sh/sysdep.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sh/sysdep.S Sun Mar 12 04:09:09 2000 @@ -0,0 +1,102 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#define _ERRNO_H +#include + +ENTRY(__syscall_error) +#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN + /* We translate the system's EWOULDBLOCK error into EAGAIN. + The GNU C library always defines EWOULDBLOCK==EAGAIN. + EWOULDBLOCK_sys is the original number. */ + mov.l .L1, r1 + cmp/eq r1, r0 + bf skip + nop + mov.l .L2, r0 +skip: +#endif + /* Store it in errno... */ +#ifndef PIC +#ifndef _LIBC_REENTRANT + mov.l .L3, r1 + mov.l r0, @r1 +#else + mov.l .L3, r1 + sts.l pr, @-r15 + jsr @r1 + mov.l r0, @-r15 + mov.l @r15+, r1 + lds.l @r15+, pr + mov.l r1, @r0 +#endif +#else + mov.l r12, @-r15 +#ifndef _LIBC_REENTRANT + mov r0, r2 + mov.l 0f, r12 + mova 0f, r0 + add r0, r12 + mov.l .L3, r0 + mov.l @(r0,r12), r1 + mov.l r2, @r1 +#else + mov.l r0, @-r15 + sts.l pr, @-r15 + mov.l 0f, r12 + mova 0f, r0 + add r0, r12 + mov.l .L3, r1 + mova .L3, r0 + add r0, r1 + jsr @r1 + nop + lds.l @r15+, pr + mov.l @r15+, r1 + mov.l r1, @r0 +#endif + mov.l @r15+, r12 +#endif + /* And just kick back a -1. */ + rts + mov #-1, r0 + + .align 2 +#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN +.L1: .long EWOULDBLOCK_sys +.L2: .long EAGAIN +#endif +#ifndef PIC +#ifndef _LIBC_REENTRANT +.L3: .long C_SYMBOL_NAME(errno) +#else +.L3: .long C_SYMBOL_NAME(__errno_location) +#endif +#else +0: + .long _GLOBAL_OFFSET_TABLE_ +#ifndef _LIBC_REENTRANT +.L3: .long C_SYMBOL_NAME(errno@GOT) +#else +.L3: .long C_SYMBOL_NAME(__errno_location@PLT) +#endif +#endif +END(__syscall_error) + +weak_alias (__syscall_error, syscall_error) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sh/sysdep.h glibc-2.1.3/sysdeps/unix/sh/sysdep.h --- glibc-2.1.3-original/sysdeps/unix/sh/sysdep.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sh/sysdep.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,29 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#ifdef __ASSEMBLER__ + +#define ret rts ; nop + +/* The sh move insn is s, d. */ +#define MOVE(x,y) mov x , y + +#endif diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/Dist glibc-2.1.3/sysdeps/unix/sysv/linux/sh/Dist --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/Dist Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/Dist Sun Mar 12 04:09:09 2000 @@ -0,0 +1,12 @@ +clone.S +init-first.h +ioperm.c +pipe.S +setresuid.c +setresgid.c +setfsuid.c +setfsgid.c +sigrestorer.S +bits/shsigctx.h +sys/io.h +sys/user.h diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/Makefile glibc-2.1.3/sysdeps/unix/sysv/linux/sh/Makefile --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/Makefile Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/Makefile Sun Mar 12 04:09:09 2000 @@ -0,0 +1,13 @@ +ifeq ($(subdir),io) +sysdep_routines += pipe +endif + +ifeq ($(subdir),misc) +sysdep_routines += setfsgid setfsuid setresgid setresuid ioperm +endif + +ifeq ($(subdir),signal) +sysdep_routines += rt_sigsuspend rt_sigprocmask rt_sigtimedwait \ + rt_sigqueueinfo rt_sigaction rt_sigpending \ + sigrestorer +endif diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/Versions glibc-2.1.3/sysdeps/unix/sysv/linux/sh/Versions --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/Versions Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/Versions Sun Mar 12 04:20:49 2000 @@ -0,0 +1,4 @@ +libc { + GLIBC_2.1 { + } +} diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/bits/mman.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/bits/mman.h --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/bits/mman.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/bits/mman.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,75 @@ +/* Definitions for POSIX memory map interface. Linux/SH version. + Copyright (C) 1997, 1999 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SYS_MMAN_H +# error "Never include this file directly. Use instead" +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + + +/* Protections are chosen from these bits, OR'd together. The + implementation does not necessarily support PROT_EXEC or PROT_WRITE + without PROT_READ. The only guarantees are that no writing will be + allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ + +#define PROT_READ 0x1 /* Page can be read. */ +#define PROT_WRITE 0x2 /* Page can be written. */ +#define PROT_EXEC 0x4 /* Page can be executed. */ +#define PROT_NONE 0x0 /* Page can not be accessed. */ + +/* Sharing types (must choose one and only one of these). */ +#define MAP_SHARED 0x01 /* Share changes. */ +#define MAP_PRIVATE 0x02 /* Changes are private. */ +#ifdef __USE_MISC +# define MAP_TYPE 0x0f /* Mask for type of mapping. */ +#endif + +/* Other flags. */ +#define MAP_FIXED 0x10 /* Interpret addr exactly. */ +#ifdef __USE_MISC +# define MAP_FILE 0 +# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ +# define MAP_ANON MAP_ANONYMOUS +#endif + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x2000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */ +#endif + +/* Flags to `msync'. */ +#define MS_ASYNC 1 /* Sync memory asynchronously. */ +#define MS_SYNC 4 /* Synchronous memory sync. */ +#define MS_INVALIDATE 2 /* Invalidate the caches. */ + +/* Flags for `mlockall'. */ +#define MCL_CURRENT 1 /* Lock all currently mapped pages. */ +#define MCL_FUTURE 2 /* Lock all additions to address + space. */ + +/* Flags for `mremap'. */ +#ifdef __USE_GNU +# define MREMAP_MAYMOVE 1 +#endif diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/brk.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/brk.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/brk.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/brk.c Thu Apr 27 21:26:38 2000 @@ -0,0 +1,48 @@ +/* brk system call for Linux/SH. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +/* This must be initialized data because commons can't have aliases. */ +void *__curbrk = 0; + +int +__brk (void *addr) +{ + void *newbrk; + register long __r3 __asm__ ("$r3") = (long) SYS_ify (brk); + register long __r4 __asm__ ("$r4") = (long) addr; + + asm ("trapa #0x11\n" /* do the system call */ + : "=z" (newbrk) + : "r" (__r3), "r" (__r4)); + + __curbrk = newbrk; + + if (newbrk < addr) + { + __set_errno (ENOMEM); + return -1; + } + + return 0; +} +weak_alias (__brk, brk) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/clone.S glibc-2.1.3/sysdeps/unix/sysv/linux/sh/clone.S --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/clone.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/clone.S Thu Apr 27 21:26:38 2000 @@ -0,0 +1,133 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* clone() is even more special than fork() as it mucks with stacks + and invokes a function in the right context after its all over. */ + +#include +#define _ERRNO_H 1 +#include + +/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ + + .text +ENTRY(__clone) + /* sanity check arguments. */ + tst r4, r4 + bf/s 1f + tst r5, r5 + bf/s 1f + mov.l .L1, r1 +#ifdef PIC + mov.l r12, @-r15 + sts.l pr, @-r15 + mov.l .LG, r12 + mova .LG, r0 + add r0, r12 + mova .L1, r0 + add r0, r1 + jsr @r1 + mov #-EINVAL, r4 + lds.l @r15+, pr + rts + mov.l @r15+, r12 +#else + jmp @r1 + mov #-EINVAL, r4 +#endif + .align 2 +.L1: + .long PLTJMP(C_SYMBOL_NAME(__syscall_error)) +1: + /* insert the args onto the new stack */ + mov.l r7, @-r5 + /* save the function pointer as the 0th element */ + mov.l r4, @-r5 + + /* do the system call */ + mov $r6, $r4 + mov #+SYS_ify(clone), $r3 + trapa #0x12 + mov $r0, $r1 + mov #-12, $r2 + shad $r2, $r1 + not r1, r1 // r1=0 means r0 = -1 to -4095 + tst r1, r1 // i.e. error in linux + bf 2f + mov.l .L2, r1 +#ifdef PIC + mov r0, r4 + mov.l r12, @-r15 + sts.l pr, @-r15 + mov.l .LG, r12 + mova .LG, r0 + add r0, r12 + mova .L2, r0 + add r0, r1 + jsr @r1 + nop + lds.l @r15+, pr + rts + mov.l @r15+, r12 +#else + jmp @r1 + mov r0, r4 +#endif + .align 2 +.L2: + .long PLTJMP(C_SYMBOL_NAME(__syscall_error)) + +2: + tst r0, r0 + bt 3f + rts + nop +3: + /* thread starts */ + mov.l @r15, r1 + jsr @r1 + mov.l @(4,r15), r4 + + /* we are done, passing the return value through r0 */ + mov.l .L3, r1 +#ifdef PIC + mov.l r12, @-r15 + sts.l pr, @-r15 + mov r0, r4 + mova .LG, r0 + mov.l .LG, r12 + add r0, r12 + mova .L3, r0 + add r0, r1 + jsr @r1 + nop + lds.l @r15+, pr + rts + mov.l @r15+, r12 +#else + jmp @r1 + mov r0, r4 +#endif + .align 2 +.LG: + .long _GLOBAL_OFFSET_TABLE_ +.L3: + .long PLTJMP(C_SYMBOL_NAME(_exit)) +PSEUDO_END (__clone) + +weak_alias (__clone, clone) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/errlist.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/errlist.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/errlist.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/errlist.c Sun Mar 12 04:09:09 2000 @@ -0,0 +1,55 @@ +/* Copyright (C) 1998, 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING + +# define SYS_ERRLIST __new_sys_errlist +# define SYS_NERR __new_sys_nerr + +asm (".data; .globl __old_sys_errlist; __old_sys_errlist:"); +#endif + +#include + +#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING +asm (".type __old_sys_errlist,%object;.size __old_sys_errlist," + OLD_ERRLIST_SIZE_STR "*" PTR_SIZE_STR); + +extern const char *const *__old_sys_errlist; + +const int __old_sys_nerr = OLD_ERRLIST_SIZE; + +strong_alias (__old_sys_nerr, _old_sys_nerr); +weak_alias (__old_sys_nerr, _old_sys_nerr) +symbol_version (__old_sys_nerr, _sys_nerr, GLIBC_2.0); +symbol_version (_old_sys_nerr, sys_nerr, GLIBC_2.0); +weak_alias (__old_sys_errlist, _old_sys_errlist); +symbol_version (__old_sys_errlist, _sys_errlist, GLIBC_2.0); +symbol_version (_old_sys_errlist, sys_errlist, GLIBC_2.0); + +weak_alias (__new_sys_nerr, _new_sys_nerr) +default_symbol_version (__new_sys_nerr, _sys_nerr, GLIBC_2.1); +default_symbol_version (_new_sys_nerr, sys_nerr, GLIBC_2.1); +weak_alias (__new_sys_errlist, _new_sys_errlist) +default_symbol_version (__new_sys_errlist, _sys_errlist, GLIBC_2.1); +default_symbol_version (_new_sys_errlist, sys_errlist, GLIBC_2.1); + +#endif diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/getgroups.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/getgroups.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/getgroups.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/getgroups.c Sun Mar 12 04:09:09 2000 @@ -0,0 +1,2 @@ +/* We also have to rewrite the kernel gid_t to the user land type. */ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/init-first.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/init-first.h --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/init-first.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/init-first.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,52 @@ +/* Prepare arguments for library initialization function. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* The job of this fragment it to find argc and friends for INIT. + This is done in one of two ways: either in the stack context + of program start, or having dlopen pass them in. */ + +#define SYSDEP_CALL_INIT(NAME, INIT) \ +void NAME (void *arg, void *arg1, void *arg2, void *arg3, void *argp) \ +{ \ + int argc; \ + char** argv; \ + char** envp; \ + /* The next variable is only here to work around a bug in gcc <= 2.7.2.2. \ + If the address would be taken inside the expression the optimizer \ + would try to be too smart and throws it away. Grrr. */ \ + int *dummy_addr = &_dl_starting_up; \ + \ + __libc_multiple_libcs = dummy_addr && !_dl_starting_up; \ + \ + if (!__libc_multiple_libcs) \ + { \ + /* In SH, argp is the first argument on stack. */ \ + argc = *(int*) (&argp); \ + argv = (char **) &argp + 1; \ + envp = &argv[argc+1]; \ + } \ + else \ + { \ + argc = (int) arg; \ + argv = (char**) arg1; \ + envp = (char**) arg2; \ + } \ + \ + INIT (argc, argv, envp); \ +} diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pipe.S glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pipe.S --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pipe.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pipe.S Thu Apr 27 21:26:38 2000 @@ -0,0 +1,63 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +ENTRY (__libc_pipe) + mov #+__NR_pipe, $r3 + trapa #0x10 + mov r0, r3 + mov #-12, r2 + shad r2, r3 + not r3, r3 // r1=0 means r0 = -1 to -4095 + tst r3, r3 // i.e. error in linux + bf 1f + mov.l .L2, r1 +#ifdef PIC + mov r0, r4 + mov.l r12, @-r15 + sts.l pr, @-r15 + mov.l 0f, r12 + mova 0f, r0 + add r0, r12 + mova .L2, r0 + add r0, r1 + jsr @r1 + nop + lds.l @r15+, pr + rts + mov.l @r15+, r12 + .align 2 +0: + .long _GLOBAL_OFFSET_TABLE_ +#else + jmp @r1 + mov r0, r4 +#endif +1: + mov.l r0, @r4 + mov.l r1, @(4, r4) + rts + mov #0, r0 + .align 2 +.L2: + .long PLTJMP(C_SYMBOL_NAME(__syscall_error)) +PSEUDO_END (__libc_pipe) + +weak_alias (__libc_pipe, __pipe) +weak_alias (__libc_pipe, pipe) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pread.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pread.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pread.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pread.c Sun Mar 12 04:09:09 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pread64.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pread64.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pread64.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pread64.c Sun Mar 12 04:09:09 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/profil-counter.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/profil-counter.h --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/profil-counter.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/profil-counter.h Sun Mar 12 04:09:09 2000 @@ -0,0 +1,28 @@ +/* Low-level statistical profiling support function. Linux/SH version. + Copyright (C) 1996, 1997, 1998, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +void +profil_counter (int signo, int _a2, int _a3, int _a4, struct sigcontext sc) +{ + void *pc; + pc = (void *) sc.sc_pc; + profil_count (pc); +} diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pwrite.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pwrite.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pwrite.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pwrite.c Sun Mar 12 04:09:09 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pwrite64.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pwrite64.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pwrite64.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pwrite64.c Sun Mar 12 04:09:09 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setegid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setegid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setegid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setegid.c Sun Mar 12 04:09:09 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/seteuid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/seteuid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/seteuid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/seteuid.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setfsgid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setfsgid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setfsgid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setfsgid.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setfsuid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setfsuid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setfsuid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setfsuid.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setgid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setgid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setgid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setgid.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setgroups.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setgroups.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setgroups.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setgroups.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1,2 @@ +/* We also have to rewrite the kernel gid_t to the user land type. */ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setregid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setregid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setregid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setregid.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setresgid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setresgid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setresgid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setresgid.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setresuid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setresuid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setresuid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setresuid.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setreuid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setreuid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setreuid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setreuid.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setuid.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setuid.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/setuid.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/setuid.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1 @@ +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sh3/register-dump.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sh3/register-dump.h --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sh3/register-dump.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sh3/register-dump.h Sun Mar 12 04:09:10 2000 @@ -0,0 +1,151 @@ +/* Dump registers. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +/* We will print the register dump in this format: + + R0: XXXXXXXX R1: XXXXXXXX R2: XXXXXXXX R3: XXXXXXXX + R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX + R8: XXXXXXXX R9: XXXXXXXX R10: XXXXXXXX R11: XXXXXXXX + R12: XXXXXXXX R13: XXXXXXXX R14: XXXXXXXX R15: XXXXXXXX + +MACL: XXXXXXXX MACH: XXXXXXXX + + PC: XXXXXXXX PR: XXXXXXXX GBR: XXXXXXXX SR: XXXXXXXX + + FR0: XXXXXXXX FR1: XXXXXXXX FR2: XXXXXXXX FR3: XXXXXXXX + FR4: XXXXXXXX FR5: XXXXXXXX FR6: XXXXXXXX FR7: XXXXXXXX + FR8: XXXXXXXX FR9: XXXXXXXX FR10: XXXXXXXX FR11: XXXXXXXX +FR12: XXXXXXXX FR13: XXXXXXXX FR14: XXXXXXXX FR15: XXXXXXXX + + XR0: XXXXXXXX XR1: XXXXXXXX XR2: XXXXXXXX XR3: XXXXXXXX + XR4: XXXXXXXX XR5: XXXXXXXX XR6: XXXXXXXX XR7: XXXXXXXX + XR8: XXXXXXXX XR9: XXXXXXXX XR10: XXXXXXXX XR11: XXXXXXXX +XR12: XXXXXXXX XR13: XXXXXXXX XR14: XXXXXXXX XR15: XXXXXXXX + +FPSCR: XXXXXXXX FPUL: XXXXXXXX + + */ + +static void +hexvalue (unsigned long int value, char *buf, size_t len) +{ + char *cp = _itoa_word (value, buf + len, 16, 0); + while (cp > buf) + *--cp = '0'; +} + +static void +register_dump (int fd, struct sigcontext *ctx) +{ + char regs[22][8]; + struct iovec iov[112]; + size_t nr = 0; + +#define ADD_STRING(str) \ + iov[nr].iov_base = (char *) str; \ + iov[nr].iov_len = strlen (str); \ + ++nr +#define ADD_MEM(str, len) \ + iov[nr].iov_base = str; \ + iov[nr].iov_len = len; \ + ++nr + + /* Generate strings of register contents. */ + hexvalue (ctx->sc_regs[0], regs[0], 8); + hexvalue (ctx->sc_regs[1], regs[1], 8); + hexvalue (ctx->sc_regs[2], regs[2], 8); + hexvalue (ctx->sc_regs[3], regs[3], 8); + hexvalue (ctx->sc_regs[4], regs[4], 8); + hexvalue (ctx->sc_regs[5], regs[5], 8); + hexvalue (ctx->sc_regs[6], regs[6], 8); + hexvalue (ctx->sc_regs[7], regs[7], 8); + hexvalue (ctx->sc_regs[8], regs[8], 8); + hexvalue (ctx->sc_regs[9], regs[9], 8); + hexvalue (ctx->sc_regs[10], regs[10], 8); + hexvalue (ctx->sc_regs[11], regs[11], 8); + hexvalue (ctx->sc_regs[12], regs[12], 8); + hexvalue (ctx->sc_regs[13], regs[13], 8); + hexvalue (ctx->sc_regs[14], regs[14], 8); + hexvalue (ctx->sc_regs[15], regs[15], 8); + hexvalue (ctx->sc_macl, regs[16], 8); + hexvalue (ctx->sc_mach, regs[17], 8); + hexvalue (ctx->sc_pc, regs[18], 8); + hexvalue (ctx->sc_pr, regs[19], 8); + hexvalue (ctx->sc_gbr, regs[20], 8); + hexvalue (ctx->sc_sr, regs[21], 8); + + /* Generate the output. */ + ADD_STRING ("Register dump:\n\n R0: "); + ADD_MEM (regs[0], 8); + ADD_STRING (" R1: "); + ADD_MEM (regs[1], 8); + ADD_STRING (" R2: "); + ADD_MEM (regs[2], 8); + ADD_STRING (" R3: "); + ADD_MEM (regs[3], 8); + ADD_STRING ("\n R4: "); + ADD_MEM (regs[4], 8); + ADD_STRING (" R5: "); + ADD_MEM (regs[5], 8); + ADD_STRING (" R6: "); + ADD_MEM (regs[6], 8); + ADD_STRING (" R7: "); + ADD_MEM (regs[7], 8); + ADD_STRING ("\n R8: "); + ADD_MEM (regs[8], 8); + ADD_STRING (" R9: "); + ADD_MEM (regs[9], 8); + ADD_STRING (" R10: "); + ADD_MEM (regs[10], 8); + ADD_STRING (" R11: "); + ADD_MEM (regs[11], 8); + ADD_STRING ("\n R12: "); + ADD_MEM (regs[12], 8); + ADD_STRING (" R13: "); + ADD_MEM (regs[13], 8); + ADD_STRING (" R14: "); + ADD_MEM (regs[14], 8); + ADD_STRING (" R15: "); + ADD_MEM (regs[15], 8); + + ADD_STRING ("\n\nMACL: "); + ADD_MEM (regs[16], 8); + ADD_STRING (" MACH: "); + ADD_MEM (regs[17], 8); + + ADD_STRING ("\n\n PC: "); + ADD_MEM (regs[18], 8); + ADD_STRING (" PR: "); + ADD_MEM (regs[19], 8); + ADD_STRING (" GBR: "); + ADD_MEM (regs[20], 8); + ADD_STRING (" SR: "); + ADD_MEM (regs[21], 8); + + ADD_STRING ("\n"); + + /* Write the stuff out. */ + writev (fd, iov, nr); +} + + +#define REGISTER_DUMP register_dump (fd, &ctx) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sh4/register-dump.h Sun Mar 12 04:09:10 2000 @@ -0,0 +1,262 @@ +/* Dump registers. + Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +/* We will print the register dump in this format: + + R0: XXXXXXXX R1: XXXXXXXX R2: XXXXXXXX R3: XXXXXXXX + R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX + R8: XXXXXXXX R9: XXXXXXXX R10: XXXXXXXX R11: XXXXXXXX + R12: XXXXXXXX R13: XXXXXXXX R14: XXXXXXXX R15: XXXXXXXX + +MACL: XXXXXXXX MACH: XXXXXXXX + + PC: XXXXXXXX PR: XXXXXXXX GBR: XXXXXXXX SR: XXXXXXXX + + FR0: XXXXXXXX FR1: XXXXXXXX FR2: XXXXXXXX FR3: XXXXXXXX + FR4: XXXXXXXX FR5: XXXXXXXX FR6: XXXXXXXX FR7: XXXXXXXX + FR8: XXXXXXXX FR9: XXXXXXXX FR10: XXXXXXXX FR11: XXXXXXXX +FR12: XXXXXXXX FR13: XXXXXXXX FR14: XXXXXXXX FR15: XXXXXXXX + + XR0: XXXXXXXX XR1: XXXXXXXX XR2: XXXXXXXX XR3: XXXXXXXX + XR4: XXXXXXXX XR5: XXXXXXXX XR6: XXXXXXXX XR7: XXXXXXXX + XR8: XXXXXXXX XR9: XXXXXXXX XR10: XXXXXXXX XR11: XXXXXXXX +XR12: XXXXXXXX XR13: XXXXXXXX XR14: XXXXXXXX XR15: XXXXXXXX + +FPSCR: XXXXXXXX FPUL: XXXXXXXX + + */ + +static void +hexvalue (unsigned long int value, char *buf, size_t len) +{ + char *cp = _itoa_word (value, buf + len, 16, 0); + while (cp > buf) + *--cp = '0'; +} + +static void +register_dump (int fd, struct sigcontext *ctx) +{ + char regs[22][8]; + char fpregs[34][8]; + struct iovec iov[112]; + size_t nr = 0; + +#define ADD_STRING(str) \ + iov[nr].iov_base = (char *) str; \ + iov[nr].iov_len = strlen (str); \ + ++nr +#define ADD_MEM(str, len) \ + iov[nr].iov_base = str; \ + iov[nr].iov_len = len; \ + ++nr + + /* Generate strings of register contents. */ + hexvalue (ctx->sc_regs[0], regs[0], 8); + hexvalue (ctx->sc_regs[1], regs[1], 8); + hexvalue (ctx->sc_regs[2], regs[2], 8); + hexvalue (ctx->sc_regs[3], regs[3], 8); + hexvalue (ctx->sc_regs[4], regs[4], 8); + hexvalue (ctx->sc_regs[5], regs[5], 8); + hexvalue (ctx->sc_regs[6], regs[6], 8); + hexvalue (ctx->sc_regs[7], regs[7], 8); + hexvalue (ctx->sc_regs[8], regs[8], 8); + hexvalue (ctx->sc_regs[9], regs[9], 8); + hexvalue (ctx->sc_regs[10], regs[10], 8); + hexvalue (ctx->sc_regs[11], regs[11], 8); + hexvalue (ctx->sc_regs[12], regs[12], 8); + hexvalue (ctx->sc_regs[13], regs[13], 8); + hexvalue (ctx->sc_regs[14], regs[14], 8); + hexvalue (ctx->sc_regs[15], regs[15], 8); + hexvalue (ctx->sc_macl, regs[16], 8); + hexvalue (ctx->sc_mach, regs[17], 8); + hexvalue (ctx->sc_pc, regs[18], 8); + hexvalue (ctx->sc_pr, regs[19], 8); + hexvalue (ctx->sc_gbr, regs[20], 8); + hexvalue (ctx->sc_sr, regs[21], 8); + + /* Generate the output. */ + ADD_STRING ("Register dump:\n\n R0: "); + ADD_MEM (regs[0], 8); + ADD_STRING (" R1: "); + ADD_MEM (regs[1], 8); + ADD_STRING (" R2: "); + ADD_MEM (regs[2], 8); + ADD_STRING (" R3: "); + ADD_MEM (regs[3], 8); + ADD_STRING ("\n R4: "); + ADD_MEM (regs[4], 8); + ADD_STRING (" R5: "); + ADD_MEM (regs[5], 8); + ADD_STRING (" R6: "); + ADD_MEM (regs[6], 8); + ADD_STRING (" R7: "); + ADD_MEM (regs[7], 8); + ADD_STRING ("\n R8: "); + ADD_MEM (regs[8], 8); + ADD_STRING (" R9: "); + ADD_MEM (regs[9], 8); + ADD_STRING (" R10: "); + ADD_MEM (regs[10], 8); + ADD_STRING (" R11: "); + ADD_MEM (regs[11], 8); + ADD_STRING ("\n R12: "); + ADD_MEM (regs[12], 8); + ADD_STRING (" R13: "); + ADD_MEM (regs[13], 8); + ADD_STRING (" R14: "); + ADD_MEM (regs[14], 8); + ADD_STRING (" R15: "); + ADD_MEM (regs[15], 8); + + ADD_STRING ("\n\nMACL: "); + ADD_MEM (regs[16], 8); + ADD_STRING (" MACH: "); + ADD_MEM (regs[17], 8); + + ADD_STRING ("\n\n PC: "); + ADD_MEM (regs[18], 8); + ADD_STRING (" PR: "); + ADD_MEM (regs[19], 8); + ADD_STRING (" GBR: "); + ADD_MEM (regs[20], 8); + ADD_STRING (" SR: "); + ADD_MEM (regs[21], 8); + + ADD_STRING ("\n"); + + if (ctx->sc_ownedfp != NULL) + { + hexvalue (ctx->sc_fpregs[0], fpregs[0], 8); + hexvalue (ctx->sc_fpregs[1], fpregs[1], 8); + hexvalue (ctx->sc_fpregs[2], fpregs[2], 8); + hexvalue (ctx->sc_fpregs[3], fpregs[3], 8); + hexvalue (ctx->sc_fpregs[4], fpregs[4], 8); + hexvalue (ctx->sc_fpregs[5], fpregs[5], 8); + hexvalue (ctx->sc_fpregs[6], fpregs[6], 8); + hexvalue (ctx->sc_fpregs[7], fpregs[7], 8); + hexvalue (ctx->sc_fpregs[8], fpregs[8], 8); + hexvalue (ctx->sc_fpregs[9], fpregs[9], 8); + hexvalue (ctx->sc_fpregs[10], fpregs[10], 8); + hexvalue (ctx->sc_fpregs[11], fpregs[11], 8); + hexvalue (ctx->sc_fpregs[12], fpregs[12], 8); + hexvalue (ctx->sc_fpregs[13], fpregs[13], 8); + hexvalue (ctx->sc_fpregs[14], fpregs[14], 8); + hexvalue (ctx->sc_fpregs[15], fpregs[15], 8); + hexvalue (ctx->sc_xfpregs[0], fpregs[16], 8); + hexvalue (ctx->sc_xfpregs[1], fpregs[17], 8); + hexvalue (ctx->sc_xfpregs[2], fpregs[18], 8); + hexvalue (ctx->sc_xfpregs[3], fpregs[19], 8); + hexvalue (ctx->sc_xfpregs[4], fpregs[20], 8); + hexvalue (ctx->sc_xfpregs[5], fpregs[21], 8); + hexvalue (ctx->sc_xfpregs[6], fpregs[22], 8); + hexvalue (ctx->sc_xfpregs[7], fpregs[23], 8); + hexvalue (ctx->sc_xfpregs[8], fpregs[24], 8); + hexvalue (ctx->sc_xfpregs[9], fpregs[25], 8); + hexvalue (ctx->sc_xfpregs[10], fpregs[26], 8); + hexvalue (ctx->sc_xfpregs[11], fpregs[27], 8); + hexvalue (ctx->sc_xfpregs[12], fpregs[28], 8); + hexvalue (ctx->sc_xfpregs[13], fpregs[29], 8); + hexvalue (ctx->sc_xfpregs[14], fpregs[30], 8); + hexvalue (ctx->sc_xfpregs[15], fpregs[31], 8); + hexvalue (ctx->sc_fpscr, fpregs[32], 8); + hexvalue (ctx->sc_fpul, fpregs[33], 8); + + ADD_STRING ("\n\n FR0: "); + ADD_MEM (fpregs[0], 8); + ADD_STRING (" FR1: "); + ADD_MEM (fpregs[1], 8); + ADD_STRING (" FR2: "); + ADD_MEM (fpregs[2], 8); + ADD_STRING (" FR3: "); + ADD_MEM (fpregs[3], 8); + ADD_STRING ("\n FR4: "); + ADD_MEM (fpregs[4], 8); + ADD_STRING (" FR5: "); + ADD_MEM (fpregs[5], 8); + ADD_STRING (" FR6: "); + ADD_MEM (fpregs[6], 8); + ADD_STRING (" FR7: "); + ADD_MEM (fpregs[7], 8); + ADD_STRING ("\n FR8: "); + ADD_MEM (fpregs[8], 8); + ADD_STRING (" FR9: "); + ADD_MEM (fpregs[9], 8); + ADD_STRING (" FR10: "); + ADD_MEM (fpregs[10], 8); + ADD_STRING (" FR11: "); + ADD_MEM (fpregs[11], 8); + ADD_STRING ("\nFR12: "); + ADD_MEM (fpregs[12], 8); + ADD_STRING (" FR13: "); + ADD_MEM (fpregs[13], 8); + ADD_STRING (" FR14: "); + ADD_MEM (fpregs[14], 8); + ADD_STRING (" FR15: "); + ADD_MEM (fpregs[15], 8); + ADD_STRING ("\n\n XR0: "); + ADD_MEM (fpregs[16], 8); + ADD_STRING (" XR1: "); + ADD_MEM (fpregs[17], 8); + ADD_STRING (" XR2: "); + ADD_MEM (fpregs[18], 8); + ADD_STRING (" XR3: "); + ADD_MEM (fpregs[19], 8); + ADD_STRING ("\n XR4: "); + ADD_MEM (fpregs[20], 8); + ADD_STRING (" XR5: "); + ADD_MEM (fpregs[21], 8); + ADD_STRING (" XR6: "); + ADD_MEM (fpregs[22], 8); + ADD_STRING (" XR7: "); + ADD_MEM (fpregs[23], 8); + ADD_STRING ("\n XR8: "); + ADD_MEM (fpregs[24], 8); + ADD_STRING (" XR9: "); + ADD_MEM (fpregs[25], 8); + ADD_STRING (" XR10: "); + ADD_MEM (fpregs[26], 8); + ADD_STRING (" XR11: "); + ADD_MEM (fpregs[27], 8); + ADD_STRING ("\nXR12: "); + ADD_MEM (fpregs[28], 8); + ADD_STRING (" XR13: "); + ADD_MEM (fpregs[29], 8); + ADD_STRING (" XR14: "); + ADD_MEM (fpregs[30], 8); + ADD_STRING (" XR15: "); + ADD_MEM (fpregs[31], 8); + + ADD_STRING ("\n\nFPSCR: "); + ADD_MEM (fpregs[32], 8); + ADD_STRING (" FPUL: "); + ADD_MEM (fpregs[33], 8); + + ADD_STRING ("\n"); + } + + /* Write the stuff out. */ + writev (fd, iov, nr); +} + + +#define REGISTER_DUMP register_dump (fd, &ctx) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sigaction.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sigaction.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sigaction.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sigaction.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1,150 @@ +/* Copyright (C) 1997, 1998, 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include +#include + +/* The difference here is that the sigaction structure used in the + kernel is not the same as we use in the libc. Therefore we must + translate it here. */ +#include + +extern int __syscall_sigaction (int, const struct old_kernel_sigaction *, + struct old_kernel_sigaction *); +extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *, + struct kernel_sigaction *, size_t); + +/* The variable is shared between all wrappers around signal handling + functions which have RT equivalents. */ +int __libc_missing_rt_sigs; + +#define SA_RESTORER 0x04000000 + +extern void __default_sa_restorer(void); +extern void __default_rt_sa_restorer(void); + +/* When RT signals are in use we need to use a different return stub. */ +#ifdef __NR_rt_sigreturn +#define choose_restorer(flags) \ + (flags & SA_SIGINFO) ? __default_rt_sa_restorer \ + : __default_sa_restorer +#else +#define choose_restorer(flags) \ + __default_sa_restorer +#endif + +/* If ACT is not NULL, change the action for SIG to *ACT. + If OACT is not NULL, put the old action for SIG in *OACT. */ +int +__sigaction (sig, act, oact) + int sig; + const struct sigaction *act; + struct sigaction *oact; +{ + struct old_kernel_sigaction k_sigact, k_osigact; + int result; + +#ifdef __NR_rt_sigaction + /* First try the RT signals. */ + if (!__libc_missing_rt_sigs) + { + struct kernel_sigaction kact, koact; + int saved_errno = errno; + + if (act) + { + kact.k_sa_handler = act->sa_handler; + memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t)); + kact.sa_flags = act->sa_flags; +# ifdef HAVE_SA_RESTORER + /* If the user specified SA_ONSTACK this means she is trying to + use the old-style stack switching. Unfortunately this + requires the sa_restorer field so we cannot install our own + handler. (In fact the user is likely to be out of luck anyway + since the kernel currently only supports stack switching via + the X/Open sigaltstack interface, but we allow for the + possibility that this might change in the future.) */ + if (kact.sa_flags & (SA_RESTORER | SA_ONSTACK)) + kact.sa_restorer = act->sa_restorer; + else + { + kact.sa_restorer = choose_restorer (kact.sa_flags); + kact.sa_flags |= SA_RESTORER; + } +# endif + } + + /* XXX The size argument hopefully will have to be changed to the + real size of the user-level sigset_t. */ + result = INLINE_SYSCALL (rt_sigaction, 4, sig, act ? &kact : NULL, + oact ? &koact : NULL, _NSIG / 8); + + if (result >= 0 || errno != ENOSYS) + { + if (oact && result >= 0) + { + oact->sa_handler = koact.k_sa_handler; + memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t)); + oact->sa_flags = koact.sa_flags; +# ifdef HAVE_SA_RESTORER + oact->sa_restorer = koact.sa_restorer; +# endif + } + return result; + } + + __set_errno (saved_errno); + __libc_missing_rt_sigs = 1; + } +#endif + + if (act) + { + k_sigact.k_sa_handler = act->sa_handler; + k_sigact.sa_mask = act->sa_mask.__val[0]; + k_sigact.sa_flags = act->sa_flags; +#ifdef HAVE_SA_RESTORER + /* See the comments above for why we test SA_ONSTACK. */ + if (k_sigact.sa_flags & (SA_RESTORER | SA_ONSTACK)) + k_sigact.sa_restorer = act->sa_restorer; + else + { + k_sigact.sa_restorer = choose_restorer (k_sigact.sa_flags); + k_sigact.sa_flags |= SA_RESTORER; + } +#endif + } + result = INLINE_SYSCALL (sigaction, 3, sig, act ? &k_sigact : NULL, + oact ? &k_osigact : NULL); + if (oact && result >= 0) + { + oact->sa_handler = k_osigact.k_sa_handler; + oact->sa_mask.__val[0] = k_osigact.sa_mask; + oact->sa_flags = k_osigact.sa_flags; +#ifdef HAVE_SA_RESTORER + oact->sa_restorer = k_osigact.sa_restorer; +#endif + } + return result; +} + +weak_alias (__sigaction, sigaction) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sigcontextinfo.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sigcontextinfo.h --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sigcontextinfo.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sigcontextinfo.h Sun Mar 12 04:09:10 2000 @@ -0,0 +1,25 @@ +/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Philip Blundell , 1999. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#define SIGCONTEXT int _a2, int _a3, int _a4, struct sigcontext + +#define SIGCONTEXT_EXTRA_ARGS _a2, _a3, _a4, +#define GET_PC(ctx) ((void *) ctx.sc_pc) +#define GET_FRAME(ctx) ((void *) ctx.sc_regs[14]) +#define GET_STACK(ctx) ((void *) ctx.sc_regs[15]) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/siglist.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/siglist.c --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/siglist.c Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/siglist.c Sun Mar 12 04:09:10 2000 @@ -0,0 +1,76 @@ +/* Copyright (C) 1997, 1998, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + +#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING +# define SYS_SIGLIST __new_sys_siglist +# define SYS_SIGABBREV __new_sys_sigabbrev +#else +# define SYS_SIGLIST _sys_siglist +# define SYS_SIGABBREV _sys_sigabbrev +#endif + +#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING +asm (".data; .globl __old_sys_siglist; __old_sys_siglist:"); +#endif + +const char *const SYS_SIGLIST[NSIG] = +{ +#define init_sig(sig, abbrev, desc) [sig] desc, +#include "siglist.h" +#undef init_sig +}; + +#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING +asm (".type __old_sys_siglist,%object;.size __old_sys_siglist," + OLD_SIGLIST_SIZE_STR "*" PTR_SIZE_STR); + +asm (".data; .globl __old_sys_sigabbrev; __old_sys_sigabbrev:"); +#endif + +const char *const SYS_SIGABBREV[NSIG] = +{ +#define init_sig(sig, abbrev, desc) [sig] abbrev, +#include "siglist.h" +#undef init_sig +}; + +#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING +asm (".type __old_sys_sigabbrev,%object;.size __old_sys_sigabbrev," + OLD_SIGLIST_SIZE_STR "*" PTR_SIZE_STR); + +extern const char *const *__old_sys_siglist; +extern const char *const *__old_sys_sigabbrev; + +strong_alias (__old_sys_siglist, _old_sys_siglist) +symbol_version (__old_sys_siglist, _sys_siglist, GLIBC_2.0); +symbol_version (_old_sys_siglist, sys_siglist, GLIBC_2.0); +symbol_version (__old_sys_sigabbrev, sys_sigabbrev, GLIBC_2.0); + +strong_alias (__new_sys_siglist, _new_sys_siglist) +default_symbol_version (__new_sys_siglist, _sys_siglist, GLIBC_2.1); +default_symbol_version (_new_sys_siglist, sys_siglist, GLIBC_2.1); +default_symbol_version (__new_sys_sigabbrev, sys_sigabbrev, GLIBC_2.1); +#else +weak_alias (_sys_siglist, sys_siglist) +weak_alias (_sys_sigabbrev, sys_sigabbrev) +#endif diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sigrestorer.S glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sigrestorer.S --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sigrestorer.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sigrestorer.S Thu Apr 27 21:26:38 2000 @@ -0,0 +1,42 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +/* If no SA_RESTORER function was specified by the application we use + one of these. This avoids the need for the kernel to synthesise a return + instruction on the stack, which would involve expensive cache flushes. */ + +ENTRY(__default_sa_restorer) + mov.w 2f, $r3 + trapa #0x10 +1: bra 1b + nop +2: + .word SYS_ify(sigreturn) + +#ifdef __NR_rt_sigreturn + +ENTRY(__default_rt_sa_restorer) + mov.w 2f, $r3 + trapa #0x10 +1: bra 1b + nop +2: + .word SYS_ify(rt_sigreturn) +#endif diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/socket.S glibc-2.1.3/sysdeps/unix/sysv/linux/sh/socket.S --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/socket.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/socket.S Tue May 16 01:17:23 2000 @@ -0,0 +1,116 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#define P(a, b) P2(a, b) +#define P2(a, b) a##b + + .text +/* The socket-oriented system calls are handled unusally in Linux. + They are all gated through the single `socketcall' system call number. + `socketcall' takes two arguments: the first is the subcode, specifying + which socket function is being called; and the second is a pointer to + the arguments to the specific function. + + The .S files for the other calls just #define socket and #include this. */ + +#ifndef __socket +#define __socket P(__,socket) +#endif + +#define PUSHARGS_1 mov.l r4,@-r15 +#define PUSHARGS_2 mov.l r5,@-r15; PUSHARGS_1 +#define PUSHARGS_3 mov.l r6,@-r15; PUSHARGS_2 +#define PUSHARGS_4 mov.l r7,@-r15; PUSHARGS_3 +#define PUSHARGS_5 PUSHARGS_4 /* Caller has already pushed arg 5 */ +#define PUSHARGS_6 PUSHARGS_4 /* Caller has already pushed arg 5,6 */ + +#define POPARGS_1 add #4,r15 +#define POPARGS_2 add #8,r15 +#define POPARGS_3 add #12,r15 +#define POPARGS_4 add #16,r15 +#define POPARGS_5 add #16,r15 +#define POPARGS_6 add #16,r15 + +#ifndef NARGS +#define NARGS 3 /* If we were called with no wrapper, this is really socket() */ +#endif + +.globl __socket +ENTRY (__socket) + /* This will not work in the case of a socket call being interrupted + by a signal. If the signal handler uses any stack the arguments + to socket will be trashed. The results of a restart of any + socket call are then unpredictable. */ + + /* Push args onto the stack. */ + P(PUSHARGS_,NARGS) + + /* Do the system call trap. */ + mov #+P(SOCKOP_,socket), r4 + mov r15, r5 + mov.l .L1, $r3 + trapa #0x12 + + /* Pop args off the stack */ + P(POPARGS_,NARGS) + + mov r0, r1 + mov #-12, r2 + shad r2, r1 + not r1, r1 // r1=0 means r0 = -1 to -4095 + tst r1, r1 // i.e. error in linux + bf 1f + + mov.l .L2, r1 +#ifdef PIC + mov r0, r4 + mov.l r12, @-r15 + sts.l pr, @-r15 + mov.l 0f, r12 + mova 0f, r0 + add r0, r12 + mova .L2, r0 + add r0, r1 + jsr @r1 + nop + lds.l @r15+, pr + rts + mov.l @r15+, r12 + .align 2 +0: + .long _GLOBAL_OFFSET_TABLE_ +#else + jmp @r1 + nop +#endif +1: + /* Successful; return the syscall's value. */ + rts + nop + .align 2 +.L1: + .long SYS_ify(socketcall) +.L2: + .long PLTJMP(C_SYMBOL_NAME(__syscall_error)) + +PSEUDO_END (__socket) + +weak_alias (__socket, socket) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sys/io.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sys/io.h --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sys/io.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sys/io.h Sun Mar 12 04:09:10 2000 @@ -0,0 +1,48 @@ +/* Copyright (C) 1996, 1998, 1999 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SYS_IO_H + +#define _SYS_IO_H 1 +#include + +__BEGIN_DECLS + +/* If TURN_ON is TRUE, request for permission to do direct i/o on the + port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O + permission off for that range. This call requires root privileges. */ +extern int ioperm __P ((unsigned long int __from, unsigned long int __num, + int __turn_on)); + +/* Set the I/O privilege level to LEVEL. If LEVEL is nonzero, + permission to access any I/O port is granted. This call requires + root privileges. */ +extern int iopl __P ((int __level)); + +/* The functions that actually perform reads and writes. */ +extern unsigned char inb (unsigned long port); +extern unsigned short inw (unsigned long port); +extern unsigned long inl (unsigned long port); + +extern void outb (unsigned char value, unsigned long port); +extern void outw (unsigned short value, unsigned long port); +extern void outl (unsigned long value, unsigned long port); + +__END_DECLS + +#endif /* _SYS_IO_H */ diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sys/user.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sys/user.h --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sys/user.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sys/user.h Thu Apr 27 21:26:38 2000 @@ -0,0 +1,30 @@ +/* Copyright (C) 1998, 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SYS_USER_H +#define _SYS_USER_H 1 + +#include + +/* and both define the PTRACE_* macros. + This leads to compilation problems with programs which include both + user.h and ptrace.h (eg: GDB). Do not include here. */ +#include +#include + +#endif /* sys/user.h */ diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/syscalls.list glibc-2.1.3/sysdeps/unix/sysv/linux/sh/syscalls.list --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/syscalls.list Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/syscalls.list Thu Apr 27 21:26:38 2000 @@ -0,0 +1,52 @@ +# File name Caller Syscall name # args Strong name Weak names + +s_ioctl ioctl ioctl 3 __syscall_ioctl +s_ipc msgget ipc 5 __syscall_ipc +s_llseek llseek _llseek 5 __syscall__llseek +s_chown chown chown 3 __syscall_chown +s_execve execve execve 3 __syscall_execve +rt_sigaction - rt_sigaction 4 __syscall_rt_sigaction +rt_sigpending - rt_sigpending 2 __syscall_rt_sigpending +rt_sigprocmask - rt_sigprocmask 4 __syscall_rt_sigprocmask +rt_sigqueueinfo - rt_sigqueueinfo 3 __syscall_rt_sigqueueinfo +rt_sigsuspend - rt_sigsuspend 2 __syscall_rt_sigsuspend +rt_sigtimedwait - rt_sigtimedwait 4 __syscall_rt_sigtimedwait +s_getcwd getcwd getcwd 2 __syscall_getcwd +s_getdents getdents getdents 3 __syscall_getdents +s_getgroups getgroups getgroups 2 __syscall_getgroups +s_getpriority getpriority getpriority 2 __syscall_getpriority +getresgid - getresgid 3 getresgid +getresuid - getresuid 3 getresuid +s_poll poll poll 3 __syscall_poll +s_pread64 pread64 pread 5 __syscall_pread +s_ptrace ptrace ptrace 4 __syscall_ptrace +s_pwrite64 pwrite64 pwrite 5 __syscall_pwrite +s_reboot reboot reboot 3 __syscall_reboot +s_sigaction sigaction sigaction 3 __syscall_sigaction +s_sigpending sigpending sigpending 1 __syscall_sigpending +s_sigprocmask sigprocmask sigprocmask 3 __syscall_sigprocmask +s_sigsuspend sigsuspend sigsuspend 3 __syscall_sigsuspend +s_setfsgid setfsgid setfsgid 1 __syscall_setfsgid +s_setfsuid setfsuid setfsuid 1 __syscall_setfsuid +s_setgid setgid setgid 1 __syscall_setgid +s_setgroups setgroups setgroups 2 __syscall_setgroups +s_setregid setregid setregid 2 __syscall_setregid +s_setresgid setresgid setresgid 3 __syscall_setresgid +s_setresuid setresuid setresuid 3 __syscall_setresuid +s_setreuid setreuid setreuid 2 __syscall_setreuid +s_setuid setuid setuid 1 __syscall_setuid +s_sysctl sysctl _sysctl 1 __syscall__sysctl +s_ugetrlimit getrlimit ugetrlimit 2 __syscall_ugetrlimit +s_ustat ustat ustat 2 __syscall_ustat +sys_fstat fxstat fstat 2 __syscall_fstat +sys_lstat lxstat lstat 2 __syscall_lstat +sys_mknod xmknod mknod 3 __syscall_mknod +sys_readv readv readv 3 __syscall_readv +sys_stat xstat stat 2 __syscall_stat +sys_writev writev writev 3 __syscall_writev +syscall - syscall 5 syscall +s_fstat64 fxstat64 fstat64 2 __syscall_fstat64 +s_ftruncate64 ftruncate64 ftruncate64 3 __syscall_ftruncate64 +s_lstat64 lxstat64 lstat64 2 __syscall_lstat64 +s_truncate64 truncate64 truncate64 3 __syscall_truncate64 +s_stat64 xstat64 stat64 2 __syscall_stat64 diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sysdep.S glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sysdep.S --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sysdep.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sysdep.S Sun Mar 12 04:09:10 2000 @@ -0,0 +1,43 @@ +/* Copyright (C) 1995, 1996, 1997, 1998, 1999 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +/* We define errno here, to be consistent with Linux/i386. */ + + .section .bss + .globl C_SYMBOL_NAME(errno) + .type C_SYMBOL_NAME(errno), @object + .size C_SYMBOL_NAME(errno), 4 +C_SYMBOL_NAME(errno): + .space 4 +weak_alias (errno, _errno) + .text + +/* The syscall stubs jump here when they detect an error. + The code for Linux is almost identical to the canonical Unix + code, except that the error number in R0 is negated. */ + +#undef CALL_MCOUNT +#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */ + +ENTRY (__syscall_error) + neg r4, r0 + +#define __syscall_error __syscall_error_1 +#include diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sysdep.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sysdep.h --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sysdep.h Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sysdep.h Thu Apr 27 21:26:38 2000 @@ -0,0 +1,143 @@ +/* Copyright (C) 1992, 93, 95-99, 2000 Free Software Foundation, + Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper, , August 1995. + Changed by Kaz Kojima, . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _LINUX_SH_SYSDEP_H +#define _LINUX_SH_SYSDEP_H 1 + +/* There is some commonality. */ +#include + +/* For Linux we can use the system call table in the header file + /usr/include/asm/unistd.h + of the kernel. But these symbols do not follow the SYS_* syntax + so we have to redefine the `SYS_ify' macro here. */ +#undef SYS_ify +#define SYS_ify(syscall_name) (__NR_##syscall_name) + + +#ifdef __ASSEMBLER__ + +/* Linux uses a negative return value to indicate syscall errors, + unlike most Unices, which use the condition codes' carry flag. + + Since version 2.1 the return value of a system call might be + negative even if the call succeeded. E.g., the `lseek' system call + might return a large offset. Therefore we must not anymore test + for < 0, but test for a real error by making sure the value in R0 + is a real error number. Linus said he will make sure the no syscall + returns a value in -1 .. -4095 as a valid result so we can savely + test with -4095. */ + +#define _IMM12 #-12 +#undef PSEUDO +#ifdef PIC +#define PSEUDO(name, syscall_name, args) \ + .text; \ + ENTRY (name); \ + DO_CALL (args, syscall_name); \ + mov r0,r1; \ + mov _IMM12,r2; \ + shad r2,r1; \ + not r1,r1; \ + tst r1,r1; \ + bf 1f; \ + mov r0,r4; \ + mov.l r12,@-r15; \ + sts.l pr,@-r15; \ + mov.l 0f,r12; \ + mova 0f,r0; \ + add r0,r12; \ + mov.l 2f,r1; \ + mova 2f,r0; \ + add r0,r1; \ + jsr @r1; \ + nop; \ + lds.l @r15+,pr; \ + rts; \ + mov.l @r15+,r12; \ + .align 2; \ + 2: .long PLTJMP(C_SYMBOL_NAME(__syscall_error)); \ + 0: .long _GLOBAL_OFFSET_TABLE_; \ + 1: +#else +#define PSEUDO(name, syscall_name, args) \ + .text; \ + ENTRY (name); \ + DO_CALL (args, syscall_name); \ + mov r0,r1; \ + mov _IMM12,r2; \ + shad r2,r1; \ + not r1,r1; \ + tst r1,r1; \ + bf 1f; \ + mov.l 2f,r1; \ + jmp @r1; \ + mov r0, r4; \ + .align 2; \ + 2: .long PLTJMP(C_SYMBOL_NAME(__syscall_error)); \ + 1: +#endif + +#undef PSEUDO_END +#define PSEUDO_END(name) \ + SYSCALL_ERROR_HANDLER \ + END (name) + +#define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */ + +#define SYSCALL_ARGS0 +#define SYSCALL_ARGS1 +#define SYSCALL_ARGS2 +#define SYSCALL_ARGS3 +#define SYSCALL_ARGS4 +#define SYSCALL_ARGS5 mov.l @$r15, $r0 +#define SYSCALL_ARGS6 SYSCALL_ARGS5; mov.l @(4,$r15), $r1 +#define SYSCALL_ARGS7 SYSCALL_ARGS6; mov.l @(8,$r15), $r2 + +#define SYSCALL_INST0 trapa #0x10 +#define SYSCALL_INST1 trapa #0x11 +#define SYSCALL_INST2 trapa #0x12 +#define SYSCALL_INST3 trapa #0x13 +#define SYSCALL_INST4 trapa #0x14 +#define SYSCALL_INST5 trapa #0x15 +#define SYSCALL_INST6 trapa #0x16 +#define SYSCALL_INST7 trapa #0x17 + +#undef DO_CALL +#define DO_CALL(args, syscall_name) \ + SYSCALL_ARGS##args; \ + mov.l 1f, $r3; \ + SYSCALL_INST##args; \ + bra 2f; \ + nop; \ + .align 2; \ + 1: .long SYS_ify(syscall_name); \ + 2: + +#else /* not __ASSEMBLER__ */ + +#undef INLINE_SYSCALL +#define INLINE_SYSCALL(name, nr, args...) \ + __syscall_##name(args) + +#endif /* __ASSEMBLER__ */ + +#endif /* linux/sh/sysdep.h */ diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/vfork.S glibc-2.1.3/sysdeps/unix/sysv/linux/sh/vfork.S --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/vfork.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/vfork.S Thu Apr 27 21:26:38 2000 @@ -0,0 +1,112 @@ +/* Copyright (C) 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#define _ERRNO_H 1 +#include + +/* Clone the calling process, but without copying the whole address space. + The calling process is suspended until the new process exits or is + replaced by a call to `execve'. Return -1 for errors, 0 to the new process, + and the process ID of the new process to the old process. */ + +ENTRY (__vfork) + +#ifdef __NR_vfork + mov #+__NR_vfork, $r3 + trapa #0x10 + mov r0, r1 + mov #-12, r2 + shad r2, r1 + not r1, r1 // r1=0 means r0 = -1 to -4095 + tst r1, r1 // i.e. error in linux + bf 1f + mov.w .L1, r1 + cmp/eq r1, r0 + bt 2f + mov.l .L2, r1 +#ifdef PIC + mov r0, r4 + mov.l r12, @-r15 + sts.l pr, @-r15 + mov.l 0f, r12 + mova 0f, r0 + add r0, r12 + mova .L2, r0 + add r0, r1 + jsr @r1 + nop + lds.l @r15+, pr + rts + mov.l @r15+, r12 + .align 2 +0: + .long _GLOBAL_OFFSET_TABLE_ +#else + jmp @r1 + mov r0, r4 +#endif +.L1: + .word -ENOSYS +1: + rts + nop +2: +#endif + + /* If we don't have vfork, fork is close enough. */ + mov #+__NR_fork, $r3 + trapa #0x10 + mov r0, r1 + mov #-12, r2 + shad r2, r1 + not r1, r1 // r1=0 means r0 = -1 to -4095 + tst r1, r1 // i.e. error in linux + bf 1f + mov.l .L2, r1 +#ifdef PIC + mov r0, r4 + mov.l r12, @-r15 + sts.l pr, @-r15 + mov.l 0f, r12 + mova 0f, r0 + add r0, r12 + mova .L2, r0 + add r0, r1 + jsr @r1 + nop + lds.l @r15+, pr + rts + mov.l @r15+, r12 + .align 2 +0: + .long _GLOBAL_OFFSET_TABLE_ +#else + jmp @r1 + mov r0, r4 +#endif + .align 2 +.L2: + .long PLTJMP(C_SYMBOL_NAME(__syscall_error)) +1: + rts + nop + +PSEUDO_END (__vfork) + +weak_alias (__vfork, vfork) diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/syscall.S glibc-2.1.3/sysdeps/unix/sysv/linux/syscall.S --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/syscall.S Thu Jan 1 09:00:00 1970 +++ glibc-2.1.3/sysdeps/unix/sysv/linux/syscall.S Sun Mar 12 04:09:10 2000 @@ -0,0 +1,33 @@ +/* Copyright (C) 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +/* Please consult the file sysdeps/unix/sysv/linux/sh/sysdep.h for + more information about the value -4095 used below.*/ + + .text +ENTRY(__syscall) + + /* XXX should be implemented !! */ + rts /* Return to caller. */ + nop + +PSEUDO_END (__syscall) + +weak_alias (__syscall, clone) From aj@suse.de Thu May 25 05:25:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Thu, 25 May 2000 05:25:00 -0000 Subject: Adding SH support to glibc-2.1.3 References: <200005251128.UAA14744@rr.iij4u.or.jp> Message-ID: >>>>> kaz Kojima writes: > Hi, > Here's a patch for glibc-2.1.3 to support new sh-linux-gnu target for > Linux on Hitachi SH processors. > We've already done the paper work for copyright assignment, and got back > the copy from FSF. > Patch consists of two parts. One is for changes of generic part, and > another is SH specific part. For the changes of generic part, there > are four diffs. First three diffs are trivial, just add sh[34] > support. We need the 4-th diff for csu/Makefile to get cststuff > routines directly. This is needed because we couldn't use generated > files. The constant (for label) is emitted far away than expected > by the generation, after the function epilogue. I didn't look at the patch yet but don't think that it will be accepted for glibc 2.1.3. Could you please port this to the current development version of glibc 2.2? All the work is done for 2.2 now and I don't know if we see a 2.1.4 release at all. Therefore adding a new port to 2.1.x doesn't make much sense. But Ulrich has to comment on this. I'll send you next week some comments on the patch, Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From kkojima@rr.iij4u.or.jp Thu May 25 06:02:00 2000 From: kkojima@rr.iij4u.or.jp (kaz Kojima) Date: Thu, 25 May 2000 06:02:00 -0000 Subject: Adding SH support to glibc-2.1.3 References: Message-ID: <200005251302.WAA06390@rr.iij4u.or.jp> Hi Andreas, > I didn't look at the patch yet but don't think that it will be > accepted for glibc 2.1.3. Could you please port this to the current > development version of glibc 2.2? All the work is done for 2.2 now > and I don't know if we see a 2.1.4 release at all. Therefore adding a > new port to 2.1.x doesn't make much sense. But Ulrich has to comment > on this. We put our patch since it's a unique stable version we have. But I agree with you. We should to do so. Please give us some more time. Thank you for your comments. kaz From drepper@redhat.com Thu May 25 07:30:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 25 May 2000 07:30:00 -0000 Subject: Adding SH support to glibc-2.1.3 References: <200005251128.UAA14744@rr.iij4u.or.jp> Message-ID: Andreas Jaeger writes: > All the work is done for 2.2 now and I don't know if we see a 2.1.4 > release at all. Therefore adding a new port to 2.1.x doesn't make > much sense. Changing the patches for 2.2 is definitely required. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From kukuk@suse.de Thu May 25 08:33:00 2000 From: kukuk@suse.de (Thorsten Kukuk) Date: Thu, 25 May 2000 08:33:00 -0000 Subject: LFS/syscalls -> Kernel interface incompatibility Message-ID: <20000525173329.A16025@suse.de> Hi, I found a big problem with the LFS interface between kernel and glibc. In glibc, we call (f)truncate64 as following: int result = INLINE_SYSCALL (truncate64, 3, path, low, high); In kernel, we have the following: long sys_truncate64(const char * path, loff_t length); or sys32_truncate64(const char * path, unsigned long high, unsigned long low); As everybody can see, our syscall only works with sys_truncate64 on little endian machines, and never with sys32_truncate64. I think we have some more functions like this (pread ?). What should we do ? If the kernel would always use something like sys32_truncate64, we had no problems. But with the current situation, I think we need to duplicate this files for every big endian architecture and change the syscall. Any other ideas ? Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE GmbH Schanzaeckerstr. 10 90443 Nuernberg Linux is like a Vorlon. It is incredibly powerful, gives terse, cryptic answers and has a lot of things going on in the background. From drepper@redhat.com Thu May 25 08:52:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 25 May 2000 08:52:00 -0000 Subject: LFS/syscalls -> Kernel interface incompatibility References: <20000525173329.A16025@suse.de> Message-ID: Thorsten Kukuk writes: > But with the current situation, I think we need to duplicate this > files for every big endian architecture and change the syscall. Yes, and this is no real problem. Just locate them and provide an alternative file. Assume we cannot change the kernel (which is most probably the correct assumption). -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From gniibe@chroot.org Thu May 25 16:59:00 2000 From: gniibe@chroot.org (NIIBE Yutaka) Date: Thu, 25 May 2000 16:59:00 -0000 Subject: Adding SH support to glibc-2.1.3 References: <200005251128.UAA14744@rr.iij4u.or.jp> Message-ID: Ulrich Drepper wrote: > Changing the patches for 2.2 is definitely required. OK, will do. BTW, I have a question about multilib. There's two processor type, SH-3 and SH-4. SH-4 has FPU and larger cache. All the (user space) code compiled for SH-3 works on SH-4. Besides, both processor support both endianess. In GCC, they are supported by multilib. In GCC, target sh-unknown-linux-gnu builds, say: libgcc.a ----- SH-3 little endian m4/libgcc.a ----- SH-4 little endian mb/libgcc.a ----- SH-3 big endian mb/m4/libgcc.a ----- SH-4 big endian (actually, sh-unknown-linux-gnu are not yet supported in GCC, we'll send patches) Should we support things like this for GNU C Library? Currently, I do configure for each target (sh3-unknown-linux-gnu, sh4-unknown-linux-gnu with different compiler switch (-mb for bigendian)), on installation. It would be better it built all of them with target sh-unknown-linux-gnu... Please let me know your opinion. -- From drepper@redhat.com Thu May 25 17:20:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 25 May 2000 17:20:00 -0000 Subject: Adding SH support to glibc-2.1.3 References: <200005251128.UAA14744@rr.iij4u.or.jp> Message-ID: NIIBE Yutaka writes: > Should we support things like this for GNU C Library? Currently, I do > configure for each target (sh3-unknown-linux-gnu, > sh4-unknown-linux-gnu with different compiler switch (-mb for > bigendian)), on installation. It would be better it built all of them > with target sh-unknown-linux-gnu... The question is: what do you want people to use? I would say having to endinanesses is bad. Decide on one and declare it the default. For the SH-3, SH-4 difference. Assuming the SH-1 and -2 will never be supported (which is obviously correct) put the SH-3 files directly in the sh subdirs. For SH-4 specific code create a subdir sh4 and put those file in their. Then we'll recognize in the configure script whether SH-3 or SH-4 is the target and include the sh4 subdir or not. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Fri May 26 02:08:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 May 2000 02:08:00 -0000 Subject: Fix for PR libc/1573 committed Message-ID: <200005260908.LAA30952@maclaurin.suse.de> FYI I'll commit later the appended patch to both branches. Andreas 2000-05-26 Andreas Jaeger * sunrpc/xdr_intXX_t.c (xdr_uint8_t): Fix conversion. Closes PR libc/1573, reported by Bradley White . ============================================================ Index: sunrpc/xdr_intXX_t.c --- sunrpc/xdr_intXX_t.c 2000/03/03 20:55:03 1.3 +++ sunrpc/xdr_intXX_t.c 2000/05/26 09:07:17 @@ -187,11 +187,11 @@ switch (xdrs->x_op) { - case XDR_DECODE: - ut = (uint32_t) *uip; - return XDR_GETINT32 (xdrs, (int32_t *) &ut); case XDR_ENCODE: - if (!XDR_PUTINT32 (xdrs, (int32_t *) &ut)) + ut = (uint32_t) *uip; + return XDR_PUTINT32 (xdrs, (int32_t *) &ut); + case XDR_DECODE: + if (!XDR_GETINT32 (xdrs, (int32_t *) &ut)) return FALSE; *uip = (uint8_t) ut; return TRUE; -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From aj@suse.de Fri May 26 02:49:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 May 2000 02:49:00 -0000 Subject: readelf: pointer validy checks patch Message-ID: ldconfig crashed when one of the elf structures is broken and a pointer points outside the mmapped region. I've added now checks to prevent the most common cases. We can still segfault if e.g. the end of file is in the middle of a string - but I don't think we should test all those cases and concentrate on the common ones first. I'll commit this patch later, Andreas 2000-05-26 Andreas Jaeger * sysdeps/generic/readelflib.c (check_ptr): New. (process_elf_file): Use check_ptr to check all accesses to the mmapped file. * elf/readlib.c (known_libs): Add more libraries. ============================================================ Index: elf/ldconfig.h --- elf/ldconfig.h 2000/05/07 21:20:01 1.3 +++ elf/ldconfig.h 2000/05/26 09:42:23 @@ -46,7 +46,8 @@ /* Declared in readelflib.c. */ extern int process_elf_file (const char *file_name, const char *lib, int *flag, - char **soname, void *file_contents); + char **soname, void *file_contents, + size_t file_length); /* Declared in ldconfig.c. */ ============================================================ Index: elf/readlib.c --- elf/readlib.c 2000/04/11 16:22:06 1.3 +++ elf/readlib.c 2000/05/26 09:42:23 @@ -56,8 +56,10 @@ static struct known_names known_libs [] = { {"libc.so.6", FLAG_ELF_LIBC6}, + {"libc.so.6.1", FLAG_ELF_LIBC6}, {"libc.so.5", FLAG_ELF_LIBC5}, {"libm.so.6", FLAG_ELF_LIBC6}, + {"libm.so.6.1", FLAG_ELF_LIBC6}, {"libm.so.5", FLAG_ELF_LIBC5} }; @@ -65,7 +67,8 @@ /* Returns 0 if everything is ok, != 0 in case of error. */ int -process_file (const char *file_name, const char *lib, int *flag, char **soname, int is_link) +process_file (const char *file_name, const char *lib, int *flag, + char **soname, int is_link) { FILE *file; struct stat statbuf; @@ -156,7 +159,8 @@ goto done; } - if (process_elf_file (file_name, lib, flag, soname, file_contents)) + if (process_elf_file (file_name, lib, flag, soname, file_contents, + statbuf.st_size)) ret = 1; done: ============================================================ Index: sysdeps/generic/readelflib.c --- sysdeps/generic/readelflib.c 1999/12/04 07:56:05 1.1 +++ sysdeps/generic/readelflib.c 2000/05/26 09:42:23 @@ -23,10 +23,24 @@ which need to handle both 32bit and 64bit ELF libraries, this file is included twice for each arch size. */ +/* check_ptr checks that a pointer is in the mmaped file and doesn't + point outside it. */ +#define check_ptr(ptr) \ +do \ + { \ + if ((void *)(ptr) < file_contents \ + || (void *)(ptr) > (file_contents+file_length)) \ + { \ + error (0, 0, _("file %s is truncated\n"), file_name); \ + return 1; \ + } \ + } \ + while (0); + /* Returns 0 if everything is ok, != 0 in case of error. */ int -process_elf_file (const char *file_name, const char *lib, int *flag, char **soname, - void *file_contents) +process_elf_file (const char *file_name, const char *lib, int *flag, + char **soname, void *file_contents, size_t file_length) { int i; unsigned int j; @@ -65,6 +79,7 @@ /* Get information from elf program header. */ elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents); + check_ptr (elf_pheader); /* The library is an elf library, now search for soname and libc5/libc6. */ @@ -77,6 +92,8 @@ for (i = 0, segment = elf_pheader; i < elf_header->e_phnum; i++, segment++) { + check_ptr (segment); + switch (segment->p_type) { case PT_LOAD: @@ -94,6 +111,7 @@ break; case PT_INTERP: program_interpreter = (char *) (file_contents + segment->p_offset); + check_ptr (program_interpreter); /* Check if this is enough to classify the binary. */ for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]); @@ -120,15 +138,18 @@ return 1; dynamic_segment = (ElfW(Dyn) *) (file_contents + dynamic_addr); + check_ptr (dynamic_segment); /* Find the string table. */ dynamic_strings = NULL; for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++dyn_entry) { + check_ptr (dyn_entry); if (dyn_entry->d_tag == DT_STRTAB) { dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr); + check_ptr (dynamic_strings); break; } } @@ -143,6 +164,7 @@ if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME) { char *name = dynamic_strings + dyn_entry->d_un.d_val; + check_ptr (name); if (dyn_entry->d_tag == DT_NEEDED) { ============================================================ Index: sysdeps/unix/sysv/linux/sparc/readelflib.c --- sysdeps/unix/sysv/linux/sparc/readelflib.c 1999/12/04 07:55:35 1.1 +++ sysdeps/unix/sysv/linux/sparc/readelflib.c 2000/05/26 09:42:23 @@ -20,23 +20,27 @@ int process_elf32_file (const char *file_name, const char *lib, int *flag, - char **soname, void *file_contents); + char **soname, void *file_contents, + size_t file_length); int process_elf64_file (const char *file_name, const char *lib, int *flag, - char **soname, void *file_contents); + char **soname, void *file_contents, + size_t file_length); /* Returns 0 if everything is ok, != 0 in case of error. */ int process_elf_file (const char *file_name, const char *lib, int *flag, - char **soname, void *file_contents) + char **soname, void *file_contents, size_t size) { ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents; int ret; if (elf_header->e_ident [EI_CLASS] == ELFCLASS32) - return process_elf32_file (file_name, lib, flag, soname, file_contents); + return process_elf32_file (file_name, lib, flag, soname, file_contents, + file_length); else { - ret = process_elf64_file (file_name, lib, flag, soname, file_contents); + ret = process_elf64_file (file_name, lib, flag, soname, file_contents, + file_length); /* Sparc 64bit libraries are always libc.so.6+. */ if (!ret) *flag = FLAG_SPARC_LIB64|FLAG_ELF_LIBC6; -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From kukuk@suse.de Fri May 26 02:57:00 2000 From: kukuk@suse.de (Thorsten Kukuk) Date: Fri, 26 May 2000 02:57:00 -0000 Subject: LFS/syscalls -> Kernel interface incompatibility References: <20000525173329.A16025@suse.de> Message-ID: <20000526115656.A30220@suse.de> On Thu, May 25, Ulrich Drepper wrote: > Thorsten Kukuk writes: > > > But with the current situation, I think we need to duplicate this > > files for every big endian architecture and change the syscall. > > Yes, and this is no real problem. Just locate them and provide an > alternative file. Assume we cannot change the kernel (which is most > probably the correct assumption). Ok, here is a patch for sparc32. It seems PowerPC doesn't support LFS in the moment, but they have to make the same changes if they support it. Have we more big-endian, 32bit architectures ? The other syscalls looks ok. The patch is for glibc 2.1 and 2.2. Thorsten -- Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de SuSE GmbH Schanzaeckerstr. 10 90443 Nuernberg Linux is like a Vorlon. It is incredibly powerful, gives terse, cryptic answers and has a lot of things going on in the background. From aj@suse.de Fri May 26 03:05:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 May 2000 03:05:00 -0000 Subject: LFS/syscalls -> Kernel interface incompatibility References: <20000525173329.A16025@suse.de> <20000526115656.A30220@suse.de> Message-ID: >>>>> Thorsten Kukuk writes: Th> On Thu, May 25, Ulrich Drepper wrote: >> Thorsten Kukuk writes: >> >> > But with the current situation, I think we need to duplicate this >> > files for every big endian architecture and change the syscall. >> >> Yes, and this is no real problem. Just locate them and provide an >> alternative file. Assume we cannot change the kernel (which is most >> probably the correct assumption). Th> Ok, here is a patch for sparc32. It seems PowerPC doesn't support Th> LFS in the moment, but they have to make the same changes if they Th> support it. Have we more big-endian, 32bit architectures ? Th> The other syscalls looks ok. Th> The patch is for glibc 2.1 and 2.2. Th> 2000-05-26 Thorsten Kukuk Th> Th> * sysdeps/unix/sysv/linux/sparc/sparc32/ftruncate64.c: New, change Th> syscall arguments for big-endian. Th> * sysdeps/unix/sysv/linux/sparc/sparc32/truncate64.c: Likewise. Th> I've one design question: In case of such problems do we put little endian or big endian files in sysdeps/unix/sysv/linux? Currently we have there for example: - ftruncate64 that works for little endian - pread64 that works for big endian Or should rewrite the general version to use: #if __BYTE_ORDER == __LITTLE_ENDIAN #elif __BYTE_ORDER == __BIG_ENDIAN #else #error "..." #endif Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From aj@suse.de Fri May 26 03:20:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 May 2000 03:20:00 -0000 Subject: ldconfig: pointer validy checks patch References: Message-ID: >>>>> Andreas Jaeger writes: > ldconfig crashed when one of the elf structures is broken and a > pointer points outside the mmapped region. I've added now checks to > prevent the most common cases. We can still segfault if e.g. the end > of file is in the middle of a string - but I don't think we should > test all those cases and concentrate on the common ones first. > I'll commit this patch later, > Andreas I've changed the library names in readlib a bit to use and commited this now. FYI I've appended the patch, Andreas 2000-05-26 Andreas Jaeger * sysdeps/generic/readelflib.c (check_ptr): New. (process_elf_file): Use check_ptr to check all accesses to the mmapped file. * elf/readlib.c (known_libs): Use to specify library names. ============================================================ Index: elf/ldconfig.h --- elf/ldconfig.h 2000/05/07 21:20:01 1.3 +++ elf/ldconfig.h 2000/05/26 10:14:18 @@ -46,7 +46,8 @@ /* Declared in readelflib.c. */ extern int process_elf_file (const char *file_name, const char *lib, int *flag, - char **soname, void *file_contents); + char **soname, void *file_contents, + size_t file_length); /* Declared in ldconfig.c. */ ============================================================ Index: elf/readlib.c --- elf/readlib.c 2000/04/11 16:22:06 1.3 +++ elf/readlib.c 2000/05/26 10:14:18 @@ -35,6 +35,7 @@ #include #include +#include #include "ldconfig.h" @@ -49,23 +50,26 @@ static struct known_names interpreters [] = { - {"/lib/ld-linux.so.2", FLAG_ELF_LIBC6}, + {"/lib/" LD_LINUX_SO, FLAG_ELF_LIBC6}, {"/lib/ld-linux.so.1", FLAG_ELF_LIBC5} }; static struct known_names known_libs [] = { - {"libc.so.6", FLAG_ELF_LIBC6}, + /* Old names: */ {"libc.so.5", FLAG_ELF_LIBC5}, - {"libm.so.6", FLAG_ELF_LIBC6}, - {"libm.so.5", FLAG_ELF_LIBC5} + {"libm.so.5", FLAG_ELF_LIBC5}, + /* Current names: */ + {LIBC_SO, FLAG_ELF_LIBC6}, + {LIBM_SO, FLAG_ELF_LIBC6} }; /* Returns 0 if everything is ok, != 0 in case of error. */ int -process_file (const char *file_name, const char *lib, int *flag, char **soname, int is_link) +process_file (const char *file_name, const char *lib, int *flag, + char **soname, int is_link) { FILE *file; struct stat statbuf; @@ -156,7 +160,8 @@ goto done; } - if (process_elf_file (file_name, lib, flag, soname, file_contents)) + if (process_elf_file (file_name, lib, flag, soname, file_contents, + statbuf.st_size)) ret = 1; done: ============================================================ Index: sysdeps/generic/readelflib.c --- sysdeps/generic/readelflib.c 1999/12/04 07:56:05 1.1 +++ sysdeps/generic/readelflib.c 2000/05/26 10:14:18 @@ -23,10 +23,24 @@ which need to handle both 32bit and 64bit ELF libraries, this file is included twice for each arch size. */ +/* check_ptr checks that a pointer is in the mmaped file and doesn't + point outside it. */ +#define check_ptr(ptr) \ +do \ + { \ + if ((void *)(ptr) < file_contents \ + || (void *)(ptr) > (file_contents+file_length)) \ + { \ + error (0, 0, _("file %s is truncated\n"), file_name); \ + return 1; \ + } \ + } \ + while (0); + /* Returns 0 if everything is ok, != 0 in case of error. */ int -process_elf_file (const char *file_name, const char *lib, int *flag, char **soname, - void *file_contents) +process_elf_file (const char *file_name, const char *lib, int *flag, + char **soname, void *file_contents, size_t file_length) { int i; unsigned int j; @@ -65,6 +79,7 @@ /* Get information from elf program header. */ elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents); + check_ptr (elf_pheader); /* The library is an elf library, now search for soname and libc5/libc6. */ @@ -77,6 +92,8 @@ for (i = 0, segment = elf_pheader; i < elf_header->e_phnum; i++, segment++) { + check_ptr (segment); + switch (segment->p_type) { case PT_LOAD: @@ -94,6 +111,7 @@ break; case PT_INTERP: program_interpreter = (char *) (file_contents + segment->p_offset); + check_ptr (program_interpreter); /* Check if this is enough to classify the binary. */ for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]); @@ -120,15 +138,18 @@ return 1; dynamic_segment = (ElfW(Dyn) *) (file_contents + dynamic_addr); + check_ptr (dynamic_segment); /* Find the string table. */ dynamic_strings = NULL; for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL; ++dyn_entry) { + check_ptr (dyn_entry); if (dyn_entry->d_tag == DT_STRTAB) { dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr); + check_ptr (dynamic_strings); break; } } @@ -143,6 +164,7 @@ if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME) { char *name = dynamic_strings + dyn_entry->d_un.d_val; + check_ptr (name); if (dyn_entry->d_tag == DT_NEEDED) { ============================================================ Index: sysdeps/unix/sysv/linux/sparc/readelflib.c --- sysdeps/unix/sysv/linux/sparc/readelflib.c 1999/12/04 07:55:35 1.1 +++ sysdeps/unix/sysv/linux/sparc/readelflib.c 2000/05/26 10:14:19 @@ -20,23 +20,27 @@ int process_elf32_file (const char *file_name, const char *lib, int *flag, - char **soname, void *file_contents); + char **soname, void *file_contents, + size_t file_length); int process_elf64_file (const char *file_name, const char *lib, int *flag, - char **soname, void *file_contents); + char **soname, void *file_contents, + size_t file_length); /* Returns 0 if everything is ok, != 0 in case of error. */ int process_elf_file (const char *file_name, const char *lib, int *flag, - char **soname, void *file_contents) + char **soname, void *file_contents, size_t size) { ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents; int ret; if (elf_header->e_ident [EI_CLASS] == ELFCLASS32) - return process_elf32_file (file_name, lib, flag, soname, file_contents); + return process_elf32_file (file_name, lib, flag, soname, file_contents, + file_length); else { - ret = process_elf64_file (file_name, lib, flag, soname, file_contents); + ret = process_elf64_file (file_name, lib, flag, soname, file_contents, + file_length); /* Sparc 64bit libraries are always libc.so.6+. */ if (!ret) *flag = FLAG_SPARC_LIB64|FLAG_ELF_LIBC6; -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From drepper@redhat.com Fri May 26 07:44:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 26 May 2000 07:44:00 -0000 Subject: LFS/syscalls -> Kernel interface incompatibility References: <20000525173329.A16025@suse.de> <20000526115656.A30220@suse.de> Message-ID: Andreas Jaeger writes: > I've one design question: In case of such problems do we put little > endian or big endian files in sysdeps/unix/sysv/linux? > > Currently we have there for example: > - ftruncate64 that works for little endian > - pread64 that works for big endian I agree with this. It is better to be consistent. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Fri May 26 07:47:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 May 2000 07:47:00 -0000 Subject: LFS/syscalls -> Kernel interface incompatibility References: <20000525173329.A16025@suse.de> <20000526115656.A30220@suse.de> Message-ID: >>>>> Ulrich Drepper writes: Uli> Andreas Jaeger writes: >> I've one design question: In case of such problems do we put little >> endian or big endian files in sysdeps/unix/sysv/linux? >> >> Currently we have there for example: >> - ftruncate64 that works for little endian >> - pread64 that works for big endian Uli> I agree with this. It is better to be consistent. So, what's the policy? Big or little? - and I would even like to use: #if __BYTE_ORDER == __LITTLE_ENDIAN #elif __BYTE_ORDER == __BIG_ENDIAN #else #error "..." #endif I'll send a patch later for pread64.c to show what I mean. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From drepper@redhat.com Fri May 26 07:58:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 26 May 2000 07:58:00 -0000 Subject: LFS/syscalls -> Kernel interface incompatibility References: <20000525173329.A16025@suse.de> <20000526115656.A30220@suse.de> Message-ID: Andreas Jaeger writes: > So, what's the policy? Big or little? - and I would even like to use: Leave pread alone and make the truncate change similar to the pread change. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Fri May 26 08:07:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 May 2000 08:07:00 -0000 Subject: pread64/pwrite64 cleanup Message-ID: <200005261507.RAA00663@maclaurin.suse.de> Here's a patch to unify the different pread64/pwrite64 versions. There're other functions that could use the same treatment. Uli, is it ok to commit this? Andreas 2000-05-26 Andreas Jaeger * sysdeps/unix/sysv/linux/i386/pread64.c: Removed, we can use the normal version now. * sysdeps/unix/sysv/linux/arm/pread64.c: Likewise. * sysdeps/unix/sysv/linux/arm/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/mips/pread64.c: Likewise. * sysdeps/unix/sysv/linux/mips/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/pwrite64.c (__libc_pwrite64): Check endianness to check how to pass argument. * sysdeps/unix/sysv/linux/pread64.c (__libc_pread64): Likewise. ============================================================ Index: sysdeps/unix/sysv/linux/pread64.c --- sysdeps/unix/sysv/linux/pread64.c 2000/03/16 07:05:20 1.7 +++ sysdeps/unix/sysv/linux/pread64.c 2000/05/26 15:06:41 @@ -18,6 +18,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include @@ -46,8 +47,16 @@ ssize_t result; /* First try the syscall. */ - result = INLINE_SYSCALL (pread, 5, fd, buf, count, (off_t) (offset >> 32), +# if __BYTE_ORDER == __LITTLE_ENDIAN + result = INLINE_SYSCALL (pread, 5, fd, buf, count, + (off_t) (offset >> 32), (off_t) (offset & 0xffffffff)); +# elif __BYTE_ORDER == __BIG_ENDIAN + result = INLINE_SYSCALL (pread, 5, fd, buf, count, + (off_t) (offset & 0xffffffff), + (off_t) (offset >> 32)); +# endif + # if __ASSUME_PREAD_SYSCALL == 0 if (result == -1 && errno == ENOSYS) /* No system call available. Use the emulation. */ ============================================================ Index: sysdeps/unix/sysv/linux/pwrite64.c --- sysdeps/unix/sysv/linux/pwrite64.c 2000/03/16 07:05:42 1.7 +++ sysdeps/unix/sysv/linux/pwrite64.c 2000/05/26 15:06:41 @@ -18,6 +18,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include @@ -46,8 +47,15 @@ ssize_t result; /* First try the syscall. */ - result = INLINE_SYSCALL (pwrite, 5, fd, buf, count, (off_t) (offset >> 32), +# if __BYTE_ORDER == __LITTLE_ENDIAN + result = INLINE_SYSCALL (pwrite, 5, fd, buf, count, + (off_t) (offset & 0xffffffff), + (off_t) (offset >> 32)); +# elif __BYTE_ORDER == __BIG_ENDIAN + result = INLINE_SYSCALL (pwrite, 5, fd, buf, count, + (off_t) (offset >> 32), (off_t) (offset & 0xffffffff)); +# endif # if __ASSUME_PWRITE_SYSCALL == 0 if (result == -1 && errno == ENOSYS) /* No system call available. Use the emulation. */ ============================================================ Index: sysdeps/unix/sysv/linux/mips/pread64.c --- sysdeps/unix/sysv/linux/mips/pread64.c Thu Mar 16 09:24:35 2000 1.1 +++ sysdeps/unix/sysv/linux/mips/pread64.c removed @@ -1,75 +0,0 @@ -/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#include - -#if defined __NR_pread || __ASSUME_PREAD_SYSCALL > 0 - -# if __ASSUME_PREAD_SYSCALL == 0 -static ssize_t __emulate_pread64 (int fd, void *buf, size_t count, - off64_t offset) internal_function; -# endif - -extern ssize_t __syscall_pread (int fd, void *buf, size_t count, int dummy, - off_t offset_hi, off_t offset_lo); - - - -ssize_t -__libc_pread64 (fd, buf, count, offset) - int fd; - void *buf; - size_t count; - off64_t offset; -{ - ssize_t result; - - /* First try the syscall. */ -# if defined(__MIPSEB__) - result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, (off_t) (offset >> 32), - (off_t) (offset & 0xffffffff)); -# elif defined(__MIPSEL__) - result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, - (off_t) (offset & 0xffffffff), - (off_t) (offset >> 32)); -# endif -# if __ASSUME_PREAD_SYSCALL == 0 - if (result == -1 && errno == ENOSYS) - /* No system call available. Use the emulation. */ - result = __emulate_pread64 (fd, buf, count, offset); -# endif - return result; -} - -weak_alias (__libc_pread64, __pread64) -weak_alias (__libc_pread64, pread64) - -# define __libc_pread64(fd, buf, count, offset) \ - static internal_function __emulate_pread64 (fd, buf, count, offset) -#endif - -#if __ASSUME_PREAD_SYSCALL == 0 -# include -#endif ============================================================ Index: sysdeps/unix/sysv/linux/mips/pwrite64.c --- sysdeps/unix/sysv/linux/mips/pwrite64.c Thu Mar 16 09:24:35 2000 1.1 +++ sysdeps/unix/sysv/linux/mips/pwrite64.c removed @@ -1,75 +0,0 @@ -/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ralf Baechle , 1998. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#include - -#if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0 - -extern ssize_t __syscall_pwrite (int fd, const void *buf, size_t count, - int dummy, off_t offset_hi, off_t offset_lo); - -# if __ASSUME_PWRITE_SYSCALL == 0 -static ssize_t __emulate_pwrite64 (int fd, const void *buf, size_t count, - off64_t offset) internal_function; -# endif - -ssize_t -__libc_pwrite64 (fd, buf, count, offset) - int fd; - const void *buf; - size_t count; - off64_t offset; -{ - ssize_t result; - - /* First try the syscall. */ -# if defined(__MIPSEB__) - result = INLINE_SYSCALL (pwrite, 6, fd, buf, count, 0, (off_t) (offset >> 32), - (off_t) (offset & 0xffffffff)); -# elif defined(__MIPSEL__) - result = INLINE_SYSCALL (pwrite, 6, fd, buf, count, 0, - (off_t) (offset & 0xffffffff), - (off_t) (offset >> 32)); -# endif - -# if __ASSUME_PWRITE_SYSCALL == 0 - if (result == -1 && errno == ENOSYS) - /* No system call available. Use the emulation. */ - result = __emulate_pwrite64 (fd, buf, count, offset); -# endif - - return result; -} - -weak_alias (__libc_pwrite64, __pwrite64) -weak_alias (__libc_pwrite64, pwrite64) - -# define __libc_pwrite64(fd, buf, count, offset) \ - static internal_function __emulate_pwrite64 (fd, buf, count, offset) -#endif - -#if __ASSUME_PWRITE_SYSCALL == 0 -# include -#endif ============================================================ Index: sysdeps/unix/sysv/linux/i386/pread64.c --- sysdeps/unix/sysv/linux/i386/pread64.c Fri May 26 17:06:28 2000 1.1 +++ sysdeps/unix/sysv/linux/i386/pread64.c removed @@ -1,67 +0,0 @@ -/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#include - -#if defined __NR_pread || __ASSUME_PREAD_SYSCALL > 0 - -# if __ASSUME_PREAD_SYSCALL == 0 -static ssize_t __emulate_pread64 (int fd, void *buf, size_t count, - off64_t offset) internal_function; -# endif - - -ssize_t -__libc_pread64 (fd, buf, count, offset) - int fd; - void *buf; - size_t count; - off64_t offset; -{ - ssize_t result; - - /* First try the syscall. */ - result = INLINE_SYSCALL (pread, 5, fd, buf, count, - (off_t) (offset & 0xffffffff), - (off_t) (offset >> 32)); -# if __ASSUME_PREAD_SYSCALL == 0 - if (result == -1 && errno == ENOSYS) - /* No system call available. Use the emulation. */ - result = __emulate_pread64 (fd, buf, count, offset); -# endif - - return result; -} - -weak_alias (__libc_pread64, __pread64) -weak_alias (__libc_pread64, pread64) - -# define __libc_pread64(fd, buf, count, offset) \ - static internal_function __emulate_pread64 (fd, buf, count, offset) -#endif - -#if __ASSUME_PREAD_SYSCALL == 0 -# include -#endif ============================================================ Index: sysdeps/unix/sysv/linux/i386/pwrite64.c --- sysdeps/unix/sysv/linux/i386/pwrite64.c Fri May 26 17:06:14 2000 1.1 +++ sysdeps/unix/sysv/linux/i386/pwrite64.c removed @@ -1,67 +0,0 @@ -/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#include - -#if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0 - -# if __ASSUME_PWRITE_SYSCALL == 0 -static ssize_t __emulate_pwrite64 (int fd, const void *buf, size_t count, - off64_t offset) internal_function; -# endif - - -ssize_t -__libc_pwrite64 (fd, buf, count, offset) - int fd; - const void *buf; - size_t count; - off64_t offset; -{ - ssize_t result; - - /* First try the syscall. */ - result = INLINE_SYSCALL (pwrite, 5, fd, buf, count, - (off_t) (offset & 0xffffffff), - (off_t) (offset >> 32)); -# if __ASSUME_PWRITE_SYSCALL == 0 - if (result == -1 && errno == ENOSYS) - /* No system call available. Use the emulation. */ - result = __emulate_pwrite64 (fd, buf, count, offset); -# endif - - return result; -} - -weak_alias (__libc_pwrite64, __pwrite64) -weak_alias (__libc_pwrite64, pwrite64) - -# define __libc_pwrite64(fd, buf, count, offset) \ - static internal_function __emulate_pwrite64 (fd, buf, count, offset) -#endif - -#if __ASSUME_PWRITE_SYSCALL == 0 -# include -#endif ============================================================ Index: sysdeps/unix/sysv/linux/arm/pread64.c --- sysdeps/unix/sysv/linux/arm/pread64.c Mon Jan 4 10:31:32 1999 1.1 +++ sysdeps/unix/sysv/linux/arm/pread64.c removed @@ -1 +0,0 @@ -#include ============================================================ Index: sysdeps/unix/sysv/linux/arm/pwrite64.c --- sysdeps/unix/sysv/linux/arm/pwrite64.c Mon Jan 4 10:31:41 1999 1.1 +++ sysdeps/unix/sysv/linux/arm/pwrite64.c removed @@ -1 +0,0 @@ -#include -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From aj@suse.de Fri May 26 08:11:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 May 2000 08:11:00 -0000 Subject: LFS/syscalls -> Kernel interface incompatibility References: <20000525173329.A16025@suse.de> <20000526115656.A30220@suse.de> Message-ID: >>>>> Ulrich Drepper writes: Uli> Andreas Jaeger writes: >> So, what's the policy? Big or little? - and I would even like to use: Uli> Leave pread alone and make the truncate change similar to the pread change. Sorry, I've been to fast ;-). Please have a look at my patch and tell me then what you don't like. Have also a look at the MIPS version - we do this already since mips can be either endianness. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From aj@suse.de Fri May 26 08:20:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 May 2000 08:20:00 -0000 Subject: pread64/pwrite64 cleanup Message-ID: <200005261520.RAA01714@maclaurin.suse.de> Here's a patch to unify the different pread64/pwrite64 versions. There're other functions that could use the same treatment. Andreas 2000-05-26 Andreas Jaeger * sysdeps/unix/sysv/linux/i386/pread64.c: Removed, we can use the normal version now. * sysdeps/unix/sysv/linux/arm/pread64.c: Likewise. * sysdeps/unix/sysv/linux/arm/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/mips/pread64.c: Likewise. * sysdeps/unix/sysv/linux/mips/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/pwrite64.c (__libc_pwrite64): Check endianness to check how to pass argument. * sysdeps/unix/sysv/linux/pread64.c (__libc_pread64): Likewise. ============================================================ Index: sysdeps/unix/sysv/linux/pread64.c --- sysdeps/unix/sysv/linux/pread64.c 2000/03/16 07:05:20 1.7 +++ sysdeps/unix/sysv/linux/pread64.c 2000/05/26 15:06:41 @@ -18,6 +18,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include @@ -46,8 +47,16 @@ ssize_t result; /* First try the syscall. */ - result = INLINE_SYSCALL (pread, 5, fd, buf, count, (off_t) (offset >> 32), +# if __BYTE_ORDER == __LITTLE_ENDIAN + result = INLINE_SYSCALL (pread, 5, fd, buf, count, + (off_t) (offset >> 32), (off_t) (offset & 0xffffffff)); +# elif __BYTE_ORDER == __BIG_ENDIAN + result = INLINE_SYSCALL (pread, 5, fd, buf, count, + (off_t) (offset & 0xffffffff), + (off_t) (offset >> 32)); +# endif + # if __ASSUME_PREAD_SYSCALL == 0 if (result == -1 && errno == ENOSYS) /* No system call available. Use the emulation. */ ============================================================ Index: sysdeps/unix/sysv/linux/pwrite64.c --- sysdeps/unix/sysv/linux/pwrite64.c 2000/03/16 07:05:42 1.7 +++ sysdeps/unix/sysv/linux/pwrite64.c 2000/05/26 15:06:41 @@ -18,6 +18,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include @@ -46,8 +47,15 @@ ssize_t result; /* First try the syscall. */ - result = INLINE_SYSCALL (pwrite, 5, fd, buf, count, (off_t) (offset >> 32), +# if __BYTE_ORDER == __LITTLE_ENDIAN + result = INLINE_SYSCALL (pwrite, 5, fd, buf, count, + (off_t) (offset & 0xffffffff), + (off_t) (offset >> 32)); +# elif __BYTE_ORDER == __BIG_ENDIAN + result = INLINE_SYSCALL (pwrite, 5, fd, buf, count, + (off_t) (offset >> 32), (off_t) (offset & 0xffffffff)); +# endif # if __ASSUME_PWRITE_SYSCALL == 0 if (result == -1 && errno == ENOSYS) /* No system call available. Use the emulation. */ ============================================================ Index: sysdeps/unix/sysv/linux/mips/pread64.c --- sysdeps/unix/sysv/linux/mips/pread64.c Thu Mar 16 09:24:35 2000 1.1 +++ sysdeps/unix/sysv/linux/mips/pread64.c removed @@ -1,75 +0,0 @@ -/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#include - -#if defined __NR_pread || __ASSUME_PREAD_SYSCALL > 0 - -# if __ASSUME_PREAD_SYSCALL == 0 -static ssize_t __emulate_pread64 (int fd, void *buf, size_t count, - off64_t offset) internal_function; -# endif - -extern ssize_t __syscall_pread (int fd, void *buf, size_t count, int dummy, - off_t offset_hi, off_t offset_lo); - - - -ssize_t -__libc_pread64 (fd, buf, count, offset) - int fd; - void *buf; - size_t count; - off64_t offset; -{ - ssize_t result; - - /* First try the syscall. */ -# if defined(__MIPSEB__) - result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, (off_t) (offset >> 32), - (off_t) (offset & 0xffffffff)); -# elif defined(__MIPSEL__) - result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, - (off_t) (offset & 0xffffffff), - (off_t) (offset >> 32)); -# endif -# if __ASSUME_PREAD_SYSCALL == 0 - if (result == -1 && errno == ENOSYS) - /* No system call available. Use the emulation. */ - result = __emulate_pread64 (fd, buf, count, offset); -# endif - return result; -} - -weak_alias (__libc_pread64, __pread64) -weak_alias (__libc_pread64, pread64) - -# define __libc_pread64(fd, buf, count, offset) \ - static internal_function __emulate_pread64 (fd, buf, count, offset) -#endif - -#if __ASSUME_PREAD_SYSCALL == 0 -# include -#endif ============================================================ Index: sysdeps/unix/sysv/linux/mips/pwrite64.c --- sysdeps/unix/sysv/linux/mips/pwrite64.c Thu Mar 16 09:24:35 2000 1.1 +++ sysdeps/unix/sysv/linux/mips/pwrite64.c removed @@ -1,75 +0,0 @@ -/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ralf Baechle , 1998. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#include - -#if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0 - -extern ssize_t __syscall_pwrite (int fd, const void *buf, size_t count, - int dummy, off_t offset_hi, off_t offset_lo); - -# if __ASSUME_PWRITE_SYSCALL == 0 -static ssize_t __emulate_pwrite64 (int fd, const void *buf, size_t count, - off64_t offset) internal_function; -# endif - -ssize_t -__libc_pwrite64 (fd, buf, count, offset) - int fd; - const void *buf; - size_t count; - off64_t offset; -{ - ssize_t result; - - /* First try the syscall. */ -# if defined(__MIPSEB__) - result = INLINE_SYSCALL (pwrite, 6, fd, buf, count, 0, (off_t) (offset >> 32), - (off_t) (offset & 0xffffffff)); -# elif defined(__MIPSEL__) - result = INLINE_SYSCALL (pwrite, 6, fd, buf, count, 0, - (off_t) (offset & 0xffffffff), - (off_t) (offset >> 32)); -# endif - -# if __ASSUME_PWRITE_SYSCALL == 0 - if (result == -1 && errno == ENOSYS) - /* No system call available. Use the emulation. */ - result = __emulate_pwrite64 (fd, buf, count, offset); -# endif - - return result; -} - -weak_alias (__libc_pwrite64, __pwrite64) -weak_alias (__libc_pwrite64, pwrite64) - -# define __libc_pwrite64(fd, buf, count, offset) \ - static internal_function __emulate_pwrite64 (fd, buf, count, offset) -#endif - -#if __ASSUME_PWRITE_SYSCALL == 0 -# include -#endif ============================================================ Index: sysdeps/unix/sysv/linux/i386/pread64.c --- sysdeps/unix/sysv/linux/i386/pread64.c Fri May 26 17:06:28 2000 1.1 +++ sysdeps/unix/sysv/linux/i386/pread64.c removed @@ -1,67 +0,0 @@ -/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#include - -#if defined __NR_pread || __ASSUME_PREAD_SYSCALL > 0 - -# if __ASSUME_PREAD_SYSCALL == 0 -static ssize_t __emulate_pread64 (int fd, void *buf, size_t count, - off64_t offset) internal_function; -# endif - - -ssize_t -__libc_pread64 (fd, buf, count, offset) - int fd; - void *buf; - size_t count; - off64_t offset; -{ - ssize_t result; - - /* First try the syscall. */ - result = INLINE_SYSCALL (pread, 5, fd, buf, count, - (off_t) (offset & 0xffffffff), - (off_t) (offset >> 32)); -# if __ASSUME_PREAD_SYSCALL == 0 - if (result == -1 && errno == ENOSYS) - /* No system call available. Use the emulation. */ - result = __emulate_pread64 (fd, buf, count, offset); -# endif - - return result; -} - -weak_alias (__libc_pread64, __pread64) -weak_alias (__libc_pread64, pread64) - -# define __libc_pread64(fd, buf, count, offset) \ - static internal_function __emulate_pread64 (fd, buf, count, offset) -#endif - -#if __ASSUME_PREAD_SYSCALL == 0 -# include -#endif ============================================================ Index: sysdeps/unix/sysv/linux/i386/pwrite64.c --- sysdeps/unix/sysv/linux/i386/pwrite64.c Fri May 26 17:06:14 2000 1.1 +++ sysdeps/unix/sysv/linux/i386/pwrite64.c removed @@ -1,67 +0,0 @@ -/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include - -#include -#include - -#include - -#if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0 - -# if __ASSUME_PWRITE_SYSCALL == 0 -static ssize_t __emulate_pwrite64 (int fd, const void *buf, size_t count, - off64_t offset) internal_function; -# endif - - -ssize_t -__libc_pwrite64 (fd, buf, count, offset) - int fd; - const void *buf; - size_t count; - off64_t offset; -{ - ssize_t result; - - /* First try the syscall. */ - result = INLINE_SYSCALL (pwrite, 5, fd, buf, count, - (off_t) (offset & 0xffffffff), - (off_t) (offset >> 32)); -# if __ASSUME_PWRITE_SYSCALL == 0 - if (result == -1 && errno == ENOSYS) - /* No system call available. Use the emulation. */ - result = __emulate_pwrite64 (fd, buf, count, offset); -# endif - - return result; -} - -weak_alias (__libc_pwrite64, __pwrite64) -weak_alias (__libc_pwrite64, pwrite64) - -# define __libc_pwrite64(fd, buf, count, offset) \ - static internal_function __emulate_pwrite64 (fd, buf, count, offset) -#endif - -#if __ASSUME_PWRITE_SYSCALL == 0 -# include -#endif ============================================================ Index: sysdeps/unix/sysv/linux/arm/pread64.c --- sysdeps/unix/sysv/linux/arm/pread64.c Mon Jan 4 10:31:32 1999 1.1 +++ sysdeps/unix/sysv/linux/arm/pread64.c removed @@ -1 +0,0 @@ -#include ============================================================ Index: sysdeps/unix/sysv/linux/arm/pwrite64.c --- sysdeps/unix/sysv/linux/arm/pwrite64.c Mon Jan 4 10:31:41 1999 1.1 +++ sysdeps/unix/sysv/linux/arm/pwrite64.c removed @@ -1 +0,0 @@ -#include -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From drepper@redhat.com Fri May 26 08:42:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 26 May 2000 08:42:00 -0000 Subject: pread64/pwrite64 cleanup References: <200005261507.RAA00663@maclaurin.suse.de> Message-ID: Andreas Jaeger writes: > Uli, is it ok to commit this? Seems OK. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Fri May 26 09:07:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Fri, 26 May 2000 09:07:00 -0000 Subject: Fix for ftruncate64/truncate64 Message-ID: <200005261606.SAA08214@maclaurin.suse.de> Here's a patch for the endianness issues in (f)truncate64.c. May I commit this? Andreas 2000-05-26 Andreas Jaeger * sysdeps/unix/sysv/linux/ftruncate64.c (ftruncate64): Make order of arguments dependend on endianness. * sysdeps/unix/sysv/linux/truncate64.c: Likewise. ============================================================ Index: sysdeps/unix/sysv/linux/ftruncate64.c --- sysdeps/unix/sysv/linux/ftruncate64.c 2000/01/17 04:04:21 1.6 +++ sysdeps/unix/sysv/linux/ftruncate64.c 2000/05/26 16:01:29 @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -31,14 +32,13 @@ extern int __have_no_truncate64; #endif +/* The order of hight, low depends on endianness. */ extern int __syscall_ftruncate64 (int fd, int high_length, int low_length); /* Truncate the file FD refers to to LENGTH bytes. */ int -ftruncate64 (fd, length) - int fd; - off64_t length; +ftruncate64 (int fd, off64_t length) { #ifndef __ASSUME_TRUNCATE64_SYSCALL if (! __have_no_truncate64) @@ -49,8 +49,11 @@ #ifndef __ASSUME_TRUNCATE64_SYSCALL int saved_errno = errno; #endif +#if __BYTE_ORDER == __LITTLE_ENDIAN int result = INLINE_SYSCALL (ftruncate64, 3, fd, low, high); - +#elif __BYTE_ORDER == __BIG_ENDIAN + int result = INLINE_SYSCALL (ftruncate64, 3, fd, high, low); +#endif #ifndef __ASSUME_TRUNCATE64_SYSCALL if (result != -1 || errno != ENOSYS) #endif ============================================================ Index: sysdeps/unix/sysv/linux/truncate64.c --- sysdeps/unix/sysv/linux/truncate64.c 2000/01/18 04:25:51 1.7 +++ sysdeps/unix/sysv/linux/truncate64.c 2000/05/26 16:01:29 @@ -17,6 +17,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include @@ -31,14 +32,13 @@ int __have_no_truncate64; #endif +/* The order of hight, low depends on endianness. */ extern int __syscall_truncate64 (const char *path, int high_length, int low_length); /* Truncate the file FD refers to to LENGTH bytes. */ int -truncate64 (path, length) - const char *path; - off64_t length; +truncate64 (const char *path, off64_t length) { #ifndef __ASSUME_TRUNCATE64_SYSCALL if (! __have_no_truncate64) @@ -49,7 +49,11 @@ #ifndef __ASSUME_TRUNCATE64_SYSCALL int saved_errno = errno; #endif +#if __BYTE_ORDER == __LITTLE_ENDIAN int result = INLINE_SYSCALL (truncate64, 3, path, low, high); +#elif __BYTE_ORDER == __BIG_ENDIAN + int result = INLINE_SYSCALL (truncate64, 3, path, high, low); +#endif #ifndef __ASSUME_TRUNCATE64_SYSCALL if (result != -1 || errno != ENOSYS) -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From drepper@redhat.com Fri May 26 09:16:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 26 May 2000 09:16:00 -0000 Subject: Fix for ftruncate64/truncate64 References: <200005261606.SAA08214@maclaurin.suse.de> Message-ID: Andreas Jaeger writes: > Here's a patch for the endianness issues in (f)truncate64.c. > > May I commit this? OK. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Sat May 27 08:54:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Sat, 27 May 2000 08:54:00 -0000 Subject: vismain patch Message-ID: <200005271554.RAA19179@maclaurin.suse.de> Since some people (including myself) have problems with an endless loop in vismain, I've made the appended patch to use the test-skeleton interface. This way the test is killed after some time. Uli, is it ok to commit the patch? Andreas 2000-05-27 Andreas Jaeger * elf/vismain.c: Use test-skeleton interface. (TEST_FUNCTION): New macro. (do_test): Renamed from main. ============================================================ Index: elf/vismain.c --- elf/vismain.c 2000/05/23 18:12:07 1.1 +++ elf/vismain.c 2000/05/27 15:53:43 @@ -20,6 +20,14 @@ #include #include +/* Prototype for our test function. */ +extern int do_test (void); + +#define TEST_FUNCTION do_test () + +/* This defines the `main' function and some more. */ +#include + /* Prototypes for the functions in the DSOs. */ extern int calllocal1 (void); extern int (*getlocal1 (void)) (void); @@ -54,7 +62,7 @@ extern const char *protvaritcpt; int -main (void) +do_test (void) { int res = 0; int val; -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From drepper@redhat.com Sat May 27 09:46:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 27 May 2000 09:46:00 -0000 Subject: vismain patch References: <200005271554.RAA19179@maclaurin.suse.de> Message-ID: Andreas Jaeger writes: > Uli, is it ok to commit the patch? OK. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Sun May 28 01:57:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Sun, 28 May 2000 01:57:00 -0000 Subject: Use LD_SO in gnu/libnames.h Message-ID: Currently we use different names for the dynamic linker in . On same platforms we have: #define LD_LINUX_SO "ld-linux.so.2" on others: #define LD_SO "ld.so.1" and ia64 is also different :-( I'm appending a patch by Andreas Schwab to always use LD_SO. If we use this patch, we also have to change elf/readlib.c to use LD_SO. Currently readlib.c uses LD_LINUX_SO and this way compilation of glibc fails on e.g. powerpc and ia64. Using LD_SO we're incompatible to former versions - but it's IMO an advantage since now all platforms use the same name for the dynamic linker. May I commit the patch to glibc 2.2? Andreas 2000-05-26 Andreas Schwab * Makeconfig ($(common-objpfx)soversions.mk): Prepend `$lib=' to entries in all-sonames. ($(common-objpfx)gnu/lib-names.h): Use it for the CPP symbol. Index: Makeconfig =================================================================== RCS file: /cvs/glibc/libc/Makeconfig,v retrieving revision 1.236 diff -u -a -u -r1.236 Makeconfig --- Makeconfig 2000/04/28 05:07:08 1.236 +++ Makeconfig 2000/05/26 12:26:43 @@ -709,9 +709,9 @@ while read lib number setname; do \ case $$number in \ [0-9]*) echo "$$lib.so-version=.$$number"; \ - echo "all-sonames+=$$lib.so\$$($$lib.so-version)";;\ + echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\ *) echo "$$lib.so-version=$$number"; \ - echo "all-sonames+=\$$($$lib.so-version)";;\ + echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\ esac; \ done < $< > $@T; exit 0 mv -f $@T $@ @@ -735,10 +735,11 @@ echo; \ (libs='$(all-sonames)';\ for l in $$libs; do \ - upname=`echo $$l | sed 's/[.]so.*//' | \ + name=`echo $$l | sed 's/.*=//'`; \ + upname=`echo $$l | sed 's/=.*//' | \ tr 'abcdefghijklmnopqrstuvwxyz-' \ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`; \ - echo "#define $${upname}_SO \"$$l\""; \ + echo "#define $${upname}_SO \"$$name\""; \ done;) | sort; \ echo; \ echo '#endif /* gnu/lib-names.h */';) > ${@:stmp=T} -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From drepper@redhat.com Sun May 28 08:36:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 28 May 2000 08:36:00 -0000 Subject: Use LD_SO in gnu/libnames.h References: Message-ID: Andreas Jaeger writes: > Using LD_SO we're incompatible to former versions - but it's IMO an > advantage since now all platforms use the same name for the dynamic > linker. Leave the old name in there as well if it is different from LD_SO. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Sun May 28 11:18:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 28 May 2000 11:18:00 -0000 Subject: [PATCH] libio fixes for glibc 2.1.90 References: <20000521144037.Y474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > The following patch makes groff and a bunch of other programs work with > glibc 2.1.90. > The issue is that libstdc++'s libio declares its own stdin/stdout/stderr > which lacks the _wide_data stuff and several pieces of glibc just trustfully > dereference _wide_data member of _IO_FILE. > IMHO even if libstdc++'s libio is changed so that for *-libc6.2-* libstdc++ > (or always) puts the _wide_data stuff in, we need to maintain backward > compatibility with older libstdc++'s. Backward compatibility, yes. But your patch is adding code to the wide char functions. This is not necessary since no program can/must use the wide character functions when the using an old libio. The changes must be reduced to the absolute minimum and not simply cover every place where a problem could be. Also, the changes should somehow be marked as only necessary if compatibility with 2.0/2.1 is required. For IA-64, for instance, it'll not be necessary. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Sun May 28 11:35:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Sun, 28 May 2000 11:35:00 -0000 Subject: [PATCH] libio fixes for glibc 2.1.90 References: <20000521144037.Y474@sunsite.ms.mff.cuni.cz> Message-ID: I've checked in a modified version of the patch: - the result of _IO_CHECK_WIDE is reversed. It returns zero if no wide char data is available. Seems more logical - none of the wide character functions is modified - I don't see why you want this: > Call _IO_WSETBUF even for _mode 1. It's also left out. If you think it is needed provide a rational. With these patches applied groff is running just fine. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From ralf@uni-koblenz.de Sun May 28 13:51:00 2000 From: ralf@uni-koblenz.de (Ralf Baechle) Date: Sun, 28 May 2000 13:51:00 -0000 Subject: pread64/pwrite64 cleanup References: <200005261507.RAA00663@maclaurin.suse.de> Message-ID: <20000528225126.A31375@uni-koblenz.de> On Fri, May 26, 2000 at 05:07:37PM +0200, Andreas Jaeger wrote: > Here's a patch to unify the different pread64/pwrite64 versions. > > There're other functions that could use the same treatment. > > Uli, is it ok to commit this? Please undo the MIPS part of the change. 32-bit MIPS passed the 64-bit offset not as the 5th but 6th argument. Praise the ABI ... Ralf From ralf@uni-koblenz.de Sun May 28 14:29:00 2000 From: ralf@uni-koblenz.de (Ralf Baechle) Date: Sun, 28 May 2000 14:29:00 -0000 Subject: Fix for ftruncate64/truncate64 References: <200005261606.SAA08214@maclaurin.suse.de> Message-ID: <20000528232704.B31375@uni-koblenz.de> On Fri, May 26, 2000 at 06:06:57PM +0200, Andreas Jaeger wrote: > Here's a patch for the endianness issues in (f)truncate64.c. We will also need special versions or MIPS here for the same reason as with pread / pwrite. Ralf From aj@suse.de Mon May 29 00:11:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 29 May 2000 00:11:00 -0000 Subject: pread64/pwrite64 cleanup References: <200005261507.RAA00663@maclaurin.suse.de> <20000528225126.A31375@uni-koblenz.de> Message-ID: >>>>> Ralf Baechle writes: Ralf> On Fri, May 26, 2000 at 05:07:37PM +0200, Andreas Jaeger wrote: >> Here's a patch to unify the different pread64/pwrite64 versions. >> >> There're other functions that could use the same treatment. >> >> Uli, is it ok to commit this? Ralf> Please undo the MIPS part of the change. 32-bit MIPS passed the 64-bit Ralf> offset not as the 5th but 6th argument. Praise the ABI ... Are you sure that it was correct before? We had (for pread.c): # if defined(__MIPSEB__) result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, 0, offset); # elif defined(__MIPSEL__) result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, offset, 0); # endif According to your comment this should be for both endianesses: result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, offset, 0) Is this correct? I'll make the changes for pread{64},pwrite{64},{f}truncate64 in the next days. Thanks for double checking! Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From aj@suse.de Mon May 29 00:26:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 29 May 2000 00:26:00 -0000 Subject: PowerPC glibc CVS problems + patch Message-ID: Hi, I get the following warnings and errors when compiling glibc 2.2 CVS on powerpc: ../sysdeps/powerpc/dl-start.S:68: warning: `/*' within comment In file included from dynamic-link.h:21, from dl-load.c:31: ../sysdeps/powerpc/dl-machine.h: In function `elf_machine_fixup_plt': ../sysdeps/powerpc/dl-machine.h:259: `map' undeclared (first use in this function) ../sysdeps/powerpc/dl-machine.h:259: (Each undeclared identifier is reported only once ../sysdeps/powerpc/dl-machine.h:259: for each function it appears in.) ../sysdeps/powerpc/dl-machine.h:259: `finaladdr' undeclared (first use in this function) make[2]: *** [/abuild/aj/build-glibc-2.2/elf/dl-load.o] Error 1 Is the appended patch ok? It still doesn't fix the finaladdr parameter, I don't know which value it should get. Thanks, Andreas 2000-05-29 Andreas Jaeger * sysdeps/powerpc/dl-machine.h (elf_machine_fixup_plt): Fix parameter for call. * sysdeps/powerpc/dl-start.S: Close open comment. ============================================================ Index: sysdeps/powerpc/dl-machine.h --- sysdeps/powerpc/dl-machine.h 2000/05/05 07:12:17 1.25 +++ sysdeps/powerpc/dl-machine.h 2000/05/29 07:24:43 @@ -256,7 +256,7 @@ const Elf32_Rela *reloc, Elf32_Addr *reloc_addr, Elf64_Addr value) { - __elf_machine_fixup_plt (map, reloc, reloc_addr, finaladdr); + __elf_machine_fixup_plt (l, reloc, reloc_addr, finaladdr); return value; } ============================================================ Index: sysdeps/powerpc/dl-start.S --- sysdeps/powerpc/dl-start.S 2000/05/04 23:12:19 1.4 +++ sysdeps/powerpc/dl-start.S 2000/05/29 07:24:43 @@ -56,7 +56,7 @@ lwz r29,_dl_argc@got(r31) lwz r27,_dl_argv@got(r31) -/* Call _dl_init (_dl_loaded, _dl_argc, _dl_argv, _dl_argv+_dl_argc+1) +/* Call _dl_init (_dl_loaded, _dl_argc, _dl_argv, _dl_argv+_dl_argc+1). */ lwz r3,0(r28) lwz r4,0(r29) lwz r5,0(r27) -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From schwab@suse.de Mon May 29 01:38:00 2000 From: schwab@suse.de (Andreas Schwab) Date: Mon, 29 May 2000 01:38:00 -0000 Subject: Use LD_SO in gnu/libnames.h References: Message-ID: <200005290838.KAA06609@hawking.suse.de> Ulrich Drepper writes: |> Andreas Jaeger writes: |> |> > Using LD_SO we're incompatible to former versions - but it's IMO an |> > advantage since now all platforms use the same name for the dynamic |> > linker. |> |> Leave the old name in there as well if it is different from LD_SO. IMHO the old names should never have been used since it is not portable. But anyway, here is a new patch: 2000-05-26 Andreas Schwab * Makeconfig ($(common-objpfx)soversions.mk): Prepend `$lib=' to entries in all-sonames. ($(common-objpfx)gnu/lib-names.h): Use it for the CPP symbol, preserving the old name if different for compatibility. Index: Makeconfig =================================================================== RCS file: /cvs/glibc/libc/Makeconfig,v retrieving revision 1.236 diff -u -a -u -r1.236 Makeconfig --- Makeconfig 2000/04/28 05:07:08 1.236 +++ Makeconfig 2000/05/29 08:34:25 @@ -709,9 +709,9 @@ while read lib number setname; do \ case $$number in \ [0-9]*) echo "$$lib.so-version=.$$number"; \ - echo "all-sonames+=$$lib.so\$$($$lib.so-version)";;\ + echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\ *) echo "$$lib.so-version=$$number"; \ - echo "all-sonames+=\$$($$lib.so-version)";;\ + echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\ esac; \ done < $< > $@T; exit 0 mv -f $@T $@ @@ -735,10 +735,17 @@ echo; \ (libs='$(all-sonames)';\ for l in $$libs; do \ - upname=`echo $$l | sed 's/[.]so.*//' | \ + name=`echo $$l | sed 's/.*=//'`; \ + upname=`echo $$l | sed 's/=.*//' | \ tr 'abcdefghijklmnopqrstuvwxyz-' \ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`; \ - echo "#define $${upname}_SO \"$$l\""; \ + upname2=`echo $$name | sed 's/[.]so.*//' | \ + tr 'abcdefghijklmnopqrstuvwxyz-' \ + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`; \ + echo "#define $${upname}_SO \"$$name\""; \ + if test $$upname != $$upname2; then \ + echo "#define $${upname2}_SO \"$$name\""; \ + fi; \ done;) | sort; \ echo; \ echo '#endif /* gnu/lib-names.h */';) > ${@:stmp=T} Andreas. -- Andreas Schwab "And now for something SuSE Labs completely different." Andreas.Schwab@suse.de SuSE GmbH, Schanz????ckerstr. 10, D-90443 N????rnberg From jakub@redhat.com Mon May 29 08:30:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 29 May 2000 08:30:00 -0000 Subject: [PATCH] rcmd bug fix Message-ID: <20000529173758.T474@sunsite.ms.mff.cuni.cz> Hi! This patch fixes rsh with glibc 2.1.90, otherwise I get rcmd: socket: All ports in use (obviously, because i is initialized with random garbage as seen by strace). 2000-05-29 Jakub Jelinek * inet/rcmd.c (rresvport_af): Use correct port number. --- libc/inet/rcmd.c.jj Mon May 8 14:30:39 2000 +++ libc/inet/rcmd.c Mon May 29 16:59:49 2000 @@ -340,11 +340,9 @@ rresvport_af(alport, family) ss.__ss_family = family; for (;;) { - *sport = htons(i); - if (bind(s, (struct sockaddr *)&ss, len) >= 0){ - *alport = i; + *sport = htons((uint16_t) *alport); + if (bind(s, (struct sockaddr *)&ss, len) >= 0) return s; - } if (errno != EADDRINUSE) { (void)__close(s); return -1; Jakub From drepper@redhat.com Mon May 29 10:16:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 29 May 2000 10:16:00 -0000 Subject: Use LD_SO in gnu/libnames.h References: <200005290838.KAA06609@hawking.suse.de> Message-ID: Andreas Schwab writes: > IMHO the old names should never have been used since it is not portable. I agree. But do you want to break some code because of something as unimportant as this? > But anyway, here is a new patch: Thanks, it's applied. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Mon May 29 10:18:00 2000 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 29 May 2000 10:18:00 -0000 Subject: [PATCH] rcmd bug fix References: <20000529173758.T474@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > This patch fixes rsh with glibc 2.1.90, otherwise I get > rcmd: socket: All ports in use Thanks, I've applied the patch. -- ---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Mon May 29 10:20:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Mon, 29 May 2000 10:20:00 -0000 Subject: Use LD_SO in gnu/libnames.h References: <200005290838.KAA06609@hawking.suse.de> Message-ID: >>>>> Ulrich Drepper writes: Uli> Thanks, it's applied. Ok, then it's time to get readlib working again;-). I've committed the appended patch. Thanks, Andreas 2000-05-29 Andreas Jaeger * elf/readlib.c (interpreters): Use LD_SO since this is supported for all platforms. Index: elf/readlib.c =================================================================== RCS file: /cvs/glibc/libc/elf/readlib.c,v retrieving revision 1.4 diff -u -r1.4 readlib.c --- readlib.c 2000/05/26 10:22:54 1.4 +++ readlib.c 2000/05/29 17:19:11 @@ -50,7 +50,7 @@ static struct known_names interpreters [] = { - {"/lib/" LD_LINUX_SO, FLAG_ELF_LIBC6}, + {"/lib/" LD_SO, FLAG_ELF_LIBC6}, {"/lib/ld-linux.so.1", FLAG_ELF_LIBC5} }; -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.rhein-neckar.de From ralf@uni-koblenz.de Mon May 29 15:54:00 2000 From: ralf@uni-koblenz.de (Ralf Baechle) Date: Mon, 29 May 2000 15:54:00 -0000 Subject: pread64/pwrite64 cleanup References: <200005261507.RAA00663@maclaurin.suse.de> <20000528225126.A31375@uni-koblenz.de> Message-ID: <20000530005424.D3330@uni-koblenz.de> On Mon, May 29, 2000 at 09:11:24AM +0200, Andreas Jaeger wrote: > Ralf> Please undo the MIPS part of the change. 32-bit MIPS passed the 64-bit > Ralf> offset not as the 5th but 6th argument. Praise the ABI ... > > Are you sure that it was correct before? We had (for pread.c): > > # if defined(__MIPSEB__) > result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, 0, offset); > # elif defined(__MIPSEL__) > result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, offset, 0); > # endif This is correct. > According to your comment this should be for both endianesses: > result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, offset, 0) No, this must be an missunderstanding. Basically the problem is that a 64-bit argument has to be split into two 32-bit arguments for the 32-bit ABI. Such a pair of arguments has to be passed in an aligned pair of arguments, that is argumnts 0/1, 2/3, 4/5 etc. but not 1/2 etc. If necessary fill arguments have to be used. Ralf From jakub@redhat.com Tue May 30 02:04:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 30 May 2000 02:04:00 -0000 Subject: [PATCH] fix resolving hostnames containing dots Message-ID: <20000530111212.J474@sunsite.ms.mff.cuni.cz> Hi! If I have in my resolv.conf search redhat.com and no explicit ndots line, then ping devserv.devel does not work with glibc 2.1.90 (but it does with glibc 2.1.3 and works the same way on Solaris as well). The reason is that res_nsearch tries to resolve the name only as is and if that fails, simply returns error. I've tried to restore the behaviour of glibc 2.1 in this patch, plus have killed root_on_list variable which is just computed and never used. Or was the change done on purpose to match some standard? The glibc 2.1 behaviour makes much more sense to me... 2000-05-30 Jakub Jelinek * resolv/res_query.c (res_nsearch): Remove unused variable root_on_list. If dots >= statp->ndots and as is querydomain fails, keep searching. --- libc/resolv/res_query.c.jj Tue Jan 4 17:11:53 2000 +++ libc/resolv/res_query.c Tue May 30 10:30:13 2000 @@ -184,8 +184,8 @@ res_nsearch(res_state statp, HEADER *hp = (HEADER *) answer; char tmp[NS_MAXDNAME]; u_int dots; - int trailing_dot, ret; - int got_nodata = 0, got_servfail = 0, root_on_list = 0; + int trailing_dot, ret, saved_herrno; + int got_nodata = 0, got_servfail = 0, tried_as_is = 0; __set_errno (0); RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); /* True if we never query. */ @@ -205,9 +205,15 @@ res_nsearch(res_state statp, * If there are enough dots in the name, do no searching. * (The threshold can be set with the "ndots" option.) */ - if (dots >= statp->ndots || trailing_dot) - return (res_nquerydomain(statp, name, NULL, class, type, - answer, anslen)); + saved_herrno = -1; + if (dots >= statp->ndots) { + ret = res_nquerydomain(statp, name, NULL, class, type, + answer, anslen); + if (ret > 0) + return ret; + saved_herrno = h_errno; + tried_as_is++; + } /* * We do at least one level of search if @@ -223,10 +229,6 @@ res_nsearch(res_state statp, *domain && !done; domain++) { - if (domain[0][0] == '\0' || - (domain[0][0] == '.' && domain[0][1] == '\0')) - root_on_list++; - ret = res_nquerydomain(statp, name, *domain, class, type, answer, anslen); @@ -278,11 +280,11 @@ res_nsearch(res_state statp, } } - /* - * If the name has any dots at all, and "." is not on the search - * list, then try an as-is query now. + /* If we have not already tried the name "as is", do that now. + * note that we do this regardless of how many dots were in the + * name or whether it ends with a dot. */ - if (statp->ndots) { + if (!tried_as_is) { ret = res_nquerydomain(statp, name, NULL, class, type, answer, anslen); if (ret > 0) @@ -296,6 +298,8 @@ res_nsearch(res_state statp, * else send back meaningless H_ERRNO, that being the one from * the last DNSRCH we did. */ + if (saved_herrno != -1) + RES_SET_H_ERRNO(statp, saved_herrno); if (got_nodata) RES_SET_H_ERRNO(statp, NO_DATA); else if (got_servfail) Jakub From aj@suse.de Wed May 31 01:05:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 31 May 2000 01:05:00 -0000 Subject: pread64/pwrite64 cleanup References: <200005261507.RAA00663@maclaurin.suse.de> <20000528225126.A31375@uni-koblenz.de> <20000530005424.D3330@uni-koblenz.de> Message-ID: >>>>> Ralf Baechle writes: Ralf> No, this must be an missunderstanding. Basically the problem is that a Ralf> 64-bit argument has to be split into two 32-bit arguments for the Ralf> 32-bit ABI. Such a pair of arguments has to be passed in an aligned Ralf> pair of arguments, that is argumnts 0/1, 2/3, 4/5 etc. but not 1/2 etc. Ralf> If necessary fill arguments have to be used. Thanks for the explanation. I've added the files now. Andreas 2000-05-30 Andreas Jaeger * sysdeps/unix/sysv/linux/mips/truncate64.c: New file. * sysdeps/unix/sysv/linux/mips/ftruncate64.c: New file. * sysdeps/unix/sysv/linux/mips/pread64.c: Readded file. * sysdeps/unix/sysv/linux/mips/pwrite64.c: Readded file. * sysdeps/unix/sysv/linux/mips/pread.c: Readded file. * sysdeps/unix/sysv/linux/mips/pwrite.c: Readded file. ============================================================ Index: sysdeps/unix/sysv/linux/mips/truncate64.c --- sysdeps/unix/sysv/linux/mips/truncate64.c created +++ sysdeps/unix/sysv/linux/mips/truncate64.c Tue May 30 14:50:17 2000 1.1 @@ -0,0 +1,84 @@ +/* Copyright (C) 1997, 1998, 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. 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 "kernel-features.h" + +#ifdef __NR_truncate64 +#ifndef __ASSUME_TRUNCATE64_SYSCALL +/* The variable is shared between all wrappers around *truncate64 calls. */ +int __have_no_truncate64; +#endif + +/* The order of hight, low depends on endianness. */ +extern int __syscall_truncate64 (const char *path, int high_length, int low_length); + + +/* Truncate the file FD refers to to LENGTH bytes. */ +int +truncate64 (const char *path, off64_t length) +{ +#ifndef __ASSUME_TRUNCATE64_SYSCALL + if (! __have_no_truncate64) +#endif + { + unsigned int low = length & 0xffffffff; + unsigned int high = length >> 32; +#ifndef __ASSUME_TRUNCATE64_SYSCALL + int saved_errno = errno; +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN + /* Use a fill argument to pass low, high in an aligned pair of + arguments (here 2/3). */ + int result = INLINE_SYSCALL (truncate64, 3, path, 0, low, high); +#elif __BYTE_ORDER == __BIG_ENDIAN + int result = INLINE_SYSCALL (truncate64, 3, path, 0, high, low); +#endif + +#ifndef __ASSUME_TRUNCATE64_SYSCALL + if (result != -1 || errno != ENOSYS) +#endif + return result; + +#ifndef __ASSUME_TRUNCATE64_SYSCALL + __set_errno (saved_errno); + __have_no_truncate64 = 1; +#endif + } + +#ifndef __ASSUME_TRUNCATE64_SYSCALL + if ((off_t) length != length) + { + __set_errno (EINVAL); + return -1; + } + return truncate (path, (off_t) length); +#endif +} + +#else +/* Use the generic implementation. */ +# include +#endif ============================================================ Index: sysdeps/unix/sysv/linux/mips/ftruncate64.c --- sysdeps/unix/sysv/linux/mips/ftruncate64.c created +++ sysdeps/unix/sysv/linux/mips/ftruncate64.c Tue May 30 14:50:17 2000 1.1 @@ -0,0 +1,83 @@ +/* Copyright (C) 1997, 1998, 1999, 2000 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. 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 "kernel-features.h" + +#ifdef __NR_ftruncate64 +#ifndef __ASSUME_TRUNCATE64_SYSCALL +/* The variable is shared between all wrappers around *truncate64 calls. */ +extern int __have_no_truncate64; +#endif + +/* The order of hight, low depends on endianness. */ +extern int __syscall_ftruncate64 (int fd, int high_length, int low_length); + + +/* Truncate the file FD refers to to LENGTH bytes. */ +int +ftruncate64 (int fd, off64_t length) +{ +#ifndef __ASSUME_TRUNCATE64_SYSCALL + if (! __have_no_truncate64) +#endif + { + unsigned int low = length & 0xffffffff; + unsigned int high = length >> 32; +#ifndef __ASSUME_TRUNCATE64_SYSCALL + int saved_errno = errno; +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN + /* Use a fill argument to pass low, high in an aligned pair of + arguments (here 2/3). */ + int result = INLINE_SYSCALL (ftruncate64, 3, fd, 0, low, high); +#elif __BYTE_ORDER == __BIG_ENDIAN + int result = INLINE_SYSCALL (ftruncate64, 3, fd, 0, high, low); +#endif +#ifndef __ASSUME_TRUNCATE64_SYSCALL + if (result != -1 || errno != ENOSYS) +#endif + return result; + +#ifndef __ASSUME_TRUNCATE64_SYSCALL + __set_errno (saved_errno); + __have_no_truncate64 = 1; +#endif + } + +#ifndef __ASSUME_TRUNCATE64_SYSCALL + if ((off_t) length != length) + { + __set_errno (EINVAL); + return -1; + } + return __ftruncate (fd, (off_t) length); +#endif +} + +#else +/* Use the generic implementation. */ +# include +#endif ============================================================ Index: sysdeps/unix/sysv/linux/mips/pread64.c --- sysdeps/unix/sysv/linux/mips/pread64.c created +++ sysdeps/unix/sysv/linux/mips/pread64.c Tue May 30 19:59:16 2000 1.1 @@ -0,0 +1,75 @@ +/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#include +#include + +#include + +#if defined __NR_pread || __ASSUME_PREAD_SYSCALL > 0 + +# if __ASSUME_PREAD_SYSCALL == 0 +static ssize_t __emulate_pread64 (int fd, void *buf, size_t count, + off64_t offset) internal_function; +# endif + +extern ssize_t __syscall_pread (int fd, void *buf, size_t count, int dummy, + off_t offset_hi, off_t offset_lo); + + + +ssize_t +__libc_pread64 (fd, buf, count, offset) + int fd; + void *buf; + size_t count; + off64_t offset; +{ + ssize_t result; + + /* First try the syscall. */ +# if defined(__MIPSEB__) + result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, (off_t) (offset >> 32), + (off_t) (offset & 0xffffffff)); +# elif defined(__MIPSEL__) + result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, + (off_t) (offset & 0xffffffff), + (off_t) (offset >> 32)); +# endif +# if __ASSUME_PREAD_SYSCALL == 0 + if (result == -1 && errno == ENOSYS) + /* No system call available. Use the emulation. */ + result = __emulate_pread64 (fd, buf, count, offset); +# endif + return result; +} + +weak_alias (__libc_pread64, __pread64) +weak_alias (__libc_pread64, pread64) + +# define __libc_pread64(fd, buf, count, offset) \ + static internal_function __emulate_pread64 (fd, buf, count, offset) +#endif + +#if __ASSUME_PREAD_SYSCALL == 0 +# include +#endif ============================================================ Index: sysdeps/unix/sysv/linux/mips/pwrite64.c --- sysdeps/unix/sysv/linux/mips/pwrite64.c created +++ sysdeps/unix/sysv/linux/mips/pwrite64.c Tue May 30 19:59:16 2000 1.1 @@ -0,0 +1,75 @@ +/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ralf Baechle , 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#include +#include + +#include + +#if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0 + +extern ssize_t __syscall_pwrite (int fd, const void *buf, size_t count, + int dummy, off_t offset_hi, off_t offset_lo); + +# if __ASSUME_PWRITE_SYSCALL == 0 +static ssize_t __emulate_pwrite64 (int fd, const void *buf, size_t count, + off64_t offset) internal_function; +# endif + +ssize_t +__libc_pwrite64 (fd, buf, count, offset) + int fd; + const void *buf; + size_t count; + off64_t offset; +{ + ssize_t result; + + /* First try the syscall. */ +# if defined(__MIPSEB__) + result = INLINE_SYSCALL (pwrite, 6, fd, buf, count, 0, (off_t) (offset >> 32), + (off_t) (offset & 0xffffffff)); +# elif defined(__MIPSEL__) + result = INLINE_SYSCALL (pwrite, 6, fd, buf, count, 0, + (off_t) (offset & 0xffffffff), + (off_t) (offset >> 32)); +# endif + +# if __ASSUME_PWRITE_SYSCALL == 0 + if (result == -1 && errno == ENOSYS) + /* No system call available. Use the emulation. */ + result = __emulate_pwrite64 (fd, buf, count, offset); +# endif + + return result; +} + +weak_alias (__libc_pwrite64, __pwrite64) +weak_alias (__libc_pwrite64, pwrite64) + +# define __libc_pwrite64(fd, buf, count, offset) \ + static internal_function __emulate_pwrite64 (fd, buf, count, offset) +#endif + +#if __ASSUME_PWRITE_SYSCALL == 0 +# include +#endif ============================================================ Index: sysdeps/unix/sysv/linux/mips/pread.c --- sysdeps/unix/sysv/linux/mips/pread.c created +++ sysdeps/unix/sysv/linux/mips/pread.c Tue May 30 19:59:16 2000 1.1 @@ -0,0 +1,71 @@ +/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#include +#include + +#include + +#if defined __NR_pread || __ASSUME_PREAD_SYSCALL > 0 + +# if __ASSUME_PREAD_SYSCALL == 0 +static ssize_t __emulate_pread (int fd, void *buf, size_t count, + off_t offset) internal_function; +# endif +extern ssize_t __syscall_pread (int fd, void *buf, size_t count, int dummy, + off_t offset_hi, off_t offset_lo); + + + +ssize_t +__libc_pread (fd, buf, count, offset) + int fd; + void *buf; + size_t count; + off_t offset; +{ + ssize_t result; + + /* First try the syscall. */ +# if defined(__MIPSEB__) + result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, 0, offset); +# elif defined(__MIPSEL__) + result = INLINE_SYSCALL (pread, 6, fd, buf, count, 0, offset, 0); +# endif +# if __ASSUME_PREAD_SYSCALL == 0 + if (result == -1 && errno == ENOSYS) + /* No system call available. Use the emulation. */ + result = __emulate_pread (fd, buf, count, offset); +# endif + return result; +} + +strong_alias (__libc_pread, __pread) +weak_alias (__libc_pread, pread) + +# define __libc_pread(fd, buf, count, offset) \ + static internal_function __emulate_pread (fd, buf, count, offset) +#endif + +#if __ASSUME_PREAD_SYSCALL == 0 +# include +#endif ============================================================ Index: sysdeps/unix/sysv/linux/mips/pwrite.c --- sysdeps/unix/sysv/linux/mips/pwrite.c created +++ sysdeps/unix/sysv/linux/mips/pwrite.c Tue May 30 19:59:16 2000 1.1 @@ -0,0 +1,71 @@ +/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#include +#include + +#include + +#if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0 + +extern ssize_t __syscall_pwrite (int fd, const void *buf, size_t count, + int dummy, off_t offset_hi, off_t offset_lo); + +# if __ASSUME_PWRITE_SYSCALL == 0 +static ssize_t __emulate_pwrite (int fd, const void *buf, size_t count, + off_t offset) internal_function; +# endif + +ssize_t +__libc_pwrite (fd, buf, count, offset) + int fd; + const void *buf; + size_t count; + off_t offset; +{ + ssize_t result; + + /* First try the syscall. */ +# if defined(__MIPSEB__) + result = INLINE_SYSCALL (pwrite, 6, fd, buf, count, 0, 0, offset); +# elif defined(__MIPSEL__) + result = INLINE_SYSCALL (pwrite, 6, fd, buf, count, 0, offset, 0); +# endif +# if __ASSUME_PWRITE_SYSCALL == 0 + if (result == -1 && errno == ENOSYS) + /* No system call available. Use the emulation. */ + result = __emulate_pwrite (fd, buf, count, offset); +# endif + + return result; +} + +strong_alias (__libc_pwrite, __pwrite) +weak_alias (__libc_pwrite, pwrite) + +# define __libc_pwrite(fd, buf, count, offset) \ + static internal_function __emulate_pwrite (fd, buf, count, offset) +#endif + +#if __ASSUME_PWRITE_SYSCALL == 0 +# include +#endif -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From aj@suse.de Wed May 31 01:06:00 2000 From: aj@suse.de (Andreas Jaeger) Date: Wed, 31 May 2000 01:06:00 -0000 Subject: Adding SH support to glibc-2.1.3 References: <200005251128.UAA14744@rr.iij4u.or.jp> Message-ID: >>>>> kaz Kojima writes: > Hi, > Here's a patch for glibc-2.1.3 to support new sh-linux-gnu target for > Linux on Hitachi SH processors. > We've already done the paper work for copyright assignment, and got back > the copy from FSF. > Patch consists of two parts. One is for changes of generic part, and > another is SH specific part. For the changes of generic part, there > are four diffs. First three diffs are trivial, just add sh[34] > support. We need the 4-th diff for csu/Makefile to get cststuff > routines directly. This is needed because we couldn't use generated > files. The constant (for label) is emitted far away than expected > by the generation, after the function epilogue. > Sorry for this long patch. Any comments are appreciated. > Thanks, Here're the promised comments: - Please send one patch with only sh-patches (sysdeps/sh etc). - Send the other patches separatly and describe why they're needed. You can start sending these patches in already, no need to wait until everything is finished. - As I've said already, please make the patches against 2.2. Please note that some internals in glibc have changed, you need to rewrite some of your patches. - you want to look at shlib-versions and add the neccessary lines to remove old compatibility code like it has been done for ia64. - In glibc 2.2 some new constants and interface have been added to e.g. mman.h. Please check all your header files with the current version in glibc (the i386 is probably the best version to synch with). > 2000-05-25 Kazumoto Kojima > Yutaka Niibe > > * configure.in: Add machine sh3, sh4. > * configure: Likewise configure is regenerated, no need to send a patch > * scripts/config.sub: Likewise. Please send patches for config.sub to the maintainer. When your patch is accepted, we merge config.sub from the central archive at: :pserver:anoncvs@subversions.gnu.org:/home/cvs (module config) The mailaddress is . > * csu/Makefile: Add new variable crts-predefined whose non-zero > value means to generate crt[in].o from system dependent predefined > crt[in].S instead of initfini.c. > > * elf/elf.h: Add SH specific declarations of relocations. > * sysdeps/sh/Dist: New file. > * sysdeps/sh/Implies: New file. > * sysdeps/sh/gmp-mparam.h: New file for SH specific definitions > for GNU MP library. > * sysdeps/sh/machine-gmon.h: New file for SH specific definitions > for profiling support. > * sysdeps/sh/memcpy.S: New file for memcpy function written in > assembler. > * sysdeps/sh/memset.S: Likewise for memset. > * sysdeps/sh/strlen.S: Likewise for strlen. > * sysdeps/sh/sysdep.h: New file for SH specific assembler macros. > > * sysdeps/sh/sh3/__longjmp.S: New file for SH-3 specific __longjmp > function written in assembler. > * sysdeps/sh/sh3/bits/endian.h: New file for SH-3 specific > definitions for endian. > * sysdeps/sh/sh3/bits/huge_val.h: New file for SH-3 specific > definitions for HUGE_VAL constant. > * sysdeps/sh/sh3/bits/setjmp.h: New file for SH-3 specific > definitions for jmp_buf. > * sysdeps/sh/sh3/bsd-_setjmp.S: New file for SH-3 specific > BSD _setjmp function written in assembler. > * sysdeps/sh/sh3/bsd-setjmp.S: Likewise for setjmp. > * sysdeps/sh/sh3/dl-machine.h: New file for SH-3 specific > ELF dynamic location inline functions. > * sysdeps/sh/sh3/elf/crti.S: Likewise for _init and _fini > function prologue. > * sysdeps/sh/sh3/elf/crti.S: Likewise for their epilogue and > __gmon_start__ function. > * sysdeps/sh/sh3/elf/start.S: New file for the startup code > for SH-3 in ELF. > * sysdeps/sh/sh3/setjmp.S: New file for SH specific __setjmp > and __sigsetjmp functions written in assembler. > * sysdeps/sh/sh3/sys/ucontext.h: New file for SH-3 specific > definitions for user context. > > * sysdeps/sh/sh4/__longjmp.S: New file for SH-4 specific __longjmp > function written in assembler. > * sysdeps/sh/sh4/bits/endian.h: New file for SH-4 specific > definitions for endian. > * sysdeps/sh/sh4/bits/huge_val.h: New file for SH-4 specific > definitions for HUGE_VAL constant. > * sysdeps/sh/sh4/bits/setjmp.h: New file for SH-4 specific > definitions for jmp_buf. > * sysdeps/sh/sh4/bsd-_setjmp.S: New file for SH-4 specific > BSD _setjmp function written in assembler. > * sysdeps/sh/sh4/bsd-setjmp.S: Likewise for setjmp. > * sysdeps/sh/sh4/dl-machine.h: New file for SH-4 specific > ELF dynamic location inline functions. > * sysdeps/sh/sh4/elf/crti.S: Likewise for _init and _fini > function prologue. > * sysdeps/sh/sh4/elf/crti.S: Likewise for their epilogue and > __gmon_start__ function. > * sysdeps/sh/sh4/elf/start.S: New file for the startup code > for SH-4 in ELF. > * sysdeps/sh/sh4/setjmp.S: New file for SH specific __setjmp > and __sigsetjmp functions written in assembler. > * sysdeps/sh/sh4/sys/ucontext.h: New file for SH-4 specific > definitions for user context. > * sysdeps/sh/sh4/fpu/bits/fenv.h: New file for SH-4 specific > definitions for FPU. > * sysdeps/sh/sh4/fpu/fclrexcpt.c: New file for SH-4 specific > feclearexcept function. > * sysdeps/sh/sh4/fpu/fegetenv.c: Likewise for fegetenv. > * sysdeps/sh/sh4/fpu/fegetround.c: Likewise for fegetround. > * sysdeps/sh/sh4/fpu/feholdexcpt.c: Likewise for feholdexcept. > * sysdeps/sh/sh4/fpu/fesetenv.c: Likewise for fesetenv. > * sysdeps/sh/sh4/fpu/fesetround.c: Likewise for fesetround. > * sysdeps/sh/sh4/fpu/fraiseexcpt.c: Likewise for feraiseexcept. > * sysdeps/sh/sh4/fpu/fsetexcptflg.c: Likewise for fesetexceptflag. > * sysdeps/sh/sh4/fpu/ftestexcept.c: Likewise for fetestexcept. > * sysdeps/sh/sh4/fpu/fpu_control.h: New file for SH-4 specific > FPU control word definitions. > > * sysdeps/unix/sh/sysdep.S: New file for SH specific __syscall_error > function in unix. > * /sysdeps/unix/sh/sysdep.h: New file for SH specific miscellaneous > definitions in unix. > * sysdeps/unix/sysv/linux/sh/Dist: New file. > * sysdeps/unix/sysv/linux/sh/Makefile: Likewise. > * sysdeps/unix/sysv/linux/sh/Versions: Likewise. > * sysdeps/unix/sysv/linux/sh/bits/mman.h: New file for Linux/SH > specific definitions for mmap interface. > * sysdeps/unix/sysv/linux/sh/sysdep.S: New files for Linux/SH > specific definitions for system call and errno. > * sysdeps/unix/sysv/linux/sh/brk.c: New file for Linux/SH specific > definitions for brk function. > * sysdeps/unix/sysv/linux/sh/clone.S: Likewise for clone. > * sysdeps/unix/sysv/linux/sh/pipe.S: Likewise for pipe. > * sysdeps/unix/sysv/linux/sh/socket.S: Likewise for socket. > * sysdeps/unix/sysv/linux/sh/vfork.S: Likewise for vfork. > * sysdeps/unix/sysv/linux/sh/sigrestorer.S: Likewise for signal > restorers. > * sysdeps/unix/sysv/linux/sh/getgroups.c: Likewise for getgroups. > * sysdeps/unix/sysv/linux/sh/pread.c: Likewise for pread. > * sysdeps/unix/sysv/linux/sh/pread64.c: Likewise for pread64. > * sysdeps/unix/sysv/linux/sh/pwrite.c: Likewise for pwrite. > * sysdeps/unix/sysv/linux/sh/pwrite64.c: Likewise for pwrite64. Can you use the general version? We've just made changes in glibc 2.2 for pread/pwrite{64}. > * sysdeps/unix/sysv/linux/sh/setgid.c: Likewise for setgid. > * sysdeps/unix/sysv/linux/sh/seteuid.c: Likewise for seteuid. > * sysdeps/unix/sysv/linux/sh/setfsgid.c: Likewise for setfsgid. > * sysdeps/unix/sysv/linux/sh/setfsuid.c: Likewise for setfsuid. > * sysdeps/unix/sysv/linux/sh/setgid.c: Likewise for setgid. > * sysdeps/unix/sysv/linux/sh/setgroups.c: Likewise for setgroups. > * sysdeps/unix/sysv/linux/sh/setregid.c: Likewise for setregid. > * sysdeps/unix/sysv/linux/sh/setresgid.c: Likewise for setresgid. > * sysdeps/unix/sysv/linux/sh/setresuid.c: Likewise for setresuid. > * sysdeps/unix/sysv/linux/sh/setreuid.c: Likewise for setreuid. > * sysdeps/unix/sysv/linux/sh/setuid.c: Likewise for setuid. > * sysdeps/unix/sysv/linux/sh/errlist.c: New file for Linux/SH > specific definitions for errlist. > * sysdeps/unix/sysv/linux/sh/errlist.c: Likewise for siglist. > * sysdeps/unix/sysv/linux/sh/sigaction.c: New file for Linux/SH > specific definitions for sigaction. > * /sysdeps/unix/sysv/linux/sh/init-first.h: New file for Linux/SH > specific definitions for library initialization. > * sysdeps/unix/sysv/linux/sh/profil-counter.h: New file for Linux/SH > specific definitions for profiling support. > * sysdeps/unix/sysv/linux/sh/register-dump.h: New file for Linux/SH > specific definitions for register dump. > * sysdeps/unix/sysv/linux/sh/sigcontextinfo.h: New file for Linux/SH > specific definitions for signal context. > * sysdeps/unix/sysv/linux/sh/sys/io.h: New file for Linux/SH specific > definitions for low level I/O. > * sysdeps/unix/sysv/linux/sh/sys/user.h: New file for Linux/SH > specific definitions for low level user context. > * sysdeps/unix/sysv/linux/sh/syscalls.list: New file for Linux/SH > specific system call list. > > * linuxthreads/sysdeps/sh/pt-machine.h: New file for SH specific > definitions in linuxthreads. > > Unfortunatly for glibc 2.2 you need also some more files. [..] > diff -u -r -N glibc-2.1.3-original/sysdeps/sh/bits/string.h glibc-2.1.3/sysdeps/sh/bits/string.h > --- glibc-2.1.3-original/sysdeps/sh/bits/string.h Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/sh/bits/string.h Sun Mar 12 04:09:09 2000 > @@ -0,0 +1,22 @@ > +/* SH specific definitions for string functions. > + Copyright (C) 2000 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 Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +#define _HAVE_STRING_ARCH_strcpy 1 > +#define _HAVE_STRING_ARCH_stpcpy 1 > +#define _HAVE_STRING_ARCH_mempcpy 1 This doesn't look right to me. [...] > diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh3/dl-machine.h glibc-2.1.3/sysdeps/sh/sh3/dl-machine.h > --- glibc-2.1.3-original/sysdeps/sh/sh3/dl-machine.h Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/sh/sh3/dl-machine.h Sun Mar 12 16:02:39 2000 > @@ -0,0 +1,523 @@ > +/* Machine-dependent ELF dynamic relocation inline functions. SH-3 version. > + Copyright (C) 1999, 2000 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 Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +#ifndef dl_machine_h > +#define dl_machine_h > + > +/* Only dummy. This doesn't work. */ > + > +#define ELF_MACHINE_NAME "SH" > + > +#include > + > +#include > + > +/* Return nonzero iff E_MACHINE is compatible with the running host. */ > +static inline int __attribute__ ((unused)) > +elf_machine_matches_host (Elf32_Half e_machine) > +{ > + switch (e_machine) > + { > + case EM_SH: > + return 1; > + default: > + return 0; > + } > +} > + > + > +/* Return the link-time address of _DYNAMIC. Conveniently, this is the > + first element of the GOT. This must be inlined in a function which > + uses global data. */ > +static inline Elf32_Addr __attribute__ ((unused)) > +elf_machine_dynamic (void) > +{ > + register Elf32_Addr *got; > + asm ("mov r12,%0" :"=r" (got)); > + return *got; > +} > + > + > +/* Return the run-time load address of the shared object. */ > +static inline Elf32_Addr __attribute__ ((unused)) > +elf_machine_load_address (void) > +{ > + Elf32_Addr addr; > + asm ("mov.l .L1,r0 > + mov.l .L3,r2 > + add r12,r2 > + mov.l @(r0,r12),r0 > + bra .L2 > + sub r0,r2 > + .align 2 > + .L1: .long _dl_start@GOT > + .L3: .long _dl_start@GOTOFF > + .L2: mov r2,%0" > + : "=r" (addr) : : "r0", "r1", "r2"); > + return addr; > +} > + > + > +/* Set up the loaded object described by L so its unrelocated PLT > + entries will jump to the on-demand fixup code in dl-runtime.c. */ > + > +static inline int __attribute__ ((unused)) > +elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) > +{ > + Elf32_Addr *got; > + extern void _dl_runtime_resolve (Elf32_Word); > + extern void _dl_runtime_profile (Elf32_Word); > + > + if (l->l_info[DT_JMPREL] && lazy) > + { > + /* The GOT entries for functions in the PLT have not yet been filled > + in. Their initial contents will arrange when called to load an > + offset into the .rela.plt section and _GLOBAL_OFFSET_TABLE_[1], > + and then jump to _GLOBAL_OFFSET_TABLE[2]. */ > + got = (Elf32_Addr *) l->l_info[DT_PLTGOT]->d_un.d_ptr; > + got[1] = (Elf32_Addr) l; /* Identify this shared object. */ > + > + /* The got[2] entry contains the address of a function which gets > + called to get the address of a so far unresolved function and > + jump to it. The profiling extension of the dynamic linker allows > + to intercept the calls to collect information. In this case we > + don't store the address in the GOT so that all future calls also > + end in this function. */ > + if (profile) > + { > + got[2] = (Elf32_Addr) &_dl_runtime_profile; > + /* Say that we really want profiling and the timers are started. */ > + _dl_profile_map = l; > + } > + else > + /* This function will get called to fix up the GOT entry indicated by > + the offset on the stack, and then jump to the resolved address. */ > + got[2] = (Elf32_Addr) &_dl_runtime_resolve; > + } > + return lazy; > +} > + > +/* This code is used in dl-runtime.c to call the `fixup' function > + and then redirect to the address it returns. */ > + > +#define ELF_MACHINE_RUNTIME_FIXUP_ARGS int plt_type > + > +#ifdef PIC Either use __PIC__ or SHARED. > +#define FUN_ADDR "\ > + mov.l 1f,r2 > + mova 1f,r0 > + bra 2f > + add r0,r2 ! Get GOT address in r2 > +0: .align 2 > +1: .long _GLOBAL_OFFSET_TABLE_ > +2: mov.l 3f,r0 > + add r2,r0" > +#define GOTJMP(x) #x "@GOTOFF" > +#else > +#define FUN_ADDR "\ > + mov.l 3f,r0" > +#define GOTJMP(x) #x > +#endif > + > +#if defined (KERNEL_MATH_EMULATION) > +#define FGR_SAVE "\ > + sts.l fpscr, @-r15 > + mov #8,r3 > + swap.w r3, r3 > + lds r3, fpscr > + fmov.s fr11, @-r15 > + fmov.s fr10, @-r15 > + fmov.s fr9, @-r15 > + fmov.s fr8, @-r15 > + fmov.s fr7, @-r15 > + fmov.s fr6, @-r15 > + fmov.s fr5, @-r15 > + fmov.s fr4, @-r15" > +#define FGR_LOAD "\ > + fmov.s @r15+, fr4 > + fmov.s @r15+, fr5 > + fmov.s @r15+, fr6 > + fmov.s @r15+, fr7 > + fmov.s @r15+, fr8 > + fmov.s @r15+, fr9 > + fmov.s @r15+, fr10 > + fmov.s @r15+, fr11 > + lds.l @r15+, fpscr" > +#else > +#define FGR_SAVE "" > +#define FGR_LOAD "" > +#endif > + > +#ifndef PROF > +# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ > + .text > + .globl _dl_runtime_resolve > + .type _dl_runtime_resolve, @function > + .align 5 > +_dl_runtime_resolve: > + mov.l r3,@-r15 > + mov.l r4,@-r15 > + mov.l r5,@-r15 > + mov.l r6,@-r15 > + mov.l r7,@-r15 > + mov.l r12,@-r15 > + movt r3 ! Save T flag. > + mov.l r3,@-r15 > + " FGR_SAVE " > + sts.l pr,@-r15 > + mov r0,r4 ! PLT type > + mov r2,r5 ! link map address > + " FUN_ADDR " > + jsr @r0 ! Call resolver. > + mov r1,r6 ! reloc offset > + lds.l @r15+,pr ! Get register content back. > + " FGR_LOAD " > + mov.l @r15+,r3 > + shal r3 ! Lode T flag. > + mov.l @r15+,r12 > + mov.l @r15+,r7 > + mov.l @r15+,r6 > + mov.l @r15+,r5 > + mov.l @r15+,r4 > + jmp @r0 ! Jump to function address. > + mov.l @r15+,r3 > + .align 2 > +3: > + .long " GOTJMP (fixup) " > + .size _dl_runtime_resolve, .-_dl_runtime_resolve > + > + .globl _dl_runtime_profile > + .type _dl_runtime_profile, @function > + .align 5 > +_dl_runtime_profile: > + mov.l r3,@-r15 > + mov.l r4,@-r15 > + mov.l r5,@-r15 > + mov.l r6,@-r15 > + mov.l r7,@-r15 > + mov.l r12,@-r15 > + movt r3 ! Save T flag. > + mov.l r3,@-r15 > + " FGR_SAVE " > + sts.l pr,@-r15 > + mov r0,r4 ! PLT type > + mov r2,r5 ! link map address > + sts pr,r7 ! return address > + " FUN_ADDR " > + jsr @r0 ! Call resolver. > + mov r1,r6 ! reloc offset > + lds.l @r15+,pr ! Get register content back. > + " FGR_LOAD " > + mov.l @r15+,r3 > + shal r3 ! Lode T flag. > + mov.l @r15+,r12 > + mov.l @r15+,r7 > + mov.l @r15+,r6 > + mov.l @r15+,r5 > + mov.l @r15+,r4 > + jmp @r0 ! Jump to function address. > + mov.l @r15+,r3 > + .align 2 > +3: > + .long " GOTJMP (profile_fixup) " > + .size _dl_runtime_profile, .-_dl_runtime_profile > + .previous > +"); > +#else > +# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ > + .text > + .globl _dl_runtime_resolve > + .globl _dl_runtime_profile > + .type _dl_runtime_resolve, @function > + .type _dl_runtime_profile, @function > + .align 5 > +_dl_runtime_resolve: > +_dl_runtime_profile: > + mov.l r3,@-r15 > + mov.l r4,@-r15 > + mov.l r5,@-r15 > + mov.l r6,@-r15 > + mov.l r7,@-r15 > + mov.l r12,@-r15 > + movt r3 ! Save T flag. > + mov.l r3,@-r15 > + " FGR_SAVE " > + sts.l pr,@-r15 > + mov r0,r4 ! PLT type > + mov r2,r5 ! link map address > + sts pr,r7 ! return address > + " FUN_ADDR " > + jsr @r0 ! Call resolver. > + mov r1,r6 ! reloc offset > + lds.l @r15+,pr ! Get register content back. > + " FGR_LOAD " > + mov.l @r15+,r3 > + shal r3 ! Lode T flag. > + mov.l @r15+,r12 > + mov.l @r15+,r7 > + mov.l @r15+,r6 > + mov.l @r15+,r5 > + mov.l @r15+,r4 > + jmp @r0 ! Jump to function address. > + mov.l @r15+,r3 > + .align 2 > +3: > + .long " GOTJMP (fixup) " > + .size _dl_runtime_resolve, .-_dl_runtime_resolve > + .size _dl_runtime_profile, .-_dl_runtime_profile > + .previous > +"); > +#endif > + > +/* Mask identifying addresses reserved for the user program, > + where the dynamic linker should not map anything. */ > +#define ELF_MACHINE_USER_ADDRESS_MASK 0x80000000UL > + > +/* Initial entry point code for the dynamic linker. > + The C function `_dl_start' is the real entry point; > + its return value is the user program's entry point. */ > + > +#define RTLD_START asm ("\ > +.text\n\ > +.globl _start\n\ > +.globl _dl_start_user\n\ > +_start:\n\ > + mov r15,r4\n\ > + mov.l .L_dl_start,r1\n\ > + mova .L_dl_start,r0\n\ > + add r1,r0\n\ > + jsr @r0\n\ > + nop\n\ > +_dl_start_user:\n\ > + ! Save the user entry point address in r8.\n\ > + mov r0,r8\n\ > + ! Point r12 at the GOT.\n\ > + mov.l 1f,r12\n\ > + mova 1f,r0\n\ > + bra 2f\n\ > + add r0,r12\n\ > + .align 2\n\ > +1: .long _GLOBAL_OFFSET_TABLE_\n\ > +2: ! Store the highest stack address\n\ > + mov.l .L_stack_end,r0\n\ > + mov.l @(r0,r12),r0\n\ > + mov.l r15,@r0\n\ > + ! See if we were run as a command with the executable file\n\ > + ! name as an extra leading argument.\n\ > + mov.l .L_dl_skip_args,r0\n\ > + mov.l @(r0,r12),r0\n\ > + mov.l @r0,r0\n\ > + ! Get the original argument count.\n\ > + mov.l @r15,r2\n\ > + ! Subtract _dl_skip_args from it.\n\ > + sub r0,r2\n\ > + ! Adjust the stack pointer to skip _dl_skip_args words.\n\ > + shll2 r0\n\ > + add r0,r15\n\ > + ! Store back the modified argument count.\n\ > + mov.l r2,@r15\n\ > + ! Push the searchlist of the main object as argument in\n\ > + ! _dl_init_next call below.\n\ > + mov.l .L_dl_main_searchlist,r0\n\ > + mov.l @(r0,r12),r0\n\ > + mov.l @r0,r9\n\ > +0: mov r9,r4\n\ > + ! Call _dl_init_next to return the address of an initializer\n\ > + ! function to run.\n\ > + mov.l .L_dl_init_next,r1\n\ > + mova .L_dl_init_next,r0\n\ > + add r1,r0\n\ > + jsr @r0\n\ > + nop\n\ > + ! Check for zero return, when out of initializers.\n\ > + tst r0,r0\n\ > + bt 1f\n\ > + ! Call the shared object initializer function.\n\ > + jsr @r0\n\ > + nop\n\ > + ! Loop to call _dl_init_next for the next initializer.\n\ > + bra 0b\n\ > + nop\n\ > +1: ! Clear the startup flag.\n\ > + mov.l .L_dl_starting_up,r0\n\ > + mov.l @(r0,r12),r0\n\ > + mov #0,r2\n\ > + mov.l r2,@r0\n\ > + ! Pass our finalizer function to the user in r4, as per ELF ABI.\n\ > + mov.l .L_dl_fini,r0\n\ > + mov.l @(r0,r12),r4\n\ > + ! Jump to the user's entry point.\n\ > + jmp @r8\n\ > + nop\n\ > + .align 2\n\ > +.L_dl_start:\n\ > + .long _dl_start@PLT\n\ > +.L_stack_end:\n\ > + .long __libc_stack_end@GOT\n\ > +.L_dl_skip_args:\n\ > + .long _dl_skip_args@GOT\n\ > +.L_dl_main_searchlist:\n\ > + .long _dl_main_searchlist@GOT\n\ > +.L_dl_init_next:\n\ > + .long _dl_init_next@PLT\n\ > +.L_dl_starting_up:\n\ > + .long _dl_starting_up@GOT\n\ > +.L_dl_fini:\n\ > + .long _dl_fini@GOT\n\ > +.previous\n\ > +"); > + > +/* Nonzero iff TYPE should not be allowed to resolve to one of > + the main executable's symbols, as for a COPY reloc. */ > +#define elf_machine_lookup_noexec_p(type) ((type) == R_SH_COPY) > + > +/* Nonzero iff TYPE describes relocation of a PLT entry, so > + PLT entries should not be allowed to define the value. */ > +#define elf_machine_lookup_noplt_p(type) ((type) == R_SH_JMP_SLOT) > + > +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ > +#define ELF_MACHINE_JMP_SLOT R_SH_JMP_SLOT > + > +/* We define an initialization functions. This is called very early in > + _dl_sysdep_start. */ > +#define DL_PLATFORM_INIT dl_platform_init () > + > +extern const char *_dl_platform; > + > +static inline void __attribute__ ((unused)) > +dl_platform_init (void) > +{ > + if (_dl_platform != NULL && *_dl_platform == '\0') > + /* Avoid an empty string which would disturb us. */ > + _dl_platform = NULL; > +} > + > +static inline void > +elf_machine_fixup_plt (struct link_map *map, const Elf32_Rela *reloc, > + Elf32_Addr *reloc_addr, Elf32_Addr value) > +{ > + *reloc_addr = value; > +} > + > +/* Return the final value of a plt relocation. */ > +static inline Elf32_Addr > +elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, > + Elf32_Addr value) > +{ > + return value + reloc->r_addend; > +} > + > +#endif /* !dl_machine_h */ > + > +#ifdef RESOLVE > + > +/* SH never uses Elf32_Rel relocations. */ > +#define ELF_MACHINE_NO_REL 1 > + > +extern char **_dl_argv; > + > +/* Perform the relocation specified by RELOC and SYM (which is fully resolved). > + MAP is the object containing the reloc. */ > + > +static inline void > +elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, > + const Elf32_Sym *sym, const struct r_found_version *version, > + Elf32_Addr *const reloc_addr) > +{ > + if (ELF32_R_TYPE (reloc->r_info) == R_SH_RELATIVE) > + { > +#ifndef RTLD_BOOTSTRAP > + if (map != &_dl_rtld_map) /* Already done in rtld itself. */ > +#endif > + *reloc_addr = map->l_addr + reloc->r_addend; > + } > + else if (ELF32_R_TYPE (reloc->r_info) != R_SH_NONE) > + { > + const Elf32_Sym *const refsym = sym; > + Elf32_Addr value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info)); > + if (sym) > + value += sym->st_value; > + value += reloc->r_addend; > + > + switch (ELF32_R_TYPE (reloc->r_info)) > + { > + case R_SH_COPY: > + if (sym == NULL) > + /* This can happen in trace mode if an object could not be > + found. */ > + break; > + if (sym->st_size > refsym->st_size > + || (sym->st_size < refsym->st_size && _dl_verbose)) > + { > + const char *strtab; > + > + strtab = (const char *) map->l_info[DT_STRTAB]->d_un.d_ptr; > + _dl_sysdep_error (_dl_argv[0] ?: "", > + ": Symbol `", strtab + refsym->st_name, > + "' has different size in shared object, " > + "consider re-linking\n", NULL); > + } > + memcpy (reloc_addr, (void *) value, MIN (sym->st_size, > + refsym->st_size)); > + break; > + case R_SH_GLOB_DAT: > + case R_SH_JMP_SLOT: > + *reloc_addr = value; > + break; > + case R_SH_DIR32: > + { > +#ifndef RTLD_BOOTSTRAP > + /* This is defined in rtld.c, but nowhere in the static > + libc.a; make the reference weak so static programs can > + still link. This declaration cannot be done when > + compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because > + rtld.c contains the common defn for _dl_rtld_map, which > + is incompatible with a weak decl in the same file. */ > + weak_extern (_dl_rtld_map); > + if (map == &_dl_rtld_map) > + /* Undo the relocation done here during bootstrapping. > + Now we will relocate it anew, possibly using a > + binding found in the user program or a loaded library > + rather than the dynamic linker's built-in definitions > + used while loading those libraries. */ > + value -= map->l_addr + refsym->st_value + reloc->r_addend; > +#endif > + *reloc_addr = value; > + break; > + } > + case R_SH_REL32: > + *reloc_addr = (value - (Elf32_Addr) reloc_addr); > + break; > + default: > + assert (! "unexpected dynamic reloc type"); > + break; > + } > + } > +} > + > +static inline void > +elf_machine_lazy_rel (Elf32_Addr l_addr, const Elf32_Rela *reloc) > +{ > + Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); > + /* Check for unexpected PLT reloc type. */ > + assert (ELF32_R_TYPE (reloc->r_info) == R_SH_JMP_SLOT); > + *reloc_addr += l_addr; /* + reloc->r_addend; */ > +} > + > +#endif /* RESOLVE */ > diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/bits/fenv.h glibc-2.1.3/sysdeps/sh/sh4/fpu/bits/fenv.h > --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/bits/fenv.h Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/bits/fenv.h Sun Mar 12 04:09:09 2000 > @@ -0,0 +1,72 @@ > +/* Copyright (C) 1999, 2000 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 Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +#ifndef _FENV_H > +# error "Never use directly; include instead." > +#endif > + > + > +/* Define bits representing the exception. We use the bit positions > + of the appropriate bits in the FPU control word. */ > +enum > + { > + FE_INEXACT = 0x04, > +#define FE_INEXACT FE_INEXACT > + FE_UNDERFLOW = 0x08, > +#define FE_UNDERFLOW FE_UNDERFLOW > + FE_OVERFLOW = 0x10, > +#define FE_OVERFLOW FE_OVERFLOW > + FE_DIVBYZERO = 0x20, > +#define FE_DIVBYZERO FE_DIVBYZERO > + FE_INVALID = 0x40, > +#define FE_INVALID FE_INVALID > + }; > + > +#define FE_ALL_EXCEPT \ > + (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) > + > +/* The SH FPU supports all of the four defined rounding modes. We > + use again the bit positions in the FPU control word as the values > + for the appropriate macros. */ > +enum > + { > + FE_TONEAREST = 0x0, > +#define FE_TONEAREST FE_TONEAREST > + FE_TOWARDZERO = 0x1, > +#define FE_TOWARDZERO FE_TOWARDZERO > + FE_UPWARD = 0x2, > +#define FE_UPWARD FE_UPWARD > + FE_DOWNWARD = 0x3 > +#define FE_DOWNWARD FE_DOWNWARD > + }; > + > + > +/* Type representing exception flags. */ > +typedef unsigned short int fexcept_t; > + > + > +/* Type representing floating-point environment. This function corresponds > + to the layout of the block written by the `fstenv'. */ > +typedef struct > + { > + unsigned int __fpscr; > + } > +fenv_t; > + > +/* If the default argument is used we use this value. */ > +#define FE_DFL_ENV ((fenv_t *) -1) > diff -u -r -N glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fclrexcpt.c glibc-2.1.3/sysdeps/sh/sh4/fpu/fclrexcpt.c > --- glibc-2.1.3-original/sysdeps/sh/sh4/fpu/fclrexcpt.c Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/sh/sh4/fpu/fclrexcpt.c Sun Mar 12 21:13:05 2000 > @@ -0,0 +1,40 @@ > +/* Clear given exceptions in current floating-point environment. > + Copyright (C) 1998, 2000 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + Contributed by Andreas Jaeger , 1998. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +#include > +#include > + > +void > +feclearexcept (int excepts) It's int __feclearexcept - this was changed in the last minute in ISO C99. Please check all your functions from with the current version in glibc 2.2. > +{ > + int cw; > + > + /* Mask out unsupported bits/exceptions. */ > + excepts &= FE_ALL_EXCEPT; > + > + /* Read the complete control word. */ > + _FPU_GETCW (cw); > + > + /* Clear exception bits. */ > + cw &= ~excepts; > + > + /* Put the new data in effect. */ > + _FPU_SETCW (cw); > +} > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/Versions glibc-2.1.3/sysdeps/unix/sysv/linux/sh/Versions > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/Versions Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/Versions Sun Mar 12 04:20:49 2000 > @@ -0,0 +1,4 @@ > +libc { > + GLIBC_2.1 { > + } > +} No versions? In that case you don't need the file at all. > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/errlist.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/errlist.c > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/errlist.c Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/errlist.c Sun Mar 12 04:09:09 2000 > @@ -0,0 +1,55 @@ > +/* Copyright (C) 1998, 1999, 2000 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 Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +#include > +#include > + > +#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING > + > +# define SYS_ERRLIST __new_sys_errlist > +# define SYS_NERR __new_sys_nerr > + > +asm (".data; .globl __old_sys_errlist; __old_sys_errlist:"); > +#endif > + > +#include > + > +#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING > +asm (".type __old_sys_errlist,%object;.size __old_sys_errlist," > + OLD_ERRLIST_SIZE_STR "*" PTR_SIZE_STR); You don't need compatibility with old versions. We've also changed the way to handle this, have a look at glibc 2.2. > + > +extern const char *const *__old_sys_errlist; > + > +const int __old_sys_nerr = OLD_ERRLIST_SIZE; > + > +strong_alias (__old_sys_nerr, _old_sys_nerr); > +weak_alias (__old_sys_nerr, _old_sys_nerr) > +symbol_version (__old_sys_nerr, _sys_nerr, GLIBC_2.0); > +symbol_version (_old_sys_nerr, sys_nerr, GLIBC_2.0); > +weak_alias (__old_sys_errlist, _old_sys_errlist); > +symbol_version (__old_sys_errlist, _sys_errlist, GLIBC_2.0); > +symbol_version (_old_sys_errlist, sys_errlist, GLIBC_2.0); > + > +weak_alias (__new_sys_nerr, _new_sys_nerr) > +default_symbol_version (__new_sys_nerr, _sys_nerr, GLIBC_2.1); > +default_symbol_version (_new_sys_nerr, sys_nerr, GLIBC_2.1); > +weak_alias (__new_sys_errlist, _new_sys_errlist) > +default_symbol_version (__new_sys_errlist, _sys_errlist, GLIBC_2.1); > +default_symbol_version (_new_sys_errlist, sys_errlist, GLIBC_2.1); > + > +#endif > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/getgroups.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/getgroups.c > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/getgroups.c Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/getgroups.c Sun Mar 12 04:09:09 2000 > @@ -0,0 +1,2 @@ > +/* We also have to rewrite the kernel gid_t to the user land type. */ > +#include Is this really needed? What kernel version are you supporting? If you start with glibc 2.2 and Linux 2.4 this might not be necessary. > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/init-first.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/init-first.h > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/init-first.h Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/init-first.h Sun Mar 12 04:09:09 2000 > @@ -0,0 +1,52 @@ > +/* Prepare arguments for library initialization function. > + Copyright (C) 1999, 2000 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 Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +/* The job of this fragment it to find argc and friends for INIT. > + This is done in one of two ways: either in the stack context > + of program start, or having dlopen pass them in. */ > + > +#define SYSDEP_CALL_INIT(NAME, INIT) \ > +void NAME (void *arg, void *arg1, void *arg2, void *arg3, void *argp) \ > +{ \ > + int argc; \ > + char** argv; \ > + char** envp; \ > + /* The next variable is only here to work around a bug in gcc <= 2.7.2.2. \ > + If the address would be taken inside the expression the optimizer \ > + would try to be too smart and throws it away. Grrr. */ \ > + int *dummy_addr = &_dl_starting_up; \ > + \ > + __libc_multiple_libcs = dummy_addr && !_dl_starting_up; \ > + \ > + if (!__libc_multiple_libcs) \ > + { \ > + /* In SH, argp is the first argument on stack. */ \ > + argc = *(int*) (&argp); \ > + argv = (char **) &argp + 1; \ > + envp = &argv[argc+1]; \ > + } \ > + else \ > + { \ > + argc = (int) arg; \ > + argv = (char**) arg1; \ > + envp = (char**) arg2; \ > + } \ > + \ > + INIT (argc, argv, envp); \ > +} > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pipe.S glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pipe.S > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pipe.S Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pipe.S Thu Apr 27 21:26:38 2000 > @@ -0,0 +1,63 @@ > +/* Copyright (C) 1999, 2000 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 Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +#include > + > +ENTRY (__libc_pipe) > + mov #+__NR_pipe, $r3 > + trapa #0x10 > + mov r0, r3 > + mov #-12, r2 > + shad r2, r3 > + not r3, r3 // r1=0 means r0 = -1 to -4095 > + tst r3, r3 // i.e. error in linux > + bf 1f > + mov.l .L2, r1 > +#ifdef PIC > + mov r0, r4 > + mov.l r12, @-r15 > + sts.l pr, @-r15 > + mov.l 0f, r12 > + mova 0f, r0 > + add r0, r12 > + mova .L2, r0 > + add r0, r1 > + jsr @r1 > + nop > + lds.l @r15+, pr > + rts > + mov.l @r15+, r12 > + .align 2 > +0: > + .long _GLOBAL_OFFSET_TABLE_ > +#else > + jmp @r1 > + mov r0, r4 > +#endif > +1: > + mov.l r0, @r4 > + mov.l r1, @(4, r4) > + rts > + mov #0, r0 > + .align 2 > +.L2: > + .long PLTJMP(C_SYMBOL_NAME(__syscall_error)) > +PSEUDO_END (__libc_pipe) > + > +weak_alias (__libc_pipe, __pipe) > +weak_alias (__libc_pipe, pipe) > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pread.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pread.c > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pread.c Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pread.c Sun Mar 12 04:09:09 2000 > @@ -0,0 +1 @@ > +#include > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pread64.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pread64.c > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pread64.c Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pread64.c Sun Mar 12 04:09:09 2000 > @@ -0,0 +1 @@ > +#include > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/profil-counter.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/profil-counter.h > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/profil-counter.h Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/profil-counter.h Sun Mar 12 04:09:09 2000 > @@ -0,0 +1,28 @@ > +/* Low-level statistical profiling support function. Linux/SH version. > + Copyright (C) 1996, 1997, 1998, 2000 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 Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +#include > + Shouldn't this be a static void? > +void > +profil_counter (int signo, int _a2, int _a3, int _a4, struct sigcontext sc) > +{ > + void *pc; > + pc = (void *) sc.sc_pc; > + profil_count (pc); > +} > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pwrite.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pwrite.c > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/pwrite.c Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/pwrite.c Sun Mar 12 04:09:09 2000 > @@ -0,0 +1 @@ > +#include Not needed in glibc 2.2 anymore. > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sigaction.c glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sigaction.c > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sigaction.c Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sigaction.c Sun Mar 12 04:09:10 2000 > @@ -0,0 +1,150 @@ > +/* Copyright (C) 1997, 1998, 1999, 2000 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 Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +#include > +#include > +#include > + > +#include > +#include > + > +/* The difference here is that the sigaction structure used in the > + kernel is not the same as we use in the libc. Therefore we must > + translate it here. */ > +#include > + > +extern int __syscall_sigaction (int, const struct old_kernel_sigaction *, > + struct old_kernel_sigaction *); > +extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *, > + struct kernel_sigaction *, size_t); > + > +/* The variable is shared between all wrappers around signal handling > + functions which have RT equivalents. */ > +int __libc_missing_rt_sigs; Are you really supporting 2.0 and 2.1 kernels? Btw. we've also added in glibc 2.2 some ASSUME_* constants, see sysdeps/unix/sysv/linux/kernel-features.h and how this is handled. > diff -u -r -N glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sys/io.h glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sys/io.h > --- glibc-2.1.3-original/sysdeps/unix/sysv/linux/sh/sys/io.h Thu Jan 1 09:00:00 1970 > +++ glibc-2.1.3/sysdeps/unix/sysv/linux/sh/sys/io.h Sun Mar 12 04:09:10 2000 > @@ -0,0 +1,48 @@ > +/* Copyright (C) 1996, 1998, 1999 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 Library General Public License as > + published by the Free Software Foundation; either version 2 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 > + Library General Public License for more details. > + > + You should have received a copy of the GNU Library General Public > + License along with the GNU C Library; see the file COPYING.LIB. If not, > + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, > + Boston, MA 02111-1307, USA. */ > + > +#ifndef _SYS_IO_H > + > +#define _SYS_IO_H 1 > +#include > + > +__BEGIN_DECLS > + > +/* If TURN_ON is TRUE, request for permission to do direct i/o on the > + port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O > + permission off for that range. This call requires root privileges. */ > +extern int ioperm __P ((unsigned long int __from, unsigned long int __num, > + int __turn_on)); With glibc 2.2 we use normal prototypes without __P (and no need for __ptr_t anymore, use void *). [...] Some of my notes apply to more than one place, I've just added the description where I noticed the problem first. Looking forward to the integration of your patch into 2.2! Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de From jakub@redhat.com Wed May 31 15:09:00 2000 From: jakub@redhat.com (Jakub Jelinek) Date: Wed, 31 May 2000 15:09:00 -0000 Subject: [PATCH] sysdeps/*/fpu/bits/mathinline.h fixes Message-ID: <20000601001659.Q474@sunsite.ms.mff.cuni.cz> Hi! Compiling a C++ program like this: #include int main(void) { return 0; } fails with current glibc if -I/usr/include is given to g++. (both egcs 1.1.x and gcc 2.96 behave the same way, they don't like the same function used once with throw() and once without). This patch tries to deal with it (tested only on i386, sparc and sparc64): 2000-06-01 Jakub Jelinek * libc/sysdeps/alpha/fpu/bits/mathinline.h: Add __THROW to all inlines to match prototypes in mathcalls.h. * libc/sysdeps/i386/fpu/bits/mathinline.h: Likewise. * libc/sysdeps/m68k/fpu/bits/mathinline.h: Likewise. * libc/sysdeps/powerpc/fpu/bits/mathinline.h: Likewise. * libc/sysdeps/sparc/fpu/bits/mathinline.h: Likewise. --- libc/sysdeps/alpha/fpu/bits/mathinline.h.jj Fri Nov 12 16:30:30 1999 +++ libc/sysdeps/alpha/fpu/bits/mathinline.h Wed May 31 23:16:05 2000 @@ -1,5 +1,5 @@ /* Inline math functions for Alpha. - Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by David Mosberger-Tang. @@ -60,7 +60,7 @@ #define __inline_copysign(NAME, TYPE) \ __MATH_INLINE TYPE \ -NAME (TYPE __x, TYPE __y) \ +NAME (TYPE __x, TYPE __y) __THROW \ { \ TYPE __z; \ __asm ("cpys %1, %2, %0" : "=f" (__z) : "f" (__y), "f" (__x)); \ @@ -76,14 +76,14 @@ __inline_copysign(copysign, double) #if __GNUC_PREREQ (2, 8) -__MATH_INLINE float __fabsf (float __x) { return __builtin_fabsf (__x); } -__MATH_INLINE float fabsf (float __x) { return __builtin_fabsf (__x); } -__MATH_INLINE double __fabs (double __x) { return __builtin_fabs (__x); } -__MATH_INLINE double fabs (double __x) { return __builtin_fabs (__x); } +__MATH_INLINE float __fabsf (float __x) __THROW { return __builtin_fabsf (__x); } +__MATH_INLINE float fabsf (float __x) __THROW { return __builtin_fabsf (__x); } +__MATH_INLINE double __fabs (double __x) __THROW { return __builtin_fabs (__x); } +__MATH_INLINE double fabs (double __x) __THROW { return __builtin_fabs (__x); } #else #define __inline_fabs(NAME, TYPE) \ __MATH_INLINE TYPE \ -NAME (TYPE __x) \ +NAME (TYPE __x) __THROW \ { \ TYPE __z; \ __asm ("cpys $f31, %1, %0" : "=f" (__z) : "f" (__x)); \ @@ -104,7 +104,7 @@ __inline_fabs(fabs, double) must be integral, as this avoids unpleasant integer overflows. */ __MATH_INLINE float -__floorf (float __x) +__floorf (float __x) __THROW { /* Check not zero since floor(-0) == -0. */ if (__x != 0 && fabsf (__x) < 16777216.0f) /* 1 << FLT_MANT_DIG */ @@ -130,7 +130,7 @@ __floorf (float __x) } __MATH_INLINE double -__floor (double __x) +__floor (double __x) __THROW { if (__x != 0 && fabs (__x) < 9007199254740992.0) /* 1 << DBL_MANT_DIG */ { @@ -148,26 +148,26 @@ __floor (double __x) return __x; } -__MATH_INLINE float floorf (float __x) { return __floorf(__x); } -__MATH_INLINE double floor (double __x) { return __floor(__x); } +__MATH_INLINE float floorf (float __x) __THROW { return __floorf(__x); } +__MATH_INLINE double floor (double __x) __THROW { return __floor(__x); } -__MATH_INLINE float __fdimf (float __x, float __y) +__MATH_INLINE float __fdimf (float __x, float __y) __THROW { return __x < __y ? 0.0f : __x - __y; } -__MATH_INLINE float fdimf (float __x, float __y) +__MATH_INLINE float fdimf (float __x, float __y) __THROW { return __x < __y ? 0.0f : __x - __y; } -__MATH_INLINE double __fdim (double __x, double __y) +__MATH_INLINE double __fdim (double __x, double __y) __THROW { return __x < __y ? 0.0 : __x - __y; } -__MATH_INLINE double fdim (double __x, double __y) +__MATH_INLINE double fdim (double __x, double __y) __THROW { return __x < __y ? 0.0 : __x - __y; } --- libc/sysdeps/i386/fpu/bits/mathinline.h.jj Wed May 31 23:02:51 2000 +++ libc/sysdeps/i386/fpu/bits/mathinline.h Wed May 31 23:28:03 2000 @@ -115,19 +115,19 @@ # if __GNUC_PREREQ (2, 8) /* Test for negative number. Used in the signbit() macro. */ __MATH_INLINE int -__signbitf (float __x) +__signbitf (float __x) __THROW { __extension__ union { float __f; int __i; } __u = { __f: __x }; return __u.__i < 0; } __MATH_INLINE int -__signbit (double __x) +__signbit (double __x) __THROW { __extension__ union { double __d; int __i[2]; } __u = { __d: __x }; return __u.__i[1] < 0; } __MATH_INLINE int -__signbitl (long double __x) +__signbitl (long double __x) __THROW { __extension__ union { long double __l; int __i[3]; } __u = { __l: __x }; return (__u.__i[2] & 0x8000) != 0; @@ -189,11 +189,11 @@ __signbitl (long double __x) #endif #define __inline_mathop_decl_(float_type, func, op, params...) \ - __MATH_INLINE float_type func (float_type); \ + __MATH_INLINE float_type func (float_type) __THROW; \ __inline_mathop_declNP_ (float_type, func, op, params) #define __inline_mathop_declNP_(float_type, func, op, params...) \ - __MATH_INLINE float_type func (float_type __x) \ + __MATH_INLINE float_type func (float_type __x) __THROW \ { \ register float_type __result; \ __asm __volatile__ (op : "=t" (__result) : params); \ @@ -242,33 +242,33 @@ __signbitl (long double __x) #endif #define __inline_mathcode_(float_type, func, arg, code) \ - __MATH_INLINE float_type func (float_type); \ + __MATH_INLINE float_type func (float_type) __THROW; \ __inline_mathcodeNP_(float_type, func, arg, code) #define __inline_mathcodeNP_(float_type, func, arg, code) \ - __MATH_INLINE float_type func (float_type arg) \ + __MATH_INLINE float_type func (float_type arg) __THROW \ { \ code; \ } #define __inline_mathcode2_(float_type, func, arg1, arg2, code) \ - __MATH_INLINE float_type func (float_type, float_type); \ + __MATH_INLINE float_type func (float_type, float_type) __THROW; \ __inline_mathcodeNP2_ (float_type, func, arg1, arg2, code) #define __inline_mathcodeNP2_(float_type, func, arg1, arg2, code) \ - __MATH_INLINE float_type func (float_type arg1, float_type arg2) \ + __MATH_INLINE float_type func (float_type arg1, float_type arg2) __THROW \ { \ code; \ } #define __inline_mathcode3_(float_type, func, arg1, arg2, arg3, code) \ - __MATH_INLINE float_type func (float_type, float_type, float_type); \ + __MATH_INLINE float_type func (float_type, float_type, float_type) __THROW; \ __inline_mathcodeNP3_(float_type, func, arg1, arg2, arg3, code) #define __inline_mathcodeNP3_(float_type, func, arg1, arg2, arg3, code) \ __MATH_INLINE float_type func (float_type arg1, float_type arg2, \ - float_type arg3) \ + float_type arg3) __THROW \ { \ code; \ } @@ -331,19 +331,19 @@ __inline_mathcode (__pow2, __x, \ *__cosx = __cosr __MATH_INLINE void -__sincos (double __x, double *__sinx, double *__cosx) +__sincos (double __x, double *__sinx, double *__cosx) __THROW { __sincos_code; } __MATH_INLINE void -__sincosf (float __x, float *__sinx, float *__cosx) +__sincosf (float __x, float *__sinx, float *__cosx) __THROW { __sincos_code; } __MATH_INLINE void -__sincosl (long double __x, long double *__sinx, long double *__cosx) +__sincosl (long double __x, long double *__sinx, long double *__cosx) __THROW { __sincos_code; } @@ -557,7 +557,7 @@ __inline_mathcodeNP (ceil, __x, \ return __value __MATH_INLINE double -ldexp (double __x, int __y) +ldexp (double __x, int __y) __THROW { __ldexp_code; } @@ -619,13 +619,13 @@ __inline_mathop_declNP (log2, "fld1; fxc #endif /* __FAST_MATH__ */ __MATH_INLINE float -ldexpf (float __x, int __y) +ldexpf (float __x, int __y) __THROW { __ldexp_code; } __MATH_INLINE long double -ldexpl (long double __x, int __y) +ldexpl (long double __x, int __y) __THROW { __ldexp_code; } @@ -643,17 +643,17 @@ __inline_mathopNP (rint, "frndint") : "=m" (__lrintres) : "t" (__x) : "st"); \ return __lrintres __MATH_INLINE long int -lrintf (float __x) +lrintf (float __x) __THROW { __lrint_code; } __MATH_INLINE long int -lrint (double __x) +lrint (double __x) __THROW { __lrint_code; } __MATH_INLINE long int -lrintl (long double __x) +lrintl (long double __x) __THROW { __lrint_code; } @@ -666,17 +666,17 @@ lrintl (long double __x) : "=m" (__llrintres) : "t" (__x) : "st"); \ return __llrintres __MATH_INLINE long long int -llrintf (float __x) +llrintf (float __x) __THROW { __llrint_code; } __MATH_INLINE long long int -llrint (double __x) +llrint (double __x) __THROW { __llrint_code; } __MATH_INLINE long long int -llrintl (long double __x) +llrintl (long double __x) __THROW { __llrint_code; } @@ -701,7 +701,7 @@ __inline_mathcodeNP2 (drem, __x, __y, \ /* This function is used in the `isfinite' macro. */ __MATH_INLINE int -__finite (double __x) +__finite (double __x) __THROW { return (__extension__ (((((union { double __d; int __i[2]; }) {__d: __x}).__i[1] --- libc/sysdeps/m68k/fpu/bits/mathinline.h.jj Wed May 31 23:39:36 2000 +++ libc/sysdeps/m68k/fpu/bits/mathinline.h Wed May 31 23:50:30 2000 @@ -1,5 +1,5 @@ /* Definitions of inline math functions implemented by the m68881/2. - Copyright (C) 1991,92,93,94,96,97,98,99 Free Software Foundation, Inc. + Copyright (C) 1991,92,93,94,96,97,98,99,2000 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 @@ -109,7 +109,7 @@ #endif #define __inline_mathop1(float_type,func, op) \ - __m81_defun (float_type, func, (float_type __mathop_x)) \ + __m81_defun (float_type, func, (float_type __mathop_x)) __THROW \ { \ float_type __result; \ __asm("f" __STRING(op) "%.x %1, %0" : "=f" (__result) : "f" (__mathop_x));\ @@ -169,7 +169,7 @@ __inline_mathop(trunc, intrz) #define __inline_functions(float_type, s) \ __m81_inline float_type \ -__m81_u(__CONCAT(__frexp,s))(float_type __value, int *__expptr) \ +__m81_u(__CONCAT(__frexp,s))(float_type __value, int *__expptr) __THROW \ { \ float_type __mantissa, __exponent; \ int __iexponent; \ @@ -190,7 +190,7 @@ __m81_u(__CONCAT(__frexp,s))(float_type return __mantissa; \ } \ \ -__m81_defun (float_type, __CONCAT(__floor,s), (float_type __x)) \ +__m81_defun (float_type, __CONCAT(__floor,s), (float_type __x)) __THROW \ { \ float_type __result; \ unsigned long int __ctrl_reg; \ @@ -206,7 +206,7 @@ __m81_defun (float_type, __CONCAT(__floo return __result; \ } \ \ -__m81_defun (float_type, __CONCAT(__ceil,s), (float_type __x)) \ +__m81_defun (float_type, __CONCAT(__ceil,s), (float_type __x)) __THROW \ { \ float_type __result; \ unsigned long int __ctrl_reg; \ @@ -232,7 +232,7 @@ __inline_functions(long double,l) #ifdef __USE_MISC # define __inline_functions(float_type, s) \ -__m81_defun (int, __CONCAT(__isinf,s), (float_type __value)) \ +__m81_defun (int, __CONCAT(__isinf,s), (float_type __value)) __THROW \ { \ /* There is no branch-condition for infinity, \ so we must extract and examine the condition codes manually. */ \ @@ -242,7 +242,7 @@ __m81_defun (int, __CONCAT(__isinf,s), ( return (__fpsr & (2 << 24)) ? (__fpsr & (8 << 24) ? -1 : 1) : 0; \ } \ \ -__m81_defun (int, __CONCAT(__finite,s), (float_type __value)) \ +__m81_defun (int, __CONCAT(__finite,s), (float_type __value)) __THROW \ { \ /* There is no branch-condition for infinity, so we must extract and \ examine the condition codes manually. */ \ @@ -253,7 +253,7 @@ __m81_defun (int, __CONCAT(__finite,s), } \ \ __m81_defun (float_type, __CONCAT(__scalbn,s), \ - (float_type __x, int __n)) \ + (float_type __x, int __n)) __THROW \ { \ float_type __result; \ __asm ("fscale%.l %1, %0" : "=f" (__result) : "dmi" (__n), "0" (__x)); \ @@ -270,7 +270,7 @@ __inline_functions(long double,l) #if defined __USE_MISC || defined __USE_XOPEN # define __inline_functions(float_type, s) \ -__m81_defun (int, __CONCAT(__isnan,s), (float_type __value)) \ +__m81_defun (int, __CONCAT(__isnan,s), (float_type __value)) __THROW \ { \ char __result; \ __asm("ftst%.x %1\n" \ @@ -290,7 +290,7 @@ __inline_functions(long double,l) #ifdef __USE_ISOC99 # define __inline_functions(float_type, s) \ -__m81_defun (int, __CONCAT(__signbit,s), (float_type __value)) \ +__m81_defun (int, __CONCAT(__signbit,s), (float_type __value)) __THROW \ { \ /* There is no branch-condition for the sign bit, so we must extract \ and examine the condition codes manually. */ \ @@ -301,12 +301,12 @@ __m81_defun (int, __CONCAT(__signbit,s), } \ \ __m81_defun (float_type, __CONCAT(__scalbln,s), \ - (float_type __x, long int __n)) \ + (float_type __x, long int __n)) __THROW \ { \ return __CONCAT(__scalbn,s) (__x, __n); \ } \ \ -__m81_defun (float_type, __CONCAT(__nearbyint,s), (float_type __x)) \ +__m81_defun (float_type, __CONCAT(__nearbyint,s), (float_type __x)) __THROW \ { \ float_type __result; \ unsigned long int __ctrl_reg; \ @@ -320,7 +320,7 @@ __m81_defun (float_type, __CONCAT(__near return __result; \ } \ \ -__m81_defun (long int, __CONCAT(__lrint,s), (float_type __x)) \ +__m81_defun (long int, __CONCAT(__lrint,s), (float_type __x)) __THROW \ { \ long int __result; \ __asm ("fmove%.l %1, %0" : "=dm" (__result) : "f" (__x)); \ @@ -329,7 +329,7 @@ __m81_defun (long int, __CONCAT(__lrint, \ __m81_inline float_type \ __m81_u(__CONCAT(__fma,s))(float_type __x, float_type __y, \ - float_type __z) \ + float_type __z) __THROW \ { \ return (__x * __y) + __z; \ } @@ -346,7 +346,7 @@ __inline_functions (long double,l) # define __inline_functions(float_type, s) \ __m81_inline void \ __m81_u(__CONCAT(__sincos,s))(float_type __x, float_type *__sinx, \ - float_type *__cosx) \ + float_type *__cosx) __THROW \ { \ __asm ("fsincos%.x %2,%1:%0" \ : "=f" (*__sinx), "=f" (*__cosx) : "f" (__x)); \ @@ -367,13 +367,13 @@ __inline_functions (long double,l) NAME, to make token pasting work correctly with -traditional. */ # define __inline_forward_c(rettype, name, args1, args2) \ extern __inline rettype __attribute__((__const__)) \ -name args1 \ +name args1 __THROW \ { \ return __CONCAT(__,name) args2; \ } # define __inline_forward(rettype, name, args1, args2) \ -extern __inline rettype name args1 \ +extern __inline rettype name args1 __THROW \ { \ return __CONCAT(__,name) args2; \ } --- libc/sysdeps/powerpc/fpu/bits/mathinline.h.jj Sun Oct 31 18:35:13 1999 +++ libc/sysdeps/powerpc/fpu/bits/mathinline.h Wed May 31 23:50:48 2000 @@ -1,5 +1,6 @@ /* Inline math functions for powerpc. - Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 + 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 @@ -45,9 +46,9 @@ #endif /* __cplusplus */ #ifdef __USE_ISOC99 -__MATH_INLINE long int lrint (double __x); +__MATH_INLINE long int lrint (double __x) __THROW; __MATH_INLINE long int -lrint (double __x) +lrint (double __x) __THROW { union { double __d; @@ -57,9 +58,9 @@ lrint (double __x) return __u.__ll[1]; } -__MATH_INLINE long int lrintf (float __x); +__MATH_INLINE long int lrintf (float __x) __THROW; __MATH_INLINE long int -lrintf (float __x) +lrintf (float __x) __THROW { union { double __d; @@ -69,16 +70,16 @@ lrintf (float __x) return __u.__ll[1]; } -__MATH_INLINE double fdim (double __x, double __y); +__MATH_INLINE double fdim (double __x, double __y) __THROW; __MATH_INLINE double -fdim (double __x, double __y) +fdim (double __x, double __y) __THROW { return __x < __y ? 0 : __x - __y; } -__MATH_INLINE float fdimf (float __x, float __y); +__MATH_INLINE float fdimf (float __x, float __y) __THROW; __MATH_INLINE float -fdimf (float __x, float __y) +fdimf (float __x, float __y) __THROW { return __x < __y ? 0 : __x - __y; } --- libc/sysdeps/sparc/fpu/bits/mathinline.h.jj Mon Jan 3 07:35:20 2000 +++ libc/sysdeps/sparc/fpu/bits/mathinline.h Wed May 31 23:50:59 2000 @@ -1,5 +1,5 @@ /* Inline math functions for SPARC. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek . @@ -144,7 +144,7 @@ __signbitl (long double __x) #endif /* sparc64 */ __MATH_INLINE double -sqrt(double __x) +sqrt(double __x) __THROW { register double __r; __asm ("fsqrtd %1,%0" : "=f" (__r) : "f" (__x)); @@ -152,7 +152,7 @@ sqrt(double __x) } __MATH_INLINE float -sqrtf(float __x) +sqrtf(float __x) __THROW { register float __r; __asm ("fsqrts %1,%0" : "=f" (__r) : "f" (__x)); @@ -161,7 +161,7 @@ sqrtf(float __x) #if __WORDSIZE == 64 __MATH_INLINE long double -sqrtl(long double __x) +sqrtl(long double __x) __THROW { long double __r; extern void _Qp_sqrt(long double *, __const__ long double *); Jakub