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