2.9
[glibc/nacl-glibc.git] / sysdeps / powerpc / powerpc32 / dl-trampoline.S
blob6a158c3fffcfaeb3f3092bb36c1a19bf0ca1361e
1 /* PLT trampolines.  PPC32 version.
2    Copyright (C) 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston MA
18    02110-1301 USA.  */
20 #include <sysdep.h>
22         .section ".text"
23         .align 2
24         .globl _dl_runtime_resolve
25         .type _dl_runtime_resolve,@function
26 _dl_runtime_resolve:
27         cfi_startproc
28  # We need to save the registers used to pass parameters, and register 0,
29  # which is used by _mcount; the registers are saved in a stack frame.
30         stwu r1,-64(r1)
31         cfi_adjust_cfa_offset (64)
32         stw r0,12(r1)
33         stw r3,16(r1)
34         stw r4,20(r1)
35  # The code that calls this has put parameters for `fixup' in r12 and r11.
36         mr r3,r12
37         stw r5,24(r1)
38         mr r4,r11
39         stw r6,28(r1)
40         mflr r0
41  # We also need to save some of the condition register fields
42         stw r7,32(r1)
43  # Don't clobber the caller's LRSAVE, it is needed by _mcount.
44         stw r0,48(r1)
45         cfi_offset (lr, -16)
46         stw r8,36(r1)
47         mfcr r0
48         stw r9,40(r1)
49         stw r10,44(r1)
50         stw r0,8(r1)
51         bl _dl_fixup@local
52  # 'fixup' returns the address we want to branch to.
53         mtctr r3
54  # Put the registers back...
55         lwz r0,48(r1)
56         lwz r10,44(r1)
57         lwz r9,40(r1)
58         mtlr r0
59         lwz r8,36(r1)
60         lwz r0,8(r1)
61         lwz r7,32(r1)
62         lwz r6,28(r1)
63         mtcrf 0xFF,r0
64         lwz r5,24(r1)
65         lwz r4,20(r1)
66         lwz r3,16(r1)
67         lwz r0,12(r1)
68  # ...unwind the stack frame, and jump to the PLT entry we updated.
69         addi r1,r1,64
70         bctr
71         cfi_endproc
72         .size    _dl_runtime_resolve,.-_dl_runtime_resolve
74 #ifndef PROF
75         .align 2
76         .globl _dl_prof_resolve
77         .type _dl_prof_resolve,@function
78 _dl_prof_resolve:
79         cfi_startproc
80  # We need to save the registers used to pass parameters, and register 0,
81  # which is used by _mcount; the registers are saved in a stack frame.
82         stwu r1,-320(r1)
83         cfi_adjust_cfa_offset (320)
84         /* Stack layout:
86           +312   stackframe
87           +308   lr
88           +304   r1
89           +288   v12
90           +272   v11
91           +256   v10
92           +240   v9
93           +224   v8
94           +208   v7
95           +192   v6
96           +176   v5
97           +160   v4
98           +144   v3
99           +128   v2
100           +112   v1
101           +104   fp8
102           +96    fp7
103           +88    fp6
104           +80    fp5
105           +72    fp4
106           +64    fp3
107           +56    fp2
108           +48    fp1
109           +44    r10
110           +40    r9
111           +36    r8
112           +32    r7
113           +28    r6
114           +24    r5
115           +20    r4
116           +16    r3
117           +12    r0
118           +8     cr
119            r1    link
120         */
121         stw r0,12(r1)
122         stw r3,16(r1)
123         stw r4,20(r1)
124  # The code that calls this has put parameters for `fixup' in r12 and r11.
125         mr r3,r12
126         stw r5,24(r1)
127         mr r4,r11
128         stw r6,28(r1)
129         mflr r5
130  # We also need to save some of the condition register fields.
131         stw r7,32(r1)
132  # Don't clobber the caller's LRSAVE, it is needed by _mcount.
133         stw r5,308(r1)
134         cfi_offset (lr, -12)
135         stw r8,36(r1)
136         mfcr r0
137         stw r9,40(r1)
138         stw r10,44(r1)
139         stw r0,8(r1)
140  # Save the floating point registers
141         stfd fp1,48(r1)
142         stfd fp2,56(r1)
143         stfd fp3,64(r1)
144         stfd fp4,72(r1)
145         stfd fp5,80(r1)
146         stfd fp6,88(r1)
147         stfd fp7,96(r1)
148         stfd fp8,104(r1)
149  # XXX TODO: store vmx registers
150  # Load the extra parameters.
151         addi r6,r1,16
152         addi r7,r1,312
153         li r0,-1
154         stw r0,0(r7)
155         bl _dl_profile_fixup@local
156  # 'fixup' returns the address we want to branch to.
157         mtctr r3
158  # Put the registers back...
159         lwz r0,308(r1)
160         lwz r10,44(r1)
161         lwz r9,40(r1)
162         mtlr r0
163         lwz r8,36(r1)
164         lwz r0,8(r1)
165         lwz r7,32(r1)
166         lwz r6,28(r1)
167         mtcrf 0xFF,r0
168         lwz r5,24(r1)
169         lwz r4,20(r1)
170         lwz r3,16(r1)
171         lwz r0,12(r1)
172  # Load the floating point registers.
173         lfd fp1,48(r1)
174         lfd fp2,56(r1)
175         lfd fp3,64(r1)
176         lfd fp4,72(r1)
177         lfd fp5,80(r1)
178         lfd fp6,88(r1)
179         lfd fp7,96(r1)
180         lfd fp8,104(r1)
181  # ...unwind the stack frame, and jump to the PLT entry we updated.
182         addi r1,r1,320
183         bctr
184         cfi_endproc
185         .size    _dl_prof_resolve,.-_dl_prof_resolve
186 #endif