chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / ports / sysdeps / m68k / dl-trampoline.S
1 /* PLT trampolines.  m68k version.
2    Copyright (C) 2005 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
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.
9
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.
14
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.  */
19
20 #include <sysdep.h>
21
22         .text
23         .globl _dl_runtime_resolve
24         .type _dl_runtime_resolve, @function
25 _dl_runtime_resolve:
26         | Save %a0 (struct return address) and %a1.
27         move.l %a0, -(%sp)
28         move.l %a1, -(%sp)
29         | Call the real address resolver.
30         jbsr _dl_fixup
31         | Restore register %a0 and %a1.
32         move.l (%sp)+, %a1
33         move.l (%sp)+, %a0
34         | Pop parameters
35         addq.l #8, %sp
36         | Call real function.
37 #ifdef __mcoldfire__
38         move.l %d0,-(%sp)
39         rts
40 #else
41         jmp (%d0)
42 #endif
43         .size _dl_runtime_resolve, . - _dl_runtime_resolve
44
45         .text
46         .globl _dl_runtime_profile
47         .type _dl_runtime_profile, @function
48 _dl_runtime_profile:
49         pea 8(%sp)
50         move.l %a1, -(%sp)
51         move.l %a0, -(%sp)
52         pea -1.w
53         | Push parameters for _dl_profile_fixup
54         pea (%sp)
55         pea 8(%sp)
56         move.l 32(%sp), -(%sp)
57         move.l 32(%sp), -(%sp)
58         move.l 32(%sp), -(%sp)
59         subq.l #8, %sp
60         | Call the real address resolver.
61         jbsr _dl_profile_fixup
62         | Pop parameters
63         lea 28(%sp), %sp
64         move.l (%sp), %d1
65         jpl 1f
66         addq.l #4, %sp
67         | Restore register %a0 and %a1.
68         move.l (%sp)+, %a0
69         move.l (%sp)+, %a1
70         lea 12(%sp), %sp
71         | Call real function.
72 #ifdef __mcoldfire__
73         move.l %d0,-(%sp)
74         rts
75 #else
76         jmp (%d0)
77 #endif
78
79         /*
80             +24     return address
81             +20     PLT1
82             +16     PLT2
83             +12     %sp
84             +8      %a1
85             +4      %a0
86            %sp      free
87         */
88 1:      move.l %a2, (%sp)
89         move.l %sp, %a2
90         move.l %sp, %a0
91         lea 28(%sp), %a1
92         | Round framesize up to longword alignment
93         addq.l #3, %d1
94         and.l #-3, %d1
95         sub.l %d1, %a0
96         move.l %a0, %sp
97 #ifdef __mcoldfire__
98         tst.l %d1
99         beq 2f
100 1:      move.l (%a0)+, (%a1)+
101         subq.l #4,%d1
102         bne 1b
103 2:
104 #else
105         lsr.l #2,%d1
106         jra 2f
107 1:      move.l (%a1)+, (%a0)+
108 2:      dbra %d1,1b
109 #endif
110         /*
111            %a2+24  return address
112            %a2+20  PLT1
113            %a2+16  PLT2
114            %a2+12  %sp
115            %a2+8   %a1
116            %a2+4   %a0
117            %a2     %a2
118            %sp     copied stack frame
119         */
120
121         move.l 4(%a2), %a0
122         move.l 8(%a2), %a1
123 #ifdef __mcoldfire__
124         pea 2f(%pc)
125         move.l %d0,-(%sp)
126         rts
127 2:
128 #else
129         jsr (%d0)
130 #endif
131         move.l %a2, %sp
132         move.l (%sp)+, %a2
133         /*
134             +20     return address
135             +16     PLT1
136             +12     PLT2
137             +8      %sp
138             +4      %a1
139            %sp      %a0
140         */
141 #if !defined (__mcoldfire__)
142         fmove.x %fp0, -(%sp)
143 #elif defined (__mcffpu__)
144         fmove.l %fp0, -(%sp)
145 #else
146         clr.l -(%sp)
147         clr.l -(%sp)
148 #endif
149         move.l %a0, -(%sp)
150         move.l %d1, -(%sp)
151         move.l %d0, -(%sp)
152         pea (%sp)
153 #ifdef __mcoldfire__
154         pea 24(%sp)
155         move.l 40(%sp), -(%sp)
156         move.l 40(%sp), -(%sp)
157 #else
158         pea 28(%sp)
159         move.l 44(%sp), -(%sp)
160         move.l 44(%sp), -(%sp)
161 #endif
162         jbsr _dl_call_pltexit
163         lea 16(%sp), %sp
164         move.l (%sp)+, %d0
165         move.l (%sp)+, %d1
166         move.l (%sp)+, %a0
167 #if !defined (__mcoldfire__)
168         fmove.x (%sp)+, %fp0
169         lea 20(%sp), %sp
170 #elif defined (__mcffpu__)
171         fmove.l (%sp)+, %fp0
172         lea 20(%sp), %sp
173 #else
174         lea 28(%sp), %sp
175 #endif
176         rts
177         .size _dl_runtime_profile, . - _dl_runtime_profile