|
|
ce426f |
commit 4603c51ef7989d7eb800cdd6f42aab206f891077
|
|
|
ce426f |
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
ce426f |
Date: Thu Mar 31 17:37:16 2016 +0200
|
|
|
ce426f |
|
|
|
ce426f |
S390: Save and restore fprs/vrs while resolving symbols.
|
|
|
ce426f |
|
|
|
ce426f |
On s390, no fpr/vrs were saved while resolving a symbol
|
|
|
ce426f |
via _dl_runtime_resolve/_dl_runtime_profile.
|
|
|
ce426f |
|
|
|
ce426f |
According to the abi, the fpr-arguments are defined as call clobbered.
|
|
|
ce426f |
In leaf-functions, gcc 4.9 and newer can use fprs for saving/restoring gprs
|
|
|
ce426f |
instead of saving them to the stack.
|
|
|
ce426f |
If gcc do this in one of the resolver-functions, then the floating point
|
|
|
ce426f |
arguments of a library-function are invalid for the first library-function-call.
|
|
|
ce426f |
Thus, this patch saves/restores the fprs around the resolving code.
|
|
|
ce426f |
|
|
|
ce426f |
The same could occur for vector registers. Furthermore an ifunc-resolver
|
|
|
ce426f |
could also clobber the vector/floating point argument registers.
|
|
|
ce426f |
Thus this patch provides the further variants _dl_runtime_resolve_vx/
|
|
|
ce426f |
_dl_runtime_profile_vx, which are used if the kernel claims, that
|
|
|
ce426f |
we run on a machine with vector registers.
|
|
|
ce426f |
|
|
|
ce426f |
Furthermore, if _dl_runtime_profile calls _dl_call_pltexit,
|
|
|
ce426f |
the pointers to inregs-/outregs-structs were setup invalid.
|
|
|
ce426f |
Now they point to the correct location in the stack-frame.
|
|
|
ce426f |
Before branching back to the caller, the return values are now
|
|
|
ce426f |
restored instead of containing the return values of the
|
|
|
ce426f |
_dl_call_pltexit() call.
|
|
|
ce426f |
On s390-32, an endless loop occurs if _dl_call_pltexit() should be called.
|
|
|
ce426f |
Now, this code-path branches to this function instead of just after the
|
|
|
ce426f |
preceding basr-instruction.
|
|
|
ce426f |
|
|
|
ce426f |
ChangeLog:
|
|
|
ce426f |
|
|
|
ce426f |
* sysdeps/s390/s390-32/dl-trampoline.S: Include dl-trampoline.h twice
|
|
|
ce426f |
to create a non-vector/vector version for _dl_runtime_resolve and
|
|
|
ce426f |
_dl_runtime_profile. Move implementation to ...
|
|
|
ce426f |
* sysdeps/s390/s390-32/dl-trampoline.h: ... here.
|
|
|
ce426f |
(_dl_runtime_resolve) Save and restore fpr/vrs.
|
|
|
ce426f |
(_dl_runtime_profile) Save and restore vrs and fix some issues
|
|
|
ce426f |
if _dl_call_pltexit is called.
|
|
|
ce426f |
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_runtime_setup):
|
|
|
ce426f |
Choose the correct resolver function if running on a machine with vx.
|
|
|
ce426f |
* sysdeps/s390/s390-64/dl-trampoline.S: Include dl-trampoline.h twice
|
|
|
ce426f |
to create a non-vector/vector version for _dl_runtime_resolve and
|
|
|
ce426f |
_dl_runtime_profile. Move implementation to ...
|
|
|
ce426f |
* sysdeps/s390/s390-64/dl-trampoline.h: ... here.
|
|
|
ce426f |
(_dl_runtime_resolve) Save and restore fpr/vrs.
|
|
|
ce426f |
(_dl_runtime_profile) Save and restore vrs and fix some issues
|
|
|
ce426f |
* sysdeps/s390/s390-64/dl-machine.h: (elf_machine_runtime_setup):
|
|
|
ce426f |
Choose the correct resolver function if running on a machine with vx.
|
|
|
ce426f |
|
|
|
ce426f |
diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h
|
|
|
ce426f |
index 14bde3b..ec0ae4a 100644
|
|
|
ce426f |
--- a/sysdeps/s390/s390-32/dl-machine.h
|
|
|
ce426f |
+++ b/sysdeps/s390/s390-32/dl-machine.h
|
|
|
ce426f |
@@ -89,6 +89,11 @@
|
|
|
ce426f |
{
|
|
|
ce426f |
extern void _dl_runtime_resolve (Elf32_Word);
|
|
|
ce426f |
extern void _dl_runtime_profile (Elf32_Word);
|
|
|
ce426f |
+#if defined HAVE_S390_VX_ASM_SUPPORT
|
|
|
ce426f |
+ extern void _dl_runtime_resolve_vx (Elf32_Word);
|
|
|
ce426f |
+ extern void _dl_runtime_profile_vx (Elf32_Word);
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+
|
|
|
ce426f |
|
|
|
ce426f |
if (l->l_info[DT_JMPREL] && lazy)
|
|
|
ce426f |
{
|
|
|
ce426f |
@@ -116,7 +121,14 @@
|
|
|
ce426f |
end in this function. */
|
|
|
ce426f |
if (__builtin_expect (profile, 0))
|
|
|
ce426f |
{
|
|
|
ce426f |
+#if defined HAVE_S390_VX_ASM_SUPPORT
|
|
|
ce426f |
+ if (GLRO(dl_hwcap) & HWCAP_S390_VX)
|
|
|
ce426f |
+ got[2] = (Elf32_Addr) &_dl_runtime_profile_vx;
|
|
|
ce426f |
+ else
|
|
|
ce426f |
+ got[2] = (Elf32_Addr) &_dl_runtime_profile;
|
|
|
ce426f |
+#else
|
|
|
ce426f |
got[2] = (Elf32_Addr) &_dl_runtime_profile;
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
|
|
|
ce426f |
if (GLRO(dl_profile) != NULL
|
|
|
ce426f |
&& _dl_name_match_p (GLRO(dl_profile), l))
|
|
|
ce426f |
@@ -125,9 +137,18 @@
|
|
|
ce426f |
GL(dl_profile_map) = l;
|
|
|
ce426f |
}
|
|
|
ce426f |
else
|
|
|
ce426f |
- /* This function will get called to fix up the GOT entry indicated by
|
|
|
ce426f |
- the offset on the stack, and then jump to the resolved address. */
|
|
|
ce426f |
- got[2] = (Elf32_Addr) &_dl_runtime_resolve;
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ /* This function will get called to fix up the GOT entry indicated by
|
|
|
ce426f |
+ the offset on the stack, and then jump to the resolved address. */
|
|
|
ce426f |
+#if defined HAVE_S390_VX_ASM_SUPPORT
|
|
|
ce426f |
+ if (GLRO(dl_hwcap) & HWCAP_S390_VX)
|
|
|
ce426f |
+ got[2] = (Elf32_Addr) &_dl_runtime_resolve_vx;
|
|
|
ce426f |
+ else
|
|
|
ce426f |
+ got[2] = (Elf32_Addr) &_dl_runtime_resolve;
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+ got[2] = (Elf32_Addr) &_dl_runtime_resolve;
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ }
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
return lazy;
|
|
|
ce426f |
diff --git a/sysdeps/s390/s390-32/dl-trampoline.S b/sysdeps/s390/s390-32/dl-trampoline.S
|
|
|
ce426f |
index 1645610..859183c 100644
|
|
|
ce426f |
--- a/sysdeps/s390/s390-32/dl-trampoline.S
|
|
|
ce426f |
+++ b/sysdeps/s390/s390-32/dl-trampoline.S
|
|
|
ce426f |
@@ -16,130 +16,18 @@
|
|
|
ce426f |
License along with the GNU C Library; if not, see
|
|
|
ce426f |
<http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
|
|
|
ce426f |
-/* This code is used in dl-runtime.c to call the `fixup' function
|
|
|
ce426f |
- and then redirect to the address it returns. */
|
|
|
ce426f |
-
|
|
|
ce426f |
-/* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile
|
|
|
ce426f |
- * with the following linkage:
|
|
|
ce426f |
- * r2 - r6 : parameter registers
|
|
|
ce426f |
- * f0, f2 : floating point parameter registers
|
|
|
ce426f |
- * 24(r15), 28(r15) : PLT arguments PLT1, PLT2
|
|
|
ce426f |
- * 96(r15) : additional stack parameters
|
|
|
ce426f |
- * The normal clobber rules for function calls apply:
|
|
|
ce426f |
- * r0 - r5 : call clobbered
|
|
|
ce426f |
- * r6 - r13 : call saved
|
|
|
ce426f |
- * r14 : return address (call clobbered)
|
|
|
ce426f |
- * r15 : stack pointer (call saved)
|
|
|
ce426f |
- * f4, f6 : call saved
|
|
|
ce426f |
- * f0 - f3, f5, f7 - f15 : call clobbered
|
|
|
ce426f |
- */
|
|
|
ce426f |
-
|
|
|
ce426f |
#include <sysdep.h>
|
|
|
ce426f |
|
|
|
ce426f |
.text
|
|
|
ce426f |
- .globl _dl_runtime_resolve
|
|
|
ce426f |
- .type _dl_runtime_resolve, @function
|
|
|
ce426f |
- cfi_startproc
|
|
|
ce426f |
- .align 16
|
|
|
ce426f |
-_dl_runtime_resolve:
|
|
|
ce426f |
- stm %r2,%r5,32(%r15) # save registers
|
|
|
ce426f |
- st %r14,8(%r15)
|
|
|
ce426f |
- cfi_offset (r14, -88)
|
|
|
ce426f |
- lr %r0,%r15 # create stack frame
|
|
|
ce426f |
- ahi %r15,-96
|
|
|
ce426f |
- cfi_adjust_cfa_offset (96)
|
|
|
ce426f |
- st 0,0(%r15)
|
|
|
ce426f |
- lm %r2,%r3,120(%r15) # load args saved by PLT
|
|
|
ce426f |
- basr %r1,0
|
|
|
ce426f |
-0: l %r14,1f-0b(%r1)
|
|
|
ce426f |
- bas %r14,0(%r14,%r1) # call resolver
|
|
|
ce426f |
- lr %r1,%r2 # function addr returned in r2
|
|
|
ce426f |
- ahi %r15,96 # remove stack frame
|
|
|
ce426f |
- cfi_adjust_cfa_offset (-96)
|
|
|
ce426f |
- l %r14,8(15) # restore registers
|
|
|
ce426f |
- lm %r2,%r5,32(%r15)
|
|
|
ce426f |
- br %r1
|
|
|
ce426f |
-1: .long _dl_fixup - 0b
|
|
|
ce426f |
- cfi_endproc
|
|
|
ce426f |
- .size _dl_runtime_resolve, .-_dl_runtime_resolve
|
|
|
ce426f |
-
|
|
|
ce426f |
-
|
|
|
ce426f |
-#ifndef PROF
|
|
|
ce426f |
- .globl _dl_runtime_profile
|
|
|
ce426f |
- .type _dl_runtime_profile, @function
|
|
|
ce426f |
- cfi_startproc
|
|
|
ce426f |
- .align 16
|
|
|
ce426f |
-_dl_runtime_profile:
|
|
|
ce426f |
- stm %r2,%r6,32(%r15) # save registers
|
|
|
ce426f |
- std %f0,56(%r15)
|
|
|
ce426f |
- std %f2,64(%r15)
|
|
|
ce426f |
- st %r6,8(%r15)
|
|
|
ce426f |
- st %r12,12(%r15)
|
|
|
ce426f |
- st %r14,16(%r15)
|
|
|
ce426f |
- cfi_offset (r6, -64)
|
|
|
ce426f |
- cfi_offset (f0, -40)
|
|
|
ce426f |
- cfi_offset (f2, -32)
|
|
|
ce426f |
- cfi_offset (r12, -84)
|
|
|
ce426f |
- cfi_offset (r14, -80)
|
|
|
ce426f |
- lr %r12,%r15 # create stack frame
|
|
|
ce426f |
- cfi_def_cfa_register (12)
|
|
|
ce426f |
- ahi %r15,-96
|
|
|
ce426f |
- st %r12,0(%r15)
|
|
|
ce426f |
- lm %r2,%r3,24(%r12) # load arguments saved by PLT
|
|
|
ce426f |
- lr %r4,%r14 # return address as third parameter
|
|
|
ce426f |
- basr %r1,0
|
|
|
ce426f |
-0: l %r14,6f-0b(%r1)
|
|
|
ce426f |
- la %r5,32(%r12) # pointer to struct La_s390_32_regs
|
|
|
ce426f |
- la %r6,20(%r12) # long int * framesize
|
|
|
ce426f |
- bas %r14,0(%r14,%r1) # call resolver
|
|
|
ce426f |
- lr %r1,%r2 # function addr returned in r2
|
|
|
ce426f |
- icm %r0,15,20(%r12) # load & test framesize
|
|
|
ce426f |
- jnm 2f
|
|
|
ce426f |
-
|
|
|
ce426f |
- lm %r2,%r6,32(%r12)
|
|
|
ce426f |
- ld %f0,56(%r12)
|
|
|
ce426f |
- ld %f2,64(%r12)
|
|
|
ce426f |
- lr %r15,%r12 # remove stack frame
|
|
|
ce426f |
- cfi_def_cfa_register (15)
|
|
|
ce426f |
- l %r14,16(%r15) # restore registers
|
|
|
ce426f |
- l %r12,12(%r15)
|
|
|
ce426f |
- br %r1 # tail-call to the resolved function
|
|
|
ce426f |
-
|
|
|
ce426f |
- cfi_def_cfa_register (12)
|
|
|
ce426f |
-2: jz 4f # framesize == 0 ?
|
|
|
ce426f |
- ahi %r0,7 # align framesize to 8
|
|
|
ce426f |
- lhi %r2,-8
|
|
|
ce426f |
- nr %r0,%r2
|
|
|
ce426f |
- slr %r15,%r0 # make room for framesize bytes
|
|
|
ce426f |
- st %r12,0(%r15)
|
|
|
ce426f |
- la %r2,96(%r15)
|
|
|
ce426f |
- la %r3,96(%r12)
|
|
|
ce426f |
- srl %r0,3
|
|
|
ce426f |
-3: mvc 0(8,%r2),0(%r3) # copy additional parameters
|
|
|
ce426f |
- la %r2,8(%r2)
|
|
|
ce426f |
- la %r3,8(%r3)
|
|
|
ce426f |
- brct %r0,3b
|
|
|
ce426f |
-4: lm %r2,%r6,32(%r12) # load register parameters
|
|
|
ce426f |
- ld %f0,56(%r12)
|
|
|
ce426f |
- ld %f2,64(%r12)
|
|
|
ce426f |
- basr %r14,%r1 # call resolved function
|
|
|
ce426f |
- stm %r2,%r3,72(%r12)
|
|
|
ce426f |
- std %f0,80(%r12)
|
|
|
ce426f |
- lm %r2,%r3,24(%r12) # load arguments saved by PLT
|
|
|
ce426f |
- basr %r1,0
|
|
|
ce426f |
-5: l %r14,7f-5b(%r1)
|
|
|
ce426f |
- la %r4,32(%r12) # pointer to struct La_s390_32_regs
|
|
|
ce426f |
- la %r5,72(%r12) # pointer to struct La_s390_32_retval
|
|
|
ce426f |
- basr %r14,%r1 # call _dl_call_pltexit
|
|
|
ce426f |
-
|
|
|
ce426f |
- lr %r15,%r12 # remove stack frame
|
|
|
ce426f |
- cfi_def_cfa_register (15)
|
|
|
ce426f |
- l %r14,16(%r15) # restore registers
|
|
|
ce426f |
- l %r12,12(%r15)
|
|
|
ce426f |
- br %r14
|
|
|
ce426f |
-
|
|
|
ce426f |
-6: .long _dl_profile_fixup - 0b
|
|
|
ce426f |
-7: .long _dl_call_pltexit - 5b
|
|
|
ce426f |
- cfi_endproc
|
|
|
ce426f |
- .size _dl_runtime_profile, .-_dl_runtime_profile
|
|
|
ce426f |
+/* Create variant of _dl_runtime_resolve/profile for machines before z13.
|
|
|
ce426f |
+ No vector registers are saved/restored. */
|
|
|
ce426f |
+#include <dl-trampoline.h>
|
|
|
ce426f |
+
|
|
|
ce426f |
+#if defined HAVE_S390_VX_ASM_SUPPORT
|
|
|
ce426f |
+/* Create variant of _dl_runtime_resolve/profile for z13 and newer.
|
|
|
ce426f |
+ The vector registers are saved/restored, too.*/
|
|
|
ce426f |
+# define _dl_runtime_resolve _dl_runtime_resolve_vx
|
|
|
ce426f |
+# define _dl_runtime_profile _dl_runtime_profile_vx
|
|
|
ce426f |
+# define RESTORE_VRS
|
|
|
ce426f |
+# include <dl-trampoline.h>
|
|
|
ce426f |
#endif
|
|
|
ce426f |
diff --git a/sysdeps/s390/s390-32/dl-trampoline.h b/sysdeps/s390/s390-32/dl-trampoline.h
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..a152a7b
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/s390/s390-32/dl-trampoline.h
|
|
|
ce426f |
@@ -0,0 +1,215 @@
|
|
|
ce426f |
+/* PLT trampolines. s390 version.
|
|
|
ce426f |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
ce426f |
+ This file is part of the GNU C Library.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
ce426f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
ce426f |
+ License as published by the Free Software Foundation; either
|
|
|
ce426f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
ce426f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce426f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce426f |
+ Lesser General Public License for more details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
ce426f |
+ License along with the GNU C Library; if not, see
|
|
|
ce426f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+/* This code is used in dl-runtime.c to call the `fixup' function
|
|
|
ce426f |
+ and then redirect to the address it returns. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+/* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile
|
|
|
ce426f |
+ * with the following linkage:
|
|
|
ce426f |
+ * r2 - r6 : parameter registers
|
|
|
ce426f |
+ * f0, f2 : floating point parameter registers
|
|
|
ce426f |
+ * v24, v26, v28, v30, v25, v27, v29, v31 : vector parameter registers
|
|
|
ce426f |
+ * 24(r15), 28(r15) : PLT arguments PLT1, PLT2
|
|
|
ce426f |
+ * 96(r15) : additional stack parameters
|
|
|
ce426f |
+ * The normal clobber rules for function calls apply:
|
|
|
ce426f |
+ * r0 - r5 : call clobbered
|
|
|
ce426f |
+ * r6 - r13 : call saved
|
|
|
ce426f |
+ * r14 : return address (call clobbered)
|
|
|
ce426f |
+ * r15 : stack pointer (call saved)
|
|
|
ce426f |
+ * f4, f6 : call saved
|
|
|
ce426f |
+ * f0 - f3, f5, f7 - f15 : call clobbered
|
|
|
ce426f |
+ * v0 - v3, v5, v7 - v15 : bytes 0-7 overlap with fprs: call clobbered
|
|
|
ce426f |
+ bytes 8-15: call clobbered
|
|
|
ce426f |
+ * v4, v6 : bytes 0-7 overlap with f4, f6: call saved
|
|
|
ce426f |
+ bytes 8-15: call clobbered
|
|
|
ce426f |
+ * v16 - v31 : call clobbered
|
|
|
ce426f |
+ */
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .globl _dl_runtime_resolve
|
|
|
ce426f |
+ .type _dl_runtime_resolve, @function
|
|
|
ce426f |
+ cfi_startproc
|
|
|
ce426f |
+ .align 16
|
|
|
ce426f |
+_dl_runtime_resolve:
|
|
|
ce426f |
+ stm %r2,%r5,32(%r15) # save registers
|
|
|
ce426f |
+ cfi_offset (r2, -64)
|
|
|
ce426f |
+ cfi_offset (r3, -60)
|
|
|
ce426f |
+ cfi_offset (r4, -56)
|
|
|
ce426f |
+ cfi_offset (r5, -52)
|
|
|
ce426f |
+ std %f0,56(%r15)
|
|
|
ce426f |
+ cfi_offset (f0, -40)
|
|
|
ce426f |
+ std %f2,64(%r15)
|
|
|
ce426f |
+ cfi_offset (f2, -32)
|
|
|
ce426f |
+ st %r14,8(%r15)
|
|
|
ce426f |
+ cfi_offset (r14, -88)
|
|
|
ce426f |
+ lr %r0,%r15
|
|
|
ce426f |
+ lm %r2,%r3,24(%r15) # load args saved by PLT
|
|
|
ce426f |
+#ifdef RESTORE_VRS
|
|
|
ce426f |
+ ahi %r15,-224 # create stack frame
|
|
|
ce426f |
+ cfi_adjust_cfa_offset (224)
|
|
|
ce426f |
+ .machine push
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ .machinemode "zarch_nohighgprs"
|
|
|
ce426f |
+ vstm %v24,%v31,96(%r15) # store call-clobbered vr arguments
|
|
|
ce426f |
+ cfi_offset (v24, -224)
|
|
|
ce426f |
+ cfi_offset (v25, -208)
|
|
|
ce426f |
+ cfi_offset (v26, -192)
|
|
|
ce426f |
+ cfi_offset (v27, -176)
|
|
|
ce426f |
+ cfi_offset (v28, -160)
|
|
|
ce426f |
+ cfi_offset (v29, -144)
|
|
|
ce426f |
+ cfi_offset (v30, -128)
|
|
|
ce426f |
+ cfi_offset (v31, -112)
|
|
|
ce426f |
+ .machine pop
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+ ahi %r15,-96 # create stack frame
|
|
|
ce426f |
+ cfi_adjust_cfa_offset (96)
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ st %r0,0(%r15) # write backchain
|
|
|
ce426f |
+ basr %r1,0
|
|
|
ce426f |
+0: l %r14,1f-0b(%r1)
|
|
|
ce426f |
+ bas %r14,0(%r14,%r1) # call _dl_fixup
|
|
|
ce426f |
+ lr %r1,%r2 # function addr returned in r2
|
|
|
ce426f |
+#ifdef RESTORE_VRS
|
|
|
ce426f |
+ .machine push
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ .machinemode "zarch_nohighgprs"
|
|
|
ce426f |
+ vlm %v24,%v31,96(%r15) # restore vector registers
|
|
|
ce426f |
+ .machine pop
|
|
|
ce426f |
+ aghi %r15,224 # remove stack frame
|
|
|
ce426f |
+ cfi_adjust_cfa_offset (-224)
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+ ahi %r15,96 # remove stack frame
|
|
|
ce426f |
+ cfi_adjust_cfa_offset (-96)
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ l %r14,8(15) # restore registers
|
|
|
ce426f |
+ ld %f0,56(%r15)
|
|
|
ce426f |
+ ld %f2,64(%r15)
|
|
|
ce426f |
+ lm %r2,%r5,32(%r15)
|
|
|
ce426f |
+ br %r1
|
|
|
ce426f |
+1: .long _dl_fixup - 0b
|
|
|
ce426f |
+ cfi_endproc
|
|
|
ce426f |
+ .size _dl_runtime_resolve, .-_dl_runtime_resolve
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+#ifndef PROF
|
|
|
ce426f |
+ .globl _dl_runtime_profile
|
|
|
ce426f |
+ .type _dl_runtime_profile, @function
|
|
|
ce426f |
+ cfi_startproc
|
|
|
ce426f |
+ .align 16
|
|
|
ce426f |
+_dl_runtime_profile:
|
|
|
ce426f |
+ stm %r2,%r6,32(%r15) # save registers
|
|
|
ce426f |
+ cfi_offset (r2, -64) # + r6 needed as arg for
|
|
|
ce426f |
+ cfi_offset (r3, -60) # _dl_profile_fixup
|
|
|
ce426f |
+ cfi_offset (r4, -56)
|
|
|
ce426f |
+ cfi_offset (r5, -52)
|
|
|
ce426f |
+ cfi_offset (r6, -48)
|
|
|
ce426f |
+ std %f0,56(%r15)
|
|
|
ce426f |
+ cfi_offset (f0, -40)
|
|
|
ce426f |
+ std %f2,64(%r15)
|
|
|
ce426f |
+ cfi_offset (f2, -32)
|
|
|
ce426f |
+ st %r12,12(%r15) # r12 is used as backup of r15
|
|
|
ce426f |
+ cfi_offset (r12, -84)
|
|
|
ce426f |
+ st %r14,16(%r15)
|
|
|
ce426f |
+ cfi_offset (r14, -80)
|
|
|
ce426f |
+ lr %r12,%r15 # backup stack pointer
|
|
|
ce426f |
+ cfi_def_cfa_register (12)
|
|
|
ce426f |
+#ifdef RESTORE_VRS
|
|
|
ce426f |
+ ahi %r15,-224 # create stack frame
|
|
|
ce426f |
+ .machine push
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ .machinemode "zarch_nohighgprs"
|
|
|
ce426f |
+ vstm %v24,%v31,96(%r15) # store call-clobbered vr arguments
|
|
|
ce426f |
+ cfi_offset (v24, -224)
|
|
|
ce426f |
+ cfi_offset (v25, -208)
|
|
|
ce426f |
+ cfi_offset (v26, -192)
|
|
|
ce426f |
+ cfi_offset (v27, -176)
|
|
|
ce426f |
+ cfi_offset (v28, -160)
|
|
|
ce426f |
+ cfi_offset (v29, -144)
|
|
|
ce426f |
+ cfi_offset (v30, -128)
|
|
|
ce426f |
+ cfi_offset (v31, -112)
|
|
|
ce426f |
+ .machine pop
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+ ahi %r15,-96 # create stack frame
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ st %r12,0(%r15) # save backchain
|
|
|
ce426f |
+ lm %r2,%r3,24(%r12) # load arguments saved by PLT
|
|
|
ce426f |
+ lr %r4,%r14 # return address as third parameter
|
|
|
ce426f |
+ basr %r1,0
|
|
|
ce426f |
+0: l %r14,6f-0b(%r1)
|
|
|
ce426f |
+ la %r5,32(%r12) # pointer to struct La_s390_32_regs
|
|
|
ce426f |
+ la %r6,20(%r12) # long int * framesize
|
|
|
ce426f |
+ bas %r14,0(%r14,%r1) # call resolver
|
|
|
ce426f |
+ lr %r1,%r2 # function addr returned in r2
|
|
|
ce426f |
+ ld %f0,56(%r12) # restore call-clobbered arg fprs
|
|
|
ce426f |
+ ld %f2,64(%r12)
|
|
|
ce426f |
+#ifdef RESTORE_VRS
|
|
|
ce426f |
+ .machine push
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ .machinemode "zarch_nohighgprs"
|
|
|
ce426f |
+ vlm %v24,%v31,96(%r15) # restore call-clobbered arg vrs
|
|
|
ce426f |
+ .machine pop
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ icm %r0,15,20(%r12) # load & test framesize
|
|
|
ce426f |
+ jnm 2f
|
|
|
ce426f |
+
|
|
|
ce426f |
+ lm %r2,%r6,32(%r12)
|
|
|
ce426f |
+ lr %r15,%r12 # remove stack frame
|
|
|
ce426f |
+ cfi_def_cfa_register (15)
|
|
|
ce426f |
+ l %r14,16(%r15) # restore registers
|
|
|
ce426f |
+ l %r12,12(%r15)
|
|
|
ce426f |
+ br %r1 # tail-call to the resolved function
|
|
|
ce426f |
+
|
|
|
ce426f |
+ cfi_def_cfa_register (12)
|
|
|
ce426f |
+2: jz 4f # framesize == 0 ?
|
|
|
ce426f |
+ ahi %r0,7 # align framesize to 8
|
|
|
ce426f |
+ lhi %r2,-8
|
|
|
ce426f |
+ nr %r0,%r2
|
|
|
ce426f |
+ slr %r15,%r0 # make room for framesize bytes
|
|
|
ce426f |
+ st %r12,0(%r15) # save backchain
|
|
|
ce426f |
+ la %r2,96(%r15)
|
|
|
ce426f |
+ la %r3,96(%r12)
|
|
|
ce426f |
+ srl %r0,3
|
|
|
ce426f |
+3: mvc 0(8,%r2),0(%r3) # copy additional parameters
|
|
|
ce426f |
+ la %r2,8(%r2)
|
|
|
ce426f |
+ la %r3,8(%r3)
|
|
|
ce426f |
+ brct %r0,3b
|
|
|
ce426f |
+4: lm %r2,%r6,32(%r12) # load register parameters
|
|
|
ce426f |
+ basr %r14,%r1 # call resolved function
|
|
|
ce426f |
+ stm %r2,%r3,72(%r12) # store return values r2, r3, f0
|
|
|
ce426f |
+ std %f0,80(%r12) # to struct La_s390_32_retval
|
|
|
ce426f |
+ lm %r2,%r3,24(%r12) # load arguments saved by PLT
|
|
|
ce426f |
+ basr %r1,0
|
|
|
ce426f |
+5: l %r14,7f-5b(%r1)
|
|
|
ce426f |
+ la %r4,32(%r12) # pointer to struct La_s390_32_regs
|
|
|
ce426f |
+ la %r5,72(%r12) # pointer to struct La_s390_32_retval
|
|
|
ce426f |
+ bas %r14,0(%r14,%r1) # call _dl_call_pltexit
|
|
|
ce426f |
+
|
|
|
ce426f |
+ lr %r15,%r12 # remove stack frame
|
|
|
ce426f |
+ cfi_def_cfa_register (15)
|
|
|
ce426f |
+ l %r14,16(%r15) # restore registers
|
|
|
ce426f |
+ l %r12,12(%r15)
|
|
|
ce426f |
+ l %r2,72(%r15) # restore return values
|
|
|
ce426f |
+ l %r3,76(%r15)
|
|
|
ce426f |
+ ld %f0,80(%r15)
|
|
|
ce426f |
+ br %r14
|
|
|
ce426f |
+
|
|
|
ce426f |
+6: .long _dl_profile_fixup - 0b
|
|
|
ce426f |
+7: .long _dl_call_pltexit - 5b
|
|
|
ce426f |
+ cfi_endproc
|
|
|
ce426f |
+ .size _dl_runtime_profile, .-_dl_runtime_profile
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h
|
|
|
ce426f |
index cb81aaf..9ee7c92 100644
|
|
|
ce426f |
--- a/sysdeps/s390/s390-64/dl-machine.h
|
|
|
ce426f |
+++ b/sysdeps/s390/s390-64/dl-machine.h
|
|
|
ce426f |
@@ -26,6 +26,7 @@
|
|
|
ce426f |
#include <sys/param.h>
|
|
|
ce426f |
#include <string.h>
|
|
|
ce426f |
#include <link.h>
|
|
|
ce426f |
+#include <sysdeps/s390/dl-procinfo.h>
|
|
|
ce426f |
#include <dl-irel.h>
|
|
|
ce426f |
|
|
|
ce426f |
#define ELF_MACHINE_IRELATIVE R_390_IRELATIVE
|
|
|
ce426f |
@@ -78,6 +79,10 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
|
|
ce426f |
{
|
|
|
ce426f |
extern void _dl_runtime_resolve (Elf64_Word);
|
|
|
ce426f |
extern void _dl_runtime_profile (Elf64_Word);
|
|
|
ce426f |
+#if defined HAVE_S390_VX_ASM_SUPPORT
|
|
|
ce426f |
+ extern void _dl_runtime_resolve_vx (Elf64_Word);
|
|
|
ce426f |
+ extern void _dl_runtime_profile_vx (Elf64_Word);
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
|
|
|
ce426f |
if (l->l_info[DT_JMPREL] && lazy)
|
|
|
ce426f |
{
|
|
|
ce426f |
@@ -105,7 +110,14 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
|
|
ce426f |
end in this function. */
|
|
|
ce426f |
if (__builtin_expect (profile, 0))
|
|
|
ce426f |
{
|
|
|
ce426f |
+#if defined HAVE_S390_VX_ASM_SUPPORT
|
|
|
ce426f |
+ if (GLRO(dl_hwcap) & HWCAP_S390_VX)
|
|
|
ce426f |
+ got[2] = (Elf64_Addr) &_dl_runtime_profile_vx;
|
|
|
ce426f |
+ else
|
|
|
ce426f |
+ got[2] = (Elf64_Addr) &_dl_runtime_profile;
|
|
|
ce426f |
+#else
|
|
|
ce426f |
got[2] = (Elf64_Addr) &_dl_runtime_profile;
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
|
|
|
ce426f |
if (GLRO(dl_profile) != NULL
|
|
|
ce426f |
&& _dl_name_match_p (GLRO(dl_profile), l))
|
|
|
ce426f |
@@ -114,9 +126,18 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
|
|
ce426f |
GL(dl_profile_map) = l;
|
|
|
ce426f |
}
|
|
|
ce426f |
else
|
|
|
ce426f |
- /* This function will get called to fix up the GOT entry indicated by
|
|
|
ce426f |
- the offset on the stack, and then jump to the resolved address. */
|
|
|
ce426f |
- got[2] = (Elf64_Addr) &_dl_runtime_resolve;
|
|
|
ce426f |
+ {
|
|
|
ce426f |
+ /* This function will get called to fix up the GOT entry indicated by
|
|
|
ce426f |
+ the offset on the stack, and then jump to the resolved address. */
|
|
|
ce426f |
+#if defined HAVE_S390_VX_ASM_SUPPORT
|
|
|
ce426f |
+ if (GLRO(dl_hwcap) & HWCAP_S390_VX)
|
|
|
ce426f |
+ got[2] = (Elf64_Addr) &_dl_runtime_resolve_vx;
|
|
|
ce426f |
+ else
|
|
|
ce426f |
+ got[2] = (Elf64_Addr) &_dl_runtime_resolve;
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+ got[2] = (Elf64_Addr) &_dl_runtime_resolve;
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ }
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
return lazy;
|
|
|
ce426f |
diff --git a/sysdeps/s390/s390-64/dl-trampoline.S b/sysdeps/s390/s390-64/dl-trampoline.S
|
|
|
ce426f |
index 6919ed0..1b0c9e2 100644
|
|
|
ce426f |
--- a/sysdeps/s390/s390-64/dl-trampoline.S
|
|
|
ce426f |
+++ b/sysdeps/s390/s390-64/dl-trampoline.S
|
|
|
ce426f |
@@ -16,126 +16,18 @@
|
|
|
ce426f |
License along with the GNU C Library; if not, see
|
|
|
ce426f |
<http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
|
|
|
ce426f |
-/* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile
|
|
|
ce426f |
- * with the following linkage:
|
|
|
ce426f |
- * r2 - r6 : parameter registers
|
|
|
ce426f |
- * f0, f2, f4, f6 : floating point parameter registers
|
|
|
ce426f |
- * 48(r15), 56(r15) : PLT arguments PLT1, PLT2
|
|
|
ce426f |
- * 160(r15) : additional stack parameters
|
|
|
ce426f |
- * The normal clobber rules for function calls apply:
|
|
|
ce426f |
- * r0 - r5 : call clobbered
|
|
|
ce426f |
- * r6 - r13 : call saved
|
|
|
ce426f |
- * r14 : return address (call clobbered)
|
|
|
ce426f |
- * r15 : stack pointer (call saved)
|
|
|
ce426f |
- * f1, f3, f5, f7 : call saved
|
|
|
ce426f |
- * f0 - f3, f5, f7 - f15 : call clobbered
|
|
|
ce426f |
- */
|
|
|
ce426f |
-
|
|
|
ce426f |
#include <sysdep.h>
|
|
|
ce426f |
|
|
|
ce426f |
.text
|
|
|
ce426f |
- .globl _dl_runtime_resolve
|
|
|
ce426f |
- .type _dl_runtime_resolve, @function
|
|
|
ce426f |
- cfi_startproc
|
|
|
ce426f |
- .align 16
|
|
|
ce426f |
-_dl_runtime_resolve:
|
|
|
ce426f |
- stmg %r2,%r5,64(15) # save call-clobbered argument registers
|
|
|
ce426f |
- stg %r14,96(15)
|
|
|
ce426f |
- cfi_offset (r14, -64)
|
|
|
ce426f |
- lgr %r0,%r15
|
|
|
ce426f |
- aghi %r15,-160 # create stack frame
|
|
|
ce426f |
- cfi_adjust_cfa_offset (160)
|
|
|
ce426f |
- stg %r0,0(%r15) # write backchain
|
|
|
ce426f |
- lmg %r2,%r3,208(%r15)# load args saved by PLT
|
|
|
ce426f |
- brasl %r14,_dl_fixup # call fixup
|
|
|
ce426f |
- lgr %r1,%r2 # function addr returned in r2
|
|
|
ce426f |
- aghi %r15,160 # remove stack frame
|
|
|
ce426f |
- cfi_adjust_cfa_offset (-160)
|
|
|
ce426f |
- lg %r14,96(15) # restore registers
|
|
|
ce426f |
- lmg %r2,%r5,64(15)
|
|
|
ce426f |
- br %r1
|
|
|
ce426f |
- cfi_endproc
|
|
|
ce426f |
- .size _dl_runtime_resolve, .-_dl_runtime_resolve
|
|
|
ce426f |
-
|
|
|
ce426f |
-
|
|
|
ce426f |
-#ifndef PROF
|
|
|
ce426f |
- .globl _dl_runtime_profile
|
|
|
ce426f |
- .type _dl_runtime_profile, @function
|
|
|
ce426f |
- cfi_startproc
|
|
|
ce426f |
- .align 16
|
|
|
ce426f |
-_dl_runtime_profile:
|
|
|
ce426f |
- stmg %r2,%r6,64(%r15) # save call-clobbered arg regs
|
|
|
ce426f |
- std %f0,104(%r15) # + r6 needed as arg for
|
|
|
ce426f |
- std %f2,112(%r15) # _dl_profile_fixup
|
|
|
ce426f |
- std %f4,120(%r15)
|
|
|
ce426f |
- std %f6,128(%r15)
|
|
|
ce426f |
- stg %r12,24(%r15) # r12 is used as backup of r15
|
|
|
ce426f |
- stg %r14,32(%r15)
|
|
|
ce426f |
- cfi_offset (r6, -96)
|
|
|
ce426f |
- cfi_offset (f0, -56)
|
|
|
ce426f |
- cfi_offset (f2, -48)
|
|
|
ce426f |
- cfi_offset (f4, -40)
|
|
|
ce426f |
- cfi_offset (f6, -32)
|
|
|
ce426f |
- cfi_offset (r12, -136)
|
|
|
ce426f |
- cfi_offset (r14, -128)
|
|
|
ce426f |
- lgr %r12,%r15 # backup stack pointer
|
|
|
ce426f |
- cfi_def_cfa_register (12)
|
|
|
ce426f |
- aghi %r15,-160 # create stack frame
|
|
|
ce426f |
- stg %r12,0(%r15) # save backchain
|
|
|
ce426f |
- lmg %r2,%r3,48(%r12) # load arguments saved by PLT
|
|
|
ce426f |
- lgr %r4,%r14 # return address as third parameter
|
|
|
ce426f |
- la %r5,64(%r12) # pointer to struct La_s390_32_regs
|
|
|
ce426f |
- la %r6,40(%r12) # long int * framesize
|
|
|
ce426f |
- brasl %r14,_dl_profile_fixup # call resolver
|
|
|
ce426f |
- lgr %r1,%r2 # function addr returned in r2
|
|
|
ce426f |
- lg %r0,40(%r12) # load framesize
|
|
|
ce426f |
- ltgr %r0,%r0
|
|
|
ce426f |
- jnm 1f
|
|
|
ce426f |
-
|
|
|
ce426f |
- lmg %r2,%r6,64(%r12) # framesize < 0 means no pltexit call
|
|
|
ce426f |
- ld %f0,104(%r12) # so we can do a tail call without
|
|
|
ce426f |
- ld %f2,112(%r12) # copying the arg overflow area
|
|
|
ce426f |
- ld %f4,120(%r12)
|
|
|
ce426f |
- ld %f6,128(%r12)
|
|
|
ce426f |
-
|
|
|
ce426f |
- lgr %r15,%r12 # remove stack frame
|
|
|
ce426f |
- cfi_def_cfa_register (15)
|
|
|
ce426f |
- lg %r14,32(%r15) # restore registers
|
|
|
ce426f |
- lg %r12,24(%r15)
|
|
|
ce426f |
- br %r1 # tail-call to resolved function
|
|
|
ce426f |
-
|
|
|
ce426f |
- cfi_def_cfa_register (12)
|
|
|
ce426f |
-1: jz 4f # framesize == 0 ?
|
|
|
ce426f |
- aghi %r0,7 # align framesize to 8
|
|
|
ce426f |
- nill %r0,0xfff8
|
|
|
ce426f |
- slgr %r15,%r0 # make room for framesize bytes
|
|
|
ce426f |
- stg %r12,0(%r15)
|
|
|
ce426f |
- la %r2,160(%r15)
|
|
|
ce426f |
- la %r3,160(%r12)
|
|
|
ce426f |
- srlg %r0,%r0,3
|
|
|
ce426f |
-3: mvc 0(8,%r2),0(%r3) # copy additional parameters
|
|
|
ce426f |
- la %r2,8(%r2)
|
|
|
ce426f |
- la %r3,8(%r3)
|
|
|
ce426f |
- brctg %r0,3b
|
|
|
ce426f |
-4: lmg %r2,%r6,64(%r12) # load register parameters
|
|
|
ce426f |
- ld %f0,104(%r12) # restore call-clobbered arg regs
|
|
|
ce426f |
- ld %f2,112(%r12)
|
|
|
ce426f |
- ld %f4,120(%r12)
|
|
|
ce426f |
- ld %f6,128(%r12)
|
|
|
ce426f |
- basr %r14,%r1 # call resolved function
|
|
|
ce426f |
- stg %r2,136(%r12)
|
|
|
ce426f |
- std %f0,144(%r12)
|
|
|
ce426f |
- lmg %r2,%r3,48(%r12) # load arguments saved by PLT
|
|
|
ce426f |
- la %r4,32(%r12) # pointer to struct La_s390_32_regs
|
|
|
ce426f |
- la %r5,72(%r12) # pointer to struct La_s390_32_retval
|
|
|
ce426f |
- brasl %r14,_dl_call_pltexit
|
|
|
ce426f |
-
|
|
|
ce426f |
- lgr %r15,%r12 # remove stack frame
|
|
|
ce426f |
- cfi_def_cfa_register (15)
|
|
|
ce426f |
- lg %r14,32(%r15) # restore registers
|
|
|
ce426f |
- lg %r12,24(%r15)
|
|
|
ce426f |
- br %r14
|
|
|
ce426f |
-
|
|
|
ce426f |
- cfi_endproc
|
|
|
ce426f |
- .size _dl_runtime_profile, .-_dl_runtime_profile
|
|
|
ce426f |
+/* Create variant of _dl_runtime_resolve/profile for machines before z13.
|
|
|
ce426f |
+ No vector registers are saved/restored. */
|
|
|
ce426f |
+#include <dl-trampoline.h>
|
|
|
ce426f |
+
|
|
|
ce426f |
+#if defined HAVE_S390_VX_ASM_SUPPORT
|
|
|
ce426f |
+/* Create variant of _dl_runtime_resolve/profile for z13 and newer.
|
|
|
ce426f |
+ The vector registers are saved/restored, too.*/
|
|
|
ce426f |
+# define _dl_runtime_resolve _dl_runtime_resolve_vx
|
|
|
ce426f |
+# define _dl_runtime_profile _dl_runtime_profile_vx
|
|
|
ce426f |
+# define RESTORE_VRS
|
|
|
ce426f |
+# include <dl-trampoline.h>
|
|
|
ce426f |
#endif
|
|
|
ce426f |
diff --git a/sysdeps/s390/s390-64/dl-trampoline.h b/sysdeps/s390/s390-64/dl-trampoline.h
|
|
|
ce426f |
new file mode 100644
|
|
|
ce426f |
index 0000000..658e3a3
|
|
|
ce426f |
--- /dev/null
|
|
|
ce426f |
+++ b/sysdeps/s390/s390-64/dl-trampoline.h
|
|
|
ce426f |
@@ -0,0 +1,211 @@
|
|
|
ce426f |
+/* PLT trampolines. s390x version.
|
|
|
ce426f |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
ce426f |
+ This file is part of the GNU C Library.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
ce426f |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
ce426f |
+ License as published by the Free Software Foundation; either
|
|
|
ce426f |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
ce426f |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce426f |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce426f |
+ Lesser General Public License for more details.
|
|
|
ce426f |
+
|
|
|
ce426f |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
ce426f |
+ License along with the GNU C Library; if not, see
|
|
|
ce426f |
+ <http://www.gnu.org/licenses/>. */
|
|
|
ce426f |
+
|
|
|
ce426f |
+/* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile
|
|
|
ce426f |
+ * with the following linkage:
|
|
|
ce426f |
+ * r2 - r6 : parameter registers
|
|
|
ce426f |
+ * f0, f2, f4, f6 : floating point parameter registers
|
|
|
ce426f |
+ * v24, v26, v28, v30, v25, v27, v29, v31 : vector parameter registers
|
|
|
ce426f |
+ * 48(r15), 56(r15) : PLT arguments PLT1, PLT2
|
|
|
ce426f |
+ * 160(r15) : additional stack parameters
|
|
|
ce426f |
+ * The normal clobber rules for function calls apply:
|
|
|
ce426f |
+ * r0 - r5 : call clobbered
|
|
|
ce426f |
+ * r6 - r13 : call saved
|
|
|
ce426f |
+ * r14 : return address (call clobbered)
|
|
|
ce426f |
+ * r15 : stack pointer (call saved)
|
|
|
ce426f |
+ * f0 - f7 : call clobbered
|
|
|
ce426f |
+ * f8 - f15 : call saved
|
|
|
ce426f |
+ * v0 - v7 : bytes 0-7 overlap with f0-f7: call clobbered
|
|
|
ce426f |
+ bytes 8-15: call clobbered
|
|
|
ce426f |
+ * v8 - v15 : bytes 0-7 overlap with f8-f15: call saved
|
|
|
ce426f |
+ bytes 8-15: call clobbered
|
|
|
ce426f |
+ * v16 - v31 : call clobbered
|
|
|
ce426f |
+ */
|
|
|
ce426f |
+
|
|
|
ce426f |
+ .globl _dl_runtime_resolve
|
|
|
ce426f |
+ .type _dl_runtime_resolve, @function
|
|
|
ce426f |
+ cfi_startproc
|
|
|
ce426f |
+ .align 16
|
|
|
ce426f |
+_dl_runtime_resolve:
|
|
|
ce426f |
+ stmg %r2,%r5,64(%r15) # save call-clobbered argument registers
|
|
|
ce426f |
+ cfi_offset (r2, -96)
|
|
|
ce426f |
+ cfi_offset (r3, -88)
|
|
|
ce426f |
+ cfi_offset (r4, -80)
|
|
|
ce426f |
+ cfi_offset (r5, -72)
|
|
|
ce426f |
+ std %f0,104(%r15)
|
|
|
ce426f |
+ cfi_offset (f0, -56)
|
|
|
ce426f |
+ std %f2,112(%r15)
|
|
|
ce426f |
+ cfi_offset (f2, -48)
|
|
|
ce426f |
+ std %f4,120(%r15)
|
|
|
ce426f |
+ cfi_offset (f4, -40)
|
|
|
ce426f |
+ std %f6,128(%r15)
|
|
|
ce426f |
+ cfi_offset (f6, -32)
|
|
|
ce426f |
+ stg %r14,96(15)
|
|
|
ce426f |
+ cfi_offset (r14, -64)
|
|
|
ce426f |
+ lmg %r2,%r3,48(%r15) # load args for fixup saved by PLT
|
|
|
ce426f |
+ lgr %r0,%r15
|
|
|
ce426f |
+#ifdef RESTORE_VRS
|
|
|
ce426f |
+ aghi %r15,-288 # create stack frame
|
|
|
ce426f |
+ cfi_adjust_cfa_offset (288)
|
|
|
ce426f |
+ .machine push
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ vstm %v24,%v31,160(%r15)# store call-clobbered vector argument registers
|
|
|
ce426f |
+ cfi_offset (v24, -288)
|
|
|
ce426f |
+ cfi_offset (v25, -272)
|
|
|
ce426f |
+ cfi_offset (v26, -256)
|
|
|
ce426f |
+ cfi_offset (v27, -240)
|
|
|
ce426f |
+ cfi_offset (v28, -224)
|
|
|
ce426f |
+ cfi_offset (v29, -208)
|
|
|
ce426f |
+ cfi_offset (v30, -192)
|
|
|
ce426f |
+ cfi_offset (v31, -176)
|
|
|
ce426f |
+ .machine pop
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+ aghi %r15,-160 # create stack frame
|
|
|
ce426f |
+ cfi_adjust_cfa_offset (160)
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ stg %r0,0(%r15) # write backchain
|
|
|
ce426f |
+ brasl %r14,_dl_fixup # call _dl_fixup
|
|
|
ce426f |
+ lgr %r1,%r2 # function addr returned in r2
|
|
|
ce426f |
+#ifdef RESTORE_VRS
|
|
|
ce426f |
+ .machine push
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ vlm %v24,%v31,160(%r15)# restore vector registers
|
|
|
ce426f |
+ .machine pop
|
|
|
ce426f |
+ aghi %r15,288 # remove stack frame
|
|
|
ce426f |
+ cfi_adjust_cfa_offset (-288)
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+ aghi %r15,160 # remove stack frame
|
|
|
ce426f |
+ cfi_adjust_cfa_offset (-160)
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ lg %r14,96(%r15) # restore registers
|
|
|
ce426f |
+ ld %f0,104(%r15)
|
|
|
ce426f |
+ ld %f2,112(%r15)
|
|
|
ce426f |
+ ld %f4,120(%r15)
|
|
|
ce426f |
+ ld %f6,128(%r15)
|
|
|
ce426f |
+ lmg %r2,%r5,64(%r15)
|
|
|
ce426f |
+ br %r1
|
|
|
ce426f |
+ cfi_endproc
|
|
|
ce426f |
+ .size _dl_runtime_resolve, .-_dl_runtime_resolve
|
|
|
ce426f |
+
|
|
|
ce426f |
+
|
|
|
ce426f |
+#ifndef PROF
|
|
|
ce426f |
+ .globl _dl_runtime_profile
|
|
|
ce426f |
+ .type _dl_runtime_profile, @function
|
|
|
ce426f |
+ cfi_startproc
|
|
|
ce426f |
+ .align 16
|
|
|
ce426f |
+_dl_runtime_profile:
|
|
|
ce426f |
+ stmg %r2,%r6,64(%r15) # save call-clobbered arg regs
|
|
|
ce426f |
+ cfi_offset (r2, -96) # + r6 needed as arg for
|
|
|
ce426f |
+ cfi_offset (r3, -88) # _dl_profile_fixup
|
|
|
ce426f |
+ cfi_offset (r4, -80)
|
|
|
ce426f |
+ cfi_offset (r5, -72)
|
|
|
ce426f |
+ cfi_offset (r6, -64)
|
|
|
ce426f |
+ std %f0,104(%r15)
|
|
|
ce426f |
+ cfi_offset (f0, -56)
|
|
|
ce426f |
+ std %f2,112(%r15)
|
|
|
ce426f |
+ cfi_offset (f2, -48)
|
|
|
ce426f |
+ std %f4,120(%r15)
|
|
|
ce426f |
+ cfi_offset (f4, -40)
|
|
|
ce426f |
+ std %f6,128(%r15)
|
|
|
ce426f |
+ cfi_offset (f6, -32)
|
|
|
ce426f |
+ stg %r12,24(%r15) # r12 is used as backup of r15
|
|
|
ce426f |
+ cfi_offset (r12, -136)
|
|
|
ce426f |
+ stg %r14,32(%r15)
|
|
|
ce426f |
+ cfi_offset (r14, -128)
|
|
|
ce426f |
+ lgr %r12,%r15 # backup stack pointer
|
|
|
ce426f |
+ cfi_def_cfa_register (12)
|
|
|
ce426f |
+#ifdef RESTORE_VRS
|
|
|
ce426f |
+ aghi %r15,-288 # create stack frame
|
|
|
ce426f |
+ .machine push
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ vstm %v24,%v31,160(%r15)# store call-clobbered vector argument registers
|
|
|
ce426f |
+ cfi_offset (v24, -288)
|
|
|
ce426f |
+ cfi_offset (v25, -272)
|
|
|
ce426f |
+ cfi_offset (v26, -256)
|
|
|
ce426f |
+ cfi_offset (v27, -240)
|
|
|
ce426f |
+ cfi_offset (v28, -224)
|
|
|
ce426f |
+ cfi_offset (v29, -208)
|
|
|
ce426f |
+ cfi_offset (v30, -192)
|
|
|
ce426f |
+ cfi_offset (v31, -176)
|
|
|
ce426f |
+ .machine pop
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+ aghi %r15,-160 # create stack frame
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ stg %r12,0(%r15) # save backchain
|
|
|
ce426f |
+ lmg %r2,%r3,48(%r12) # load arguments saved by PLT
|
|
|
ce426f |
+ lgr %r4,%r14 # return address as third parameter
|
|
|
ce426f |
+ la %r5,64(%r12) # pointer to struct La_s390_64_regs
|
|
|
ce426f |
+ la %r6,40(%r12) # long int * framesize
|
|
|
ce426f |
+ brasl %r14,_dl_profile_fixup # call resolver
|
|
|
ce426f |
+ lgr %r1,%r2 # function addr returned in r2
|
|
|
ce426f |
+ ld %f0,104(%r12) # restore call-clobbered arg fprs
|
|
|
ce426f |
+ ld %f2,112(%r12)
|
|
|
ce426f |
+ ld %f4,120(%r12)
|
|
|
ce426f |
+ ld %f6,128(%r12)
|
|
|
ce426f |
+#ifdef RESTORE_VRS
|
|
|
ce426f |
+ .machine push
|
|
|
ce426f |
+ .machine "z13"
|
|
|
ce426f |
+ vlm %v24,%v31,160(%r15) # restore call-clobbered arg vrs
|
|
|
ce426f |
+ .machine pop
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ lg %r0,40(%r12) # load framesize
|
|
|
ce426f |
+ ltgr %r0,%r0
|
|
|
ce426f |
+ jnm 1f
|
|
|
ce426f |
+
|
|
|
ce426f |
+ lmg %r2,%r6,64(%r12) # framesize < 0 means no pltexit call
|
|
|
ce426f |
+ # so we can do a tail call without
|
|
|
ce426f |
+ # copying the arg overflow area
|
|
|
ce426f |
+ lgr %r15,%r12 # remove stack frame
|
|
|
ce426f |
+ cfi_def_cfa_register (15)
|
|
|
ce426f |
+ lg %r14,32(%r15) # restore registers
|
|
|
ce426f |
+ lg %r12,24(%r15)
|
|
|
ce426f |
+ br %r1 # tail-call to resolved function
|
|
|
ce426f |
+
|
|
|
ce426f |
+ cfi_def_cfa_register (12)
|
|
|
ce426f |
+1: jz 4f # framesize == 0 ?
|
|
|
ce426f |
+ aghi %r0,7 # align framesize to 8
|
|
|
ce426f |
+ nill %r0,0xfff8
|
|
|
ce426f |
+ slgr %r15,%r0 # make room for framesize bytes
|
|
|
ce426f |
+ stg %r12,0(%r15) # save backchain
|
|
|
ce426f |
+ la %r2,160(%r15)
|
|
|
ce426f |
+ la %r3,160(%r12)
|
|
|
ce426f |
+ srlg %r0,%r0,3
|
|
|
ce426f |
+3: mvc 0(8,%r2),0(%r3) # copy additional parameters
|
|
|
ce426f |
+ la %r2,8(%r2) # depending on framesize
|
|
|
ce426f |
+ la %r3,8(%r3)
|
|
|
ce426f |
+ brctg %r0,3b
|
|
|
ce426f |
+4: lmg %r2,%r6,64(%r12) # restore call-clobbered arg gprs
|
|
|
ce426f |
+ basr %r14,%r1 # call resolved function
|
|
|
ce426f |
+ stg %r2,136(%r12) # store return values r2, f0
|
|
|
ce426f |
+ std %f0,144(%r12) # to struct La_s390_64_retval
|
|
|
ce426f |
+ lmg %r2,%r3,48(%r12) # load arguments saved by PLT
|
|
|
ce426f |
+ la %r4,64(%r12) # pointer to struct La_s390_64_regs
|
|
|
ce426f |
+ la %r5,136(%r12) # pointer to struct La_s390_64_retval
|
|
|
ce426f |
+ brasl %r14,_dl_call_pltexit
|
|
|
ce426f |
+
|
|
|
ce426f |
+ lgr %r15,%r12 # remove stack frame
|
|
|
ce426f |
+ cfi_def_cfa_register (15)
|
|
|
ce426f |
+ lg %r14,32(%r15) # restore registers
|
|
|
ce426f |
+ lg %r12,24(%r15)
|
|
|
ce426f |
+ lg %r2,136(%r15) # restore return values
|
|
|
ce426f |
+ ld %f0,144(%r15)
|
|
|
ce426f |
+ br %r14 # Jump back to caller
|
|
|
ce426f |
+
|
|
|
ce426f |
+ cfi_endproc
|
|
|
ce426f |
+ .size _dl_runtime_profile, .-_dl_runtime_profile
|
|
|
ce426f |
+#endif
|