aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/naked-3.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.target/i386/naked-3.c')
-rw-r--r--gcc/testsuite/gcc.target/i386/naked-3.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/naked-3.c b/gcc/testsuite/gcc.target/i386/naked-3.c
new file mode 100644
index 00000000000..b3a17f635ee
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/naked-3.c
@@ -0,0 +1,39 @@
+/* { dg-do run { target *-*-linux* *-*-gnu* } } */
+/* { dg-options "-O0" } */
+
+#include <unistd.h>
+#include <signal.h>
+#include <stdlib.h>
+
+/* Verify that naked function traps at the end. */
+
+void
+__attribute__((naked, noinline, noclone))
+#ifdef __i386__
+__attribute__((regparm(1)))
+#endif
+naked (int data)
+{
+ if (data == 0x12345678)
+ return;
+ asm ("ret");
+}
+
+void handler (int i)
+{
+ exit (0);
+}
+
+int main ()
+{
+ struct sigaction s;
+
+ sigemptyset (&s.sa_mask);
+ s.sa_handler = handler;
+ s.sa_flags = 0;
+ sigaction (SIGILL, &s, NULL);
+
+ naked (0x12345678);
+
+ abort ();
+}