2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / ms_hook_prologue.c
blobe11bcc049cb2ca14f644944e29e17fd92d39c73b
1 /* Test that the ms_hook_prologue attribute generates the correct code. */
3 /* { dg-do run } */
4 /* { dg-require-effective-target ms_hook_prologue } */
5 /* { dg-options "-O2 -fomit-frame-pointer" } */
7 int __attribute__ ((__ms_hook_prologue__)) foo ()
9 unsigned char *ptr = (unsigned char *) foo;
11 /* The NOP mov must not be optimized away by optimizations.
12 The push %ebp, mov %esp, %ebp must not be removed by
13 -fomit-frame-pointer */
14 #ifndef __x86_64__
15 /* movl.s %edi, %edi */
16 if(*ptr++ != 0x8b) return 1;
17 if(*ptr++ != 0xff) return 1;
18 /* push %ebp */
19 if(*ptr++ != 0x55) return 1;
20 /* movl.s %esp, %ebp */
21 if(*ptr++ != 0x8b) return 1;
22 if(*ptr++ != 0xec) return 1;
23 #else
24 /* leaq 0(%rsp), %rsp */
25 if (*ptr++ != 0x48) return 1;
26 if (*ptr++ != 0x8d) return 1;
27 if (*ptr++ != 0xa4) return 1;
28 if (*ptr++ != 0x24) return 1;
29 if (ptr[0] != 0 || ptr[1] != 0 || ptr[2] != 0 || ptr[3] != 0)
30 return 1;
31 #endif
32 return 0;
35 int main ()
37 return foo();