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

source code of glibc/sysdeps/m68k/dl-trampoline.S