On Tue, May 28, 2019 at 10:37 AM Wilco Dijkstra <wilco.dijks...@arm.com> wrote:
>
>
> diff --git a/gcc/testsuite/gcc.c-torture/execute/pr84521.c 
> b/gcc/testsuite/gcc.c-torture/execute/pr84521.c
> new file mode 100644
> index 
> 0000000000000000000000000000000000000000..995a30223afd1401186c7eaf541f27606aed59b5
> --- /dev/null
> +++ b/gcc/testsuite/gcc.c-torture/execute/pr84521.c
> @@ -0,0 +1,54 @@
> +/* { dg-require-effective-target indirect_jumps } */
> +/* { dg-additional-options "-fomit-frame-pointer -fno-inline" }  */
> +
> +extern void abort (void);
> +
> +void
> +broken_longjmp (void *p)
> +{
> +  __builtin_longjmp (p, 1);
> +}
> +
> +volatile int x = 256;
> +void *volatile p = (void*)&x;
> +void *volatile p1;
> +
> +void
> +test (void)
> +{
> +  void *buf[5];
> +  void *volatile q = p;
> +
> +  if (!__builtin_setjmp (buf))
> +    broken_longjmp (buf);

Is this test valid?  Can jmp buffer be allowed on stack?

> +  /* Fails if stack pointer corrupted.  */
> +  if (p != q)
> +    abort ();
> +}
> +
> +void
> +test2 (void)
> +{
> +  void *volatile q = p;
> +  p1 = __builtin_alloca (x);
> +  test ();
> +
> +  /* Fails if frame pointer corrupted.  */
> +  if (p != q)
> +    abort ();
> +}
> +
> +int
> +main (void)
> +{
> +  void *volatile q = p;
> +  test ();
> +  test2 ();
> +  /* Fails if stack pointer corrupted.  */
> +  if (p != q)
> +    abort ();
> +
> +  return 0;
> +}
> +



-- 
H.J.

Reply via email to