[03/12] S390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_resolve

Message ID 20180802075735.3457-4-iii@linux.ibm.com
State New
Headers show
Series
  • S390: Implement __fentry__
Related show

Commit Message

Ilya Leoshkevich Aug. 2, 2018, 7:57 a.m.
Maintainability improvement.

         * sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
           Use symbolic offsets for stack variables.
---
 sysdeps/s390/s390-64/dl-trampoline.h | 124 ++++++++++++++++++---------
 1 file changed, 83 insertions(+), 41 deletions(-)

-- 
2.18.0

Patch

diff --git a/sysdeps/s390/s390-64/dl-trampoline.h b/sysdeps/s390/s390-64/dl-trampoline.h
index d313fd521d..0a74694fad 100644
--- a/sysdeps/s390/s390-64/dl-trampoline.h
+++ b/sysdeps/s390/s390-64/dl-trampoline.h
@@ -37,47 +37,71 @@ 
  *   v16 - v31 : call clobbered
  */
 
+#define CFA_OFF 160
+#define FRAME_OFF CFA_OFF + FRAME_SIZE
+#define V24_OFF -288
+#define V25_OFF -272
+#define V26_OFF -256
+#define V27_OFF -240
+#define V28_OFF -224
+#define V29_OFF -208
+#define V30_OFF -192
+#define V31_OFF -176
+#define PLT1_OFF -112
+#define PLT2_OFF -104
+#define R2_OFF -96
+#define R3_OFF -88
+#define R4_OFF -80
+#define R5_OFF -72
+#define R14_OFF -64
+#define R15_OFF -56
+#define F0_OFF -48
+#define F2_OFF -40
+#define F4_OFF -32
+#define F6_OFF -24
 	.globl _dl_runtime_resolve
 	.type _dl_runtime_resolve, @function
 	cfi_startproc
 	.align 16
 _dl_runtime_resolve:
-	stmg   %r2,%r5,64(%r15)	# save call-clobbered argument registers
-	cfi_offset (r2, -96)
-	cfi_offset (r3, -88)
-	cfi_offset (r4, -80)
-	cfi_offset (r5, -72)
-	stmg   %r14,%r15,96(%r15)
-	cfi_offset (r14, -64)
-	cfi_offset (r15, -56)
-	std    %f0,112(%r15)
-	cfi_offset (f0, -48)
-	std    %f2,120(%r15)
-	cfi_offset (f2, -40)
-	std    %f4,128(%r15)
-	cfi_offset (f4, -32)
-	std    %f6,136(%r15)
-	cfi_offset (f6, -24)
-	lmg    %r2,%r3,48(%r15) # load args for fixup saved by PLT
+	stmg   %r2,%r5,CFA_OFF+R2_OFF(%r15) # save registers
+	cfi_offset (r2, R2_OFF)
+	cfi_offset (r3, R3_OFF)
+	cfi_offset (r4, R4_OFF)
+	cfi_offset (r5, R5_OFF)
+	stmg   %r14,%r15,CFA_OFF+R14_OFF(%r15)
+	cfi_offset (r14, R14_OFF)
+	cfi_offset (r15, R15_OFF)
+	std    %f0,CFA_OFF+F0_OFF(%r15)
+	cfi_offset (f0, F0_OFF)
+	std    %f2,CFA_OFF+F2_OFF(%r15)
+	cfi_offset (f2, F2_OFF)
+	std    %f4,CFA_OFF+F4_OFF(%r15)
+	cfi_offset (f4, F4_OFF)
+	std    %f6,CFA_OFF+F6_OFF(%r15)
+	cfi_offset (f6, F6_OFF)
+	lmg    %r2,%r3,CFA_OFF+PLT1_OFF(%r15) # load args saved by PLT
 	lgr    %r0,%r15
 #ifdef RESTORE_VRS
-	aghi   %r15,-288        # create stack frame
-	cfi_adjust_cfa_offset (288)
+# define FRAME_SIZE (CFA_OFF + 128)
+	aghi   %r15,-FRAME_SIZE # create stack frame
+	cfi_adjust_cfa_offset (FRAME_SIZE)
 	.machine push
 	.machine "z13"
-	vstm   %v24,%v31,160(%r15)# store call-clobbered vector argument registers
-	cfi_offset (v24, -288)
-	cfi_offset (v25, -272)
-	cfi_offset (v26, -256)
-	cfi_offset (v27, -240)
-	cfi_offset (v28, -224)
-	cfi_offset (v29, -208)
-	cfi_offset (v30, -192)
-	cfi_offset (v31, -176)
+	vstm   %v24,%v31,FRAME_OFF+V24_OFF(%r15) # save call-clobbered vr args
+	cfi_offset (v24, V24_OFF)
+	cfi_offset (v25, V25_OFF)
+	cfi_offset (v26, V26_OFF)
+	cfi_offset (v27, V27_OFF)
+	cfi_offset (v28, V28_OFF)
+	cfi_offset (v29, V29_OFF)
+	cfi_offset (v30, V30_OFF)
+	cfi_offset (v31, V31_OFF)
 	.machine pop
 #else
-	aghi   %r15,-160        # create stack frame
-	cfi_adjust_cfa_offset (160)
+# define FRAME_SIZE CFA_OFF
+	aghi   %r15,-FRAME_SIZE # create stack frame
+	cfi_adjust_cfa_offset (FRAME_SIZE)
 #endif
 	stg    %r0,0(%r15)      # write backchain
 	brasl  %r14,_dl_fixup	# call _dl_fixup
@@ -85,22 +109,40 @@  _dl_runtime_resolve:
 #ifdef RESTORE_VRS
 	.machine push
 	.machine "z13"
-	vlm    %v24,%v31,160(%r15)# restore vector registers
+	vlm    %v24,%v31,FRAME_OFF+V24_OFF(%r15) # restore vector registers
 	.machine pop
-	lmg    %r14,%r15,384(%r15)# remove stack frame and restore registers
-#else
-	lmg    %r14,%r15,256(%r15)# remove stack frame and restore registers
 #endif
-	cfi_def_cfa_offset (160)
-	ld     %f0,112(%r15)
-	ld     %f2,120(%r15)
-	ld     %f4,128(%r15)
-	ld     %f6,136(%r15)
-	lmg    %r2,%r5,64(%r15)
+	lmg    %r14,%r15,FRAME_OFF+R14_OFF(%r15) # restore frame and registers
+#undef FRAME_SIZE
+	cfi_def_cfa_offset (CFA_OFF)
+	ld     %f0,CFA_OFF+F0_OFF(%r15)
+	ld     %f2,CFA_OFF+F2_OFF(%r15)
+	ld     %f4,CFA_OFF+F4_OFF(%r15)
+	ld     %f6,CFA_OFF+F6_OFF(%r15)
+	lmg    %r2,%r5,CFA_OFF+R2_OFF(%r15)
 	br     %r1
 	cfi_endproc
 	.size _dl_runtime_resolve, .-_dl_runtime_resolve
-
+#undef V24_OFF
+#undef V25_OFF
+#undef V26_OFF
+#undef V27_OFF
+#undef V28_OFF
+#undef V29_OFF
+#undef V30_OFF
+#undef V31_OFF
+#undef PLT1_OFF
+#undef PLT2_OFF
+#undef R2_OFF
+#undef R3_OFF
+#undef R4_OFF
+#undef R5_OFF
+#undef R14_OFF
+#undef R15_OFF
+#undef F0_OFF
+#undef F2_OFF
+#undef F4_OFF
+#undef F6_OFF
 
 #ifndef PROF
 	.globl _dl_runtime_profile