Hello! Needed because of GCC changes. Not everything is ready for upstream inclusion.
This is no proper fix, but a workaround to not make argp-enabled programs segfault on ``PROGRAM --help'' when glibc is build with GCC 4.1. Reported on <http://lists.gnu.org/archive/html/bug-hurd/2006-12/msg00064.html>. --- argp/Makefile~ 2004-03-28 16:15:30.000000000 +0200 +++ argp/Makefile 2007-01-29 21:54:59.000000000 +0100 @@ -30,6 +30,7 @@ CFLAGS-argp-help.c = $(uses-callbacks) -fexceptions CFLAGS-argp-parse.c = $(uses-callbacks) -CFLAGS-argp-fmtstream.c = -fexceptions +# The following `-fno-strict-aliasing' is of course not a proper fix. +CFLAGS-argp-fmtstream.c = -fexceptions -fno-strict-aliasing include ../Rules If building with GCC 4.1, needed for HEAD, glibc-2_5-branch and glibc-2_3-branch. Produces one warning in `init-first.c' that should be fixed. Reported at <http://savannah.gnu.org/bugs/?17647>. Continued at <http://lists.gnu.org/archive/html/bug-hurd/2006-11/msg00249.html>. Revert Roland patch. (Part of `-r 1.44' to '-r 1.43'). Index: sysdeps/mach/hurd/i386/init-first.c =================================================================== RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/i386/init-first.c,v retrieving revision 1.43.4.1 diff -u -p -r1.43.4.1 init-first.c --- sysdeps/mach/hurd/i386/init-first.c 23 Oct 2005 01:00:09 -0000 1.43.4.1 +++ sysdeps/mach/hurd/i386/init-first.c 20 Nov 2006 11:05:47 -0000 @@ -320,11 +320,11 @@ first_init (void) stack set up just as the user will see it, so it can switch stacks. */ void -_dl_init_first (void) +_dl_init_first (int argc, ...) { first_init (); - init ((int *) __builtin_frame_address (0) + 2); + init (&argc); } #endif @@ -351,23 +351,21 @@ strong_alias (posixland_init, __libc_ini This poorly-named function is called by static-start.S, which should not exist at all. */ void -_hurd_stack_setup (void) +_hurd_stack_setup (volatile int argc, ...) { - intptr_t caller = (intptr_t) __builtin_return_address (0); - void doinit (intptr_t *data) { /* This function gets called with the argument data at TOS. */ - void doinit1 (void) + void doinit1 (volatile int argc, ...) { - init ((int *) __builtin_frame_address (0) + 2); + init ((int *) &argc); } /* Push the user return address after the argument data, and then jump to `doinit1' (above), so it is as if __libc_init_first's caller had called `doinit1' with the argument data already on the stack. */ - *--data = caller; + *--data = (&argc)[-1]; asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack. */ "movl $0, %%ebp\n" /* Clear outermost frame pointer. */ "jmp *%1" : : "r" (data), "r" (&doinit1) : "sp"); @@ -376,7 +374,7 @@ _hurd_stack_setup (void) first_init (); - _hurd_startup ((void **) __builtin_frame_address (0) + 2, &doinit); + _hurd_startup ((void **) &argc, &doinit); } #endif Make the code work with GCC 4.1. This is essentially what Roland had done -- moving the resolution of the return address out of the nested subfunction -- but this time without replacing it with `__builtin_return_address'. Index: sysdeps/mach/hurd/i386/init-first.c =================================================================== RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/i386/init-first.c,v retrieving revision 1.43.4.1 diff -u -p -r1.43.4.1 init-first.c --- sysdeps/mach/hurd/i386/init-first.c 23 Oct 2005 01:00:09 -0000 1.43.4.1 +++ sysdeps/mach/hurd/i386/init-first.c 20 Nov 2006 11:05:47 -0000 @@ -353,6 +355,8 @@ void _hurd_stack_setup (volatile int argc, ...) { + intptr_t caller = (&argc)[-1]; + void doinit (intptr_t *data) { /* This function gets called with the argument data at TOS. */ @@ -365,7 +369,7 @@ jump to `doinit1' (above), so it is as if __libc_init_first's caller had called `doinit1' with the argument data already on the stack. */ - *--data = (&argc)[-1]; + *--data = caller; asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack. */ "movl $0, %%ebp\n" /* Clear outermost frame pointer. */ "jmp *%1" : : "r" (data), "r" (&doinit1) : "sp"); Cosmetical and documentation fixes. Index: sysdeps/mach/hurd/i386/init-first.c =================================================================== RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/i386/init-first.c,v retrieving revision 1.43.4.1 diff -u -p -r1.43.4.1 init-first.c --- sysdeps/mach/hurd/i386/init-first.c 23 Oct 2005 01:00:09 -0000 1.43.4.1 +++ sysdeps/mach/hurd/i386/init-first.c 20 Nov 2006 11:05:47 -0000 @@ -243,8 +243,8 @@ init (int *data) be the return address for `init1'; we will jump there with NEWSP as the stack pointer. */ *--newsp = data[-1]; - ((void **) data)[-1] = switch_stacks; - /* Force NEWSP into %ecx and &init1 into %eax, which are not restored + data[-1] = (int) &switch_stacks; + /* Force NEWSP into %eax and &init1 into %ecx, which are not restored by function return. */ asm volatile ("# a %0 c %1" : : "a" (newsp), "c" (&init1)); } In HEAD, but not yet in glibc-2_5-branch and glibc-2_3-branch. Needed when building with GCC 4.0 (I think) and newer. Reported on <http://savannah.gnu.org/bugs/?17808>. 2006-10-10 Roland McGrath <[EMAIL PROTECTED]> * sysdeps/mach/hurd/utimes.c: Use a union to avoid an improper cast. * sysdeps/mach/hurd/futimes.c: Likewise. * sysdeps/mach/hurd/lutimes.c: Likewise. diff -x CVS -ru sysdeps/mach/hurd/futimes.c ../HEAD/sysdeps/mach/hurd/futimes.c --- sysdeps/mach/hurd/futimes.c 2006-12-18 00:35:54.000000000 +0100 +++ ../HEAD/sysdeps/mach/hurd/futimes.c 2006-10-10 11:28:40.000000000 +0200 @@ -28,20 +28,24 @@ int __futimes (int fd, const struct timeval tvp[2]) { - struct timeval timevals[2]; + union tv + { + struct timeval tv; + time_value_t tvt; + }; + const union tv *u = (const union tv *) tvp; + union tv nulltv[2]; error_t err; if (tvp == NULL) { /* Setting the number of microseconds to `-1' tells the underlying filesystems to use the current time. */ - timevals[1].tv_usec = timevals[0].tv_usec = (time_t)-1; - tvp = timevals; + nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1; + u = nulltv; } - err = HURD_DPORT_USE (fd, __file_utimes (port, - *(time_value_t *) &tvp[0], - *(time_value_t *) &tvp[1])); + err = HURD_DPORT_USE (fd, __file_utimes (port, u[0].tvt, u[1].tvt)); return err ? __hurd_dfail (fd, err) : 0; } weak_alias (__futimes, futimes) diff -x CVS -ru sysdeps/mach/hurd/lutimes.c ../HEAD/sysdeps/mach/hurd/lutimes.c --- sysdeps/mach/hurd/lutimes.c 2006-12-18 00:35:54.000000000 +0100 +++ ../HEAD/sysdeps/mach/hurd/lutimes.c 2006-10-10 11:28:40.000000000 +0200 @@ -28,7 +28,13 @@ int __lutimes (const char *file, const struct timeval tvp[2]) { - struct timeval timevals[2]; + union tv + { + struct timeval tv; + time_value_t tvt; + }; + const union tv *u = (const union tv *) tvp; + union tv nulltv[2]; error_t err; file_t port; @@ -36,15 +42,14 @@ { /* Setting the number of microseconds to `-1' tells the underlying filesystems to use the current time. */ - timevals[1].tv_usec = timevals[0].tv_usec = (time_t)-1; - tvp = timevals; + nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1; + u = nulltv; } port = __file_name_lookup (file, O_NOLINK, 0); if (port == MACH_PORT_NULL) return -1; - err = __file_utimes (port, - *(time_value_t *) &tvp[0], *(time_value_t *) &tvp[1]); + err = __file_utimes (port, u[0].tvt, u[1].tvt); __mach_port_deallocate (__mach_task_self (), port); if (err) return __hurd_fail (err); diff -x CVS -ru sysdeps/mach/hurd/utimes.c ../HEAD/sysdeps/mach/hurd/utimes.c --- sysdeps/mach/hurd/utimes.c 2006-12-18 00:35:54.000000000 +0100 +++ ../HEAD/sysdeps/mach/hurd/utimes.c 2006-10-10 11:28:40.000000000 +0200 @@ -28,7 +29,13 @@ const char *file; const struct timeval tvp[2]; { - struct timeval timevals[2]; + union tv + { + struct timeval tv; + time_value_t tvt; + }; + const union tv *u = (const union tv *) tvp; + union tv nulltv[2]; error_t err; file_t port; @@ -36,19 +43,17 @@ { /* Setting the number of microseconds to `-1' tells the underlying filesystems to use the current time. */ - timevals[1].tv_usec = timevals[0].tv_usec = (time_t)-1; - tvp = timevals; + nulltv[0].tvt.microseconds = nulltv[1].tvt.microseconds = -1; + u = nulltv; } port = __file_name_lookup (file, 0, 0); if (port == MACH_PORT_NULL) return -1; - err = __file_utimes (port, - *(time_value_t *) &tvp[0], *(time_value_t *) &tvp[1]); + err = __file_utimes (port, u[0].tvt, u[1].tvt); __mach_port_deallocate (__mach_task_self (), port); if (err) return __hurd_fail (err); return 0; } - weak_alias (__utimes, utimes) Regards, Thomas
signature.asc
Description: Digital signature