linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / arch / x86_64 / ia32 / vsyscall-sigreturn.S
1 /*
2  * Common code for the sigreturn entry points on the vsyscall page.
3  * This code uses SYSCALL_ENTER_KERNEL (either syscall or int $0x80)
4  * to enter the kernel.
5  * This file is #include'd by vsyscall-*.S to define them after the
6  * vsyscall entry point.  The addresses we get for these entry points
7  * by doing ".balign 32" must match in both versions of the page.
8  */
9
10         .code32
11         .section .text.sigreturn,"ax"
12         .balign 32
13         .globl __kernel_sigreturn
14         .type __kernel_sigreturn,@function
15 __kernel_sigreturn:
16 .LSTART_sigreturn:
17         popl %eax
18         movl $__NR_ia32_sigreturn, %eax
19         SYSCALL_ENTER_KERNEL
20 .LEND_sigreturn:
21         .size __kernel_sigreturn,.-.LSTART_sigreturn
22
23         .section .text.rtsigreturn,"ax"
24         .balign 32
25         .globl __kernel_rt_sigreturn
26         .type __kernel_rt_sigreturn,@function
27 __kernel_rt_sigreturn:
28 .LSTART_rt_sigreturn:
29         movl $__NR_ia32_rt_sigreturn, %eax
30         SYSCALL_ENTER_KERNEL
31 .LEND_rt_sigreturn:
32         .size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
33
34         .section .eh_frame,"a",@progbits
35         .long .LENDFDE2-.LSTARTFDE2     /* Length FDE */
36 .LSTARTFDE2:
37         .long .LSTARTFDE2-.LSTARTFRAME  /* CIE pointer */
38         /* HACK: The dwarf2 unwind routines will subtract 1 from the
39            return address to get an address in the middle of the
40            presumed call instruction.  Since we didn't get here via
41            a call, we need to include the nop before the real start
42            to make up for it.  */
43         .long .LSTART_sigreturn-1-.     /* PC-relative start address */
44         .long .LEND_sigreturn-.LSTART_sigreturn+1
45         .uleb128 0                      /* Augmentation length */
46         /* What follows are the instructions for the table generation.
47            We record the locations of each register saved.  This is
48            complicated by the fact that the "CFA" is always assumed to
49            be the value of the stack pointer in the caller.  This means
50            that we must define the CFA of this body of code to be the
51            saved value of the stack pointer in the sigcontext.  Which
52            also means that there is no fixed relation to the other 
53            saved registers, which means that we must use DW_CFA_expression
54            to compute their addresses.  It also means that when we 
55            adjust the stack with the popl, we have to do it all over again.  */
56
57 #define do_cfa_expr(offset)                                             \
58         .byte 0x0f;                     /* DW_CFA_def_cfa_expression */ \
59         .uleb128 1f-0f;                 /*   length */                  \
60 0:      .byte 0x74;                     /*     DW_OP_breg4 */           \
61         .sleb128 offset;                /*      offset */               \
62         .byte 0x06;                     /*     DW_OP_deref */           \
63 1:
64
65 #define do_expr(regno, offset)                                          \
66         .byte 0x10;                     /* DW_CFA_expression */         \
67         .uleb128 regno;                 /*   regno */                   \
68         .uleb128 1f-0f;                 /*   length */                  \
69 0:      .byte 0x74;                     /*     DW_OP_breg4 */           \
70         .sleb128 offset;                /*       offset */              \
71 1:
72
73         do_cfa_expr(IA32_SIGCONTEXT_esp+4)
74         do_expr(0, IA32_SIGCONTEXT_eax+4)
75         do_expr(1, IA32_SIGCONTEXT_ecx+4)
76         do_expr(2, IA32_SIGCONTEXT_edx+4)
77         do_expr(3, IA32_SIGCONTEXT_ebx+4)
78         do_expr(5, IA32_SIGCONTEXT_ebp+4)
79         do_expr(6, IA32_SIGCONTEXT_esi+4)
80         do_expr(7, IA32_SIGCONTEXT_edi+4)
81         do_expr(8, IA32_SIGCONTEXT_eip+4)
82
83         .byte 0x42      /* DW_CFA_advance_loc 2 -- nop; popl eax. */
84
85         do_cfa_expr(IA32_SIGCONTEXT_esp)
86         do_expr(0, IA32_SIGCONTEXT_eax)
87         do_expr(1, IA32_SIGCONTEXT_ecx)
88         do_expr(2, IA32_SIGCONTEXT_edx)
89         do_expr(3, IA32_SIGCONTEXT_ebx)
90         do_expr(5, IA32_SIGCONTEXT_ebp)
91         do_expr(6, IA32_SIGCONTEXT_esi)
92         do_expr(7, IA32_SIGCONTEXT_edi)
93         do_expr(8, IA32_SIGCONTEXT_eip)
94
95         .align 4
96 .LENDFDE2:
97
98         .long .LENDFDE3-.LSTARTFDE3     /* Length FDE */
99 .LSTARTFDE3:
100         .long .LSTARTFDE3-.LSTARTFRAME  /* CIE pointer */
101         /* HACK: See above wrt unwind library assumptions.  */
102         .long .LSTART_rt_sigreturn-1-.  /* PC-relative start address */
103         .long .LEND_rt_sigreturn-.LSTART_rt_sigreturn+1
104         .uleb128 0                      /* Augmentation */
105         /* What follows are the instructions for the table generation.
106            We record the locations of each register saved.  This is
107            slightly less complicated than the above, since we don't
108            modify the stack pointer in the process.  */
109
110         do_cfa_expr(IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_esp)
111         do_expr(0, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_eax)
112         do_expr(1, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ecx)
113         do_expr(2, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_edx)
114         do_expr(3, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ebx)
115         do_expr(5, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ebp)
116         do_expr(6, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_esi)
117         do_expr(7, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_edi)
118         do_expr(8, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_eip)
119
120         .align 4
121 .LENDFDE3:
122
123 #include "../../i386/kernel/vsyscall-note.S"
124