Update the i586-geode-linux-uclibc sample.
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
3 paths adjusted, and rediffed against glibc-2.3.2
4 (i.e. to compensate for fact that
5 http://sources.redhat.com/ml/glibc-cvs/2003-q1/msg01155.html
10 In file included from ../sysdeps/unix/sysv/linux/mips/sys/procfs.h:29,
11 from ../linuxthreads_db/proc_service.h:20,
12 from ../linuxthreads_db/thread_dbP.h:7,
13 from ../linuxthreads/descr.h:43,
14 from ../linuxthreads/internals.h:29,
15 from ../linuxthreads/sysdeps/pthread/bits/libc-lock.h:27,
16 from ../sysdeps/generic/ldsodefs.h:38,
17 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
18 from ../sysdeps/mips/elf/ldsodefs.h:25,
19 from ../sysdeps/unix/sysv/linux/init-first.c:30:
20 ../sysdeps/unix/sysv/linux/mips/sys/user.h:26:21: asm/reg.h: No such file or directory
21 In file included from ../sysdeps/unix/sysv/linux/mips/sys/procfs.h:29,
22 from ../linuxthreads_db/proc_service.h:20,
23 from ../linuxthreads_db/thread_dbP.h:7,
24 from ../linuxthreads/descr.h:43,
25 from ../linuxthreads/internals.h:29,
26 from ../linuxthreads/sysdeps/pthread/bits/libc-lock.h:27,
27 from ../sysdeps/generic/ldsodefs.h:38,
28 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
29 from ../sysdeps/mips/elf/ldsodefs.h:25,
30 from ../sysdeps/unix/sysv/linux/init-first.c:30:
31 ../sysdeps/unix/sysv/linux/mips/sys/user.h:30: error: `EF_SIZE' undeclared here (not in a function)
32 make[2]: *** [mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/csu/init-first.o] Error 1
33 make[2]: Leaving directory `mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/glibc-2.3.2/csu'
34 make[1]: *** [csu/subdir_lib] Error 2
35 make[1]: Leaving directory `mipsel-unknown-linux-gnu/gcc-3.4.0-glibc-2.3.2/glibc-2.3.2'
36 make: *** [all] Error 2
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
39 Return-Path: <libc-alpha-return-12105-listarch-libc-alpha=sources dot redhat dot com at sources dot redhat dot com>
40 Delivered-To: listarch-libc-alpha at sources dot redhat dot com
41 Received: (qmail 2802 invoked by alias); 12 Apr 2003 09:28:56 -0000
42 Mailing-List: contact libc-alpha-help at sources dot redhat dot com; run by ezmlm
44 List-Subscribe: <mailto:libc-alpha-subscribe at sources dot redhat dot com>
45 List-Archive: <http://sources.redhat.com/ml/libc-alpha/>
46 List-Post: <mailto:libc-alpha at sources dot redhat dot com>
47 List-Help: <mailto:libc-alpha-help at sources dot redhat dot com>, <http://sources dot redhat dot com/ml/#faqs>
48 Sender: libc-alpha-owner at sources dot redhat dot com
49 Delivered-To: mailing list libc-alpha at sources dot redhat dot com
50 Received: (qmail 2795 invoked from network); 12 Apr 2003 09:28:55 -0000
51 Received: from unknown (HELO lacrosse.corp.redhat.com) (66.187.233.200)
52 by sources dot redhat dot com with SMTP; 12 Apr 2003 09:28:55 -0000
53 Received: from free.redhat.lsd.ic.unicamp.br (aoliva.cipe.redhat.com [10.0.1.10])
54 by lacrosse dot corp dot redhat dot com (8 dot 11 dot 6/8 dot 9 dot 3) with ESMTP id h3C9SqV01131
55 for <libc-alpha at sources dot redhat dot com>; Sat, 12 Apr 2003 05:28:52 -0400
56 Received: from free.redhat.lsd.ic.unicamp.br (free.redhat.lsd.ic.unicamp.br [127.0.0.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
58 for <libc-alpha at sources dot redhat dot com>; Sat, 12 Apr 2003 06:28:51 -0300
59 Received: (from aoliva@localhost)
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;
61 Sat, 12 Apr 2003 06:28:51 -0300
62 To: libc-alpha at sources dot redhat dot com
63 Subject: signal-handling tweaks for mips/mips64
64 From: Alexandre Oliva <aoliva at redhat dot com>
65 Organization: GCC Team, Red Hat
66 Date: 12 Apr 2003 06:28:51 -0300
67 Message-ID: <orfzoof4j0.fsf@free.redhat.lsd.ic.unicamp.br>
69 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
71 Content-Type: multipart/mixed; boundary="=-=-="
75 It was reported to me that ucontext is utterly broken, even in o32
76 with a stable 32-bit mips kernel. Indeed, it doesn't match the
77 ucontext structure defined by the kernel at all. This means that
78 programs taking real-time signals in o32 won't be able to extract
79 correct information from the mcontext_t, since the kernel puts data in
80 there that's in an entirely different format.
82 I've looked for any ways in which the current data structures could
83 possibly be useful, and didn't find any. gdb and rda thought they
84 were using the register arrays, but it turned out they were using the
85 arrays in procps instead. makecontext(), [sg]etcontext() et al aren't
86 implemented on mips, so any uses thereof will just return ENOSYS,
87 without messing with the given data structure. So, I believe it is
88 not too late for us to fix it such that it matches the kernel data
91 While at that, I fixed a number of incompatibilities introduced by
92 either differences between kernel headers that we used to include,
93 whose contents are different depending on whether asm points to
94 asm-mips or asm-mips64.
96 With this patch, after some pending kernel patches are checked in, one
97 will be able to obtain the correct information from signal handlers in
98 all mips ABIs. With n64, this is already true. With o32, it works
99 with the 32-bit mips kernel, but the mips64 kernel needs a patch to
100 implement the proper sigcontext ABI. n32 still a patch to be
101 developed for it to be possible for ucontext to be POSIX-compliant.
102 Currently, the kernel uses the same ucontext for n32 and n64, but this
103 doesn't work in n32 because uc_link must be a pointer and stack_t must
104 contain a pointer and a size_t, whose sizes differ between n32 and
105 n64. I believe Ralf is working on a patch for the kernel to generate
106 n32-compliant ucontext when invoking signal handlers in n32 processes.
107 The only uncertainty is whether uc_flags will be a 32- or 64-bit value
108 in n32; I left it as the latter, just because I already had that in
109 place; if it changes, a (simplifying) follow-up patch will be posted.
110 However, I wanted to circulate the idea of fixing ucontext_t for o32
111 as soon as possible, so I didn't wait for a decision on the exact n32
118 Content-Type: text/x-patch
119 Content-Disposition: inline; filename=mips-sigstuff.patch
122 from Alexandre Oliva <aoliva@redhat.com>
124 * sysdeps/unix/sysv/linux/mips/profil-counter: New.
125 * sysdeps/unix/sysv/linux/mips/sigcontextinfo.h: Port to n32/n64.
126 * sysdeps/unix/sysv/linux/mips/bits/sigcontext.h: New.
127 * sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Port to n32/n64.
128 (mcontext_t): Make it match the 32-bit mips kernel in o32.
129 * sysdeps/unix/sysv/linux/mips/sys/user.h: Bring in constants from
130 the mips and mips64 headers.
131 (struct user): Port to n32/n64.
133 Index: sysdeps/unix/sysv/linux/mips/profil-counter.h
134 ===================================================================
135 RCS file: sysdeps/unix/sysv/linux/mips/profil-counter.h
136 diff -N sysdeps/unix/sysv/linux/mips/profil-counter.h
137 --- /dev/null 1 Jan 1970 00:00:00 -0000
138 +++ libc/sysdeps/unix/sysv/linux/mips/profil-counter.h 12 Apr 2003 09:13:13 -0000
140 +/* We can use the ix86 version. */
141 +#include <sysdeps/unix/sysv/linux/i386/profil-counter.h>
142 Index: sysdeps/unix/sysv/linux/mips/sigcontextinfo.h
143 ===================================================================
144 RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h,v
145 retrieving revision 1.6
146 diff -u -p -r1.6 sigcontextinfo.h
147 --- libc/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h 6 Jul 2001 04:56:18 -0000 1.6
148 +++ libc/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h 12 Apr 2003 09:13:13 -0000
150 -/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
151 +/* Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
152 This file is part of the GNU C Library.
153 Contributed by Andreas Jaeger <aj@suse.de>, 2000.
159 +#if _MIPS_SIM == _MIPS_SIM_ABI32
161 #define SIGCONTEXT unsigned long _code, struct sigcontext *
162 #define SIGCONTEXT_EXTRA_ARGS _code,
163 #define GET_PC(ctx) ((void *) ctx->sc_pc)
165 #define GET_STACK(ctx) ((void *) ctx->sc_regs[29])
166 #define CALL_SIGHANDLER(handler, signo, ctx) \
167 (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
171 +#define SIGCONTEXT unsigned long _code, ucontext_t *
172 +#define SIGCONTEXT_EXTRA_ARGS _code,
173 +#define GET_PC(ctx) ((void *) ctx->uc_mcontext.pc)
174 +#define GET_FRAME(ctx) ((void *) ctx->uc_mcontext.gregs[30])
175 +#define GET_STACK(ctx) ((void *) ctx->uc_mcontext.gregs[29])
176 +#define CALL_SIGHANDLER(handler, signo, ctx) \
177 + (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
180 Index: sysdeps/unix/sysv/linux/mips/bits/sigcontext.h
181 ===================================================================
182 RCS file: sysdeps/unix/sysv/linux/mips/bits/sigcontext.h
183 diff -N sysdeps/unix/sysv/linux/mips/bits/sigcontext.h
184 --- /dev/null 1 Jan 1970 00:00:00 -0000
185 +++ libc/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h 12 Apr 2003 09:13:13 -0000
187 +/* Copyright (C) 1996, 1997, 1998, 2003 Free Software Foundation, Inc.
188 + This file is part of the GNU C Library.
190 + The GNU C Library is free software; you can redistribute it and/or
191 + modify it under the terms of the GNU Lesser General Public
192 + License as published by the Free Software Foundation; either
193 + version 2.1 of the License, or (at your option) any later version.
195 + The GNU C Library is distributed in the hope that it will be useful,
196 + but WITHOUT ANY WARRANTY; without even the implied warranty of
197 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
198 + Lesser General Public License for more details.
200 + You should have received a copy of the GNU Lesser General Public
201 + License along with the GNU C Library; if not, write to the Free
202 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
205 +#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
206 +# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
209 +#ifndef sigcontext_struct
210 +/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but
211 + we need sigcontext. */
212 +# define sigcontext_struct sigcontext
214 +/* # include <asm/sigcontext.h> */
215 +/* Instead of including the kernel header, that will vary depending on
216 + whether the 32- or the 64-bit kernel is installed, we paste the
217 + contents here. In case you're wondering about the different
218 + licenses, the fact that the file is pasted, instead of included,
219 + doesn't really make any difference for the program that includes
221 +#if _MIPS_SIM == _MIPS_SIM_ABI32
223 + * This file is subject to the terms and conditions of the GNU General Public
224 + * License. See the file "COPYING" in the main directory of this archive
225 + * for more details.
227 + * Copyright (C) 1996, 1997, 2000 by Ralf Baechle
229 +#ifndef _ASM_SIGCONTEXT_H
230 +#define _ASM_SIGCONTEXT_H
233 + * Keep this struct definition in sync with the sigcontext fragment
234 + * in arch/mips/tools/offset.c
237 + unsigned int sc_regmask; /* Unused */
238 + unsigned int sc_status;
239 + unsigned long long sc_pc;
240 + unsigned long long sc_regs[32];
241 + unsigned long long sc_fpregs[32];
242 + unsigned int sc_ownedfp; /* Unused */
243 + unsigned int sc_fpc_csr;
244 + unsigned int sc_fpc_eir; /* Unused */
245 + unsigned int sc_used_math;
246 + unsigned int sc_ssflags; /* Unused */
247 + unsigned long long sc_mdhi;
248 + unsigned long long sc_mdlo;
250 + unsigned int sc_cause; /* Unused */
251 + unsigned int sc_badvaddr; /* Unused */
253 + unsigned long sc_sigset[4]; /* kernel's sigset_t */
256 +#endif /* _ASM_SIGCONTEXT_H */
257 +#else /* _MIPS_SIM != _MIPS_SIM_ABI32 */
259 + * This file is subject to the terms and conditions of the GNU General Public
260 + * License. See the file "COPYING" in the main directory of this archive
261 + * for more details.
263 + * Copyright (C) 1996, 1997, 1999 by Ralf Baechle
264 + * Copyright (C) 1999 Silicon Graphics, Inc.
266 +#ifndef _ASM_SIGCONTEXT_H
267 +#define _ASM_SIGCONTEXT_H
270 + * Keep this struct definition in sync with the sigcontext fragment
271 + * in arch/mips/tools/offset.c
274 + unsigned long long sc_regs[32];
275 + unsigned long long sc_fpregs[32];
276 + unsigned long long sc_mdhi;
277 + unsigned long long sc_mdlo;
278 + unsigned long long sc_pc;
279 + unsigned int sc_status;
280 + unsigned int sc_fpc_csr;
281 + unsigned int sc_fpc_eir;
282 + unsigned int sc_used_math;
283 + unsigned int sc_cause;
284 + unsigned int sc_badvaddr;
287 +#endif /* _ASM_SIGCONTEXT_H */
288 +#endif /* _MIPS_SIM != _MIPS_SIM_ABI32 */
290 [hunk deleted, see below]
291 Index: sysdeps/unix/sysv/linux/mips/sys/user.h
292 ===================================================================
293 RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/sys/user.h,v
294 retrieving revision 1.1
295 diff -u -p -r1.1 user.h
296 --- libc/sysdeps/unix/sysv/linux/mips/sys/user.h 8 Feb 2002 16:21:00 -0000 1.1
297 +++ libc/sysdeps/unix/sysv/linux/mips/sys/user.h 12 Apr 2003 09:13:13 -0000
299 -/* Copyright (C) 2002 Free Software Foundation, Inc.
300 +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
301 This file is part of the GNU C Library.
303 The GNU C Library is free software; you can redistribute it and/or
305 too much into it. Don't use it for anything other than GDB unless
306 you know what you are doing. */
308 -#include <asm/reg.h>
309 +/* #include <asm/reg.h> */
310 +/* Instead of including the kernel header, that will vary depending on
311 + whether the 32- or the 64-bit kernel is installed, we paste its
312 + contents here. Note that the fact that the file is inline here,
313 + instead of included separately, doesn't change in any way the
314 + licensing status of a program that includes user.h. Since this is
315 + for gdb alone, and gdb is GPLed, no surprises here. */
316 +#if _MIPS_SIM == _MIPS_SIM_ABI32
318 + * Various register offset definitions for debuggers, core file
319 + * examiners and whatnot.
321 + * This file is subject to the terms and conditions of the GNU General Public
322 + * License. See the file "COPYING" in the main directory of this archive
323 + * for more details.
325 + * Copyright (C) 1995, 1999 by Ralf Baechle
327 +#ifndef __ASM_MIPS_REG_H
328 +#define __ASM_MIPS_REG_H
331 + * This defines/structures correspond to the register layout on stack -
332 + * if the order here is changed, it needs to be updated in
333 + * include/asm-mips/stackframe.h
370 + * Saved special registers
375 +#define EF_CP0_EPC 40
376 +#define EF_CP0_BADVADDR 41
377 +#define EF_CP0_STATUS 42
378 +#define EF_CP0_CAUSE 43
380 +#define EF_SIZE 180 /* size in bytes */
382 +#endif /* __ASM_MIPS_REG_H */
384 +#else /* _MIPS_SIM != _MIPS_SIM_ABI32 */
387 + * Various register offset definitions for debuggers, core file
388 + * examiners and whatnot.
390 + * This file is subject to the terms and conditions of the GNU General Public
391 + * License. See the file "COPYING" in the main directory of this archive
392 + * for more details.
394 + * Copyright (C) 1995, 1999 Ralf Baechle
395 + * Copyright (C) 1995, 1999 Silicon Graphics
401 + * This defines/structures correspond to the register layout on stack -
402 + * if the order here is changed, it needs to be updated in
403 + * include/asm-mips/stackframe.h
440 + * Saved special registers
445 +#define EF_CP0_EPC 34
446 +#define EF_CP0_BADVADDR 35
447 +#define EF_CP0_STATUS 36
448 +#define EF_CP0_CAUSE 37
450 +#define EF_SIZE 304 /* size in bytes */
452 +#endif /* _ASM_REG_H */
454 +#endif /* _MIPS_SIM != _MIPS_SIM_ABI32 */
456 +#if _MIPS_SIM == _MIPS_SIM_ABI32
460 @@ -39,6 +186,24 @@ struct user
461 unsigned long magic; /* identifies a core file */
462 char u_comm[32]; /* user command name */
468 + __extension__ unsigned long regs[EF_SIZE/8+64]; /* integer and fp regs */
469 + __extension__ unsigned long u_tsize; /* text size (pages) */
470 + __extension__ unsigned long u_dsize; /* data size (pages) */
471 + __extension__ unsigned long u_ssize; /* stack size (pages) */
472 + __extension__ unsigned long long start_code; /* text starting address */
473 + __extension__ unsigned long long start_data; /* data starting address */
474 + __extension__ unsigned long long start_stack; /* stack starting address */
475 + __extension__ long long signal; /* signal causing core dump */
476 + __extension__ unsigned long long u_ar0; /* help gdb find registers */
477 + __extension__ unsigned long long magic; /* identifies a core file */
478 + char u_comm[32]; /* user command name */
483 #define PAGE_SHIFT 12
484 #define PAGE_SIZE (1UL << PAGE_SHIFT)
490 Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
491 Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
492 CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
493 Free Software Evangelist Professional serial bug killer
497 And the rediffed hunk:
499 --- glibc-2.3.2/sysdeps/unix/sysv/linux/mips/sys/ucontext.h.old 2004-05-30 07:23:32.000000000 -0700
500 +++ glibc-2.3.2/sysdeps/unix/sysv/linux/mips/sys/ucontext.h 2004-05-30 07:22:56.000000000 -0700
502 #include <bits/sigcontext.h>
505 -/* Type for general register. */
506 -typedef unsigned long int greg_t;
507 +/* Type for general register. Even in o32 we assume 64-bit registers,
508 + like the kernel. */
509 +__extension__ typedef unsigned long long int greg_t;
511 /* Number of general registers. */
517 /* Container for all general registers. */
518 -/* gregset_t must be an array. The below declared array corresponds to:
519 -typedef struct gregset {
525 typedef greg_t gregset_t[NGREG];
527 /* Container for all FPU registers. */
528 typedef struct fpregset {
530 - double fp_dregs[32];
531 + double fp_dregs[NFPREG];
534 unsigned int _fp_pad;
536 + } fp_fregs[NFPREG];
538 - unsigned int fp_csr;
539 - unsigned int fp_pad;
543 /* Context to describe whole processor state. */
544 +#if _MIPS_SIM == _MIPS_SIM_ABI32
545 +/* Earlier versions of glibc for mips had an entirely different
546 + definition of mcontext_t, that didn't even resemble the
547 + corresponding kernel data structure. Since all legitimate uses of
548 + ucontext_t in glibc mustn't have accessed anything beyond
549 + uc_mcontext and, even then, taking a pointer to it, casting it to
550 + sigcontext_t, and accessing it as such, which is what it has always
551 + been, this can still be rectified. Fortunately, makecontext,
552 + [gs]etcontext et all have never been implemented. */
555 + unsigned int regmask;
556 + unsigned int status;
560 + unsigned int fp_owned;
561 + unsigned int fpc_csr;
562 + unsigned int fpc_eir;
563 + unsigned int used_math;
564 + unsigned int ssflags;
567 + unsigned int cause;
568 + unsigned int badvaddr;
578 + unsigned int status;
579 + unsigned int fpc_csr;
580 + unsigned int fpc_eir;
581 + unsigned int used_math;
582 + unsigned int cause;
583 + unsigned int badvaddr;
587 /* Userlevel context. */
588 typedef struct ucontext