Add Changelog ...
[glibc.git] / sysdeps / m68k / dl-trampoline.S
blobfad1864588fe10faa872e985d7fe7802bc1a1793
1 /* PLT trampolines.  m68k version.
2    Copyright (C) 2005, 2011, 2012 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, see
17    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
21         .text
22         .globl _dl_runtime_resolve
23         .type _dl_runtime_resolve, @function
24 _dl_runtime_resolve:
25         cfi_startproc
26         cfi_adjust_cfa_offset (8)
27         | Save %a0 (struct return address) and %a1.
28         move.l %a0, -(%sp)
29         cfi_adjust_cfa_offset (4)
30         move.l %a1, -(%sp)
31         cfi_adjust_cfa_offset (4)
32         | Call the real address resolver.
33         jbsr _dl_fixup
34         | Restore register %a0 and %a1.
35         move.l (%sp)+, %a1
36         cfi_adjust_cfa_offset (-4)
37         move.l (%sp)+, %a0
38         cfi_adjust_cfa_offset (-4)
39         | Pop parameters
40         addq.l #8, %sp
41         cfi_adjust_cfa_offset (-8)
42         | Call real function.
43 #ifdef __mcoldfire__
44         move.l %d0,-(%sp)
45         cfi_adjust_cfa_offset (4)
46         rts
47 #else
48         jmp (%d0)
49 #endif
50         cfi_endproc
51         .size _dl_runtime_resolve, . - _dl_runtime_resolve
53         .text
54         .globl _dl_runtime_profile
55         .type _dl_runtime_profile, @function
56 _dl_runtime_profile:
57         cfi_startproc
58         cfi_adjust_cfa_offset (8)
59         pea 8(%sp)
60         cfi_adjust_cfa_offset (4)
61         move.l %a1, -(%sp)
62         cfi_adjust_cfa_offset (4)
63         move.l %a0, -(%sp)
64         cfi_adjust_cfa_offset (4)
65         pea -1.w
66         cfi_adjust_cfa_offset (4)
67         | Push parameters for _dl_profile_fixup
68         pea (%sp)
69         cfi_adjust_cfa_offset (4)
70         pea 8(%sp)
71         cfi_adjust_cfa_offset (4)
72         move.l 32(%sp), -(%sp)
73         cfi_adjust_cfa_offset (4)
74         move.l 32(%sp), -(%sp)
75         cfi_adjust_cfa_offset (4)
76         move.l 32(%sp), -(%sp)
77         cfi_adjust_cfa_offset (4)
78         subq.l #8, %sp
79         cfi_adjust_cfa_offset (8)
80         | Call the real address resolver.
81         jbsr _dl_profile_fixup
82         | Pop parameters
83         lea 28(%sp), %sp
84         cfi_adjust_cfa_offset (-28)
85         move.l (%sp), %d1
86         jpl 1f
87         addq.l #4, %sp
88         cfi_adjust_cfa_offset (-4)
89         | Restore register %a0 and %a1.
90         move.l (%sp)+, %a0
91         cfi_adjust_cfa_offset (-4)
92         move.l (%sp)+, %a1
93         cfi_adjust_cfa_offset (-4)
94         lea 12(%sp), %sp
95         cfi_adjust_cfa_offset (-12)
96         | Call real function.
97 #ifdef __mcoldfire__
98         move.l %d0,-(%sp)
99         cfi_adjust_cfa_offset (4)
100         rts
101 #else
102         jmp (%d0)
103 #endif
105         /*
106             +24     return address
107             +20     PLT1
108             +16     PLT2
109             +12     %sp
110             +8      %a1
111             +4      %a0
112            %sp      free
113         */
114 #ifdef __mcoldfire__
115         cfi_adjust_cfa_offset (20)
116 #else
117         cfi_adjust_cfa_offset (24)
118 #endif
119 1:      move.l %a2, (%sp)
120         cfi_rel_offset (%a2, 0)
121         move.l %sp, %a2
122         move.l %sp, %a0
123         lea 28(%sp), %a1
124         | Round framesize up to longword alignment
125         addq.l #3, %d1
126         and.l #-3, %d1
127         sub.l %d1, %a0
128         move.l %a0, %sp
129         cfi_def_cfa_register (%a2)
130 #ifdef __mcoldfire__
131         tst.l %d1
132         beq 2f
133 1:      move.l (%a0)+, (%a1)+
134         subq.l #4,%d1
135         bne 1b
137 #else
138         lsr.l #2,%d1
139         jra 2f
140 1:      move.l (%a1)+, (%a0)+
141 2:      dbra %d1,1b
142 #endif
143         /*
144            %a2+24  return address
145            %a2+20  PLT1
146            %a2+16  PLT2
147            %a2+12  %sp
148            %a2+8   %a1
149            %a2+4   %a0
150            %a2     %a2
151            %sp     copied stack frame
152         */
154         move.l 4(%a2), %a0
155         move.l 8(%a2), %a1
156 #ifdef __mcoldfire__
157         pea 2f(%pc)
158         move.l %d0,-(%sp)
159         rts
161 #else
162         jsr (%d0)
163 #endif
164         move.l %a2, %sp
165         cfi_def_cfa_register (%sp)
166         move.l (%sp)+, %a2
167         cfi_adjust_cfa_offset (4)
168         cfi_restore (%a2)
169         /*
170             +20     return address
171             +16     PLT1
172             +12     PLT2
173             +8      %sp
174             +4      %a1
175            %sp      %a0
176         */
177 #ifdef __mcoldfire__
178         fmove.d %fp0, -(%sp)
179         cfi_adjust_cfa_offset (8)
180 #else
181         fmove.x %fp0, -(%sp)
182         cfi_adjust_cfa_offset (12)
183 #endif
184         move.l %a0, -(%sp)
185         cfi_adjust_cfa_offset (4)
186         move.l %d1, -(%sp)
187         cfi_adjust_cfa_offset (4)
188         move.l %d0, -(%sp)
189         cfi_adjust_cfa_offset (4)
190         pea (%sp)
191         cfi_adjust_cfa_offset (4)
192 #ifdef __mcoldfire__
193         pea 24(%sp)
194         cfi_adjust_cfa_offset (4)
195         move.l 40(%sp), -(%sp)
196         cfi_adjust_cfa_offset (4)
197         move.l 40(%sp), -(%sp)
198         cfi_adjust_cfa_offset (4)
199 #else
200         pea 28(%sp)
201         cfi_adjust_cfa_offset (4)
202         move.l 44(%sp), -(%sp)
203         cfi_adjust_cfa_offset (4)
204         move.l 44(%sp), -(%sp)
205         cfi_adjust_cfa_offset (4)
206 #endif
207         jbsr _dl_call_pltexit
208         lea 16(%sp), %sp
209         cfi_adjust_cfa_offset (-16)
210         move.l (%sp)+, %d0
211         cfi_adjust_cfa_offset (-4)
212         move.l (%sp)+, %d1
213         cfi_adjust_cfa_offset (-4)
214         move.l (%sp)+, %a0
215         cfi_adjust_cfa_offset (-4)
216 #ifdef __mcoldfire__
217         fmove.d (%sp)+, %fp0
218         cfi_adjust_cfa_offset (-8)
219 #else
220         fmove.x (%sp)+, %fp0
221         cfi_adjust_cfa_offset (-12)
222 #endif
223         lea 20(%sp), %sp
224         cfi_adjust_cfa_offset (-20)
225         rts
226         cfi_endproc
227         .size _dl_runtime_profile, . - _dl_runtime_profile