2.9
[glibc/nacl-glibc.git] / sysdeps / sparc / sparc32 / dl-trampoline.S
blobb0f86dda4ec3d9fef194810797272f89658088e5
1 /* PLT trampolines.  Sparc 32-bit version.
2    Copyright (C) 2005 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         .align  32
25         /* %g1: PLT offset loaded by PLT entry
26          * %g2: callers PC, which is PLT0 + 4, and we store the
27          *      link map at PLT0 + 12, therefore we add 8 to get
28          *      the address of the link map
29          */
30         .globl  _dl_runtime_resolve
31         .type   _dl_runtime_resolve, @function
32 _dl_runtime_resolve:
33         cfi_startproc
35         save    %sp, -104, %sp
36         cfi_def_cfa_register(%fp)
37         cfi_window_save
38         cfi_register (%o7, %i7)
40         ld      [%g2 + 8], %o0
41         srl     %g1, 10, %o1
42         call    _dl_fixup
43          sub    %o1, 4*12, %o1
44         jmp     %o0
45          restore
47         cfi_endproc
49         .size   _dl_runtime_resolve, .-_dl_runtime_resolve
51         /* For the profiling cases we pass in our stack frame
52          * as the base of the La_sparc64_regs, so it looks
53          * like:
54          *      %l0                     %sp
55          *      ...
56          *      %l7                     %sp + (7 * 8)
57          *      %i0                     %sp + (8 * 8)
58          *      ...
59          *      %i7                     %sp + (15 * 8)
60          *      %f0                     %sp + (16 * 8)
61          *      %f16                    %sp + (31 * 8)
62          *      framesize               %sp + (32 * 8)
63          */
65         .globl  _dl_profile_save_regs
66         .type   _dl_profile_save_regs, @function
67 _dl_profile_save_regs:
68         cfi_startproc
70         std     %l0, [%sp + ( 0 * 8)]
71         std     %l2, [%sp + ( 1 * 8)]
72         std     %l4, [%sp + ( 2 * 8)]
73         std     %l6, [%sp + ( 3 * 8)]
74         std     %i0, [%sp + ( 4 * 8)]
75         std     %i2, [%sp + ( 5 * 8)]
76         std     %i4, [%sp + ( 6 * 8)]
77         std     %i6, [%sp + ( 7 * 8)]
78         ld      [%sp + (8 * 8)], %l4
79         retl
80          st     %l4, [%sp + (8 * 8)]
82         cfi_endproc
84         .size   _dl_profile_save_regs, .-_dl_profile_save_regs
86         /* If we are going to call pltexit, then we must replicate
87          * the caller's stack frame.
88          * %o0: PLT resolved function address
89          */
90         .globl  _dl_profile_invoke
91         .type   _dl_profile_invoke, @function
92 _dl_profile_invoke:
93         cfi_startproc
95         sub     %sp, %l0, %sp
97         srl     %l0, 3, %l7
98         mov     %o0, %l1
99         mov     %i0, %o0
100         mov     %i1, %o1
101         mov     %i2, %o2
102         mov     %i3, %o3
103         mov     %i4, %o4
104         mov     %i5, %o5
105         mov     %fp, %l2
106         mov     %sp, %l3
107 1:      ldd     [%l2], %g2
108         add     %l2, 0x8, %l2
109         subcc   %l7, 1, %l7
110         std     %g2, [%l3]
111         bne     1b
112          add    %l3, 0x8, %l3
114         jmpl    %l1, %o7
115          nop
117         std     %o0, [%sp + ( 9 * 8)]
118         std     %f0, [%sp + (10 * 8)]
120         mov     %l5, %o0
121         mov     %l6, %o1
122         add     %sp, %l0, %o2
123         call    _dl_call_pltexit
124          add    %sp, (16 * 8), %o3
126         ldd     [%sp + (9 * 8)], %i0
128         jmpl    %i7 + 8, %g0
129          restore
131         cfi_endproc
133         .size   _dl_profile_invoke, .-_dl_profile_invoke
135         /* %g1: PLT offset loaded by PLT entry
136          * %g2: callers PC, which is PLT0 + 4, and we store the
137          *      link map at PLT0 + 12, therefore we add 8 to get
138          *      the address of the link map
139          */
140         .align  32
141         .globl  _dl_runtime_profile
142         .type   _dl_runtime_profile, @function
143 _dl_runtime_profile:
144         cfi_startproc
146         cmp     %fp, 0
147         be,a    1f
148          mov    104, %g3
149         sub     %fp, %sp, %g3
150 1:      save    %sp, -104, %sp
151         cfi_def_cfa_register(%fp)
152         cfi_window_save
153         cfi_register(%o7, %i7)
155         ld      [%g2 + 8], %o0
156         srl     %g1, 10, %o1
157         mov     %i7, %o2
158         sub     %o1, 4*12, %o1
160         mov     %g3, %l0
161         mov     %o0, %l5
162         mov     %o1, %l6
164         call _dl_profile_save_regs
165          nop
167         mov     %sp, %o3
168         call    _dl_profile_fixup
169          add    %sp, (9 * 8), %o4
171         ld      [%sp + (9 * 8)], %o1
172         cmp     %o1, 0
173         bgeu    1f
174          nop
175         
176         call    _dl_profile_invoke
177          nop
179 1:      jmp     %o0
180          restore
182         cfi_endproc
184         .size   _dl_runtime_profile, .-_dl_runtime_profile