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