This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
MIPS sigcontext adjustment
- From: Daniel Jacobowitz <drow at false dot org>
- To: libc-ports at sourceware dot org
- Date: Wed, 10 May 2006 15:00:07 -0400
- Subject: MIPS sigcontext adjustment
Kernel 2.6.12 rearranged the MIPS64 sigcontext layout and changed the
size of the structure. Some reserved fields in the sigcontext also
were adjusted for the new DSP registers. The 32-bit layout is
basically compatible; the 64-bit layout is not, because sc_pc has
changed offsets. The best we can do is update glibc to match;
for some corner cases to work, you'll need to use the patched glibc
along with kernels after 2.6.12.
I've committed the attached.
--
Daniel Jacobowitz
CodeSourcery
2006-05-10 Richard Sandiford <richard@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>
* sysdeps/unix/sysv/linux/mips/register-dump.h (register_dump): Don't
dump sc_cause, sc_status or sc_badvaddr.
* sysdeps/unix/sysv/linux/mips/bits/sigcontext.h: Rewrite. Update
structure definitions after DSP kernel changes.
* sysdeps/unix/sysv/linux/mips/sys/ucontext.h (mcontext_t): Update
after the same DSP changes.
Index: libc/ports/sysdeps/unix/sysv/linux/mips/register-dump.h
===================================================================
--- libc.orig/ports/sysdeps/unix/sysv/linux/mips/register-dump.h 2002-07-12 19:25:56.000000000 -0400
+++ libc/ports/sysdeps/unix/sysv/linux/mips/register-dump.h 2006-05-08 11:01:48.000000000 -0400
@@ -1,5 +1,5 @@
/* Dump registers.
- Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Andreas Jaeger <aj@suse.de>, 2000.
@@ -27,8 +27,8 @@
R8 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
R16 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
R24 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
- pc cause status badvaddr lo hi
- XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
+ pc lo hi
+ XXXXXXXX XXXXXXXX XXXXXXXX
The FPU registers will not be printed.
*/
@@ -61,11 +61,8 @@ register_dump (int fd, struct sigcontext
for (i = 0; i < 32; i++)
hexvalue (ctx->sc_regs[i], regs[i], 8);
hexvalue (ctx->sc_pc, regs[32], 8);
- hexvalue (ctx->sc_cause, regs[33], 8);
- hexvalue (ctx->sc_status, regs[34], 8);
- hexvalue (ctx->sc_badvaddr, regs[35], 8);
- hexvalue (ctx->sc_mdhi, regs[36], 8);
- hexvalue (ctx->sc_mdlo, regs[37], 8);
+ hexvalue (ctx->sc_mdhi, regs[33], 8);
+ hexvalue (ctx->sc_mdlo, regs[34], 8);
/* Generate the output. */
ADD_STRING ("Register dump:\n\n R0 ");
@@ -92,8 +89,8 @@ register_dump (int fd, struct sigcontext
ADD_MEM (regs[i], 8);
ADD_STRING (" ");
}
- ADD_STRING ("\n pc cause status badvaddr lo hi\n ");
- for (i = 32; i < 38; i++)
+ ADD_STRING ("\n pc lo hi\n ");
+ for (i = 32; i < 35; i++)
{
ADD_MEM (regs[i], 8);
ADD_STRING (" ");
Index: libc/ports/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h
===================================================================
--- libc.orig/ports/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h 2004-11-23 23:37:34.000000000 -0500
+++ libc/ports/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h 2006-05-08 12:20:44.000000000 -0400
@@ -1,5 +1,5 @@
-/* Copyright (C) 1996, 1997, 1998, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
+/* Copyright (C) 1996, 1997, 1998, 2003, 2004, 2006 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 Lesser General Public
@@ -16,90 +16,69 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#ifndef _BITS_SIGCONTEXT_H
+#define _BITS_SIGCONTEXT_H 1
+
#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
#endif
#include <sgidefs.h>
-#ifndef sigcontext_struct
-/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but
- we need sigcontext. */
-# define sigcontext_struct sigcontext
-
-/* # include <asm/sigcontext.h> */
-/* Instead of including the kernel header, that will vary depending on
- whether the 32- or the 64-bit kernel is installed, we paste the
- contents here. In case you're wondering about the different
- licenses, the fact that the file is pasted, instead of included,
- doesn't really make any difference for the program that includes
- this header. */
#if _MIPS_SIM == _ABIO32
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1996, 1997, 2000 by Ralf Baechle
- */
-#ifndef _ASM_SIGCONTEXT_H
-#define _ASM_SIGCONTEXT_H
-
-/*
- * Keep this struct definition in sync with the sigcontext fragment
- * in arch/mips/tools/offset.c
- */
-struct sigcontext {
- unsigned int sc_regmask; /* Unused */
- unsigned int sc_status;
- unsigned long long sc_pc;
- unsigned long long sc_regs[32];
- unsigned long long sc_fpregs[32];
- unsigned int sc_ownedfp; /* Unused */
- unsigned int sc_fpc_csr;
- unsigned int sc_fpc_eir; /* Unused */
- unsigned int sc_used_math;
- unsigned int sc_ssflags; /* Unused */
- unsigned long long sc_mdhi;
- unsigned long long sc_mdlo;
- unsigned int sc_cause; /* Unused */
- unsigned int sc_badvaddr; /* Unused */
+/* Certain unused fields were replaced with new ones in 2.6.12-rc4.
+ The changes were as follows:
+
+ sc_cause -> sc_hi1
+ sc_badvaddr -> sc_lo1
+ sc_sigset[0] -> sc_hi2
+ sc_sigset[1] -> sc_lo2
+ sc_sigset[2] -> sc_hi3
+ sc_sigset[3] -> sc_lo3
- unsigned long sc_sigset[4]; /* kernel's sigset_t */
+ sc_regmask, sc_ownedfp and sc_fpc_eir are not used. */
+struct sigcontext {
+ unsigned int sc_regmask;
+ unsigned int sc_status;
+ unsigned long long sc_pc;
+ unsigned long long sc_regs[32];
+ unsigned long long sc_fpregs[32];
+ unsigned int sc_ownedfp;
+ unsigned int sc_fpc_csr;
+ unsigned int sc_fpc_eir;
+ unsigned int sc_used_math;
+ unsigned int sc_dsp;
+ unsigned long long sc_mdhi;
+ unsigned long long sc_mdlo;
+ unsigned long sc_hi1;
+ unsigned long sc_lo1;
+ unsigned long sc_hi2;
+ unsigned long sc_lo2;
+ unsigned long sc_hi3;
+ unsigned long sc_lo3;
};
-#endif /* _ASM_SIGCONTEXT_H */
-#else /* _MIPS_SIM != _ABIO32 */
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1996, 1997, 1999 by Ralf Baechle
- * Copyright (C) 1999 Silicon Graphics, Inc.
- */
-#ifndef _ASM_SIGCONTEXT_H
-#define _ASM_SIGCONTEXT_H
-
-/*
- * Keep this struct definition in sync with the sigcontext fragment
- * in arch/mips/tools/offset.c
- */
+#else
+
+/* This structure changed in 2.6.12-rc4 when DSP support was added. */
struct sigcontext {
- unsigned long long sc_regs[32];
- unsigned long long sc_fpregs[32];
- unsigned long long sc_mdhi;
- unsigned long long sc_mdlo;
- unsigned long long sc_pc;
- unsigned int sc_status;
- unsigned int sc_fpc_csr;
- unsigned int sc_fpc_eir;
- unsigned int sc_used_math;
- unsigned int sc_cause;
- unsigned int sc_badvaddr;
+ unsigned long long sc_regs[32];
+ unsigned long long sc_fpregs[32];
+ unsigned long long sc_mdhi;
+ unsigned long long sc_hi1;
+ unsigned long long sc_hi2;
+ unsigned long long sc_hi3;
+ unsigned long long sc_mdlo;
+ unsigned long long sc_lo1;
+ unsigned long long sc_lo2;
+ unsigned long long sc_lo3;
+ unsigned long long sc_pc;
+ unsigned int sc_fpc_csr;
+ unsigned int sc_used_math;
+ unsigned int sc_dsp;
+ unsigned int sc_reserved;
};
-#endif /* _ASM_SIGCONTEXT_H */
#endif /* _MIPS_SIM != _ABIO32 */
#endif
Index: libc/ports/sysdeps/unix/sysv/linux/mips/sys/ucontext.h
===================================================================
--- libc.orig/ports/sysdeps/unix/sysv/linux/mips/sys/ucontext.h 2004-11-23 23:36:11.000000000 -0500
+++ libc/ports/sysdeps/unix/sysv/linux/mips/sys/ucontext.h 2006-05-08 11:35:16.000000000 -0400
@@ -1,5 +1,5 @@
-/* Copyright (C) 1997, 1998, 2000, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
+/* Copyright (C) 1997, 1998, 2000, 2003, 2004, 2006 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 Lesser General Public
@@ -73,11 +73,15 @@ typedef struct
unsigned int fpc_csr;
unsigned int fpc_eir;
unsigned int used_math;
- unsigned int ssflags;
+ unsigned int dsp;
greg_t mdhi;
greg_t mdlo;
- unsigned int cause;
- unsigned int badvaddr;
+ unsigned long hi1;
+ unsigned long lo1;
+ unsigned long hi2;
+ unsigned long lo2;
+ unsigned long hi3;
+ unsigned long lo3;
} mcontext_t;
#else
typedef struct
@@ -85,14 +89,18 @@ typedef struct
gregset_t gregs;
fpregset_t fpregs;
greg_t mdhi;
+ greg_t hi1;
+ greg_t hi2;
+ greg_t hi3;
greg_t mdlo;
+ greg_t lo1;
+ greg_t lo2;
+ greg_t lo3;
greg_t pc;
- unsigned int status;
unsigned int fpc_csr;
- unsigned int fpc_eir;
unsigned int used_math;
- unsigned int cause;
- unsigned int badvaddr;
+ unsigned int dsp;
+ unsigned int reserved;
} mcontext_t;
#endif