Module Name:    src
Committed By:   dennis
Date:           Mon Jan 12 02:48:20 UTC 2015

Modified Files:
        src/lib/libc/arch/powerpc64: SYS.h
        src/lib/libc/arch/powerpc64/sys: cerror.S

Log Message:
Replace the branch to __cerror() in powerpc64 syscall stubs
with inline code which does what __cerror() was doing.  #ifdef
that code (i.e. all code) out of cerror.S; __cerror() is no more.
This seems to be necessary to fix the link of rescue/rescue, and
should have the pleasant side effect of making all other workarounds
done to keep the 'b __cerror' working unnecessary.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/powerpc64/SYS.h
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/arch/powerpc64/sys/cerror.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/arch/powerpc64/SYS.h
diff -u src/lib/libc/arch/powerpc64/SYS.h:1.3 src/lib/libc/arch/powerpc64/SYS.h:1.4
--- src/lib/libc/arch/powerpc64/SYS.h:1.3	Sat Aug 23 02:24:22 2014
+++ src/lib/libc/arch/powerpc64/SYS.h	Mon Jan 12 02:48:20 2015
@@ -1,13 +1,39 @@
-/*	$NetBSD: SYS.h,v 1.3 2014/08/23 02:24:22 matt Exp $	*/
+/*	$NetBSD: SYS.h,v 1.4 2015/01/12 02:48:20 dennis Exp $	*/
 
 #include <machine/asm.h>
 #include <sys/syscall.h>
 
-#ifdef _CALL_AIX
-#define	BRANCH_TO_CERROR()	b	._C_LABEL(__cerror); nop
-#else
-#define	BRANCH_TO_CERROR()	b	_C_LABEL(__cerror)
-#endif
+/*
+ * Inline what __cerror() is generally used to do since branching
+ * to __cerror() can't be done reliably with the powerpc64 ABI.
+ */
+#ifdef _REENTRANT
+#define	_DO_CERROR_SF_SZ	(SF_SZ + SF_ALIGN(8))
+#define	_DO_CERROR()		mflr	%r0				;\
+				streg	%r31,-8(%r1)			;\
+				streg	%r0,SF_LR(%r1)			;\
+				stptru	%r1,-_DO_CERROR_SF_SZ(%r1)	;\
+				mr	%r31,%r3			;\
+				bl	PIC_PLT(_C_LABEL(__errno))	;\
+				nop					;\
+				stint	%r31,0(%r3)			;\
+				addi	%r1,%r1,_DO_CERROR_SF_SZ	;\
+				ldreg	%r0,SF_LR(%r1)			;\
+				ldreg	%r31,-8(%r1)			;\
+				mtlr	%r0				;\
+				li	%r3,-1				;\
+				li	%r4,-1				;\
+				blr
+#else	/* !_REENTRANT */
+#define	_DO_CERROR()		lwz	%r4,_C_LABEL(errno)@got(%r2)	;\
+				stw	%r3,0(%r4)			;\
+				li	%r3,-1				;\
+				li	%r4,-1				;\
+				blr
+#endif	/* _REENTRANT */
+
+/* Clearly BRANCH_TO_CERROR() no longer does that... */
+#define	BRANCH_TO_CERROR()	_DO_CERROR()
 
 #define	_DOSYSCALL(x)		li	%r0,(SYS_ ## x)		;\
 				sc
@@ -19,7 +45,7 @@
 
 #define _SYSCALL(x,y)		.text				;\
 				.p2align 2			;\
-			2:	BRANCH_TO_CERROR()		;\
+			2:	_DO_CERROR()			;\
 				_SYSCALL_NOERROR(x,y)		;\
 				bso	2b
 
@@ -33,7 +59,7 @@
 
 #define PSEUDO(x,y)		_SYSCALL_NOERROR(x,y)		;\
 				bnslr				;\
-				BRANCH_TO_CERROR()		;\
+				_DO_CERROR()			;\
 				END(x)
 
 #define RSYSCALL_NOERROR(x)	PSEUDO_NOERROR(x,x)

Index: src/lib/libc/arch/powerpc64/sys/cerror.S
diff -u src/lib/libc/arch/powerpc64/sys/cerror.S:1.6 src/lib/libc/arch/powerpc64/sys/cerror.S:1.7
--- src/lib/libc/arch/powerpc64/sys/cerror.S:1.6	Sat Aug 23 02:24:22 2014
+++ src/lib/libc/arch/powerpc64/sys/cerror.S	Mon Jan 12 02:48:20 2015
@@ -1,5 +1,8 @@
-/*	$NetBSD: cerror.S,v 1.6 2014/08/23 02:24:22 matt Exp $	*/
+/*	$NetBSD: cerror.S,v 1.7 2015/01/12 02:48:20 dennis Exp $	*/
 
+/* Now inlined in the syscall stubs.  Keep code for a while for mind changes. */
+
+#if 0
 #include <machine/asm.h>
 #include "SYS.h"
 
@@ -13,26 +16,24 @@
 ENTRY(__cerror)
 #ifdef _REENTRANT
 	mflr	%r0
-	streg	%r0,__SIZEOF_POINTER__(%r1)
-	stptru	%r1,-(4*__SIZEOF_POINTER__)(%r1) # allocate new stack frame
-	streg	%r31,(3*__SIZEOF_POINTER__)(%r1)
+	streg	%r0,SF_LR(%r1)
+	streg	%r31,-8(%r1)
+	stptru	%r1,-(SF_SZ+16)(%r1)	# allocate new stack frame
 	mr	%r31,%r3		# stash away in callee-saved register
 	bl	PIC_PLT(_C_LABEL(__errno))
 	nop
 	stint	%r31,0(%r3)
 
-	ldreg	%r31,(3*__SIZEOF_POINTER__)(%r1)
-	addi	%r1,%r1,4*__SIZEOF_POINTER__
-	ldreg	%r0,__SIZEOF_POINTER__(%r1)
+	addi	%r1,%r1,(SF_SZ+16)
+	ldreg	%r31,-8(%r1)
+	ldreg	%r0,SF_LR(%r1)
 	mtlr	%r0
 #else
-	.pushsection ".toc", "aw"
-.Lerrno:.tc	errno[TC], errno
-	.popsection
-	lwz	%r4,_C_LABEL(.Lerrno)@toc(%r2)
+	lwz	%r4,_C_LABEL(errno)@got(%r2)
 	stw	%r3,0(%r4)
 #endif /* _REENTRANT */
 	li	%r3,-1
 	li	%r4,-1
 	blr
 END(__cerror)
+#endif	/* 0 */

Reply via email to