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