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