00db10
# commit 8b8a692cfd7d80f1ee7c8b9ab356a259367dd187
00db10
# Author: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
00db10
# Date:   Wed Dec 4 06:55:03 2013 -0600
00db10
# 
00db10
#     PowerPC64 ELFv2 ABI 4/6: Stack frame layout changes
00db10
#     
00db10
#     This updates glibc for the changes in the ELFv2 relating to the
00db10
#     stack frame layout.  These are described in more detail here:
00db10
#     http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01149.html
00db10
#     http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01146.html
00db10
#     
00db10
#     Specifically, the "compiler and linker doublewords" were removed,
00db10
#     which has the effect that the save slot for the TOC register is
00db10
#     now at offset 24 rather than 40 to the stack pointer.
00db10
#     
00db10
#     In addition, a function may now no longer necessarily assume that
00db10
#     its caller has set up a 64-byte register save area its use.
00db10
#     
00db10
#     To address the first change, the patch goes through all assembler
00db10
#     files and replaces immediate offsets in instructions accessing the
00db10
#     ABI-defined stack slots by symbolic offsets.  Those already were
00db10
#     defined in ucontext_i.sym and used in some of the context routines,
00db10
#     but that doesn't really seem like the right place for those defines.
00db10
#     
00db10
#     The patch instead defines those symbolic offsets in sysdeps.h,
00db10
#     in two variants for the old and new ABI, and uses them systematically
00db10
#     in all assembler files, not just the context routines.
00db10
#     
00db10
#     The second change only affected a few assembler files that used
00db10
#     the save area to temporarily store some registers.  In those
00db10
#     cases where this happens within a leaf function, this patch
00db10
#     changes the code to store those registers to the "red zone"
00db10
#     below the stack pointer.  Otherwise, the functions already allocate
00db10
#     a stack frame, and the patch changes them to add extra space in
00db10
#     these frames as temporary space for the ELFv2 ABI.
00db10
# 
00db10
diff -urN glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
00db10
--- glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h	2014-05-29 14:10:00.000000000 -0500
00db10
+++ glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -31,6 +31,14 @@
00db10
 #  define DASHDASHPFX(str) __##str
00db10
 # endif
00db10
 
00db10
+#if _CALL_ELF == 2
00db10
+#define CANCEL_FRAMESIZE (FRAME_MIN_SIZE+16+48)
00db10
+#define CANCEL_PARM_SAVE (FRAME_MIN_SIZE+16)
00db10
+#else
00db10
+#define CANCEL_FRAMESIZE (FRAME_MIN_SIZE+16)
00db10
+#define CANCEL_PARM_SAVE (CANCEL_FRAMESIZE+FRAME_PARM_SAVE)
00db10
+#endif
00db10
+
00db10
 # undef PSEUDO
00db10
 # define PSEUDO(name, syscall_name, args)				\
00db10
   .section ".text";							\
00db10
@@ -44,52 +52,52 @@
00db10
     PSEUDO_RET;								\
00db10
   .size DASHDASHPFX(syscall_name##_nocancel),.-DASHDASHPFX(syscall_name##_nocancel);	\
00db10
   .Lpseudo_cancel:							\
00db10
-    stdu 1,-128(1);							\
00db10
-    cfi_adjust_cfa_offset (128);					\
00db10
+    stdu 1,-CANCEL_FRAMESIZE(1);					\
00db10
+    cfi_adjust_cfa_offset (CANCEL_FRAMESIZE);				\
00db10
     mflr 9;								\
00db10
-    std  9,128+16(1);							\
00db10
-    cfi_offset (lr, 16);						\
00db10
+    std  9,CANCEL_FRAMESIZE+FRAME_LR_SAVE(1);				\
00db10
+    cfi_offset (lr, FRAME_LR_SAVE);					\
00db10
     DOCARGS_##args;	/* save syscall args around CENABLE.  */	\
00db10
     CENABLE;								\
00db10
-    std  3,112(1);	/* store CENABLE return value (MASK).  */	\
00db10
+    std  3,FRAME_MIN_SIZE(1); /* store CENABLE return value (MASK).  */	\
00db10
     UNDOCARGS_##args;	/* restore syscall args.  */			\
00db10
     DO_CALL (SYS_ify (syscall_name));					\
00db10
     mfcr 0;		/* save CR/R3 around CDISABLE.  */		\
00db10
-    std  3,120(1);							\
00db10
-    std  0,128+8(1);							\
00db10
-    cfi_offset (cr, 8);							\
00db10
-    ld   3,112(1);	/* pass MASK to CDISABLE.  */			\
00db10
+    std  3,FRAME_MIN_SIZE+8(1);						\
00db10
+    std  0,CANCEL_FRAMESIZE+FRAME_CR_SAVE(1);				\
00db10
+    cfi_offset (cr, FRAME_CR_SAVE);					\
00db10
+    ld   3,FRAME_MIN_SIZE(1); /* pass MASK to CDISABLE.  */		\
00db10
     CDISABLE;								\
00db10
-    ld   9,128+16(1);							\
00db10
-    ld   0,128+8(1);	/* restore CR/R3. */				\
00db10
-    ld   3,120(1);							\
00db10
+    ld   9,CANCEL_FRAMESIZE+FRAME_LR_SAVE(1);				\
00db10
+    ld   0,CANCEL_FRAMESIZE+FRAME_CR_SAVE(1); /* restore CR/R3. */	\
00db10
+    ld   3,FRAME_MIN_SIZE+8(1);						\
00db10
     mtlr 9;								\
00db10
     mtcr 0;								\
00db10
-    addi 1,1,128;							\
00db10
-    cfi_adjust_cfa_offset (-128);					\
00db10
+    addi 1,1,CANCEL_FRAMESIZE;						\
00db10
+    cfi_adjust_cfa_offset (-CANCEL_FRAMESIZE);				\
00db10
     cfi_restore (lr);							\
00db10
     cfi_restore (cr)
00db10
 
00db10
 # define DOCARGS_0
00db10
 # define UNDOCARGS_0
00db10
 
00db10
-# define DOCARGS_1	std 3,128+48(1); DOCARGS_0
00db10
-# define UNDOCARGS_1	ld 3,128+48(1); UNDOCARGS_0
00db10
+# define DOCARGS_1	std 3,CANCEL_PARM_SAVE(1); DOCARGS_0
00db10
+# define UNDOCARGS_1	ld 3,CANCEL_PARM_SAVE(1); UNDOCARGS_0
00db10
 
00db10
-# define DOCARGS_2	std 4,128+56(1); DOCARGS_1
00db10
-# define UNDOCARGS_2	ld 4,128+56(1); UNDOCARGS_1
00db10
+# define DOCARGS_2	std 4,CANCEL_PARM_SAVE+8(1); DOCARGS_1
00db10
+# define UNDOCARGS_2	ld 4,CANCEL_PARM_SAVE+8(1); UNDOCARGS_1
00db10
 
00db10
-# define DOCARGS_3	std 5,128+64(1); DOCARGS_2
00db10
-# define UNDOCARGS_3	ld 5,128+64(1); UNDOCARGS_2
00db10
+# define DOCARGS_3	std 5,CANCEL_PARM_SAVE+16(1); DOCARGS_2
00db10
+# define UNDOCARGS_3	ld 5,CANCEL_PARM_SAVE+16(1); UNDOCARGS_2
00db10
 
00db10
-# define DOCARGS_4	std 6,128+72(1); DOCARGS_3
00db10
-# define UNDOCARGS_4	ld 6,128+72(1); UNDOCARGS_3
00db10
+# define DOCARGS_4	std 6,CANCEL_PARM_SAVE+24(1); DOCARGS_3
00db10
+# define UNDOCARGS_4	ld 6,CANCEL_PARM_SAVE+24(1); UNDOCARGS_3
00db10
 
00db10
-# define DOCARGS_5	std 7,128+80(1); DOCARGS_4
00db10
-# define UNDOCARGS_5	ld 7,128+80(1); UNDOCARGS_4
00db10
+# define DOCARGS_5	std 7,CANCEL_PARM_SAVE+32(1); DOCARGS_4
00db10
+# define UNDOCARGS_5	ld 7,CANCEL_PARM_SAVE+32(1); UNDOCARGS_4
00db10
 
00db10
-# define DOCARGS_6	std 8,128+88(1); DOCARGS_5
00db10
-# define UNDOCARGS_6	ld 8,128+88(1); UNDOCARGS_5
00db10
+# define DOCARGS_6	std 8,CANCEL_PARM_SAVE+40(1); DOCARGS_5
00db10
+# define UNDOCARGS_6	ld 8,CANCEL_PARM_SAVE+40(1); UNDOCARGS_5
00db10
 
00db10
 # ifdef IS_IN_libpthread
00db10
 #  ifdef SHARED
00db10
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/__longjmp-common.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/__longjmp-common.S
00db10
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/__longjmp-common.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/__longjmp-common.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -133,7 +133,7 @@
00db10
 	ld r14,((JB_GPRS+0)*8)(r3)
00db10
 	lfd fp14,((JB_FPRS+0)*8)(r3)
00db10
 #if defined SHARED && !defined IS_IN_rtld
00db10
-	std r2,40(r1)	/* Restore the callers TOC save area.  */
00db10
+	std r2,FRAME_TOC_SAVE(r1)	/* Restore the callers TOC save area.  */
00db10
 #endif
00db10
 	ld r15,((JB_GPRS+1)*8)(r3)
00db10
 	lfd fp15,((JB_FPRS+1)*8)(r3)
00db10
@@ -151,7 +151,7 @@
00db10
 	PTR_DEMANGLE2 (r0, r25)
00db10
 #endif
00db10
 	mtlr r0
00db10
-/* 	std r2,40(r1)	Restore the TOC save area.  */
00db10
+/* 	std r2,FRAME_TOC_SAVE(r1)	Restore the TOC save area.  */
00db10
 	ld r21,((JB_GPRS+7)*8)(r3)
00db10
 	lfd fp21,((JB_FPRS+7)*8)(r3)
00db10
 	ld r22,((JB_GPRS+8)*8)(r3)
00db10
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crti.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crti.S
00db10
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crti.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crti.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -66,8 +66,8 @@
00db10
 BODY_LABEL (_init):
00db10
 	LOCALENTRY(_init)
00db10
 	mflr 0
00db10
-	std 0, 16(r1)
00db10
-	stdu r1, -112(r1)
00db10
+	std 0, FRAME_LR_SAVE(r1)
00db10
+	stdu r1, -FRAME_MIN_SIZE_PARM(r1)
00db10
 #if PREINIT_FUNCTION_WEAK
00db10
 	addis r9, r2, .LC0@toc@ha
00db10
 	ld r0, .LC0@toc@l(r9)
00db10
@@ -84,5 +84,5 @@
00db10
 BODY_LABEL (_fini):
00db10
 	LOCALENTRY(_fini)
00db10
 	mflr 0
00db10
-	std 0, 16(r1)
00db10
-	stdu r1, -112(r1)
00db10
+	std 0, FRAME_LR_SAVE(r1)
00db10
+	stdu r1, -FRAME_MIN_SIZE_PARM(r1)
00db10
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crtn.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crtn.S
00db10
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crtn.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/crtn.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -39,13 +39,13 @@
00db10
 #include <sysdep.h>
00db10
 
00db10
 	.section .init,"ax",@progbits
00db10
-	addi r1, r1, 112
00db10
-	ld r0, 16(r1)
00db10
+	addi r1, r1, FRAME_MIN_SIZE_PARM
00db10
+	ld r0, FRAME_LR_SAVE(r1)
00db10
 	mtlr r0
00db10
 	blr
00db10
 
00db10
 	.section .fini,"ax",@progbits
00db10
-	addi r1, r1, 112
00db10
-	ld r0, 16(r1)
00db10
+	addi r1, r1, FRAME_MIN_SIZE_PARM
00db10
+	ld r0, FRAME_LR_SAVE(r1)
00db10
 	mtlr r0
00db10
 	blr
00db10
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-trampoline.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-trampoline.S
00db10
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-trampoline.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/dl-trampoline.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -26,13 +26,13 @@
00db10
    parm1 (r3) and the index (r0) need to be converted to an offset
00db10
    (index * 24) in parm2 (r4).  */
00db10
 
00db10
-#define FRAME_SIZE 176
00db10
+#define FRAME_SIZE (FRAME_MIN_SIZE+64)
00db10
 /* We need to save the registers used to pass parameters, ie. r3 thru
00db10
    r10;  Use local var space rather than the parameter save area,
00db10
    because gcc as of 2010/05 doesn't allocate a proper stack frame for
00db10
    a function that makes no calls except for __tls_get_addr and we
00db10
    might be here resolving the __tls_get_addr call.  */
00db10
-#define INT_PARMS 112
00db10
+#define INT_PARMS FRAME_MIN_SIZE
00db10
 EALIGN(_dl_runtime_resolve, 4, 0)
00db10
 	stdu	r1,-FRAME_SIZE(r1)
00db10
 	cfi_adjust_cfa_offset (FRAME_SIZE)
00db10
@@ -48,25 +48,25 @@
00db10
 	mflr	r0
00db10
 	std	r8,INT_PARMS+40(r1)
00db10
 /* Store the LR in the LR Save area.  */
00db10
-	std	r0,FRAME_SIZE+16(r1)
00db10
-	cfi_offset (lr, 16)
00db10
+	std	r0,FRAME_SIZE+FRAME_LR_SAVE(r1)
00db10
+	cfi_offset (lr, FRAME_LR_SAVE)
00db10
 	mfcr	r0
00db10
 	std	r9,INT_PARMS+48(r1)
00db10
 	std	r10,INT_PARMS+56(r1)
00db10
 /* I'm almost certain we don't have to save cr...  be safe.  */
00db10
-	std	r0,FRAME_SIZE+8(r1)
00db10
+	std	r0,FRAME_SIZE+FRAME_CR_SAVE(r1)
00db10
 	bl	JUMPTARGET(_dl_fixup)
00db10
 #ifndef SHARED
00db10
 	nop
00db10
 #endif
00db10
 /* Put the registers back.  */
00db10
-	ld	r0,FRAME_SIZE+16(r1)
00db10
+	ld	r0,FRAME_SIZE+FRAME_LR_SAVE(r1)
00db10
 	ld	r10,INT_PARMS+56(r1)
00db10
 	ld	r9,INT_PARMS+48(r1)
00db10
 	ld	r8,INT_PARMS+40(r1)
00db10
 	ld	r7,INT_PARMS+32(r1)
00db10
 	mtlr	r0
00db10
-	ld	r0,FRAME_SIZE+8(r1)
00db10
+	ld	r0,FRAME_SIZE+FRAME_CR_SAVE(r1)
00db10
 	ld	r6,INT_PARMS+24(r1)
00db10
 	ld	r5,INT_PARMS+16(r1)
00db10
 	ld	r4,INT_PARMS+8(r1)
00db10
@@ -76,7 +76,7 @@
00db10
 	ld	r3,INT_PARMS+0(r1)
00db10
 #if _CALL_ELF == 2
00db10
 /* Restore the caller's TOC in case we jump to a local entry point.  */
00db10
-	ld	r2,FRAME_SIZE+40(r1)
00db10
+	ld	r2,FRAME_SIZE+FRAME_TOC_SAVE(r1)
00db10
 #endif
00db10
 /* Unwind the stack frame, and jump.  */
00db10
 	addi	r1,r1,FRAME_SIZE
00db10
@@ -86,6 +86,7 @@
00db10
 #undef INT_PARMS
00db10
 
00db10
 	/* Stack layout:
00db10
+	   (Note: some of these are not required for the ELFv2 ABI.)
00db10
 	  +592   previous backchain
00db10
 	  +584   spill_r31
00db10
 	  +576   spill_r30
00db10
@@ -147,10 +148,11 @@
00db10
 	  +64    parm3
00db10
 	  +56    parm2
00db10
 	  +48    parm1
00db10
-	 * Parameter save area, Allocated by the call, at least 8 double words
00db10
-	  +40    TOC save area
00db10
-	  +32    Reserved for linker
00db10
-	  +24    Reserved for compiler
00db10
+	 * Parameter save area
00db10
+	 * (v1 ABI: Allocated by the call, at least 8 double words)
00db10
+	  +40    v1 ABI: TOC save area
00db10
+	  +32    v1 ABI: Reserved for linker
00db10
+	  +24    v1 ABI: Reserved for compiler / v2 ABI: TOC save area
00db10
 	  +16    LR save area
00db10
 	  +8     CR save area
00db10
 	r1+0     stack back chain
00db10
@@ -206,15 +208,15 @@
00db10
 /* Store the LR in the LR Save area of the previous frame.  */
00db10
 /* XXX Do we have to do this?  */
00db10
 	la	r8,FRAME_SIZE(r1)
00db10
-	std	r5,FRAME_SIZE+16(r1)
00db10
-	cfi_offset (lr, 16)
00db10
+	std	r5,FRAME_SIZE+FRAME_LR_SAVE(r1)
00db10
+	cfi_offset (lr, FRAME_LR_SAVE)
00db10
 	std	r5,CALLING_LR(r1)
00db10
 	mfcr	r0
00db10
 	std	r9,INT_PARMS+48(r1)
00db10
 	std	r10,INT_PARMS+56(r1)
00db10
 	std	r8,CALLING_SP(r1)
00db10
 /* I'm almost certain we don't have to save cr...  be safe.  */
00db10
-	std	r0,FRAME_SIZE+8(r1)
00db10
+	std	r0,FRAME_SIZE+FRAME_CR_SAVE(r1)
00db10
 	ld	r12,.LC__dl_hwcap@toc(r2)
00db10
 #ifdef SHARED
00db10
 	/* Load _rtld_local_ro._dl_hwcap.  */
00db10
@@ -311,13 +313,13 @@
00db10
 	lvx	v12,r11,r10
00db10
 	lvx	v13,r11,r9
00db10
 L(restoreFXR):
00db10
-	ld	r0,FRAME_SIZE+16(r1)
00db10
+	ld	r0,FRAME_SIZE+FRAME_LR_SAVE(r1)
00db10
 	ld	r10,INT_PARMS+56(r1)
00db10
 	ld	r9,INT_PARMS+48(r1)
00db10
 	ld	r8,INT_PARMS+40(r1)
00db10
 	ld	r7,INT_PARMS+32(r1)
00db10
 	mtlr	r0
00db10
-	ld	r0,FRAME_SIZE+8(r1)
00db10
+	ld	r0,FRAME_SIZE+FRAME_CR_SAVE(r1)
00db10
 	ld	r6,INT_PARMS+24(r1)
00db10
 	ld	r5,INT_PARMS+16(r1)
00db10
 	ld	r4,INT_PARMS+8(r1)
00db10
@@ -327,7 +329,7 @@
00db10
 	ld	r3,INT_PARMS+0(r1)
00db10
 #if _CALL_ELF == 2
00db10
 /* Restore the caller's TOC in case we jump to a local entry point.  */
00db10
-	ld	r2,FRAME_SIZE+40(r1)
00db10
+	ld	r2,FRAME_SIZE+FRAME_TOC_SAVE(r1)
00db10
 #endif
00db10
 /* Load the floating point registers.  */
00db10
 	lfd	fp1,FPR_PARMS+0(r1)
00db10
@@ -375,19 +377,19 @@
00db10
 	lvx	v12,r11,r10
00db10
 	lvx	v13,r11,r9
00db10
 L(restoreFXR2):
00db10
-	ld	r0,FRAME_SIZE+16(r1)
00db10
+	ld	r0,FRAME_SIZE+FRAME_LR_SAVE(r1)
00db10
 	ld	r10,INT_PARMS+56(r1)
00db10
 	ld	r9,INT_PARMS+48(r1)
00db10
 	ld	r8,INT_PARMS+40(r1)
00db10
 	ld	r7,INT_PARMS+32(r1)
00db10
 	mtlr	r0
00db10
-	ld	r0,FRAME_SIZE+8(r1)
00db10
+	ld	r0,FRAME_SIZE+FRAME_CR_SAVE(r1)
00db10
 	ld	r6,INT_PARMS+24(r1)
00db10
 	ld	r5,INT_PARMS+16(r1)
00db10
 	ld	r4,INT_PARMS+8(r1)
00db10
 	mtcrf	0xFF,r0
00db10
 /* Prepare for calling the function returned by fixup.  */
00db10
-	std	r2,40(r1)
00db10
+	std	r2,FRAME_TOC_SAVE(r1)
00db10
 	PPC64_LOAD_FUNCPTR r3
00db10
 	ld	r3,INT_PARMS+0(r1)
00db10
 /* Load the floating point registers.  */
00db10
@@ -406,7 +408,7 @@
00db10
 	lfd	fp13,FPR_PARMS+96(r1)
00db10
 /* Call the target function.  */
00db10
 	bctrl
00db10
-	ld	r2,40(r1)
00db10
+	ld	r2,FRAME_TOC_SAVE(r1)
00db10
 	lwz	r12,VR_VRSAVE(r1)
00db10
 /* But return here and store the return values.  */
00db10
 	std	r3,INT_RTN(r1)
00db10
@@ -441,7 +443,7 @@
00db10
 	beq	L(pltexitreturn)
00db10
 	lvx	v2,0,r10
00db10
 L(pltexitreturn):
00db10
-	ld	r0,FRAME_SIZE+16(r1)
00db10
+	ld	r0,FRAME_SIZE+FRAME_LR_SAVE(r1)
00db10
 	ld	r31,584(r1)
00db10
 	ld	r30,576(r1)
00db10
 	mtlr	r0
00db10
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/ppc-mcount.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/ppc-mcount.S
00db10
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/ppc-mcount.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/ppc-mcount.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -24,16 +24,16 @@
00db10
 ENTRY(_mcount)
00db10
 	mflr		 r4
00db10
 	ld		 r11, 0(r1)
00db10
-	stdu		 r1,-112(r1)
00db10
-	cfi_adjust_cfa_offset (112)
00db10
-	std		 r4, 128(r1)
00db10
-	cfi_offset (lr, 16)
00db10
-	ld		 r3, 16(r11)
00db10
+	stdu		 r1,-FRAME_MIN_SIZE(r1)
00db10
+	cfi_adjust_cfa_offset (FRAME_MIN_SIZE)
00db10
+	std		 r4, FRAME_MIN_SIZE+FRAME_LR_SAVE(r1)
00db10
+	cfi_offset (lr, FRAME_LR_SAVE)
00db10
+	ld		 r3, FRAME_LR_SAVE(r11)
00db10
 	bl		 JUMPTARGET(__mcount_internal)
00db10
 	nop
00db10
-	ld		 r0, 128(r1)
00db10
+	ld		 r0, FRAME_MIN_SIZE+FRAME_LR_SAVE(r1)
00db10
 	mtlr		 r0
00db10
-	addi		 r1,r1,112
00db10
+	addi		 r1,r1,FRAME_MIN_SIZE
00db10
 	blr
00db10
 END(_mcount)
00db10
 
00db10
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/setjmp-common.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/setjmp-common.S
00db10
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/setjmp-common.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/setjmp-common.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -56,7 +56,7 @@
00db10
    bugz #269.  __GI__setjmp is used in csu/libc-start.c when
00db10
    HAVE_CLEANUP_JMP_BUF is defined.  */
00db10
 ENTRY (__GI__setjmp)
00db10
-	std r2,40(r1)		/* Save the callers TOC in the save area.  */
00db10
+	std r2,FRAME_TOC_SAVE(r1)		/* Save the callers TOC in the save area.  */
00db10
 	CALL_MCOUNT 1
00db10
 	li r4,0			/* Set second argument to 0.  */
00db10
 	b JUMPTARGET (GLUE(__sigsetjmp,_ent))
00db10
@@ -83,7 +83,7 @@
00db10
 #endif
00db10
 	mflr r0
00db10
 #if defined SHARED && !defined IS_IN_rtld
00db10
-	ld   r5,40(r1)	/* Retrieve the callers TOC.  */
00db10
+	ld   r5,FRAME_TOC_SAVE(r1)	/* Retrieve the callers TOC.  */
00db10
 	std  r5,(JB_GPR2*8)(3)
00db10
 #else
00db10
 	std  r2,(JB_GPR2*8)(3)
00db10
@@ -219,14 +219,14 @@
00db10
 	b	JUMPTARGET (__sigjmp_save)
00db10
 #else
00db10
 	mflr	r0
00db10
-	std	r0,16(r1)
00db10
-	stdu	r1,-112(r1)
00db10
-	cfi_adjust_cfa_offset(112)
00db10
-	cfi_offset(lr,16)
00db10
+	std	r0,FRAME_LR_SAVE(r1)
00db10
+	stdu	r1,-FRAME_MIN_SIZE(r1)
00db10
+	cfi_adjust_cfa_offset(FRAME_MIN_SIZE)
00db10
+	cfi_offset(lr,FRAME_LR_SAVE)
00db10
 	bl	JUMPTARGET (__sigjmp_save)
00db10
 	nop
00db10
-	ld	r0,112+16(r1)
00db10
-	addi	r1,r1,112
00db10
+	ld	r0,FRAME_MIN_SIZE+FRAME_LR_SAVE(r1)
00db10
+	addi	r1,r1,FRAME_MIN_SIZE
00db10
 	mtlr	r0
00db10
 	blr
00db10
 #endif
00db10
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/sysdep.h glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/sysdep.h
00db10
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/sysdep.h	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/sysdep.h	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -20,25 +20,67 @@
00db10
 
00db10
 #ifdef __ASSEMBLER__
00db10
 
00db10
+/* Stack frame offsets.  */
00db10
+#if _CALL_ELF != 2
00db10
+#define FRAME_MIN_SIZE		112
00db10
+#define FRAME_MIN_SIZE_PARM	112
00db10
+#define FRAME_BACKCHAIN		0
00db10
+#define FRAME_CR_SAVE		8
00db10
+#define FRAME_LR_SAVE		16
00db10
+#define FRAME_TOC_SAVE		40
00db10
+#define FRAME_PARM_SAVE		48
00db10
+#define FRAME_PARM1_SAVE	48
00db10
+#define FRAME_PARM2_SAVE	56
00db10
+#define FRAME_PARM3_SAVE	64
00db10
+#define FRAME_PARM4_SAVE	72
00db10
+#define FRAME_PARM5_SAVE	80
00db10
+#define FRAME_PARM6_SAVE	88
00db10
+#define FRAME_PARM7_SAVE	96
00db10
+#define FRAME_PARM8_SAVE	104
00db10
+#define FRAME_PARM9_SAVE	112
00db10
+#else
00db10
+#define FRAME_MIN_SIZE		32
00db10
+#define FRAME_MIN_SIZE_PARM	96
00db10
+#define FRAME_BACKCHAIN		0
00db10
+#define FRAME_CR_SAVE		8
00db10
+#define FRAME_LR_SAVE		16
00db10
+#define FRAME_TOC_SAVE		24
00db10
+#define FRAME_PARM_SAVE		32
00db10
+#define FRAME_PARM1_SAVE	32
00db10
+#define FRAME_PARM2_SAVE	40
00db10
+#define FRAME_PARM3_SAVE	48
00db10
+#define FRAME_PARM4_SAVE	56
00db10
+#define FRAME_PARM5_SAVE	64
00db10
+#define FRAME_PARM6_SAVE	72
00db10
+#define FRAME_PARM7_SAVE	80
00db10
+#define FRAME_PARM8_SAVE	88
00db10
+#define FRAME_PARM9_SAVE	96
00db10
+#endif
00db10
+
00db10
 /* Support macros for CALL_MCOUNT.  */
00db10
+#if _CALL_ELF == 2
00db10
+#define call_mcount_parm_offset (-64)
00db10
+#else
00db10
+#define call_mcount_parm_offset FRAME_PARM_SAVE
00db10
+#endif
00db10
 	.macro SAVE_ARG NARG
00db10
 	.if \NARG
00db10
 	SAVE_ARG \NARG-1
00db10
-	std	2+\NARG,40+8*(\NARG)(1)
00db10
+	std	2+\NARG,call_mcount_parm_offset-8+8*(\NARG)(1)
00db10
 	.endif
00db10
 	.endm
00db10
 
00db10
 	.macro REST_ARG NARG
00db10
 	.if \NARG
00db10
 	REST_ARG \NARG-1
00db10
-	ld	2+\NARG,112+40+8*(\NARG)(1)
00db10
+	ld	2+\NARG,FRAME_MIN_SIZE_PARM+call_mcount_parm_offset-8+8*(\NARG)(1)
00db10
 	.endif
00db10
 	.endm
00db10
 
00db10
 	.macro CFI_SAVE_ARG NARG
00db10
 	.if \NARG
00db10
 	CFI_SAVE_ARG \NARG-1
00db10
-	cfi_offset(2+\NARG,40+8*(\NARG))
00db10
+	cfi_offset(2+\NARG,call_mcount_parm_offset-8+8*(\NARG))
00db10
 	.endif
00db10
 	.endm
00db10
 
00db10
@@ -55,20 +97,20 @@
00db10
 #ifdef	PROF
00db10
 	mflr	r0
00db10
 	SAVE_ARG \NARG
00db10
-	std	r0,16(r1)
00db10
-	stdu	r1,-112(r1)
00db10
-	cfi_adjust_cfa_offset(112)
00db10
-	cfi_offset(lr,16)
00db10
+	std	r0,FRAME_LR_SAVE(r1)
00db10
+	stdu	r1,-FRAME_MIN_SIZE_PARM(r1)
00db10
+	cfi_adjust_cfa_offset(FRAME_MIN_SIZE_PARM)
00db10
+	cfi_offset(lr,FRAME_LR_SAVE)
00db10
 	CFI_SAVE_ARG \NARG
00db10
 	bl	JUMPTARGET (_mcount)
00db10
 #ifndef SHARED
00db10
 	nop
00db10
 #endif
00db10
-	ld	r0,128(r1)
00db10
+	ld	r0,FRAME_MIN_SIZE_PARM+FRAME_LR_SAVE(r1)
00db10
 	REST_ARG \NARG
00db10
 	mtlr	r0
00db10
-	addi	r1,r1,112
00db10
-	cfi_adjust_cfa_offset(-112)
00db10
+	addi	r1,r1,FRAME_MIN_SIZE_PARM
00db10
+	cfi_adjust_cfa_offset(-FRAME_MIN_SIZE_PARM)
00db10
 	cfi_restore(lr)
00db10
 	CFI_REST_ARG \NARG
00db10
 #endif
00db10
@@ -267,15 +309,15 @@
00db10
     .else; \
00db10
 .Local_syscall_error: \
00db10
     mflr 0; \
00db10
-    std 0,16(1); \
00db10
-    stdu 1,-112(1); \
00db10
-    cfi_adjust_cfa_offset(112); \
00db10
-    cfi_offset(lr,16); \
00db10
+    std 0,FRAME_LR_SAVE(1); \
00db10
+    stdu 1,-FRAME_MIN_SIZE(1); \
00db10
+    cfi_adjust_cfa_offset(FRAME_MIN_SIZE); \
00db10
+    cfi_offset(lr,FRAME_LR_SAVE); \
00db10
     bl JUMPTARGET(__syscall_error); \
00db10
     nop; \
00db10
-    ld 0,112+16(1); \
00db10
-    addi 1,1,112; \
00db10
-    cfi_adjust_cfa_offset(-112); \
00db10
+    ld 0,FRAME_MIN_SIZE+FRAME_LR_SAVE(1); \
00db10
+    addi 1,1,FRAME_MIN_SIZE; \
00db10
+    cfi_adjust_cfa_offset(-FRAME_MIN_SIZE); \
00db10
     mtlr 0; \
00db10
     cfi_restore(lr); \
00db10
     blr; \
00db10
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/____longjmp_chk.S glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/____longjmp_chk.S
00db10
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/____longjmp_chk.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/____longjmp_chk.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -33,24 +33,24 @@
00db10
 	cmpld	reg, r1;				\
00db10
 	bge+	.Lok;					\
00db10
 	mflr	r0;					\
00db10
-	std	r0,16(r1);				\
00db10
+	std	r0,FRAME_LR_SAVE(r1);			\
00db10
 	mr	r31,r3;					\
00db10
 	mr	r30,r4;					\
00db10
-	stdu	r1,-144(r1);				\
00db10
+	stdu	r1,-FRAME_MIN_SIZE-32(r1);		\
00db10
 	cfi_remember_state;				\
00db10
-	cfi_adjust_cfa_offset (144);			\
00db10
-	cfi_offset (lr, 16);				\
00db10
+	cfi_adjust_cfa_offset (FRAME_MIN_SIZE+32);	\
00db10
+	cfi_offset (lr, FRAME_LR_SAVE);			\
00db10
 	li	r3,0;					\
00db10
-	addi	r4,r1,112;				\
00db10
+	addi	r4,r1,FRAME_MIN_SIZE;			\
00db10
 	li	r0,__NR_sigaltstack;			\
00db10
 	sc;						\
00db10
 	/* Without working sigaltstack we cannot perform the test.  */ \
00db10
 	bso	.Lok2;					\
00db10
-	lwz	r0,112+8(r1);				\
00db10
+	lwz	r0,FRAME_MIN_SIZE+8(r1);		\
00db10
 	andi.	r4,r0,1;				\
00db10
 	beq	.Lfail;					\
00db10
-	ld	r0,112+16(r1);				\
00db10
-	ld	r4,112(r1);				\
00db10
+	ld	r0,FRAME_MIN_SIZE+16(r1);		\
00db10
+	ld	r4,FRAME_MIN_SIZE(r1);			\
00db10
 	add	r4,r4,r0;				\
00db10
 	sub	r3,r3,reg;				\
00db10
 	cmpld	r3,r0;					\
00db10
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/brk.S glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/brk.S
00db10
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/brk.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/brk.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -31,9 +31,9 @@
00db10
 	CALL_MCOUNT 1
00db10
 	DISCARD_BOUNDS (r3)	/* the bounds are meaningless, so toss 'em.  */
00db10
 
00db10
-	std	r3,48(r1)
00db10
+	std	r3,-8(r1)
00db10
 	DO_CALL(SYS_ify(brk))
00db10
-	ld	r6,48(r1)
00db10
+	ld	r6,-8(r1)
00db10
 	ld	r5,.LC__curbrk@toc(r2)
00db10
 	std     r3,0(r5)
00db10
 	cmpld   r6,r3
00db10
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
00db10
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -45,22 +45,22 @@
00db10
 	cror	cr0*4+eq,cr1*4+eq,cr0*4+eq
00db10
 	beq-	cr0,L(badargs)
00db10
 
00db10
-	/* Save some regs in parm save area.  */
00db10
+	/* Save some regs in the "red zone".  */
00db10
 #ifdef RESET_PID
00db10
-	std	r29,48(r1)
00db10
+	std	r29,-24(r1)
00db10
 #endif
00db10
-	std	r30,56(r1)
00db10
-	std	r31,64(r1)
00db10
+	std	r30,-16(r1)
00db10
+	std	r31,-8(r1)
00db10
 #ifdef RESET_PID
00db10
-	cfi_offset(r29,48)
00db10
+	cfi_offset(r29,-24)
00db10
 #endif
00db10
-	cfi_offset(r30,56)
00db10
-	cfi_offset(r31,64)
00db10
+	cfi_offset(r30,-16)
00db10
+	cfi_offset(r31,-8)
00db10
 
00db10
 	/* Set up stack frame for child.  */
00db10
 	clrrdi	r4,r4,4
00db10
 	li	r0,0
00db10
-	stdu	r0,-112(r4) /* min stack frame is 112 bytes per ABI */
00db10
+	stdu	r0,-FRAME_MIN_SIZE_PARM(r4)
00db10
 
00db10
 	/* Save fn, args, stack across syscall.  */
00db10
 	mr	r30,r3			/* Function in r30.  */
00db10
@@ -102,12 +102,12 @@
00db10
 L(oldpid):
00db10
 #endif
00db10
 
00db10
-	std	r2,40(r1)
00db10
+	std	r2,FRAME_TOC_SAVE(r1)
00db10
 	/* Call procedure.  */
00db10
 	PPC64_LOAD_FUNCPTR r30
00db10
 	mr	r3,r31
00db10
 	bctrl
00db10
-	ld	r2,40(r1)
00db10
+	ld	r2,FRAME_TOC_SAVE(r1)
00db10
 	/* Call _exit with result from procedure.  */
00db10
 #ifdef SHARED
00db10
 	b	JUMPTARGET(__GI__exit)
00db10
@@ -126,15 +126,15 @@
00db10
 L(parent):
00db10
 	/* Parent.  Restore registers & return.  */
00db10
 #ifdef RESET_PID
00db10
-	cfi_offset(r29,48)
00db10
+	cfi_offset(r29,-24)
00db10
 #endif
00db10
-	cfi_offset(r30,56)
00db10
-	cfi_offset(r31,64)
00db10
+	cfi_offset(r30,-16)
00db10
+	cfi_offset(r31,-8)
00db10
 #ifdef RESET_PID
00db10
-	ld	r29,48(r1)
00db10
+	ld	r29,-24(r1)
00db10
 #endif
00db10
-	ld	r30,56(r1)
00db10
-	ld	r31,64(r1)
00db10
+	ld	r30,-16(r1)
00db10
+	ld	r31,-8(r1)
00db10
 #ifdef RESET_PID
00db10
 	cfi_restore(r29)
00db10
 #endif
00db10
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S
00db10
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/socket.S	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -46,8 +46,13 @@
00db10
 # endif
00db10
 #endif
00db10
 
00db10
-#define FRAMESIZE 128
00db10
-#define stackblock FRAMESIZE+48 /* offset to parm save area.  */
00db10
+#if _CALL_ELF == 2
00db10
+#define FRAMESIZE (FRAME_MIN_SIZE+16+64)
00db10
+#define stackblock (FRAME_MIN_SIZE+16)
00db10
+#else
00db10
+#define FRAMESIZE (FRAME_MIN_SIZE+16)
00db10
+#define stackblock (FRAMESIZE+FRAME_PARM_SAVE) /* offset to parm save area.  */
00db10
+#endif
00db10
 
00db10
 	.text
00db10
 ENTRY(__socket)
00db10
@@ -98,22 +103,22 @@
00db10
 .Lsocket_cancel:
00db10
 	cfi_adjust_cfa_offset(FRAMESIZE)
00db10
 	mflr	r9
00db10
-	std	r9,FRAMESIZE+16(r1)
00db10
-	cfi_offset (lr, 16)
00db10
+	std	r9,FRAMESIZE+FRAME_LR_SAVE(r1)
00db10
+	cfi_offset (lr, FRAME_LR_SAVE)
00db10
 	CENABLE
00db10
-	std	r3,120(r1)
00db10
+	std	r3,FRAME_MIN_SIZE+8(r1)
00db10
 	li	r3,P(SOCKOP_,socket)
00db10
 	addi	r4,r1,stackblock
00db10
 	DO_CALL(SYS_ify(socketcall))
00db10
 	mfcr	r0
00db10
-	std	r3,112(r1)
00db10
-	std	r0,FRAMESIZE+8(r1)
00db10
-	cfi_offset (cr, 8)
00db10
-	ld  	r3,120(r1)
00db10
+	std	r3,FRAME_MIN_SIZE(r1)
00db10
+	std	r0,FRAMESIZE+FRAME_CR_SAVE(r1)
00db10
+	cfi_offset (cr, FRAME_CR_SAVE)
00db10
+	ld  	r3,FRAME_MIN_SIZE+8(r1)
00db10
 	CDISABLE
00db10
-	ld	r4,FRAMESIZE+16(r1)
00db10
-	ld	r0,FRAMESIZE+8(r1)
00db10
-	ld	r3,112(r1)
00db10
+	ld	r4,FRAMESIZE+FRAME_LR_SAVE(r1)
00db10
+	ld	r0,FRAMESIZE+FRAME_CR_SAVE(r1)
00db10
+	ld	r3,FRAME_MIN_SIZE(r1)
00db10
 	mtlr	r4
00db10
 	mtcr	r0
00db10
 	addi	r1,r1,FRAMESIZE
00db10
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/ucontext_i.sym glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/ucontext_i.sym
00db10
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/ucontext_i.sym	2014-05-29 14:09:56.000000000 -0500
00db10
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/ucontext_i.sym	2014-05-29 14:10:00.000000000 -0500
00db10
@@ -8,27 +8,6 @@
00db10
 SIG_SETMASK
00db10
 
00db10
 
00db10
--- Offsets of the fields in the powerpc64 ABI stack frame.
00db10
--- XXX Do these correspond to some struct?
00db10
-
00db10
-FRAME_BACKCHAIN		0
00db10
-FRAME_CR_SAVE		8
00db10
-FRAME_LR_SAVE		16
00db10
-FRAME_COMPILER_DW	24
00db10
-FRAME_LINKER_DW		32
00db10
-FRAME_TOC_SAVE		40
00db10
-FRAME_PARM_SAVE		48
00db10
-FRAME_PARM1_SAVE	48
00db10
-FRAME_PARM2_SAVE	56
00db10
-FRAME_PARM3_SAVE	64
00db10
-FRAME_PARM4_SAVE	72
00db10
-FRAME_PARM5_SAVE	80
00db10
-FRAME_PARM6_SAVE	88
00db10
-FRAME_PARM7_SAVE	96
00db10
-FRAME_PARM8_SAVE	104
00db10
-FRAME_PARM9_SAVE	112
00db10
-
00db10
-
00db10
 -- Offsets of the fields in the ucontext_t structure.
00db10
 #define ucontext(member)	offsetof (ucontext_t, member)
00db10
 #define mcontext(member)	ucontext (uc_mcontext.member)