1 /* PLT trampolines. s390 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 /* This code is used in dl-runtime.c to call the `fixup' function
20 and then redirect to the address it returns. */
22 /* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile
23 * with the following linkage:
24 * r2 - r6 : parameter registers
25 * f0, f2 : floating point parameter registers
26 * 24(r15), 28(r15) : PLT arguments PLT1, PLT2
27 * 96(r15) : additional stack parameters
28 * The normal clobber rules for function calls apply:
29 * r0 - r5 : call clobbered
30 * r6 - r13 : call saved
31 * r14 : return address (call clobbered)
32 * r15 : stack pointer (call saved)
34 * f0 - f3, f5, f7 - f15 : call clobbered
40 .globl _dl_runtime_resolve
41 .type _dl_runtime_resolve, @function
45 stm %r2,%r5,32(%r15) # save registers
48 lr %r0,%r15 # create stack frame
50 cfi_adjust_cfa_offset (96)
52 lm %r2,%r3,120(%r15) # load args saved by PLT
55 bas %r14,0(%r14,%r1) # call resolver
56 lr %r1,%r2 # function addr returned in r2
57 ahi %r15,96 # remove stack frame
58 cfi_adjust_cfa_offset (-96)
59 l %r14,8(15) # restore registers
62 1: .long _dl_fixup - 0b
64 .size _dl_runtime_resolve, .-_dl_runtime_resolve
68 .globl _dl_runtime_profile
69 .type _dl_runtime_profile, @function
73 stm %r2,%r6,32(%r15) # save registers
84 lr %r12,%r15 # create stack frame
85 cfi_def_cfa_register (12)
88 lm %r2,%r3,24(%r12) # load arguments saved by PLT
89 lr %r4,%r14 # return address as third parameter
92 la %r5,32(%r12) # pointer to struct La_s390_32_regs
93 la %r6,20(%r12) # long int * framesize
94 bas %r14,0(%r14,%r1) # call resolver
95 lr %r1,%r2 # function addr returned in r2
96 icm %r0,15,20(%r12) # load & test framesize
102 lr %r15,%r12 # remove stack frame
103 cfi_def_cfa_register (15)
104 l %r14,16(%r15) # restore registers
106 br %r1 # tail-call to the resolved function
108 cfi_def_cfa_register (12)
109 2: jz 4f # framesize == 0 ?
110 ahi %r0,7 # align framesize to 8
113 slr %r15,%r0 # make room for framesize bytes
118 3: mvc 0(8,%r2),0(%r3) # copy additional parameters
122 4: lm %r2,%r6,32(%r12) # load register parameters
125 basr %r14,%r1 # call resolved function
128 lm %r2,%r3,24(%r12) # load arguments saved by PLT
131 la %r4,32(%r12) # pointer to struct La_s390_32_regs
132 la %r5,72(%r12) # pointer to struct La_s390_32_retval
133 basr %r14,%r1 # call _dl_call_pltexit
135 lr %r15,%r12 # remove stack frame
136 cfi_def_cfa_register (15)
137 l %r14,16(%r15) # restore registers
141 6: .long _dl_profile_fixup - 0b
142 7: .long _dl_call_pltexit - 5b
144 .size _dl_runtime_profile, .-_dl_runtime_profile