00db10
From e883cafe35f52b3e511dbaf85052f8dddd395a2e Mon Sep 17 00:00:00 2001
00db10
From: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
00db10
Date: Mon, 30 May 2016 18:00:57 -0300
00db10
Subject: [PATCH] powerpc: Fix --disable-multi-arch build on POWER8
00db10
00db10
Add missing symbols of stpncpy and strcasestr when multi-arch is
00db10
disabled.
00db10
Fix memset call from strncpy/stpncpy when multi-arch is disabled.
00db10
00db10
(cherry picked from commit c24480ce3b5fed848243fc9642932ef2fa670109)
00db10
---
00db10
 ChangeLog                                            | 15 +++++++++++++++
00db10
 sysdeps/powerpc/powerpc64/multiarch/stpncpy-power8.S |  3 +++
00db10
 sysdeps/powerpc/powerpc64/multiarch/strncpy-power8.S |  3 +++
00db10
 sysdeps/powerpc/powerpc64/power8/stpncpy.S           |  4 ++++
00db10
 sysdeps/powerpc/powerpc64/power8/strcasestr.S        |  7 +++++--
00db10
 sysdeps/powerpc/powerpc64/power8/strncpy.S           | 16 ++++++++++++----
00db10
 6 files changed, 42 insertions(+), 6 deletions(-)
00db10
00db10
diff --git a/ChangeLog b/ChangeLog
00db10
index 8d0e296..c01d1a0 100644
00db10
diff --git a/sysdeps/powerpc/powerpc64/multiarch/stpncpy-power8.S b/sysdeps/powerpc/powerpc64/multiarch/stpncpy-power8.S
00db10
index d5d835d..d9babb5 100644
00db10
--- a/sysdeps/powerpc/powerpc64/multiarch/stpncpy-power8.S
00db10
+++ b/sysdeps/powerpc/powerpc64/multiarch/stpncpy-power8.S
00db10
@@ -36,4 +36,7 @@
00db10
   TRACEBACK(__stpncpy_power8)					\
00db10
   END_2(__stpncpy_power8)
00db10
 
00db10
+#undef libc_hidden_builtin_def
00db10
+#define libc_hidden_builtin_def(name)
00db10
+
00db10
 #include <sysdeps/powerpc/powerpc64/power8/stpncpy.S>
00db10
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncpy-power8.S b/sysdeps/powerpc/powerpc64/multiarch/strncpy-power8.S
00db10
index ed906a4..f86a0f0 100644
00db10
--- a/sysdeps/powerpc/powerpc64/multiarch/strncpy-power8.S
00db10
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncpy-power8.S
00db10
@@ -37,4 +37,7 @@
00db10
 #undef libc_hidden_builtin_def
00db10
 #define libc_hidden_builtin_def(name)
00db10
 
00db10
+/* memset is used to pad the end of the string.  */
00db10
+#define MEMSET __memset_power8
00db10
+
00db10
 #include <sysdeps/powerpc/powerpc64/power8/strncpy.S>
00db10
diff --git a/sysdeps/powerpc/powerpc64/power8/stpncpy.S b/sysdeps/powerpc/powerpc64/power8/stpncpy.S
00db10
index 76a1466..e66bd0a 100644
00db10
--- a/sysdeps/powerpc/powerpc64/power8/stpncpy.S
00db10
+++ b/sysdeps/powerpc/powerpc64/power8/stpncpy.S
00db10
@@ -18,3 +18,7 @@
00db10
 
00db10
 #define USE_AS_STPNCPY
00db10
 #include <sysdeps/powerpc/powerpc64/power8/strncpy.S>
00db10
+
00db10
+weak_alias (__stpncpy, stpncpy)
00db10
+libc_hidden_def (__stpncpy)
00db10
+libc_hidden_builtin_def (stpncpy)
00db10
diff --git a/sysdeps/powerpc/powerpc64/power8/strcasestr.S b/sysdeps/powerpc/powerpc64/power8/strcasestr.S
00db10
index 24b2b76..60015ae 100644
00db10
--- a/sysdeps/powerpc/powerpc64/power8/strcasestr.S
00db10
+++ b/sysdeps/powerpc/powerpc64/power8/strcasestr.S
00db10
@@ -81,7 +81,7 @@
00db10
 /* TODO: change this to .machine power8 when the minimum required binutils
00db10
    allows it.  */
00db10
 	.machine  power7
00db10
-EALIGN (strcasestr, 4, 0)
00db10
+EALIGN (__strcasestr, 4, 0)
00db10
 	CALL_MCOUNT 2
00db10
 	mflr	r0			/* Load link register LR to r0.  */
00db10
 	std	r31, -8(r1)		/* Save callers register r31.  */
00db10
@@ -527,5 +527,8 @@ L(end):
00db10
 	cfi_restore(r31)
00db10
 	mtlr	r0		/* Branch to link register.  */
00db10
 	blr
00db10
-END (strcasestr)
00db10
+END (__strcasestr)
00db10
+
00db10
+weak_alias (__strcasestr, strcasestr)
00db10
+libc_hidden_def (__strcasestr)
00db10
 libc_hidden_builtin_def (strcasestr)
00db10
diff --git a/sysdeps/powerpc/powerpc64/power8/strncpy.S b/sysdeps/powerpc/powerpc64/power8/strncpy.S
00db10
index 80136cc..05c7d8a 100644
00db10
--- a/sysdeps/powerpc/powerpc64/power8/strncpy.S
00db10
+++ b/sysdeps/powerpc/powerpc64/power8/strncpy.S
00db10
@@ -24,6 +24,16 @@
00db10
 # define FUNC_NAME strncpy
00db10
 #endif
00db10
 
00db10
+#ifndef MEMSET
00db10
+/* For builds without IFUNC support, local calls should be made to internal
00db10
+   GLIBC symbol (created by libc_hidden_builtin_def).  */
00db10
+# ifdef SHARED
00db10
+#  define MEMSET   __GI_memset
00db10
+# else
00db10
+#  define MEMSET   memset
00db10
+# endif
00db10
+#endif
00db10
+
00db10
 #define FRAMESIZE (FRAME_MIN_SIZE+48)
00db10
 
00db10
 /* Implements the function
00db10
@@ -187,7 +197,7 @@ L(zero_pad_start_1):
00db10
 	stdu	r1,-FRAMESIZE(r1)
00db10
 	cfi_adjust_cfa_offset(FRAMESIZE)
00db10
 
00db10
-	bl	__memset_power8
00db10
+	bl	MEMSET
00db10
 	nop
00db10
 
00db10
 	/* Restore the stack frame.  */
00db10
@@ -406,8 +416,6 @@ L(zero_pad_start_prepare_1):
00db10
 	b	L(zero_pad_start_1)
00db10
 END (FUNC_NAME)
00db10
 
00db10
-#ifdef USE_AS_STPNCPY
00db10
-libc_hidden_def (__stpncpy)
00db10
-#else
00db10
+#ifndef USE_AS_STPNCPY
00db10
 libc_hidden_builtin_def (strncpy)
00db10
 #endif
00db10
-- 
00db10
2.1.0
00db10