1 /* PLT trampolines. s390x version.
2 Copyright (C) 2005-2014 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, see
17 <http://www.gnu.org/licenses/>. */
19 /* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile
20 * with the following linkage:
21 * r2 - r6 : parameter registers
22 * f0, f2, f4, f6 : floating point parameter registers
23 * 48(r15), 56(r15) : PLT arguments PLT1, PLT2
24 * 160(r15) : additional stack parameters
25 * The normal clobber rules for function calls apply:
26 * r0 - r5 : call clobbered
27 * r6 - r13 : call saved
28 * r14 : return address (call clobbered)
29 * r15 : stack pointer (call saved)
30 * f1, f3, f5, f7 : call saved
31 * f0 - f3, f5, f7 - f15 : call clobbered
37 .globl _dl_runtime_resolve
38 .type _dl_runtime_resolve, @function
42 stmg %r2,%r5,64(15) # save call-clobbered argument registers
46 aghi %r15,-160 # create stack frame
47 cfi_adjust_cfa_offset (160)
48 stg %r0,0(%r15) # write backchain
49 lmg %r2,%r3,208(%r15)# load args saved by PLT
50 brasl %r14,_dl_fixup # call fixup
51 lgr %r1,%r2 # function addr returned in r2
52 aghi %r15,160 # remove stack frame
53 cfi_adjust_cfa_offset (-160)
54 lg %r14,96(15) # restore registers
58 .size _dl_runtime_resolve, .-_dl_runtime_resolve
62 .globl _dl_runtime_profile
63 .type _dl_runtime_profile, @function
67 stmg %r2,%r6,64(%r15) # save call-clobbered arg regs
68 std %f0,104(%r15) # + r6 needed as arg for
69 std %f2,112(%r15) # _dl_profile_fixup
72 stg %r12,24(%r15) # r12 is used as backup of r15
79 cfi_offset (r12, -136)
80 cfi_offset (r14, -128)
81 lgr %r12,%r15 # backup stack pointer
82 cfi_def_cfa_register (12)
83 aghi %r15,-160 # create stack frame
84 stg %r12,0(%r15) # save backchain
85 lmg %r2,%r3,48(%r12) # load arguments saved by PLT
86 lgr %r4,%r14 # return address as third parameter
87 la %r5,64(%r12) # pointer to struct La_s390_32_regs
88 la %r6,40(%r12) # long int * framesize
89 brasl %r14,_dl_profile_fixup # call resolver
90 lgr %r1,%r2 # function addr returned in r2
91 lg %r0,40(%r12) # load framesize
95 lmg %r2,%r6,64(%r12) # framesize < 0 means no pltexit call
96 ld %f0,104(%r12) # so we can do a tail call without
97 ld %f2,112(%r12) # copying the arg overflow area
101 lgr %r15,%r12 # remove stack frame
102 cfi_def_cfa_register (15)
103 lg %r14,32(%r15) # restore registers
105 br %r1 # tail-call to resolved function
107 cfi_def_cfa_register (12)
108 1: jz 4f # framesize == 0 ?
109 aghi %r0,7 # align framesize to 8
111 slgr %r15,%r0 # make room for framesize bytes
116 3: mvc 0(8,%r2),0(%r3) # copy additional parameters
120 4: lmg %r2,%r6,64(%r12) # load register parameters
121 ld %f0,104(%r12) # restore call-clobbered arg regs
125 basr %r14,%r1 # call resolved function
128 lmg %r2,%r3,48(%r12) # load arguments saved by PLT
129 la %r4,32(%r12) # pointer to struct La_s390_32_regs
130 la %r5,72(%r12) # pointer to struct La_s390_32_retval
131 brasl %r14,_dl_call_pltexit
133 lgr %r15,%r12 # remove stack frame
134 cfi_def_cfa_register (15)
135 lg %r14,32(%r15) # restore registers
140 .size _dl_runtime_profile, .-_dl_runtime_profile