patches/glibc/2.3.2/glibc-2.3.2-mips-user.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Feb 24 11:00:05 2007 +0000 (2007-02-24)
changeset 1 eeea35fbf182
permissions -rw-r--r--
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!".
Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup.
That means I'm putting backups in place in the afternoon.
That also means we've lost history... :-(
yann@1
     1
Retrieved from
yann@1
     2
http://sources.redhat.com/cgi-bin/get-raw-msg?listname=libc-alpha&date=2003-04&msgid=orfzoof4j0.fsf%40free.redhat.lsd.ic.unicamp.br
yann@1
     3
paths adjusted, and rediffed against glibc-2.3.2
yann@1
     4
(i.e. to compensate for fact that
yann@1
     5
http://sources.redhat.com/ml/glibc-cvs/2003-q1/msg01155.html
yann@1
     6
is not present)
yann@1
     7
yann@1
     8
Should fix
yann@1
     9
yann@1
    10
In file included from ../sysdeps/unix/sysv/linux/mips/sys/procfs.h:29,
yann@1
    11
                 from ../linuxthreads_db/proc_service.h:20,
yann@1
    12
                 from ../linuxthreads_db/thread_dbP.h:7,
yann@1
    13
                 from ../linuxthreads/descr.h:43,
yann@1
    14
                 from ../linuxthreads/internals.h:29,
yann@1
    15
                 from ../linuxthreads/sysdeps/pthread/bits/libc-lock.h:27,
yann@1
    16
                 from ../sysdeps/generic/ldsodefs.h:38,
yann@1
    17
                 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
yann@1
    18
                 from ../sysdeps/mips/elf/ldsodefs.h:25,
yann@1
    19
                 from ../sysdeps/unix/sysv/linux/init-first.c:30:
yann@1
    20
../sysdeps/unix/sysv/linux/mips/sys/user.h:26:21: asm/reg.h: No such file or directory
yann@1
    21
In file included from ../sysdeps/unix/sysv/linux/mips/sys/procfs.h:29,
yann@1
    22
                 from ../linuxthreads_db/proc_service.h:20,
yann@1
    23
                 from ../linuxthreads_db/thread_dbP.h:7,
yann@1
    24
                 from ../linuxthreads/descr.h:43,
yann@1
    25
                 from ../linuxthreads/internals.h:29,
yann@1
    26
                 from ../linuxthreads/sysdeps/pthread/bits/libc-lock.h:27,
yann@1
    27
                 from ../sysdeps/generic/ldsodefs.h:38,
yann@1
    28
                 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
yann@1
    29
                 from ../sysdeps/mips/elf/ldsodefs.h:25,
yann@1
    30
                 from ../sysdeps/unix/sysv/linux/init-first.c:30:
yann@1
    31
../sysdeps/unix/sysv/linux/mips/sys/user.h:30: error: `EF_SIZE' undeclared here (not in a function)
yann@1
    32
make[2]: *** [mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/csu/init-first.o] Error 1
yann@1
    33
make[2]: Leaving directory `mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/glibc-2.3.2/csu'
yann@1
    34
make[1]: *** [csu/subdir_lib] Error 2
yann@1
    35
make[1]: Leaving directory `mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/glibc-2.3.2'
yann@1
    36
make: *** [all] Error 2
yann@1
    37
yann@1
    38
From libc-alpha-return-12105-listarch-libc-alpha=sources dot redhat dot com at sources dot redhat dot com Sat Apr 12 09:28:56 2003
yann@1
    39
Return-Path: <libc-alpha-return-12105-listarch-libc-alpha=sources dot redhat dot com at sources dot redhat dot com>
yann@1
    40
Delivered-To: listarch-libc-alpha at sources dot redhat dot com
yann@1
    41
Received: (qmail 2802 invoked by alias); 12 Apr 2003 09:28:56 -0000
yann@1
    42
Mailing-List: contact libc-alpha-help at sources dot redhat dot com; run by ezmlm
yann@1
    43
Precedence: bulk
yann@1
    44
List-Subscribe: <mailto:libc-alpha-subscribe at sources dot redhat dot com>
yann@1
    45
List-Archive: <http://sources.redhat.com/ml/libc-alpha/>
yann@1
    46
List-Post: <mailto:libc-alpha at sources dot redhat dot com>
yann@1
    47
List-Help: <mailto:libc-alpha-help at sources dot redhat dot com>, <http://sources dot redhat dot com/ml/#faqs>
yann@1
    48
Sender: libc-alpha-owner at sources dot redhat dot com
yann@1
    49
Delivered-To: mailing list libc-alpha at sources dot redhat dot com
yann@1
    50
Received: (qmail 2795 invoked from network); 12 Apr 2003 09:28:55 -0000
yann@1
    51
Received: from unknown (HELO lacrosse.corp.redhat.com) (66.187.233.200)
yann@1
    52
  by sources dot redhat dot com with SMTP; 12 Apr 2003 09:28:55 -0000
yann@1
    53
Received: from free.redhat.lsd.ic.unicamp.br (aoliva.cipe.redhat.com [10.0.1.10])
yann@1
    54
	by lacrosse dot corp dot redhat dot com (8 dot 11 dot 6/8 dot 9 dot 3) with ESMTP id h3C9SqV01131
yann@1
    55
	for <libc-alpha at sources dot redhat dot com>; Sat, 12 Apr 2003 05:28:52 -0400
yann@1
    56
Received: from free.redhat.lsd.ic.unicamp.br (free.redhat.lsd.ic.unicamp.br [127.0.0.1])
yann@1
    57
	by free dot redhat dot lsd dot ic dot unicamp dot br (8 dot 12 dot 8/8 dot 12 dot 8) with ESMTP id h3C9SpVT028734
yann@1
    58
	for <libc-alpha at sources dot redhat dot com>; Sat, 12 Apr 2003 06:28:51 -0300
yann@1
    59
Received: (from aoliva@localhost)
yann@1
    60
	by free dot redhat dot lsd dot ic dot unicamp dot br (8 dot 12 dot 8/8 dot 12 dot 8/Submit) id h3C9SpFb028730;
yann@1
    61
	Sat, 12 Apr 2003 06:28:51 -0300
yann@1
    62
To: libc-alpha at sources dot redhat dot com
yann@1
    63
Subject: signal-handling tweaks for mips/mips64
yann@1
    64
From: Alexandre Oliva <aoliva at redhat dot com>
yann@1
    65
Organization: GCC Team, Red Hat
yann@1
    66
Date: 12 Apr 2003 06:28:51 -0300
yann@1
    67
Message-ID: <orfzoof4j0.fsf@free.redhat.lsd.ic.unicamp.br>
yann@1
    68
Lines: 49
yann@1
    69
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
yann@1
    70
MIME-Version: 1.0
yann@1
    71
Content-Type: multipart/mixed; boundary="=-=-="
yann@1
    72
yann@1
    73
--=-=-=
yann@1
    74
yann@1
    75
It was reported to me that ucontext is utterly broken, even in o32
yann@1
    76
with a stable 32-bit mips kernel.  Indeed, it doesn't match the
yann@1
    77
ucontext structure defined by the kernel at all.  This means that
yann@1
    78
programs taking real-time signals in o32 won't be able to extract
yann@1
    79
correct information from the mcontext_t, since the kernel puts data in
yann@1
    80
there that's in an entirely different format.
yann@1
    81
yann@1
    82
I've looked for any ways in which the current data structures could
yann@1
    83
possibly be useful, and didn't find any.  gdb and rda thought they
yann@1
    84
were using the register arrays, but it turned out they were using the
yann@1
    85
arrays in procps instead.  makecontext(), [sg]etcontext() et al aren't
yann@1
    86
implemented on mips, so any uses thereof will just return ENOSYS,
yann@1
    87
without messing with the given data structure.  So, I believe it is
yann@1
    88
not too late for us to fix it such that it matches the kernel data
yann@1
    89
structures.
yann@1
    90
yann@1
    91
While at that, I fixed a number of incompatibilities introduced by
yann@1
    92
either differences between kernel headers that we used to include,
yann@1
    93
whose contents are different depending on whether asm points to
yann@1
    94
asm-mips or asm-mips64.
yann@1
    95
yann@1
    96
With this patch, after some pending kernel patches are checked in, one
yann@1
    97
will be able to obtain the correct information from signal handlers in
yann@1
    98
all mips ABIs.  With n64, this is already true.  With o32, it works
yann@1
    99
with the 32-bit mips kernel, but the mips64 kernel needs a patch to
yann@1
   100
implement the proper sigcontext ABI.  n32 still a patch to be
yann@1
   101
developed for it to be possible for ucontext to be POSIX-compliant.
yann@1
   102
Currently, the kernel uses the same ucontext for n32 and n64, but this
yann@1
   103
doesn't work in n32 because uc_link must be a pointer and stack_t must
yann@1
   104
contain a pointer and a size_t, whose sizes differ between n32 and
yann@1
   105
n64.  I believe Ralf is working on a patch for the kernel to generate
yann@1
   106
n32-compliant ucontext when invoking signal handlers in n32 processes.
yann@1
   107
The only uncertainty is whether uc_flags will be a 32- or 64-bit value
yann@1
   108
in n32; I left it as the latter, just because I already had that in
yann@1
   109
place; if it changes, a (simplifying) follow-up patch will be posted.
yann@1
   110
However, I wanted to circulate the idea of fixing ucontext_t for o32
yann@1
   111
as soon as possible, so I didn't wait for a decision on the exact n32
yann@1
   112
ABI.
yann@1
   113
yann@1
   114
Ok to install?
yann@1
   115
yann@1
   116
yann@1
   117
--=-=-=
yann@1
   118
Content-Type: text/x-patch
yann@1
   119
Content-Disposition: inline; filename=mips-sigstuff.patch
yann@1
   120
yann@1
   121
Index: ChangeLog
yann@1
   122
from  Alexandre Oliva  <aoliva@redhat.com>
yann@1
   123
yann@1
   124
	* sysdeps/unix/sysv/linux/mips/profil-counter: New.
yann@1
   125
	* sysdeps/unix/sysv/linux/mips/sigcontextinfo.h: Port to n32/n64.
yann@1
   126
	* sysdeps/unix/sysv/linux/mips/bits/sigcontext.h: New.
yann@1
   127
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Port to n32/n64.
yann@1
   128
	(mcontext_t): Make it match the 32-bit mips kernel in o32.
yann@1
   129
	* sysdeps/unix/sysv/linux/mips/sys/user.h: Bring in constants from
yann@1
   130
	the mips and mips64 headers.
yann@1
   131
	(struct user): Port to n32/n64.
yann@1
   132
yann@1
   133
Index: sysdeps/unix/sysv/linux/mips/profil-counter.h
yann@1
   134
===================================================================
yann@1
   135
RCS file: sysdeps/unix/sysv/linux/mips/profil-counter.h
yann@1
   136
diff -N sysdeps/unix/sysv/linux/mips/profil-counter.h
yann@1
   137
--- /dev/null	1 Jan 1970 00:00:00 -0000
yann@1
   138
+++ libc/sysdeps/unix/sysv/linux/mips/profil-counter.h 12 Apr 2003 09:13:13 -0000
yann@1
   139
@@ -0,0 +1,2 @@
yann@1
   140
+/* We can use the ix86 version.  */
yann@1
   141
+#include <sysdeps/unix/sysv/linux/i386/profil-counter.h>
yann@1
   142
Index: sysdeps/unix/sysv/linux/mips/sigcontextinfo.h
yann@1
   143
===================================================================
yann@1
   144
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h,v
yann@1
   145
retrieving revision 1.6
yann@1
   146
diff -u -p -r1.6 sigcontextinfo.h
yann@1
   147
--- libc/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h 6 Jul 2001 04:56:18 -0000 1.6
yann@1
   148
+++ libc/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h 12 Apr 2003 09:13:13 -0000
yann@1
   149
@@ -1,4 +1,4 @@
yann@1
   150
-/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
yann@1
   151
+/* Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
yann@1
   152
    This file is part of the GNU C Library.
yann@1
   153
    Contributed by Andreas Jaeger <aj@suse.de>, 2000.
yann@1
   154
 
yann@1
   155
@@ -18,6 +18,8 @@
yann@1
   156
    02111-1307 USA.  */
yann@1
   157
 
yann@1
   158
 
yann@1
   159
+#if _MIPS_SIM == _MIPS_SIM_ABI32
yann@1
   160
+
yann@1
   161
 #define SIGCONTEXT unsigned long _code, struct sigcontext *
yann@1
   162
 #define SIGCONTEXT_EXTRA_ARGS _code,
yann@1
   163
 #define GET_PC(ctx)	((void *) ctx->sc_pc)
yann@1
   164
@@ -25,3 +27,15 @@
yann@1
   165
 #define GET_STACK(ctx)	((void *) ctx->sc_regs[29])
yann@1
   166
 #define CALL_SIGHANDLER(handler, signo, ctx) \
yann@1
   167
   (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
yann@1
   168
+
yann@1
   169
+#else
yann@1
   170
+
yann@1
   171
+#define SIGCONTEXT unsigned long _code, ucontext_t *
yann@1
   172
+#define SIGCONTEXT_EXTRA_ARGS _code,
yann@1
   173
+#define GET_PC(ctx)	((void *) ctx->uc_mcontext.pc)
yann@1
   174
+#define GET_FRAME(ctx)	((void *) ctx->uc_mcontext.gregs[30])
yann@1
   175
+#define GET_STACK(ctx)	((void *) ctx->uc_mcontext.gregs[29])
yann@1
   176
+#define CALL_SIGHANDLER(handler, signo, ctx) \
yann@1
   177
+  (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
yann@1
   178
+
yann@1
   179
+#endif
yann@1
   180
Index: sysdeps/unix/sysv/linux/mips/bits/sigcontext.h
yann@1
   181
===================================================================
yann@1
   182
RCS file: sysdeps/unix/sysv/linux/mips/bits/sigcontext.h
yann@1
   183
diff -N sysdeps/unix/sysv/linux/mips/bits/sigcontext.h
yann@1
   184
--- /dev/null	1 Jan 1970 00:00:00 -0000
yann@1
   185
+++ libc/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h 12 Apr 2003 09:13:13 -0000
yann@1
   186
@@ -0,0 +1,103 @@
yann@1
   187
+/* Copyright (C) 1996, 1997, 1998, 2003 Free Software Foundation, Inc.
yann@1
   188
+   This file is part of the GNU C Library.
yann@1
   189
+
yann@1
   190
+   The GNU C Library is free software; you can redistribute it and/or
yann@1
   191
+   modify it under the terms of the GNU Lesser General Public
yann@1
   192
+   License as published by the Free Software Foundation; either
yann@1
   193
+   version 2.1 of the License, or (at your option) any later version.
yann@1
   194
+
yann@1
   195
+   The GNU C Library is distributed in the hope that it will be useful,
yann@1
   196
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
yann@1
   197
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
yann@1
   198
+   Lesser General Public License for more details.
yann@1
   199
+
yann@1
   200
+   You should have received a copy of the GNU Lesser General Public
yann@1
   201
+   License along with the GNU C Library; if not, write to the Free
yann@1
   202
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
yann@1
   203
+   02111-1307 USA.  */
yann@1
   204
+
yann@1
   205
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
yann@1
   206
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
yann@1
   207
+#endif
yann@1
   208
+
yann@1
   209
+#ifndef sigcontext_struct
yann@1
   210
+/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but
yann@1
   211
+   we need sigcontext.  */
yann@1
   212
+# define sigcontext_struct sigcontext
yann@1
   213
+
yann@1
   214
+/* # include <asm/sigcontext.h> */
yann@1
   215
+/* Instead of including the kernel header, that will vary depending on
yann@1
   216
+   whether the 32- or the 64-bit kernel is installed, we paste the
yann@1
   217
+   contents here.  In case you're wondering about the different
yann@1
   218
+   licenses, the fact that the file is pasted, instead of included,
yann@1
   219
+   doesn't really make any difference for the program that includes
yann@1
   220
+   this header.  */
yann@1
   221
+#if _MIPS_SIM == _MIPS_SIM_ABI32
yann@1
   222
+/*
yann@1
   223
+ * This file is subject to the terms and conditions of the GNU General Public
yann@1
   224
+ * License.  See the file "COPYING" in the main directory of this archive
yann@1
   225
+ * for more details.
yann@1
   226
+ *
yann@1
   227
+ * Copyright (C) 1996, 1997, 2000 by Ralf Baechle
yann@1
   228
+ */
yann@1
   229
+#ifndef _ASM_SIGCONTEXT_H
yann@1
   230
+#define _ASM_SIGCONTEXT_H
yann@1
   231
+
yann@1
   232
+/*
yann@1
   233
+ * Keep this struct definition in sync with the sigcontext fragment
yann@1
   234
+ * in arch/mips/tools/offset.c
yann@1
   235
+ */
yann@1
   236
+struct sigcontext {
yann@1
   237
+	unsigned int       sc_regmask;		/* Unused */
yann@1
   238
+	unsigned int       sc_status;
yann@1
   239
+	unsigned long long sc_pc;
yann@1
   240
+	unsigned long long sc_regs[32];
yann@1
   241
+	unsigned long long sc_fpregs[32];
yann@1
   242
+	unsigned int       sc_ownedfp;		/* Unused */
yann@1
   243
+	unsigned int       sc_fpc_csr;
yann@1
   244
+	unsigned int       sc_fpc_eir;		/* Unused */
yann@1
   245
+	unsigned int       sc_used_math;
yann@1
   246
+	unsigned int       sc_ssflags;		/* Unused */
yann@1
   247
+	unsigned long long sc_mdhi;
yann@1
   248
+	unsigned long long sc_mdlo;
yann@1
   249
+
yann@1
   250
+	unsigned int       sc_cause;		/* Unused */
yann@1
   251
+	unsigned int       sc_badvaddr;		/* Unused */
yann@1
   252
+
yann@1
   253
+	unsigned long      sc_sigset[4];	/* kernel's sigset_t */
yann@1
   254
+};
yann@1
   255
+
yann@1
   256
+#endif /* _ASM_SIGCONTEXT_H */
yann@1
   257
+#else /* _MIPS_SIM != _MIPS_SIM_ABI32 */
yann@1
   258
+/*
yann@1
   259
+ * This file is subject to the terms and conditions of the GNU General Public
yann@1
   260
+ * License.  See the file "COPYING" in the main directory of this archive
yann@1
   261
+ * for more details.
yann@1
   262
+ *
yann@1
   263
+ * Copyright (C) 1996, 1997, 1999 by Ralf Baechle
yann@1
   264
+ * Copyright (C) 1999 Silicon Graphics, Inc.
yann@1
   265
+ */
yann@1
   266
+#ifndef _ASM_SIGCONTEXT_H
yann@1
   267
+#define _ASM_SIGCONTEXT_H
yann@1
   268
+
yann@1
   269
+/*
yann@1
   270
+ * Keep this struct definition in sync with the sigcontext fragment
yann@1
   271
+ * in arch/mips/tools/offset.c
yann@1
   272
+ */
yann@1
   273
+struct sigcontext {
yann@1
   274
+	unsigned long long sc_regs[32];
yann@1
   275
+	unsigned long long sc_fpregs[32];
yann@1
   276
+	unsigned long long sc_mdhi;
yann@1
   277
+	unsigned long long sc_mdlo;
yann@1
   278
+	unsigned long long sc_pc;
yann@1
   279
+	unsigned int       sc_status;
yann@1
   280
+	unsigned int       sc_fpc_csr;
yann@1
   281
+	unsigned int       sc_fpc_eir;
yann@1
   282
+	unsigned int       sc_used_math;
yann@1
   283
+	unsigned int       sc_cause;
yann@1
   284
+	unsigned int       sc_badvaddr;
yann@1
   285
+};
yann@1
   286
+
yann@1
   287
+#endif /* _ASM_SIGCONTEXT_H */
yann@1
   288
+#endif /* _MIPS_SIM != _MIPS_SIM_ABI32 */
yann@1
   289
+#endif
yann@1
   290
[hunk deleted, see below]
yann@1
   291
Index: sysdeps/unix/sysv/linux/mips/sys/user.h
yann@1
   292
===================================================================
yann@1
   293
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/sys/user.h,v
yann@1
   294
retrieving revision 1.1
yann@1
   295
diff -u -p -r1.1 user.h
yann@1
   296
--- libc/sysdeps/unix/sysv/linux/mips/sys/user.h 8 Feb 2002 16:21:00 -0000 1.1
yann@1
   297
+++ libc/sysdeps/unix/sysv/linux/mips/sys/user.h 12 Apr 2003 09:13:13 -0000
yann@1
   298
@@ -1,4 +1,4 @@
yann@1
   299
-/* Copyright (C) 2002 Free Software Foundation, Inc.
yann@1
   300
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
yann@1
   301
    This file is part of the GNU C Library.
yann@1
   302
 
yann@1
   303
    The GNU C Library is free software; you can redistribute it and/or
yann@1
   304
@@ -23,7 +23,154 @@
yann@1
   305
    too much into it.  Don't use it for anything other than GDB unless
yann@1
   306
    you know what you are doing.  */
yann@1
   307
 
yann@1
   308
-#include <asm/reg.h>
yann@1
   309
+/* #include <asm/reg.h> */
yann@1
   310
+/* Instead of including the kernel header, that will vary depending on
yann@1
   311
+   whether the 32- or the 64-bit kernel is installed, we paste its
yann@1
   312
+   contents here.  Note that the fact that the file is inline here,
yann@1
   313
+   instead of included separately, doesn't change in any way the
yann@1
   314
+   licensing status of a program that includes user.h.  Since this is
yann@1
   315
+   for gdb alone, and gdb is GPLed, no surprises here.  */
yann@1
   316
+#if _MIPS_SIM == _MIPS_SIM_ABI32
yann@1
   317
+/*
yann@1
   318
+ * Various register offset definitions for debuggers, core file
yann@1
   319
+ * examiners and whatnot.
yann@1
   320
+ *
yann@1
   321
+ * This file is subject to the terms and conditions of the GNU General Public
yann@1
   322
+ * License.  See the file "COPYING" in the main directory of this archive
yann@1
   323
+ * for more details.
yann@1
   324
+ *
yann@1
   325
+ * Copyright (C) 1995, 1999 by Ralf Baechle
yann@1
   326
+ */
yann@1
   327
+#ifndef __ASM_MIPS_REG_H
yann@1
   328
+#define __ASM_MIPS_REG_H
yann@1
   329
+
yann@1
   330
+/*
yann@1
   331
+ * This defines/structures correspond to the register layout on stack -
yann@1
   332
+ * if the order here is changed, it needs to be updated in
yann@1
   333
+ * include/asm-mips/stackframe.h
yann@1
   334
+ */
yann@1
   335
+#define EF_REG0			6
yann@1
   336
+#define EF_REG1			7
yann@1
   337
+#define EF_REG2			8
yann@1
   338
+#define EF_REG3			9
yann@1
   339
+#define EF_REG4			10
yann@1
   340
+#define EF_REG5			11
yann@1
   341
+#define EF_REG6			12
yann@1
   342
+#define EF_REG7			13
yann@1
   343
+#define EF_REG8			14
yann@1
   344
+#define EF_REG9			15
yann@1
   345
+#define EF_REG10		16
yann@1
   346
+#define EF_REG11		17
yann@1
   347
+#define EF_REG12		18
yann@1
   348
+#define EF_REG13		19
yann@1
   349
+#define EF_REG14		20
yann@1
   350
+#define EF_REG15		21
yann@1
   351
+#define EF_REG16		22
yann@1
   352
+#define EF_REG17		23
yann@1
   353
+#define EF_REG18		24
yann@1
   354
+#define EF_REG19		25
yann@1
   355
+#define EF_REG20		26
yann@1
   356
+#define EF_REG21		27
yann@1
   357
+#define EF_REG22		28
yann@1
   358
+#define EF_REG23		29
yann@1
   359
+#define EF_REG24		30
yann@1
   360
+#define EF_REG25		31
yann@1
   361
+/*
yann@1
   362
+ * k0/k1 unsaved
yann@1
   363
+ */
yann@1
   364
+#define EF_REG28		34
yann@1
   365
+#define EF_REG29		35
yann@1
   366
+#define EF_REG30		36
yann@1
   367
+#define EF_REG31		37
yann@1
   368
+
yann@1
   369
+/*
yann@1
   370
+ * Saved special registers
yann@1
   371
+ */
yann@1
   372
+#define EF_LO			38
yann@1
   373
+#define EF_HI			39
yann@1
   374
+
yann@1
   375
+#define EF_CP0_EPC		40
yann@1
   376
+#define EF_CP0_BADVADDR		41
yann@1
   377
+#define EF_CP0_STATUS		42
yann@1
   378
+#define EF_CP0_CAUSE		43
yann@1
   379
+
yann@1
   380
+#define EF_SIZE			180	/* size in bytes */
yann@1
   381
+
yann@1
   382
+#endif /* __ASM_MIPS_REG_H */
yann@1
   383
+
yann@1
   384
+#else /* _MIPS_SIM != _MIPS_SIM_ABI32 */
yann@1
   385
+
yann@1
   386
+/*
yann@1
   387
+ * Various register offset definitions for debuggers, core file
yann@1
   388
+ * examiners and whatnot.
yann@1
   389
+ *
yann@1
   390
+ * This file is subject to the terms and conditions of the GNU General Public
yann@1
   391
+ * License.  See the file "COPYING" in the main directory of this archive
yann@1
   392
+ * for more details.
yann@1
   393
+ *
yann@1
   394
+ * Copyright (C) 1995, 1999 Ralf Baechle
yann@1
   395
+ * Copyright (C) 1995, 1999 Silicon Graphics
yann@1
   396
+ */
yann@1
   397
+#ifndef _ASM_REG_H
yann@1
   398
+#define _ASM_REG_H
yann@1
   399
+
yann@1
   400
+/*
yann@1
   401
+ * This defines/structures correspond to the register layout on stack -
yann@1
   402
+ * if the order here is changed, it needs to be updated in
yann@1
   403
+ * include/asm-mips/stackframe.h
yann@1
   404
+ */
yann@1
   405
+#define EF_REG0			 0
yann@1
   406
+#define EF_REG1			 1
yann@1
   407
+#define EF_REG2			 2
yann@1
   408
+#define EF_REG3			 3
yann@1
   409
+#define EF_REG4			 4
yann@1
   410
+#define EF_REG5			 5
yann@1
   411
+#define EF_REG6			 6
yann@1
   412
+#define EF_REG7			 7
yann@1
   413
+#define EF_REG8			 8
yann@1
   414
+#define EF_REG9			 9
yann@1
   415
+#define EF_REG10		10
yann@1
   416
+#define EF_REG11		11
yann@1
   417
+#define EF_REG12		12
yann@1
   418
+#define EF_REG13		13
yann@1
   419
+#define EF_REG14		14
yann@1
   420
+#define EF_REG15		15
yann@1
   421
+#define EF_REG16		16
yann@1
   422
+#define EF_REG17		17
yann@1
   423
+#define EF_REG18		18
yann@1
   424
+#define EF_REG19		19
yann@1
   425
+#define EF_REG20		20
yann@1
   426
+#define EF_REG21		21
yann@1
   427
+#define EF_REG22		22
yann@1
   428
+#define EF_REG23		23
yann@1
   429
+#define EF_REG24		24
yann@1
   430
+#define EF_REG25		25
yann@1
   431
+/*
yann@1
   432
+ * k0/k1 unsaved
yann@1
   433
+ */
yann@1
   434
+#define EF_REG28		28
yann@1
   435
+#define EF_REG29		29
yann@1
   436
+#define EF_REG30		30
yann@1
   437
+#define EF_REG31		31
yann@1
   438
+
yann@1
   439
+/*
yann@1
   440
+ * Saved special registers
yann@1
   441
+ */
yann@1
   442
+#define EF_LO			32
yann@1
   443
+#define EF_HI			33
yann@1
   444
+
yann@1
   445
+#define EF_CP0_EPC		34
yann@1
   446
+#define EF_CP0_BADVADDR		35
yann@1
   447
+#define EF_CP0_STATUS		36
yann@1
   448
+#define EF_CP0_CAUSE		37
yann@1
   449
+
yann@1
   450
+#define EF_SIZE			304	/* size in bytes */
yann@1
   451
+
yann@1
   452
+#endif /* _ASM_REG_H */
yann@1
   453
+
yann@1
   454
+#endif /* _MIPS_SIM != _MIPS_SIM_ABI32 */
yann@1
   455
+
yann@1
   456
+#if _MIPS_SIM == _MIPS_SIM_ABI32
yann@1
   457
 
yann@1
   458
 struct user
yann@1
   459
 {
yann@1
   460
@@ -39,6 +186,24 @@ struct user
yann@1
   461
   unsigned long	magic;			/* identifies a core file */
yann@1
   462
   char		u_comm[32];		/* user command name */
yann@1
   463
 };
yann@1
   464
+
yann@1
   465
+#else
yann@1
   466
+
yann@1
   467
+struct user {
yann@1
   468
+  __extension__ unsigned long	regs[EF_SIZE/8+64]; /* integer and fp regs */
yann@1
   469
+  __extension__ unsigned long	u_tsize;	/* text size (pages) */
yann@1
   470
+  __extension__ unsigned long	u_dsize;	/* data size (pages) */
yann@1
   471
+  __extension__ unsigned long	u_ssize;	/* stack size (pages) */
yann@1
   472
+  __extension__ unsigned long long start_code;	/* text starting address */
yann@1
   473
+  __extension__ unsigned long long start_data;	/* data starting address */
yann@1
   474
+  __extension__ unsigned long long start_stack;	/* stack starting address */
yann@1
   475
+  __extension__ long long	signal;		/* signal causing core dump */
yann@1
   476
+  __extension__ unsigned long long u_ar0;	/* help gdb find registers */
yann@1
   477
+  __extension__ unsigned long long magic;	/* identifies a core file */
yann@1
   478
+  char		u_comm[32];		/* user command name */
yann@1
   479
+};
yann@1
   480
+
yann@1
   481
+#endif
yann@1
   482
 
yann@1
   483
 #define PAGE_SHIFT		12
yann@1
   484
 #define PAGE_SIZE		(1UL << PAGE_SHIFT)
yann@1
   485
yann@1
   486
--=-=-=
yann@1
   487
yann@1
   488
yann@1
   489
-- 
yann@1
   490
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
yann@1
   491
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
yann@1
   492
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
yann@1
   493
Free Software Evangelist                Professional serial bug killer
yann@1
   494
yann@1
   495
--=-=-=--
yann@1
   496
yann@1
   497
And the rediffed hunk:
yann@1
   498
yann@1
   499
--- glibc-2.3.2/sysdeps/unix/sysv/linux/mips/sys/ucontext.h.old	2004-05-30 07:23:32.000000000 -0700
yann@1
   500
+++ glibc-2.3.2/sysdeps/unix/sysv/linux/mips/sys/ucontext.h	2004-05-30 07:22:56.000000000 -0700
yann@1
   501
@@ -29,43 +29,72 @@
yann@1
   502
 #include <bits/sigcontext.h>
yann@1
   503
 
yann@1
   504
 
yann@1
   505
-/* Type for general register.  */
yann@1
   506
-typedef unsigned long int greg_t;
yann@1
   507
+/* Type for general register.  Even in o32 we assume 64-bit registers,
yann@1
   508
+   like the kernel.  */
yann@1
   509
+__extension__ typedef unsigned long long int greg_t;
yann@1
   510
 
yann@1
   511
 /* Number of general registers.  */
yann@1
   512
-#define NGREG	37
yann@1
   513
-#define NFPREG	33
yann@1
   514
+#define NGREG	32
yann@1
   515
+#define NFPREG	32
yann@1
   516
 
yann@1
   517
 /* Container for all general registers.  */
yann@1
   518
-/* gregset_t must be an array.  The below declared array corresponds to:
yann@1
   519
-typedef struct gregset {
yann@1
   520
-	greg_t	g_regs[32];
yann@1
   521
-	greg_t	g_hi;
yann@1
   522
-	greg_t	g_lo;
yann@1
   523
-	greg_t	g_pad[3];
yann@1
   524
-} gregset_t;  */
yann@1
   525
 typedef greg_t gregset_t[NGREG];
yann@1
   526
 
yann@1
   527
 /* Container for all FPU registers.  */
yann@1
   528
 typedef struct fpregset {
yann@1
   529
 	union {
yann@1
   530
-		double	fp_dregs[32];
yann@1
   531
+		double	fp_dregs[NFPREG];
yann@1
   532
 		struct {
yann@1
   533
 			float		_fp_fregs;
yann@1
   534
 			unsigned int	_fp_pad;
yann@1
   535
-		} fp_fregs[32];
yann@1
   536
+		} fp_fregs[NFPREG];
yann@1
   537
 	} fp_r;
yann@1
   538
-	unsigned int	fp_csr;
yann@1
   539
-	unsigned int	fp_pad;
yann@1
   540
 } fpregset_t;
yann@1
   541
 
yann@1
   542
 
yann@1
   543
 /* Context to describe whole processor state.  */
yann@1
   544
+#if _MIPS_SIM == _MIPS_SIM_ABI32
yann@1
   545
+/* Earlier versions of glibc for mips had an entirely different
yann@1
   546
+   definition of mcontext_t, that didn't even resemble the
yann@1
   547
+   corresponding kernel data structure.  Since all legitimate uses of
yann@1
   548
+   ucontext_t in glibc mustn't have accessed anything beyond
yann@1
   549
+   uc_mcontext and, even then, taking a pointer to it, casting it to
yann@1
   550
+   sigcontext_t, and accessing it as such, which is what it has always
yann@1
   551
+   been, this can still be rectified.  Fortunately, makecontext,
yann@1
   552
+   [gs]etcontext et all have never been implemented.  */
yann@1
   553
 typedef struct
yann@1
   554
   {
yann@1
   555
+    unsigned int regmask;
yann@1
   556
+    unsigned int status;
yann@1
   557
+    greg_t pc;
yann@1
   558
     gregset_t gregs;
yann@1
   559
     fpregset_t fpregs;
yann@1
   560
+    unsigned int fp_owned;
yann@1
   561
+    unsigned int fpc_csr;
yann@1
   562
+    unsigned int fpc_eir;
yann@1
   563
+    unsigned int used_math;
yann@1
   564
+    unsigned int ssflags;
yann@1
   565
+    greg_t mdhi;
yann@1
   566
+    greg_t mdlo;
yann@1
   567
+    unsigned int cause;
yann@1
   568
+    unsigned int badvaddr;
yann@1
   569
   } mcontext_t;
yann@1
   570
+#else
yann@1
   571
+typedef struct
yann@1
   572
+  {
yann@1
   573
+    gregset_t gregs;
yann@1
   574
+    fpregset_t fpregs;
yann@1
   575
+    greg_t mdhi;
yann@1
   576
+    greg_t mdlo;
yann@1
   577
+    greg_t pc;
yann@1
   578
+    unsigned int status;
yann@1
   579
+    unsigned int fpc_csr;
yann@1
   580
+    unsigned int fpc_eir;
yann@1
   581
+    unsigned int used_math;
yann@1
   582
+    unsigned int cause;
yann@1
   583
+    unsigned int badvaddr;
yann@1
   584
+  } mcontext_t;
yann@1
   585
+#endif
yann@1
   586
 
yann@1
   587
 /* Userlevel context.  */
yann@1
   588
 typedef struct ucontext