From 73f7c32c47ab2397935d9fc2aeaa594794b38c7e Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 2 Sep 2004 18:59:24 +0000 Subject: [BZ #357] Update. 2004-09-02 Steven Munroe [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. --- stdlib/tst-setcontext.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'stdlib/tst-setcontext.c') 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) -- cgit v1.2.3