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