Add even more cfi to s390 asm files.
[glibc.git] / sysdeps / s390 / s390-64 / dl-trampoline.S
blobb49c68108d0b34a93e83fd480d031857874b3b20
1 /* PLT trampolines.  s390 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 /* 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  */
35 #include <sysdep.h>
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         cfi_offset (r14, -64)
46         lgr    0,15             # create stack frame
47         aghi   15,-160
48         cfi_adjust_cfa_offset (160)
49         stg    0,0(15)
50         lmg    2,3,208(15)      # load args saved by PLT
51         brasl  14,_dl_fixup     # call fixup
52         lgr    1,2              # function addr returned in r2
53         aghi   15,160           # remove stack frame
54         cfi_adjust_cfa_offset (-160)
55         lg     14,96(15)        # restore registers
56         lmg    2,5,64(15)
57         br     1
58         cfi_endproc
59         .size _dl_runtime_resolve, .-_dl_runtime_resolve
62 #ifndef PROF
63         .globl _dl_runtime_profile
64         .type _dl_runtime_profile, @function
65         cfi_startproc
66         .align 16
67 _dl_runtime_profile:
68         stmg   %r2,%r6,64(%r15)         # save registers
69         std    %f0,104(%r15)
70         std    %f2,112(%r15)
71         std    %f4,120(%r15)
72         std    %f6,128(%r15)
73         stg    %r6,16(%r15)
74         stg    %r12,24(%r15)
75         stg    %r14,32(%r15)
76         cfi_offset (r6, -96)
77         cfi_offset (f0, -56)
78         cfi_offset (f2, -48)
79         cfi_offset (f4, -40)
80         cfi_offset (f6, -32)
81         cfi_offset (r12, -136)
82         cfi_offset (r14, -128)
83         lgr    %r12,%r15                # create stack frame
84         cfi_def_cfa_register (12)
85         aghi   %r15,-160
86         stg    %r12,0(%r15)
87         lmg    %r2,%r3,48(%r12)         # load arguments saved by PLT
88         lgr    %r4,%r14                 # return address as third parameter
89         la     %r5,64(%r12)             # pointer to struct La_s390_32_regs
90         la     %r6,40(%r12)             # long int * framesize
91         brasl  %r14,_dl_profile_fixup   # call resolver
92         lgr    %r1,%r2                  # function addr returned in r2
93         lg     %r0,40(%r12)             # load framesize
94         ltgr   %r0,%r0
95         jnm    1f
96         lmg    %r2,%r6,64(%r12)
97         ld     %f0,104(%r12)
98         ld     %f2,112(%r12)
99         ld     %f4,120(%r12)
100         ld     %f6,128(%r12)
101         basr   %r14,%r1                 # call resolved function
102 0:      lgr    %r15,%r12                # remove stack frame
103         cfi_def_cfa_register (15)
104         lg     %r14,32(%r15)            # restore registers
105         lg     %r12,24(%r15)
106         lg     %r6,16(%r15)
107         br     %r14
108         cfi_def_cfa_register (12)
109 1:      jz     4f                       # framesize == 0 ?
110         aghi   %r0,7                    # align framesize to 8
111         nill   %r0,0xfff8
112         slgr   %r15,%r0                 # make room for framesize bytes
113         stg    %r12,0(%r15)
114         la     %r2,160(%r15)
115         la     %r3,160(%r12)
116         srlg   %r0,%r0,3
117 3:      mvc    0(8,%r2),0(%r3)          # copy additional parameters
118         la     %r2,8(%r2)
119         la     %r3,8(%r3)
120         brctg  %r0,3b
121 4:      lmg    %r2,%r6,64(%r12)         # load register parameters
122         ld     %f0,104(%r12)
123         ld     %f2,112(%r12)
124         ld     %f4,120(%r12)
125         ld     %f6,128(%r12)
126         basr   %r14,%r1                 # call resolved function
127         stg    %r2,136(%r12)
128         std    %f0,144(%r12)
129         lmg    %r2,%r3,48(%r12)         # load arguments saved by PLT
130         la     %r4,32(%r12)             # pointer to struct La_s390_32_regs
131         la     %r5,72(%r12)             # pointer to struct La_s390_32_retval
132         brasl  %r14,_dl_call_pltexit
133         j      0b
134         cfi_endproc
135         .size _dl_runtime_profile, .-_dl_runtime_profile
136 #endif