Make an empty file.
[glibc.git] / sysdeps / x86_64 / dl-trampoline.S
blob84fe4724b1bc03eea8b8d815e10bd7a27d7b5281
1 /* PLT trampolines.  x86-64 version.
2    Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
20 #include <sysdep.h>
22         .text
23         .globl _dl_runtime_resolve
24         .type _dl_runtime_resolve, @function
25         .align 16
26         cfi_startproc
27 _dl_runtime_resolve:
28         subq $56,%rsp
29         cfi_adjust_cfa_offset(72) # Incorporate PLT
30         movq %rax,(%rsp)        # Preserve registers otherwise clobbered.
31         movq %rcx, 8(%rsp)
32         movq %rdx, 16(%rsp)
33         movq %rsi, 24(%rsp)
34         movq %rdi, 32(%rsp)
35         movq %r8, 40(%rsp)
36         movq %r9, 48(%rsp)
37         movq 64(%rsp), %rsi     # Copy args pushed by PLT in register.
38         movq %rsi, %r11         # Multiply by 24
39         addq %r11, %rsi
40         addq %r11, %rsi
41         shlq $3, %rsi
42         movq 56(%rsp), %rdi     # %rdi: link_map, %rsi: reloc_offset
43         call _dl_fixup          # Call resolver.
44         movq %rax, %r11         # Save return value
45         movq 48(%rsp), %r9      # Get register content back.
46         movq 40(%rsp), %r8
47         movq 32(%rsp), %rdi
48         movq 24(%rsp), %rsi
49         movq 16(%rsp), %rdx
50         movq 8(%rsp), %rcx
51         movq (%rsp), %rax
52         addq $72, %rsp          # Adjust stack(PLT did 2 pushes)
53         cfi_adjust_cfa_offset(-72)
54         jmp *%r11               # Jump to function address.
55         cfi_endproc
56         .size _dl_runtime_resolve, .-_dl_runtime_resolve
59 #ifndef PROF
60         .globl _dl_runtime_profile
61         .type _dl_runtime_profile, @function
62         .align 16
63         cfi_startproc
64 _dl_runtime_profile:
65         subq $80, %rsp
66         cfi_adjust_cfa_offset(96) # Incorporate PLT
67         movq %rax, (%rsp)       # Preserve registers otherwise clobbered.
68         movq %rdx, 8(%rsp)
69         movq %r8, 16(%rsp)
70         movq %r9, 24(%rsp)
71         movq %rcx, 32(%rsp)
72         movq %rsi, 40(%rsp)
73         movq %rdi, 48(%rsp)
74         movq %rbp, 56(%rsp)     # Information for auditors.
75         leaq 96(%rsp), %rax
76         movq %rax, 64(%rsp)
77         leaq 8(%rsp), %rcx
78         movq 96(%rsp), %rdx     # Load return address if needed
79         movq 88(%rsp), %rsi     # Copy args pushed by PLT in register.
80         movq %rsi,%r11          # Multiply by 24
81         addq %r11,%rsi
82         addq %r11,%rsi
83         shlq $3, %rsi
84         movq 80(%rsp), %rdi     # %rdi: link_map, %rsi: reloc_offset
85         leaq 72(%rsp), %r8
86         call _dl_profile_fixup  # Call resolver.
87         movq %rax, %r11         # Save return value
88         movq 8(%rsp), %rdx      # Get back register content.
89         movq 16(%rsp), %r8
90         movq 24(%rsp), %r9
91         movq (%rsp),%rax
92         movq 72(%rsp), %r10
93         testq %r10, %r10
94         jns 1f
95         movq 32(%rsp), %rcx
96         movq 40(%rsp), %rsi
97         movq 48(%rsp), %rdi
98         addq $96,%rsp           # Adjust stack
99         cfi_adjust_cfa_offset (-96)
100         jmp *%r11               # Jump to function address.
102         /*
103             +96     return address
104             +88     PLT2
105             +80     PLT1
106             +72     free
107             +64     %rsp
108             +56     %rbp
109             +48     %rdi
110             +40     %rsi
111             +32     %rcx
112             +24     %r9
113             +16     %r8
114             +8      %rdx
115            %esp     %rax
116         */
117         cfi_adjust_cfa_offset (96)
118 1:      movq %rbx, 72(%rsp)
119         cfi_rel_offset (1, 72)
120         leaq 104(%rsp), %rsi
121         movq %rsp, %rbx
122         cfi_def_cfa_register (1)
123         movq %r10, %rcx
124         addq $8, %r10
125         andq $0xfffffffffffffff0, %r10
126         subq %r10, %rsp
127         movq %rsp, %rdi
128         shrq $3, %rcx
129         rep
130         movsq
131         movq 32(%rbx), %rcx
132         movq 40(%rbx), %rsi
133         movq 48(%rbx), %rdi
134         call *%r11
135         movq %rbx, %rsp
136         cfi_def_cfa_register (7)
137         subq $72, %rsp
138         cfi_adjust_cfa_offset (72)
139         movq %rsp, %rcx
140         movq %rax, (%rcx)
141         movq %rdx, 8(%rcx)
142         /* Even though the stack is correctly aligned to allow using movaps
143            we use movups.  Some callers might provide an incorrectly aligned
144            stack and we do not want to have it blow up here.  */
145         movups %xmm0, 16(%rcx)
146         movups %xmm1, 32(%rcx)
147         fstpt 48(%rcx)
148         fstpt 64(%rcx)
149         /*
150             +168    return address
151             +160    PLT2
152             +152    PLT1
153             +144    free
154             +136    %rsp
155             +128    %rbp
156             +120    %rdi
157             +112    %rsi
158             +104    %rcx
159             +96     %r9
160             +88     %r8
161             +80     %rdx
162             +64     %st1 result
163             +48     %st result
164             +32     %xmm1 result
165             +16     %xmm0 result
166             +8      %rdx result
167            %esp     %rax result
168         */
169         leaq 80(%rsp), %rdx
170         movq 144(%rsp), %rbx
171         cfi_restore (1)
172         movq 160(%rsp), %rsi    # Copy args pushed by PLT in register.
173         movq %rsi,%r11          # Multiply by 24
174         addq %r11,%rsi
175         addq %r11,%rsi
176         shlq $3, %rsi
177         movq 152(%rsp), %rdi    # %rdi: link_map, %rsi: reloc_offset
178         call _dl_call_pltexit
179         movq (%rsp), %rax
180         movq 8(%rsp), %rdx
181         movups 16(%rsp), %xmm0
182         movups 32(%rsp), %xmm1
183         fldt 64(%rsp)
184         fldt 48(%rsp)
185         addq $168, %rsp
186         cfi_adjust_cfa_offset (-168)
187         retq
188         cfi_endproc
189         .size _dl_runtime_profile, .-_dl_runtime_profile
190 #endif