summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-09-02 18:59:24 +0000
committerUlrich Drepper <drepper@redhat.com>2004-09-02 18:59:24 +0000
commit73f7c32c47ab2397935d9fc2aeaa594794b38c7e (patch)
tree1a0f7d20c9009fbd67c33495f9db0a5d665092b3 /stdlib
parent86aca5ac58e152336e676bc1231acac6adc32068 (diff)
[BZ #357]
Update. 2004-09-02 Steven Munroe <sjmunroe@us.ibm.com> [BZ #357] * stdlib/tst-setcontext.c (test_stack): Added test for stack clobber. (main): Call test_stack. * sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S (__getcontext): Push stack frame then save parms in local frame. Improve instruction scheduling. * sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S (__swapcontext): Likewise.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/tst-setcontext.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/stdlib/tst-setcontext.c b/stdlib/tst-setcontext.c
index 89b8cdfd98..c8f7fdb459 100644
--- a/stdlib/tst-setcontext.c
+++ b/stdlib/tst-setcontext.c
@@ -72,6 +72,55 @@ f2 (void)
was_in_f2 = 1;
}
+void
+test_stack(volatile int a, volatile int b,
+ volatile int c, volatile int d)
+{
+ volatile int e = 5;
+ volatile int f = 6;
+ ucontext_t uc;
+
+ /* Test for cases where getcontext is clobbering the callers
+ stack, including parameters. */
+ getcontext(&uc);
+
+ if (a != 1)
+ {
+ printf ("%s: getcontext clobbers parm a\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (b != 2)
+ {
+ printf ("%s: getcontext clobbers parm b\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (c != 3)
+ {
+ printf ("%s: getcontext clobbers parm c\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (d != 4)
+ {
+ printf ("%s: getcontext clobbers parm d\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (e != 5)
+ {
+ printf ("%s: getcontext clobbers varible e\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (f != 6)
+ {
+ printf ("%s: getcontext clobbers variable f\n", __FUNCTION__);
+ exit (1);
+ }
+}
+
volatile int global;
int
@@ -88,6 +137,8 @@ main (void)
printf ("%s: getcontext: %m\n", __FUNCTION__);
exit (1);
}
+
+ test_stack (1, 2, 3, 4);
/* Play some tricks with this context. */
if (++global == 1)