]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/s390/s390-64/dl-trampoline.S
Update.
[thirdparty/glibc.git] / sysdeps / s390 / s390-64 / dl-trampoline.S
1 /* PLT trampolines. s390 version.
2 Copyright (C) 2005 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 /* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile
21 * with the following linkage:
22 * r2 - r6 : parameter registers
23 * f0, f2, f4, f6 : floating point parameter registers
24 * 24(r15), 28(r15) : PLT arguments PLT1, PLT2
25 * 96(r15) : additional stack parameters
26 * The normal clobber rules for function calls apply:
27 * r0 - r5 : call clobbered
28 * r6 - r13 : call saved
29 * r14 : return address (call clobbered)
30 * r15 : stack pointer (call saved)
31 * f1, f3, f5, f7 : call saved
32 * f0 - f3, f5, f7 - f15 : call clobbered
33 */
34
35 #include <sysdep.h>
36
37 .text
38 .globl _dl_runtime_resolve
39 .type _dl_runtime_resolve, @function
40 cfi_startproc
41 .align 16
42 _dl_runtime_resolve:
43 stmg 2,5,64(15) # save registers
44 stg 14,96(15)
45 lgr 0,15 # create stack frame
46 aghi 15,-160
47 cfi_adjust_cfa_offset (160)
48 stg 0,0(15)
49 lmg 2,3,208(15) # load args saved by PLT
50 brasl 14,_dl_fixup # call fixup
51 lgr 1,2 # function addr returned in r2
52 aghi 15,160 # remove stack frame
53 cfi_adjust_cfa_offset (-160)
54 lg 14,96(15) # restore registers
55 lmg 2,5,64(15)
56 br 1
57 cfi_endproc
58 .size _dl_runtime_resolve, .-_dl_runtime_resolve
59
60
61 .globl _dl_runtime_profile
62 .type _dl_runtime_profile, @function
63 cfi_startproc
64 .align 16
65 _dl_runtime_profile:
66 stmg %r2,%r6,64(%r15) # save registers
67 std %f0,104(%r15)
68 std %f2,112(%r15)
69 std %f4,120(%r15)
70 std %f6,128(%r15)
71 stg %r6,16(%r15)
72 stg %r12,24(%r15)
73 stg %r14,32(%r15)
74 lgr %r12,%r15 # create stack frame
75 cfi_def_cfa_register (12)
76 aghi %r15,-160
77 stg %r12,0(%r15)
78 lmg %r2,%r3,48(%r12) # load arguments saved by PLT
79 lgr %r4,%r14 # return address as third parameter
80 la %r5,64(%r12) # pointer to struct La_s390_32_regs
81 la %r6,40(%r12) # long int * framesize
82 brasl %r14,_dl_profile_fixup # call resolver
83 lgr %r1,%r2 # function addr returned in r2
84 lg %r0,40(%r12) # load framesize
85 ltgr %r0,%r0
86 jnm 1f
87 lmg %r2,%r6,64(%r12)
88 ld %f0,104(%r12)
89 ld %f2,112(%r12)
90 ld %f4,120(%r12)
91 ld %f6,128(%r12)
92 basr %r14,%r1 # call resolved function
93 0: lr %r15,%r12 # remove stack frame
94 cfi_def_cfa_register (15)
95 lg %r14,32(%r15) # restore registers
96 lg %r12,24(%r15)
97 lg %r6,16(%r15)
98 br %r14
99 cfi_def_cfa_register (12)
100 1: jz 4f # framesize == 0 ?
101 aghi %r0,7 # align framesize to 8
102 nill %r0,0xfff8
103 slgr %r15,%r0 # make room for framesize bytes
104 stg %r12,0(%r15)
105 la %r2,160(%r15)
106 la %r3,160(%r12)
107 srlg %r0,%r0,3
108 3: mvc 0(8,%r2),0(%r3) # copy additional parameters
109 la %r2,8(%r2)
110 la %r3,8(%r3)
111 brctg %r0,3b
112 4: lmg %r2,%r6,64(%r12) # load register parameters
113 ld %f0,104(%r12)
114 ld %f2,112(%r12)
115 ld %f4,120(%r12)
116 ld %f6,128(%r12)
117 basr %r14,%r1 # call resolved function
118 stg %r2,136(%r12)
119 std %f0,144(%r12)
120 lmg %r2,%r3,48(%r12) # load arguments saved by PLT
121 la %r4,32(%r12) # pointer to struct La_s390_32_regs
122 la %r5,72(%r12) # pointer to struct La_s390_32_retval
123 brasl %r14,_dl_call_pltexit
124 j 0b
125 cfi_endproc
126 .size _dl_runtime_profile, .-_dl_runtime_profile