summaryrefslogtreecommitdiff
path: root/sysdeps/unix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/sysv/linux/adjtime.c7
-rw-r--r--sysdeps/unix/sysv/linux/alpha/adjtime.c11
-rw-r--r--sysdeps/unix/sysv/linux/alpha/register-dump.h161
-rw-r--r--sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h12
-rw-r--r--sysdeps/unix/sysv/linux/i386/syscall.S10
-rw-r--r--sysdeps/unix/sysv/linux/i386/sysdep.h7
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/sysdep.h5
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h5
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h5
-rw-r--r--sysdeps/unix/sysv/linux/readonly-area.c90
10 files changed, 286 insertions, 27 deletions
diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c
index 62008f63ca..38ef805cd5 100644
--- a/sysdeps/unix/sysv/linux/adjtime.c
+++ b/sysdeps/unix/sysv/linux/adjtime.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995, 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998, 2002, 2004
+ 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
@@ -51,9 +52,7 @@ extern int INTUSE(__adjtimex) (struct timex *__ntx);
#endif
LINKAGE int
-ADJTIME (itv, otv)
- const struct TIMEVAL *itv;
- struct TIMEVAL *otv;
+ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv)
{
struct TIMEX tntx;
diff --git a/sysdeps/unix/sysv/linux/alpha/adjtime.c b/sysdeps/unix/sysv/linux/alpha/adjtime.c
index f8b272e9ce..e206cb4727 100644
--- a/sysdeps/unix/sysv/linux/alpha/adjtime.c
+++ b/sysdeps/unix/sysv/linux/alpha/adjtime.c
@@ -87,14 +87,15 @@ compat_symbol (libc, __adjtime_tv32, adjtime, GLIBC_2_0);
#define TIMEVAL timeval
#undef TIMEX
#define TIMEX timex
-#undef ADJTIME
-#define ADJTIME __adjtime_tv64
#undef ADJTIMEX
#define ADJTIMEX(x) INLINE_SYSCALL (adjtimex, 1, x)
+
#undef LINKAGE
+#undef ADJTIME
+#if !defined __ASSUME_TIMEVAL64
#define LINKAGE static
-
-LINKAGE int ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv);
+#define ADJTIME __adjtime_tv64
+#endif
#include <sysdeps/unix/sysv/linux/adjtime.c>
#include <stdbool.h>
@@ -135,8 +136,6 @@ __adjtime (itv, otv)
return ret;
}
-#else
-strong_alias (__adjtime_tv64, __adjtime);
#endif
versioned_symbol (libc, __adjtime, adjtime, GLIBC_2_1);
diff --git a/sysdeps/unix/sysv/linux/alpha/register-dump.h b/sysdeps/unix/sysv/linux/alpha/register-dump.h
new file mode 100644
index 0000000000..d55899a2c1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/register-dump.h
@@ -0,0 +1,161 @@
+/* Dump registers.
+ Copyright (C) 2004 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
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stddef.h>
+#include <sys/uio.h>
+
+/* We will print the register dump in this format:
+
+ V0: XXXXXXXXXXXXXXXX T0: XXXXXXXXXXXXXXXX T1: XXXXXXXXXXXXXXXX
+ T2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21: XXXXXXXXXXXXXXXX FP22: XXXXXXXXXXXXXXXX FP23: XXXXXXXXXXXXXXXX
+ FP24: XXXXXXXXXXXXXXXX FP25: XXXXXXXXXXXXXXXX FP26: XXXXXXXXXXXXXXXX
+ FP27: XXXXXXXXXXXXXXXX FP28: XXXXXXXXXXXXXXXX FP29: XXXXXXXXXXXXXXXX
+ FP30: XXXXXXXXXXXXXXXX FPCR: XXXXXXXXXXXXXXXX
+
+ TA0: XXXXXXXXXXXXXXXX TA1: XXXXXXXXXXXXXXXX TA2: XXXXXXXXXXXXXXXX
+*/
+
+#define NREGS (32+32+3)
+
+static const char regnames[NREGS][8] =
+{
+ " V0: ", " T0: ", " T1: ",
+ " T2: ", " T3: ", " T4: ",
+ " T5: ", " T6: ", " T7: ",
+ " S0: ", " S1: ", " S2: ",
+ " S3: ", " S4: ", " S5: ",
+ " S6: ", " A0: ", " A1: ",
+ " A2: ", " A3: ", " A4: ",
+ " A5: ", " T8: ", " T9: ",
+ " T10: ", " T11: ", " RA: ",
+ " T12: ", " AT: ", " GP: ",
+ " SP: ", " PC: ",
+
+ " FP0: ", " FP1: ", " FP2: ",
+ " FP3: ", " FP4: ", " FP5: ",
+ " FP6: ", " FP7: ", " FP8: ",
+ " FP9: ", " FP10: ", " FP11: ",
+ " FP12: ", " FP13: ", " FP14: ",
+ " FP15: ", " FP16: ", " FP17: ",
+ " FP18: ", " FP19: ", " FP20: ",
+ " FP21: ", " FP22: ", " FP23: ",
+ " FP24: ", " FP25: ", " FP26: ",
+ " FP27: ", " FP28: ", " FP29: ",
+ " FP30: ", " FPCR: ",
+
+ " TA0: ", " TA1: ", " TA2: "
+};
+
+#define O(FIELD, LF) offsetof(struct sigcontext, FIELD) + LF
+
+static const int offsets[NREGS] =
+{
+ O(sc_regs[0], 0), O(sc_regs[1], 0), O(sc_regs[2], 1),
+ O(sc_regs[3], 0), O(sc_regs[4], 0), O(sc_regs[5], 1),
+ O(sc_regs[6], 0), O(sc_regs[7], 0), O(sc_regs[8], 1),
+ O(sc_regs[9], 0), O(sc_regs[10], 0), O(sc_regs[11], 1),
+ O(sc_regs[12], 0), O(sc_regs[13], 0), O(sc_regs[14], 1),
+ O(sc_regs[15], 0), O(sc_regs[16], 0), O(sc_regs[17], 1),
+ O(sc_regs[18], 0), O(sc_regs[19], 0), O(sc_regs[20], 1),
+ O(sc_regs[21], 0), O(sc_regs[22], 0), O(sc_regs[23], 1),
+ O(sc_regs[24], 0), O(sc_regs[25], 0), O(sc_regs[26], 1),
+ O(sc_regs[27], 0), O(sc_regs[28], 0), O(sc_regs[29], 1),
+ O(sc_regs[30], 0), O(sc_pc, 2),
+
+ O(sc_fpregs[0], 0), O(sc_fpregs[1], 0), O(sc_fpregs[2], 1),
+ O(sc_fpregs[3], 0), O(sc_fpregs[4], 0), O(sc_fpregs[5], 1),
+ O(sc_fpregs[6], 0), O(sc_fpregs[7], 0), O(sc_fpregs[8], 1),
+ O(sc_fpregs[9], 0), O(sc_fpregs[10], 0), O(sc_fpregs[11], 1),
+ O(sc_fpregs[12], 0), O(sc_fpregs[13], 0), O(sc_fpregs[14], 1),
+ O(sc_fpregs[15], 0), O(sc_fpregs[16], 0), O(sc_fpregs[17], 1),
+ O(sc_fpregs[18], 0), O(sc_fpregs[19], 0), O(sc_fpregs[20], 1),
+ O(sc_fpregs[21], 0), O(sc_fpregs[22], 0), O(sc_fpregs[23], 1),
+ O(sc_fpregs[24], 0), O(sc_fpregs[25], 0), O(sc_fpregs[26], 1),
+ O(sc_fpregs[27], 0), O(sc_fpregs[28], 0), O(sc_fpregs[29], 1),
+ O(sc_fpregs[30], 0), O(sc_fpcr, 2),
+
+ O(sc_traparg_a0, 0), O(sc_traparg_a1, 0), O(sc_traparg_a2, 1)
+};
+
+#undef O
+
+static const char linefeed[2] = "\n\n";
+
+static void
+register_dump (int fd, struct sigcontext *ctx)
+{
+ char regs[NREGS][16];
+ struct iovec iov[2*NREGS+24];
+ size_t iov_i = 0, i, j;
+
+#define ADD_MEM(str, len) \
+ (iov[iov_i].iov_base = (void *)(str), \
+ iov[iov_i].iov_len = len, \
+ ++iov_i)
+
+#define ADD_STRING(str) ADD_MEM(str, strlen(str))
+
+ ADD_STRING ("Register dump:\n\n");
+
+ for (i = 0; i < NREGS; ++i)
+ {
+ int this_offset, this_lf;
+ unsigned long val;
+
+ this_offset = offsets[i];
+ this_lf = this_offset & 7;
+ this_offset &= -8;
+
+ val = *(unsigned long *)((char *)ctx + this_offset);
+
+ for (j = 0; j < 16; ++j)
+ {
+ unsigned long x = (val >> (64 - (j + 1) * 4)) & 15;
+ x += x < 10 ? '0' : 'a' - 10;
+ regs[i][j] = x;
+ }
+
+ ADD_MEM (regnames[i], 8);
+ ADD_MEM (regs[i], 16);
+ if (this_lf)
+ ADD_MEM (linefeed, this_lf);
+ }
+
+ writev (fd, iov, iov_i);
+}
+
+#define REGISTER_DUMP register_dump (fd, ctx)
diff --git a/sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h b/sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h
index eb6f4f0758..16c5dcbc5b 100644
--- a/sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h
+++ b/sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2004 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
@@ -16,10 +16,10 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define SIGCONTEXT struct sigcontext
-#define SIGCONTEXT_EXTRA_ARGS
-#define GET_PC(ctx) ((void *) (ctx).sc_pc)
-#define GET_FRAME(ctx) ((void *) (ctx).sc_regs[15])
-#define GET_STACK(ctx) ((void *) (ctx).sc_regs[30])
+#define SIGCONTEXT int _code, struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS _code,
+#define GET_PC(ctx) ((void *) (ctx)->sc_pc)
+#define GET_FRAME(ctx) ((void *) (ctx)->sc_regs[15])
+#define GET_STACK(ctx) ((void *) (ctx)->sc_regs[30])
#define CALL_SIGHANDLER(handler, signo, ctx) \
(handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/sysdeps/unix/sysv/linux/i386/syscall.S b/sysdeps/unix/sysv/linux/i386/syscall.S
index cd7dc65a5f..b569650b24 100644
--- a/sysdeps/unix/sysv/linux/i386/syscall.S
+++ b/sysdeps/unix/sysv/linux/i386/syscall.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1998, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1998, 2002, 2004 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
@@ -24,11 +24,11 @@
.text
ENTRY (syscall)
- PUSHARGS_5 /* Save register contents. */
- _DOARGS_5(36) /* Load arguments. */
- movl 16(%esp), %eax /* Load syscall number into %eax. */
+ PUSHARGS_6 /* Save register contents. */
+ _DOARGS_6(44) /* Load arguments. */
+ movl 20(%esp), %eax /* Load syscall number into %eax. */
ENTER_KERNEL /* Do the system call. */
- POPARGS_5 /* Restore register contents. */
+ POPARGS_6 /* Restore register contents. */
cmpl $-4095, %eax /* Check %eax for error. */
jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
L(pseudo_end):
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 37e7459a9c..af75d4c51a 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -297,6 +297,13 @@ __i686.get_pc_thunk.reg: \
#define _DOARGS_5(n) movl n(%esp), %edi; _DOARGS_4 (n-4)
#define _POPARGS_5 _POPARGS_4; popl %edi; L(POPDI1):
+#define PUSHARGS_6 _PUSHARGS_6
+#define DOARGS_6 _DOARGS_6 (36)
+#define POPARGS_6 _POPARGS_6
+#define _PUSHARGS_6 pushl %ebp; L(PUSHBP1): _PUSHARGS_5
+#define _DOARGS_6(n) movl n(%esp), %ebp; _DOARGS_5 (n-4)
+#define _POPARGS_6 _POPARGS_5; popl %ebp; L(POPBP1):
+
#else /* !__ASSEMBLER__ */
/* We need some help from the assembler to generate optimal code. We
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index 1f56671ba0..5eaf7a276b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2003, 2004 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
@@ -275,7 +275,8 @@
_sys_result; \
})
-#define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25"
+#define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \
+ "$14", "$15", "$24", "$25", "memory"
#endif /* __ASSEMBLER__ */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
index 2b2aefa15d..be343aabca 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2003, 2004 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
@@ -235,7 +235,8 @@
_sys_result; \
})
-#define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25"
+#define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
+ "$14", "$15", "$24", "$25", "memory"
#endif /* __ASSEMBLER__ */
#endif /* linux/mips/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
index e2d8707d25..f30a465081 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2003, 2004 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
@@ -235,7 +235,8 @@
_sys_result; \
})
-#define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25"
+#define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
+ "$14", "$15", "$24", "$25", "memory"
#endif /* __ASSEMBLER__ */
#endif /* linux/mips/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
new file mode 100644
index 0000000000..ce5321bcef
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -0,0 +1,90 @@
+/* Copyright (C) 2004 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
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdlib.h>
+#include <string.h>
+#include "libio/libioP.h"
+
+/* Return 1 if the whole area PTR .. PTR+SIZE is not writable.
+ Return -1 if it is writable. */
+
+int
+__readonly_area (const char *ptr, size_t size)
+{
+ const void *ptr_end = ptr + size;
+
+ FILE *fp = fopen ("/proc/self/maps", "rc");
+ if (fp == NULL)
+ return -1;
+
+ /* We need no locking. */
+ __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
+ char *line = NULL;
+ size_t linelen = 0;
+
+ while (! feof_unlocked (fp))
+ {
+ if (_IO_getdelim (&line, &linelen, '\n', fp) <= 0)
+ break;
+
+ char *p;
+ uintptr_t from = strtoul (line, &p, 16);
+
+ if (p == line || *p++ != '-')
+ break;
+
+ char *q;
+ uintptr_t to = strtoul (p, &q, 16);
+
+ if (q == p || *q++ != ' ')
+ break;
+
+ if (from < (uintptr_t) ptr_end && to > (uintptr_t) ptr)
+ {
+ /* Found an entry that at least partially covers the area. */
+ if (*q++ != 'r' || *q++ != '-')
+ break;
+
+ if (from <= (uintptr_t) ptr && to >= (uintptr_t) ptr_end)
+ {
+ size = 0;
+ break;
+ }
+ else if (from <= (uintptr_t) ptr)
+ size -= to - (uintptr_t) ptr;
+ else if (to >= (uintptr_t) ptr_end)
+ size -= (uintptr_t) ptr_end - from;
+ else
+ size -= to - from;
+
+ if (!size)
+ break;
+ }
+ }
+
+ fclose (fp);
+ free (line);
+
+ /* If the whole area between ptr and ptr_end is covered by read-only
+ VMAs, return 1. Otherwise return -1. */
+ return size == 0 ? 1 : -1;
+}